/* ==========================================================================
   Investing Course — stylesheet
   No external fonts, no CDN, no icon packs. Everything here works offline.
   Dark theme is the default; light theme is opt-in via data-theme="light".
   ========================================================================== */

:root {
  --bg:            #0f1216;
  --bg-soft:       #151a21;
  --panel:         #161b23;
  --panel-2:       #1b212b;
  --line:          #262e3a;
  --line-soft:     #1f2630;
  --text:          #e6e9ef;
  --text-strong:   #f6f8fb;
  --muted:         #9aa6ba;
  --muted-2:       #77839a;
  --accent:        #7fb2ff;
  --accent-soft:   #1d2b44;
  --accent-text:   #0f1216;
  --good:          #6fd08c;
  --good-soft:     #17301f;
  --warn:          #f0b45f;
  --warn-soft:     #33260f;
  --danger:        #ff8a8a;
  --danger-soft:   #3a1d1f;
  --mm:            #c3a8ff;
  --mm-soft:       #251e3b;
  --applied:       #6fd8d0;
  --applied-soft:  #103030;
  --shadow:        0 10px 30px rgba(0,0,0,.45);
  --radius:        10px;
  --radius-sm:     7px;
  --maxread:       70ch;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

html[data-theme="light"] {
  --bg:            #fbfaf7;
  --bg-soft:       #f3f1ec;
  --panel:         #ffffff;
  --panel-2:       #f6f5f1;
  --line:          #ddd9d0;
  --line-soft:     #e8e5de;
  --text:          #23262c;
  --text-strong:   #14171c;
  --muted:         #5d6674;
  --muted-2:       #77809020;
  --muted-2:       #6e7787;
  --accent:        #1d5fd0;
  --accent-soft:   #e3ecfb;
  --accent-text:   #ffffff;
  --good:          #1e7d4c;
  --good-soft:     #e2f3e8;
  --warn:          #8a5a08;
  --warn-soft:     #fbf0d9;
  --danger:        #a32a2a;
  --danger-soft:   #fae3e3;
  --mm:            #5b3fb0;
  --mm-soft:       #ece7fb;
  --applied:       #0c6b66;
  --applied-soft:  #dcf1f0;
  --shadow:        0 8px 24px rgba(20,23,28,.12);
}

* { box-sizing: border-box; }

/* The hidden attribute must win over any display rule below. */
[hidden] { display: none !important; }

/* min-height, not height: a sticky element is constrained by its containing
   block, so a body fixed at 100% would let the top bar and sidebar scroll
   away as soon as the page is taller than one viewport. */
html, body { min-height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16.5px;
  line-height: 1.65;
  -webkit-text-size-adjust: 100%;
}

/* ------------------------------ utilities ------------------------------- */

.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;
}

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 200;
  background: var(--accent); color: var(--accent-text);
  padding: 10px 16px; border-radius: 0 0 var(--radius-sm) 0; font-weight: 600;
}
.skip-link:focus { left: 0; }

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

a { color: var(--accent); text-decoration-color: color-mix(in srgb, var(--accent) 45%, transparent); }
a:hover { text-decoration-color: currentColor; }

/* ------------------------------- topbar --------------------------------- */

.topbar {
  position: sticky; top: 0; z-index: 60;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex; align-items: center; gap: 9px;
  font-weight: 700; letter-spacing: .01em;
  color: var(--text-strong); text-decoration: none; white-space: nowrap;
}
.brand-mark {
  display: inline-grid; place-items: center;
  width: 26px; height: 26px; border-radius: 7px;
  background: var(--accent); color: var(--accent-text);
  font-size: 15px; font-weight: 800;
}

.topbar-search { position: relative; flex: 1 1 auto; max-width: 460px; margin-left: auto; }
.topbar-search input {
  width: 100%; padding: 8px 12px;
  background: var(--panel); color: var(--text);
  border: 1px solid var(--line); border-radius: 999px;
  font: inherit; font-size: 15px;
}
.topbar-search input::placeholder { color: var(--muted-2); }

