:root {
  --paper:       #F4F7F0;
  --paper-2:     #EAF0E4;
  --glass:       rgba(250, 252, 247, 0.72);
  --glass-strong:rgba(250, 252, 247, 0.9);
  --ink:         #1C2B22;
  --ink-2:       #46574C;
  --ink-3:       #7E8C83;
  --bamboo:      #4E7A55;
  --bamboo-deep: #2F5537;
  --jade:        #A9C9A3;
  --jade-soft:   #DCE9D6;
  --seal:        #B23A2A;
  --line:        rgba(28, 43, 34, 0.10);
  --line-strong: rgba(28, 43, 34, 0.18);
  --shadow:      0 10px 30px -12px rgba(28, 43, 34, 0.22);
  --bg-hi:       #FFFFFF;
  --surface:     #FFFFFF;
  --wash:        rgba(255, 255, 255, 0.55);
  --wash-strong: rgba(255, 255, 255, 0.78);
  --on-accent:   #F4F7F0;
  --ring:        rgba(78, 122, 85, 0.15);

  --sans:  "Inter", -apple-system, system-ui, sans-serif;
  --serif: "Newsreader", "Iowan Old Style", Georgia, serif;
  --r:     14px;
  --r-lg:  22px;
  --ease:  cubic-bezier(0.22, 1, 0.36, 1);

  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --app-h:  100dvh;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --paper:       #0E1511;
  --paper-2:     #121C16;
  --glass:       rgba(20, 30, 24, 0.72);
  --glass-strong:rgba(22, 33, 26, 0.92);
  --ink:         #E2E9DC;
  --ink-2:       #B0BDB0;
  --ink-3:       #7F8D82;
  --bamboo:      #8DBB8F;
  --bamboo-deep: #A9D0A6;
  --jade:        #3E5C44;
  --jade-soft:   rgba(141, 187, 143, 0.15);
  --seal:        #E08A72;
  --line:        rgba(226, 233, 220, 0.10);
  --line-strong: rgba(226, 233, 220, 0.18);
  --shadow:      0 10px 30px -12px rgba(0, 0, 0, 0.65);
  --bg-hi:       #17221B;
  --surface:     #18231D;
  --wash:        rgba(255, 255, 255, 0.05);
  --wash-strong: rgba(255, 255, 255, 0.09);
  --on-accent:   #0E1511;
  --ring:        rgba(141, 187, 143, 0.22);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: radial-gradient(120% 90% at 20% 10%, var(--bg-hi) 0%, var(--paper) 45%, var(--paper-2) 100%);
  color: var(--ink);
  font: 400 16px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
button:focus-visible, a:focus-visible, textarea:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--bamboo); outline-offset: 2px;
}
[hidden] { display: none !important; }

.ic { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }

/* ── Background ───────────────────────────────────────── */
#mist {
  position: fixed; inset: 0; width: 100%; height: 100%;
  z-index: 0; opacity: 0; transition: opacity 1.6s ease;
}
#mist.ready { opacity: 1; }
.bamboo { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; color: var(--bamboo-deep); }
.bamboo svg { position: absolute; bottom: -2vh; height: 104vh; width: auto; }
.bamboo .left  { left: -40px; }
.bamboo .right { right: -40px; transform: scaleX(-1); }
.bamboo .stalk { transform-box: fill-box; transform-origin: 50% 100%; animation: sway var(--d, 11s) ease-in-out infinite alternate; }
@keyframes sway { from { transform: rotate(-0.6deg); } to { transform: rotate(0.8deg); } }

/* ── Shell ────────────────────────────────────────────── */
.shell {
  position: relative; z-index: 1;
  display: flex; height: var(--app-h);
}
.scrim {
  position: fixed; inset: 0; z-index: 30;
  background: rgba(28, 43, 34, 0.25); backdrop-filter: blur(2px);
  opacity: 0; pointer-events: none; transition: opacity 0.3s var(--ease);
}
.shell.menu-open .scrim { opacity: 1; pointer-events: auto; }

/* ── Rail ─────────────────────────────────────────────── */
.rail {
  position: fixed; z-index: 40; top: 0; bottom: 0; left: 0;
  width: min(84vw, 300px);
  padding: calc(18px + var(--safe-t)) 16px calc(16px + var(--safe-b));
  display: flex; flex-direction: column; gap: 18px;
  background: var(--glass-strong);
  backdrop-filter: blur(18px) saturate(1.2);
  border-right: 1px solid var(--line);
  transform: translateX(-104%);
  transition: transform 0.38s var(--ease);
}
.shell.menu-open .rail { transform: none; box-shadow: var(--shadow); }

