/* ============================================================
   Gas Leak SVM — project defence & interview prep
   M.S. Mathematics (Applied), University of Chittagong

   Teal for the "no gas" side of the margin, burnt orange for the
   "gas present" side, on cool paper.
   ============================================================ */

:root {
  /* neutrals — blue-biased, never pure grey */
  --bg:          #F2F3F8;
  --surface:     #FFFFFF;
  --surface-2:   #E8EAF3;
  --text:        #161A2C;
  --text-dim:    #545B72;
  --text-faint:  #7B8199;
  --border:      #D5D8E6;
  --border-soft: #E4E7F1;

  /* accents — the two solution branches */
  --accent:       #0F766E;   /* U_tau branch / indigo */
  --accent-soft:  #E2F3F0;
  --accent-2:     #C2410C;   /* U_upsilon branch / red */
  --accent-2-soft:#FCEDE3;

  /* semantic */
  --warn:        #8A5A06;
  --warn-soft:   #FAF0DC;
  --risk:        #A32A2A;
  --risk-soft:   #FAE9E9;

  --shadow: 0 1px 2px rgba(22,26,44,.05), 0 4px 16px rgba(22,26,44,.05);
  --shadow-lg: 0 2px 6px rgba(22,26,44,.07), 0 12px 40px rgba(22,26,44,.09);

  --sans: "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --serif: "IBM Plex Serif", ui-serif, Georgia, "Times New Roman", serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;

  --fs-xs:   .75rem;
  --fs-sm:   .8125rem;
  --fs-ms:   .9375rem;
  --fs-base: 1.0625rem;
  --fs-lg:   1.1875rem;
  --fs-xl:   1.4375rem;
  --fs-2xl:  1.875rem;
  --fs-3xl:  2.5rem;

  --sp-1: .25rem; --sp-2: .5rem;  --sp-3: .75rem; --sp-4: 1rem;
  --sp-5: 1.5rem; --sp-6: 2rem;   --sp-7: 3rem;   --sp-8: 4rem;

  --radius: 10px;
  --radius-sm: 6px;
  --sidebar-w: 300px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:          #0B0E18;
    --surface:     #141827;
    --surface-2:   #1C2133;
    --text:        #E5E8F2;
    --text-dim:    #9AA1BA;
    --text-faint:  #737A94;
    --border:      #272D42;
    --border-soft: #1F2436;

    --accent:       #5FD3C1;
    --accent-soft:  #10302C;
    --accent-2:     #F5A06B;
    --accent-2-soft:#3A2416;

    --warn:        #DFA65B;
    --warn-soft:   #2C2212;
    --risk:        #E8807E;
    --risk-soft:   #331A1A;

    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.3);
    --shadow-lg: 0 2px 6px rgba(0,0,0,.45), 0 12px 40px rgba(0,0,0,.4);
  }
}

/* explicit toggle must beat the media query in BOTH directions */
:root[data-theme="dark"] {
  --bg:#0B0E18; --surface:#141827; --surface-2:#1C2133;
  --text:#E5E8F2; --text-dim:#9AA1BA; --text-faint:#737A94;
  --border:#272D42; --border-soft:#1F2436;
  --accent:#5FD3C1; --accent-soft:#10302C;
  --accent-2:#F5A06B; --accent-2-soft:#3A2416;
  --warn:#DFA65B; --warn-soft:#2C2212;
  --risk:#E8807E; --risk-soft:#331A1A;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.3);
  --shadow-lg: 0 2px 6px rgba(0,0,0,.45), 0 12px 40px rgba(0,0,0,.4);
}
:root[data-theme="light"] {
  --bg:#F2F3F8; --surface:#FFFFFF; --surface-2:#E8EAF3;
  --text:#161A2C; --text-dim:#545B72; --text-faint:#7B8199;
  --border:#D5D8E6; --border-soft:#E4E7F1;
  --accent:#0F766E; --accent-soft:#E2F3F0;
  --accent-2:#C2410C; --accent-2-soft:#FCEDE3;
  --warn:#8A5A06; --warn-soft:#FAF0DC;
  --risk:#A32A2A; --risk-soft:#FAE9E9;
  --shadow: 0 1px 2px rgba(22,26,44,.05), 0 4px 16px rgba(22,26,44,.05);
  --shadow-lg: 0 2px 6px rgba(22,26,44,.07), 0 12px 40px rgba(22,26,44,.09);
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 1.5rem; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration:.01ms !important; transition-duration:.01ms !important; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: var(--fs-base);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

/* ---------- skip link ---------- */
.skip {
  position: absolute; left: -9999px; top: 0; z-index: 200;
  background: var(--accent); color: var(--surface); padding: .6rem 1rem;
  border-radius: 0 0 var(--radius-sm) 0; font-size: var(--fs-sm); font-weight: 600;
}
.skip:focus { left: 0; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0,1fr); min-height: 100vh; }
@media (max-width: 1023px) { .shell { grid-template-columns: 1fr; } }

