/* Hestia HQ — "a fireplace at night". Warm charcoal + stone, ember accents,
   pixel font for the logo and page headings only. */

:root,
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #15120f;
  --bg-glow: rgba(214, 116, 56, 0.075);
  --sidebar: #1a1612;
  --surface: #211c17;
  --surface-2: #29231d;
  --surface-3: #332b24;
  --line: #3a3129;
  --line-soft: #2c251f;
  --text: #ebe3d7;
  --text-2: #b9ad9e;
  --text-3: #8b7f71;
  --ember: #e48a4e;
  --ember-strong: #f0a066;
  --ember-ink: #1d130c;
  --ember-soft: rgba(228, 138, 78, 0.13);
  --amber: #e2b363;
  --glow: rgba(228, 138, 78, 0.32);
  --danger: #d4877b;
  --danger-soft: rgba(212, 135, 123, 0.12);
  --shadow: 0 1px 0 rgba(255, 240, 220, 0.03) inset, 0 10px 30px -18px rgba(0, 0, 0, 0.6);
  --overlay: rgba(10, 8, 6, 0.72);
  --code-bg: #1b1713;

  --s-proposed: #a89a8a;
  --s-discussing: #e2b363;
  --s-approved: #93b483;
  --s-in_progress: #e48a4e;
  --s-done: #80aca3;
  --s-rejected: #c07e74;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f3ece2;
  --bg-glow: rgba(214, 120, 60, 0.07);
  --sidebar: #ede4d7;
  --surface: #faf6f0;
  --surface-2: #f2eadf;
  --surface-3: #e8ddcf;
  --line: #dccfbe;
  --line-soft: #e7ddd0;
  --text: #2e2620;
  --text-2: #5e5147;
  --text-3: #8a7b6d;
  --ember: #c4622b;
  --ember-strong: #b05523;
  --ember-ink: #fff8f0;
  --ember-soft: rgba(196, 98, 43, 0.1);
  --amber: #9e731f;
  --glow: rgba(196, 98, 43, 0.22);
  --danger: #b04f42;
  --danger-soft: rgba(176, 79, 66, 0.09);
  --shadow: 0 1px 2px rgba(80, 50, 20, 0.05), 0 10px 26px -18px rgba(80, 50, 20, 0.35);
  --overlay: rgba(40, 30, 20, 0.55);
  --code-bg: #efe6da;

  --s-proposed: #8d7f70;
  --s-discussing: #b0821f;
  --s-approved: #5f8a4d;
  --s-in_progress: #c4622b;
  --s-done: #4e8b80;
  --s-rejected: #a85a4f;
}

:root {
  --font-body: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-pixel: "Pixelify Sans", var(--font-body);
  --font-mono: ui-monospace, "Cascadia Code", "JetBrains Mono", Consolas, monospace;
  --r-sm: 8px;
  --r: 12px;
  --r-lg: 16px;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --sidebar-w: 248px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1200px 700px at -10% 110%, var(--bg-glow), transparent 60%),
    radial-gradient(900px 500px at 110% -10%, rgba(226, 179, 99, 0.03), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font: 400 15.5px/1.6 var(--font-body);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--ember); text-decoration: none; }
a:hover { color: var(--ember-strong); }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; }
::selection { background: rgba(228, 138, 78, 0.3); }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ------------------------------------------------------------ boot */
.boot { min-height: 100vh; display: grid; place-items: center; }
.boot-flame {
  width: 12px; height: 12px; background: var(--ember);
  box-shadow: 0 0 24px 6px var(--glow);
  animation: flicker 1.4s ease-in-out infinite;
}