.brand { display: flex; align-items: center; gap: 12px; padding: 2px 4px; }
.mark {
  width: 40px; height: 40px; flex-shrink: 0;
  color: var(--bamboo-deep);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-name { font: 500 19px var(--serif); letter-spacing: 0.3px; }
.brand-sub { font-size: 12px; color: var(--ink-3); font-style: italic; font-family: var(--serif); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: 999px;
  font-weight: 500; font-size: 15px;
  transition: background 0.2s, transform 0.2s var(--ease), box-shadow 0.2s;
}
.btn-block { width: 100%; }
.btn-primary { background: var(--bamboo-deep); color: var(--on-accent); box-shadow: 0 6px 16px -8px rgba(47,85,55,0.7); }
.btn-primary:hover { background: var(--bamboo); transform: translateY(-1px); }
.btn-primary:disabled { opacity: 0.55; transform: none; cursor: default; }
.btn-ghost { border: 1px solid var(--line-strong); background: var(--wash); }
.btn-ghost:hover { background: var(--surface); }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  min-height: 44px; padding: 0 12px; border-radius: 12px;
  color: var(--ink-2); font-size: 15px; text-align: left;
  transition: background 0.2s, color 0.2s;
}
.nav-item:hover { background: var(--wash-strong); color: var(--ink); }
.nav-item.active { background: var(--jade-soft); color: var(--bamboo-deep); font-weight: 500; }

.history { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 6px; }
.history-label { font-size: 11px; letter-spacing: 1.2px; text-transform: uppercase; color: var(--ink-3); padding: 0 12px; }
.history-list { overflow-y: auto; display: flex; flex-direction: column; gap: 1px; margin: 0 -4px; padding: 0 4px; }
.history-empty { font: italic 14px/1.5 var(--serif); color: var(--ink-3); padding: 6px 12px; }
.history-item {
  display: flex; align-items: center; gap: 6px;
  border-radius: 10px; transition: background 0.2s;
}
.history-item:hover, .history-item.active { background: var(--wash-strong); }
.history-item.active .history-open { color: var(--ink); }
.history-open {
  flex: 1; min-width: 0; min-height: 40px; padding: 0 12px; text-align: left;
  font-size: 14px; color: var(--ink-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.history-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--bamboo); flex-shrink: 0; }
.history-del { opacity: 0; color: var(--ink-3); width: 34px; height: 34px; display: grid; place-items: center; border-radius: 8px; }
.history-item:hover .history-del, .history-item.active .history-del { opacity: 1; }
.history-del:hover { color: var(--seal); }
.history-del .ic { width: 16px; height: 16px; }