/* ---------- sidebar ---------- */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  padding: var(--sp-5) var(--sp-4) var(--sp-6);
  display: flex; flex-direction: column; gap: var(--sp-4);
}
.brand { display: flex; flex-direction: column; gap: .3rem; text-decoration: none; color: inherit; margin-bottom: var(--sp-2); }
.brand-sub {
  font-family: var(--mono); font-size: var(--fs-xs); color: var(--accent);
  text-transform: uppercase; letter-spacing: .1em;
}
.brand-name { font-family: var(--serif); font-weight: 700; font-size: 1.0625rem; letter-spacing: -.01em; line-height: 1.25; }

.navgroup { display: flex; flex-direction: column; gap: .12rem; }
.navlabel {
  font-family: var(--mono); font-size: var(--fs-xs); color: var(--text-faint);
  text-transform: uppercase; letter-spacing: .12em; padding: .3rem .55rem; margin: var(--sp-3) 0 .3rem;
  background: none; border: 0; text-align: left; cursor: pointer; width: 100%;
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
}
.navlabel .fold { transition: transform .15s ease; font-size: .9em; }
.navgroup.is-folded .navlabel .fold { transform: rotate(-90deg); }
.navgroup.is-folded .navlink { display: none; }
.navlink {
  display: flex; align-items: baseline; gap: .55rem;
  padding: .4rem .55rem; border-radius: var(--radius-sm);
  color: var(--text-dim); text-decoration: none; font-size: var(--fs-ms); line-height: 1.4;
  border-left: 2px solid transparent; transition: background .12s, color .12s;
}
.navlink:hover { background: var(--surface-2); color: var(--text); }
.navlink .n { font-family: var(--mono); font-size: var(--fs-xs); color: var(--text-faint); flex: none; }
.navlink[aria-current="page"] {
  background: var(--accent-soft); color: var(--accent);
  font-weight: 600; border-left-color: var(--accent);
}
.navlink[aria-current="page"] .n { color: var(--accent); }

.sidebar-foot {
  margin-top: auto; padding-top: var(--sp-4); border-top: 1px solid var(--border-soft);
  display: flex; flex-wrap: wrap; gap: .4rem;
}

/* ---------- collapsing the whole rail (desktop only) ----------
   On narrow screens the sidebar is already a drawer, so the collapse
   rules must not apply there or the drawer would be display:none. */
/* .btn also sets display, at equal specificity and later in the file, so these
   rules are written as .btn.navshow to win regardless of source order. */
.btn.navshow {
  display: none;
  position: fixed; left: 1rem; bottom: 1rem; z-index: 70;
  box-shadow: var(--shadow-lg); background: var(--surface);
}
@media (min-width: 1024px) {
  :root[data-nav="collapsed"] .shell { grid-template-columns: minmax(0, 1fr); }
  :root[data-nav="collapsed"] .sidebar { display: none; }
  :root[data-nav="collapsed"] .btn.navshow { display: inline-flex; }
}

/* ---------- mobile topbar ---------- */
.topbar {
  display: none; position: sticky; top: 0; z-index: 50;
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: .7rem 1rem; align-items: center; justify-content: space-between; gap: 1rem;
}
.topbar-title { font-family: var(--serif); font-weight: 600; font-size: var(--fs-ms); }
@media (max-width: 1023px) {
  .topbar { display: flex; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: min(88vw, 320px); z-index: 60;
    transform: translateX(-100%); transition: transform .22s ease; box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: none; }
  .scrim { position: fixed; inset: 0; background: rgba(8,10,18,.5); z-index: 55; }
}

