/* glen-charts base stylesheet: the glen-web sidebar shell (map left,
 * full-height resizable panel right). An app re-themes it by overriding the
 * :root tokens (palette, --header-h) in its own stylesheet, loaded after this one. */

:root {
    --primary: #006837;
    --primary-strong: #004d29;
    --primary-wash: rgba(0, 104, 55, 0.08);
    --accent: #39b54a;
    --surface: #f5faf1;
    --backdrop: #e5f1e0;
    --chrome-bg: #fbfdf9;
    --card-bg: #ffffff;
    --text: #22201f;
    --text-2: #4f4a47;
    --text-3: #77706b;
    --line: rgba(30, 40, 30, 0.12);
    --line-strong: rgba(30, 40, 30, 0.22);
    --hover: rgba(0, 0, 0, 0.05);
    --shadow: rgba(0, 0, 0, 0.14);
    --focus: #004d29;
    --danger: #b3261e;

    /* chart roles */
    --series-protected: #1f7a3a;
    --series-other: #9aa59a;
    --series-state: #2b2b2b;
    --grid: rgba(0, 0, 0, 0.08);

    --overlay-bg: rgba(255, 255, 255, .94);   /* map legends and chips */
    --code-bg: #f3f4f2;
    --skeleton-a: #eef2ec;
    --skeleton-b: #f6f9f4;
    --mix-base: white;                         /* tints: color-mix(<colour> 10%, var(--mix-base)) */
    --on-primary: #fff;                        /* text on --primary and on series colours */
    --header-bg: var(--primary);
    --header-fg: #fff;
    --sidebar-width: 50vw;
    --header-h: 52px;
    font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    color: var(--text);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--backdrop); }
body { font-size: 14px; line-height: 1.4; }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ----- header ---------------------------------------------------------- */
#app-header {
    height: var(--header-h);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 16px;
    background: var(--header-bg);
    color: var(--header-fg);
}
.brand { display: flex; align-items: baseline; gap: 12px; min-width: 0; }
.brand h1 { font-size: 17px; margin: 0; font-weight: 650; letter-spacing: .2px; white-space: nowrap; }
.brand-sub { font-size: 13px; opacity: .8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-mark {
    width: 14px; height: 14px; align-self: center; border-radius: 3px;
    background: linear-gradient(135deg, #8fd694, #39b54a);
}
.header-links a { color: inherit; opacity: .85; text-decoration: none; font-size: 13px; }
.header-links a:hover { opacity: 1; text-decoration: underline; }

/* ----- layout ---------------------------------------------------------- */
#layout, .glen-layout {
    position: absolute; top: var(--header-h); left: 0; right: 0; bottom: 0;
    display: flex;
}
#map-wrap { position: relative; flex: 1 1 auto; min-width: 0; }
#map { position: absolute; inset: 0; }

#sidebar {
    position: relative;
    flex: 0 0 var(--sidebar-width);
    width: var(--sidebar-width);
    min-width: 360px;
    container-type: inline-size;
    background: var(--chrome-bg);
    border-left: 1px solid var(--line);
    box-shadow: -2px 0 6px var(--shadow);
    display: flex; flex-direction: column;
    min-height: 0;
}
.sidebar-resize {
    position: absolute; left: -3px; top: 0; bottom: 0; width: 6px;
    cursor: col-resize; z-index: 5;
}
.sidebar-resize:hover { background: rgba(57, 181, 74, .25); }