.q-results {
  position: absolute; top: calc(100% + 8px); left: 0; right: 0;
  max-height: min(70vh, 560px); overflow-y: auto;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); z-index: 90;
}
.q-empty { padding: 16px; color: var(--muted); font-size: 14.5px; }
.q-group { padding: 8px 14px 4px; font-size: 11.5px; letter-spacing: .09em;
  text-transform: uppercase; color: var(--muted-2); font-weight: 700; }
.q-item {
  display: block; padding: 9px 14px; border: 0; width: 100%; text-align: left;
  background: none; color: var(--text); font: inherit; cursor: pointer;
  border-top: 1px solid var(--line-soft); text-decoration: none;
}
.q-item:hover, .q-item.is-active { background: var(--accent-soft); }
.q-item strong { display: block; font-weight: 600; font-size: 15px; }
.q-item span { display: block; color: var(--muted); font-size: 13px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.q-item mark { background: color-mix(in srgb, var(--accent) 35%, transparent); color: inherit; border-radius: 3px; }

.topbar-links { display: flex; gap: 14px; font-size: 14.5px; }
.topbar-links a { color: var(--muted); text-decoration: none; white-space: nowrap; }
.topbar-links a:hover { color: var(--text); }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 36px; height: 36px; flex: 0 0 auto;
  background: var(--panel); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  cursor: pointer; font-size: 17px;
}
.icon-btn:hover { background: var(--panel-2); }
.menu-only { display: none; }

.bars, .bars::before, .bars::after {
  display: block; width: 16px; height: 2px; background: currentColor; border-radius: 2px;
}
.bars { position: relative; }
.bars::before, .bars::after { content: ""; position: absolute; left: 0; }
.bars::before { top: -5px; }
.bars::after  { top: 5px; }

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

.layout { display: flex; align-items: flex-start; min-height: calc(100vh - 57px); }

.sidebar {
  position: sticky; top: 57px;
  flex: 0 0 300px; width: 300px;
  height: calc(100vh - 57px); overflow-y: auto;
  border-right: 1px solid var(--line);
  background: var(--bg-soft);
  padding-bottom: 40px;
}

