@font-face {
  font-family: "Public Sans";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/assets/fonts/public-sans-400.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Public Sans";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/assets/fonts/public-sans-500.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Public Sans";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/assets/fonts/public-sans-600.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  /* data-terminal tokens (app sheet, seed 1272354647) */
  --ground: #171719;
  --surface: #131217;
  --raised: #212023;
  --border: #222224;
  --rule: #1b1a1f;
  --control: #3a3a3e;
  --text: #ffffff;
  --muted: #8a8c92;
  --faint: #92949a;
  --accent: #4a8ad6;
  --primary: #ffffff;
  --primary-ink: #171719;
  --positive: #44a282;
  --negative: #e5566f;
  --warning: #d9a441;

  --font: "Public Sans", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;

  --fs-title: 26px;
  --fs-section: 20px;
  --fs-lead: 15px;
  --fs-kpi: 18px;
  --fs-body: 14px;
  --fs-small: 12px;

  --rail: 56px;
  --pad-x: 32px;
  --pad-y: 28px;
  --gap: 20px;
  --row-h: 42px;
  --radius-card: 6px;
  --radius-control: 6px;
  --radius-pill: 999px;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --t-hover: 150ms;
  --t-press: 110ms;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--text);
  font: var(--fs-body)/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p, figure, ul, ol, dl, dd { margin: 0; }
ul, ol { padding: 0; list-style: none; }
img, svg, video { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
.num, table, .asm-v, .asm-s, .v, .stamp { font-variant-numeric: tabular-nums; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}

.skip {
  position: fixed; left: 12px; top: -48px; z-index: 40;
  padding: 10px 14px; background: var(--primary); color: var(--primary-ink);
  border-radius: var(--radius-control); font-size: var(--fs-small); font-weight: 600;
  transition: top var(--t-hover) var(--ease);
}
.skip:focus-visible { top: 12px; }

/* ---------- rail ---------- */
.app { display: grid; grid-template-columns: var(--rail) minmax(0, 1fr); min-height: 100svh; }

.rail {
  position: sticky; top: 0;
  height: 100svh;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 16px 0 18px;
  border-right: 1px solid var(--rule);
}
.rail-mark {
  display: grid; place-items: center;
  width: 32px; height: 32px; margin-bottom: 18px;
  color: var(--text);
}
.rail-mark svg { width: 22px; height: 22px; }
.rail-mark .mark-a { color: var(--accent); }

.rail-item {
  position: relative;
  display: grid; place-items: center;
  width: 40px; height: 40px;
  background: none; border: 0; border-radius: var(--radius-control);
  color: var(--muted); cursor: pointer;
  transition: color var(--t-hover) var(--ease), background-color var(--t-hover) var(--ease);
}
.rail-item svg {
  width: 18px; height: 18px;
  fill: none; stroke: currentColor; stroke-width: 1.5;
  stroke-linecap: round; stroke-linejoin: round;
}
.rail-item:hover { color: var(--text); background: var(--raised); }
.rail-item:active { transform: translateY(1px); }
/* the style's move: every selection is a 1px accent line on the nearest edge */
.rail-item[aria-current="page"] { color: var(--text); }
.rail-item[aria-current="page"]::before {
  content: ""; position: absolute; right: -8px; top: 6px; bottom: 6px;
  width: 1px; background: var(--accent);
}
.rail-label { display: none; }

/* ---------- canvas ---------- */
.canvas {
  min-width: 0;
  padding: var(--pad-y) var(--pad-x) 80px;
}
.view { max-width: 1180px; margin-inline: auto; }
.view[hidden] { display: none; }
.panel[hidden] { display: none; }

.view-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 24px; flex-wrap: wrap;
  max-width: 1180px; margin: 0 auto var(--gap);
  padding-bottom: 18px;
}
.view-title h1 {
  font-size: var(--fs-title); font-weight: 600; letter-spacing: -0.015em; line-height: 1.15;
}
.lede {
  margin-top: 8px; max-width: 62ch;
  font-size: var(--fs-body); color: var(--muted);
}
.lede code, .sub code, .switch-copy code {
  font-family: inherit; font-variant-numeric: tabular-nums;
  padding: 1px 5px; border-radius: 4px;
  background: var(--raised); color: var(--text);
}