/* ------------------------------------------------------------ shell */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh;
  width: var(--sidebar-w); flex: none;
  display: flex; flex-direction: column;
  padding: 22px 14px 16px;
  background: var(--sidebar);
  border-right: 1px solid var(--line-soft);
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 10px 22px; color: var(--text); }
.brand:hover { color: var(--text); }
.brand svg { width: 30px; height: auto; flex: none; filter: drop-shadow(0 0 10px rgba(228, 138, 78, 0.25)); }
.brand-name { font: 600 21px/1 var(--font-pixel); letter-spacing: 0.04em; }
.brand-hq {
  display: inline-block; margin-left: 6px; padding: 2px 5px 1px;
  font: 500 11px/1.2 var(--font-pixel); letter-spacing: 0.08em;
  color: var(--ember-ink); background: var(--ember); border-radius: 2px;
  vertical-align: 3px;
}
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px; border-radius: 10px;
  color: var(--text-2); font-weight: 500;
  transition: background 0.18s var(--ease), color 0.18s var(--ease);
}
.nav a svg { width: 19px; height: 19px; flex: none; opacity: 0.85; }
.nav a:hover { background: var(--surface); color: var(--text); }
.nav a.active { background: var(--surface-2); color: var(--text); }
.nav a.active::before {
  content: ""; position: absolute; left: -14px; top: 50%; width: 4px; height: 16px;
  margin-top: -8px; background: var(--ember); box-shadow: 0 0 12px var(--glow);
}
.nav a.active svg { color: var(--ember); opacity: 1; }
.nav .dot { margin-left: auto; width: 6px; height: 6px; background: var(--ember); box-shadow: 0 0 8px var(--glow); }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.me-chip {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--line-soft); color: var(--text);
}
.me-chip:hover { color: var(--text); border-color: var(--line); }
.me-chip .who { min-width: 0; line-height: 1.25; }
.me-chip .who b { display: block; font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-chip .who small { color: var(--text-3); font-size: 12px; }
.foot-row { display: flex; gap: 6px; }
.foot-row .btn { flex: 1; }

.main { flex: 1; min-width: 0; }
.page { max-width: 1080px; margin: 0 auto; padding: 34px 40px 80px; }
.page.narrow { max-width: 820px; }
.page.wide { max-width: 1280px; }

.topbar, .tabbar, .fab { display: none; }

/* account sheet (phones) */
.me-button { padding: 3px; border: 0; border-radius: 10px; background: none; cursor: pointer; display: grid; }
.me-button .avatar { width: 34px; height: 34px; border-radius: 8px; }
.account-head { display: flex; align-items: center; gap: 12px; padding: 12px; margin: 4px 0 12px; border-radius: 12px; background: var(--surface-2); }
.sheet-list { display: flex; flex-direction: column; gap: 2px; }
.sheet-list a, .sheet-list button {
  display: flex; align-items: center; gap: 14px; width: 100%; min-height: 50px; padding: 0 12px;
  border: 0; border-radius: 12px; background: none; color: var(--text); font-size: 16px; font-weight: 550; text-align: left; cursor: pointer;
}
.sheet-list a:hover, .sheet-list button:hover, .sheet-list a:active, .sheet-list button:active { background: var(--surface-2); color: var(--text); }
.sheet-list svg { width: 20px; height: 20px; color: var(--text-3); }
.sheet-list .danger, .sheet-list .danger svg { color: var(--danger); }

/* "add to home screen" hint */
.install-hint {
  display: flex; align-items: center; gap: 12px; margin: 16px 16px 0; padding: 12px 12px 12px 14px;
  border-radius: 14px; border: 1px solid color-mix(in srgb, var(--ember) 35%, var(--line-soft));
  background: linear-gradient(135deg, var(--ember-soft), transparent 70%), var(--surface);
  font-size: 13.5px; line-height: 1.45; color: var(--text-2);
}
.install-hint img { border-radius: 10px; flex: none; }
.install-hint b { color: var(--text); }
.install-hint .grow { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
@media (min-width: 861px) { .install-hint { max-width: 1000px; margin: 24px auto 0; } }

/* ------------------------------------------------------------ headings */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head h1, .h-pixel {
  margin: 0; font: 600 30px/1.1 var(--font-pixel); letter-spacing: 0.02em; color: var(--text);
}
.page-head p { margin: 6px 0 0; color: var(--text-3); }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.section-label {
  display: flex; align-items: center; gap: 8px;
  margin: 0 0 12px; font-size: 12px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-3);
}
.section-label::before { content: ""; width: 6px; height: 6px; background: var(--ember); }
.section-label .count { color: var(--text-3); font-weight: 600; letter-spacing: 0; }
.section-label .grow { flex: 1; }
.pixel-rule {
  height: 2px; margin: 28px 0;
  background-image: linear-gradient(90deg, var(--line) 50%, transparent 50%);
  background-size: 6px 2px;
}

/* ------------------------------------------------------------ buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 15px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text);
  font-weight: 600; font-size: 14.5px; cursor: pointer; white-space: nowrap;
  transition: background 0.18s var(--ease), border-color 0.18s var(--ease), box-shadow 0.25s var(--ease), color 0.18s;
}
.btn svg { width: 17px; height: 17px; flex: none; }
.btn:hover { background: var(--surface-3); color: var(--text); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn.primary { background: var(--ember); border-color: transparent; color: var(--ember-ink); }
.btn.primary:hover { background: var(--ember-strong); box-shadow: 0 0 0 4px var(--ember-soft), 0 6px 24px -6px var(--glow); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn.sm { height: 32px; padding: 0 11px; font-size: 13.5px; border-radius: 9px; }
.btn.xs { height: 26px; padding: 0 8px; font-size: 12.5px; border-radius: 7px; gap: 5px; }
.btn.xs svg { width: 14px; height: 14px; }
.btn.icon { width: 38px; padding: 0; }
.btn.sm.icon { width: 32px; }
.btn.xs.icon { width: 26px; }
.btn.block { width: 100%; }
.linkish { background: none; border: 0; padding: 0; color: var(--text-3); font-size: 13px; font-weight: 600; cursor: pointer; }
.linkish:hover { color: var(--ember); }
.linkish.danger:hover { color: var(--danger); }

/* ------------------------------------------------------------ inputs */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field > span { font-size: 13px; font-weight: 600; color: var(--text-2); }
.field small { color: var(--text-3); font-size: 12.5px; }
.input, .select, textarea.input {
  width: 100%; height: 40px; padding: 0 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; color: var(--text);
  transition: border-color 0.18s, box-shadow 0.2s;
}
textarea.input { height: auto; min-height: 88px; padding: 10px 12px; resize: vertical; line-height: 1.55; }
.input::placeholder { color: var(--text-3); }
.input:focus, .select:focus { outline: none; border-color: var(--ember); box-shadow: 0 0 0 3px var(--ember-soft); }
.input.title-input { height: 52px; font-size: 22px; font-weight: 700; }
.select {
  appearance: none; padding-right: 32px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%);
  background-position: calc(100% - 17px) 17px, calc(100% - 12px) 17px;
  background-size: 5px 5px; background-repeat: no-repeat;
}
.select.sm { height: 34px; font-size: 14px; background-position: calc(100% - 17px) 14px, calc(100% - 12px) 14px; }
.search {
  position: relative; flex: 1; min-width: 200px;
}
.search svg { position: absolute; left: 12px; top: 50%; width: 17px; height: 17px; margin-top: -8.5px; color: var(--text-3); pointer-events: none; }
.search .input { padding-left: 38px; }
.form-error {
  margin: 0 0 14px; padding: 10px 12px; border-radius: 10px;
  background: var(--danger-soft); color: var(--danger); font-size: 14px;
}

/* ------------------------------------------------------------ cards */
.card {
  background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--r-lg);
  box-shadow: var(--shadow);
}
.card.pad { padding: 20px 22px; }
.ember-hover { transition: border-color 0.22s var(--ease), box-shadow 0.3s var(--ease), transform 0.22s var(--ease); }
.ember-hover:hover {
  border-color: rgba(228, 138, 78, 0.38);
  box-shadow: var(--shadow), 0 0 0 1px rgba(228, 138, 78, 0.12), 0 12px 36px -16px var(--glow);
}

