/* Clj Desk — one stylesheet, both themes, no external fonts. */

:root {
  --bg: #0b1220;
  --bg-soft: #111a2b;
  --card: #131d31;
  --card-2: #17223a;
  --ink: #e8eefc;
  --ink-dim: #a7b4cd;
  --ink-faint: #7c8aa5;
  --line: #24314e;
  --line-soft: #1c2740;
  --accent: #5eead4;
  --accent-ink: #052e2b;
  --link: #7dd3fc;
  --ok: #34d399;
  --warn: #fbbf24;
  --bad: #fb7185;
  --crit: #f43f5e;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .28);
  --radius: 12px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

:root[data-theme="light"] {
  --bg: #f6f8fc;
  --bg-soft: #eef2f9;
  --card: #ffffff;
  --card-2: #f4f7fc;
  --ink: #16203a;
  --ink-dim: #4a5876;
  --ink-faint: #6b7897;
  --line: #d9e1ee;
  --line-soft: #e6ecf6;
  --accent: #0d9488;
  --accent-ink: #ffffff;
  --link: #0369a1;
  --ok: #059669;
  --warn: #b45309;
  --bad: #be123c;
  --crit: #9f1239;
  --shadow: 0 1px 2px rgba(16, 32, 64, .06), 0 8px 24px rgba(16, 32, 64, .07);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre, .mono { font-family: var(--mono); font-size: .92em; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5rem; }
h1 { font-size: clamp(1.5rem, 3.2vw, 2.1rem); letter-spacing: -.01em; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.05rem; }
h4 { font-size: .95rem; color: var(--ink-dim); margin-top: 1.1rem; }
p { margin: 0 0 .8rem; }
.muted { color: var(--ink-dim); }
.small { font-size: .85rem; }
.hidden { display: none !important; }
.sep { color: var(--ink-faint); margin: 0 .4rem; }

/* ---------------------------------------------------------------- topbar */

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap;
  padding: .7rem clamp(.8rem, 3vw, 2rem);
  border-bottom: 1px solid var(--line);
  background: var(--bg-soft);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: .2rem; min-width: 0; }
.brand strong { white-space: nowrap; }
.backlink { color: var(--ink-dim); font-size: .9rem; }
.topactions { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.credits { font-family: var(--mono); font-size: .85rem; color: var(--ink-dim); }
.topup { font-size: .85rem; }

button {
  font: inherit; cursor: pointer; border-radius: 9px;
  border: 1px solid var(--line); background: var(--card);
  color: var(--ink); padding: .42rem .8rem;
}
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.ghost { background: transparent; }
button.primary {
  background: var(--accent); color: var(--accent-ink);
  border-color: var(--accent); font-weight: 650; padding: .55rem 1.15rem;
}
button.secondary { background: var(--card-2); }
button.big { padding: .6rem 1.1rem; font-weight: 600; }
button.mini { padding: .28rem .6rem; font-size: .82rem; }

/* ---------------------------------------------------------------- lanebar */

.lanebar {
  display: flex; gap: .6rem; flex-wrap: wrap;
  padding: .8rem clamp(.8rem, 3vw, 2rem);
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}
.lanegroup { display: flex; flex-direction: column; gap: .25rem; flex: 1 1 220px; min-width: 0; }
.stagelabel {
  font-size: .7rem; text-transform: uppercase; letter-spacing: .09em;
  color: var(--ink-faint); padding-left: .2rem;
}
button.lane {
  display: flex; flex-direction: column; align-items: flex-start; gap: .1rem;
  text-align: left; padding: .55rem .8rem; width: 100%;
  background: var(--card); border: 1px solid var(--line);
}
button.lane strong { font-size: .95rem; }
button.lane span { font-size: .8rem; color: var(--ink-dim); }
button.lane[aria-pressed="true"] {
  border-color: var(--accent);
  box-shadow: inset 3px 0 0 var(--accent);
  background: var(--card-2);
}

/* ---------------------------------------------------------------- layout */

main { max-width: 1080px; margin: 0 auto; padding: clamp(1rem, 3vw, 2rem); }
.hero { margin-bottom: 1.4rem; }
.lede { color: var(--ink-dim); max-width: 74ch; }
.herobtns { display: flex; gap: .6rem; flex-wrap: wrap; margin: .9rem 0 .5rem; }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: clamp(.9rem, 2.2vw, 1.3rem); margin-bottom: 1.1rem;
}

.field { margin-bottom: 1rem; }
.labelrow { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
label { font-weight: 600; font-size: .92rem; }
label.inline { font-weight: 500; font-size: .85rem; color: var(--ink-dim); }

textarea, input[type="search"], select {
  width: 100%; font-family: var(--mono); font-size: .86rem;
  color: var(--ink); background: var(--bg-soft);
  border: 1px solid var(--line); border-radius: 9px;
  padding: .6rem .7rem; resize: vertical; line-height: 1.5;
}
input[type="search"], select { font-family: var(--sans); font-size: .87rem; width: auto; }
textarea:focus, input:focus, select:focus, button:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
.dropzone { border: 1px dashed var(--line); border-radius: 10px; padding: .5rem; }
.dropzone.over { border-color: var(--accent); background: var(--card-2); }
.droprow { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-top: .45rem; }
.droprow input[type="file"] { font-size: .78rem; color: var(--ink-dim); max-width: 100%; }

/* ---------------------------------------------------------------- prescan */

.prescan { border-top: 1px solid var(--line-soft); padding-top: .9rem; margin-bottom: 1rem; }
.factgrid {
  display: grid; gap: .5rem; margin-bottom: .8rem;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}
.fact {
  background: var(--card-2); border: 1px solid var(--line-soft);
  border-radius: 9px; padding: .5rem .6rem;
}
.fact .k { display: block; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-faint); }
.fact .v { font-family: var(--mono); font-size: 1.02rem; font-weight: 600; }
.fact .sub { display: block; font-size: .76rem; color: var(--ink-dim); }

.flaglist { display: flex; flex-direction: column; gap: .4rem; }
.flag {
  display: grid; grid-template-columns: auto 1fr; gap: .55rem;
  padding: .45rem .55rem; border-radius: 8px;
  background: var(--card-2); border: 1px solid var(--line-soft);
}
.flag .sev {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .06em;
  font-weight: 700; padding: .1rem .4rem; border-radius: 5px; height: fit-content;
  white-space: nowrap;
}
.sev-blocker { background: color-mix(in srgb, var(--crit) 22%, transparent); color: var(--crit); }
.sev-warn { background: color-mix(in srgb, var(--warn) 22%, transparent); color: var(--warn); }
.sev-note { background: color-mix(in srgb, var(--link) 20%, transparent); color: var(--link); }
.flag .what { font-size: .88rem; }
.flag .fix { font-size: .82rem; color: var(--ink-dim); }
.flag .fid { font-family: var(--mono); font-size: .74rem; color: var(--ink-faint); }

.warnline {
  background: color-mix(in srgb, var(--warn) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--warn) 45%, transparent);
  color: var(--ink); border-radius: 9px; padding: .5rem .7rem; font-size: .87rem;
}
.delta {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  border-radius: 9px; padding: .5rem .7rem; font-size: .86rem;
}
.exportrow { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: .8rem; }

