/* NFL Prediction Model -- web frontend styles.
   Brand: Emerald Ink / Champagne, matching the iOS app, with the same
   light/dark mode-swap pattern (BrandTint/BrandSurface) -- Champagne
   becomes the primary accent in dark mode rather than staying static.
   Type: Manrope for UI text, IBM Plex Mono (tabular-nums) for every
   number that needs to line up -- scores, odds, percentages, stat values. */

:root {
  /* ---- Brand + surface tokens (light) ---- */
  --ink: #064E3B;
  --champagne: #F8E7C9;
  --bg: #FBFAF6;
  --card-bg: #FFFFFF;
  --card-bg-alt: #F6F4EE;
  --text: #16211C;
  --text-secondary: #667066;
  --border: #E7E2D3;
  --border-strong: #D9D2BE;
  --shadow-a: rgba(30, 35, 25, 0.06);
  --shadow-b: rgba(30, 35, 25, 0.09);

  /* ---- Semantic (distinct from the brand accent -- win/loss/push read
     the same regardless of which color is "brand" this mode) ---- */
  --green: #1F8A4C;
  --red: #C93B2E;
  --gray: #8B8D86;
  --orange: #C77800;
  --yellow: #B99400;
  --indigo: #4B4BD9;
  --teal: #0E8484;
  --purple: #8341C9;

  /* ---- Scales ---- */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 999px;
  --shadow-sm: 0 1px 2px var(--shadow-a);
  --shadow-md: 0 10px 24px -12px var(--shadow-b), 0 2px 6px -2px var(--shadow-a);

  --font-ui: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #F8E7C9;
    --champagne: #0E2A20;
    --bg: #0A100D;
    --card-bg: #131B16;
    --card-bg-alt: #182019;
    --text: #F1ECE0;
    --text-secondary: #9BA096;
    --border: #232C25;
    --border-strong: #303B31;
    --shadow-a: rgba(0, 0, 0, 0.35);
    --shadow-b: rgba(0, 0, 0, 0.55);

    --green: #35C46B;
    --red: #FF7A6E;
    --gray: #9A9D93;
    --orange: #FFB238;
    --yellow: #E3C43C;
    --indigo: #8C8CFF;
    --teal: #45D6D6;
    --purple: #C58CFF;
  }
}

* { box-sizing: border-box; }

html { color-scheme: light dark; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: color-mix(in srgb, var(--ink) 30%, transparent); }

a { color: inherit; text-decoration: none; }

button, select, input, textarea { font-family: inherit; }

:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--ink) 70%, var(--champagne) 30%);
  outline-offset: 2px;
  border-radius: 4px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* A soft cross-fade for the View Transitions API (see main.js) -- kept
   short and subtle since it fires on every tab switch. */
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 0.16s; }

/* ---------- Shell ---------- */

.icon { display: block; flex: none; }

/* .topbar is always ONE row (header title / nav / refresh-menu, in that
   order) -- never wraps to two lines. Scrolling only shrinks sizes (see
   .topbar.compact below, toggled by main.js's scroll listener), it never
   rearranges anything. Built with plain flexbox, deliberately not CSS
   grid -- grid containers have real, if uncommon, cross-browser quirks
   with position:sticky that plain flex avoids. */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--ink) 92%, transparent);
  backdrop-filter: saturate(160%) blur(16px);
  -webkit-backdrop-filter: saturate(160%) blur(16px);
  box-shadow: 0 1px 0 color-mix(in srgb, var(--champagne) 10%, transparent);
  display: flex;
  align-items: center;
}

header.app-header {
  flex: none;
  display: flex;
  align-items: center;
  min-width: 0;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 8px 10px 16px;
  transition: padding 0.2s ease;
}
.topbar.compact header.app-header {
  padding: calc(env(safe-area-inset-top, 0px) + 8px) 6px 8px 16px;
}

/* The week title as a filled pill (not plain text on the header's own
   background) -- a distinct "chip" the way a sportsbook header sets its
   current section/league apart from the surrounding nav. */
