/* TasteFit redesign prototype. Tokens are documented in TASTEFIT-DESIGN-SYSTEM.md. */

@font-face {
  font-family: "Schibsted Grotesk";
  src: url("fonts/SchibstedGrotesk-latin.woff2") format("woff2");
  font-weight: 400 900;
  font-style: normal;
  font-display: swap;
}

/* ---------- tokens ---------- */
:root {
  --paper: #F3F5F7;
  --surface: #FFFFFF;
  --sunken: #E9EDF1;
  --ink: #15203B;
  --ink-2: #4B5568;
  --ink-3: #5E6779;
  --on-ink: #FFFFFF;
  --rule: #DDE2E8;
  --rule-strong: #C3CAD3;
  --field: #8A93A3;
  --hl: #FFD84D;
  --hl-soft: #FFF3C2;
  --hatch-ink: #15203B;
  --plan: #2445A8;
  --plan-soft: #E6ECFB;
  --go: #17703F;      --go-bg: #E3F3E9;
  --adjust: #8A5A00;  --adjust-bg: #FBEFD3;
  --nogo: #B42318;    --nogo-bg: #FCE4E1;
  --love: #2445A8;
  --comp: #B42318;

  --font: "Schibsted Grotesk", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --t-12: 0.75rem; --t-13: 0.8125rem; --t-14: 0.875rem; --t-16: 1rem; --t-18: 1.125rem;
  --t-22: 1.375rem; --t-28: 1.75rem; --t-36: 2.25rem; --t-48: 3rem;
  --t-hero: clamp(2.6rem, 1.6rem + 4.2vw, 5.25rem);

  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 20px; --s-6: 24px;
  --s-8: 32px; --s-10: 40px; --s-14: 56px; --s-18: 72px; --s-24: 96px;

  --r-xs: 4px; --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-xl: 20px; --r-pill: 999px;

  --sh-1: 0 1px 0 rgba(21, 32, 59, .05), 0 1px 2px rgba(21, 32, 59, .08);
  --sh-2: 0 1px 2px rgba(21, 32, 59, .06), 0 10px 28px -10px rgba(21, 32, 59, .22);
  --sh-3: 0 2px 6px rgba(21, 32, 59, .08), 0 24px 56px -16px rgba(21, 32, 59, .32);
  --ring: 0 0 0 2px var(--surface), 0 0 0 4px var(--plan);

  --ease-out: cubic-bezier(.2, .8, .2, 1);
  --d-fast: 120ms; --d-base: 200ms; --d-slow: 360ms;

  --topbar-h: 64px;
  --tile-filter: grayscale(1) contrast(.9) brightness(1.06);
  color-scheme: light;
}

[data-theme="dark"] {
  --paper: #0F1626;
  --surface: #172036;
  --sunken: #111A2C;
  --ink: #E8ECF4;
  --ink-2: #A3ADC2;
  --ink-3: #97A1B6;
  --on-ink: #0F1626;
  --rule: #26314A;
  --rule-strong: #34405C;
  --field: #5F6B85;
  --hl-soft: #3A3417;
  --hatch-ink: #15203B;
  --plan: #9DB2FF;
  --plan-soft: #1F2C52;
  --go: #5CC98A;      --go-bg: #173A2A;
  --adjust: #F2B84B;  --adjust-bg: #3A2E14;
  --nogo: #FF8A7A;    --nogo-bg: #40201E;
  --love: #9DB2FF;
  --comp: #FF8A7A;
  --sh-1: 0 1px 0 rgba(0, 0, 0, .3);
  --sh-2: 0 10px 28px -10px rgba(0, 0, 0, .6);
  --sh-3: 0 24px 56px -16px rgba(0, 0, 0, .7);
  --tile-filter: grayscale(1) invert(1) brightness(.82) contrast(.9);
  color-scheme: dark;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body { margin: 0; font: 400 var(--t-16)/1.55 var(--font); color: var(--ink); background: var(--paper); }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { text-wrap: balance; letter-spacing: -0.015em; }
p, li, small { text-wrap: pretty; }
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--r-sm); }
[tabindex="-1"]:focus { box-shadow: none; outline: none; }
[hidden] { display: none !important; }
.i { width: 18px; height: 18px; flex: none; }
.num, .mini-score, .score-n, .clock, .meter { font-variant-numeric: tabular-nums; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: var(--s-4); top: -60px; z-index: 50; background: var(--ink); color: var(--on-ink); padding: var(--s-3) var(--s-4); border-radius: var(--r-sm); text-decoration: none; }
.skip:focus { top: var(--s-3); }

/* SVG colour hooks (presentation attributes cannot read CSS variables) */
.f-hl { fill: var(--hl); } .f-hatch { fill: var(--hatch-ink); } .f-ink { fill: var(--ink); } .f-on-ink { fill: var(--on-ink); }
.f-surface { fill: var(--surface); } .s-hl { stroke: var(--hl); } .s-ink { stroke: var(--ink); } .s-rule { stroke: var(--rule-strong); }

