:root {
  --bg: #fbfbf9;
  --fg: #1c1c1a;
  --muted: #74746f;
  --faint: #a3a39d;
  --line: rgba(20, 20, 10, 0.09);
  --card: #ffffff;
  --card-2: #f4f4f1;
  --accent: #e5530a;
  --accent-soft: rgba(229, 83, 10, 0.1);
  --hi: #16834a;
  --mid: #b7791f;
  --lo: #9a9a94;
  --shadow: 0 1px 1px rgba(0, 0, 0, 0.03), 0 4px 14px rgba(0, 0, 0, 0.04);
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --serif: Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "JetBrains Mono", SFMono-Regular, Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #131312; --fg: #ededea; --muted: #a0a09a; --faint: #6d6d68; --line: rgba(255, 255, 240, 0.1);
    --card: #1b1b1a; --card-2: #232321; --accent: #ff7a33; --accent-soft: rgba(255, 122, 51, 0.14);
    --hi: #4cc38a; --mid: #e2a33a; --lo: #77776f; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #131312; --fg: #ededea; --muted: #a0a09a; --faint: #6d6d68; --line: rgba(255, 255, 240, 0.1);
  --card: #1b1b1a; --card-2: #232321; --accent: #ff7a33; --accent-soft: rgba(255, 122, 51, 0.14);
  --hi: #4cc38a; --mid: #e2a33a; --lo: #77776f; --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg); font: 16px/28px var(--sans);
  -webkit-font-smoothing: antialiased; font-variant-numeric: tabular-nums;
}
::selection { background: var(--accent); color: #fff; }
a { color: inherit; text-decoration-color: var(--faint); text-underline-offset: 3px; transition: text-decoration-color 150ms; }
a:hover { text-decoration-color: currentColor; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

main { max-width: 760px; margin: 0 auto; padding: 56px 16px 120px; }
.crumbs { font-size: 14px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; }
.crumbs a { text-decoration: none; }
.crumbs a:hover { color: var(--fg); }

.hero { padding: 48px 0 8px; }
h1 { font-size: clamp(32px, 6vw, 44px); line-height: 1.1; letter-spacing: -0.02em; font-weight: 600; margin: 0 0 20px; }
h1 i, .serif { font-family: var(--serif); font-weight: 400; font-style: italic; letter-spacing: -0.01em; }
.lead { font-size: 20px; line-height: 32px; margin: 0 0 16px; text-wrap: pretty; }
.meta { font-size: 14px; color: var(--muted); margin: 0; }

section { padding-top: 56px; }
h2 { font-size: 16px; font-weight: 500; color: var(--muted); margin: 0 0 12px; letter-spacing: 0; }
p { margin: 0 0 16px; text-wrap: pretty; }
.note { font-size: 14px; color: var(--muted); }

sup { line-height: 0; font-size: 11px; }
.cite {
  display: inline-block; min-width: 16px; padding: 0 4px; margin-left: 2px; border-radius: 4px; text-align: center;
  font: 500 11px/16px var(--mono); color: var(--muted); background: var(--card-2); text-decoration: none;
  vertical-align: 2px; transition: background 150ms, color 150ms;
}
.cite:hover, .cite:focus-visible { background: var(--accent-soft); color: var(--accent); }
#tip {
  position: fixed; z-index: 10; max-width: min(360px, calc(100vw - 32px)); padding: 10px 12px; border-radius: 8px;
  background: var(--fg); color: var(--bg); font-size: 13px; line-height: 20px; pointer-events: none;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.18); opacity: 0; transform: translateY(4px);
  transition: opacity 150ms var(--ease), transform 150ms var(--ease);
}
#tip.on { opacity: 1; transform: none; }
#tip b { display: block; font-weight: 500; opacity: 0.6; font-size: 12px; margin-top: 4px; }

table.costs { width: 100%; border-collapse: collapse; font-size: 15px; margin: 8px 0 12px; }
.costs th { font-weight: 500; color: var(--muted); font-size: 13px; text-align: left; padding: 0 8px 8px 0; }
.costs td { border-top: 1px solid var(--line); padding: 12px 8px 12px 0; vertical-align: top; line-height: 22px; }
.costs .ex { display: block; color: var(--muted); font-size: 14px; }
.num { text-align: right; white-space: nowrap; }
.costs td.num { font-weight: 500; padding-right: 16px; }

.conf {
  display: inline-flex; align-items: center; gap: 2px; font-size: 13px; color: var(--muted); white-space: nowrap; line-height: 20px;
}
.conf i { width: 3px; height: 10px; border-radius: 2px; background: var(--line); }
.conf i:nth-child(2) { height: 13px; } .conf i:nth-child(3) { height: 16px; margin-right: 6px; }
.conf-low i:nth-child(1) { background: var(--lo); }
.conf-medium i:nth-child(-n+2) { background: var(--mid); }
.conf-high i { background: var(--hi); }
.conf-rule, .conf-none { font-size: 13px; color: var(--muted); }

/* billing toggle + chips */
.seg { display: inline-flex; padding: 3px; border-radius: 10px; background: var(--card-2); margin: 4px 0 16px; }
.seg button, .chip {
  font: 500 14px/20px var(--sans); color: var(--muted); background: transparent; border: 0; padding: 6px 12px;
  border-radius: 8px; cursor: pointer; transition: background 150ms, color 150ms, transform 120ms var(--ease);
}
.seg button[aria-checked="true"] { background: var(--card); color: var(--fg); box-shadow: var(--shadow); }
.seg button:active, .chip:active, button:active { transform: scale(0.96); }

.cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 640px) { .cards { grid-template-columns: 1fr; } }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px 18px 16px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 10px; min-width: 0;
}
.card h3 { margin: 0; font-size: 16px; font-weight: 600; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.card .price { font-size: 28px; line-height: 32px; font-weight: 600; letter-spacing: -0.02em; }
.card .price small { font-size: 14px; color: var(--muted); font-weight: 400; letter-spacing: 0; }
.card select, .usage select, .usage input:not([type="checkbox"]) {
  font: 15px/22px var(--sans); color: var(--fg); background: var(--card-2); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 10px; width: 100%; min-width: 0;
}
.card .line { font-size: 14px; line-height: 22px; color: var(--muted); margin: 0; }
.card .buys { list-style: none; margin: 0; padding: 10px 0 0; border-top: 1px solid var(--line); font-size: 14px; line-height: 22px; }
.card .buys li { display: flex; justify-content: space-between; gap: 12px; padding: 2px 0; }
.card .buys li span:last-child { font-weight: 500; white-space: nowrap; }
.card .buys .cap { color: var(--muted); font-size: 13px; display: block; padding-top: 4px; }
.card.custom .price { font-size: 20px; }

ul.rules, ul.gotchas, ul.gaps { list-style: none; padding: 0; margin: 0; }
ul.rules li, ul.gotchas li, ul.gaps li { padding: 12px 0 12px 28px; border-top: 1px solid var(--line); position: relative; }
ul.rules li::before, ul.gotchas li::before, ul.gaps li::before {
  position: absolute; left: 0; top: 12px; font: 500 13px/28px var(--mono); color: var(--faint);
}
ul.rules li::before { content: "◷"; }
ul.gotchas li::before { content: "!"; color: var(--accent); left: 6px; }
ul.gaps li::before { content: "?"; left: 5px; }

/* questionnaire */
.q { border-top: 1px solid var(--line); padding: 14px 0; }
.q legend { font-weight: 500; padding: 0; margin-bottom: 8px; }
.q fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: var(--card-2); color: var(--fg); font-weight: 400; }
.chip[aria-checked="true"] { background: var(--fg); color: var(--bg); }
.chip:disabled { opacity: 0.45; cursor: not-allowed; }
.chip small { color: inherit; opacity: 0.6; }
.result {
  margin-top: 16px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 20px; box-shadow: var(--shadow);
}
.result .rec { font-size: 24px; line-height: 32px; font-weight: 600; letter-spacing: -0.01em; margin: 4px 0 12px; }
.result dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0 0 12px; font-size: 15px; }
.result dt { color: var(--muted); }
.result dd { margin: 0; }
.result ul.tips { margin: 8px 0 0; padding-left: 18px; font-size: 15px; }
.result .eyebrow { font-size: 13px; color: var(--muted); }
details.math { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 10px; }
details.math summary { cursor: pointer; font-size: 14px; color: var(--muted); list-style: none; }
details.math summary::-webkit-details-marker { display: none; }
details.math summary::before { content: "▸ "; display: inline-block; transition: transform 150ms var(--ease); }
details.math[open] summary::before { transform: rotate(90deg); }
details.math ol { font-size: 14px; line-height: 22px; padding-left: 20px; margin: 10px 0 0; }
details.math li { margin-bottom: 8px; }
details.math .assume { color: var(--mid); font-size: 12px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em; }
details.math table { border-collapse: collapse; margin-top: 6px; font-size: 13px; }
details.math td { padding: 2px 12px 2px 0; }
.pending { color: var(--muted); }

/* usage form */
.usage { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 640px) { .usage { grid-template-columns: 1fr; } }
.usage label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--muted); }
.usage .wide { grid-column: 1 / -1; }
.usage .check { flex-direction: row; align-items: center; gap: 8px; color: var(--fg); }
.usage .row { display: flex; align-items: center; gap: 12px; }
.usage button {
  font: 500 15px/22px var(--sans); background: var(--fg); color: var(--bg); border: 0; border-radius: 8px;
  padding: 8px 18px; cursor: pointer; transition: transform 120ms var(--ease), opacity 150ms;
}
.usage button:disabled { opacity: 0.5; }
.usage .status { font-size: 14px; color: var(--muted); }
.usage .status.ok { color: var(--hi); }
.usage .status.err { color: var(--accent); }

ol.sources { padding-left: 24px; font-size: 14px; line-height: 22px; }
ol.sources li { margin-bottom: 8px; scroll-margin-top: 80px; }
ol.sources li:target { background: var(--accent-soft); border-radius: 6px; }
ol.sources .kind { display: block; color: var(--muted); font-size: 13px; }
ol.sources a { word-break: break-word; }

footer { margin-top: 64px; padding-top: 16px; border-top: 1px solid var(--line); font-size: 14px; line-height: 22px; color: var(--muted); }
footer i { font-family: var(--serif); }

ul.products { list-style: none; padding: 0; margin: 0; }
ul.products li { border-top: 1px solid var(--line); padding: 12px 0; display: grid; grid-template-columns: 140px 1fr; gap: 12px; }
@media (max-width: 640px) { ul.products li { grid-template-columns: 1fr; gap: 0; } }
ul.products li a { font-weight: 500; }
ul.products li span { color: var(--muted); font-size: 15px; }
ul.products li.soon { color: var(--faint); }

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

.preview-bar {
  position: sticky; top: 0; z-index: 5; padding: 8px 16px; text-align: center; font-size: 13px; font-weight: 500;
  background: var(--mid); color: #1c1c1a;
}
