/* App shell, components and views. Tokens live in tokens.css. Mobile-first breakpoints: 700 px (sheet/bottom nav), 1100 px (docked panels). */

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 400 var(--fs-sm)/1.5 var(--f-body); font-feature-settings: "cv11", "ss03";
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  display: flex; flex-direction: column; height: 100dvh; overflow: hidden;
}
h1, h2, h3, h4, p, ul, ol, dl, dd, figure { margin: 0; padding: 0; }
ul, ol { list-style: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
.num { font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: var(--r-sm); }
.skip-link { position: absolute; left: var(--s-2); top: -48px; z-index: 100; background: var(--fg); color: var(--bg); padding: var(--s-2) var(--s-3); border-radius: var(--r); text-decoration: none; }
.skip-link:focus { top: var(--s-2); }
.brand-mark { display: inline-block; width: 24px; height: 23px; background: currentColor; -webkit-mask: url("../assets/symbole.svg") center / contain no-repeat; mask: url("../assets/symbole.svg") center / contain no-repeat; }
.icon { flex: none; }

/* ---------- buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2); border: 1px solid transparent; border-radius: var(--r); font-weight: 550; line-height: 1; white-space: nowrap; transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), transform var(--dur) var(--ease); }
.btn-md { height: 36px; padding: 0 var(--s-4); font-size: var(--fs-sm); }
.btn-sm { height: 28px; padding: 0 var(--s-3); font-size: var(--fs-xs); }
.btn-primary { background: var(--fg); color: var(--bg); }
.btn-primary:hover:not(:disabled) { background: var(--fg-2); }
.btn-secondary { background: var(--surface); border-color: var(--line-2); color: var(--fg); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-3); }
.btn-ghost { background: transparent; color: var(--fg-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-3); color: var(--fg); }
.btn-danger { background: var(--err-soft); color: var(--err); border-color: var(--err); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.is-loading { cursor: progress; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; padding: 0; background: transparent; border: 1px solid transparent; border-radius: var(--r); color: var(--fg-2); transition: background var(--dur) var(--ease); }
.icon-btn:hover { background: var(--surface-3); color: var(--fg); }
.icon-btn[aria-pressed="true"] { background: var(--surface-3); color: var(--fg); border-color: var(--line-2); }

/* ---------- feedback */
.spinner { display: inline-block; border: 2px solid var(--line-2); border-top-color: var(--fg); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { display: block; border-radius: var(--r-sm); background: linear-gradient(90deg, var(--surface-3) 25%, var(--line) 50%, var(--surface-3) 75%); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.skeleton-stack { display: grid; gap: var(--s-2); }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } .skeleton { animation: none; } * { scroll-behavior: auto !important; transition-duration: 0ms !important; } }
.state { display: grid; justify-items: start; gap: var(--s-2); padding: var(--s-4); border: 1px dashed var(--line-2); border-radius: var(--r-lg); background: var(--surface-2); }
.state-icon { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: var(--r); background: var(--surface-3); color: var(--fg-2); }
.state-error { border-style: solid; border-color: var(--err); background: var(--err-soft); }
.state-error .state-icon { background: transparent; color: var(--err); }
.state-title { font-weight: 600; font-size: var(--fs-md); }
.state-text { color: var(--fg-2); max-width: 46ch; }
.toasts { position: fixed; right: var(--s-4); bottom: var(--s-4); z-index: var(--z-toast); display: grid; gap: var(--s-2); max-width: min(420px, calc(100vw - 32px)); }
.toast { display: flex; gap: var(--s-3); align-items: center; padding: var(--s-3) var(--s-3) var(--s-3) var(--s-4); background: var(--fg); color: var(--bg); border-radius: var(--r-lg); box-shadow: var(--shadow-3); }
.toast .icon-btn { color: inherit; margin-left: auto; }
.toast .icon-btn:hover { background: rgba(127, 127, 127, 0.3); }
.toast-err { background: var(--err); color: var(--bg); }
.badge { display: inline-flex; align-items: center; gap: var(--s-1); height: 20px; padding: 0 var(--s-2); border-radius: var(--r-pill); font-size: var(--fs-2xs); font-weight: 600; letter-spacing: 0.02em; background: var(--surface-3); color: var(--fg-2); white-space: nowrap; }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-err { background: var(--err-soft); color: var(--err); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-accent { background: var(--accent-soft); color: var(--accent); }
.kbd { font: 500 var(--fs-2xs)/1 var(--f-mono); padding: 3px 5px; border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: var(--r-sm); background: var(--surface); color: var(--fg-2); }

/* ---------- fields */
.field { display: grid; gap: var(--s-1); }
.field-label, .slider-label { font-size: var(--fs-xs); font-weight: 550; color: var(--fg-2); }
.select-wrap { position: relative; }
.select-wrap .icon { position: absolute; right: var(--s-2); top: 50%; transform: translateY(-50%); pointer-events: none; color: var(--fg-3); }
.select { width: 100%; height: 34px; padding: 0 var(--s-8) 0 var(--s-3); appearance: none; background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r); }
.select:hover { border-color: var(--fg-3); }
.slider-field { display: grid; gap: var(--s-1); }
.slider-head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s-2); }
.slider-value { font-size: var(--fs-xs); color: var(--fg); }
.slider-desc { font-size: var(--fs-xs); color: var(--fg-3); }
.slider { --slider-accent: var(--fg); width: 100%; height: 20px; margin: 0; appearance: none; background: transparent; cursor: pointer; }
.slider::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: linear-gradient(90deg, var(--slider-accent) var(--fill, 0%), var(--line-2) var(--fill, 0%)); }
.slider::-moz-range-track { height: 4px; border-radius: 2px; background: var(--line-2); }
.slider::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--slider-accent); }
.slider::-webkit-slider-thumb { appearance: none; width: 16px; height: 16px; margin-top: -6px; border-radius: 50%; background: var(--surface); border: 2px solid var(--slider-accent); box-shadow: var(--shadow-1); }
.slider::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 2px solid var(--slider-accent); }
.segmented { display: inline-grid; grid-auto-flow: column; grid-auto-columns: 1fr; padding: 2px; gap: 2px; border: 1px solid var(--line-2); border-radius: var(--r); background: var(--surface-3); }
.seg { border: 0; background: transparent; padding: 0 var(--s-3); height: 28px; border-radius: var(--r-sm); font-size: var(--fs-xs); font-weight: 550; color: var(--fg-2); white-space: nowrap; }
.seg[aria-checked="true"] { background: var(--surface); color: var(--fg); box-shadow: var(--shadow-1); }
.tabs { display: flex; gap: var(--s-1); border-bottom: 1px solid var(--line); }
.tab { border: 0; background: transparent; padding: var(--s-2) var(--s-3); margin-bottom: -1px; border-bottom: 2px solid transparent; font-weight: 550; color: var(--fg-2); }
.tab[aria-selected="true"] { color: var(--fg); border-bottom-color: var(--accent); }
.tab:hover { color: var(--fg); }

