:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f2f1ed;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --hairline: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --accent: #2a78d6;
  --place: #0f8a8a; /* cited places (turquoise, distinct from the sea of the relief) */
  --gain: #1f3a68; /* Polytopie circles: night blue / ochre, away from the gradient colours */
  --loss: #b8860b;
  --vb: #3a3a38; /* Verbatims: anthracite circles and words, ochre (--loss) for the selected word */
  --flow: #eb6834;
  /* diverging: red (below / detested) <-> gray <-> blue (above / liked) */
  --div-n2: #c23a3a;
  --div-n1: #f0a09c;
  --div-0: #d9d8d2;
  --div-p1: #86b6ef;
  --div-p2: #1c5cab;
  --na: #ecebe6;
  --sample-a: #1baf7a;
  --sample-b: #4a3aa7;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.06);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #232321;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --hairline: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --accent: #3987e5;
    --place: #3dbab5;
    --gain: #8fa9d9;
    --loss: #d9a634;
    --vb: #d6d4cc;
    --flow: #d95926;
    --div-n2: #e66767;
    --div-n1: #8a3b3a;
    --div-0: #4a4a46;
    --div-p1: #2b5a92;
    --div-p2: #6da7ec;
    --na: #262624;
    --sample-a: #199e70;
    --sample-b: #9085e9;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.35);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d; --surface: #1a1a19; --surface-2: #232321; --ink: #ffffff; --ink-2: #c3c2b7;
  --muted: #898781; --hairline: #2c2c2a; --axis: #383835; --border: rgba(255,255,255,.10);
  --accent: #3987e5; --place: #3dbab5; --gain: #8fa9d9; --loss: #d9a634; --vb: #d6d4cc; --flow: #d95926; --div-n2: #e66767; --div-n1: #8a3b3a; --div-0: #4a4a46;
  --div-p1: #2b5a92; --div-p2: #6da7ec; --na: #262624; --sample-a: #199e70; --sample-b: #9085e9;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--page); color: var(--ink); }
body { font-size: 14px; line-height: 1.4; }
button, select, input { font: inherit; color: inherit; }

.app { display: flex; height: 100vh; height: 100dvh; }
.panel {
  width: 380px; flex: none; overflow-y: auto; background: var(--surface);
  border-right: 1px solid var(--border); padding: 20px 18px 16px;
  display: flex; flex-direction: column; gap: 18px;
}
.map-wrap { position: relative; flex: 1; min-width: 0; }
/* drag handle on the panel's right edge, to widen it and read long wordings */
.panel-resizer { flex: none; width: 7px; margin-left: -4px; margin-right: -3px; z-index: 1000; cursor: col-resize; position: relative; touch-action: none; }
.panel-resizer::after { content: ""; position: absolute; top: 0; bottom: 0; left: 3px; width: 1px; background: transparent; transition: background .15s; }
.panel-resizer:hover::after, .panel-resizer:focus-visible::after, body.resizing .panel-resizer::after { background: var(--accent); width: 2px; }
body.resizing { cursor: col-resize; user-select: none; }
body.resizing #map { pointer-events: none; }
.full-text { color: var(--ink); font-style: italic; }
.full-text[hidden] { display: none; }
.filter-top span { min-width: 0; overflow-wrap: anywhere; }
#map { position: absolute; inset: 0; background: var(--page); }

