/* Voice Fortress Support Console. One family, one accent, hairlines instead of boxes. */
:root {
  --ground: #f3f6f4; --surface: #ffffff; --sunk: #edf2ef;
  --ink: #17262d; --ink-2: #41545b; --ink-3: #5a6f76;
  --line: #dce4df; --line-strong: #c3cfcb; --control: #7b8f8b;
  --accent: #0f6b78; --accent-hover: #0b5661; --accent-ink: #ffffff; --accent-soft: #dff0f1;
  --warn: #7d4a00; --warn-soft: #fcf0d9; --bad: #a3271f; --bad-soft: #fdecea; --ok: #1b6436; --ok-soft: #e4f3e9;
  --rail: #142930; --rail-ink: #e4eeee; --rail-muted: #a3babf; --rail-on: #21434d; --signal: #8ed0d9;
  --shadow: 0 1px 2px rgb(20 41 48 / .06), 0 8px 24px -12px rgb(20 41 48 / .18);
  --sans: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
  --r: 8px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #0f1c21; --surface: #16272e; --sunk: #1b3038;
    --ink: #f2f6f6; --ink-2: #c6d8db; --ink-3: #98b0b6;
    --line: #253a42; --line-strong: #36525c; --control: #6b8893;
    --accent: #8ed0d9; --accent-hover: #a9dde4; --accent-ink: #0b1e24; --accent-soft: #1b3a43;
    --warn: #f0b45a; --warn-soft: #382a10; --bad: #f29186; --bad-soft: #3a1c19; --ok: #86d5a1; --ok-soft: #152d20;
    --rail: #0b1519; --rail-on: #1a343d;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 10px 28px -14px rgb(0 0 0 / .6);
  }
}
:root[data-theme="dark"] {
  --ground: #0f1c21; --surface: #16272e; --sunk: #1b3038;
  --ink: #f2f6f6; --ink-2: #c6d8db; --ink-3: #98b0b6;
  --line: #253a42; --line-strong: #36525c; --control: #6b8893;
  --accent: #8ed0d9; --accent-hover: #a9dde4; --accent-ink: #0b1e24; --accent-soft: #1b3a43;
  --warn: #f0b45a; --warn-soft: #382a10; --bad: #f29186; --bad-soft: #3a1c19; --ok: #86d5a1; --ok-soft: #152d20;
  --rail: #0b1519; --rail-on: #1a343d;
  --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 10px 28px -14px rgb(0 0 0 / .6);
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
*, *::before, *::after { box-sizing: border-box; }
html { scrollbar-color: var(--line-strong) transparent; }
body { margin: 0; background: var(--ground); color: var(--ink); font: 14px/1.5 var(--sans); font-variant-numeric: tabular-nums; -webkit-text-size-adjust: 100%; }
::selection { background: var(--accent); color: var(--accent-ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 20px; line-height: 1.3; font-weight: 650; letter-spacing: -0.01em; text-wrap: balance; }
h2 { font-size: 13px; font-weight: 650; color: var(--ink-2); }
a { color: var(--accent); text-underline-offset: 3px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; border-radius: var(--r); z-index: 10; }
.skip:focus { left: 8px; }

/* ---------------------------------------------------------------- shell */
.app { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; }
.rail { background: var(--rail); color: var(--rail-ink); display: flex; flex-direction: column; padding: 20px 12px 16px; position: sticky; top: 0; height: 100vh; height: 100dvh; }
.brand { font-weight: 650; font-size: 15px; padding: 0 10px 20px; letter-spacing: -0.01em; }
.brand span { color: var(--rail-muted); font-weight: 400; }
#nav { display: flex; flex-direction: column; gap: 2px; }
#nav a { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; border-radius: 6px; color: var(--rail-muted); text-decoration: none; transition: background .15s, color .15s; }
#nav a:hover { color: var(--rail-ink); background: rgb(255 255 255 / .05); }
#nav a[aria-current="page"] { background: var(--rail-on); color: #fff; font-weight: 600; }
#nav a:focus-visible { outline-color: var(--signal); }
.count { min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--signal); color: #0b1e24; font-size: 12px; font-weight: 650; text-align: center; line-height: 20px; }
.count:empty { display: none; }
.rail-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 10px; font-size: 12px; color: var(--rail-muted); }
.rail-foot .link { color: var(--rail-muted); }
.rail-foot .link:hover { color: #fff; }
main { padding: 28px 32px 96px; min-width: 0; }
main:focus { outline: none; }
.page { max-width: 880px; margin: 0 auto; }
.page.wide { max-width: 1120px; }
.head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 4px; }
.sub { color: var(--ink-3); margin-bottom: 20px; max-width: 68ch; }
.updated { color: var(--ink-3); font-size: 12px; display: flex; gap: 10px; align-items: center; }

/* ---------------------------------------------------------------- controls */
button { font: inherit; color: inherit; cursor: pointer; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 0 14px; border-radius: var(--r); border: 1px solid var(--control); background: var(--surface); color: var(--ink); font-weight: 550; transition: background .15s, border-color .15s, color .15s; }
.btn:hover { border-color: var(--ink-3); }
.btn:active { background: var(--ground); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 650; }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger { color: var(--bad); }
.btn.danger:hover { border-color: var(--bad); }
.btn[disabled], .btn[aria-busy="true"] { opacity: .55; cursor: default; pointer-events: none; }
.link { background: none; border: none; padding: 0; color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.link:hover { color: var(--accent-hover); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
select, textarea { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--control); border-radius: var(--r); caret-color: var(--accent); }
select { min-height: 36px; padding: 0 8px; max-width: 100%; }
.confirm { display: inline-flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 8px 10px; border-radius: var(--r); background: var(--warn-soft); color: var(--warn); }
.confirm .btn { min-height: 30px; }

.tag { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 550; background: var(--sunk); color: var(--ink-2); border: 1px solid var(--line); white-space: nowrap; }
.tag.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.tag.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.tag.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.note { padding: 10px 14px; border-radius: var(--r); background: var(--accent-soft); color: var(--ink); margin: 0 0 16px; }
.note.warn { background: var(--warn-soft); color: var(--warn); }
.note.bad { background: var(--bad-soft); color: var(--bad); }
.note strong { font-weight: 650; }
.note ul { margin: 4px 0 0 18px; padding: 0; }
.muted { color: var(--ink-3); }
.mono { font-family: var(--mono); font-size: 12px; }

/* ---------------------------------------------------------------- lists */
.rows { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.row { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 2fr) auto; gap: 4px 20px; align-items: center; width: 100%; padding: 12px 16px; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left; transition: background .15s; }
.row:last-child { border-bottom: 0; }
.row:hover { background: var(--sunk); }
.row:focus-visible { outline-offset: -2px; }
.row .who { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .what { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .what b { color: var(--ink); font-weight: 600; }
.row .todo { display: flex; gap: 8px; align-items: center; justify-content: flex-end; white-space: nowrap; color: var(--ink-3); font-size: 13px; }
.row .todo strong { color: var(--ink); font-weight: 600; }
.empty { padding: 40px 24px; text-align: center; color: var(--ink-3); background: var(--surface); border: 1px dashed var(--line-strong); border-radius: 12px; }
.empty strong { display: block; color: var(--ink); font-size: 15px; margin-bottom: 4px; }
.empty p { max-width: 52ch; margin: 0 auto; }
.skeleton { height: 46px; border-bottom: 1px solid var(--line); background: linear-gradient(90deg, transparent, var(--sunk), transparent) 0 0 / 200% 100%; animation: sheen 1.2s linear infinite; }
@keyframes sheen { to { background-position: -200% 0; } }
.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 16px; margin: 0; }
.facts dt { color: var(--ink-3); }
.facts dd { margin: 0; }
.stats { display: flex; flex-wrap: wrap; gap: 6px 24px; margin-bottom: 16px; color: var(--ink-3); }
.stats b { color: var(--ink); font-weight: 650; }
section + section { margin-top: 28px; }
section > h2 { margin-bottom: 8px; }

/* ---------------------------------------------------------------- case */
.back { display: inline-block; margin-bottom: 12px; color: var(--ink-3); text-decoration: none; }
.back:hover { color: var(--ink); }
.meta { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; color: var(--ink-3); margin: 6px 0 20px; }
.case { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 32px; align-items: start; }
.msg { padding: 0 0 20px; }
.msg-head { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; margin-bottom: 6px; }
.msg-head b { font-weight: 650; }
.msg-head time, .msg-head .muted { font-size: 12px; }
.letter { white-space: pre-wrap; overflow-wrap: anywhere; font: 15px/1.6 var(--sans); margin: 0; }
.msg.in .letter { padding: 12px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.msg.out .letter { padding: 12px 16px; background: var(--accent-soft); border-radius: 12px; }
.msg .subject { font-weight: 600; margin-bottom: 6px; }

.sheet { background: var(--surface); border: 1px solid var(--line-strong); border-radius: 12px; box-shadow: var(--shadow); }
.sheet-head { padding: 12px 20px; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 2px 12px; font-size: 13px; margin: 0; }
.sheet-head dt { color: var(--ink-3); }
.sheet-head dd { margin: 0; overflow-wrap: anywhere; }
.sheet-body { padding: 18px 20px 6px; }
.sheet-body .fixed { white-space: pre-wrap; font: 15px/1.6 var(--sans); color: var(--ink-2); margin: 0 0 12px; }
.sheet-body textarea { display: block; width: 100%; min-height: 120px; padding: 10px 12px; margin: 0 0 12px; font: 15px/1.6 var(--sans); resize: vertical; border-color: var(--control); background: var(--ground); transition: border-color .15s, background .15s; }
.sheet-body textarea:hover { border-color: var(--ink-3); }
.sheet-body textarea:focus { background: var(--surface); border-color: var(--accent); outline: none; }
.sheet-foot { padding: 12px 20px 16px; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; justify-content: space-between; }
.sheet-foot .hint { color: var(--ink-3); font-size: 13px; flex: 1 1 220px; }
.sheet-title { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 8px 0 8px; }

.side { position: sticky; top: 28px; display: grid; gap: 24px; }
.side h2 { margin-bottom: 8px; }
.due-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.due-list li { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.due-list small { display: block; color: var(--ink-3); font-size: 12px; }
details { border-top: 1px solid var(--line); }
details:last-of-type { border-bottom: 1px solid var(--line); }
summary { cursor: pointer; padding: 10px 0; font-weight: 550; color: var(--ink-2); }
summary:hover { color: var(--ink); }
details > div { padding: 0 0 14px; display: grid; gap: 10px; justify-items: start; }
details p { color: var(--ink-3); font-size: 13px; }
.quote { white-space: pre-wrap; overflow-wrap: anywhere; font: 13px/1.5 var(--sans); background: var(--ground); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; margin: 0; max-height: 320px; overflow: auto; width: 100%; }
.history { width: 100%; border-collapse: collapse; font-size: 12px; }
.history td { padding: 4px 8px 4px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.history td:first-child { white-space: nowrap; color: var(--ink-3); }

/* ---------------------------------------------------------------- settings */
.setting { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 20px; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.setting:last-child { border-bottom: 0; }
.setting b { font-weight: 600; }
.setting p { color: var(--ink-3); font-size: 13px; max-width: 62ch; }
.setting .confirm { grid-column: 1 / -1; justify-self: start; }
.setting .ctl { display: flex; align-items: center; }
.switch { position: relative; width: 44px; height: 24px; border-radius: 999px; border: 1px solid var(--control); background: var(--sunk); padding: 0; transition: background .15s, border-color .15s; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: var(--ink-3); transition: transform .15s cubic-bezier(.2, .8, .2, 1), background .15s; }
.switch[aria-checked="true"] { background: var(--accent); border-color: var(--accent); }
.switch[aria-checked="true"]::after { transform: translateX(20px); background: var(--accent-ink); }
.seg { display: inline-flex; border: 1px solid var(--control); border-radius: var(--r); overflow: hidden; }
.seg button { min-height: 34px; padding: 0 12px; border: 0; border-right: 1px solid var(--line); background: var(--surface); color: var(--ink-2); }
.seg button:last-child { border-right: 0; }
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--accent-soft); color: var(--ink); font-weight: 600; }
.switch-state { font-size: 12px; color: var(--ink-3); margin-right: 8px; min-width: 2ch; text-align: right; }
.group-note { color: var(--ink-3); margin: 0 0 8px; max-width: 68ch; }

#toast { position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 12px); background: var(--ink); color: var(--ground); padding: 10px 16px; border-radius: var(--r); box-shadow: var(--shadow); opacity: 0; transition: opacity .2s, transform .2s cubic-bezier(.2, .8, .2, 1); pointer-events: none; max-width: min(90vw, 520px); z-index: 20; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
[hidden] { display: none !important; }

/* ---------------------------------------------------------------- narrow */
@media (max-width: 1100px) {
  .case { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; }
  .row { grid-template-columns: minmax(0, 1fr) auto; }
  .row .what { grid-column: 1 / -1; grid-row: 2; }
}
@media (max-width: 760px) {
  .app { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .rail { position: sticky; top: 0; z-index: 5; height: auto; flex-direction: row; align-items: center; padding: 8px 12px; gap: 8px; }
  .brand { padding: 0; font-size: 14px; white-space: nowrap; }
  .brand span { display: none; }
  #nav { flex-direction: row; overflow-x: auto; flex: 1; scrollbar-width: none; }
  #nav a { white-space: nowrap; padding: 8px 10px; }
  .rail-foot { margin: 0; padding: 0; }
  .rail-foot .mode { display: none; }
  main { padding: 20px 16px 96px; }
  .row { grid-template-columns: minmax(0, 1fr) auto; }
  .row .what { grid-column: 1 / -1; grid-row: 2; }
  .sheet-body, .sheet-head, .sheet-foot { padding-left: 14px; padding-right: 14px; }
  .sheet-foot .btn { flex: 1 1 auto; }
  .btn { min-height: 44px; }
  .switch { width: 52px; height: 30px; }
  .switch::after { width: 24px; height: 24px; }
  .switch[aria-checked="true"]::after { transform: translateX(22px); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