/* ---------------------------------------------------------------- run row */

.runrow {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap; border-top: 1px solid var(--line-soft); padding-top: .9rem;
}
.runinfo { display: flex; align-items: center; gap: .7rem; flex-wrap: wrap; }
.lanenow { font-weight: 650; }
.estimate { font-family: var(--mono); }
.runbtns { display: flex; gap: .5rem; }
.shortfall { color: var(--bad); font-size: .85rem; }

/* ---------------------------------------------------------------- progress */

.progresshead { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.steps { list-style: none; margin: .7rem 0 .4rem; padding: 0; display: flex; flex-direction: column; gap: .3rem; }
.steps li { display: flex; align-items: center; gap: .55rem; font-size: .89rem; color: var(--ink-faint); }
.steps li .dot {
  width: .7rem; height: .7rem; border-radius: 50%; flex: none;
  border: 1px solid var(--line); background: transparent;
}
.steps li.active { color: var(--ink); }
.steps li.active .dot { background: var(--accent); border-color: var(--accent); }
.steps li.done { color: var(--ink-dim); }
.steps li.done .dot { background: var(--ok); border-color: var(--ok); }

/* ---------------------------------------------------------------- result */

.verdicthead { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: .5rem; }
.badge {
  font-size: .74rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  padding: .18rem .5rem; border-radius: 6px;
  background: color-mix(in srgb, var(--accent) 20%, transparent); color: var(--accent);
}
.badge.subtle { background: var(--card-2); color: var(--ink-dim); font-weight: 600; }
.badge.warnbadge { background: color-mix(in srgb, var(--warn) 20%, transparent); color: var(--warn); }
.badge.good { background: color-mix(in srgb, var(--ok) 20%, transparent); color: var(--ok); }
.badge.mid { background: color-mix(in srgb, var(--warn) 20%, transparent); color: var(--warn); }
.badge.bad { background: color-mix(in srgb, var(--crit) 20%, transparent); color: var(--crit); }
.verdict { font-size: 1.05rem; font-weight: 600; }

.handoff { background: var(--card-2); }
.handoffbtns { display: flex; gap: .5rem; flex-wrap: wrap; }

.finding {
  border: 1px solid var(--line-soft); border-radius: 10px;
  padding: .7rem .8rem; margin-bottom: .6rem; background: var(--card-2);
}
.finding.crit { border-left: 3px solid var(--crit); }
.finding.high { border-left: 3px solid var(--bad); }
.finding.medium { border-left: 3px solid var(--warn); }
.finding.low { border-left: 3px solid var(--link); }
.findinghead { display: flex; align-items: baseline; gap: .5rem; flex-wrap: wrap; }
.findinghead .fid { font-family: var(--mono); font-size: .78rem; color: var(--ink-faint); }
.findinghead .ftitle { font-weight: 650; }
.findinghead .area {
  font-size: .72rem; color: var(--ink-dim); background: var(--card);
  border: 1px solid var(--line-soft); border-radius: 5px; padding: .05rem .35rem;
}
.finding .target { font-family: var(--mono); font-size: .82rem; color: var(--accent); }
.finding dl { margin: .45rem 0 0; display: grid; grid-template-columns: auto 1fr; gap: .2rem .6rem; }
.finding dt { font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-faint); }
.finding dd { margin: 0; font-size: .88rem; }
.blocksflag { color: var(--crit); font-size: .78rem; font-weight: 700; }
.cited { font-family: var(--mono); font-size: .76rem; color: var(--ink-faint); }