.title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.theme-btn { box-shadow: none; padding: 4px 10px; font-size: 12px; }
.title-btns { display: flex; gap: 6px; }
a.tool { text-decoration: none; display: inline-flex; align-items: center; }
.title-btns { flex-wrap: wrap; justify-content: flex-end; }
/* guided tour card, top left of the map (next to the zoom buttons) */
.tour {
  position: absolute; top: 12px; left: 56px; z-index: 900; width: 380px; max-width: calc(100% - 80px);
  background: var(--surface); color: var(--ink); border: 1px solid var(--border); border-left: 4px solid var(--vb);
  border-radius: 10px; box-shadow: var(--shadow); padding: 12px 14px; font-size: 13px; line-height: 1.45;
}
.tour h2 { margin: 4px 0 6px; font-size: 15px; }
.tour p { margin: 0 0 10px; color: var(--ink2, var(--ink)); }
.tour-head { display: flex; justify-content: space-between; align-items: center; }
.tour-count { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.tour-x { border: 0; background: none; color: var(--muted); font-size: 20px; line-height: 1; cursor: pointer; padding: 0 2px; }
.tour-nav { display: flex; justify-content: space-between; gap: 8px; }
.tour-nav .tool[disabled] { opacity: 0.4; cursor: default; }
.tour-next { font-weight: 600; }
/* Guide tab */
.guide p { margin: 0 0 8px; font-size: 13px; line-height: 1.5; }
.guide h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin: 14px 0 6px; }
.guide dl { margin: 0; font-size: 13px; line-height: 1.45; }
.guide dt { font-weight: 650; margin-top: 8px; }
.guide dd { margin: 2px 0 0; color: var(--ink); }
.guide-start { width: 100%; font-weight: 600; padding: 8px 10px; margin: 2px 0 4px; }
@media (max-width: 760px) { .tour { left: 8px; right: 8px; width: auto; max-width: none; } }
/* « fond épuré »: no relief, white background, black country borders */
.panel-head h1 { margin: 0; font-size: 22px; font-weight: 650; letter-spacing: -0.01em; }
.sub { margin: 2px 0 0; color: var(--ink-2); font-size: 13px; }

.tabs { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 3px; }
.tab { border: 0; background: transparent; padding: 8px 6px; border-radius: 8px; cursor: pointer; color: var(--ink-2); font-weight: 550; font-size: 13px; }
.tab[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

.block { display: flex; flex-direction: column; gap: 10px; }
.block[hidden] { display: none; }
.block-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.block h2 { margin: 0; font-size: 13px; font-weight: 650; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-2); }
.block h3 { margin: 4px 0 0; font-size: 15px; font-weight: 650; }
.pill { font-size: 12px; color: var(--ink-2); background: var(--surface-2); border-radius: 99px; padding: 2px 9px; font-variant-numeric: tabular-nums; }

.field { display: flex; flex-direction: column; gap: 4px; }
.field-label { font-size: 12px; color: var(--muted); font-weight: 550; }
select, input[type="search"] {
  width: 100%; padding: 7px 9px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); min-height: 34px;
}
select:focus-visible, input:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.hint { margin: 0; font-size: 12px; color: var(--ink-2); }
.toggles { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; font-size: 13px; color: var(--ink-2); }
.toggles label, .toggle-line { display: flex; gap: 6px; align-items: center; cursor: pointer; }
.toggle-line { font-size: 13px; color: var(--ink-2); }
input[type="checkbox"] { accent-color: var(--accent); margin: 0; }

