/* GAF-J visual system: ink rail + warm paper (light, default) and ink rail + graphite canvas (dark, by choice).
   The rail is a brand constant — #14171c in both modes, never themed. Fonts are self-hosted
   (ui/fonts/*.woff2, latin subset only) so the CSP's style-src/font-src 'self' never has to loosen. */

@font-face { font-family: "Space Grotesk"; font-style: normal; font-weight: 500 700; font-display: swap; src: url("/fonts/spacegrotesk-var.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-style: normal; font-weight: 400; font-display: swap; src: url("/fonts/plexmono-400.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-style: normal; font-weight: 500; font-display: swap; src: url("/fonts/plexmono-500.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-style: normal; font-weight: 600; font-display: swap; src: url("/fonts/plexmono-600.woff2") format("woff2"); }

:root {
  --sans: "Space Grotesk", ui-sans-serif, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --rail: #14171c; --rail-active: #20242c; --rail-text: #e6e8ec; --rail-muted: #8b90a0; --rail-dim: #5b6070;

  /* light (default) */
  --canvas: #f6f4ef; --surface: #ffffff; --surface-2: #ffffff;
  --line: #e3ddd0; --line-2: #d9d2c4;
  --ink: #1c1f26; --muted: #6b7280; --dim: #8a8477;
  --accent: #0e8f83; --accent-ink: #ffffff; --accent-hover: #0b746a;
  --good: #1f9d5c; --good-bg: #dff3e6; --good-bright: #146942;
  --warn: #b5750d; --warn-bg: #f5e6cc;
  --bad: #c8392c; --bad-bg: #f6dedb; --bad-bright: #8f261c;
  --pin: #7c4fd1; --pin-bg: #ece3fa;
  --shadow: 0 20px 60px -35px #0003;
}
/* dark is a choice, never inferred from the OS */
:root[data-theme="dark"] { --canvas: #0e1015; --surface: #15171d; --surface-2: #1b1e24;
  --line: #262a33; --line-2: #333744; --ink: #e9ebf0; --muted: #8b90a0; --dim: #5b6070;
  --accent: #3ecfc0; --accent-ink: #0e1015; --accent-hover: #6fe0d4;
  --good: #34c77b; --good-bg: #234d3a; --good-bright: #7bf0ac;
  --warn: #e0a634; --warn-bg: #4a3a1c;
  --bad: #e0554a; --bad-bg: #4a2b28; --bad-bright: #ff9d94;
  --pin: #a578e8; --pin-bg: #3a2f52; --shadow: 0 20px 60px -30px #000; }

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--canvas); color: var(--ink); font: 14px/1.5 var(--sans); }
a { color: var(--accent); text-decoration: none; transition: color .15s; }
a:hover { color: var(--accent-hover); text-decoration: underline; }
button, select, input, textarea { font: inherit; color: inherit; }
button { background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 6px; padding: 7px 13px; cursor: pointer; font-size: 13px; transition: border-color .15s, opacity .15s; }
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
button.danger { color: var(--bad); }
button.small { padding: 5px 10px; font-size: 12px; }
button:disabled { opacity: .5; cursor: default; }
input, select, textarea { background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 6px; padding: 7px 9px; }
textarea { width: 100%; min-height: 120px; font-family: var(--mono); font-size: 12px; }

.layout { display: grid; grid-template-columns: 170px 1fr; min-height: 100vh; }
.rail { background: var(--rail); color: var(--rail-text); padding: 22px 16px; display: flex; flex-direction: column; gap: 22px; }
.rail .brand { font-family: var(--mono); font-weight: 600; font-size: 15px; letter-spacing: .02em; display: flex; align-items: center; justify-content: space-between; }
.rail .brand .mark { width: 40px; height: 40px; border-radius: 9px; margin-right: 10px; border: 1px solid #333744; }
.rail .brand span { flex: 1; }
.rail nav, .rail > a { display: flex; flex-direction: column; gap: 2px; }
.rail a { color: var(--rail-muted); padding: 9px 10px; border-radius: 6px; display: block; font-size: 13.5px; }
.rail a.active { background: var(--rail-active); color: var(--rail-text); font-weight: 600; }
.rail a:hover { background: var(--rail-active); color: var(--rail-text); text-decoration: none; }
.rail .foot { margin-top: auto; font-size: 11.5px; color: var(--rail-dim); display: flex; flex-direction: column; gap: 4px; }
.rail .foot .name { color: #c7cad2; }
.rail .dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--good); margin-right: 6px; }
.rail .theme-toggle { background: transparent; border: 1px solid #333744; color: var(--rail-muted); padding: 3px 6px; font-size: 11px; border-radius: 5px; }
.rail .theme-toggle:hover { border-color: var(--accent); color: var(--rail-text); }

.main { padding: 28px 32px; max-width: 1200px; background: var(--surface); }
h1 { font-size: 22px; margin: 0 0 4px; font-weight: 700; }
h2 { font-family: var(--mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 22px 0 8px; font-weight: 500; }
h3 { font-size: 15px; margin: 12px 0 6px; font-weight: 600; }
.sub { color: var(--muted); margin-bottom: 8px; font-family: var(--mono); font-size: 12px; }
.card { background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; margin-bottom: 10px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 12px 0; border-bottom: 1px solid var(--line); display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.list li:last-child { border-bottom: 0; }
.tag { display: inline-block; font-family: var(--mono); font-size: 10.5px; padding: 3px 10px; border-radius: 100px; border: 1px solid var(--line-2); color: var(--muted); }
.tag.passed { color: var(--good); border-color: var(--good-bg); }
.tag.blocked { color: var(--bad); border-color: var(--bad-bg); }
.tag.warn { color: var(--warn); border-color: var(--warn); }
.tag.pin { color: var(--pin); border-color: var(--pin); }
.need { color: var(--bad); }
.need.soft { color: var(--warn); }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 12px; }
.small { font-size: 12px; }
.error { color: var(--bad); }
details summary { cursor: pointer; color: var(--accent); }
.intel { white-space: pre-wrap; margin: 6px 0 0 14px; color: var(--ink); }
form.inline { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 8px 0; }
form.inline input, form.inline select { min-width: 120px; }
.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: flex-start; justify-content: center; padding: 30px 12px; overflow: auto; z-index: 10; }
.modal { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; width: min(960px, 100%); padding: 18px 20px 22px; box-shadow: var(--shadow); }
.modal h1 { font-size: 17px; }

/* packet gate: terminal / scan-line direction. .term is a monospace status block on the
   near-black canvas tone in both themes, colored by the leading VALIDATE line. */
.term { background: var(--canvas); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; margin: 8px 0; font-family: var(--mono); }
.term .headline { font-size: 12px; margin-bottom: 8px; }
.term.blocked .headline { color: var(--bad); }
.term.passed .headline { color: var(--good); }
.term .kv { font-size: 12px; color: var(--dim); line-height: 1.9; }
.term .kv b { color: var(--muted); font-weight: 500; }
.term .kv .hl { background: var(--bad-bg); color: var(--bad-bright); border-radius: 3px; padding: 0 3px; }
.block { border-left: 3px solid var(--bad); border-radius: 0 6px 6px 0; padding: 10px 12px; margin: 8px 0; background: var(--surface-2); }
.block.warn { border-left-color: var(--warn); }
.block .path { font-family: var(--mono); font-size: 11px; color: var(--dim); }
.block textarea { min-height: 60px; margin-top: 6px; }
.nearby { margin: 6px 0 0 10px; font-size: 12px; }
.nearby button { padding: 2px 7px; font-size: 12px; margin-right: 4px; }
.attempt { color: var(--muted); font-size: 12px; font-family: var(--mono); }

.doc { background: var(--surface-2); padding: 28px 36px; border: 1px solid var(--line); border-radius: 8px; max-width: 800px; }
.doc h1 { font-size: 22px; }
.doc h2 { text-transform: none; letter-spacing: 0; font-size: 14px; color: var(--ink); border-bottom: 1px solid var(--line); padding-bottom: 3px; margin: 16px 0 6px; font-family: var(--sans); }
.doc p { margin: 4px 0; }
.doc ol, .doc ul { margin: 4px 0; padding-left: 20px; }
.doc.onepager { font-size: 12.5px; line-height: 1.3; }
.doc.onepager h2 { margin: 10px 0 4px; font-size: 12px; }
.doc .lead { font-weight: 700; }
@media print {
  :root { --canvas: #fff; --surface: #fff; --surface-2: #fff; --line: #ccc; --ink: #111; --muted: #555; --accent: #0b5fff; }
  .rail, .noprint, .modal-back { display: none !important; }
  .layout { display: block; }
  .main { padding: 0; max-width: none; background: #fff; }
  .doc { border: 0; padding: 0; max-width: none; }
  .doc.onepager { font-size: 10.5pt; line-height: 1.25; }
  @page { margin: 12mm; }
}
table.cats { border-collapse: collapse; width: 100%; font-size: 13px; }
table.cats th, table.cats td { border-bottom: 1px solid var(--line); padding: 6px; text-align: left; vertical-align: top; }
table.cats th { font-family: var(--mono); font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 500; }
table.cats input:not([type=checkbox]) { width: 100%; }
input.narrow { width: 76px; }
pre.wrap { white-space: pre-wrap; }
/* KB "receipt" moment: the confirmed span highlighted inline against its muted source sentence. */
mark { background: var(--good-bg); color: var(--good-bright); border-radius: 3px; padding: 0 3px; font-weight: 500; }

/* guided setup on the dashboard: the next step is open with its words and its button; done steps collapse to a line */
.setup { margin-top: 10px; border-color: var(--accent); }
.setup-steps { list-style: none; margin: 10px 0 0; padding: 0; }
.setup-steps li { display: grid; grid-template-columns: 28px 1fr; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); align-items: start; }
.setup-steps li:first-child { border-top: 0; }
.setup-steps .n { width: 24px; height: 24px; border-radius: 50%; border: 1px solid var(--line-2); display: inline-flex; align-items: center; justify-content: center; font-size: 11px; color: var(--muted); }
.setup-steps li.done .n { background: var(--good-bg); color: var(--good-bright); border-color: var(--good-bg); }
.setup-steps li.next .n { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.setup-steps li.done .t { color: var(--muted); }
.setup-steps li.later .t { color: var(--dim); }
.setup-steps li.next .t { font-weight: 600; }
.setup-steps p { margin: 4px 0 8px; color: var(--muted); max-width: 66ch; }
.ai-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 8px; margin-top: 4px; }
.ai-options button { text-align: left; display: flex; flex-direction: column; gap: 4px; padding: 10px 12px; height: 100%; }
.ai-options button:hover { border-color: var(--accent); }
.provider-form details.advanced { width: 100%; }
.provider-form details.advanced input { margin: 6px 6px 0 0; min-width: 240px; }

/* the first-run screen: no rail, one step at a time */
.welcome { max-width: 860px; margin: 0 auto; padding: 36px 24px 60px; background: var(--surface); min-height: 100vh; }
.welcome-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.welcome-head img { border-radius: 9px; }
.welcome-head a { margin-left: auto; }
.stepper { list-style: none; margin: 0 0 16px; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12.5px; color: var(--dim); }
.stepper li { display: inline-flex; align-items: center; gap: 6px; }
.stepper li.done { color: var(--muted); }
.stepper li.now { color: var(--ink); font-weight: 600; }
.stepper .n { width: 20px; height: 20px; border-radius: 50%; border: 1px solid var(--line-2); display: inline-flex; align-items: center; justify-content: center; font-size: 10.5px; }
.stepper li.done .n { background: var(--good-bg); color: var(--good-bright); border-color: var(--good-bg); }
.stepper li.now .n { border-color: var(--accent); color: var(--accent); }
.welcome-body h3 { margin-top: 0; }
.welcome-body p { color: var(--muted); max-width: 66ch; }
.welcome-body .card { border: 0; padding: 0; background: transparent; }
.ai-options button.picked { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.welcome-head .links { margin-left: auto; display: flex; gap: 14px; }
.stepper li.can { cursor: pointer; }
.stepper li.can:hover { color: var(--accent); }
.welcome-nav { margin-top: 16px; justify-content: space-between; }
/* a switch: one provider is on at a time; off everywhere is a warning, not a state to sit in */
.switch { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track { width: 34px; height: 18px; border-radius: 100px; background: var(--line-2); position: relative; transition: background .15s; }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--surface); transition: left .15s; box-shadow: 0 1px 2px #0003; }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { left: 18px; }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }
/* a small spinner beside anything that is with the model */
.spin { display: inline-block; width: 10px; height: 10px; border: 2px solid var(--line-2); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -1px; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation: none; border-top-color: var(--line-2); } }
