/* SupportDesk. Warm paper by day, turned soil by night. Colour only where it means something. */
@font-face { font-family: "Instrument Sans"; src: url("fonts/instrument-sans.woff2") format("woff2"); font-weight: 400 700; font-display: swap; }
@font-face { font-family: "Fraunces"; src: url("fonts/fraunces.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }

:root {
  color-scheme: light;
  --bg: #f4efe4;
  --rail: #efe9db;
  --surface: #fffdf8;
  --surface-2: #f8f4ea;
  --surface-3: #efe9db;
  --hover: rgba(70, 55, 30, .055);
  --ink: #1c1812;
  --ink-2: #544c3f;
  --ink-3: #686051;
  --line: #e5dece;
  --line-2: #d4cab5;
  --accent: #c94f18;
  --accent-hover: #b34412;
  --on-accent: #ffffff;
  --accent-soft: #fbe9dc;
  --focus: #c94f18;
  --note: #fff6d6;
  --note-2: #fdefb8;
  --note-line: #e3c357;
  --note-ink: #5e4905;
  --red: #b3261e;
  --red-soft: #fbe8e5;
  --amber: #8f5a00;
  --amber-soft: #fbefd5;
  --green: #2c7445;
  --green-soft: #e3f1e6;
  --blue: #3b6ea5;
  --plum: #7a5c99;
  --series-in: #c94f18;
  --series-out: #3b6ea5;
  --heat-0: #f4efe4; --heat-1: #fbe0cc; --heat-2: #f6bb94; --heat-3: #ea9160; --heat-4: #d76a33; --heat-5: #ad4310;
  --shadow: 0 12px 32px rgba(45, 34, 15, .16), 0 1px 3px rgba(45, 34, 15, .1);
  --sans: "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --serif: "Fraunces", Georgia, serif;
  --radius: 8px;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #120f0b;
  --rail: #0f0d0a;
  --surface: #1a1610;
  --surface-2: #211c15;
  --surface-3: #2a241b;
  --hover: rgba(242, 234, 219, .06);
  --ink: #f2eadb;
  --ink-2: #c9bda8;
  --ink-3: #9d917b;
  --line: #2c261d;
  --line-2: #3f3729;
  --accent: #ff9a4a;
  --accent-hover: #ffad6b;
  --on-accent: #1a1006;
  --accent-soft: #3a2413;
  --focus: #ff9a4a;
  --note: #2c2410;
  --note-2: #372d13;
  --note-line: #7d6522;
  --note-ink: #f0d98a;
  --red: #ff8a80;
  --red-soft: #3a1a17;
  --amber: #f0b961;
  --amber-soft: #33260f;
  --green: #7fcb95;
  --green-soft: #17291c;
  --blue: #7fa8d8;
  --plum: #b79cd6;
  --series-in: #d4732b;
  --series-out: #4f8ddc;
  --heat-0: #211c15; --heat-1: #41291a; --heat-2: #6b3d1e; --heat-3: #a05a25; --heat-4: #d47a30; --heat-5: #ffa35a;
  --shadow: 0 12px 32px rgba(0, 0, 0, .55), 0 1px 3px rgba(0, 0, 0, .5);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 14px/1.45 var(--sans); -webkit-font-smoothing: antialiased; }
h1, h2, h3, p, ul, ol, dl, dd { margin: 0; padding: 0; }
ul, ol { list-style: none; }
button, input, textarea, select { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
button:disabled { cursor: default; }
a { color: inherit; }
code, kbd { font: 12.5px ui-monospace, Consolas, Menlo, monospace; }
kbd { padding: 1px 6px; background: var(--surface-3); border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 4px; }
code { padding: 1px 5px; background: var(--surface-3); border-radius: 4px; }
mark { background: var(--amber-soft); color: inherit; border-radius: 2px; padding: 0 1px; }
fieldset.plain { border: 0; margin: 0; padding: 0; min-width: 0; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.muted { color: var(--ink-3); }
.icon { flex: none; display: block; }
[hidden] { display: none !important; }

/* ---- Frame ---- */
.app { height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
.app-body { flex: 1; min-height: 0; display: flex; }
.app-main { flex: 1; min-width: 0; min-height: 0; }
.boot { height: 100dvh; display: flex; flex-direction: column; gap: 14px; align-items: center; justify-content: center; }
.demo-banner { flex: none; display: flex; gap: 14px; align-items: center; justify-content: center; padding: 7px 16px; background: var(--ink); color: var(--surface); font-size: 13px; text-align: center; }
.demo-banner a { color: inherit; font-weight: 600; white-space: nowrap; }
.demo-short { display: none; }
.mail-banner { flex: none; display: flex; gap: 14px; align-items: center; justify-content: center; padding: 8px 16px; background: var(--red-soft); color: var(--red); border-bottom: 1px solid var(--red); font-size: 13px; text-align: center; }
.mail-banner a { color: inherit; font-weight: 600; white-space: nowrap; }

/* ---- Rail ---- */
.rail { width: 216px; flex: none; display: flex; flex-direction: column; background: var(--rail); border-right: 1px solid var(--line); padding: 10px 8px 8px; overflow-y: auto; }
.rail-top { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 2px 2px 10px 8px; }
.rail-brand { display: flex; align-items: center; gap: 8px; font-weight: 600; min-width: 0; }
.rail-brand span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.logo { color: var(--accent); flex: none; }
.rail-group { display: flex; flex-direction: column; gap: 1px; margin-bottom: 14px; }
.rail-heading { font-size: 11.5px; font-weight: 600; color: var(--ink-3); padding: 2px 8px 4px; }
.rail-row { position: relative; display: flex; align-items: center; border-radius: 6px; }
.rail-row:hover { background: var(--hover); }
.rail-row.is-active { background: var(--surface); box-shadow: 0 0 0 1px var(--line); }
.rail-link { flex: 1; min-width: 0; display: flex; align-items: center; gap: 9px; padding: 6px 8px; color: var(--ink-2); text-align: left; border-radius: 6px; }
.rail-row.is-active .rail-link { color: var(--ink); font-weight: 600; }
.rail-row.is-active .icon { color: var(--accent); }
.rail-label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rail-count { font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.rail-row.is-active .rail-count { color: var(--ink-2); }
.rail-remove { position: absolute; right: 4px; padding: 4px; border-radius: 4px; color: var(--ink-3); display: none; }
.rail-row:hover .rail-remove { display: block; }
.rail-remove:hover { background: var(--hover); color: var(--ink); }
.rail-spacer { flex: 1; min-height: 12px; }
.rail-foot { border-top: 1px solid var(--line); padding-top: 6px; }
.rail-account { display: flex; align-items: center; gap: 8px; width: 100%; padding: 5px 6px; border-radius: 6px; text-align: left; }
.rail-account:hover { background: var(--hover); }
.rail-me { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; color: var(--ink-2); }
.rail-offline { display: block; padding: 3px 8px 0; font-size: 12px; color: var(--amber); }
.icon-btn.rail-toggle, .icon-btn.t-back { display: none; }
.rail-scrim { display: none; }
.rail .menu-wrap { display: block; }
.rail .menu { bottom: calc(100% + 4px); top: auto; }

.checklist { margin: 2px 2px 12px; padding: 9px 10px 8px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); font-size: 12.5px; }
.checklist-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 5px; }
.checklist li button { display: flex; gap: 7px; align-items: center; padding: 3px 0; color: var(--ink-2); text-align: left; width: 100%; }
.checklist li button:hover { color: var(--ink); }
.checklist li.is-done button { color: var(--ink-3); text-decoration: line-through; }
.checklist-mark { width: 14px; height: 14px; flex: none; border: 1.5px solid var(--line-2); border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.is-done .checklist-mark { background: var(--green); border-color: var(--green); color: var(--surface); }

/* ---- Buttons ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: 7px; font-weight: 500; white-space: nowrap; text-decoration: none; border: 1px solid transparent; transition: background .1s; }
.btn:disabled { opacity: .5; }
.btn-primary { background: var(--accent); color: var(--on-accent); font-weight: 600; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-ghost { border-color: var(--line-2); background: transparent; color: var(--ink); }
.btn-ghost:hover:not(:disabled) { background: var(--hover); }
.btn-danger { color: var(--red); }
.btn-note { background: var(--note-line); color: #2c2204; font-weight: 600; }
.btn-destroy { background: var(--red); color: #fff; font-weight: 600; }
:root[data-theme="dark"] .btn-destroy { color: #2a0e0b; }
.side-forget { color: var(--ink-3); }
.btn-solve { border-color: var(--line-2); color: var(--ink); font-weight: 600; }
.btn-solve:hover { background: var(--green-soft); border-color: var(--green); color: var(--green); }
.btn-compact { height: 28px; padding: 0 8px; font-size: 13px; border-color: transparent; }
.btn-compact:hover:not(:disabled) { background: var(--hover); }
.btn-compact.btn-destroy { background: var(--red); color: #fff; font-weight: 600; }
:root[data-theme="dark"] .btn-destroy { color: #2a0e0b; }
.side-forget { color: var(--ink-3); }
.btn-solve { border-color: var(--line-2); padding: 0 10px; }
.btn-small { height: 26px; font-size: 12.5px; padding: 0 9px; }
.btn-block { width: 100%; height: 38px; }
.is-urgent { color: var(--red); font-weight: 600; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 6px; color: var(--ink-2); flex: none; }
.icon-btn:hover:not(:disabled) { background: var(--hover); color: var(--ink); }
.icon-btn:disabled { opacity: .35; }
.icon-btn.is-on { background: var(--surface-3); color: var(--ink); }
.icon-btn-small { width: 20px; height: 20px; }
.linkish { color: var(--ink-2); text-decoration: underline; text-decoration-color: var(--line-2); text-underline-offset: 2px; font-size: 12.5px; }
.linkish:hover { color: var(--ink); text-decoration-color: currentColor; }

/* ---- Menus ---- */
.menu-wrap { position: relative; display: inline-flex; }
.menu { position: absolute; top: calc(100% + 4px); z-index: 40; min-width: 170px; background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius); box-shadow: var(--shadow); padding: 4px; }
.menu-left { left: 0; }
.menu-right { right: 0; }
.menu-search { width: 100%; height: 30px; padding: 0 8px; margin-bottom: 4px; border: 0; border-bottom: 1px solid var(--line); background: transparent; }
.menu-search:focus-visible { outline: none; }
.menu-items { max-height: 280px; overflow-y: auto; outline: none; }
.menu-item { display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 8px; border-radius: 5px; text-align: left; font-size: 13.5px; }
.menu-item.is-active { background: var(--hover); }
.menu-item.is-danger { color: var(--red); }
.menu-icon { display: flex; flex: none; }
.menu-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-hint { font-size: 12px; color: var(--ink-3); white-space: nowrap; }
.menu-check { color: var(--accent); }
.menu-empty { padding: 8px; color: var(--ink-3); font-size: 13px; }

/* ---- Avatars and status ---- */
.avatar { display: inline-flex; align-items: center; justify-content: center; flex: none; border-radius: 50%; font-weight: 600; color: var(--ink); background: color-mix(in srgb, var(--h, #888) 30%, var(--surface)); }
.avatar-xs { width: 18px; height: 18px; font-size: 8.5px; }
.avatar-sm { width: 24px; height: 24px; font-size: 10px; }
.avatar-md { width: 30px; height: 30px; font-size: 11.5px; }
.avatar-lg { width: 40px; height: 40px; font-size: 14px; }
.avatar-empty { background: var(--surface-3); color: var(--ink-3); }
.hue-0 { --h: #d9612a; } .hue-1 { --h: #2f7f9e; } .hue-2 { --h: #7a5c99; } .hue-3 { --h: #3f8a58; } .hue-4 { --h: #b8862d; } .hue-5 { --h: #b34a6e; } .hue-6 { --h: #4a6fb5; } .hue-7 { --h: #6f7d3a; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; display: inline-block; }
.status-open { background: var(--accent); }
.status-waiting { background: var(--blue); }
.status-snoozed { background: var(--plum); }
.status-solved { background: var(--green); }
.status-spam, .status-merged { background: var(--ink-3); }
.status-pill { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 9px; font-size: 13px; font-weight: 500; }
.pill { font-size: 11.5px; padding: 1px 7px; border-radius: 10px; background: var(--surface-3); color: var(--ink-2); }

/* ---- Inbox: list ---- */
.inbox { height: 100%; display: flex; min-width: 0; }
.list-pane { width: 368px; flex: none; display: flex; flex-direction: column; min-height: 0; background: var(--surface); border-right: 1px solid var(--line); }
.list-head { display: flex; align-items: center; gap: 6px; padding: 10px 10px 4px; }
.search { position: relative; flex: 1; min-width: 0; display: flex; align-items: center; gap: 7px; height: 32px; padding: 0 9px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 7px; color: var(--ink-3); }
.search.is-focused, .search:focus-within { border-color: var(--line-2); background: var(--surface); }
.search input { flex: 1; min-width: 0; border: 0; background: none; color: var(--ink); height: 100%; }
.search input:focus-visible { outline: none; }
.search input::-webkit-search-cancel-button { display: none; }
.search-save { flex: none; }
.search-page { max-width: 340px; margin-top: 10px; }
.search-tips { position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 30; background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius); box-shadow: var(--shadow); padding: 4px; }
.search-tips button { display: flex; justify-content: space-between; gap: 10px; width: 100%; padding: 5px 7px; border-radius: 5px; font-size: 12.5px; color: var(--ink-3); }
.search-tips button:hover { background: var(--hover); }
.search-tips code { color: var(--ink); background: none; padding: 0; }
.list-title { display: flex; align-items: baseline; gap: 7px; padding: 8px 14px 6px; }
.list-title h1 { font-size: 15px; font-weight: 600; }
.list-count { font-size: 12.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.list-empty { padding: 44px 26px; text-align: center; color: var(--ink-3); display: flex; flex-direction: column; align-items: center; gap: 5px; }
.list-empty strong { color: var(--ink); font-weight: 600; }
.rows { flex: 1; overflow-y: auto; min-height: 0; border-top: 1px solid var(--line); }
.row { position: relative; border-bottom: 1px solid var(--line); }
.row:hover { background: var(--hover); }
.row.is-active { background: var(--surface-3); }
.row.is-active::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 2px; background: var(--ink); }
.row.is-selected { background: var(--accent-soft); }
.row-main { display: block; width: 100%; padding: 9px 12px 9px 14px; text-align: left; }
.row-main:focus-visible { outline-offset: -2px; }
.row-check { position: absolute; left: 0; top: 0; width: 26px; height: 32px; display: none; align-items: center; justify-content: center; z-index: 2; }
.row-check input { margin: 0; accent-color: var(--accent); }
.row:hover .row-check, .row.is-selected .row-check { display: flex; }
.row:hover .row-main, .row.is-selected .row-main { padding-left: 26px; }
.row-line { display: flex; align-items: center; gap: 6px; min-width: 0; }
.row-name { flex: 1; min-width: 0; font-size: 13px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 6px; }
.is-unread .row-name { color: var(--ink); font-weight: 600; }
.row-unread { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex: none; }
.row-time { font-size: 12px; color: var(--ink-3); flex: none; font-variant-numeric: tabular-nums; }
.row-subject { margin-top: 1px; }
.row-subject-text { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.is-unread .row-subject-text { font-weight: 500; }
.row-flag { color: var(--red); }
.row-line-3 { margin-top: 1px; min-height: 18px; }
.row-preview { flex: 1; min-width: 0; font-size: 12.5px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-typing { color: var(--green); font-style: normal; }
.row-viewer { width: 7px; height: 7px; border-radius: 50%; background: var(--green); flex: none; }
.row-sla { font-size: 11.5px; font-weight: 600; flex: none; }
.row-sla.is-over { color: var(--red); }
.row-sla.is-soon { color: var(--amber); }
.rows-more { padding: 12px; text-align: center; }
.bulk { display: flex; align-items: center; gap: 2px; padding: 5px 8px 5px 14px; min-height: 37px; background: var(--accent-soft); font-size: 13px; }
.bulk-count { font-weight: 600; margin-right: 6px; white-space: nowrap; }

/* ---- Ticket ---- */
.t-layout { flex: 1; min-width: 0; display: flex; }
.t-pane { position: relative; flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--bg); }
.t-empty { align-items: center; justify-content: center; color: var(--ink-3); }
.t-empty-inner { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.t-head { flex: none; background: var(--surface); border-bottom: 1px solid var(--line); padding: 8px 12px 6px 16px; }
.t-head-top { display: flex; align-items: center; gap: 8px; min-height: 30px; }
.t-num { font-size: 12.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; flex: none; }
.t-subject { flex: 1; min-width: 0; font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: text; }
.t-subject-input { flex: 1; min-width: 0; font-size: 16px; font-weight: 600; border: 0; border-bottom: 1px solid var(--line-2); background: none; padding: 1px 0; }
.t-subject-input:focus-visible { outline: none; border-bottom-color: var(--accent); }
.t-nav { display: flex; align-items: center; gap: 1px; flex: none; }
.t-nav-gap { width: 6px; }
.t-head-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 2px; margin-top: 4px; margin-left: -8px; }
.t-spacer { flex: 1; }
.sla { font-size: 12.5px; font-weight: 600; padding: 2px 8px; border-radius: 10px; color: var(--ink-2); background: var(--surface-3); margin: 0 3px; white-space: nowrap; }
.sla-soon { color: var(--amber); background: var(--amber-soft); }
.sla-over { color: var(--red); background: var(--red-soft); }
.tags { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-left: 4px; min-width: 0; }
.chip { display: inline-flex; align-items: center; gap: 3px; height: 22px; padding: 0 5px 0 8px; font-size: 12px; border-radius: 11px; background: var(--surface-3); color: var(--ink-2); white-space: nowrap; }
.chip button { display: flex; align-items: center; color: inherit; border-radius: 4px; }
.chip button:not(.chip-go) { opacity: .6; }
.chip button:not(.chip-go):hover { opacity: 1; }
.chip-add { padding: 0 8px 0 6px; background: none; border: 1px dashed var(--line-2); color: var(--ink-3); cursor: pointer; }
.chip-add:hover { color: var(--ink); border-color: var(--ink-3); }
.tag-add { position: relative; }
.tag-add input { width: 96px; height: 22px; font-size: 12px; padding: 0 8px; border: 1px solid var(--line-2); border-radius: 11px; background: var(--surface); }
.tag-options { position: absolute; top: calc(100% + 3px); left: 0; z-index: 30; min-width: 130px; background: var(--surface); border: 1px solid var(--line-2); border-radius: 6px; box-shadow: var(--shadow); padding: 3px; }
.tag-options button { display: block; width: 100%; padding: 4px 7px; border-radius: 4px; text-align: left; font-size: 12.5px; }
.tag-options button:hover { background: var(--hover); }
.presence-bar { flex: none; display: flex; align-items: center; gap: 7px; padding: 4px 18px; font-size: 12.5px; background: var(--green-soft); color: var(--green); }
.presence-bar.is-typing { font-weight: 600; }
.presence-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.presence-bar.is-typing .presence-dot { animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.merged-note { padding: 8px 18px; background: var(--surface-3); font-size: 13px; }

.t-thread { flex: 1; min-height: 0; overflow-y: auto; padding: 18px 18px 8px; overscroll-behavior: contain; }
.thread { max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; gap: 10px; }
.msg { display: flex; gap: 10px; }
.msg-main { flex: 1; min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px 12px; }
.msg-reply .msg-main { background: var(--surface-2); }
.msg-note .msg-main { background: var(--note); border-color: var(--note-line); }
.msg-head { display: flex; align-items: baseline; flex-wrap: wrap; column-gap: 8px; margin-bottom: 4px; font-size: 13px; }
.msg-head strong { font-weight: 600; }
.msg-head time { margin-left: auto; font-size: 12px; color: var(--ink-3); white-space: nowrap; }
.msg-label { font-size: 11.5px; color: var(--ink-3); }
.msg-label-auto { display: inline-flex; align-items: center; gap: 3px; }
.msg-note .msg-label { color: var(--note-ink); font-weight: 600; }
.send-state { font-size: 11.5px; color: var(--ink-3); }
.send-pending { color: var(--amber); }
.send-warn { color: var(--amber); font-weight: 600; }
.send-bad { color: var(--red); font-weight: 600; }
.msg-error { margin-bottom: 6px; padding: 5px 9px; font-size: 12.5px; border-radius: 5px; background: var(--red-soft); color: var(--red); }
.msg-tools { display: flex; gap: 12px; margin-top: 7px; }
.msg-quoted { margin: 8px 0 0; padding: 8px 10px; background: var(--surface-3); border-radius: 5px; font: 12.5px/1.5 var(--sans); color: var(--ink-2); white-space: pre-wrap; overflow-wrap: anywhere; max-height: 340px; overflow: auto; }
.msg-original { overflow-x: auto; }
.prose { font-size: 14.5px; line-height: 1.55; overflow-wrap: anywhere; }
.prose > * + * { margin-top: .62em; }
.prose a { color: var(--accent); }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose ul { list-style: disc; }
.prose ol { list-style: decimal; }
.prose blockquote { margin: 0; padding-left: 10px; border-left: 3px solid var(--line-2); color: var(--ink-2); }
.prose pre { padding: 8px 10px; background: var(--surface-3); border-radius: 5px; overflow-x: auto; }
.prose code { font-size: 12.5px; }
.prose img { max-width: 100%; height: auto; border-radius: 6px; border: 1px solid var(--line); }
.prose table { border-collapse: collapse; }
.prose td, .prose th { border: 1px solid var(--line); padding: 3px 7px; }
.event { display: flex; justify-content: center; gap: 8px; font-size: 12px; color: var(--ink-3); text-align: center; padding: 1px 0; }
.event strong { font-weight: 600; color: var(--ink-2); }
.attachments { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 9px; }
.attachment-image img { display: block; max-width: 220px; max-height: 160px; border-radius: 6px; border: 1px solid var(--line); }
.attachment-file { display: inline-flex; align-items: center; gap: 6px; padding: 5px 9px; border: 1px solid var(--line-2); border-radius: 6px; font-size: 12.5px; text-decoration: none; }
.attachment-file:hover { background: var(--hover); }
.attachment-file small { color: var(--ink-3); }
.new-pill { position: absolute; left: 50%; bottom: 150px; transform: translateX(-50%); z-index: 5; display: inline-flex; gap: 5px; align-items: center; padding: 5px 12px; font-size: 12.5px; font-weight: 600; background: var(--ink); color: var(--surface); border-radius: 14px; box-shadow: var(--shadow); }

/* ---- Composer ---- */
.composer { flex: none; margin: 0 auto 12px; width: calc(100% - 36px); max-width: 760px; background: var(--surface); border: 1px solid var(--line-2); border-radius: 10px; box-shadow: 0 1px 2px rgba(40, 30, 15, .05); transition: background .12s, border-color .12s; }
.composer:focus-within { border-color: var(--ink-3); }
.composer-note { background: var(--note); border-color: var(--note-line); }
.composer-note:focus-within { border-color: var(--note-line); box-shadow: 0 0 0 1px var(--note-line); }
.composer.is-dragging { outline: 2px dashed var(--accent); outline-offset: 2px; }
.composer-top { display: flex; align-items: center; gap: 10px; padding: 6px 8px 0 6px; flex-wrap: wrap; }
.seg { display: inline-flex; padding: 2px; background: var(--surface-3); border-radius: 7px; flex: none; }
.seg button { height: 24px; padding: 0 10px; border-radius: 5px; font-size: 12.5px; font-weight: 500; color: var(--ink-2); }
.seg button.is-on { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(40, 30, 15, .12); }
.composer-note .seg { background: var(--note-2); }
.composer-note .seg button.is-on { background: var(--note-line); color: #2c2204; }
.composer-to { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink-3); }
.composer-to-who { color: var(--ink); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.composer-cc-count { color: var(--ink-2); }
.composer-note-label { display: inline-flex; align-items: center; gap: 5px; color: var(--note-ink); font-weight: 500; }
.composer-cc { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; padding: 6px 10px 0; }
.composer-cc input { flex: 1; min-width: 120px; border: 0; background: none; font-size: 12.5px; height: 22px; }
.composer-cc input:focus-visible { outline: none; }
.composer-input { position: relative; }
.composer textarea { display: block; width: 100%; padding: 8px 12px 4px; border: 0; background: none; resize: none; font-size: 14.5px; line-height: 1.5; max-height: 42vh; }
.composer textarea:focus-visible { outline: none; }
.composer textarea::placeholder { color: var(--ink-3); }
.draft { margin: 2px 10px 8px; padding: 8px 10px 9px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; }
.draft-head { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink-2); font-weight: 500; }
.draft-head span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.draft-text { margin: 4px 0 7px; font-size: 13.5px; color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.suggest { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; padding: 2px 10px 6px 12px; font-size: 12.5px; color: var(--ink-3); }
.suggest-label { margin-right: 2px; }
.suggest-item { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; background: var(--surface-3); border-radius: 11px; color: var(--ink); max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.suggest-item:hover { background: var(--accent-soft); }
.composer-files { display: flex; flex-wrap: wrap; gap: 6px; padding: 2px 10px 6px; font-size: 12.5px; }
.composer-files li { display: inline-flex; align-items: center; gap: 4px; padding: 2px 3px 2px 7px; background: var(--surface-3); border-radius: 5px; }
.composer-bar { display: flex; align-items: center; gap: 3px; padding: 2px 6px 6px; }
.composer-spacer { flex: 1; }
.composer-bar .btn { height: 30px; }
.composer-bar .btn-ghost { margin-right: 4px; border-color: var(--line-2); }
.composer-conflict { padding: 9px 12px; font-size: 13px; background: var(--amber-soft); border-radius: 10px 10px 0 0; border-bottom: 1px solid var(--line-2); }
.composer-conflict-actions { display: flex; gap: 6px; margin-top: 7px; }
.picker { position: absolute; bottom: calc(100% + 5px); left: 8px; right: 8px; z-index: 20; background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius); box-shadow: var(--shadow); padding: 4px; max-height: 280px; overflow-y: auto; color: var(--ink); }
.picker-item { display: block; width: 100%; padding: 6px 8px; border-radius: 5px; text-align: left; }
.picker-item.is-active { background: var(--hover); }
.picker-title { display: block; font-size: 13.5px; font-weight: 500; }
.picker-sub { display: block; font-size: 12px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---- Customer sidecar ---- */
.sidecar { width: 276px; flex: none; overflow-y: auto; background: var(--surface); border-left: 1px solid var(--line); padding: 14px 14px 20px; }
.side-person { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; }
.side-person > div { min-width: 0; }
.side-person strong { display: block; font-weight: 600; }
.side-email { display: block; max-width: 100%; font-size: 12.5px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; }
.side-email:hover { color: var(--ink); }
.side-change { font-size: 12px; }
.side-blocked { padding: 6px 9px; font-size: 12.5px; border-radius: 5px; background: var(--red-soft); color: var(--red); margin-bottom: 10px; }
.side-section { padding: 11px 0; border-top: 1px solid var(--line); }
.side-section h2 { display: flex; justify-content: space-between; gap: 6px; font-size: 12px; font-weight: 600; color: var(--ink-3); margin-bottom: 6px; }
.side-domain { font-weight: 400; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 130px; font-size: 12px; }
.side-notes { width: 100%; font-size: 13px; padding: 6px 8px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; resize: vertical; }
.side-empty { font-size: 12.5px; }
.side-tickets button { display: flex; align-items: center; gap: 7px; width: 100%; padding: 4px 4px; margin: 0 -4px; border-radius: 5px; text-align: left; font-size: 12.5px; }
.side-tickets button:hover { background: var(--hover); }
.side-ticket-subject { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-tickets time { font-size: 11.5px; color: var(--ink-3); flex: none; }
.side-bad { color: var(--red); }
.side-facts { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; font-size: 12.5px; margin-bottom: 8px; }
.side-facts dt { color: var(--ink-3); }
.side-link { display: inline-flex; align-items: center; gap: 5px; }

/* ---- Modals and toasts ---- */
.modal-back { position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-start; justify-content: center; padding: 8vh 16px 16px; background: rgba(20, 15, 8, .42); overflow-y: auto; }
.modal { width: 100%; max-width: 440px; background: var(--surface); border-radius: 12px; box-shadow: var(--shadow); }
.modal-wide { max-width: 620px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 12px 4px 18px; }
.modal-head h2 { font-size: 15px; font-weight: 600; }
.modal-body { padding: 6px 18px 18px; }
.modal-lede { font-size: 13px; margin-bottom: 10px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; align-items: center; margin-top: 4px; }
.merge-list { margin-top: 8px; max-height: 300px; overflow-y: auto; }
.merge-list button { display: flex; gap: 8px; width: 100%; padding: 7px 8px; border-radius: 6px; text-align: left; align-items: baseline; }
.merge-list button:hover { background: var(--hover); }
.merge-num { font-size: 12.5px; color: var(--ink-3); flex: none; }
.merge-subject { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.merge-who { font-size: 12.5px; color: var(--ink-3); flex: none; max-width: 120px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.merge-empty { padding: 10px 8px; }
.keys { display: grid; grid-template-columns: 1fr 1fr; gap: 0 24px; }
.keys-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 5px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.keys-row dd { color: var(--ink-2); text-align: right; }
.keys-note { margin-top: 12px; font-size: 12.5px; }
.toasts { position: fixed; left: 16px; bottom: 16px; z-index: 80; display: flex; flex-direction: column; gap: 6px; max-width: calc(100vw - 32px); }
.toast { display: flex; align-items: center; gap: 10px; padding: 9px 13px; background: var(--ink); color: var(--surface); border-radius: 8px; box-shadow: var(--shadow); font-size: 13px; }
.toast-error { background: var(--red); color: #fff; }
:root[data-theme="dark"] .toast-error { color: #2a0e0b; }
:root[data-theme="dark"] .composer-note .seg button.is-on, :root[data-theme="dark"] .btn-note { color: #fff6d6; }
.toast-count { opacity: .65; font-variant-numeric: tabular-nums; }
.toast-action { font-weight: 700; text-decoration: underline; text-underline-offset: 2px; color: inherit; }
.spinner { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--line-2); border-top-color: var(--ink-2); animation: spin .7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Forms ---- */
.stack { display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field-label { font-size: 13px; font-weight: 500; }
.field-hint { font-size: 12.5px; color: var(--ink-3); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.input { width: 100%; min-height: 34px; padding: 6px 10px; background: var(--surface); border: 1px solid var(--line-2); border-radius: 7px; }
textarea.input { resize: vertical; line-height: 1.5; }
.input:focus-visible { outline: 2px solid var(--focus); outline-offset: 0; border-color: transparent; }
.input-auto { width: auto; }
.input-compact { width: auto; min-height: 28px; padding: 2px 6px; font-size: 13px; }
.input-number { width: 66px; }
.form-error { padding: 7px 10px; font-size: 13px; background: var(--red-soft); color: var(--red); border-radius: 6px; }
.check-row { display: flex; align-items: center; gap: 8px; font-size: 13.5px; }
.check-row input { margin: 0; accent-color: var(--accent); }
.switch { position: relative; width: 36px; height: 20px; flex: none; background: var(--line-2); border-radius: 10px; transition: background .12s; }
.switch.is-on { background: var(--accent); }
.switch-dot { position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: left .12s; }
.switch.is-on .switch-dot { left: 18px; }

/* ---- Sign in ---- */
.auth { min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px; background: var(--bg); }
.auth-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 26px 26px 22px; }
.auth-brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; text-decoration: none; margin-bottom: 18px; }
.auth h1 { font: 500 24px/1.2 var(--serif); margin-bottom: 4px; }
.auth-sub { color: var(--ink-2); margin-bottom: 4px; }
.auth .stack { margin-top: 14px; }
.auth-gap { margin-top: 10px; font-size: 13.5px; }
.auth-link { font-size: 13px; color: var(--ink-2); text-align: center; }
.auth-foot { margin-top: 14px; font-size: 13.5px; color: var(--ink-2); }
.auth-foot a { font-weight: 600; }

/* ---- Pages: settings, reports, help ---- */
.page { height: 100%; overflow-y: auto; background: var(--bg); }
.page-head { padding: 18px 24px 0; max-width: 880px; margin: 0 auto; }
.page-wide .page-head, .page-wide .page-body { max-width: 1120px; }
.page-head h1 { font-size: 20px; font-weight: 600; }
.page-sub { color: var(--ink-2); margin-top: 2px; }
.page-head-row { display: flex; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.page-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.page-body { padding: 18px 24px 48px; max-width: 880px; margin: 0 auto; }
.page-empty { padding: 48px 20px; text-align: center; display: flex; flex-direction: column; gap: 8px; align-items: center; color: var(--ink-2); }
.page-empty strong { color: var(--ink); font-size: 15px; }
.tabs { display: flex; gap: 2px; margin-top: 12px; border-bottom: 1px solid var(--line); overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.tabs button { padding: 7px 10px; font-weight: 500; color: var(--ink-2); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button:hover { color: var(--ink); }
.tabs button.is-on { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.settings-form { display: flex; flex-direction: column; gap: 14px; }
.settings-form fieldset { display: flex; flex-direction: column; gap: 14px; }
.set-section { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; }
.set-section h2 { font-size: 14.5px; font-weight: 600; }
.set-lede { color: var(--ink-2); font-size: 13.5px; }
.set-title-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.set-toggle { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding: 2px 0; }
.set-toggle strong { font-weight: 500; }
.set-toggle p { font-size: 13px; }
.set-save { position: sticky; bottom: 0; padding: 8px 0; }
.set-steps { list-style: decimal; padding-left: 20px; color: var(--ink-2); display: flex; flex-direction: column; gap: 4px; font-size: 13.5px; }
.copy-line { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.copy-line code { padding: 5px 9px; font-size: 13px; overflow-wrap: anywhere; }
.code-block { display: block; flex: 1 1 100%; overflow-x: auto; white-space: nowrap; }
.callout { padding: 10px 13px; border-radius: 8px; background: var(--surface-3); font-size: 13.5px; }
.callout-warn { background: var(--amber-soft); }
.hours { display: flex; flex-direction: column; gap: 4px; }
.hours-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 36px; flex-wrap: wrap; }
.hours-row .check-row { width: 130px; }
.hours-times { display: flex; align-items: center; gap: 6px; }
.hours-times .input { width: 118px; }
.invite-form { display: flex; gap: 8px; flex-wrap: wrap; }
.invite-form input { flex: 1; min-width: 180px; }
.invite-form select { width: auto; }
.people li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.people li:first-child { border-top: 0; }
.people li.is-off { opacity: .6; }
.people-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.people-main strong { font-weight: 500; }
.people-main span { font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.people-rows { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.people-rows li { padding: 0; }
.people-button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 14px; text-align: left; }
.people-button:hover { background: var(--hover); }
.people-count, .people-when { font-size: 12.5px; white-space: nowrap; }
.people-when { width: 70px; text-align: right; }
.items li { display: flex; align-items: center; gap: 10px; border-top: 1px solid var(--line); }
.items li:first-child { border-top: 0; }
.items li.is-off .items-main { opacity: .55; }
.items-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; padding: 8px 6px; margin: 0 -6px; text-align: left; border-radius: 6px; }
.items-main:hover:not(:disabled) { background: var(--hover); }
.items-main strong { font-weight: 500; }
.items-sub { font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.items-wrap { white-space: normal; }
.items-meta { font-size: 12px; white-space: nowrap; }
.items-empty { padding: 12px 0; }
.var-chip { font: 12px ui-monospace, Consolas, monospace; padding: 1px 6px; margin: 0 3px 3px 0; background: var(--surface-3); border-radius: 4px; }
.var-chip:hover { background: var(--line-2); }
.rule-form { gap: 10px; }
.rule-line { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.rule-line .input { flex: 1; min-width: 130px; }
.rule-line .input-auto, .rule-line .input-number { flex: none; min-width: 0; }
.rule-word { font-weight: 600; font-size: 13px; color: var(--ink-2); min-width: 34px; }
.rule-more { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; padding-left: 41px; font-size: 12.5px; }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.swatch { width: 26px; height: 26px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12); }
.swatch.is-on { outline: 2px solid var(--ink); outline-offset: 2px; }
.swatch-custom { width: 30px; height: 28px; padding: 0; border: 0; background: none; cursor: pointer; }
.logo-row { display: flex; gap: 8px; }
.page-editor { display: flex; flex-direction: column; }
.page-editor .page-head { max-width: none; width: 100%; padding-bottom: 10px; }
.editor { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--line); }
.editor-write { display: flex; flex-direction: column; gap: 8px; padding: 16px 20px; background: var(--surface); min-height: 0; }
.editor-title { font: 500 22px/1.25 var(--serif); border: 0; background: none; padding: 2px 0; }
.editor-title:focus-visible { outline: none; }
.editor-section { max-width: 300px; }
.editor-body { flex: 1; min-height: 300px; border: 0; background: none; resize: none; font: 13.5px/1.6 ui-monospace, Consolas, monospace; padding: 8px 0; }
.editor-body:focus-visible { outline: none; }
.editor-tools { display: flex; gap: 6px; }
.editor-preview { padding: 16px 24px; overflow-y: auto; border-left: 1px solid var(--line); }
.editor-preview-label { display: block; font-size: 11.5px; font-weight: 600; color: var(--ink-3); margin-bottom: 8px; }
.editor-preview h1 { font: 500 24px/1.25 var(--serif); margin-bottom: 12px; }

.box-status { display: flex; gap: 10px; align-items: flex-start; }
.box-status .status-dot { margin-top: 6px; }
.box-status p { font-size: 13.5px; }
.dot-bad { background: var(--red); }
.box-error { margin-top: 6px; }
.box-hint { padding: 8px 11px; font-size: 13px; background: var(--surface-3); border-radius: 7px; color: var(--ink-2); }
.box-hint strong { color: var(--ink); font-weight: 600; }
.inline-icon { display: inline-block; vertical-align: -2px; }
.box-advanced { display: flex; flex-direction: column; gap: 10px; padding: 12px; background: var(--surface-2); border-radius: 8px; }
.field-row-port { grid-template-columns: 1fr 96px; }
.box-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; }
.set-small { font-size: 12.5px; }

.modes { display: flex; flex-direction: column; gap: 6px; }
.mode { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line-2); border-radius: 8px; cursor: pointer; }
.mode.is-on { border-color: var(--accent); background: var(--accent-soft); }
.mode input { margin: 3px 0 0; accent-color: var(--accent); }
.mode strong { display: block; font-weight: 600; }
.mode .muted { font-size: 13px; color: var(--ink-2); }
.try-form { display: flex; gap: 8px; }
.try-form .input { flex: 1; }
.try-result { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.try-verdict { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; padding: 8px 12px; font-size: 13px; font-weight: 500; background: var(--surface-2); border-bottom: 1px solid var(--line); }
.try-verdict .muted { font-weight: 400; }
.try-answer { padding: 10px 12px; font-size: 14px; }
.plain-list { display: flex; flex-direction: column; gap: 6px; font-size: 13.5px; color: var(--ink-2); }
.plain-list strong { color: var(--ink); font-weight: 600; }

.input-suffix { display: flex; align-items: center; gap: 8px; }
.input-suffix .input { flex: 1; }

.recovery { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 6px; }
.qr-row { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.qr-row .stack { flex: 1; min-width: 200px; }
.qr { border-radius: 8px; background: #fff; padding: 6px; }
.qr-key { display: inline-block; padding: 6px 9px; font-size: 13px; overflow-wrap: anywhere; }
.input-code { max-width: 160px; letter-spacing: 2px; }
.box-on { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; }

/* ---- Reports ---- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin-bottom: 12px; }
.tile { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; min-width: 0; }
.tile-label { font-size: 12.5px; color: var(--ink-2); }
.tile-value { font: 500 26px/1.2 var(--serif); font-variant-numeric: tabular-nums; }
.tile-delta { display: inline-flex; gap: 3px; align-items: flex-start; font-size: 12px; color: var(--ink-3); line-height: 1.3; }
.tile-delta .icon { margin-top: 1px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; margin-bottom: 12px; min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.card-head h2 { font-size: 14.5px; font-weight: 600; }
.card-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.card-grid .card { margin-bottom: 0; }
.card-grid + .card-grid, .card + .card-grid { margin-top: 12px; }
.legend { display: flex; align-items: center; gap: 14px; font-size: 12.5px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.key { display: inline-block; width: 14px; height: 2px; border-radius: 1px; flex: none; }
.key-in { background: var(--series-in); }
.key-out { background: var(--series-out); }
.chart { position: relative; overflow: hidden; }
.chart svg { display: block; touch-action: pan-y; }
.chart svg:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.grid { stroke: var(--line); stroke-width: 1; }
.tick { fill: var(--ink-3); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.series-in { stroke: var(--series-in); }
.series-out { stroke: var(--series-out); }
.series-in-area { fill: var(--series-in); opacity: .1; }
.crosshair { stroke: var(--ink-3); stroke-width: 1; }
.dot { stroke: var(--surface); stroke-width: 2; }
.series-in-fill { fill: var(--series-in); }
.series-out-fill { fill: var(--series-out); }
.tip { position: absolute; z-index: 5; pointer-events: none; display: flex; flex-direction: column; gap: 2px; padding: 7px 10px; background: var(--surface); border: 1px solid var(--line-2); border-radius: 7px; box-shadow: var(--shadow); font-size: 12.5px; white-space: nowrap; }
.tip-title { font-size: 12px; color: var(--ink-3); }
.tip-row { display: flex; align-items: center; gap: 6px; color: var(--ink-2); }
.tip-row strong { color: var(--ink); font-variant-numeric: tabular-nums; }
.heat-wrap { min-width: 0; }
.heat { display: flex; flex-direction: column; gap: 2px; }
.heat-row { display: grid; grid-template-columns: 34px repeat(24, 1fr); gap: 2px; align-items: center; }
.heat-day { font-size: 11.5px; color: var(--ink-3); }
.heat-hour { font-size: 10.5px; color: var(--ink-3); white-space: nowrap; height: 15px; }
.heat-cell { display: block; aspect-ratio: 1; border-radius: 2px; }
.lv-0 { background: var(--heat-0); } .lv-1 { background: var(--heat-1); } .lv-2 { background: var(--heat-2); } .lv-3 { background: var(--heat-3); } .lv-4 { background: var(--heat-4); } .lv-5 { background: var(--heat-5); }
.heat-cell.is-hover { outline: 1.5px solid var(--ink); outline-offset: 0; }
.heat-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 8px; font-size: 12px; color: var(--ink-2); min-height: 18px; }
.heat-scale { display: inline-flex; align-items: center; gap: 2px; color: var(--ink-3); white-space: nowrap; }
.heat-scale .heat-cell { width: 11px; margin: 0 1px; }
.bars li + li { margin-top: 3px; }
.bars-row { display: grid; grid-template-columns: 96px 1fr; gap: 8px; align-items: center; width: 100%; padding: 2px 4px; margin: 0 -4px; border-radius: 4px; text-align: left; }
.bars-row:hover { background: var(--hover); }
.bars-label { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bars-track { display: flex; align-items: center; gap: 6px; }
.bars-fill { display: block; height: 14px; background: var(--series-in); border-radius: 0 4px 4px 0; }
.bars-value { font-size: 12px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.table-scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; font-weight: 500; font-size: 12px; color: var(--ink-3); padding: 3px 8px 5px 0; border-bottom: 1px solid var(--line); }
.table td { padding: 6px 8px 6px 0; border-bottom: 1px solid var(--line); }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.unhappy li + li { border-top: 1px solid var(--line); }
.unhappy button { display: block; width: 100%; padding: 8px 6px; margin: 0 -6px; border-radius: 6px; text-align: left; }
.unhappy button:hover { background: var(--hover); }
.unhappy-comment { display: block; }
.unhappy-meta { display: block; font-size: 12.5px; }

/* ---- Narrower screens ---- */
@media (max-width: 1279px) {
  .sidecar { position: absolute; top: 0; right: 0; bottom: 0; z-index: 30; box-shadow: var(--shadow); }
  .t-layout { position: relative; }
}
@media (max-width: 1000px) {
  .list-pane { width: 320px; }
  .rail { width: 186px; }
}
@media (max-width: 899px) {
  .rail { position: fixed; top: 0; bottom: 0; left: 0; z-index: 50; width: 250px; transform: translateX(-100%); transition: transform .16s ease-out; }
  .rail.is-open { transform: none; box-shadow: var(--shadow); }
  .rail-scrim { display: block; position: fixed; inset: 0; z-index: 49; background: rgba(20, 15, 8, .4); }
  .icon-btn.rail-toggle, .icon-btn.t-back { display: inline-flex; }
  .t-head-top { flex-wrap: wrap; }
  .t-subject, .t-subject-input { order: 5; flex-basis: 100%; white-space: normal; font-size: 15.5px; }
  .t-num { margin-right: auto; }
  .t-nav .icon-btn[aria-label="Previous ticket"], .t-nav .icon-btn[aria-label="Next ticket"], .t-nav-gap { display: none; }
  .demo-long { display: none; }
  .list-pane { width: 100%; border-right: 0; }
  .inbox.has-ticket .list-pane { display: none; }
  .inbox:not(.has-ticket) .t-pane, .inbox:not(.has-ticket) .t-layout { display: none; }
  .row-check { display: none !important; }
  .row:hover .row-main, .row.is-selected .row-main { padding-left: 14px; }
  .row-main { padding-top: 11px; padding-bottom: 11px; }
  .t-thread { padding: 12px 10px 6px; }
  .msg > .avatar { display: none; }
  .composer { width: calc(100% - 16px); margin-bottom: 8px; }
  .composer textarea, .input, .search input, .side-notes, .menu-search { font-size: 16px; }
  .composer-bar .btn-ghost { padding: 0 8px; font-size: 13px; }
  .sidecar { width: min(300px, 88vw); }
  .page-head { padding: 12px 16px 0; }
  .page-body { padding: 12px 16px 40px; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .tile-value { font-size: 22px; }
  .card-grid { grid-template-columns: 1fr; }
  .field-row { grid-template-columns: 1fr; }
  .keys { grid-template-columns: 1fr; }
  .editor { grid-template-columns: 1fr; }
  .editor-preview { border-left: 0; border-top: 1px solid var(--line); }
  .demo-banner { font-size: 12.5px; padding: 6px 12px; gap: 10px; }
  .demo-short { display: inline; }
  .toasts { left: 8px; right: 8px; bottom: 8px; }
  .hours-times .input { width: 104px; }
  .modal-back { padding: 16px 8px; }
  .people-when { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
@media (forced-colors: active) {
  .status-dot, .row-unread, .presence-dot { forced-color-adjust: none; }
}

/* Fingers need more room than a mouse. Last in the file so these win. */
@media (pointer: coarse), (max-width: 760px) {
  .btn-compact { height: 38px; padding: 0 10px; }
  .icon-btn { width: 38px; height: 38px; }
  .icon-btn-small { width: 30px; height: 30px; }
  .chip { height: 30px; padding-right: 0; }
  .chip-add { height: 30px; padding-right: 8px; }
  .chip-go { min-height: 30px; }
  .chip button:not(.chip-go) { min-width: 28px; min-height: 30px; justify-content: center; }
  .t-head-bar { gap: 4px; }
  .composer-to-label ~ .linkish { min-width: 32px; min-height: 32px; display: inline-flex; align-items: center; justify-content: center; }
  /* The conversation is what you came for, so what's above it stays to one swipeable row. What matters most goes first. */
  .t-head-bar { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-right: -12px; padding-right: 12px; }
  .t-head-bar::-webkit-scrollbar { display: none; }
  .t-head-bar > * { flex: none; }
  .t-head-bar .sla { order: -1; }
  /* Menus open at the bottom, where a thumb can reach, and no row can clip them. */
  .menu { position: fixed; left: 8px; right: 8px; top: auto; bottom: 8px; max-height: 60dvh; overflow-y: auto; z-index: 70; }
  .menu button { min-height: 44px; }
  /* Above the send buttons, so the next reply doesn't have to wait out the last one's undo. */
  .toasts { bottom: 64px; }
}
