/* Workstation look: an analysis workspace in cool blue-grey, one accent, 1px borders, no shadows.
   Loaded last, after the page's own styles and foundry.css, so these rules win. Both themes switch on
   html[data-theme="dark"|"light"] (set by boot.js before first paint and by setTheme in app.js).

   1. tokens   2. old variable names mapped to tokens   3. flat reset   4. shell layout
   5. components   6. map   7. timeline   8. details panel   9. phones   10. Arabic */

/* ---------- 1. tokens ---------- */
html[data-theme="dark"] {
  --bg-app: #111418; --bg-panel: #1c2127; --bg-raised: #252a31; --bg-hover: #2f343c; --bg-selected: #383e47;
  --border: #383e47; --border-strong: #5f6b7c;
  --text: #f6f7f9; --text-muted: #abb3bf; --text-faint: #738091;
  --accent: #4c90f0; --accent-strong: #2d72d2;
  --ok: #32a467; --warn: #ec9a3c; --danger: #e76a6e;
  --on-accent: #111418; --mk-line: #f6f7f9; --map-bg: #3d4652; --halo: #111418;
  color-scheme: dark;
}
html[data-theme="light"] {
  --bg-app: #f6f7f9; --bg-panel: #ffffff; --bg-raised: #edeff2; --bg-hover: #e5e8eb; --bg-selected: #d3d8de;
  --border: #d3d8de; --border-strong: #8f99a8;
  --text: #1c2127; --text-muted: #5f6b7c; --text-faint: #8f99a8;
  --accent: #2d72d2; --accent-strong: #215db0;
  --ok: #238551; --warn: #c87619; --danger: #cd4246;
  --on-accent: #ffffff; --mk-line: #1c2127; --map-bg: #eef0f3; --halo: #ffffff;
  color-scheme: light;
}
html[data-theme] {
  --f-ui: Inter, "Noto Sans Arabic", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --f-text: var(--f-ui);
  --f-mono: "JetBrains Mono", ui-monospace, "Cascadia Mono", Consolas, Menlo, monospace;
  --fs: 13px;
  --rail-w: 48px; --left-w: 320px; --right-w: 360px; --sb-h: 24px; --bar-h: 32px;
  --tint: color-mix(in srgb, var(--accent) 16%, transparent);
}
html[data-theme].big { --fs: 15px; }
html[data-theme].huge { --fs: 17px; }

/* ---------- 2. the older variable names, pointed at the tokens ---------- */
html[data-theme] {
  --fy-bg: var(--bg-app); --fy-panel: var(--bg-panel); --fy-head: var(--bg-panel); --fy-line: var(--border); --fy-border: var(--border); --fy-input: var(--border-strong);
  --fy-text: var(--text); --fy-muted: var(--text-muted); --fy-accent: var(--accent); --fy-accent-hover: var(--accent-strong);
  --fy-sel: var(--bg-selected); --fy-sel-text: var(--text); --fy-shadow: none; --fy-shadow-sm: none; --fy-r: 2px;
  --muted: var(--text-muted); --link: var(--accent); --line: var(--border); --edge: var(--border);
  --panel: var(--bg-panel); --panel-2: var(--bg-raised); --panel-3: var(--bg-hover); --bg: var(--bg-panel); --ink: var(--halo);
  --ring: var(--accent); --focus: var(--accent); --accent-ink: var(--on-accent);
  --glass: var(--bg-panel); --glass-strong: var(--bg-panel); --blur: none; --shine: none; --lift: none;
  --pp-mono: var(--f-mono);
  --pp-amber: var(--warn); --pp-amber-soft: color-mix(in srgb, var(--warn) 16%, transparent);
  --pp-blue: var(--accent); --pp-blue-soft: var(--tint);
  --pp-red: var(--danger); --pp-red-soft: color-mix(in srgb, var(--danger) 16%, transparent);
  --pp-green: var(--ok); --pp-green-soft: color-mix(in srgb, var(--ok) 16%, transparent);
}

