/* Replies desk and Settings & help. Tokens and base components live in /styles.css; follow ../DESIGN.md.
   Layout: the landing page's Work widget (rail | list | preview). Every rule is scoped to .desk or .help-*.
   Spacing on the 4/8px scale; colors only through tokens; gold only as the selected edge and the hot dot. */

/* ============================== Replies desk ============================== */
.desk { display: grid; gap: 16px; }

/* --- Log a reply: a dialog opened from the rail, so the desk is the first thing on the page.
   CSV import is the secondary action inside it. Base dialog look: styles.css. --- */
dialog.desk-log { width: min(760px, calc(100% - 32px)); max-width: 760px; max-height: calc(100vh - 48px); padding: 0; overflow: auto; }
.desk-log-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 20px 24px 16px; border-bottom: 1px solid var(--border-hair); }
dialog .desk-log-hint { margin-top: 4px; font-size: var(--fs-small); line-height: 1.5; color: var(--text-2); }
.desk-log-body { padding: 20px 24px 24px; }
.desk-log label { margin-top: 0; }
.desk-rail-foot { display: grid; gap: 6px; margin-top: auto; padding: 20px 20px 0; }
.desk-rail-foot small { font-size: var(--fs-caption); color: var(--text-2); }
.desk-form textarea { min-height: 120px; }
.desk-form .actions { margin-top: 0; }
.desk-import { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border-hair); }
.desk-import label { flex: 1 1 320px; max-width: 560px; }
.desk-import input[type=file] { padding: 7px 10px; font-size: var(--fs-small); }
.desk-import small { display: block; margin-top: 6px; font: 400 var(--fs-caption)/1.5 var(--font-body); color: var(--text-2); }

/* --- The three panes --- */
.panes.three.desk-panes { grid-template-columns: 208px minmax(280px, 360px) minmax(0, 1fr); min-height: 560px; }

/* Rail: queues (server filters, gold edge when active) and a read-only tally of the loaded list */
.desk-rail { display: flex; flex-direction: column; padding: 12px 0 16px; }
.desk-tally + .pane-rail-title, .desk-filter + .pane-rail-title { margin-top: 20px; }
.desk-filter { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; padding: 10px 20px 10px 17px; border: 0; border-left: 3px solid transparent; background: transparent; color: var(--text-2); font: 500 var(--fs-body)/1.3 var(--font-body); text-align: left; transition: background .15s ease, color .15s ease; }
.desk-filter:hover { color: var(--text); background: var(--surface); }
.desk-filter.is-selected, .desk-filter[aria-pressed=true] { border-left-color: var(--gold-mark); background: var(--surface); color: var(--text); font-weight: 600; }
.desk-filter:focus-visible { outline-offset: -3px; }
.desk-filter small { flex: none; min-width: 22px; padding: 0 7px; border: 1px solid var(--border-cool); border-radius: var(--radius-pill); background: var(--surface); color: var(--text); font: 600 var(--fs-micro)/18px var(--font-body); text-align: center; font-variant-numeric: tabular-nums; }
.desk-tally { list-style: none; margin: 0; padding: 0 20px; }
.desk-tally-row { display: flex; align-items: center; gap: 8px; padding: 5px 0; font-size: var(--fs-small); color: var(--text-2); }
.desk-tally-row small { margin-left: auto; font-size: var(--fs-caption); font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.desk-tally-row.is-zero { color: var(--text-3); }
.desk-tally-row.is-zero small { color: var(--text-2); font-weight: 400; }
.desk-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--status-neutral-dot); box-shadow: var(--status-dot-ring); }
.desk-dot.warn { background: var(--status-warn-dot); }
.desk-dot.danger { background: var(--status-danger-dot); }
.desk-dot.paused { background: var(--status-paused-dot); }
.desk-dot.ok { background: var(--status-ok-dot); }
.is-zero .desk-dot { opacity: .45; }