/* ---------- buttons ---------- */
.btn {
  --h: 44px;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  height: var(--h); padding: 0 var(--s-5); border-radius: var(--r-pill);
  font-weight: 600; font-size: var(--t-16); line-height: 1; text-decoration: none; white-space: nowrap;
  border: 1.5px solid transparent;
  transition-property: transform, background-color, border-color, box-shadow, color;
  transition-duration: var(--d-fast); transition-timing-function: ease-out;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn-lg { --h: 54px; padding: 0 var(--s-6); font-size: var(--t-18); }
.btn-sm { --h: 40px; padding: 0 var(--s-4); font-size: var(--t-14); }
.btn-hl { background: var(--hl); color: #15203B; border-color: #15203B; box-shadow: 0 2px 0 #15203B; }
.btn-hl:hover { background: #FFE173; }
.btn-hl:active { box-shadow: 0 0 0 #15203B; transform: translateY(2px); }
.btn-ink { background: var(--ink); color: var(--on-ink); }
.btn-ink:hover { background: color-mix(in srgb, var(--ink) 88%, var(--plan)); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--rule-strong); }
.btn-ghost:hover { border-color: var(--ink); }
.btn-quiet { background: transparent; color: var(--ink-2); padding: 0 var(--s-3); }
.btn-quiet:hover { color: var(--ink); background: var(--sunken); }
.btn-block { width: 100%; }

.icon-btn {
  position: relative; display: inline-grid; place-items: center; width: 40px; height: 40px;
  border-radius: var(--r-pill); border: 1px solid var(--rule); background: var(--surface); color: var(--ink);
  transition: background-color var(--d-fast) ease-out, border-color var(--d-fast) ease-out;
}
.icon-btn:hover { border-color: var(--rule-strong); }
.icon-btn .i { transition-property: opacity, transform, filter; transition-duration: var(--d-base); transition-timing-function: var(--ease-out); }
.icon-btn .i-moon, [data-theme="dark"] .icon-btn .i-sun { position: absolute; opacity: 0; transform: scale(.6); filter: blur(2px); }
[data-theme="dark"] .icon-btn .i-moon { position: static; opacity: 1; transform: none; filter: none; }

.chip-btn {
  display: inline-flex; align-items: center; gap: var(--s-2); height: 40px; padding: 0 var(--s-4);
  border-radius: var(--r-pill); border: 1px solid var(--rule-strong); background: var(--surface); color: var(--ink);
  font-weight: 600; font-size: var(--t-14); box-shadow: var(--sh-2);
  transition: background-color var(--d-fast) ease-out, color var(--d-fast) ease-out;
}
.chip-btn[aria-pressed="true"] { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }

/* ---------- inputs ---------- */
.field { display: grid; gap: 6px; }
.field label { font-size: var(--t-14); font-weight: 600; color: var(--ink-2); }
.field .help { font-size: var(--t-13); color: var(--ink-3); }
.input {
  height: 48px; width: 100%; padding: 0 var(--s-4); border-radius: var(--r-md);
  border: 1.5px solid var(--field); background: var(--surface); color: var(--ink);
  transition: border-color var(--d-fast) ease-out, box-shadow var(--d-fast) ease-out;
}
.input::placeholder { color: var(--ink-3); }
.input:hover { border-color: var(--ink-2); }
.input:focus { outline: none; border-color: var(--plan); box-shadow: 0 0 0 3px var(--plan-soft); }
.input[aria-invalid="true"] { border-color: var(--nogo); }
.input-affix { position: relative; }
.input-affix .input { padding-left: 34px; }
.input-affix span { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--ink-2); font-weight: 600; }
.field-error { font-size: var(--t-13); color: var(--nogo); font-weight: 600; }

/* ---------- topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40; height: var(--topbar-h);
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: var(--s-4);
  padding: 0 var(--s-6); background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--rule);
}
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; font-size: var(--t-18); letter-spacing: -0.02em; text-decoration: none; justify-self: start; }
.brand-mark { width: 28px; height: 28px; }
.topbar-end { justify-self: end; display: flex; gap: var(--s-2); align-items: center; }

.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: var(--r-pill); background: var(--sunken); border: 1px solid var(--rule); }
.seg button {
  height: 34px; padding: 0 var(--s-4); border: 0; border-radius: var(--r-pill); background: transparent;
  color: var(--ink-2); font-weight: 600; font-size: var(--t-14);
  transition: background-color var(--d-base) var(--ease-out), color var(--d-base) var(--ease-out), box-shadow var(--d-base) var(--ease-out);
}
.seg button[aria-checked="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--sh-1); }

/* ---------- landing ---------- */
.landing { max-width: 1200px; margin: 0 auto; padding: 0 var(--s-6); }

.hero { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: var(--s-14); align-items: center; padding: var(--s-18) 0 var(--s-24); }
.hero h1 { font-size: var(--t-hero); line-height: 0.98; font-weight: 800; letter-spacing: -0.035em; max-width: 11ch; }
.lede { margin-top: var(--s-6); font-size: var(--t-18); line-height: 1.55; color: var(--ink-2); max-width: 46ch; }
.hero-actions { display: flex; gap: var(--s-3); flex-wrap: wrap; margin-top: var(--s-8); }
.proof { margin-top: var(--s-6); font-size: var(--t-14); color: var(--ink-2); max-width: 52ch; padding-left: var(--s-4); border-left: 3px solid var(--hl); }

.plan { position: relative; margin: 0; }
.plan-svg { display: block; width: 100%; height: auto; border-radius: var(--r-xl); box-shadow: var(--sh-2); border: 1px solid var(--rule); }
.parcels rect { fill: var(--paper); stroke: var(--rule-strong); }
.plan-labels text, .plan-street { font: 600 12px var(--font); fill: var(--ink-3); }
.plan-street { fill: var(--ink-2); letter-spacing: .02em; }
.vacant-tag text { font: 700 12px var(--font); }
.vacant-fill { transform-origin: 330px 180px; animation: rise 900ms var(--ease-out) 150ms both; }
@keyframes rise { from { transform: scaleY(0); } to { transform: scaleY(1); } }

.plan-card {
  position: absolute; right: -12px; bottom: -36px; width: min(320px, 70%);
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-lg); padding: var(--s-4);
  box-shadow: var(--sh-3);
}
.plan-card-title { font-weight: 700; font-size: var(--t-14); margin-bottom: var(--s-2); }
.mini-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.mini-list li {
  display: grid; grid-template-columns: 1fr auto 66px; gap: var(--s-3); align-items: center;
  padding: 7px var(--s-2); border-radius: var(--r-sm); font-size: var(--t-14);
  animation: enter 420ms var(--ease-out) both; animation-delay: calc(900ms + var(--i) * 140ms);
}
.mini-list li:first-child { background: var(--hl-soft); }
.mini-score { font-weight: 800; text-align: right; }
.mini-list .badge { justify-self: end; }
.plan-card-foot { margin-top: var(--s-2); font-size: var(--t-12); color: var(--ink-2); padding: 0 var(--s-2); }
.plan-cap { margin-top: var(--s-4); max-width: 40%; font-size: var(--t-13); color: var(--ink-3); }
@keyframes enter { from { opacity: 0; transform: translateY(6px); filter: blur(2px); } to { opacity: 1; transform: none; filter: none; } }

.how { padding: var(--s-14) 0; border-top: 1px solid var(--rule); }
.how h2, .versus h2, .limits-band h2 { font-size: var(--t-28); font-weight: 800; }
.steps3 { list-style: none; margin: var(--s-8) 0 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s-8); }
.steps3 h3 { font-size: var(--t-18); font-weight: 700; margin: var(--s-3) 0 var(--s-2); }
.steps3 p { color: var(--ink-2); max-width: 36ch; }
.step-n { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: var(--r-sm); background: var(--ink); color: var(--on-ink); font-weight: 800; }