/* ---------- 3. flat reset: no shadows, glows, gradients, glass, pills or serifs ---------- */
html[data-theme] *, html[data-theme] *::before, html[data-theme] *::after {
  box-shadow: none !important; text-shadow: none !important; -webkit-backdrop-filter: none !important; backdrop-filter: none !important; border-radius: 0 !important;
}
html[data-theme] body, html[data-theme] body * { font-family: var(--f-ui) !important; letter-spacing: 0; }
html[data-theme] body :is(code, kbd, samp, pre, .mono, .tl-read, .tl-tick, .tl-max, .tl-n b, .tl-cursor b, .tl-hover b, .tl-pop .yr, .hood-n, .yr, .n, .td, .idrow, .pp-ref, .pp-chron .y, .pp-fn, .meta dd, .ws-num, .ws-menu kbd, .leaflet-control-scale-line, .leaflet-control-attribution, .ws-north, .fulltext),
html[data-theme] #statusbar, html[data-theme] #statusbar * { font-family: var(--f-mono) !important; font-variant-numeric: tabular-nums; }
html[data-theme] :is([lang="ar"], .d-ar, .pp-ar, .hood-ar, .district span), html[data-theme].ar body * { font-family: "Noto Sans Arabic", Inter, system-ui, sans-serif !important; }
html[data-theme], html[data-theme] body { background: var(--bg-app); color: var(--text); font-size: var(--fs); line-height: 1.45; overflow: hidden; }
html[data-theme] :is(h1, h2, h3, h4, h5) { font-weight: 600; letter-spacing: 0; }
html[data-theme] a { color: var(--accent); }
html[data-theme] :focus-visible { outline: 1px solid var(--accent); outline-offset: 1px; }
html[data-theme] ::selection { background: var(--tint); }
html[data-theme] * { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
/* buttons, inputs and panels get the 2px corner; tables and panes stay square; only map markers may be round */
html[data-theme] :is(.btn, button, input, select, textarea, .tag, .dtag, .tk, .pp-pill, .ws-menu, .tl-pop, kbd, .tip, .modal-box, .term-box, .chat, .story-card, .otd, .fy-card, .leaflet-tooltip, .leaflet-bar, .picking-banner, .credit .btn) { border-radius: 2px !important; }
html[data-theme] :is(#drawer, #sheet, #timeline, #topbar, #rail, #statusbar, table, th, td, .ws-table *, .panel-head, .panel-body) { border-radius: 0 !important; }
html[data-theme] :is(.hood-n, .spot, .spot .ping, .mk.sel::before, .lg .sw[style*="dashed"]) { border-radius: 50% !important; }

/* ---------- 4. shell ---------- */
html[data-theme] .bar {
  height: calc(var(--bar-h) + var(--top)); padding: var(--top) 8px 0 0; gap: 8px; z-index: 1130;
  background: var(--bg-panel); border: 0; border-bottom: 1px solid var(--border); color: var(--text);
}
html[data-theme] .brand { display: flex; align-items: center; gap: 8px; height: 100%; padding-left: 12px; flex: none; white-space: nowrap; }
html[data-theme] .brand b { font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; display: inline; }
html[data-theme] .brand small { display: none; }
.crumbs { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-muted); min-width: 0; }
.crumbs i { font-style: normal; color: var(--text-faint); }
.crumbs span { overflow: hidden; text-overflow: ellipsis; max-width: 28vw; }
.crumbs span:last-child { color: var(--text); }
.top-search { flex: 1; max-width: 480px; margin: 0 auto; display: flex; align-items: center; gap: 6px; height: 24px; padding: 0 6px; background: var(--bg-app); border: 1px solid var(--border); border-radius: 2px !important; color: var(--text-muted); }
.top-search:focus-within { border-color: var(--accent); }
.top-search svg { width: 12px; height: 12px; fill: currentColor; flex: none; }
html[data-theme] .top-search input { flex: 1; min-width: 0; height: 22px; min-height: 0; border: 0; background: none; padding: 0; font-size: 12px; color: var(--text); outline: none; }
html[data-theme] .top-search input::placeholder { color: var(--text-faint); }
html[data-theme] kbd { display: inline-block; min-width: 16px; padding: 0 4px; border: 1px solid var(--border); background: var(--bg-raised); color: var(--text-muted); font-size: 10px; line-height: 14px; text-align: center; }
html[data-theme] .bar-actions { gap: 4px; align-items: center; }
html[data-theme] .bar-actions .btn { height: 24px; min-height: 24px; padding: 0 6px; gap: 6px; font-size: 12px; background: transparent; border-color: transparent; }
html[data-theme] .bar-actions .btn:hover, html[data-theme] .bar-actions .btn[aria-expanded="true"] { background: var(--bg-hover); color: var(--text); }
html[data-theme] .bar-actions .btn svg { width: 14px; height: 14px; }

#rail { display: flex; background: var(--bg-panel); }
#rail button { position: relative; flex: none; width: 36px; height: 36px; min-height: 0; padding: 0; display: grid; place-items: center; background: transparent; border: 1px solid transparent; border-radius: 2px !important; color: var(--text-muted); cursor: pointer; }
#rail button svg { width: 16px; height: 16px; fill: currentColor; }
#rail button:hover { background: var(--bg-hover); color: var(--text); }
#rail button:is([aria-expanded="true"], [aria-pressed="true"]) { background: var(--bg-selected); color: var(--text); }
#rail button:is([aria-expanded="true"], [aria-pressed="true"])::before { content: ''; position: absolute; left: -7px; top: 4px; bottom: 4px; width: 2px; background: var(--accent); }
#rail button.primary { color: var(--accent); }
#rail .sep { flex: none; width: 24px; height: 1px; background: var(--border); margin: 4px 0; }
#rail .grow { flex: 1; }
#rail button .lbl { display: none; }

#statusbar { display: none; }
.ws-rz { display: none; }

@media (min-width: 900px) {
  html[data-theme] body { --map-l: var(--rail-w); --map-r: 0px; --map-b: var(--sb-h); }
  html[data-theme] body.drawer-open { --map-l: calc(var(--rail-w) + var(--left-w)); }
  html[data-theme] body.sheet-open { --map-r: var(--right-w); }
  html[data-theme] body:not(.no-timeline):not(.unknown-on) { --map-b: calc(var(--sb-h) + var(--tl-h, 112px)); }
  html[data-theme] #map { top: var(--map-top) !important; left: var(--map-l) !important; right: var(--map-r) !important; bottom: var(--map-b) !important; }
  #rail { position: fixed; z-index: 1120; left: 0; top: var(--map-top); bottom: var(--sb-h); width: var(--rail-w); flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; border-right: 1px solid var(--border); }
  #rail button::after { content: attr(aria-label); position: absolute; left: 44px; top: 50%; transform: translateY(-50%); z-index: 5; padding: 0 8px; height: 24px; line-height: 22px; white-space: nowrap; background: var(--bg-raised); border: 1px solid var(--border-strong); border-radius: 2px; color: var(--text); font: 400 12px var(--f-ui); opacity: 0; pointer-events: none; }
  #rail button[data-k]::after { content: attr(aria-label) "   " attr(data-k); }
  #rail button:hover::after, #rail button:focus-visible::after { opacity: 1; }
  html[data-theme] #drawer, html[data-theme] #sheet { top: var(--map-top) !important; bottom: var(--sb-h) !important; background: var(--bg-panel); border: 0 solid var(--border); z-index: 1100; transform: none; }
  html[data-theme] #drawer { left: var(--rail-w) !important; width: var(--left-w) !important; border-right-width: 1px; }
  html[data-theme] #sheet { right: 0 !important; width: var(--right-w) !important; border-left-width: 1px; }
  html[data-theme] #timeline { left: var(--map-l) !important; right: var(--map-r) !important; bottom: var(--sb-h) !important; border: 0; border-top: 1px solid var(--border); background: var(--bg-panel); z-index: 1030; }
  #statusbar { display: flex; position: fixed; z-index: 1125; left: 0; right: 0; bottom: 0; height: var(--sb-h); align-items: center; gap: 0; padding: 0 4px; background: var(--bg-panel); border-top: 1px solid var(--border); font-size: 11px; color: var(--text-muted); white-space: nowrap; overflow: hidden; }
  #statusbar > span { padding: 0 8px; border-right: 1px solid var(--border); line-height: 23px; }
  #statusbar > .grow { flex: 1; border: 0; }
  #statusbar > span:last-child { border-right: 0; }
  #statusbar b { font-weight: 500; color: var(--text); }
  #statusbar .dot { display: inline-block; width: 6px; height: 6px; margin-right: 6px; background: var(--ok); vertical-align: 1px; }
  #statusbar .off .dot { background: var(--danger); }
  .ws-rz { display: block; position: absolute; z-index: 6; top: 0; bottom: 0; width: 7px; cursor: col-resize; touch-action: none; }
  .ws-rz::after { content: ''; position: absolute; top: 0; bottom: 0; left: 3px; width: 1px; background: transparent; }
  .ws-rz:hover::after, .ws-rz.on::after { background: var(--accent); }
  #drawer .ws-rz { right: -4px; } #sheet .ws-rz { left: -4px; }
  /* map furniture sits inside the map area now, not under the panels */
  html[data-theme] body .leaflet-bottom, html[data-theme] body .leaflet-top, html[data-theme] body .leaflet-bottom.leaflet-left, html[data-theme] body .leaflet-top.leaflet-right, html[data-theme] body .leaflet-bottom.leaflet-right { margin: 0 !important; }
  html[data-theme] body .chat { left: calc(var(--map-l) + 8px) !important; right: auto !important; bottom: calc(var(--map-b) + 8px) !important; margin: 0 !important; width: min(var(--chat-uw, 420px), calc(100vw - var(--map-l) - var(--map-r) - 16px)); max-width: none !important; }
  html[data-theme] body .tip { left: auto !important; right: calc(var(--map-r) + 8px) !important; bottom: calc(var(--map-b) + 36px) !important; margin: 0; max-width: 360px; }
  html[data-theme] body .status { top: auto !important; left: auto !important; right: calc(var(--map-r) + 8px) !important; bottom: calc(var(--map-b) + 36px) !important; transform: none !important; max-width: 360px; text-align: left; }
  html[data-theme] body .yearbadge { left: calc(var(--map-l) + 8px) !important; top: calc(var(--map-top) + 8px) !important; }
  html[data-theme] body :is(.otd, .picking-banner) { left: calc((var(--map-l) + 100vw - var(--map-r)) / 2) !important; }
  html[data-theme] #unknown { left: var(--rail-w) !important; bottom: var(--sb-h) !important; }
  html[data-theme] .hud { display: none !important; }
  html[data-theme] #drawer-close { display: none; }
}

/* ---------- 5. components ---------- */
html[data-theme] :is(.btn, .chips button, .seg button, .act, .grp-parts button, .row-btns .btn, .tl-ctrl button, .door-choice, .fy-cats button) {
  min-height: 28px; height: 28px; padding: 0 10px; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--bg-raised); color: var(--text); border: 1px solid var(--border); font-size: 12px; font-weight: 500; line-height: 1; text-decoration: none; white-space: nowrap; cursor: pointer;
}
html[data-theme] :is(.btn, .chips button, .seg button, .act, .grp-parts button, .tl-ctrl button, .fy-cats button):hover { background: var(--bg-hover); border-color: var(--border-strong); }
html[data-theme] :is(.btn.primary, button.primary) { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
html[data-theme] :is(.btn.primary, button.primary):hover { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }
html[data-theme] .btn.ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
html[data-theme] .btn.ghost:hover { background: var(--bg-hover); color: var(--text); }
html[data-theme] :is(.btn, button):disabled { opacity: .45; cursor: default; }
html[data-theme] :is(.chips button, .seg button, .grp-parts button, .fy-cats button, .tl-ctrl button)[aria-pressed="true"] { background: var(--bg-selected); border-color: var(--accent); color: var(--text); }
html[data-theme] .door-choice, html[data-theme] .act { height: auto; min-height: 28px; padding: 6px 10px; justify-content: flex-start; white-space: normal; text-align: left; line-height: 1.35; }
html[data-theme] .row-btns { gap: 4px; }
html[data-theme] .chips { gap: 4px; }
html[data-theme] .seg { gap: 4px; }

html[data-theme] :is(input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]), select, textarea) {
  min-height: 28px; height: 28px; padding: 0 8px; background: var(--bg-app); color: var(--text); border: 1px solid var(--border); font-size: 12px; outline: none;
}
html[data-theme] textarea { height: auto; min-height: 56px; padding: 6px 8px; line-height: 1.45; }
html[data-theme] :is(input:not([type=checkbox]):not([type=radio]):not([type=range]), select, textarea):focus { border-color: var(--accent); outline: none; }
html[data-theme] ::placeholder { color: var(--text-faint); opacity: 1; }
html[data-theme] :is(input[type=checkbox], input[type=radio], input[type=range]) { accent-color: var(--accent); }
html[data-theme] :is(.toggle input, .omap input[type=checkbox]) { width: 14px; height: 14px; }
html[data-theme] label { font-size: 12px; }
html[data-theme] .fy-form label, html[data-theme] .field label { font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--text-muted); margin-bottom: 4px; }

