:root {
  --ink: #1f2a44;
  --ink-soft: #4a5570;
  --paper: #f6f1e7;
  --card: #fffdf8;
  --line: #ddd3c2;
  --ochre: #c8892b;
  --ochre-dark: #8a5a14;
  --green: #2f6f4e;
  --radius: 6px;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 80px; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.65;
  color: var(--ink);
  background: var(--paper);
}

a { color: var(--ochre-dark); text-underline-offset: 3px; }
a:hover { color: var(--ink); }
:focus-visible { outline: 3px solid var(--ochre); outline-offset: 2px; }

h1, h2, h3 { line-height: 1.2; letter-spacing: -0.01em; margin: 0 0 0.6em; }
h1 { font-size: clamp(2rem, 4.5vw, 3.2rem); font-weight: 800; max-width: 20ch; }
h2 { font-size: 1.6rem; font-weight: 750; }
h3 { font-size: 1.12rem; font-weight: 700; }
h3 a { color: inherit; }

.wrap { width: min(1140px, 100% - 40px); margin-inline: auto; }

.skip { position: absolute; left: -999px; top: 0; background: var(--ink); color: #fff; padding: 8px 14px; z-index: 50; }
.skip:focus { left: 8px; top: 8px; }

/* Header */
.top { background: var(--ink); color: #fff; position: sticky; top: 0; z-index: 20; }
.top__row { display: flex; align-items: center; justify-content: space-between; gap: 8px 20px; min-height: 64px; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 800; font-size: 1.15rem; min-height: 48px; }
.brand__mark { width: 28px; height: 28px; fill: var(--ochre); }
.nav { display: flex; gap: 4px 6px; flex-wrap: wrap; }
.nav a { color: #e9e4d8; text-decoration: none; font-size: 0.95rem; padding: 12px 10px; border-radius: var(--radius); }
.nav a:hover, .nav a[aria-current="page"] { color: #fff; background: rgba(255, 255, 255, 0.08); }
.nav a[aria-current="page"] { box-shadow: inset 0 -3px 0 var(--ochre); }

.notice { background: #ebe3d3; border-bottom: 1px solid var(--line); font-size: 0.88rem; color: var(--ink-soft); padding: 6px 0; }
.notice a { display: inline-block; padding: 6px 0; }

/* Intro */
.intro { padding: 40px 0 36px; }
.intro__meta { font-size: 0.92rem; color: var(--ink-soft); margin: 0 0 14px; }
.lead { font-size: 1.15rem; max-width: 62ch; color: var(--ink-soft); }
.intro__actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 26px; }

.crumbs { font-size: 0.88rem; color: var(--ink-soft); margin-bottom: 18px; }
.crumbs a { color: var(--ink-soft); display: inline-block; padding: 12px 4px 12px 0; }

/* Buttons */
.btn { display: inline-block; padding: 12px 22px; border-radius: var(--radius); font-weight: 700; text-decoration: none; font-size: 1rem; border: 2px solid var(--ink); cursor: pointer; font-family: inherit; min-height: 48px; }
.btn--solid { background: var(--ochre); border-color: var(--ochre); color: #1b1408; }
.btn--solid:hover { background: var(--ochre-dark); border-color: var(--ochre-dark); color: #fff; }
.btn--line { background: transparent; color: var(--ink); }
.btn--line:hover { background: var(--ink); color: #fff; }
.btn--small { padding: 9px 16px; font-size: 0.9rem; min-height: 44px; }

/* Layout with sticky contents */
.layout { display: grid; grid-template-columns: 230px 1fr; gap: 48px; padding-bottom: 64px; align-items: start; }
.toc--mob { display: none; }
.toc { position: sticky; top: 88px; border-left: 1px solid var(--line); padding-left: 16px; font-size: 0.92rem; }
.toc__title { font-weight: 700; margin: 0 0 6px; cursor: pointer; list-style: none; padding: 4px 0; }
.toc__title::-webkit-details-marker { display: none; }
.toc ul { margin: 0; padding: 0; list-style: none; }
.toc a { color: var(--ink-soft); text-decoration: none; display: block; padding: 4px 0; }
.toc a:hover, .toc a.is-active { color: var(--ink); text-decoration: underline; }

.content { min-width: 0; }
.block { padding: 36px 0; border-top: 1px solid var(--line); }
.block:first-child { border-top: 0; padding-top: 0; }

.small { font-size: 0.92rem; color: var(--ink-soft); }

/* Brief */
.brief { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin: 0 0 12px; }
.brief div { background: var(--card); padding: 16px 18px; }
.brief dt { font-size: 0.86rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-soft); font-weight: 700; }
.brief dd { margin: 4px 0 0; }

/* Lists */
.pluses { list-style: none; padding: 0; margin: 0 0 20px; }
.pluses li { padding: 12px 0; border-bottom: 1px dashed var(--line); }
.steps, .timeline { padding-left: 22px; }
.steps li, .timeline li { margin: 0 0 10px; padding-left: 4px; }
.timeline { border-left: 1px solid var(--line); list-style: none; padding-left: 20px; }
.callout { background: var(--ink); color: #f3eee3; padding: 18px 22px; border-radius: var(--radius); margin: 0; }

/* Cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; display: flex; flex-direction: column; }
.card p { margin: 0 0 10px; font-size: 0.95rem; }
.card ul { margin: 0; padding-left: 20px; font-size: 0.95rem; }
.card__use { font-weight: 600; color: var(--green); }
.card .card__watch { margin-top: auto; font-size: 0.88rem; color: var(--ink-soft); }
.card__watch span { font-weight: 700; color: var(--ink); }
.cta-line { margin: 24px 0 0; }

/* Table */
.table-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); margin-bottom: 12px; }
.compare { width: 100%; border-collapse: collapse; min-width: 520px; font-size: 0.95rem; }
.compare caption { text-align: left; padding: 12px 16px; font-weight: 700; }
.compare th, .compare td { padding: 11px 16px; border-top: 1px solid var(--line); text-align: left; vertical-align: top; }
.compare thead th { background: var(--ink); color: #fff; border-top: 0; }
.compare tbody th { font-weight: 600; color: var(--ink-soft); }

/* Checklist */
.checklist { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; }
.checklist ul { list-style: none; padding: 0; margin: 0 0 16px; }
.checklist li { border-bottom: 1px solid var(--line); }
.checklist label { display: flex; gap: 12px; padding: 11px 0; cursor: pointer; min-height: 48px; }
.checklist input { width: 22px; height: 22px; margin-top: 3px; accent-color: var(--green); flex: none; }
.checklist label:has(input:checked) { color: var(--ink-soft); text-decoration: line-through; }
.checklist__progress { font-weight: 700; margin: 0 0 6px; }

/* Calculator */
.calc { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-bottom: 12px; }
.calc__fields { display: grid; gap: 14px; }
.calc label { display: grid; gap: 6px; font-weight: 600; font-size: 0.95rem; }
.calc input, .calc select { font: inherit; font-weight: 400; padding: 10px 12px; min-height: 48px; border: 1px solid #b9ad97; border-radius: var(--radius); background: #fff; color: var(--ink); width: 100%; }
.calc__out { display: grid; gap: 1px; background: var(--line); border-radius: var(--radius); overflow: hidden; align-content: start; }
.calc__out div { background: var(--paper); padding: 14px 16px; }
.calc__label { display: block; font-size: 0.86rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-soft); font-weight: 700; }
.calc output { font-size: 1.6rem; font-weight: 800; font-variant-numeric: tabular-nums; }

/* FAQ */
details:not(.toc) { border-bottom: 1px solid var(--line); padding: 4px 0; }
details:not(.toc) summary { cursor: pointer; font-weight: 650; padding: 12px 0; }
details:not(.toc) p { margin: 0 0 12px; color: var(--ink-soft); }

/* Related and sources */
.related { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.related__item { display: block; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; text-decoration: none; color: var(--ink); }
.related__item:hover { border-color: var(--ochre); }
.related__title { display: block; font-weight: 700; margin-bottom: 4px; color: var(--ochre-dark); }
.related__text { display: block; font-size: 0.9rem; color: var(--ink-soft); }
.sources { padding-left: 20px; font-size: 0.92rem; }
.sources li { margin: 0 0 6px; overflow-wrap: anywhere; }

.block--end { background: #ebe3d3; border-radius: var(--radius); padding: 32px; border-top: 0; margin: 20px 0 36px; }

/* Plain pages */
.page { padding: 40px 0 72px; max-width: 760px; }
.page h1 { font-size: clamp(1.9rem, 4vw, 2.6rem); max-width: none; }
.page h2 { margin-top: 1.6em; }

/* Footer */
.foot { background: var(--ink); color: #cfd4df; padding: 40px 0 24px; font-size: 0.9rem; }
.foot a { color: #e9e4d8; display: inline-block; padding: 12px 0; }
.foot__grid li { line-height: 1.2; }
.foot__grid { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 32px; }
.foot__grid ul { list-style: none; margin: 0; padding: 0; }
.foot__h { font-weight: 700; color: #fff; margin: 0 0 6px; }
.foot__brand { font-weight: 800; color: #fff; font-size: 1.05rem; margin: 0 0 6px; }
.foot__legal { border-top: 1px solid #36415c; margin-top: 28px; padding-top: 16px; font-size: 0.8rem; }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; gap: 0; }
  .toc { position: static; margin-bottom: 28px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 16px; }
  .toc__title::after { content: " +"; color: var(--ochre-dark); }
  .toc[open] .toc__title::after { content: " −"; }
  .toc a { padding: 8px 0; }
  .brief { grid-template-columns: 1fr; }
  .calc { grid-template-columns: 1fr; }
  .foot__grid { grid-template-columns: 1fr; gap: 20px; }
  .top { position: static; }
  .nav { margin: 0 -10px 6px; }
}

@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

/* Key facts summary (top of each guide) */
.keyfacts { margin-top: 28px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 20px; max-width: 760px; }
.keyfacts__title { font-weight: 800; margin: 0 0 6px; }
.keyfacts ul { margin: 0; padding-left: 20px; }
.keyfacts li { margin: 4px 0; }

/* Figures */
.figure { margin: 20px 0; }
.timeline-svg { width: 100%; height: auto; max-width: 640px; display: block; font-family: var(--font); }
.figure figcaption { font-size: 0.92rem; color: var(--ink-soft); margin-top: 6px; }

/* Scrollable tables: focusable, with edge shadows as a scroll cue */
.table-scroll:focus-visible { outline: 3px solid var(--ochre); outline-offset: 2px; }
.table-scroll {
  background:
    linear-gradient(to right, var(--card) 30%, rgba(255, 253, 248, 0)) left center / 40px 100% no-repeat local,
    linear-gradient(to left, var(--card) 30%, rgba(255, 253, 248, 0)) right center / 40px 100% no-repeat local,
    linear-gradient(to right, rgba(31, 42, 68, 0.18), rgba(31, 42, 68, 0)) left center / 14px 100% no-repeat scroll,
    linear-gradient(to left, rgba(31, 42, 68, 0.18), rgba(31, 42, 68, 0)) right center / 14px 100% no-repeat scroll,
    var(--card);
}

/* Review verdict */
.verdict { font-size: 1.1rem; font-weight: 600; }
.cards--two { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); margin-top: 16px; }
.card ul li { margin: 4px 0; }

/* Calculator hints */
.calc__hint { font-weight: 400; font-size: 0.86rem; color: var(--ink-soft); }
.calc__note { grid-column: 1 / -1; margin: 0; color: #8a2a14; font-weight: 600; min-height: 0; }
.calc__note:empty { display: none; }
.calc input[aria-invalid="true"] { border-color: #8a2a14; }

/* Related links: larger tap targets */
.related__item { min-height: 48px; }

@media (max-width: 860px) {
  .toc--desk { display: none; }
  .toc--mob { display: block; margin-bottom: 16px; }
  .layout > .content > .block:first-child h2 { margin-bottom: 0.4em; }
  .top__row { min-height: 0; padding: 6px 0 0; }
  .nav { flex-wrap: nowrap; overflow-x: auto; margin: 0 -20px; padding: 0 20px 4px; scrollbar-width: none; }
  .nav::-webkit-scrollbar { display: none; }
  .nav a { white-space: nowrap; padding: 12px 10px; }
  .intro { padding: 18px 0 28px; }
  .crumbs { margin-bottom: 6px; }
  .intro__meta { margin-bottom: 8px; }
  h1 { font-size: 1.9rem; }
  .lead { font-size: 1.05rem; }
  .intro__actions { margin-top: 18px; }
}
