/* Cachew Studio — design tokens first, then layout, components, pages. */

:root {
  --bg: #0a0e15; --surface: #0d121b; --surface-2: #121926; --surface-3: #18212f;
  --border: #1a2230; --border-strong: #273245; --text: #e6ebf3; --text-2: #b8c1cf; --muted: #6f7a8c; --faint: #4a5466;
  --accent: #86a6ea; --accent-hover: #a9c0f2; --accent-soft: #121c33; --accent-line: #2a3b63;
  --good: #6fd3a0; --good-soft: #0d1f18; --good-line: #1d4634;
  --warn: #e3b25c; --warn-soft: #1f1910; --warn-line: #4d3b17;
  --bad: #f0857a; --bad-soft: #23110f; --bad-line: #5a2722;
  --human: #b9a2f5; --human-soft: #19152b; --human-line: #3d3366; --track: #1a2230;
  --shadow-sm: none; --shadow: 0 1px 0 rgba(0, 0, 0, .3);
  --shadow-lg: 0 24px 64px rgba(0, 0, 0, .6);
  --radius: 3px;
  --radius-sm: 2px;
  --font: Inter, "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --display: "Inter Tight", "Helvetica Neue", Arial, var(--font);
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
  color-scheme: dark;
}

/* ---------------------------------------------------------------- base */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
html, body { margin: 0; }
body {
  min-height: 100vh; display: flex; flex-direction: column;
  background: var(--bg); color: var(--text);
  font: 14.5px/1.55 var(--font); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
main { flex: 1; outline: none; }
h1, h2, h3, h4 { margin: 0; color: var(--text); letter-spacing: -.01em; line-height: 1.25; font-weight: 650; font-family: var(--display); }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
code, kbd, pre, .mono { font-family: var(--mono); font-size: .86em; }
img, svg { flex-shrink: 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
::selection { background: var(--accent-line); }

.container { width: 100%; max-width: 1240px; margin: 0 auto; padding: 0 24px; }
.page-pad { padding-top: 28px; padding-bottom: 56px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.num { font-variant-numeric: tabular-nums; }
.eyebrow { font-family: var(--mono); font-size: 11px; font-weight: 500; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.clamp-3 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.wrap-any { overflow-wrap: anywhere; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: 12px; top: -48px; z-index: 50; background: var(--surface); padding: 8px 12px; border: 1px solid var(--border-strong); }
.skip-link:focus { top: 12px; }

/* ---------------------------------------------------------------- top bar & footer */

.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; height: 56px; }
.brand { display: flex; align-items: center; gap: 12px; color: var(--text); min-width: 0; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 8px; height: 8px; background: var(--accent); flex-shrink: 0; }
.brand-text { font-family: var(--mono); font-size: 12px; font-weight: 500; letter-spacing: .18em; text-transform: uppercase; white-space: nowrap; }
.brand-text small { font-size: inherit; color: var(--muted); letter-spacing: inherit; }
.topbar-actions { display: flex; align-items: center; gap: 4px; }
.footer { border-top: 1px solid var(--border); color: var(--faint); font: 500 10.5px/1.6 var(--mono); letter-spacing: .14em; text-transform: uppercase; }
.footer-inner { display: flex; flex-wrap: wrap; gap: 6px 28px; padding-top: 20px; padding-bottom: 20px; }

/* ---------------------------------------------------------------- buttons & inputs */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 16px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: transparent; color: var(--text); cursor: pointer;
  font: 500 11.5px/1 var(--mono); letter-spacing: .14em; text-transform: uppercase;
  white-space: nowrap; text-decoration: none; transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.sm { height: 32px; padding: 0 12px; font-size: 11px; }
.btn.lg { height: 46px; padding: 0 22px; font-size: 12px; }
.btn.block { width: 100%; }
.btn.primary { background: var(--text); border-color: var(--text); color: var(--bg); font-weight: 600; }
.btn.primary:hover { background: #fff; border-color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: transparent; color: var(--text); }
.btn.outline { background: transparent; }
.btn.danger { background: var(--bad); border-color: transparent; color: #1f0806; }
.btn.danger:hover { filter: brightness(1.06); background: var(--bad); }
.btn.danger-ghost { background: transparent; color: var(--bad); border-color: var(--bad-line); }
.btn.danger-ghost:hover { background: var(--bad-soft); }
.btn.good { background: var(--good); border-color: transparent; color: #04170e; }
.btn.good:hover { filter: brightness(1.06); background: var(--good); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn .spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: var(--radius-sm);
  border: 1px solid transparent; background: transparent; color: var(--text-2); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field + .field { margin-top: 18px; }
.field-label { font: 500 11px/1.4 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--text-2); display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.field-label .opt { font-weight: 400; color: var(--faint); font-size: 10.5px; letter-spacing: .08em; }
.hint { font-size: 12.5px; color: var(--muted); }
.input, .select, .textarea {
  width: 100%; min-width: 0; background: var(--bg); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 9px 12px; font-size: 14px; transition: border-color .15s, box-shadow .15s;
}
.textarea { resize: vertical; min-height: 96px; line-height: 1.5; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: none; }
.input:disabled, .select:disabled { background: var(--surface-2); color: var(--muted); }
.select { appearance: none; -webkit-appearance: none; padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; }
.field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.field-row .field + .field { margin-top: 0; }

.stepper { display: flex; align-items: stretch; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); }
.stepper:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.stepper button { width: 40px; border: 0; background: var(--surface-2); cursor: pointer; font-size: 18px; color: var(--text-2); }
.stepper button:hover { background: var(--surface-3); }
.stepper button:disabled { opacity: .4; cursor: not-allowed; }
.stepper input { flex: 1; min-width: 0; border: 0; text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; background: transparent; padding: 9px 4px; -moz-appearance: textfield; }
.stepper input:focus { outline: none; }
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 0; border: 1px solid var(--border-strong); }
.segmented label { position: relative; display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; cursor: pointer; min-width: 0; }
.segmented label + label { border-left: 1px solid var(--border-strong); }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label:has(input:checked) { background: var(--accent-soft); box-shadow: inset 0 -2px 0 var(--accent); }
.segmented label:has(input:focus-visible) { outline: 2px solid var(--accent); }
.segmented label:has(input:disabled) { opacity: .5; cursor: not-allowed; }
.segmented b { font-size: 13.5px; }
.segmented span { font-size: 12px; color: var(--muted); }

.switch { display: flex; align-items: flex-start; gap: 12px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track { flex-shrink: 0; width: 40px; height: 24px; border-radius: 2px; background: var(--border-strong); position: relative; transition: background .2s; margin-top: 1px; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 1px; background: var(--text); transition: transform .2s; }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(16px); background: var(--bg); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.switch-text b { font-size: 13.5px; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; }

.dropzone { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); background: var(--surface-2); cursor: pointer; min-width: 0; }
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: var(--accent-soft); }
.dropzone input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.dropzone:focus-within { border-color: var(--accent); }
.dropzone-text { min-width: 0; font-size: 13px; }

/* ---------------------------------------------------------------- surfaces */

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; min-width: 0; }
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.card-head h2, .card-head h3 { font: 600 11.5px/1.4 var(--mono); letter-spacing: .16em; text-transform: uppercase; color: var(--text); }
.card-head p { color: var(--muted); font-size: 13px; margin-top: 3px; }
.card-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.card-title .ico { display: grid; place-items: center; width: 28px; height: 28px; border: 1px solid var(--border-strong); color: var(--accent); }
.section-title { font: 500 11.5px/1.4 var(--mono); letter-spacing: .18em; text-transform: uppercase; color: var(--text-2); margin: 36px 0 14px; display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.section-title::before { content: ""; width: 7px; height: 7px; background: var(--accent); align-self: center; }
.section-title small { font-size: 10.5px; color: var(--faint); font-weight: 400; letter-spacing: .1em; }
.grid { display: grid; gap: 16px; }
.grid > * { min-width: 0; }
.grid .card + .card { margin-top: 0; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.stack { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

.badge {
  display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px; border-radius: 2px;
  font: 500 10.5px/1 var(--mono); letter-spacing: .1em; text-transform: uppercase; white-space: nowrap; border: 1px solid var(--border-strong); background: transparent; color: var(--text-2);
}
.badge.sm { height: 18px; padding: 0 6px; font-size: 10px; }
.badge.accent { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); }
.badge.good { background: var(--good-soft); border-color: var(--good-line); color: var(--good); }
.badge.warn { background: var(--warn-soft); border-color: var(--warn-line); color: var(--warn); }
.badge.bad { background: var(--bad-soft); border-color: var(--bad-line); color: var(--bad); }
.badge.human { background: var(--human-soft); border-color: var(--human-line); color: var(--human); }
.badge .dot { width: 7px; height: 7px; }

.dot { width: 7px; height: 7px; border-radius: 0; background: var(--border-strong); display: inline-block; flex-shrink: 0; }
.dot.live { background: var(--accent); animation: pulse 1.3s ease-in-out infinite; }
.dot.done { background: var(--good); }
.dot.error { background: var(--bad); }
.dot.warn { background: var(--warn); }
.dot.human { background: var(--human); animation: pulse 1.3s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }

.callout { display: flex; gap: 14px; align-items: flex-start; padding: 16px 18px; border-radius: var(--radius); border: 1px solid var(--border); border-left-width: 3px; background: var(--surface); margin-bottom: 16px; }
.callout .ico { display: grid; place-items: center; width: 22px; height: 22px; flex-shrink: 0; }
.callout-body { min-width: 0; flex: 1; }
.callout-body h3 { font-size: 15px; margin-bottom: 4px; }
.callout-body p { color: var(--text-2); font-size: 13.5px; }
.callout.bad { border-color: var(--bad-line); background: var(--bad-soft); }
.callout.bad .ico { background: none; color: var(--bad); }
.callout.warn { border-color: var(--warn-line); background: var(--warn-soft); }
.callout.warn .ico { background: none; color: var(--warn); }
.callout.info { border-color: var(--accent-line); background: var(--accent-soft); }
.callout.info .ico { background: none; color: var(--accent); }

.empty { padding: 36px 20px; text-align: center; color: var(--muted); }
.empty .ico { width: 40px; height: 40px; margin: 0 auto 12px; display: grid; place-items: center; border: 1px solid var(--border-strong); color: var(--muted); }
.empty h3 { color: var(--text); font-size: 15px; margin-bottom: 4px; }
.empty p { max-width: 460px; margin: 0 auto; font-size: 13.5px; }

.kv { display: grid; grid-template-columns: minmax(110px, 34%) minmax(0, 1fr); gap: 8px 14px; font-size: 13.5px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }

.meter { height: 6px; border-radius: 0; background: var(--track); overflow: hidden; }
.meter > i { display: block; height: 100%; border-radius: inherit; background: var(--accent); transition: width .5s ease; }
.meter.good > i { background: var(--good); }
.meter.warn > i { background: var(--warn); }
.meter.bad > i { background: var(--bad); }
.meter.muted > i { background: var(--border-strong); }

.skeleton-block { height: 220px; border-radius: var(--radius); background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.4s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------------------------------------------------------------- discovery loop */

.loop { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(var(--n, 7), minmax(0, 1fr)); gap: 0; counter-reset: loop; }
.loop-item { position: relative; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 0 6px; min-width: 0; }
.loop-item::before { content: ""; position: absolute; top: 19px; left: calc(-50% + 24px); right: calc(50% + 24px); height: 2px; background: var(--border); border-radius: 2px; }
.loop-item:first-child::before { display: none; }
.loop-item.done::before, .loop-item.active::before, .loop-item.human::before { background: var(--good); }
.loop-node { position: relative; z-index: 1; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 2px; border: 2px solid var(--border-strong); background: var(--surface); color: var(--muted); transition: all .2s; }
.loop-item.done .loop-node { border-color: var(--good); background: var(--good); color: #04170e; }
.loop-item.active .loop-node { border-color: var(--accent); color: var(--accent); box-shadow: 0 0 0 5px var(--accent-soft); }
.loop-item.active .loop-node::after { content: ""; position: absolute; inset: -6px; border-radius: 2px; border: 2px solid var(--accent); opacity: .35; animation: ring 1.6s ease-out infinite; }
.loop-item.human .loop-node { border-color: var(--human); color: var(--human); box-shadow: 0 0 0 5px var(--human-soft); }
.loop-item.error .loop-node { border-color: var(--bad); color: var(--bad); background: var(--bad-soft); }
.loop-item.skipped .loop-node { border-style: dashed; }
@keyframes ring { from { transform: scale(.9); opacity: .5; } to { transform: scale(1.25); opacity: 0; } }
.loop-label { font: 500 11px/1.3 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--text); }
.loop-sub { font-size: 11.5px; color: var(--muted); line-height: 1.3; max-width: 140px; }
.loop-item.pending .loop-label { color: var(--muted); }
.loop.demo .loop-node { border-color: var(--accent-line); background: var(--accent-soft); color: var(--accent); }
.loop.demo .loop-item.human .loop-node { border-color: var(--human-line); background: var(--human-soft); color: var(--human); box-shadow: none; }
.loop.demo .loop-item::before { background: var(--accent-line); }
.loop-card { padding: 22px 16px 18px; }

.savings-banner {
  display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 16px 28px; align-items: center; margin-bottom: 16px;
  padding: 20px 22px; border-radius: var(--radius); border: 1px solid var(--border); border-left: 3px solid var(--good);
  background: var(--surface);
}
.savings-banner.pending { border-color: var(--border); background: var(--surface); }
.sb-main { display: flex; gap: 14px; align-items: flex-start; min-width: 0; }
.sb-ico { display: grid; place-items: center; width: 36px; height: 36px; color: var(--good); border: 1px solid var(--good-line); flex-shrink: 0; }
.savings-banner .eyebrow { color: var(--good); }
.savings-banner.pending .eyebrow { color: var(--muted); }
.sb-value { font-family: var(--display); font-size: clamp(26px, 3.4vw, 36px); font-weight: 800; letter-spacing: -.02em; line-height: 1.1; color: var(--good); margin-top: 4px; }
.sb-value small { font-size: 14px; font-weight: 600; color: var(--text-2); margin-left: 10px; letter-spacing: 0; }
.savings-banner.pending .sb-value { color: var(--muted); }
.sb-sub { font-size: 13.5px; color: var(--text-2); margin-top: 6px; max-width: 62ch; }
.sb-sub b { color: var(--good); }
.sb-side { min-width: 0; }
.sb-side .bars { gap: 6px; }
.sb-stats { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 10px; font-size: 12.5px; color: var(--muted); align-items: baseline; }
.sb-stats b { color: var(--text); font-variant-numeric: tabular-nums; }
.sb-stats a { margin-left: auto; color: var(--accent); font-weight: 600; text-decoration: none; white-space: nowrap; }
@media (max-width: 960px) { .savings-banner { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 420px) { .savings-banner { padding: 16px; } .sb-ico { display: none; } .sb-value small { display: block; margin: 4px 0 0; } }
.loop-foot { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 16px; padding-top: 14px; border-top: 1px dashed var(--border); font-size: 12.5px; color: var(--muted); text-align: center; flex-wrap: wrap; }
.loop-foot svg { color: var(--good); }

/* ---------------------------------------------------------------- home */

.marker, .tagline, .fineprint, .art-label, .art-note { font-family: var(--mono); text-transform: uppercase; }
.marker { display: flex; align-items: center; gap: 14px; font-size: 12px; letter-spacing: .22em; color: var(--text-2); }
.marker::before { content: ""; width: 7px; height: 7px; background: var(--accent); }
.intro {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: stretch;
  min-height: min(calc(100vh - 56px), 760px); border-bottom: 1px solid var(--border);
}
.intro-text { display: flex; flex-direction: column; justify-content: center; padding: 56px 48px 40px 0; min-width: 0; }
.display {
  font: 800 clamp(56px, 8.4vw, 124px)/.9 var(--display); letter-spacing: -.035em; text-transform: uppercase;
  color: var(--text); margin: 34px 0 30px;
}
.tagline { font-size: clamp(11px, .9vw, 12.5px); letter-spacing: .16em; color: var(--accent); }
.rule { border: 0; border-top: 1px solid var(--border-strong); margin: 34px 0 30px; max-width: 560px; }
.statement { font: 700 clamp(20px, 2vw, 29px)/1.15 var(--display); letter-spacing: -.005em; text-transform: uppercase; color: var(--text-2); }
.intro-actions { display: flex; gap: 8px; margin-top: 36px; flex-wrap: wrap; }
.readout { display: flex; align-items: center; gap: 22px; margin-top: 30px; padding: 18px 22px 18px 0; color: inherit;
  border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); max-width: 560px; }
.readout:hover { text-decoration: none; }
.readout:hover .ro-big { color: #9ff0c4; }
.ro-big { font: 800 clamp(54px, 6.4vw, 92px)/.9 var(--display); letter-spacing: -.04em; color: var(--good); white-space: nowrap; transition: color .2s; }
.ro-text { display: flex; flex-direction: column; gap: 6px; font: 500 10.5px/1.6 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); min-width: 0; }
.ro-text b { font-weight: 600; color: var(--text); font-size: 11.5px; }
.fineprint { margin-top: 48px; font-size: 10.5px; letter-spacing: .18em; color: var(--faint); line-height: 1.9; }

.intro-art { position: relative; margin: 0; border-left: 1px solid var(--border); min-width: 0; min-height: 420px;
  background: radial-gradient(closest-side at 50% 52%, rgba(70, 105, 190, .16), transparent 75%); }
.art-label { position: absolute; top: 18px; left: 50%; transform: translateX(-50%); font-size: 10.5px; letter-spacing: .22em; color: var(--faint); white-space: nowrap; z-index: 1; }
.art-note { position: absolute; bottom: 18px; right: 22px; margin: 0; font-size: 10.5px; letter-spacing: .16em; color: var(--faint); z-index: 1; }
.art-canvas { position: absolute; inset: 44px 8px 44px 24px; }
.art-canvas canvas { display: block; }

.ledger-block { padding: 56px 0 8px; }
.ledger-title { display: flex; align-items: baseline; gap: 18px; font: 500 12px/1.4 var(--mono); letter-spacing: .22em; text-transform: uppercase; color: var(--text); margin-bottom: 18px; }
.ledger-title span { color: var(--accent); }
.ledger { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--border-strong); }
.ledger > li, .ledger.rules > div {
  display: grid; grid-template-columns: 56px minmax(120px, 190px) minmax(0, 1fr) minmax(0, 220px); gap: 8px 24px;
  align-items: baseline; padding: 16px 0; border-bottom: 1px solid var(--border);
}
.ledger.rules > div { grid-template-columns: minmax(120px, 270px) minmax(0, 1fr); }
.ledger.rules dd { margin: 0; }
.l-n { font: 500 11px var(--mono); color: var(--faint); letter-spacing: .1em; }
.l-k { font: 700 15px/1.3 var(--display); text-transform: uppercase; letter-spacing: .02em; color: var(--text); }
.l-v { font-size: 14px; color: var(--text-2); max-width: 70ch; }
.l-r { font: 500 10.5px/1.5 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--accent); text-align: right; }
.ledger-foot { margin-top: 14px; font: 500 10.5px/1.6 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.ledger-empty { padding: 22px 0; border-bottom: 1px solid var(--border); color: var(--muted); font-size: 14px; }
#page-home .ledger-block:last-child { padding-bottom: 72px; }
#page-home .run-list-card { border-top: 1px solid var(--border-strong); }
#page-home .run-row { padding: 16px 0; border-top: 0; border-bottom: 1px solid var(--border); }
#page-home .run-row:hover { background: transparent; }
#page-home .run-row:hover .q { color: #fff; }
#page-home .run-list-card .empty { border-bottom: 1px solid var(--border); }

.figures { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-top: 1px solid var(--border-strong); border-bottom: 1px solid var(--border); }
.figures > div { display: flex; flex-direction: column; gap: 8px; padding: 22px 20px 22px 0; min-width: 0; }
.figures > div + div { border-left: 1px solid var(--border); padding-left: 20px; }
.fig-k { font: 500 10.5px/1.4 var(--mono); letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.fig-v { font: 800 clamp(34px, 4vw, 56px)/1 var(--display); letter-spacing: -.03em; color: var(--text); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.fig-v.good { color: var(--good); }
.fig-s { font-size: 13px; color: var(--text-2); }
.vs { display: flex; flex-direction: column; gap: 10px; padding: 22px 0; border-bottom: 1px solid var(--border); }
.vs-row { display: grid; grid-template-columns: 140px minmax(0, 1fr) 80px; gap: 18px; align-items: center; }
.vs-k { font: 500 10.5px var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.vs-row b { font: 600 13px var(--mono); text-align: right; color: var(--text-2); }
.vs-row.good b { color: var(--good); }
.vs-bar { height: 18px; }
/* dot-matrix bars, to match the figure */
.vs-bar i { display: block; height: 100%; transition: width .6s ease;
  background: radial-gradient(circle, var(--border-strong) 1.1px, transparent 1.4px) 0 0 / 5px 5px; }
.vs-row.good .vs-bar i { background-image: radial-gradient(circle, var(--good) 1.1px, transparent 1.4px); }
.mech { display: grid; grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr); gap: 32px; align-items: center; padding: 28px 0; border-bottom: 1px solid var(--border); }
.mech-text .l-v { margin-top: 10px; }
.cells { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); gap: 4px; }
.cell { display: flex; flex-direction: column; gap: 6px; padding: 10px 8px; border: 1px solid var(--border); min-width: 0; }
.cell span { font: 500 9.5px var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell b { font: 700 13px var(--display); text-transform: uppercase; letter-spacing: .02em; }
.cell em { font: 600 12px var(--mono); font-style: normal; }
.cell.write { border-color: var(--accent-line); background: var(--accent-soft); }
.cell.write b, .cell.write em { color: var(--accent); }
.cell.read b, .cell.read em { color: var(--good); }
.mech-sum { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 12px; font: 500 10.5px/1.6 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.mech-sum b { color: var(--good); font-weight: 600; }
.mech-sum span:last-child b { color: var(--text-2); }
#page-home .run-row { grid-template-columns: minmax(0, 1fr) auto 112px; }
#page-home .run-meta { grid-column: 1 / 3; }
.run-save { grid-column: 3; grid-row: 1 / 3; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.run-save b { font: 800 28px/1 var(--display); letter-spacing: -.02em; color: var(--good); }
.run-save small { font: 500 10px var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.run-save.none { color: var(--faint); font: 500 14px var(--mono); }

/* vertical timeline variant (every loop on narrow screens) */
.loop.vertical { grid-template-columns: minmax(0, 1fr); row-gap: 0; }
.loop.vertical .loop-item { flex-direction: row; text-align: left; gap: 14px; padding: 0 0 14px; align-items: flex-start; }
.loop.vertical .loop-item::before { display: block; top: 22px; bottom: 0; left: 19px; right: auto; width: 2px; height: auto; }
.loop.vertical .loop-item:last-child::before { display: none; }
.loop.vertical .loop-item > div { min-width: 0; padding-top: 2px; }
.loop.vertical .loop-sub { max-width: none; font-size: 12.5px; }

.run-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.run-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 16px; align-items: center; padding: 14px 18px; border-top: 1px solid var(--border); color: inherit; }
.run-list li:first-child .run-row { border-top: 0; }
.run-row:hover { background: var(--surface-2); text-decoration: none; }
.run-row .q { font-weight: 500; color: var(--text); min-width: 0; }
.run-meta { display: flex; flex-wrap: wrap; gap: 4px 18px; font: 500 10.5px/1.6 var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); grid-column: 1 / -1; }
.run-meta .saved { color: var(--good); font-weight: 600; }
.run-list-card { padding: 0; overflow: hidden; }
.run-list-card .card-head { padding: 18px 18px 0; margin-bottom: 12px; }

/* ---------------------------------------------------------------- new research */

.new-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; align-items: start; }
.form-section { padding: 24px; }
.form-section + .form-section { margin-top: 16px; }
.form-section-head { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 18px; }
.form-section-head .n { font: 500 12px/1.5 var(--mono); color: var(--accent); letter-spacing: .1em; flex-shrink: 0; }
.form-section-head .n::before { content: "0"; }
.form-section-head h2 { font: 600 12px/1.5 var(--mono); letter-spacing: .18em; text-transform: uppercase; }
.form-section-head p { font-size: 13px; color: var(--muted); margin-top: 2px; }
.key-box { margin-top: 14px; padding: 14px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); }
.key-row { display: flex; gap: 8px; }
.key-row .input { font-family: var(--mono); font-size: 13px; }
.key-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.tier-note { display: flex; gap: 10px; align-items: flex-start; margin-top: 14px; font-size: 12.5px; color: var(--text-2); padding: 10px 12px; border-left: 2px solid var(--accent); background: var(--accent-soft); }
.tier-note svg { color: var(--accent); margin-top: 1px; }
.summary { position: sticky; top: 84px; }
.summary h2 { font: 600 11.5px/1.4 var(--mono); letter-spacing: .18em; text-transform: uppercase; margin-bottom: 14px; }
.summary-big { font-family: var(--display); font-size: 44px; font-weight: 800; letter-spacing: -.02em; line-height: 1; font-variant-numeric: tabular-nums; }
.summary-rows { display: flex; flex-direction: column; gap: 10px; margin: 18px 0; padding: 16px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); font-size: 13.5px; }
.summary-rows div { display: flex; justify-content: space-between; gap: 12px; }
.summary-rows span:first-child { color: var(--muted); }
.summary-rows span:last-child { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; min-width: 0; overflow-wrap: anywhere; }
.form-error { margin-top: 12px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--bad-soft); color: var(--bad); border: 1px solid var(--bad-line); font-size: 13.5px; overflow-wrap: anywhere; }
.form-warn { margin-top: 12px; font-size: 12.5px; color: var(--warn); display: flex; gap: 8px; align-items: flex-start; }

/* ---------------------------------------------------------------- run header */

.crumbs { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); margin-bottom: 12px; min-width: 0; }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--text); }
.run-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 20px; }
.run-head-main { min-width: 0; flex: 1; }
.run-head h1 { font-size: clamp(22px, 2.6vw, 30px); font-weight: 700; letter-spacing: -.015em; overflow-wrap: anywhere; }
.full-q { margin-top: 8px; max-width: 860px; }
.full-q summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--accent); width: max-content; list-style: none; }
.full-q summary::-webkit-details-marker { display: none; }
.full-q summary::after { content: " ▾"; }
.full-q[open] summary::after { content: " ▴"; }
.full-q p { margin-top: 8px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--border);
  font-size: 13.5px; color: var(--text-2); max-height: 260px; overflow-y: auto; white-space: pre-wrap; }
