/* Niro's AI Assistant: app shell v2, LIGHT theme. See docs/brandbook.md.
   Color is state only: a card type's hue appears ONLY as the left border + chip.
   Chrome (nav, topbar, buttons, focus) is neutral ink on paper. */

:root {
  color-scheme: light;

  /* surfaces */
  --bg: #f5f6f8;          /* page / main pane */
  --surface: #ffffff;     /* cards, topbar, nav, chat */
  --surface-2: #eef0f3;   /* hover, focus, active nav */
  --surface-3: #e6e9ee;   /* pressed, user bubble */
  --line: #e3e6eb;        /* hairlines */
  --line-2: #cbd1da;      /* control borders */

  /* text (contrast on #fff / #f5f6f8) */
  --text-hi: #14171c;     /* 17.9 / 16.6 */
  --text: #2a303a;        /* 13.3 / 12.3 */
  --dim: #586171;         /* 6.2 / 5.8 */
  --faint: #636c7a;       /* 5.3 / 4.9 */
  --ink: #14171c;         /* primary button, focus ring, active nav marker */

  /* card type / state hues (>= 4.5:1 as text on white and on their own 10% tint) */
  --c-action: #b53a08;
  --c-review: #92580a;
  --c-awaiting: #1d5fd0;
  --c-tracking: #0b7567;
  --c-event: #6d3fd1;
  --c-fyi: #566580;
  --c-noise: #656d7a;
  --c-intro: #a8267a;

  --font: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px;
  --radius: 6px;
  --radius-sm: 4px;
  --topbar-h: 52px;
  --nav-w: 232px;
  --nav-w-rail: 56px;
  --chat-w: 380px;
  --shadow: 0 8px 28px rgba(20, 23, 28, .14);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
.num { font-variant-numeric: tabular-nums; }
.dim { color: var(--dim); }
[hidden] { display: none !important; }
button, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; }

/* ---------------------------------------------------------------- shell */
.app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
.app-body { flex: 1; display: flex; min-height: 0; position: relative; }

/* ---------------------------------------------------------------- topbar */
.topbar {
  flex: none; height: var(--topbar-h);
  display: flex; align-items: center; gap: var(--s4);
  padding: 0 var(--s4);
  background: var(--surface); border-bottom: 1px solid var(--line);
  z-index: 30;
}
.topbar-left { display: flex; align-items: center; gap: var(--s3); min-width: 0; }
.brand { margin: 0; font-size: 14px; font-weight: 650; letter-spacing: .005em; color: var(--text-hi); white-space: nowrap; }
.search {
  flex: 1; max-width: 460px; margin: 0 auto 0 var(--s4);
  display: flex; align-items: center; gap: var(--s2);
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 0 var(--s3); height: 34px; color: var(--faint);
}
.search:focus-within { background: var(--surface); border-color: var(--ink); }
.search input {
  flex: 1; min-width: 0; border: 0; background: transparent; outline: none;
  font-size: 13.5px; color: var(--text-hi); height: 100%;
}
.search input::placeholder { color: var(--faint); }
.search input::-webkit-search-cancel-button { cursor: pointer; }
.search kbd, .kbd {
  font: 11px/16px var(--mono); color: var(--faint);
  border: 1px solid var(--line-2); border-radius: 3px; padding: 0 5px; background: var(--surface);
}
.topbar-right { display: flex; align-items: center; gap: var(--s4); margin-left: auto; }
.status { font-size: 12px; color: var(--dim); white-space: nowrap; }
.status.offline { color: var(--c-review); font-weight: 600; }
.topbar-right .sep { width: 1px; height: 18px; background: var(--line); }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-width: 34px; height: 34px; padding: 0 8px;
  background: transparent; border: 1px solid transparent; border-radius: var(--radius);
  color: var(--dim); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text-hi); }
