:root {
  color-scheme: dark;
  --bg: #0a1220;
  --panel: #131f30;
  --panel-alt: #1a293d;
  --sidebar: #101a2a;
  --text: #edf2fa;
  --muted: #b4c4d9;
  --subtle: #9aaac1;
  --border: #2d3e54;
  --accent: #ffbf59;
  --accent-text: #251604;
  --brand: #84a9ef;
  --success: #48d6a0;
  --danger: #ff8790;
  --hero-a: #222743;
  --hero-b: #102f3a;
  --shadow: 0 12px 28px #0002;
  font: 16px/1.55 "Segoe UI", system-ui, -apple-system, sans-serif;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f1f5fb;
  --panel: #ffffff;
  --panel-alt: #e9f0f8;
  --sidebar: #f9fbff;
  --text: #1b293c;
  --muted: #465972;
  --subtle: #50647d;
  --border: #c1cfdf;
  --accent: #8b4e03;
  --accent-text: #fff7e6;
  --brand: #254f9a;
  --success: #087451;
  --danger: #a42436;
  --hero-a: #eff0ff;
  --hero-b: #dcf2ee;
  --shadow: 0 12px 28px #283d5e12;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); min-width: 280px; }
[hidden] { display: none !important; }
img { display: block; max-width: 100%; }
a { color: var(--accent); text-underline-offset: .22em; }
a:hover { text-decoration-thickness: 2px; }
button, input, textarea, select { font: inherit; color: var(--text); }
button, .primary, .quiet { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .7; }
button, a, input, textarea, select, summary, [tabindex="0"] { outline-offset: 4px; }
:focus-visible { outline: 2px solid var(--brand); }
input, select, textarea { min-width: 0; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: .62rem .72rem; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); width: 1.1rem; height: 1.1rem; flex: 0 0 auto; }
input::placeholder { color: var(--subtle); }
textarea { resize: vertical; width: 100%; }
select { appearance: none; padding-right: 2rem; background-image: linear-gradient(45deg,transparent 50%,var(--subtle) 50%),linear-gradient(135deg,var(--subtle) 50%,transparent 50%);
  background-position: calc(100% - 15px) 50%, calc(100% - 10px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
h1, h2, h3, h4, p { margin-top: 0; }
p { margin-bottom: .9rem; }
h1, h2, h3 { line-height: 1.2; letter-spacing: -.025em; }
h1 { margin-bottom: .48rem; font-size: clamp(1.85rem, 3vw, 2.7rem); }
h2 { margin-bottom: .95rem; font-size: 1.25rem; }
h3 { margin-bottom: .58rem; font-size: 1.12rem; }
h4 { margin-bottom: .5rem; }
small { font-size: .83rem; color: var(--muted); }
ul, ol { padding-inline-start: 1.35rem; }
li + li { margin-top: .4rem; }
pre { white-space: pre-wrap; overflow-wrap: anywhere; }
output { display: block; margin-top: .7rem; font-weight: 700; }
.skip { position: absolute; z-index: 100; left: .8rem; top: .5rem; transform: translateY(-200%); background: var(--panel); padding: .55rem; }
.skip:focus { transform: translateY(0); }
.muted, .empty { color: var(--muted); }
.danger { color: var(--danger); }
.success { color: var(--success); }
.wrap-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.wide { grid-column: 1 / -1; }
.loading { min-height: 100svh; display: grid; align-content: center; justify-items: center; padding: 1.5rem; }
.loading .panel { max-width: 38rem; width: min(100%,38rem); padding: 2rem; }
.loading img { border-radius: 13px; margin-bottom: 1rem; }
.loading .auth-panel { max-width: 28rem; padding: clamp(1.25rem, 6vw, 2.25rem); }
.auth-form, .auth-form label { display: grid; gap: .45rem; }
.auth-form { gap: 1rem; margin-top: 1.35rem; }
.auth-form [role="alert"] { color: var(--danger); margin: 0; }
.auth-return { margin: 1rem 0 0; }

.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100svh; }
.sidebar { height: 100svh; position: sticky; top: 0; display: flex; flex-direction: column; background: var(--sidebar); border-right: 1px solid var(--border); }
.brand { display: flex; gap: .8rem; align-items: center; margin: 1.55rem 1rem 1.25rem; color: var(--text); text-decoration: none; }
.brand img { border-radius: 12px; border: 1px solid color-mix(in srgb, var(--accent) 38%, var(--border)); }
.brand b { display: block; font-size: 1.06rem; line-height: 1.2; }
.brand small { display: block; font-size: .77rem; margin-top: .18rem; }
nav { overflow: auto; padding: .15rem .72rem; scrollbar-width: thin; }
.nav-group { margin-bottom: .9rem; }
.nav-group h2 { margin: .4rem .71rem .38rem; text-transform: uppercase; letter-spacing: .11em; font-size: .71rem; color: var(--subtle); }
.nav-group a { display: flex; gap: .63rem; min-height: 2.45rem; align-items: center; padding: .44rem .7rem; border: 1px solid transparent; border-radius: 8px; color: var(--muted); text-decoration: none; font-size: .92rem; line-height: 1.15; }
.nav-group a:hover { background: var(--panel-alt); color: var(--text); }
.nav-group a[aria-current] { background: color-mix(in srgb, var(--accent) 11%, var(--panel)); border-color: color-mix(in srgb,var(--accent) 42%,var(--border)); color: var(--accent); font-weight: 650; }
.nav-icon { display: grid; place-items: center; flex: 0 0 1.6rem; height: 1.6rem; border-radius: .45rem; background: color-mix(in srgb, currentColor 8%, transparent); font-size: 1.05rem; }
.sidebar-footer { margin-top: auto; border-top: 1px solid var(--border); padding: .8rem 1rem; }
.workspace { min-width: 0; }
.topbar { min-height: 64px; display: flex; align-items: center; justify-content: space-between; gap: .85rem; padding: .65rem clamp(1rem, 3vw, 2.4rem); border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--sidebar) 92%, transparent); backdrop-filter: blur(14px); }
.top-search { display: flex; gap: .35rem; width: min(28rem, 100%); }
.top-search input { flex: 1; font-size: .9rem; }
.top-search button { background: var(--panel-alt); border: 1px solid var(--border); border-radius: 8px; padding: 0 .85rem; font-size: 1.25rem; }
.top-tools { display: flex; align-items: center; gap: .65rem; }
.sync { text-align: right; line-height: 1.25; white-space: nowrap; min-width: min-content; }
.sync span { display: block; font-weight: 650; font-size: .85rem; }
.sync [data-tone="good"] { color: var(--success); }
.sync [data-tone="warn"] { color: var(--accent); }
.sync small { display: block; font-size: .75rem; margin-top: .2rem; }
.mobile-menu { display: none !important; }
#main { width: min(100%, 1460px); margin-inline: auto; padding: clamp(1rem, 3vw, 2.4rem); }
#main:focus { outline: none; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.45rem; }
.page-head p { color: var(--muted); margin-bottom: 0; }
.head-actions, .chips, .form-footer { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.head-actions { justify-content: flex-end; }
.quiet, .primary { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; border-radius: 8px; min-height: 2.65rem; padding: .53rem .84rem; border: 1px solid var(--border); font-weight: 650; font-size: .88rem; text-align: center; line-height: 1.25; }
.quiet { background: var(--panel-alt); color: var(--text); }
.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.quiet:hover, .primary:hover { filter: brightness(1.12); }
.nav-group a, .quiet, .primary, .variant-card { transition: background-color .18s ease, border-color .18s ease, box-shadow .18s ease, filter .18s ease; }
.tag { display: inline-flex; align-items: center; align-self: start; border: 1px solid var(--border); border-radius: 999px; background: var(--panel-alt); color: var(--muted); padding: .18rem .57rem; font-size: .81rem; line-height: 1.45; }
.tag.good { color: var(--success); border-color: var(--success); }
.tag.bad { color: var(--danger); border-color: var(--danger); }
.tag.warn { color: var(--accent); border-color: var(--accent); }
.panel { min-width: 0; background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: clamp(1rem, 2vw, 1.45rem); box-shadow: var(--shadow); }
#main > .panel + .panel, .two-col + .panel, .panel + .two-col, .metric-grid + .panel { margin-top: 1rem; }
.panel p:last-child, .panel ul:last-child { margin-bottom: 0; }
.hero { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) minmax(125px, 24%); align-items: center; gap: 1.6rem;
  padding: clamp(1.2rem, 3vw, 2.2rem); margin-bottom: 1.15rem; border-radius: 17px;
  background: radial-gradient(ellipse at 90% 2%, color-mix(in srgb, var(--brand) 20%, transparent), transparent 60%),
    linear-gradient(118deg, var(--hero-a), var(--hero-b)); border: 1px solid var(--border); }