/* ---------- buttons ---------- */
.btn {
  font-family: var(--sans); font-size: var(--fs-sm); font-weight: 600;
  color: var(--text-dim); background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: .4rem .7rem; cursor: pointer;
  display: inline-flex; align-items: center; gap: .4rem; line-height: 1.3;
  transition: background .12s, color .12s, border-color .12s;
}
.btn:hover { background: var(--surface-2); color: var(--text); }
.btn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--surface); }
.btn:disabled { opacity: .55; cursor: progress; }

:where(a, button, input, textarea, select, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px;
}

/* ---------- main ---------- */
.main { padding: var(--sp-7) var(--sp-6) var(--sp-8); display: flex; justify-content: center; }
@media (max-width: 1023px) { .main { padding: var(--sp-5) var(--sp-4) var(--sp-8); } }
.col { width: 100%; max-width: 78ch; }
.col-wide { max-width: 100ch; }

/* ---------- page head ---------- */
.eyebrow {
  font-family: var(--mono); font-size: var(--fs-xs); color: var(--accent);
  text-transform: uppercase; letter-spacing: .13em; margin: 0 0 .6rem;
  display: flex; align-items: center; gap: .55rem;
}
.eyebrow::after { content: ""; flex: 1; height: 1px; background: var(--border); }

h1 {
  font-family: var(--serif); font-weight: 700; font-size: var(--fs-3xl);
  line-height: 1.12; letter-spacing: -.022em; margin: 0 0 var(--sp-4);
  text-wrap: balance;
}
@media (max-width: 640px) { h1 { font-size: 2rem; } }

.lede { font-size: var(--fs-lg); line-height: 1.6; color: var(--text-dim); margin: 0 0 var(--sp-6); text-wrap: pretty; }

h2 {
  font-family: var(--serif); font-weight: 600; font-size: var(--fs-2xl);
  line-height: 1.22; letter-spacing: -.015em; margin: var(--sp-7) 0 var(--sp-4);
  text-wrap: balance; scroll-margin-top: 1.5rem;
}
h3 {
  font-family: var(--serif); font-weight: 600; font-size: var(--fs-xl);
  line-height: 1.3; margin: var(--sp-6) 0 var(--sp-3); text-wrap: balance;
  scroll-margin-top: 1.5rem;
}
h4 {
  font-family: var(--sans); font-weight: 700; font-size: var(--fs-base);
  margin: var(--sp-5) 0 var(--sp-2); letter-spacing: -.005em;
}
p { margin: 0 0 var(--sp-4); text-wrap: pretty; }

a { color: var(--accent); text-underline-offset: 2px; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }

strong { font-weight: 600; color: var(--text); }

ul, ol { margin: 0 0 var(--sp-4); padding-left: 1.35rem; display: flex; flex-direction: column; gap: .45rem; }
li { padding-left: .15rem; }
li::marker { color: var(--text-faint); }
ol li::marker { font-family: var(--mono); font-size: .9em; }

hr { border: 0; border-top: 1px solid var(--border); margin: var(--sp-7) 0; }

code {
  font-family: var(--mono); font-size: .875em;
  background: var(--surface-2); padding: .12em .38em; border-radius: 4px;
  border: 1px solid var(--border-soft);
}

/* ---------- equation block ---------- */
.eq {
  font-family: var(--mono); font-size: var(--fs-ms); line-height: 1.95;
  background: var(--surface); border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm); padding: var(--sp-4) var(--sp-5);
  margin: 0 0 var(--sp-4); overflow-x: auto;
  display: flex; justify-content: space-between; align-items: center; gap: var(--sp-5);
}
.eq > div:first-child { white-space: pre; }
.eq .num { font-size: var(--fs-sm); color: var(--text-faint); flex: none; }
.eq.eq-2 { border-left-color: var(--accent-2); }
.eq.plain { display: block; }
.eq-note { font-size: var(--fs-sm); color: var(--text-dim); margin: -.6rem 0 var(--sp-4); padding-left: .2rem; }

