/* Layout: desktop = cargo list | 3D scene | result; phone = scene, result, cargo list, action bar pinned to the bottom.
   Pages (vehicles, guide, about) are single readable columns. Tokens come from the Stowago design system. */
:root {
  --surface: #f4f6f8;
  --surface-raised: #ffffff;
  --line: #d5dce3;
  --ink: #0b1b2b;
  --muted: #4e5d6c;
  --harbor: #0f3b66;
  --harbor-tint: #cfe0f1;
  --on-harbor: #ffffff;
  --signal: #f47a20;
  --on-signal: #0b1b2b;
  --focus: #0f3b66;
  --fit: #1d6b52;
  --warn: #8a5a00;
  --over: #b3261e;
  --mark: #0f3b66;
  --cargo-8: #8b97a3;
  --scrim: rgba(11, 27, 43, 0.45);
  --shadow-sheet: 0 8px 24px rgba(11, 27, 43, 0.14);

  --font-display: Unbounded, "Arial Black", system-ui, sans-serif;
  --font-sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;

  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px; --space-6: 24px; --space-12: 48px;
  --radius-sm: 2px; --radius-md: 6px; --radius-pill: 999px;
  --gutter-l: max(16px, env(safe-area-inset-left, 0px));
  --gutter-r: max(16px, env(safe-area-inset-right, 0px));
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --surface: #0a1622; --surface-raised: #112233; --line: #24384c; --ink: #e8eef3; --muted: #9aabbb;
    --harbor: #8fbce8; --harbor-tint: #1b3a5a; --on-harbor: #0a1622; --signal: #ff8c3a; --on-signal: #0b1b2b;
    --focus: #ff8c3a; --fit: #5fc79a; --warn: #f2c14e; --over: #ff8a80; --mark: #e8eef3;
    --scrim: rgba(0, 0, 0, 0.6); --shadow-sheet: 0 8px 24px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --surface: #0a1622; --surface-raised: #112233; --line: #24384c; --ink: #e8eef3; --muted: #9aabbb;
  --harbor: #8fbce8; --harbor-tint: #1b3a5a; --on-harbor: #0a1622; --signal: #ff8c3a; --on-signal: #0b1b2b;
  --focus: #ff8c3a; --fit: #5fc79a; --warn: #f2c14e; --over: #ff8a80; --mark: #e8eef3;
  --scrim: rgba(0, 0, 0, 0.6); --shadow-sheet: 0 8px 24px rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--surface);
  color: var(--ink);
  font: 400 15px/24px var(--font-sans);
  -webkit-text-size-adjust: 100%;
}
h1, h2, h3, p, ol, ul, dl { margin: 0; }
a { color: var(--harbor); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[tabindex="-1"]:focus { outline: none; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 13px; line-height: 20px; }
.label { font: 600 12px/16px var(--font-sans); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.heading { font: 600 18px/26px var(--font-sans); }
.title { font: 600 20px/28px var(--font-display); letter-spacing: -0.01em; text-wrap: balance; }
.display { font: 600 clamp(28px, 4vw, 40px)/1.1 var(--font-display); letter-spacing: -0.01em; text-wrap: balance; }
.data { font: 400 13px/20px var(--font-mono); font-variant-numeric: tabular-nums; }
svg { flex: none; }

/* ------------------------------------------------ header and menu */
.top {
  position: relative; z-index: 30;
  display: flex; align-items: center; gap: var(--space-4);
  padding-block: 10px; padding-left: var(--gutter-l); padding-right: var(--gutter-r);
  background: var(--surface-raised); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; }
.brand svg { width: 30px; height: 30px; }
.brand .blk { fill: var(--mark); }
.brand .drop { fill: var(--signal); }
.wordmark { font: 600 20px/1 var(--font-display); letter-spacing: -0.01em; }
.proto-tag { font: 600 11px/16px var(--font-sans); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 1px 6px; }
.nav { display: flex; gap: 2px; margin-left: var(--space-4); }
.nav a, .drawer-nav a {
  color: var(--muted); text-decoration: none; font-weight: 600; font-size: 14px; line-height: 20px;
  padding: 7px 10px; border-radius: var(--radius-sm); position: relative;
}
.nav a:hover { color: var(--ink); background: var(--harbor-tint); }
.nav a[aria-current="page"] { color: var(--ink); }
.nav a[aria-current="page"]::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: -11px; height: 3px; background: var(--signal); }
.settings { margin-left: auto; display: flex; align-items: center; gap: var(--space-2); }
.menu-btn {
  display: none; margin-left: auto; align-items: center; gap: 6px;
  border: 1px solid var(--line); background: var(--surface-raised); border-radius: var(--radius-sm);
  padding: 6px 10px; font-weight: 600; font-size: 14px; cursor: pointer;
}
.menu-btn svg { width: 20px; height: 20px; }

.drawer { position: fixed; inset: 0; z-index: 50; }
.drawer-backdrop { position: absolute; inset: 0; background: var(--scrim); }
.drawer-panel {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(340px, 88vw);
  background: var(--surface-raised); box-shadow: var(--shadow-sheet);
  display: flex; flex-direction: column; gap: var(--space-6);
  padding-top: calc(var(--space-4) + env(safe-area-inset-top, 0px)); padding-bottom: calc(var(--space-6) + env(safe-area-inset-bottom, 0px));
  padding-left: var(--space-6); padding-right: max(var(--space-6), env(safe-area-inset-right, 0px));
  overflow-y: auto; animation: drawer-in 180ms ease-out;
}
@keyframes drawer-in { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer-head { display: flex; align-items: center; justify-content: space-between; }
.drawer-nav { display: flex; flex-direction: column; }
.drawer-nav a { font-size: 18px; line-height: 26px; padding: 12px 0; border-bottom: 1px solid var(--line); color: var(--ink); border-radius: 0; }
.drawer-nav a[aria-current="page"] { color: var(--harbor); box-shadow: inset 3px 0 0 var(--signal); padding-left: 12px; }
.drawer-settings { display: flex; flex-direction: column; gap: var(--space-3); }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }

/* ------------------------------------------------ shared controls */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface-raised); }
.seg button { border: 0; background: transparent; color: var(--muted); font: 600 13px/20px var(--font-sans); padding: 5px 10px; cursor: pointer; white-space: nowrap; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--harbor); color: var(--on-harbor); }
.seg button:hover:not([aria-pressed="true"]) { background: var(--harbor-tint); color: var(--ink); }

