:root {
  --bg: #f6f7f9; --panel: #ffffff; --ink: #1d232b; --muted: #5d6875; --line: #dde2e8;
  --accent: #1f5f8b; --accent-ink: #ffffff; --ok: #217a4b; --warn: #a15c00; --err: #b3261e;
  --soft: #eef3f8; --code: #f1f3f6;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14181d; --panel: #1b2128; --ink: #e6e9ed; --muted: #9aa5b1; --line: #2c343e;
    --accent: #6aa9d8; --accent-ink: #0d1116; --ok: #5cc28c; --warn: #e0a64a; --err: #f08a80;
    --soft: #202a35; --code: #232a33;
  }
}
:root[data-theme="dark"] {
  --bg: #14181d; --panel: #1b2128; --ink: #e6e9ed; --muted: #9aa5b1; --line: #2c343e;
  --accent: #6aa9d8; --accent-ink: #0d1116; --ok: #5cc28c; --warn: #e0a64a; --err: #f08a80;
  --soft: #202a35; --code: #232a33;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.5; }
a { color: var(--accent); }
.top { display: flex; align-items: center; gap: 12px; padding: 12px 20px; background: var(--panel);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; flex-wrap: wrap; }
.brand { font-weight: 700; text-decoration: none; color: var(--ink); }
.sub { color: var(--muted); font-size: 13px; }
.pill { margin-left: auto; font-size: 12px; padding: 3px 10px; border-radius: 99px; background: var(--soft); color: var(--muted); }
.pill.ok { color: var(--ok); } .pill.err { color: var(--err); }
.layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); min-height: calc(100vh - 50px); }
.side { border-right: 1px solid var(--line); padding: 16px; background: var(--panel); }
.side h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 18px 0 8px; }
.side section:first-child h3 { margin-top: 0; }
main { padding: 24px 28px 60px; max-width: 1100px; }
h1 { font-size: 26px; margin: 0 0 10px; } h2 { font-size: 19px; margin: 26px 0 10px; }
.lead { font-size: 16px; } .muted { color: var(--muted); } .small { font-size: 13px; }
.error { color: var(--err); }
button, a.btn { font: inherit; text-decoration: none; display: inline-block; border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  padding: 7px 14px; border-radius: 8px; cursor: pointer; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button:disabled { opacity: .5; cursor: not-allowed; }
.check { display: block; margin-bottom: 10px; font-size: 14px; } .check small { display: block; color: var(--muted); margin-left: 22px; }
.runs { list-style: none; padding: 0; margin: 0; max-height: 40vh; overflow: auto; }
.runs li a { display: block; padding: 6px 8px; border-radius: 6px; text-decoration: none; color: var(--ink); font-size: 13px; }
.runs li a.active, .runs li a:hover { background: var(--soft); }
.runs li small { display: block; color: var(--muted); }
.link { font-size: 14px; line-height: 2; }
.principles li { margin: 4px 0; }
.about-stages li { margin: 6px 0; }
code, pre { background: var(--code); border-radius: 6px; font-size: 13px; }
code { padding: 1px 5px; } pre { padding: 12px; overflow: auto; white-space: pre-wrap; word-break: break-word; }
.stepper { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; margin: 14px 0 18px; }
.step { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px; font-size: 12.5px; }
.step b { display: block; font-size: 13.5px; margin-bottom: 3px; }
.step .who { color: var(--muted); } .step .out { margin-top: 4px; font-family: ui-monospace, Menlo, monospace; font-size: 11.5px; color: var(--muted); }
.step.done { border-color: var(--ok); } .step.now { border-color: var(--accent); box-shadow: 0 0 0 2px var(--soft); }
.step.human.now { border-color: var(--warn); }
.banner { padding: 12px 14px; border-radius: 10px; margin: 10px 0; background: var(--soft); }
.banner.ok { border-left: 4px solid var(--ok); } .banner.err { border-left: 4px solid var(--err); }
.banner.run { border-left: 4px solid var(--accent); } .banner.wait { border-left: 4px solid var(--warn); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 18px 0 14px; }
.tabs button { border: none; border-bottom: 2px solid transparent; border-radius: 0; background: none; color: var(--muted); }
.tabs button.on { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; margin: 12px 0; }
.risk { display: grid; grid-template-columns: minmax(0, 1fr) 140px minmax(0, 1fr); gap: 10px; align-items: start;
  padding: 10px 0; border-top: 1px solid var(--line); }
.risk:first-of-type { border-top: none; }
.risk .meta { color: var(--muted); font-size: 13px; }
select, input[type=text], input[type=password], textarea { font: inherit; width: 100%; padding: 7px 9px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--ink); }
textarea { min-height: 70px; }
label.f { display: block; margin: 10px 0 4px; font-weight: 600; font-size: 14px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.ev { border-top: 1px solid var(--line); padding: 8px 0; }
.ev .h { font-size: 12.5px; color: var(--muted); }
.ev .h b { color: var(--ink); }
.ev .body { margin-top: 4px; }
.ev.message .body { background: var(--soft); padding: 8px 10px; border-radius: 8px; white-space: pre-wrap; }
.md table { border-collapse: collapse; display: block; overflow-x: auto; font-size: 13.5px; }
.md th, .md td { border: 1px solid var(--line); padding: 5px 8px; text-align: left; vertical-align: top; }
.md th { background: var(--soft); }
.filebar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.filebrowser { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 16px; align-items: start; }
.filelist { position: sticky; top: 64px; max-height: calc(100vh - 80px); overflow: auto; background: var(--panel);
  border: 1px solid var(--line); border-radius: 10px; padding: 8px; }
.filelist h4 { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 10px 6px 4px; }
.filelist h4:first-child { margin-top: 2px; }
.filelist button { display: block; width: 100%; text-align: left; border: 0; background: none; color: var(--ink);
  font: inherit; font-size: 13.5px; padding: 5px 8px; border-radius: 6px; cursor: pointer; overflow-wrap: anywhere; }
.filelist button:hover { background: var(--soft); }
.filelist button.on { background: var(--accent); color: var(--accent-ink); }
.fileview { min-width: 0; }
.fileview .filebar { margin-bottom: 8px; }
.fname { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13.5px; overflow-wrap: anywhere; }
.csv { overflow: auto; max-height: 70vh; }
.csv table { border-collapse: collapse; font-size: 12.5px; }
.csv td, .csv th { border: 1px solid var(--line); padding: 3px 6px; white-space: nowrap; }
dialog { border: 1px solid var(--line); border-radius: 12px; background: var(--panel); color: var(--ink); width: min(360px, 92vw); }
dialog::backdrop { background: rgba(0, 0, 0, .4); }
@media (max-width: 860px) {
  .filebrowser { grid-template-columns: 1fr; }
  .filelist { position: static; max-height: 220px; }
  .layout { grid-template-columns: 1fr; }
  .side { border-right: none; border-bottom: 1px solid var(--line); }
  main { padding: 16px; }
  .stepper { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .risk { grid-template-columns: 1fr; }
}
