:root {
  --ink: #1C2128;
  --muted: #5B6470;
  --line: #E6E3DC;
  --line-strong: #CFCAC0;
  --surface: #F4F2EE;
  --bg: #FFFFFF;
  --teal: #1F6F6B;
  --teal-dark: #154F4C;
  --teal-soft: #E3F0EF;
  --gold: #F2B33D;
  --gold-soft: #FFF6E3;
  --gold-ink: #7A5410;
  --danger: #C2412D;
  --radius: 16px;
  --display: 'Bricolage Grotesque', system-ui, sans-serif;
  --body: Inter, system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--surface);
  color: var(--ink);
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--teal); }
a:hover { color: var(--teal-dark); }
button, input, textarea, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Shell: a phone-width column, centred on larger screens */
#app {
  max-width: 520px;
  min-height: 100%;
  margin: 0 auto;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 0 1px var(--line);
}
.screen { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(env(safe-area-inset-top) + 18px) 20px 10px;
}
.top-title { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
h1, h2, h3 { font-family: var(--display); margin: 0; line-height: 1.15; }
h1 { font-size: 28px; font-weight: 700; }
h2 { font-size: 20px; font-weight: 700; }
h3 { font-size: 18px; font-weight: 700; }
.content { flex: 1; padding: 6px 20px 24px; display: flex; flex-direction: column; gap: 16px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; gap: 10px; align-items: center; }
.row > .grow { flex: 1; min-width: 0; }
.spacer { flex: 1; }

/* Bottom tab bar */
.tabs {
  position: sticky; bottom: 0;
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
  border-top: 1px solid var(--line); background: var(--bg);
  padding: 6px 4px calc(env(safe-area-inset-bottom) + 10px);
}
.tabs a {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 8px 0; min-height: 44px;
  color: var(--muted); text-decoration: none; font-size: 11px; font-weight: 500;
}
.tabs a[aria-current="page"] { color: var(--teal); font-weight: 600; }
.icon { width: 22px; height: 22px; flex-shrink: 0; }

/* Cards */
.card { border: 1px solid var(--line); border-radius: 20px; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.card.soft { background: var(--surface); border-color: transparent; }
.card.gold { background: var(--gold-soft); border-color: transparent; }
.card.teal { background: var(--teal); border-color: transparent; color: #fff; }
.card.teal .eyebrow { color: #CDE5E3; }
.pill { display: inline-flex; align-items: center; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--teal-soft); color: var(--teal-dark); white-space: nowrap; }
.pill.gold { background: var(--gold-soft); color: var(--gold-ink); }

/* Book "cover" blocks (solid colour + title; no cover images) */
.cover {
  width: 92px; height: 136px; flex-shrink: 0; border-radius: 6px;
  display: flex; align-items: flex-end; padding: 10px;
  font-family: var(--display); color: #fff; font-size: 13px; font-weight: 700; line-height: 1.15;
  overflow: hidden;
}
.cover.sm { width: 70px; height: 104px; font-size: 11px; padding: 8px; }

/* Progress bar */
.bar { height: 8px; border-radius: 4px; background: #E2DED6; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--gold); border-radius: 4px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 18px; border-radius: 14px;
  border: 1px solid var(--line-strong); background: var(--bg); color: var(--ink);
  font-weight: 600; font-size: 15px; text-decoration: none; cursor: pointer;
}
.btn:hover { border-color: var(--muted); color: var(--ink); }
.btn.primary { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn.primary:hover { background: var(--teal-dark); color: #fff; }
.btn.gold { background: var(--gold); border-color: var(--gold); color: var(--ink); }
.btn.dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.danger { color: var(--danger); }
.btn.block { width: 100%; }
.btn.small { min-height: 40px; padding: 0 14px; font-size: 14px; border-radius: 12px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn.dashed { border-style: dashed; border-color: #A8A296; }
.btn.on { background: var(--teal); border-color: var(--teal); color: #fff; }
.icon-btn { width: 44px; height: 44px; border-radius: 22px; border: none; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; background: transparent; color: var(--ink); text-decoration: none; }
.avatar-btn { width: 44px; height: 44px; border-radius: 22px; border: none; background: var(--teal); color: #fff; font-weight: 600; font-size: 16px; display: inline-flex; align-items: center; justify-content: center; text-decoration: none; flex-shrink: 0; }
.avatar-btn:hover { color: #fff; background: var(--teal-dark); }
.seg { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }

/* Forms */
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 600; }
input[type=text], input[type=email], input[type=datetime-local], input[type=date], textarea, select {
  width: 100%; min-height: 46px; padding: 10px 14px; border-radius: 12px;
  border: 1px solid var(--line-strong); background: var(--bg); font-size: 16px; font-weight: 400;
}
textarea { resize: vertical; line-height: 1.45; }
input[type=color] { width: 56px; height: 46px; border: 1px solid var(--line-strong); border-radius: 12px; padding: 4px; background: var(--bg); }

/* Lists */
.list { border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.list > * { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); font-size: 14px; }
.list > *:last-child { border-bottom: none; }
.list > .now { background: var(--gold-soft); font-weight: 600; }
.list > .done { color: var(--muted); }

/* Chips (section tabs) */
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; }
.chip { flex-shrink: 0; min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--bg); font-size: 13px; font-weight: 500; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.chip[aria-selected="true"] { background: var(--ink); border-color: var(--ink); color: #fff; font-weight: 600; }
.chip.locked { border-style: dashed; background: var(--surface); color: var(--muted); }

/* Posts */
.post { display: flex; gap: 12px; }
.avatar { width: 36px; height: 36px; border-radius: 18px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 14px; }
.post p { margin: 2px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.composer { position: sticky; bottom: 0; display: flex; gap: 8px; padding: 10px 16px calc(env(safe-area-inset-bottom) + 10px); border-top: 1px solid var(--line); background: var(--bg); }
.composer textarea { min-height: 46px; max-height: 140px; }

/* Vote */
.vote { text-align: left; border-radius: 16px; padding: 14px 16px; border: 1px solid var(--line); background: var(--bg); display: flex; flex-direction: column; gap: 10px; cursor: pointer; width: 100%; }
.vote[aria-pressed="true"] { border: 2px solid var(--teal); background: var(--teal-soft); }

/* Stars */
.stars { display: flex; gap: 4px; }
.stars button { width: 44px; height: 44px; border: none; background: none; font-size: 26px; color: #C9C3B8; cursor: pointer; }
.stars button[aria-pressed="true"] { color: var(--gold); }

/* Notices */
.notice { padding: 12px 14px; border-radius: 12px; background: var(--surface); font-size: 14px; color: var(--muted); }
.notice.error { background: #FCE9E6; color: #8A2A1C; }
.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 90px); transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px;
  max-width: calc(100% - 32px); z-index: 50; box-shadow: 0 6px 20px rgba(0,0,0,.2);
}
.empty { padding: 28px 12px; text-align: center; color: var(--muted); }
.loading { padding: 40px; text-align: center; color: var(--muted); }

/* Pre-join */
.preview { position: relative; height: 300px; border-radius: 22px; background: var(--ink); overflow: hidden; display: flex; align-items: center; justify-content: center; }
.preview video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.preview .tag { position: absolute; left: 12px; bottom: 12px; padding: 6px 10px; border-radius: 999px; background: rgba(0,0,0,.55); color: #fff; font-size: 13px; font-weight: 500; }
.big-initial { width: 84px; height: 84px; border-radius: 42px; background: var(--teal); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 32px; font-weight: 600; }

/* Meeting room */
body.in-room { background: #12161B; }
body.in-room #app { max-width: none; box-shadow: none; background: #12161B; }
.room { flex: 1; display: flex; flex-direction: column; height: 100dvh; background: #12161B; color: #F3F4F6; }
.room-head { margin: calc(env(safe-area-inset-top) + 10px) 12px 8px; padding: 10px 14px; border-radius: 16px; background: #1F2730; display: flex; gap: 12px; align-items: flex-start; }
.room-head .eyebrow { color: #A9B2BC; }
.room-head p { margin: 4px 0 0; font-family: var(--display); font-size: 16px; font-weight: 500; line-height: 1.3; }
.room-head button { flex-shrink: 0; background: #2A333D; color: #F3F4F6; }
.host-cue { margin-top: 8px; font-size: 13px; color: #C9D0D7; }
.host-cue summary { cursor: pointer; color: #F2B33D; font-weight: 600; min-height: 32px; display: flex; align-items: center; }
.host-cue p { margin: 6px 0 0; font-family: var(--body); font-size: 13px; font-weight: 400; line-height: 1.45; }
.room-stage { flex: 1; min-height: 0; position: relative; }
.room-stage rtk-meeting { position: absolute; inset: 0; display: block; }
.room .notice { margin: 16px; }

@media (min-width: 560px) {
  body:not(.in-room) { padding: 24px 0; }
  #app { min-height: calc(100% - 48px); border-radius: 24px; overflow: clip; }
}