.versus { padding: var(--s-14) 0; border-top: 1px solid var(--rule); }
.versus-head { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-8); align-items: end; }
.versus-head p { color: var(--ink-2); max-width: 50ch; }
.versus-grid { display: grid; grid-template-columns: 1fr 1fr; margin-top: var(--s-8); border: 1px solid var(--rule); border-radius: var(--r-xl); overflow: hidden; background: var(--surface); }
.vs-col { padding: var(--s-6); }
.vs-col + .vs-col { border-left: 1px solid var(--rule); }
.vs-col h3 { font-size: var(--t-16); font-weight: 700; margin-bottom: var(--s-3); }
.vs-without { background: var(--sunken); }
.vs-without h3 { color: var(--ink-2); }
.vs-list { list-style: none; margin: 0; padding: 0; display: grid; }
.vs-list li { display: grid; grid-template-columns: 1fr auto; gap: 2px var(--s-3); padding: var(--s-3) 0; border-top: 1px solid var(--rule); }
.vs-list li > span:first-child { font-weight: 600; }
.vs-list small { grid-column: 1 / -1; color: var(--ink-2); font-size: var(--t-13); }
.fine { margin-top: var(--s-3); font-size: var(--t-13); color: var(--ink-3); }

.limits-band { padding: var(--s-14) 0 var(--s-18); border-top: 1px solid var(--rule); display: grid; grid-template-columns: 1fr 2fr; gap: var(--s-8); }
.limits-band p { color: var(--ink-2); max-width: 68ch; }

.foot { display: flex; justify-content: space-between; gap: var(--s-2) var(--s-6); flex-wrap: wrap; padding: var(--s-6); border-top: 1px solid var(--rule); color: var(--ink-3); font-size: var(--t-13); }
body.in-app .foot, body.in-app .topbar [data-go-app] { display: none; }