/* ----- controls -------------------------------------------------------- */
/* the settings scroll inside a box no taller than --controls-max; the bar under them drags it */
#controls {
    flex: 0 0 auto;
    max-height: var(--controls-max, 40%);
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 12px 16px 10px;
    background: var(--chrome-bg);
    display: grid; gap: 10px; align-content: start;
}
.controls-bar { position: relative; flex: 0 0 auto; height: 9px; border-top: 1px solid var(--line); background: var(--chrome-bg); }
.controls-resize { position: absolute; inset: -4px 0 0; cursor: row-resize; z-index: 4; touch-action: none; }
.controls-resize::after {
    content: ''; position: absolute; left: 50%; top: 6px; width: 36px; height: 3px; margin-left: -18px;
    border-radius: 2px; background: var(--line-strong);
}
.controls-resize:hover, .controls-resize:focus-visible { background: rgba(57, 181, 74, .18); outline: none; }
.controls-bar .cs-done {
    position: absolute; right: 12px; top: -1px; z-index: 5;
    border: 1px solid var(--line); border-top: 0; border-radius: 0 0 6px 6px;
    background: var(--chrome-bg); color: var(--text-3); font-size: 11px; padding: 1px 8px 2px; cursor: pointer;
}
.controls-bar .cs-done:hover { color: var(--text); background: var(--hover); }
/* the folded settings: one line naming the area and each setting */
#controls-summary {
    flex: 0 0 auto; display: flex; align-items: center; gap: 10px;
    padding: 9px 16px; border-bottom: 1px solid var(--line); background: var(--chrome-bg); font-size: 13px;
}
#controls-summary .cs-text { flex: 1 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-2); }
#controls-summary .cs-text b { color: var(--text); font-weight: 600; }
/* a pick list floats over the sidebar so the settings box cannot clip it (placed by explorer.js) */
#controls .search > [role="listbox"].floating { position: fixed; right: auto; z-index: 30; }
.step-label {
    font-size: 11px; font-weight: 650; letter-spacing: .6px; text-transform: uppercase;
    color: var(--text-3); margin-bottom: 6px; display: flex; align-items: center; gap: 6px;
}
.step-num {
    display: inline-grid; place-items: center;
    width: 17px; height: 17px; border-radius: 50%;
    background: var(--primary); color: var(--on-primary); font-size: 10px; letter-spacing: 0;
}
.step.pending .step-num { background: var(--text-3); }
.step.pending .step-label { opacity: .7; }
.step-help { font-size: 12px; color: var(--text-3); margin-top: 4px; }

