/* playbook web gym — paper, ink, one redline accent. mono, committed.
 * Voice: landing copy uses editorial sentence case and lowercase calls to
 * action; the active workspace uses terse lowercase throughout. */

:root {
  --paper: #faf9f6;
  --paper-2: #f3f1ec;
  --ink: #1c1a18;
  --muted: #6f6963;
  --line: #e2ded6;
  --red: #8b1e1e;          /* the accent is the redline */
  --green: #3d5c3a;
  --mono: ui-monospace, "Cascadia Code", "JetBrains Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; margin: 0; }
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  background: var(--paper);
  color: var(--ink);
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}
body.matter-active { height: 100dvh; overflow: hidden; }
body.matter-active header, body.matter-active footer { flex: none; }
body.matter-active main { height: 0; }

a { color: var(--ink); text-underline-offset: 2px; }
a:hover { color: var(--red); }
.brand { text-decoration: none; }

/* ---------------------------------------------------------------- header */

header {
  display: flex;
  align-items: baseline;
  gap: 14px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
}

.mark { font-weight: 650; letter-spacing: 0.01em; }
.mark::after { content: "."; color: var(--red); }
.tag { color: var(--muted); }
.spacer { flex: 1; }
.header-link { border: 0; background: transparent; padding: 0; color: var(--muted); text-decoration: none; }
.header-link:hover { color: var(--ink); }

.pick { color: var(--muted); }

select, input, textarea, button {
  font: inherit;
  color: inherit;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 5px 8px;
}

textarea { width: 100%; resize: vertical; }
input { width: 100%; }
select:focus, input:focus, textarea:focus, button:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: -1px;
}

button { cursor: pointer; }
button:hover:not(:disabled) { border-color: var(--ink); }
button:disabled { color: var(--muted); cursor: default; }
button.danger { border-color: var(--red); color: var(--red); }
button.danger:hover:not(:disabled) { background: var(--red); color: var(--paper); }
button.ghost { border-style: dashed; color: var(--muted); }
button.primary { background: var(--ink); border-color: var(--ink); color: var(--paper); padding-inline: 12px; }
button.primary:hover:not(:disabled) { background: var(--red); border-color: var(--red); }

.budgets { font-variant-numeric: tabular-nums; }
.budgets b { color: var(--red); font-weight: 700; }
.mode-badge { padding: 2px 7px; border: 1px solid var(--line); color: var(--muted); font-size: 11px; white-space: nowrap; }
.save-status { color: var(--muted); font: 11px/1 var(--mono); white-space: nowrap; }
.save-status::before { content: "●"; margin-right: 5px; color: var(--green); font-size: 8px; }
.capture-controls { display: inline-flex; }
.capture-status { padding: 2px 7px; border-color: var(--line); color: var(--muted); font-size: 11px; white-space: nowrap; }
.capture-status[aria-pressed="true"]::before { content: "●"; margin-right: 5px; color: var(--green); font-size: 8px; }
.capture-dialog { max-width: 590px; }
.capture-dialog p { color: var(--muted); font-size: 15px; }

/* ------------------------------------------------------------------ boot */

.boot {
  flex: 1;
  display: grid;
  place-items: center;
  padding: clamp(32px, 7vw, 90px) 20px;
}

