:root {
  color-scheme: light;
  --color-primary: #0f766e;
  --color-primary-dark: #075d57;
  --color-accent: #ea580c;
  --color-ink: #0f172a;
  --color-muted-ink: #475569;
  --color-subtle-ink: #64748b;
  --color-background: #f8fafc;
  --color-surface: #ffffff;
  --color-muted: #f1f5f9;
  --color-border: #cbd5e1;
  --color-border-soft: #e2e8f0;
  --focus-ring: 0 0 0 3px rgba(15, 118, 110, .2);
  --font-body: "Avenir Next", Avenir, Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --shadow-panel: 0 10px 30px rgba(15, 23, 42, .09);
  --transition-fast: 180ms ease;
}
* { box-sizing: border-box; }
html, body { width: 100%; min-height: 100%; margin: 0; background: var(--color-background); color: var(--color-ink); font-family: var(--font-body); }
body { overflow: hidden; }
button, select, input { font: inherit; }
button, select { color: inherit; }
button { cursor: pointer; }
button:focus-visible, select:focus-visible, input:focus-visible { outline: none; box-shadow: var(--focus-ring); }
[hidden] { display: none !important; }

.workspace { height: 100vh; min-height: 0; display: grid; grid-template-columns: 320px minmax(520px, 1fr) 320px; background: var(--color-border); gap: 1px; }
.research-panel, .results-panel { min-height: 0; overflow-y: auto; background: var(--color-surface); scrollbar-width: thin; scrollbar-color: var(--color-border) transparent; }
.research-panel { padding: 28px 24px 22px; }
.study-header { padding-bottom: 24px; border-bottom: 1px solid var(--color-border-soft); }
.location-label, .map-kicker, .panel-kicker { margin: 0; color: var(--color-primary); font-family: var(--font-mono); font-size: 11px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; }
.study-header h1 { margin: 9px 0 12px; max-width: 10ch; font-size: 32px; line-height: 1.02; letter-spacing: -.04em; font-weight: 680; text-wrap: balance; }
.research-question { margin: 0; color: var(--color-muted-ink); font-size: 15px; line-height: 1.55; }
.study-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 20px 0 0; }
.study-facts div { padding-left: 10px; border-left: 2px solid var(--color-primary); }
.study-facts dt { color: var(--color-subtle-ink); font-size: 11px; }
.study-facts dd { margin: 2px 0 0; font-family: var(--font-mono); font-size: 16px; font-weight: 700; }

