/* Buildability Code Assistant — single stylesheet, no build step, no CDN. */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #d9dee5;
  --border-strong: #b9c2ce;
  --text: #1b2430;
  --text-dim: #5a6675;
  --text-faint: #8894a3;
  --accent: #1f5fa8;
  --accent-soft: #e6eefa;
  --pass: #1a7f4b;
  --pass-soft: #e3f4ea;
  --fail: #b3261e;
  --fail-soft: #fbe9e7;
  --warn: #8a5a00;
  --warn-soft: #fdf1dc;
  --info: #35507a;
  --info-soft: #e9eefa;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .06);
}

[data-theme="dark"] {
  --bg: #10151c;
  --surface: #171d26;
  --surface-2: #1e2632;
  --border: #2b3542;
  --border-strong: #3b4757;
  --text: #e6ebf2;
  --text-dim: #a3b0c0;
  --text-faint: #77869a;
  --accent: #6ba4ec;
  --accent-soft: #1b2c44;
  --pass: #58d69a;
  --pass-soft: #12301f;
  --fail: #ff8a80;
  --fail-soft: #3a1a17;
  --warn: #e8b563;
  --warn-soft: #34260f;
  --info: #9db8e8;
  --info-soft: #1a2436;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

.skip {
  position: absolute; left: -999px; top: 0; z-index: 100;
  background: var(--accent); color: #fff; padding: 8px 14px;
}
.skip:focus { left: 8px; top: 8px; }

/* ------------------------------- top bar -------------------------------- */

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 10px 18px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark { font-size: 26px; line-height: 1; }
.brand-title { font-weight: 650; letter-spacing: -.01em; }
.brand-sub { font-size: 12.5px; color: var(--text-dim); }
.topbar-actions { display: flex; gap: 8px; flex-shrink: 0; }

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

.shell { display: grid; grid-template-columns: 268px minmax(0, 1fr); align-items: start; }
.sidenav {
  position: sticky; top: 57px; height: calc(100vh - 57px); overflow-y: auto;
  padding: 16px 12px 40px; border-right: 1px solid var(--border); background: var(--surface);
}
.main { padding: 26px 32px 64px; max-width: 1180px; min-width: 0; }
.main:focus { outline: none; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidenav { position: static; height: auto; border-right: none; border-bottom: 1px solid var(--border); }
  .main { padding: 20px 16px 48px; }
}

.nav-group { margin-bottom: 18px; }
.nav-group-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--text-faint); font-weight: 650; padding: 0 10px 6px;
}
.nav-item {
  display: flex; align-items: baseline; gap: 9px; width: 100%;
  padding: 7px 10px; border-radius: 7px; text-decoration: none;
  color: var(--text); font-size: 14px; line-height: 1.35;
}
.nav-item:hover { background: var(--surface-2); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-num {
  font: 600 10.5px/1 var(--mono); color: var(--text-faint);
  min-width: 20px; flex-shrink: 0; padding-top: 3px;
}
.nav-item.active .nav-num { color: var(--accent); }

/* -------------------------------- footer -------------------------------- */

.footer {
  display: flex; flex-wrap: wrap; gap: 6px 18px; justify-content: space-between;
  padding: 12px 20px; border-top: 1px solid var(--border);
  background: var(--surface); font-size: 12px; color: var(--text-dim);
}
.footer-note { color: var(--text-faint); }

/* ------------------------------- typography ----------------------------- */

h1 { font-size: 24px; letter-spacing: -.02em; margin: 0 0 6px; }
h2 { font-size: 17px; letter-spacing: -.01em; margin: 30px 0 12px; }
h3 { font-size: 14.5px; margin: 20px 0 8px; }
.lede { color: var(--text-dim); margin: 0 0 22px; max-width: 76ch; }
.muted { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.small { font-size: 12.5px; }
code, .mono { font-family: var(--mono); font-size: .89em; }
a { color: var(--accent); }

.page-head { border-bottom: 1px solid var(--border); padding-bottom: 16px; margin-bottom: 22px; }
.demo-tag {
  display: inline-block; font: 600 10.5px/1 var(--mono); letter-spacing: .06em;
  text-transform: uppercase; color: var(--accent); background: var(--accent-soft);
  padding: 4px 8px; border-radius: 5px; margin-bottom: 10px;
}

/* --------------------------------- cards -------------------------------- */

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.card-title { font-weight: 650; font-size: 14.5px; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); }
.split { display: grid; grid-template-columns: minmax(300px, 380px) minmax(0, 1fr); gap: 18px; align-items: start; }
@media (max-width: 1000px) { .split { grid-template-columns: 1fr; } }

/* ------------------------------ stat tiles ------------------------------ */

.stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
}
.stat-label { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-faint); font-weight: 600; }
.stat-value { font-size: 27px; font-weight: 620; letter-spacing: -.02em; margin: 3px 0 2px; font-variant-numeric: tabular-nums; }
.stat-sub { font-size: 12px; color: var(--text-dim); }
.stat.pass { border-color: var(--pass); background: var(--pass-soft); }
.stat.fail { border-color: var(--fail); background: var(--fail-soft); }
.stat.warn { border-color: var(--warn); background: var(--warn-soft); }
.stat.pass .stat-value { color: var(--pass); }
.stat.fail .stat-value { color: var(--fail); }
.stat.warn .stat-value { color: var(--warn); }