/* ------------------------------------------------------------ avatar */
.avatar {
  position: relative; display: inline-grid; place-items: center; flex: none;
  width: 28px; height: 28px; border-radius: 6px; overflow: hidden;
  background: var(--surface-3); color: var(--ember-ink); font-weight: 700; font-size: 12px;
  box-shadow: 0 0 0 2px var(--ring, transparent);
}
.avatar img { width: 100%; height: 100%; image-rendering: pixelated; display: block; }
.avatar.sm { width: 22px; height: 22px; border-radius: 5px; font-size: 10px; }
.avatar.lg { width: 44px; height: 44px; border-radius: 9px; font-size: 16px; }
.avatar.xl { width: 72px; height: 72px; border-radius: 12px; font-size: 26px; }
.who-inline { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; color: var(--text); }
.who-inline .name, .uname { color: color-mix(in srgb, var(--uc, var(--text)) 72%, var(--text)); }
.btn.primary.danger-primary { background: var(--danger); color: var(--ember-ink); }
.btn.primary.danger-primary:hover { box-shadow: 0 0 0 4px var(--danger-soft); }

/* ------------------------------------------------------------ chips, tags, status */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 11px;
  border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--text-2);
  font-size: 13px; font-weight: 600; cursor: pointer; transition: all 0.18s var(--ease);
}
.chip:hover { color: var(--text); border-color: var(--text-3); }
.chip.on { background: var(--ember-soft); border-color: rgba(228, 138, 78, 0.55); color: var(--text); }
.chip .sq { width: 7px; height: 7px; background: currentColor; }
.tag {
  display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 6px;
  background: var(--surface-2); border: 1px solid var(--line-soft); color: var(--text-2);
  font-size: 12px; font-weight: 600; letter-spacing: 0.01em;
}
.status {
  display: inline-flex; align-items: center; gap: 7px; height: 24px; padding: 0 9px 0 8px;
  border-radius: 6px; font-size: 12.5px; font-weight: 700;
  color: var(--sc); background: color-mix(in srgb, var(--sc) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--sc) 28%, transparent);
}
.status::before { content: ""; width: 7px; height: 7px; background: var(--sc); flex: none; }
.status-select {
  appearance: none; cursor: pointer; height: 30px; padding: 0 28px 0 12px;
  border-radius: 8px; font-weight: 700; font-size: 13.5px;
  color: var(--sc); background-color: color-mix(in srgb, var(--sc) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--sc) 35%, transparent);
  background-image: linear-gradient(45deg, transparent 50%, var(--sc) 50%), linear-gradient(135deg, var(--sc) 50%, transparent 50%);
  background-position: calc(100% - 15px) 12px, calc(100% - 10px) 12px; background-size: 5px 5px; background-repeat: no-repeat;
}
.status-select option { color: var(--text); background: var(--surface); }
.badge-example {
  display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 3px;
  font: 600 11px/1 var(--font-pixel); letter-spacing: 0.1em;
  color: var(--amber); border: 1px dashed color-mix(in srgb, var(--amber) 60%, transparent);
}
.role-badge {
  display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 4px;
  font-size: 11.5px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  background: var(--surface-2); color: var(--text-3); border: 1px solid var(--line-soft);
}
.role-badge.admin { color: var(--amber); border-color: color-mix(in srgb, var(--amber) 35%, transparent); }

/* ------------------------------------------------------------ announcements */
.announce { padding: 16px 18px 14px; margin-bottom: 22px; position: relative; overflow: hidden; }
.announce::after {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--amber); opacity: 0.85;
}
.announce .section-label::before { background: var(--amber); }
.announce-list { display: flex; flex-direction: column; gap: 10px; }
.announce-item { display: flex; gap: 10px; align-items: flex-start; }
.announce-item .body { flex: 1; min-width: 0; font-size: 14.5px; white-space: pre-wrap; overflow-wrap: anywhere; }
.announce-item .meta { color: var(--text-3); font-size: 12.5px; margin-top: 2px; }
.announce-add { display: flex; gap: 8px; margin-top: 12px; }
.announce-add .input { height: 36px; }
.announce-empty { color: var(--text-3); font-size: 14px; }

/* ------------------------------------------------------------ banner */
.banner {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 14px; margin-bottom: 18px; border-radius: 12px;
  border: 1px dashed color-mix(in srgb, var(--amber) 50%, transparent);
  background: color-mix(in srgb, var(--amber) 6%, transparent);
  color: var(--text-2); font-size: 14px;
}
.banner .grow { flex: 1; min-width: 200px; }

/* ------------------------------------------------------------ toolbar */
.toolbar { display: flex; flex-direction: column; gap: 12px; margin-bottom: 18px; }
.toolbar-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line-soft); }
.seg button {
  height: 30px; padding: 0 11px; border: 0; border-radius: 7px; background: transparent;
  color: var(--text-3); font-size: 13.5px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
.seg button svg { width: 15px; height: 15px; }
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--surface-3); color: var(--text); }

/* ------------------------------------------------------------ idea list */
.idea-list { display: flex; flex-direction: column; gap: 10px; }
.idea-card {
  display: flex; gap: 16px; padding: 16px 18px 15px 12px; color: var(--text); cursor: pointer;
}
.idea-card:hover { color: var(--text); }
.idea-card.example { border-style: dashed; border-color: color-mix(in srgb, var(--amber) 30%, var(--line-soft)); }
.idea-card .content { flex: 1; min-width: 0; }
.idea-card h3 { margin: 0 0 5px; font-size: 17px; font-weight: 700; line-height: 1.35; overflow-wrap: anywhere; }
.idea-card .excerpt {
  margin: 0 0 10px; color: var(--text-2); font-size: 14.5px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.meta-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; color: var(--text-3); font-size: 13px; }