.hero h2 { margin-top: .55rem; margin-bottom: .45rem; font-size: clamp(1.6rem, 3vw, 2.6rem); }
.dashboard-hero { grid-template-columns: minmax(0, 1fr) auto; padding: clamp(1.2rem, 4.5vw, 3.5rem); border-radius: 22px;
  background: radial-gradient(ellipse at 89% 15%, color-mix(in srgb, var(--brand) 24%, transparent), transparent 56%),
    linear-gradient(118deg, var(--hero-a), var(--hero-b)); }
.dashboard-hero h1 { margin-block: .5rem; font-size: clamp(2rem, 4vw, 3.45rem); overflow-wrap: anywhere; }
.dashboard-hero .ring-frame { width: clamp(112px, 13vw, 164px); }
.hero p { margin-bottom: 1rem; color: var(--muted); }
.hero-label { color: var(--accent); font-size: .86rem; font-weight: 700; letter-spacing: .035em; }
.hero-progress { display: grid; justify-items: center; color: var(--muted); gap: .35rem; font-size: .85rem; white-space: nowrap; }
.ring-frame { display: grid; width: min(100%, 132px); aspect-ratio: 1; grid-template-areas: "inside"; align-items: center; justify-items: center; }
.ring-frame > * { grid-area: inside; }
.ring-frame > strong { font-size: 2rem; color: var(--text); }
.ring-frame strong small { font-size: 1rem; margin-left: .1rem; }
.ring-frame svg { width: 100%; fill: none; stroke-width: 7; transform: rotate(-90deg); }
.ring-track { stroke: var(--border); }
.ring-value { stroke: var(--accent); stroke-linecap: round; }
.metric-grid, .card-grid, .two-col { display: grid; gap: 1rem; }
.metric-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%,11rem), 1fr)); margin-bottom: 1rem; }
.card-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%,17rem), 1fr)); }
.two-col { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.metric { min-height: 7rem; }
.metric p { color: var(--muted); font-size: .89rem; margin-bottom: .55rem; }
.metric strong { display: block; font-size: clamp(1.13rem, 1.7vw, 1.5rem); line-height: 1.25; font-variant-numeric: tabular-nums; }
.metric small { display: block; margin-top: .4rem; }
.row { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .44rem .7rem; min-height: 2.9rem; padding: .48rem 0; border-top: 1px solid var(--border); }
.row:first-child { border-top: 0; }
.steps-navigation { border-top: 1px solid var(--border); margin-top: .5rem; padding-top: .75rem; }
.steps-caption { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .45rem; color: var(--muted); font-size: .86rem; }
.steps-caption button { min-height: 2rem; padding: .32rem .64rem; }
.steps-controls { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: .65rem; margin-top: .5rem; }
.steps-controls .quiet { width: 2.75rem; min-height: 2.75rem; padding: 0; font-size: 1.45rem; }
.steps-controls input[type="range"] { width: 100%; min-height: 2.25rem; margin: 0; padding: 0; accent-color: var(--accent); cursor: pointer; }
.project-flow { display: grid; justify-items: stretch; max-width: 62rem; margin-inline: auto; }
.map-stage { position: relative; padding: 1rem; border: 1px solid var(--border); border-radius: 12px; background: var(--panel-alt); }
.map-stage-header { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .45rem .65rem; margin-bottom: .45rem; }
.map-stage h3, .map-stage-header h3 { margin-bottom: 0; }
.map-stage > p { margin: .55rem 0; }
.map-stage > ul { margin-bottom: 0; }
.map-stem { justify-self: center; color: var(--brand); font-size: 1.35rem; line-height: 1.25; padding: .15rem; }
.map-fork { position: relative; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; padding-block: .9rem; }
.map-fork::before, .map-fork::after { content: ""; position: absolute; left: 25%; right: 25%; border-top: 1px solid var(--brand); }
.map-fork::before { top: 0; }
.map-fork::after { bottom: 0; }
.map-fork .map-stage::before, .map-fork .map-stage::after { content: ""; position: absolute; left: 50%; height: .9rem; border-left: 1px solid var(--brand); }
.map-fork .map-stage::before { top: -.9rem; }
.map-fork .map-stage::after { bottom: -.9rem; }
.map-result { background: linear-gradient(130deg, var(--hero-a), var(--hero-b)); }
.map-result .quiet { margin-top: .25rem; }
.map-detail { margin-top: 1rem; }
.map-detail h2 { scroll-margin-top: 5rem; }
.map-select { max-width: 32rem; margin-bottom: 1rem; }
.map-dependencies { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; margin: .8rem 0 1rem; }
.map-dependencies > section { min-width: 0; padding: .8rem; border: 1px solid var(--border); border-radius: 10px; }
.map-dependencies h4 { margin: 0; }
.map-dependencies details { margin-top: .55rem; }
.stack { display: grid; gap: .55rem; }
.chapter-group { margin: 1.4rem 0; }
.chapter-card { display: flex; flex-direction: column; transition: border-color .18s ease; }
.chapter-card:focus-within, .chapter-card:hover { border-color: var(--brand); }
.chapter-card h3 { margin-top: .65rem; }
.chapter-card h3 a { color: var(--text); text-decoration: none; }
.chapter-card h3 a:hover { color: var(--accent); }
.chapter-card p { color: var(--muted); margin-bottom: .85rem; }
.chapter-card-top, .chapter-meta { display: flex; justify-content: space-between; align-items: center; gap: .4rem; }
.chapter-meta { margin-top: auto; color: var(--accent); font-size: .85rem; }
.progress-strip { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: .8rem; }
.academy-filters { margin: 1rem 0; padding: 0; overflow: visible; }
.academy-filters a[aria-current] { border-color: var(--accent); color: var(--accent); }
.academy-filters a span { margin-left: .35rem; }
progress { width: 100%; height: .58rem; overflow: hidden; appearance: none; border: 0; border-radius: 999px; background: var(--panel-alt); accent-color: var(--accent); }
progress::-webkit-progress-bar { background: var(--panel-alt); }
progress::-webkit-progress-value { background: var(--accent); border-radius: 999px; }
progress::-moz-progress-bar { background: var(--accent); border-radius: 999px; }

.reading-layout { display: grid; grid-template-columns: minmax(0, 1.9fr) minmax(265px, 1fr); gap: 1rem; align-items: start; }
.reading { padding: clamp(1rem, 2.8vw, 1.8rem); }
.reading p, .reading li { overflow-wrap: anywhere; white-space: pre-line; }
.reading section + section { margin-top: 1.4rem; }
.variant-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr)); gap: .85rem; align-items: start; }
.option.variant-card {
  min-width: 0; padding: 1rem; border-radius: 14px;
  background: linear-gradient(145deg, color-mix(in srgb, var(--brand) 8%, var(--panel)), var(--bg));
}
.variant-card:hover, .variant-card:focus-within { border-color: var(--brand); }
.variant-card.selected {
  border-color: var(--success); box-shadow: inset 3px 0 var(--success);
  background: linear-gradient(145deg, color-mix(in srgb, var(--success) 10%, var(--panel)), var(--bg));
}
.variant-card p { margin-bottom: .66rem; }
.variant-card h4 { line-height: 1.3; overflow-wrap: anywhere; }
.variant-action { margin-top: .78rem; }
.variant-action .quiet { min-height: 44px; }
.variant-procedure { border-top: 1px solid var(--border); margin-top: .65rem; }
.variant-procedure summary { min-height: 44px; align-content: center; font-weight: 650; cursor: pointer; }
.variant-procedure ol { margin-block: .2rem .6rem; }
.choice-status { color: var(--muted); margin-bottom: .66rem; }
.choice-status:focus { outline: 2px solid var(--brand); outline-offset: 4px; }
.choice-row { display: flex; align-items: flex-start; justify-content: space-between; gap: .65rem; padding-block: .8rem; }
.choice-row + .choice-row { border-top: 1px solid var(--border); }
.choice-row a { color: var(--text); font-weight: 650; }
.choice-row a:hover { color: var(--accent); }
.choice-row p { margin: .18rem 0 0; color: var(--muted); }
.choice-row .tag { flex-shrink: 0; }
.choices-hero progress { height: .75rem; }
@media (max-width: 560px) { .hero.choices-hero { grid-template-columns: minmax(0, 1fr); gap: 1rem; } }
@media (prefers-reduced-motion: reduce) { .nav-group a, .quiet, .primary, .variant-card, .chapter-card { transition: none; } }
@media print { .variant-action, .choice-status { display: none; } }
.reading h3 { margin: .9rem 0 .55rem; }
.worksheet { padding: 1rem; border: 1px solid var(--border); border-radius: 12px; }
.worksheet-index { margin-bottom: 1rem; }
.worksheet-template { color: var(--text); background: var(--panel-alt); padding: .8rem; border-radius: 8px;
  white-space: pre-wrap; overflow-wrap: anywhere; }