/* ---------- callouts ---------- */
.note {
  border-radius: var(--radius-sm); padding: var(--sp-4) var(--sp-5);
  margin: 0 0 var(--sp-4); border: 1px solid var(--border);
  background: var(--surface); font-size: var(--fs-ms); line-height: 1.65;
}
.note > :last-child { margin-bottom: 0; }
.note-title {
  font-family: var(--mono); font-size: var(--fs-xs); text-transform: uppercase;
  letter-spacing: .1em; margin: 0 0 .5rem; font-weight: 600;
}
.note.good  { background: var(--accent-soft);  border-color: color-mix(in srgb, var(--accent) 28%, transparent); }
.note.good .note-title { color: var(--accent); }
.note.info  { background: var(--accent-2-soft); border-color: color-mix(in srgb, var(--accent-2) 28%, transparent); }
.note.info .note-title { color: var(--accent-2); }
.note.warn  { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 32%, transparent); }
.note.warn .note-title { color: var(--warn); }
.note.risk  { background: var(--risk-soft); border-color: color-mix(in srgb, var(--risk) 32%, transparent); }
.note.risk .note-title { color: var(--risk); }

/* say-this box — verbatim lines to rehearse aloud */
.say {
  border: 1px solid var(--border); border-left: 3px solid var(--accent-2);
  background: var(--surface); border-radius: var(--radius-sm);
  padding: var(--sp-4) var(--sp-5); margin: 0 0 var(--sp-4);
}
.say-label {
  font-family: var(--mono); font-size: var(--fs-xs); text-transform: uppercase;
  letter-spacing: .1em; color: var(--accent-2); font-weight: 600; margin-bottom: .5rem;
}
.say p { font-family: var(--serif); font-size: var(--fs-base); line-height: 1.65; font-style: italic; margin-bottom: .6rem; }
.say p:last-child { margin-bottom: 0; }

/* ---------- "in plain words" ----------
   The read-this-first block at the top of every page: the same idea as the
   section below it, said without jargon. Deliberately warmer and wider-set
   than body text so the eye lands on it before the mathematics. */
.plain {
  background: var(--surface);
  border: 1px solid color-mix(in srgb, var(--accent-2) 26%, var(--border));
  border-left: 3px solid var(--accent-2);
  border-radius: var(--radius);
  padding: var(--sp-5);
  margin: 0 0 var(--sp-6);
  box-shadow: var(--shadow);
}
.plain-label {
  font-family: var(--mono); font-size: var(--fs-xs); font-weight: 600;
  text-transform: uppercase; letter-spacing: .12em; color: var(--accent-2);
  margin: 0 0 var(--sp-3); display: flex; align-items: center; gap: .55rem;
}
.plain-label::after { content: ""; flex: 1; height: 1px; background: color-mix(in srgb, var(--accent-2) 25%, transparent); }
.plain p { font-size: var(--fs-base); line-height: 1.78; margin-bottom: var(--sp-4); }
.plain > :last-child { margin-bottom: 0; }
.plain h3 {
  font-family: var(--sans); font-weight: 700; font-size: var(--fs-ms);
  letter-spacing: .01em; margin: var(--sp-5) 0 var(--sp-2); color: var(--text);
}
.plain ul, .plain ol { margin-bottom: var(--sp-4); }
.plain li { line-height: 1.7; }
.plain .aside {
  font-size: var(--fs-sm); color: var(--text-dim); line-height: 1.65;
  border-top: 1px dashed color-mix(in srgb, var(--accent-2) 30%, transparent);
  padding-top: var(--sp-3); margin-top: var(--sp-4);
}

/* ---------- cards & grids ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: var(--sp-5); box-shadow: var(--shadow);
}
.grid { display: grid; gap: var(--sp-4); margin-bottom: var(--sp-4); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }

.stat { display: flex; flex-direction: column; gap: .2rem; }
.stat .k { font-family: var(--mono); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .1em; color: var(--text-faint); }
.stat .v { font-family: var(--serif); font-size: var(--fs-lg); font-weight: 600; line-height: 1.3; }

/* ---------- tables ---------- */
.tw { overflow-x: auto; margin: 0 0 var(--sp-5); border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: var(--fs-ms); }
th, td { text-align: left; padding: .7rem .85rem; border-bottom: 1px solid var(--border-soft); vertical-align: top; line-height: 1.55; }
th {
  font-family: var(--mono); font-size: var(--fs-xs); text-transform: uppercase;
  letter-spacing: .09em; color: var(--text-dim); font-weight: 600;
  background: var(--surface-2); border-bottom: 1px solid var(--border);
}
tbody tr:last-child td { border-bottom: 0; }
.num-col { font-variant-numeric: tabular-nums; }