.meta-row .sep { width: 3px; height: 3px; background: var(--text-3); opacity: 0.6; }
.meta-row .stat { display: inline-flex; align-items: center; gap: 5px; }
.meta-row .stat svg { width: 15px; height: 15px; }
.title-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.vote {
  display: flex; flex-direction: column; align-items: center; gap: 0; width: 44px; flex: none;
}
.vote button {
  width: 32px; height: 26px; border: 0; border-radius: 7px; background: transparent; color: var(--text-3);
  cursor: pointer; display: grid; place-items: center; transition: background 0.15s, color 0.15s;
}
.vote button svg { width: 18px; height: 18px; }
.vote button:hover { background: var(--surface-2); color: var(--text); }
.vote button.up.on { color: var(--ember); }
.vote button.down.on { color: #8fa6c4; }
.vote .score { font-weight: 800; font-size: 15px; font-variant-numeric: tabular-nums; line-height: 1.5; }
.vote .score.pos { color: var(--ember); }
.vote.row { flex-direction: row; width: auto; gap: 4px; padding: 3px; border-radius: 10px; border: 1px solid var(--line-soft); background: var(--surface); }
.vote.row .score { min-width: 28px; text-align: center; }

/* ------------------------------------------------------------ idea detail */
.back { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 18px; color: var(--text-3); font-weight: 600; font-size: 14px; }
.back svg { width: 16px; height: 16px; }
.back:hover { color: var(--text); }
.detail-head h1 { margin: 0 0 12px; font-size: 30px; line-height: 1.25; font-weight: 800; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.detail-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-bottom: 18px; }
.detail-bar .grow { flex: 1; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 290px; gap: 0 22px; align-items: start; }
.detail-grid .d-main { grid-column: 1; grid-row: 1; min-width: 0; }
.detail-grid .d-disc { grid-column: 1; grid-row: 2; min-width: 0; }
.side-stack { grid-column: 2; grid-row: 1 / span 2; display: flex; flex-direction: column; gap: 16px; position: sticky; top: 20px; }
.side-card { padding: 16px 16px 14px; }
.side-card .section-label { margin-bottom: 10px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 12px; font-size: 14px; align-items: center; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; text-align: right; }

/* ------------------------------------------------------------ rich content */
.rich { font-size: 16px; line-height: 1.7; overflow-wrap: anywhere; }
.rich > :first-child { margin-top: 0; }
.rich > :last-child { margin-bottom: 0; }
.rich h1, .rich h2, .rich h3 { line-height: 1.3; margin: 1.5em 0 0.5em; font-weight: 750; }
.rich h1 { font-size: 1.55em; }
.rich h2 { font-size: 1.3em; }
.rich h3 { font-size: 1.1em; }
.rich p { margin: 0 0 0.9em; }
.rich ul, .rich ol { margin: 0 0 1em; padding-left: 1.4em; }
.rich li { margin: 0.2em 0; }
.rich li::marker { color: var(--ember); }
.rich blockquote { margin: 0 0 1em; padding: 4px 0 4px 16px; border-left: 3px solid var(--line); color: var(--text-2); }
.rich pre, .rich .ql-code-block-container {
  margin: 0 0 1em; padding: 14px 16px; border-radius: 10px; overflow-x: auto;
  background: var(--code-bg); border: 1px solid var(--line-soft);
  font: 13.5px/1.6 var(--font-mono); white-space: pre; color: var(--text);
}
.rich code { font: 0.88em var(--font-mono); padding: 2px 5px; border-radius: 5px; background: var(--code-bg); border: 1px solid var(--line-soft); }
.rich pre code { padding: 0; border: 0; background: none; }
.rich img { display: block; max-height: 640px; border-radius: 10px; margin: 0.4em 0 1em; border: 1px solid var(--line-soft); cursor: zoom-in; }
.rich a { text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--ember) 45%, transparent); text-underline-offset: 3px; }
.rich hr { border: 0; height: 2px; margin: 1.6em 0; background-image: linear-gradient(90deg, var(--line) 50%, transparent 50%); background-size: 6px 2px; }

/* ------------------------------------------------------------ comments */
.composer { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 22px; }
.composer .box { flex: 1; min-width: 0; }
.composer .row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 8px; }
.composer .hint { color: var(--text-3); font-size: 12.5px; }
.thread { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; }
.comment { display: flex; gap: 12px; padding: 10px 0; }
.comment .c-body { flex: 1; min-width: 0; }
.comment .c-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; font-size: 14px; }
.comment .c-head time { color: var(--text-3); font-size: 12.5px; }
.comment .c-text { margin-top: 3px; font-size: 15px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.comment .c-text code { font: 0.88em var(--font-mono); padding: 1px 5px; border-radius: 5px; background: var(--code-bg); }
.comment .c-actions { display: flex; gap: 14px; margin-top: 5px; }
.replies { margin-left: 22px; padding-left: 18px; border-left: 2px solid var(--line-soft); }
.reply-box { margin: 6px 0 8px; }

/* ------------------------------------------------------------ attachments */
.attach-list { display: flex; flex-direction: column; gap: 6px; }
.file-row {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--line-soft); color: var(--text);
}
.file-row:hover { color: var(--text); }
.file-row .ficon {
  width: 36px; height: 36px; flex: none; display: grid; place-items: center; border-radius: 8px;
  background: var(--surface-2); color: var(--ember);
}
.file-row .ficon svg { width: 19px; height: 19px; }
.file-row .fmain { flex: 1; min-width: 0; }
.file-row .fmain b { display: block; font-weight: 650; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-row .fmain small { color: var(--text-3); font-size: 12.5px; }
.file-row .fside { display: flex; align-items: center; gap: 6px; color: var(--text-3); font-size: 13px; flex: none; }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.thumbs button {
  aspect-ratio: 1; padding: 0; border: 1px solid var(--line-soft); border-radius: 10px; overflow: hidden;
  background: var(--surface-2); cursor: zoom-in;
}
.thumbs img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.3s var(--ease); }
.thumbs button:hover img { transform: scale(1.04); }