.welcome { width: min(980px, 100%); }
.eyebrow { color: var(--red); letter-spacing: .13em; font-size: 11px; font-weight: 700; }
.section-label { color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: .08em; }
.welcome h1 { font-family: Georgia, "Times New Roman", serif; font-size: clamp(38px, 5vw, 58px); font-weight: 400; line-height: 1.08; letter-spacing: -.02em; margin: 16px 0 18px; }
.lede { max-width: 680px; font-size: clamp(16px, 2vw, 19px); line-height: 1.55; color: #514c47; }
.mode-picker { display: flex; align-items: baseline; gap: 26px; margin-top: 26px; padding: 0; border: 0; }
.mode-picker legend { float: left; margin-right: 26px; color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: .08em; }
.mode-option { display: inline-flex; align-items: baseline; gap: 7px; padding: 2px 0 4px; border-bottom: 2px solid transparent; cursor: pointer; }
.mode-option:hover { border-bottom-color: var(--line); }
.mode-option.selected { border-bottom-color: var(--red); }
.mode-option input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.mode-option span { display: inline; }
.mode-option strong { font-size: 13px; font-weight: 700; }
.mode-option small { color: var(--muted); font-size: 12px; }
.mode-option small::before { content: "— "; }
.welcome-actions { display: flex; align-items: center; gap: 22px; margin: 26px 0 42px; }
.welcome-actions button { padding: 10px 15px; }
.time-note { color: var(--muted); font-size: 12px; }
.steps { display: grid; grid-template-columns: repeat(4, 1fr); border-block: 1px solid var(--line); }
.steps > div { display: grid; gap: 4px; padding: 20px 24px 22px 0; }
.steps b { color: var(--red); font-size: 11px; font-weight: 700; letter-spacing: .12em; }
.steps > div + div { border-left: 1px solid var(--line); padding-left: 24px; }
.steps strong { font-size: 14px; }
.steps span { color: var(--muted); }
.trust-row { display: flex; flex-wrap: wrap; gap: 9px 28px; color: var(--muted); padding: 18px 0; }
.trust-row span + span::before { content: "·"; margin-right: 28px; color: var(--line); }
.boot-details { margin-top: 16px; color: var(--muted); }
.boot-details summary { cursor: pointer; }

#boot-log {
  font-family: var(--mono);
  color: var(--muted);
  white-space: pre-wrap;
  max-width: 60ch;
  max-height: 120px;
  overflow: auto;
  margin-top: 8px;
  padding: 8px 10px;
  background: var(--paper-2);
}
#boot-log .done { color: var(--ink); }

/* ------------------------------------------------------------------ main */

main {
  flex: 1;
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr) 360px;
  min-height: 0;
}

main > * { min-height: 0; overflow-y: auto; }