.sidebar-head { padding: 16px 16px 12px; border-bottom: 1px solid var(--line); }
.sidebar-title { font-size: 11.5px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted-2); font-weight: 700; margin-bottom: 10px; }
.sidebar-progress-text { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.sidebar-actions { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.mini-link {
  font-size: 13px; text-decoration: none; color: var(--muted);
  border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px;
}
.mini-link:hover { color: var(--text); border-color: var(--muted-2); }

.bar { height: 7px; background: var(--panel-2); border-radius: 999px; overflow: hidden; border: 1px solid var(--line-soft); }
.bar-thin { height: 5px; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 999px; transition: width .25s ease; }

.toc { padding: 10px 8px 0; }

.toc-stage { margin: 4px 0 14px; }
.toc-stage-head {
  padding: 6px 8px; font-size: 11.5px; letter-spacing: .09em; text-transform: uppercase;
  color: var(--muted-2); font-weight: 700;
}
.toc-module { margin: 2px 0; }
.toc-module-btn {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 7px 8px; background: none; border: 0; border-radius: var(--radius-sm);
  color: var(--text); font: inherit; font-size: 14.5px; font-weight: 600;
  text-align: left; cursor: pointer;
}
.toc-module-btn:hover { background: var(--panel); }
.toc-module-btn .caret { flex: 0 0 auto; color: var(--muted-2); font-size: 11px; transition: transform .15s ease; }
.toc-module.open > .toc-module-btn .caret { transform: rotate(90deg); }
.toc-module-count { margin-left: auto; font-size: 11.5px; color: var(--muted-2); font-weight: 600; }
.toc-sections { display: none; margin: 2px 0 6px; padding-left: 6px; border-left: 1px solid var(--line); }
.toc-module.open > .toc-sections { display: block; }

.toc-link {
  display: flex; gap: 8px; align-items: baseline;
  padding: 5px 8px 5px 10px; border-radius: var(--radius-sm);
  color: var(--muted); text-decoration: none; font-size: 14px; line-height: 1.4;
}
.toc-link:hover { background: var(--panel); color: var(--text); }
.toc-link.is-current { background: var(--accent-soft); color: var(--text-strong); font-weight: 600; }
.toc-link .tick { flex: 0 0 14px; font-size: 11px; color: var(--muted-2); }
.toc-link.is-done .tick { color: var(--good); }
.toc-link .flag { color: var(--warn); font-size: 11px; }

/* --------------------------------- main --------------------------------- */

.main { flex: 1 1 auto; min-width: 0; }
.main:focus { outline: none; }
.view { padding: 28px 32px 120px; max-width: 980px; margin: 0 auto; }

.breadcrumb { font-size: 13px; color: var(--muted-2); margin-bottom: 10px; }
.breadcrumb a { color: var(--muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--text); }
.breadcrumb .sep { padding: 0 6px; opacity: .6; }

h1, h2, h3, h4 { color: var(--text-strong); line-height: 1.25; }
h1 { font-size: 30px; margin: 4px 0 6px; letter-spacing: -.015em; }
h2 { font-size: 21px; margin: 32px 0 10px; }
h3 { font-size: 17px; margin: 24px 0 8px; }

.lesson { max-width: var(--maxread); }
.lesson p, .lesson ul, .lesson ol, .lesson table, .lesson .fig { margin: 0 0 15px; }
.lesson ul, .lesson ol { padding-left: 22px; }
.lesson li { margin: 4px 0; }
.lesson li > ul, .lesson li > ol { margin: 4px 0; }
.lesson strong { color: var(--text-strong); }
.lesson code, code { font-family: var(--mono); font-size: .92em;
  background: var(--panel-2); border: 1px solid var(--line-soft);
  border-radius: 4px; padding: 1px 5px; }

.meta-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  color: var(--muted); font-size: 13px; margin: 0 0 22px; }
.pill { border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; font-size: 12.5px; }
.pill-done { color: var(--good); border-color: color-mix(in srgb, var(--good) 45%, var(--line)); background: var(--good-soft); }

/* content boxes */
.box { border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; margin: 0 0 18px; background: var(--panel); max-width: var(--maxread); }
.box > :last-child { margin-bottom: 0; }
.box-label { font-size: 11.5px; letter-spacing: .09em; text-transform: uppercase;
  font-weight: 700; margin-bottom: 6px; display: block; }

.box-why     { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 30%, var(--line)); }
.box-why .box-label { color: var(--accent); }
.box-example { background: var(--panel); }
.box-example .box-label { color: var(--muted-2); }
.box-mm      { background: var(--mm-soft); border-color: color-mix(in srgb, var(--mm) 30%, var(--line)); }
.box-mm .box-label { color: var(--mm); }
.box-warn    { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 30%, var(--line)); }
.box-warn .box-label { color: var(--warn); }
.box-applied { background: var(--applied-soft); border-color: color-mix(in srgb, var(--applied) 30%, var(--line)); }
.box-applied .box-label { color: var(--applied); }
.box-asof { font-size: 14px; }
.box-asof .box-label { color: var(--muted-2); }

.asof { display: inline-block; font-size: 12px; color: var(--muted-2);
  border: 1px dashed var(--line); border-radius: 999px; padding: 1px 8px; margin-left: 4px;
  white-space: nowrap; }

/* tables */
.lesson table, table.data {
  width: 100%; border-collapse: collapse; font-size: 14.5px;
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
}
th, td { padding: 8px 11px; text-align: left; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
thead th { background: var(--panel-2); font-size: 12.5px; letter-spacing: .04em;
  text-transform: uppercase; color: var(--muted); font-weight: 700; }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--mono); font-size: 13.5px; }
.table-wrap { overflow-x: auto; margin: 0 0 18px; max-width: 100%; }

/* glossary link inside lessons */
gl {
  border-bottom: 1px dashed color-mix(in srgb, var(--accent) 65%, transparent);
  cursor: help; color: inherit;
}
gl:hover { border-bottom-style: solid; color: var(--accent); }
gl:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* formula display */
.formula {
  font-family: var(--mono); font-size: 15px; background: var(--panel-2);
  border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm); padding: 12px 14px; margin: 0 0 15px;
  overflow-x: auto; white-space: pre-wrap; color: var(--text-strong);
}