.account { border-top: 1px solid var(--line); padding-top: 14px; display: flex; align-items: center; gap: 10px; }
.avatar .ic { width: 18px; height: 18px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center;
  background: var(--jade-soft); color: var(--bamboo-deep); font: 500 15px var(--serif);
}
.account-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.account-name { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account-sub { font-size: 12px; color: var(--ink-3); }
.link-btn { font-size: 13px; color: var(--bamboo-deep); font-weight: 500; padding: 8px 4px; }
.link-btn:hover { text-decoration: underline; }

/* ── Stage ────────────────────────────────────────────── */
.stage { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 8px;
  padding: calc(10px + var(--safe-t)) 12px 10px;
}
.topbar-title {
  flex: 1; min-width: 0; text-align: center;
  font: 500 17px var(--serif); color: var(--ink-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-actions { display: flex; gap: 4px; }
.support {
  display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0;
  height: 36px; padding: 0 14px 0 11px; margin-left: 2px; border-radius: 999px;
  font-size: 14px; font-weight: 500; text-decoration: none;
  color: var(--bamboo-deep); background: var(--jade-soft); border: 1px solid var(--jade);
  transition: background 0.2s, color 0.2s, transform 0.2s var(--ease);
}
.support .ic { width: 17px; height: 17px; }
.support:hover { background: var(--bamboo-deep); color: var(--on-accent); transform: translateY(-1px); }
@media (max-width: 600px) {
  .topbar { gap: 2px; padding-left: 6px; padding-right: 6px; }
  .topbar-actions { gap: 0; }
  .topbar .icon-btn { width: 40px; }
  .support { width: 40px; height: 40px; padding: 0; justify-content: center; margin-left: 0; }
  .support span { display: none; }
}
.icon-btn {
  width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center; color: var(--ink-2);
  transition: background 0.2s, color 0.2s;
}
.icon-btn:hover { background: var(--wash-strong); color: var(--ink); }
.icon-btn[aria-pressed="false"] { color: var(--ink-3); }
.icon-btn.listening { color: var(--seal); background: rgba(178,58,42,0.08); }

.dropdown-wrapper { position: relative; }
.dropdown-menu {
  position: absolute; top: 100%; right: -8px; z-index: 100;
  min-width: 140px; border-radius: 10px;
  background: var(--glass-strong); backdrop-filter: blur(18px);
  border: 1px solid var(--line); box-shadow: var(--shadow);
  list-style: none; margin: 4px 0 0;
  overflow: hidden;
}
.dropdown-item {
  display: block; width: 100%; text-align: left; padding: 10px 14px;
  font-size: 14px; color: var(--ink-2);
  transition: background 0.2s, color 0.2s;
  border: 0;
}
.dropdown-item:hover { background: var(--wash); color: var(--ink); }
.dropdown-item.active { background: var(--jade-soft); color: var(--bamboo-deep); font-weight: 500; }

.view { flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* ── Dialogue ─────────────────────────────────────────── */
.dialogue {
  flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  padding: 8px 20px 24px;
  scroll-behavior: smooth;
  mask-image: linear-gradient(to bottom, transparent 0, #000 18px, #000 calc(100% - 18px), transparent 100%);
}
.dialogue > * { max-width: 680px; margin-left: auto; margin-right: auto; }

.opening { text-align: center; padding: 6vh 0 12px; animation: rise 0.9s var(--ease) both; }
.enso { width: 92px; height: 92px; margin: 0 auto 14px; display: block; }
.enso path {
  fill: none; stroke: var(--bamboo-deep); stroke-linecap: round;
  filter: url(#ink);
  stroke-dasharray: 560; stroke-dashoffset: 560;
  animation: brush 2.2s var(--ease) 0.2s forwards;
}
.enso .enso-main { stroke-width: 8; opacity: 0.8; }
.enso .enso-load { stroke-width: 15; opacity: 0.9; animation-duration: 1.2s; }
@keyframes brush { to { stroke-dashoffset: 0; } }
.opening-title { font: 400 clamp(28px, 7vw, 44px)/1.15 var(--serif); letter-spacing: -0.5px; margin-bottom: 14px; }
.opening-title em { color: var(--bamboo-deep); }
.opening-sub { color: var(--ink-2); max-width: 30em; margin: 0 auto 28px; font-size: 15.5px; }

.openings { display: grid; gap: 10px; text-align: left; }
.opening-line {
  display: flex; flex-direction: column; gap: 3px;
  padding: 14px 18px; border-radius: var(--r);
  background: var(--glass); border: 1px solid var(--line);
  backdrop-filter: blur(10px);
  transition: transform 0.25s var(--ease), border-color 0.25s, background 0.25s;
}
.opening-line:hover { transform: translateY(-2px); border-color: var(--jade); background: var(--glass-strong); }
.ol-tag { font-size: 11px; letter-spacing: 1.2px; text-transform: uppercase; color: var(--bamboo); font-weight: 600; }
.ol-text { font: 400 17px/1.4 var(--serif); color: var(--ink); }

.turn { margin-top: 22px; animation: rise 0.5s var(--ease) both; }
.speaker { font-size: 11px; letter-spacing: 1.6px; text-transform: uppercase; font-weight: 600; margin-bottom: 6px; }
.turn.you { display: flex; flex-direction: column; align-items: flex-end; }
.turn.you .speaker { color: var(--ink-3); }
.turn.you .words {
  max-width: 88%;
  background: var(--glass-strong); border: 1px solid var(--line);
  border-radius: var(--r-lg) var(--r-lg) 6px var(--r-lg);
  padding: 12px 16px; font-size: 16px; color: var(--ink);
  white-space: pre-wrap; overflow-wrap: anywhere;
  box-shadow: 0 4px 14px -10px rgba(28,43,34,0.35);
}
.turn.aw .speaker { color: var(--seal); }
.turn.aw .words {
  font: 400 19px/1.62 var(--serif); color: var(--ink);
  border-left: 2px solid var(--jade); padding: 2px 0 2px 16px;
  overflow-wrap: anywhere;
}
.turn.aw .words p + p { margin-top: 0.75em; }
.turn.aw .words em { color: var(--bamboo-deep); }
.turn.aw .words strong { font-weight: 500; }
.turn.aw .words blockquote { border-left: 2px solid var(--line-strong); padding-left: 12px; color: var(--ink-2); font-style: italic; }
.turn.aw .words ul { padding-left: 1.2em; }
.turn.aw .words.error { color: var(--seal); font-style: italic; }

.turn-foot { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; margin: 8px 0 0 16px; }
.mini {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 34px; padding: 0 12px; border-radius: 999px;
  font-size: 13px; color: var(--ink-2);
  background: var(--wash); border: 1px solid var(--line);
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.mini .ic { width: 15px; height: 15px; }
.mini:hover { background: var(--surface); color: var(--ink); }
.mini.playing { color: var(--bamboo-deep); border-color: var(--jade); background: var(--jade-soft); }
.sources { font: italic 13.5px/1.4 var(--serif); color: var(--ink-3); width: 100%; }
.mini.icon-only { padding: 0; width: 34px; justify-content: center; }

/* Read-along: the sentence being spoken gets a soft jade wash, the word a
   bamboo underline. Literal colors — highlight pseudos don't reliably see
   custom properties. */
::highlight(aw-sentence) { background-color: rgba(169, 201, 163, 0.42); color: #1C2B22; }
::highlight(aw-word) { background-color: rgba(78, 122, 85, 0.26); color: #14241A; text-decoration: underline 2px rgba(47, 85, 55, 0.85); text-underline-offset: 4px; }
:root[data-theme="dark"] ::highlight(aw-sentence) { background-color: rgba(141, 187, 143, 0.23); color: #F1F6EC; }
:root[data-theme="dark"] ::highlight(aw-word) { background-color: rgba(141, 187, 143, 0.32); color: #FFFFFF; text-decoration: underline 2px rgba(169, 208, 166, 0.9); text-underline-offset: 4px; }
.reading-block { background: var(--jade-soft); border-radius: 6px; box-shadow: 0 0 0 6px var(--jade-soft); transition: background 0.3s; }

.thinking { display: flex; align-items: center; gap: 10px; color: var(--ink-3); font: italic 16px var(--serif); padding-left: 16px; }
.thinking svg { width: 26px; height: 26px; }
.thinking path {
  fill: none; stroke: var(--bamboo); stroke-width: 14; stroke-linecap: round; filter: url(#ink);
  stroke-dasharray: 520; animation: think 1.8s ease-in-out infinite;
}
@keyframes think { 0% { stroke-dashoffset: 520; } 60% { stroke-dashoffset: 0; } 100% { stroke-dashoffset: -520; } }

/* ── Moves + composer ─────────────────────────────────── */
.moves {
  display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none;
  padding: 2px 20px 10px;
  max-width: 720px; width: 100%; margin: 0 auto;
  animation: rise 0.4s var(--ease) both;
}
.moves::-webkit-scrollbar { display: none; }
.move {
  flex-shrink: 0; min-height: 38px; padding: 0 15px; border-radius: 999px;
  font-size: 14px; color: var(--bamboo-deep);
  background: var(--glass); border: 1px solid var(--jade);
  backdrop-filter: blur(8px);
  transition: background 0.2s, transform 0.2s var(--ease);
}
.move:hover { background: var(--jade-soft); transform: translateY(-1px); }

.composer {
  display: flex; align-items: flex-end; gap: 4px;
  width: calc(100% - 24px); max-width: 720px;
  margin: 0 auto calc(12px + var(--safe-b));
  padding: 6px 6px 6px 18px;
  background: var(--glass-strong); border: 1px solid var(--line-strong);
  border-radius: 26px;
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.composer:focus-within { border-color: var(--bamboo); box-shadow: 0 0 0 4px var(--ring), var(--shadow); }
.composer textarea {
  flex: 1; min-width: 0; resize: none; border: 0; outline: 0; background: transparent;
  font: 400 16px/1.5 var(--sans); color: var(--ink);
  padding: 10px 0; max-height: 160px;
  overflow-y: hidden; scrollbar-width: thin;
}
.composer textarea::placeholder { color: var(--ink-3); font-style: italic; font-family: var(--serif); font-size: 17px; }
.composer textarea:focus-visible { outline: none; }
.send {
  width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center;
  background: var(--bamboo-deep); color: var(--on-accent);
  transition: background 0.2s, transform 0.2s var(--ease), opacity 0.2s;
}
.send:hover { background: var(--bamboo); }
.send:disabled { opacity: 0.4; cursor: default; }
.send.stop { background: var(--seal); }

/* ── Agora ────────────────────────────────────────────── */
.agora, .reader { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 20px calc(24px + var(--safe-b)); }
.agora > *, .reader > * { max-width: 720px; margin-left: auto; margin-right: auto; }
.agora-head { padding: 8px 0 16px; }
.agora-title { font: 400 34px/1.15 var(--serif); margin-bottom: 6px; }
.agora-sub { color: var(--ink-2); font-size: 15px; margin-bottom: 16px; }
.filters { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 -20px; padding: 0 20px; }
.filters::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0; min-height: 36px; padding: 0 14px; border-radius: 999px;
  font-size: 14px; color: var(--ink-2); background: var(--glass); border: 1px solid var(--line);
}
.chip.active { background: var(--bamboo-deep); border-color: var(--bamboo-deep); color: var(--on-accent); }
.agora-list { display: grid; gap: 12px; }
.agora-note { font: italic 14.5px/1.5 var(--serif); color: var(--ink-3); padding: 4px 2px 6px; }
.entry {
  display: block; width: 100%; text-align: left;
  padding: 18px 18px 14px; border-radius: var(--r-lg);
  background: var(--glass); border: 1px solid var(--line); backdrop-filter: blur(10px);
  transition: transform 0.25s var(--ease), border-color 0.25s, background 0.25s;
}
.entry:not(.sample):hover { transform: translateY(-2px); border-color: var(--jade); background: var(--glass-strong); }
.entry-meta { display: flex; gap: 8px; font-size: 12px; color: var(--ink-3); margin-bottom: 6px; letter-spacing: 0.3px; }
.entry-cat { color: var(--bamboo); font-weight: 600; text-transform: uppercase; letter-spacing: 1px; font-size: 11px; }
.entry-title { font: 500 20px/1.3 var(--serif); margin-bottom: 6px; }
.entry-preview { font: 400 15.5px/1.5 var(--serif); color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.entry-foot { display: flex; align-items: center; gap: 14px; margin-top: 10px; font-size: 13px; color: var(--ink-3); }
.entry-foot .ic { width: 15px; height: 15px; }
.entry-foot span { display: inline-flex; align-items: center; gap: 4px; }

.reader-head { padding: 4px 0 6px; }
.reader-back { margin-left: -8px; }
.reader-title { font: 400 30px/1.2 var(--serif); margin: 8px 0 4px; }
.reader-meta { font-size: 13px; color: var(--ink-3); }
.reader-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 6px; }
.vote.active { color: var(--bamboo-deep); border-color: var(--jade); background: var(--jade-soft); }

/* ── Sheets (dialogs) ─────────────────────────────────── */
.sheet {
  margin: auto auto 0; width: 100%; max-width: 100%;
  max-height: calc(100dvh - 40px);
  border: 0; border-radius: 26px 26px 0 0;
  padding: 26px 22px calc(22px + var(--safe-b));
  background: var(--paper); color: var(--ink);
  box-shadow: 0 -20px 60px -20px rgba(28,43,34,0.35);
}
.sheet[open] { animation: sheet-up 0.38s var(--ease); }
.sheet::backdrop { background: rgba(28,43,34,0.3); backdrop-filter: blur(3px); }
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } }
.sheet-close { position: absolute; top: 10px; right: 10px; }
.sheet-title { font: 400 26px/1.2 var(--serif); padding-right: 40px; margin-bottom: 6px; }
.sheet-sub { color: var(--ink-2); font-size: 14.5px; margin-bottom: 18px; }

.tabs { display: flex; padding: 4px; border-radius: 999px; background: var(--paper-2); margin-bottom: 16px; }
.tab { flex: 1; min-height: 38px; border-radius: 999px; font-size: 14px; color: var(--ink-2); }
.tab.active { background: var(--surface); color: var(--ink); font-weight: 500; box-shadow: 0 2px 8px -4px rgba(28,43,34,0.3); }

.form { display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--ink-2); font-weight: 500; }
.field input, .field select {
  font: 400 16px var(--sans); color: var(--ink);
  min-height: 46px; padding: 0 14px; border-radius: 12px;
  border: 1px solid var(--line-strong); background: var(--surface);
}
.field input:focus, .field select:focus { border-color: var(--bamboo); outline: none; box-shadow: 0 0 0 3px var(--ring); }
.form-note { font-size: 14px; padding: 10px 14px; border-radius: 12px; background: var(--jade-soft); color: var(--bamboo-deep); }
.form-note.bad { background: rgba(178,58,42,0.08); color: var(--seal); }

.share-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 18px; }
.share-opt {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 14px 4px; border-radius: 16px; font-size: 13px; color: var(--ink-2);
  background: var(--surface); border: 1px solid var(--line);
  transition: border-color 0.2s, transform 0.2s var(--ease);
}
.share-opt:hover { border-color: var(--jade); transform: translateY(-1px); }
.share-opt .ic { width: 22px; height: 22px; color: var(--bamboo-deep); }
.publish { border-top: 1px solid var(--line); padding-top: 16px; }
.publish h4 { font: 500 18px var(--serif); margin-bottom: 4px; }
.publish p { font-size: 14px; color: var(--ink-2); margin-bottom: 12px; }
.public-link { display: flex; gap: 8px; align-items: center; }
.public-link input { flex: 1; min-width: 0; font: 400 14px var(--sans); min-height: 44px; padding: 0 12px; border-radius: 12px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink-2); }

/* ── Membership card (landing) ────────────────────────── */
.join {
  margin: 0 0 22px; padding: 20px 20px 18px; text-align: left;
  border-radius: var(--r-lg); background: var(--glass); border: 1px solid var(--jade);
  backdrop-filter: blur(10px);
}
.join-title { font: 400 24px/1.3 var(--serif); margin-bottom: 10px; display: flex; flex-wrap: wrap; align-items: center; column-gap: 8px; row-gap: 4px; }
.join-dash { color: var(--ink-3); }
.join-names { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 8px; font: 500 18px/1.3 var(--sans); color: var(--ink-2); }
.pali-title { display: inline-flex; align-items: center; gap: 7px; color: var(--bamboo-deep); white-space: nowrap; }
.pali-title .ic { width: 30px; height: 30px; stroke-width: 1.5; }
.join-or { font: italic 400 17px var(--serif); color: var(--ink-3); }
.paren { color: var(--ink-3); font-weight: 400; }
@media (max-width: 600px) {
  .join-names { font-size: 16px; gap: 6px; }
  .pali-title { gap: 5px; }
  .pali-title .ic { width: 24px; height: 24px; }
  .join-or { font-size: 15px; }
}
.join-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.join-soon { font: italic 15px/1.5 var(--serif); color: var(--bamboo-deep); padding: 10px 14px; border-radius: 12px; background: var(--jade-soft); }
.join-sub { font-size: 15px; color: var(--ink-2); margin-bottom: 12px; }
.join-sub strong { color: var(--ink); font-weight: 600; }
.join-list { list-style: none; display: grid; gap: 8px; margin-bottom: 18px; }
.join-list li { position: relative; padding-left: 20px; font-size: 15px; color: var(--ink-2); line-height: 1.45; }
.join-list li::before { content: ""; position: absolute; left: 3px; top: 0.6em; width: 7px; height: 7px; border-radius: 50%; border: 1.5px solid var(--bamboo); }
.join-list strong { color: var(--ink); font-weight: 600; }

/* ── Sign-up splash (guest limit reached) ─────────────── */
.splash {
  position: fixed; inset: 0; width: 100%; height: 100%; max-width: none; max-height: none;
  margin: 0; padding: 0; border: 0; color: var(--ink);
  background: var(--glass-strong); backdrop-filter: blur(16px) saturate(1.15);
  overflow-y: auto; overscroll-behavior: contain;
}
.splash[open] { animation: splash-in 0.55s var(--ease); }
.splash::backdrop { background: rgba(28, 43, 34, 0.18); }
@keyframes splash-in { from { opacity: 0; } }
.splash-inner {
  min-height: 100%; max-width: 560px; margin: 0 auto;
  padding: calc(32px + var(--safe-t)) 22px calc(28px + var(--safe-b));
  display: flex; flex-direction: column; justify-content: center; text-align: center;
  animation: rise 0.7s var(--ease) 0.1s both;
}
.splash-mark { width: 76px; height: 76px; margin: 0 auto 14px; color: var(--bamboo-deep); }
.splash-kicker { font-size: 12px; letter-spacing: 1.4px; text-transform: uppercase; font-weight: 600; color: var(--bamboo); margin-bottom: 6px; }
.splash-title { font: 400 clamp(30px, 7vw, 40px)/1.15 var(--serif); margin-bottom: 18px; }
.splash-card { text-align: left; padding: 18px 18px 6px; border-radius: var(--r-lg); background: var(--glass); border: 1px solid var(--jade); margin-bottom: 20px; }
.splash-card .join-title { margin-bottom: 12px; }
.splash .join-list { grid-template-columns: 1fr; margin-bottom: 12px; }
@media (max-width: 600px) {
  .splash-inner { justify-content: flex-start; padding-top: calc(22px + var(--safe-t)); padding-bottom: 0; }
  .splash-mark { width: 56px; height: 56px; margin-bottom: 8px; }
  .splash-title { margin-bottom: 14px; }
  .splash-card { padding: 14px 14px 4px; margin-bottom: 12px; }
  .splash .join-list { gap: 6px; }
  .splash .join-list li { font-size: 14.5px; }
  .splash-actions {
    position: sticky; bottom: 0; margin: 0 -22px; padding: 12px 22px calc(10px + var(--safe-b));
    background: var(--glass-strong); backdrop-filter: blur(12px);
    border-top: 1px solid var(--line);
  }
  .splash-note { margin-top: 0; padding: 0 0 4px; }
  .splash-later { margin-bottom: calc(14px + var(--safe-b)); }
}
.splash-actions { display: grid; gap: 10px; }
.splash-actions .btn { min-height: 50px; font-size: 16px; }
.splash-note { font: italic 14.5px/1.5 var(--serif); color: var(--ink-3); margin-top: 12px; }
.splash-later { margin: 6px auto 0; color: var(--ink-3); font-weight: 500; }

/* ── Sign-up titles ───────────────────────────────────── */
.titles { border: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.titles legend { font-size: 13px; color: var(--ink-2); font-weight: 500; margin-bottom: 6px; }
.title-opt {
  position: relative; display: grid; justify-items: center; gap: 2px; text-align: center;
  padding: 12px 8px 10px; border-radius: 14px; cursor: pointer;
  border: 1px solid var(--line-strong); background: var(--surface);
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}
.title-opt input { position: absolute; opacity: 0; pointer-events: none; }
.title-opt .ic { width: 26px; height: 26px; color: var(--bamboo); margin-bottom: 4px; }
.title-name { font: 500 16px var(--sans); color: var(--ink); }
.title-gloss { font-size: 12px; color: var(--ink-3); }
.title-opt:has(input:checked) { border-color: var(--bamboo); background: var(--jade-soft); box-shadow: 0 0 0 3px var(--ring); }
.title-opt:has(input:focus-visible) { outline: 2px solid var(--bamboo); outline-offset: 2px; }
.field-hint { font-size: 12.5px; font-weight: 400; color: var(--ink-3); }

.avatar.glyph .ic { width: 19px; height: 19px; }
.badge {
  margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px;
  display: inline-grid; place-items: center; font-size: 12px; font-weight: 600;
  background: var(--bamboo-deep); color: var(--on-accent);
}

/* ── Voice menu extras ────────────────────────────────── */
.dropdown-label { font-size: 11px; letter-spacing: 1.2px; text-transform: uppercase; color: var(--ink-3); padding: 10px 14px 4px; }
.dropdown-status { font-size: 12.5px; line-height: 1.4; color: var(--ink-3); padding: 8px 14px 10px; border-top: 1px solid var(--line); }
.dropdown-status:empty { display: none; }
.dropdown-status b { color: var(--ink-2); font-weight: 600; }

/* ── Agora discussion ─────────────────────────────────── */
.discussion { margin-top: 34px; padding-top: 18px; border-top: 1px solid var(--line); }
.discussion h3 { font: 400 22px var(--serif); margin-bottom: 12px; }
.comments { display: grid; gap: 10px; margin-bottom: 14px; }
.comment { padding: 12px 14px; border-radius: var(--r); background: var(--glass); border: 1px solid var(--line); }
.comment-head { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--ink-3); margin-bottom: 4px; }
.comment-author { font-weight: 600; color: var(--ink-2); }
.comment-head .link-btn { padding: 2px 4px; font-size: 12.5px; }
.comment-head .link-btn:first-of-type { margin-left: auto; }
.comment-body { font-size: 15px; white-space: pre-wrap; overflow-wrap: anywhere; }
.reply-box { display: grid; gap: 8px; }
.reply-box textarea, .dm-compose textarea {
  width: 100%; resize: vertical; min-height: 72px; max-height: 240px;
  font: 400 15.5px/1.5 var(--sans); color: var(--ink);
  padding: 10px 14px; border-radius: 14px; border: 1px solid var(--line-strong); background: var(--surface);
}
.reply-box textarea:focus, .dm-compose textarea:focus { outline: none; border-color: var(--bamboo); box-shadow: 0 0 0 3px var(--ring); }
.reply-box .btn { justify-self: end; }

/* ── Messages ─────────────────────────────────────────── */
.inbox { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 20px calc(24px + var(--safe-b)); }
.inbox > * { max-width: 720px; margin-left: auto; margin-right: auto; }
.thread-row {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 14px 16px; border-radius: var(--r); margin-bottom: 8px;
  background: var(--glass); border: 1px solid var(--line);
  transition: border-color 0.2s, background 0.2s;
}
.thread-row:hover { border-color: var(--jade); background: var(--glass-strong); }
.thread-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.thread-name { font-weight: 600; font-size: 15px; }
.thread-last { font-size: 14px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread-row.unread .thread-last { color: var(--ink); }
.dm-list { display: flex; flex-direction: column; gap: 8px; padding: 12px 0 16px; }
.dm { max-width: 82%; padding: 10px 14px; border-radius: 18px; font-size: 15px; white-space: pre-wrap; overflow-wrap: anywhere; background: var(--glass-strong); border: 1px solid var(--line); }
.dm.mine { align-self: flex-end; background: var(--jade-soft); border-color: var(--jade); }
.dm-about { display: block; font-size: 12px; color: var(--bamboo); margin-bottom: 4px; }
.dm-time { display: block; font-size: 11px; color: var(--ink-3); margin-top: 4px; }
.dm-compose { display: grid; gap: 8px; }
.dm-compose .btn { justify-self: end; }

#dmTitle { font: 500 24px/1.25 var(--sans); }

/* ── Admin ────────────────────────────────────────────── */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-bottom: 22px; }
.stat { padding: 14px 16px; border-radius: var(--r); background: var(--glass); border: 1px solid var(--line); }
.stat-n { font: 400 28px/1.1 var(--serif); color: var(--ink); }
.stat-l { font-size: 12.5px; color: var(--ink-3); margin-top: 4px; }
.admin-h { font: 400 20px var(--serif); margin: 6px 0 10px; }
.services { display: grid; gap: 6px; margin-bottom: 18px; }
.service { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 12px; background: var(--glass); border: 1px solid var(--line); font-size: 14.5px; }
.service b { margin-left: auto; font-weight: 600; font-size: 13px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--seal); flex-shrink: 0; }
.dot.ok { background: var(--bamboo); }
.voice-tests { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
.voice-result { font-size: 13.5px; color: var(--ink-2); }
.admin-search { width: 100%; min-height: 44px; padding: 0 14px; margin-bottom: 12px; border-radius: 12px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font: 400 15px var(--sans); }
.admin-search:focus { outline: none; border-color: var(--bamboo); box-shadow: 0 0 0 3px var(--ring); }
.member { padding: 14px 16px; border-radius: var(--r); background: var(--glass); border: 1px solid var(--line); margin-bottom: 10px; }
.member-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.member-name { font-weight: 600; font-size: 15px; }
.member-email { font-size: 13.5px; color: var(--ink-2); overflow-wrap: anywhere; }
.tag { font-size: 11px; font-weight: 600; letter-spacing: 0.6px; text-transform: uppercase; padding: 2px 8px; border-radius: 999px; background: var(--jade-soft); color: var(--bamboo-deep); }
.tag.warn { background: rgba(178,58,42,0.10); color: var(--seal); }
.member-stats { font-size: 13px; color: var(--ink-3); margin: 6px 0 10px; line-height: 1.5; }
.member-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.mini.danger { color: var(--seal); }
.mod-row { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: 12px; background: var(--glass); border: 1px solid var(--line); margin-bottom: 8px; }
.mod-text { flex: 1; min-width: 0; font-size: 14px; }
.mod-text small { display: block; color: var(--ink-3); font-size: 12.5px; margin-top: 2px; }
.mod-text q { overflow-wrap: anywhere; }

/* ── Toasts ───────────────────────────────────────────── */
.toasts {
  position: fixed; z-index: 100; left: 50%; transform: translateX(-50%);
  top: calc(12px + var(--safe-t)); width: min(92vw, 420px);
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.toast {
  pointer-events: auto;
  background: var(--ink); color: var(--paper);
  padding: 12px 16px; border-radius: 14px; font-size: 14.5px;
  box-shadow: var(--shadow);
  animation: toast-in 0.35s var(--ease);
  display: flex; align-items: center; gap: 12px;
}
.toast button { color: var(--jade); font-weight: 600; font-size: 14px; margin-left: auto; white-space: nowrap; }
.toast.out { opacity: 0; transform: translateY(-6px); transition: all 0.3s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-10px); } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

/* ── Larger screens ───────────────────────────────────── */
@media (min-width: 900px) {
  .join-list { grid-template-columns: 1fr 1fr; column-gap: 22px; }
  .only-mobile { display: none; }
  .scrim { display: none; }
  .rail {
    position: relative; transform: none; width: 280px; flex-shrink: 0;
    background: var(--glass); box-shadow: none;
  }
  .topbar { padding: 16px 24px 8px; }
  .topbar-title { text-align: left; font-size: 18px; }
  .dialogue { padding: 12px 40px 32px; }
  .opening { padding-top: 10vh; }
  .openings { grid-template-columns: 1fr 1fr; }
  .turn.aw .words { font-size: 20px; }
  .sheet {
    margin: auto; width: min(460px, calc(100vw - 32px)); border-radius: 26px;
    padding-bottom: 26px;
  }
  .sheet[open] { animation-name: sheet-pop; }
  @keyframes sheet-pop { from { transform: scale(0.97); opacity: 0; } }
  .agora, .reader { padding: 8px 40px 40px; }
}

@media (max-width: 899px) {
  .bamboo { display: none; }
  .opening { padding: 2vh 0 8px; }
  .enso { width: 68px; height: 68px; margin-bottom: 8px; }
  .opening-sub { margin-bottom: 18px; font-size: 15px; }
  .opening-line { padding: 11px 16px; }
  .ol-text { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  .enso path { stroke-dashoffset: 0; }
}