.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px; flex: none;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-raised); color: var(--ink); cursor: pointer;
}
.icon-btn:hover { background: var(--harbor-tint); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn[disabled] { color: var(--muted); background: var(--surface); cursor: not-allowed; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  font: 600 15px/24px var(--font-sans); padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-sm); border: 2px solid transparent; cursor: pointer; text-decoration: none;
}
.btn svg { width: 18px; height: 18px; }
.btn.primary { background: var(--signal); color: var(--on-signal); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.secondary { background: transparent; color: var(--harbor); border-color: var(--harbor); }
.btn.secondary:hover { background: var(--harbor-tint); color: var(--ink); }
.btn.ghost { background: transparent; color: var(--harbor); border-color: transparent; padding-inline: var(--space-2); }
.btn.ghost:hover { background: var(--harbor-tint); color: var(--ink); }

.input {
  width: 100%; min-width: 0; height: 38px; padding: 6px 10px;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius-sm);
}
select.input { cursor: pointer; }
select.input.lang-select { width: auto; max-width: 170px; height: 32px; padding: 3px 8px; font-size: 13px; font-weight: 600; }
.input[aria-invalid="true"] { border-color: var(--over); box-shadow: inset 0 0 0 1px var(--over); }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; line-height: 20px; cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 0; accent-color: var(--harbor); flex: none; }

/* ------------------------------------------------ planner */
.work {
  display: grid; gap: var(--space-4);
  padding-block: var(--space-4); padding-left: var(--gutter-l); padding-right: var(--gutter-r);
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "scene" "results" "cargo";
}
.panel { position: relative; background: var(--surface-raised); border: 1px solid var(--line); border-radius: var(--radius-md); padding: var(--space-4); min-width: 0; }
.cargo-panel { grid-area: cargo; display: flex; flex-direction: column; gap: var(--space-6); }
.results { grid-area: results; display: flex; flex-direction: column; gap: var(--space-4); }
.viewport { grid-area: scene; position: relative; min-width: 0; height: min(62vh, 560px); min-height: 340px; background: var(--surface-raised); border: 1px solid var(--line); border-radius: var(--radius-md); overflow: hidden; }

