/* The interactive map (/map/<slug>, templates/interactive_map.html, js/interactive-map.js).
 * Prefix `im-`. Label and overview rules are DayZMap's and live in dayz-map.css.
 *
 * Layout: the map fills the page under the navbar and every control floats over it -- the side panel
 * (a drawer on phones), the toolbar docks top right (bottom right on phones), the readout, legend and
 * overview along the bottom. Design tokens below are the redesign's (2026-10), scoped on .im-root. */

.im-root {
    --im-bg: #000027;          --im-panel: rgba(10,14,28,.96);
    --im-surface: #0a0e1c;     --im-field: #0f1424;      --im-raised: #151b2e;
    --im-hover: rgba(255,255,255,.06);
    --im-line: rgba(255,255,255,.08);  --im-line-strong: rgba(255,255,255,.14);
    --im-text: #e5e7eb;        --im-text-2: #c3c9d4;     --im-muted: #8b95a8;
    --im-accent: #facc15;      --im-accent-ink: #0a0e1c; --im-accent-soft: rgba(250,204,21,.12);
    --im-blue: #3b82f6;        --im-blue-fill: #2563eb;
    --im-tier-1: #4ade80; --im-tier-2: #fde047; --im-tier-3: #fb923c; --im-tier-4: #ef4444;
    --im-r-xs: 4px; --im-r-sm: 6px; --im-r-md: 10px; --im-r-lg: 14px; --im-r-xl: 20px;
    --im-shadow-1: 0 1px 2px rgba(0,0,0,.5);
    --im-shadow-2: 0 6px 20px rgba(0,0,0,.45);
    --im-shadow-3: 0 20px 48px rgba(0,0,0,.6), 0 2px 6px rgba(0,0,0,.4);
    --im-nav-h: 64px; --im-panel-w: 320px; --im-inset: 12px;
    --im-tool: 40px;  --im-tool-touch: 44px;
    --im-ease: cubic-bezier(.2,.8,.2,1);
    --im-font: 'Roboto', system-ui, sans-serif;
    --im-mono: 'Roboto Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.im-root :focus-visible { outline: 2px solid var(--im-accent); outline-offset: 2px; }
@media (max-width: 767px) { .im-root { --im-nav-h: 56px; --im-tool: 44px; } }
@media (prefers-reduced-motion: reduce) {
    .im-root *, .im-root *::before, .im-root *::after { animation: none !important; transition: none !important; }
}

/* ---------------------------------------------------------------- shell */

.im-shell {
    position: relative; overflow: hidden;
    height: calc(100vh - 4rem - 1px);    /* navbar is h-16 plus its 1px border, and sticky */
    height: calc(100dvh - 4rem - 1px);
    min-height: 26rem;
    font-family: var(--im-font); font-size: 14px; line-height: 1.4; color: var(--im-text);
    background: var(--im-bg); -webkit-font-smoothing: antialiased;
}
.im-shell *, .im-shell *::before, .im-shell *::after { box-sizing: border-box; }
/* :where() keeps these resets at element specificity, so any one-class rule below wins over them. */
:where(.im-shell) button, :where(.im-shell) input { font: inherit; color: inherit; }
:where(.im-shell) button { cursor: pointer; }
/* The map fills the viewport under the navbar; base.html's footer bar would push the page into a scroll. */
body:has(#im-shell) > footer { display: none; }

/* `hidden` must win over the display of any im- class (script toggles it on flex/grid elements). */
.im-shell [hidden] { display: none !important; }
.im-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.im-mono { font-family: var(--im-mono); font-variant-numeric: tabular-nums; }
.im-muted { color: var(--im-muted); }

/* The map is its own stacking context, so the floating chrome below needs only small z-indices:
 * readout / legend / overview 18 · panel 20 · toolbar 22 · hint 24 · results 45 · sheet 50 · toast 60. */
.im-map { position: absolute; inset: 0; z-index: 0; isolation: isolate; background: #0b0f19; }
.im-map--crosshair, .im-map--crosshair .leaflet-interactive { cursor: crosshair !important; }
.im-map--pointer, .im-map--pointer .leaflet-interactive { cursor: pointer; }

/* Thin progress bar while markers.json loads. */
.im-progress { position: absolute; top: 0; left: 0; right: 0; height: 3px; z-index: 19; overflow: hidden;
    background: rgba(255,255,255,.08); }
.im-progress span { display: block; height: 100%; width: 40%; background: var(--im-accent); border-radius: 2px;
    animation: im-bar 1.2s ease-in-out infinite; }

/* ---------------------------------------------------------------- shared controls */

.im-iconbtn {
    width: 36px; height: 36px; display: grid; place-items: center; flex: none; padding: 0; border: 0;
    border-radius: var(--im-r-md); background: transparent; color: var(--im-muted);
    transition: background .12s, color .12s;
}
.im-iconbtn:hover { background: var(--im-hover); color: var(--im-text); }
.im-iconbtn--sm { width: 28px; height: 28px; border-radius: var(--im-r-sm); font-size: 13px; }

.im-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 36px; padding: 0 14px;
    border-radius: var(--im-r-md); border: 1px solid transparent; font-size: 13px; font-weight: 500;
    white-space: nowrap; text-decoration: none; transition: background .12s, border-color .12s, color .12s;
}
.im-btn i { font-size: 13px; }
.im-btn--accent { background: var(--im-accent); color: var(--im-accent-ink); font-weight: 700; }
.im-btn--accent:hover { background: #fde047; }
.im-btn--ghost { background: var(--im-field); border-color: var(--im-line-strong); color: var(--im-text-2); }
.im-btn--ghost:hover { background: #161d33; color: var(--im-text); }
.im-btn--danger:hover { color: #fecaca; border-color: rgba(248,113,113,.5); }
.im-btn:disabled, .im-btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }

.im-link { background: none; border: 0; padding: 4px 6px; margin: -4px -6px; color: var(--im-accent);
    font-size: 12px; font-weight: 500; border-radius: 6px; }
.im-link:hover { text-decoration: underline; text-underline-offset: 3px; }

.im-pill { display: inline-grid; place-items: center; min-width: 20px; height: 18px; padding: 0 6px; border-radius: 999px;
    background: var(--im-accent); color: var(--im-accent-ink); font-size: 11px; font-weight: 700; letter-spacing: 0;
    font-variant-numeric: tabular-nums; }
.im-pill--muted { background: #1d2438; color: var(--im-text-2); }

.im-kbd { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 5px; border-radius: 5px;
    border: 1px solid var(--im-line-strong); border-bottom-width: 2px; font-family: var(--im-mono); font-size: 11px;
    color: var(--im-muted); background: #141a2c; margin-right: 4px; }

/* Category badge: the category colour with a white or dark glyph (whichever reads better on it). */
.im-badge { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; flex: none;
    font-size: 11px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.25); }
.im-badge--lg { width: 34px; height: 34px; font-size: 15px; }
.im-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }

/* ---------------------------------------------------------------- side panel */

.im-panel {
    position: absolute; top: var(--im-inset); left: var(--im-inset); bottom: var(--im-inset); width: var(--im-panel-w);
    display: flex; flex-direction: column; z-index: 20;
    background: var(--im-panel); border: 1px solid var(--im-line); border-radius: var(--im-r-lg);
    box-shadow: var(--im-shadow-3); backdrop-filter: blur(10px);
    animation: im-slide .2s var(--im-ease) both;
}
.im-shell--closed .im-panel, .im-shell--closed .im-scrim { display: none; }
.im-panel__head { padding: 14px 14px 14px 16px; display: flex; flex-direction: column; gap: 12px; border-bottom: 1px solid var(--im-line); }
.im-title-row { display: flex; align-items: center; gap: 10px; }
.im-title-row > div { flex: 1; min-width: 0; }
/* Map | Loot Finder: the two tools over one terrain. The current one is a span, the other a real link. */
.im-modes { display: flex; gap: 2px; margin-top: 10px; padding: 3px; background: var(--im-field);
  border: 1px solid var(--im-line); border-radius: var(--im-r-md); }
.im-mode { flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; height: 30px;
  border-radius: var(--im-r-sm); font-size: 12px; font-weight: 500; color: var(--im-text-2); text-decoration: none; }
.im-mode[aria-current="page"] { background: var(--im-accent); color: var(--im-accent-ink); }
a.im-mode:hover { background: var(--im-hover); color: var(--im-text); }
a.im-tool { text-decoration: none; }
.im-eyebrow { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--im-muted); font-weight: 500; }
.im-h1 { margin: 0; font-size: 22px; line-height: 1.15; font-weight: 700; letter-spacing: -.01em; color: var(--im-text); }
.im-panel__body { flex: 1; min-height: 0; overflow-y: auto; scrollbar-width: thin; scrollbar-color: #2a3247 transparent;
    border-radius: 0 0 var(--im-r-lg) var(--im-r-lg); }
.im-panel__foot { display: none; }

.im-section { padding: 14px 16px; border-bottom: 1px solid var(--im-line); display: flex; flex-direction: column; gap: 10px; }
.im-section--flush { padding: 14px 0 6px; }
.im-section--flush > .im-section-head { padding: 0 16px; }
.im-section-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 20px; }
.im-h2 { margin: 0; display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 700; letter-spacing: .08em;
    text-transform: uppercase; color: var(--im-text-2); }
.im-meta { font-size: 12px; color: var(--im-muted); font-variant-numeric: tabular-nums; }
.im-empty-line { margin: 0; font-size: 12px; color: var(--im-muted); }
.im-note { margin: 0; font-size: 11px; color: var(--im-muted); }
.im-credit { margin: 0; padding: 12px 16px 14px; font-size: 11px; line-height: 1.5; color: var(--im-muted); }
.im-credit a { color: var(--im-accent); text-decoration: underline; text-underline-offset: 2px; }

/* Search */
.im-search { position: relative; }
.im-search-field { display: flex; align-items: center; gap: 8px; height: 42px; padding: 0 6px 0 12px; background: var(--im-field);
    border: 1px solid var(--im-line-strong); border-radius: var(--im-r-md); color: var(--im-muted);
    transition: border-color .12s, box-shadow .12s; }
.im-search-field:focus-within { border-color: var(--im-accent); box-shadow: 0 0 0 3px rgba(250,204,21,.18); }
.im-search-field > i { font-size: 14px; }
.im-search-field input { flex: 1; min-width: 0; height: 100%; background: transparent; border: 0; outline: 0; font-size: 14px; color: var(--im-text); }
.im-search-field input:focus-visible { outline: none; }
.im-search-field input::placeholder { color: var(--im-muted); }
.im-search-field input::-webkit-search-cancel-button { display: none; }
.im-search-field:focus-within .im-kbd, .im-search--filled .im-search-field .im-kbd { display: none; }

.im-results { position: absolute; top: 48px; left: 0; right: 0; max-height: min(60vh, 460px); overflow-y: auto;
    background: #0d1222; border: 1px solid var(--im-line-strong); border-radius: 12px; box-shadow: var(--im-shadow-3);
    padding: 6px; z-index: 45; animation: im-drop .14s var(--im-ease) both; scrollbar-width: thin; scrollbar-color: #2a3247 transparent; }
.im-results-label { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--im-muted); padding: 6px 8px 4px; }
.im-result { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 48px; padding: 6px 8px; border-radius: 8px;
    background: transparent; border: 0; text-align: left; }
.im-result:hover { background: var(--im-hover); }
.im-result.is-active { background: var(--im-accent-soft); box-shadow: inset 0 0 0 1px rgba(250,204,21,.45); }
.im-result-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.im-result-title { font-size: 14px; font-weight: 500; color: var(--im-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.im-result-meta { font-size: 12px; color: var(--im-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.im-result-right { font-family: var(--im-mono); font-size: 12px; color: var(--im-text-2); flex: none; }
.im-results-foot { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; padding: 8px 8px 4px; margin-top: 4px;
    border-top: 1px solid var(--im-line); font-size: 11px; color: var(--im-muted); }
.im-results-foot .im-kbd { margin: 0; height: 20px; min-width: 20px; }
.im-empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: 18px 14px 16px; }
.im-empty-ico { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: #161d33;
    color: var(--im-muted); flex: none; }
.im-empty-title { font-size: 14px; font-weight: 500; color: var(--im-text); }
.im-empty-text { font-size: 12px; color: var(--im-muted); max-width: 250px; }

/* "On the map" chips */
.im-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.im-chip { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 3px 0 9px; border-radius: 999px;
    background: var(--im-raised); border: 1px solid var(--im-line-strong); font-size: 12px; font-weight: 500; color: var(--im-text); }
.im-chip--more { padding: 0 10px; color: var(--im-muted); }
.im-chip-x { width: 22px; height: 22px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 50%;
    background: transparent; color: var(--im-muted); font-size: 11px; }
.im-chip-x:hover { background: rgba(255,255,255,.1); color: var(--im-text); }

/* Overlay toggles */
.im-toggles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.im-toggle { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; min-height: 58px;
    padding: 8px 2px; border-radius: var(--im-r-md); border: 1px solid var(--im-line); background: var(--im-field);
    color: var(--im-muted); font-size: 11.5px; font-weight: 500; line-height: 1.15; text-align: center; transition: all .12s; }
.im-toggle i { font-size: 15px; }
.im-toggle:hover { color: var(--im-text); border-color: var(--im-line-strong); }
.im-toggle[aria-pressed="true"] { color: var(--im-text); border-color: rgba(250,204,21,.55); background: var(--im-accent-soft); }
.im-toggle[aria-pressed="true"] i { color: var(--im-accent); }
.im-tiers { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.im-tier-key { display: flex; flex-direction: column; gap: 4px; font-size: 11px; color: var(--im-text-2); }
.im-tier-key span:first-child { height: 6px; border-radius: 3px; }

/* Marker groups + categories */
.im-groups { display: flex; flex-direction: column; padding: 4px 8px 8px; }
.im-group-head { display: flex; align-items: center; gap: 6px; padding-right: 6px; }
.im-group-toggle { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 8px;
    background: transparent; border: 0; border-radius: 8px; text-align: left; color: var(--im-text); }
.im-group-toggle:hover { background: var(--im-hover); }
.im-chev { width: 16px; font-size: 11px; color: var(--im-muted); transition: transform .15s var(--im-ease); }
.im-group-toggle[aria-expanded="false"] .im-chev { transform: rotate(-90deg); }
.im-group-name { flex: 1; font-size: 14px; font-weight: 500; }
.im-group-meta { font-size: 12px; color: var(--im-muted); font-variant-numeric: tabular-nums; }
.im-group-meta.is-on { color: var(--im-accent); }
.im-switch { position: relative; width: 34px; height: 20px; flex: none; padding: 0; border: 0; border-radius: 999px;
    background: #2a3247; transition: background .15s; }
.im-switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%;
    background: #c3c9d4; transition: transform .15s var(--im-ease), background .15s; }
.im-switch[aria-checked="true"] { background: var(--im-accent); }
.im-switch[aria-checked="true"]::after { transform: translateX(14px); background: #0a0e1c; }
.im-cats { list-style: none; margin: 0 0 6px; padding: 0 0 0 14px; }
.im-cats[hidden] { display: none; }
.im-cat { display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 8px; border-radius: 8px; cursor: pointer; color: var(--im-muted); }
.im-cat:hover { background: var(--im-hover); color: var(--im-text); }
.im-cat.is-on { color: var(--im-text); }
.im-check { appearance: none; -webkit-appearance: none; position: relative; width: 16px; height: 16px; margin: 0; flex: none;
    border: 1.5px solid #5b6579; border-radius: var(--im-r-xs); background: transparent; cursor: pointer; }
.im-check:checked { background: var(--im-accent); border-color: var(--im-accent); }
.im-check:checked::after { content: ""; position: absolute; left: 4px; top: 1px; width: 4px; height: 8px;
    border: solid #0a0e1c; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.im-cat-name { flex: 1; min-width: 0; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.im-count { min-width: 44px; text-align: right; font-size: 12px; font-variant-numeric: tabular-nums; color: var(--im-muted); }
.im-cat.is-on .im-count { color: var(--im-text-2); }

/* Loading skeleton (markers.json not in yet) */
.im-skel { display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 16px; }
.im-skel i { display: block; height: 12px; border-radius: 6px;
    background: linear-gradient(90deg, #161d33 0%, #1f2741 50%, #161d33 100%); background-size: 200% 100%;
    animation: im-shim 1.3s linear infinite; }
.im-spin { display: inline-block; width: 14px; height: 14px; border-radius: 50%; border: 2px solid rgba(250,204,21,.25);
    border-top-color: var(--im-accent); animation: im-spin .8s linear infinite; vertical-align: -2px; margin-right: 6px; }

/* My markers */
.im-mylist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.im-mylist:empty { display: none; }
.im-mymark { display: flex; align-items: center; gap: 10px; padding: 6px 4px 6px 10px; border-radius: var(--im-r-md);
    background: var(--im-field); border: 1px solid var(--im-line); }
.im-mydot { width: 12px; height: 12px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); flex: none; }
.im-mymain { flex: 1; min-width: 0; }
.im-myname { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.im-mymeta { font-size: 11px; color: var(--im-muted); font-family: var(--im-mono); }
.im-myempty { display: flex; gap: 12px; align-items: flex-start; padding: 12px; border: 1px dashed rgba(255,255,255,.18); border-radius: 10px; }
.im-myempty .im-empty-ico { width: 36px; height: 36px; }
.im-myempty .im-empty-text { text-align: left; }
.im-btnrow { display: flex; gap: 6px; }
.im-btnrow .im-btn { flex: 1; height: 34px; padding: 0 8px; }

/* Collapsed panel: one button in its place */
.im-fab { position: absolute; top: var(--im-inset); left: var(--im-inset); z-index: 20; display: flex; align-items: center; gap: 10px;
    height: 44px; padding: 0 8px 0 14px; border-radius: 12px; border: 1px solid var(--im-line); background: rgba(10,14,28,.94);
    box-shadow: var(--im-shadow-2); font-size: 14px; font-weight: 500; color: var(--im-text); }
.im-fab:hover { background: #121a30; }
.im-fab[hidden] { display: none; }
.im-fab i { color: var(--im-text-2); }
.im-fab__short { display: none; }

.im-scrim { display: none; }

/* ---------------------------------------------------------------- toolbar (top right) */

.im-tr { position: absolute; top: var(--im-inset); right: var(--im-inset); z-index: 22; display: flex; flex-direction: column;
    align-items: flex-end; gap: 10px; }
.im-dock { display: flex; flex-direction: column; gap: 2px; padding: 4px; background: rgba(10,14,28,.92); border: 1px solid var(--im-line);
    border-radius: 12px; box-shadow: var(--im-shadow-2); backdrop-filter: blur(8px); }
.im-dock--row { flex-direction: row; }
.im-dock-sep { height: 1px; background: var(--im-line); margin: 2px 6px; }
.im-tool { position: relative; width: var(--im-tool); height: var(--im-tool); display: grid; place-items: center; padding: 0; border: 0;
    border-radius: 9px; background: transparent; color: var(--im-text-2); font-size: 15px; transition: background .12s, color .12s; }
.im-tool:hover { background: var(--im-hover); color: var(--im-text); }
.im-tool:disabled { opacity: .35; cursor: default; background: transparent; }
.im-tool[aria-pressed="true"] { background: var(--im-accent); color: var(--im-accent-ink); }
.im-tool[data-tip]:hover::after, .im-tool[data-tip]:focus-visible::after {
    content: attr(data-tip); position: absolute; right: calc(100% + 10px); top: 50%; transform: translateY(-50%); white-space: nowrap;
    background: #e5e7eb; color: #0a0e1c; font-family: var(--im-font); font-size: 12px; font-weight: 500; padding: 5px 8px;
    border-radius: var(--im-r-sm); box-shadow: var(--im-shadow-2); pointer-events: none; }
.im-layer { display: flex; align-items: center; gap: 8px; height: var(--im-tool); padding: 0 12px 0 6px; border: 0; border-radius: 9px;
    background: transparent; color: var(--im-text-2); font-size: 13px; font-weight: 500; white-space: nowrap; transition: background .12s, color .12s; }
.im-layer:hover { background: var(--im-hover); color: var(--im-text); }
.im-layer[aria-pressed="true"] { background: var(--im-accent-soft); color: var(--im-text); box-shadow: inset 0 0 0 1px rgba(250,204,21,.6); }
.im-layer-sw { position: relative; width: 28px; height: 28px; border-radius: var(--im-r-sm); overflow: hidden; flex: none;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.15); background: var(--sw1); }
.im-layer-sw::before { content: ""; position: absolute; left: 4px; top: 7px; width: 18px; height: 12px; border-radius: 50%; background: var(--sw2); }
.im-layer-sw::after { content: ""; position: absolute; left: -2px; top: 18px; width: 34px; height: 2px; transform: rotate(-20deg); background: var(--sw3); }

/* ---------------------------------------------------------------- floating status */

.im-hint { position: absolute; top: var(--im-inset); left: 50%; transform: translateX(-50%); z-index: 24; display: flex; align-items: center;
    gap: 10px; height: 44px; padding: 0 6px 0 14px; border-radius: 12px; background: rgba(10,14,28,.94);
    border: 1px solid rgba(250,204,21,.4); box-shadow: var(--im-shadow-2); font-size: 13px; white-space: nowrap; }
.im-hint[hidden] { display: none; }
.im-hint > i { color: var(--im-accent); }
.im-hint strong { font-family: var(--im-mono); font-weight: 500; color: var(--im-accent); }
.im-hint strong:empty { display: none; }
.im-hint .im-btn { height: 32px; }
.im-hint .im-link { margin: 0; }

.im-readout { position: absolute; bottom: var(--im-inset); left: var(--im-inset); z-index: 18; display: flex; align-items: stretch; height: 38px;
    background: rgba(10,14,28,.92); border: 1px solid var(--im-line); border-radius: var(--im-r-md); box-shadow: var(--im-shadow-2);
    max-width: calc(100% - 24px - 160px - 24px); overflow: hidden; }
.im-rcell { display: flex; align-items: center; gap: 6px; padding: 0 12px; border-left: 1px solid var(--im-line); white-space: nowrap; }
.im-rcell:first-child { border-left: 0; }
.im-rcell--scale { flex-direction: column; align-items: flex-start; justify-content: center; gap: 2px; }
.im-rcell--centre i { color: var(--im-muted); font-size: 11px; }
.im-rl { font-size: 11px; font-weight: 500; letter-spacing: .06em; text-transform: uppercase; color: var(--im-muted); }
.im-rv { font-family: var(--im-mono); font-size: 13px; color: var(--im-text); font-variant-numeric: tabular-nums; }
.im-rv--accent { color: var(--im-accent); }
.im-scalebar { display: block; height: 7px; border: 2px solid var(--im-text); border-top: 0; }
.im-scale-l { font-family: var(--im-mono); font-size: 11px; }

.im-legend { position: absolute; bottom: 60px; left: var(--im-inset); width: 224px; z-index: 18; padding: 10px 12px 8px;
    background: rgba(10,14,28,.92); border: 1px solid var(--im-line); border-radius: 12px; box-shadow: var(--im-shadow-2); }
.im-legend[hidden] { display: none; }
.im-legend-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.im-legend ul { list-style: none; margin: 0; padding: 0; }
.im-legend li { display: flex; align-items: center; gap: 8px; height: 24px; font-size: 12px; color: var(--im-text-2); }
.im-legend li .im-dot { width: 10px; height: 10px; }
.im-legend li span:nth-child(2) { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.im-legend li span:last-child { font-variant-numeric: tabular-nums; color: var(--im-muted); }
.im-legend-more { padding: 2px 0 2px 18px; }
/* With the panel open the bottom-left chrome starts right of it. */
.im-shell:not(.im-shell--closed) .im-readout,
.im-shell:not(.im-shell--closed) .im-legend { left: calc(var(--im-panel-w) + 2 * var(--im-inset)); }
.im-shell:not(.im-shell--closed) .im-readout { max-width: calc(100% - var(--im-panel-w) - 160px - 4 * var(--im-inset)); }

.im-ov { position: absolute; right: var(--im-inset); bottom: var(--im-inset); z-index: 18; width: 160px; height: 160px;
    border: 1px solid var(--im-line-strong); border-radius: 12px; overflow: hidden; box-shadow: var(--im-shadow-2); }

.im-toast { position: absolute; left: 50%; bottom: 64px; transform: translateX(-50%); z-index: 60; display: flex; align-items: center; gap: 8px;
    min-height: 42px; max-width: calc(100% - 24px); padding: 8px 16px 8px 12px; border-radius: var(--im-r-md); background: #e5e7eb; color: #0a0e1c;
    font-size: 14px; font-weight: 500; box-shadow: var(--im-shadow-3); animation: im-rise .2s var(--im-ease) both; }
.im-toast[hidden] { display: none; }
.im-toast i { color: #15803d; }

/* ---------------------------------------------------------------- map layers: labels, pins, tips */

.im-canvas { pointer-events: none; }      /* points and outlines are canvases; hit tests run in script */
.im-gridlabel-icon { background: transparent; border: 0; pointer-events: none; }
.im-gridlabel { display: inline-block; font-family: var(--im-mono); font-size: 11px; font-weight: 500; color: #e5e7eb;
    background: rgba(10,14,28,.78); padding: 1px 5px; border-radius: var(--im-r-xs); white-space: nowrap; }
.im-shell[data-base="paper"] .im-gridlabel, .im-shell[data-base="topo"] .im-gridlabel { color: #2b2112; background: rgba(255,250,235,.8); }
/* The paper map prints its own place names; ours would sit on top of them. */
.im-shell[data-base="paper"] .dz-loc-icon { display: none; }

.im-mypin-icon { background: transparent; border: 0; }
.im-mypin { display: block; width: 24px; height: 24px; border: 2px solid #0a0e1c; border-radius: 50% 50% 50% 0; transform: rotate(-45deg);
    background: var(--c); box-shadow: 0 3px 8px rgba(0,0,0,.55); position: relative; }
.im-mypin::after { content: ""; position: absolute; left: 6px; top: 6px; width: 8px; height: 8px; border-radius: 50%; background: #0a0e1c; }

.im-shell .leaflet-tooltip { background: rgba(10,14,28,.95); color: var(--im-text); border: 1px solid var(--im-line-strong);
    border-radius: var(--im-r-sm); box-shadow: var(--im-shadow-2); font-family: var(--im-font); font-size: 12px; font-weight: 500; padding: 4px 8px; }
.im-shell .leaflet-tooltip-top::before { border-top-color: rgba(10,14,28,.95); }
.im-shell .im-measure-tip, .im-shell .im-hl-tip { background: var(--im-accent); color: #0a0e1c; border: 0; font-family: var(--im-mono);
    font-weight: 500; box-shadow: var(--im-shadow-1); }
.im-shell .im-measure-tip::before { display: none; }
.im-shell .im-hl-tip { font-family: var(--im-font); font-weight: 700; }
.im-shell .im-hl-tip.leaflet-tooltip-top::before { border-top-color: var(--im-accent); }

/* ---------------------------------------------------------------- the point card (popup / phone sheet) */

.im-shell .im-popup .leaflet-popup-content-wrapper { padding: 0; background: #0d1222; color: var(--im-text); border: 1px solid var(--im-line-strong);
    border-radius: var(--im-r-lg); box-shadow: var(--im-shadow-3); overflow: hidden; }
.im-shell .im-popup .leaflet-popup-content { margin: 0; width: 300px !important; font-size: 14px; line-height: 1.4; }
.im-shell .im-popup .leaflet-popup-tip { background: #0d1222; box-shadow: none; border: 1px solid var(--im-line-strong); }
.im-shell .im-popup { animation: im-drop .16s var(--im-ease) both; }

.im-card__strip { height: 4px; background: var(--c); }
.im-card__head { display: flex; align-items: flex-start; gap: 12px; padding: 12px 8px 8px 14px; }
.im-card__titles { flex: 1; min-width: 0; }
.im-kicker { display: flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--im-muted); }
.im-card__title { margin: 2px 0 0; font-size: 16px; line-height: 1.25; font-weight: 700; color: var(--im-text); overflow-wrap: anywhere; }
.im-card__pic { margin: 0 14px 12px; border-radius: var(--im-r-md); overflow: hidden;
  background: radial-gradient(ellipse at 50% 35%, #2a3350 0%, #121729 75%); aspect-ratio: 16 / 10; }
.im-card__pic img { display: block; width: 100%; height: 100%; object-fit: contain; }
.im-card__near { display: flex; align-items: center; gap: 6px; padding: 0 14px 12px; font-size: 13px; color: var(--im-text-2); }
.im-card__near i { font-size: 12px; color: var(--im-muted); }
.im-coords { margin: 0 14px; border: 1px solid var(--im-line); border-radius: var(--im-r-md); overflow: hidden; }
.im-coords__main { display: flex; align-items: center; gap: 8px; padding: 8px 6px 8px 12px; background: #0a0f1d; }
.im-coords__main > div { flex: 1; }
.im-coords__val { font-family: var(--im-mono); font-size: 15px; color: var(--im-text); font-variant-numeric: tabular-nums; white-space: pre; }
.im-coords__grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border-top: 1px solid var(--im-line); }
.im-coords__grid > div { padding: 7px 12px; }
.im-coords__grid > div + div { border-left: 1px solid var(--im-line); }
.im-card__foot { display: flex; gap: 8px; padding: 12px 14px 14px; }
.im-card__foot .im-btn { flex: 1; height: 38px; }
.im-card__form { display: flex; flex-direction: column; gap: 8px; padding: 0 14px 12px; }
.im-card__form input[type="text"] { width: 100%; height: 38px; padding: 0 10px; border-radius: var(--im-r-md); background: var(--im-field);
    border: 1px solid var(--im-line-strong); color: var(--im-text); font-size: 14px; outline: none; }
.im-card__form input[type="text"]:focus { border-color: var(--im-accent); box-shadow: 0 0 0 3px rgba(250,204,21,.18); }
.im-colors { display: flex; gap: 6px; }
.im-colors button { width: 22px; height: 22px; border-radius: 50%; border: 2px solid transparent; box-shadow: inset 0 0 0 1px rgba(0,0,0,.3); }
.im-colors button.is-on { border-color: #fff; }

/* Phone: the card is a bottom sheet instead of a popup. */
.im-sheet { position: absolute; left: 0; right: 0; bottom: 0; z-index: 50; max-height: 80%; overflow-y: auto;
    background: #0d1222; border-top: 1px solid var(--im-line-strong); border-radius: var(--im-r-xl) var(--im-r-xl) 0 0;
    box-shadow: 0 -12px 40px rgba(0,0,0,.55); animation: im-up .24s var(--im-ease) both; }
.im-sheet[hidden] { display: none; }
.im-sheet .im-card__strip { border-radius: var(--im-r-xl) var(--im-r-xl) 0 0; }
.im-grab { position: absolute; top: 4px; left: 50%; transform: translateX(-50%); display: block; width: 88px; height: 20px;
    padding: 0; border: 0; background: transparent; }
.im-sheet .im-card__head { padding-top: 22px; }
.im-grab span { display: block; width: 40px; height: 4px; margin: 0 auto; border-radius: 2px; background: #3a4258; }

/* ---------------------------------------------------------------- motion */

@keyframes im-drop { from { opacity: 0; transform: translateY(-4px); } }
@keyframes im-rise { from { opacity: 0; transform: translate(-50%, 8px); } }
@keyframes im-slide { from { opacity: 0; transform: translateX(-12px); } }
@keyframes im-up { from { transform: translateY(40px); opacity: 0; } }
@keyframes im-bar { 0% { transform: translateX(-100%); } 100% { transform: translateX(260%); } }
@keyframes im-shim { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@keyframes im-spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- phones */

@media (max-width: 767px) {
    .im-shell { font-size: 15px; height: calc(100vh - 4rem - 1px); height: calc(100dvh - 4rem - 1px); }

    /* The panel becomes a drawer over a scrim. */
    .im-scrim { display: block; position: absolute; inset: 0; z-index: 25; background: rgba(0,0,12,.62); }
    .im-panel { top: 0; left: 0; bottom: 0; width: min(336px, 86vw); z-index: 30; background: var(--im-surface);
        border: 0; border-right: 1px solid var(--im-line-strong); border-radius: 0 var(--im-r-xl) var(--im-r-xl) 0; backdrop-filter: none;
        animation: im-in .22s var(--im-ease) both; }
    .im-panel__head { border-bottom: 0; padding: 12px 8px 4px 18px; }
    .im-search { margin-right: 8px; }
    .im-search-field { height: 48px; border-radius: 12px; padding: 0 6px 0 14px; }
    .im-search-field input { font-size: 16px; }   /* 16px: iOS does not zoom the page on focus */
    .im-search-field .im-kbd { display: none; }
    .im-iconbtn { width: 44px; height: 44px; }
    .im-panel__body { border-top: 1px solid var(--im-line); border-radius: 0; }
    .im-panel__foot { display: block; padding: 12px 16px 16px; border-top: 1px solid var(--im-line); }
    .im-panel__foot .im-btn { width: 100%; height: 48px; font-size: 15px; }
    .im-link { min-height: 44px; margin: -12px -8px; padding: 0 8px; font-size: 13px; }
    .im-chips { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px; padding: 0 16px 2px; scrollbar-width: none; }
    .im-chip { height: 36px; padding: 0 4px 0 12px; font-size: 13px; white-space: nowrap; flex: none; }
    .im-chip-x { width: 28px; height: 28px; }
    .im-toggles { gap: 8px; }
    .im-toggle { min-height: 60px; border-radius: 12px; }
    .im-group-toggle { height: 46px; }
    .im-switch { width: 44px; height: 26px; }
    .im-switch::after { top: 4px; left: 4px; width: 18px; height: 18px; }
    .im-switch[aria-checked="true"]::after { transform: translateX(18px); }
    .im-cat { height: 46px; gap: 12px; padding: 0 10px; border-radius: 10px; }
    .im-check { width: 20px; height: 20px; border-radius: 5px; }
    .im-check:checked::after { left: 6px; top: 2px; width: 5px; height: 10px; }
    .im-btnrow .im-btn { height: 44px; }

    /* Closed: one button bottom left; tools bottom right; position chip top left. */
    .im-fab { top: auto; bottom: 16px; height: 48px; padding: 0 10px 0 16px; font-size: 15px; border-radius: 14px; }
    .im-fab__long { display: none; }
    .im-fab__short { display: inline; }
    .im-tr { top: auto; bottom: 16px; }
    .im-dock { border-radius: 14px; }
    .im-layer { width: var(--im-tool); padding: 0; justify-content: center; }
    .im-layer__label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
    .im-tool[data-tip]:hover::after { display: none; }

    .im-readout, .im-shell:not(.im-shell--closed) .im-readout { top: var(--im-inset); bottom: auto; left: var(--im-inset); height: 32px;
        max-width: calc(100% - 24px); border-radius: 999px; }
    .im-rcell { padding: 0 10px; border-left: 0; }
    .im-rcell--scale, .im-rcell--alt { display: none; }
    .im-rv { font-size: 12px; }
    .im-legend, .im-ov { display: none; }
    .im-hint { top: 56px; max-width: calc(100% - 24px); }
    .im-hint span { overflow: hidden; text-overflow: ellipsis; }
    .im-toast { bottom: 80px; }
}
@keyframes im-in { from { transform: translateX(-24px); opacity: 0; } }