.seg { display: flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.tab { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seg-btn { flex: 1; border: 0; background: var(--surface); padding: 7px; cursor: pointer; color: var(--ink-2); }
.seg-btn + .seg-btn { border-left: 1px solid var(--border); }
.seg-btn[aria-pressed="true"] { background: var(--surface-2); color: var(--ink); font-weight: 600; }

/* filters */
#filters { display: flex; flex-direction: column; gap: 8px; }
#filters:empty::before { content: "Tous les répondants. Ajoutez un filtre pour restreindre la population."; font-size: 12px; color: var(--muted); }
.filter { border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; background: var(--surface); }
.filter-top { display: flex; justify-content: space-between; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; }
.filter-top button { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 16px; line-height: 1; padding: 2px 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.chip { border: 1px solid var(--border); background: var(--surface); border-radius: 12px; padding: 3px 9px; font-size: 12px; cursor: pointer; color: var(--ink-2); max-width: 100%; text-align: left; overflow-wrap: anywhere; }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }

/* result lists & bars */
.rank { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.rank li { display: grid; grid-template-columns: 22px 1fr auto; gap: 8px; align-items: center; padding: 5px 4px; border-radius: 6px; cursor: pointer; }
.rank li:hover, .rank li.active { background: var(--surface-2); }
.rank .pos { color: var(--muted); font-size: 12px; text-align: right; font-variant-numeric: tabular-nums; }
.rank .name { min-width: 0; }
.rank .name span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank .bar { height: 4px; border-radius: 0 2px 2px 0; background: var(--accent); margin-top: 3px; }
.rank .val { font-variant-numeric: tabular-nums; font-size: 13px; color: var(--ink-2); text-align: right; }
.rank .bar.neg { background: var(--div-n2); }
.rank .val small { margin-left: 5px; color: var(--muted); font-size: 11px; }

.dist { display: flex; flex-direction: column; gap: 8px; }
.dist-row { display: flex; flex-direction: column; gap: 3px; }
.dist-row.highlight .dist-label { color: var(--ink); font-weight: 600; }
.dist-label { display: flex; justify-content: space-between; gap: 10px; font-size: 12.5px; color: var(--ink-2); }
.dist-label span:first-child { min-width: 0; }
.dist-label span:last-child { font-variant-numeric: tabular-nums; white-space: nowrap; }
.dist-track { position: relative; height: 8px; background: var(--surface-2); border-radius: 0 4px 4px 0; }
.dist-fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--accent); border-radius: 0 4px 4px 0; }
.dist-ref { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--ink); border-radius: 1px; }
.key { display: flex; gap: 14px; align-items: center; font-size: 12px; color: var(--ink-2); flex-wrap: wrap; }
.key i { display: inline-block; vertical-align: middle; margin-right: 5px; }
.key .k-fill { width: 14px; height: 8px; border-radius: 0 3px 3px 0; background: var(--accent); }
.key .k-ref { width: 2px; height: 12px; background: var(--ink); }

.selection-card { border: 1px solid var(--border); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 10px; background: var(--surface); }
.selection-card .close { align-self: flex-start; border: 0; background: none; color: var(--muted); cursor: pointer; padding: 0; font-size: 12px; text-decoration: underline; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.stat { background: var(--surface-2); border-radius: 8px; padding: 7px 8px; }
.stat b { display: block; font-size: 17px; font-weight: 650; }
.stat span { font-size: 11px; color: var(--ink-2); }
.warn { font-size: 12px; color: var(--ink-2); background: var(--surface-2); border-left: 3px solid var(--axis); padding: 6px 8px; border-radius: 0 6px 6px 0; }

/* split-sample badges: A = teal, B = violet (identity colours, used for nothing else) */
.sample-badge { display: flex; flex-direction: column; gap: 2px; border-radius: 10px; padding: 8px 10px; font-size: 12px; color: var(--ink-2); border: 1px solid var(--border); background: var(--surface-2); border-left: 4px solid var(--axis); }
.sample-badge b { color: var(--ink); font-size: 13px; }
.sample-badge.sA { border-left-color: var(--sample-a); background: color-mix(in srgb, var(--sample-a) 10%, var(--surface)); }
.sample-badge.sB { border-left-color: var(--sample-b); background: color-mix(in srgb, var(--sample-b) 10%, var(--surface)); }
.legend-sample { display: inline-block; font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: 99px; color: #fff; margin-left: 4px; vertical-align: 1px; }
.legend-sample.sA { background: var(--sample-a); }
.legend-sample.sB { background: var(--sample-b); }

/* whole-sample benchmark under the question */
.var-ref { border: 1px solid var(--border); border-radius: 10px; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.var-ref:empty { display: none; }
.ref-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 12px; font-weight: 650; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-2); }
.var-ref .dist-row { cursor: pointer; }
.var-ref .dist-fill { background: var(--muted); }
.var-ref .dist-row.highlight .dist-fill { background: var(--accent); }

/* 16 gradients d'urbanité */
.gu-block { display: flex; flex-direction: column; gap: 8px; }
.gu-grid { display: flex; flex-direction: column; gap: 3px; }
.gu-sep { font-size: 11px; color: var(--muted); margin-top: 5px; text-transform: uppercase; letter-spacing: .04em; }
.gu-row { display: grid; grid-template-columns: 140px 1fr 88px; gap: 8px; align-items: center; font-size: 12.5px; }
.gu-row.small { opacity: .45; }
.gu-name { color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gu-track { position: relative; height: 10px; background: var(--surface-2); border-radius: 0 4px 4px 0; }
.gu-fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--muted); border-radius: 0 4px 4px 0; }
.gu-fill.up { background: var(--div-p2); }
.gu-fill.down { background: var(--div-n2); }
.gu-avg { position: absolute; top: -3px; bottom: -3px; width: 2px; margin-left: -1px; background: var(--ink); }
.gu-val { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink); }
.gu-val small { color: var(--muted); margin-left: 4px; font-size: 10.5px; }

