:root {
  --bg: #f9f8fd;
  --surface: #ffffff;
  --ink: #1c1838;
  --body: #3a3556;
  --muted: #6f6a8c;
  --line: #e9e6f3;
  --violet: #7765d4;
  --violet-ink: #5a48b8;
  --violet-soft: #f1eefc;
  --lime: #d3ee6b;
  --apricot: #f2a066;
  --serif: "Iowan Old Style", "New York", "Charter", Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14111f;
    --surface: #1d192c;
    --ink: #f3f1fb;
    --body: #d4d0e6;
    --muted: #9c97b8;
    --line: #2e2943;
    --violet: #a596f0;
    --violet-ink: #b8acf5;
    --violet-soft: #26203f;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--body);
  font: 17px/1.65 var(--sans);
}
a { color: var(--violet-ink); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
img { max-width: 100%; height: auto; }

.wrap { max-width: 1040px; margin: 0 auto; padding: 0 20px; }
.narrow { max-width: 720px; margin: 0 auto; padding: 0 20px; }

/* Header */
.top { border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 88%, transparent); position: sticky; top: 0; backdrop-filter: blur(10px); z-index: 5; }
.top .wrap { display: flex; align-items: center; justify-content: space-between; height: 60px; }
.brand { font: 700 20px/1 var(--serif); color: var(--ink); text-decoration: none; letter-spacing: -0.01em; }
.brand span { color: var(--violet); }
.top nav { display: flex; gap: 22px; font-size: 15px; }
.top nav a { color: var(--muted); text-decoration: none; font-weight: 600; }
.top nav a:hover, .top nav a[aria-current] { color: var(--ink); }

/* Home hero */
.hero { padding: 64px 0 40px; }
.eyebrow { font-size: 13px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--violet-ink); }
.hero h1 { font: 700 clamp(34px, 6vw, 54px)/1.08 var(--serif); color: var(--ink); margin: 12px 0 16px; letter-spacing: -0.02em; max-width: 16ch; }
.hero p { font-size: 19px; max-width: 58ch; margin: 0; color: var(--body); }

/* Post list */
.posts { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(290px, 100%), 1fr)); gap: 18px; padding: 8px 0 56px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 24px; text-decoration: none; color: inherit; display: flex; flex-direction: column; gap: 10px; transition: border-color .15s, transform .15s; }
.card:hover { border-color: var(--violet); transform: translateY(-2px); }
.card .tag { align-self: flex-start; font-size: 12px; font-weight: 700; color: var(--violet-ink); background: var(--violet-soft); border-radius: 99px; padding: 3px 10px; }
.card h2 { font: 700 22px/1.25 var(--serif); color: var(--ink); margin: 0; }
.card p { margin: 0; font-size: 15.5px; color: var(--muted); }
.card .meta { margin-top: auto; font-size: 13px; color: var(--muted); }

/* Article */
.article-head { padding: 48px 0 8px; }
.article-head h1 { font: 700 clamp(30px, 5vw, 44px)/1.12 var(--serif); color: var(--ink); margin: 10px 0 14px; letter-spacing: -0.015em; }
.lede { font-size: 20px; line-height: 1.55; color: var(--body); margin: 0 0 18px; }
.byline { font-size: 14px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px 14px; padding-bottom: 22px; border-bottom: 1px solid var(--line); }
article { padding-bottom: 24px; }
article h2 { font: 700 27px/1.25 var(--serif); color: var(--ink); margin: 44px 0 10px; letter-spacing: -0.01em; }
article h3 { font-size: 18px; color: var(--ink); margin: 28px 0 6px; }
article p, article li { max-width: 68ch; }
article ul, article ol { padding-left: 22px; }
article li { margin: 6px 0; }
article strong { color: var(--ink); }
sup a { text-decoration: none; font-weight: 700; font-size: 12px; }

.tldr { background: var(--violet-soft); border-radius: 18px; padding: 18px 22px; margin: 26px 0 8px; }
.tldr strong { display: block; color: var(--violet-ink); font-size: 13px; letter-spacing: .06em; text-transform: uppercase; margin-bottom: 6px; }
.tldr ul { margin: 0; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 22px 0; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 16px; }
.stat b { display: block; font: 700 32px/1.1 var(--serif); color: var(--ink); }
.stat span { font-size: 14px; color: var(--muted); }

