:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #1d2430;
  --muted: #667085;
  --line: #e2e5ea;
  --accent: #2459c4;
  --accent-soft: #e8efff;
  --ok: #1f7a45;
  --warn: #a15c00;
  --bad: #b42318;
  --mark: #ffe58a;
  --mark-current: #ffb02e;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
button {
  border: 1px solid var(--line); background: var(--panel); border-radius: 8px;
  padding: 6px 12px; cursor: pointer;
}
button:hover:not(:disabled) { border-color: #c5cbd5; }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.ghost { border-color: transparent; background: transparent; color: var(--muted); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
kbd {
  font: 12px ui-monospace, monospace; border: 1px solid var(--line); border-bottom-width: 2px;
  border-radius: 4px; padding: 0 4px; background: #fafbfc; color: var(--muted);
}
.muted { color: var(--muted); }
.error { color: var(--bad); }

/* Sign in */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: min(360px, 100%); background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 28px; display: grid; gap: 14px;
}
.login-card h1 { margin: 0; font-size: 22px; }
.login-card p { margin: 0; }
.login-card label { display: grid; gap: 4px; font-size: 14px; color: var(--muted); }
.login-card input { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; }

/* Top bar */
#app-view { height: 100vh; display: flex; flex-direction: column; }
.topbar {
  flex: none; z-index: 5; display: flex; align-items: center; gap: 20px;
  padding: 10px 24px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 650; font-size: 15px; }