header.app-header h1 {
  margin: 0;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: -0.01em;
  white-space: nowrap;
  color: var(--ink);
  background: var(--champagne);
  padding: 6px 11px;
  border-radius: var(--radius-full);
  transition: font-size 0.2s ease, padding 0.2s ease;
}
.topbar.compact header.app-header h1 {
  font-size: 11.5px;
  padding: 4px 9px;
}

#refresh-menu {
  flex: none;
  display: flex;
  align-items: center;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 16px 10px 8px;
  transition: padding 0.2s ease;
}
.topbar.compact #refresh-menu {
  padding: calc(env(safe-area-inset-top, 0px) + 8px) 16px 8px 6px;
}

.refresh-widget {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
}
/* Shrinks rather than disappears -- the row's overall height is set by
   whichever sibling (usually this one, icon + timestamp stacked) is
   tallest, so keeping it doesn't force a second line the way the nav
   tabs used to. */
.topbar.compact .data-as-of {
  font-size: 9px;
}

.data-as-of {
  font-size: 10.5px;
  font-weight: 600;
  color: color-mix(in srgb, var(--champagne) 65%, transparent);
  white-space: nowrap;
  padding-right: 2px;
  transition: font-size 0.2s ease;
}

.topbar.compact .refresh-button {
  width: 28px;
  height: 28px;
}
.topbar.compact .top-nav a {
  padding: 5px 10px;
  font-size: 11.5px;
}
.topbar.compact .top-nav {
  padding: 6px 4px;
}

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 12px calc(env(safe-area-inset-bottom, 0px) + 28px);
}

.app-footer {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 20px calc(env(safe-area-inset-bottom, 0px) + 20px);
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--text-secondary);
  text-align: center;
}

/* Top tab strip -- a horizontally scrollable row of icon+label pills
   under the header, one sticky unit together with it (.topbar above). */
.top-nav {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 0 4px;
  transition: padding 0.2s ease;
}
.top-nav::-webkit-scrollbar { display: none; }

.top-nav a {
  flex: none;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  color: color-mix(in srgb, var(--champagne) 65%, transparent);
  transition: background-color 0.15s ease, color 0.15s ease, padding 0.2s ease, font-size 0.2s ease;
}

.top-nav a:hover { color: var(--champagne); }

.top-nav a.active {
  background: color-mix(in srgb, var(--champagne) 16%, transparent);
  color: var(--champagne);
}

/* Narrow viewports: 6 nav tabs can't fit beside the header pill and
   refresh widget without being squeezed into heavy internal horizontal
   scrolling, so let the nav wrap onto its own full-width row underneath
   -- the header pill and refresh widget stay together on the first row,
   same as before the single-line redesign. */
@media (max-width: 600px) {
  .topbar {
    flex-wrap: wrap;
    justify-content: space-between;
  }
  header.app-header { order: 1; }
  #refresh-menu { order: 2; }
  .top-nav {
    order: 3;
    flex: 1 1 100%;
    margin: 0 8px 8px;
  }
}

/* ---------- Matchups ---------- */

.matchups-header {
  display: flex;
  justify-content: center;
  padding: 6px 0 14px;
}

