:root {
  color-scheme: light;
  --accent: #007a9c;
  --accent-dark: #005f78;
  --ink: #20272b;
  --muted: #52616a;
  --line: #d8e1e6;
  --soft: #edf5f7;
  --paper: #fff;
  --field: #f8fbfc;
  --danger: #9b2c2c;
  font-family: Inter, "Segoe UI", system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; letter-spacing: 0; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--paper); color: var(--ink); }
button, input, textarea, select { font: inherit; }
button, .download-link {
  align-items: center;
  display: inline-flex;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  font-weight: 650;
  line-height: 1.35;
  min-height: 42px;
  padding: 10px 14px;
  text-decoration: none;
}
button:hover, .download-link:hover { background: var(--accent-dark); }
button:disabled { cursor: default; opacity: .55; }
:focus-visible { outline: 3px solid #88c6d6; outline-offset: 3px; }
svg.lucide { width: 18px; height: 18px; flex: 0 0 18px; }
a { color: var(--accent-dark); }
.shell { min-height: 100vh; padding: 24px 32px 48px; max-width: 1420px; margin: auto; }
.login-view { margin: 10vh auto 0; max-width: 460px; }
.brand { align-items: center; display: flex; gap: 16px; margin-bottom: 28px; min-width: 0; }
.brand.compact { margin: 0; }
.mark { align-items: center; background: var(--accent); border-radius: 6px; color: white; display: inline-flex; flex: 0 0 48px; font-weight: 800; justify-content: center; width: 48px; height: 48px; }
.eyebrow { color: var(--accent-dark); font-size: .76rem; font-weight: 750; margin: 0 0 6px; text-transform: uppercase; }
h1, h2, h3, p { overflow-wrap: anywhere; }
h1, h2, h3 { margin: 0; }
h1 { font-size: 1.65rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1rem; }
.project-title { font-size: 1.75rem; }
.login-form { background: var(--field); border: 1px solid var(--line); border-radius: 8px; padding: 24px; }
form { display: grid; gap: 16px; }
label { color: var(--muted); display: grid; font-size: .92rem; font-weight: 650; gap: 8px; }
input, textarea, select { background: var(--field); border: 1px solid var(--line); border-radius: 6px; color: var(--ink); min-height: 42px; min-width: 0; width: 100%; padding: 10px 12px; }
textarea { resize: vertical; }
.form-message { color: var(--muted); margin: 0; font-size: .9rem; }
.form-message:empty { display: none; }
.form-message.error { color: var(--danger); }
.workspace-message:not(:empty) { margin-bottom: 20px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.topbar { align-items: center; display: flex; gap: 20px; justify-content: space-between; border-bottom: 1px solid var(--line); padding-bottom: 22px; margin-bottom: 32px; }
.account, .actions { align-items: center; display: flex; gap: 10px; flex-wrap: wrap; }
.account { color: var(--muted); font-size: .9rem; }
.ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.ghost:hover { background: var(--soft); color: var(--ink); }
.section-head, .panel-head { align-items: center; display: flex; gap: 16px; justify-content: space-between; margin-bottom: 20px; }
.section-head > div:first-child, .panel-head h3 { min-width: 0; }
.section-head > button { flex-shrink: 0; }
.pap-list { border-top: 1px solid var(--line); }
.pap-item { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 24px; border-bottom: 1px solid var(--line); padding: 24px 12px; text-decoration: none; color: var(--ink); }
.pap-item:hover { background: var(--field); }
.pap-item h3 { font-size: 1.12rem; margin-bottom: 6px; }
.pap-item p { color: var(--muted); font-size: .92rem; margin: 0; white-space: pre-line; }
.pap-meta { color: var(--muted); display: grid; gap: 8px; font-size: .87rem; min-width: 105px; }
.phase-label { color: #346a48; }
.library-link, .back-link { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font-size: .92rem; }
.library-link { margin-top: 28px; }
.back-link { margin-bottom: 24px; }
.pap-summary { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; max-width: 1000px; margin-bottom: 24px; }
.pap-summary p { color: var(--muted); line-height: 1.65; font-size: .95rem; margin: 6px 0 0; white-space: pre-line; }
.pap-summary h3 { font-size: .84rem; }
.phase-strip { display: grid; gap: 8px; grid-template-columns: repeat(5, minmax(0, 1fr)); margin: 0 0 32px; padding: 0; list-style: none; }
.phase-strip li { border-top: 3px solid var(--line); padding-top: 10px; color: var(--muted); font-size: .87rem; overflow-wrap: anywhere; }
.phase-strip li[aria-current="step"] { color: var(--accent-dark); border-color: var(--accent); font-weight: 750; }
.document-toolbar { padding-top: 22px; border-top: 1px solid var(--line); }
.count { color: var(--muted); font-weight: 400; margin-left: 5px; }
.work-grid { display: grid; gap: 28px; grid-template-columns: minmax(260px, .85fr) minmax(0, 1.65fr); }
.list-panel, .preview-panel { min-width: 0; }
.preview-panel { border-left: 1px solid var(--line); padding-left: 28px; }
.panel-head { align-items: flex-start; margin-bottom: 16px; }
.panel-head .actions { flex-shrink: 0; }
.document-list { display: grid; gap: 8px; align-content: start; }
.document-item { background: var(--paper); border: 1px solid var(--line); border-radius: 6px; display: grid; gap: 8px; padding: 14px; text-align: left; justify-content: stretch; min-width: 0; }
.document-item:hover, .document-item.active { border-color: var(--accent); background: var(--soft); }
.document-title { color: var(--ink); font-size: .92rem; font-weight: 650; overflow-wrap: anywhere; }
.document-meta { color: var(--muted); display: flex; flex-wrap: wrap; gap: 8px; font-size: .8rem; font-weight: 400; }
.preview-empty { align-items: center; background: var(--field); color: var(--muted); display: flex; justify-content: center; min-height: 440px; padding: 24px; }
iframe { background: var(--field); border: 1px solid var(--line); height: 620px; width: 100%; }
.document-purpose { color: var(--muted); line-height: 1.6; }
.document-state { color: var(--muted); font-size: .85rem; margin: 0 0 14px; }
.output-status { color: #795322; }
.choice-meta { display: block; color: var(--muted); font-size: .8rem; margin-top: 4px; }
.document-tabs { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
.document-tabs a { display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px; min-height: 44px; text-decoration: none; border: 1px solid var(--line); border-radius: 6px; color: var(--muted); }
.document-tabs a:hover { background: var(--field); }
.document-tabs a[aria-current="page"] { background: var(--soft); border-color: var(--accent); color: var(--accent-dark); font-weight: 650; }
.document-tabs .count { font-weight: 400; min-width: 2ch; text-align: right; margin: 0; }
#classifyName { margin: 0; }
.details { border-top: 1px solid var(--line); margin-top: 16px; padding-top: 12px; font-size: .85rem; }
.details summary { color: var(--accent-dark); cursor: pointer; font-weight: 650; }
dl { display: grid; gap: 8px 14px; grid-template-columns: max-content minmax(0, 1fr); margin: 12px 0 0; }
dt { color: var(--muted); font-weight: 650; }
dd { margin: 0; overflow-wrap: anywhere; }
dialog { width: min(640px, calc(100% - 32px)); max-height: calc(100dvh - 40px); padding: 28px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); box-shadow: 0 16px 60px #18282f26; }
dialog::backdrop { background: #16232c66; }
dialog .panel-head { margin: 0; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; border-top: 1px solid var(--line); padding-top: 18px; }
fieldset { border: 0; border-top: 1px solid var(--line); padding: 12px 0 0; margin: 0; min-width: 0; }
legend { color: var(--muted); font-size: .92rem; font-weight: 650; padding: 0 8px 0 0; }
.document-choices { display: grid; gap: 2px; max-height: 220px; overflow-y: auto; }
.document-choice { display: flex; align-items: flex-start; gap: 10px; padding: 10px 4px; font-weight: 400; color: var(--ink); overflow-wrap: anywhere; cursor: pointer; }
.document-choice input { width: 18px; height: 18px; min-height: 18px; flex: 0 0 18px; margin: 2px 0 0; accent-color: var(--accent); }
.dropzone { position: relative; align-items: center; background: var(--field); border: 1px dashed var(--accent); border-radius: 6px; color: var(--ink); cursor: pointer; justify-items: center; min-height: 150px; padding: 24px; text-align: center; overflow-wrap: anywhere; }
.dropzone.dragging { background: var(--soft); }
.dropzone:focus-within { outline: 3px solid #88c6d6; }
.dropzone input { inset: 0; width: 100%; height: 100%; opacity: 0; position: absolute; cursor: pointer; }
.pap-tabs { display: flex; gap: 24px; border-bottom: 1px solid var(--line); margin-bottom: 24px; }
.pap-tabs a { display: inline-flex; gap: 8px; align-items: center; padding: 12px 0; border-bottom: 3px solid transparent; text-decoration: none; color: var(--muted); }
.pap-tabs a[aria-current="page"] { color: var(--accent-dark); border-bottom-color: var(--accent); font-weight: 700; }
.assistant-layout { display: grid; grid-template-columns: minmax(240px, .8fr) minmax(0, 1.6fr); gap: 40px; }
#questionForm { align-content: start; min-width: 0; }
#assistantView > .form-message:not(:empty) { margin-bottom: 20px; }
.connection-state { color: var(--muted); font-size: .85rem; }
.assistant-history { min-width: 0; }
.question-item { border-top: 1px solid var(--line); padding: 22px 0; }
.question-meta { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; color: var(--muted); font-size: .8rem; }
.job-state { color: #795322; }
.job-state[data-status="completed"] { color: #346a48; }
.job-state[data-status="failed"], .job-state[data-status="interrupted"] { color: var(--danger); }
.question-item h4 { margin: 14px 0; font-size: 1rem; overflow-wrap: anywhere; white-space: pre-wrap; }
.question-item h5 { margin: 16px 0 8px; font-size: .92rem; }
.question-scope { color: var(--muted); font-size: .85rem; margin: 0; }
.citation-review { color: var(--muted); font-size: .85rem; line-height: 1.5; margin: 16px 0; }
.source-inventory { margin: 14px 0; }
.source-inventory li { margin: 6px 0; overflow-wrap: anywhere; }
.assistant-answer { line-height: 1.65; overflow-wrap: anywhere; }
.assistant-answer :is(h1, h2, h3, h4, h5, h6) { font-size: 1rem; line-height: 1.4; margin: 22px 0 10px; }
.assistant-answer p { margin: 12px 0; }
.assistant-answer :is(ul, ol) { padding-left: 22px; }
.assistant-answer li { margin: 10px 0; }
.assistant-answer pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.answer-sources { padding-left: 20px; font-size: .87rem; }
.answer-sources blockquote { color: var(--muted); margin: 8px 0 16px; padding-left: 12px; border-left: 2px solid var(--line); }
.source-package { margin: 18px 0; font-size: .86rem; }
.source-package summary { cursor: pointer; color: var(--accent-dark); overflow-wrap: anywhere; }
.source-excerpt { border-top: 1px solid var(--line); padding: 12px 0; }
.source-excerpt p { white-space: pre-wrap; line-height: 1.6; max-height: 260px; overflow-y: auto; }
.source-warnings { color: #795322; padding-left: 20px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.matrix-filters { display: grid; grid-template-columns: minmax(180px, 1fr) minmax(150px, 220px) auto 44px; gap: 16px; align-items: end; margin-bottom: 24px; }
.matrix-check { display: flex; align-items: center; min-height: 42px; }
.matrix-check input { width: 18px; height: 18px; min-height: 18px; accent-color: var(--accent); }
.matrix-table { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: .9rem; }
.matrix-table th { text-align: left; color: var(--muted); font-size: .8rem; font-weight: 650; padding: 12px; border-bottom: 2px solid var(--line); }
.matrix-table th:nth-child(1) { width: 28%; }
.matrix-table th:nth-child(2) { width: 26%; }
.matrix-table th:nth-child(3) { width: 25%; }
.matrix-table th:nth-child(4) { width: 15%; }
.matrix-table th:last-child { width: 64px; }
.matrix-table td { vertical-align: top; border-bottom: 1px solid var(--line); padding: 18px 12px; overflow-wrap: anywhere; }
.matrix-table p { margin: 6px 0; color: var(--muted); line-height: 1.5; white-space: pre-line; }
.matrix-title { display: block; text-align: left; padding: 0; min-height: 0; color: var(--ink); background: none; border: 0; font-size: 1rem; overflow-wrap: anywhere; }
.matrix-title:hover { color: var(--accent-dark); background: none; text-decoration: underline; }
.matrix-evidence { font-weight: 650; }
.matrix-status { color: #795322; font-weight: 650; }
.matrix-status[data-status="active"] { color: var(--accent-dark); }
.matrix-status[data-status="documented"] { color: #346a48; }
.matrix-empty { padding: 30px 0; border-top: 1px solid var(--line); color: var(--muted); }
#matrixCounts { margin-top: 8px; }
#matrixMessage:not(:empty) { margin-bottom: 16px; }
#matrixDialog { width: min(860px, calc(100% - 32px)); }
.matrix-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.matrix-reference { display: grid; grid-template-columns: 160px minmax(0, 1fr) 90px 44px; gap: 12px; align-items: end; padding: 14px 0; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.matrix-reference-note { grid-column: 1 / -1; }
.matrix-reference-link { grid-column: 1 / -1; font-size: .87rem; justify-self: start; }
.matrix-reflection summary { cursor: pointer; color: var(--accent-dark); font-weight: 650; }
.matrix-reflection label { margin-top: 16px; }
.matrix-review { padding-top: 12px; border-top: 1px solid var(--line); }
.matrix-review p { font-size: .85rem; color: var(--muted); margin: 0 0 12px; }
.matrix-revision { padding: 18px 0; border-bottom: 1px solid var(--line); }
.matrix-revision summary { cursor: pointer; line-height: 1.5; overflow-wrap: anywhere; }
.matrix-revision dd { white-space: pre-wrap; }
.pap-tabs { flex-wrap: wrap; gap: 4px 24px; }
@media (max-width: 980px) {
  .section-head { flex-wrap: wrap; }
  .work-grid { grid-template-columns: minmax(230px, .85fr) minmax(0, 1.3fr); gap: 20px; }
  .preview-panel { padding-left: 20px; }
}
@media (max-width: 680px) {
  .matrix-filters { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
  .matrix-filters > button { justify-self: end; }
  .matrix-table, .matrix-table tbody, .matrix-table tr, .matrix-table td { display: block; width: 100%; }
  .matrix-table thead { display: none; }
  .matrix-table tr { border-top: 1px solid var(--line); padding: 14px 0; }
  .matrix-table td { border: 0; padding: 8px 0; }
  .matrix-table td[data-label]::before { content: attr(data-label); display: block; font-size: .75rem; color: var(--muted); margin-bottom: 6px; }
  .matrix-form-grid { grid-template-columns: minmax(0, 1fr); }
  .matrix-reference { grid-template-columns: minmax(0, 1fr) 44px; }
  .matrix-reference label:nth-child(1), .matrix-reference label:nth-child(2) { grid-column: 1 / -1; }
  .matrix-reference-note { grid-column: 1 / -1; }
  .matrix-revision dl { grid-template-columns: minmax(0, 1fr); }
  .matrix-revision dd { margin-bottom: 12px; }
  .assistant-layout { grid-template-columns: minmax(0, 1fr); gap: 28px; }
  .shell { padding: 20px 16px 32px; }
  .topbar { align-items: flex-start; flex-direction: column; gap: 16px; margin-bottom: 24px; }
  .account { width: 100%; justify-content: space-between; }
  .project-title { font-size: 1.45rem; }
  .pap-summary { grid-template-columns: 1fr; gap: 16px; }
  .pap-item { grid-template-columns: minmax(0, 1fr) 18px; gap: 12px; padding: 20px 0; }
  .pap-meta { grid-column: 1; display: flex; flex-wrap: wrap; }
  .pap-item > svg { grid-column: 2; grid-row: 1; }
  .phase-strip { gap: 6px; }
  .phase-strip li { font-size: .72rem; }
  .document-toolbar { align-items: flex-start; }
  .document-toolbar .actions { width: 100%; }
  .work-grid { grid-template-columns: minmax(0, 1fr); }
  .document-list { max-height: 310px; overflow-y: auto; }
  .preview-panel { border-left: 0; border-top: 1px solid var(--line); padding: 20px 0 0; }
  iframe { height: 520px; }
  dialog { padding: 20px; }
}
