/* The fault-code pages. Same palette as the site's own index.html, so the
   dictionary reads as part of the same site. */
:root {
  color-scheme: light dark;
  --bg: #f4f7fa;
  --panel: #ffffff;
  --ink: #0d1b26;
  --muted: #566e80;
  --line: #e1e8ee;
  --accent: #0b5586;
  --accent-ink: #ffffff;
  --tint: #e8f2f9;
  --warn-bg: #fff7e3;
  --warn-line: #ecd08a;
  --critical: #b3261e;
  --high: #b45309;
  --medium: #0b5586;
  --low: #3f7a39;
  --shadow: 0 1px 2px rgb(13 27 38 / .04), 0 4px 16px rgb(13 27 38 / .05);
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #07121a;
    --panel: #0e1e28;
    --ink: #e6eff5;
    --muted: #93a9b9;
    --line: #1c3341;
    --accent: #4bb6ea;
    --accent-ink: #04263d;
    --tint: #10324a;
    --warn-bg: #2a2110;
    --warn-line: #6e561d;
    --critical: #ff8a80;
    --high: #f5b86b;
    --medium: #4bb6ea;
    --low: #9fd39a;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-underline-offset: 2px; }
[hidden] { display: none !important; }
.mono, .tag, .code-pill, .chips.mono a { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }

/* ---- header and footer ------------------------------------------------ */
header.site {
  position: sticky; top: 0; z-index: 5;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.bar {
  max-width: 54rem; margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; gap: 12px;
}
.brand {
  display: inline-flex; align-items: center; gap: 10px; margin-right: auto;
  color: var(--ink); text-decoration: none; font-weight: 700; font-size: 1.05rem;
}
.brand img { border-radius: 8px; display: block; }
header.site nav { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
header.site nav a {
  padding: 6px 12px; border-radius: 999px; text-decoration: none;
  color: var(--muted); font-size: .94rem; font-weight: 500;
}
header.site nav a:hover { background: var(--tint); color: var(--accent); }
header.site nav a[aria-current] { background: var(--tint); color: var(--accent); }
header.site nav a.lang { color: var(--accent); }

main { max-width: 54rem; margin: 0 auto; padding: 22px 16px 56px; }

footer.site { border-top: 1px solid var(--line); color: var(--muted); font-size: .9rem; }
footer.site div { max-width: 54rem; margin: 0 auto; padding: 22px 16px 40px; }
footer.site p { margin: 0 0 8px; }

/* ---- page head --------------------------------------------------------- */
.crumbs ol {
  list-style: none; margin: 0 0 14px; padding: 0;
  display: flex; flex-wrap: wrap; align-items: center; gap: 2px 0;
  font-size: .9rem; color: var(--muted);
}
.crumbs li { display: inline; }
.crumbs li + li::before { content: "/"; margin: 0 8px; opacity: .5; }
.crumbs a { text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }

.hero { margin: 0 0 14px; }
.code-pill {
  display: inline-block; margin: 0 0 8px; padding: 3px 12px; border-radius: 10px;
  background: var(--tint); color: var(--accent);
  font-weight: 700; font-size: 1.05rem; letter-spacing: .02em;
}
h1 { font-size: clamp(1.5rem, 1.1rem + 1.6vw, 2.05rem); line-height: 1.2; margin: 0; letter-spacing: -.02em; }
h2 { font-size: 1.15rem; line-height: 1.3; margin: 0 0 12px; letter-spacing: -.01em; }
h3 { font-size: 1rem; margin: 18px 0 8px; }
p { margin: 0 0 14px; }
.lead { font-size: 1.06rem; color: var(--ink); max-width: 44rem; }

/* ---- facts, notes ------------------------------------------------------ */
.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 16px 0 0; }
.facts div {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 14px; box-shadow: var(--shadow);
}
.facts dt { font-size: .74rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.facts dd { margin: 2px 0 0; font-weight: 650; line-height: 1.35; }
.sev-critical dd, .drive-stop_now dd { color: var(--critical); }
.sev-high dd, .drive-limp_home dd { color: var(--high); }
.sev-medium dd { color: var(--medium); }
.sev-low dd, .drive-ok dd { color: var(--low); }

.note {
  background: var(--warn-bg); border: 1px solid var(--warn-line);
  border-radius: var(--radius); padding: 12px 16px; margin: 18px 0;
}
.note.info { background: var(--tint); border-color: transparent; color: var(--ink); font-size: .95rem; }

/* ---- pills ------------------------------------------------------------- */
.pill {
  display: inline-block; padding: 2px 9px; border-radius: 999px; white-space: nowrap;
  font-size: .74rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  background: var(--tint); color: var(--accent);
}
.pill.sev-critical { color: var(--critical); background: color-mix(in srgb, var(--critical) 12%, transparent); }
.pill.sev-high { color: var(--high); background: color-mix(in srgb, var(--high) 13%, transparent); }
.pill.sev-medium { color: var(--medium); background: color-mix(in srgb, var(--medium) 12%, transparent); }
.pill.sev-low { color: var(--low); background: color-mix(in srgb, var(--low) 13%, transparent); }
.pill.struct, .pill.lik-rare { color: var(--muted); background: color-mix(in srgb, var(--muted) 12%, transparent); }
.pill.lik-possible { color: var(--muted); background: color-mix(in srgb, var(--muted) 10%, transparent); }

/* ---- code page sections ------------------------------------------------ */
section.block {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; margin: 16px 0; box-shadow: var(--shadow);
}
ul.causes { list-style: none; margin: 0; padding: 0; }
ul.causes li { display: grid; grid-template-columns: 7.2rem 1fr; gap: 12px; align-items: baseline; padding: 8px 0; border-top: 1px solid var(--line); }
ul.causes li:first-child { border-top: 0; padding-top: 0; }
ul.causes .pill { justify-self: start; }
ul.dots { margin: 0; padding-left: 1.2rem; }
ul.dots li { margin: 0 0 6px; }
ul.dots li::marker { color: var(--accent); }
ol.steps { list-style: none; margin: 0; padding: 0; counter-reset: step; }
ol.steps li { counter-increment: step; position: relative; padding: 0 0 12px 40px; }
ol.steps li:last-child { padding-bottom: 0; }
ol.steps li::before {
  content: counter(step); position: absolute; left: 0; top: 0;
  width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink); font-size: .8rem; font-weight: 700;
}

/* ---- list panels: systems, blocks, codes ------------------------------- */
ul.list {
  list-style: none; margin: 0 0 18px; padding: 0; overflow: hidden;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
ul.list li + li { border-top: 1px solid var(--line); }
ul.list a, .tree summary, .tree a.leaf {
  display: grid; grid-template-columns: 4.8rem minmax(0, 1fr) auto; gap: 14px; align-items: center;
  padding: 11px 16px; text-decoration: none; color: var(--ink);
}
ul.list a:hover, .tree summary:hover, .tree a.leaf:hover { background: var(--tint); }
ul.list a[aria-current] { background: var(--tint); }
.tag { color: var(--accent); font-weight: 700; font-size: .95rem; }
.what { min-width: 0; line-height: 1.4; }
.what b { display: block; font-weight: 650; }
.what small { display: block; color: var(--muted); font-size: .88rem; margin-top: 2px; }
.meta { color: var(--muted); font-size: .86rem; white-space: nowrap; display: inline-flex; align-items: center; gap: 8px; }
ul.list .meta::after { content: "›"; font-size: 1.3rem; line-height: 1; color: var(--muted); opacity: .6; }

ul.list.systems a, .tree summary.systems { grid-template-columns: 2rem minmax(0, 1fr) auto; }

h3.scope { display: flex; align-items: baseline; gap: 10px; margin: 26px 0 4px; font-size: 1rem; }
.scope-note { color: var(--muted); font-size: .92rem; margin: 0 0 10px; }

/* ---- chips ------------------------------------------------------------- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips.wide { margin: 14px 0 22px; }
.chip {
  padding: 4px 10px; border-radius: 8px; text-decoration: none; font-size: .9rem;
  background: var(--panel); border: 1px solid var(--line); color: var(--accent);
}
.chip:hover { border-color: var(--accent); }
.chip.dim { color: var(--muted); }
.chip[aria-current] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 700; }

/* ---- where this code sits ---------------------------------------------- */
section.where {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; margin: 16px 0; box-shadow: var(--shadow);
}
.levels { display: grid; gap: 14px; }
.level { padding-left: 14px; border-left: 2px solid var(--line); }
.level + .level { margin-left: 14px; }
.level + .level + .level { margin-left: 28px; }
.level-name { margin: 0 0 6px; font-weight: 600; font-size: .92rem; }

/* ---- the full tree ----------------------------------------------------- */
.tree-tools { display: flex; gap: 8px; }
.tree-tools button {
  font: inherit; font-size: .9rem; padding: 6px 14px; border-radius: 999px; cursor: pointer;
  background: var(--panel); color: var(--accent); border: 1px solid var(--line);
}
.tree-tools button:hover { border-color: var(--accent); }
.tree details.sys {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  margin: 0 0 12px; overflow: hidden; box-shadow: var(--shadow);
}
.tree summary { cursor: pointer; list-style: none; }
.tree summary::-webkit-details-marker { display: none; }
.tree summary .meta::after { content: "▸"; font-size: .9rem; transition: transform .15s; }
.tree details[open] > summary .meta::after { transform: rotate(90deg); }
.tree details.sys > h3.scope, .tree details.sys > .scope-note { margin-left: 16px; margin-right: 16px; }
.tree details.blk, .tree a.leaf { margin: 0 16px; border-top: 1px solid var(--line); }
.tree details.blk > summary, .tree a.leaf { padding-left: 4px; padding-right: 4px; }
.tree details.blk > ul.list { margin: 4px 0 6px 18px; box-shadow: none; }
.blk-link { margin: 0 0 12px 22px; font-size: .9rem; }
.tree details.sys > :last-child { margin-bottom: 14px; }

/* ---- search ------------------------------------------------------------ */
.search { margin: 6px 0 18px; }
.search label { display: block; font-weight: 650; margin: 0 0 6px; }
.search input {
  display: block; width: 100%; padding: 13px 16px 13px 44px;
  font: inherit; font-size: 1.05rem; color: var(--ink);
  background: var(--panel) no-repeat 14px 50% / 20px
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23839aaa' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E");
  border: 1px solid var(--line); border-radius: 999px; box-shadow: var(--shadow);
  outline: none;
}
.search input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent); }
#browse h2 { margin-top: 8px; }
.more { margin: -6px 0 0; font-weight: 600; }
.more a { text-decoration: none; }

.derived {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; margin: 0 0 16px; box-shadow: var(--shadow);
}
.derived .hero h2 { font-size: 1.3rem; margin: 0; }
.derived section.where { box-shadow: none; margin: 18px 0 0; padding: 14px 0 0; border: 0; border-top: 1px solid var(--line); border-radius: 0; }
.derived section.where h3 { margin-top: 0; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; margin: 16px 0 0; }
.actions .quiet { font-weight: 500; }

/* ---- call to action, pager --------------------------------------------- */
.cta {
  display: grid; gap: 14px; align-items: center;
  margin: 28px 0 16px; padding: 22px 22px; border-radius: 18px;
  background: linear-gradient(135deg, var(--tint), color-mix(in srgb, var(--tint) 40%, var(--panel)));
  border: 1px solid var(--line);
}
.cta h2 { margin: 0 0 6px; }
.cta p { margin: 0; color: var(--muted); }
.button {
  justify-self: start; display: inline-block; padding: 11px 20px; border-radius: 999px;
  background: var(--accent); color: var(--accent-ink); text-decoration: none; font-weight: 650;
  box-shadow: 0 2px 8px color-mix(in srgb, var(--accent) 30%, transparent);
}
.button:hover { filter: brightness(1.08); }
@media (min-width: 720px) {
  .cta { grid-template-columns: 1fr auto; }
}

.pager { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; margin-top: 18px; font-family: var(--mono); }
.pager a { text-decoration: none; }
.pager a[rel="next"] { justify-self: end; }

@media (max-width: 520px) {
  .bar { padding: 8px 12px; gap: 8px; }
  .brand span { display: none; }
  header.site nav { flex-wrap: nowrap; gap: 0; }
  header.site nav a { padding: 6px 9px; font-size: .9rem; }
  ul.list a, .tree summary, .tree a.leaf { grid-template-columns: 4.2rem minmax(0, 1fr) auto; gap: 10px; padding: 10px 12px; }
  ul.causes li { grid-template-columns: 1fr; gap: 4px; }
  ul.list.systems a, .tree summary.systems { grid-template-columns: 1.6rem minmax(0, 1fr); row-gap: 6px; }
  ul.list.systems .meta, .tree summary.systems .meta { grid-column: 2; }
  section.block, section.where, .derived { padding: 16px; }
  .level + .level { margin-left: 8px; }
  .level + .level + .level { margin-left: 16px; }
}