.icon-btn[aria-expanded="true"].is-toggle { background: var(--surface-2); color: var(--text-hi); border-color: var(--line); }
.icon-btn .lbl { font-size: 13px; font-weight: 500; }
.ico { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------------------------------------------------------------- left nav */
.nav {
  flex: none; width: var(--nav-w);
  display: flex; flex-direction: column;
  background: var(--surface); border-right: 1px solid var(--line);
  padding: var(--s3) var(--s2); gap: var(--s1);
  overflow-y: auto; min-height: 0;
  transition: width .2s ease-out;
}
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 10px; border: 1px solid transparent; border-radius: var(--radius);
  background: transparent; color: var(--dim); font-size: 13.5px; font-weight: 500; text-align: left; cursor: pointer;
  position: relative;
}
.nav-item:hover { background: var(--surface-2); color: var(--text-hi); }
.nav-item.active { background: var(--surface-2); color: var(--text-hi); font-weight: 600; border-color: var(--line); }
.nav-item.active::before { content: ""; position: absolute; left: -9px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 2px 2px 0; background: var(--ink); }
.nav-label { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-count { font-size: 11.5px; color: var(--faint); min-width: 18px; text-align: right; }
.nav-item.active .nav-count { color: var(--text); }
.nav-h {
  margin: var(--s4) 10px var(--s2); font-size: 11px; font-weight: 650; letter-spacing: .1em; text-transform: uppercase; color: var(--faint);
}
.cat-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 var(--s2); }
.cat {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 9px; border: 1px solid var(--line-2); border-radius: 999px; background: var(--surface);
  font-size: 12px; line-height: 18px; color: var(--text); cursor: pointer; white-space: nowrap;
}
.cat:hover { background: var(--surface-2); }
.cat .n { color: var(--faint); font-size: 11px; }
.cat[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.cat[aria-pressed="true"] .n { color: #d5d9e0; }
.cat.zero { opacity: .55; }
.nav-foot { margin-top: auto; padding: var(--s3) 10px 0; border-top: 1px solid var(--line); font-size: 12px; color: var(--dim); display: flex; flex-direction: column; gap: 2px; }
.nav-foot .keys { margin-top: var(--s2); font: 11px/1.5 var(--mono); color: var(--faint); }
.nav-foot .status { white-space: normal; }

/* collapsed rail (desktop) */
.nav.collapsed { width: var(--nav-w-rail); }
.nav.collapsed .nav-item { justify-content: center; padding: 9px 0; }
.nav.collapsed .nav-label, .nav.collapsed .nav-count, .nav.collapsed .nav-h,
.nav.collapsed .cat-chips, .nav.collapsed .nav-foot { display: none; }
.nav.collapsed .nav-item.active::before { left: -9px; }
.nav.collapsed .nav-item .rail-dot { display: block; }
.rail-dot { display: none; position: absolute; top: 6px; right: 10px; width: 7px; height: 7px; border-radius: 50%; background: var(--ink); }

.backdrop { position: fixed; inset: var(--topbar-h) 0 0 0; background: rgba(20, 23, 28, .35); z-index: 24; }

/* ---------------------------------------------------------------- main pane */
.main { flex: 1; min-width: 0; overflow-y: auto; outline: none; scroll-padding-top: 60px; }
.pane { max-width: 1040px; margin: 0 auto; padding: var(--s5) var(--s5) var(--s7); }
.pane-head { display: flex; align-items: baseline; gap: var(--s3); margin-bottom: var(--s4); flex-wrap: wrap; }
.pane-title { margin: 0; font-size: 20px; font-weight: 650; color: var(--text-hi); letter-spacing: -.005em; }
.pane-sub { font-size: 13px; color: var(--dim); }
.pane-filters { margin-left: auto; display: flex; gap: var(--s2); align-items: center; }
.filter-pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 1px 4px 1px 10px; border-radius: 999px;
  border: 1px solid var(--line-2); background: var(--surface); font-size: 12px; color: var(--text);
}
.filter-pill button { border: 0; background: transparent; cursor: pointer; color: var(--dim); padding: 0 6px; font-size: 14px; line-height: 20px; border-radius: 50%; }
.filter-pill button:hover { background: var(--surface-2); color: var(--text-hi); }

.sec-h {
  display: flex; align-items: center; gap: var(--s2);
  margin: var(--s5) 0 var(--s2); padding: 0;
  font-size: 11.5px; font-weight: 650; letter-spacing: .1em; text-transform: uppercase; color: var(--dim);
  background: none; border: 0; width: 100%; text-align: left; cursor: default;
}
.sec-h:first-child { margin-top: 0; }
.sec-h .count { color: var(--faint); font-weight: 500; letter-spacing: 0; }
.sec-h.toggle { cursor: pointer; }
.sec-h .chev { width: 12px; height: 12px; transition: transform .15s; }
.sec-h.toggle[aria-expanded="false"] .chev { transform: rotate(-90deg); }

/* ---------------------------------------------------------------- type hues */
[data-type="ACTION_REQUIRED"] { --hue: var(--c-action); }
[data-type="REVIEW"]          { --hue: var(--c-review); }
[data-type="AWAITING_REPLY"]  { --hue: var(--c-awaiting); }
[data-type="TRACKING"]        { --hue: var(--c-tracking); }
[data-type="EVENT"]           { --hue: var(--c-event); }
[data-type="FYI"]             { --hue: var(--c-fyi); }
[data-type="NOISE"]           { --hue: var(--c-noise); }
[data-type="INTRO"]           { --hue: var(--c-intro); }

.chip {
  display: inline-block; padding: 0 6px; border-radius: 3px;
  font-size: 10.5px; line-height: 17px; font-weight: 650; letter-spacing: .07em; text-transform: uppercase;
  color: var(--hue, var(--dim));
  background: color-mix(in srgb, var(--hue, var(--dim)) 10%, #fff);
  border: 1px solid color-mix(in srgb, var(--hue, var(--dim)) 32%, #fff);
  white-space: nowrap;
}
.chip.phish { --hue: var(--c-action); }
.chip.stale { --hue: var(--c-review); }
.chip.soon  { --hue: var(--c-event); }
.chip.pri { --hue: var(--text-hi); letter-spacing: .04em; background: var(--surface-2); border-color: var(--line-2); }
.chip.cat-chip { --hue: var(--dim); text-transform: none; letter-spacing: 0; font-weight: 550; font-size: 11px; background: var(--surface); border-color: var(--line-2); }
.chip.state { --hue: var(--dim); background: var(--surface-2); border-color: var(--line-2); }

/* ---------------------------------------------------------------- shared item */
.item { outline: none; }
.item:focus-visible { box-shadow: 0 0 0 2px var(--ink); }
.item.phish { border-style: dashed; border-color: var(--hue); }

/* ---------------------------------------------------------------- P1 large cards */
.stack { display: flex; flex-direction: column; gap: var(--s3); }
.card {
  background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--hue);
  border-radius: var(--radius); padding: var(--s4) var(--s5) var(--s4) var(--s4);
  box-shadow: 0 1px 2px rgba(20, 23, 28, .04);
}
.card.phish { border-width: 1px 1px 1px 4px; border-style: dashed; border-color: var(--hue); }
.card:hover { border-color: var(--line-2); border-left-color: var(--hue); }
.card-head { display: flex; gap: var(--s2); align-items: center; flex-wrap: wrap; }
.card-head .when { margin-left: auto; color: var(--dim); font-size: 12px; }
.card-title { margin: var(--s2) 0 var(--s1); font-size: 17px; line-height: 1.3; font-weight: 650; color: var(--text-hi); cursor: pointer; }
.card-title:hover { text-decoration: underline; text-decoration-color: var(--line-2); text-underline-offset: 3px; }
.card-summary {
  margin: 0 0 var(--s3); color: var(--text); max-width: 74ch;
  display: -webkit-box; -webkit-line-clamp: 3; line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.card-meta { display: flex; gap: var(--s3); flex-wrap: wrap; align-items: center; font-size: 12px; color: var(--dim); margin-bottom: var(--s3); }
.card-meta .from { color: var(--text); font-weight: 500; }
.tag { color: var(--dim); }
.tag::before { content: "#"; color: var(--faint); }
.due { color: var(--hue); font-weight: 650; }

.actions { display: flex; gap: var(--s2); flex-wrap: wrap; align-items: center; }
.actions .spacer { flex: 1; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  padding: 3px 11px; font-size: 12.5px; line-height: 18px; font-weight: 500; cursor: pointer; color: var(--text-hi);
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); border-color: var(--faint); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.primary:hover { background: #2a303a; border-color: #2a303a; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--dim); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text-hi); }
.btn kbd { font: 10px var(--mono); color: var(--faint); margin-left: 2px; }
.btn.primary kbd { color: #c9ced7; }
.btn.sm { padding: 0 8px; font-size: 12px; line-height: 22px; }

.picker { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; margin-top: var(--s3); padding-top: var(--s3); border-top: 1px solid var(--line); }
.picker input { background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius-sm); padding: 3px 8px; font-size: 13px; color: var(--text-hi); }

/* ---------------------------------------------------------------- dense rows */
.rows { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; --act-w: 252px; }
.rows[data-kind="intro"] { --act-w: 156px; }
.rows[data-kind="default"], .rows[data-kind="backlog"] { --act-w: 0px; }
.rows[data-kind="default"] .row, .rows[data-kind="backlog"] .row { position: relative; grid-template-columns: 74px minmax(0, 1fr) auto 84px; }
.rows[data-kind="default"] .row-actions, .rows[data-kind="backlog"] .row-actions {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  padding: 2px 2px 2px 28px; background: linear-gradient(90deg, rgba(250,251,252,0), #fafbfc 24px);
}
.rows[data-kind="default"] .row:hover .row-when, .rows[data-kind="default"] .row:focus-within .row-when,
.rows[data-kind="backlog"] .row:hover .row-when, .rows[data-kind="backlog"] .row:focus-within .row-when { visibility: hidden; }
.rows[data-kind="readonly"] { --act-w: 0px; }
.row {
  display: grid; grid-template-columns: 74px minmax(0, 1fr) auto 84px var(--act-w);
  gap: var(--s3); align-items: center;
  padding: 6px var(--s3) 6px var(--s3);
  border-bottom: 1px solid var(--line); border-left: 3px solid var(--hue);
  min-height: 36px; background: var(--surface);
}
.row:last-child { border-bottom: 0; }
.row:hover, .row:focus-within { background: #fafbfc; }
.row.phish { border-left-style: dashed; }
.row-main { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.row-title { color: var(--text-hi); font-weight: 600; }
.row-sum { color: var(--dim); }
.row-from { color: var(--text); margin-left: 10px; font-weight: 500; }
.row-sum { margin-left: 10px; }
.row-cat { justify-self: end; }
.row-when { color: var(--dim); font-size: 12px; text-align: right; white-space: nowrap; }
.row-actions { display: flex; gap: var(--s1); justify-content: flex-end; opacity: 0; }
.row:hover .row-actions, .row:focus-within .row-actions, .rows[data-kind="intro"] .row-actions { opacity: 1; }
.row.soon .row-when { color: var(--hue); font-weight: 650; }
.row.stale-row .row-when { color: var(--c-review); font-weight: 600; }
.row.dimmed .row-main { opacity: .75; }
.row .picker { grid-column: 1 / -1; margin-top: 0; padding-top: var(--s2); }
.rows[data-kind="readonly"] .row { grid-template-columns: 74px minmax(0, 1fr) auto 84px; }
.rows[data-kind="readonly"] .row-actions { display: none; }

/* ---------------------------------------------------------------- detail view */
.back { margin: 0 0 var(--s3) calc(-1 * var(--s2)); }
.d-card {
  background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--hue);
  border-radius: var(--radius); padding: var(--s5);
}
.d-card.phish { border-style: dashed; border-width: 1px 1px 1px 4px; border-color: var(--hue); }
.d-title { margin: var(--s3) 0 var(--s2); font-size: 22px; line-height: 1.25; font-weight: 700; color: var(--text-hi); letter-spacing: -.01em; }
.d-summary { margin: 0 0 var(--s3); max-width: 76ch; font-size: 14.5px; }
.d-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s5); margin-top: var(--s5); }
.d-h { margin: 0 0 var(--s3); font-size: 11.5px; font-weight: 650; letter-spacing: .1em; text-transform: uppercase; color: var(--dim); }
.d-note { color: var(--dim); font-size: 13px; }

/* conversation items: pattern from orchestrator detail_conversation (details/summary, label + preview) */
.convo { display: flex; flex-direction: column; gap: var(--s2); }
.cv {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); border-left: 3px solid var(--line-2);
}
.cv.out { border-left-color: var(--ink); }
.cv > summary {
  display: flex; align-items: baseline; gap: var(--s2); padding: 8px var(--s3); cursor: pointer; list-style: none; min-width: 0;
}
.cv > summary::-webkit-details-marker { display: none; }
.cv > summary::before { content: "\25B8"; color: var(--faint); font-size: 10px; flex: none; transition: transform .15s; }
.cv[open] > summary::before { transform: rotate(90deg); }
.cv-label { flex: none; font-size: 10.5px; font-weight: 650; text-transform: uppercase; letter-spacing: .05em; color: var(--faint); }
.cv.out .cv-label { color: var(--text-hi); }
.cv-who { flex: none; max-width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); font-weight: 550; font-size: 13px; }
.cv-prev { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--dim); font-size: 13px; }
.cv[open] .cv-prev { visibility: hidden; }
.cv-when { flex: none; color: var(--faint); font-size: 12px; }
.cv-body { padding: 0 var(--s3) var(--s3) 26px; font-size: 13.5px; }
.cv-subj { font-weight: 600; color: var(--text-hi); margin-bottom: var(--s1); }
.cv-text { max-height: 420px; overflow-y: auto; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text); }
.cv-meta { margin-top: var(--s2); color: var(--faint); font-size: 12px; }