/* ---------- Q&A ---------- */
.qa-toolbar {
  display: flex; flex-wrap: wrap; gap: var(--sp-3); align-items: center;
  padding: var(--sp-4); background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); margin-bottom: var(--sp-5); position: sticky; top: 0; z-index: 20;
  box-shadow: var(--shadow);
}
@media (max-width: 1023px) { .qa-toolbar { top: 56px; } }
.search {
  flex: 1 1 200px; min-width: 0;
  font-family: var(--sans); font-size: var(--fs-ms); color: var(--text);
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: .45rem .7rem;
}
.search::placeholder { color: var(--text-faint); }
.counter { font-family: var(--mono); font-size: var(--fs-xs); color: var(--text-faint); font-variant-numeric: tabular-nums; }

.qa {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); margin-bottom: var(--sp-4);
  box-shadow: var(--shadow); overflow: hidden;
}
.qa[data-done="1"] { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.qa-head {
  display: flex; gap: var(--sp-3); align-items: flex-start;
  padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--border-soft);
  background: linear-gradient(to bottom, var(--surface-2), var(--surface));
}
.qa-id {
  font-family: var(--mono); font-size: var(--fs-xs); font-weight: 600;
  color: var(--accent); background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-radius: 4px; padding: .18rem .42rem; flex: none; margin-top: .22rem;
  letter-spacing: .04em;
}
.qa-q {
  font-family: var(--serif); font-weight: 600; font-size: var(--fs-lg);
  line-height: 1.4; margin: 0; flex: 1; letter-spacing: -.008em; text-wrap: pretty;
}
.qa-done { flex: none; margin-top: .3rem; width: 1.05rem; height: 1.05rem; accent-color: var(--accent); cursor: pointer; }
.qa-body { padding: var(--sp-4) var(--sp-5) var(--sp-5); }
.qa-body > :last-child { margin-bottom: 0; }
.qa-short {
  font-weight: 600; color: var(--text); margin-bottom: var(--sp-4);
  padding-left: .85rem; border-left: 3px solid var(--accent); line-height: 1.6;
}
.qa-tags { display: flex; flex-wrap: wrap; gap: .35rem; padding: 0 var(--sp-5) var(--sp-4); }
.tag {
  font-family: var(--mono); font-size: var(--fs-xs); letter-spacing: .04em;
  color: var(--text-dim); background: var(--surface-2);
  border: 1px solid var(--border-soft); border-radius: 999px; padding: .1rem .5rem;
}

body.quiz .qa-body { display: none; }
body.quiz .qa.revealed .qa-body { display: block; }
body.quiz .qa-head { cursor: pointer; }
body.quiz .qa-head::after {
  content: "reveal"; font-family: var(--mono); font-size: var(--fs-xs);
  color: var(--text-faint); flex: none; align-self: center; letter-spacing: .06em;
}
body.quiz .qa.revealed .qa-head::after { content: ""; }
.qa.hidden { display: none; }

.qa-sec > :first-child { margin-top: var(--sp-7); }
.qa-sec p { font-size: var(--fs-ms); color: var(--text-dim); }

/* ---------- steps ---------- */
.steps { list-style: none; padding: 0; margin: 0 0 var(--sp-5); display: flex; flex-direction: column; gap: var(--sp-5); counter-reset: s; }
.steps > li { counter-increment: s; position: relative; padding-left: 3.1rem; }
.steps > li::before {
  content: counter(s, decimal-leading-zero);
  position: absolute; left: 0; top: .12rem;
  font-family: var(--mono); font-size: var(--fs-xs); font-weight: 600;
  color: var(--accent); background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-radius: 4px; padding: .2rem .45rem; letter-spacing: .04em;
}
.steps h4 { margin-top: 0; }

