/* ═══ Things We Said — styles ═══════════════════════════════════════════════ */
:root {
  --bg: #faf6f0;
  --surface: #ffffff;
  --surface-2: #f3ede4;
  --text: #2b2620;
  --text-soft: #6b6459;
  --text-faint: #9a9186;
  --border: #e7ddd0;
  --accent: #e4572e;
  --accent-soft: #fbe6de;
  --accent-ink: #b83c17;
  --good: #2f9e6f;
  --danger: #d1435b;
  --on-accent: #fff;
  --on-good: #fff;
  --on-danger: #fff;
  --shadow: 0 1px 2px rgba(43,38,32,.04), 0 6px 20px rgba(43,38,32,.06);
  --shadow-lg: 0 10px 40px rgba(43,38,32,.16);
  --radius: 16px;
  --radius-sm: 10px;
  --maxw: 620px;
  --nav-w: 220px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16130f;
    --surface: #201c17;
    --surface-2: #2a251f;
    --text: #f0e9df;
    --text-soft: #b3a998;
    --text-faint: #857b6d;
    --border: #342e26;
    --accent: #ff7043;
    --accent-soft: #3a241b;
    --accent-ink: #ffb59c;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.35);
    --shadow-lg: 0 10px 40px rgba(0,0,0,.55);
  }
}

/* ── theme: Classic (default warm cream/orange) ─────────────────────────── */
:root[data-theme="classic-dark"] {
  --bg:#16130f;--surface:#201c17;--surface-2:#2a251f;--text:#f0e9df;--text-soft:#b3a998;
  --text-faint:#857b6d;--border:#342e26;--accent:#ff7043;--accent-soft:#3a241b;--accent-ink:#ffb59c;
  --good:#2f9e6f;--danger:#d1435b;
  --shadow:0 1px 2px rgba(0,0,0,.3),0 6px 20px rgba(0,0,0,.35);--shadow-lg:0 10px 40px rgba(0,0,0,.55);
}
:root[data-theme="classic-light"] {
  --bg:#faf6f0;--surface:#fff;--surface-2:#f3ede4;--text:#2b2620;--text-soft:#6b6459;
  --text-faint:#9a9186;--border:#e7ddd0;--accent:#e4572e;--accent-soft:#fbe6de;--accent-ink:#b83c17;
  --good:#2f9e6f;--danger:#d1435b;
}

/* ── theme: Apple (SF-style clean whites/blacks, iOS blue) ──────────────── */
:root[data-theme="apple-light"] {
  --bg:#f2f2f7;--surface:#fff;--surface-2:#e5e5ea;--text:#1c1c1e;--text-soft:#636366;
  --text-faint:#aeaeb2;--border:#d1d1d6;--accent:#007aff;--accent-soft:#e5f1ff;--accent-ink:#0060df;
  --good:#34c759;--danger:#ff3b30;--radius:14px;--radius-sm:10px;
  --shadow:0 1px 2px rgba(0,0,0,.04),0 4px 16px rgba(0,0,0,.06);--shadow-lg:0 10px 40px rgba(0,0,0,.18);
  --serif: ui-serif, "New York", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
}
:root[data-theme="apple-dark"] {
  --bg:#000;--surface:#1c1c1e;--surface-2:#2c2c2e;--text:#f2f2f7;--text-soft:#a1a1a6;
  --text-faint:#6e6e73;--border:#38383a;--accent:#0a84ff;--accent-soft:#142a3d;--accent-ink:#6bb7ff;
  --good:#30d158;--danger:#ff453a;--radius:14px;--radius-sm:10px;
  --shadow:0 1px 2px rgba(0,0,0,.4),0 6px 20px rgba(0,0,0,.4);--shadow-lg:0 10px 40px rgba(0,0,0,.6);
  --serif: ui-serif, "New York", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
}