.week-select {
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  padding: 9px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.error-banner {
  background: color-mix(in srgb, var(--red) 14%, transparent);
  color: var(--red);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  margin-bottom: 12px;
  font-size: 14px;
  font-weight: 600;
}

.game-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.game-card {
  display: block;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 16px;
  transition: box-shadow 0.15s ease, transform 0.15s ease, border-color 0.15s ease;
}

.game-card:hover { box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.game-card:active { transform: scale(0.995); }

/* Divergent games (model vs. market) are outlined in their confidence
   pill's own color -- High and Medium stay visually distinct at a glance
   instead of sharing one "divergent" color. */
.game-card.divergent-high { border-color: var(--green); border-width: 1.5px; }
.game-card.divergent-medium { border-color: var(--orange); border-width: 1.5px; }
.game-card.divergent-low { border-color: var(--gray); border-width: 1.5px; }

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.header-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.matchup-title {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.header-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.badge-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.pill {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  padding: 3.5px 9px;
  border-radius: var(--radius-full);
}

.pill-final { background: color-mix(in srgb, var(--gray) 18%, transparent); color: var(--text-secondary); }
.pill-conf-high { background: color-mix(in srgb, var(--green) 16%, transparent); color: var(--green); }
.pill-conf-med { background: color-mix(in srgb, var(--yellow) 20%, transparent); color: var(--orange); }
.pill-conf-low { background: color-mix(in srgb, var(--gray) 16%, transparent); color: var(--gray); }
.pill-div-rating { background: color-mix(in srgb, var(--indigo) 16%, transparent); color: var(--indigo); }
.pill-div-situational { background: color-mix(in srgb, var(--teal) 16%, transparent); color: var(--teal); }

.situational-line {
  font-size: 12px;
  color: var(--teal);
  font-weight: 600;
  text-align: right;
  max-width: 200px;
}

.neutral-line {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--purple);
  font-weight: 600;
}

.card-weather-line {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 600;
}

.score-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
}

.score-col {
  flex: 1;
  text-align: center;
}
.score-col.faded { opacity: 0.45; }

.team-logo {
  width: 36px;
  height: 36px;
  object-fit: contain;
}

.team-code {
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin-top: 4px;
  color: var(--text-secondary);
}

.score-value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 22px;
  font-weight: 600;
  margin-top: 1px;
}

.score-sub {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  color: var(--text-secondary);
}

.at-sign {
  color: var(--text-secondary);
  font-size: 13px;
  padding: 0 8px;
}

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

.pick-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  font-size: 14px;
  border-left: 3px solid transparent;
}

.pick-row.pick-win, .pick-row.pick-take { background: color-mix(in srgb, var(--green) 13%, transparent); border-left-color: var(--green); }
.pick-row.pick-loss { background: color-mix(in srgb, var(--red) 13%, transparent); border-left-color: var(--red); }
.pick-row.pick-push { background: color-mix(in srgb, var(--gray) 13%, transparent); border-left-color: var(--gray); }
.pick-row.pick-none { background: color-mix(in srgb, var(--gray) 8%, transparent); border-left-color: var(--border-strong); }

.pick-text { font-weight: 800; flex: 1; }
.ou-text { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 11px; color: var(--text-secondary); }

.stats-row {
  display: flex;
  margin-top: 14px;
}

.stat-pill { flex: 1; text-align: center; }
.stat-label { font-size: 10px; font-weight: 600; letter-spacing: 0.02em; color: var(--text-secondary); }
.stat-value { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 13px; font-weight: 600; margin-top: 2px; }

.empty-state {
  text-align: center;
  padding: 70px 24px;
  color: var(--text-secondary);
}
.empty-icon { display: flex; justify-content: center; color: var(--border-strong); margin-bottom: 10px; }
.empty-state h2 { font-size: 17px; color: var(--text); margin: 8px 0 4px; }
.empty-state p { margin: 0; font-size: 14px; }

/* ---------- Shared "section card" (Settings, Game Detail, Season, Backtesting) ---------- */

.settings-section {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 16px 18px;
  margin-bottom: 12px;
}

.settings-section-title {
  font-size: 12.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  margin: 0 0 12px;
}

.setting-row { padding: 10px 0; }
.setting-row:not(:last-child) { border-bottom: 1px solid var(--border); }

.setting-row-head {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
}

.setting-value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--text-secondary);
}

.setting-slider {
  width: 100%;
  accent-color: var(--ink);
  height: 20px;
  cursor: pointer;
}

.settings-footer {
  font-size: 12.5px;
  color: var(--text-secondary);
  margin: 12px 0 0;
  line-height: 1.5;
}

.danger-button {
  width: 100%;
  padding: 11px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--red);
  background: none;
  color: var(--red);
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: background-color 0.15s ease;
}
.danger-button:hover { background: color-mix(in srgb, var(--red) 10%, transparent); }
.danger-button:active { background: color-mix(in srgb, var(--red) 16%, transparent); }

