/* Tezaur sau Fidelis
   A ledger palette: cream paper, a state-treasury teal for Tezaur, a market-copper for
   Fidelis, and a separate semantic green/rust pair for real (inflation-adjusted) return
   that stays independent of which program is selected. Both themes declared here in full;
   no colour is written outside a token block. */

:root {
  --paper:        #f3f0e7;
  --surface:      #fbfaf4;
  --surface-deep: #e8e2d0;
  --rule:         #d7cfb8;
  --rule-strong:  #ab9d7c;

  --text:         #1a1d15;
  --text-soft:    #40452e;
  --text-muted:   #565b45;

  --tezaur:       #1f6f5c;
  --tezaur-deep:  #144d3f;
  --fidelis:      #a15a1f;
  --fidelis-deep: #7d4517;
  --pos:          #2f7d3a;
  --neg:          #a3311f;
  --chalk:        #83795c;

  --ink-tezaur:   #123f34;
  --ink-fidelis:  #5c3210;

  --shadow:       0 1px 2px rgba(26, 29, 21, .07), 0 8px 28px rgba(26, 29, 21, .08);
  --focus:        #1f6f5c;

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: ui-sans-serif, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --measure: 34rem;
  --gutter: clamp(1.15rem, 4vw, 2.5rem);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper:        #12140f;
    --surface:      #1c1f18;
    --surface-deep: #262a1f;
    --rule:         #3a3d30;
    --rule-strong:  #59594a;

    --text:         #f1efe2;
    --text-soft:    #ccc8b5;
    --text-muted:   #b6b19c;

    --tezaur:       #4fae95;
    --tezaur-deep:  #78c6b0;
    --fidelis:      #d99552;
    --fidelis-deep: #e8b076;
    --pos:          #6fbf74;
    --neg:          #e07a63;
    --chalk:        #a49a7c;

    --ink-tezaur:   #b6e6d8;
    --ink-fidelis:  #f2cfa0;

    --shadow:       0 1px 2px rgba(0, 0, 0, .44), 0 10px 34px rgba(0, 0, 0, .36);
    --focus:        #78c6b0;
  }
}

:root[data-theme="dark"] {
  --paper:        #12140f;
  --surface:      #1c1f18;
  --surface-deep: #262a1f;
  --rule:         #3a3d30;
  --rule-strong:  #59594a;

  --text:         #f1efe2;
  --text-soft:    #ccc8b5;
  --text-muted:   #b6b19c;

  --tezaur:       #4fae95;
  --tezaur-deep:  #78c6b0;
  --fidelis:      #d99552;
  --fidelis-deep: #e8b076;
  --pos:          #6fbf74;
  --neg:          #e07a63;
  --chalk:        #a49a7c;

  --ink-tezaur:   #b6e6d8;
  --ink-fidelis:  #f2cfa0;

  --shadow:       0 1px 2px rgba(0, 0, 0, .44), 0 10px 34px rgba(0, 0, 0, .36);
  --focus:        #78c6b0;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0; background: var(--paper); color: var(--text);
  font-family: var(--serif); font-size: 1.0625rem; line-height: 1.62;
  text-rendering: optimizeLegibility;
}
@media (min-width: 46rem) { body { font-size: 1.125rem; line-height: 1.66; } }

a { color: inherit; text-underline-offset: .18em; text-decoration-thickness: from-font; }
a:hover { text-decoration-color: var(--tezaur); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 2px; }

.wrap { max-width: calc(var(--measure) + 2 * var(--gutter)); margin: 0 auto; padding: 0 var(--gutter); }
.wide { max-width: 78rem; margin: 0 auto; padding: 0 var(--gutter); }
.skip {
  position: absolute; left: -9999px; top: 0; background: var(--surface); color: var(--text);
  padding: .6rem .9rem; border: 1px solid var(--rule-strong); border-radius: 5px; z-index: 60;
}
.skip:focus { left: .8rem; top: .8rem; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40; display: flex; align-items: center; gap: .55rem;
  padding: .3rem var(--gutter); background: color-mix(in srgb, var(--paper) 97%, transparent);
  backdrop-filter: saturate(1.2) blur(8px); border-bottom: 1px solid var(--rule);
  font-family: var(--sans); font-size: .75rem; min-height: 2.5rem;
}
.topbar .home { font-weight: 600; text-decoration: none; color: var(--text-soft); flex: none; }
.topbar .spacer { flex: 1; }