.block { display: flex; flex-direction: column; gap: var(--space-2); }
.block-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); flex-wrap: wrap; }
.head-actions { display: flex; align-items: center; gap: var(--space-1); }
.preset { width: auto; max-width: 170px; height: 34px; padding: 3px 8px; font-size: 14px; }
.space-meta { display: flex; flex-direction: column; gap: 4px; }
.src { display: flex; flex-wrap: wrap; align-items: center; gap: 4px var(--space-2); color: var(--muted); }
.src a { color: var(--harbor); text-underline-offset: 2px; overflow-wrap: anywhere; }
.src .chip { font-size: 11px; padding: 1px var(--space-2); }
.custom { display: flex; flex-direction: column; gap: var(--space-2); padding: var(--space-3); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.custom-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-2); }

.items { list-style: none; padding: 0; display: flex; flex-direction: column; }
.item { display: flex; flex-direction: column; gap: var(--space-2); padding-block: var(--space-3); border-top: 1px solid var(--line); }
.item:first-child { border-top: 0; padding-top: var(--space-1); }
.item.hl { background: linear-gradient(var(--harbor-tint), var(--harbor-tint)) left / 3px 100% no-repeat; }
.item-head { display: flex; align-items: center; gap: var(--space-2); }
.swatch { width: 14px; height: 14px; flex: none; border-radius: var(--radius-sm); background: var(--sw); box-shadow: inset 0 0 0 1px rgba(11, 27, 43, 0.25); }
.item-name { flex: 1; font-weight: 600; height: 34px; }
.item-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: var(--space-2); align-items: end; }
.item-grid .f-dim { grid-column: span 2; }
.item-grid .f-wide { grid-column: span 3; }
.field { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.field .label { font-size: 11px; letter-spacing: 0.04em; overflow-wrap: anywhere; }
.num { font: 400 14px/20px var(--font-mono); font-variant-numeric: tabular-nums; height: 36px; }
.item-flags { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-4); }
.more summary { cursor: pointer; color: var(--harbor); font-size: 14px; font-weight: 600; width: fit-content; list-style: none; display: inline-flex; align-items: center; gap: 4px; }
.more summary::-webkit-details-marker { display: none; }
.more summary::before { content: ""; width: 7px; height: 7px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(-45deg); transition: transform 120ms; margin-right: 3px; }
.more[open] summary::before { transform: rotate(45deg); }
.more-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--space-2); align-items: end; padding-top: var(--space-2); }
.more-body .muted { grid-column: 1 / -1; }
.item-err { color: var(--over); font-size: 13px; line-height: 18px; }
.add { align-self: flex-start; }
.multi { align-items: flex-start; padding-top: var(--space-2); }
.multi input { margin-top: 1px; }
.action-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  padding-top: var(--space-3); padding-bottom: calc(var(--space-3) + env(safe-area-inset-bottom, 0px));
  padding-left: var(--gutter-l); padding-right: var(--gutter-r);
  background: var(--surface-raised); border-top: 1px solid var(--line); box-shadow: var(--shadow-sheet);
}
.action-bar .btn { width: 100%; }
.app { padding-bottom: 76px; }
.app.no-bar { padding-bottom: 0; }