.table-wrap { overflow-x: auto; margin: 18px 0; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: 15px; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { white-space: nowrap; }
@media (max-width: 560px) { th, td { padding: 9px 10px; font-size: 14px; } th { white-space: normal; } }
th { color: var(--ink); font-weight: 700; background: var(--violet-soft); }
tr:last-child td { border-bottom: 0; }
caption { caption-side: bottom; text-align: left; padding: 8px 14px; font-size: 13px; color: var(--muted); }

.bar { display: grid; grid-template-columns: 120px 1fr 64px; align-items: center; gap: 10px; font-size: 14px; margin: 8px 0; }
.bar i { display: block; height: 14px; border-radius: 7px; background: var(--violet); }
.bar i.placebo { background: var(--line); }
.bar b { color: var(--ink); text-align: right; }

.note { border-left: 4px solid var(--apricot); background: var(--surface); padding: 12px 16px; border-radius: 0 12px 12px 0; margin: 20px 0; font-size: 15.5px; }

/* Calculator */
.calc { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 22px; margin: 22px 0; }
.calc label { font-weight: 700; color: var(--ink); display: block; margin-bottom: 8px; }
.calc .row { display: flex; gap: 10px; flex-wrap: wrap; }
.calc input, .calc select { font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); color: var(--ink); }
.calc input { width: 130px; }
.calc output { display: block; margin-top: 14px; font: 700 26px/1.2 var(--serif); color: var(--ink); }
.calc small { color: var(--muted); }

/* CTA */
.cta { display: grid; grid-template-columns: 96px 1fr; gap: 18px; align-items: center; background: var(--ink); color: #e9e6f8; border-radius: 24px; padding: 24px; margin: 40px 0; }
.cta img { width: 96px; height: auto; }
.cta h3 { margin: 0 0 6px; font: 700 21px/1.3 var(--serif); color: #fff; }
.cta p { margin: 0 0 14px; font-size: 15.5px; color: #cfc9ea; }
.cta .buttons { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.btn { display: inline-flex; align-items: center; gap: 8px; background: var(--lime); color: #1c1838; font-weight: 800; font-size: 15px; text-decoration: none; padding: 11px 18px; border-radius: 999px; }
.btn:hover { filter: brightness(1.05); text-decoration: none; }
.soon { font-size: 13.5px; color: #a9a3c8; }
@media (prefers-color-scheme: dark) { .cta { background: #2a2342; } }

/* Sources */
.sources { border-top: 1px solid var(--line); margin-top: 36px; padding-top: 10px; font-size: 14.5px; }
.sources h2 { font-size: 20px; margin-top: 18px; }
.sources ol { padding-left: 20px; }
.sources li { margin: 8px 0; color: var(--muted); }

.disclaimer { font-size: 14px; color: var(--muted); background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; margin: 28px 0; }

/* Footer */
footer { border-top: 1px solid var(--line); margin-top: 40px; padding: 28px 0 40px; font-size: 14px; color: var(--muted); }
footer .wrap { display: flex; flex-wrap: wrap; gap: 10px 28px; justify-content: space-between; }
footer p { margin: 0; max-width: 60ch; }
footer a { color: var(--muted); }

@media (max-width: 560px) {
  body { font-size: 16.5px; }
  .top nav { gap: 14px; }
  .cta { grid-template-columns: 1fr; text-align: left; }
  .cta img { width: 72px; }
  .bar { grid-template-columns: 92px 1fr 54px; }
}

/* Images, breadcrumbs, related */
.crumbs { font-size: 13.5px; color: var(--muted); padding-top: 22px; }
.crumbs a { color: var(--muted); }
.article-head { padding-top: 14px; }
.hero-img, .illo { margin: 0 0 8px; }
.hero-img img, .illo img { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 20px; background: var(--violet-soft); }
.illo { margin: 30px 0 4px; }
.card { overflow: hidden; }
.card .thumb { display: block; width: auto; max-width: none; align-self: stretch; margin: -24px -24px 6px; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 20px 20px 0 0; background: var(--violet-soft); }
.related { border-top: 1px solid var(--line); margin-top: 30px; }
.related h2 { font-size: 20px; margin-top: 18px; }
.related ul { padding-left: 20px; }

/* Let images run wider than the 720px text column on large screens */
@media (min-width: 800px) {
  .hero-img, .illo { width: min(960px, calc(100vw - 40px)); position: relative; left: 50%; transform: translateX(-50%); }
}

/* Sticky app bar (phones only, shown by JS after the reader scrolls) */
.sticky-cta { position: fixed; left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 20;
  display: flex; align-items: center; gap: 10px; padding: 9px 9px 9px 10px; border-radius: 18px;
  background: var(--ink); color: #fff; box-shadow: 0 10px 30px rgba(28, 24, 56, .28);
  transform: translateY(140%); transition: transform .25s ease; }
.sticky-cta.show { transform: none; }
.sticky-cta img { width: 40px; height: 40px; border-radius: 10px; flex: none; }
.sticky-cta .txt { flex: 1; min-width: 0; line-height: 1.25; }
.sticky-cta .txt b { display: block; font-size: 15px; }
.sticky-cta .txt span { display: block; font-size: 12.5px; color: #cfc9ea; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sticky-cta .btn { padding: 9px 14px; font-size: 14px; flex: none; }
.sticky-cta .x { flex: none; width: 30px; height: 30px; border: 0; border-radius: 50%; background: transparent; color: #a9a3c8; font-size: 20px; line-height: 1; cursor: pointer; }
@media (prefers-color-scheme: dark) { .sticky-cta { background: #2a2342; } }
@media (min-width: 721px) { .sticky-cta { display: none; } }
body.has-sticky footer { padding-bottom: 96px; }