.gu-sw { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 6px; vertical-align: 0; }
.dist-label .cnt { color: var(--muted); font-size: 11px; }
.stats.two { grid-template-columns: repeat(2, 1fr); }
.quick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.explain { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: var(--ink-2); }
.explain p { margin: 0; }
.gu-table { width: 100%; border-collapse: collapse; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.gu-table th { text-align: right; font-weight: 600; color: var(--muted); font-size: 11.5px; padding: 3px 4px; }
.gu-table th:first-child, .gu-table td:first-child { text-align: left; }
.gu-table td { text-align: right; padding: 3px 4px; border-top: 1px solid var(--hairline); }
.gu-table tr[data-gu] { cursor: pointer; }
.gu-table tr[data-gu]:hover, .gu-table tr.on { background: var(--surface-2); }
.gu-table tr.small td { color: var(--muted); }
.gu-table tr.sep td { border-top: 0; padding-top: 8px; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; text-align: left; }
.gu-matrix { border-collapse: separate; border-spacing: 3px; font-size: 11px; }
.gu-matrix th { font-weight: 500; color: var(--ink-2); text-align: left; padding-right: 4px; white-space: nowrap; }
.gu-matrix thead th { text-align: center; font-size: 10.5px; color: var(--muted); }
.gu-cell { width: 34px; height: 20px; border: 0; border-radius: 3px; cursor: pointer; color: #fff; font-size: 10.5px; font-weight: 600; text-shadow: 0 0 2px rgba(0,0,0,.5); }
.gu-cell.wide { width: 100%; color: #3a3420; text-shadow: none; }
.gu-cell.on { outline: 2px solid var(--ink); outline-offset: 1px; }

/* trajectories: sankey + bloc table */
.sankey { width: 100%; height: auto; display: block; }
.sk-tools { display: flex; gap: 6px; justify-content: flex-end; }
.sk-tools .tool { box-shadow: none; padding: 4px 10px; font-size: 12px; }
.sankey .lk { fill-opacity: .38; transition: fill-opacity .15s; }
.sankey .lk:hover { fill-opacity: .75; }
.sankey text { font-size: 10.5px; fill: var(--ink-2); }
.sankey .hd { font-size: 11px; font-weight: 650; fill: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.traj-table { width: 100%; border-collapse: collapse; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.traj-table th { text-align: right; font-weight: 600; color: var(--muted); font-size: 11.5px; padding: 3px 4px; }
.traj-table th:first-child, .traj-table td:first-child { text-align: left; }
.traj-table td { text-align: right; padding: 4px; border-top: 1px solid var(--hairline); }
.traj-table tr[data-b] { cursor: pointer; }
.traj-table tr[data-b]:hover, .traj-table tr.on { background: var(--surface-2); }
.traj-table tr.off td { opacity: .4; }
.traj-table tr.small td { color: var(--muted); }
.bl-sw { display: inline-block; width: 14px; height: 4px; border-radius: 2px; margin-right: 6px; vertical-align: 3px; }

/* table of the 16 gradients, to the right of the map (Effectifs tab) */
.side-panel {
  position: absolute; top: 56px; right: 12px; bottom: 32px; z-index: 500; width: 300px; overflow-y: auto;
  background: var(--surface); color: var(--ink); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow); padding: 12px; display: flex; flex-direction: column; gap: 10px;
}
.side-panel { width: 340px; }
.side-panel .gu-row { grid-template-columns: 128px 1fr 78px; }
.side-panel[hidden] { display: none; }
.side-panel.wide { width: 440px; max-width: 50%; }
.side-panel .sankey text { font-size: 11px; }
.leaflet-container { background: var(--page); } /* seen through the translucent relief */
/* French place names drawn over the relief base map */
.map-label { pointer-events: none; }
.map-label span { position: absolute; transform: translate(-50%, -50%); white-space: nowrap; font-size: 11px; color: var(--ink-2);
  text-shadow: 0 0 2px var(--surface), 0 0 3px var(--surface), 0 0 4px var(--surface); }
.map-label.country span { font-size: 10.5px; font-style: italic; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.map-label.city.c1 span, .map-label.city.c2 span { font-weight: 650; font-size: 12px; color: var(--ink); }
.map-label.city.c3 span { font-weight: 600; }
.map-label.city.c5 span { font-size: 10px; }

/* Typologie tab */
.typo-pick { display: flex; flex-direction: column; gap: 4px; }
.typo-btn { display: flex; align-items: center; gap: 8px; text-align: left; border: 1px solid var(--border); background: var(--surface);
  color: var(--ink-2); border-radius: 8px; padding: 6px 8px; cursor: pointer; font-size: 12.5px; }
.typo-btn[aria-pressed="true"] { background: var(--surface-2); color: var(--ink); font-weight: 600; border-color: var(--ink-2); }
.typo-btn.sub { margin-left: 18px; font-size: 12px; padding: 4px 8px; }
.typo-btn .sw { width: 16px; height: 12px; border-radius: 6px; opacity: .85; }
.typo-btn .pc { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 500; }
.stack { display: flex; height: 12px; border-radius: 3px; overflow: hidden; background: var(--surface-2); }
.stack span { display: block; height: 100%; }
.prof-row td:first-child { max-width: 190px; }
.prof-row .q { display: block; color: var(--muted); font-size: 11px; }
.up { color: var(--div-p2); font-weight: 600; }
.down { color: var(--div-n2); font-weight: 600; }

/* Verbatims tab: word cloud, lexicometric tables, concordance */
.wcloud-wrap { position: relative; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.wcloud { width: 100%; height: auto; display: block; flex: none; aspect-ratio: 840 / 800; touch-action: none; cursor: grab; user-select: none; }
.wcloud.panning { cursor: grabbing; }
.wcloud-tools { position: absolute; top: 6px; right: 6px; display: flex; gap: 4px; }
.wcloud-tools .tool { min-width: 28px; padding: 3px 7px; }
.side-panel > * { flex-shrink: 0; }
.wcloud text { cursor: pointer; font-family: inherit; }
.wcloud text:hover { text-decoration: underline; }
.wcloud text.on { text-decoration: underline; font-weight: 800; }
.pol-block { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.pol-table { width: 100%; border-collapse: separate; border-spacing: 2px; font-size: 11px; table-layout: fixed; }
.pol-table th { font-weight: 600; color: var(--ink-2); text-align: center; font-size: 10px; padding: 1px; overflow-wrap: anywhere; }
.pol-table thead th:first-child, .pol-table tbody th { width: 28%; }
.pol-table tbody th { text-align: left; font-weight: 400; font-size: 11px; hyphens: auto; }
.pol-table tr.tot th { font-weight: 700; color: var(--ink); }
.pol-table tr[data-pol] { cursor: pointer; }
.pol-table tr[data-pol]:hover th, .pol-table tr.on th { color: var(--ink); text-decoration: underline; }
.pol-table tr.on th { font-weight: 700; }
.pol-table td.pc { text-align: center; padding: 3px 1px; border-radius: 3px; background: var(--div-0); color: var(--ink); font-variant-numeric: tabular-nums; }
.pol-table td.pc small { display: block; font-size: 9.5px; color: var(--muted); }
.pol-table td.p2 { background: var(--div-p2); color: #fff; }
.pol-table td.p1 { background: var(--div-p1); }
.pol-table td.n2 { background: var(--div-n2); color: #fff; }
.pol-table td.n1 { background: var(--div-n1); }
.pol-table td.p2 small, .pol-table td.n2 small { color: rgba(255,255,255,.85); }
.pol-table td.small { background: var(--na); color: var(--muted); }
.pol-table td.all { background: var(--surface); box-shadow: inset 0 0 0 1px var(--axis); font-weight: 700; }
.lex-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.lex-table th { text-align: left; font-weight: 600; color: var(--muted); padding: 3px 4px; border-bottom: 1px solid var(--border); }
.lex-table td { padding: 3px 4px; border-bottom: 1px solid var(--border); vertical-align: top; }
.lex-table td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.lex-table tr[data-w] { cursor: pointer; }
.lex-table tr[data-w]:hover, .lex-table tr.on { background: var(--surface-2); }
.wchip { display: inline-block; margin: 1px 3px 1px 0; padding: 0 5px; border-radius: 4px; background: var(--surface-2); cursor: pointer; }
.wchip:hover { text-decoration: underline; }
.verb { font-size: 12.5px; line-height: 1.4; padding: 6px 8px; background: var(--surface-2); border-radius: 6px; }
.verb mark { background: color-mix(in srgb, var(--vb) 22%, transparent); font-weight: 650; color: inherit; border-radius: 2px; padding: 0 1px; }
.verb .who { display: block; color: var(--muted); font-size: 11px; margin-top: 2px; }
.side-panel h2 { margin: 0; font-size: 13px; font-weight: 650; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-2); }

.credits { margin-top: auto; font-size: 11px; color: var(--muted); }
.credits a { color: var(--ink-2); }

/* map chrome */
.map-tools { position: absolute; top: 12px; right: 12px; z-index: 500; display: flex; gap: 6px; }
.tool { border: 1px solid var(--border); background: var(--surface); color: var(--ink); border-radius: 8px; padding: 6px 10px; cursor: pointer; box-shadow: var(--shadow); font-size: 13px; }
.tool:hover { background: var(--surface-2); }
.tool-check { display: inline-flex; align-items: center; gap: 5px; user-select: none; }
.tool-check input { margin: 0; }
#toggle-panel { display: none; }
.legend {
  position: absolute; left: 12px; bottom: 24px; z-index: 500; background: var(--surface); color: var(--ink);
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; box-shadow: var(--shadow);
  font-size: 12px; max-width: 330px;
}
/* the background grows with the gradient matrix (wider than the text), so nothing overflows the box */
.legend:has(.gu-matrix) { width: min-content; }
.legend:empty { display: none; }
.legend-title { font-weight: 600; margin-bottom: 6px; }
.legend-row { display: flex; align-items: center; gap: 8px; margin: 3px 0; color: var(--ink-2); }
.sw { width: 14px; height: 14px; border-radius: 3px; flex: none; }
.circles { display: flex; align-items: flex-end; gap: 10px; }
.circles div { display: flex; flex-direction: column; align-items: center; gap: 3px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.circles span.c { border-radius: 50%; background: color-mix(in srgb, var(--muted) 45%, transparent); border: 1px solid var(--muted); }

.leaflet-container { font: inherit; background: var(--surface-2); }
.leaflet-tooltip { background: var(--surface); color: var(--ink); border: 1px solid var(--border); box-shadow: var(--shadow); border-radius: 8px; padding: 6px 9px; }
.leaflet-tooltip-top:before { border-top-color: var(--surface); }
.tt-title { font-weight: 600; }
.tt-sub { color: var(--ink-2); font-variant-numeric: tabular-nums; }
.leaflet-control-attribution { background: color-mix(in srgb, var(--surface) 85%, transparent) !important; color: var(--muted); }
.leaflet-control-attribution a { color: var(--ink-2); }
.leaflet-bar a { background: var(--surface); color: var(--ink); border-color: var(--hairline); }

@media (max-width: 760px) {
  .app { flex-direction: column-reverse; }
  .panel-resizer { display: none; }
  .panel { width: 100% !important; height: 52%; border-right: 0; border-top: 1px solid var(--border); padding: 14px 16px; }
  .panel.collapsed { display: none; }
  .map-wrap { flex: 1; }
  #toggle-panel { display: inline-block; }
  .legend { left: 8px; bottom: 8px; max-width: 60%; }
  .toggles, .quick { grid-template-columns: 1fr; }
  .side-panel { top: auto; bottom: 8px; right: 8px; width: auto; left: 8px; max-height: 45%; }
}