.view-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.view-actions[hidden] { display: none; }
.stamp { font-size: var(--fs-small); color: var(--muted); margin-right: 4px; }

/* ---------- controls ---------- */
.btn {
  height: 34px; padding: 0 16px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border-radius: var(--radius-pill); border: 1px solid var(--control);
  background: transparent; color: var(--text);
  font-size: var(--fs-body); font-weight: 500; white-space: nowrap; cursor: pointer;
  transition: background-color var(--t-hover) var(--ease), border-color var(--t-hover) var(--ease), color var(--t-hover) var(--ease);
}
.btn:hover { background: var(--raised); border-color: var(--muted); }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: var(--primary); border-color: var(--primary); color: var(--primary-ink); font-weight: 600;
}
.btn.primary:hover { background: #e8e8ea; border-color: #e8e8ea; }
.btn.ghost { border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--raised); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

.linkbtn {
  background: none; border: 0; padding: 0; cursor: pointer;
  color: var(--muted); font-size: var(--fs-small); font-weight: 500;
  border-bottom: 1px solid transparent;
  transition: color var(--t-hover) var(--ease), border-color var(--t-hover) var(--ease);
}
.linkbtn:hover { color: var(--text); border-bottom-color: var(--accent); }

input, select, textarea {
  width: 100%;
  background: var(--ground);
  border: 1px solid var(--control);
  border-radius: var(--radius-control);
  padding: 9px 12px;
  font-size: var(--fs-body);
  transition: border-color var(--t-hover) var(--ease);
}
input { height: 38px; }
input::placeholder, textarea::placeholder { color: var(--muted); }
input:hover, select:hover, textarea:hover { border-color: var(--muted); }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; }
select { height: 38px; padding-right: 32px; cursor: pointer; }
textarea {
  min-height: 320px; resize: vertical;
  font-size: 13px; line-height: 1.65;
  white-space: pre-wrap; overflow-wrap: anywhere;
  border-radius: var(--radius-card);
  padding: 14px 16px;
}

/* switch: the accent line sits on the track's near edge */
.switch {
  background: transparent;
  appearance: none; -webkit-appearance: none;
  position: relative; flex: none;
  width: 40px; height: 22px; padding: 0; border-radius: var(--radius-pill);
  border: 1px solid var(--control); cursor: pointer;
  transition: background-color var(--t-hover) var(--ease), border-color var(--t-hover) var(--ease);
}
.switch::after {
  content: ""; position: absolute; top: 50%; left: 3px;
  width: 14px; height: 14px; margin-top: -7px;
  border-radius: 50%; background: var(--muted);
  transition: transform var(--t-hover) var(--ease), background-color var(--t-hover) var(--ease);
}
.switch:checked { border-color: var(--accent); }
.switch:checked::after { transform: translateX(16px); background: var(--text); }
.switch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch:active::after { width: 17px; }

/* ---------- panel ---------- */
.panel {
  background: var(--surface);
  border-radius: var(--radius-card);
  padding: 20px 22px 22px;
  margin-bottom: var(--gap);
}
.panel-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  margin-bottom: 16px;
}
.panel-head h2 {
  font-size: var(--fs-section); font-weight: 400; color: var(--muted); letter-spacing: -0.005em;
}
.panel-meta { font-size: var(--fs-small); color: var(--faint); }