/* ---------- Refresh menu ---------- */

#refresh-menu { position: relative; }
.refresh-menu { position: static; }

.refresh-button {
  appearance: none;
  list-style: none;
  border: none;
  cursor: pointer;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  background: transparent;
  color: var(--champagne);
  transition: background-color 0.15s ease, opacity 0.15s ease, width 0.2s ease, height 0.2s ease;
}
.refresh-button:hover { background: color-mix(in srgb, var(--champagne) 14%, transparent); }
.refresh-button::-webkit-details-marker { display: none; }
.refresh-button[disabled] { cursor: default; opacity: 0.6; }
.refresh-button[disabled] .icon { animation: spin 1s linear infinite; }

.refresh-menu-list {
  position: absolute;
  right: 0;
  top: 58px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  min-width: 226px;
  overflow: hidden;
  z-index: 20;
  animation: menu-in 0.12s ease;
}
@keyframes menu-in { from { opacity: 0; transform: translateY(-4px) scale(0.98); } }

.refresh-menu-list button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 11px 14px;
  border: none;
  background: none;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: background-color 0.1s ease;
}
.refresh-menu-list button:hover { background: var(--card-bg-alt); }
.refresh-menu-list button:not(:last-child) { border-bottom: 1px solid var(--border); }

.refresh-progress, .refresh-finished {
  position: absolute;
  right: 0;
  top: 58px;
  display: flex;
  align-items: flex-start;
  gap: 7px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 9px 12px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.45;
  max-width: min(290px, calc(100vw - 32px));
  box-shadow: var(--shadow-md);
  z-index: 20;
  color: var(--text);
}
.refresh-progress .icon, .refresh-finished .icon { margin-top: 1px; }
.refresh-finished.ok { color: var(--green); }
.refresh-finished.error { color: var(--orange); }

.spinner {
  display: inline-block;
  width: 13px; height: 13px;
  flex: none;
  border: 2px solid var(--border);
  border-top-color: var(--ink);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Game Detail ---------- */

.back-link {
  display: inline-flex;
  align-items: center;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 12px;
}

.detail-title {
  font-size: 21px;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin: 0 0 14px;
}

.detail-score-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0 8px;
}

.detail-score-col { flex: 1; }
.team-logo-lg { width: 44px; height: 44px; object-fit: contain; }
.detail-team { font-size: 14.5px; font-weight: 700; margin-top: 6px; color: var(--text-secondary); }
.detail-score { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 22px; font-weight: 600; margin-top: 2px; }

.labeled-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.labeled-row:last-of-type { border-bottom: none; }
.labeled-row .label { color: var(--text-secondary); }
.labeled-row .value { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; }

.books-block { padding: 10px 0; font-size: 12px; color: var(--text-secondary); }
.books-title { margin-bottom: 5px; font-weight: 600; }
.book-line { padding: 1px 0; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

.badge-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 0;
  flex-wrap: wrap;
}
.divergence-note { font-size: 12px; font-weight: 600; color: var(--orange); }

.stepper-row, .toggle-row, .manual-adj-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.stepper-row:last-of-type, .toggle-row:last-of-type { border-bottom: none; }

.stepper { display: flex; gap: 8px; }
.stepper button {
  width: 40px; height: 40px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--card-bg-alt);
  color: var(--text);
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}
.stepper button:hover { background: color-mix(in srgb, var(--ink) 10%, transparent); border-color: var(--border-strong); }
.stepper button:active { background: color-mix(in srgb, var(--ink) 16%, transparent); }

.toggle-row input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--ink); cursor: pointer; }

.manual-adj-row input[type="range"] { flex: 1; accent-color: var(--ink); height: 20px; cursor: pointer; }
.manual-adj-value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  min-width: 46px;
  text-align: right;
}

.notes-field {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--card-bg-alt);
  color: var(--text);
  padding: 11px;
  font-family: inherit;
  font-size: 14px;
  resize: vertical;
  transition: border-color 0.15s ease;
}
.notes-field:focus { border-color: var(--ink); }