.tl { list-style: none; margin: 0; padding: 0 0 0 var(--s4); border-left: 1px solid var(--line-2); }
.tl li { position: relative; padding: 0 0 var(--s3) var(--s3); font-size: 13px; color: var(--text); }
.tl li::before { content: ""; position: absolute; left: -21px; top: 6px; width: 9px; height: 9px; border-radius: 50%; background: var(--surface); border: 2px solid var(--line-2); }
.tl li.st::before { border-color: var(--ink); }
.tl .t { display: block; color: var(--faint); font-size: 11.5px; }
.tl .actor { color: var(--dim); }

/* ---------------------------------------------------------------- empty */
.empty { margin: 96px 0; text-align: center; font-size: 22px; letter-spacing: -.005em; color: var(--dim); }
.empty small { display: block; margin-top: var(--s2); font-size: 13px; color: var(--faint); letter-spacing: 0; }
.empty.mini { margin: 48px 0; font-size: 16px; }

/* ---------------------------------------------------------------- chat drawer */
.chat {
  flex: none; width: var(--chat-w);
  display: none; flex-direction: column; min-height: 0;
  background: var(--surface); border-left: 1px solid var(--line); z-index: 26;
}
.app.chat-open .chat { display: flex; }
.chat-head { flex: none; display: flex; align-items: center; gap: var(--s2); padding: var(--s3) var(--s3) var(--s3) var(--s4); border-bottom: 1px solid var(--line); min-height: 56px; }
.chat-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.kicker { font-size: 10.5px; font-weight: 650; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); }
.chat-name { font-size: 13.5px; font-weight: 650; color: var(--text-hi); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-log { flex: 1; min-height: 0; overflow-y: auto; padding: var(--s4); display: flex; flex-direction: column; gap: var(--s3); background: var(--bg); }
.chat-empty { margin: auto; text-align: center; color: var(--faint); font-size: 13px; max-width: 28ch; }
.msg { display: flex; flex-direction: column; gap: 4px; max-width: 92%; }
.msg.user { align-self: flex-end; align-items: flex-end; }
.msg.assistant { align-self: flex-start; }
.bubble { padding: 8px 12px; border-radius: 12px; font-size: 13.5px; line-height: 1.5; overflow-wrap: anywhere; }
.msg.user .bubble { background: var(--ink); color: #fff; border-bottom-right-radius: 4px; white-space: pre-wrap; }
.msg.assistant .bubble { background: var(--surface); color: var(--text); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.bubble p { margin: 0 0 var(--s2); } .bubble p:last-child { margin-bottom: 0; }
.bubble ul, .bubble ol { margin: 0 0 var(--s2); padding-left: 20px; } .bubble li { margin: 1px 0; }
.bubble code { font: 12px var(--mono); background: var(--surface-2); padding: 0 4px; border-radius: 3px; }
.msg .ts { font-size: 11px; color: var(--faint); padding: 0 4px; }
.msg.failed .bubble { border: 1px dashed var(--c-action); }
.typing { align-self: flex-start; display: inline-flex; gap: 4px; padding: 11px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; border-bottom-left-radius: 4px; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--faint); animation: blink 1.2s infinite ease-in-out; }
.typing i:nth-child(2) { animation-delay: .15s; } .typing i:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.chat-err { font-size: 12.5px; color: var(--c-action); display: flex; gap: var(--s2); align-items: center; }

.draft {
  align-self: stretch; background: var(--surface); border: 1px solid var(--line-2); border-left: 4px solid var(--ink);
  border-radius: var(--radius); padding: var(--s3); font-size: 13px; box-shadow: 0 1px 2px rgba(20, 23, 28, .05);
}
.draft-h { display: flex; align-items: center; gap: var(--s2); margin-bottom: var(--s2); }
.draft-h .kicker { color: var(--text-hi); }
.draft-state { margin-left: auto; font-size: 11.5px; font-weight: 600; color: var(--dim); }
.draft-row { display: flex; gap: var(--s2); font-size: 12.5px; padding: 2px 0; min-width: 0; }
.draft-row b { flex: none; width: 54px; color: var(--faint); font-weight: 500; }
.draft-row span { min-width: 0; overflow-wrap: anywhere; color: var(--text-hi); }
.draft-body {
  margin: var(--s2) 0; padding: var(--s2) var(--s3); background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm);
  white-space: pre-wrap; overflow-wrap: anywhere; max-height: 180px; overflow-y: auto; color: var(--text); font-size: 13px;
}
.draft-actions { display: flex; gap: var(--s2); }
.draft.done { border-left-color: var(--line-2); }
.draft.done .draft-body { max-height: 64px; opacity: .8; }

.chat-form { flex: none; display: flex; gap: var(--s2); align-items: flex-end; padding: var(--s3); border-top: 1px solid var(--line); background: var(--surface); }
.chat-form textarea {
  flex: 1; min-width: 0; resize: none; max-height: 140px; min-height: 36px;
  border: 1px solid var(--line-2); border-radius: var(--radius); padding: 7px 10px; background: var(--surface);
  font-size: 13.5px; line-height: 1.4; color: var(--text-hi);
}
.chat-form textarea:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
.chat-form textarea:disabled { background: var(--bg); color: var(--faint); }
.chat-form .btn { height: 36px; padding: 0 14px; }
.chat-hint { flex: none; padding: 0 var(--s4) var(--s2); font-size: 11px; color: var(--faint); background: var(--surface); }

/* ---------------------------------------------------------------- toast */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: var(--s5);
  background: var(--ink); color: #fff; border-radius: var(--radius);
  padding: 8px 16px; font-size: 13px; z-index: 60; box-shadow: var(--shadow);
}