/* ------------------------------------------------------------ docs list */
.doc-table { display: flex; flex-direction: column; gap: 8px; }
.doc-row { display: flex; align-items: center; gap: 14px; padding: 12px 14px; color: var(--text); }
.doc-row:hover { color: var(--text); }
.doc-row.example { border-style: dashed; }
.doc-row .dmain { flex: 1; min-width: 0; }
.doc-row .dmain b { display: block; font-weight: 650; font-size: 15.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-row .dmeta { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; margin-top: 3px; color: var(--text-3); font-size: 13px; }
.doc-row .fside { display: flex; align-items: center; gap: 10px; flex: none; color: var(--text-3); font-size: 13px; }
.doc-row .ficon { width: 40px; height: 40px; flex: none; display: grid; place-items: center; border-radius: 10px; background: var(--surface-2); color: var(--ember); }
.doc-row .ficon.page { color: var(--amber); }
.doc-row .ficon svg { width: 20px; height: 20px; }
.doc-view-head { margin-bottom: 22px; }
.doc-view-head h1 { margin: 0 0 10px; font-size: 32px; line-height: 1.2; font-weight: 800; overflow-wrap: anywhere; }
.preview-box { padding: 0; overflow: hidden; }
.preview-box pre { margin: 0; padding: 16px 18px; max-height: 620px; overflow: auto; font: 13px/1.6 var(--font-mono); background: var(--code-bg); white-space: pre; }
.preview-box iframe { width: 100%; height: 76vh; border: 0; display: block; background: #fff; }
.preview-box img { display: block; margin: 0 auto; max-height: 76vh; }
.download-card { display: flex; align-items: center; gap: 16px; padding: 22px; flex-wrap: wrap; }
.download-card .ficon { width: 52px; height: 52px; border-radius: 12px; display: grid; place-items: center; background: var(--surface-2); color: var(--ember); }
.download-card .ficon svg { width: 26px; height: 26px; }

/* ------------------------------------------------------------ gallery */
.masonry { columns: 4 240px; column-gap: 12px; }
.tile {
  position: relative; display: block; width: 100%; margin: 0 0 12px; padding: 0; break-inside: avoid;
  border: 1px solid var(--line-soft); border-radius: 14px; overflow: hidden; background: var(--surface-2);
  cursor: zoom-in; color: var(--text); text-align: left;
}
.tile > img { display: block; width: 100%; height: auto; transition: transform 0.4s var(--ease), filter 0.3s; }
.tile:hover > img { transform: scale(1.025); }
.tile .cap {
  position: absolute; inset: auto 0 0 0; padding: 26px 12px 10px;
  background: linear-gradient(transparent, rgba(12, 9, 7, 0.82));
  color: #f1e9de; font-size: 13.5px; line-height: 1.4;
  opacity: 0; transform: translateY(6px); transition: opacity 0.22s var(--ease), transform 0.22s var(--ease);
  display: flex; align-items: flex-end; gap: 8px;
}
.tile .cap .cap-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.tile:hover .cap, .tile:focus-visible .cap { opacity: 1; transform: none; }
.tile .idea-pin {
  position: absolute; top: 8px; left: 8px; max-width: calc(100% - 16px);
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 7px; border-radius: 6px;
  background: rgba(20, 16, 12, 0.72); color: #eadfce; font-size: 11.5px; font-weight: 600;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
.tile .idea-pin svg { width: 12px; height: 12px; flex: none; }

.lightbox {
  position: fixed; inset: 0; z-index: 60; display: flex; flex-direction: column;
  background: rgba(10, 8, 6, 0.94); animation: fade 0.18s var(--ease);
}
.lb-top { display: flex; align-items: center; gap: 10px; padding: max(12px, env(safe-area-inset-top)) 16px 12px; color: #eadfce; }
.lb-top .grow { flex: 1; min-width: 0; }
.lb-top .btn { background: rgba(255, 240, 220, 0.06); border-color: rgba(255, 240, 220, 0.1); color: #eadfce; }
.lb-top .btn:hover { background: rgba(255, 240, 220, 0.12); }
.lb-stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; position: relative; padding: 0 64px; }
.lb-stage img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.8); }
.lb-nav {
  position: absolute; top: 50%; width: 46px; height: 46px; margin-top: -23px; border-radius: 12px;
  border: 1px solid rgba(255, 240, 220, 0.12); background: rgba(255, 240, 220, 0.06); color: #eadfce;
  display: grid; place-items: center; cursor: pointer;
}
.lb-nav:hover { background: rgba(255, 240, 220, 0.14); }
.lb-nav svg { width: 22px; height: 22px; }
.lb-nav.prev { left: 12px; }
.lb-nav.next { right: 12px; }
.lb-foot { padding: 14px 20px max(20px, env(safe-area-inset-bottom)); color: #d9cebf; text-align: center; }
.lb-foot .cap { font-size: 16px; color: #f1e9de; white-space: pre-wrap; max-width: 760px; margin: 0 auto 6px; }
.lb-foot .meta-row { justify-content: center; color: #a4978a; }
.lb-foot .meta-row a { color: var(--amber); }
.lb-foot .input { max-width: 560px; margin: 0 auto; }

/* ------------------------------------------------------------ upload / drop */
.drop-overlay {
  position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; pointer-events: none;
  background: var(--overlay); animation: fade 0.15s var(--ease);
}
.drop-overlay .inner {
  padding: 34px 44px; border-radius: 20px; border: 2px dashed var(--ember); background: var(--surface);
  text-align: center; box-shadow: 0 0 60px -10px var(--glow);
}
.drop-overlay .inner b { display: block; font: 600 22px/1.2 var(--font-pixel); margin-bottom: 6px; }
.drop-overlay .inner span { color: var(--text-3); }
.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 26px 18px; text-align: center;
  border: 1.5px dashed var(--line); border-radius: 14px; color: var(--text-3); cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.dropzone:hover, .dropzone.hot { border-color: var(--ember); background: var(--ember-soft); color: var(--text-2); }
.dropzone svg { width: 26px; height: 26px; color: var(--ember); }
.dropzone b { color: var(--text); }
.queue { display: flex; flex-direction: column; gap: 10px; margin: 14px 0; max-height: 46vh; overflow: auto; }
.queue-item { display: flex; gap: 12px; align-items: center; }
.queue-item .qthumb { width: 64px; height: 64px; flex: none; border-radius: 10px; overflow: hidden; background: var(--surface-2); display: grid; place-items: center; color: var(--ember); }
.queue-item .qthumb img { width: 100%; height: 100%; object-fit: cover; }
.queue-item .qthumb svg { width: 24px; height: 24px; }
.queue-item .qmain { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.queue-item .qmain small { color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queue-item .input { height: 34px; }
.progress { height: 4px; border-radius: 2px; background: var(--surface-3); overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--ember); transition: width 0.2s; }

/* ------------------------------------------------------------ modal */
.modal-wrap {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px;
  background: var(--overlay); animation: fade 0.16s var(--ease);
}
.modal {
  width: 100%; max-width: 540px; max-height: calc(100vh - 32px); overflow: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 22px 22px 18px;
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.6); animation: rise 0.2s var(--ease);
}
.modal.wide { max-width: 680px; }
.modal h2 { margin: 0 0 4px; font: 600 22px/1.2 var(--font-pixel); }
.modal .sub { margin: 0 0 18px; color: var(--text-3); font-size: 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* ------------------------------------------------------------ toasts */
.toasts { position: fixed; z-index: 80; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; max-width: min(380px, calc(100vw - 36px)); }
.toast {
  padding: 11px 14px; border-radius: 12px; background: var(--surface-3); border: 1px solid var(--line);
  box-shadow: 0 16px 40px -16px rgba(0, 0, 0, 0.6); font-size: 14px; animation: rise 0.2s var(--ease);
  display: flex; gap: 10px; align-items: center;
}
.toast::before { content: ""; width: 7px; height: 7px; flex: none; background: var(--ember); }
.toast.error::before { background: var(--danger); }

/* ------------------------------------------------------------ editor (Quill) */
.editor-wrap { border: 1px solid var(--line); border-radius: 14px; background: var(--surface); overflow: hidden; }
.editor-wrap:focus-within { border-color: var(--ember); box-shadow: 0 0 0 3px var(--ember-soft); }
.editor-wrap .ql-toolbar.ql-snow {
  border: 0; border-bottom: 1px solid var(--line-soft); padding: 8px 10px; background: var(--surface-2);
  font-family: var(--font-body); position: sticky; top: 0; z-index: 2;
}
.editor-wrap .ql-container.ql-snow { border: 0; font-family: var(--font-body); font-size: 16px; }
.editor-wrap .ql-editor { min-height: 280px; padding: 18px 20px; line-height: 1.7; color: var(--text); }
.editor-wrap.short .ql-editor { min-height: 180px; }
.editor-wrap .ql-editor.ql-blank::before { color: var(--text-3); font-style: normal; left: 20px; }
.editor-wrap .ql-editor h1, .editor-wrap .ql-editor h2, .editor-wrap .ql-editor h3 { margin: 0.9em 0 0.35em; font-weight: 750; }
.editor-wrap .ql-editor .ql-code-block-container { background: var(--code-bg); color: var(--text); border-radius: 10px; padding: 12px 14px; font: 13.5px/1.6 var(--font-mono); border: 1px solid var(--line-soft); }
.editor-wrap .ql-editor img { border-radius: 8px; max-height: 480px; }
.editor-wrap .ql-editor blockquote { border-left: 3px solid var(--line); color: var(--text-2); }
.editor-wrap .ql-editor li[data-list]::before { color: var(--ember); }
.editor-wrap .ql-snow .ql-stroke { stroke: var(--text-2); }
.editor-wrap .ql-snow .ql-fill { fill: var(--text-2); }
.editor-wrap .ql-snow .ql-picker { color: var(--text-2); }
.editor-wrap .ql-snow button:hover .ql-stroke, .editor-wrap .ql-snow button.ql-active .ql-stroke,
.editor-wrap .ql-snow .ql-picker-label:hover .ql-stroke, .editor-wrap .ql-snow .ql-picker-label.ql-active .ql-stroke { stroke: var(--ember); }
.editor-wrap .ql-snow button:hover .ql-fill, .editor-wrap .ql-snow button.ql-active .ql-fill { fill: var(--ember); }
.editor-wrap .ql-snow .ql-picker-label:hover, .editor-wrap .ql-snow .ql-picker-label.ql-active,
.editor-wrap .ql-snow .ql-picker-item:hover, .editor-wrap .ql-snow .ql-picker-item.ql-selected { color: var(--ember); }
.editor-wrap .ql-snow .ql-picker-options { background: var(--surface-2); border-color: var(--line) !important; border-radius: 8px; box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5); }
.editor-wrap .ql-snow .ql-tooltip {
  background: var(--surface-3); border: 1px solid var(--line); color: var(--text); border-radius: 10px;
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5); z-index: 5;
}
.editor-wrap .ql-snow .ql-tooltip input[type=text] { background: var(--surface); border: 1px solid var(--line); color: var(--text); border-radius: 6px; height: 30px; }
.editor-wrap .ql-snow .ql-tooltip a.ql-action, .editor-wrap .ql-snow .ql-tooltip a.ql-remove, .editor-wrap .ql-snow .ql-tooltip a.ql-preview { color: var(--ember); }
.editor-status { color: var(--text-3); font-size: 13px; }

/* ------------------------------------------------------------ team */
.team-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.member { padding: 20px; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; position: relative; overflow: hidden; }
.member::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 84px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--uc) 22%, transparent), transparent);
}
.member .bust { position: relative; height: 108px; image-rendering: pixelated; filter: drop-shadow(0 8px 14px rgba(0, 0, 0, 0.35)); margin-bottom: 6px; }
.member h3 { margin: 4px 0 0; font-size: 18px; font-weight: 750; }
.member .mc { color: var(--text-3); font-size: 13.5px; font-family: var(--font-mono); }
.member .stats { display: flex; gap: 18px; margin-top: 12px; font-size: 13px; color: var(--text-3); }
.member .stats b { display: block; font-size: 18px; color: var(--text); font-variant-numeric: tabular-nums; }
.member .row-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; margin-top: 14px; }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.swatch {
  width: 30px; height: 30px; border-radius: 8px; border: 2px solid transparent; cursor: pointer; padding: 0;
  background: var(--c); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15);
}
.swatch.on { border-color: var(--text); }
.swatch-custom { width: 34px; height: 34px; padding: 0; border: 1px solid var(--line); border-radius: 8px; background: none; cursor: pointer; }
.invite-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line-soft); background: var(--surface); }
.invite-row .grow { flex: 1; min-width: 0; }
.invite-row small { color: var(--text-3); }
.link-box {
  display: flex; gap: 8px; align-items: center; padding: 10px 12px; border-radius: 10px;
  background: var(--code-bg); border: 1px solid var(--line-soft); font: 13px/1.4 var(--font-mono); overflow-wrap: anywhere;
}
.link-box span { flex: 1; min-width: 0; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }

/* ------------------------------------------------------------ activity */
.feed-day { margin-bottom: 26px; }
.feed { display: flex; flex-direction: column; }
.feed-item { display: flex; gap: 12px; padding: 11px 4px; border-bottom: 1px solid var(--line-soft); align-items: flex-start; }
.feed-item:last-child { border-bottom: 0; }
.feed-item .ftext { flex: 1; min-width: 0; font-size: 15px; line-height: 1.5; }
.feed-item .ftext a { color: var(--text); font-weight: 650; }
.feed-item .ftext a:hover { color: var(--ember); }
.feed-item .ftext .quote { display: block; margin-top: 3px; color: var(--text-3); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed-item time { color: var(--text-3); font-size: 12.5px; white-space: nowrap; flex: none; padding-top: 2px; }
.feed-icon { width: 28px; height: 28px; flex: none; display: grid; place-items: center; border-radius: 7px; background: var(--surface-2); color: var(--ember); }
.feed-icon svg { width: 15px; height: 15px; }
.mini-feed .feed-item { padding: 8px 0; font-size: 14px; }
.mini-feed .feed-item .ftext { font-size: 14px; }

/* ------------------------------------------------------------ auth */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 420px; padding: 32px 30px 26px; }
.auth-brand { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-bottom: 24px; text-align: center; }
.auth-brand svg { width: 52px; height: auto; filter: drop-shadow(0 0 22px rgba(228, 138, 78, 0.35)); animation: flicker 3.2s ease-in-out infinite; }
.auth-brand .brand-name { font-size: 30px; }
.auth-brand p { margin: 0; color: var(--text-3); font-size: 14px; }
.auth-foot { margin-top: 18px; text-align: center; color: var(--text-3); font-size: 13px; }
.welcome-head { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; padding: 12px; border-radius: 12px; background: var(--surface-2); }