/* ---------- status, badges, chips ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px 0 8px;
  border-radius: var(--r-pill); font-weight: 800; font-size: var(--t-13); letter-spacing: .04em; white-space: nowrap;
}
.badge::before { content: ""; width: 10px; height: 10px; flex: none; background: currentColor; }
.badge-go { color: var(--go); background: var(--go-bg); }
.badge-go::before { border-radius: 50%; }
.badge-adjust { color: var(--adjust); background: var(--adjust-bg); }
.badge-adjust::before { transform: rotate(45deg) scale(.85); border-radius: 2px; }
.badge-nogo { color: var(--nogo); background: var(--nogo-bg); }
.badge-nogo::before { width: 11px; height: 3px; border-radius: 2px; }
.badge-xs { height: 22px; font-size: 11px; padding: 0 8px 0 6px; gap: 5px; }
.badge-xs::before { width: 8px; height: 8px; }
.badge-xs.badge-nogo::before { width: 9px; height: 2.5px; }
.badge-lg { height: 40px; font-size: var(--t-16); padding: 0 var(--s-4) 0 var(--s-3); gap: var(--s-2); }
.badge-lg::before { width: 12px; height: 12px; }

.status { font-size: var(--t-12); font-weight: 700; padding: 2px 8px; border-radius: var(--r-pill); align-self: center; }
.status-ok { color: var(--go); background: var(--go-bg); }
.status-bad { color: var(--nogo); background: var(--nogo-bg); }
.status-mid { color: var(--adjust); background: var(--adjust-bg); }
.status-none { color: var(--ink-2); background: var(--surface); border: 1px solid var(--rule-strong); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 28px; padding: 3px 10px; border-radius: var(--r-xs);
  background: var(--sunken); border: 1px solid var(--rule); font-size: var(--t-13); color: var(--ink);
}
.chip b { font-weight: 700; }
.chip .k { color: var(--ink-2); }

.trend { display: inline-flex; align-items: center; gap: 4px; font-weight: 700; }
.trend svg { width: 15px; height: 15px; }
.trend-up { color: var(--go); } .trend-up svg { transform: rotate(-40deg); }
.trend-flat { color: var(--ink-2); }
.trend-down { color: var(--nogo); } .trend-down svg { transform: rotate(40deg); }

/* ---------- app shell ---------- */
.app { display: grid; grid-template-columns: minmax(0, 1fr) minmax(400px, 468px); height: calc(100dvh - var(--topbar-h)); }
.map-wrap { position: relative; min-height: 0; }
#map { position: absolute; inset: 0; background: var(--sunken); }
#map .leaflet-tile-pane { filter: var(--tile-filter); }
.leaflet-container { font: inherit; }
.leaflet-control-attribution { font-size: 11px; }
[data-theme="dark"] .leaflet-control-attribution, [data-theme="dark"] .leaflet-bar a { background: var(--surface); color: var(--ink-2); }
.map-tools { position: absolute; z-index: 500; top: var(--s-4); right: var(--s-4); display: flex; gap: var(--s-2); }
.map-legend {
  position: absolute; z-index: 500; left: var(--s-4); bottom: var(--s-6); display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-4);
  padding: var(--s-2) var(--s-3); border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--rule); box-shadow: var(--sh-2);
  font-size: var(--t-13); color: var(--ink-2);
}
.map-legend span { display: inline-flex; align-items: center; gap: 6px; }
.lg { width: 12px; height: 12px; display: inline-block; border-radius: 50%; }
.lg-vacant { border-radius: 3px; background: repeating-linear-gradient(45deg, #15203B 0 1.5px, #FFD84D 1.5px 4px); outline: 1.5px solid #15203B; }
.lg-love { background: var(--love); }
.lg-comp { background: var(--surface); border: 2.5px solid var(--comp); }
.lg-scan { border-radius: 2px; background: linear-gradient(90deg, rgba(36, 69, 168, .12), rgba(36, 69, 168, .6)); width: 20px; }
.map-legend [hidden] { display: none; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.sample-flag { position: absolute; z-index: 500; left: 58px; top: var(--s-4); font-size: var(--t-12); font-weight: 700; padding: 4px 10px; border-radius: var(--r-pill); background: var(--hl); color: #15203B; border: 1px solid #15203B; }

/* map pins: the vacant unit is the brand mark */
.pin-unit {
  width: 30px; height: 30px; border-radius: 7px; border: 2px solid #15203B;
  background: repeating-linear-gradient(45deg, #15203B 0 1.8px, #FFD84D 1.8px 6px);
  box-shadow: 0 2px 0 #15203B, 0 6px 14px rgba(21, 32, 59, .3);
  transition: transform var(--d-base) var(--ease-out);
}
.pin-unit.is-active { transform: scale(1.25); box-shadow: 0 0 0 4px #FFD84D, 0 0 0 6px #15203B, 0 8px 18px rgba(21, 32, 59, .4); }
.leaflet-marker-icon:focus-visible .pin-unit { box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--plan); }
.leaflet-marker-icon:focus-visible { box-shadow: none; outline: none; }
.pin-drop { width: 22px; height: 22px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); background: var(--ink); border: 3px solid var(--hl); }
.leaflet-tooltip.tf-tip { font: 600 13px var(--font); border-radius: var(--r-sm); border: 1px solid var(--rule); box-shadow: var(--sh-2); background: var(--surface); color: var(--ink); }
.leaflet-tooltip.tf-tip::before { display: none; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--surface); color: var(--ink); border-radius: var(--r-md); box-shadow: var(--sh-3); }
.leaflet-popup-content { margin: var(--s-4); font: 14px/1.45 var(--font); }
.scan-pop b { font-size: var(--t-22); font-weight: 800; }
.scan-pop table { border-collapse: collapse; margin-top: var(--s-2); }
.scan-pop td, .scan-pop th { padding: 3px 12px 3px 0; text-align: left; font-size: var(--t-13); }

/* ---------- panel ---------- */
.panel { min-height: 0; background: var(--surface); border-left: 1px solid var(--rule); display: flex; flex-direction: column; }
.panel-scroll { position: relative; flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: var(--s-6); display: grid; align-content: start; grid-template-columns: minmax(0, 1fr); grid-auto-rows: max-content; gap: var(--s-6); }
.panel h2 { font-size: var(--t-22); font-weight: 800; }
.panel .sub { color: var(--ink-2); font-size: var(--t-14); margin-top: 4px; }
.panel-enter > * { animation: enter 260ms var(--ease-out) both; }

.unit-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s-2); }
.unit-btn {
  width: 100%; display: grid; grid-template-columns: 34px 1fr auto; gap: var(--s-3); align-items: center; text-align: left;
  padding: var(--s-3); border-radius: var(--r-md); border: 1px solid var(--rule); background: var(--surface);
  transition: border-color var(--d-fast) ease-out, background-color var(--d-fast) ease-out;
}
.unit-btn:hover { border-color: var(--ink-2); }
.unit-btn .pin-unit { width: 26px; height: 26px; box-shadow: none; border-radius: 6px; }
.unit-btn b { display: block; font-weight: 700; }
.unit-btn small { color: var(--ink-2); font-size: var(--t-13); }
.unit-btn .num { font-weight: 700; font-size: var(--t-14); }
.unit-btn .i { color: var(--ink-3); }
.hint-line { font-size: var(--t-13); color: var(--ink-3); }

.unit-card { display: grid; gap: var(--s-4); padding: var(--s-5); border-radius: var(--r-lg); background: var(--hl-soft); border: 1px solid color-mix(in srgb, var(--hl) 60%, var(--rule)); }
.unit-head { display: grid; grid-template-columns: 1fr auto; gap: var(--s-3); align-items: start; }
.unit-head h2 { font-size: var(--t-22); }
.unit-facts { display: flex; gap: var(--s-2) var(--s-5); flex-wrap: wrap; font-size: var(--t-14); color: var(--ink-2); }
.unit-facts b { color: var(--ink); font-weight: 700; }
.unit-card form { display: grid; gap: var(--s-3); }
.row2 { display: grid; grid-template-columns: 1fr auto; gap: var(--s-2); align-items: end; }

/* agent trace */
.trace { display: grid; gap: var(--s-3); }
.trace-head { display: flex; justify-content: space-between; align-items: center; gap: var(--s-3); }
.trace-head h3 { font-size: var(--t-16); font-weight: 700; }
.trace-meta { font-size: var(--t-13); color: var(--ink-2); display: flex; gap: var(--s-3); align-items: center; }
.meter { height: 4px; border-radius: 2px; background: var(--sunken); overflow: hidden; }
.meter i { display: block; height: 100%; width: calc(var(--p, 0) * 1%); background: var(--ink); border-radius: 2px; transition: width var(--d-slow) var(--ease-out); }
.steps { list-style: none; margin: 0; padding: 0; position: relative; }
.step { position: relative; display: grid; grid-template-columns: 24px 1fr; gap: var(--s-3); padding-bottom: var(--s-4); }
.step::after { content: ""; position: absolute; left: 11.5px; top: 26px; bottom: 2px; width: 1px; background: var(--rule-strong); }
.step:last-child::after { display: none; }
.dot { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); border: 1.5px solid var(--rule-strong); color: var(--on-ink); }
.dot svg { width: 13px; height: 13px; }
.step.done .dot { background: var(--ink); border-color: var(--ink); }
.step.live .dot { border-color: var(--ink); }
.step.live .dot::after { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--hl); border: 1.5px solid #15203B; animation: breathe 1.1s ease-in-out infinite; }
.step.warn .dot { background: var(--adjust-bg); border-color: var(--adjust); color: var(--adjust); }
.step.fail .dot { background: var(--nogo); border-color: var(--nogo); }
.step.pending { opacity: .5; }
@keyframes breathe { 50% { transform: scale(.65); } }
.step-title { font-weight: 600; font-size: var(--t-14); line-height: 1.4; display: flex; gap: var(--s-2); align-items: baseline; flex-wrap: wrap; }
.wf { font-size: var(--t-12); font-weight: 700; padding: 1px 7px; border-radius: var(--r-xs); background: var(--plan-soft); color: var(--plan); }
.wf-local { background: var(--sunken); color: var(--ink-2); }
.wf-llm { background: var(--sunken); color: var(--ink-2); border: 1px dashed var(--rule-strong); }
.step-out { font-size: var(--t-13); color: var(--ink-2); margin-top: 2px; }
.step.enter { animation: enter 280ms var(--ease-out) both; }
.step details { margin-top: 6px; }
.step summary { font-size: var(--t-13); color: var(--plan); font-weight: 600; cursor: pointer; list-style: none; display: inline-flex; align-items: center; gap: 4px; min-height: 28px; }
.step summary::-webkit-details-marker { display: none; }
.step summary .i { width: 14px; height: 14px; transition: transform var(--d-base) var(--ease-out); }
.step details[open] summary .i { transform: rotate(90deg); }

