
:root {
  --navy: #08265a;
  --blue: #0d67c7;
  --blue-light: #eaf5ff;
  --green: #11834c;
  --green-light: #edf9f1;
  --orange: #df8b00;
  --orange-light: #fff6df;
  --purple: #6b3fb3;
  --purple-light: #f4efff;
  --red: #c83232;
  --red-light: #fff0f0;
  --ink: #172033;
  --muted: #5d687a;
  --line: #d9e2ee;
  --paper: #ffffff;
  --page: #f5f8fc;
  --max: 900px;
  --radius: 16px;
  --shadow: 0 10px 30px rgba(8, 38, 90, .08);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--page);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.7;
  font-size: 18px;
}

a { color: var(--blue); }
a:hover { color: var(--navy); }

.site-header {
  background: linear-gradient(135deg, var(--navy), #0b4f9f);
  color: white;
  position: sticky;
  top: 0;
  z-index: 40;
  box-shadow: 0 2px 14px rgba(0,0,0,.15);
}
.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: .75rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}
.site-title {
  color: white;
  text-decoration: none;
  font-weight: 800;
  letter-spacing: -.02em;
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.site-title-short { display: none; }
.nav-toggle-short { display: none; }
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}
.nav-toggle {
  margin-left: auto;
  border: 1px solid rgba(255,255,255,.5);
  background: transparent;
  color: white;
  border-radius: 8px;
  padding: .45rem .7rem;
  font: inherit;
  cursor: pointer;
  display: none;
}