/* simple bar figure */
.fig { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; background: var(--panel); }
.fig-title { font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.fig-row { display: grid; grid-template-columns: 110px 1fr 90px; gap: 10px; align-items: center; margin: 5px 0; font-size: 14px; }
.fig-label { color: var(--muted); }
.fig-track { background: var(--panel-2); border-radius: 4px; height: 18px; overflow: hidden; border: 1px solid var(--line-soft); }
.fig-bar { height: 100%; background: var(--accent); }
.fig-bar.alt { background: var(--mm); }
.fig-bar.good { background: var(--good); }
.fig-bar.warn { background: var(--warn); }
.fig-val { text-align: right; font-family: var(--mono); font-size: 13px; color: var(--text); }
.fig-note { font-size: 12.5px; color: var(--muted-2); margin-top: 10px; }

/* key terms */
.terms { display: flex; flex-wrap: wrap; gap: 7px; margin: 0 0 18px; }
.term-chip {
  display: inline-block; border: 1px solid var(--line); background: var(--panel); color: var(--text);
  border-radius: 999px; padding: 4px 11px; cursor: pointer; font-size: 13.5px;
  border-bottom-style: solid; line-height: 1.4;
}
.term-chip:hover { border-color: var(--accent); color: var(--accent); }

/* quiz */
.quiz { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel);
  padding: 16px; margin: 0 0 18px; max-width: var(--maxread); }
.quiz-q { font-weight: 600; color: var(--text-strong); margin: 0 0 12px; }
.quiz-opt {
  display: block; width: 100%; text-align: left; font: inherit; cursor: pointer;
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 9px 12px; margin: 0 0 8px;
}
.quiz-opt:hover:not(:disabled) { border-color: var(--accent); }
.quiz-opt:disabled { cursor: default; }
.quiz-opt .mark { font-weight: 700; margin-right: 8px; }
.quiz-opt.is-correct { border-color: var(--good); background: var(--good-soft); }
.quiz-opt.is-wrong   { border-color: var(--danger); background: var(--danger-soft); }
.quiz-why { font-size: 14px; color: var(--muted); margin: 8px 0 0; padding-left: 4px;
  border-left: 2px solid var(--line); padding: 2px 0 2px 10px; }
.quiz-why.show-correct { border-color: var(--good); }
.quiz-why.show-wrong { border-color: var(--danger); }
.quiz-reset { background: none; border: 0; color: var(--muted); font: inherit;
  font-size: 13px; cursor: pointer; text-decoration: underline; padding: 0; margin-top: 4px; }

/* details / references */
details.refs { border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--panel); padding: 10px 14px; margin: 0 0 18px; max-width: var(--maxread); }
details.refs summary { cursor: pointer; font-size: 14px; color: var(--muted); font-weight: 600; }
details.refs summary::marker { color: var(--muted-2); }
details.refs ul { margin: 10px 0 2px; padding-left: 20px; font-size: 14px; }
details.refs li { margin: 6px 0; color: var(--muted); }
details.refs a { word-break: break-word; }

/* section action bar */
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 26px 0 22px; }
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--panel); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 8px 14px; font: inherit; font-size: 14.5px; cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: var(--panel-2); border-color: var(--muted-2); }
.btn-primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 85%, #fff); color: var(--accent-text); }
.btn.is-on { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.btn.is-done { border-color: var(--good); color: var(--good); background: var(--good-soft); }
.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); }
.btn-sm { padding: 5px 10px; font-size: 13.5px; }

/* --------------------------- bottom navigation --------------------------- */