/* List: kicker (brand) + age, sender, one pill + owner. Selected = gold edge + sunken + 600. */
.desk-list { display: flex; flex-direction: column; max-height: calc(100vh - 200px); }
.desk-list > .pane-header { position: sticky; top: 0; z-index: 1; flex: none; }
.desk-list > .pane-header span:last-child { font-variant-numeric: tabular-nums; }
.desk-row { display: grid; gap: 4px; }
.desk-row-line { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
.desk-row .row-kicker, .desk-row .row-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.desk-row .row-kicker { min-width: 0; }
.desk-row .row-title { font-size: var(--fs-body); }
.desk-age { flex: none; font-size: var(--fs-caption); color: var(--text-2); font-variant-numeric: tabular-nums; }
.desk-row-foot { margin-top: 2px; }
.desk-row-foot .pill { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.desk-owner { flex: none; font-size: var(--fs-caption); color: var(--text-2); }
.desk-list .empty-state { margin: 16px; }

/* Detail: the reply itself, its thread context, then the decision */
.desk-detail .reply-card { display: block; padding: 0; border: 0; border-radius: 0; background: transparent; }
.desk-detail .reply-card.hot { border-left: 0; padding-left: 0; }
.desk-when { font: 500 var(--fs-caption)/1.3 var(--font-body); letter-spacing: 0; text-transform: none; color: var(--text-2); font-variant-numeric: tabular-nums; }
.desk-detail .pane-body { display: grid; gap: 20px; padding: 20px 24px 28px; }
.desk-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.desk-head > .pill { flex: none; margin-top: 4px; }
.desk-who { min-width: 0; }
.desk-who h2 { font-size: var(--fs-h2); letter-spacing: -0.01em; overflow-wrap: anywhere; }
.desk-sub { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin-top: 4px; font-size: var(--fs-small); color: var(--text-2); overflow-wrap: anywhere; }
.desk-sub .text-button.inline { font-size: var(--fs-small); }
.desk-thread { border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); overflow: hidden; }
.desk-subject { padding: 10px 16px; border-bottom: 1px solid var(--border-hair); background: var(--surface-sunken); font: 600 var(--fs-body)/1.4 var(--font-body); color: var(--text); overflow-wrap: anywhere; }
.desk-thread .reply-body { max-height: 360px; margin: 0; padding: 16px; border: 0; border-radius: 0; background: var(--surface); font-size: var(--fs-lead); line-height: 1.65; }
.desk-context { display: flex; flex-wrap: wrap; gap: 6px 24px; margin: 0; padding: 10px 16px; border-top: 1px solid var(--border-hair); background: var(--surface-sunken); font-size: var(--fs-small); }
.desk-context > div { display: flex; gap: 6px; min-width: 0; }
.desk-context dt { color: var(--text-3); white-space: nowrap; }
.desk-context dd { margin: 0; color: var(--text); font-weight: 500; overflow-wrap: anywhere; }
.desk-next { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 16px; margin: 0; padding: 14px 16px; border-radius: 0 var(--radius-md) var(--radius-md) 0; border-left: 3px solid var(--navy-600); background: var(--surface-tint); font-size: var(--fs-body); line-height: 1.55; }
.desk-next > div { display: contents; }
.desk-next dt { font: 700 var(--fs-micro)/1.7 var(--font-heading); letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); }
.desk-next dd { margin: 0; color: var(--text); overflow-wrap: anywhere; }