.seg { display: flex; flex-wrap: wrap; gap: 4px; }
.seg button, .chips button {
    border: 1px solid var(--line-strong);
    background: var(--card-bg);
    padding: 5px 11px; border-radius: 999px;
    cursor: pointer; font-size: 13px;
    transition: background 120ms, border-color 120ms;
}
.seg button:hover, .chips button:hover { background: var(--primary-wash); }
.seg button[aria-checked="true"] {
    background: var(--primary); color: var(--on-primary); border-color: var(--primary);
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { display: inline-flex; align-items: center; gap: 6px; }
.chips button .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c); opacity: .35; }
.chips button[aria-pressed="true"] {
    border-color: var(--c); background: color-mix(in srgb, var(--c) 10%, var(--mix-base)); font-weight: 600;
}
.chips button[aria-pressed="true"] .dot { opacity: 1; }
/* a param with "multiple": true: toggle pills, every chosen one highlighted */
.chips.param-multi { --c: var(--primary); gap: 4px; }
.chips.param-multi button[aria-pressed="true"] { background: var(--primary); color: var(--on-primary); border-color: var(--primary); font-weight: 400; }
/* a "multiple" param with groups: a heading pill per group that chooses it whole */
.param-groups { display: flex; flex-direction: column; gap: 6px; --c: var(--primary); }
.param-groups .chips { gap: 4px; }
.param-groups .chips button[aria-pressed="true"] { background: var(--primary); color: var(--on-primary); border-color: var(--primary); font-weight: 400; }
.param-group { display: flex; flex-direction: column; gap: 4px; }
.param-group .group-head { align-self: flex-start; background: none; border: 0; padding: 0; font: inherit; font-size: 12px; font-weight: 600; color: var(--text-2); cursor: pointer; }
.param-group .group-head::before { content: '☐ '; }
.param-group .group-head[aria-pressed="true"]::before { content: '☑ '; }
.param-group .group-head:hover { color: var(--text); }
/* a "multiple" param as a menu ("control": "menu", or past 8 options): a button over a checklist */
.param-menu { --c: var(--primary); }
.pm-toggle {
    width: 100%; text-align: left; padding: 6px 30px 6px 10px; font-size: 13px; cursor: pointer;
    border: 1px solid var(--line-strong); border-radius: 8px; background-color: var(--card-bg); color: var(--text);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 10px center; background-size: 12px;
}
.pm-toggle[aria-expanded="true"] { border-color: var(--primary); border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.pm-toggle .menu-label { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pm-panel {
    border: 1px solid var(--primary); border-top: 0; border-radius: 0 0 8px 8px; background: var(--card-bg);
    max-height: 260px; overflow-y: auto; overscroll-behavior: contain; padding: 4px 0 6px;
}
.pm-filter { display: block; width: calc(100% - 16px); margin: 4px 8px 6px; padding: 5px 8px; border: 1px solid var(--line-strong); border-radius: 6px; font: inherit; font-size: 13px; background: var(--card-bg); color: var(--text); }
.pm-list { display: flex; flex-direction: column; }
.param-menu .param-group { gap: 0; margin-top: 4px; }
.pm-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 2px 10px; }
.pm-head .group-count { font-size: 11px; color: var(--text-3); }
.param-menu .param-group .group-head { font-size: 11px; letter-spacing: .5px; text-transform: uppercase; color: var(--text-3); }
.param-menu .param-group .group-head::before { content: none; }
.pm-opt, .param-menu .group-head { display: flex; align-items: center; gap: 8px; }
.pm-opt {
    border: 0; background: none; text-align: left; padding: 4px 10px; font: inherit; font-size: 13px;
    color: var(--text); cursor: pointer; width: 100%;
}
.param-group .pm-opt { padding-left: 18px; }
.pm-opt:hover, .pm-opt:focus-visible { background: var(--primary-wash); outline: none; }
/* a checkbox drawn on each row and each group heading: ticked, empty, or a dash for part of a group */
.pm-opt::before, .param-menu .param-group .group-head::after {
    content: ''; flex: 0 0 auto; width: 13px; height: 13px; box-sizing: border-box; border-radius: 3px;
    border: 1.5px solid var(--line-strong); background: var(--card-bg) center / 10px no-repeat;
}
.param-menu .param-group .group-head::after { order: -1; }
.pm-opt[aria-pressed="true"]::before, .param-menu .group-head[aria-pressed="true"]::after {
    border-color: var(--primary); background-color: var(--primary);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12l5 5 9-10'/%3E%3C/svg%3E");
}
.param-menu .group-head[aria-pressed="mixed"]::after {
    border-color: var(--primary); background-color: var(--primary);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='4' stroke-linecap='round'%3E%3Cpath d='M6 12h12'/%3E%3C/svg%3E");
}
/* "control": "range" params: two handles on one track over the stops */
.param-span { padding: 0 4px; }
.pr-track { position: relative; height: 18px; width: calc(100% - 100% / var(--n)); margin: 4px calc(50% / var(--n)) 0; }
.pr-track::before, .pr-fill { content: ''; position: absolute; top: 50%; height: 4px; margin-top: -2px; border-radius: 2px; }
.pr-track::before { left: 0; right: 0; background: var(--line-strong); }
.pr-fill { background: var(--primary); left: calc(var(--lo, 0) / var(--last) * 100%); width: calc((var(--hi, 0) - var(--lo, 0)) / var(--last) * 100%); }
.pr-track input[type="range"] { position: absolute; inset: 0; width: 100%; height: 18px; margin: 0; background: none; -webkit-appearance: none; appearance: none; pointer-events: none; }
.pr-track input[type="range"]::-webkit-slider-runnable-track { background: none; }
.pr-track input[type="range"]::-moz-range-track { background: none; }
.pr-track input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none; pointer-events: auto; cursor: pointer;
    width: 14px; height: 14px; border-radius: 50%; background: var(--primary); border: 2px solid var(--card-bg); box-shadow: 0 0 0 1px var(--primary);
}
.pr-track input[type="range"]::-moz-range-thumb {
    pointer-events: auto; cursor: pointer;
    width: 10px; height: 10px; border-radius: 50%; background: var(--primary); border: 2px solid var(--card-bg); box-shadow: 0 0 0 1px var(--primary);
}
.pr-track input[type="range"]:focus-visible { outline: none; }
.pr-track input[type="range"]:focus-visible::-webkit-slider-thumb { outline: 2px solid var(--primary); outline-offset: 2px; }
.pr-track input[type="range"]:focus-visible::-moz-range-thumb { outline: 2px solid var(--primary); outline-offset: 2px; }
.param-span.lo-top .pr-track input[type="range"]:first-of-type { z-index: 1; }
.param-span .param-stops button.in-range { color: var(--text-2); }