/* evidence receipt: one per Qloo call */
.receipt {
  --notch: 6px;
  margin-top: var(--s-2); padding: var(--s-4) var(--s-4) var(--s-3); background: var(--paper); color: var(--ink);
  border: 1px solid var(--rule); border-top: 0; border-bottom: 0; position: relative; font-size: var(--t-13);
  -webkit-mask: radial-gradient(circle var(--notch) at 50% 0, #0000 98%, #000) 50% 0 / calc(2 * var(--notch) + 4px) 51% repeat-x,
                radial-gradient(circle var(--notch) at 50% 100%, #0000 98%, #000) 50% 100% / calc(2 * var(--notch) + 4px) 51% repeat-x;
          mask: radial-gradient(circle var(--notch) at 50% 0, #0000 98%, #000) 50% 0 / calc(2 * var(--notch) + 4px) 51% repeat-x,
                radial-gradient(circle var(--notch) at 50% 100%, #0000 98%, #000) 50% 100% / calc(2 * var(--notch) + 4px) 51% repeat-x;
}
.receipt-head { display: flex; justify-content: space-between; gap: var(--s-2); font-weight: 700; padding-bottom: var(--s-2); border-bottom: 1px dashed var(--rule-strong); }
.receipt dl { display: grid; grid-template-columns: auto 1fr; gap: 4px var(--s-4); margin: var(--s-2) 0; }
.receipt dt { color: var(--ink-2); }
.receipt dd { margin: 0; overflow-wrap: anywhere; }
.receipt-foot { padding-top: var(--s-2); border-top: 1px dashed var(--rule-strong); color: var(--ink-3); font-size: var(--t-12); }

/* trace summary once done */
.trace-done { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); padding: var(--s-3) var(--s-4); border-radius: var(--r-md); background: var(--sunken); font-size: var(--t-14); }
.trace-done b { font-weight: 700; }

/* tabs */
.tabs { display: flex; gap: var(--s-1); border-bottom: 1px solid var(--rule); overflow-x: auto; scrollbar-width: none; }
.tab { flex: none; height: 44px; padding: 0 var(--s-3); border: 0; background: none; color: var(--ink-2); font-weight: 600; font-size: var(--t-14); border-bottom: 2.5px solid transparent; margin-bottom: -1px; border-radius: 0; }
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); }
.tab:hover { color: var(--ink); }
.tab .count { font-size: var(--t-12); color: var(--ink-3); margin-left: 4px; }

[role="tabpanel"] { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s-4); }
[role="tabpanel"]:focus-visible { box-shadow: none; }

/* lead verdict */
.lead { display: grid; gap: var(--s-3); }
.lead-row { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; }
.lead h3 { font-size: var(--t-28); font-weight: 800; line-height: 1.1; letter-spacing: -0.025em; }
.lead p { color: var(--ink-2); font-size: var(--t-14); max-width: 52ch; }