.topnav {
  display: flex; gap: .1rem; overflow-x: auto; scrollbar-width: none;
  -ms-overflow-style: none; margin-left: .25rem; min-width: 0;
}
.topnav::-webkit-scrollbar { display: none; }
.topnav a {
  padding: .2rem .5rem; border-radius: 999px; text-decoration: none;
  color: var(--text-muted); white-space: nowrap;
}
.topnav a:hover { color: var(--tezaur); background: var(--surface-deep); }
.topnav a[aria-current="true"] { color: var(--text); background: var(--surface-deep); font-weight: 600; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 1.85rem; height: 1.85rem; padding: 0; border-radius: 999px; cursor: pointer;
  color: var(--text-muted); background: var(--surface); border: 1px solid var(--rule-strong);
}
.icon-btn:hover { color: var(--tezaur); border-color: var(--tezaur); }
.icon-btn svg { display: block; }
.icon-btn svg[hidden] { display: none; }

.chip {
  display: inline-flex; align-items: center; gap: .3rem; padding: .2rem .55rem;
  border: 1px solid var(--rule-strong); border-radius: 999px; background: var(--surface);
  color: var(--text-soft); text-decoration: none; font: inherit; cursor: pointer;
}
.chip:hover { border-color: var(--tezaur); color: var(--tezaur); }
.chip[aria-current="true"] { background: var(--text); color: var(--paper); border-color: var(--text); }
@media (max-width: 34rem) {
  .topbar .home { max-width: 6.4rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar { gap: .35rem; }
  .topnav a { padding: .2rem .4rem; }
}

/* ---------- hero ---------- */
.hero { padding: clamp(2.4rem, 7vw, 4.6rem) 0 1.2rem; }
.kicker {
  font-family: var(--sans); font-size: .72rem; letter-spacing: .16em; text-transform: uppercase;
  color: var(--tezaur); margin: 0 0 .85rem; font-weight: 650;
}
h1 {
  font-size: clamp(2.05rem, 6.4vw, 3.3rem); line-height: 1.07; letter-spacing: -.022em;
  font-weight: 650; margin: 0 0 1rem; text-wrap: balance;
}
.deck { font-size: 1.1rem; color: var(--text-soft); margin: 0 0 1.3rem; }
@media (min-width: 46rem) { .deck { font-size: 1.24rem; } }
.byline { font-family: var(--sans); font-size: .78rem; color: var(--text-muted); margin: 0; }

h2 {
  font-size: clamp(1.4rem, 3.6vw, 1.85rem); line-height: 1.16; letter-spacing: -.015em;
  font-weight: 650; margin: 2.8rem 0 .9rem; text-wrap: balance;
}
h3 { font-size: 1.09rem; font-weight: 650; margin: 1.9rem 0 .55rem; }
section { scroll-margin-top: 3.4rem; }
p { margin: 0 0 1.15rem; }
.lede::first-letter {
  float: left; font-size: 3.3em; line-height: .84; padding: .06em .09em 0 0;
  color: var(--tezaur); font-weight: 650;
}
strong { font-weight: 650; }
.num { font-variant-numeric: tabular-nums; }
.pos { color: var(--pos); font-weight: 650; }
.neg { color: var(--neg); font-weight: 650; }

.note {
  background: var(--surface); border: 1px solid var(--rule); border-left: 3px solid var(--chalk);
  border-radius: 0 6px 6px 0; padding: 1rem 1.15rem; margin: 1.7rem 0;
  font-size: .9375rem; color: var(--text-soft);
}
.note h3 { margin: 0 0 .4rem; font-size: .76rem; letter-spacing: .1em; text-transform: uppercase; color: var(--chalk); }
.note p:last-child { margin-bottom: 0; }
.note.warn { border-left-color: var(--neg); }
.note-inline { font-family: var(--sans); font-size: .88rem; color: var(--text-muted); margin: -.4rem 0 1.3rem; }

/* ---------- reading rail ---------- */
.rail {
  display: none; position: fixed; top: 50%; right: 1.4rem; transform: translateY(-50%);
  flex-direction: column; align-items: flex-end; gap: .5rem; z-index: 30;
}
@media (min-width: 76rem) { .rail { display: flex; } }
.rail-dot {
  position: relative; display: flex; align-items: center; justify-content: flex-end;
  text-decoration: none; padding: .15rem 0; width: 14px;
}
.rail-dot .dot {
  display: block; width: 6px; height: 6px; border-radius: 50%; flex: none;
  background: var(--rule-strong); transition: background-color .15s ease, transform .15s ease;
}
.rail-dot:hover .dot, .rail-dot:focus-visible .dot { background: var(--text-soft); }
.rail-dot.active .dot { background: var(--tezaur); transform: scale(1.45); }
.rail-label {
  position: absolute; right: 100%; top: 50%; margin-top: -.85rem; margin-right: .5rem;
  font-family: var(--sans); font-size: .75rem; line-height: 1.2; color: var(--text-soft);
  background: var(--surface); border: 1px solid var(--rule); border-radius: 4px;
  padding: .25rem .55rem; white-space: nowrap; box-shadow: var(--shadow);
  opacity: 0; transform: translateX(6px); pointer-events: none;
  transition: opacity .12s ease, transform .12s ease;
}
.rail-dot:hover .rail-label, .rail-dot:focus-visible .rail-label { opacity: 1; transform: none; }
.rail-dot.active .rail-label { color: var(--text); border-color: var(--rule-strong); }
@media (prefers-reduced-motion: reduce) { .rail-dot .dot, .rail-label { transition: none; } }
@media print { .rail { display: none; } }

/* ---------- figures ---------- */
figure { margin: 2rem 0; }
figcaption { font-family: var(--sans); font-size: .8125rem; line-height: 1.5; color: var(--text-muted); margin-top: .55rem; }

/* ---------- program comparison cards ---------- */
.progrid { display: grid; gap: 1rem; margin: 1.6rem 0 2rem; grid-template-columns: 1fr; }
@media (min-width: 40rem) { .progrid { grid-template-columns: 1fr 1fr; } }
.progcard {
  border: 1px solid var(--rule); border-radius: 8px; padding: 1.1rem 1.2rem; background: var(--surface);
  border-top: 3px solid var(--card-accent, var(--tezaur));
}
.progcard.tez { --card-accent: var(--tezaur); }
.progcard.fid { --card-accent: var(--fidelis); }
.progcard h3 { margin: 0 0 .6rem; font-size: 1.15rem; }
.progcard.tez h3 { color: var(--ink-tezaur); }
.progcard.fid h3 { color: var(--ink-fidelis); }
.progcard dl { margin: 0; font-family: var(--sans); font-size: .86rem; }
.progcard dt { color: var(--text-muted); margin: .55rem 0 .05rem; }
.progcard dt:first-child { margin-top: 0; }
.progcard dd { margin: 0; color: var(--text-soft); }

/* ---------- bar charts ---------- */
.bars { margin: 1.6rem 0; }
.barchart { display: block; width: 100%; height: auto; font-family: var(--sans); }
.barchart .bl { font-size: 12px; fill: var(--text-soft); }
.barchart .bv { font-size: 12px; fill: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.barchart .btrack { fill: var(--surface-deep); }
.barchart .bar-tez { fill: var(--tezaur); }
.barchart .bar-fid { fill: var(--fidelis); }
.barchart .infl { stroke: var(--neg); stroke-width: 1.6; stroke-dasharray: 4 3; fill: none; }
.barchart .infl-dot { fill: var(--neg); }
.barchart .infl-lab { fill: var(--neg); }
.barchart .axis { stroke: var(--rule-strong); stroke-width: 1; }
.keyrow { display: flex; flex-wrap: wrap; gap: .5rem 1.1rem; font-family: var(--sans); font-size: .8125rem; color: var(--text-soft); margin: .85rem 0 0; }
.keyrow span { display: inline-flex; align-items: center; gap: .4rem; }
.keyrow i { width: 11px; height: 11px; border-radius: 2px; display: block; }
.k-tez { background: var(--tezaur); }
.k-fid { background: var(--fidelis); }
.k-infl { width: 16px; height: 2px; border-radius: 0; background: repeating-linear-gradient(to right, var(--neg) 0 4px, transparent 4px 7px); }

/* ---------- tables ---------- */
.tablewrap {
  overflow-x: auto; margin: 1.7rem 0; border: 1px solid var(--rule); border-radius: 8px;
  background: var(--surface);
}
@media (min-width: 52rem) {
  .wrap .tablewrap {
    width: min(58rem, calc(100vw - 2 * var(--gutter)));
    margin-left: 50%; transform: translateX(-50%);
  }
}
table { border-collapse: collapse; width: 100%; font-family: var(--sans); font-size: .84rem; }
caption { text-align: left; padding: .8rem .9rem .1rem; color: var(--text-muted); font-size: .8rem; }
th, td { text-align: left; padding: .48rem .9rem; border-top: 1px solid var(--rule); vertical-align: top; }
td:first-child { font-weight: 600; color: var(--text); }
@media (min-width: 52rem) { td:first-child, th:first-child { white-space: nowrap; } }
thead th { border-top: 0; color: var(--text-muted); font-weight: 600; font-size: .75rem; letter-spacing: .04em; text-transform: uppercase; white-space: nowrap; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:hover { background: var(--surface-deep); }
tr.below-infl td.n.rate { color: var(--neg); font-weight: 650; }
tr.eq-infl td.n.rate { color: var(--chalk); font-weight: 650; text-decoration: underline dotted; text-decoration-color: var(--chalk); }
[hidden] { display: none !important; }
.tablewrap .loadmore {
  display: block; width: 100%; padding: .6rem; border: 0; border-top: 1px solid var(--rule);
  background: var(--surface-deep); color: var(--text-soft); font-family: var(--sans);
  font-size: .82rem; cursor: pointer;
}
.tablewrap .loadmore:hover { color: var(--tezaur); }

/* ---------- calculator ---------- */
.calc {
  background: var(--surface); border: 1px solid var(--rule); border-radius: 10px;
  padding: clamp(1.1rem, 3vw, 1.7rem); margin: 1.6rem 0 2rem;
}
.calc-grid { display: grid; gap: 1.1rem; grid-template-columns: 1fr; }
@media (min-width: 40rem) { .calc-grid { grid-template-columns: 1fr 1fr; } }
.field { font-family: var(--sans); font-size: .86rem; }
.field label, .field legend {
  display: block; color: var(--text-muted); font-size: .75rem; letter-spacing: .04em;
  text-transform: uppercase; margin: 0 0 .35rem; padding: 0; border: 0;
}
.field input[type="number"], .field select {
  width: 100%; font: inherit; font-size: 1rem; padding: .5rem .6rem;
  border: 1px solid var(--rule-strong); border-radius: 6px; background: var(--surface);
  color: var(--text); appearance: none; -webkit-appearance: none;
}
.field select {
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
                    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 16px) 55%, calc(100% - 11px) 55%;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 1.8rem;
}
.seg { display: flex; border: 1px solid var(--rule-strong); border-radius: 999px; overflow: hidden; width: fit-content; }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg label {
  display: block; margin: 0; padding: .45rem 1.05rem; cursor: pointer; text-transform: none;
  letter-spacing: 0; font-size: .88rem; color: var(--text-soft);
}
.seg input:checked + label { background: var(--text); color: var(--paper); }
.seg input:focus-visible + label { outline: 2px solid var(--focus); outline-offset: -2px; }
.check { display: flex; align-items: center; gap: .5rem; margin-top: .5rem; text-transform: none; }
.check input { width: 1rem; height: 1rem; accent-color: var(--tezaur); }
.inflrow { display: flex; flex-wrap: wrap; gap: .4rem; }
.inflrow .seg { flex: none; }

.calc-result {
  margin-top: 1.4rem; padding-top: 1.2rem; border-top: 1px dashed var(--rule-strong);
  display: grid; gap: .9rem 1.6rem; grid-template-columns: repeat(2, 1fr);
}
@media (min-width: 34rem) { .calc-result { grid-template-columns: repeat(4, 1fr); } }
.stat dt { font-family: var(--sans); font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); margin: 0 0 .2rem; }
.stat dd { margin: 0; font-size: 1.18rem; font-weight: 650; font-variant-numeric: tabular-nums; color: var(--text); }
.stat.neg dd { color: var(--neg); }
.stat.pos dd { color: var(--pos); }
.stat dd small { display: block; font-family: var(--sans); font-size: .68rem; font-weight: 500; color: var(--text-muted); text-transform: none; margin-top: .1rem; letter-spacing: 0; }
.calc-foot { font-family: var(--sans); font-size: .78rem; color: var(--text-muted); margin: 1rem 0 0; }
.calc noscript p.state { margin: 0; }

/* ---------- footer ---------- */
footer { border-top: 1px solid var(--rule); margin-top: 3.2rem; padding: 1.8rem 0 3rem; font-family: var(--sans); font-size: .84rem; color: var(--text-muted); }
footer a { color: var(--text-soft); }
footer ul { margin: .5rem 0 0; padding-left: 1.1rem; }
footer li { margin: .2rem 0; }
.totop { display: inline-flex; align-items: center; gap: .35rem; text-decoration: none; color: var(--text-soft); }

@media print {
  .topbar, .calc { display: none; }
  body { background: #fff; color: #000; }
}