/* ---------- system assembly ---------- */
.asm-track {
  display: flex; gap: 2px; height: 8px; margin-bottom: 18px;
  border-radius: 2px; overflow: hidden;
  background: var(--raised);
}
.asm-seg { width: var(--w); background: var(--accent); }
.asm-seg.seg-capability { background: #6f8fb8; }
.asm-seg.seg-anchor { background: var(--warning); }

.asm-cells {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px; background: var(--rule);
  border-radius: 3px; overflow: hidden;
}
.asm-cell {
  display: grid; gap: 5px;
  padding: 13px 16px 14px;
  background: var(--surface);
}
.asm-k { font-size: var(--fs-small); color: var(--muted); }
.asm-v { font-size: 15px; font-weight: 500; }
.asm-s { font-size: var(--fs-small); color: var(--faint); }
.asm-runtime {
  margin-top: 14px; padding: 11px 14px;
  background: var(--ground); border-radius: 4px;
  font-size: var(--fs-small); line-height: 1.65; color: var(--muted);
}
.asm-runtime-k {
  display: inline-block; margin-right: 8px; padding: 1px 7px;
  border-radius: 3px; background: var(--raised); color: var(--text);
  font-size: var(--fs-small);
}

.asm-note {
  margin-top: 16px; max-width: 88ch;
  font-size: var(--fs-small); line-height: 1.7; color: var(--muted);
}

/* ---------- KPI strip ---------- */
.strip {
  display: grid; grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 1px; background: var(--rule);
  border-radius: var(--radius-card); overflow: hidden;
  margin-bottom: var(--gap);
}
.strip .cell {
  display: grid; gap: 6px;
  padding: 14px 16px 16px;
  background: var(--surface);
}
.strip .k { font-size: var(--fs-small); color: var(--muted); }
.strip .v { font-size: var(--fs-kpi); font-weight: 400; letter-spacing: -0.01em; }
.strip .cell.is-bad .v { color: var(--negative); }
.strip .cell.is-ok .v { color: var(--positive); }
.strip .v .unit { font-size: var(--fs-small); color: var(--muted); margin-left: 2px; }

/* ---------- composition strip: one row per group, groups side by side ---------- */
.bars {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 28px;
}
.bar-group { display: grid; gap: 2px; align-content: start; }
.bar-title { font-size: var(--fs-small); color: var(--faint); margin-bottom: 4px; }
.bar-empty { font-size: var(--fs-small); color: var(--muted); }
.bar-row {
  display: grid; grid-template-columns: minmax(0, 110px) minmax(0, 1fr) 26px;
  align-items: center; gap: 10px;
  height: 30px;
}
.bar-k {
  font-size: var(--fs-small); color: var(--muted); font-variant-numeric: tabular-nums;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.bar-track { display: block; height: 6px; background: var(--raised); border-radius: 1px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--accent); }
.bar-fill.bad { background: var(--negative); }
.bar-n { font-size: var(--fs-body); text-align: right; }

/* ---------- tables ---------- */
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-body); }
.table th {
  font-size: var(--fs-small); font-weight: 400; color: var(--muted); text-align: left;
  padding: 0 12px 9px 0;
}
.table th.right, .table td.right { text-align: right; padding-right: 0; }
.table td {
  height: var(--row-h); padding: 0 12px 0 0;
  border-top: 1px solid var(--rule);
  vertical-align: middle;
}
.table tbody tr:hover td { background: #191820; }
.table .t { color: var(--faint); font-size: var(--fs-small); }
.table .m { color: var(--text); }
.table .col-proto { width: 96px; }
.table .st { font-variant-numeric: tabular-nums; }
.table .st.bad { color: var(--negative); }
.table .st.ok { color: var(--muted); }
.table .mark { width: 18px; }
.table .mark span {
  display: block; width: 6px; height: 6px; border-radius: 50%;
  background: var(--positive);
}
.table .mark span.bad { background: var(--negative); }

.empty {
  padding: 22px 0 6px;
  font-size: var(--fs-small); color: var(--muted);
}
.more {
  margin-top: 14px; height: 34px; padding: 0 18px;
  background: transparent; border: 1px solid var(--control); border-radius: var(--radius-pill);
  color: var(--muted); font-size: var(--fs-small); cursor: pointer;
  transition: color var(--t-hover) var(--ease), border-color var(--t-hover) var(--ease);
}
.more:hover { color: var(--text); border-color: var(--muted); }
.more-row { display: flex; justify-content: flex-start; }

/* ---------- fields ---------- */
.fields { display: grid; gap: 18px; }
.inline-fields { grid-template-columns: 1fr 140px 1fr; gap: 16px; }
.field { display: grid; gap: 8px; }
.field label { font-size: var(--fs-body); font-weight: 500; }
.sub { font-size: var(--fs-small); line-height: 1.65; color: var(--muted); }
.row { display: flex; gap: 10px; }
.row .btn { flex: none; }

.switch-list { display: grid; gap: 1px; background: var(--rule); border-radius: 3px; overflow: hidden; }
.switch-row {
  position: relative;
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  padding: 14px 16px;
  background: var(--surface);
}
.switch-row:has(.switch:checked)::before {
  content: ""; position: absolute; left: 0; top: 10px; bottom: 10px;
  width: 1px; background: var(--accent);
}
.switch-copy { display: grid; gap: 4px; }
.switch-copy label { font-size: var(--fs-body); font-weight: 500; cursor: pointer; }

/* ---------- models ---------- */
.models { display: flex; flex-wrap: wrap; gap: 8px; }
.model {
  display: inline-flex; align-items: center; gap: 8px;
  height: 32px; padding: 0 14px;
  border: 1px solid var(--control); border-radius: var(--radius-pill);
  background: transparent; color: var(--muted);
  font-size: var(--fs-small); font-variant-numeric: tabular-nums; cursor: pointer;
  transition: color var(--t-hover) var(--ease), border-color var(--t-hover) var(--ease);
}
.model:hover { color: var(--text); border-color: var(--muted); }
.model.pick { color: var(--text); border-color: var(--accent); }
.model .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }

/* ---------- tabs: 1px accent underline as wide as the label ---------- */
.tabs { display: flex; flex-wrap: wrap; gap: 22px; margin-bottom: 14px; }
.tab {
  background: none; border: 0; padding: 0 0 7px;
  color: var(--muted); font-size: var(--fs-body); cursor: pointer;
  border-bottom: 1px solid transparent;
  transition: color var(--t-hover) var(--ease), border-color var(--t-hover) var(--ease);
}
.tab:hover { color: var(--text); }
.tab .sz { color: var(--faint); font-size: var(--fs-small); margin-left: 6px; font-variant-numeric: tabular-nums; }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.tab.active .sz { color: var(--text); }

.editor-wrap { position: relative; }
/* the editor is the page: it takes the height the viewport has left, so the view has no dead band */
#promptText { min-height: max(320px, calc(100svh - 340px)); }
.dirty { margin-top: 10px; font-size: var(--fs-small); color: var(--warning); }

/* ---------- key/value and code ---------- */
.kv { display: grid; gap: 1px; background: var(--rule); border-radius: 3px; overflow: hidden; }
.kv .kv-row {
  display: flex; align-items: baseline; justify-content: space-between; gap: 20px;
  padding: 11px 16px; background: var(--surface);
}
.kv .kv-k { font-size: var(--fs-small); color: var(--muted); }
.kv .kv-v {
  font-size: var(--fs-body); font-variant-numeric: tabular-nums;
  text-align: right; overflow-wrap: anywhere;
}

.code {
  margin: 0; padding: 16px 18px;
  background: var(--ground); border-radius: var(--radius-card);
  font-family: inherit; font-size: 13px; line-height: 1.75;
  color: #c9cad0; font-variant-numeric: tabular-nums;
  white-space: pre-wrap; overflow-wrap: anywhere;
}