.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; font-size: .87rem; min-width: 520px; }
th, td { text-align: left; padding: .38rem .55rem; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
th { font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-faint); font-weight: 600; white-space: nowrap; }
td.mono, th.mono { font-family: var(--mono); }
tr.g-broken td:first-child { box-shadow: inset 3px 0 0 var(--crit); }
tr.g-watch td:first-child { box-shadow: inset 3px 0 0 var(--warn); }
tr.g-ok td:first-child { box-shadow: inset 3px 0 0 var(--ok); }
.grade { font-weight: 650; }
.grade-ok { color: var(--ok); }
.grade-watch { color: var(--warn); }
.grade-broken { color: var(--crit); }
.cov-confirmed { color: var(--ok); font-weight: 600; }
.cov-set-aside { color: var(--warn); font-weight: 600; }
.cov-contradicted { color: var(--link); font-weight: 600; }
.cov-missing { color: var(--crit); font-weight: 700; }

.artifact { border: 1px solid var(--line-soft); border-radius: 10px; margin-bottom: .7rem; overflow: hidden; }
.artifacthead {
  display: flex; align-items: center; justify-content: space-between; gap: .6rem;
  flex-wrap: wrap; padding: .45rem .65rem; background: var(--card-2);
  border-bottom: 1px solid var(--line-soft);
}
.artifacthead .an { font-family: var(--mono); font-size: .84rem; font-weight: 600; }
.artifact pre {
  margin: 0; padding: .7rem; overflow-x: auto; max-height: 30rem;
  background: var(--bg-soft); font-size: .8rem; line-height: 1.5;
}
.numbered { padding-left: 1.3rem; }
.numbered li { margin-bottom: .35rem; }
ul { padding-left: 1.2rem; }
ul li { margin-bottom: .25rem; }
.emptynote { color: var(--ink-faint); font-style: italic; font-size: .88rem; }

/* ---------------------------------------------------------------- history */