/* ---------- stat, section, legend */
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-2); }
.stat { padding: var(--s-3); border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); display: grid; gap: var(--s-1); align-content: start; }
.stat-label { font-size: var(--fs-xs); color: var(--fg-2); }
.stat-value { display: flex; align-items: baseline; gap: var(--s-1); font-size: var(--fs-xl); font-weight: 600; line-height: 1.2; }
.stat-value .num { font-weight: 500; }
.stat-unit { font-size: var(--fs-xs); font-weight: 400; color: var(--fg-2); }
.stat-hint { font-size: var(--fs-2xs); color: var(--fg-3); }
.stat-hot .stat-value { color: var(--accent); }
.section { padding: var(--s-4); border-bottom: 1px solid var(--line); display: grid; gap: var(--s-3); }
.section-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-2); }
.section-title { font: 600 var(--fs-2xs)/1.4 var(--f-body); letter-spacing: 0.08em; text-transform: uppercase; color: var(--fg-2); }
.section-body { display: grid; gap: var(--s-3); }
.section-toggle { display: inline-grid; place-items: center; min-width: 24px; min-height: 24px; border: 0; background: transparent; padding: 2px; color: var(--fg-3); border-radius: var(--r-sm); }
summary { min-height: 24px; }
.section-toggle[aria-expanded="false"] .icon { transform: rotate(-90deg); }
.legend { display: grid; gap: var(--s-2); padding: var(--s-3); border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); }
.legend-title { font-weight: 600; font-size: var(--fs-xs); }
.legend-modes { display: grid; width: 100%; }
.legend-modes .seg { padding: 0 var(--s-2); }
.legend-mean { margin: 0; font-size: var(--fs-xs); color: var(--fg-2); }
.ramp { height: 10px; border-radius: var(--r-sm); border: 1px solid var(--line-2); }
.ramp-ends { display: flex; justify-content: space-between; font-size: var(--fs-2xs); color: var(--fg-2); margin-top: var(--s-1); }
.ramp-unit { color: var(--fg-3); }
.legend-cats { display: grid; gap: var(--s-1); }
.legend-cats li { display: flex; align-items: center; gap: var(--s-2); font-size: var(--fs-xs); color: var(--fg-2); }
.swatch { width: 12px; height: 12px; border-radius: 3px; border: 1px solid var(--line-2); flex: none; }
.legend-meta { display: grid; grid-template-columns: auto 1fr; gap: 2px var(--s-3); font-size: var(--fs-2xs); color: var(--fg-3); padding-top: var(--s-2); border-top: 1px solid var(--line); }
.legend-details summary { cursor: pointer; font-size: var(--fs-2xs); color: var(--fg-2); padding-top: var(--s-1); }
.legend-details summary:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.legend-details .legend-meta { margin-top: var(--s-2); }
.model-note, .stat-model { color: var(--fg-3); }
.legend-meta dt { font-weight: 600; }
.legend-meta dd { color: var(--fg-2); }