/* ---------------------------------------------------------------- motion: state changes only */
.item.leaving { transition: transform .2s ease-in, opacity .2s ease-in; transform: translateX(28px); opacity: 0; pointer-events: none; }
@media (prefers-reduced-motion: reduce) {
  .item.leaving, .nav { transition: none; }
  .typing i { animation: none; opacity: .6; }
}

/* ---------------------------------------------------------------- responsive */
/* <= 1280px: chat becomes an overlay drawer so the main pane keeps its width */
@media (max-width: 1280px) {
  .chat { position: fixed; top: var(--topbar-h); right: 0; bottom: 0; box-shadow: var(--shadow); max-width: 100vw; }
  .status.trust-top, .topbar-right .sep { display: none; }
}
@media (max-width: 900px) { #sync-top { display: none; } }

/* <= 768px: nav off-canvas, chat full-width, search second row */
@media (max-width: 768px) {
  :root { --topbar-h: 96px; }
  .topbar { flex-wrap: wrap; height: auto; min-height: 96px; padding: var(--s2) var(--s3); row-gap: var(--s2); }
  .topbar-left { order: 1; }
  .topbar-right { order: 2; margin-left: auto; }
  .search { order: 3; flex: 1 1 100%; max-width: none; margin: 0; }
  .search kbd { display: none; }
  .icon-btn .lbl { display: none; }
  .nav {
    position: fixed; top: var(--topbar-h); bottom: 0; left: 0; z-index: 25; width: 264px; max-width: 86vw;
    transform: translateX(-102%); transition: transform .22s ease-out; box-shadow: var(--shadow);
  }
  .app.nav-open .nav { transform: translateX(0); }
  .nav.collapsed { width: 264px; }
  .nav.collapsed .nav-item { justify-content: flex-start; padding: 8px 10px; }
  .nav.collapsed .nav-label, .nav.collapsed .nav-count, .nav.collapsed .nav-h, .nav.collapsed .cat-chips { display: revert; }
  .nav.collapsed .nav-count { display: block; }
  .nav.collapsed .cat-chips { display: flex; }
  .nav.collapsed .nav-foot { display: flex; }
  .pane { padding: var(--s4) var(--s3) var(--s6); }
  .pane-title { font-size: 18px; }
  .chat { left: 0; width: 100%; }
  .card { padding: var(--s3); }
  .card-title { font-size: 16px; }
  .btn { padding: 6px 12px; }
  .row { grid-template-columns: minmax(0, 1fr) auto; row-gap: 2px; padding: 8px var(--s3); }
  .row .chip.type-chip { justify-self: start; grid-column: 1; grid-row: 1; }
  .row-chip { grid-column: 1; grid-row: 1; }
  .row-main { grid-column: 1 / -1; grid-row: 2; white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; }
  .row-when { grid-column: 2; grid-row: 1; }
  .row-cat { display: none; }
  .rows[data-kind] .row-actions { grid-column: 1 / -1; grid-row: 3; opacity: 1; justify-content: flex-start; position: static; transform: none; padding: 0; background: none; }
  .rows[data-kind] .row { grid-template-columns: minmax(0, 1fr) auto; position: relative; }
  .rows[data-kind] .row:hover .row-when { visibility: visible; }
  .d-card { padding: var(--s4); }
  .d-title { font-size: 19px; }
  .cv-who { max-width: 30%; }
  #app-name-long { display: none; }
}
@media (hover: none) { .row-actions { opacity: 1; } }
@media (min-width: 769px) { .nav-toggle-mobile-only { display: none; } }