.run-head-actions { display: flex; gap: 8px; flex-shrink: 0; align-items: center; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 2px; background: transparent; border: 1px solid var(--border); font: 500 10.5px/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--text-2); white-space: nowrap; }
.chip svg { color: var(--muted); }
.chip b { color: var(--text); font-weight: 600; }
.budget-chip { min-width: 180px; }
.budget-chip .meter { width: 64px; height: 6px; }
.phase-line { margin-top: 10px; font-size: 13px; color: var(--muted); display: flex; gap: 8px; align-items: center; min-width: 0; }

/* ---------------------------------------------------------------- tabs */

.tabs { display: flex; gap: 2px; margin: 24px 0 20px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.tabs::-webkit-scrollbar { display: none; }
.tab { position: relative; display: inline-flex; align-items: center; gap: 7px; padding: 10px 14px 12px; color: var(--muted); font: 500 11px/1.4 var(--mono); letter-spacing: .14em; text-transform: uppercase; white-space: nowrap; border: 0; background: none; cursor: pointer; }
.tab:hover { color: var(--text); text-decoration: none; }
.tab[aria-selected="true"] { color: var(--text); }
.tab[aria-selected="true"]::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--accent); }
.tab .count { font-size: 10px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 2px; background: var(--surface-3); color: var(--text-2); display: inline-grid; place-items: center; }
.tab .dot { width: 7px; height: 7px; }