.reading-side { display: grid; gap: 1rem; min-width: 0; }
.reading-side .form-grid { grid-template-columns: 1fr; }
.reading-side .stack { margin-bottom: .8rem; }
.reading-side .chips, .chapter-summary { margin-bottom: .75rem; }
.option, .form-group { border: 1px solid var(--border); border-radius: 9px; padding: .75rem; background: var(--bg); }
.check-list { display: grid; gap: .52rem; }
.check-list label { display: flex; align-items: flex-start; gap: .48rem; overflow-wrap: anywhere; }
.check-list label input { margin-top: .22rem; }
.check-deposit { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .6rem; margin: .35rem 0 .25rem 1.6rem; }
.check-deposit .quiet { min-height: 2rem; padding: .28rem .56rem; font-size: .8rem; }
.term { color: var(--brand); text-decoration: underline dotted; }
.table-scroll { border: 1px solid var(--border); border-radius: 9px; overflow: auto; }
table { width: 100%; border-collapse: collapse; text-align: start; }
table:has(th:nth-child(4)):not(.route-comparison table) { min-width: 36rem; }
.route-comparison table { min-width: 0; }
.route-comparison th, .route-comparison td { padding-inline: .52rem; overflow-wrap: normal; }
.route-comparison td:nth-child(n + 2) { font-variant-numeric: tabular-nums; }
th, td { padding: .64rem .73rem; color: var(--text); text-align: start; vertical-align: top; overflow-wrap: anywhere; }
th { background: var(--panel-alt); color: var(--muted); font-size: .87rem; }
td { border-top: 1px solid var(--border); }
tbody tr:nth-child(even) { background: color-mix(in srgb, var(--panel-alt) 32%, var(--panel)); }
td button + button { margin-left: .27rem; }
td button { min-height: 2.2rem !important; padding: .36rem .52rem !important; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 12rem), 1fr)); align-items: start; gap: .9rem; }
.form-footer { margin: .9rem 0 .25rem; }
.expense-preview { margin: 0; color: var(--muted); font-size: .86rem; font-weight: 500; }
.field { min-width: 0; width: 100%; display: grid; align-content: start; gap: .3rem; color: var(--text); }
.field span { font-size: .87rem; font-weight: 600; }
.check-field { display: flex; align-items: center; font-size: .91rem; gap: .42rem; min-height: 2.4rem; }
.form-group summary { cursor: pointer; font-weight: 650; }
.form-group[open] summary { margin-bottom: .8rem; }
.inline-search { display: flex; align-items: end; gap: .6rem; max-width: 35rem; margin-bottom: 1rem; }
.chart { margin: .45rem 0 .85rem; overflow: hidden; }
.chart figcaption { font-size: .88rem; color: var(--muted); }
.chart canvas { display: block; width: 100%; height: 160px; }
.chart-values { padding: 0; display: flex; flex-wrap: wrap; gap: .35rem .7rem; list-style: none; font-size: .8rem; color: var(--muted); }
.chart-values li { margin: 0; }
.chart-values strong { color: var(--text); }
.timeline { list-style: none; padding-left: .6rem; margin-bottom: 0; }
.timeline li { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .4rem 1rem; border-left: 2px solid var(--accent); padding: .6rem .8rem; }
.timeline li span:not(.tag) { color: var(--muted); }
.glossary { margin: 0; }
.glossary > div { padding: .6rem 0; border-bottom: 1px solid var(--border); }
.glossary > div:last-child { border-bottom: none; }
.glossary dt { color: var(--accent); font-weight: 700; }
.glossary dd { margin-left: 0; color: var(--muted); }
.sources { overflow-wrap: anywhere; }
.banner { color: var(--accent); background: var(--panel); border-left: 3px solid var(--accent); padding: .5rem .75rem; }
#toast { position: fixed; z-index: 4; right: 1rem; bottom: 1rem; max-width: min(calc(100% - 2rem), 34rem); padding: .75rem 1rem;
  border: 1px solid var(--accent); border-radius: 9px; color: var(--text); background: var(--panel-alt); box-shadow: var(--shadow); }