/* the chosen areas of an area type with "multiple": true */
.area-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.area-tag {
    display: inline-flex; align-items: center; gap: 2px;
    padding: 2px 2px 2px 10px; border-radius: 999px; font-size: 13px;
    background: var(--primary-wash); border: 1px solid var(--line-strong);
}
.area-tag button {
    border: 0; background: none; cursor: pointer; color: var(--text-3);
    width: 20px; height: 20px; border-radius: 50%; font-size: 14px; line-height: 1; padding: 0;
}
.area-tag button:hover { background: var(--hover); color: var(--text); }

.search { position: relative; }
#place-input, .search .search-input {
    width: 100%; padding: 8px 30px 8px 10px;
    border: 1px solid var(--line-strong); border-radius: 8px; background-color: var(--card-bg);
    /* a chevron, so a filled-in box still reads as a list to choose from */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 10px center; background-size: 12px;
}
#place-input:disabled, .search .search-input:disabled { background: var(--hover); }
.search .search-input { background-image: none; padding-right: 10px; }   /* an address search, not a pick list */
#place-results, .search .search-results {
    position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 4px);
    margin: 0; padding: 4px; list-style: none;
    background: var(--card-bg); border: 1px solid var(--line-strong); border-radius: 8px;
    box-shadow: 0 6px 18px var(--shadow);
    max-height: 300px; overflow-y: auto;
}
#place-results li, .search .search-results li { padding: 6px 8px; border-radius: 5px; cursor: pointer; display: flex; justify-content: space-between; gap: 8px; }
#place-results li small, .search .search-results li small { color: var(--text-3); }
#place-results li[aria-selected="true"], #place-results li:hover, .search .search-results li[aria-selected="true"], .search .search-results li:hover { background: var(--primary-wash); }

/* ----- report ---------------------------------------------------------- */
#report { flex: 1 1 auto; overflow-y: auto; padding: 14px 16px 40px; min-height: 0; }

.intro h2 { font-size: 20px; margin: 6px 0 8px; }
.intro p { color: var(--text-2); margin: 0 0 10px; }
.intro ul { color: var(--text-2); padding-left: 18px; margin: 0 0 10px; }

.report-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.report-head h2 { font-size: 22px; margin: 0; line-height: 1.15; }
.report-head .kind { font-size: 12px; color: var(--text-3); text-transform: uppercase; letter-spacing: .6px; }
.head-actions { display: flex; gap: 6px; flex-shrink: 0; }
.ghost-btn {
    border: 1px solid var(--line-strong); background: var(--card-bg);
    border-radius: 6px; padding: 4px 9px; cursor: pointer; font-size: 12px; white-space: nowrap;
}
.ghost-btn:hover { background: var(--hover); }