/* 3D viewport */
#scene { position: absolute; inset: 0; }
#scene canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.loading-3d { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: var(--space-3); color: var(--muted); font-size: 14px; }
.stack { position: relative; width: 64px; height: 64px; }
.stack i { position: absolute; width: 18px; height: 18px; border-radius: var(--radius-sm); background: var(--harbor-tint); }
.stack i:nth-child(1) { left: 2px; top: 38px; } .stack i:nth-child(2) { left: 23px; top: 38px; } .stack i:nth-child(3) { left: 23px; top: 17px; }
.stack i.d { left: 44px; top: 17px; background: var(--signal); animation: drop 1.2s ease-in-out infinite; }
@keyframes drop { 0%, 20% { transform: translateY(-14px); opacity: 0.3; } 60%, 100% { transform: none; opacity: 1; } }
.view-tools { position: absolute; top: var(--space-3); left: var(--space-3); right: var(--space-3); display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; pointer-events: none; }
.view-tools > * { pointer-events: auto; }
.chip-check { background: var(--surface-raised); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 4px 8px; font-size: 13px; }
.unit-tabs { margin-left: auto; max-width: 100%; overflow-x: auto; }
.unit-tabs button { font-family: var(--font-mono); font-weight: 500; }
.tip {
  position: absolute; z-index: 5; pointer-events: none; max-width: min(280px, calc(100% - 24px));
  background: var(--surface-raised); color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sheet); padding: 8px 10px; font-size: 13px; line-height: 18px;
}
.tip b { display: block; font-weight: 600; }
.tip .data { color: var(--muted); }
.busy {
  position: absolute; bottom: 92px; right: var(--space-3);
  font: 600 13px/20px var(--font-sans); background: var(--harbor); color: var(--on-harbor);
  padding: 4px 10px; border-radius: var(--radius-sm);
}
.player {
  position: absolute; left: var(--space-3); right: var(--space-3); bottom: var(--space-3);
  display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap;
  background: var(--surface-raised); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 6px 8px;
}
.player .btns { display: flex; gap: 4px; }
.player input[type="range"] { flex: 1 1 140px; min-width: 120px; accent-color: var(--harbor); }
.step-label { flex: 1 1 100%; order: -1; font: 400 13px/18px var(--font-mono); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.scene-note { flex: 1 1 100%; margin: 0; font: 400 12px/16px var(--font-sans); color: var(--muted); }
.scene-note b { color: var(--ink); font-weight: 600; }
.icon-btn.play { background: var(--harbor); color: var(--on-harbor); border-color: var(--harbor); }
.no-webgl { position: absolute; inset: 0; display: grid; place-items: center; padding: var(--space-6); text-align: center; color: var(--muted); }

/* Result */
.res-body { display: flex; flex-direction: column; gap: var(--space-4); }
.res-body.stale { opacity: 0.55; transition: opacity 120ms; }
.need { display: flex; flex-direction: column; gap: var(--space-1); padding: var(--space-3); border-radius: var(--radius-sm); background: var(--harbor-tint); }
.need .title { font-size: 18px; line-height: 24px; }
.meter { display: grid; gap: var(--space-1); }
.meter-top { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-2); }
.fig { font: 500 20px/28px var(--font-mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.unit { color: var(--muted); font: 400 13px/20px var(--font-mono); }
.bar { height: 8px; background: var(--harbor-tint); border-radius: var(--radius-sm); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--harbor); transition: width 240ms ease-out; }
.bar.w i { background: var(--warn); }
.chips { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.chip { font: 600 12px/16px var(--font-sans); padding: var(--space-1) var(--space-3); border-radius: var(--radius-pill); border: 1.5px solid currentColor; }
.chip.fit { color: var(--fit); } .chip.warn { color: var(--warn); } .chip.over { color: var(--over); }
.facts { display: grid; gap: var(--space-3); }
.facts dt { margin-bottom: 2px; }
.facts dd { margin: 0; display: flex; flex-direction: column; gap: var(--space-1); align-items: flex-start; }
.by-type { list-style: none; padding: 0; display: grid; gap: 2px; }
.by-type li { display: grid; grid-template-columns: 14px minmax(0, 1fr) auto; gap: var(--space-2); align-items: baseline; padding: 4px 6px; margin-inline: -6px; border-radius: var(--radius-sm); cursor: default; }
.by-type li:hover, .by-type li:focus-visible { background: var(--harbor-tint); }
.by-type .swatch { transform: translateY(2px); }
.by-type .nm { overflow-wrap: anywhere; font-size: 14px; line-height: 20px; }
.by-type .why { grid-column: 2 / 4; color: var(--over); font-size: 13px; line-height: 18px; }
.foot { display: grid; gap: var(--space-2); border-top: 1px solid var(--line); padding-top: var(--space-3); }
.res-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.res-actions .btn.secondary { flex: 1 1 100%; }

/* ------------------------------------------------ pages */
.page { padding-block: var(--space-6) var(--space-12); padding-left: var(--gutter-l); padding-right: var(--gutter-r); }
.page-inner { max-width: 1120px; margin: 0 auto; display: flex; flex-direction: column; gap: var(--space-6); }
.page-head { display: flex; flex-direction: column; gap: var(--space-2); max-width: 680px; }
.lead { font-size: 17px; line-height: 26px; color: var(--muted); }
.filters { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.filters button {
  border: 1px solid var(--line); background: var(--surface-raised); color: var(--ink); cursor: pointer;
  font: 600 14px/20px var(--font-sans); padding: 6px 12px; border-radius: var(--radius-sm);
}
.filters button[aria-pressed="true"] { background: var(--harbor); color: var(--on-harbor); border-color: var(--harbor); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: var(--space-4); }
.card {
  display: flex; flex-direction: column; gap: var(--space-3);
  background: var(--surface-raised); border: 1px solid var(--line); border-radius: var(--radius-md); padding: var(--space-4);
}
.card:hover { border-color: var(--harbor); }
.card .pic { height: 96px; display: grid; place-items: center; background: var(--surface); border-radius: var(--radius-sm); }
.card .pic svg { width: 100%; height: 100%; }
.card h3 { font: 600 16px/22px var(--font-sans); }
.card .group { color: var(--muted); }
.card .dims { margin-top: 2px; }
.card dl { display: grid; gap: 2px; font-size: 13px; line-height: 20px; }
.card dl > div { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-3); }
.card dt { color: var(--muted); }
.card dd { margin: 0; font: 400 12px/20px var(--font-mono); font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.card .btn { margin-top: auto; }
.pic .body { fill: var(--harbor-tint); stroke: var(--harbor); stroke-width: 1.5; }
.pic .shade { fill: var(--harbor); opacity: 0.18; }
.pic .ink { fill: var(--ink); }
.pic .line { stroke: var(--harbor); stroke-width: 1; opacity: 0.55; fill: none; }
.pic .load { fill: none; stroke: var(--harbor); stroke-width: 1.5; stroke-dasharray: 4 3; }
.pic .wood { fill: var(--cargo-8); }
.pic .accent { fill: var(--signal); }
.steps { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: var(--space-4); counter-reset: step; }
.steps li { background: var(--surface-raised); border: 1px solid var(--line); border-radius: var(--radius-md); padding: var(--space-4); display: flex; flex-direction: column; gap: var(--space-2); counter-increment: step; }
.steps li::before { content: counter(step); font: 600 22px/1 var(--font-display); color: var(--harbor); }
.steps h3, .about h3 { font: 600 16px/22px var(--font-sans); }
.prose { max-width: 680px; display: flex; flex-direction: column; gap: var(--space-3); }
.prose ul { padding-left: 20px; display: flex; flex-direction: column; gap: var(--space-2); }
.about { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: var(--space-4); }
.about section { background: var(--surface-raised); border: 1px solid var(--line); border-radius: var(--radius-md); padding: var(--space-4); display: flex; flex-direction: column; gap: var(--space-2); }

/* ------------------------------------------------ dialogs and toast */
.dlg {
  width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px);
  border: 1px solid var(--line); border-radius: var(--radius-md); padding: var(--space-6);
  background: var(--surface-raised); color: var(--ink); box-shadow: var(--shadow-sheet);
}
.dlg[open] { display: flex; flex-direction: column; gap: var(--space-3); }
.dlg.wide { width: min(960px, calc(100vw - 32px)); }
.dlg::backdrop { background: var(--scrim); }
.dlg-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-3); }
.dlg-tools { display: flex; gap: var(--space-2); align-items: center; }
.dlg-foot { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: var(--space-2); }
.imp-text { height: auto; min-height: 160px; font: 400 13px/20px var(--font-mono); resize: vertical; }
.stages { list-style: none; padding: 0; display: flex; flex-direction: column; gap: var(--space-3); }
.stage { display: grid; grid-template-columns: minmax(0, 280px) minmax(0, 1fr); gap: var(--space-4); align-items: center; border: 1px solid var(--line); border-radius: var(--radius-md); padding: var(--space-3); background: var(--surface); }
.stage img { width: 100%; height: auto; aspect-ratio: 56 / 34; border-radius: var(--radius-sm); background: var(--surface-raised); }
.stage h3 { font: 600 16px/22px var(--font-sans); }
.stage ul { list-style: none; padding: 0; display: grid; gap: 2px; margin-top: var(--space-2); }
.stage li { display: flex; gap: var(--space-2); align-items: baseline; font-size: 14px; }
.stage li .swatch { transform: translateY(2px); }
.toast {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 60;
  background: var(--ink); color: var(--surface); padding: 8px 14px; border-radius: var(--radius-sm); font-weight: 600; font-size: 14px;
  box-shadow: var(--shadow-sheet);
}