.historyhead { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.historyctl { display: flex; align-items: center; gap: .45rem; flex-wrap: wrap; }
.histrow {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: .7rem; flex-wrap: wrap; padding: .5rem .1rem;
  border-bottom: 1px solid var(--line-soft);
}
.histmain { min-width: 0; flex: 1 1 320px; }
.histmain .ht { font-weight: 600; font-size: .92rem; }
.histmain .hv { font-size: .84rem; color: var(--ink-dim); }
.histmeta { font-family: var(--mono); font-size: .76rem; color: var(--ink-faint); }
.histbtns { display: flex; gap: .35rem; }

.explainer { background: var(--card-2); }
.explaingrid { display: grid; gap: .9rem; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.explaingrid h4 { margin-top: 0; color: var(--ink); }
.explaingrid p { font-size: .87rem; color: var(--ink-dim); margin: 0; }

.foot {
  max-width: 1080px; margin: 0 auto; padding: 1.4rem clamp(.8rem, 3vw, 2rem) 3rem;
  border-top: 1px solid var(--line); color: var(--ink-dim); font-size: .88rem;
}

@media (max-width: 560px) {
  .lanebar { flex-direction: column; }
  .runrow { flex-direction: column; align-items: stretch; }
  .runbtns button { width: 100%; }
}

/* ------------------------------------------------- docs pages (api, tokens) */

main.doc { max-width: 900px; }
main.doc h1 { margin-bottom: .8rem; }
main.doc h2 { margin-top: 2rem; padding-top: .4rem; border-top: 1px solid var(--line-soft); }
main.doc h3 { margin-top: 1.4rem; }
main.doc p, main.doc li { color: var(--ink-dim); }
main.doc p code, main.doc li code, main.doc td code {
  background: var(--card-2); border: 1px solid var(--line-soft);
  border-radius: 5px; padding: .05rem .3rem; color: var(--ink);
}
main.doc table { margin: .6rem 0 1rem; }
main.doc table code { white-space: nowrap; }

.codegroup { margin: .7rem 0 1.2rem; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.tabs {
  display: flex; gap: .1rem; flex-wrap: wrap; padding: .3rem .35rem;
  background: var(--card-2); border-bottom: 1px solid var(--line);
}
button.tab {
  border: 1px solid transparent; background: transparent; color: var(--ink-dim);
  padding: .22rem .55rem; font-size: .82rem; border-radius: 6px;
}
button.tab:hover { color: var(--ink); }
button.tab.active {
  background: var(--card); color: var(--ink);
  border-color: var(--line); font-weight: 600;
}
.codegroup pre {
  margin: 0; padding: .8rem; overflow-x: auto;
  background: var(--bg-soft); font-size: .8rem; line-height: 1.55;
}
.codegroup pre[hidden] { display: none; }

.statebox {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; padding: .7rem .8rem; margin: 1rem 0;
}
.statebox strong { display: block; margin-bottom: .2rem; }
.statebox p { margin: 0; }
.tokenrow { display: flex; gap: .45rem; flex-wrap: wrap; align-items: center; margin: .5rem 0; }
.tokenbox {
  flex: 1 1 320px; min-width: 0; font-family: var(--mono); font-size: .82rem;
  background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: 8px; padding: .5rem .6rem; overflow-wrap: anywhere; color: var(--ink);
}
.envelope { background: var(--card-2); }
.note-callout {
  background: color-mix(in srgb, var(--link) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--link) 40%, transparent);
  border-radius: 9px; padding: .6rem .75rem; margin: .8rem 0;
}
.note-callout p:last-child { margin-bottom: 0; }

/* ---- Clj Desk additions ---------------------------------------------- */

/* A survived mutant is the whole point of the mutants lane, so it must not
   look like a note. */
.mstatus { font-weight: 600; font-size: .8rem; padding: .1rem .42rem; border-radius: 5px; white-space: nowrap; border: 1px solid var(--line); }
.mstatus-killed { color: var(--ok); border-color: var(--ok); }
.mstatus-survived { color: var(--bad); border-color: var(--bad); font-weight: 700; }
.mstatus-uncertain { color: var(--warn); border-color: var(--warn); }

/* The docstring lane shows prose before and after, so a verdict chip plus a
   pre-wrapped block reads better than another table cell. */
.dsverdict { font-weight: 600; font-size: .8rem; padding: .1rem .42rem; border-radius: 5px; white-space: nowrap; border: 1px solid var(--line); }
.dsv-keep { color: var(--ok); border-color: var(--ok); }
.dsv-tighten { color: var(--warn); border-color: var(--warn); }
.dsv-relocate { color: var(--link); border-color: var(--link); }
.dsv-delete { color: var(--bad); border-color: var(--bad); }
.dsv-add { color: var(--accent); border-color: var(--accent); }
.prose { white-space: pre-wrap; font-family: var(--mono); font-size: .8rem; line-height: 1.5; margin: .2rem 0; }
.prosewas { color: var(--ink-faint); }
.dscard { border: 1px solid var(--line-soft); border-radius: 10px; padding: .6rem .75rem; margin: .5rem 0; background: var(--card-2); }
.dshead { display: flex; flex-wrap: wrap; gap: .5rem; align-items: baseline; }
.dshead .dn { font-family: var(--mono); font-weight: 600; }

/* Wide reader tables scroll inside their own box; the page body never does. */
.formscroll { max-height: 24rem; overflow: auto; }
.balancebad { font-family: var(--mono); font-size: .8rem; white-space: pre; overflow-x: auto; padding: .4rem 0; }
.nsbox { display: grid; gap: .3rem; margin: .4rem 0; }
.nsrow { display: grid; grid-template-columns: 9rem 1fr; gap: .5rem; font-size: .86rem; }
.nsrow > span:first-child { color: var(--ink-faint); }
.nsrow code { font-family: var(--mono); font-size: .82rem; }