/* ── theme: Cool (icy blues/cyans, glowing dark mode) ────────────────────── */
:root[data-theme="cool-light"] {
  --bg:#eef4fb;--surface:#fff;--surface-2:#e1ecf7;--text:#0f2436;--text-soft:#4d6a80;
  --text-faint:#8fa9bb;--border:#cddce9;--accent:#0891b2;--accent-soft:#d3f3f9;--accent-ink:#0e6c82;
  --good:#059669;--danger:#dc2626;
  --shadow:0 1px 2px rgba(15,60,90,.05),0 6px 20px rgba(15,60,90,.08);--shadow-lg:0 10px 40px rgba(15,60,90,.2);
}
:root[data-theme="cool-dark"] {
  --bg:#060c18;--surface:#0d1b2f;--surface-2:#14243c;--text:#e3edf7;--text-soft:#93aec7;
  --text-faint:#5d7893;--border:#1f3350;--accent:#22d3ee;--accent-soft:#113247;--accent-ink:#67e8f9;
  --good:#34d399;--danger:#f87171;
  --on-accent:#052430;--on-good:#052430;--on-danger:#052430;
  --shadow:0 1px 2px rgba(0,0,0,.3),0 6px 20px rgba(0,0,0,.4);
  --shadow-lg:0 10px 50px rgba(34,211,238,.15),0 10px 40px rgba(0,0,0,.6);
}

/* ── theme: Office Space (beige cubicle walls, red stapler accent) ──────── */
:root[data-theme="officespace-light"] {
  --bg:#e8e2d0;--surface:#f5f1e6;--surface-2:#ded5b8;--text:#2e2a1f;--text-soft:#6b6350;
  --text-faint:#9c9478;--border:#c7bd9c;--accent:#b0201f;--accent-soft:#f0d9d3;--accent-ink:#7d1614;
  --good:#4a7c3f;--danger:#b0201f;--radius:8px;--radius-sm:6px;
  --shadow:0 1px 2px rgba(46,42,31,.06),0 6px 18px rgba(46,42,31,.1);--shadow-lg:0 10px 36px rgba(46,42,31,.25);
  --serif: "Courier New", Courier, monospace;
}
:root[data-theme="officespace-dark"] {
  --bg:#14150f;--surface:#1e2015;--surface-2:#272a1c;--text:#e8e6d8;--text-soft:#a6a48d;
  --text-faint:#74725d;--border:#383a28;--accent:#d1453a;--accent-soft:#3a201c;--accent-ink:#ff8f84;
  --good:#7fae5a;--danger:#d1453a;--radius:8px;--radius-sm:6px;
  --shadow:0 1px 2px rgba(0,0,0,.35),0 6px 20px rgba(0,0,0,.4);--shadow-lg:0 10px 40px rgba(0,0,0,.6);
  --serif: "Courier New", Courier, monospace;
}

/* ── theme: Color-blind friendly (Okabe-Ito palette, blue/orange only) ──── */
:root[data-theme="colorblind-light"] {
  --bg:#f7f7f5;--surface:#fff;--surface-2:#ececea;--text:#1a1a1a;--text-soft:#55555a;
  --text-faint:#86868c;--border:#b8b8bd;--accent:#0072b2;--accent-soft:#d9ecf7;--accent-ink:#00507e;
  --good:#009e73;--danger:#d55e00;
  --shadow:0 1px 2px rgba(0,0,0,.06),0 6px 18px rgba(0,0,0,.08);--shadow-lg:0 10px 36px rgba(0,0,0,.2);
}
:root[data-theme="colorblind-dark"] {
  --bg:#101113;--surface:#1a1c1f;--surface-2:#232629;--text:#eef0f2;--text-soft:#a9adb3;
  --text-faint:#75797f;--border:#3a3e44;--accent:#56b4e9;--accent-soft:#16324a;--accent-ink:#9ad4f5;
  --good:#33c9a3;--danger:#e8813a;
  --on-accent:#0b1116;--on-good:#0b1116;--on-danger:#0b1116;
  --shadow:0 1px 2px rgba(0,0,0,.35),0 6px 20px rgba(0,0,0,.4);--shadow-lg:0 10px 40px rgba(0,0,0,.6);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--text); font-family: var(--sans);
  font-size: 16px; line-height: 1.5; -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* boot spinner */