/* score cards */
.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s-3); }
.card {
  border: 1px solid var(--rule); border-radius: var(--r-lg); background: var(--surface); padding: var(--s-4);
  display: grid; gap: var(--s-3); transition: border-color var(--d-fast) ease-out, box-shadow var(--d-fast) ease-out;
}
.card:hover { border-color: var(--rule-strong); }
.card.is-top { border-color: var(--ink); box-shadow: var(--sh-2); }
.card-head { display: grid; grid-template-columns: 28px 1fr auto; gap: var(--s-3); align-items: center; }
.rank { width: 28px; height: 28px; border-radius: var(--r-sm); display: grid; place-items: center; font-weight: 800; font-size: var(--t-14); background: var(--sunken); }
.card.is-top .rank { background: var(--hl); color: #15203B; }
.card-name { font-weight: 700; font-size: var(--t-18); line-height: 1.25; }
.card-why { font-size: var(--t-13); color: var(--ink-2); }
.score { display: grid; justify-items: end; }
.score-n { font-size: var(--t-28); font-weight: 800; line-height: 1; letter-spacing: -0.02em; }
.score-n small { font-size: var(--t-13); color: var(--ink-3); font-weight: 600; }
.stack { display: grid; gap: 6px; }
.stack-bar { display: flex; height: 8px; border-radius: 4px; background: var(--sunken); overflow: hidden; }
.stack-bar i { display: block; height: 100%; transition: width var(--d-slow) var(--ease-out); }
.stack-bar i + i { box-shadow: inset 2px 0 0 var(--surface); }
.seg-demand { background: var(--ink); }
.seg-space { background: var(--plan); opacity: .75; }
.seg-overlap { background: repeating-linear-gradient(45deg, var(--ink-2) 0 1.5px, transparent 1.5px 4px); }
.stack-key { display: flex; gap: var(--s-2) var(--s-4); flex-wrap: wrap; font-size: var(--t-12); color: var(--ink-2); }
.stack-key span { display: inline-flex; align-items: center; gap: 5px; }
.stack-key i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.rent-line { font-size: var(--t-13); display: flex; gap: var(--s-2); align-items: baseline; }
.rent-line .k { color: var(--ink-2); flex: none; }
.card-more { justify-self: start; }
.card-more summary { list-style: none; }
.card-more summary::-webkit-details-marker { display: none; }
.card-more summary .i { width: 14px; height: 14px; transition: transform var(--d-base) var(--ease-out); }
.card-more[open] summary .i { transform: rotate(90deg); }
.card .receipts { display: grid; gap: var(--s-2); }
.unscored { font-size: var(--t-13); color: var(--ink-2); padding: var(--s-3) var(--s-4); border: 1px dashed var(--rule-strong); border-radius: var(--r-md); }

/* comparison panel */
.compare { display: grid; gap: var(--s-4); }
.compare-sum { font-size: var(--t-14); color: var(--ink-2); }
.compare-sum b { color: var(--ink); }
.cmp-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); border: 1px solid var(--rule); border-radius: var(--r-lg); overflow: hidden; }
.cmp-col { padding: var(--s-4); display: grid; align-content: start; gap: var(--s-2); }
.cmp-col + .cmp-col { border-left: 1px solid var(--rule); }
.cmp-col h4 { margin: 0 0 var(--s-1); font-size: var(--t-14); font-weight: 700; }
.cmp-without { background: var(--sunken); }
.cmp-item { display: grid; gap: 3px; padding-top: var(--s-2); border-top: 1px solid var(--rule); }
.cmp-item .top { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px var(--s-2); align-items: center; font-weight: 600; font-size: var(--t-14); }
.cmp-item small { font-size: var(--t-12); color: var(--ink-2); }
.cmp-new { font-size: var(--t-12); font-weight: 700; color: var(--plan); }