/* ---------------------------------------------------------------- overview */

.overview { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.decision-card { position: relative; overflow: hidden; }
.decision-answer { font-size: 18px; line-height: 1.45; font-weight: 600; letter-spacing: -.01em; margin: 10px 0 18px; overflow-wrap: anywhere; }
.decision-block { padding: 14px 16px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); }
.decision-block + .decision-block { margin-top: 10px; }
.decision-block h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 6px; display: flex; align-items: center; gap: 6px; }
.decision-block .md { font-size: 13.5px; }
.progress-big { display: flex; align-items: baseline; gap: 8px; margin: 14px 0 8px; }
.progress-big b { font-family: var(--display); font-weight: 800; font-size: 38px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-top: 16px; }
.kpi { padding: 18px; }
.kpi-label { font: 500 10.5px/1.4 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.kpi-value { font-family: var(--display); font-size: 30px; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; margin-top: 8px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.kpi-value small { font-size: 14px; font-weight: 600; color: var(--muted); margin-left: 4px; }
.kpi-value.good { color: var(--good); }
.kpi-sub { font-size: 12.5px; color: var(--muted); margin-top: 4px; }

.standards-list { list-style: none; margin: 0; padding: 0; }
.std-row { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 12px; align-items: start; padding: 13px 0; border-top: 1px solid var(--border); }
.standards-list li:first-child .std-row { border-top: 0; padding-top: 2px; }
.std-state { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 2px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.std-state.done { background: var(--good-soft); color: var(--good); border-color: var(--good-line); }
.std-state.active { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-line); }
.std-row h4 { font-size: 14px; }
.std-row p { font-size: 12.5px; color: var(--muted); margin-top: 2px; overflow-wrap: anywhere; }
.std-link { font-size: 12.5px; font-weight: 600; white-space: nowrap; border: 0; background: none; color: var(--accent); cursor: pointer; padding: 4px 0; }

/* ---------------------------------------------------------------- team graph */

.graph-card { padding: 0; overflow: hidden; }
.graph-head { display: flex; justify-content: space-between; align-items: flex-start; padding: 18px 20px; border-bottom: 1px solid var(--border); gap: 12px 20px; flex-wrap: wrap; }
.graph-head h2 { font-size: 16px; }
.graph-head p { color: var(--muted); font-size: 13px; margin-top: 3px; max-width: 60ch; }
.legend { display: flex; gap: 6px 14px; font-size: 12px; color: var(--muted); flex-wrap: wrap; padding-top: 4px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .bar { width: 22px; height: 5px; border-radius: 3px; background: linear-gradient(90deg, var(--good) 70%, var(--border-strong) 70%); }
.canvas-wrap {
  position: relative; overflow-x: auto; overflow-y: hidden; padding: 4px 0;
  background-color: var(--bg);
  background-image: radial-gradient(color-mix(in srgb, var(--accent) 16%, transparent) 1px, transparent 1px);
  background-size: 18px 18px;
}
#canvas { position: relative; transform-origin: 0 0; }
#canvas > svg { position: absolute; inset: 0; overflow: visible; pointer-events: none; }
.edge { fill: none; stroke: var(--border-strong); stroke-width: 1.6; }
.edge.brief { stroke-dasharray: 5 5; stroke: var(--accent); opacity: .55; }
.edge.done { stroke: var(--good); opacity: .7; }
.edge.active { stroke: var(--accent); stroke-dasharray: 7 6; animation: flow 1s linear infinite; opacity: 1; }
.edge.file { stroke: var(--warn); opacity: 0; stroke-dasharray: 3 4; }
.edge.file.show { opacity: .9; }
@keyframes flow { to { stroke-dashoffset: -26; } }
.arrow { fill: var(--border-strong); }

.node {
  position: absolute; width: 230px; height: 112px; border-radius: 3px; padding: 12px 14px; text-align: left; font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong); box-shadow: var(--shadow); cursor: pointer;
  display: flex; flex-direction: column; justify-content: space-between; transition: border-color .2s, box-shadow .2s;
}
.node:hover { border-color: var(--accent); }
.node:focus-visible, .stage-head:focus-visible, .file:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.node.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft), var(--shadow); }
.node.thinking { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow); }
.node.pi { border-style: dashed; border-color: var(--accent); }
.node .nbody { display: block; min-width: 0; }
.node .nhead { display: flex; align-items: center; gap: 8px; min-width: 0; }
.node .nhead svg { flex-shrink: 0; color: var(--muted); }
.node .name { font-family: var(--display); font-weight: 700; font-size: 15px; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.node .sub { display: block; color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.node .nfoot { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
.cachebar { flex: 1; height: 5px; border-radius: 3px; background: var(--track); overflow: hidden; max-width: 110px; }
.cachebar i { display: block; height: 100%; background: var(--good); }

.stage-head {
  position: absolute; width: 230px; height: 46px; border-radius: 2px; padding: 6px 12px; text-align: left; font: inherit; color: var(--text);
  border: 1px dashed var(--accent); background: var(--accent-soft); font-size: 12px; cursor: pointer;
  display: flex; flex-direction: column; justify-content: center;
}
.stage-head b { display: flex; align-items: center; gap: 6px; font-size: 12.5px; }
.stage-head span { color: var(--muted); font-family: var(--mono); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stage-head.selected { box-shadow: 0 0 0 2px var(--accent-soft); border-style: solid; }
.stage-head.pending { border-color: var(--border-strong); background: transparent; }
.stage-head.pending b { color: var(--muted); }

.file {
  position: absolute; height: 34px; border-radius: 2px; padding: 0 12px; display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--border-strong); background: var(--surface); font-family: var(--mono); font-size: 12px;
  color: var(--muted); white-space: nowrap; overflow: hidden;
}
.file.ready { color: var(--text); border-color: var(--warn); cursor: pointer; }
.file.ready:hover, .file.hl { border-color: var(--warn); box-shadow: 0 0 0 2px var(--warn-soft); }

.spec-card h3 { font-size: 15px; display: flex; align-items: center; gap: 8px; }
.spec-card .kv { margin-top: 14px; font-size: 13px; grid-template-columns: 84px minmax(0, 1fr); }

/* ---------------------------------------------------------------- hypotheses & experiment */

.hyp { display: grid; grid-template-columns: 52px minmax(0, 1fr) minmax(220px, 300px); gap: 18px; padding: 18px 20px; align-items: start; }
.hyp + .hyp { border-top: 1px solid var(--border); }
.hyp-id { display: grid; place-items: center; height: 30px; border: 1px solid var(--accent-line); color: var(--accent); font: 600 12px var(--mono); letter-spacing: .06em; }
.hyp.none .hyp-id { background: var(--surface-2); color: var(--muted); }
.hyp-claim { font-size: 14.5px; font-weight: 550; color: var(--text); overflow-wrap: anywhere; }
.hyp-pred { margin-top: 10px; font-size: 13px; color: var(--text-2); padding-left: 12px; border-left: 2px solid var(--border-strong); overflow-wrap: anywhere; }
.hyp-pred b { color: var(--text); font-weight: 600; }
.hyp-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.prob { display: grid; grid-template-columns: 66px minmax(0, 1fr) 46px; gap: 10px; align-items: center; font-size: 12.5px; color: var(--muted); }
.prob + .prob { margin-top: 8px; }
.prob .meter { height: 8px; }
.prob b { text-align: right; color: var(--text); font-variant-numeric: tabular-nums; }
.delta { margin-top: 8px; font-size: 12.5px; font-weight: 600; text-align: right; }
.delta.up { color: var(--good); }
.delta.down { color: var(--bad); }
.delta.flat { color: var(--muted); }
.list-card { padding: 0; overflow: hidden; }
.list-card > .card-head { padding: 20px 20px 0; }

.tests { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.test-card { position: relative; padding: 16px; border-radius: 3px; border: 1px solid var(--border); background: var(--surface); min-width: 0; }
.test-card.chosen { border-color: var(--good); box-shadow: 0 0 0 3px var(--good-soft); }
.test-card .test-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.test-card .letter { font-weight: 750; font-size: 13px; color: var(--muted); }
.test-card p { font-size: 13.5px; color: var(--text-2); overflow-wrap: anywhere; }
.why { margin-top: 14px; padding: 14px 16px; border-radius: var(--radius-sm); background: var(--surface-2); font-size: 13.5px; color: var(--text-2); overflow-wrap: anywhere; }
.why b { color: var(--text); }

details.code { margin-top: 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
details.code summary { cursor: pointer; padding: 10px 14px; font-size: 13px; font-weight: 600; background: var(--surface-2); display: flex; align-items: center; gap: 8px; list-style: none; }
details.code summary::-webkit-details-marker { display: none; }
details.code summary::before { content: "▸"; color: var(--muted); transition: transform .15s; }
details.code[open] summary::before { transform: rotate(90deg); }
details.code pre { margin: 0; border: 0; border-radius: 0; max-height: 480px; }

/* ---------------------------------------------------------------- approval */

.approval { border-color: var(--human-line); border-left: 3px solid var(--human); background: var(--surface); margin-bottom: 16px; }
.approval .card-title .ico { background: var(--surface); color: var(--human); border: 1px solid var(--human-line); }
.choice-list { display: flex; flex-direction: column; gap: 8px; margin: 4px 0 14px; }
.choice { display: grid; grid-template-columns: 20px minmax(0, 1fr); gap: 12px; padding: 12px 14px; border-radius: 2px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; align-items: start; }
.choice:hover { border-color: var(--human-line); }
.choice:has(input:checked) { border-color: var(--human); box-shadow: 0 0 0 3px var(--human-soft); }
.choice input { width: 16px; height: 16px; margin: 2px 0 0; accent-color: var(--human); }
.choice-text { font-size: 13.5px; color: var(--text-2); overflow-wrap: anywhere; }
.choice-text .badge { margin-left: 6px; vertical-align: 1px; }
.approval-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 14px; flex-wrap: wrap; }

/* ---------------------------------------------------------------- review */

.verdict-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.verdict-tile { padding: 14px 16px; border-radius: 3px; border: 1px solid var(--border); background: var(--surface); }
.verdict-tile b { display: block; font-family: var(--display); font-weight: 800; font-size: 28px; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.verdict-tile span { font-size: 12.5px; color: var(--muted); }
.verdict-tile.good b { color: var(--good); }
.verdict-tile.warn b { color: var(--warn); }
.verdict-tile.bad b { color: var(--bad); }
.review-card { display: flex; flex-direction: column; gap: 10px; text-align: left; cursor: pointer; padding: 16px; border-radius: 3px; border: 1px solid var(--border); background: var(--surface); min-width: 0; transition: border-color .15s, box-shadow .15s; }
.review-card:hover { border-color: var(--accent-line); box-shadow: var(--shadow); }
.review-card .rc-top { display: flex; justify-content: space-between; gap: 10px; align-items: center; min-width: 0; }
.review-card h4 { font-size: 14px; min-width: 0; }
.review-card p { font-size: 13px; color: var(--muted); }

/* ---------------------------------------------------------------- acceleration */

.bottleneck { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; }
.bottleneck h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 6px; }
.bottleneck p { font-size: 13.5px; color: var(--text-2); }
.bars { display: flex; flex-direction: column; gap: 14px; }
.bar-group h4 { font-size: 13px; margin-bottom: 8px; display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.bar-group h4 > span:last-child { color: var(--good); font-variant-numeric: tabular-nums; }
.bar-group h4 .bg-label { color: var(--text); }
.bar-group h4 small { font-weight: 500; color: var(--muted); font-size: 12px; margin-left: 6px; }
.nowrap { white-space: nowrap; }
.bar-line { display: grid; grid-template-columns: 120px minmax(0, 1fr) 76px; gap: 10px; align-items: center; font-size: 12.5px; color: var(--muted); }
.bar-line + .bar-line { margin-top: 6px; }
.bar-line .meter { height: 10px; }
.bar-line b { text-align: right; color: var(--text); font-variant-numeric: tabular-nums; font-weight: 600; }
.table-wrap { overflow-x: auto; margin: 0 -20px -20px; border-top: 1px solid var(--border); }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 760px; }
table.data th, table.data td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.data th { font: 500 10.5px var(--mono); text-transform: uppercase; letter-spacing: .12em; color: var(--muted); background: var(--surface-2); white-space: nowrap; }
table.data td.r, table.data th.r { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr { cursor: pointer; }
table.data tbody tr:hover td { background: var(--surface-2); }
.tags { display: flex; flex-wrap: wrap; gap: 4px; }
.footnote { font-size: 12.5px; color: var(--muted); margin-top: 14px; }

/* ---------------------------------------------------------------- record */

.record { list-style: none; margin: 0; padding: 0; }
.record-row { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 11px 20px; border-top: 1px solid var(--border); cursor: pointer; width: 100%; text-align: left; background: none; border-left: 0; border-right: 0; border-bottom: 0; color: inherit; }
.record li:first-child .record-row { border-top: 0; }
.record-row:hover { background: var(--surface-2); }
.record-row .ico { display: grid; place-items: center; width: 30px; height: 30px; border: 1px solid var(--border); color: var(--muted); }
.record-row .path { font-family: var(--mono); font-size: 12.5px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.record-row .desc { font-size: 12px; color: var(--muted); }
.record-group { padding: 10px 20px; font: 500 10.5px var(--mono); letter-spacing: .16em; text-transform: uppercase; color: var(--muted); background: var(--surface-2); border-top: 1px solid var(--border); }
.record li:first-child.record-group { border-top: 0; }

/* ---------------------------------------------------------------- drawer, dialog, toast */

.drawer { position: fixed; inset: 0; z-index: 40; }
.drawer-scrim { position: absolute; inset: 0; background: rgba(5, 8, 13, .6); animation: fade .2s ease; }
.drawer-panel { position: absolute; top: 0; right: 0; bottom: 0; width: min(640px, 100vw); background: var(--surface); border-left: 1px solid var(--border-strong); box-shadow: var(--shadow-lg); display: flex; flex-direction: column; animation: slide .22s ease; }
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.drawer-titles { min-width: 0; }
.drawer-head h2 { font-size: 17px; overflow-wrap: anywhere; margin-top: 2px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 20px 22px 32px; overscroll-behavior: contain; }
.drawer-body .kv { margin-bottom: 18px; }
.drawer-file { margin-top: 6px; }
.drawer-file-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; margin-bottom: 8px; border-bottom: 1px solid var(--border); font-family: var(--mono); font-size: 12.5px; color: var(--muted); min-width: 0; }
@keyframes fade { from { opacity: 0; } }
@keyframes slide { from { transform: translateX(24px); } }
body.drawer-open { overflow: hidden; }

.confirm { border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; width: min(420px, calc(100vw - 32px)); background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); }
.confirm::backdrop { background: rgba(10, 14, 22, .45); }
.confirm h2 { font-size: 17px; margin-bottom: 8px; }
.confirm p { color: var(--text-2); font-size: 14px; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60; max-width: calc(100vw - 32px); padding: 11px 16px; border-radius: 2px; background: var(--text); color: var(--bg); font-size: 13.5px; font-weight: 500; box-shadow: var(--shadow-lg); animation: fade .2s ease; }
.toast.bad { background: var(--bad); color: #1f0806; }

/* ---------------------------------------------------------------- markdown */

.md { font-size: 14px; line-height: 1.65; color: var(--text-2); overflow-wrap: anywhere; }
.md > :first-child { margin-top: 0; }
.md h1, .md h2, .md h3, .md h4 { color: var(--text); margin: 20px 0 8px; font-size: 15.5px; }
.md h1 { font-size: 18px; }
.md p { margin: 8px 0; }
.md ul, .md ol { margin: 8px 0; padding-left: 22px; }
.md li { margin: 3px 0; }
.md strong { color: var(--text); }
.md pre { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; overflow: auto; font-size: 12.5px; line-height: 1.55; }
.md code { background: var(--surface-2); padding: 1px 5px; border-radius: 2px; border: 1px solid var(--border); }
.md pre code { background: none; border: 0; padding: 0; }
.md table { width: 100%; border-collapse: collapse; font-size: 13px; margin: 10px 0; display: block; overflow-x: auto; }
.md th, .md td { border: 1px solid var(--border); padding: 7px 10px; text-align: left; vertical-align: top; }
.md th { background: var(--surface-2); color: var(--text); }
.md hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }
.md blockquote { margin: 8px 0; padding: 4px 14px; border-left: 3px solid var(--border-strong); color: var(--muted); }

/* ---------------------------------------------------------------- responsive */

@media (max-width: 1100px) {
  .new-layout { grid-template-columns: minmax(0, 1fr) 300px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hyp { grid-template-columns: 48px minmax(0, 1fr); }
  .hyp-probs { grid-column: 2; }
}
@media (max-width: 960px) {
  .intro { grid-template-columns: minmax(0, 1fr); min-height: 0; }
  .intro-text { padding: 40px 0 24px; }
  .intro-art { border-left: 0; border-top: 1px solid var(--border); height: 440px; }
  .figures { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .figures > div:nth-child(3) { border-left: 0; padding-left: 0; }
  .figures > div:nth-child(n+3) { border-top: 1px solid var(--border); }
  .mech { grid-template-columns: minmax(0, 1fr); }
  .cells { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .ledger > li { grid-template-columns: 40px minmax(0, 1fr); }
  .ledger > li .l-v, .ledger > li .l-r { grid-column: 2; text-align: left; }
  .overview { grid-template-columns: minmax(0, 1fr); }
  .new-layout { grid-template-columns: minmax(0, 1fr); }
  .summary { position: static; }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bottleneck { grid-template-columns: minmax(0, 1fr); }
  .loop { grid-template-columns: repeat(4, minmax(0, 1fr)); row-gap: 22px; }
  .loop-item:nth-child(5)::before { display: none; }
}
@media (max-width: 720px) {
  .container { padding: 0 16px; }
  .page-pad { padding-top: 20px; padding-bottom: 40px; }
  .hide-sm { display: none !important; }
  .brand-text small { display: none; }
  .intro-art { height: 340px; }
  .art-canvas { inset: 40px 0; }
  .ledger.rules > div { grid-template-columns: minmax(0, 1fr); }
  .vs-row { grid-template-columns: 90px minmax(0, 1fr) 64px; gap: 10px; }
  .readout { gap: 16px; }
  #page-home .run-row { grid-template-columns: minmax(0, 1fr) 80px; }
  #page-home .run-row .badge { grid-column: 1; justify-self: start; }
  #page-home .run-meta { grid-column: 1; }
  .run-save { grid-column: 2; grid-row: 1 / 4; }
  .run-save b { font-size: 22px; }
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .field-row { grid-template-columns: minmax(0, 1fr); }
  .run-head { flex-direction: column; gap: 14px; }
  .run-head-actions { width: 100%; }
  .run-head-actions .btn { flex: 1; }
  .card { padding: 16px; }
  .graph-card { padding: 0; }
  .graph-head { padding: 16px; }
  .form-section { padding: 18px; }
  .table-wrap { margin: 0 -16px -16px; }
  .loop { grid-template-columns: minmax(0, 1fr); row-gap: 0; }
  .loop-item { flex-direction: row; text-align: left; gap: 12px; padding: 0 0 18px; align-items: flex-start; }
  /* vertical connector: from this node down to the next one */
  .loop-item::before, .loop-item:first-child::before, .loop-item:nth-child(5)::before { display: block; top: 22px; bottom: 0; left: 19px; right: auto; width: 2px; height: auto; }
  .loop-item:last-child::before { display: none; }
  .loop-item.active::before, .loop-item.human::before { background: var(--border); }
  .loop-item > div { min-width: 0; padding-top: 2px; }
  .loop-sub { max-width: none; }
  .loop-card { padding: 18px 16px 4px; }
  .loop-foot { margin-bottom: 14px; }
  .hyp { grid-template-columns: minmax(0, 1fr); gap: 12px; padding: 16px; }
  .hyp-id { width: 44px; }
  .hyp-probs { grid-column: auto; }
  .verdict-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .verdict-tile { padding: 12px; }
  .bar-line { grid-template-columns: 88px minmax(0, 1fr) 64px; }
  .kpi-value { font-size: 24px; }
  .record-row { padding: 11px 16px; grid-template-columns: 32px minmax(0, 1fr); }
  .record-row .badge { display: none; }
  .budget-chip { min-width: 0; }
  .segmented { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 420px) {
  .kpis { grid-template-columns: minmax(0, 1fr); }
  .grid-4 { grid-template-columns: minmax(0, 1fr); }
  .topbar-actions .btn.primary { padding: 0 10px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