/* ---------- modal, table */
.modal-backdrop { position: fixed; inset: 0; z-index: var(--z-modal); display: grid; place-items: center; padding: var(--s-4); background: var(--scrim); }
.modal { width: min(520px, 100%); max-height: calc(100dvh - 32px); display: grid; grid-template-rows: auto 1fr auto; background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-3); overflow: hidden; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: var(--s-3) var(--s-3) var(--s-3) var(--s-4); border-bottom: 1px solid var(--line); }
.modal-title { font: 600 var(--fs-lg)/1.3 var(--f-display); }
.modal-body { padding: var(--s-4); overflow: auto; }
.modal-actions { display: flex; justify-content: flex-end; gap: var(--s-2); padding: var(--s-3) var(--s-4); border-top: 1px solid var(--line); background: var(--surface-2); }
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-xs); }
.table th { text-align: left; font-weight: 600; font-size: var(--fs-2xs); letter-spacing: 0.04em; text-transform: uppercase; color: var(--fg-3); padding: var(--s-2); border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); }
.table td { padding: var(--s-2); border-bottom: 1px solid var(--line); vertical-align: middle; }
.table .align-right { text-align: right; }
.table .align-center { text-align: center; }
.table .row[tabindex] { cursor: pointer; }
.table .row.is-hover, .table .row:hover { background: var(--surface-3); }
.table .row.is-selected { background: var(--accent-soft); box-shadow: inset 2px 0 0 var(--accent); }