.control-section { padding: 22px 0; border-bottom: 1px solid var(--color-border-soft); }
.section-heading { display: flex; align-items: center; gap: 9px; margin-bottom: 16px; }
.section-heading > span { display: grid; place-items: center; width: 23px; height: 23px; border-radius: 50%; background: var(--color-muted); color: var(--color-primary); font-family: var(--font-mono); font-size: 9px; font-weight: 700; }
.section-heading h2 { margin: 0; font-size: 14px; letter-spacing: -.01em; }
.control-section label, .control-label { display: block; margin: 15px 0 7px; color: var(--color-muted-ink); font-size: 13px; font-weight: 650; }
.segmented { display: grid; grid-template-columns: 1fr 1fr; padding: 3px; border: 1px solid var(--color-border); border-radius: 7px; background: var(--color-muted); }
.segmented button { min-height: 44px; border: 0; border-radius: 5px; background: transparent; color: var(--color-muted-ink); font-size: 12px; font-weight: 600; transition: background var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast); }
.segmented button:hover { color: var(--color-ink); }
.segmented button.active { background: var(--color-surface); color: var(--color-primary-dark); box-shadow: 0 1px 3px rgba(15, 23, 42, .12); }
.select-wrap { position: relative; }
.select-wrap select { width: 100%; min-height: 44px; appearance: none; border: 1px solid var(--color-border); border-radius: 6px; background: var(--color-surface); padding: 9px 38px 9px 11px; font-size: 13px; transition: border-color var(--transition-fast), box-shadow var(--transition-fast); }
.select-wrap select:hover { border-color: #94a3b8; }
.select-wrap svg { position: absolute; right: 11px; top: 11px; width: 20px; height: 20px; fill: none; stroke: var(--color-primary); stroke-width: 1.7; pointer-events: none; }
.field-note { margin: 8px 0 0; color: var(--color-subtle-ink); font-size: 11px; line-height: 1.5; }
.threshold-control { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.threshold-control button { min-height: 52px; padding: 7px 4px; border: 1px solid var(--color-border); border-radius: 6px; background: var(--color-surface); transition: border-color var(--transition-fast), background var(--transition-fast), color var(--transition-fast); }
.threshold-control button:hover { border-color: var(--color-primary); }
.threshold-control button.active { border-color: var(--color-primary); background: #e6f3f0; color: var(--color-primary-dark); }
.threshold-control strong, .threshold-control small { display: block; }
.threshold-control strong { font-family: var(--font-mono); font-size: 13px; }
.threshold-control small { margin-top: 3px; color: var(--color-subtle-ink); font-size: 10px; }
.label-row { display: flex; align-items: center; justify-content: space-between; }
.label-row label { margin: 0; }
.label-row output { color: var(--color-primary-dark); font-family: var(--font-mono); font-size: 14px; font-weight: 700; }
input[type="range"] { width: 100%; height: 44px; appearance: none; border-radius: 999px; background-color: transparent; background-image: linear-gradient(90deg, var(--color-primary) 0 84%, var(--color-border) 84%); background-position: center; background-repeat: no-repeat; background-size: 100% 4px; margin: 0 0 2px; }
input[type="range"]::-webkit-slider-thumb { width: 17px; height: 17px; appearance: none; border: 3px solid var(--color-surface); border-radius: 50%; background: var(--color-primary); box-shadow: 0 0 0 1px var(--color-primary); }
.range-labels { display: flex; justify-content: space-between; color: var(--color-subtle-ink); font-size: 10px; }
.play-button { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 44px; margin-top: 20px; border: 1px solid var(--color-primary); border-radius: 6px; background: var(--color-surface); color: var(--color-primary-dark); font-size: 12px; font-weight: 700; transition: background var(--transition-fast), color var(--transition-fast); }
.play-button:hover, .play-button.playing { background: var(--color-primary); color: white; }
.play-button svg { width: 18px; height: 18px; fill: currentColor; }
.source-note { margin-top: 18px; color: var(--color-subtle-ink); font-size: 10px; line-height: 1.6; }

.map-stage { min-width: 0; position: relative; overflow: hidden; background: #edf2f5; }
#map { display: block; width: 100%; height: 100%; min-height: 620px; cursor: grab; touch-action: none; }
#map.dragging { cursor: grabbing; }
.map-heading { position: absolute; z-index: 4; top: 20px; left: 20px; right: 20px; display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; pointer-events: none; }
.map-heading > div { max-width: 560px; padding: 13px 15px; border: 1px solid var(--color-border); background: var(--color-surface); box-shadow: var(--shadow-panel); }
.map-heading h2 { margin: 4px 0 3px; font-size: 18px; line-height: 1.25; letter-spacing: -.025em; }
.map-heading p:last-child { margin: 0; color: var(--color-muted-ink); font-size: 12px; }
.site-status { padding: 9px 11px; border: 1px solid var(--color-border); border-left: 3px solid var(--color-accent); background: var(--color-surface); color: var(--color-muted-ink); font-family: var(--font-mono); font-size: 10px; font-weight: 700; box-shadow: var(--shadow-panel); white-space: nowrap; }
.landuse { stroke: rgba(100, 116, 139, .25); stroke-width: .45; vector-effect: non-scaling-stroke; pointer-events: none; }
.landuse.residential { fill: #e7e2dc; }.landuse.commercial { fill: #eadbd6; }.landuse.institutional { fill: #dfdaf0; }
.landuse.industrial { fill: #ddd9d5; }.landuse.transport { fill: #e4e7eb; }.landuse.openSpace { fill: #dbe9d7; }.landuse.water { fill: #cfe5ef; }
.block { stroke: rgba(71, 85, 105, .35); stroke-width: .65; vector-effect: non-scaling-stroke; cursor: pointer; transition: fill 240ms ease, opacity 240ms ease; }
.block:hover { stroke: var(--color-ink); stroke-width: 1.6; }
.buildings { fill: rgba(255, 255, 255, .28); stroke: rgba(71, 85, 105, .42); stroke-width: .42; vector-effect: non-scaling-stroke; pointer-events: none; }
.road { fill: none; vector-effect: non-scaling-stroke; pointer-events: none; stroke-linecap: round; stroke-linejoin: round; }
.road.path { stroke: #a8b2bd; stroke-width: .4; opacity: .55; stroke-dasharray: 1.3 1.5; }
.road.local { stroke: #7f8d9b; stroke-width: .58; opacity: .66; }
.road.major { stroke: #526171; stroke-width: 1.12; opacity: .82; }
#map.coverage-off .buildings { fill: rgba(255, 255, 255, .65); stroke: rgba(71, 85, 105, .52); }
.boundary { fill: none; stroke: #0f172a; stroke-width: 1.5; vector-effect: non-scaling-stroke; stroke-dasharray: 5 4; opacity: .82; }
.site-marker { cursor: pointer; vector-effect: non-scaling-stroke; }
.site-marker .halo { fill: white; stroke: currentColor; stroke-width: 1.5; opacity: .9; }
.site-marker .core { fill: currentColor; stroke: white; stroke-width: 1.4; }
.site-marker.outside .core { fill: white; stroke: currentColor; stroke-width: 2; }
.site-marker:hover .halo { stroke-width: 3; }
.demand-point { fill: #334155; opacity: .42; pointer-events: none; }
.layer-hidden { display: none; }
.map-toolbar { position: absolute; z-index: 6; top: 102px; right: 20px; }
.layer-menu-button { display: flex; align-items: center; justify-content: center; gap: 7px; min-height: 44px; padding: 7px 12px; border: 1px solid var(--color-border); border-radius: 5px; background: var(--color-surface); color: var(--color-muted-ink); font-size: 11px; font-weight: 700; box-shadow: 0 2px 8px rgba(15, 23, 42, .08); transition: border-color var(--transition-fast), color var(--transition-fast); }
.layer-menu-button:hover, .layer-menu-button[aria-expanded="true"] { border-color: var(--color-primary); color: var(--color-primary-dark); }
.layer-menu-button svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.6; }
.layer-panel { position: absolute; top: 50px; right: 0; width: 292px; max-height: calc(100vh - 178px); overflow-y: auto; border: 1px solid var(--color-border); border-radius: 7px; background: var(--color-surface); box-shadow: var(--shadow-panel); }
.layer-panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 54px; padding: 7px 7px 7px 14px; border-bottom: 1px solid var(--color-border-soft); }
.layer-panel-title, .layer-panel-title strong, .layer-panel-title small { display: block; }.layer-panel-title strong { font-size: 13px; }.layer-panel-title small { margin-top: 2px; color: var(--color-subtle-ink); font-size: 10px; }
.layer-panel-heading button { display: grid; place-items: center; flex: 0 0 44px; width: 44px; height: 44px; border: 0; border-radius: 5px; background: transparent; color: var(--color-muted-ink); }.layer-panel-heading button:hover { background: var(--color-muted); color: var(--color-ink); }.layer-panel-heading svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; }
.layer-panel fieldset { margin: 0; padding: 8px 8px 9px; border: 0; border-bottom: 1px solid var(--color-border-soft); }
.layer-panel legend { padding: 8px 6px 4px; color: var(--color-subtle-ink); font-family: var(--font-mono); font-size: 9px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.layer-row { display: grid; grid-template-columns: 20px 18px 1fr; align-items: center; gap: 9px; min-height: 48px; padding: 5px 6px; border-radius: 5px; cursor: pointer; }
.layer-row:hover { background: var(--color-muted); }.layer-row input { width: 17px; height: 17px; margin: 0; accent-color: var(--color-primary); cursor: pointer; }
.layer-row span, .layer-row b, .layer-row small { display: block; }.layer-row b { font-size: 11px; line-height: 1.25; }.layer-row small { margin-top: 2px; color: var(--color-subtle-ink); font-size: 9px; line-height: 1.25; }
.layer-swatch { display: block; width: 17px; height: 12px; border: 1px solid rgba(71, 85, 105, .35); }
.coverage-swatch { background: #4ca99e; }.site-swatch { width: 12px; height: 12px; margin-left: 2px; border: 3px solid white; border-radius: 50%; background: var(--color-accent); box-shadow: 0 0 0 1px var(--color-accent); }.demand-swatch { width: 8px; height: 8px; margin-left: 4px; border: 0; border-radius: 50%; background: #475569; }.boundary-swatch { height: 0; border: 0; border-top: 2px dashed #334155; }.road-swatch { height: 0; border: 0; border-top: 2px solid #64748b; }.building-swatch { background: #f8fafc; }.landuse-swatch { background: #dbe9d7; }
.landuse-key { display: grid; grid-template-columns: 1fr 1fr; gap: 7px 10px; padding: 11px 14px 13px; color: var(--color-subtle-ink); font-size: 9px; }
.landuse-key span { display: flex; align-items: center; gap: 5px; }.landuse-key i { width: 10px; height: 10px; border: 1px solid rgba(71, 85, 105, .22); }.landuse-key .open-space { background: #dbe9d7; }.landuse-key .civic { background: #dfdaf0; }.landuse-key .commercial { background: #eadbd6; }.landuse-key .water { background: #cfe5ef; }
.zoom-controls { position: absolute; z-index: 4; right: 20px; bottom: 78px; display: grid; overflow: hidden; border: 1px solid var(--color-border); border-radius: 5px; background: var(--color-surface); box-shadow: 0 4px 14px rgba(15, 23, 42, .11); }
.zoom-controls button { display: grid; place-items: center; width: 44px; height: 44px; border: 0; border-bottom: 1px solid var(--color-border-soft); background: var(--color-surface); color: var(--color-muted-ink); transition: background var(--transition-fast), color var(--transition-fast); }
.zoom-controls button:last-child { border-bottom: 0; }
.zoom-controls button:hover { background: var(--color-muted); color: var(--color-primary-dark); }
.zoom-controls svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; }
.legend { position: absolute; z-index: 4; left: 20px; bottom: 20px; display: flex; align-items: center; gap: 11px; padding: 10px 12px; border: 1px solid var(--color-border); background: var(--color-surface); color: var(--color-muted-ink); font-size: 10px; box-shadow: 0 4px 14px rgba(15, 23, 42, .09); }
.legend strong { color: var(--color-ink); font-size: 10px; }
.legend span { display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.legend i { display: block; width: 16px; height: 8px; border: 1px solid rgba(71, 85, 105, .2); }
.legend .c0 { background: #e8edf0; }.legend .c1 { background: #9acfc6; }.legend .c2 { background: #4ca99e; }.legend .c3 { background: #075d57; }
.map-tooltip { position: absolute; z-index: 8; min-width: 210px; max-width: 260px; padding: 11px 12px; border: 1px solid var(--color-border); border-top: 3px solid var(--color-primary); background: var(--color-surface); box-shadow: var(--shadow-panel); color: var(--color-muted-ink); font-size: 11px; line-height: 1.5; pointer-events: none; }
.map-tooltip strong { display: block; margin-bottom: 2px; color: var(--color-ink); font-size: 12px; }.map-tooltip span { color: var(--color-primary-dark); font-weight: 700; }.map-tooltip small { color: var(--color-subtle-ink); }

.results-panel { display: flex; flex-direction: column; padding: 27px 22px 18px; }
.results-header { display: flex; align-items: center; justify-content: space-between; padding-bottom: 16px; border-bottom: 1px solid var(--color-border-soft); }
.results-header > span { color: var(--color-subtle-ink); font-family: var(--font-mono); font-size: 10px; }
.primary-result { padding: 24px 0 20px; }
.primary-result h2 { margin: 0; color: var(--color-muted-ink); font-size: 13px; font-weight: 600; }
.primary-result > strong { display: block; margin: 5px 0 11px; color: var(--color-primary-dark); font-family: var(--font-mono); font-size: 52px; line-height: 1; letter-spacing: -.06em; }
.primary-result > strong small { margin-left: 3px; font-size: 19px; letter-spacing: 0; }
.metric-bar { height: 6px; overflow: hidden; border-radius: 999px; background: var(--color-muted); }.metric-bar i { display: block; width: 25.3%; height: 100%; border-radius: inherit; background: var(--color-primary); transition: width 240ms ease; }
.primary-result p { margin: 9px 0 0; color: var(--color-muted-ink); font-size: 12px; line-height: 1.5; }
.supporting-metrics { display: grid; grid-template-columns: 1fr 1fr; margin: 0; padding: 0 0 20px; border-bottom: 1px solid var(--color-border-soft); }
.supporting-metrics div { padding: 11px 0; }.supporting-metrics div + div { padding-left: 18px; border-left: 1px solid var(--color-border-soft); }
.supporting-metrics dt { color: var(--color-subtle-ink); font-size: 11px; }.supporting-metrics dd { margin: 2px 0 0; font-family: var(--font-mono); font-size: 22px; font-weight: 700; }.supporting-metrics dd small { margin-left: 3px; color: var(--color-subtle-ink); font-size: 11px; }
.result-section { padding: 20px 0; border-bottom: 1px solid var(--color-border-soft); }
.result-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }.result-heading h2 { margin: 0; font-size: 13px; }.result-heading span { color: var(--color-subtle-ink); font-family: var(--font-mono); font-size: 9px; text-transform: uppercase; }
.bar-row { display: grid; grid-template-columns: 82px 1fr 38px; align-items: center; gap: 8px; min-height: 30px; color: var(--color-muted-ink); font-size: 10px; }
.bar-track { height: 6px; overflow: hidden; border-radius: 999px; background: var(--color-muted); }.bar-track i { display: block; height: 100%; border-radius: inherit; background: #94a3b8; transition: width 240ms ease; }.bar-row.selected { color: var(--color-ink); font-weight: 700; }.bar-row.selected .bar-track i { background: var(--color-accent); }.bar-row b { text-align: right; font-family: var(--font-mono); font-size: 10px; }
.sensitivity-row { display: grid; grid-template-columns: 44px 1fr 40px; align-items: center; gap: 8px; min-height: 27px; color: var(--color-muted-ink); font-size: 10px; }.sensitivity-row span:first-child, .sensitivity-row b { font-family: var(--font-mono); }.sensitivity-track { position: relative; height: 3px; background: var(--color-border-soft); }.sensitivity-track i { display: block; height: 100%; background: var(--color-primary); }.sensitivity-track::after { content: ""; position: absolute; top: -3px; left: var(--value); width: 8px; height: 8px; border: 2px solid var(--color-primary); border-radius: 50%; background: white; transform: translateX(-50%); }
.reading-note { padding: 20px 0 0; }.reading-note h2 { margin: 0 0 6px; font-size: 12px; }.reading-note p { margin: 0; color: var(--color-subtle-ink); font-size: 10px; line-height: 1.55; }
.results-footer { display: flex; justify-content: space-between; margin-top: auto; padding-top: 18px; color: var(--color-subtle-ink); font-family: var(--font-mono); font-size: 8px; }

/* ---- Evaluation button + dialog ------------------------------------------------- */
.analysis-button { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; min-height: 52px; margin-top: 16px; padding: 9px 14px; border: 1px solid var(--color-primary-dark); border-radius: 6px; background: var(--color-primary-dark); color: #fff; text-align: left; box-shadow: 0 4px 12px rgba(7, 93, 87, .22); transition: background var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast); }
.analysis-button:hover { background: #054a45; transform: translateY(-1px); box-shadow: 0 6px 16px rgba(7, 93, 87, .28); }
.analysis-button:focus-visible { box-shadow: 0 0 0 3px rgba(7, 93, 87, .35); }
.analysis-button span, .analysis-button strong, .analysis-button small { display: block; }
.analysis-button strong { font-size: 13px; letter-spacing: -.01em; }
.analysis-button small { margin-top: 2px; color: rgba(255, 255, 255, .74); font-size: 10px; }
.analysis-button svg { flex: 0 0 20px; width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
body.dialog-open { overflow: hidden; }

.analysis-dialog { width: min(1120px, calc(100vw - 48px)); max-height: calc(100dvh - 48px); padding: 0; border: 1px solid var(--color-border); border-radius: 10px; background: var(--color-background); color: var(--color-ink); box-shadow: 0 24px 60px rgba(15, 23, 42, .28); overflow: hidden; }
.analysis-dialog[open] { display: flex; flex-direction: column; animation: dialog-in 200ms ease; }
.analysis-dialog::backdrop { background: rgba(15, 23, 42, .46); backdrop-filter: blur(2px); }
@keyframes dialog-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.analysis-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding: 22px 26px 18px; border-bottom: 1px solid var(--color-border-soft); border-top: 4px solid var(--color-primary-dark); background: var(--color-surface); }
.analysis-header h2 { margin: 6px 0 6px; font-size: 26px; line-height: 1.1; letter-spacing: -.035em; font-weight: 680; }
.analysis-lede { max-width: 68ch; margin: 0; color: var(--color-muted-ink); font-size: 13px; line-height: 1.55; }
.analysis-close { display: grid; place-items: center; flex: 0 0 44px; width: 44px; height: 44px; border: 1px solid var(--color-border-soft); border-radius: 6px; background: var(--color-surface); color: var(--color-muted-ink); }
.analysis-close:hover { background: var(--color-muted); color: var(--color-ink); }
.analysis-close svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.analysis-body { overflow-y: auto; padding: 20px 26px 22px; scrollbar-width: thin; scrollbar-color: var(--color-border) transparent; }
.analysis-loading { color: var(--color-subtle-ink); font-size: 12px; }

.eval-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; overflow: hidden; border: 1px solid var(--color-border-soft); border-radius: 8px; background: var(--color-border-soft); }
.eval-kpi { padding: 14px 16px 13px; background: var(--color-surface); }
.eval-kpi strong { display: block; color: var(--color-ink); font-family: var(--font-mono); font-size: 28px; line-height: 1; letter-spacing: -.05em; }
.eval-kpi strong small { margin-left: 2px; color: var(--color-subtle-ink); font-size: 13px; letter-spacing: 0; }
.eval-kpi span { display: block; margin-top: 8px; color: var(--color-ink); font-size: 12px; font-weight: 650; }
.eval-kpi > small { display: block; margin-top: 2px; color: var(--color-subtle-ink); font-size: 10px; }
.eval-kpi.primary { background: #e6f3f0; }.eval-kpi.primary strong { color: var(--color-primary-dark); font-size: 34px; }
.eval-kpi.accent strong { color: #c2410c; }

.eval-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 14px; }
.eval-card { min-width: 0; padding: 16px 18px 15px; border: 1px solid var(--color-border-soft); border-radius: 8px; background: var(--color-surface); }
.eval-card.wide { grid-column: 1 / -1; }
.eval-card > header { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 14px; }
.eval-card > header > span { display: grid; place-items: center; flex: 0 0 23px; height: 23px; border-radius: 50%; background: var(--color-muted); color: var(--color-primary); font-family: var(--font-mono); font-size: 9px; font-weight: 700; }
.eval-card > header > div:first-of-type { flex: 1; }
.eval-card h3 { margin: 2px 0 3px; font-size: 14px; letter-spacing: -.01em; }
.eval-card header p { margin: 0; color: var(--color-subtle-ink); font-size: 10px; }
.eval-takeaway { margin: 13px 0 0; padding-top: 11px; border-top: 1px solid var(--color-border-soft); color: var(--color-muted-ink); font-size: 11px; line-height: 1.55; }
.eval-takeaway b { color: var(--color-ink); font-family: var(--font-mono); }
.eval-toggle { flex: 0 0 180px; }.eval-toggle button { min-height: 32px; font-size: 11px; }

.eval-bars { display: grid; gap: 3px; }
.eval-bar { display: grid; grid-template-columns: 168px 1fr 58px; align-items: center; gap: 10px; min-height: 26px; color: var(--color-muted-ink); font-size: 11px; }
.eval-track { position: relative; height: 10px; border-radius: 2px; background: var(--color-muted); }
.eval-track i { display: block; height: 100%; border-radius: 2px; background: #4ca99e; }
.eval-track em { position: absolute; top: -3px; height: 16px; border-left: 1px solid #64748b; border-right: 1px solid #64748b; }
.eval-track em::after { content: ""; position: absolute; top: 7px; left: 0; right: 0; border-top: 1px solid #64748b; }
.eval-bar b { text-align: right; color: var(--color-ink); font-family: var(--font-mono); font-size: 11px; }
.eval-bar b small { display: block; color: var(--color-subtle-ink); font-size: 8px; font-weight: 400; }
.eval-bar.observed, .eval-bar.observed b { color: #c2410c; font-weight: 700; }.eval-bar.observed .eval-track i { background: var(--color-accent); }
.eval-bar.observed-light .eval-track i { background: #fdba74; }
.eval-bar.random .eval-track i { background: #94a3b8; }
.eval-bar.hybrid { color: var(--color-ink); font-weight: 650; }.eval-bar.hybrid .eval-track i { background: repeating-linear-gradient(135deg, var(--color-primary-dark) 0 5px, #16766f 5px 8px); }
.eval-bar.model .eval-track i { background: var(--color-primary-dark); }

.eval-range { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; }
.eval-range-group h4, .eval-stack-group h4 { margin: 0 0 6px; font-size: 11px; color: var(--color-ink); }
.eval-range-group h4 small { margin-left: 6px; color: var(--color-subtle-ink); font-weight: 400; }
.eval-range-row { display: grid; grid-template-columns: 82px 1fr 40px; align-items: center; gap: 10px; min-height: 30px; font-size: 11px; color: var(--color-muted-ink); }
.eval-range-row > span:first-child small { display: block; color: var(--color-subtle-ink); font-size: 9px; }
.eval-range-track { position: relative; height: 22px; border-bottom: 1px solid var(--color-border-soft); background: linear-gradient(90deg, transparent calc(33.33% - .5px), var(--color-border-soft) calc(33.33% - .5px) 33.33%, transparent 33.33% calc(66.66% - .5px), var(--color-border-soft) calc(66.66% - .5px) 66.66%, transparent 66.66%); }
.eval-range-track i { position: absolute; top: 50%; }
.eval-range-track .band { height: 10px; margin-top: -5px; border-radius: 2px; background: #d7ebe7; border: 1px solid #9acfc6; }
.eval-range-track .mean { width: 2px; height: 16px; margin: -8px 0 0 -1px; background: var(--color-primary-dark); }
.eval-range-track .obs { width: 11px; height: 11px; margin: -5.5px 0 0 -5.5px; border: 2px solid #fff; border-radius: 50%; background: var(--color-accent); box-shadow: 0 0 0 1px var(--color-accent); }
.eval-range-row b { text-align: right; color: var(--color-ink); font-family: var(--font-mono); font-size: 12px; }
.eval-range-row b small { font-size: 8px; font-weight: 400; }
.eval-range-row b.below, .eval-legend b.below { color: #c2410c; }
.eval-axis { display: flex; justify-content: space-between; margin: 3px 50px 0 92px; color: var(--color-subtle-ink); font-family: var(--font-mono); font-size: 8px; }
.eval-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 12px; color: var(--color-subtle-ink); font-size: 10px; }
.eval-legend span { display: flex; align-items: center; gap: 5px; }
.eval-legend i { display: inline-block; width: 14px; height: 9px; border-radius: 2px; }
.eval-legend i.obs { width: 9px; border-radius: 50%; background: var(--color-accent); }.eval-legend i.band { background: #d7ebe7; border: 1px solid #9acfc6; }.eval-legend i.mean { width: 2px; height: 12px; background: var(--color-primary-dark); }
.eval-legend i.robust { background: var(--color-primary-dark); }.eval-legend i.conditional { background: #9acfc6; }
.eval-legend b { font-family: var(--font-mono); }

.eval-columns { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.eval-column { display: grid; justify-items: center; text-align: center; color: var(--color-muted-ink); font-size: 10px; }
.eval-column-plot { position: relative; width: 100%; max-width: 64px; height: 130px; border-bottom: 1px solid var(--color-border); }
.eval-column-plot i { position: absolute; bottom: 0; left: 0; right: 0; border-radius: 2px 2px 0 0; }
.eval-column-plot .c800 { background: #d7ebe7; }.eval-column-plot .c400 { left: 14%; right: 14%; background: var(--color-accent); }
.eval-column b { margin-top: 7px; color: var(--color-ink); font-family: var(--font-mono); font-size: 13px; }
.eval-column span { margin-top: 1px; font-weight: 650; }.eval-column small { color: var(--color-subtle-ink); font-size: 9px; }

.eval-stack { display: grid; gap: 10px; }
.eval-stack-row { display: grid; grid-template-columns: 104px 1fr 92px; align-items: center; gap: 10px; min-height: 22px; color: var(--color-muted-ink); font-size: 11px; }
.eval-stack-row.vinted span:first-child { color: #c2410c; font-weight: 650; }
.eval-stack-track { display: flex; height: 10px; border-radius: 2px; background: var(--color-muted); overflow: hidden; }
.eval-stack-track .robust { background: var(--color-primary-dark); }.eval-stack-track .conditional { background: #9acfc6; }
.eval-stack-row b { text-align: right; color: var(--color-ink); font-family: var(--font-mono); font-size: 11px; }
.eval-stack-row b small { margin-left: 3px; color: var(--color-subtle-ink); font-weight: 400; font-size: 9px; }

.eval-implications { margin-top: 14px; padding: 16px 18px; border-radius: 8px; background: var(--color-primary-dark); color: #fff; }
.eval-implications h3 { margin: 0 0 10px; color: #99d6cd; font-family: var(--font-mono); font-size: 10px; letter-spacing: .09em; text-transform: uppercase; }
.eval-implications ol { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin: 0; padding: 0; list-style: none; counter-reset: imp; }
.eval-implications li { counter-increment: imp; padding-left: 26px; position: relative; font-size: 11px; line-height: 1.5; }
.eval-implications li::before { content: counter(imp); position: absolute; left: 0; top: 0; display: grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: rgba(255, 255, 255, .14); font-family: var(--font-mono); font-size: 9px; }
.eval-implications b { display: block; font-size: 13px; }.eval-implications span { color: rgba(255, 255, 255, .78); }

.eval-source { margin: 12px 0 0; color: var(--color-subtle-ink); font-size: 9px; }

@media (max-width: 860px) {
  .analysis-dialog { width: calc(100vw - 16px); max-height: calc(100dvh - 16px); }
  .analysis-header, .analysis-body { padding-left: 16px; padding-right: 16px; }
  .eval-kpis { grid-template-columns: 1fr 1fr; }
  .eval-grid, .eval-range, .eval-implications ol { grid-template-columns: 1fr; }
  .eval-card > header { flex-wrap: wrap; }.eval-toggle { flex-basis: 100%; }
  .eval-bar { grid-template-columns: 112px 1fr 52px; }
  .analysis-lede { display: none; }
  .analysis-header h2 { font-size: 22px; }
}

/* ---- Full-analysis tabs --------------------------------------------------------- */
.analysis-tabs { display: grid; grid-template-columns: repeat(4, 1fr); padding: 0 26px; border-bottom: 1px solid var(--color-border); background: var(--color-surface); }
.analysis-tabs button { min-height: 52px; padding: 8px 12px 9px; border: 0; border-bottom: 3px solid transparent; background: transparent; color: var(--color-muted-ink); text-align: left; transition: color var(--transition-fast), border-color var(--transition-fast), background var(--transition-fast); }
.analysis-tabs button:hover { background: var(--color-muted); color: var(--color-ink); }
.analysis-tabs button.active { border-bottom-color: var(--color-primary-dark); color: var(--color-primary-dark); }
.analysis-tabs b, .analysis-tabs small { display: block; }
.analysis-tabs b { font-size: 13px; }.analysis-tabs small { margin-top: 1px; color: var(--color-subtle-ink); font-size: 10px; font-weight: 400; }
.analysis-header { border-bottom: 0; padding-bottom: 12px; }

.curve-host { min-height: 240px; }
.curve-svg { display: block; width: 100%; height: auto; overflow: visible; }
.curve-svg .grid { stroke: var(--color-border-soft); }
.curve-svg .tick { fill: var(--color-subtle-ink); font: 10px var(--font-mono); }
.curve-svg .tick.strong { fill: #c2410c; font-weight: 700; }
.curve-svg .end { text-anchor: end; }.curve-svg .mid { text-anchor: middle; }
.curve-svg .band { fill: #e2e8f0; opacity: .8; }
.curve-svg .ln { fill: none; stroke-width: 2.2; stroke-linejoin: round; }
.curve-svg .ln.random { stroke: #94a3b8; stroke-dasharray: 4 3; stroke-width: 1.6; }
.curve-svg .ln.greedy { stroke: var(--color-primary-dark); }
.curve-svg .ln.pmedian { stroke: #4ca99e; }
.curve-svg .ln.kmeans { stroke: #9acfc6; }
.curve-svg .match { stroke: var(--color-accent); stroke-width: 1.4; stroke-dasharray: 3 3; }
.curve-svg .match-dot { fill: #fff; stroke: var(--color-primary-dark); stroke-width: 2; }
.curve-svg .obs { fill: var(--color-accent); stroke: #fff; stroke-width: 2; }
.curve-svg .lab { fill: var(--color-ink); font: 600 11px var(--font-body); }
.curve-svg .obs-lab { fill: #c2410c; }
.eval-legend i.l-greedy, .eval-legend i.l-pmedian, .eval-legend i.l-kmeans { height: 3px; }
.eval-legend i.l-greedy { background: var(--color-primary-dark); }.eval-legend i.l-pmedian { background: #4ca99e; }.eval-legend i.l-kmeans { background: #9acfc6; }
.eval-card .eval-legend i.band { background: #e2e8f0; border-color: #cbd5e1; }
#curveHost + .eval-legend i.obs { width: 9px; height: 9px; }
.eval-sub { margin: 12px 0 4px; color: var(--color-subtle-ink); font-family: var(--font-mono); font-size: 9px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.eval-sub:first-of-type { margin-top: 0; }

.eval-defs { display: grid; gap: 10px; margin: 0; }
.eval-defs div { padding-left: 10px; border-left: 2px solid var(--color-border-soft); }
.eval-defs dt { font-size: 12px; font-weight: 700; }.eval-defs dd { margin: 2px 0 0; color: var(--color-muted-ink); font-size: 11px; line-height: 1.5; }

.cost-row { display: grid; grid-template-columns: 124px 1fr 70px; align-items: center; gap: 10px; min-height: 26px; color: var(--color-muted-ink); font-size: 11px; }
.cost-row span:first-child small { display: block; color: var(--color-subtle-ink); font-size: 9px; }
.cost-row.vinted span:first-child { color: #c2410c; font-weight: 650; }
.cost-track { position: relative; height: 10px; border-radius: 2px; background: var(--color-muted); }
.cost-track i { display: block; height: 100%; border-radius: 2px; }
.cost-track i.over { background: #fdba74; }.cost-row.vinted .cost-track i.over { background: var(--color-accent); }
.cost-track i.under { background: var(--color-primary-dark); }
.cost-track::after { content: ""; position: absolute; top: -4px; bottom: -4px; left: var(--ref); border-left: 2px solid var(--color-ink); }
.cost-row b { text-align: right; color: var(--color-ink); font-family: var(--font-mono); font-size: 11px; }
.cost-row b small { display: block; color: var(--color-subtle-ink); font-size: 8px; font-weight: 400; }
.eval-legend i.ref { width: 2px; height: 12px; background: var(--color-ink); }.eval-legend i.over { background: #fdba74; }.eval-legend i.under { background: var(--color-primary-dark); }

.eval-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.eval-table th { padding: 0 0 7px; border-bottom: 1px solid var(--color-border); color: var(--color-subtle-ink); font-size: 10px; font-weight: 600; text-align: right; }
.eval-table th:first-child, .eval-table td:first-child { text-align: left; }
.eval-table td { padding: 8px 0; border-bottom: 1px solid var(--color-border-soft); color: var(--color-ink); font-family: var(--font-mono); text-align: right; white-space: nowrap; }
.eval-table td:first-child { font-family: var(--font-body); }
.eval-table tr:first-child td:first-child { color: #c2410c; font-weight: 650; }

.eval-assume { display: grid; gap: 0; margin: 0; }
.eval-assume div { display: grid; grid-template-columns: 136px 1fr; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--color-border-soft); font-size: 11px; }
.eval-assume dt { color: var(--color-muted-ink); }.eval-assume dd { margin: 0; }
.eval-assume dd b { font-family: var(--font-mono); font-size: 11px; }.eval-assume dd small { display: block; color: var(--color-subtle-ink); font-size: 9px; }

.method-flow { display: grid; grid-template-columns: repeat(5, 1fr); gap: 0; padding: 0; overflow: hidden; }
.flow-step { position: relative; padding: 14px 16px 14px; border-right: 1px solid var(--color-border-soft); }
.flow-step:last-child { border-right: 0; background: #e6f3f0; }
.flow-step span { display: block; color: var(--color-primary); font-family: var(--font-mono); font-size: 9px; font-weight: 700; letter-spacing: .04em; }
.flow-step strong { display: block; margin: 7px 0 4px; font-family: var(--font-mono); font-size: 22px; letter-spacing: -.04em; }
.flow-step small { display: block; color: var(--color-muted-ink); font-size: 10px; line-height: 1.45; }
.check-grid { display: grid; grid-template-columns: 1fr; gap: 0; }
.check-grid div { display: grid; grid-template-columns: 74px 1fr; column-gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--color-border-soft); }
.check-grid strong { grid-row: span 2; align-self: center; color: var(--color-primary-dark); font-family: var(--font-mono); font-size: 16px; }
.check-grid span { font-size: 12px; font-weight: 650; }.check-grid small { color: var(--color-subtle-ink); font-size: 10px; }
.limit-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px 20px; margin: 0; padding: 0; list-style: none; }
.limit-list li { padding-left: 10px; border-left: 2px solid #fdba74; font-size: 11px; line-height: 1.5; }
.limit-list b { display: block; font-size: 12px; }.limit-list span { color: var(--color-muted-ink); }

@media (max-width: 860px) {
  .analysis-tabs { padding: 0 8px; overflow-x: auto; grid-template-columns: repeat(4, minmax(96px, 1fr)); }
  .analysis-tabs small { display: none; }
  .method-flow { grid-template-columns: 1fr 1fr; }.flow-step { border-bottom: 1px solid var(--color-border-soft); }
  .limit-list { grid-template-columns: 1fr; }
  .cost-row { grid-template-columns: 96px 1fr 62px; }
}

@media (max-width: 1180px) {
  body { overflow: auto; }
  .workspace { height: auto; min-height: 100vh; grid-template-columns: 300px minmax(468px, 1fr); grid-template-rows: minmax(620px, 100vh) auto; }
  .results-panel { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(4, 1fr); gap: 0 24px; overflow: visible; }
  .results-header { grid-column: 1 / -1; }.primary-result, .supporting-metrics, .result-section { border-bottom: 0; }
  .reading-note, .results-footer, .analysis-button { grid-column: span 2; }.results-footer { align-self: end; }
}
@media (max-width: 780px) {
  .workspace { display: flex; flex-direction: column; }
  .research-panel, .results-panel { overflow: visible; }
  .research-panel { padding: 22px 20px; }
  .study-header h1 { max-width: none; font-size: 30px; }
  .study-facts { max-width: 320px; }
  .map-stage { min-height: 620px; }
  #map { height: 620px; }
  .map-heading { top: 12px; left: 12px; right: 12px; }.map-heading > div { max-width: calc(100% - 98px); padding: 10px 11px; }.map-heading h2 { font-size: 15px; }.map-heading p:last-child { font-size: 10px; }.site-status { font-size: 9px; }
  .map-toolbar { top: auto; right: 12px; bottom: 150px; }.layer-menu-button { width: 44px; padding: 0; }.layer-menu-button span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }.layer-panel { position: fixed; top: 12px; right: 12px; bottom: auto; width: min(340px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); }
  .zoom-controls { right: 12px; bottom: 12px; }.legend { left: 12px; right: 62px; bottom: 12px; flex-wrap: wrap; gap: 6px 9px; }
  .results-panel { display: block; padding: 24px 20px; }
}
@media (max-width: 420px) {
  .threshold-control { gap: 4px; }.threshold-control button { min-height: 56px; }
  .map-heading .map-kicker, .site-status { display: none; }.map-heading > div { max-width: 100%; }
  .legend strong { width: 100%; }.legend { font-size: 9px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