/* ------------------------------------------------------------ misc */
.empty { padding: 46px 20px; text-align: center; color: var(--text-3); }
.empty .pix { display: inline-grid; grid-template-columns: repeat(3, 8px); gap: 3px; margin-bottom: 14px; opacity: 0.7; }
.empty .pix i { width: 8px; height: 8px; background: var(--line); }
.empty .pix i:nth-child(5) { background: var(--ember); box-shadow: 0 0 12px var(--glow); }
.empty b { display: block; color: var(--text-2); font-size: 16px; margin-bottom: 4px; }
.muted { color: var(--text-3); }
.small { font-size: 13px; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.mt { margin-top: 18px; }
.mb { margin-bottom: 18px; }
.loading-line { height: 2px; background: linear-gradient(90deg, transparent, var(--ember), transparent); background-size: 200% 100%; animation: slide 1.1s linear infinite; border-radius: 2px; }
.skeleton { background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%); background-size: 200% 100%; animation: slide 1.4s linear infinite; border-radius: var(--r-lg); }
.more { display: flex; justify-content: center; margin-top: 18px; }
.menu-pop {
  position: absolute; z-index: 30; min-width: 190px; padding: 6px; border-radius: 12px;
  background: var(--surface-2); border: 1px solid var(--line); box-shadow: 0 18px 40px -14px rgba(0, 0, 0, 0.6);
  animation: rise 0.14s var(--ease);
}
.menu-pop button, .menu-pop a {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: 8px;
  background: none; color: var(--text); font-size: 14px; font-weight: 500; text-align: left; cursor: pointer;
}
.menu-pop button:hover, .menu-pop a:hover { background: var(--surface-3); color: var(--text); }
.menu-pop svg { width: 16px; height: 16px; color: var(--text-3); }
.menu-pop .danger { color: var(--danger); }
.rel { position: relative; }
kbd { font: 11.5px var(--font-mono); padding: 1px 5px; border-radius: 4px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text-2); }

@keyframes flicker {
  0%, 100% { opacity: 1; transform: translateY(0) scale(1); }
  45% { opacity: 0.88; transform: translateY(-0.5px) scale(0.995); }
  70% { opacity: 0.96; }
}
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
@keyframes slide { from { background-position: 200% 0; } to { background-position: -200% 0; } }

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

