  @import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=DM+Sans:wght@300;400;500;600;700&display=swap');

  /* Page-local aliases, matching the Samples & Guides page this one is built
     after. Everything else comes from dark.css / light.css / shared.css. */
  :root {
    --surface:     #162033;
    --card:        #1C2942;
    --label:       #A8B6CF;
    --mono:        'DM Mono', monospace;
    --sans:        'DM Sans', sans-serif;
    --radius:      10px;
    --radius-card: 14px;
    /* Six chart series, one per loan shape on the comparison card. Chosen for
       hue separation rather than for the palette they sit in, because six
       balance curves share one set of axes there. */
    --lt-1:#8DBBFF; --lt-2:#FFD28C; --lt-3:#8FCDBD;
    --lt-4:#FF8B8B; --lt-5:#C9A6FF; --lt-6:#A8B6CF;
    /* The two halves of a repayment: what clears the debt, and what does not. */
    --c-principal:#8FCDBD;
    --c-interest: #FFD28C;
    --c-balance:  #8DBBFF;
    --c-residual: #C9A6FF;
  }

  body.light {
    --surface:     #FFFFFF;
    --card:        #FFFFFF;
    --label:       #7F8C8D;
    --shadow:      0 2px 16px rgba(120,160,220,0.10);
    --lt-1:#3A71C8; --lt-2:#B45309; --lt-3:#1F8A6B;
    --lt-4:#C0392B; --lt-5:#6D48B8; --lt-6:#5B6B7F;
    --c-principal:#1F8A6B;
    --c-interest: #B45309;
    --c-balance:  #3A71C8;
    --c-residual: #6D48B8;
  }

  *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

  body {
    font-family: var(--sans);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    font-size: 14px;
    line-height: 1.5;
    display: flex;
    flex-direction: column;
    transition: background 0.25s, color 0.25s;
  }

  /* ── HEADER ─────────────────────────────────────────────────────── */
  header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 8px 24px 10px;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 100;
  }
  .header-left { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; min-width: 0; }
  .header-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
  .header-nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
  .header-text { min-width: 0; }
  .header-title {
    font-family: var(--mono);
    font-weight: 600;
    font-size: 15px;
    color: var(--accent);
    letter-spacing: 0.04em;
  }
  .header-subtitle { font-size: 12px; color: var(--muted); margin-top: 2px; }
  .back-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 3px 8px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text);
    background: var(--bg);
    text-decoration: none;
    transition: border-color 0.15s, color 0.15s;
    white-space: nowrap;
  }
  .back-link:hover { border-color: var(--accent); color: var(--accent); }
  .btn-theme {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 3px 10px;
    font-size: 11px;
    font-weight: 600;
    color: var(--muted);
    background: var(--bg);
    cursor: pointer;
    font-family: var(--sans);
    transition: border-color 0.15s, color 0.15s, background 0.15s;
    white-space: nowrap;
  }
  .btn-theme:hover { border-color: var(--accent); color: var(--text); }

  /* ── MAIN ────────────────────────────────────────────────────────── */
  main {
    flex: 1;
    max-width: 900px;
    width: 100%;
    margin: 0 auto;
    padding: 32px 24px 60px;
  }

  .page-hero { margin-bottom: 28px; }
  .page-hero h1 {
    font-family: var(--mono);
    font-size: 22px;
    font-weight: 600;
    color: var(--accent);
    letter-spacing: 0.03em;
    margin-bottom: 8px;
  }
  .page-hero p {
    font-size: 13.5px;
    color: var(--muted);
    line-height: 1.65;
    max-width: 660px;
  }

  /* ── SECTION CARDS ───────────────────────────────────────────────── */
  .section-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    margin-bottom: 20px;
    box-shadow: var(--shadow);
    overflow: visible;
  }
  .section-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    border-radius: var(--radius-card) var(--radius-card) 0 0;
    cursor: pointer;
    user-select: none;
  }
  .section-header.collapsed { border-bottom: none; border-radius: var(--radius-card); }
  .section-header h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    flex: 1;
    margin: 0;
    text-transform: none;
    letter-spacing: normal;
  }
  .toggle-icon { color: var(--muted); font-size: 12px; transition: transform 0.2s; flex-shrink: 0; }
  .section-header.collapsed .toggle-icon { transform: rotate(-90deg); }
  .section-body { padding: 20px; }
  .section-body.hidden { display: none; }

  .type-num {
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 600;
    color: var(--accent);
    background: rgba(141,187,255,0.12);
    border: 1px solid rgba(141,187,255,0.25);
    border-radius: 6px;
    padding: 2px 7px;
    flex-shrink: 0;
  }
  body.light .type-num {
    background: rgba(90,145,232,0.12);
    border-color: rgba(90,145,232,0.25);
    color: var(--accent);
  }
  .qs-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 11.5px;
    color: var(--muted);
    background: rgba(141,187,255,0.07);
    border: 1px solid rgba(141,187,255,0.18);
    border-radius: var(--radius);
    padding: 6px 11px;
    margin-bottom: 10px;
    line-height: 1.45;
  }
  body.light .qs-badge {
    background: rgba(90,145,232,0.06);
    border-color: rgba(90,145,232,0.18);
  }
  .qs-badge b { color: var(--accent); font-weight: 600; }
  .qs-badge .qs-icon { color: var(--accent); flex-shrink: 0; }

  .try-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    border: 1px solid rgba(143,205,189,0.35);
    border-radius: var(--radius);
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 600;
    color: var(--accent2);
    background: rgba(143,205,189,0.08);
    text-decoration: none;
    transition: border-color 0.15s, background 0.15s;
    white-space: nowrap;
    flex-shrink: 0;
  }
  .try-link:hover { border-color: var(--accent2); background: rgba(143,205,189,0.16); }
  body.light .try-link {
    background: rgba(46,158,122,0.08);
    border-color: rgba(46,158,122,0.35);
    color: var(--accent2);
  }
  body.light .try-link:hover { background: rgba(46,158,122,0.16); border-color: var(--accent2); }

  /* ── SUB-SECTIONS ────────────────────────────────────────────────── */
  .sub-section { margin-bottom: 24px; }
  .sub-section:last-child { margin-bottom: 0; }
  .sub-section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 12px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
  }
  .step-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(141,187,255,0.12);
    border: 1px solid rgba(141,187,255,0.28);
    font-size: 12px;
    color: var(--accent);
    flex-shrink: 0;
  }
  body.light .step-badge {
    background: rgba(90,145,232,0.12);
    border-color: rgba(90,145,232,0.28);
    color: var(--accent);
  }

  .objective-text { font-size: 13.5px; color: var(--text); line-height: 1.7; }
  .objective-text + .objective-text { margin-top: 10px; }
  .objective-text strong { color: var(--text); font-weight: 600; }

  /* ── WHERE YOU MEET IT ───────────────────────────────────────────── */
  /* A structure is a local habit as much as a formula: the same shape is sold
     as a novated lease in Perth and as a PCP in Dublin. The chips name the
     markets a reader is most likely to have met it in. */
  .where-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 8px;
    margin-top: 12px;
    padding-top: 11px;
    border-top: 1px dashed var(--border);
  }
  .where-label {
    font-size: 10.5px;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    margin-right: 2px;
  }
  .where-chip {
    font-size: 12px;
    line-height: 1.45;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-pill, 999px);
    padding: 3px 10px;
  }
  .where-chip b {
    font-weight: 600;
    color: var(--accent2);
  }

  .assumption-list { list-style: none; padding: 0; }
  .assumption-list li {
    font-size: 13px;
    color: var(--text);
    line-height: 1.65;
    padding: 3px 0 3px 18px;
    position: relative;
  }
  .assumption-list li::before { content: '-'; position: absolute; left: 0; color: var(--muted); }
  .assumption-list code,
  .hint code,
  .objective-text code,
  .faq-answer code,
  .ref-table td code {
    font-family: var(--mono);
    font-size: 12px;
    color: var(--accent);
    background: rgba(141,187,255,0.1);
    border-radius: 4px;
    padding: 1px 5px;
  }
  body.light .assumption-list code,
  body.light .hint code,
  body.light .objective-text code,
  body.light .faq-answer code,
  body.light .ref-table td code {
    background: rgba(90,145,232,0.10);
    color: var(--accent);
  }

  .hint { font-size: 12.5px; color: var(--muted); line-height: 1.6; }
  .hint + .hint { margin-top: 8px; }
  .hint strong { color: var(--text); font-weight: 600; }

  /* ── EQUATIONS ───────────────────────────────────────────────────── */
  .eq-block {
    background: rgba(141,187,255,0.05);
    border: 1px solid rgba(141,187,255,0.14);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin: 2px 0 12px;
  }
  body.light .eq-block {
    background: rgba(90,145,232,0.05);
    border-color: rgba(90,145,232,0.15);
  }
  .eq {
    font-family: var(--mono);
    font-size: 14px;
    color: var(--text);
    line-height: 2.1;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0 2px;
    overflow-x: auto;
  }
  .eq + .eq { margin-top: 6px; }
  .eq .lhs { color: var(--accent); font-weight: 500; }
  .eq .cmt { color: var(--muted); font-size: 12px; font-family: var(--sans); margin-left: 10px; }
  .frac {
    display: inline-flex;
    flex-direction: column;
    text-align: center;
    margin: 0 0.35em;
    vertical-align: middle;
  }
  .frac .num { padding: 0 0.5em 3px; }
  .frac .den { padding: 3px 0.5em 0; border-top: 1px solid currentColor; }

  .eq-where {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 18px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed var(--border);
    font-size: 12px;
    color: var(--muted);
  }
  .eq-where span b {
    font-family: var(--mono);
    color: var(--accent);
    font-weight: 500;
    margin-right: 4px;
  }

  /* ── KEY FIGURES ─────────────────────────────────────────────────── */
  .fig-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin: 12px 0 14px;
  }
  .fig {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 12px;
  }
  .fig .fig-k {
    font-size: 10.5px;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 5px;
  }
  .fig .fig-v {
    font-family: var(--mono);
    font-size: 15px;
    font-weight: 500;
    color: var(--text);
    line-height: 1.3;
    word-break: break-word;
  }
  .fig .fig-sub { font-size: 11px; color: var(--muted); margin-top: 3px; }
  .fig.warn .fig-v { color: var(--gold); }
  .fig.good .fig-v { color: var(--accent2); }

  /* ── CHARTS ──────────────────────────────────────────────────────── */
  .chart-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
    margin: 14px 0;
  }
  .chart-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px 10px;
    overflow: hidden;
  }
  .chart-title {
    font-size: 11px;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    margin-bottom: 8px;
  }
  .chart-slot svg { display: block; max-width: 100%; }
  .chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 16px;
    margin-top: 8px;
    font-size: 11.5px;
    color: var(--muted);
  }
  .chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
  .chart-legend i {
    width: 16px;
    height: 3px;
    border-radius: 2px;
    flex-shrink: 0;
    display: inline-block;
  }
  .chart-legend i.box { height: 10px; width: 10px; border-radius: 2px; }
  .chart-caption { font-size: 12px; color: var(--muted); line-height: 1.55; margin-top: 8px; }

  /* ── SHAPE GRID (at a glance) ────────────────────────────────────── */
  .shape-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-top: 14px;
  }
  .shape-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 11px 13px 9px;
    text-decoration: none;
    color: inherit;
    display: block;
    transition: border-color 0.15s, transform 0.15s;
  }
  .shape-item:hover { border-color: var(--accent); transform: translateY(-1px); }
  .shape-head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
  }
  .shape-badge {
    font-family: var(--mono);
    font-size: 10.5px;
    font-weight: 600;
    color: var(--accent2);
    background: rgba(143,205,189,0.10);
    border: 1px solid rgba(143,205,189,0.28);
    border-radius: 6px;
    padding: 1px 6px;
    flex-shrink: 0;
  }
  body.light .shape-badge {
    background: rgba(46,158,122,0.10);
    border-color: rgba(46,158,122,0.28);
    color: var(--accent2);
  }
  .shape-item p { font-size: 12px; color: var(--muted); line-height: 1.55; margin: 0 0 6px; }
  .shape-spark { line-height: 0; }

  /* ── TABLES ──────────────────────────────────────────────────────── */
  .table-wrap { overflow-x: auto; margin: 12px 0; }
  .ref-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12.5px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    min-width: 460px;
  }
  .ref-table th {
    background: var(--surface);
    color: var(--label);
    font-weight: 600;
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 7px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
  }
  .ref-table td {
    padding: 7px 12px;
    border-bottom: 1px solid var(--border);
    color: var(--muted);
    vertical-align: top;
    line-height: 1.5;
  }
  .ref-table tbody tr:last-child td { border-bottom: none; }
  .ref-table td:first-child { color: var(--text); font-weight: 500; }
  .ref-table td.num, .ref-table th.num { text-align: right; font-family: var(--mono); white-space: nowrap; }
  .ref-table tr.hl td { background: rgba(255,210,140,0.08); }
  body.light .ref-table tr.hl td { background: rgba(180,83,9,0.06); }
  .ref-table td .swatch {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 2px;
    margin-right: 7px;
    vertical-align: baseline;
  }
  .table-note { font-size: 11.5px; color: var(--muted); line-height: 1.55; margin-top: -4px; }

  /* ── CALLOUT ─────────────────────────────────────────────────────── */
  .callout {
    display: flex;
    gap: 10px;
    background: rgba(255,210,140,0.07);
    border: 1px solid rgba(255,210,140,0.22);
    border-radius: var(--radius);
    padding: 11px 14px;
    margin: 12px 0;
    font-size: 12.5px;
    color: var(--text);
    line-height: 1.6;
  }
  body.light .callout {
    background: rgba(180,83,9,0.06);
    border-color: rgba(180,83,9,0.20);
  }
  .callout .callout-icon { color: var(--gold); flex-shrink: 0; font-size: 13px; }
  .callout strong { color: var(--text); font-weight: 600; }

  /* ── FAQ ─────────────────────────────────────────────────────────── */
  .faq-list { margin-top: 4px; }
  .faq-item { border-bottom: 1px solid var(--border); }
  .faq-item:last-child { border-bottom: none; }
  .faq-question {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 13px 4px;
    cursor: pointer;
    user-select: none;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text);
    transition: color 0.15s;
  }
  .faq-question:hover { color: var(--accent); }
  .faq-toggle { color: var(--muted); font-size: 12px; margin-left: auto; transition: transform 0.2s; flex-shrink: 0; }
  .faq-question.open .faq-toggle { transform: rotate(180deg); }
  .faq-answer { display: none; padding: 0 4px 16px; }
  .faq-answer.open { display: block; }
  .faq-answer p { font-size: 13px; color: var(--muted); line-height: 1.65; margin-bottom: 8px; }
  .faq-answer p:last-child { margin-bottom: 0; }
  .faq-answer strong { color: var(--text); font-weight: 600; }
  .faq-answer a { color: var(--accent); text-decoration: none; }
  .faq-answer a:hover { text-decoration: underline; }

  /* ── FOOTER ──────────────────────────────────────────────────────── */
  .app-footer {
    border-top: 1px solid var(--border);
    padding: 12px 20px 14px;
    background: var(--bg);
    flex-shrink: 0;
  }
  .app-footer p { font-size: 11px; color: var(--muted); line-height: 1.6; margin-bottom: 5px; }
  .app-footer a { color: var(--accent); text-decoration: none; }
  .app-footer a:hover { text-decoration: underline; }

  /* ── MOBILE ──────────────────────────────────────────────────────── */
  @media (max-width: 860px) {
    .shape-grid { grid-template-columns: repeat(2, 1fr); }
    .fig-grid { grid-template-columns: repeat(2, 1fr); }
  }
  @media (max-width: 768px) {
    header { padding: 8px 12px; align-items: flex-start; }
    .header-left { gap: 6px; }
    main { padding: 20px 14px 40px; }
    .page-hero h1 { font-size: 18px; }
    .section-body { padding: 14px; }
    .eq { font-size: 12.5px; }
    .section-header h3 { font-size: 13px; }
  }
  @media (max-width: 520px) {
    .shape-grid { grid-template-columns: 1fr; }
  }