/* panels */
html[data-theme] :is(.panel, .chat, .modal-box, .term-box, .tip, .status, .story-card, .otd, .picking-banner) { background: var(--bg-panel); color: var(--text); border: 1px solid var(--border); }
html[data-theme] .panel-head { min-height: 32px; height: 32px; padding: 0 4px 0 8px; gap: 8px; background: var(--bg-panel); border-bottom: 1px solid var(--border); }
html[data-theme] .panel-head h2 { font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--text-muted); }
html[data-theme] .panel-head .btn { height: 24px; min-height: 24px; padding: 0 8px; background: transparent; border-color: transparent; color: var(--text-muted); font-size: 12px; }
html[data-theme] .panel-head .btn:hover { background: var(--bg-hover); color: var(--text); }
html[data-theme] .panel-body { padding: 8px; gap: 8px; font-size: var(--fs); }
html[data-theme] .grab { background: var(--border-strong); }
/* tabs: 2px accent underline, no filled shapes */
html[data-theme] .fy-tabs { gap: 0; height: 100%; align-items: stretch; }
html[data-theme] .fy-tabs button { min-height: 0; height: auto; padding: 0 8px; gap: 6px; background: none; border: 0; border-bottom: 2px solid transparent; color: var(--text-muted); font-size: 12px; font-weight: 500; }
html[data-theme] .fy-tabs button svg { width: 12px; height: 12px; }
html[data-theme] .fy-tabs button:hover { color: var(--text); background: none; }
html[data-theme] .fy-tabs button[aria-selected="true"] { background: none; color: var(--text); border-bottom-color: var(--accent); }
/* sections: 11px uppercase header on a 1px rule */
html[data-theme] #drawer .sec, html[data-theme] #drawer details.more { border: 0; border-bottom: 1px solid var(--border); background: none; padding: 0 0 8px; overflow: visible; }
html[data-theme] :is(#drawer .sec h3, #drawer details.more > summary, .sec h3, .modal-box .sec h3, .lg-grp, .legend h4, .legend h5, .ai-h, .sugg-h) {
  min-height: 24px; margin: 0 0 4px; padding: 0; display: flex; align-items: center; background: none; border: 0;
  font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--text-muted);
}
html[data-theme] #drawer .sec > :not(h3), html[data-theme] #drawer details.more > :not(summary) { margin: 4px 0; }
html[data-theme] #drawer details.more[open] > summary { border-bottom: 0; }
html[data-theme] #drawer details.more > summary::before { margin-right: 6px; border-left-color: var(--text-muted); }
/* rows: 24px, hover and selected states */
html[data-theme] .toggle { min-height: 24px; padding: 2px 0; gap: 8px; border-bottom: 0; }
html[data-theme] .toggle span.t { font-weight: 400; font-size: var(--fs); }
html[data-theme] .toggle small, html[data-theme] .grp-head .gt small, html[data-theme] .basemaps small, html[data-theme] .omap small { font-size: 11px; color: var(--text-muted); }
html[data-theme] .toggle .n { font-size: 11px; color: var(--text-muted); }
html[data-theme] :is(.places button, .links button, .qchip, .yc-list button, .trow) { min-height: 24px; padding: 3px 4px; gap: 8px; border-bottom: 0; font-size: var(--fs); color: var(--text); background: none; text-decoration: none; }
html[data-theme] :is(.places button, .links button, .qchip, .yc-list button, .trow):hover { background: var(--bg-hover); }
html[data-theme] .qchip { color: var(--accent); }
html[data-theme] .links small, html[data-theme] .trow .tt small { font-size: 11px; color: var(--text-muted); }
html[data-theme] .places .yr { width: 34px; font-size: 11px; color: var(--text-muted); }
html[data-theme] .grp { padding: 2px 0 6px; border-bottom: 0; }
html[data-theme] .grp-head { min-height: 24px; gap: 8px; }
html[data-theme] .grp-head .gt { font-weight: 500; font-size: var(--fs); }
html[data-theme] .grp-head .box { width: 14px; height: 14px; border: 1px solid var(--border-strong); background: var(--bg-app); font-size: 10px; color: var(--on-accent); }
html[data-theme] .grp-head:is([data-state="all"], [data-state="some"]) .box { background: var(--accent); border-color: var(--accent); }
html[data-theme] .grp-parts { margin: 2px 0 0 22px; gap: 4px; }
html[data-theme] .grp-parts button { height: 24px; min-height: 24px; padding: 0 6px; font-size: 12px; font-weight: 400; }
html[data-theme] .grp-help { font-size: 11px; color: var(--text-muted); margin: 0 0 4px; }
html[data-theme] :is(.grp-parts .tm, .k-then, .k-now) { padding: 0 4px; font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; background: var(--tint); color: var(--text); }
html[data-theme] :is(.grp-parts .tm.then, .k-then) { background: color-mix(in srgb, var(--warn) 18%, transparent); }
html[data-theme] .basemaps { gap: 4px; grid-template-columns: repeat(3, 1fr); }
html[data-theme] .basemaps .thumb { height: 40px; border: 1px solid var(--border); }
html[data-theme] .basemaps button { height: auto; }
html[data-theme] .basemaps .nm { font-size: 12px; font-weight: 500; padding-top: 2px; }
html[data-theme] .basemaps button[aria-pressed="true"] .thumb { outline: 2px solid var(--accent); outline-offset: -2px; }
html[data-theme] .basemaps button[aria-pressed="true"] .nm { color: var(--accent); }
html[data-theme] .unplaced { gap: 8px; }
html[data-theme] .unplaced div { border-left: 1px solid var(--border-strong); padding-left: 8px; font-size: 12px; }
html[data-theme] .omap { padding: 4px 0; border-bottom: 1px solid var(--border); gap: 4px; }
html[data-theme] .omap .t { font-weight: 500; font-size: var(--fs); }
/* shape glyphs in lists and legends */
html[data-theme] .glyph { width: 14px; height: 14px; flex: none; display: grid; place-items: center; border: 0; background: none; transform: none; color: var(--on-accent); }
html[data-theme] .glyph.square:not(.g-shp) { width: 14px; height: 14px; }
html[data-theme] .glyph:not(.g-shp) svg, html[data-theme] .glyph .osm-ic svg { width: 10px; height: 10px; }
html[data-theme] .glyph .osm-ic { width: 14px; height: 14px; border-width: 1px; }
.shp { display: block; width: 12px; height: 12px; overflow: visible; fill: var(--c); stroke: var(--mk-line); stroke-width: 1.1; stroke-linejoin: miter; }
.g-shp .shp { stroke-width: .9; }
.v-testimony > .shp { fill: color-mix(in srgb, var(--c) 45%, var(--map-bg)); stroke: var(--c); stroke-width: 1.6; }
.v-suspected > .shp { fill: var(--halo); stroke: var(--c); stroke-width: 1.8; }
/* tags and badges: rectangular, 11px, tinted with matching text */
html[data-theme] :is(.tag, .dtag, .trow .tk, .pp-pill, .omap .yr, .pp-kw li) {
  display: inline-flex; align-items: center; gap: 4px; height: 18px; padding: 0 6px; border: 0; font-size: 11px; font-weight: 500; line-height: 18px; letter-spacing: 0;
  background: color-mix(in srgb, var(--c, var(--accent)) 16%, transparent); color: color-mix(in srgb, var(--c, var(--accent)) 55%, var(--text));
}
html[data-theme] .tag::before { width: 6px; height: 6px; background: var(--c, var(--text-muted)); }
html[data-theme] .pp-pill { --c: var(--ok); }
html[data-theme] .pp-pill.rep { --c: var(--accent); }
html[data-theme] .pp-pill.unc { --c: var(--warn); }
html[data-theme] .pp-pill.ctx, html[data-theme] .pp-kw li { --c: var(--text-muted); }
html[data-theme] .trow.k-area .tk { --c: var(--ok); }
html[data-theme] .trow.k-doc .tk, html[data-theme] .dtag { --c: var(--warn); }
html[data-theme] .trow.k-event .tk { --c: var(--danger); }
/* tables */
html[data-theme] table.kv { font-size: 12px; }
html[data-theme] table.kv td { border-top: 1px solid var(--border); padding: 3px 4px; height: 24px; }
html[data-theme] table.kv td:first-child { color: var(--text-muted); }
.ws-tools { display: flex; align-items: center; gap: 4px; padding: 4px 8px; border-bottom: 1px solid var(--border); font-size: 11px; color: var(--text-muted); }
.ws-tools .grow { flex: 1; }
#table-body { padding: 0 !important; gap: 0 !important; }
.ws-scroll { flex: 1; min-height: 0; overflow: auto; }
.ws-table { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 12px; }
.ws-table th { position: sticky; top: 0; z-index: 2; height: 24px; padding: 0; background: var(--bg-raised); border-bottom: 1px solid var(--border); text-align: left; }
.ws-table tr.f th { top: 24px; background: var(--bg-panel); padding: 1px 2px; }
html[data-theme] .ws-table th button { width: 100%; height: 23px; min-height: 0; padding: 0 6px; display: flex; align-items: center; justify-content: space-between; gap: 4px; background: none; border: 0; color: var(--text-muted); font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; cursor: pointer; }
html[data-theme] .ws-table th button:hover { color: var(--text); background: var(--bg-hover); }
html[data-theme] .ws-table th[aria-sort] button { color: var(--text); }
html[data-theme] .ws-table tr.f :is(input, select) { width: 100%; height: 20px; min-height: 0; padding: 0 4px; font-size: 11px; }
.ws-table td { height: 24px; padding: 0 6px; border-bottom: 1px solid var(--border); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: default; }
.ws-table td.ws-num { text-align: right; color: var(--text-muted); }
.ws-table td .g-shp { display: inline-grid; vertical-align: -2px; margin-right: 6px; }
.ws-table tbody tr:hover td { background: var(--bg-hover); }
.ws-table tbody tr[aria-selected="true"] td { background: var(--bg-selected); color: var(--text); }
.ws-table tbody tr.cur td:first-child { box-shadow: inset 2px 0 0 var(--accent) !important; }
.ws-table tbody tr:focus-visible { outline: 1px solid var(--accent); outline-offset: -1px; }
.ws-empty { padding: 8px; color: var(--text-muted); font-size: 12px; }
/* menus (context menu, account, export) */
.ws-menu { position: fixed; z-index: 1400; min-width: 200px; max-width: 320px; padding: 4px 0; background: var(--bg-panel); border: 1px solid var(--border-strong); font-size: 12px; }
html[data-theme] .ws-menu button, html[data-theme] .ws-menu a { display: flex; align-items: center; justify-content: space-between; gap: 16px; width: 100%; height: 24px; min-height: 0; padding: 0 8px; background: none; border: 0; border-radius: 0 !important; color: var(--text); font-size: 12px; font-weight: 400; text-decoration: none; text-align: left; cursor: pointer; }
html[data-theme] .ws-menu :is(button, a):hover, html[data-theme] .ws-menu :is(button, a):focus-visible { background: var(--bg-hover); outline: none; }
html[data-theme] .ws-menu kbd { border: 0; background: none; color: var(--text-muted); font-size: 11px; }
.ws-menu hr { border: 0; border-top: 1px solid var(--border); margin: 4px 0; }
.ws-menu .hd { padding: 2px 8px 4px; font-size: 11px; color: var(--text-muted); }
/* toasts: small, bottom right */
html[data-theme] .status { padding: 4px 8px; font-size: 12px; z-index: 1260; border-color: var(--border-strong); }
html[data-theme] .tip { padding: 8px; gap: 8px; border-left: 2px solid var(--accent); font-size: 12px; }
html[data-theme] .credit { background: var(--bg-raised); color: var(--text); border-bottom: 1px solid var(--warn); font-size: 12px; font-weight: 400; padding-top: 4px; padding-bottom: 4px; z-index: 1128; }
html[data-theme] .credit.out { border-bottom-color: var(--danger); }
html[data-theme] .yearbadge { padding: 0 8px; height: 24px; line-height: 22px; background: var(--bg-panel); border: 1px solid var(--border); font-size: 11px; font-weight: 500; }
/* modals are rare and plain */
html[data-theme] .modal, html[data-theme] .term { background: color-mix(in srgb, var(--bg-app) 72%, transparent); }
html[data-theme] .modal.float { background: none !important; }
html[data-theme] .modal-box { border-color: var(--border-strong); }
html[data-theme] .term-box { padding: 0; gap: 0; border-color: var(--border-strong); max-width: 760px; }
html[data-theme] .term-top { padding: 4px 8px; gap: 8px; border-bottom: 1px solid var(--border); min-height: 32px; }
html[data-theme] .term-head { padding: 8px; }
html[data-theme] .term-head input, html[data-theme] #term-q { height: 28px; min-height: 28px; font-size: 13px; }
html[data-theme] #term-kinds, html[data-theme] #term-src { padding: 0 8px 8px; }
html[data-theme] .term-meta { padding: 4px 8px; font-size: 11px; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
html[data-theme] .trow { grid-template-columns: 64px 80px 1fr; padding: 3px 8px; align-items: center; border-bottom: 1px solid var(--border); }
html[data-theme] .trow .tt b { font-size: 13px; font-weight: 500; }
html[data-theme] .trow .td { font-size: 11px; padding: 0; }
html[data-theme] .term-ic, html[data-theme] .selhead .ic { width: 24px; height: 24px; background: color-mix(in srgb, var(--c, var(--accent)) 20%, transparent); color: var(--c, var(--accent)); font-size: 11px; }
html[data-theme] .term-ic svg, html[data-theme] .selhead .ic svg { width: 14px; height: 14px; fill: currentColor; }
/* the guide: plain rows, no bubbles */
html[data-theme] .chat-form { padding: 4px; gap: 4px; }
html[data-theme] .chat-log { padding: 8px; gap: 8px; }
html[data-theme] .msg { max-width: 100%; padding: 0 0 0 8px; border: 0; border-left: 1px solid var(--border-strong); text-align: left; font-style: normal; align-self: stretch; }
html[data-theme] .msg.me { border-left-color: var(--accent); color: var(--text-muted); }
html[data-theme] .msg.err p, html[data-theme] .ai-out.err, html[data-theme] .ai-out.err p, html[data-theme] .field .err { color: var(--danger); }
html[data-theme] .did { color: var(--ok); font-size: 11px; }
html[data-theme] .chat-grip::after { background: var(--border-strong); height: 2px; }
html[data-theme] .fulltext { background: var(--bg-app); border: 1px solid var(--border); padding: 8px; font-size: 12px; }
html[data-theme] .legend .lg { min-height: 24px; gap: 8px; font-size: var(--fs); display: flex; align-items: center; }
html[data-theme] .legend .lg small { margin-left: auto; color: var(--text-muted); font-family: var(--f-mono) !important; font-size: 11px; }
html[data-theme] .legend .lg .sw { width: 12px; height: 12px; flex: none; }
html[data-theme] .leaflet-tooltip.fy-tip, html[data-theme] .fy-card { background: var(--bg-panel); color: var(--text); }
html[data-theme] .leaflet-tooltip.fy-tip { border: 1px solid var(--border-strong); }
html[data-theme] .fy-card { min-width: 160px; }
html[data-theme] .fy-card .ch { padding: 4px 8px; font-size: 12px; font-weight: 600; gap: 6px; border-bottom-color: var(--border); }
html[data-theme] .fy-card .ch i { width: 8px; height: 8px; background: var(--c); font-size: 0; }
html[data-theme] .fy-card .ch i svg { display: none; }
html[data-theme] .fy-card .cr { padding: 2px 8px; font-size: 11px; }
html[data-theme] .fy-card .cr + .cr { border-top: 0; }
html[data-theme] .fy-card .cr span:first-child { color: var(--text-muted); }
html[data-theme] .fy-card .cr span:last-child { font-weight: 400; }

/* ---------- 6. map ---------- */
html[data-theme] #map, html[data-theme] .leaflet-container { background: var(--map-bg); }
html[data-theme="dark"] .tiles-dark { filter: invert(1) hue-rotate(180deg) grayscale(.82) brightness(.82) contrast(.9); opacity: .88 !important; }
html[data-theme="light"] .tiles-light, html[data-theme] .tiles-light { filter: grayscale(1) contrast(.86) brightness(1.04); }
html[data-theme] .tiles-dark { filter: invert(1) hue-rotate(180deg) grayscale(.82) brightness(.82) contrast(.9); opacity: .88 !important; }
html[data-theme] .mk { position: absolute; left: 6px; top: 6px; width: 12px; height: 12px; display: block; background: none; border: 0; transform: none !important; transition: none; }
html[data-theme] .mk::after { content: ''; position: absolute; inset: -8px; }
html[data-theme] .mk.sel::before { content: ''; position: absolute; inset: -5px; border: 2px solid var(--accent); }
html[data-theme] .mk.multi::before { content: ''; position: absolute; inset: -4px; border: 1px solid var(--accent); border-radius: 50% !important; }
html[data-theme] .leaflet-tooltip.site-label { padding: 0 4px; background: color-mix(in srgb, var(--bg-panel) 88%, transparent); color: var(--text); border: 1px solid var(--border); font-size: 11px; font-weight: 500; line-height: 16px; }
html[data-theme] .district { font: 500 11px var(--f-ui); font-style: normal; letter-spacing: .04em; text-transform: uppercase; color: var(--text-muted); text-shadow: 0 0 2px var(--halo), 0 0 2px var(--halo), 0 0 3px var(--halo) !important; }
html[data-theme] .district span { font-size: 11px; opacity: 1; text-transform: none; letter-spacing: 0; }
html[data-theme] .osm-ic { width: 16px; height: 16px; background: var(--bg-panel); border: 1px solid var(--c); }
html[data-theme] .osm-ic svg { width: 10px; height: 10px; }
html[data-theme] .spot { width: 12px; height: 12px; background: var(--accent); border: 1px solid var(--mk-line); }
html[data-theme] .spot .ping { inset: -8px; border: 1px solid var(--accent); }
/* clusters: a flat circle with a mono count, the neighbourhood name beside it */
html[data-theme] .hood { flex-direction: row; align-items: center; gap: 4px; padding: 0; background: none; border: 0; margin: 0 auto; }
html[data-theme] .hood-n { display: grid; place-items: center; flex: none; min-width: 22px; height: 22px; padding: 0 3px; background: var(--bg-panel); border: 1px solid var(--accent); color: var(--text); font-size: 11px; font-weight: 500; }
html[data-theme] .hood:hover .hood-n { background: var(--accent); color: var(--on-accent); }
html[data-theme] .hood > span { padding: 0 4px; background: color-mix(in srgb, var(--bg-panel) 88%, transparent); border: 1px solid var(--border); font-size: 11px; font-weight: 500; line-height: 16px; }
html[data-theme] .hood > span > em, html[data-theme] .hood small { display: none; }
html[data-theme] .glyph .hood-n { min-width: 14px; height: 14px; font-size: 9px; padding: 0; }
/* leaflet chrome as flat bordered boxes */
html[data-theme] .leaflet-bar { border: 1px solid var(--border) !important; background: var(--bg-panel) !important; margin: 8px !important; }
html[data-theme] .leaflet-bar a { width: 28px !important; height: 28px !important; line-height: 28px !important; font-size: 16px !important; background: var(--bg-panel) !important; color: var(--text) !important; border-color: var(--border) !important; }
html[data-theme] .leaflet-bar a:hover { background: var(--bg-hover) !important; }
html[data-theme] .leaflet-bar a.on { background: var(--bg-selected) !important; color: var(--accent) !important; }
html[data-theme] .leaflet-control-scale { margin: 8px !important; }
html[data-theme] .leaflet-control-scale-line { background: var(--bg-panel) !important; color: var(--text-muted); border: 1px solid var(--border); border-top: 0; padding: 0 4px; font-size: 10px; line-height: 16px; }
html[data-theme] .leaflet-control-attribution { background: var(--bg-panel) !important; color: var(--text-muted) !important; border: 1px solid var(--border); border-width: 1px 0 0 1px; padding: 0 4px; font-size: 10px; line-height: 16px; }
html[data-theme] .leaflet-control-attribution a { color: var(--text-muted) !important; }
.ws-north, .ws-legend { background: var(--bg-panel); border: 1px solid var(--border); color: var(--text); margin: 8px !important; }
.ws-north { width: 28px; height: 28px; display: grid; place-items: center; font-size: 10px; line-height: 1; margin-top: 0 !important; }
.ws-north svg { width: 10px; height: 12px; fill: var(--text); display: block; margin: 0 auto 1px; }
.ws-legend { min-width: 150px; max-width: 220px; font-size: 11px; }
html[data-theme] .ws-legend > button { width: 100%; height: 22px; min-height: 0; padding: 0 6px; display: flex; align-items: center; justify-content: space-between; background: none; border: 0; color: var(--text-muted); font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; cursor: pointer; }
.ws-legend ul { list-style: none; margin: 0; padding: 2px 6px 4px; border-top: 1px solid var(--border); }
.ws-legend li { display: flex; align-items: center; gap: 6px; height: 18px; white-space: nowrap; }
.ws-legend li .n { margin-left: auto; padding-left: 8px; color: var(--text-muted); }
html[data-theme] .swipe { background: var(--accent); width: 2px; margin-left: -1px; }
html[data-theme] .swipe::after { width: 24px; height: 24px; margin: -12px 0 0 -12px; background: var(--bg-panel); border: 1px solid var(--accent); color: var(--text); font-size: 12px; }
html[data-theme] .swipe span { background: var(--bg-panel); border: 1px solid var(--border); color: var(--text); font-size: 11px; font-weight: 500; padding: 0 4px; }

/* ---------- 7. timeline strip ---------- */
html[data-theme] #timeline { overflow: visible; font-size: 11px; outline-offset: -1px; user-select: none; -webkit-user-select: none; }
#timeline .tl-head { position: absolute; left: 0; right: 0; top: 0; height: 24px; display: flex; align-items: center; gap: 12px; padding: 0 4px 0 8px; border-bottom: 1px solid var(--border); }
html[data-theme] #timeline .tl-title { position: static; font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--text-muted); }
#timeline .tl-read { font-size: 11px; color: var(--text); white-space: pre; min-width: 190px; }
html[data-theme] #timeline .tl-hint { position: static; flex: 1; min-width: 0; font-size: 11px; color: var(--text-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
html[data-theme] #timeline .tl-ctrl { position: static; display: flex; gap: 2px; flex: none; }
html[data-theme] #timeline .tl-ctrl button { height: 20px; min-height: 0; padding: 0 6px; font-size: 11px; background: var(--bg-raised); color: var(--text); }
html[data-theme] #timeline .tl-lab { left: 8px; width: 100px; font-size: 11px; font-weight: 400; color: var(--text-muted); line-height: 14px; }
#timeline .tl-max { position: absolute; width: 22px; text-align: right; font-size: 9px; line-height: 10px; color: var(--text-faint); }
html[data-theme] #timeline .tl-bar { position: absolute; bottom: auto; min-width: 0; padding: 0; border: 0; background: var(--border-strong); pointer-events: none; }
#timeline .tl-bar.dim { background: var(--border); }
html[data-theme] #timeline .tl-era { position: absolute; padding: 0 4px; border: 0; border-right: 1px solid var(--bg-panel); background: var(--bg-raised); color: var(--text-muted); font-size: 10px; font-weight: 500; line-height: 16px; text-align: left; white-space: nowrap; overflow: hidden; z-index: 2; min-height: 0; height: 16px; display: block; }
html[data-theme] #timeline .tl-era.alt { background: var(--bg-hover); }
html[data-theme] #timeline .tl-era:hover { background: var(--bg-selected); color: var(--text); }
html[data-theme] #timeline .tl-era.sel { background: var(--accent); color: var(--on-accent); }
html[data-theme] #timeline .tl-grid { background: var(--border); opacity: .6; }
html[data-theme] #timeline .tl-lane { height: 1px; background: var(--border); }
html[data-theme] #timeline .tl-axis { height: 1px; background: var(--border-strong); }
html[data-theme] #timeline .tl-tick { font-size: 10px; color: var(--text-muted); height: 16px; min-height: 0; line-height: 16px; padding: 0 3px; background: none; border: 0; z-index: 2; }
html[data-theme] #timeline .tl-tick:hover { color: var(--accent); }
#timeline .tl-break { position: absolute; width: 5px; height: 9px; margin-left: -2px; border-left: 1px solid var(--border-strong); border-right: 1px solid var(--border-strong); background: var(--bg-panel); transform: skewX(-18deg); z-index: 2; }
html[data-theme] #timeline .tl-span { position: absolute; height: 3px; background: var(--c); opacity: .55; }
#timeline .tl-span.dim { opacity: .15 !important; }
html[data-theme] #timeline .tl-dot { position: absolute; z-index: 3; width: 14px; height: 14px; margin-left: -7px; padding: 1px; display: grid; place-items: center; background: none; border: 0; transform: none !important; outline: 0; color: var(--text); min-height: 0; cursor: pointer; }
html[data-theme] #timeline .tl-dot .shp { width: 10px; height: 10px; }
html[data-theme] #timeline .tl-dot.tl-n { min-width: 14px; width: auto; padding: 0 3px; margin-left: -7px; background: var(--bg-raised); border: 1px solid var(--border-strong); }
html[data-theme] #timeline .tl-dot.tl-n b { font-size: 9px; font-weight: 500; line-height: 12px; }
html[data-theme] #timeline .tl-dot:hover, html[data-theme] #timeline .tl-dot:focus-visible { outline: 1px solid var(--text); outline-offset: 0; }
html[data-theme] #timeline .tl-dot.sel { outline: 2px solid var(--accent); outline-offset: 1px; }
#timeline .tl-dot.dim { opacity: .22; }
html[data-theme] #timeline .tl-hit { position: absolute; z-index: 1; cursor: crosshair; }
#timeline .tl-hover, html[data-theme] #timeline .tl-cursor { position: absolute; width: 1px; margin-left: 0; background: var(--border-strong); pointer-events: none; z-index: 4; }
html[data-theme] #timeline .tl-cursor { background: var(--accent); }
#timeline .tl-hover b, html[data-theme] #timeline .tl-cursor b { position: absolute; top: 0; left: 50%; transform: translate(-50%, -100%); padding: 0 4px; background: var(--bg-raised); border: 1px solid var(--border-strong); color: var(--text); font-size: 10px; font-weight: 500; line-height: 14px; white-space: nowrap; }
html[data-theme] #timeline .tl-cursor b { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
#timeline .tl-brush { position: absolute; z-index: 2; background: color-mix(in srgb, var(--accent) 22%, transparent); border-left: 1px solid var(--accent); border-right: 1px solid var(--accent); pointer-events: none; }
#timeline .tl-hd { position: absolute; top: 0; bottom: 0; width: 9px; pointer-events: auto; cursor: ew-resize; }
#timeline .tl-hd.l { left: -5px; } #timeline .tl-hd.r { right: -5px; }
#timeline .tl-hd::after { content: ''; position: absolute; top: 50%; left: 2px; width: 5px; height: 14px; margin-top: -7px; background: var(--accent); }
html[data-theme] .tl-pop { position: absolute; z-index: 20; width: 300px; max-height: 260px; overflow-y: auto; padding: 4px 0; background: var(--bg-panel); border: 1px solid var(--border-strong); }
html[data-theme] .tl-pop button { display: flex; align-items: center; gap: 8px; width: 100%; height: 24px; min-height: 0; padding: 0 8px; background: none; border: 0; border-radius: 0 !important; color: var(--text); font-size: 12px; text-align: left; cursor: pointer; }
html[data-theme] .tl-pop button:hover, html[data-theme] .tl-pop button:focus-visible { background: var(--bg-hover); outline: 0; }
.tl-pop .yr { color: var(--text-muted); font-size: 11px; flex: none; }
.tl-pop .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 8. details panel: type icon, title, type tag, label/value list, sections ---------- */
html[data-theme] #sheet-body { padding: 8px; gap: 8px; }
html[data-theme] #sheet-body .pp-head, html[data-theme] .selhead { gap: 8px; align-items: flex-start; }
html[data-theme] #sheet-body .pp-head > .glyph { margin-top: 3px; }
html[data-theme] :is(#sheet-body .pp-title, .d-title) { font-size: 15px; font-weight: 600; line-height: 1.3; letter-spacing: 0; }
html[data-theme] :is(#sheet-body .pp-ar, .d-ar) { font-size: 13px; color: var(--text-muted); margin-top: 0; text-align: start; }
html[data-theme] #sheet-body .pp-type { margin-top: 4px; font-family: var(--f-ui) !important; font-size: 11px; font-weight: 600; letter-spacing: .04em; color: var(--text-muted); }
html[data-theme] #sheet-body .pp-status, html[data-theme] .meta { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 0; margin: 8px 0 0; padding: 0; border: 0; border-top: 1px solid var(--border); font-size: 12px; }
html[data-theme] #sheet-body .pp-status > div { display: contents; }
html[data-theme] #sheet-body .pp-status dt, html[data-theme] .meta dt { min-height: 24px; padding: 4px 8px 4px 0; border-bottom: 1px solid var(--border); font-family: var(--f-ui) !important; font-size: 12px; letter-spacing: 0; text-transform: none; color: var(--text-muted); }
html[data-theme] #sheet-body .pp-status dd, html[data-theme] .meta dd { min-height: 24px; margin: 0; padding: 4px 0; border-bottom: 1px solid var(--border); font-weight: 400; color: var(--text); }
html[data-theme] #sheet-body .pp-status dd.nr { color: var(--text-muted); font-style: normal; }
html[data-theme] #sheet-body .pp-acts { margin: 8px 0 0; gap: 4px; }
html[data-theme] #sheet-body .pp-sec { margin-top: 12px; padding-top: 0; border-top: 1px solid var(--border); }
html[data-theme] #sheet-body :is(.pp-sec > h3, .pp-sec .sec h3, .pp-sec .ai-h, .pp-sub, .pp-conflict b, .pp-acct .who) {
  min-height: 24px; display: flex; align-items: center; margin: 0 0 4px; font-family: var(--f-ui) !important; font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--text-muted);
}
html[data-theme] #sheet-body .pp-bl { font-weight: 500; margin: 0 0 8px; }
html[data-theme] #sheet-body .pp-chron { gap: 0; }
html[data-theme] #sheet-body .pp-chron li { grid-template-columns: 56px minmax(0, 1fr); gap: 8px; padding: 4px 0; border-bottom: 1px solid var(--border); }
html[data-theme] #sheet-body :is(.pp-chron.seq, .pp-chron.per) li { grid-template-columns: 96px minmax(0, 1fr); }
html[data-theme] #sheet-body .pp-nodate li { grid-template-columns: minmax(0, 1fr); }
html[data-theme] #sheet-body .pp-chron .y { font-size: 11px; color: var(--text-muted); padding-top: 2px; }
html[data-theme] #sheet-body .pp-chron .y.g { color: var(--warn); }
html[data-theme] #sheet-body .pp-fn { color: var(--accent); }
html[data-theme] #sheet-body .pp-conflict { background: none; color: var(--text); border-left: 2px solid var(--danger); padding: 0 0 0 8px; margin-top: 8px; font-size: 12px; }
html[data-theme] #sheet-body .pp-acct { background: none; border-left: 2px solid var(--ok); padding: 0 0 0 8px; }
html[data-theme] #sheet-body .pp-ref { font-size: 10px; margin-top: 12px; }
html[data-theme] #sheet-body .srcs li.pp-hit { background: var(--tint); }
html[data-theme] .srcs { font-size: 12px; gap: 4px; padding-left: 20px; }
html[data-theme] .brief { border-left: 2px solid var(--accent); padding-left: 8px; font-size: var(--fs); }
html[data-theme] .d-text, html[data-theme] .ai-out p { max-width: none; }
html[data-theme] .ai { border-top: 1px solid var(--border); padding-top: 8px; gap: 8px; }
html[data-theme] .idrow { font-size: 11px; color: var(--text-muted); }
html[data-theme] .conn-row, html[data-theme] .links button { border-bottom: 1px solid var(--border); }

/* ---------- 9. phones and tablets: same tokens, sheets from the bottom, larger touch targets ---------- */
@media (max-width: 899px) {
  html[data-theme] { --bar-h: 84px; }
  html[data-theme] .bar { height: calc(44px + var(--top)); }
  html[data-theme] .brand b { font-size: 12px; }
  .crumbs, .top-search kbd { display: none; }
  .top-search { max-width: none; height: 28px; }
  #rail { position: fixed; z-index: 1125; left: 0; right: 0; top: calc(44px + var(--top)); height: 40px; flex-direction: row; align-items: center; gap: 2px; padding: 0 6px; border-bottom: 1px solid var(--border); overflow-x: auto; }
  #rail .sep { width: 1px; height: 20px; margin: 0 4px; }
  #rail button:is([aria-expanded="true"], [aria-pressed="true"])::before { left: 4px; right: 4px; top: auto; bottom: -3px; width: auto; height: 2px; }
  #rail #btn-timeline, #rail #btn-table { display: none; }
  html[data-theme] .panel { border-width: 1px 0 0; }
  html[data-theme] :is(.btn, .chips button, .seg button, .grp-parts button, .row-btns .btn) { min-height: 36px; height: 36px; font-size: 13px; }
  html[data-theme] :is(input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]), select) { min-height: 36px; height: 36px; font-size: 16px; }
  html[data-theme] textarea { font-size: 16px; }
  html[data-theme] :is(.places button, .links button, .qchip, .yc-list button, .toggle, .grp-head) { min-height: 36px; }
  html[data-theme] .panel-head { height: 40px; min-height: 40px; }
  html[data-theme] .panel-head .btn { height: 32px; min-height: 32px; }
  html[data-theme] .mk::after { inset: -14px; }
  .ws-legend, .ws-north { display: none; }
}