/* ------------------------------------------------------------ responsive */
@media (max-width: 1100px) {
  .detail-grid { grid-template-columns: minmax(0, 1fr); }
  .detail-grid .d-main, .detail-grid .d-disc, .side-stack { grid-column: 1; grid-row: auto; }
  .detail-grid .d-main { order: 1; }
  .side-stack { order: 2; }
  .detail-grid .d-disc { order: 3; }
  .side-stack { position: static; margin-top: 18px; }
}

@media (max-width: 860px) {
  .shell { flex-direction: column; }
  .sidebar { display: none; }
  .topbar {
    display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 20;
    padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
    background: color-mix(in srgb, var(--sidebar) 92%, transparent);
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line-soft);
  }
  .topbar .brand { padding: 0; }
  .topbar .brand svg { width: 24px; }
  .topbar .brand-name { font-size: 18px; }
  .topbar .grow { flex: 1; }
  .tabbar {
    display: flex; position: fixed; z-index: 20; left: 0; right: 0; bottom: 0;
    padding: 6px 6px max(6px, env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--sidebar) 94%, transparent);
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid var(--line-soft);
  }
  .tabbar a {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0 4px;
    color: var(--text-3); font-size: 11px; font-weight: 600; border-radius: 10px; position: relative;
  }
  .tabbar a svg { width: 21px; height: 21px; }
  .tabbar a.active { color: var(--ember); }
  .tabbar a.active::before { content: ""; position: absolute; top: -6px; width: 18px; height: 3px; background: var(--ember); box-shadow: 0 0 10px var(--glow); }
  .tabbar .dot { position: absolute; top: 4px; right: calc(50% - 16px); width: 6px; height: 6px; background: var(--ember); }
  .page, .page.narrow, .page.wide { padding: 20px 16px 100px; }
  .page-head h1 { font-size: 26px; }
  .detail-head h1, .doc-view-head h1 { font-size: 25px; }
  .idea-card { padding: 14px 14px 13px 6px; gap: 8px; }
  .idea-card h3 { font-size: 16px; }
  .vote { width: 38px; }
  .masonry { columns: 2 150px; column-gap: 8px; }
  .tile { margin-bottom: 8px; border-radius: 10px; }
  .tile .cap { opacity: 1; transform: none; font-size: 12px; padding: 22px 8px 7px; }
  .lb-stage { padding: 0 8px; }
  .lb-nav { top: auto; bottom: 8px; margin-top: 0; }
  .two-col { grid-template-columns: 1fr; }
  .toasts { bottom: 84px; right: 12px; left: 12px; max-width: none; }
  .modal-wrap { place-items: end center; padding: 0; }
  .modal { max-width: none; border-radius: 18px 18px 0 0; max-height: 92vh; padding-bottom: max(18px, env(safe-area-inset-bottom)); }
  .search { min-width: 100%; }
  .editor-wrap .ql-editor { padding: 14px; }
  .replies { margin-left: 8px; padding-left: 12px; }
  /* floating action button, above the tab bar */
  .fab {
    display: grid; place-items: center; position: fixed; z-index: 21;
    right: 16px; bottom: calc(76px + env(safe-area-inset-bottom));
    width: 56px; height: 56px; border-radius: 16px;
    background: var(--ember); color: var(--ember-ink);
    box-shadow: 0 10px 28px -8px var(--glow), 0 2px 6px rgba(0, 0, 0, 0.35);
    transition: transform 0.15s var(--ease);
  }
  .fab:active { transform: scale(0.94); }
  .fab:hover { color: var(--ember-ink); }
  .fab svg { width: 26px; height: 26px; }
  body.typing .tabbar, body.typing .fab { display: none; }

  /* no iOS zoom-on-focus: inputs must be 16px+ */
  .input, .select, .select.sm, textarea.input, .editor-wrap .ql-editor, .comment textarea { font-size: 16px; }
  .select.sm { height: 40px; background-position: calc(100% - 17px) 17px, calc(100% - 12px) 17px; }

  /* bigger tap targets */
  .vote button { width: 40px; height: 34px; }
  .vote.row button { width: 38px; height: 34px; }
  .chip { height: 36px; padding: 0 14px; font-size: 14px; }
  .seg button { height: 34px; }
  .linkish { padding: 6px 0; font-size: 14px; }
  .btn.xs { height: 34px; padding: 0 11px; font-size: 13.5px; }
  .btn.xs.icon { width: 34px; }

  /* filters: tags scroll sideways instead of stacking four rows deep */
  .toolbar .chips, .doc-filters .chips {
    flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
    margin: 0 -16px; padding: 0 16px 2px;
  }
  .toolbar .chips::-webkit-scrollbar { display: none; }
  .toolbar .chip { flex: none; }
  .toolbar-row > .select.sm { flex: 1; min-width: 0; width: auto !important; }
  .toolbar-row > .seg { width: 100%; }
  .toolbar-row > .seg button { flex: 1; justify-content: center; }

  /* editor toolbar sticks under the top bar */
  .editor-wrap .ql-toolbar.ql-snow { top: calc(max(10px, env(safe-area-inset-top)) + 51px); }
  .editor-wrap { overflow: visible; }
  .editor-wrap .ql-toolbar.ql-snow { border-radius: 14px 14px 0 0; }

  .page-head { margin-bottom: 16px; }
  .page-head p { font-size: 14px; }
  .install-hint + .route .page { padding-top: 14px; }
  .page-head .actions.fab-covered { display: none; }
  .doc-row { gap: 10px; padding: 10px 12px; }
  .doc-row .fside .name, .file-row .fside .name { display: none; }
  .detail-bar .grow { display: none; }
  .page-head .actions { width: 100%; }
  .page-head .actions .btn { flex: 1; }
}