/* Decision: a segmented set of dispositions, then brand inputs */
.desk-decide { display: grid; gap: 14px; padding-top: 20px; border-top: 1px solid var(--border-hair); }
.desk-decide-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; }
.desk-decide-head small { font-size: var(--fs-small); color: var(--text-2); }
.desk .dispo.desk-segments { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 1px; padding: 1px; border-radius: var(--radius-sm); overflow: hidden; }
.desk .desk-segments button { position: relative; display: inline-flex; align-items: center; gap: 6px; min-height: 38px; margin: 0; padding: 8px 12px; justify-content: center; border: 0; border-radius: 0; box-shadow: 0 0 0 1px var(--border); background: var(--surface); color: var(--text); font: 500 var(--fs-small)/1.2 var(--font-body); transition: background .15s ease, color .15s ease; }
.desk .desk-segments button:hover { background: var(--surface-sunken); }
.desk .desk-segments button.hot::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--gold-mark); box-shadow: var(--status-dot-ring); }
.desk .desk-segments button.stop { color: var(--status-danger-text); }
.desk .desk-segments button.stop:hover { background: var(--status-danger-bg); }
/* The chosen disposition: white, 2px navy ring, weight 600 (the app's chip selection), never a navy fill. */
.desk .desk-segments button[aria-pressed=true] { z-index: 1; padding: 8px 12px; border: 0; background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 0 0 1px var(--border), inset 0 0 0 2px var(--navy-900); }
.desk .desk-segments button.stop[aria-pressed=true] { background: var(--surface); color: var(--status-danger-text); box-shadow: 0 0 0 1px var(--border), inset 0 0 0 2px var(--status-danger-dot); }
.desk .desk-segments button:focus-visible { z-index: 2; outline-offset: -5px; } /* inside the 2px selected ring, with a gap */
.desk .dispo-extra.desk-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px 16px; align-items: end; font-size: inherit; }
.desk .dispo-extra.desk-fields label { display: block; gap: 0; font: 700 var(--fs-caption)/1.4 var(--font-heading); color: var(--text); }
.desk .dispo-extra.desk-fields input, .desk .dispo-extra.desk-fields select { width: 100%; max-width: none; margin: 6px 0 0; padding: 9px 12px; font-size: var(--fs-body); }
.desk .dispo-extra.desk-fields select { padding-right: 32px; }
.desk .dispo-extra.desk-fields label.checkbox { display: flex; align-items: center; gap: 8px; min-height: 40px; margin: 0; padding: 8px 12px; font: 500 var(--fs-small)/1.4 var(--font-body); }
.desk .dispo-extra.desk-fields label.checkbox input { width: auto; margin: 0; }
/* Suppression is the one irreversible choice here: calm danger outline, never a red fill. */
.desk .desk-suppress.checkbox { border: 1px solid var(--status-danger-dot); border-radius: var(--radius-sm); background: var(--surface); color: var(--status-danger-text); }
.desk .desk-suppress input { accent-color: var(--status-danger-dot); }
.desk .desk-followup { padding-top: 14px; border-top: 1px solid var(--border-hair); }
.desk .desk-actions.actions { margin-top: 0; }
.desk-note { margin: 0; color: var(--text-2); }