/* ---------- 10. Arabic ---------- */
html[data-theme].ar .top-search input, html[data-theme] input:is([dir="rtl"], [dir="auto"]) { text-align: start; }
html[data-theme].ar #rail button::after { font-family: "Noto Sans Arabic", Inter, sans-serif !important; }
html[data-theme] .ws-name-ar { color: var(--text-muted); margin-inline-start: 6px; unicode-bidi: isolate; }

@media print { #rail, #statusbar, #topbar { display: none !important; } html[data-theme], html[data-theme] body { overflow: visible; } }

html[data-theme] .mk.sel::before { border-radius: 50% !important; }

/* ---------- start screen, story and year cards ---------- */
html[data-theme] .door-box { max-width: 560px; padding: 12px; background: var(--bg-panel); border: 1px solid var(--border-strong); }
html[data-theme] .door-head h2 { font-size: 15px; font-weight: 600; margin: 0 0 4px; }
html[data-theme] .door-head p { margin: 0 0 12px; color: var(--text-muted); font-size: 12px; }
html[data-theme] .door-grid { gap: 4px; }
html[data-theme] .door-choice { display: flex; height: auto; min-height: 48px; padding: 8px; gap: 8px; align-items: flex-start; justify-content: flex-start; white-space: normal; text-align: start; line-height: 1.35; background: var(--bg-raised); border: 1px solid var(--border); color: var(--text); }
html[data-theme] .door-choice:hover, html[data-theme] .door-choice:focus-visible { background: var(--bg-hover); border-color: var(--accent); }
html[data-theme] .door-choice b { font-size: 13px; font-weight: 600; margin-bottom: 2px; }
html[data-theme] .door-choice small { font-size: 11px; color: var(--text-muted); }
html[data-theme] .dc-ic { width: 24px; height: 24px; background: var(--tint); color: var(--accent); }
html[data-theme] .dc-ic svg { width: 14px; height: 14px; }
html[data-theme] .door-foot { margin-top: 12px; }
html[data-theme] .door-off { font-size: 12px; gap: 6px; }
html[data-theme] .door-off input { width: 14px; height: 14px; }
html[data-theme] .story-card { padding: 8px; gap: 8px; border: 1px solid var(--border-strong); font-size: 12px; }
html[data-theme] .sc-head b, html[data-theme] .sc-place b { font-size: 13px; font-weight: 600; }
html[data-theme] .sc-head .btn, html[data-theme] .sc-btns .btn { min-height: 28px; height: 28px; }
@media (min-width: 900px) {
  html[data-theme] body .story-card { right: auto !important; left: calc(var(--map-l) + 8px) !important; top: calc(var(--map-top) + 40px) !important; bottom: auto !important; transform: none !important; width: 340px; max-height: calc(100vh - var(--map-top) - var(--map-b) - 60px); overflow-y: auto; }
}
@media (max-width: 899px) {
  html[data-theme] .top-search { display: none; }
  html[data-theme] .bar { justify-content: space-between; }
  html[data-theme] .bar-actions .btn { height: 32px; min-height: 32px; }
}

/* contrast: --text-faint is below AA on every surface, so it is kept for placeholders and dividers only */
html[data-theme] #timeline .tl-hint, html[data-theme] #timeline .tl-max, html[data-theme] .crumbs i { color: var(--text-muted); }
html[data-theme] #timeline .tl-era { color: var(--text); }
html[data-theme] :is(.places button, .links button, .yc-list button, .trow):hover :is(small, .yr, .td), .ws-table tbody tr:hover td.ws-num, .ws-table tbody tr[aria-selected="true"] td.ws-num { color: var(--text); }
html[data-theme] #sheet-body .pp-chron .y.g { color: var(--text); font-weight: 500; }

/* ---------- timeline, formal dress: even year scale, a tick per year, end sections set apart ---------- */
html[data-theme] #timeline .tl-lab { width: 136px; color: var(--text); font-weight: 500; }
html[data-theme] #timeline .tl-title { color: var(--text); }
#timeline .tl-read { min-width: 170px; padding: 0 8px; border-left: 1px solid var(--border); border-right: 1px solid var(--border); line-height: 23px; }
html[data-theme] #timeline .tl-hint { display: flex; align-items: center; gap: 6px; color: var(--text-muted); }
#timeline .tl-hint .g-shp { display: inline-grid; margin-left: 8px; }
#timeline .tl-hint .shp { width: 9px; height: 9px; }
#timeline .tl-tk { position: absolute; width: 1px; height: 3px; background: var(--border-strong); pointer-events: none; }
#timeline .tl-tk.major { height: 6px; background: var(--text-muted); }
html[data-theme] #timeline .tl-tick { transform: translateX(-50%); top: auto; color: var(--text); font-size: 10px; line-height: 14px; height: 14px; }
#timeline .tl-cap { position: absolute; height: 17px; margin-top: 0; text-align: center; pointer-events: auto; }
#timeline .tl-cap span { font-family: var(--f-mono) !important; font-size: 10px; line-height: 17px; color: var(--text-muted); white-space: nowrap; }
#timeline .tl-gap { position: absolute; z-index: 5; background: var(--bg-app); border-left: 1px solid var(--border-strong); border-right: 1px solid var(--border-strong); pointer-events: none; }

html[data-theme] #timeline .tl-era { text-align: center; font-size: 10px; letter-spacing: .02em; }
html[data-theme] #timeline .tl-lane { background: var(--border); }
html[data-theme] #timeline .tl-ctrl button { min-width: 44px; }
html[data-theme] #timeline .tl-span { height: 2px; opacity: .4; }

/* analyst grades beside citations */
.grade { display: inline-block; min-width: 20px; margin-inline-end: 6px; padding: 0 3px; border: 1px solid var(--border-strong); border-radius: 2px; font-family: var(--f-mono) !important; font-size: 10px; line-height: 14px; text-align: center; color: var(--text); cursor: help; vertical-align: 1px; }
.grade.g-B, .grade.g-A { border-color: var(--ok); }
.grade.g-C { border-color: var(--border-strong); }
.grade.g-D, .grade.g-E { border-color: var(--danger); }
.grade.g-F { border-style: dashed; color: var(--text-muted); }
html[data-theme] .grade-key { margin: 6px 0 0; font-size: 11px; color: var(--text-muted); }

/* ---------- country view ---------- */
.region { display: flex; align-items: flex-start; gap: 6px; cursor: pointer; white-space: nowrap; }
.region i { flex: none; width: 12px; height: 12px; border: 1px solid var(--mk-line); background: var(--text-faint); }
.region.published i { background: var(--accent); }
.region span { display: flex; flex-direction: column; padding: 0 5px; background: color-mix(in srgb, var(--bg-panel) 90%, transparent); border: 1px solid var(--border); }
.region b { font-size: 11px; font-weight: 600; line-height: 16px; color: var(--text); }
.region small { font-family: var(--f-mono) !important; font-size: 10px; line-height: 14px; color: var(--text-muted); }
.region:hover span { border-color: var(--accent); }
html[data-theme] body.country :is(.hood, .leaflet-marker-icon .mk, .site-label, .district, .osm-ic, .rep) { display: none !important; }
html[data-theme] .crumb-btn { height: 20px; min-height: 0; padding: 0 4px; background: none; border: 0; color: var(--text-muted); font-size: 12px; font-weight: 400; cursor: pointer; }
html[data-theme] .crumb-btn:hover { color: var(--accent); background: none; }

/* speeches */
html[data-theme] details.sp { border-bottom: 1px solid var(--border); }
html[data-theme] details.sp > summary { display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 0 8px; min-height: 24px; padding: 3px 0; cursor: pointer; list-style: none; font-size: 12px; }
html[data-theme] details.sp > summary::-webkit-details-marker { display: none; }
html[data-theme] details.sp > summary:hover { background: var(--bg-hover); }
html[data-theme] details.sp .yr { color: var(--text-muted); font-size: 11px; grid-row: span 2; padding-top: 1px; }
html[data-theme] details.sp .sp-who { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
html[data-theme] details.sp .sp-at { color: var(--text-muted); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
html[data-theme] details.sp[open] > summary { background: var(--bg-raised); }
html[data-theme] details.sp > :not(summary) { margin: 6px 0; }
html[data-theme] .sp-desc { font-size: 12px; border-left: 2px solid var(--border-strong); padding-left: 8px; }
html[data-theme] .sp-open { font-family: var(--f-mono) !important; font-size: 11px; line-height: 1.55; padding: 8px; background: var(--bg-app); border: 1px solid var(--border); max-height: 220px; overflow-y: auto; }

/* Close in (map zoom 15 and up) a site marker becomes a 20px tile carrying the layer's drawing (layer-icons.js). The shape and colour
   stay the same channel pair; the evidence level keeps its fill: solid tile (documented), half tone (reported), outline (suspected).
   White on every layer colour is at least 3.09:1 (the weakest, the gold of seats of power). */
html[data-theme] .mk .mkI { display: none; }
html[data-theme] .z-icons .mk .shp { display: none; }
html[data-theme] .z-icons .mk .mkI { display: grid; place-items: center; position: absolute; left: -4px; top: -4px; width: 20px; height: 20px; background: var(--c); color: #fff; border: 1px solid var(--mk-line); }
html[data-theme] .z-icons .mk .mkI svg { width: 16px; height: 16px; display: block; }
html[data-theme] .z-icons .mk.v-testimony .mkI { background: color-mix(in srgb, var(--c) 45%, var(--map-bg)); color: var(--c); border-color: var(--c); }
html[data-theme] .z-icons .mk.v-suspected .mkI { background: var(--halo); color: var(--c); border: 2px solid var(--c); }
html[data-theme] .z-icons .mk.sel::before { inset: -9px; }

/* Timeline lane for records with no map position (see unLane in app.js): neutral grey, a tick at the first year; hollow when the
   date is only a decade or "about"; a bar where the text gives a range. The list opens to each record's text and sources. */
html[data-theme] #timeline .tl-span.un { background: var(--text-muted); }
html[data-theme] #timeline .tl-dot.tl-un:not(.tl-n) i { display: block; width: 3px; height: 10px; background: var(--text-muted); box-sizing: border-box; }
html[data-theme] #timeline .tl-dot.tl-un.approx i { width: 5px; background: none; border: 1px solid var(--text-muted); }
html[data-theme] .tl-pop.tl-pop-un { width: 420px; max-height: 320px; }
html[data-theme] .tl-pop .un-item { border-top: 1px solid var(--border); }
html[data-theme] .tl-pop .un-item:first-child { border-top: 0; }
html[data-theme] .tl-pop .un-body { padding: 2px 12px 8px 30px; font-size: 12px; line-height: 1.45; color: var(--text); }
html[data-theme] .tl-pop .un-body p { margin: 0 0 4px; }
html[data-theme] .tl-pop .un-src { color: var(--text-muted); }
html[data-theme] .tl-pop .un-src a { color: var(--accent); }

/* One-publisher note beside a source list */
html[data-theme] .one-pub { margin: 0 0 6px; padding: 3px 6px; font-size: 11px; line-height: 1.4; color: var(--text); border-left: 2px solid var(--text-muted); background: var(--surface-2, transparent); }
html[data-theme] .evi { margin: 0 0 6px; font-size: 11px; color: var(--text-muted); }
html[data-theme] .no-qr { display: block; font-size: 11px; color: var(--text-muted); }
/* Encyclopedia search results: the list is a column that scrolls, and a row must keep its own height. Without this the
   rows were squeezed to their 24px minimum and their text ran over the next row. */
html[data-theme] .term-list > * { flex: none; }
html[data-theme] .trow { align-items: start; }
html[data-theme] .trow .tt { min-width: 0; overflow-wrap: anywhere; }

#places [hidden] { display: none !important; }

/* ---------- 11. Intelligence: the entity graph in the workstation look ----------
   Same tokens as the rest of the shell (both themes): flat panel header with a 1px rule, mono object IDs, accent for selection,
   square nodes with 1px frames, no grain, no vignette. The symbolic pictures keep their own dark tones inside a 1px frame. */
html[data-theme] #unknown { background: var(--bg-app); color: var(--text); }
html[data-theme] #unknown .un-grain { display: none; }
html[data-theme] #unknown .un-head { padding: 0; gap: 0; align-items: stretch; flex-wrap: nowrap; background: var(--bg-panel); border-bottom: 1px solid var(--border); height: var(--bar-h); }
html[data-theme] #unknown .un-title { display: flex; align-items: center; gap: 12px; min-width: 0; padding: 0 12px; }
html[data-theme] #unknown .un-title h2 { margin: 0; font: 600 13px/1 var(--f-ui); letter-spacing: 0; color: var(--text); white-space: nowrap; }
html[data-theme] #unknown .un-title p { margin: 0; max-width: none; font-size: 12px; line-height: 1.2; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
html[data-theme] #unknown .un-tools { align-items: center; gap: 6px; padding: 0 8px; flex-wrap: nowrap; flex: none; }
html[data-theme] #unknown .un-tools input { height: 24px; min-width: 200px; padding: 0 8px; background: var(--bg-app); color: var(--text); border: 1px solid var(--border-strong); border-radius: 2px; font: 12px var(--f-ui); }
html[data-theme] #unknown .un-tools input:focus { outline: none; border-color: var(--accent); }
html[data-theme] #unknown .btn { height: 24px; padding: 0 10px; background: var(--bg-raised); color: var(--text); border: 1px solid var(--border-strong); border-radius: 2px; font: 12px var(--f-ui); }
html[data-theme] #unknown .btn:hover { background: var(--bg-hover); }
html[data-theme] #unknown .btn.primary { background: var(--accent-strong); color: #fff; border-color: var(--accent-strong); }
html[data-theme] #unknown .btn.primary:hover { background: var(--accent); }
html[data-theme] .un-lrow .un-why { border: 1px solid var(--border-strong) !important; color: var(--accent); border-radius: 2px; }
@media (max-width: 899px) {
  html[data-theme] #unknown .un-head { height: auto; flex-wrap: wrap; padding: 6px 8px; gap: 6px; }
  html[data-theme] #unknown .un-title { padding: 0; } html[data-theme] #unknown .un-title p { display: none; }
  html[data-theme] #unknown .un-tools { padding: 0; width: 100%; flex-wrap: wrap; } html[data-theme] #unknown .un-tools input { flex: 1; min-width: 0; }
}

/* ---------- 12. town markers: entries the sources place only by town (pos 'town'), one marker per town with a count ---------- */
html[data-theme] .mk-town { position: relative; width: 34px; height: 30px; cursor: pointer; }
html[data-theme] .mk-town b { position: absolute; left: 0; right: 0; top: 0; height: 20px; display: flex; align-items: center; justify-content: center; background: var(--bg-panel); color: var(--text); border: 1px solid var(--border-strong); font: 600 11px/1 var(--f-mono) !important; font-variant-numeric: tabular-nums; }
html[data-theme] .mk-town i { position: absolute; left: 16px; top: 20px; width: 1px; height: 8px; background: var(--border-strong); }
html[data-theme] .mk-town i::after { content: ''; position: absolute; left: -2px; top: 7px; width: 5px; height: 5px; background: var(--border-strong); }
html[data-theme] .leaflet-marker-icon:hover .mk-town b, html[data-theme] .leaflet-marker-icon:focus-visible .mk-town b { border-color: var(--accent); color: var(--accent); }
html[data-theme] .site-label.town-label { color: var(--text-muted); font-style: normal; }
html[data-theme] .glyph.g-town { display: inline-flex; align-items: center; justify-content: center; min-width: 28px; height: 22px; padding: 0 4px; border: 1px solid var(--border-strong); font: 600 11px var(--f-mono) !important; color: var(--text); }

/* ---------- 13. Intelligence as a link-analysis graph (19 Nov 2026) ----------
   The conventions of analyst link-chart tools: round nodes with one flat glyph per object type, type colour on the ring and
   glyph only, thin neutral links that turn accent when selected, a measured grid that pans with the graph, a type histogram
   that filters, mono object IDs. No drawn faces, grain, shadows or draw-in animation. Type colours are the shell's own
   status hues plus one violet, and every type also has its own glyph, so colour is never the only cue. */
html[data-theme="dark"] { --ty-person: #4c90f0; --ty-org: #ec9a3c; --ty-place: #32a467; --ty-mapped: #2ec4b6; --ty-event: #bdadff; --ty-militant: #e76a6e; --ty-unknown: #8f99a8; }
html[data-theme="light"] { --ty-person: #2d72d2; --ty-org: #c87619; --ty-place: #238551; --ty-mapped: #00857a; --ty-event: #7961db; --ty-militant: #cd4246; --ty-unknown: #738091; }
html[data-theme] .t-agent, html[data-theme] .t-official, html[data-theme] .t-dissident, html[data-theme] .t-trader { --tc: var(--ty-person); }
html[data-theme] .t-militant { --tc: var(--ty-militant); }
html[data-theme] .t-org, html[data-theme] .t-state { --tc: var(--ty-org); }
html[data-theme] .t-place { --tc: var(--ty-place); }
html[data-theme] .t-mapped { --tc: var(--ty-mapped); }
html[data-theme] .t-event { --tc: var(--ty-event); }
html[data-theme] .t-unknown { --tc: var(--ty-unknown); }

html[data-theme] .un-pic { overflow: visible; }
html[data-theme] .un-pic .disc { fill: var(--bg-panel); }
html[data-theme] .un-pic .ring { fill: none; stroke: var(--tc, var(--border-strong)); stroke-width: 6; }
html[data-theme] .un-pic .gl { fill: var(--tc, var(--text-muted)); }
html[data-theme] .un-pic .gl .gc { fill: var(--bg-panel); }
html[data-theme] .un-pic.real .ph { filter: grayscale(1) contrast(1.05); }

html[data-theme] #unknown .un-gridbg { pointer-events: all; }
html[data-theme] #unknown pattern .g1 { fill: none; stroke: var(--border); stroke-width: .6; opacity: .6; }
html[data-theme] #unknown pattern .g5 { fill: none; stroke: var(--border); stroke-width: 1; opacity: .7; }
html[data-theme] #unknown .un-e { stroke: var(--border-strong); opacity: .5; animation: none; stroke-dasharray: none; }
html[data-theme] #unknown .un-e.strong { opacity: .75; }
html[data-theme] #unknown.dim .un-e { opacity: .12; }
html[data-theme] #unknown .un-e.hot { stroke: var(--accent); opacity: .95; }
html[data-theme] #unknown .un-e.on { stroke: var(--accent); opacity: 1; stroke-width: 2.5; }

html[data-theme] #unknown .un-n { transition: opacity .15s; }
html[data-theme] #unknown.dim .un-n { opacity: .18; }
html[data-theme] #unknown .un-n.hot { opacity: 1; }
html[data-theme] #unknown .un-n .halo { fill: none; stroke: none; }
html[data-theme] #unknown .un-n:hover .disc, html[data-theme] #unknown .un-n:focus-visible .disc { fill: var(--bg-hover); }
html[data-theme] #unknown .un-n:focus-visible .halo { stroke: var(--accent); stroke-width: 1.5; stroke-dasharray: 3 2; }
html[data-theme] #unknown .un-n.sel .halo { fill: var(--tint); stroke: var(--accent); stroke-width: 2; }
html[data-theme] #unknown .un-n text { text-anchor: middle; }
html[data-theme] #unknown .un-n .nm { fill: var(--text); font-size: 10.5px; font-weight: 500; paint-order: stroke; stroke: var(--bg-app); stroke-width: 3px; stroke-linejoin: round; }
html[data-theme] #unknown .un-n .cn { fill: var(--text-faint); font-family: var(--f-mono) !important; font-size: 8.5px; paint-order: stroke; stroke: var(--bg-app); stroke-width: 3px; }
html[data-theme] #unknown .un-n.sel .nm { font-weight: 600; }

html[data-theme] #unknown .un-sep { width: 1px; align-self: stretch; margin: 7px 0; background: var(--border); flex: none; }
html[data-theme] #unknown .un-legend { left: 8px; top: calc(var(--bar-h) + 8px); bottom: auto; right: auto; width: 208px; display: block; padding: 0 0 4px; max-width: none;
  background: var(--bg-panel); border: 1px solid var(--border); border-radius: 2px; }
html[data-theme] #unknown .un-lg-h { display: flex; justify-content: space-between; padding: 6px 8px; border-bottom: 1px solid var(--border); font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
html[data-theme] #unknown .un-lg-h small { font-weight: 500; text-transform: none; letter-spacing: 0; color: var(--text-faint); }
html[data-theme] #unknown .un-legend button { position: relative; display: grid; grid-template-columns: 16px 1fr auto; align-items: center; gap: 8px; width: 100%; height: 26px; padding: 0 8px;
  background: transparent; color: var(--text); border: 0; border-left: 2px solid transparent; border-radius: 0; font: 12px var(--f-ui); text-align: left; cursor: pointer; }
html[data-theme] #unknown .un-legend button:hover { background: var(--bg-hover); }
html[data-theme] #unknown .un-legend button[aria-pressed="true"] { background: var(--tint); border-left-color: var(--accent); }
html[data-theme] #unknown .un-legend button small { color: var(--text-muted); font-family: var(--f-mono) !important; font-size: 11px; }
html[data-theme] #unknown .un-legend .lg-bar { position: absolute; left: 0; top: 3px; bottom: 3px; max-width: 100%; background: var(--tc); opacity: .1; pointer-events: none; }
html[data-theme] #unknown .un-legend button > :not(.lg-bar) { position: relative; }
html[data-theme] #unknown .un-legend .lg-pic svg { display: block; }
html[data-theme] .un-portrait svg { border: 0; box-shadow: none; }
html[data-theme] .un-portrait .un-case { left: 50%; bottom: -4px; transform: translateX(-50%); white-space: nowrap; }
html[data-theme] .un-links .un-mini svg { border: 0; }
@media (max-width: 899px) {
  html[data-theme] #unknown .un-legend { top: auto; bottom: 8px; left: 8px; right: 8px; width: auto; display: flex; overflow-x: auto; padding: 0; }
  html[data-theme] #unknown .un-lg-h { display: none; }
  html[data-theme] #unknown .un-legend button { width: auto; flex: none; grid-template-columns: 16px auto auto; }
  html[data-theme] #unknown .un-sep { display: none; }
}

/* start screen: keep the four choices inside the box; developer's note about positions outside Tripoli */
html[data-theme] .door-box { overflow-x: hidden; }
html[data-theme] .door-grid > * { min-width: 0; }
html[data-theme] .door-head p.door-note { max-width: none; margin: 0 0 12px; padding: 8px 10px; font-size: 12px; line-height: 1.45; color: var(--text); background: var(--bg-raised); border-left: 2px solid var(--accent); }
html[data-theme] .door-choice > * { min-width: 0; overflow-wrap: anywhere; }
html[data-theme] .door-choice small, html[data-theme] .door-choice b { white-space: normal; }
html[data-theme] .tip { flex-direction: column; align-items: stretch; }
html[data-theme] .tip p { margin: 0; }
html[data-theme] .tip .tip-note { line-height: 1.45; }
html[data-theme] .tip #tip-ok { align-self: flex-end; }
/* profile and present-day markers: the drawing takes the marker colour, so it is never white on the white panel background */
html[data-theme] .osm-ic svg { fill: var(--c); }
html[data-theme] .ws-legend-prof { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 4px; }
html[data-theme] .ws-legend-prof .osm-ic { display: grid; place-items: center; width: 14px; height: 14px; }
html[data-theme] .ws-legend-prof .osm-ic svg { width: 10px; height: 10px; }
/* miscellaneous marker: solid grey tile with white dots, so it never reads as an empty square */
html[data-theme] .osm-ic.prof.misc { background: var(--c); border-color: var(--c); }
html[data-theme] .osm-ic.prof.misc svg { fill: #fff; }
