:root {
  --bg: #f6f5f1;
  --panel: #ffffff;
  --panel-2: #f1efe8;
  --text: #1d2420;
  --soft: #56605a;
  --faint: #89918b;
  --line: rgba(29, 36, 32, 0.12);
  --accent: #1f5c46;
  --accent-ink: #ffffff;
  --accent-soft: #e3efe9;
  --ok: #1f7a4d;
  --ok-bg: #e2f3ea;
  --warn: #9a6200;
  --warn-bg: #fbf0d9;
  --stop: #8a3b2c;
  --stop-bg: #f8e6e1;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --serif: "Source Serif 4", Georgia, serif;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131714; --panel: #1b201c; --panel-2: #222823; --text: #e8ece8; --soft: #b0b9b2; --faint: #7f8a82;
    --line: rgba(232, 236, 232, 0.12); --accent: #6fc39b; --accent-ink: #0e1a14; --accent-soft: #1f3329;
    --ok: #7fd3a6; --ok-bg: #1d3328; --warn: #f0c46a; --warn-bg: #3a2f17; --stop: #f09c86; --stop-bg: #3b221c;
  }
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-font-smoothing: antialiased; }
body { min-height: 100vh; display: flex; flex-direction: column; background: var(--bg); color: var(--text); font: 15px/1.55 var(--sans); }
button, input, textarea { font: inherit; color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.topbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 14px 24px; border-bottom: 1px solid var(--line); background: var(--panel); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -0.01em; }
.mark { width: 22px; height: 22px; border-radius: 6px; background: linear-gradient(135deg, var(--accent), #3e8c6b); position: relative; }
.mark::after { content: ""; position: absolute; inset: 6px 5px; border-left: 2px solid var(--accent-ink); border-bottom: 2px solid var(--accent-ink); transform: rotate(-45deg) translate(1px, -2px); width: 9px; height: 5px; }
.model-tag { font-size: 12.5px; color: var(--soft); padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel-2); }
.model-tag.off { color: var(--stop); background: var(--stop-bg); }
main { flex: 1; width: 100%; }
.foot { padding: 14px 24px; font-size: 12.5px; color: var(--faint); border-top: 1px solid var(--line); text-align: center; }

a.btn { color: var(--text); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 8px 16px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); font-weight: 600; cursor: pointer; text-decoration: none; transition: background .15s, border-color .15s; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; }
.btn.small { min-height: 34px; padding: 6px 12px; font-size: 13.5px; }
.btn.danger:hover { border-color: var(--stop); color: var(--stop); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* Start view */
.start { max-width: 760px; margin: 0 auto; padding: 56px 20px 40px; }
.start h1 { font-family: var(--serif); font-weight: 600; font-size: clamp(30px, 5vw, 42px); line-height: 1.12; letter-spacing: -0.015em; }
.lede { margin-top: 14px; color: var(--soft); font-size: 16.5px; }
.dropzone { margin-top: 28px; padding: 30px 24px; border: 1.5px dashed color-mix(in srgb, var(--accent) 45%, var(--line)); border-radius: var(--radius); background: var(--panel); text-align: center; transition: background .15s, border-color .15s; }
.dropzone.over { background: var(--accent-soft); border-color: var(--accent); }
.drop-title { font-weight: 600; font-size: 17px; margin-bottom: 12px; }
.hint { margin-top: 10px; font-size: 13px; color: var(--faint); }
.drop-busy, .drop-error { display: none; }
body[data-phase="FILE_SELECTED"] .drop-idle, body[data-phase="PROCESSING"] .drop-idle, body[data-phase="PROCESSING_ERROR"] .drop-idle { display: none; }
body[data-phase="FILE_SELECTED"] .drop-busy, body[data-phase="PROCESSING"] .drop-busy { display: block; }
body[data-phase="PROCESSING_ERROR"] .drop-error { display: block; }
.progress { height: 8px; border-radius: 999px; background: var(--panel-2); overflow: hidden; max-width: 420px; margin: 0 auto; }
.bar { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.drop-busy .btn { margin-top: 14px; }
.drop-error .hint { margin: 0 0 16px; color: var(--stop); }
.privacy { margin-top: 22px; padding: 16px 18px; border-radius: var(--radius); background: var(--accent-soft); font-size: 14px; }
.privacy h2 { font-size: 14px; font-weight: 700; margin-bottom: 6px; }
.privacy p + p { margin-top: 6px; }
.steps { margin-top: 22px; padding-left: 20px; color: var(--soft); font-size: 14px; display: grid; gap: 6px; }
.steps b { color: var(--text); }

/* Workspace */
.workspace { display: none; }
body[data-phase="READY"] .start, body[data-phase="ANSWERING"] .start { display: none; }
body[data-phase="READY"] .workspace, body[data-phase="ANSWERING"] .workspace { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 0; height: calc(100vh - 110px); min-height: 560px; }
.tabs { display: none; }
.pane { min-width: 0; min-height: 0; }
.chat { overflow-y: auto; padding: 20px 22px 32px; border-right: 1px solid var(--line); }
.viewer { display: flex; flex-direction: column; background: var(--panel-2); }
.viewer-bar { padding: 10px 16px; font-size: 13px; color: var(--soft); border-bottom: 1px solid var(--line); background: var(--panel); }
#viewer { flex: 1; width: 100%; border: 0; background: var(--panel-2); }

.report-bar { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.report-name { font-weight: 700; overflow-wrap: anywhere; }
.report-meta { font-size: 13px; color: var(--soft); }
.report-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.notes { list-style: none; margin-top: 10px; display: grid; gap: 4px; font-size: 12.5px; color: var(--soft); }
.notes li::before { content: "· "; color: var(--faint); }

.ask { margin-top: 16px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.ask textarea { width: 100%; resize: vertical; min-height: 56px; border: 0; background: transparent; outline: none; font-size: 15px; }
.ask-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
.mode { border: 0; display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--soft); }
.mode label { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; }
.mode-note { font-size: 12.5px; color: var(--warn); margin-top: 6px; display: none; }
.mode-note.show { display: block; }
body[data-phase="ANSWERING"] #askBtn { opacity: .6; pointer-events: none; }

.answers { margin-top: 18px; display: grid; gap: 14px; }
.card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); padding: 14px 16px; }
.card .q { font-weight: 600; }
.chip { display: inline-flex; align-items: center; gap: 6px; margin-top: 8px; padding: 3px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 700; letter-spacing: .01em; }
.chip.supported { color: var(--ok); background: var(--ok-bg); }
.chip.partial { color: var(--warn); background: var(--warn-bg); }
.chip.insufficient_evidence, .chip.error { color: var(--stop); background: var(--stop-bg); }
.chip.pending { color: var(--soft); background: var(--panel-2); }
.card .a { margin-top: 8px; }
.claims { list-style: none; margin-top: 10px; display: grid; gap: 10px; }
.claim { padding: 10px 12px; border-radius: 10px; background: var(--panel-2); }
.claim.bad { opacity: .75; border-left: 3px solid var(--stop); }
.claim .kind { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); font-weight: 700; }
.claim blockquote { margin-top: 6px; padding-left: 10px; border-left: 2px solid var(--line); font-family: var(--serif); color: var(--soft); font-size: 14px; }
.cites { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.cite { font-size: 12.5px; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; }
.cite:hover { border-color: var(--accent); color: var(--accent); }
.checks { font-size: 12px; color: var(--faint); margin-top: 6px; }
.warn-list { margin-top: 10px; padding-left: 18px; font-size: 13px; color: var(--warn); }
.reason { margin-top: 8px; font-size: 14px; color: var(--soft); }
.meta { margin-top: 10px; font-size: 12px; color: var(--faint); }
details.unverified { margin-top: 8px; font-size: 13px; color: var(--soft); }
details.unverified summary { cursor: pointer; }

@media (max-width: 900px) {
  body[data-phase="READY"] .workspace, body[data-phase="ANSWERING"] .workspace { display: flex; flex-direction: column; height: auto; min-height: 0; }
  .tabs { display: flex; gap: 6px; padding: 10px 16px 0; }
  .tab { flex: 1; padding: 9px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); font-weight: 600; cursor: pointer; }
  .tab[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
  .chat { border-right: 0; padding: 16px; }
  .viewer { height: calc(100vh - 170px); min-height: 480px; }
  .workspace[data-tab="chat"] .viewer, .workspace[data-tab="report"] .chat { display: none; }
  .topbar { padding: 12px 16px; }
  .model-tag { display: none; }
  .start { padding-top: 32px; }
}
