/* Tokens follow the reference data-viz palette: series 1 (blue) = 对方来信, series 2 (orange) = 我方发出. */
:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f3f2ee;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --ring: rgba(11, 11, 11, 0.10);
  --accent: #2a78d6;
  --accent-wash: rgba(42, 120, 214, 0.10);
  --inbound: #2a78d6;
  --outbound: #eb6834;
  --neutral: #898781;
  --mark: #fde9a8;
  --font: system-ui, -apple-system, "PingFang SC", "Hiragino Sans", "Segoe UI", sans-serif;
  /* Recency, newest first: one blue ramp (validated as an ordinal ramp per mode) and the ink that reads on it. */
  --rc0: #184f95; --rc1: #2a78d6; --rc2: #5598e7; --rc3: #86b6ef;
  --on0: #ffffff; --on1: #ffffff; --on2: #0b0b0b; --on3: #0b0b0b;
  --warning: #fab219;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #242423;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --ring: rgba(255, 255, 255, 0.10);
    --accent: #3987e5;
    --accent-wash: rgba(57, 135, 229, 0.16);
    --inbound: #3987e5;
    --outbound: #d95926;
    --mark: #5c4a12;
    --rc0: #86b6ef; --rc1: #3987e5; --rc2: #256abf; --rc3: #184f95;
    --on0: #0b0b0b; --on1: #0b0b0b; --on2: #ffffff; --on3: #ffffff;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--page); color: var(--ink); font: 14px/1.5 var(--font); display: flex; flex-direction: column; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
[hidden] { display: none !important; }