/* ---------- jump nav ---------- */
.jump {
  display: flex; flex-wrap: wrap; gap: .4rem; margin: 0 0 var(--sp-6);
  padding-bottom: var(--sp-5); border-bottom: 1px solid var(--border);
}
.jump a {
  font-family: var(--mono); font-size: var(--fs-xs); text-decoration: none;
  color: var(--text-dim); background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; padding: .25rem .7rem; letter-spacing: .03em;
  transition: background .12s, color .12s, border-color .12s;
}
.jump a:hover { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }

/* ---------- page footer nav ---------- */
.pagenav {
  display: flex; gap: var(--sp-4); justify-content: space-between;
  margin-top: var(--sp-8); padding-top: var(--sp-5); border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
.pagenav a {
  text-decoration: none; color: var(--text); flex: 1 1 200px;
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: var(--sp-4); background: var(--surface);
  display: flex; flex-direction: column; gap: .2rem; transition: border-color .12s, background .12s;
}
.pagenav a:hover { border-color: var(--accent); background: var(--accent-soft); }
.pagenav .dir { font-family: var(--mono); font-size: var(--fs-xs); color: var(--text-faint); text-transform: uppercase; letter-spacing: .1em; }
.pagenav .ttl { font-family: var(--serif); font-weight: 600; font-size: var(--fs-base); }
.pagenav .next { text-align: right; align-items: flex-end; }

/* ---------- misc ---------- */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .5rem var(--sp-4); font-size: var(--fs-ms); margin-bottom: var(--sp-4); }
.kv dt { font-family: var(--mono); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .08em; color: var(--text-faint); padding-top: .18rem; }
.kv dd { margin: 0; }

.pill {
  display: inline-flex; align-items: center; gap: .3rem;
  font-family: var(--mono); font-size: var(--fs-xs); font-weight: 600;
  border-radius: 999px; padding: .15rem .55rem; letter-spacing: .04em;
}
.pill.yes  { background: var(--accent-soft); color: var(--accent); }
.pill.no   { background: var(--risk-soft); color: var(--risk); }
.pill.part { background: var(--warn-soft); color: var(--warn); }

.footnote { font-size: var(--fs-sm); color: var(--text-dim); line-height: 1.6; }

/* ---------- report figures ----------
   Maple exported these on white; keeping the plate white in dark mode is
   deliberate — inverting a scientific figure changes what it says. */
.fig {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: var(--sp-4);
  margin: 0 0 var(--sp-5); box-shadow: var(--shadow);
}
.fig img {
  width: 100%; height: auto; display: block;
  background: #fff; border-radius: var(--radius-sm);
}
.fig figcaption { font-size: var(--fs-sm); color: var(--text-dim); margin-top: var(--sp-3); line-height: 1.6; }
.fig .fig-n {
  font-family: var(--mono); font-size: var(--fs-xs); color: var(--accent);
  text-transform: uppercase; letter-spacing: .1em; font-weight: 600;
  display: block; margin-bottom: .25rem;
}
.fig-pair { display: grid; gap: var(--sp-4); grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.fig-pair .fig { margin-bottom: 0; }

/* ---------- hero canvas ---------- */
.hero {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: var(--sp-5); margin-bottom: var(--sp-6);
  box-shadow: var(--shadow);
}
.hero canvas { width: 100%; height: 170px; display: block; }
.hero-cap {
  font-family: var(--mono); font-size: var(--fs-xs); color: var(--text-faint);
  margin-top: .7rem; letter-spacing: .03em; line-height: 1.6;
}

/* ============================================================
   Python runner
   ============================================================ */
.runner {
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow);
  margin: 0 0 var(--sp-5); overflow: hidden;
}
.runner-head {
  display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap;
  padding: .6rem var(--sp-4); border-bottom: 1px solid var(--border-soft);
  background: var(--surface-2);
}
.runner-title {
  font-family: var(--mono); font-size: var(--fs-xs); text-transform: uppercase;
  letter-spacing: .1em; color: var(--text-dim); font-weight: 600; flex: 1; min-width: 0;
}
.btn-run { background: var(--accent); border-color: var(--accent); color: var(--surface); }
.btn-run:hover:not(:disabled) { background: var(--accent); color: var(--surface); filter: brightness(1.08); }