/* ---------- header and navigation */
.app-header { flex: none; height: var(--header-h); display: flex; align-items: center; gap: var(--s-4); padding: 0 var(--s-3); background: var(--surface); border-bottom: 1px solid var(--line); z-index: var(--z-header); }
.brand { display: inline-flex; align-items: center; gap: var(--s-2); text-decoration: none; font: 600 var(--fs-lg)/1 var(--f-display); letter-spacing: -0.01em; }
.brand-sub { font: 500 var(--fs-xs)/1 var(--f-body); color: var(--fg-3); padding-left: var(--s-2); border-left: 1px solid var(--line-2); }
.nav { display: flex; gap: 2px; margin-left: var(--s-2); }
.nav-item { position: relative; display: inline-flex; align-items: center; gap: var(--s-2); height: 32px; padding: 0 var(--s-3); border-radius: var(--r); text-decoration: none; color: var(--fg-2); font-weight: 550; white-space: nowrap; }
.nav-item:hover { background: var(--surface-3); color: var(--fg); }
.nav-item[aria-current="page"] { color: var(--fg); font-weight: 650; }
/* numbered steps: the active one is the only accent of the header */
.nav-step { display: inline-grid; place-items: center; flex: none; width: 20px; height: 20px; border-radius: 50%; border: 1px solid var(--line-2); font: 600 var(--fs-2xs)/1 var(--f-body); font-variant-numeric: tabular-nums; color: var(--fg-2); }
.nav-item[aria-current="page"] .nav-step { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.nav-item .icon { display: none; }
.header-spacer { flex: 1; }
.header-tools { display: flex; align-items: center; gap: var(--s-2); }
.commune-select { width: 168px; }
.user-chip { display: inline-flex; align-items: center; gap: var(--s-2); max-width: 200px; font-size: var(--fs-xs); color: var(--fg-2); }
.user-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- workspace: docked panels (>= 1100 px) */
.workspace { position: relative; flex: 1; min-height: 0; overflow: clip; display: grid; grid-template-columns: var(--left-w) minmax(0, 1fr) 0; transition: grid-template-columns var(--dur) var(--ease); }
.workspace.left-collapsed { grid-template-columns: 0 minmax(0, 1fr) 0; }
.workspace.right-open { grid-template-columns: var(--left-w) minmax(0, 1fr) var(--right-w); }
.workspace.left-collapsed.right-open { grid-template-columns: 0 minmax(0, 1fr) var(--right-w); }
.panel { position: relative; min-width: 0; min-height: 0; overflow: hidden; background: var(--surface); z-index: var(--z-panel); display: flex; flex-direction: column; }
.panel-left { border-right: 1px solid var(--line); }
.panel-right { border-left: 1px solid var(--line); }
.workspace.left-collapsed .panel-left, .workspace:not(.right-open) .panel-right { visibility: hidden; }
.panel-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.panel-left .panel-scroll { width: var(--left-w); }
.step-foot { width: var(--left-w); display: flex; justify-content: space-between; align-items: center; gap: var(--s-2); padding: var(--s-3) var(--s-4); border-top: 1px solid var(--line); background: var(--surface); }
.step-foot:empty { display: none; }
.step-foot .btn { text-decoration: none; }
.step-foot .step-next { margin-left: auto; }
.panel-right .panel-scroll { width: var(--right-w); }
.sheet-handle { display: none; }
.map-wrap { position: relative; min-width: 0; background: var(--map-bg); }
#map { position: absolute; inset: 0; }
.map-overlay { position: absolute; left: var(--s-3); right: var(--s-3); top: var(--s-3); bottom: 48px; pointer-events: none; display: flex; flex-direction: column; justify-content: flex-end; align-items: flex-start; gap: var(--s-2); }
.map-overlay > * { pointer-events: auto; }
.map-overlay .legend { width: max-content; min-width: 240px; max-width: min(320px, 100%); box-shadow: var(--shadow-2); }
.map-tools { position: absolute; top: var(--s-3); left: var(--s-3); display: flex; gap: var(--s-2); z-index: 2; }
.map-tools .icon-btn { background: var(--surface); border-color: var(--line-2); box-shadow: var(--shadow-1); }
.map-tools-right { left: auto; right: var(--s-3); }
.map-view-tools { display: flex; gap: var(--s-2); }
.map-view-tools:empty { display: none; }
.map-tools .segmented { background: var(--surface); box-shadow: var(--shadow-1); }
.maplibregl-ctrl-attrib { font-size: 10px !important; }
.maplibregl-ctrl-group { border-radius: var(--r) !important; box-shadow: var(--shadow-1) !important; }

/* ---------- views: shared panel header */
.view-head { padding: var(--s-5) var(--s-4) var(--s-4); border-bottom: 1px solid var(--line); display: grid; gap: var(--s-1); }
.view-kicker { font: 600 var(--fs-2xs)/1.2 var(--f-body); letter-spacing: 0.08em; text-transform: uppercase; color: var(--fg-3); }
.view-title { font: 600 var(--fs-xl)/1.2 var(--f-display); letter-spacing: -0.01em; }
.view-lead { color: var(--fg-2); font-size: var(--fs-sm); }
.stack { display: grid; gap: var(--s-3); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); }
.muted { color: var(--fg-2); }
.small { font-size: var(--fs-xs); }
.link-btn { border: 0; background: none; padding: 0; color: var(--fg-2); text-decoration: underline; text-underline-offset: 3px; font-size: var(--fs-xs); }
.link-btn:hover { color: var(--fg); }