/* ------------------------------------------------ breakpoints */
@media (min-width: 1100px) {
  html, body { height: 100%; }
  .app { height: 100%; display: grid; grid-template-rows: auto minmax(0, 1fr); padding-bottom: 0; }
  .main { min-height: 0; overflow: hidden; display: flex; flex-direction: column; }
  .main > .view { flex: 1; min-height: 0; }
  .page { overflow-y: auto; }
  .work {
    grid-template-columns: minmax(330px, 390px) minmax(0, 1fr) minmax(270px, 310px);
    grid-template-areas: "cargo scene results";
  }
  .panel { padding: var(--space-6); overflow: auto; }
  .cargo-panel { padding-bottom: 0; }
  .viewport { height: auto; min-height: 0; }
  .action-bar {
    position: sticky; bottom: 0; margin-top: auto; z-index: 1;
    padding: var(--space-4) 0 var(--space-6); box-shadow: none; border-top: 1px solid var(--line);
  }
  .toast { bottom: 32px; }
}
@media (max-width: 1099px) {
  .busy { bottom: auto; top: 56px; }
}
@media (max-width: 1023px) {
  .nav, .top-settings { display: none; }
  .menu-btn { display: inline-flex; }
}
@media (max-width: 560px) {
  .proto-tag { display: none; }
  .item-grid { gap: 6px; }
  .custom-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stage { grid-template-columns: minmax(0, 1fr); }
  .dlg { padding: var(--space-4); max-height: calc(100vh - 24px); }
  .view-tools .seg button { padding: 5px 8px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media print {
  .app, .toast, #dlg-import, .dlg-tools { display: none !important; }
  .dlg.wide { position: static; display: block; width: auto; max-height: none; border: 0; box-shadow: none; padding: 0; }
  .stage { break-inside: avoid; }
}

/* Big phone text sizes: the header wraps instead of pushing the menu button off the screen (24.10.2026) */
.top { flex-wrap: wrap; row-gap: 8px; }
.top > * { min-width: 0; }
.seg { flex-wrap: wrap; max-width: 100%; }
.btn { white-space: normal; overflow-wrap: break-word; max-width: 100%; }
.meter-top { flex-wrap: wrap; }
.fig { white-space: normal; }

/* Site pages around the planner: vehicle pages, "how many fit" answers, calculators, tables and the footer. */
.site-main { display: block; }
.crumbs { display: flex; flex-wrap: wrap; gap: 4px var(--space-2); font-size: 13px; line-height: 20px; color: var(--muted); }
.crumbs a { color: var(--muted); }
.crumbs li { list-style: none; display: inline-flex; gap: var(--space-2); }
.crumbs li + li::before { content: "›"; }
.crumbs ol { display: contents; }

.hero { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-6); align-items: start; }
.hero .pic { background: var(--surface-raised); border: 1px solid var(--line); border-radius: var(--radius-md); padding: var(--space-4); }
.hero .pic svg { width: 100%; height: auto; display: block; }
.answer { background: var(--surface-raised); border: 1px solid var(--line); border-left: 4px solid var(--signal); border-radius: var(--radius-md); padding: var(--space-4) var(--space-6); display: flex; flex-direction: column; gap: var(--space-1); }
.answer .big { font: 600 clamp(26px, 4vw, 34px)/1.15 var(--font-display); }
.cta { display: flex; flex-wrap: wrap; gap: var(--space-2); }
a.btn { text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); }