/* -------------------------------- badges -------------------------------- */

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font: 600 11px/1 inherit; padding: 4px 8px; border-radius: 20px;
  background: var(--surface-2); color: var(--text-dim); white-space: nowrap;
}
.badge.pass { background: var(--pass-soft); color: var(--pass); }
.badge.fail { background: var(--fail-soft); color: var(--fail); }
.badge.pending { background: var(--warn-soft); color: var(--warn); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.ref { font-family: var(--mono); font-size: 10.5px; background: var(--surface-2); color: var(--text-dim); border: 1px solid var(--border); }

.refs { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 10px; }
.refs-label { font-size: 11px; color: var(--text-faint); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; align-self: center; margin-right: 3px; }

/* -------------------------------- tables -------------------------------- */

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-weight: 620; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-faint); background: var(--surface-2); white-space: nowrap; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.row-fail { background: var(--fail-soft); }
.row-pass td:first-child { box-shadow: inset 3px 0 0 var(--pass); }
.row-fail td:first-child { box-shadow: inset 3px 0 0 var(--fail); }
.row-pending td:first-child { box-shadow: inset 3px 0 0 var(--warn); }
.row-total td { font-weight: 650; background: var(--surface-2); }
.row-group td { font-weight: 620; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-dim); background: var(--surface-2); }

/* -------------------------------- forms --------------------------------- */

.field { margin-bottom: 13px; }
label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-dim); margin-bottom: 4px; }
input[type=text], input[type=number], input[type=search], select, textarea {
  width: 100%; padding: 8px 10px; font: inherit; font-size: 14px;
  color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: 7px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
input[type=range] { width: 100%; accent-color: var(--accent); }
input[type=checkbox] { accent-color: var(--accent); width: 15px; height: 15px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; font: inherit; font-size: 13.5px; font-weight: 600;
  border-radius: 7px; border: 1px solid transparent; cursor: pointer;
  background: var(--accent); color: #fff; text-decoration: none;
}
.btn:hover { filter: brightness(1.07); }
.btn.ghost { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn.ghost:hover { background: var(--surface-2); filter: none; }
.btn.small { padding: 5px 10px; font-size: 12.5px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

.check-row { display: flex; align-items: flex-start; gap: 9px; padding: 6px 0; font-size: 13.5px; }
.check-row label { margin: 0; font-weight: 400; color: var(--text); font-size: 13.5px; }
.check-row .pts { margin-left: auto; font: 600 12px var(--mono); color: var(--text-dim); white-space: nowrap; }

.slider-row { display: grid; grid-template-columns: minmax(0,1fr) 74px; gap: 10px; align-items: center; margin-bottom: 9px; }
.slider-row .name { font-size: 13px; }
.slider-row .name small { display: block; color: var(--text-faint); font-size: 11.5px; }

.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  padding: 6px 11px; font-size: 12.5px; border-radius: 20px; cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
}
.chip:hover { background: var(--surface-2); }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* -------------------------------- misc ---------------------------------- */

.bar { height: 7px; border-radius: 4px; background: var(--surface-2); overflow: hidden; margin-top: 6px; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 4px; transition: width .25s ease; }
.bar.pass > i { background: var(--pass); }
.bar.fail > i { background: var(--fail); }

.callout {
  border-left: 3px solid var(--accent); background: var(--accent-soft);
  padding: 11px 14px; border-radius: 0 8px 8px 0; font-size: 13.5px; margin: 12px 0;
}
.callout.warn { border-color: var(--warn); background: var(--warn-soft); }
.callout.fail { border-color: var(--fail); background: var(--fail-soft); }
.callout.pass { border-color: var(--pass); background: var(--pass-soft); }

.working {
  font-family: var(--mono); font-size: 12.5px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 7px; padding: 10px 12px;
  white-space: pre-wrap; word-break: break-word; color: var(--text-dim); margin: 10px 0 0;
}

.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 13.5px; }
.kv dt { color: var(--text-dim); font-weight: 600; }
.kv dd { margin: 0; }

ul.tight { margin: 6px 0; padding-left: 20px; }
ul.tight li { margin-bottom: 3px; }

.list-reset { list-style: none; margin: 0; padding: 0; }

details.disclose { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; background: var(--surface); }
details.disclose > summary { cursor: pointer; font-weight: 600; font-size: 13.5px; }
details.disclose[open] > summary { margin-bottom: 9px; }

.empty { color: var(--text-faint); font-size: 13.5px; padding: 14px 0; }
.spinner { color: var(--text-dim); padding: 40px 0; text-align: center; }

.pill-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }

.entity-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 18px 24px; border-left: 2px solid var(--border); }
.timeline li:last-child { border-left-color: transparent; padding-bottom: 0; }
.timeline li::before {
  content: ''; position: absolute; left: -6px; top: 4px; width: 10px; height: 10px;
  border-radius: 50%; background: var(--accent); border: 2px solid var(--surface);
}
.timeline .t-title { font-weight: 620; font-size: 13.5px; }

pre.json {
  font-family: var(--mono); font-size: 12px; line-height: 1.5;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
  padding: 14px; overflow: auto; max-height: 560px; margin: 0;
}
.tok-key { color: var(--accent); }
.tok-str { color: var(--pass); }
.tok-num { color: var(--warn); }
.tok-bool { color: var(--fail); }

.answer-head { font-size: 19px; font-weight: 640; letter-spacing: -.015em; margin: 0 0 6px; }
