:root {
  color-scheme: light dark;
  --paper: light-dark(#fcfbf7, #202522);
  --surface: light-dark(#ffffff, #2d3731);
  --ink: light-dark(#1d352b, #ecf4ec);
  --quiet: light-dark(#4a6257, #bbcfc2);
  --line: light-dark(#d5dfd5, #45574c);
  --green: light-dark(#245640, #c0e5c9);
  --on-green: light-dark(#ffffff, #203b2e);
  --tint: light-dark(#e2eddf, #34473b);
  --error: light-dark(#813b2d, #f8c3a9);
  color: var(--ink);
  background: var(--paper);
  font: 16px/1.5 "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
.masthead { background: var(--surface); border-bottom: 1px solid var(--line); }
.masthead-inner, main { max-width: 1080px; margin: auto; padding: 18px 22px; }
.masthead-inner { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; }
.masthead strong { border-left: 4px solid var(--green); padding-left: 9px; }
.masthead [aria-current="page"] { color: var(--on-green); background: var(--green); }
h1 { margin: 8px 0 16px; font-size: clamp(24px, 5vw, 36px); line-height: 1.15; }
h2 { font-size: 19px; }
h3, h2, p { margin: 0; }
.quiet { color: var(--quiet); font-size: 14px; }
.panel { padding: 16px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.panel > * + * { margin-top: 9px; }
.panel-title { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.accent { border-top: 3px solid var(--green); }
.login { max-width: 400px; margin: 30px auto; }
.workspace-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); align-items: start; gap: 14px; }
.column { display: grid; gap: 14px; min-width: 0; }
.route, .assistant-note { background: var(--tint); }
.route ol, .route ul { padding-left: 21px; }
.route li + li { margin-top: 7px; }
.assistant-note { padding: 9px; border-radius: 5px; }
.result-list { list-style: none; padding: 0; margin-bottom: 0; }
.result-list li + li { border-top: 1px solid var(--line); margin-top: 10px; padding-top: 10px; }
.result-list li > * + * { margin-top: 4px; }
.result-observation { white-space: pre-wrap; overflow-wrap: anywhere; }
.task-description { margin-bottom: 16px; white-space: pre-wrap; overflow-wrap: anywhere; }
.branch-navigation { margin-bottom: 14px; }
.branch-navigation p { margin-bottom: 0; }
.branch-controls { display: flex; align-items: end; flex-wrap: wrap; gap: 8px; }
.branch-controls > label { max-width: 430px; }
.branch-controls .actions { margin-bottom: 1px; }
.wide-dialog { width: min(660px, calc(100vw - 24px)); max-width: none; }
.wide-dialog > * + * { margin-top: 12px; }
#history-compare fieldset {
  display: flex;
  justify-content: start;
  align-items: end;
  gap: 8px;
  flex-wrap: wrap;
  border: 1px solid var(--line);
  border-radius: 6px;
}
#history-compare fieldset label { width: auto; }
#history-compare input { max-width: 115px; }
#history-changes { table-layout: fixed; }
#history-changes td { vertical-align: top; white-space: pre-wrap; overflow-wrap: anywhere; }
#trace-source { overflow-wrap: anywhere; }
.assertion-past { padding-left: 12px; }
.assertion-past summary { cursor: pointer; }
.assertion-past .result-list { margin-top: 6px; }
#contradiction-form { width: 100%; }
#contradiction-form fieldset {
  display: grid;
  gap: 8px;
  min-width: 0;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
}
.metric-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; }
.horizontal-scroll { max-width: 100%; overflow-x: auto; }
.comparison-table td, .comparison-table th { min-width: 110px; overflow-wrap: anywhere; }
.comparison-table td { vertical-align: top; }
#variant-estimates, #trial-findings fieldset {
  display: grid;
  gap: 8px;
  min-width: 0;
  width: 100%;
  margin: 0 0 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
}
#trial-findings { width: 100%; }
.result-list .quiet { overflow-wrap: anywhere; }
.assessment-history { border-left: 3px solid var(--green); padding-left: 10px; }
.assessment-history > * + * { margin-top: 4px; }
.account-list { list-style: none; padding: 0; margin-bottom: 0; }
.account-list li { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; padding: 10px 0; }
.account-list li + li { border-top: 1px solid var(--line); }
.account-list .account-name { font-weight: 650; overflow-wrap: anywhere; }
.admin-projects { margin-top: 16px; }
.task-list { list-style: none; padding: 10px 16px; }
.task-list li + li { border-top: 1px solid var(--line); padding-top: 8px; }
.link { border: 0; background: none; color: var(--green); padding: 4px 0; text-align: start; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: 6px; border-top: 1px solid var(--line); text-align: start; }
th { font-size: 13px; color: var(--quiet); }
td { font-size: 14px; }
button, input, textarea, select { font: inherit; }
button {
  padding: 6px 12px;
  border: 1px solid var(--green);
  border-radius: 6px;
  background: var(--green);
  color: var(--on-green);
  font-weight: 600;
  cursor: pointer;
}
button:disabled { opacity: .7; cursor: default; }
.secondary { background: var(--surface); color: var(--green); border-color: var(--line); }
form, label { display: grid; gap: 8px; }
form { justify-items: start; }
label { min-width: 0; width: 100%; }
input, textarea, select { width: 100%; padding: 7px 8px; border: 1px solid var(--line); color: var(--ink); background: var(--surface); border-radius: 5px; }
textarea { resize: vertical; }
dialog { max-width: min(440px, calc(100vw - 24px)); border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); }
#decision-dialog, #result-dialog, #assessment-dialog, #closure-dialog,
#task-dialog, #criterion-dialog, #project-dialog, #members-dialog,
#access-dialog, #branch-dialog, #links-dialog,
#assertion-dialog, #assertion-assessment-dialog,
#contradiction-confirm-dialog, #selection-dialog { width: min(440px, calc(100vw - 24px)); }
#members-dialog > * + *, #access-dialog > * + *, #links-dialog > * + * { margin-top: 12px; }
dialog::backdrop { background: #0007; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.checkbox { display: flex; align-items: center; gap: 9px; }
.checkbox input { width: auto; }
#message, [role="alert"] { color: var(--error); margin-top: 12px; }

@media (max-width: 720px) {
  .workspace-grid { grid-template-columns: 1fr; }
  .masthead-inner, main { padding-inline: 12px; }
  .panel { padding: 12px; }
  th, td { padding-inline: 3px; }
  table button { padding: 4px; font-size: 13px; }
}