.editor {
  display: block; width: 100%; border: 0; resize: vertical;
  font-family: var(--mono); font-size: var(--fs-sm); line-height: 1.65;
  padding: var(--sp-4); background: var(--surface); color: var(--text);
  tab-size: 4; min-height: 6rem; overflow: hidden;
}
.editor:focus { outline: 0; box-shadow: inset 3px 0 0 var(--accent); }

.out {
  font-family: var(--mono); font-size: var(--fs-sm); line-height: 1.65;
  white-space: pre-wrap; word-break: break-word;
  padding: var(--sp-4); margin: 0; border-top: 1px solid var(--border-soft);
  background: var(--bg); color: var(--text-dim); min-height: 1rem;
}
.out:empty { display: none; }
.out.is-wait { color: var(--text-faint); font-style: italic; }
.out.is-err  { color: var(--risk); background: var(--risk-soft); }
.hint-fix {
  display: block; margin-top: .8rem; padding-top: .8rem;
  border-top: 1px dashed color-mix(in srgb, var(--risk) 40%, transparent);
  color: var(--text-dim); font-style: normal; white-space: pre-wrap;
}
.figs { display: flex; flex-direction: column; gap: var(--sp-3); padding: 0; }
.figs:not(:empty) { padding: var(--sp-4); border-top: 1px solid var(--border-soft); background: var(--bg); }
.figs img { max-width: 100%; height: auto; display: block; border-radius: var(--radius-sm); }

.chip {
  font-family: var(--mono); font-size: var(--fs-xs); font-weight: 600;
  border-radius: 999px; padding: .15rem .6rem; letter-spacing: .04em;
  background: var(--surface-2); color: var(--text-dim); border: 1px solid var(--border-soft);
}
.chip-accent { background: var(--accent-soft); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.chip-2 { background: var(--accent-2-soft); color: var(--accent-2); border-color: color-mix(in srgb, var(--accent-2) 30%, transparent); }
.chip-warn { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }

/* ============================================================
   Additions for the Gas Leak SVM site
   ============================================================ */

/* report downloads under the brand in the sidebar */
.dl-row { display: flex; gap: .5rem; margin: -.25rem 0 var(--sp-5); }
.dl-row .btn { flex: 1; justify-content: center; text-decoration: none; }

/* download cards on the start page */
.downloads { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-4); margin: 0 0 var(--sp-6); }
.downloads a {
  display: block; text-decoration: none; color: inherit;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: var(--sp-4) var(--sp-5); box-shadow: var(--shadow);
}
.downloads a:hover { border-color: var(--accent); }
.downloads .k { display: block; font-family: var(--mono); font-size: var(--fs-xs); letter-spacing: .08em;
  text-transform: uppercase; color: var(--accent); font-weight: 600; margin-bottom: .25rem; }
.downloads .v { display: block; font-weight: 600; }
.downloads .d { display: block; font-size: var(--fs-sm); color: var(--text-dim); margin-top: .2rem; }

/* display mathematics (KaTeX) with an equation number on the right */
.math {
  display: flex; align-items: center; gap: var(--sp-4);
  background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm); padding: .35rem var(--sp-4); margin: 0 0 var(--sp-4);
  overflow-x: auto;
}
.math > div { flex: 1; min-width: 0; }
.math .num { font-size: var(--fs-sm); color: var(--text-faint); flex: none; font-family: var(--mono); }
.math.m2 { border-left-color: var(--accent-2); }
.katex { font-size: 1.08em; }
.katex-display { margin: .45rem 0; overflow-x: auto; overflow-y: hidden; padding: .1rem 0; }

/* term definitions */
.terms { margin: 0 0 var(--sp-5); }
.term { border-bottom: 1px solid var(--border-soft); padding: var(--sp-3) 0; }
.term:last-child { border-bottom: 0; }
.term dt { font-weight: 600; color: var(--text); }
.term dt .sym { font-family: var(--mono); font-size: var(--fs-sm); color: var(--accent); font-weight: 500; margin-left: .4rem; }
.term dd { margin: .2rem 0 0; color: var(--text-dim); font-size: var(--fs-ms); line-height: 1.6; }
@media (max-width: 560px) { .downloads { grid-template-columns: 1fr; } }