/* --- Responsive: 1150 tightens, 900 turns the rail into a strip, 720 stacks to one column --- */
@media (max-width: 1150px) {
  .panes.three.desk-panes { grid-template-columns: 184px minmax(240px, 300px) minmax(0, 1fr); }
  .desk-rail .pane-rail-title, .desk-filter { padding-left: 16px; padding-right: 16px; }
  .desk-filter { padding-left: 13px; }
  .desk-tally { padding: 0 16px; }
  .desk-detail .pane-body { padding: 18px 20px 24px; }
}
@media (max-width: 900px) {
  .panes.three.desk-panes { grid-template-columns: minmax(240px, 300px) minmax(0, 1fr); }
  .desk-rail { grid-column: 1 / -1; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 4px; max-height: none; padding: 10px 12px; border-right: 0; border-bottom: 1px solid var(--border); }
  .desk-rail .pane-rail-title, .desk-tally { display: none; }
  .desk-rail-foot { margin: 0 0 0 auto; padding: 0; }
  .desk-rail-foot small { display: none; }
  .desk-filter { width: auto; padding: 6px 12px; border: 1px solid var(--border); border-radius: var(--radius-pill); background: var(--surface); }
  .desk-filter.is-selected, .desk-filter[aria-pressed=true] { border: 2px solid var(--navy-900); padding: 5px 11px; background: var(--surface); }
  .desk-list { max-height: none; border-right: 1px solid var(--border); border-bottom: 0; }
  .desk-list > .pane-header { position: static; }
}
@media (max-width: 720px) {
  .panes.three.desk-panes { grid-template-columns: 1fr; min-height: 0; }
  .desk-list { max-height: 320px; border-right: 0; border-bottom: 1px solid var(--border); }
  .desk-detail .pane-body { padding: 16px; gap: 16px; }
  .desk-head { flex-direction: column; gap: 8px; }
  .desk-head > .pill { margin-top: 0; }
  .desk-next { grid-template-columns: 1fr; gap: 2px 0; }
  .desk-next dd { margin-bottom: 6px; }
  .desk .dispo.desk-segments { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .desk-log-head, .desk-log-body { padding-left: 16px; padding-right: 16px; }
}

/* ============================== Settings & help ============================== */
/* Documentation cards: eyebrow (gold bar + small caps), title, readable body, tables that scroll. */
.help-grid { gap: 16px; align-items: start; grid-auto-flow: row dense; }
/* Legal lanes (4th) and Suppression (last) carry wide tables: full width. */
.help-grid > .help-card:nth-child(4), .help-grid > .help-card:last-child { grid-column: 1 / -1; }
.help-card.panel { margin: 0; padding: 22px 24px 24px; }
.help-card .eyebrow { margin-bottom: 10px; }
.help-card .panel-title { margin-bottom: 12px; }
.help-card .table-wrap { margin: 12px 0; }
.help-card .table-wrap table { min-width: 100%; }
.help-card td { color: var(--text-2); line-height: 1.55; }
.help-card td:first-child { color: var(--text); }
.help-card td small { display: block; margin-top: 4px; color: var(--text-2); font-size: var(--fs-small); }
.help-card td .help-list { margin: 0; padding-left: 16px; }
.help-sub { margin: 18px 0 6px; font-size: var(--fs-body); color: var(--text); }
.help-step + .help-step { margin-top: 4px; }
.help-step .help-sub { margin-top: 12px; }
.help-list { margin: 0; padding-left: 20px; font-size: var(--fs-body); line-height: 1.7; color: var(--text-2); }
.help-list li + li { margin-top: 2px; }
.help-list li::marker { color: var(--accent); font-weight: 600; }
.help-text { margin-top: 12px; font-size: var(--fs-body); line-height: 1.6; color: var(--text-2); }
.help-card .notice { margin: 14px 0 0; }
.help-card .notice + .notice { margin-top: 8px; }
.help-card .notice + .help-sub { margin-top: 18px; }
.help-search.toolbar { margin: 0 0 12px; }
.help-search label { flex: 1 1 260px; max-width: 420px; }
.help-search input[type=search] { width: 100%; }
.help-add.inline-form { margin: 0 0 12px; padding: 14px 16px; border: 1px solid var(--border-hair); border-radius: var(--radius-md); background: var(--surface-sunken); }
.help-add label { flex: 1 1 180px; }
.help-add input, .help-add select { width: 100%; }
@media (max-width: 900px) {
  .help-card.panel { padding: 18px 16px 20px; }
}

/* ---- Research rules (More menu): judgment counts, examples by source type, the export ---- */
#rules-view { display: grid; gap: var(--space-5); }
#rules-view .rules-metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
#rules-view .rules-export { margin-top: var(--space-2); }
#rules-view .rules-groups { display: grid; gap: var(--space-5); }
#rules-view .rules-columns { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--space-6); }
#rules-view .rules-columns h3 { margin-bottom: var(--space-2); font-size: var(--fs-h3); }
#rules-view .rules-list { display: grid; gap: var(--space-3); margin: 0; padding: 0; list-style: none; }
#rules-view .rules-example { padding: var(--space-3) var(--space-4); border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); }
#rules-view .rules-quote { font-size: var(--fs-body); line-height: 1.6; color: var(--text); }
#rules-view .rules-meta, #rules-view .rules-note { margin-top: var(--space-1); font-size: var(--fs-small); line-height: 1.5; color: var(--text-2); overflow-wrap: anywhere; }
#rules-view .rules-reasons { display: flex; flex-wrap: wrap; gap: var(--space-1); margin-top: var(--space-2); }
@media (max-width: 900px) { #rules-view .rules-columns, #rules-view .rules-metrics { grid-template-columns: 1fr; } }