/* overview */
.steps { display: grid; gap: 2px; }
.step { display: grid; grid-template-columns: 28px 1fr auto; gap: var(--s-3); align-items: center; padding: var(--s-2) var(--s-3); margin-inline: calc(-1 * var(--s-3)); width: calc(100% + 2 * var(--s-3)); border-radius: var(--r); text-decoration: none; color: inherit; }
.step-text { display: grid; gap: 2px; }
.step:hover { background: var(--surface-3); }
.step-n { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--line-2); font: 600 var(--fs-xs)/1 var(--f-body); font-variant-numeric: tabular-nums; color: var(--fg-2); }
.step-title { font-weight: 600; }
.step-desc { font-size: var(--fs-xs); color: var(--fg-2); }
.step .icon { color: var(--fg-3); }
.source-list { display: grid; gap: var(--s-2); }
.source-list li { font-size: var(--fs-xs); color: var(--fg-2); padding-left: var(--s-3); border-left: 2px solid var(--line-2); }
.source-list b { color: var(--fg); font-weight: 600; }
.prose { color: var(--fg-2); font-size: var(--fs-sm); max-width: 62ch; }
.prose + .prose { margin-top: var(--s-2); }

/* observe */
.layer-group { display: grid; gap: 2px; }
.layer-group-title { font: 600 var(--fs-2xs)/1.4 var(--f-body); letter-spacing: 0.08em; text-transform: uppercase; color: var(--fg-3); padding: var(--s-1) 0; }
.layer-item { display: grid; grid-template-columns: 16px 1fr; gap: var(--s-3); align-items: start; width: 100%; padding: var(--s-2) var(--s-3); text-align: left; border: 1px solid transparent; border-radius: var(--r); background: transparent; }
.layer-item:hover { background: var(--surface-3); }
.layer-item[aria-checked="true"] { background: var(--surface-3); border-color: var(--line-2); }
.radio-dot { width: 14px; height: 14px; margin-top: 3px; border-radius: 50%; border: 1.5px solid var(--fg-3); display: grid; place-items: center; }
.layer-item[aria-checked="true"] .radio-dot { border-color: var(--fg); }
.layer-item[aria-checked="true"] .radio-dot::after { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--fg); }
.layer-title { font-weight: 550; }
.layer-meta { font-size: var(--fs-2xs); color: var(--fg-3); }
.day-card { display: grid; gap: var(--s-3); }
.day-main { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-2); }
.day-date { font: 600 var(--fs-lg)/1.2 var(--f-display); }
.day-index { font-size: var(--fs-2xs); color: var(--fg-3); }
.weather { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-2); }
.weather > div { padding: var(--s-2); border-radius: var(--r); background: var(--surface-2); border: 1px solid var(--line); }
.weather dt { font-size: var(--fs-2xs); color: var(--fg-3); }
.weather dd { font-size: var(--fs-sm); color: var(--fg); }
.day-actions { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.hottest-label { flex-basis: 100%; }
.hint { font-size: var(--fs-2xs); color: var(--fg-3); display: flex; flex-wrap: wrap; gap: var(--s-1) var(--s-3); align-items: center; }
.cell-head { padding: var(--s-4); border-bottom: 1px solid var(--line); display: grid; gap: var(--s-2); }
.cell-title { font: 600 var(--fs-lg)/1.2 var(--f-display); }
.cell-badges { display: flex; flex-wrap: wrap; gap: var(--s-1); }
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart text { font: 500 10px var(--f-body); font-variant-numeric: tabular-nums; fill: var(--fg-3); }
.chart .axis { stroke: var(--line-2); stroke-width: 1; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .series { fill: none; stroke: var(--c-heat-day); stroke-width: 1.4; stroke-linejoin: round; }
.chart .marker { stroke: var(--fg); stroke-width: 1; stroke-dasharray: 3 2; }
.chart .dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.chart-readout { font-size: var(--fs-xs); color: var(--fg-2); min-height: 1.5em; font-variant-numeric: tabular-nums; }
.fields { display: grid; }
.field-row { display: grid; grid-template-columns: 1fr auto; gap: 0 var(--s-3); padding: var(--s-2) 0; border-bottom: 1px solid var(--line); }
.field-row:last-child { border-bottom: 0; }
.field-name { color: var(--fg-2); font-size: var(--fs-xs); }
.field-value { text-align: right; font-size: var(--fs-sm); }
.field-value small { color: var(--fg-3); font-family: var(--f-body); }
.field-source { grid-column: 1 / -1; font-size: var(--fs-2xs); color: var(--fg-3); }

/* prioritize */
.weight-item { display: grid; gap: var(--s-1); padding: var(--s-2) 0; }
.weight-item .share { font-size: var(--fs-2xs); color: var(--fg-3); }
.weight-info { font-size: var(--fs-2xs); color: var(--fg-3); }
.weight-info summary { cursor: pointer; color: var(--fg-2); width: max-content; }
.weight-info p { margin-top: var(--s-1); }
.dot { width: 8px; height: 8px; border-radius: 2px; flex: none; display: inline-block; }
.norm-bar { display: flex; height: 10px; border-radius: var(--r-sm); overflow: hidden; background: var(--surface-3); gap: 1px; }
.norm-bar i { display: block; height: 100%; }
.rank-key { display: flex; flex-wrap: wrap; gap: var(--s-1) var(--s-3); font-size: var(--fs-2xs); color: var(--fg-2); }
.rank-key span { display: inline-flex; align-items: center; gap: var(--s-1); }
.rank-n { font-weight: 600; color: var(--fg-2); }
.stack-bar { display: flex; height: 8px; border-radius: 2px; overflow: hidden; background: var(--surface-3); min-width: 80px; }
.stack-bar i { display: block; height: 100%; }
.score-cell { display: grid; gap: 3px; }
.score-line { display: flex; justify-content: space-between; align-items: center; gap: var(--s-2); }
.stable-mark { color: var(--accent); display: inline-flex; vertical-align: middle; }
.totals { display: grid; gap: var(--s-2); }
.check { display: flex; align-items: center; gap: var(--s-2); font-size: var(--fs-xs); color: var(--fg-2); cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; }

/* ---------- tablet (700-1099): panels overlay the map and collapse */
@media (max-width: 1099px) {
  .workspace, .workspace.left-collapsed, .workspace.right-open, .workspace.left-collapsed.right-open { grid-template-columns: minmax(0, 1fr); }
  .panel-left, .panel-right { position: absolute; top: 0; bottom: 0; width: min(var(--left-w), 92%); box-shadow: var(--shadow-3); transition: transform var(--dur) var(--ease), visibility var(--dur); }
  .panel-left { left: 0; }
  .panel-right { right: 0; width: min(var(--right-w), 92%); }
  .workspace.left-collapsed .panel-left { transform: translateX(-102%); }
  .workspace:not(.right-open) .panel-right { transform: translateX(102%); }
  .workspace.right-open .panel-right { z-index: calc(var(--z-panel) + 1); }
  .panel-left .panel-scroll, .panel-right .panel-scroll, .step-foot { width: auto; }
  /* --map-inset-left is set on .workspace by main.js (syncInsets): the width of the map hidden under the open left panel */
  .map-tools:not(.map-tools-right) { left: calc(var(--map-inset-left, 0px) + var(--s-3)); }
  .map-overlay { left: calc(var(--s-3) + var(--map-inset-left, 0px)); }
  .brand-sub { display: none; }
}
/* tablet header: numbered steps, only the current one named (other labels kept for screen readers, title as tooltip), narrower commune menu, no user name */
@media (min-width: 700px) and (max-width: 1099px) {
  .app-header { gap: var(--s-2); }
  .nav { margin-left: 0; min-width: 0; }
  .nav-item { padding: 0 var(--s-2); }
  .nav-item:not([aria-current="page"]) .nav-label { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .commune-select { width: 140px; }
  .user-chip span { display: none; }
}
/* narrow desktop: drop the secondary header text before the header overflows */
@media (min-width: 1100px) and (max-width: 1399px) {
  .brand-sub, .user-chip span { display: none; }
  .commune-select { width: 140px; }
}

/* ---------- mobile (< 700): bottom navigation and sliding sheets */
@media (max-width: 699px) {
  .app-header { gap: var(--s-2); padding: 0 var(--s-3); }
  .brand-name, .user-chip span, .nav-item .nav-step { display: none; }
  .brand-sub { display: inline; padding-left: 0; border-left: 0; font-size: var(--fs-sm); color: var(--fg); }
  .commune-select { width: 130px; }
  .nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: var(--z-sheet); height: var(--nav-h); margin: 0; padding: 0 var(--s-1) env(safe-area-inset-bottom); gap: 0; justify-content: space-around; background: var(--surface); border-top: 1px solid var(--line); box-sizing: content-box; }
  .nav-item { flex: 1; flex-direction: column; justify-content: center; gap: 2px; height: auto; padding: 0 2px; font-size: var(--fs-2xs); border-radius: 0; background: transparent !important; }
  .nav-item .icon { display: block; }
  .nav-item[aria-current="page"] { color: var(--accent); }
  .nav-item[aria-current="page"]::after { content: ""; position: absolute; top: 0; left: 25%; right: 25%; height: 2px; background: var(--accent); border-radius: 2px; }
  .workspace { padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); }
  .workspace, .workspace.left-collapsed, .workspace.right-open { transition: none; }
  .panel-left, .panel-right { left: 0; right: 0; width: auto; top: auto; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); height: min(78%, calc(100% - 56px)); border: 0; border-radius: var(--r-lg) var(--r-lg) 0 0; transition: transform 260ms var(--ease), height 260ms var(--ease); visibility: visible !important; }
  .panel-right { z-index: calc(var(--z-panel) + 2); height: min(62%, calc(100% - 56px)); }
  /* half: a shorter sheet rather than a pushed-down one, so its end (and the step buttons) stays reachable */
  .workspace[data-sheet="half"] .panel-left, .workspace:not([data-sheet]) .panel-left { height: calc(min(78%, 100% - 56px) * 0.62); }
  .workspace .panel-left { transform: translateY(0); }
  /* "peek" (left-collapsed) comes last: it wins over the remembered half/full level, restored on reopening */
  .workspace.left-collapsed .panel-left { transform: translateY(calc(100% - 52px)); }
  .workspace:not(.right-open) .panel-right { transform: translateY(110%); visibility: hidden !important; }
  .sheet-handle { display: flex; align-items: center; justify-content: center; flex: none; height: 28px; width: 100%; border: 0; background: transparent; touch-action: none; cursor: grab; }
  .sheet-handle::before { content: ""; width: 36px; height: 4px; border-radius: 2px; background: var(--line-2); }
  .map-tools .icon-btn { display: none; } /* the sheet handle replaces the panel toggle on mobile */
  .map-tools-right { flex-direction: column; align-items: flex-end; }
  /* the legend stays on the map, top left, reduced to its title and colours */
  .map-overlay { top: var(--s-3); bottom: auto; right: auto; max-width: calc(100% - 170px); justify-content: flex-start; }
  .map-overlay .legend { width: 184px; min-width: 0; padding: var(--s-2); gap: var(--s-1); }
  .map-overlay .legend-details, .map-overlay .legend-modes, .map-overlay .legend-mean { display: none; }
  .map-overlay .legend-cats { grid-template-columns: 1fr 1fr; gap: 2px var(--s-2); }
  .map-overlay .legend-cats li { font-size: var(--fs-2xs); }
  .step-foot { padding: var(--s-2) var(--s-4); }
  .view-head { padding: var(--s-2) var(--s-4) var(--s-3); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .toasts { bottom: calc(var(--nav-h) + var(--s-4)); right: var(--s-3); left: var(--s-3); max-width: none; }
  .maplibregl-ctrl-bottom-right { bottom: 56px; }
  /* touch targets of at least 44 px for disclosure summaries, section toggles and check boxes */
  summary { min-height: 44px; padding-block: 12px; }
  .section-toggle { min-width: 44px; min-height: 44px; margin: -10px -10px -10px 0; }
  .check { min-height: 44px; }
}
@media (min-width: 700px) { .sheet-handle { display: none; } }

/* MapLibre controls follow the theme */
.maplibregl-ctrl-group { background: var(--surface) !important; }
.maplibregl-ctrl-group button + button { border-top-color: var(--line) !important; }
html[data-theme="dark"] .maplibregl-ctrl-icon { filter: invert(1); }
.maplibregl-ctrl-scale { background: color-mix(in srgb, var(--surface) 80%, transparent) !important; color: var(--fg-2) !important; border-color: var(--fg-3) !important; font-variant-numeric: tabular-nums; }
.maplibregl-ctrl-attrib { background: color-mix(in srgb, var(--surface) 82%, transparent) !important; color: var(--fg-2) !important; }
.maplibregl-ctrl-attrib a { color: var(--fg-2) !important; }
.stable-mark svg { fill: currentColor; }

.cell-note { padding: 0 var(--s-4) var(--s-3); }

/* ---------- apps menu (header): the Horama demo apps of this server, each in its own window. Same block in every app. */
.apps-menu { position: relative; }
.apps-menu > summary { list-style: none; cursor: pointer; min-height: 0; padding: 0; }
.apps-menu > summary::-webkit-details-marker { display: none; }
.apps-menu[open] > summary { background: var(--surface-3); color: var(--fg); border-color: var(--line-2); }
.apps-list { position: absolute; right: 0; top: calc(100% + var(--s-2)); z-index: var(--z-modal); min-width: 260px; margin: 0; padding: var(--s-1); list-style: none; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-3); }
.apps-item { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-2) var(--s-3); border-radius: var(--r); text-decoration: none; color: var(--fg); }
.apps-item:hover { background: var(--surface-3); }
.apps-item[aria-current="page"] { background: var(--surface-2); }
.apps-item .icon { margin-left: auto; color: var(--fg-3); flex: none; }
.apps-text { display: grid; gap: 2px; }
.apps-name { font-weight: 550; font-size: var(--fs-sm); }
.apps-place { font-size: var(--fs-2xs); color: var(--fg-3); }
@media (max-width: 699px) { .apps-menu > summary { min-height: 0; padding: 0; } .apps-list { position: fixed; left: var(--s-3); right: var(--s-3); top: calc(var(--header-h) + var(--s-1)); } }