/* ---------- Season / stat grid ---------- */

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 10px;
}
.stat-card { padding: 14px 16px; margin-bottom: 0; }
.stat-card-label { font-size: 11px; font-weight: 700; text-transform: none; letter-spacing: 0; color: var(--text-secondary); margin-bottom: 5px; }
.stat-card-value { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 18px; font-weight: 600; }

.season-caption {
  text-align: center;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.week-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.week-row:last-child { border-bottom: none; }
.week-row-label { font-weight: 700; }
.week-row-stats { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 13px; }
.week-row-ou { font-size: 11px; color: var(--text-secondary); }
.group-row-n { font-weight: 500; color: var(--text-secondary); font-family: var(--font-mono); font-size: 12px; }

.rain-icon { color: var(--indigo); flex: none; }

/* ---------- Backtesting ---------- */

.overfitting-warning {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  background: color-mix(in srgb, var(--ink) 7%, transparent);
  border: 1px solid color-mix(in srgb, var(--ink) 16%, transparent);
  border-radius: var(--radius-md);
  padding: 11px 13px;
  margin-bottom: 12px;
  font-size: 12.5px;
  line-height: 1.5;
}
.overfitting-warning p { margin: 0; }
.overfitting-icon { color: var(--ink); flex: none; margin-top: 1px; }

.chart-box {
  position: relative;
  height: 180px;
  margin-top: 8px;
}

/* ---------- Documentation ---------- */

.doc-section {
  /* Clears the sticky header+tabs when a jump-nav button scrolls a section
     into view -- otherwise its heading would land tucked underneath them. */
  scroll-margin-top: 140px;
}

.doc-jump-nav {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 4px;
  margin-bottom: 14px;
}
.doc-jump-nav::-webkit-scrollbar { display: none; }

.doc-jump-nav button {
  flex: none;
  appearance: none;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 700;
  white-space: nowrap;
  padding: 7px 13px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.doc-jump-nav button:hover { color: var(--ink); border-color: var(--border-strong); }

.doc-section p { margin: 0 0 10px; font-size: 14px; line-height: 1.6; }
.doc-section p:last-child { margin-bottom: 0; }
.doc-section b { font-weight: 700; color: var(--text); }

.doc-subhead {
  font-size: 13px;
  font-weight: 700;
  margin: 18px 0 8px;
}
.doc-subhead:first-child { margin-top: 0; }

.doc-formula {
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.7;
  background: var(--card-bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 12px;
  overflow-x: auto;
  white-space: pre;
}

.doc-pill-row {
  display: flex;
  gap: 8px;
  margin: 4px 0 16px;
}

.doc-term-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 0;
  font-size: 13.5px;
  line-height: 1.5;
}
.doc-term-row .icon { margin-top: 1px; color: var(--text-secondary); flex: none; }
.doc-term-row .pill { flex: none; }
.doc-term-row p { margin: 0; }

.doc-glossary { margin: 0; }
.doc-glossary dt {
  font-weight: 700;
  font-size: 13.5px;
  margin-top: 12px;
}
.doc-glossary dt:first-of-type { margin-top: 0; }
.doc-term-range {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 11px;
  color: var(--text-secondary);
  margin-left: 4px;
}
.doc-glossary dd {
  margin: 3px 0 0;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.doc-settings-group:not(:last-child) { margin-bottom: 20px; }
.doc-settings-category {
  font-size: 11.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink);
  margin: 0 0 4px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.doc-list { margin: 0; padding-left: 20px; }
.doc-list li { font-size: 13.5px; line-height: 1.6; margin-bottom: 8px; }
.doc-list li:last-child { margin-bottom: 0; }

.doc-note {
  font-size: 12.5px;
  color: var(--text-secondary);
  background: var(--card-bg-alt);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  margin: 14px 0 0;
  line-height: 1.5;
}

/* ---------- Small screens ---------- */

@media (max-width: 380px) {
  .stat-grid { gap: 8px; }
  .stat-card { padding: 12px 13px; }
  main { padding: 12px 10px 60px; }
}