.table-wrap { overflow-x: auto; background: var(--surface-raised); border: 1px solid var(--line); border-radius: var(--radius-md); }
.spec { width: 100%; border-collapse: collapse; font-size: 14px; line-height: 20px; }
.spec th, .spec td { text-align: left; vertical-align: top; padding: 10px var(--space-4); border-top: 1px solid var(--line); }
.spec tr:first-child > * { border-top: 0; }
.spec thead th { font: 600 12px/16px var(--font-sans); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); background: var(--surface); }
.spec tbody th { font-weight: 600; }
.spec .data, .spec td.num-cell { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 13px; }
.spec .alt { display: block; color: var(--muted); font-size: 12px; }
.spec.kv th { width: 42%; color: var(--muted); font-weight: 400; }

.section { display: flex; flex-direction: column; gap: var(--space-3); }
.notes { max-width: 760px; display: flex; flex-direction: column; gap: var(--space-2); }
.faq { display: flex; flex-direction: column; gap: var(--space-2); max-width: 760px; }
.faq details { background: var(--surface-raised); border: 1px solid var(--line); border-radius: var(--radius-md); padding: var(--space-3) var(--space-4); }
.faq summary { cursor: pointer; font-weight: 600; }
.faq details p { margin-top: var(--space-2); color: var(--muted); }
.links { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: var(--space-1) var(--space-4); padding: 0; list-style: none; }
.links a { display: inline-block; padding: 4px 0; text-underline-offset: 3px; }