.app-loading { display: grid; place-items: center; min-height: 100vh; }
.boot-spinner, .spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid var(--border); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── layout ──────────────────────────────────────────────────────────────── */
.layout { display: grid; grid-template-columns: minmax(0, 1fr); min-height: 100vh; }
.main { min-width: 0; width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 14px 112px; }
.rail { display: none; }
.leftnav { display: none; }

@media (min-width: 900px) {
  .layout {
    grid-template-columns: var(--nav-w) minmax(0, var(--maxw)) 260px;
    justify-content: center; gap: 24px; max-width: 1180px; margin: 0 auto;
  }
  .leftnav { display: block; position: sticky; top: 0; height: 100vh; padding: 18px 8px; }
  .rail { display: block; position: sticky; top: 18px; height: fit-content; padding-top: 18px; }
  .main { padding-bottom: 40px; }
  .bottomnav, .fab { display: none !important; }
}

/* ── top bar (mobile) ────────────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 30; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; margin: 0 -14px 14px;
}
.brand { font-family: var(--serif); font-weight: 700; font-size: 20px; letter-spacing: -.01em; color: var(--text); }
.brand .mark { color: var(--accent); }
.topbar-actions { display: flex; gap: 6px; align-items: center; }
@media (min-width: 900px) { .topbar { display: none; } }

/* ── left nav ────────────────────────────────────────────────────────────── */
.leftnav .brand { display: block; padding: 8px 12px 16px; font-size: 24px; }
.navlink {
  display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 12px;
  color: var(--text); font-weight: 600; margin-bottom: 2px; position: relative;
}
.navlink:hover { background: var(--surface-2); text-decoration: none; }
.navlink.active { background: var(--accent-soft); color: var(--accent-ink); }
.navlink .ic { font-size: 20px; width: 22px; text-align: center; }
.navlink .badge { margin-left: auto; }
.leftnav .post-btn { width: 100%; margin-top: 12px; }

/* ── bottom nav + FAB (mobile) ───────────────────────────────────────────── */
.bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(12px);
  border-top: 1px solid var(--border); display: flex; justify-content: space-around;
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.bottomnav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 0; color: var(--text-soft); font-size: 10.5px; font-weight: 600; position: relative;
}
.bottomnav a.active { color: var(--accent); }
.bottomnav .ic { font-size: 21px; }
.fab {
  position: fixed; right: 18px; bottom: calc(64px + env(safe-area-inset-bottom)); z-index: 45;
  width: 58px; height: 58px; border-radius: 50%; border: none; background: var(--accent);
  color: var(--on-accent); font-size: 30px; line-height: 1; box-shadow: var(--shadow-lg);
  display: grid; place-items: center;
}
.fab:active { transform: scale(.94); }

/* ── icons ───────────────────────────────────────────────────────────────── */
/* All interface icons are inline Lucide SVGs (see js/icons.js) — never emoji. */
.ico { display: block; flex: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important; scroll-behavior: auto !important;
  }
}

/* ── buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 10px 16px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-weight: 650; font-size: 14.5px;
  transition: transform .06s ease, background .15s ease; white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-ink); }
.btn.ghost { background: transparent; }
.btn.subtle { background: var(--surface-2); border-color: transparent; }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); }
.btn.sm { padding: 6px 11px; font-size: 13px; border-radius: 10px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.iconbtn {
  width: 40px; height: 40px; border-radius: 50%; border: 1px solid transparent;
  background: transparent; display: grid; place-items: center; font-size: 19px; color: var(--text);
  position: relative;
}
.iconbtn:hover { background: var(--surface-2); }

.badge {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--accent);
  color: var(--on-accent); font-size: 11px; font-weight: 700; display: inline-grid; place-items: center;
}
.dot-badge { position: absolute; top: 4px; right: 6px; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); border: 2px solid var(--bg); }

/* ── cards & quotes ──────────────────────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px; margin-bottom: 14px;
}
.quote-card { position: relative; }
.card-enter { animation: card-in .25s ease both; }
@keyframes card-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.quote-body {
  font-family: var(--serif); font-size: 21px; line-height: 1.4; color: var(--text);
  letter-spacing: -.005em; white-space: pre-wrap; word-break: break-word; margin: 2px 0 4px;
}
.quote-body .qmark { color: var(--accent); font-weight: 700; }
.quote-attr { font-size: 15px; color: var(--text); margin-top: 10px; font-weight: 600; }
.quote-attr .dash { color: var(--text-faint); }
.quote-said-time { font-size: 13px; color: var(--text-soft); margin-top: 2px; }
.quote-context { font-size: 13.5px; color: var(--text-soft); margin-top: 8px; font-style: italic; }
.quote-context::before { content: "📍 "; font-style: normal; }
.mention-link { color: var(--accent-ink); font-weight: 700; }
.quote-meta {
  display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center;
  font-size: 12.5px; color: var(--text-faint); margin-top: 12px;
}
.quote-meta .poster { display: inline-flex; align-items: center; gap: 6px; }
.vis-pill { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--text-soft); font-weight: 600; }
.orphan-pill { background: var(--accent-soft); color: var(--accent-ink); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.tag { font-size: 12px; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); color: var(--text-soft); font-weight: 600; }
.tag:hover { background: var(--accent-soft); color: var(--accent-ink); text-decoration: none; }
.quote-img { margin-top: 12px; border-radius: 12px; max-width: 100%; max-height: 420px; display: block; border: 1px solid var(--border); }

.actions { display: flex; align-items: center; gap: 4px; margin-top: 12px; flex-wrap: wrap; }
.react-btn, .act-btn {
  display: inline-flex; align-items: center; gap: 5px; padding: 6px 10px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); font-size: 13px; font-weight: 600; color: var(--text-soft);
}
.react-btn.on { background: var(--accent-soft); border-color: transparent; color: var(--accent-ink); }
.react-btn:hover, .act-btn:hover { border-color: var(--accent); }
.act-btn.spacer { margin-left: auto; }

.avatar {
  width: 36px; height: 36px; border-radius: 50%; object-fit: cover; background: var(--surface-2);
  display: inline-grid; place-items: center; font-weight: 700; color: var(--text-soft); font-size: 14px; flex: none;
}
.avatar.sm { width: 28px; height: 28px; font-size: 12px; }
.avatar.lg { width: 76px; height: 76px; font-size: 30px; }

/* ── forms ───────────────────────────────────────────────────────────────── */
.field { margin-bottom: 14px; }
.field label { display: block; font-weight: 650; font-size: 13.5px; margin-bottom: 6px; color: var(--text-soft); }
.input, textarea, select {
  width: 100%; padding: 11px 13px; border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface); color: var(--text); font-family: inherit; font-size: 15px;
}
textarea { resize: vertical; }
.input:focus, textarea:focus, select:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.hint { font-size: 12px; color: var(--text-faint); margin-top: 5px; }
.err { color: var(--danger); font-size: 13px; margin-top: 6px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 0; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 12px; padding: 3px; gap: 2px; }
.seg button { border: none; background: transparent; padding: 7px 13px; border-radius: 9px; font-weight: 650; font-size: 13.5px; color: var(--text-soft); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.chip-toggle { display: inline-flex; align-items: center; gap: 5px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); font-size: 13px; font-weight: 600; color: var(--text-soft); }
.chip-toggle.on { background: var(--accent-soft); border-color: transparent; color: var(--accent-ink); }

/* ── theme picker ────────────────────────────────────────────────────────── */
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.theme-opt {
  display: flex; flex-direction: column; align-items: flex-start; gap: 8px;
  padding: 10px; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); text-align: left;
}
.theme-opt.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.theme-swatch { display: flex; gap: 4px; }
.theme-swatch i { width: 16px; height: 16px; border-radius: 50%; border: 1px solid rgba(0,0,0,.08); display: block; }
.theme-name { font-size: 13px; font-weight: 650; color: var(--text); }