/* ---------- endpoint ---------- */
.endpoint { display: grid; gap: 8px; }
.endpoint-url {
  display: block; padding: 12px 14px;
  background: var(--ground); border-radius: var(--radius-card);
  color: var(--text); font-size: var(--fs-lead); font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

/* ---------- auth bar ---------- */
.authbar[hidden] { display: none; }
.authbar {
  max-width: 1180px; margin: 0 auto var(--gap);
  padding: 16px 18px;
  background: var(--raised); border-radius: var(--radius-card);
  display: grid; gap: 12px;
}
.authbar-text { font-size: var(--fs-body); }
.authbar-row { display: flex; gap: 10px; }
.authbar-row input { max-width: 320px; }

/* ---------- login gate ---------- */
.gate[hidden] { display: none; }
.gate {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center;
  padding: 24px;
  background: var(--ground);
}
.gate-card {
  width: min(380px, 100%);
  display: grid; gap: 14px;
  padding: 26px 24px 22px;
  background: var(--surface);
  border-radius: var(--radius-card);
}
.gate-mark {
  display: grid; place-items: center;
  width: 32px; height: 32px; color: var(--text);
}
.gate-mark svg { width: 22px; height: 22px; }
.gate-title {
  font-size: var(--fs-section); font-weight: 500; color: var(--text);
  margin: 2px 0 0;
}
.gate-lede { font-size: var(--fs-body); color: var(--muted); margin: -4px 0 4px; }
.gate-field { display: grid; gap: 6px; }
.gate-field label { font-size: var(--fs-small); color: var(--muted); }
.gate-submit { justify-content: center; margin-top: 4px; }
.gate-error {
  font-size: var(--fs-small); color: var(--negative);
  margin: -2px 0 0;
}
.gate-error[hidden] { display: none; }
.gate-alt { border-top: 1px solid var(--rule); padding-top: 12px; margin-top: 4px; }
.gate-alt summary {
  font-size: var(--fs-small); color: var(--muted); cursor: pointer;
  list-style: none;
}
.gate-alt summary::-webkit-details-marker { display: none; }
.gate-alt summary::before { content: "＋ "; color: var(--faint); }
.gate-alt[open] summary::before { content: "－ "; }
.gate-alt[open] summary { color: var(--text); }
.gate-alt > * + * { margin-top: 10px; }
.gate-foot {
  font-size: var(--fs-small); color: var(--faint);
  margin: 2px 0 0; text-align: center;
}

/* ---------- logout ---------- */
.rail-exit { margin-top: auto; }
.rail-exit[hidden] { display: none; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 50;
  transform: translateX(-50%) translateY(10px);
  max-width: min(560px, calc(100vw - 32px));
  padding: 11px 18px;
  background: var(--raised); border: 1px solid var(--control); border-radius: var(--radius-pill);
  color: var(--text); font-size: var(--fs-body);
  opacity: 0; pointer-events: none;
  transition: opacity var(--t-hover) var(--ease), transform var(--t-hover) var(--ease);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.ok { border-color: #2c4a3d; }
.toast.err { border-color: #4a2430; color: #ffd7de; }

/* ---------- responsive ---------- */
@media (max-width: 1080px) {
  .bars { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .strip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .inline-fields { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 760px) {
  :root { --pad-x: 18px; --pad-y: 18px; --fs-title: 22px; }

  .app { grid-template-columns: minmax(0, 1fr); }

  .rail {
    position: fixed; inset: auto 0 0 0; z-index: 30;
    height: auto; flex-direction: row; align-items: stretch; justify-content: space-around;
    gap: 0; padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    background: var(--surface); border-right: 0; border-top: 1px solid var(--rule);
  }
  .rail-mark { display: none; }
  .rail-item { flex: 1; flex-direction: column; gap: 3px; height: 46px; width: auto; }
  .rail-item svg { width: 17px; height: 17px; }
  .rail-label { display: block; font-size: var(--fs-small); line-height: 1; }
  .rail-item[aria-current="page"]::before { left: 22%; right: 22%; top: -6px; bottom: auto; width: auto; height: 1px; }

  .canvas { padding-bottom: 84px; }
  .view-head { gap: 14px; padding-bottom: 0; }
  .view-actions { width: 100%; justify-content: flex-end; }
  .view-actions .btn { flex: 0 0 auto; }
  .stamp { order: -1; width: 100%; margin: 0; }

  .strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  /* three items would orphan a cell in a 2-up grid; on the phone each becomes one line */
  .asm-cells { grid-template-columns: minmax(0, 1fr); gap: 1px; }
  .asm-cell {
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: baseline; gap: 12px;
    padding: 11px 14px;
  }
  .asm-cell .asm-v { font-size: var(--fs-body); }
  .asm-cell .asm-s { min-width: 40px; text-align: right; }
  .inline-fields { grid-template-columns: 1fr; }
  .table .col-proto, .table .col-shape { width: 56px; }
  .panel { padding: 16px 16px 18px; }
  .tabs { gap: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 1ms !important;
    animation-duration: 1ms !important;
  }
  .btn:active, .rail-item:active { transform: none; }
}