.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 55;
  display: flex; align-items: center; gap: 16px;
  padding: 10px 18px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
}
.nav-btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--panel); color: var(--text); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 9px 16px; font: inherit; font-size: 15px; cursor: pointer;
  min-width: 118px; justify-content: center;
}
.nav-btn:hover:not(:disabled) { background: var(--panel-2); border-color: var(--muted-2); }
.nav-btn:disabled { opacity: .4; cursor: not-allowed; }
.nav-centre { flex: 1 1 auto; min-width: 0; text-align: center; }
.nav-position { font-size: 13px; color: var(--muted); margin-bottom: 5px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ------------------------------- popover -------------------------------- */

.pop {
  position: absolute; z-index: 120; max-width: 360px; width: max-content;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px;
  font-size: 14.5px; line-height: 1.55;
}
.pop h4 { margin: 0 0 2px; font-size: 15.5px; }
.pop .pop-full { color: var(--muted); font-size: 13px; margin: 0 0 8px; }
.pop p { margin: 0 0 8px; }
.pop .pop-why { color: var(--muted); font-size: 13.5px; }
.pop .pop-why b { color: var(--text); }
.pop-foot { display: flex; gap: 12px; margin-top: 10px; font-size: 13px; }
.pop-close { position: absolute; top: 6px; right: 8px; background: none; border: 0;
  color: var(--muted-2); font-size: 18px; cursor: pointer; line-height: 1; padding: 4px; }

/* --------------------------------- home --------------------------------- */

.hero { max-width: 760px; }
.hero h1 { font-size: 34px; margin-bottom: 8px; }
.hero .lede { color: var(--muted); font-size: 17px; max-width: 62ch; margin: 0 0 24px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 0 0 24px; max-width: 760px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat-num { font-size: 25px; font-weight: 700; color: var(--text-strong); font-variant-numeric: tabular-nums; }
.stat-label { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

.continue-card {
  background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: var(--radius); padding: 18px 20px; margin: 0 0 26px; max-width: 760px;
}
.continue-card .kicker { font-size: 12px; text-transform: uppercase; letter-spacing: .09em;
  color: var(--muted-2); font-weight: 700; }
.continue-card h2 { margin: 6px 0 4px; font-size: 20px; }
.continue-card .where { color: var(--muted); font-size: 14px; margin: 0 0 14px; }

.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; margin: 0 0 26px; max-width: 980px; }
.card {
  display: block; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; text-decoration: none; color: var(--text);
}
.card:hover { border-color: var(--accent); }
.card h3 { margin: 0 0 4px; font-size: 16px; }
.card p { margin: 0; color: var(--muted); font-size: 13.5px; line-height: 1.5; }

.stage-progress { max-width: 760px; margin: 0 0 26px; }
.stage-progress-row { margin: 0 0 14px; }
.stage-progress-row .label { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 5px; }
.stage-progress-row .label span:last-child { color: var(--muted); font-variant-numeric: tabular-nums; }

/* --------------------------- glossary / lists --------------------------- */

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 0 0 18px; }
.toolbar input[type="search"], .toolbar select {
  background: var(--panel); color: var(--text); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 8px 12px; font: inherit; font-size: 15px;
}
.alpha { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 18px; }
.alpha a, .alpha button {
  display: inline-grid; place-items: center; min-width: 30px; height: 30px; padding: 0 6px;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--panel);
  color: var(--muted); text-decoration: none; font-size: 13.5px; font: inherit; cursor: pointer;
  font-size: 13.5px;
}
.alpha a:hover, .alpha button:hover { color: var(--accent); border-color: var(--accent); }
.alpha .off { opacity: .35; pointer-events: none; }

.gl-letter { font-size: 13px; letter-spacing: .1em; color: var(--muted-2); font-weight: 700;
  margin: 26px 0 8px; padding-bottom: 5px; border-bottom: 1px solid var(--line); }
.gl-entry { border-bottom: 1px solid var(--line-soft); padding: 14px 0; max-width: var(--maxread);
  border-left: 3px solid transparent; padding-left: 0; transition: border-color .2s ease, background .2s ease; }
.gl-entry.is-target {
  background: var(--accent-soft); border-left-color: var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0; padding: 14px 14px 14px 16px;
}
.box.is-target { border-color: var(--accent); border-left: 3px solid var(--accent); }
.gl-term { font-size: 17px; font-weight: 700; color: var(--text-strong); margin: 0; }
.gl-full { color: var(--muted); font-size: 13.5px; margin: 1px 0 7px; }
.gl-def { margin: 0 0 7px; }
.gl-why { color: var(--muted); font-size: 14.5px; margin: 0 0 7px; }
.gl-why b, .gl-ex b { color: var(--text); }
.gl-ex { font-size: 14px; color: var(--muted); margin: 0 0 7px; }
.gl-rel { font-size: 13.5px; color: var(--muted-2); }
.gl-rel a { text-decoration: none; }
.gl-rel a:hover { text-decoration: underline; }
.gl-seen { float: right; font-size: 11px; color: var(--muted-2); }