.card {
    background: var(--card-bg); border: 1px solid var(--line);
    border-radius: 10px; padding: 12px 14px; margin-bottom: 12px;
}
.theme-card { border-top: 3px solid var(--c, var(--primary)); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.card-head h3 { margin: 0; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.card-head h3 .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.card-blurb { color: var(--text-3); font-size: 12.5px; margin: 0 0 10px; }

.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 6px; }
.tiles[data-n="4"], .tiles[data-n="2"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 420px) { .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.tile { padding: 8px 10px; border-radius: 8px; background: var(--surface); min-width: 0; }
.tile-label { font-size: 12px; color: var(--text-2); }
.tile-value { font-size: 24px; font-weight: 650; font-variant-numeric: tabular-nums; line-height: 1.15; margin-top: 2px; }
.tile-area { font-size: 12px; color: var(--text-2); margin-top: 1px; }
.tile-compare { font-size: 11.5px; color: var(--text-3); margin-top: 2px; font-variant-numeric: tabular-nums; }
.tile-note { font-size: 11px; color: var(--text-3); margin-top: 2px; }
.tile-rank { font-size: 12px; color: var(--text-2); margin-top: 3px; }
.tile-rank b { color: var(--c, var(--primary)); font-variant-numeric: tabular-nums; }

.chart { margin-top: 12px; min-width: 0; }
/* wide panel: four tiles in a row, charts side by side */
@container (min-width: 680px) {
    .tiles[data-n="4"] { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .charts .chart.wide { grid-column: 1 / -1; }
    .charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); column-gap: 24px; align-items: start; }
}
.chart h4 { font-size: 13px; margin: 0; font-weight: 600; }
.chart .sub { font-size: 12px; color: var(--text-3); margin: 1px 0 6px; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart svg text { font-size: 11.5px; fill: var(--text-2); font-variant-numeric: tabular-nums; }
.chart svg .val { fill: var(--text); }
.legend-row { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; color: var(--text-2); margin: 2px 0 4px; }
.legend-row span { display: inline-flex; align-items: center; gap: 5px; }
.legend-row i { width: 11px; height: 11px; border-radius: 2px; display: inline-block; }
.legend-row i.tick { width: 2px; height: 12px; border-radius: 0; }

details.method { margin-top: 10px; font-size: 12px; color: var(--text-2); }
details.method summary { cursor: pointer; color: var(--text-3); }
details.method pre {
    background: var(--code-bg); padding: 8px; border-radius: 6px; overflow-x: auto;
    font-size: 11px; line-height: 1.35; max-height: 260px;
}

.skeleton { background: linear-gradient(90deg, var(--skeleton-a) 25%, var(--skeleton-b) 50%, var(--skeleton-a) 75%); background-size: 200% 100%;
    animation: shimmer 1.2s infinite; border-radius: 6px; color: transparent !important; }
.skeleton * { visibility: hidden; }
@keyframes shimmer { to { background-position: -200% 0; } }
.err { color: var(--danger); font-size: 12px; }

.map-btn {
    border: 1px solid var(--line-strong); background: var(--card-bg); color: var(--text-2);
    border-radius: 999px; font-size: 12px; padding: 3px 9px; cursor: pointer; white-space: nowrap;
}
.map-btn[aria-pressed="true"] { background: var(--c); color: var(--on-primary); border-color: var(--c); }

/* ----- map overlays ---------------------------------------------------- */
.map-overlay {
    position: absolute; z-index: 5;
    background: var(--overlay-bg); border: 1px solid var(--line);
    border-radius: 8px; box-shadow: 0 2px 8px var(--shadow);
}
#map-chips { top: 10px; left: 10px; padding: 6px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; max-width: calc(100% - 70px); }
#map-chips .lbl { font-size: 11px; color: var(--text-3); padding: 0 4px; text-transform: uppercase; letter-spacing: .5px; }
#map-legend { left: 10px; bottom: 28px; padding: 8px 10px; font-size: 12px; max-width: 260px; }
.map-legends { left: 10px; bottom: 28px; padding: 0; font-size: 12px; max-width: 260px; background: none; border: 0; box-shadow: none; display: flex; flex-direction: column; gap: 6px; }
.map-legends:not(:has(> :not([hidden]))) { display: none; }
.map-legends > div { position: static; padding: 8px 10px; background: var(--overlay-bg); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 2px 8px var(--shadow); }
.map-legends #map-legend { left: auto; bottom: auto; }
#overlay-legend .title { font-weight: 600; }
#overlay-legend .lg-row { display: flex; align-items: center; gap: 6px; margin-top: 4px; color: var(--text-2); }
#overlay-legend .lg-row i { width: 12px; height: 12px; border-radius: 2px; display: inline-block; flex: none; }
#overlay-legend .lg-row i.snone { box-shadow: inset 0 0 0 1px rgba(0,0,0,.18); }
#overlay-legend .lg-toggle { display: flex; align-items: center; gap: 5px; margin-top: 6px; font-size: 11.5px; color: var(--text-3); cursor: pointer; }
#overlay-legend .ov + .ov { margin-top: 8px; }
#map-legend .ramp { display: flex; height: 10px; border-radius: 2px; overflow: hidden; margin: 5px 0 3px; }
#map-legend .ramp span { flex: 1; }
#map-legend .ends { display: flex; justify-content: space-between; color: var(--text-3); font-variant-numeric: tabular-nums; }
#map-legend .title { font-weight: 600; }
/* basemap switch, a MapLibre control under the zoom buttons */
.basemap-switch.maplibregl-ctrl { display: flex; background: var(--card-bg); border-radius: 6px; box-shadow: 0 0 0 2px rgba(0,0,0,.1); overflow: hidden; }
.basemap-switch button { border: 0; background: none; padding: 4px 9px; font-size: 12px; color: var(--text-2); cursor: pointer; white-space: nowrap; }
.basemap-switch button + button { border-left: 1px solid var(--line); }
.basemap-switch button:hover { background: var(--hover); }
.basemap-switch button[aria-pressed="true"] { background: var(--primary); color: var(--on-primary); }
#map-hint { top: 10px; left: 50%; transform: translateX(-50%); padding: 6px 12px; font-size: 13px; }

#tooltip {
    position: fixed; z-index: 60; pointer-events: none;
    background: #1d1f1d; color: #fff; padding: 6px 8px; border-radius: 6px; font-size: 12px;
    max-width: 260px; box-shadow: 0 4px 12px rgba(0,0,0,.25);
}
#tooltip b { font-weight: 600; }

/* ----- narrow screens: map on top, panel below ------------------------- */
@media (max-width: 820px) {
    .brand-sub { display: none; }
    #app-header { gap: 12px; padding: 0 12px; }
    .brand h1 { font-size: 16px; }
    #map-legend { bottom: 8px; padding: 6px 8px; max-width: 200px; font-size: 11px; }
    .map-legends { bottom: 6px; max-width: 160px; font-size: 10.5px; }
    .map-legends > div { padding: 5px 7px; }
    #overlay-legend .title, #overlay-legend .lg-toggle, #overlay-legend .lg-long { display: none; }
    .brand h1 { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
    #map-legend .tile-note { display: none; }
    #map-chips .lbl { display: none; }
    #layout, .glen-layout { flex-direction: column; }
    #map-wrap { flex: 0 0 42vh; }
    #sidebar { flex: 1 1 auto; width: auto; min-width: 0; border-left: none; border-top: 1px solid var(--line); }
    .sidebar-resize { display: none; }
}

/* ----- phones: the sidebar as a bottom sheet over a full-height map ----- */
/* explorer.js adds .sheet at the same width and sets --sheet-h from the handle */
.sheet-handle { display: none; }
@media (max-width: 820px) {
    .glen-layout.sheet { display: block; --sheet-pad: min(var(--sheet-h, 50%), 50%); }
    .glen-layout.sheet #map-wrap { position: absolute; inset: 0; }
    .glen-layout.sheet #sidebar {
        position: absolute; left: 0; right: 0; bottom: 0; z-index: 20;
        width: auto; min-width: 0; height: var(--sheet-h, 50%);
        border: 0; border-radius: 14px 14px 0 0; overflow: hidden;
        box-shadow: 0 -3px 14px var(--shadow);
        transition: height .22s ease;
    }
    .glen-layout.sheet .sheet-handle {
        display: block; flex: 0 0 auto; position: relative; width: 100%; height: 24px;
        border: 0; padding: 0; background: var(--chrome-bg); cursor: grab; touch-action: none;
    }
    .glen-layout.sheet .sheet-handle::after {
        content: ''; position: absolute; left: 50%; top: 9px; width: 48px; height: 5px; margin-left: -24px;
        border-radius: 3px; background: var(--text-3);
    }
    .glen-layout.sheet .sheet-handle:focus-visible { outline-offset: -2px; }
    /* map legends and attribution ride above the sheet */
    .glen-layout.sheet .map-legends { bottom: calc(var(--sheet-pad) + 8px); transition: bottom .22s ease; }
    .glen-layout.sheet .maplibregl-ctrl-bottom-left,
    .glen-layout.sheet .maplibregl-ctrl-bottom-right { bottom: var(--sheet-pad); transition: bottom .22s ease; }
    .glen-layout.sheet.sheet-dragging #sidebar,
    .glen-layout.sheet.sheet-dragging .map-legends,
    .glen-layout.sheet.sheet-dragging .maplibregl-ctrl-bottom-left,
    .glen-layout.sheet.sheet-dragging .maplibregl-ctrl-bottom-right { transition: none; }
    .glen-layout.sheet[data-sheet="full"] #sidebar { border-radius: 0; }
}
@media (prefers-reduced-motion: reduce) {
    .glen-layout.sheet #sidebar, .glen-layout.sheet .map-legends,
    .glen-layout.sheet .maplibregl-ctrl-bottom-left, .glen-layout.sheet .maplibregl-ctrl-bottom-right { transition: none; }
}

/* ----- point/isochrone variant ---------------------------------------- */
.step-row { display: flex; flex-wrap: wrap; gap: 10px 22px; }
.header-links { display: flex; gap: 16px; }
.header-links a { white-space: nowrap; }
@media (max-width: 820px) { .header-links { gap: 10px; } .header-links a { font-size: 12px; } }
.origin-marker {
    width: 16px; height: 16px; border-radius: 50%;
    background: #111; border: 3px solid #fff; box-shadow: 0 0 0 1.5px #111, 0 2px 6px rgba(0,0,0,.35);
}
.band-legend { display: flex; gap: 10px; align-items: center; font-size: 12px; color: var(--text-2); margin-top: 4px; flex-wrap: wrap; }
.band-legend i { display: inline-block; width: 18px; height: 0; border-top: 2.5px solid; margin-right: 4px; vertical-align: middle; }
.band-legend i.dash { border-top-style: dashed; border-top-width: 1.5px; }
.note-card { font-size: 12.5px; color: var(--text-2); }

/* ----- shared additions (area sources, notes, no-data) ------------------ */
.draw-row { display: flex; flex-wrap: wrap; gap: 6px; }
.draw-row .upload { cursor: pointer; }
.live-note { margin: -4px 0 10px; }
.chart svg text.nodata { fill: var(--text-3); font-style: italic; }
#step-params .param + .param { margin-top: 8px; }
/* "control": "slider" params: a range input over evenly spaced, clickable stops */
.param-slider { padding: 0 4px; }
.param-slider input[type="range"] { width: calc(100% - 100% / var(--n)); margin: 4px calc(50% / var(--n)) 0; accent-color: var(--primary); cursor: pointer; display: block; }
.param-stops { display: grid; grid-template-columns: repeat(var(--n), 1fr); }
.param-stops button {
    background: none; border: 0; padding: 2px 0; font: inherit; font-size: 12px;
    color: var(--text-3); cursor: pointer; text-align: center;
}
.param-stops button:hover { color: var(--text); }
.param-stops button[aria-pressed="true"] { color: var(--text); font-weight: 600; }
/* "control": "number" params: a box for a typed value, held to the nearest option */
.param-number input[type="number"] {
    width: 8em; padding: 4px 8px; font: inherit; color: var(--text);
    background: var(--card-bg); border: 1px solid var(--line-strong); border-radius: 6px;
}
.param-number input[type="number"]:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
.param-number .param-range { margin-top: 4px; }
#source-steps:not(:has(> :not([hidden]))) { display: none; }
#source-steps { display: contents; }

/* ----- view tabs and pages ---------------------------------------------- */
.view-tabs { display: flex; gap: 2px; padding: 6px 16px 0; background: var(--chrome-bg); border-bottom: 1px solid var(--line); flex: 0 0 auto; overflow-x: auto; }
.view-tabs button {
    border: 0; background: none; padding: 7px 12px 8px; cursor: pointer; font-size: 13.5px; font-weight: 600;
    color: var(--text-3); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.view-tabs button:hover { color: var(--text); }
.view-tabs button[aria-selected="true"] { color: var(--primary); border-bottom-color: var(--primary); }
/* a view with full: true hides the map and gives the panel the whole width */
.glen-full #map-wrap { display: none; }
.glen-full #sidebar { flex: 1 1 auto; width: auto; border-left: none; box-shadow: none; }
.glen-full .sidebar-resize { display: none; }
.page { max-width: 860px; color: var(--text-2); }
.page h2 { color: var(--text); font-size: 20px; margin: 6px 0 8px; }
.page h3 { color: var(--text); font-size: 15px; margin: 18px 0 6px; }
.page p, .page li { line-height: 1.5; }
.page ul.sources { padding-left: 18px; }
.page ul.sources li { margin-bottom: 8px; }
.page .cite { font-size: 12.5px; }
.page .meta { font-size: 12px; color: var(--text-3); }

/* ----- chat (app.chat) ---------------------------------------------------
   The chat itself is glen-harness's (ui/chat.css and ui/chat-docked.css); the
   dock holds it, and the tokens below give it this app's palette. */
.chat-dock {
    flex: 0 0 auto; height: var(--chat-height, 32%); min-height: 0; display: flex; flex-direction: column;
    border-top: 2px solid var(--line-strong); background: var(--surface);
    --chrome-bg: var(--surface); --chrome-fg: var(--text); --chrome-fg-muted: var(--text-3);
    --chrome-line: var(--line); --chrome-hover: var(--hover); --chrome-accent-wash: var(--primary-wash);
    --control-bg: var(--primary); --control-fg: var(--on-primary); --control-accent: var(--primary);
    --chat-fg: var(--text); --chat-surface: var(--card-bg); --chat-code-bg: var(--code-bg);
    --chat-accent-fg: var(--primary-strong); --chat-input-bg: var(--card-bg); --chat-input-bg-focus: var(--card-bg);
    --danger-fg: var(--danger);
}
.chat-dock.compact { height: auto; }
.chat-dock.compact #chat-messages, .chat-dock.compact #chat-footer { display: none; }
.chat-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 16px; border-bottom: 1px solid var(--line); }
.chat-head b { font-size: 14px; }
.chat-body { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.chat-dock #chat-container { font-size: 13px; }
.chat-dock #chat-input { border: 1px solid var(--line-strong); }
.chat-off { color: var(--text-3); font-style: italic; font-size: 12px; padding: 6px 16px; margin: 0; }
.chat-message.card-msg { max-width: none; width: 100%; box-sizing: border-box; }
.chat-card { margin-bottom: 4px; }
.chat-card h4 { margin: 0 0 4px; font-size: 13.5px; }
.table-wrap { overflow-x: auto; }
.chat-table { border-collapse: collapse; font-size: 12px; width: 100%; }
.chat-table th { text-align: left; color: var(--text-2); font-weight: 600; border-bottom: 1px solid var(--line-strong); padding: 4px 6px; }
.chat-table td { border-bottom: 1px solid var(--line); padding: 4px 6px; vertical-align: top; }
.chat-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