.progress-wrap { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 220px; }
#position { font-weight: 600; white-space: nowrap; }
#progress-text { font-size: 13px; white-space: nowrap; }
.progress { flex: 1; max-width: 220px; height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
#progress-bar { height: 100%; width: 0; background: var(--ok); transition: width .2s; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.topbar select { padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); max-width: 220px; }
.divider { width: 1px; height: 22px; background: var(--line); margin: 0 2px; }
button.link { border-color: transparent; background: transparent; color: var(--muted); padding: 6px 6px; }
button.link:hover:not(:disabled) { border-color: transparent; color: var(--text); }
.chip { font-size: 12.5px; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.chip.ok { background: #e7f5ec; color: var(--ok); }
.chip.busy { background: #eef2f8; color: var(--muted); }
.chip.warn { background: #fff4e0; color: var(--warn); }
.banner { flex: none; padding: 10px 24px; background: #fff4e0; color: var(--warn); border-bottom: 1px solid var(--line); }

/* Workspace */
.workspace {
  flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(380px, 2fr) 3fr;
}
.evidence-pane { overflow: auto; }
.rating-pane {
  display: flex; flex-direction: column; min-height: 0;
  border-right: 1px solid var(--line); background: var(--panel);
}
.rating-scroll { flex: 1; overflow: auto; padding: 28px 32px 24px; }
.statement-card {
  background: var(--accent-soft); border-radius: 12px; padding: 18px 20px; margin-bottom: 26px;
}
.block { margin: 0 0 24px; border: 0; padding: 0; }
.label { display: block; font-size: 11.5px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .05em; color: var(--muted); margin-bottom: 8px; }
.claim { font-size: 19px; line-height: 1.45; margin: 0; font-weight: 550; }
.paragraph, .comments { margin: 0; line-height: 1.6; color: #344054; white-space: pre-wrap; font-size: 15px; }
.comments-note { border-left: 3px solid var(--line); padding-left: 14px; }
.hint { font-size: 13px; color: var(--muted); margin: 10px 0 0; line-height: 1.45; }

.question { margin: 0; padding: 24px 0 0; border: 0; border-top: 1px solid var(--line); margin-top: 4px; margin-bottom: 24px; }
.question legend, .question > label { display: block; float: left; width: 100%; padding: 0; margin-bottom: 12px;
  font-size: 15px; font-weight: 600; }
.question legend + *, .question > label + * { clear: both; }
.severity-list { display: grid; gap: 8px; }
.option { text-align: left; padding: 11px 14px; display: flex; gap: 14px; align-items: baseline; border-radius: 10px; }
.option b { font-size: 17px; min-width: 14px; color: var(--muted); }
.option span { font-size: 14.5px; line-height: 1.35; }
.option small { color: var(--muted); font-size: 13.5px; }
.option small::before { content: " – "; }
.option.selected { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.option.selected b { color: var(--accent); }
.segmented { display: flex; gap: 8px; }
.segmented .option { flex: 1; justify-content: center; text-align: center; }
textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; resize: vertical; line-height: 1.45; }
.locked .option, .locked textarea { pointer-events: none; opacity: .7; }
.pager {
  flex: none; display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 12px 32px; border-top: 1px solid var(--line); background: var(--panel);
}
.pager button { padding: 8px 18px; }

/* Evidence */
.evidence-pane { --tabs-h: 49px; background: var(--panel); }
.tabs { position: sticky; top: 0; z-index: 2; height: var(--tabs-h); display: flex; align-items: flex-end; gap: 4px;
  padding: 0 20px; background: var(--bg); border-bottom: 1px solid var(--line); }
.tab { border-radius: 8px 8px 0 0; border-bottom: none; background: transparent; padding: 8px 16px; color: var(--muted); margin-bottom: -1px; }
.tab.active { background: var(--panel); border-color: var(--line); font-weight: 600; color: var(--text); }
.tab-body { padding: 0; }
.doc { margin: 0; padding: 24px 28px; white-space: pre-wrap; word-break: break-word;
  font: 13.5px/1.65 ui-monospace, "SF Mono", Menlo, monospace; background: var(--panel); min-height: 100%; }
.record-tools { position: sticky; top: var(--tabs-h); z-index: 1; background: var(--bg); padding: 12px 20px;
  border-bottom: 1px solid var(--line); display: grid; gap: 8px; }
.admission { font-size: 13px; color: var(--muted); }
.search { display: flex; gap: 6px; align-items: center; }
.search input { flex: 1; padding: 7px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.search button { padding: 6px 10px; }
.record { display: grid; grid-template-columns: 230px 1fr; }
.note-index { list-style: none; margin: 0; padding: 12px 0; border-right: 1px solid var(--line);
  font-size: 12.5px; position: sticky; top: calc(var(--tabs-h) + 82px); align-self: start;
  max-height: calc(100vh - 210px); overflow: auto; }
.note-index li { padding: 7px 16px; cursor: pointer; line-height: 1.35; }
.note-index li:hover { background: var(--accent-soft); }
.note-index li.outside { color: var(--muted); font-style: italic; }
.note-index li small { display: block; color: var(--muted); margin-top: 1px; }
.notes { background: var(--panel); }
.note { padding: 20px 28px 24px; border-bottom: 1px solid var(--line); scroll-margin-top: calc(var(--tabs-h) + 90px); }
.note h3 { margin: 0 0 10px; font: 600 13px system-ui, sans-serif; color: var(--accent); }
.note.outside h3 { color: var(--muted); }
.note pre { margin: 0; white-space: pre-wrap; word-break: break-word; font: 13.5px/1.65 ui-monospace, "SF Mono", Menlo, monospace; }
mark { background: var(--mark); padding: 0; }
mark.current { background: var(--mark-current); }

dialog { border: 1px solid var(--line); border-radius: 12px; max-width: 640px; padding: 28px 32px; }
dialog::backdrop { background: rgba(16, 24, 40, .35); }
dialog h2 { margin-top: 0; }
dialog li { margin-bottom: 8px; line-height: 1.45; }

@media (max-width: 1100px) {
  .topbar { flex-wrap: wrap; gap: 10px 16px; }
  .progress-wrap { order: 3; flex-basis: 100%; }
}
@media (max-width: 1000px) {
  #app-view { height: auto; }
  .workspace { grid-template-columns: 1fr; }
  .rating-pane { border-right: none; border-bottom: 1px solid var(--line); }
  .rating-scroll { padding: 20px 16px; }
  .pager { padding: 12px 16px; }
  .topbar { padding: 10px 16px; }
  .topbar-actions { flex-wrap: wrap; }
  .record { grid-template-columns: 1fr; }
  .note-index { display: none; }
}