/* Case handling: decide first, read the letter second, envelope last. */
.case-page { max-width: 1440px; padding: 20px 24px 210px; margin: auto; }
.case-page h1 { font-size: 21px; margin: 12px 0; }
.case-page h2 { font-size: 15px; margin: 0 0 12px; }
.case-page h3 { font-size: 14px; margin: 18px 0 8px; }
.case-page-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.case-heading { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.case-heading h1 { overflow-wrap: anywhere; }
.case-head-actions { display: flex; align-items: center; gap: 16px; margin-left: auto; flex-shrink: 0; }
.case-head-actions > details { position: relative; }
.case-head-actions > details > button { position: absolute; top: 100%; right: 0; z-index: 5; white-space: nowrap; }
.case-columns { display: grid; grid-template-columns: minmax(240px,1fr) minmax(0,2fr); gap: 24px; }
.case-columns main { min-width: 0; }
.case-card,.case-letter-host:not(:empty) { background: var(--surface); border: 1px solid var(--grid); border-radius: 8px; padding: 16px; margin-bottom: 16px; }
.case-summary { font-size: 15px; }.case-mail { white-space: pre-wrap; color: var(--ink-2); font-size: 13px; margin-top: 10px; }
.case-situation details { margin-top: 12px; }.case-page summary { cursor: pointer; }
.case-steps { display: flex; gap: 8px; margin-bottom: 14px; color: var(--muted); font-size: 12px; }
.case-steps button { border: 1px solid transparent; border-radius: 18px; padding: 4px 10px; background: var(--surface-2); color: var(--muted); cursor: pointer; }
.case-steps [data-state=current] { background: var(--accent-wash); color: var(--accent); font-weight: 600; border-color: var(--accent); }
.case-steps [data-state=done] { background: transparent; color: var(--accent); }
.case-steps [data-state=done]::after { content: " ✓"; }
.case-recommend { background: var(--accent-wash); border-radius: 6px; padding: 10px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.case-reply { border-bottom: 1px solid var(--grid); padding: 12px 0; }
.case-page blockquote,.case-letter blockquote { margin: 6px 0; padding: 8px 10px; border-left: 3px solid var(--axis); background: var(--surface-2); color: var(--muted); font-size: 12px; white-space: pre-wrap; }
.case-modes { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.case-modes [aria-pressed=true] { color: var(--accent); border-color: var(--accent); background: var(--accent-wash); }
.case-page input,.case-page textarea,.case-page select,.case-letter input,.case-letter select { font: inherit; border: 1px solid var(--grid); background: var(--page); color: var(--ink); border-radius: 5px; padding: 6px 8px; }
.case-reply textarea { width: 100%; }.case-page :disabled { opacity: .55; cursor: default; }
.case-task-row { display: flex; gap: 6px; align-items: center; margin: 6px 0; }.case-task-row input[aria-label="内部处理内容"] { flex: 1; min-width: 80px; }
.case-task-row input[type=date] { width: 130px; flex-shrink: 0; }.case-internal { padding: 3px 0; }.case-children:not(:empty) { margin: 6px 0 0 22px; border-left: 2px solid var(--grid); padding-left: 10px; }
.case-item-flags { display: flex; gap: 6px; flex-wrap: wrap; font-size: 11px; color: var(--muted); }.needs-review { background: var(--accent-wash); border-radius: 6px; padding: 8px; }
.case-item-menu { position: relative; flex-shrink: 0; }
.case-item-menu > summary { list-style: none; padding: 2px 8px; font-size: 18px; border-radius: 5px; }
.case-item-menu > summary::-webkit-details-marker { display: none; }
.case-item-menu-actions { position: absolute; right: 0; top: 100%; z-index: 6; display: grid; gap: 4px; padding: 8px; background: var(--surface); border: 1px solid var(--grid); border-radius: 6px; box-shadow: 0 4px 14px var(--ring); min-width: 165px; }
.case-item-menu-actions button { text-align: left; white-space: nowrap; }
.case-suggestion { border: 1px dashed var(--axis); margin: 8px 0; padding: 8px; }
.case-reply-note { display: block; width: 100%; }
.case-generate-actions { display: flex; justify-content: flex-end; margin-top: 14px; }
.case-primary { background: var(--accent); color: white; border: 0; border-radius: 6px; padding: 7px 16px; cursor: pointer; font-weight: 600; }
.case-pair { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 20px; border-bottom: 1px dashed var(--grid); }
.case-para { min-height: 40px; padding: 10px 0; white-space: pre-wrap; overflow-wrap: anywhere; }.case-para[contenteditable=true]:focus { outline: 2px solid var(--accent-wash); }.case-para.cn { color: var(--ink-2); }
.case-fixed { padding: 12px 0; color: var(--muted); }.case-letter mark { background: var(--mark); color: inherit; }
.case-instruct { display: flex; gap: 8px; margin: 14px 0; }.case-instruct input { flex: 1; min-width: 0; }
.case-mirror-state { font-size: 12px; color: var(--muted); }.case-history { font-size: 12px; }
.case-sendbar { position: fixed; bottom: 0; left: 0; right: 0; z-index: 8; background: var(--surface); border-top: 1px solid var(--grid); padding: 10px 24px; display: flex; align-items: flex-start; gap: 20px; max-height: 65vh; overflow: auto; }
.case-envelope-slot { flex: 1; min-width: 220px; }.case-envelope-summary { margin: 0 0 4px; }.case-envelope { font-size: 13px; }.case-envelope .compose-fields { max-width: 850px; }
.case-sendbar .send-controls { margin: 0; padding: 0; border: 0; min-width: 180px; }.case-sendbar .send-controls > h3 { display: none; }.case-sendbar .send-controls p { margin: 2px 0; }
.case-sendbar dialog { max-height: 85vh; overflow: auto; }.case-end { background: var(--surface); color: var(--ink); border: 1px solid var(--grid); border-radius: 8px; padding: 24px; max-width: 600px; }.case-end label { display: flex; gap: 8px; margin: 10px 0; }
.case-format-setting { border-top: 1px solid var(--grid); padding: 12px 0; }.client-project-row[role=link] { cursor: pointer; }
@media(max-width:900px) { .case-columns { grid-template-columns: 1fr; }.case-page { padding: 16px 14px 230px; }.case-sendbar { padding: 10px 14px; flex-wrap: wrap; }.case-situation { font-size: 13px; } }
@media(max-width:600px) { .case-pair { grid-template-columns: 1fr; gap: 0; }.case-task-row { flex-wrap: wrap; }.case-steps { gap: 2px; }.case-steps button { padding: 3px 6px; }.case-children:not(:empty) { margin-left: 12px; } }

/* top bar */
.topbar { display: flex; align-items: center; gap: 16px; padding: 10px 16px; background: var(--surface);
  border-bottom: 1px solid var(--ring); flex: none; }
.brand { font-weight: 600; color: var(--ink); white-space: nowrap; }
.brand:hover { text-decoration: none; }
.search { position: relative; flex: 1; max-width: 720px; }
.search input { width: 100%; padding: 7px 12px; border: 1px solid var(--ring); border-radius: 8px; background: var(--page); }
.search input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.status { color: var(--muted); font-size: 12px; white-space: nowrap; margin-left: auto; }
.ghost { border: 1px solid var(--ring); background: var(--surface); border-radius: 6px; padding: 4px 10px; cursor: pointer; }
.ghost:hover { background: var(--accent-wash); }
.ghost.small { padding: 1px 8px; font-size: 12px; }

.search-panel { position: absolute; top: calc(100% + 6px); left: 0; right: 0; max-height: 70vh; overflow: auto;
  background: var(--surface); border: 1px solid var(--ring); border-radius: 10px; box-shadow: 0 8px 28px rgba(0,0,0,.14);
  z-index: 20; padding: 6px 0; }
.search-panel h4 { margin: 8px 14px 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
.search-panel .hit { display: block; padding: 7px 14px; color: var(--ink); cursor: pointer; }
.search-panel .hit:hover, .search-panel .hit.active { background: var(--accent-wash); text-decoration: none; }
.hit .t { font-weight: 500; }
.hit .m { color: var(--muted); font-size: 12px; }
.hit .s { color: var(--ink-2); font-size: 12px; margin-top: 2px; }
.search-panel .empty { padding: 10px 14px; color: var(--muted); }
mark { background: var(--mark); color: inherit; border-radius: 2px; padding: 0 1px; }

/* three columns */
.cols { flex: 1; display: grid; grid-template-columns: 280px minmax(360px, 440px) 1fr; min-height: 0; }
.cols.home { grid-template-columns: 280px 1fr; }
.cols.home .detail { display: none; }
.client-home { padding: 24px 28px; max-width: 1660px; margin: auto; }
.client-page-head, .client-project-heading, .client-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.client-page-head { justify-content: space-between; margin-bottom: 20px; }
.client-page-head h2 { margin: 0; }
.client-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--grid); border-radius: 10px; margin-bottom: 28px; background: var(--surface-2); }
.client-summary > * { padding: 14px 18px; color: var(--ink); border-right: 1px solid var(--grid); }
.client-summary > :last-child { border-right: 0; }
.client-summary strong { font-size: 28px; font-weight: 600; margin-right: 4px; }
.client-summary .sub { display: block; }
.client-home-columns { display: grid; grid-template-columns: minmax(0, 1fr); gap: 28px; align-items: start; }
.client-groups { min-width: 0; }
.client-group { margin-bottom: 26px; }
.client-group > h3 { margin: 0 0 8px; display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.client-group > h3 a { color: var(--ink); }
.client-group > h3 .sub { font-weight: 400; white-space: nowrap; }
.client-project-row { padding: 10px 8px; border: 0; border-bottom: 1px solid var(--grid); border-left: 3px solid var(--axis); border-radius: 0; margin: 0; background: transparent; }
.client-lanes { flex-wrap: nowrap; gap: 8px; font-size: 12px; }
.client-lanes .client-project-title { flex: 1; min-width: 100px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; }
.client-lanes .tag,.client-customer-lane { flex-shrink: 0; white-space: nowrap; }
.client-followup-actions { display: inline-flex; align-items: center; gap: 8px; flex-shrink: 0; white-space: nowrap; }
.client-internal-lane { max-width: 250px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.client-row-notice { margin: 4px 0 0; color: var(--accent); font-size: 12px; }
.case-notice-node { padding: 8px 0; border-bottom: 1px solid var(--grid); }
.case-notice-node > span { display: block; }
.case-reconcile-row { padding: 10px 0; border-bottom: 1px solid var(--grid); }
.case-reconcile-row button { margin-right: 8px; }
.client-rules-diagram { overflow-x: auto; }
.client-rules svg { width: 100%; min-width: 620px; height: auto; }
.client-playbook { padding: 12px 0; border-bottom: 1px solid var(--grid); }
.client-playbook summary { cursor: pointer; font-weight: 600; }
.client-playbook li { margin: 8px 0; }.client-playbook .tag { margin-left: 6px; }
@media(max-width:1100px) { .client-lanes { flex-wrap: wrap; }.client-lanes .client-project-title { flex-basis: 100%; white-space: normal; }.client-internal-lane { max-width: 100%; white-space: normal; }.client-summary { grid-template-columns: repeat(2,minmax(0,1fr)); } }
.client-project-row.urgency-0 { border-left-color: var(--outbound); }
.client-project-row.urgency-2 { border-left-color: var(--accent); }
.client-project-title { color: var(--ink); font-weight: 500; overflow-wrap: anywhere; flex: 1 1 220px; }
.client-badges { display: inline-flex; gap: 6px; flex-wrap: wrap; align-items: center; font-size: 12px; }
.client-state.wait_me { background: var(--accent-wash); color: var(--accent); }
.client-state.wait_them { color: var(--ink-2); }
.client-state.closed { color: var(--muted); }
.client-pending { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding-top: 10px; margin-top: 8px; border-top: 1px solid var(--grid); font-size: 12px; color: var(--ink-2); }
.client-pending > :first-child { flex: 1; min-width: 120px; overflow-wrap: anywhere; }
.client-agenda { background: var(--surface-2); padding: 16px; border: 1px solid var(--grid); border-radius: 10px; min-width: 0; }
.client-agenda h3 { margin: 0 0 12px; }
.client-agenda h4 { margin: 16px 0 4px; font-size: 12px; color: var(--ink-2); }
.client-todo { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--grid); }
.client-todo > input { flex-shrink: 0; accent-color: var(--accent); }
.client-todo-copy { display: flex; align-items: baseline; gap: 12px; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.client-todo-text { flex: 1; min-width: 0; }
.client-date, .client-todo-copy > a { font-size: 12px; }
.client-date { flex-shrink: 0; white-space: nowrap; }
.client-todo-copy > a { max-width: 45%; }
@media(max-width:600px) { .client-todo-copy { flex-wrap: wrap; gap: 2px; }.client-todo-copy > a { max-width: 100%; flex-basis: 100%; } }
.client-date { color: var(--ink-2); }
.client-date.late,.client-customer-lane.followup-due { color: var(--outbound); font-weight: 600; }
.client-todo.done .client-todo-text { text-decoration: line-through; color: var(--muted); }
.client-todo-editor { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; width: 100%; }
.client-todo-editor input, .client-todo-editor select, .client-actions select { min-width: 0; max-width: 100%; border: 1px solid var(--axis); background: var(--surface); padding: 5px 8px; border-radius: 6px; }
.client-todo-editor input[type=text] { flex: 1 1 170px; }
.client-todo-editor select { flex-basis: 100%; width: 100%; }
.client-todo-editor input[type=date] { width: 145px; }
.client-project { padding: 0 20px 18px; border-bottom: 1px solid var(--grid); }
.client-done { margin: 14px 0; }
.client-done summary { color: var(--ink-2); cursor: pointer; }
.client-party-project { display: grid; gap: 4px; padding: 8px 0; border-bottom: 1px solid var(--grid); }
.client-party-project > a { overflow-wrap: anywhere; }
.client-all-todos { max-width: 1000px; }
.client-error { flex-basis: 100%; }
@media (max-width: 1200px) {
  .client-home-columns { grid-template-columns: minmax(0, 1fr); }
  .client-home { padding: 20px; }
  .client-summary > * { padding: 12px; }
}
@media (max-width: 650px) {
  .client-summary { grid-template-columns: 1fr; }
  .client-summary > * { border-right: 0; border-bottom: 1px solid var(--grid); }
  .client-summary > :last-child { border-bottom: 0; }
}
.col { min-height: 0; overflow: auto; border-right: 1px solid var(--ring); background: var(--surface); }
.col.detail { border-right: 0; background: var(--page); }
.col-tools { position: sticky; top: 0; background: var(--surface); padding: 10px 12px; border-bottom: 1px solid var(--ring);
  display: grid; gap: 8px; z-index: 2; }
.col-tools input, .col-tools select { padding: 5px 8px; border: 1px solid var(--ring); border-radius: 6px; background: var(--page); width: 100%; }
.row { display: flex; gap: 8px; align-items: center; }
.row select { width: auto; flex: 1; }
.seg { display: inline-flex; border: 1px solid var(--ring); border-radius: 6px; overflow: hidden; flex: none; }
.seg button { border: 0; background: transparent; padding: 4px 10px; cursor: pointer; color: var(--ink-2); }
.seg button.on { background: var(--accent-wash); color: var(--ink); font-weight: 600; }

.list { list-style: none; margin: 0; padding: 4px 0; }
.list li { padding: 8px 12px; cursor: pointer; border-left: 3px solid transparent; }
.list li:hover { background: var(--surface-2); }
.list li.sel { background: var(--accent-wash); border-left-color: var(--accent); }
.list li:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.list .name { font-weight: 500; overflow-wrap: anywhere; }
.list .meta { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.list .empty { color: var(--muted); cursor: default; }
.badge { display: inline-block; font-size: 11px; color: var(--ink-2); border: 1px solid var(--ring); border-radius: 4px;
  padding: 0 4px; margin-left: 4px; vertical-align: 1px; font-weight: 400; }

/* party column */
.pad { padding: 14px 16px; }
h2 { font-size: 18px; margin: 0 0 2px; font-weight: 600; overflow-wrap: anywhere; }
h3 { font-size: 13px; margin: 18px 0 8px; font-weight: 600; color: var(--ink-2); }
.sub { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.facts { color: var(--ink-2); font-size: 13px; margin-top: 6px; }
.note { margin-top: 8px; padding: 8px 10px; background: var(--surface-2); border-radius: 6px; font-size: 13px; color: var(--ink-2); }
.note b { color: var(--ink); font-weight: 600; }

.legend { display: flex; gap: 14px; font-size: 12px; color: var(--ink-2); align-items: center; }
.key { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.key.in { background: var(--inbound); }
.key.out { background: var(--outbound); }
.chart-head { display: flex; justify-content: space-between; align-items: baseline; margin: 14px 0 4px; }
.chart-head h3 { margin: 0; }
svg.months { display: block; width: 100%; height: 108px; overflow: visible; }
svg.months .bar { cursor: pointer; }
svg.months .bar:hover path, svg.months .bar.on path { opacity: .75; }
svg.months .hit { fill: transparent; }
svg .grid { stroke: var(--grid); stroke-width: 1; }
svg .base { stroke: var(--axis); stroke-width: 1; }
svg .tick { fill: var(--muted); font-size: 10px; }
.fill-in { fill: var(--inbound); }
.fill-out { fill: var(--outbound); }
.filter-chip { display: inline-flex; gap: 6px; align-items: center; font-size: 12px; background: var(--accent-wash);
  border-radius: 12px; padding: 2px 4px 2px 10px; margin-top: 6px; }
.filter-chip button { border: 0; background: transparent; cursor: pointer; color: var(--ink-2); padding: 0 6px; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--ring); margin: 14px 0 0; position: sticky; top: 0;
  background: inherit; z-index: 1; }
.tabs button { border: 0; background: transparent; padding: 8px 10px; cursor: pointer; color: var(--ink-2);
  border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.on { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.tabs .spacer { flex: 1; }
.tabs select { border: 0; background: transparent; color: var(--ink-2); font-size: 12px; }

.projects { list-style: none; margin: 0; padding: 0; }
.projects li { padding: 10px 16px; border-bottom: 1px solid var(--grid); cursor: pointer; }
.projects li:hover { background: var(--surface-2); }
.projects li.sel { background: var(--accent-wash); }
.projects li:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.projects .title { font-weight: 500; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.projects .meta { color: var(--muted); font-size: 12px; margin-top: 2px; }
.projects .last-in { color: var(--ink-2); }
svg.strip { display: block; width: 100%; height: 14px; margin-top: 6px; }
svg.strip .track { stroke: var(--grid); stroke-width: 2; stroke-linecap: round; }
svg.strip .span { stroke: var(--axis); stroke-width: 6; stroke-linecap: round; }
svg.strip .t-in { stroke: var(--inbound); stroke-width: 2; }
svg.strip .t-out { stroke: var(--outbound); stroke-width: 2; }
svg.strip .t-n { stroke: var(--neutral); stroke-width: 2; }
.more { padding: 10px 16px; color: var(--muted); font-size: 12px; }

/* detail column */
.detail .pad { max-width: 980px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border: 1px solid var(--ring); border-radius: 12px;
  font-size: 12px; color: var(--ink-2); background: var(--surface); cursor: pointer; max-width: 100%; }
.chip:hover { background: var(--accent-wash); text-decoration: none; }
.chip .c { color: var(--muted); }
.owner-link { display: inline-block; margin-top: 5px; max-width: 100%; overflow-wrap: anywhere; text-decoration: none; }
.owner-chip { color: var(--accent); border-color: var(--accent); background: var(--accent-wash); }
.owner-editor { margin-top: 6px; font-size: 12px; }
.owner-editor > summary { color: var(--accent); cursor: pointer; width: fit-content; }
.owner-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px; margin-top: 6px;
  background: var(--surface-2); border: 1px solid var(--ring); border-radius: 8px; }
.owner-form select, .owner-form input { min-width: 0; max-width: 100%; border: 1px solid var(--ring);
  background: var(--page); border-radius: 6px; padding: 5px 8px; flex: 1 1 160px; }
.owner-form input[hidden] { display: none; }
.owner-status { flex-basis: 100%; overflow-wrap: anywhere; }
.owner-status:empty { display: none; }
.owner-editor :is(summary,select,input,button):focus-visible, .owner-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 10px; }

.timeline { padding: 4px 16px 40px; }
.month { position: sticky; top: 37px; z-index: 1; margin: 18px 0 8px; font-size: 12px; color: var(--muted); font-weight: 600;
  background: var(--page); padding: 2px 0; }
.msg { max-width: 82%; margin: 8px 0; background: var(--surface); border: 1px solid var(--ring); border-radius: 10px;
  padding: 10px 12px; border-left: 3px solid var(--inbound); }
.msg.out { margin-left: auto; border-left-color: var(--outbound); }
.msg.n { margin-left: 9%; border-left-color: var(--neutral); }
.msg.target { box-shadow: 0 0 0 2px var(--accent); }
.msg .head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.msg .dir { font-size: 12px; color: var(--ink-2); white-space: nowrap; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; vertical-align: 0; }
.dot.in { background: var(--inbound); }
.dot.out { background: var(--outbound); }
.dot.n { background: var(--neutral); }
.msg .who { font-weight: 500; overflow-wrap: anywhere; }
.msg .when { color: var(--muted); font-size: 12px; margin-left: auto; white-space: nowrap; }
.msg .to { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; margin-top: 2px; }
.msg .subj { color: var(--ink-2); font-size: 12px; margin-top: 4px; overflow-wrap: anywhere; }
.msg .body { white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 8px; font-size: 13.5px; }
.msg .body.clamp { max-height: 11.5em; overflow: hidden; -webkit-mask-image: linear-gradient(#000 70%, transparent); mask-image: linear-gradient(#000 70%, transparent); }
.msg .body.empty { color: var(--muted); font-style: italic; }
.msg .quoted { white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 8px; padding: 8px 10px; background: var(--surface-2);
  border-radius: 6px; font-size: 12.5px; color: var(--ink-2); max-height: 480px; overflow: auto; }
.msg .actions { display: flex; gap: 12px; margin-top: 8px; font-size: 12px; flex-wrap: wrap; }
.msg .actions button, .linkish { border: 0; background: transparent; color: var(--accent); cursor: pointer; padding: 0; font-size: 12px; }
.files { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.attachment-row { width: 100%; min-width: 0; }
.attachment-detail { margin: 6px 0 10px; }
.attachment-detail summary { color: var(--ink-2); font-size: 12px; cursor: pointer; padding: 4px 0; }
.attachment-text { max-height: 360px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere;
  tab-size: 4; font: 12px/1.7 ui-monospace, monospace; padding: 12px; margin: 8px 0 0;
  color: var(--ink); background: var(--surface-2); border: 1px solid var(--ring); border-radius: 6px; }
.file { display: inline-flex; gap: 6px; align-items: center; max-width: 100%; padding: 4px 9px; border: 1px solid var(--ring);
  border-radius: 6px; background: var(--page); color: var(--ink); font-size: 12.5px; }
.file:hover { background: var(--accent-wash); text-decoration: none; }
.file .ext { flex: none; display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 4px;
  font-size: 8.5px; font-weight: 700; letter-spacing: .02em; color: #fff; background: #6b6a66; }
/* File-type colours follow the familiar application icons; white text stays readable in light and dark. */
.file .ext.k-pdf { background: #d93025; }
.file .ext.k-word { background: #2b579a; }
.file .ext.k-excel { background: #1e7145; }
.file .ext.k-ppt { background: #c43e1c; }
.file .ext.k-image { background: #7a4cc2; }
.file .ext.k-cad { background: #00796b; }
.file .ext.k-archive { background: #8a6400; }
.file .ext.k-eml { background: #2a78d6; }
.msg .has-files { display: inline-flex; align-items: center; gap: 2px; border: 0; background: none; padding: 0 2px; cursor: pointer;
  color: var(--ink-2); font: inherit; font-size: 12px; }
.msg .has-files:hover { color: var(--accent); }
.file .nm { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 360px; }
.file .sz { color: var(--muted); font-size: 11px; white-space: nowrap; }

table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th { text-align: left; font-weight: 600; color: var(--ink-2); font-size: 12px; padding: 6px 8px; border-bottom: 1px solid var(--axis);
  position: sticky; top: 37px; background: var(--page); }
table.data td { padding: 6px 8px; border-bottom: 1px solid var(--grid); vertical-align: top; overflow-wrap: anywhere; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data td.date { white-space: nowrap; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.party table.data th { background: var(--surface); top: 0; }

/* home */
.home-wrap { padding: 20px 24px; max-width: 1100px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin: 12px 0 8px; }
.tile { background: var(--surface); border: 1px solid var(--ring); border-radius: 10px; padding: 12px 14px; }
.tile .label { color: var(--ink-2); font-size: 12px; }
.tile .value { font-size: 24px; font-weight: 600; margin-top: 2px; }
.tile .hint { color: var(--muted); font-size: 12px; }
.recent { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--ring); border-radius: 10px; }
.recent li { display: grid; grid-template-columns: 96px 180px 1fr auto; gap: 12px; padding: 9px 14px; border-bottom: 1px solid var(--grid);
  cursor: pointer; align-items: baseline; }
.recent li:last-child { border-bottom: 0; }
.recent li:hover { background: var(--accent-wash); }
.recent .d { color: var(--ink-2); font-size: 12px; font-variant-numeric: tabular-nums; }
.recent .p { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.recent .t { overflow-wrap: anywhere; }
.recent .c { color: var(--muted); font-size: 12px; white-space: nowrap; }
.inbox-filters { margin: 0 0 10px; }
.inbox { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--ring); border-radius: 10px; }
.inbox > li { border-bottom: 1px solid var(--grid); }
.inbox > li:last-child { border-bottom: 0; }
.inbox > li.open { background: var(--surface-2); }
.inbox .row-head { display: grid; grid-template-columns: 116px 180px 1fr auto; gap: 12px; padding: 9px 14px; cursor: pointer; align-items: baseline; }
.inbox .row-head:hover { background: var(--accent-wash); }
.inbox .row-head:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.inbox .d { color: var(--ink-2); font-size: 12px; font-variant-numeric: tabular-nums; }
.inbox .p { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.inbox .tags { display: flex; flex-wrap: wrap; gap: 4px; }
.inbox .s { margin-top: 2px; overflow-wrap: anywhere; }
.inbox-detail { padding: 2px 14px 12px 142px; font-size: 13px; }
.verdict { display: inline-flex; border: 1px solid var(--ring); border-radius: 6px; overflow: hidden; align-self: center; }
.verdict button { border: 0; background: transparent; padding: 1px 8px; font-size: 12px; color: var(--muted); cursor: pointer; white-space: nowrap; }
.verdict button + button { border-left: 1px solid var(--ring); }
.verdict button:hover { background: var(--accent-wash); color: var(--ink); }
.verdict button.on { background: var(--accent-wash); color: var(--ink); font-weight: 600; cursor: default; }
.inbox-detail .subj { color: var(--ink-2); overflow-wrap: anywhere; }
.inbox-detail .why { color: var(--ink-2); margin-top: 4px; }
.inbox-detail .why b { color: var(--ink); font-weight: 600; }
.inbox-detail .body { white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 8px; padding: 8px 10px; background: var(--surface);
  border: 1px solid var(--ring); border-radius: 6px; max-height: 320px; overflow: auto; font-size: 13px; }
.inbox-detail .actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-top: 10px; font-size: 12px; }
.linkish.more { margin-top: 6px; }
.help { color: var(--ink-2); font-size: 13px; line-height: 1.7; }
.help b { color: var(--ink); }

.empty-state { padding: 40px 24px; color: var(--muted); }
.loading { opacity: .55; transition: opacity .15s; }
.error { margin: 16px; padding: 10px 12px; border-radius: 6px; background: var(--surface-2); color: var(--ink); }

.tooltip { position: fixed; z-index: 50; pointer-events: none; background: var(--surface); border: 1px solid var(--ring);
  border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.14); padding: 8px 10px; font-size: 12px; max-width: 320px; }
.tooltip .tt { color: var(--ink-2); margin-bottom: 4px; }
.tooltip .tr { display: flex; align-items: center; gap: 6px; }
.tooltip .tr b { font-weight: 600; color: var(--ink); min-width: 1.5em; }
.tooltip .lk { display: inline-block; width: 12px; height: 2px; }
.tooltip .lk.in { background: var(--inbound); }
.tooltip .lk.out { background: var(--outbound); }

.back-to-party { display: none; margin-bottom: 8px; }
.pad-x { padding: 0 16px; }

@media (max-width: 1100px) {
  .cols, .cols.home { grid-template-columns: 240px 1fr; }
  .cols.has-project .party { display: none; }
  .cols:not(.has-project) .detail { display: none; }
  .back-to-party { display: inline-flex; }
  .recent li { grid-template-columns: 90px 1fr; }
  .recent .t, .recent .c { grid-column: 2; }
  .inbox .row-head { grid-template-columns: 90px 1fr; }
  .inbox .row-head .t, .inbox .row-head .verdict { grid-column: 2; justify-self: start; }
  .inbox-detail { padding-left: 14px; }
}

/* triage tags – status colors carry an icon or a label, never color alone */
.tag { display: inline-flex; align-items: center; gap: 3px; font-size: 11px; line-height: 16px; padding: 0 6px;
  border-radius: 4px; border: 1px solid var(--ring); color: var(--ink-2); background: var(--surface); white-space: nowrap; }
.tag.important { border-color: var(--inbound); color: var(--ink); }
.tag.unimportant, .tag.cat { color: var(--muted); }
.tag.reference { border-color: var(--axis); color: var(--ink-2); }
.tag.reply { border-color: var(--outbound); color: var(--ink); }
.tag.warn { background: #d03b3b; border-color: #d03b3b; color: #ffffff; font-weight: 600; }
.msg .triage { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 6px; }
.msg .triage .sum { color: var(--ink-2); font-size: 12px; }
.msg .signals { margin-top: 4px; font-size: 12px; color: var(--ink-2); }
.row-tags { display: flex; gap: 6px; margin-top: 3px; }
.row-sum { color: var(--ink-2); font-size: 12px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chips .tag { align-self: center; }

/* view switch */
.views { display: flex; gap: 2px; background: var(--surface-2); border-radius: 8px; padding: 2px; flex: none; }
.views a { padding: 3px 12px; border-radius: 6px; color: var(--ink-2); font-size: 13px; }
.views a:hover { text-decoration: none; color: var(--ink); }
.views a.on { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 0 0 1px var(--ring); }

/* relationship map */
.cols.map, .cols.map.home { grid-template-columns: 1fr; }
.cols.map .parties, .cols.map .detail { display: none !important; }
.cols.map .party { display: block !important; background: var(--page); }
.map-head { padding: 20px 24px 4px; }
.crumbs { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.map-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 22px; margin-top: 12px; }
.map-tools .legend { flex-wrap: wrap; gap: 10px; }
.key.rc0, .key.rc1, .key.rc2, .key.rc3 { width: 12px; height: 12px; border-radius: 50%; }
.key.rc0 { background: var(--rc0); } .key.rc1 { background: var(--rc1); } .key.rc2 { background: var(--rc2); } .key.rc3 { background: var(--rc3); }
.badge-key { display: inline-grid; place-items: center; width: 14px; height: 14px; border-radius: 50%; margin-right: 5px;
  background: var(--warning); color: #0b0b0b; font-size: 10px; font-weight: 700; vertical-align: -2px; }
.bubbles { padding: 8px 24px 32px; }
.map-stage { position: relative; }
svg.bubble-map { display: block; width: 100%; height: auto; margin: 0 auto; overflow: hidden; touch-action: none; }
svg.bubble-map.zoomed { cursor: grab; }
svg.bubble-map.dragging, svg.bubble-map.dragging .bubble { cursor: grabbing; }
svg.bubble-map .c, svg.bubble-map .badge { vector-effect: non-scaling-stroke; }
.map-zoom { position: absolute; top: 0; right: 0; display: flex; gap: 4px; }
.map-zoom button { min-width: 30px; }
svg .c.rc0 { fill: var(--rc0); } svg .c.rc1 { fill: var(--rc1); } svg .c.rc2 { fill: var(--rc2); } svg .c.rc3 { fill: var(--rc3); }
svg .lbl { text-anchor: middle; font-weight: 600; pointer-events: none; }
svg .lbl.sub { font-weight: 400; opacity: .85; }
svg .on0 { fill: var(--on0); } svg .on1 { fill: var(--on1); } svg .on2 { fill: var(--on2); } svg .on3 { fill: var(--on3); }
.bubble { cursor: pointer; outline: none; animation: grow .45s cubic-bezier(.2, .8, .2, 1) both; transform-box: fill-box; transform-origin: center; }
.bubble .hit { fill: transparent; }
.bubble .c { stroke: var(--page); stroke-width: 2; transition: stroke .12s; }
.bubble:hover .c, .bubble:focus-visible .c { stroke: var(--ink); stroke-width: 2.5; }
.bubble .badge, svg .badge { fill: var(--warning); stroke: var(--page); stroke-width: 2; }
svg .badge-t { fill: #0b0b0b; font-size: 10px; font-weight: 700; text-anchor: middle; pointer-events: none; }
@keyframes grow { from { opacity: 0; transform: scale(.4); } to { opacity: 1; transform: none; } }

.tree-wrap { padding: 8px 24px 40px; overflow-x: auto; }
svg.tree { display: block; overflow: visible; }
svg.tree .link { fill: none; stroke: var(--axis); stroke-width: 1.5; }
svg.tree .link.muted { stroke: var(--grid); }
svg.tree .root .c { stroke: var(--page); stroke-width: 2; }
svg.tree .root-name { text-anchor: middle; font-size: 14px; font-weight: 600; fill: var(--ink); }
svg.tree .meta { font-size: 11px; fill: var(--muted); }
svg.tree .title { font-size: 13px; fill: var(--ink); }
svg.tree .flag { fill: var(--ink); font-weight: 600; }
svg.tree .flag.warn { fill: #d03b3b; }
svg.tree .pill { cursor: pointer; outline: none; }
svg.tree .pill rect { fill: var(--surface); stroke: var(--axis); stroke-width: 1; }
svg.tree .pill.open rect { stroke: var(--accent); }
svg.tree .pill text { font-size: 12.5px; font-weight: 600; fill: var(--ink); }
svg.tree .pill .count { font-weight: 400; fill: var(--muted); }
svg.tree .pill.muted text { fill: var(--ink-2); font-weight: 400; }
svg.tree .pill:hover rect, svg.tree .pill:focus-visible rect { fill: var(--accent-wash); }
svg.tree .leaf { cursor: pointer; outline: none; }
svg.tree .leaf .row { fill: transparent; }
svg.tree .leaf:hover .row, svg.tree .leaf:focus-visible .row { fill: var(--accent-wash); }
svg.tree .leaf.muted .title { fill: var(--ink-2); }
svg.tree .dot-in { fill: var(--inbound); stroke: var(--page); stroke-width: 2; }
svg.tree .dot-out { fill: var(--outbound); stroke: var(--page); stroke-width: 2; }
svg.tree .dot-n { fill: var(--neutral); stroke: var(--page); stroke-width: 2; }
svg.tree .enter { animation: slide-in .35s ease-out both; }
@keyframes slide-in { from { opacity: 0; transform: translateX(-8px); } to { opacity: 1; transform: none; } }
.tooltip .lk.n { background: var(--neutral); }
.tooltip .lk.warn { background: var(--warning); }
@media (prefers-reduced-motion: reduce) {
  .bubble, svg.tree .enter { animation: none; }
}
@media (max-width: 1100px) {
  .cols.map, .cols.map.home { grid-template-columns: 1fr; }
}

/* Question panel shares the archive's surfaces, blue accent and compact type. */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.qa-launch { white-space: nowrap; color: var(--accent); font-weight: 600; padding: 6px 10px; }
.qa-launch kbd { font: 10px var(--font); color: var(--muted); margin-left: 8px; font-weight: 400; }
.qa-panel { position: fixed; z-index: 30; right: 0; top: 54px; bottom: 0; width: min(720px, calc(100vw - 560px));
  display: flex; flex-direction: column; min-width: 0; background: var(--surface); border-left: 1px solid var(--grid);
  box-shadow: -12px 0 36px rgba(0,0,0,.08); animation: qa-enter .18s ease-out; }
.qa-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 24px 12px; flex: none; }
.qa-header h2 { font-size: 18px; margin: 0; }
.qa-header-actions { display: flex; gap: 6px; align-items: center; }
.qa-icon { font-size: 22px; line-height: 24px; padding: 3px 10px; }
.qa-scope-row { display: flex; gap: 10px; align-items: center; padding: 0 24px 14px; border-bottom: 1px solid var(--grid); }
.qa-scope-row select { flex: 1; min-width: 0; max-width: 100%; text-overflow: ellipsis; border: 1px solid var(--ring); border-radius: 6px; padding: 5px 8px; background: var(--surface-2); font-size: 12px; }
.qa-messages { flex: 1; min-height: 0; overflow: auto; padding: 24px; overscroll-behavior: contain; scroll-padding: 20px; }
.qa-empty { max-width: 460px; margin: min(7vh, 64px) auto 30px; }
.qa-empty-mark { width: 42px; height: 42px; display: grid; place-items: center; color: var(--accent); background: var(--accent-wash); border: 1px solid var(--ring); border-radius: 12px; font-size: 24px; margin-bottom: 20px; }
.qa-empty h3 { color: var(--ink); font-size: 21px; font-weight: 600; margin: 0 0 5px; }
.qa-empty-scope { font-size: 13px; color: var(--ink-2); margin: 0 0 24px; overflow-wrap: anywhere; }
.qa-example { display: block; width: 100%; text-align: left; border: 1px solid var(--grid); border-radius: 8px; padding: 12px 14px; background: var(--page); margin: 8px 0; cursor: pointer; font-size: 13px; line-height: 1.6; }
.qa-example:hover { background: var(--accent-wash); border-color: var(--accent); }
.qa-turn + .qa-turn { border-top: 1px solid var(--grid); padding-top: 24px; margin-top: 28px; }
.qa-question-bubble { margin: 0 0 24px auto; padding: 12px 16px; border-radius: 12px 12px 3px 12px; background: var(--surface-2); max-width: 88%; width: fit-content; white-space: pre-wrap; overflow-wrap: anywhere; font-weight: 500; }
.qa-answer { min-width: 0; }
.qa-answer-label { display: flex; gap: 8px; align-items: center; color: var(--accent); font-size: 12px; font-weight: 600; margin-bottom: 12px; }
.qa-markdown { line-height: 1.8; font-size: 13.5px; overflow-wrap: anywhere; }
.qa-markdown p { margin: 8px 0; white-space: pre-wrap; }
.qa-markdown strong { font-weight: 600; }
.qa-markdown h4 { font-size: 14px; margin: 18px 0 8px; }
.qa-markdown ul, .qa-markdown ol { padding-left: 22px; margin: 10px 0; }
.qa-markdown li { padding-left: 2px; margin: 5px 0; }
.qa-table-wrap { overflow: auto; max-width: 100%; margin: 14px 0; border: 1px solid var(--grid); border-radius: 8px; }
.qa-table { border-collapse: collapse; width: 100%; min-width: 340px; text-align: left; font-size: 12.5px; }
.qa-table th { background: var(--surface-2); color: var(--ink-2); font-weight: 600; padding: 9px 12px; border-bottom: 1px solid var(--grid); }
.qa-table td { vertical-align: top; padding: 9px 12px; border-bottom: 1px solid var(--grid); min-width: 72px; }
.qa-table tr:last-child td { border-bottom: 0; }
.qa-cite { display: inline-flex; align-items: center; gap: 3px; color: var(--accent); background: var(--accent-wash); border: 0; border-radius: 4px; font-size: 11px; line-height: 1.6; padding: 0 4px; cursor: pointer; margin: 0 2px; vertical-align: 1px; }
.qa-cite.unverified { color: var(--ink-2); background: var(--surface-2); box-shadow: inset 0 -2px var(--warning); }
.qa-unverified-label { font-size: 10px; white-space: nowrap; }
.qa-sources { margin: 20px 0 10px; }
.qa-sources-label { color: var(--muted); font-size: 11px; margin-bottom: 7px; }
.qa-source { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 9px 10px; margin: 5px 0; border: 1px solid var(--grid); border-radius: 7px; background: var(--page); cursor: pointer; min-width: 0; }
.qa-source:hover { background: var(--accent-wash); }
.qa-source-number { display: grid; place-items: center; width: 23px; height: 23px; flex: none; color: var(--accent); background: var(--accent-wash); border-radius: 5px; font-size: 11px; }
.qa-source-info { display: flex; flex-direction: column; min-width: 0; flex: 1; gap: 2px; }
.qa-source-title { color: var(--ink); font-size: 12px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qa-source-status { white-space: nowrap; font-size: 11px; color: var(--ink-2); }
.qa-source.unverified { border-left: 3px solid var(--warning); }
.qa-source.unverified .qa-source-number { color: var(--ink-2); background: var(--surface-2); }
.qa-answer-meta { color: var(--muted); font-size: 11px; margin-top: 12px; }
.qa-citation-tip { position: fixed; z-index: 60; width: 320px; max-width: calc(100vw - 24px); padding: 14px; border: 1px solid var(--grid); border-radius: 10px; background: var(--surface); box-shadow: 0 8px 30px rgba(0,0,0,.18); pointer-events: none; }
.qa-source-heading { font-size: 11px; color: var(--ink-2); margin-bottom: 7px; }
.qa-quote { margin: 10px 0; font-size: 13px; line-height: 1.7; color: var(--ink); overflow-wrap: anywhere; white-space: pre-wrap; border-left: 2px solid var(--accent); padding-left: 10px; }
.qa-progress { border: 1px solid var(--grid); background: var(--page); border-radius: 8px; padding: 14px; font-size: 12px; }
.qa-progress-top { display: flex; align-items: center; gap: 8px; color: var(--ink-2); }
.qa-progress-top > span:nth-child(2) { flex: 1; overflow-wrap: anywhere; }
.qa-progress-dot { width: 7px; height: 7px; background: var(--accent); border-radius: 50%; flex: none; animation: qa-pulse 1.8s ease-in-out infinite; }
.qa-elapsed { font-variant-numeric: tabular-nums; color: var(--muted); white-space: nowrap; font-size: 11px; }
.qa-progress-steps { padding-left: 22px; color: var(--muted); margin: 10px 0; line-height: 1.8; }
.qa-cancel { margin-top: 12px; }
.qa-composer { padding: 14px 24px 18px; background: var(--surface); border-top: 1px solid var(--grid); flex: none; }
.qa-composer textarea { display: block; resize: vertical; width: 100%; min-height: 76px; max-height: 180px; font: 13px/1.7 var(--font); color: var(--ink); background: var(--page); border: 1px solid var(--axis); border-radius: 9px; padding: 10px 12px; }
.qa-composer textarea::placeholder { color: var(--muted); }
.qa-compose-bottom { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 10px; }
.qa-compose-bottom .sub { font-size: 11px; }
.qa-primary { background: var(--accent); color: var(--surface); border: 0; padding: 6px 16px; border-radius: 7px; font-weight: 600; font-size: 12px; cursor: pointer; }
.qa-primary:disabled { background: var(--surface-2); color: var(--muted); cursor: default; }
.qa-panel :is(button,select,textarea,[tabindex="0"]):focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.qa-history-list { max-height: 40%; overflow: auto; padding: 8px 24px; border-bottom: 1px solid var(--grid); background: var(--page); }
.qa-history-row { display: flex; gap: 10px; align-items: center; border-bottom: 1px solid var(--grid); padding: 8px 0; }
.qa-history-row:last-child { border-bottom: 0; }
.qa-history-open { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; text-align: left; background: transparent; border: 0; cursor: pointer; padding: 4px 0; }
.qa-history-open > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.qa-error { padding: 8px 24px; background: var(--surface-2); color: var(--ink); border-top: 2px solid var(--warning); font-size: 12px; }
.qa-turn-error { padding: 10px 12px; background: var(--surface-2); border-left: 2px solid var(--warning); margin-bottom: 10px; border-radius: 4px; font-size: 13px; }
.mail-passage { margin: 0 0 1em; white-space: pre-wrap; overflow-wrap: anywhere; scroll-margin: 100px 0; border-radius: 3px; transition: background .25s, box-shadow .25s; }
.mail-passage:last-child { margin-bottom: 0; }
.passage-label { display: block; font: 10px var(--font); color: var(--muted); margin-bottom: 4px; }
.mail-passage.passage-target { background: var(--mark); box-shadow: 0 0 0 6px var(--mark); outline: none; }
.source-status { position: fixed; z-index: 70; left: 50%; bottom: 28px; transform: translateX(-50%); background: var(--surface); border: 1px solid var(--axis); border-radius: 8px; padding: 10px 16px; box-shadow: 0 4px 20px rgba(0,0,0,.14); max-width: calc(100vw - 32px); font-size: 13px; }
.cols.orphan-project { grid-template-columns: 280px 1fr; }
.cols.orphan-project .party { display: none; }
@keyframes qa-pulse { 50% { opacity: .3; } }
@keyframes qa-enter { from { transform: translateX(12px); opacity: .6; } to { transform: none; opacity: 1; } }
@media (max-width: 1000px) {
  .qa-panel { top: 0; width: 100%; border-left: 0; }
  .qa-header, .qa-scope-row, .qa-composer { padding-left: 24px; padding-right: 24px; }
  .qa-messages { padding: 24px max(24px, calc((100vw - 700px) / 2)); }
  .qa-composer { padding-left: max(24px, calc((100vw - 700px) / 2)); padding-right: max(24px, calc((100vw - 700px) / 2)); }
  .qa-launch kbd { display: none; }
  .qa-is-open { overflow: hidden; }
}
@media (max-width: 600px) {
  .qa-header { padding: 12px 16px; }
  .qa-scope-row { padding: 0 16px 12px; }
  .qa-messages { padding: 18px 16px; }
  .qa-composer { padding: 12px 16px max(12px, env(safe-area-inset-bottom)); }
  .qa-compose-bottom .sub { max-width: 140px; }
  .qa-source-status { font-size: 10px; }
}
@media (prefers-reduced-motion: reduce) { .qa-panel, .qa-progress-dot { animation: none; } .mail-passage { transition: none; } }

.inline-images { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 2px; }
.inline-images a, .attachment-row .thumb { display: block; width: fit-content; border: 1px solid var(--grid); border-radius: 6px; overflow: hidden; background: var(--page); line-height: 0; }
.inline-images img, .attachment-row .thumb img { display: block; max-width: 220px; max-height: 160px; width: auto; height: auto; object-fit: contain; }
.attachment-row .thumb { margin: 2px 0 6px; }
.inline-images a:hover, .inline-images a:focus-visible, .attachment-row .thumb:hover { border-color: var(--accent); }

/* Attachment tables: the file name gives way so the project column stays readable. */
.data .file .nm { max-width: 240px; }
.data td.proj { min-width: 140px; }

/* Incoming analysis: mail remains readable at both desktop and narrow widths. */
.client-mail-summary { margin: 2px 0 12px; font-size: 13px; line-height: 1.7; overflow-wrap: anywhere; }
.client-analysis-notice { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; color: var(--muted); font-size: 13px; margin: 12px 0; }
.client-handle-columns { display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, .75fr); gap: 28px; margin-top: 24px; }
.client-handle-columns:has(.compose-editor) { grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); }
.client-handle-columns:has(.client-reading-panel:not([open])) { grid-template-columns: minmax(130px, .6fr) minmax(0, 3fr); }
.client-reading-panel { min-width: 0; }
.client-reading-panel > summary { margin-bottom: 16px; color: var(--muted); cursor: pointer; font-size: 13px; }
.client-handle-reading, .client-compose-placeholder { min-width: 0; }
.client-handle-reading > section { margin-bottom: 24px; }
.client-handle h3 { font-size: 15px; margin: 12px 0; }
.client-handle h4 { font-size: 13px; margin: 16px 0 8px; color: var(--muted); }
.client-handle li { margin: 8px 0; }
.client-mail-body { font-size: 14px; line-height: 1.85; white-space: pre-wrap; overflow-wrap: anywhere; }
.client-mail-body p { margin: 0 0 14px; }
.client-analysis-summary { padding: 12px 18px; background: var(--surface-2); border-radius: 8px; }
.client-compose-placeholder { border-left: 1px solid var(--grid); padding-left: 28px; min-height: 200px; }
.client-suggestion { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--grid); }
.client-suggestion > span:first-child { flex: 1; min-width: 140px; overflow-wrap: anywhere; }
.client-earlier { border-top: 1px solid var(--grid); padding: 16px 0; }
.client-earlier-row { margin: 16px 0; font-size: 13px; overflow-wrap: anywhere; }
.client-compose { min-width: 0; border-left: 1px solid var(--grid); padding-left: 24px; }
.error:empty, .compose-notice:empty, .compose-warning:empty { display: none; }
.compose-editor input:not([type="checkbox"]), .compose-editor textarea, .compose-editor select,
.compose-settings textarea, .compose-settings select { width: 100%; min-width: 0; color: var(--ink); background: var(--surface); border: 1px solid var(--axis); border-radius: 6px; padding: 8px; font: inherit; }
.compose-editor textarea, .compose-settings textarea { resize: vertical; line-height: 1.7; }
.compose-field { display: grid; gap: 6px; margin: 10px 0; font-size: 12px; }
.compose-field > span { color: var(--muted); }
.compose-pair { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 12px; }
.compose-editor > section, .compose-editor > details { margin: 24px 0; }
.compose-editor .client-actions { margin: 12px 0; }
.compose-editor .client-actions select { width: auto; }
.compose-comparison { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 16px; border-bottom: 1px solid var(--grid); font-size: 13px; line-height: 1.8; }
.compose-comparison p { white-space: pre-wrap; overflow-wrap: anywhere; }
.compose-notice, .compose-warning { display: block; padding: 8px 12px; border-left: 3px solid var(--warning); background: var(--surface-2); font-size: 13px; }
.compose-page, .compose-settings { max-width: 900px; }
.compose-editor pre, .compose-settings pre { white-space: pre-wrap; overflow-wrap: anywhere; font: 13px/1.8 var(--font); }
.compose-settings section { margin: 28px 0; }
.compose-settings section > label { display: block; margin-top: 10px; }
.compose-candidate { border: 1px solid var(--grid); border-radius: 8px; padding: 10px 16px; margin: 12px 0; }
@media (max-width: 1000px) {
  .client-handle-columns, .client-handle-columns:has(.compose-editor), .client-handle-columns:has(.client-reading-panel:not([open])) { grid-template-columns: minmax(0, 1fr); }
  .client-compose-placeholder { border-left: 0; border-top: 1px solid var(--grid); padding: 20px 0; }
  .client-compose { border-left: 0; border-top: 1px solid var(--grid); padding: 20px 0; }
}
/* Native modal confirmation blocks background interaction and traps focus. */
.send-controls, .send-settings { border-top:1px solid var(--grid); margin-top:24px; padding-top:20px; }
.send-confirm { width:min(640px,calc(100vw - 40px)); max-height:85vh; overflow:auto; color:var(--ink); border:1px solid var(--grid); border-radius:10px; padding:24px; background:var(--surface); }
.send-confirm::backdrop { background:rgba(0,0,0,.55); }
.send-confirm > .compose-notice, .send-confirm > .compose-warning { font-weight:650; padding:12px; background:var(--mark); color:#382600; border-radius:6px; }
.send-real-recipient { color:#b93321; font-weight:650; }
.compose-editable[aria-disabled="true"] { opacity:.6; }
.compose-readonly pre { white-space:pre-wrap; overflow-wrap:anywhere; font:inherit; line-height:1.7; }
@media(prefers-color-scheme:dark) { .send-real-recipient { color:#ff9989; } }
.send-confirm p, .send-local p { overflow-wrap:anywhere; }
.send-promise { display:grid; grid-template-columns:auto minmax(0,1fr) 145px; align-items:center; gap:8px; margin:12px 0; }
.send-promise input:not([type=checkbox]), .send-promise div { min-width:0; width:100%; }
.send-local { padding:18px; margin:16px 0; }
.send-local pre { white-space:pre-wrap; overflow-wrap:anywhere; }
@media(max-width:700px) { .send-promise { grid-template-columns:auto minmax(0,1fr); } .send-promise input[type=date] { grid-column:2; } }
/* Client login uses the existing form rhythm, including narrow screens. */
.client-login { max-width: 32rem; margin: 2rem auto; }
.client-login form { display: grid; gap: 1rem; margin-bottom: 1rem; }
.client-login-settings { margin: 2rem 0; }
/* Archive login shares the panel palette, without loading mail navigation. */
.archive-login-page { display: grid; place-items: center; min-height: 100vh; height: auto; }
.archive-login-card { width: min(420px,calc(100% - 40px)); padding: 28px; background: var(--surface); border: 1px solid var(--grid); border-radius: 12px; }
.archive-login-card h1 { font-size: 20px; margin: 0 0 24px; }
.archive-login-card label { display: grid; gap: 8px; margin: 18px 0; }
.archive-login-card input { width: 100%; padding: 10px; border: 1px solid var(--axis); border-radius: 6px; background: var(--surface); color: var(--ink); }
.archive-login-card code { display: block; overflow-wrap: anywhere; }
#archive-account { white-space: nowrap; }
.archive-menu { display: inline-block; position: relative; }
.archive-menu summary { cursor: pointer; padding: 4px 8px; }
.archive-menu > div { position: absolute; right: 0; top: 100%; z-index: 20; padding: 8px; background: var(--surface); border: 1px solid var(--grid); border-radius: 6px; display: grid; gap: 8px; }
#archive-audit { color: var(--ink); background: var(--surface); border: 1px solid var(--grid); border-radius: 10px; width: min(900px,95vw); max-height: 85vh; }
#archive-audit::backdrop { background: #0008; }
#archive-audit header { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.archive-audit-scroll { overflow: auto; max-height: 60vh; }
#archive-audit table { border-collapse: collapse; width: 100%; text-align: left; font-size: 13px; }
#archive-audit th,#archive-audit td { padding: 8px; border-bottom: 1px solid var(--grid); overflow-wrap: anywhere; }
.archive-title { display:flex; align-items:flex-start; gap:12px; flex-wrap:wrap; }
.archive-title h2 { flex:1 1 180px; margin-top:0; }
.archive-assignment { font-size:12px; display:grid; gap:4px; max-width:100%; color:var(--muted); }
.archive-assignment details { position:relative; }
.archive-assignment summary { cursor:pointer; color:var(--ink); }
.archive-assignment details > div { position:absolute; z-index:30; right:0; min-width:180px; padding:12px; background:var(--surface); border:1px solid var(--grid); border-radius:8px; max-height:240px; overflow:auto; }
.archive-assignment label { display:flex; gap:8px; align-items:center; padding:6px; color:var(--ink); }
.archive-admin-dialog { color:var(--ink); background:var(--surface); border:1px solid var(--grid); border-radius:12px; padding:24px; width:min(640px,94vw); max-height:85vh; overflow:auto; }
.archive-admin-dialog::backdrop { background:#0008; }
.archive-admin-dialog header { display:flex; align-items:center; justify-content:space-between; gap:16px; }
.archive-admin-dialog form { display:flex; gap:10px; margin:16px 0; }
.archive-admin-dialog input:not([type=checkbox]),.archive-admin-dialog textarea { min-width:0; width:100%; padding:10px; border:1px solid var(--axis); border-radius:6px; color:var(--ink); background:var(--surface); }
.archive-admin-dialog label { display:grid; gap:6px; margin:14px 0; overflow-wrap:anywhere; }
.archive-admin-dialog li { display:flex; gap:10px; justify-content:space-between; align-items:center; border-bottom:1px solid var(--grid); padding:8px 0; }
.archive-admin-dialog ul { list-style:none; padding:0; }
.archive-admin-dialog p:empty { display:none; }
.archive-user-row { padding:6px 0; border-bottom:1px solid var(--grid); }
.archive-enroll-qr { width:220px; max-width:100%; background:white; padding:8px; }