/* founder verdict */
.verdict-card { display: grid; grid-template-columns: auto 1fr; gap: var(--s-5); align-items: center; padding: var(--s-5); border: 1px solid var(--ink); border-radius: var(--r-lg); box-shadow: var(--sh-2); }
.dial { --v: 0; --c: var(--go); width: 108px; height: 108px; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(var(--c) calc(var(--v) * 1%), var(--sunken) 0); }
.dial > div { width: 86px; height: 86px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; text-align: center; }
.dial b { font-size: var(--t-36); font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.dial span { display: block; font-size: 11px; color: var(--ink-2); }

/* actions */
.actions { display: flex; gap: var(--s-2); align-items: center; position: sticky; bottom: calc(-1 * var(--s-6)); margin: 0 calc(-1 * var(--s-6)) calc(-1 * var(--s-6)); padding: var(--s-3) var(--s-6) var(--s-4); background: var(--surface); border-top: 1px solid var(--rule); }
.actions { flex-wrap: wrap; }
.actions .btn { padding: 0 var(--s-4); }
.actions .btn-quiet { margin-left: auto; }

/* empty / error / skeleton */
.state { display: grid; gap: var(--s-3); padding: var(--s-5); border-radius: var(--r-lg); border: 1px solid var(--rule); }
.state h3 { font-size: var(--t-18); font-weight: 700; }
.state p { color: var(--ink-2); font-size: var(--t-14); }
.state-error { border-color: var(--nogo); border-left-width: 4px; }
.state-warn { border-color: var(--adjust); border-left-width: 4px; background: var(--adjust-bg); }
.state-warn p { color: var(--ink); }
.state .btns { display: flex; gap: var(--s-2); flex-wrap: wrap; margin-top: var(--s-1); }
.sk { height: 12px; border-radius: 6px; background: linear-gradient(90deg, var(--sunken) 0 40%, var(--rule) 50%, var(--sunken) 60% 100%) 0 0 / 300% 100%; animation: shimmer 1.4s linear infinite; }
@keyframes shimmer { to { background-position: -150% 0; } }
.empty-art { width: 100%; max-width: 220px; height: auto; }

/* toast */
.toast { position: fixed; z-index: 80; left: 50%; bottom: var(--s-6); transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--ink); color: var(--on-ink); padding: var(--s-3) var(--s-5); border-radius: var(--r-pill); font-weight: 600; font-size: var(--t-14);
  transition-property: opacity, transform; transition-duration: var(--d-base); transition-timing-function: var(--ease-out); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- memo (screen + print) ---------- */
.memo { width: min(860px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); padding: 0; border: 0; border-radius: var(--r-xl); background: var(--paper); color: var(--ink); box-shadow: var(--sh-3); }
.memo::backdrop { background: rgba(15, 22, 38, .55); backdrop-filter: blur(3px); }
.memo[open] { animation: enter 260ms var(--ease-out); }
.memo-bar { position: sticky; top: 0; z-index: 2; display: flex; justify-content: space-between; align-items: center; padding: var(--s-3) var(--s-4); background: var(--paper); border-bottom: 1px solid var(--rule); }
.memo-page { margin: var(--s-6); padding: var(--s-10); background: #fff; color: #15203B; border-radius: var(--r-sm); box-shadow: var(--sh-1);
  --ink: #15203B; --ink-2: #4B5568; --ink-3: #5E6779; --rule: #DDE2E8; --rule-strong: #C3CAD3; --sunken: #E9EDF1; --surface: #fff;
  --go: #17703F; --go-bg: #E3F3E9; --adjust: #8A5A00; --adjust-bg: #FBEFD3; --nogo: #B42318; --nogo-bg: #FCE4E1; --on-ink: #fff; --plan: #2445A8; }
.memo-top { display: flex; justify-content: space-between; align-items: start; gap: var(--s-4); padding-bottom: var(--s-4); border-bottom: 2px solid #15203B; }
.memo-top .brand { font-size: var(--t-16); }
.memo-top .meta { text-align: right; font-size: var(--t-13); color: var(--ink-2); }
.memo-stamp { display: inline-block; margin-top: 4px; font-weight: 800; font-size: var(--t-12); padding: 2px 8px; border: 1.5px solid #15203B; background: #FFD84D; border-radius: var(--r-xs); color: #15203B; }
.memo-page h1 { font-size: var(--t-36); font-weight: 800; letter-spacing: -0.03em; margin: var(--s-6) 0 var(--s-2); line-height: 1.05; }
.memo-page h2 { font-size: var(--t-16); font-weight: 800; margin: var(--s-6) 0 var(--s-2); }
.memo-page p, .memo-page li { font-size: var(--t-14); max-width: 75ch; }
.memo-page ul { padding-left: 18px; margin: 0; display: grid; gap: 4px; }
.memo-table { width: 100%; border-collapse: collapse; font-size: var(--t-13); }
.memo-table th, .memo-table td { text-align: left; padding: 8px 10px 8px 0; border-bottom: 1px solid var(--rule); vertical-align: top; }
.memo-table thead th { color: var(--ink-2); font-weight: 600; border-bottom: 1.5px solid #15203B; }
.memo-table td:first-child { font-weight: 700; }
.memo-table td:last-child, .memo-table th:last-child { white-space: nowrap; padding-right: 0; }
.memo-limits { margin-top: var(--s-6); padding-top: var(--s-3); border-top: 1px solid var(--rule); color: var(--ink-2); }
.memo-limits li, .memo-limits p { font-size: var(--t-12); }

@media print {
  @page { size: A4; margin: 14mm; }
  body > *:not(.memo) { display: none !important; }
  .memo { position: static; display: block; width: auto; max-height: none; box-shadow: none; background: #fff; border-radius: 0; }
  .memo::backdrop { display: none; }
  .memo-bar { display: none; }
  .memo-page { margin: 0; padding: 0; box-shadow: none; }
  .memo-table tr, .memo-page h2 { break-inside: avoid; break-after: avoid; }
}

/* ---------- responsive ---------- */
@media (max-width: 1040px) {
  .hero { grid-template-columns: 1fr; gap: var(--s-14); padding-top: var(--s-10); }
  .plan-card { right: var(--s-4); }
}
@media (max-width: 860px) {
  :root { --topbar-h: 112px; }
  .topbar { grid-template-columns: 1fr auto; grid-template-rows: 60px 52px; height: auto; padding: 0 var(--s-4); row-gap: 0; }
  .seg { grid-column: 1 / -1; grid-row: 2; justify-self: stretch; margin-bottom: var(--s-2); }
  .seg button { flex: 1; }
  .landing { padding: 0 var(--s-4); }
  .steps3, .versus-head, .limits-band { grid-template-columns: 1fr; gap: var(--s-6); }
  .versus-grid, .cmp-grid { grid-template-columns: 1fr; }
  .vs-col + .vs-col, .cmp-col + .cmp-col { border-left: 0; border-top: 1px solid var(--rule); }
  .plan-card { position: relative; right: auto; bottom: auto; width: auto; margin: -40px var(--s-3) 0; }
  .plan-cap { margin-top: var(--s-3); }
  .app { display: block; height: auto; }
  .map-wrap { height: 46dvh; min-height: 300px; position: sticky; top: var(--topbar-h); z-index: 1; }
  .map-legend { display: none; }
  .map-wrap .leaflet-bottom { bottom: 18px; }
  .panel { position: relative; z-index: 2; border-left: 0; border-radius: var(--r-xl) var(--r-xl) 0 0; margin-top: -18px; box-shadow: 0 -8px 24px -12px rgba(21, 32, 59, .3); }
  .panel::before { content: ""; display: block; width: 40px; height: 4px; border-radius: 2px; background: var(--rule-strong); margin: 10px auto 0; }
  .panel-scroll { overflow: visible; padding: var(--s-4) var(--s-4) var(--s-10); }
  .actions { bottom: 0; margin: 0 calc(-1 * var(--s-4)); padding: var(--s-3) var(--s-4) calc(var(--s-3) + env(safe-area-inset-bottom)); }
  .memo-page { margin: var(--s-3); padding: var(--s-5); }
}
@media (max-width: 420px) {
  .brand span { display: none; }
  .hero-actions .btn { width: 100%; }
  .verdict-card { grid-template-columns: 1fr; justify-items: start; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-delay: 0ms !important; transition-duration: 1ms !important; }
}

/* ---------- live app additions ---------- */
.cta-line { margin-top: var(--s-4); font-size: var(--t-14); color: var(--ink-2); max-width: 52ch; }
.cta-line a { color: var(--ink); text-underline-offset: 3px; font-weight: 600; }
.foot a { color: inherit; text-underline-offset: 3px; }
.chip-warn { color: var(--adjust); background: var(--adjust-bg); border-color: var(--adjust); font-weight: 700; }
.memo-md h1, .memo-md h2 { font-size: var(--t-16); font-weight: 800; margin: var(--s-6) 0 var(--s-2); }
.memo-md h3 { font-size: var(--t-14); font-weight: 700; margin: var(--s-4) 0 var(--s-1); }
.memo-md ul { padding-left: 1.2em; }
.memo-md table { border-collapse: collapse; font-size: var(--t-13); }
.memo-md th, .memo-md td { text-align: left; padding: 6px 10px 6px 0; border-bottom: 1px solid var(--rule); }
#scan-concept { appearance: auto; }
.scan-pop table { border-collapse: collapse; margin-top: 8px; font-size: 12px; }
.scan-pop th, .scan-pop td { text-align: left; padding: 3px 10px 3px 0; border-bottom: 1px solid #DDE2E8; }

.scan { padding: var(--s-14) 0 var(--s-18); border-top: 1px solid var(--rule); }
.scan-head-row h2 { font-size: var(--t-28); font-weight: 800; }
.scan-head-row p { color: var(--ink-2); max-width: 60ch; margin-top: var(--s-2); }
.scan-form { display: flex; gap: var(--s-4) var(--s-5); align-items: end; flex-wrap: wrap; margin-top: var(--s-6); }
.scan-form label { display: grid; gap: 6px; font-size: var(--t-14); font-weight: 600; color: var(--ink-2); }
.scan-form select { font: 500 var(--t-16)/1.2 var(--font); color: var(--ink); background: var(--surface); border: 1px solid var(--rule-strong); border-radius: var(--r-md); padding: 11px 12px; min-width: 200px; }
.scan-form button:disabled { opacity: .5; cursor: progress; }
#scan-out { margin-top: var(--s-6); display: grid; gap: var(--s-2); }
.scan-sub { font-size: var(--t-14); font-weight: 600; color: var(--ink-2); }
.cells { list-style: none; margin: 0; padding: 0; border: 1px solid var(--rule); border-radius: var(--r-xl); background: var(--surface); overflow: hidden; }
.cell { padding: var(--s-5) var(--s-6); display: grid; gap: var(--s-2); justify-items: start; }
.cell + .cell { border-top: 1px solid var(--rule); }
.cell-head { display: flex; justify-content: space-between; align-items: baseline; gap: 6px 16px; flex-wrap: wrap; width: 100%; }
.cell-head h3 { font-size: var(--t-18); font-weight: 700; }
.cell-head span { font-size: var(--t-14); color: var(--ink-2); font-variant-numeric: tabular-nums; }
.cell-head b { font-size: var(--t-22); font-weight: 800; color: var(--ink); margin-right: 6px; }
.cell p { font-size: var(--t-14); color: var(--ink-2); max-width: 72ch; }
.cell p.watch { color: var(--nogo); }
.rent-table { border-collapse: collapse; font-size: var(--t-14); font-variant-numeric: tabular-nums; }
.rent-table th, .rent-table td { text-align: left; padding: 8px 24px 8px 0; border-bottom: 1px solid var(--rule); vertical-align: baseline; }
.rent-table tr:first-child th { color: var(--ink-2); font-weight: 600; }
.rent-table th[scope=row] { font-weight: 500; }
.scan-attr { font-size: var(--t-13); color: var(--ink-3); max-width: 80ch; }
.adjust-note { font-size: var(--t-14); color: var(--adjust); font-weight: 600; }
.breakdown { display: grid; gap: var(--s-2); padding-top: var(--s-2); }
.wf-bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.wf-bars li { display: grid; grid-template-columns: minmax(0, 11rem) 1fr 3.2rem; gap: var(--s-2); align-items: center; font-size: var(--t-13); }
.wf-bars .k { color: var(--ink-3); }
.wf-bars b { text-align: right; }
.wf-track { position: relative; height: 10px; background: var(--sunken); border-radius: 5px; }
.wf-track::after { content: ""; position: absolute; left: 50%; top: -2px; bottom: -2px; width: 1px; background: var(--rule-strong); }
.wf-track i { position: absolute; top: 0; bottom: 0; border-radius: 5px; }
.wf-pos { background: var(--go); }
.wf-neg { background: var(--nogo); }
.voi { margin-top: var(--s-3); padding: var(--s-3) var(--s-4); border-left: 3px solid var(--hl); background: var(--hl-soft); border-radius: var(--r-sm); display: grid; gap: var(--s-1); }
.voi p { font-size: var(--t-14); color: var(--ink); }