/* ── headers / misc ──────────────────────────────────────────────────────── */
.page-head { display: flex; align-items: center; justify-content: space-between; margin: 6px 0 14px; gap: 10px; }
.page-head h1 { font-family: var(--serif); font-size: 26px; margin: 0; letter-spacing: -.01em; }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-faint); font-weight: 700; margin: 18px 0 8px; }
.empty { text-align: center; padding: 48px 20px; color: var(--text-soft); }
.empty .big { font-size: 40px; margin-bottom: 10px; }
.empty h3 { margin: 0 0 6px; font-family: var(--serif); color: var(--text); }
.muted { color: var(--text-faint); }
.center { text-align: center; }
hr.sep { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

/* skeletons */
.skel { background: linear-gradient(90deg, var(--surface-2) 25%, color-mix(in srgb, var(--surface-2) 60%, var(--surface)) 37%, var(--surface-2) 63%); background-size: 400% 100%; animation: shimmer 1.4s infinite; border-radius: 8px; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
.skel-line { height: 14px; margin-bottom: 9px; }

/* ── mention autocomplete ────────────────────────────────────────────────── */
.mention-pop {
  position: absolute; z-index: 60; background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow-lg); overflow: hidden;
  width: 100%; min-width: 240px; max-height: 264px; overflow-y: auto;
}
.mention-item { display: flex; align-items: center; gap: 10px; padding: 9px 11px; cursor: pointer; }
.mention-item.active, .mention-item:hover { background: var(--accent-soft); }
.mention-item .who { min-width: 0; }
.mention-item .name { font-weight: 650; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mention-item .uname { font-size: 12px; color: var(--text-faint); }
.mention-item .rel { margin-left: auto; font-size: 11px; color: var(--accent-ink); background: var(--accent-soft); padding: 2px 7px; border-radius: 999px; font-weight: 600; flex: none; }

/* ── composer sheet ──────────────────────────────────────────────────────── */
/* The quote is the focal point: it gets the serif face and the only large type.
   Everything else is a quiet row, so hierarchy comes from spacing + weight
   rather than from borders and cards. */
.modal.composer {
  padding: 0; display: flex; flex-direction: column; overflow: hidden;
  max-height: min(92vh, 92dvh);
}
.cx-head {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px;
  padding: 10px 10px 10px 12px; border-bottom: 1px solid var(--border); flex: none;
}
.cx-head h2 { font-size: 16px; font-weight: 650; margin: 0; font-family: var(--sans); letter-spacing: -.01em; }
.cx-head-btn {
  justify-self: start; border: none; background: none; color: var(--text-soft);
  font-size: 15px; font-weight: 600; padding: 10px 6px; border-radius: 10px; min-height: 44px;
}
.cx-head-btn:hover { color: var(--text); }
.cx-post {
  justify-self: end; border: none; background: var(--accent); color: var(--on-accent);
  font-size: 15px; font-weight: 650; padding: 0 18px; height: 40px; border-radius: 11px;
  transition: opacity .15s ease, transform .06s ease;
}
.cx-post:active { transform: translateY(1px); }
.cx-post[disabled] { opacity: .6; cursor: not-allowed; }

.cx-scroll { overflow-y: auto; flex: 1; padding: 4px 16px 12px; -webkit-overflow-scrolling: touch; }
.cx-quote-wrap { position: relative; padding: 8px 0 4px; }
.cx-quote {
  width: 100%; border: none; background: none; padding: 6px 0; resize: none; overflow-y: auto;
  font-family: var(--serif); font-size: 22px; line-height: 1.38; color: var(--text);
  letter-spacing: -.005em; min-height: 76px;
}
.cx-quote::placeholder { color: var(--text-faint); }
.cx-quote:focus { outline: none; box-shadow: none; }
.cx-tip { font-size: 12px; color: var(--text-faint); margin: 2px 0 0; }
.cx-tip b { color: var(--text-soft); }

.cx-rows { border-top: 1px solid var(--border); margin-top: 10px; }
.cx-row {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 48px;
  padding: 6px 0; border: none; background: none; text-align: left; color: var(--text);
  border-bottom: 1px solid var(--border);
}
.cx-row-ic { color: var(--text-faint); display: inline-flex; flex: none; }
.cx-row-label { font-size: 14px; font-weight: 600; color: var(--text-soft); flex: none; margin: 0; }
.cx-row-btn .cx-row-value {
  margin-left: auto; font-size: 14px; color: var(--text-faint); font-weight: 550;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cx-row-btn .cx-row-value.set { color: var(--text); }
.cx-row-btn:hover .cx-row-ic, .cx-row-btn:hover .cx-row-value { color: var(--accent-ink); }
.cx-chev { color: var(--text-faint); display: inline-flex; flex: none; transition: transform .18s ease; }
.cx-row-btn.open .cx-chev { transform: rotate(180deg); }
.cx-row-input .cx-row-label { min-width: 62px; }
.cx-inline-input {
  flex: 1; min-width: 0; border: none; background: none; padding: 8px 0;
  font-family: inherit; font-size: 15px; color: var(--text); text-align: right;
}
.cx-row-input .cx-inline-input { text-align: right; }
.cx-inline-input::placeholder { color: var(--text-faint); }
.cx-inline-input:focus { outline: none; }
.cx-row-input:focus-within .cx-row-ic { color: var(--accent); }
.cx-inline-input.invalid, .cx-quote.invalid { box-shadow: none; }
.cx-row-input:has(.invalid) { box-shadow: inset 2px 0 0 var(--danger); }

/* disclosure panels — animated by grid-rows so height stays automatic */
.cx-panel { display: grid; grid-template-rows: 1fr; border-bottom: 1px solid var(--border); }
.cx-panel[hidden] { display: none; }
.cx-panel-in { overflow: hidden; padding: 4px 0 14px; }
@media (prefers-reduced-motion: no-preference) {
  .cx-panel-in { animation: cx-reveal .2s ease; }
}
@keyframes cx-reveal { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.cx-mini-label {
  display: block; font-size: 12px; font-weight: 600; color: var(--text-faint);
  margin: 8px 0 5px; letter-spacing: .01em;
}
.cx-field {
  width: 100%; min-height: 42px; padding: 9px 12px; font-family: inherit; font-size: 15px;
  color: var(--text); background: var(--surface-2); border: 1px solid transparent;
  border-radius: var(--radius-sm);
}
.cx-field:focus { outline: none; border-color: var(--accent); background: var(--surface); }
.cx-panel-foot { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.cx-tz { font-size: 12px; color: var(--text-faint); }
.cx-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; min-height: 36px;
  border: 1px solid var(--border); background: var(--surface); border-radius: 999px;
  font-size: 13px; font-weight: 600; color: var(--text-soft);
}
.cx-chip:hover { border-color: var(--accent); color: var(--accent-ink); }

.cx-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.cx-tag {
  display: inline-flex; align-items: center; gap: 5px; padding: 7px 11px; min-height: 34px;
  border: 1px solid var(--border); background: var(--surface); border-radius: 999px;
  font-size: 13px; font-weight: 600; color: var(--text-soft);
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.cx-tag .cx-tag-ic { display: inline-flex; color: var(--text-faint); }
.cx-tag:hover { border-color: var(--accent); }
.cx-tag.on { background: var(--accent-soft); border-color: transparent; color: var(--accent-ink); }
.cx-tag.on .cx-tag-ic { color: var(--accent-ink); }

/* attachments */
.cx-attachments:not(:empty) { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.cx-attach {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  background: var(--surface-2); border-radius: var(--radius-sm);
}
.cx-attach-ic { color: var(--text-soft); display: inline-flex; flex: none; }
.cx-attach-main { flex: 1; min-width: 0; }
.cx-attach-name { display: block; font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cx-attach-thumb { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; flex: none; }
.cx-attach-sug { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.cx-attach-sug .cx-tag { font-size: 12px; min-height: 30px; padding: 5px 10px; }
.cx-attach .cx-inline-input { text-align: left; padding: 2px 0; font-size: 14px; }
.cx-attach-x {
  width: 34px; height: 34px; flex: none; display: grid; place-items: center; border: none;
  border-radius: 50%; background: none; color: var(--text-soft);
}
.cx-attach-x:hover { background: var(--surface); color: var(--danger); }

.cx-err {
  display: flex; align-items: center; gap: 7px; margin-top: 12px; padding: 10px 12px;
  border-radius: var(--radius-sm); background: color-mix(in srgb, var(--danger) 12%, transparent);
  color: var(--danger); font-size: 13.5px; font-weight: 600;
}
.cx-err svg { flex: none; }
/* display:flex above would otherwise defeat the [hidden] attribute */
.cx-err[hidden] { display: none; }

/* toolbar pinned above the safe area so Post-adjacent actions stay reachable */
.cx-toolbar {
  display: flex; align-items: center; gap: 4px; flex: none;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border); background: var(--surface);
}
.cx-tool {
  width: 44px; height: 44px; display: grid; place-items: center; border: none;
  border-radius: 11px; background: none; color: var(--text-soft); cursor: pointer;
}
.cx-tool:hover { background: var(--surface-2); color: var(--accent-ink); }
.cx-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.cx-vis-wrap { position: relative; margin-left: auto; }
.cx-vis-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: 11px; background: var(--surface);
  font-size: 14px; font-weight: 600; color: var(--text-soft);
}
.cx-vis-btn:hover { border-color: var(--accent); color: var(--accent-ink); }
.cx-vis-menu {
  position: absolute; right: 0; bottom: calc(100% + 8px); z-index: 10; width: 250px; max-width: 78vw;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: var(--shadow-lg); padding: 5px; overflow: hidden;
}
@media (prefers-reduced-motion: no-preference) {
  .cx-vis-menu { animation: cx-reveal .14s ease; }
}
.cx-vis-menu button {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px;
  border: none; background: none; border-radius: 10px; text-align: left; color: var(--text);
}
.cx-vis-menu button:hover { background: var(--surface-2); }
.cx-vis-menu button.on { background: var(--accent-soft); }
.cx-vis-ic { display: inline-flex; color: var(--text-soft); flex: none; }
.cx-vis-menu button.on .cx-vis-ic { color: var(--accent-ink); }
.cx-vis-text { flex: 1; min-width: 0; }
.cx-vis-text b { display: block; font-size: 14px; font-weight: 650; }
.cx-vis-text small { font-size: 11.5px; color: var(--text-faint); }
.cx-vis-check { display: none; color: var(--accent-ink); flex: none; }
.cx-vis-menu button.on .cx-vis-check { display: inline-flex; }

/* ── modal ───────────────────────────────────────────────────────────────── */
.modal-backdrop { position: fixed; inset: 0; background: rgba(20,16,12,.5); z-index: 100; display: flex; align-items: flex-end; justify-content: center; padding: 0; }
@media (min-width: 640px) { .modal-backdrop { align-items: center; padding: 20px; } }
.modal {
  background: var(--surface); width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto;
  border-radius: 20px 20px 0 0; box-shadow: var(--shadow-lg); padding: 18px 18px calc(18px + env(safe-area-inset-bottom)); animation: slideup .22s ease;
}
@media (min-width: 640px) { .modal { border-radius: 20px; } }
@keyframes slideup { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.modal-head h2 { font-family: var(--serif); font-size: 21px; margin: 0; }

/* ── toasts ──────────────────────────────────────────────────────────────── */
.toast-host { position: fixed; top: 14px; left: 0; right: 0; z-index: 200; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast {
  background: var(--text); color: var(--bg); padding: 11px 16px; border-radius: 999px; font-weight: 600; font-size: 14px;
  box-shadow: var(--shadow-lg); animation: toastin .25s ease; max-width: 90vw;
}
.toast.err { background: var(--danger); color: var(--on-danger); }
.toast.ok { background: var(--good); color: var(--on-good); }
@keyframes toastin { from { transform: translateY(-14px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ── landing ─────────────────────────────────────────────────────────────── */
.landing { max-width: 460px; margin: 0 auto; padding: 34px 20px 60px; min-height: 100vh; display: flex; flex-direction: column; justify-content: center; }
.landing .logo { font-family: var(--serif); font-size: 40px; font-weight: 700; letter-spacing: -.02em; }
.landing .logo .mark { color: var(--accent); }
.landing .tag { font-size: 17px; color: var(--text-soft); margin: 6px 0 26px; font-style: italic; }
.big-quote { font-family: var(--serif); font-size: 26px; line-height: 1.35; margin: 24px 0; }
.big-quote .qmark { color: var(--accent); }

/* profile header */
.profile-head { display: flex; gap: 16px; align-items: flex-start; }
.profile-head .info { flex: 1; min-width: 0; }
.profile-stats { display: flex; gap: 18px; margin-top: 10px; font-size: 13.5px; }
.profile-stats b { display: block; font-size: 17px; }

/* list rows */
.urow { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.urow:last-child { border-bottom: none; }
.urow .who { flex: 1; min-width: 0; }
.urow .name { font-weight: 650; }
.urow .uname { font-size: 12.5px; color: var(--text-faint); }

/* admin */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px,1fr)); gap: 10px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px; text-align: center; }
.stat b { display: block; font-size: 26px; font-family: var(--serif); }
.stat span { font-size: 12px; color: var(--text-soft); }
.tabbar { display: flex; gap: 4px; overflow-x: auto; margin-bottom: 14px; padding-bottom: 4px; }
.tabbar button { border: none; background: var(--surface-2); color: var(--text-soft); padding: 8px 13px; border-radius: 10px; font-weight: 650; font-size: 13.5px; white-space: nowrap; }
.tabbar button.on { background: var(--accent); color: var(--on-accent); }
.quota-bar { height: 7px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin-top: 4px; }
.quota-bar > i { display: block; height: 100%; background: var(--accent); }

/* ── stats page ──────────────────────────────────────────────────────────── */
.stats-section { margin: 26px 0; }
.stats-section:first-of-type { margin-top: 18px; }

.lb { display: flex; flex-direction: column; gap: 4px; }
.lb-row {
  position: relative; display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 12px; overflow: hidden; min-height: 44px;
}
.lb-fill {
  position: absolute; inset: 0; left: 0; z-index: 0; border-radius: 12px;
  background: var(--accent-soft);
}
.lb-rank {
  position: relative; z-index: 1; flex: none; width: 24px; height: 24px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 800; color: var(--text-faint);
}
.lb-row[data-rank="1"] .lb-rank { background: var(--accent); color: var(--on-accent); border-radius: 50%; }
.lb-row[data-rank="2"] .lb-rank, .lb-row[data-rank="3"] .lb-rank { background: var(--surface); color: var(--accent-ink); border-radius: 50%; box-shadow: var(--shadow); }
.lb-row .avatar { position: relative; z-index: 1; }
.lb-name { position: relative; z-index: 1; flex: 1; min-width: 0; font-weight: 650; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-name a { color: var(--text); }
.lb-count { position: relative; z-index: 1; flex: none; font-family: var(--serif); font-weight: 700; font-size: 15px; color: var(--text); }

.year-chart { display: flex; align-items: flex-end; gap: 5px; height: 160px; padding-top: 8px; }
.year-bar { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; }
.year-bar i { display: block; width: 100%; max-width: 30px; background: var(--accent); border-radius: 5px 5px 2px 2px; min-height: 3px; }
.yb-count { font-size: 10.5px; font-weight: 700; color: var(--text-soft); margin-bottom: 3px; }
.yb-label { font-size: 10.5px; color: var(--text-faint); margin-top: 6px; font-weight: 600; }

.rx-bars { display: flex; flex-direction: column; gap: 8px; }
.rx-row { display: flex; align-items: center; gap: 10px; }
.rx-emoji { font-size: 18px; flex: none; width: 24px; text-align: center; }
.rx-track { flex: 1; height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.rx-track > i { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.rx-count { flex: none; font-weight: 700; font-size: 13.5px; color: var(--text-soft); min-width: 24px; text-align: right; }

.tag-bars { display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: baseline; }
.tag-bars .tag { font-weight: 700; }

.notif { display: flex; gap: 11px; padding: 12px 4px; border-bottom: 1px solid var(--border); align-items: flex-start; }
.notif.unread { background: color-mix(in srgb, var(--accent-soft) 40%, transparent); border-radius: 10px; padding-left: 10px; }
.notif .txt { flex: 1; font-size: 14px; }
.notif .time { font-size: 12px; color: var(--text-faint); }

.scroll-sentinel { display: flex; align-items: center; justify-content: center; min-height: 1px; padding: 20px 0; }
.spinner.sm { width: 22px; height: 22px; border-width: 2px; }
