/* Design system (AGENTS.md, section 10). Theme: data-theme="auto" on <html>
   follows the OS; "light" / "dark" force a theme. Never write raw hex in
   templates or component rules: use these tokens. */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../vendor/inter/InterVariable.woff2") format("woff2");
}

:root {
  --bg: #e4e5e5;
  --card: #fefefe;
  --fg: #333a44;
  --muted: #5c636d;
  --border: #d3d6d9;
  --border-strong: #b4b9bf;
  --accent: #77bc1f;          /* decoration only, never text on light */
  --link: #3f6e0c;
  --focus: #0786b4;
  --danger: #990033;
  --danger-bg: #f7e6ec;
  --success: #3f6e0c;
  --primary: #77bc1f;
  --primary-hover: #86cb2e;
  --on-primary: #1e232a;      /* text on lime: graphite, never white */
  --surface: #f0f1f1;         /* secondary buttons */
  --surface-hover: #e4e6e8;
  --field: #fefefe;
  --menu-bg: #fefefe;
  --mark: #ffd206;            /* highlighted text */
  --badge-bg: #990033;
  --badge-fg: #ffffff;
  --topbar-bg: linear-gradient(90deg, #333a44, #4b535c);
  --shadow: 0 1px 2px rgba(51, 58, 68, 0.06), 0 1px 3px rgba(51, 58, 68, 0.08);
  --control-h: 2.25rem;
  --control-h-sm: 2rem;
  --radius: 8px;
  --radius-sm: 6px;
  --radius-lg: 12px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --bg: #1e232a;
    --card: #333a44;
    --fg: #e4e5e5;
    --muted: #a9afb7;
    --border: #4b535c;
    --border-strong: #5f6872;
    --accent: #8bf50a;
    --link: #8bf50a;
    --focus: #52d4e3;
    --danger: #f58bc9;
    --danger-bg: #4a2d3f;
    --success: #8bf50a;
    --surface: #3b424c;
    --surface-hover: #4b535c;
    --field: #262c34;
    --menu-bg: #3b424c;
    --mark: #6d5a14;
    --badge-bg: #f58bc9;
    --badge-fg: #1e232a;
    --topbar-bg: linear-gradient(90deg, #12171d, #262c34);
    --shadow: none;
  }
}

/* Same values as the block above: keep the two in sync. */
:root[data-theme="dark"] {
  --bg: #1e232a;
  --card: #333a44;
  --fg: #e4e5e5;
  --muted: #a9afb7;
  --border: #4b535c;
  --border-strong: #5f6872;
  --accent: #8bf50a;
  --link: #8bf50a;
  --focus: #52d4e3;
  --danger: #f58bc9;
  --danger-bg: #4a2d3f;
  --success: #8bf50a;
  --surface: #3b424c;
  --surface-hover: #4b535c;
  --field: #262c34;
  --menu-bg: #3b424c;
  --mark: #6d5a14;
  --badge-bg: #f58bc9;
  --badge-fg: #1e232a;
  --topbar-bg: linear-gradient(90deg, #12171d, #262c34);
  --shadow: none;
  color-scheme: dark;
}
:root[data-theme="light"] { color-scheme: light; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.5 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-feature-settings: "cv11";
}
a { color: var(--link); }

/* Brand tokens used by the top bar in both themes (section 10.4). */
:root {
  --on-topbar: #ffffff;
  --brand-mark: linear-gradient(180deg, #8bf50a, #77bc1f);
}

/* The top bar is graphite in both themes, so it uses the dark-theme values
   (same as the dark blocks above: keep in sync). */
.topbar {
  --fg: #e4e5e5; --muted: #a9afb7; --border: #4b535c; --border-strong: #5f6872;
  --surface: #3b424c; --surface-hover: #4b535c; --field: #262c34;
  --focus: #52d4e3; --link: #8bf50a; --accent: #8bf50a;
}

/* ----- Layout ----- */
* { box-sizing: border-box; }
h1 { font-size: 1.75rem; line-height: 1.25; font-weight: 600; margin: 0 0 1rem; }
h2 { font-size: 1.125rem; line-height: 1.4; font-weight: 600; margin: 0; }
p { margin: 0; }
.container { max-width: 48rem; margin: 0 auto; padding: 1.5rem 1rem 3rem; }
.container-narrow { max-width: 26rem; }
.stack { display: flex; flex-direction: column; gap: 1rem; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.grow { flex: 1 1 auto; min-width: 0; }
.row > * { min-width: 0; max-width: 100%; }
.card .row > .control { flex: 1 1 12rem; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.error { color: var(--danger); }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* ----- Top bar (dark tokens inside, both themes) ----- */
.topbar {
  background: var(--topbar-bg);
  color: var(--on-topbar);
  color-scheme: dark;
}
.topbar-row {
  display: flex; align-items: center; gap: 0.625rem; flex-wrap: wrap;
  max-width: 48rem; margin: 0 auto; padding: 0.625rem 1rem;
}
.brand-mark {
  width: 0.375rem; height: 1.25rem; border-radius: 2px;
  background: var(--brand-mark);
}
.brand-name { font-weight: 700; }
.topbar-tools { margin-left: auto; display: flex; flex-wrap: wrap; gap: 0.5rem; }
.tabs { display: flex; gap: 1.25rem; max-width: 48rem; margin: 0 auto; padding: 0 1rem; }
.tabs a {
  color: var(--fg); text-decoration: none; font-weight: 500; padding: 0.5rem 0;
  border-bottom: 2px solid transparent;
}
.tabs a[aria-current="page"] { border-bottom-color: var(--accent); color: var(--on-topbar); }

/* ----- Cards ----- */
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow); padding: 1.5rem; margin: 0;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 0.25rem 1rem; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.list { list-style: none; padding: 0.5rem 1.5rem; }
.list-row { display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem 0; }
.list-row + .list-row { border-top: 1px solid var(--border); }
.form { max-width: 38rem; }
.status {
  font-size: 0.875rem; font-weight: 600; padding: 0.125rem 0.625rem;
  border: 1px solid currentColor; border-radius: 999px; text-transform: capitalize;
}
.status-ok { color: var(--success); }
.status-bad { color: var(--danger); }
.status-warn { color: var(--fg); background: var(--mark); border-color: var(--mark); }
.code {
  font-size: 2rem; font-weight: 600; letter-spacing: 0.12em;
  font-variant-numeric: tabular-nums;
}

/* ----- Controls: one height, one padding, one radius ----- */
.btn, .control {
  height: var(--control-h); padding: 0 0.875rem; border-radius: var(--radius-sm);
  font: inherit; font-size: 0.9375rem; font-weight: 500; white-space: nowrap;
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
  background: var(--surface); color: var(--fg); border: 1px solid var(--border);
  text-decoration: none;
}
.btn:hover { background: var(--surface-hover); }
.btn-primary { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { background: transparent; color: var(--danger); border-color: transparent; }
.btn-danger:hover { background: var(--danger-bg); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-sm, .control-sm { height: var(--control-h-sm); font-size: 0.875rem; }
.control {
  background: var(--field); color: var(--fg); border: 1px solid var(--border-strong);
  font-weight: 400; min-width: 0; max-width: 100%;
}
textarea.control {
  height: auto; width: 100%; padding: 0.5rem 0.875rem; white-space: pre; overflow: auto;
  resize: vertical;
}
.control:user-invalid { border-color: var(--danger); }
.field { display: flex; flex-direction: column; gap: 0.25rem; font-weight: 500; }
.field .control { width: 100%; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--primary); }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