.item-list { max-width: var(--maxread); }
.item {
  display: flex; gap: 12px; align-items: flex-start;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--panel); padding: 12px 14px; margin: 0 0 10px;
}
.item .item-main { flex: 1 1 auto; min-width: 0; }
.item a { text-decoration: none; font-weight: 600; }
.item .item-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.item .item-actions { flex: 0 0 auto; display: flex; gap: 6px; }

.empty { border: 1px dashed var(--line); border-radius: var(--radius);
  padding: 26px; text-align: center; color: var(--muted); max-width: var(--maxread); }

/* ------------------------------ calculators ------------------------------ */

.calc { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel);
  padding: 16px; margin: 0 0 20px; max-width: 760px; }
.calc h3 { margin: 0 0 4px; font-size: 16px; }
.calc .calc-sub { color: var(--muted); font-size: 13.5px; margin: 0 0 14px; }
.calc-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 0 0 14px; }
.calc-field label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 4px; }
.calc-field input, .calc-field select {
  width: 100%; background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 7px 10px; font: inherit; font-size: 14.5px; font-variant-numeric: tabular-nums;
}
.calc-out { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin: 0 0 12px; }
.calc-out .o { background: var(--panel-2); border: 1px solid var(--line-soft); border-radius: var(--radius-sm); padding: 10px 12px; }
.calc-out .o-num { font-size: 19px; font-weight: 700; color: var(--text-strong); font-variant-numeric: tabular-nums; }
.calc-out .o-lab { font-size: 12px; color: var(--muted); margin-top: 1px; }
.calc-note { font-size: 12.5px; color: var(--muted-2); margin: 10px 0 0; }
.calc svg { width: 100%; height: auto; display: block; }
.calc-legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12.5px; color: var(--muted); margin-top: 8px; }
.calc-legend i { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

/* --------------------------------- toast --------------------------------- */

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 84px; z-index: 200;
  background: var(--panel); color: var(--text); border: 1px solid var(--line);
  border-radius: 999px; padding: 9px 18px; box-shadow: var(--shadow); font-size: 14.5px;
}

/* --------------------------------- scrim --------------------------------- */

.scrim { display: none; }

/* ------------------------------- responsive ------------------------------ */

@media (max-width: 1080px) {
  .topbar-links { display: none; }
}

@media (max-width: 900px) {
  .menu-only { display: inline-grid; }
  .layout { display: block; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 110;
    width: min(88vw, 340px); height: 100%;
    transform: translateX(-102%); transition: transform .22s ease;
    border-right: 1px solid var(--line);
  }
  body.nav-open .sidebar { transform: translateX(0); box-shadow: var(--shadow); }
  body.nav-open .scrim {
    display: block; position: fixed; inset: 0; z-index: 105;
    background: rgba(0,0,0,.5);
  }
  .view { padding: 20px 18px 140px; }
  h1 { font-size: 26px; }
  .hero h1 { font-size: 28px; }
  .topbar-search { max-width: none; }
}

@media (max-width: 620px) {
  body { font-size: 16px; }
  .brand-text { display: none; }
  .nav-btn { min-width: 0; padding: 9px 12px; }
  .nav-btn-label { display: none; }
  .bottomnav { gap: 10px; padding: 8px 12px; }
  .view { padding: 18px 14px 130px; }
  .fig-row { grid-template-columns: 84px 1fr 72px; font-size: 13px; }
  .calc-fields { grid-template-columns: 1fr 1fr; }
}

@media print {
  .topbar, .sidebar, .bottomnav, .actions, .pop, .toast { display: none !important; }
  body { background: #fff; color: #000; }
  .view { padding: 0; max-width: none; }
}

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