.plan-svg { width: 100%; height: auto; display: block; }
.plan-svg .wall { fill: var(--surface); stroke: var(--ink); stroke-width: 2; }
.plan-svg .obst { fill: var(--line); }
.plan-svg .pal { fill: var(--harbor-tint); stroke: var(--harbor); stroke-width: 1.2; }
.plan-svg text { fill: var(--muted); font: 600 11px var(--font-sans); letter-spacing: 0.08em; }

.calc { display: grid; gap: var(--space-6); grid-template-columns: minmax(0, 1fr); }
.calc form, .calc .out { background: var(--surface-raised); border: 1px solid var(--line); border-radius: var(--radius-md); padding: var(--space-4); display: flex; flex-direction: column; gap: var(--space-3); }
.calc .seg { align-self: flex-start; }
.calc .grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-2); }
.calc .grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2); }
.calc dl { display: grid; gap: var(--space-2); }
.calc dl > div { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-3); border-top: 1px solid var(--line); padding-top: var(--space-2); }
.calc dl > div:first-child { border-top: 0; padding-top: 0; }
.calc dt { color: var(--muted); }
.calc dd { margin: 0; font: 500 15px/22px var(--font-mono); font-variant-numeric: tabular-nums; text-align: right; }
.calc dd.key { font-size: 20px; color: var(--ink); }

.site-foot { border-top: 1px solid var(--line); background: var(--surface-raised); padding-block: var(--space-6) calc(var(--space-12) + env(safe-area-inset-bottom, 0px)); padding-left: var(--gutter-l); padding-right: var(--gutter-r); }
.site-foot .inner { max-width: 1120px; margin: 0 auto; display: flex; flex-direction: column; gap: var(--space-6); }
.site-foot .cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--space-6); }
.site-foot h2 { font: 600 12px/16px var(--font-sans); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin-bottom: var(--space-2); }
.site-foot ul { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 2px; font-size: 14px; }
.site-foot a { color: var(--ink); text-underline-offset: 3px; }
.site-foot .langs { display: flex; flex-wrap: wrap; gap: 4px var(--space-3); flex-direction: row; }
.planner-intro { padding-bottom: calc(var(--space-12) + 76px); }
.lang-list { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: var(--space-2); }
.lang-list a { display: block; padding: var(--space-3) var(--space-4); background: var(--surface-raised); border: 1px solid var(--line); border-radius: var(--radius-md); color: var(--ink); text-decoration: none; font-weight: 600; }
.lang-list a:hover { border-color: var(--harbor); }

@media (min-width: 900px) {
  .hero { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); }
  .calc { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}
@media (min-width: 1100px) {
  .planner-intro { padding-bottom: var(--space-12); }
}
@media (max-width: 560px) {
  .calc .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .spec th, .spec td { padding: 8px var(--space-3); }
}

/* Big phone text sizes: long words in headings wrap instead of widening the page (24.10.2026) */
.hero > *, .page-head { min-width: 0; }
.page-head .display, .page-head .lead { overflow-wrap: break-word; }