#docs { border-right: 1px solid var(--line); padding: 14px; }
#composer { border-left: 1px solid var(--line); padding: 14px; }
#file { padding: 0 22px 80px; background: var(--paper-2); }
.workspace-bar { position: sticky; top: 0; z-index: 2; margin: 0 -22px; padding: 8px 14px; border-bottom: 1px solid var(--line); background: var(--paper-2); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
#workspace-tabs { display: flex; gap: 2px; }
#workspace-tabs button { border: 0; background: transparent; color: var(--muted); padding: 4px 9px; }
#workspace-tabs button.active { background: var(--paper); color: var(--ink); box-shadow: inset 0 -2px var(--red); }
.tab-count { display: inline-block; min-width: 17px; margin-left: 3px; padding: 0 4px; border: 1px solid var(--line); color: inherit; font-size: 10px; font-variant-numeric: tabular-nums; }
#current-document { color: var(--muted); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#document-view { max-width: 850px; margin: 0 auto; padding: clamp(28px, 5vw, 64px) clamp(12px, 5vw, 54px); min-height: 70vh; background: #fff; border-inline: 1px solid #eeeae3; }
#document-view pre { font-family: Georgia, "Times New Roman", serif; font-size: 16px; line-height: 1.75; white-space: pre-wrap; overflow-wrap: anywhere; }
.document-paper { color: #24211e; font-family: Georgia, "Times New Roman", serif; font-size: 16px; line-height: 1.78; }
.document-heading { scroll-margin-top: 70px; font-weight: 600; line-height: 1.3; }
.document-paper h2 { margin: 0 0 34px; padding-bottom: 18px; border-bottom: 1px solid var(--line); font-size: clamp(25px, 3vw, 34px); text-align: center; }
.document-paper h3 { margin: 34px 0 12px; font-size: 19px; }
.document-paper h4, .document-paper h5, .document-paper h6 { margin: 26px 0 10px; font-size: 16px; }
.document-paragraph { margin: 0 0 18px; text-align: left; }
.document-list { margin: 0 0 20px; padding-left: 28px; }
.document-list li + li { margin-top: 6px; }
.document-table { width: 100%; margin: 8px 0 24px; border-collapse: collapse; font-family: "Segoe UI", Arial, sans-serif; font-size: 13px; line-height: 1.45; }
.document-table th, .document-table td { padding: 9px 10px; border: 1px solid var(--line); text-align: left; vertical-align: top; }
.document-table th { background: var(--paper-2); font-weight: 650; }
.document-paper code { padding: 1px 3px; background: var(--paper-2); font: .88em/1.4 var(--mono); }
.document-paragraph::selection, .document-heading::selection { background: #f1d9a9; }
.citation-target { animation: citation-flash 1.8s ease-out; }
@keyframes citation-flash { 0%, 35% { background: #fff0b8; } 100% { background: transparent; } }

.selection-tools { position: fixed; z-index: 20; display: flex; align-items: center; gap: 3px; padding: 5px; border: 1px solid #332f2a; background: #332f2a; box-shadow: 0 7px 24px #1c1a1830; color: #fff; }
.selection-tools span { padding: 0 8px; color: #d7d0c7; font: 10px/1 var(--mono); white-space: nowrap; }
.selection-tools button { border-color: #5d5750; background: transparent; color: #fff; font-size: 11px; }
.selection-tools button:hover:not(:disabled) { border-color: #fff; background: #fff; color: var(--ink); }
.empty-document { max-width: 570px; margin: 12vh auto 0; }
.empty-document h2 { font-family: Georgia, "Times New Roman", serif; font-size: 38px; font-weight: 400; margin: 8px 0 12px; }
.empty-document > p:last-child { color: var(--muted); font-size: 15px; }
.empty-document p { margin-top: 10px; }
.empty-document .start-hint { border-left: 2px solid var(--red); padding-left: 12px; margin-top: 24px; }
.matter-time { color: var(--muted); font-family: var(--mono); font-size: 11px; }

/* submitted work product */
#review-view { max-width: 920px; margin: 0 auto; padding: clamp(28px, 5vw, 56px) 0; }
.review-heading { display: flex; align-items: end; justify-content: space-between; gap: 30px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.review-heading h2 { font-family: Georgia, "Times New Roman", serif; font-size: 34px; font-weight: 400; }
.review-heading > p { max-width: 430px; color: var(--muted); }
.review-list { display: grid; gap: 12px; padding-top: 18px; }
.empty-review { display: flex; flex-direction: column; gap: 4px; padding: 28px; border: 1px dashed var(--line); color: var(--muted); }
.empty-review strong { color: var(--ink); }
.issue-card { padding: 18px; border: 1px solid var(--line); border-left: 3px solid var(--line); background: var(--paper); }
.issue-card.severity-critical, .issue-card.severity-high { border-left-color: var(--red); }
.issue-card.severity-medium { border-left-color: #9a702b; }
.issue-card-head { display: flex; align-items: start; justify-content: space-between; gap: 20px; }
.issue-meta { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
.issue-card h3 { margin-top: 3px; font-family: Georgia, "Times New Roman", serif; font-size: 21px; font-weight: 400; }
.issue-status { flex: none; padding: 2px 6px; border: 1px solid var(--line); color: var(--muted); font-size: 10px; text-transform: uppercase; }
.issue-status.complete { color: var(--green); border-color: var(--green); }
.issue-analysis { margin-top: 12px; white-space: pre-wrap; }
.issue-recommendation { margin-top: 12px; padding: 10px 12px; background: var(--paper-2); }
.issue-recommendation strong { font-size: 11px; color: var(--muted); }
.issue-recommendation p { margin-top: 3px; white-space: pre-wrap; }
.issue-card-actions { display: flex; align-items: end; justify-content: space-between; gap: 14px; margin-top: 14px; }
.citation-list { display: flex; flex-wrap: wrap; gap: 5px; }
button.citation-link { padding: 2px 6px; border-color: var(--line); background: transparent; color: var(--muted); font-size: 11px; text-decoration: underline; text-underline-offset: 2px; }
button.draft-redline { flex: none; border-color: var(--red); color: var(--red); background: transparent; }
button.draft-redline:hover:not(:disabled) { background: var(--red); color: var(--paper); }
.issue-card-buttons { display: flex; flex: none; gap: 6px; }
.edit-issue { background: transparent; }

.pane-label {
  color: var(--muted);
  letter-spacing: 0.08em;
  margin-bottom: 10px;
}
.pane-label, .entry-head, .budgets, .issue-meta, .issue-status, #engine-line { font-family: var(--mono); }

.learned-facts { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line); }
.learned-facts-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.learned-facts-heading .eyebrow { margin: 0; }
.learned-facts-heading h2 { margin: 0; font-size: 14px; }
#learned-facts-list { display: grid; gap: 8px; margin-top: 10px; }
.learned-fact { padding: 8px 9px; border-left: 2px solid var(--green); background: var(--paper-2); }
.learned-fact dt { color: var(--muted); font: 700 10px/1.3 var(--mono); overflow-wrap: anywhere; }
.learned-fact dd { margin: 3px 0 0; font-size: 12px; line-height: 1.45; white-space: pre-wrap; }
.learned-facts-empty { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.progress { list-style: none; padding: 0 0 13px; margin: 0 0 12px; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 1fr 1fr; gap: 4px 10px; color: var(--muted); font-size: 11px; }
.progress li::before { content: "○"; display: inline-block; width: 16px; }
.progress li.done { color: var(--green); }
.progress li.done::before { content: "●"; }
.next-step { margin-bottom: 13px; padding: 13px; border: 1px solid var(--ink); background: #fff; }
.next-step strong { display: block; margin-top: 3px; font-family: Georgia, "Times New Roman", serif; font-size: 18px; font-weight: 400; }
.next-step > p:not(.eyebrow) { margin: 5px 0 10px; color: var(--muted); font-size: 12px; }
.next-step button { width: 100%; border-color: var(--ink); background: var(--ink); color: var(--paper); }
.next-step button:hover:not(:disabled) { border-color: var(--red); background: var(--red); }
.form-help { color: var(--muted); font-size: 12px; margin-bottom: 2px; }
.tabform label { color: #5e5953; font-size: 11px; margin-bottom: -5px; }

/* documents nav */
.doc { margin-bottom: 12px; }
.doc-heading { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; gap: 8px; }
.doc .doc-title { display: block; width: 100%; padding: 5px 0; border: 0; background: transparent; font-weight: 650; text-align: left; }
.doc .doc-title:hover:not(:disabled) { color: var(--red); }
.doc-id { color: var(--muted); font-size: 9px; }
.doc .sections { display: flex; flex-wrap: wrap; gap: 2px 10px; padding-left: 1ch; }
.doc .sections a { color: var(--muted); text-decoration: none; }
.doc .sections a:hover { color: var(--red); text-decoration: underline; }
.doc .sections a.read { color: var(--ink); }
.hint { color: var(--muted); margin-top: 16px; border-top: 1px solid var(--line); padding-top: 10px; }

.thread-heading { display: flex; justify-content: space-between; gap: 12px; padding: 10px 11px; border-left: 3px solid var(--ink); background: #fff; }
.thread-heading span { color: var(--muted); font-size: 10px; }
.search-hit { display: grid; width: 100%; margin: 5px 0; padding: 9px 10px; background: var(--paper); text-align: left; }
.search-hit strong { color: var(--red); font: 11px/1.3 var(--mono); }
.search-hit span { margin-top: 3px; color: var(--muted); }

/* ------------------------------------------------------------ transcript */

.entry { padding: 14px 0; border-bottom: 1px solid var(--line); }
.entry-head {
  display: flex;
  gap: 10px;
  align-items: baseline;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.entry-head .kind { color: var(--ink); }
.entry-head .rew { margin-left: auto; }
.rew.pos { color: var(--green); }
.rew.neg { color: var(--red); }
.rew.zero { color: var(--muted); }

.entry .body { margin-top: 6px; white-space: pre-wrap; overflow-wrap: anywhere; }
.entry .body.doc-text {
  background: var(--paper-2);
  border-left: 2px solid var(--line);
  padding: 10px 14px;
}
.entry .error { color: var(--red); }
.entry .answer { border-left: 2px solid var(--red); padding-left: 12px; }

/* score block */
.score {
  margin: 26px 0;
  border: 1px solid var(--ink);
  padding: 18px;
}
.score .big {
  font-size: 44px;
  line-height: 1.1;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.score .big.capped { color: var(--red); }
.score-title { font-family: Georgia, "Times New Roman", serif; font-size: 30px; font-weight: 400; margin: 5px 0 2px; }
.score .sub { color: var(--muted); margin-bottom: 12px; }
.score-metrics { display: grid; grid-template-columns: repeat(3, 1fr); margin: 18px 0; border: 1px solid var(--line); }
.score-metric { display: grid; gap: 2px; padding: 12px; }
.score-metric + .score-metric { border-left: 1px solid var(--line); }
.score-metric strong { font-family: var(--mono); font-size: 20px; }
.score-metric span { color: var(--muted); font-size: 11px; }
.score-feedback { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 18px 0; }
.feedback-panel { padding: 13px 15px; background: var(--paper-2); }
.feedback-panel h3 { font-size: 13px; }
.feedback-panel ul { padding-left: 18px; margin-top: 7px; color: #514c47; }
.feedback-panel li + li { margin-top: 4px; }
.score-integrity { display: grid; gap: 10px; margin: 18px 0; }
.integrity-panel { padding: 13px 15px; border-left: 3px solid var(--red); background: #8b1e140d; }
.integrity-panel h3 { margin-bottom: 4px; font-size: 13px; }
.integrity-panel p { color: #514c47; }
.integrity-panel ul { margin: 7px 0 0; padding-left: 19px; font-family: var(--mono); overflow-wrap: anywhere; }
.integrity-panel li + li { margin-top: 4px; }
.integrity-panel.critical h3 { color: var(--red); }
.score-detail { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 10px; }
.score-detail summary { cursor: pointer; color: var(--muted); }
.score table { border-collapse: collapse; width: 100%; margin-top: 8px; }
.score th { padding: 5px 12px 5px 0; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 10px; letter-spacing: .06em; text-align: left; text-transform: uppercase; }
.score td { padding: 2px 12px 2px 0; vertical-align: top; font-variant-numeric: tabular-nums; }
.score .pts { text-align: right; white-space: nowrap; }
.criterion-name { text-transform: capitalize; }
.score .actions-row { margin-top: 14px; display: flex; gap: 10px; }
.contribute { display: grid; gap: 8px; margin-top: 14px; padding: 14px; border-top: 1px solid var(--line); background: var(--paper-2); }
.contribute-note, .contribute-detail, .contribute-status { color: var(--muted); font-size: 12px; }
.contribute-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.contribute-consent { display: flex; align-items: flex-start; gap: 8px; }
.contribute-consent input { flex: none; width: auto; margin-top: 4px; }
.contribute-submit { display: flex; align-items: center; gap: 10px; }

/* -------------------------------------------------------------- composer */

#tabs { display: flex; gap: 2px; margin-bottom: 12px; flex-wrap: wrap; }
#tabs button { border: none; padding: 3px 8px; color: var(--muted); background: none; }
#tabs button.active { color: var(--paper); background: var(--ink); }

.tabform { display: none; flex-direction: column; gap: 8px; }
.tabform.active { display: flex; }
#composer[aria-busy="true"] .tabform.active {
  pointer-events: none;
}
#composer[aria-busy="true"] .tabform.active > :not(button[type="submit"]) {
  opacity: 0.45;
}
#composer[aria-busy="true"] .tabform.active::after {
  content: "saving\2026";
  align-self: flex-end;
  margin-top: -39px;
  margin-right: 12px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  pointer-events: none;
}
.retry-step { margin-top: 10px; border-color: var(--red); color: var(--red); background: transparent; }
.row { display: flex; gap: 8px; }
.row select { flex: 1; }
.row input { width: 90px; }

.field-label, .doc-heading, .quote-citation-tools { display: flex; align-items: center; gap: 8px; }
.field-label label { margin-right: auto; }
.insert-section, .copy-citation, .normalize-citation, .submit-anyway {
  border: 0; background: transparent; color: var(--red); padding: 2px 4px;
  font-family: var(--mono); font-size: 11px; text-decoration: underline; text-underline-offset: 2px;
}
.section-field { display: flex; flex: 0 0 auto; align-items: center; gap: 3px; }
.section-field input { flex: 1; }
.field-errors, .quote-error { display: grid; gap: 5px; }
.field-error, .submission-warning, .quote-error:not(:empty) {
  border-left: 2px solid var(--red); padding: 6px 9px; color: var(--red); font-size: 12px;
}
.field-error { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.submission-warning { display: flex; align-items: center; justify-content: space-between; gap: 8px; background: #8b1e1410; }
.hard-warning { font-weight: 700; }
[aria-invalid="true"] { border-color: var(--red); outline-color: var(--red); }
.doc-heading { justify-content: space-between; }
.doc-id { color: var(--muted); font-size: 10px; }
.section-actions { display: flex; align-items: center; gap: 2px; }
.copy-citation { color: var(--muted); font-size: 9px; }
.quote-citation-tools .q-cite { flex: 1; }

.quote-row { border: 1px dashed var(--line); padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.quote-row .remove { align-self: flex-end; border: none; background: none; color: var(--muted); }

.supervisor-guidance { border-left: 3px solid var(--green); background: #edf3e9; padding: 12px; }
.supervisor-guidance::before { content: "supervisor guidance"; display: block; margin-bottom: 5px; color: var(--green); font: 700 10px/1.2 ui-monospace, monospace; letter-spacing: .08em; text-transform: uppercase; }
.counterparty-response { border-left: 3px solid var(--red); background: var(--paper-2); padding: 10px 12px; }
.pending-counter { display: grid; gap: 8px; margin-top: 14px; padding: 12px; border: 1px solid var(--line); background: var(--paper-2); }
.pending-counter pre { white-space: pre-wrap; margin: 0; font-family: inherit; }
.accept-counter { justify-self: start; }
.negotiation-chip { border: 1px solid currentColor; border-radius: 999px; padding: 3px 7px; font: 700 10px/1 ui-monospace, monospace; text-transform: uppercase; }
.negotiation-chip.open { color: var(--muted); }
.negotiation-chip.countered { color: #765b16; background: #fff8dc; }
.negotiation-chip.settled { color: var(--green); background: #edf3e9; }
.negotiation-chip.refused { color: var(--red); background: #f8e9e7; }

/* ---------------------------------------------------------------- footer */

footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 18px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

dialog { width: min(720px, calc(100% - 28px)); padding: 30px; border: 1px solid var(--ink); background: var(--paper); color: var(--ink); box-shadow: 0 18px 80px #1c1a1833; }
dialog::backdrop { background: #1c1a1877; backdrop-filter: blur(2px); }
dialog h2 { font-family: Georgia, "Times New Roman", serif; font-size: 36px; font-weight: 400; margin: 10px 0 12px; }
.dialog-close { position: absolute; right: 18px; top: 14px; border: 0; font-size: 22px; background: transparent; }
.help-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin: 26px 0; }
.help-grid p { color: var(--muted); margin-top: 4px; }
code { background: var(--paper-2); padding: 1px 4px; }
.finish-checklist { display: grid; gap: 1px; margin: 24px 0 14px; background: var(--line); border: 1px solid var(--line); }
.finish-row { display: flex; justify-content: space-between; gap: 20px; background: var(--paper); padding: 9px 11px; }
.finish-row strong { text-align: right; }
.finish-warnings { border-left: 2px solid var(--red); padding: 8px 12px; color: var(--muted); }
.finish-warnings p + p { margin-top: 5px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 24px; }
#mobile-nav { display: none; }

body.mode-benchmark .learn-only { display: none !important; }
body.mode-benchmark .form-help { display: none; }
body.mode-benchmark.matter-active #help-btn { display: none; }

/* ---------------------------------------------------------------- mobile */

@media (max-width: 980px) {
  body.matter-active { height: auto; min-height: 100dvh; overflow-y: auto; }
  body.matter-active main { height: auto; }
  header { flex-wrap: wrap; }
  .tag, header .header-link { display: none; }
  .pick { margin-left: auto; }
  .steps { grid-template-columns: 1fr; }
  .steps > div + div { border-left: 0; border-top: 1px solid var(--line); padding-left: 0; }
  .welcome-actions { align-items: flex-start; flex-direction: column; margin-bottom: 36px; }
  .mode-picker { flex-direction: column; align-items: flex-start; gap: 10px; }
  main { display: block; padding-bottom: 72px; }
  #docs { border-right: none; border-bottom: 1px solid var(--line); }
  #composer { border-left: none; border-top: 1px solid var(--line); }
  #file { order: 2; padding: 0 14px 30px; min-height: 340px; }
  #docs { order: 1; }
  #composer { order: 3; }
  #document-view { min-height: 320px; }
  #review-view { padding-inline: 2px; }
  main > * { overflow: visible; min-height: calc(100dvh - 130px); }
  main > [hidden] { display: none !important; }
  #mobile-nav { position: fixed; inset: auto 0 0; z-index: 30; min-height: 64px; padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); background: var(--paper); border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(5, 1fr); gap: 3px; }
  #mobile-nav button { min-height: 48px; border: 0; padding: 5px 2px; color: var(--muted); background: transparent; font-size: 11px; }
  #mobile-nav button[aria-current="page"] { color: var(--ink); box-shadow: inset 0 2px var(--red); background: var(--paper-2); }
  header { position: sticky; top: 0; z-index: 20; background: var(--paper); }
  header #help-btn { display: inline-flex; }
  .doc .sections a, #tabs button, .tabform button { min-height: 44px; align-items: center; }
  dialog { max-height: calc(100dvh - 20px); overflow-y: auto; }
  footer { flex-direction: column; gap: 2px; }
}

@media (max-width: 600px) {
  .welcome h1 { font-size: 38px; }
  .pick { width: 100%; min-width: 0; display: flex; gap: 8px; align-items: center; order: 3; }
  .pick select { flex: 1; min-width: 0; max-width: 100%; }
  #start-btn { order: 3; }
  .help-grid { grid-template-columns: 1fr; }
  .review-heading, .issue-card-head, .issue-card-actions { align-items: stretch; flex-direction: column; }
  .issue-status { align-self: flex-start; }
  #workspace-tabs button { min-height: 44px; padding-inline: 12px; }
  button.citation-link, button.draft-redline { min-height: 44px; padding: 9px 12px; }
  button.draft-redline { align-self: stretch; }
  .citation-list { display: grid; grid-template-columns: 1fr; }
  input, select, textarea, button { font-size: 16px; }
  .row { flex-direction: column; }
  .row input { width: 100%; }
  #workspace-tabs { overflow-x: auto; }
  .score { overflow-x: auto; }
  .score-metrics, .score-feedback { grid-template-columns: 1fr 1fr; }
  .score-metric + .score-metric { border-left: 0; border-top: 1px solid var(--line); }
  .score .actions-row, .dialog-actions { flex-direction: column; }
  .contribute-fields { grid-template-columns: 1fr; }
  .dialog-actions button { min-height: 48px; }
  #finish-dialog { width: 100%; max-width: none; max-height: 88dvh; margin: auto 0 0; border-width: 1px 0 0; padding: 20px 16px calc(16px + env(safe-area-inset-bottom)); }
}

@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