dialog { color: var(--text); background: var(--panel); border: 1px solid var(--border); border-radius: 14px; width: min(90vw, 620px); max-height: 90svh; box-shadow: var(--shadow); }
dialog::backdrop { background: #050911b8; }
.dialog-inner { padding: .55rem; }
.dialog-inner header { display: flex; align-items: center; gap: .6rem; justify-content: space-between; margin-bottom: .8rem; }
.dialog-inner header h2 { margin: 0; }
.dialog-inner fieldset { margin-bottom: .85rem; border: 1px solid var(--border); }
.dialog-inner fieldset label { display: block; }

@media (max-width: 1050px) {
  .shell { grid-template-columns: 214px minmax(0,1fr); }
  .reading-layout { grid-template-columns: 1fr; }
  .reading-side { grid-template-columns: repeat(auto-fit, minmax(min(100%,17rem), 1fr)); }
  .two-col:has(> .route-comparison) { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 754px) {
  .shell { display: block; }
  .sidebar { position: fixed; z-index: 3; top: 3.65rem; bottom: 0; left: 0; width: min(86vw,300px); height: calc(100svh - 3.65rem); box-shadow: var(--shadow); }
  .sidebar:not(.open) { display: none; }
  .topbar { min-height: 3.65rem; position: sticky; z-index: 2; top: 0; padding: .38rem .55rem; gap: .45rem; }
  .mobile-menu { display: inline-flex !important; }
  .top-tools { gap: .35rem; }
  .sync { white-space: normal; min-width: 4rem; max-width: 7rem; }
  .sync small { display: none; }
  .top-search { min-width: 0; width: auto; flex: 1; }
  .top-search input { width: 100%; }
  .top-search button { padding-inline: .52rem; min-width: 2.75rem; }
  .theme-switch { display: none; }
  .page-head { flex-direction: column; gap: .65rem; }
  .head-actions { justify-content: flex-start; }
  .map-fork, .map-dependencies { grid-template-columns: 1fr; }
  .map-fork { padding: 0 0 0 .75rem; border-left: 2px solid var(--brand); }
  .map-fork::before, .map-fork::after, .map-fork .map-stage::before, .map-fork .map-stage::after { display: none; }
}
@media (max-width: 520px) {
  #main { padding: 1rem .75rem; scroll-margin-top: 3.65rem; }
  .two-col { grid-template-columns: 1fr; }
  .hero { gap: .6rem; grid-template-columns: minmax(0,1fr) 94px; padding: 1rem; }
  .hero.dashboard-hero { grid-template-columns: minmax(0, 1fr); gap: 1rem; }
  .dashboard-hero .hero-progress { grid-template-columns: auto 1fr; justify-items: start; text-align: start; }
  .dashboard-hero .ring-frame { width: 62px; }
  .dashboard-hero .ring-frame > strong { font-size: 1.12rem; }
  .dashboard-hero .ring-frame small { font-size: .72rem; }
  .top-search input { font-size: 1rem; }
  .route-comparison th { overflow-wrap: anywhere; }
  .ring-frame > strong { font-size: 1.55rem; }
  .hero-progress { white-space: normal; text-align: center; }
  .metric-grid { grid-template-columns: repeat(2,minmax(0,1fr)); gap: .6rem; }
  .metric { padding: .72rem; }
}
@page { size: A4; margin: 15mm; }
@media print {
  :root, :root[data-theme] { color-scheme: light; --bg: #fff; --panel: #fff; --panel-alt: #f2f5fa; --text: #17263c; --muted: #40506a;
    --border: #b4becb; --accent: #674102; --accent-text: #fff; --brand: #234e89; --danger: #962433; --success: #155e46;
    --hero-a: #fff; --hero-b: #fff; --shadow: none; }
  .sidebar, .topbar, .head-actions, .skip, button, #toast, dialog, form, .reading-side section:last-child { display: none !important; }
  .steps-navigation { display: none; }
  .shell, .reading-layout { display: block; }
  #main { padding: 0; width: 100%; }
  body { font-size: 10.5pt; }
  .panel { box-shadow: none; }
  .book-chapter { break-before: page; border: 0; padding: 0; }
  .row, table tr, .option, .metric, .check-list label { break-inside: avoid; }
  .worksheet-fields li { break-inside: avoid; }
  .worksheet-fields li::after { content: ''; display: block; height: .85em; border-bottom: 1px dotted var(--muted); }
  .reading-side { display: block; }
  h2, h3 { break-after: avoid; }
  .hero { background: #fff; }
  .table-scroll { overflow: visible; }
  table:has(th:nth-child(4)):not(.route-comparison table) { min-width: 0; }
}