.shell {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 245px minmax(0, 1fr);
  gap: 2rem;
  padding: 2rem 1.25rem 4rem;
}
.sidebar {
  position: sticky;
  top: 78px;
  align-self: start;
  max-height: calc(100vh - 95px);
  overflow: auto;
}
.sidebar h2 {
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--muted);
  margin: 0 0 .65rem;
}
.chapter-nav { list-style: none; padding: 0; margin: 0; }
.chapter-nav li { margin: .2rem 0; }
.chapter-nav a {
  display: block;
  padding: .55rem .7rem;
  text-decoration: none;
  border-radius: 9px;
  color: var(--ink);
  font-size: .93rem;
  line-height: 1.3;
}
.chapter-nav a:hover { background: #e9f2fc; }
.chapter-nav a.active {
  background: var(--blue-light);
  color: var(--navy);
  font-weight: 700;
  border-left: 4px solid var(--blue);
}

main {
  min-width: 0;
}
.article {
  max-width: var(--max);
  background: var(--paper);
  margin: 0 auto;
  padding: clamp(1.4rem, 4vw, 3.6rem);
  border-radius: 22px;
  box-shadow: var(--shadow);
}

.article h1 {
  color: var(--navy);
  font-size: clamp(2.25rem, 5vw, 4.25rem);
  line-height: 1.02;
  letter-spacing: -.04em;
  margin: 0 0 .6rem;
}
.article h2 {
  color: var(--navy);
  font-size: clamp(1.45rem, 3vw, 2rem);
  line-height: 1.18;
  margin-top: 2.5rem;
  margin-bottom: .8rem;
}
.article h3 {
  color: var(--navy);
  margin-top: 1.8rem;
}
.article p { margin: .8rem 0 1rem; }
.article ul, .article ol { padding-left: 1.5rem; }
.article li { margin: .35rem 0; }
.article blockquote {
  margin: 1.25rem 0;
  padding: .2rem 0 .2rem 1.2rem;
  border-left: 5px solid var(--blue);
  color: var(--navy);
  font-weight: 650;
  font-size: 1.12em;
}
.article img.full-width {
  width: 100%;
  height: auto;
  display: block;
  margin: 1.4rem auto 2rem;
  border-radius: 12px;
  border: 1px solid var(--line);
}

.callout {
  border-radius: var(--radius);
  padding: 1.15rem 1.35rem;
  margin: 1.5rem 0;
  border: 1px solid var(--line);
  background: #f8fbff;
}
.callout h2 {
  margin: 0 0 .5rem;
  font-size: 1.25rem;
}
.callout p:last-child { margin-bottom: 0; }
.callout.tax-map { background: var(--blue-light); border-color: #a7cdf5; }
.callout.tax-map h2 { color: var(--blue); }
.callout.translation { background: var(--green-light); border-color: #adddbf; }
.callout.translation h2 { color: #0d713e; }
.callout.archaeology { background: var(--orange-light); border-color: #edc66f; }
.callout.archaeology h2 { color: #9a5c00; }
.callout.policy { background: var(--purple-light); border-color: #ccbaf0; }
.callout.policy h2 { color: var(--purple); }
.callout.myth { background: var(--red-light); border-color: #efb2b2; }
.callout.myth h2 { color: #9e2222; }
.callout.reasonableness { background: #eef8ff; border-color: #afd5ef; }
.callout.reasonableness h2 { color: #145b8e; }
.callout.try-it { background: #fff9e8; border-color: #edd082; }
.callout.try-it h2 { color: #8e5c00; }
.callout.big-idea {
  background: linear-gradient(135deg, #eef6ff, #f7fbff);
  border: 2px solid #78b6ee;
}
.callout.big-idea h2 { color: var(--navy); }
.callout.note { background: #f7f8fb; border-color: #d8dde8; color: #414b5e; }

code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
pre { overflow-x: auto; background: #0d1b2a; color: #fff; padding: 1rem; border-radius: 12px; }

details {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 10px;
  margin: .8rem 0 1.2rem;
  padding: .75rem 1rem;
}
summary { cursor: pointer; font-weight: 700; color: var(--navy); }

.chapter-meta {
  color: var(--muted);
  margin-top: -.2rem;
  margin-bottom: 2rem;
  font-size: 1.05rem;
}
.chapter-footer {
  border-top: 1px solid var(--line);
  margin-top: 3rem;
  padding-top: 1rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-size: .95rem;
}

.site-footer {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.25rem 2.5rem;
  color: var(--muted);
  text-align: center;
  font-size: .88rem;
}

@media (max-width: 850px) {
  .nav-toggle { display: inline-block; }
  .shell { grid-template-columns: 1fr; padding-top: 1rem; }
  body.nav-open { overflow: hidden; }
  body.nav-open::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 25;
    background: rgba(8, 20, 42, .38);
  }
  .sidebar {
    display: none;
    position: fixed;
    top: calc(var(--site-header-height, 62px) + .55rem);
    left: .75rem;
    right: .75rem;
    bottom: .75rem;
    z-index: 35;
    max-height: none;
    overflow: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    background: white;
    padding: 1rem;
    border-radius: 12px;
    box-shadow: 0 18px 50px rgba(0,0,0,.28);
  }
  .sidebar.open { display: block; }
  .article { border-radius: 14px; padding: 1.35rem; }
  body { font-size: 17px; }
}

@media print {
  body { background: white; font-size: 11pt; color: black; }
  .site-header, .sidebar, .site-footer, .chapter-footer, .nav-toggle { display: none !important; }
  .shell { display: block; max-width: none; padding: 0; }
  .article { max-width: none; box-shadow: none; border-radius: 0; padding: 0; }
  .article h1, .article h2, .article h3 { color: black; }
  .callout { break-inside: avoid; box-shadow: none; }
  .article img { break-inside: avoid; max-height: 8.5in; object-fit: contain; }
  details { display: block; }
  details > * { display: block !important; }
  a { color: black; text-decoration: none; }
}

/* Reusable calculation blocks -------------------------------------------------
   Use for multi-line tax math and accounting-style computations. These blocks
   use the entire text column. Preformatted calculations NEVER wrap: we first
   give them the full width, then use a modestly smaller mono font. Horizontal
   scrolling is only the final fallback on a genuinely narrow screen.
*/
.calculation {
  width: 100%;
  max-width: none;
  margin: 1.35rem 0 1.6rem;
  border: 1px solid #c9d5e5;
  border-left: 4px solid var(--blue);
  border-radius: 12px;
  background: #f7f9fc;
  box-shadow: 0 5px 16px rgba(8, 38, 90, .06);
  min-width: 0;
}
.calculation pre {
  margin: 0;
  padding: 1rem 1.05rem;
  background: transparent;
  color: #142033;
  border-radius: 0;
  max-width: 100%;
  font-family: "Cascadia Mono", "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
  font-size: .80rem;
  line-height: 1.55;
  font-variant-numeric: tabular-nums;
  white-space: pre !important;
  overflow-wrap: normal !important;
  word-break: normal !important;
  hyphens: none !important;
  overflow-x: auto;
  scrollbar-width: thin;
}
.calculation code {
  color: inherit;
  background: transparent;
  padding: 0;
  font: inherit;
  white-space: inherit !important;
  overflow-wrap: normal !important;
  word-break: normal !important;
}

/* Side-by-side workpapers should use layout, not spaces in a long code line. */
.calculation-comparison {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  padding: 1rem 1.05rem;
}
.calc-panel {
  min-width: 0;
  font-family: "Cascadia Mono", "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
  font-size: .80rem;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
}
.calc-panel-title {
  font-weight: 800;
  color: var(--navy);
  margin-bottom: .5rem;
}
.calc-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: .8rem;
  align-items: baseline;
  white-space: nowrap;
}
.calc-row + .calc-row { margin-top: .18rem; }
.calc-row.calc-total {
  border-top: 1px solid #7e8ca0;
  margin-top: .45rem;
  padding-top: .45rem;
  font-weight: 800;
}
.calc-amount { text-align: right; }

@media (max-width: 700px) {
  .calculation pre, .calc-panel { font-size: .74rem; }
  .calculation pre { padding: .9rem; }
  .calculation-comparison { grid-template-columns: 1fr; }
}

@media (max-width: 440px) {
  .calculation pre, .calc-panel { font-size: .70rem; }
}

@media print {
  .calculation {
    box-shadow: none;
    border-color: #aaa;
    background: #fafafa;
    break-inside: avoid;
  }
  .calculation pre, .calc-panel {
    font-size: 9pt;
  }
  .calculation pre {
    overflow: visible;
  }
}

/* Nested section navigation ------------------------------------------------ */
.chapter-nav .nav-top { margin-bottom: .25rem; }
.chapter-nav a.section-active {
  color: var(--navy);
  font-weight: 700;
  background: #eef4fb;
}
.chapter-subnav {
  list-style: none;
  padding: .15rem 0 .35rem .75rem;
  margin: 0;
  border-left: 1px solid #ccd8e8;
}
.chapter-subnav li { margin: .1rem 0; }
.chapter-subnav a {
  padding: .38rem .55rem;
  font-size: .86rem;
  color: #45536a;
}
.chapter-subnav a.active {
  border-left: 3px solid var(--blue);
  background: var(--blue-light);
  color: var(--navy);
}

/* Reusable HTML/CSS tax formula ------------------------------------------ */
.tax-formula-component {
  margin: 1.5rem auto 2rem;
  border: 1px solid #cbd8e8;
  border-radius: 16px;
  overflow: hidden;
  background: white;
  box-shadow: 0 7px 22px rgba(8, 38, 90, .07);
}
.tax-formula-heading {
  padding: .8rem 1rem;
  background: var(--navy);
  color: white;
  font-weight: 800;
  text-align: center;
  letter-spacing: .01em;
}
.tax-formula-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .91rem;
  line-height: 1.35;
}
.tax-formula-table tr {
  border-bottom: 1px solid #e2e8f1;
  transition: background .15s ease;
}
.tax-formula-table tr:last-child { border-bottom: 0; }
.tax-formula-table td,
.tax-formula-table th {
  padding: .55rem .65rem;
  vertical-align: middle;
}
.tax-formula-table th {
  width: 39%;
  color: var(--navy);
  text-align: left;
  font-weight: 750;
}
.tax-formula-table .tax-op {
  width: 2.2rem;
  text-align: center;
  color: var(--muted);
  font-family: "Cascadia Mono", "SFMono-Regular", Menlo, Consolas, monospace;
  font-weight: 800;
  font-size: 1.02rem;
}
.tax-formula-table .tax-note {
  color: var(--muted);
  font-size: .88rem;
}
.tax-formula-table tr.is-active {
  background: #e8f4ff;
  box-shadow: inset 5px 0 0 var(--blue);
}
.tax-formula-table tr.is-active th {
  color: #063f7b;
}
.tax-formula-caption {
  border-top: 1px solid #dce5ef;
  padding: .65rem .9rem;
  background: #f7f9fc;
  color: var(--muted);
  text-align: center;
  font-size: .8rem;
}

/* Topic cards on section landing pages ----------------------------------- */
.topic-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .85rem;
  margin: 1.2rem 0 1.8rem;
}
.topic-card {
  display: flex;
  flex-direction: column;
  gap: .25rem;
  min-height: 118px;
  padding: 1rem 1.05rem;
  border: 1px solid #cdd9e8;
  border-radius: 13px;
  background: #fbfdff;
  color: var(--ink);
  text-decoration: none;
  box-shadow: 0 4px 14px rgba(8, 38, 90, .04);
}
.topic-card strong {
  color: var(--navy);
  font-size: 1.02rem;
}
.topic-card span {
  color: var(--muted);
  font-size: .9rem;
  line-height: 1.45;
}
.topic-card:hover {
  color: var(--ink);
  border-color: #8dbce9;
  background: #f2f8ff;
  transform: translateY(-1px);
}

/* Personal-decision callout ---------------------------------------------- */
.callout.personal { background: #eefaf8; border-color: #a9dcd3; }
.callout.personal h2 { color: #156b5b; }

@media (max-width: 700px) {
  .tax-formula-table .tax-note { display: none; }
  .tax-formula-table th { width: auto; }
  .topic-grid { grid-template-columns: 1fr; }
}

@media print {
  .tax-formula-component { box-shadow: none; break-inside: avoid; }
  .tax-formula-heading { background: white; color: black; border-bottom: 2px solid #555; }
  .tax-formula-table tr.is-active { background: #eee; box-shadow: inset 4px 0 0 #555; }
  .topic-grid { display: block; }
  .topic-card { display: block; min-height: auto; margin: .4rem 0; box-shadow: none; }
}


/* Phaseout number line -----------------------------------------------------
   HTML/CSS rather than an image so the example values and styling are easy
   to change with the book.
*/
.phaseout-line {
  position: relative;
  min-height: 230px;
  margin: 2rem auto 2.3rem;
  padding: 0 3.5rem;
}
.phaseout-axis {
  position: absolute;
  left: 3.5rem;
  right: 3.5rem;
  top: 112px;
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, #158048 0%, #1f6fb2 50%, #cf3434 100%);
}
.phaseout-axis::before,
.phaseout-axis::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 0;
  height: 0;
  transform: translateY(-50%);
  border-top: 11px solid transparent;
  border-bottom: 11px solid transparent;
}
.phaseout-axis::before {
  left: -16px;
  border-right: 18px solid #158048;
}
.phaseout-axis::after {
  right: -16px;
  border-left: 18px solid #cf3434;
}
.phaseout-point {
  position: absolute;
  top: 0;
  width: 190px;
  text-align: center;
  transform: translateX(-50%);
}
.phaseout-start { left: 3.5rem; transform: translateX(-18%); color: #126f3f; }
.phaseout-mid { left: 50%; color: #145f9c; }
.phaseout-end { right: 3.5rem; left: auto; transform: translateX(18%); color: #a92222; }
.phaseout-benefit {
  display: block;
  min-height: 70px;
  font-weight: 700;
  line-height: 1.25;
}
.phaseout-benefit strong { font-size: 1.28em; }
.phaseout-dot {
  display: block;
  width: 28px;
  height: 28px;
  margin: 27px auto 15px;
  border-radius: 50%;
  background: currentColor;
  border: 4px solid white;
  box-shadow: 0 0 0 2px currentColor;
}
.phaseout-amount {
  display: block;
  color: var(--navy);
  font-weight: 800;
  font-size: 1.08rem;
}
.phaseout-range-label {
  position: absolute;
  left: 18%;
  right: 18%;
  top: 194px;
  padding-top: .25rem;
  border-top: 2px solid #9caaba;
  color: #667488;
  text-align: center;
  font-weight: 700;
}

@media (max-width: 620px) {
  .phaseout-line {
    min-height: 205px;
    padding: 0 1.2rem;
    font-size: .82rem;
  }
  .phaseout-axis { left: 1.6rem; right: 1.6rem; top: 100px; height: 6px; }
  .phaseout-point { width: 120px; }
  .phaseout-start { left: 1.6rem; transform: translateX(-6%); }
  .phaseout-end { right: 1.6rem; transform: translateX(6%); }
  .phaseout-benefit { min-height: 66px; }
  .phaseout-dot { width: 23px; height: 23px; margin-top: 22px; }
  .phaseout-amount { font-size: .93rem; }
  .phaseout-range-label { top: 174px; left: 20%; right: 20%; }
}

@media print {
  .phaseout-axis { background: #777; }
  .phaseout-axis::before { border-right-color: #777; }
  .phaseout-axis::after { border-left-color: #777; }
}

/* In-page table of contents in the sticky site header ------------------------
   Generated automatically from Markdown H2/H3 headings. Keeping it inside
   the existing sticky header avoids consuming any additional reading space.
*/
.header-page-jump {
  position: static;
  flex: 0 1 330px;
  min-width: 190px;
  max-width: 360px;
  margin: 0 0 0 auto;
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
  backdrop-filter: none;
}
.page-jump-select {
  width: 100%;
  min-width: 0;
  height: 38px;
  padding: .35rem 2rem .35rem .7rem;
  border: 1px solid rgba(255,255,255,.48);
  border-radius: 8px;
  background: rgba(255,255,255,.98);
  color: var(--ink);
  font: inherit;
  font-size: .86rem;
  line-height: 1.1;
  cursor: pointer;
}
.page-jump-select:hover { border-color: white; }
.page-jump-select:focus {
  outline: 3px solid rgba(255,255,255,.25);
  border-color: white;
}
.article h2[id],
.article h3[id] {
  scroll-margin-top: 5.5rem;
}

@media (max-width: 850px) {
  .header-inner { gap: .55rem; }
  .site-title-full { display: none; }
  .site-title-short { display: inline; }
  .header-page-jump {
    flex: 1 1 180px;
    min-width: 105px;
    max-width: 230px;
    margin-left: .25rem;
  }
  .page-jump-select {
    height: 36px;
    font-size: .8rem;
    padding-left: .55rem;
  }
}

@media (max-width: 520px) {
  .header-inner { padding-left: .7rem; padding-right: .7rem; }
  .site-title { flex: 0 0 auto; font-size: .92rem; }
  .header-page-jump { flex: 1 1 auto; min-width: 0; }
  .nav-toggle { padding: .4rem .55rem; }
  .nav-toggle-full { display: none; }
  .nav-toggle-short { display: inline; font-size: 1.05rem; line-height: 1; }
}

@media print {
  .page-jump { display: none !important; }
}


/* Marginal-rate glasses ----------------------------------------------------
   Reusable visual for the "tax brackets are glasses" analogy. The first
   glasses are full; the final glass is partially filled because that is the
   marginal bracket. A deduction removes taxable income from that last glass
   first.
*/
.marginal-glasses {
  margin: 1.6rem 0 1.8rem;
  padding: 1.15rem 1.2rem 1rem;
  border: 1px solid #cbd9ea;
  border-radius: 16px;
  background: linear-gradient(180deg, #fbfdff 0%, #f4f8fd 100%);
  box-shadow: 0 6px 18px rgba(8, 38, 90, .06);
}
.glasses-title {
  margin-bottom: 1rem;
  color: var(--navy);
  font-weight: 800;
  text-align: center;
  font-size: 1.05rem;
}
.glasses-row {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: clamp(1.25rem, 5vw, 3.75rem);
  min-height: 225px;
  padding: .5rem 1rem .2rem;
}
.tax-glass {
  position: relative;
  width: 145px;
  height: 155px;
  border: 5px solid #718198;
  border-top-width: 3px;
  border-radius: 10px 10px 25px 25px;
  background: rgba(255,255,255,.8);
  overflow: visible;
}
.tax-glass::before {
  content: "";
  position: absolute;
  left: -9px;
  right: -9px;
  top: -8px;
  height: 10px;
  border: 4px solid #718198;
  border-radius: 50%;
  background: #fff;
  z-index: 3;
}
.glass-liquid {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  border-radius: 0 0 19px 19px;
  background: linear-gradient(180deg, #61b8ed 0%, #2279c7 100%);
  z-index: 1;
}
.glass-full .glass-liquid { height: 92%; }
.glass-partial .glass-liquid { height: 52%; }
.glass-label {
  position: absolute;
  left: 50%;
  top: calc(100% + 14px);
  width: 160px;
  transform: translateX(-50%);
  text-align: center;
  color: var(--navy);
  font-weight: 800;
  font-size: .94rem;
}
.deduction-arrow {
  position: absolute;
  left: 50%;
  bottom: 52%;
  transform: translateX(-50%);
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
}
.arrow-line {
  color: var(--red);
  font-size: 3rem;
  line-height: .9;
  font-weight: 900;
  text-shadow: 0 1px 0 white;
}
.arrow-text {
  width: 185px;
  margin-bottom: .15rem;
  padding: .35rem .45rem;
  border-radius: 8px;
  background: rgba(255,255,255,.95);
  color: #9f2020;
  font-size: .78rem;
  line-height: 1.25;
  font-weight: 800;
  text-align: center;
  box-shadow: 0 2px 8px rgba(8,38,90,.08);
}
.glasses-caption {
  max-width: 720px;
  margin: 2.25rem auto 0;
  color: var(--muted);
  text-align: center;
  font-size: .9rem;
  line-height: 1.45;
}
@media (max-width: 620px) {
  .glasses-row { gap: .75rem; min-height: 190px; padding-left: 0; padding-right: 0; }
  .tax-glass { width: 92px; height: 125px; border-width: 4px; }
  .glass-label { width: 105px; font-size: .78rem; }
  .arrow-text { width: 135px; font-size: .68rem; }
  .arrow-line { font-size: 2.4rem; }
}
@media (max-width: 430px) {
  .glasses-row { gap: .45rem; }
  .tax-glass { width: 78px; height: 112px; }
  .glass-label { width: 90px; font-size: .72rem; }
  .arrow-text { width: 118px; font-size: .62rem; }
}
@media print {
  .marginal-glasses { box-shadow: none; break-inside: avoid; }
  .glass-liquid { background: #bbb; }
}

/* Landing-page topic cards: flexible, breathable, and responsive. */
.topic-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 1.15rem;
  margin: 1.35rem 0 1.9rem;
}
.topic-card {
  flex: 1 1 300px;
  min-width: min(100%, 280px);
  margin: 0;
}
@media (max-width: 700px) {
  .topic-card { flex-basis: 100%; }
}

/* V11: Deductions-for-AGI route map ---------------------------------------- */
.deduction-routes {
  margin: 1.45rem 0 1.75rem;
  padding: 1rem 1.05rem 1.05rem;
  border: 1px solid #cbd9ea;
  border-radius: 16px;
  background: linear-gradient(180deg, #fbfdff 0%, #f5f9fd 100%);
  box-shadow: 0 6px 18px rgba(8, 38, 90, .05);
}
.deduction-routes-title {
  margin: 0 0 .85rem;
  color: var(--navy);
  font-size: 1.04rem;
  font-weight: 800;
  text-align: center;
}
.deduction-routes-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .7rem;
}
.deduction-route {
  position: relative;
  min-height: 142px;
  padding: .8rem .82rem;
  border: 1px solid #d6e1ee;
  border-radius: 12px;
  background: #fff;
}
.deduction-route strong {
  display: block;
  margin-bottom: .3rem;
  color: var(--navy);
  font-size: .9rem;
  line-height: 1.25;
}
.deduction-route span {
  display: block;
  color: var(--muted);
  font-size: .78rem;
  line-height: 1.35;
}
.route-kicker {
  display: inline-block;
  margin-bottom: .45rem;
  padding: .18rem .42rem;
  border-radius: 999px;
  background: #eaf4ff;
  color: #115b9d;
  font-size: .69rem;
  font-weight: 800;
  letter-spacing: .02em;
  text-transform: uppercase;
}
.deduction-routes-feed {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: .7rem;
  height: 28px;
  margin: 0 .5rem;
}
.deduction-routes-feed span {
  position: relative;
}
.deduction-routes-feed span::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 5px;
  border-left: 2px solid #8aa7c5;
}
.deduction-routes-feed span::after {
  content: "";
  position: absolute;
  left: calc(50% - 5px);
  bottom: 0;
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 8px solid #8aa7c5;
}
.deduction-routes-agi {
  max-width: 620px;
  margin: 0 auto;
  padding: .62rem .8rem;
  border-radius: 10px;
  background: #e9f6ed;
  color: #1d5d37;
  text-align: center;
  font-size: .86rem;
}
@media (max-width: 820px) {
  .deduction-routes-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .deduction-routes-feed { display: none; }
  .deduction-routes-agi { margin-top: .8rem; }
}
@media (max-width: 520px) {
  .deduction-routes-grid { grid-template-columns: 1fr; }
  .deduction-route { min-height: 0; }
}

/* V11: MAGI comparison ----------------------------------------------------- */
.magi-compare {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .9rem;
  margin: 1rem 0 1.2rem;
}
.magi-card {
  padding: .9rem 1rem;
  border: 1px solid #d6e1ee;
  border-radius: 12px;
  background: #f9fbfd;
}
.magi-card strong {
  display: block;
  margin-bottom: .35rem;
  color: var(--navy);
}
.magi-card span {
  color: var(--muted);
  font-size: .9rem;
  line-height: 1.45;
}
@media (max-width: 620px) {
  .magi-compare { grid-template-columns: 1fr; }
}

/* V11: marginal-rate glasses. The yellow band is the income removed by the
   deduction; the annotation sits beside the glass instead of covering it. */
.glasses-row {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: clamp(1.2rem, 4vw, 3rem);
  min-height: 220px;
  padding: .5rem 0 .2rem;
}
.glass-stage {
  position: relative;
  flex: 0 0 145px;
  min-height: 198px;
}
.glass-stage .tax-glass {
  margin: 0 auto;
}
.glass-stage .glass-label {
  position: static;
  width: auto;
  margin-top: .82rem;
  transform: none;
}
.glass-stage-marginal {
  flex-basis: 315px;
  padding-right: 165px;
}
.glass-deduction-demo .glass-liquid {
  height: 52%;
}
.deduction-layer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 52%;
  height: 18%;
  z-index: 2;
  background: linear-gradient(180deg, #ffd95a 0%, #f3bc2d 100%);
  border-top: 1px solid rgba(122, 88, 0, .25);
}
.deduction-side-label {
  position: absolute;
  left: 164px;
  top: 48px;
  width: 145px;
  padding: .48rem .55rem;
  border: 1px solid #efd16f;
  border-radius: 9px;
  background: #fffaf0;
  color: #805b00;
  font-size: .76rem;
  line-height: 1.25;
  box-shadow: 0 2px 8px rgba(8,38,90,.06);
}
.deduction-side-label span {
  display: block;
  margin-bottom: .16rem;
  font-weight: 800;
}
.deduction-side-label small {
  display: block;
  font-size: .72rem;
}
.deduction-side-label i {
  position: absolute;
  right: 100%;
  top: 50%;
  width: 42px;
  border-top: 3px solid #c99b16;
  transform: translateY(-50%);
}
.deduction-side-label i::before {
  content: "";
  position: absolute;
  left: -1px;
  top: -6px;
  width: 0;
  height: 0;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-right: 8px solid #c99b16;
}
@media (max-width: 720px) {
  .glasses-row { gap: .7rem; }
  .glass-stage { flex-basis: 100px; min-height: 170px; }
  .glass-stage-marginal { flex-basis: 205px; padding-right: 102px; }
  .glass-stage .tax-glass { width: 92px; height: 125px; }
  .deduction-side-label { left: 104px; top: 35px; width: 98px; padding: .35rem .4rem; font-size: .63rem; }
  .deduction-side-label small { font-size: .59rem; }
  .deduction-side-label i { width: 18px; }
}
@media (max-width: 480px) {
  .glasses-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: .35rem; }
  .glass-stage { min-width: 0; width: auto; }
  .glass-stage-marginal { padding-right: 0; }
  .glass-stage .tax-glass { width: 74px; height: 108px; }
  .glass-stage .glass-label { font-size: .69rem; }
  .deduction-side-label {
    left: 50%;
    top: 118px;
    width: 112px;
    transform: translateX(-50%);
    text-align: center;
  }
  .deduction-side-label i { display: none; }
  .glass-stage-marginal { min-height: 218px; }
}

/* V11: compact topic buttons in a true two-column grid -------------------- */
.topic-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 325px));
  justify-content: start;
  align-items: stretch;
  gap: 1rem 1rem;
  margin: 1.3rem 0 1.9rem;
}
.topic-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: .78rem .9rem;
}
.topic-card strong { font-size: .96rem; }
.topic-card span { font-size: .84rem; line-height: 1.35; }
@media (max-width: 640px) {
  .topic-grid { grid-template-columns: minmax(0, 1fr); }
}

/* Pandoc may wrap the raw topic-card links in a paragraph. Let the links
   participate directly in the grid. */
.topic-grid > p { display: contents; }

/* V13: Traditional vs. Roth timing comparison ----------------------------- */
.retirement-timing {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin: 1.25rem 0 1.5rem;
}
.retirement-timing-card {
  border: 1px solid var(--line, #cbd9ea);
  border-radius: 16px;
  padding: 1.15rem 1.2rem;
  text-align: center;
  background: #f8fbff;
  box-shadow: 0 4px 14px rgba(21, 55, 94, .06);
}
.retirement-timing-card.traditional-card {
  border-top: 5px solid #1f67b1;
}
.retirement-timing-card.roth-card {
  border-top: 5px solid #7a4fb3;
}
.retirement-timing-label {
  font-weight: 800;
  font-size: 1.12rem;
  margin-bottom: .65rem;
}
.retirement-timing-big {
  font-weight: 800;
  font-size: 1.32rem;
  color: #102f5d;
}
.retirement-timing-arrow {
  font-size: 1.4rem;
  line-height: 1.25;
  margin: .12rem 0;
  color: #526b8a;
}
.retirement-timing-note {
  margin-top: .7rem;
  color: #4a5b70;
  font-size: .94rem;
  line-height: 1.45;
}
@media (max-width: 680px) {
  .retirement-timing { grid-template-columns: 1fr; }
}
@media print {
  .retirement-timing-card { box-shadow: none; }
}

/* V14: clearer Traditional/Roth timing meanings */
.retirement-timing-meaning {
  margin: .45rem auto .25rem;
  max-width: 33rem;
  color: #42566f;
  font-size: .92rem;
  line-height: 1.42;
}
.retirement-timing-card .retirement-timing-big + .retirement-timing-meaning {
  min-height: 4.2rem;
}
@media (max-width: 680px) {
  .retirement-timing-card .retirement-timing-big + .retirement-timing-meaning { min-height: 0; }
}

/* Current-year examples --------------------------------------------------- */
.callout.current-year {
  background: #f5f8fc;
  border-color: #c7d4e5;
}
.callout.current-year h2 { color: #35506f; }

/* Tax-year selector --------------------------------------------------------
   Current-year examples pull their amounts from data/YYYY.json. The selector
   lives in the sticky header so students can switch years without losing
   reading space.
*/
.tax-year-control {
  display: flex;
  align-items: center;
  gap: .4rem;
  flex: 0 0 auto;
  white-space: nowrap;
}
.tax-year-control-label {
  color: rgba(255,255,255,.9);
  font-size: .76rem;
  font-weight: 700;
  letter-spacing: .02em;
}
.tax-year-select {
  height: 38px;
  min-width: 78px;
  padding: .3rem 1.65rem .3rem .55rem;
  border: 1px solid rgba(255,255,255,.48);
  border-radius: 8px;
  background: rgba(255,255,255,.98);
  color: var(--ink);
  font: inherit;
  font-size: .84rem;
  line-height: 1.1;
  cursor: pointer;
}
.tax-year-select:hover { border-color: white; }
.tax-year-select:focus {
  outline: 3px solid rgba(255,255,255,.25);
  border-color: white;
}
/* Keep short year/amount replacements together, but let longer year-specific
   explanation text wrap naturally inside its callout. */
.tax-year-value[data-tax-format="money"],
.tax-year-value[data-tax-format="year"] {
  white-space: nowrap;
}
.tax-year-value[data-tax-format="text"] {
  white-space: normal;
  overflow-wrap: anywhere;
}

@media (max-width: 980px) {
  .header-page-jump { max-width: 285px; flex-basis: 260px; }
  .tax-year-control-label { display: none; }
}

@media (max-width: 650px) {
  .tax-year-select {
    min-width: 70px;
    height: 36px;
    padding-left: .45rem;
    font-size: .78rem;
  }
  .header-page-jump { max-width: 190px; min-width: 90px; }
}

@media (max-width: 520px) {
  .tax-year-control { flex: 0 0 auto; }
  .tax-year-select {
    min-width: 80px;
    width: 80px;
    padding-left: .5rem;
    padding-right: 1.35rem;
    font-size: .8rem;
  }
  .page-jump-select { font-size: .76rem; }
}

@media print {
  .tax-year-control { display: none !important; }
}


/* v46 recovered-current components */
.concept-flow,.self-employed-benefits{margin:1.25rem 0 1.6rem;border:1px solid #d6d6d6;border-radius:14px;padding:1rem 1.1rem;background:#fbfbfb}.concept-flow-title,.self-employed-benefits-title{font-weight:700;margin-bottom:.85rem}.concept-flow-grid{display:grid;grid-template-columns:1fr auto 1fr;gap:.7rem;align-items:stretch}.concept-flow-grid.three{grid-template-columns:1fr auto 1fr auto 1fr}.concept-card{border:1px solid #d8d8d8;border-radius:12px;padding:.9rem;background:#fff;display:flex;flex-direction:column;gap:.3rem}.concept-card em{font-style:normal;color:#555}.concept-arrow{display:flex;align-items:center;justify-content:center;font-weight:700;font-size:1.25rem}.mini-cards,.comparison-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:.75rem;margin:1rem 0}.mini-cards{grid-template-columns:repeat(3,minmax(0,1fr))}.comparison-grid.three{grid-template-columns:repeat(3,minmax(0,1fr))}.mini-cards>div,.comparison-grid>div{border:1px solid #d8d8d8;border-radius:12px;padding:.9rem;background:#fff}.mini-cards strong,.mini-cards span,.comparison-grid strong,.comparison-grid span{display:block}.mini-cards span,.comparison-grid span{margin-top:.25rem;color:#555}.self-employed-benefits-grid{display:grid;grid-template-columns:1fr auto 1fr;gap:.8rem;align-items:stretch}.self-employed-benefits-card{border:1px solid #d8d8d8;border-radius:12px;padding:.95rem;background:#fff}.self-employed-benefits-kicker{font-size:.78rem;font-weight:700;letter-spacing:.04em;color:#555;margin-bottom:.3rem}.self-employed-benefits-main{font-weight:700;margin-bottom:.7rem}.self-employed-benefits-row{display:flex;justify-content:space-between;gap:1rem;padding:.45rem 0;border-top:1px solid #e3e3e3}.self-employed-benefits-row span{color:#555}.self-employed-benefits-row strong{text-align:right}.self-employed-benefits-arrow{display:flex;align-items:center;justify-content:center;font-size:1.5rem;font-weight:700;color:#666}.self-employed-benefits-caption{margin-top:.8rem;font-size:.95rem;color:#555}@media(max-width:760px){.concept-flow-grid,.concept-flow-grid.three,.self-employed-benefits-grid,.mini-cards,.comparison-grid,.comparison-grid.three{grid-template-columns:1fr}.concept-arrow,.self-employed-benefits-arrow{transform:rotate(90deg);min-height:1.4rem}.self-employed-benefits-row{display:block}.self-employed-benefits-row strong{display:block;text-align:left;margin-top:.15rem}}
