/* WindCircles — layout and map overlays (stage 1b). Colours come from css/theme.css (--t-*).
   The map drawing labels at the end follow the house style (fonts, radius, theme colours). */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; line-height: 1.5; }
body { min-height: 100dvh; }
[hidden] { display: none !important; }
.hidden { display: none !important; }
:root { --map-label-size: 16px; --rail-w: 1.9rem; --sidebar-w: 19rem; }

/* roles */
body.role-viewer .admin-only { display: none !important; }
body:not(.role-viewer) .viewer-only { display: none !important; }
.topbar .off-tab { display: none; }

/* content column (same max-width and side padding as the tab bar) */
.content { width: 100%; max-width: min(1680px, 100%); margin: 0 auto; padding: 0 1.5rem 1.25rem; box-sizing: border-box; }
.page-sub { padding-bottom: 2rem; }

/* ================= login card (AeroLedger pattern, house style §login) =================
   No banner on the login view; the card is centred on the page: brand (mark + title + subtitle),
   a tab strip on a 2px rule, the form, and the copyright line under a 1px rule. No "Create account". */
body.is-auth .topbar { display: none; }
body.is-auth .content { padding: 0 1rem; }
.page-auth { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 2rem 0; }
.auth-card { width: 100%; max-width: 420px; margin: 0 auto; padding: 1.5rem; }
html[data-theme="light"] .auth-card { box-shadow: 0 1px 0 rgba(0, 0, 0, 0.04), 0 10px 30px rgba(43, 45, 48, 0.08); }
html[data-theme="dark"] .auth-card { box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35); }
.auth-brand { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1.1rem; }
.auth-brand .brand-mark { width: 2.6rem; height: 2.6rem; font-size: 0.95rem; flex: 0 0 auto; }
.auth-brand h1 { margin: 0; font-family: var(--tech); font-weight: 700; letter-spacing: 0.2em; text-transform: uppercase; color: var(--t-strong); line-height: 1.15; }
.auth-brand .auth-sub { margin: 0.15rem 0 0; color: var(--t-muted); font-size: 0.9rem; }
.auth-tabs { display: flex; gap: 0.3rem; margin-bottom: 1rem; border-bottom: 2px solid var(--t-strong); }
.auth-tab {
  display: inline-block; padding: 0.55rem 1.1rem; border-radius: var(--radius) var(--radius) 0 0;
  font-family: var(--cond); font-size: 0.9rem; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--t-strong);
}
.auth-tab.active { background: var(--t-strong); color: var(--t-page); }
.auth-form > label:first-child { margin-top: 0; }
.site-copyright { margin: 1.5rem 0 0; padding-top: 1rem; border-top: 1px solid var(--t-line); text-align: center; font-size: 0.72rem; color: var(--t-muted); line-height: 1.4; }
.auth-form > .btn-primary, .auth-form > .btn-row { margin-top: 0.9rem; }
.pw-rules { list-style: none; margin: 0.7rem 0 0; padding: 0; font-size: 0.85rem; color: var(--t-muted); }
.pw-rules li { padding-left: 1.4rem; position: relative; margin: 0.15rem 0; }
.pw-rules li::before { content: "○"; position: absolute; left: 0.1rem; }
.pw-rules li.ok { color: var(--t-ok); }
.pw-rules li.ok::before { content: "✓"; font-weight: 700; }
.pw-rules li.bad { color: var(--t-danger); }
.pw-rules li.bad::before { content: "✗"; font-weight: 700; }

/* ================= settings / admin ================= */
.settings-card { max-width: 46rem; }
.setting-row { margin-bottom: 1rem; }
.setting-row > label:first-child, .setting-row > .field-label:first-child { margin-top: 0; }
.setting-row select { max-width: 22rem; }
.units-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 0 1.2rem; }
.units-grid .setting-row { margin-bottom: 0.4rem; }
#page-admin .card { max-width: 72rem; }
.settings-card-wide { max-width: 72rem; margin-bottom: 1rem; }
.mapdata-url { font-size: 0.75rem; overflow-wrap: anywhere; color: var(--t-muted); }
.mapdata-licences { margin: 0.3rem 0 0; padding-left: 1.1rem; }
.mapdata-licences li { margin-bottom: 0.6rem; }
.mapdata-licences .hint { margin: 0.15rem 0 0; display: inline-block; }
.badge-online { background: var(--t-accent-soft); border-color: var(--t-accent); color: var(--t-accent-ink); }
.badge-offline { background: var(--t-ok-soft); border-color: var(--t-ok); color: var(--t-ok); }
.data-table .empty-row td { color: var(--t-muted); font-style: italic; }
.mapdata-manage { margin-top: 0.6rem; padding-top: 0.5rem; border-top: 1px dashed var(--t-line); }

/* ================= map page: full height under the header and tabs, and FULL WIDTH =================
   House style §map: the Map tab ignores the content column (no max-width, no side padding) and runs edge to
   edge down to the bottom of the window. The tab bar above it keeps the column, like on every other tab. */
body[data-tab="map"] { overflow: hidden; }
body[data-tab="map"] .content { max-width: none; padding: 0; }
.page-map { height: calc(100dvh - var(--wc-topbar-h, 56px) - var(--wc-tabbar-h, 48px)); padding: 0.6rem 0 0; }
.page-map .map-shell { border-width: 1px 0 0; border-radius: 0; }
.map-shell {
  position: relative; height: 100%; display: flex; min-height: 22rem;
  border: 1px solid var(--t-line); border-radius: var(--radius); overflow: hidden; background: var(--t-panel);
}
.sidebar { position: relative; flex: 0 0 auto; display: flex; width: calc(var(--sidebar-w) + var(--rail-w)); background: var(--t-panel); border-right: 1px solid var(--t-line); z-index: 1150; }
.sidebar-body { width: var(--sidebar-w); overflow-y: auto; padding: 0.6rem; display: flex; flex-direction: column; gap: 0.6rem; }
.sidebar-body .panel { padding: 0.7rem 0.8rem; }
.sidebar-body .panel h2 { margin: 0 0 0.2rem; font-size: 0.95rem; }
.sidebar-body label { margin-top: 0.5rem; }
.sidebar-rail {
  width: var(--rail-w); flex: 0 0 var(--rail-w); border: 0; border-left: 1px solid var(--t-line);
  background: var(--t-soft); color: var(--t-strong); cursor: pointer; display: flex; align-items: flex-start; justify-content: center; padding-top: 0.7rem;
}
.sidebar-rail:hover { background: var(--t-soft-2); }
.map-shell.sidebar-closed .sidebar { width: var(--rail-w); }
.map-shell.sidebar-closed .sidebar-body { display: none; }
.map-shell.sidebar-closed .sidebar-rail { border-left: 0; }
.sidebar-backdrop { display: none; }
.check-row { display: flex !important; align-items: center; gap: 0.5rem; font-weight: 400 !important; font-size: 0.9rem !important; color: var(--t-ink) !important; margin: 0.35rem 0 !important; cursor: pointer; }
.param-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 0 0.6rem; }
.param-columns [hidden] { display: none !important; }
.export-tick-row input { width: 5.5rem; }
.param-columns label input { margin-top: 0.25rem; font-weight: 400; }

.map-wrap { position: relative; flex: 1 1 auto; min-width: 0; }
#map { position: absolute; inset: 0; background: #1e2a3a; font-family: var(--cond); }

/* tablet / phone: the options slide over the map from the rail */
@media (max-width: 900px) {
  .sidebar { position: absolute; top: 0; bottom: 0; left: 0; width: min(calc(var(--sidebar-w) + var(--rail-w)), 92%); box-shadow: 4px 0 18px rgba(0, 0, 0, 0.25); }
  .sidebar-body { flex: 1 1 auto; width: auto; }
  .map-shell.sidebar-closed .sidebar { box-shadow: none; }
  .map-wrap { margin-left: var(--rail-w); }
  .sidebar-backdrop { display: block; position: absolute; inset: 0; z-index: 1140; background: transparent; }
}

/* fullscreen of the map area */
.map-shell:fullscreen { border: 0; border-radius: 0; }
.map-shell.fs-fallback { position: fixed; inset: 0; z-index: 2500; border: 0; border-radius: 0; height: 100dvh; }
body.fs-active { overflow: hidden; }
/* full screen (real or CSS): no page scrolling, overscroll glow, pull-to-refresh or scroll chaining; the map takes
   every touch (Leaflet pans and pinch-zooms itself). */
html.wc-fs, html.wc-fs body { overscroll-behavior: none; overflow: hidden; }
html.wc-fs #map, html.wc-fs .map-wrap { touch-action: none; }
.map-shell.fs-fallback { overscroll-behavior: none; }
/* full screen: the side pane is hidden and the map takes the whole screen; the burger floats top left (44 px, touch)
   and opens the pane over the map. */
.map-shell.fs-on .map-wrap { margin-left: 0; }
.map-shell.fs-on .sidebar { position: absolute; top: 0; bottom: 0; left: 0; width: min(calc(var(--sidebar-w) + var(--rail-w)), 92%); box-shadow: 4px 0 18px rgba(0, 0, 0, 0.25); }
.map-shell.fs-on .sidebar-body { flex: 1 1 auto; width: auto; }
.map-shell.fs-on.sidebar-closed .sidebar { top: 10px; left: 10px; bottom: auto; width: auto; background: transparent; border: 0; box-shadow: none; }
.map-shell.fs-on.sidebar-closed .sidebar-rail {
  width: 44px; height: 44px; flex: 0 0 44px; padding: 0; align-items: center; border: 1px solid var(--t-line);
  border-radius: var(--radius); background: var(--t-panel); box-shadow: 0 1px 5px rgba(0, 0, 0, 0.35);
}
.map-shell.fs-on.sidebar-closed .map-tool-col { top: 64px; }

/* ================= map overlays (themed) ================= */
.map-tool-col {
  position: absolute; top: 10px; left: 10px; z-index: 1000; display: flex; flex-direction: column;
  border-radius: var(--radius); overflow: hidden; border: 1px solid var(--t-line); box-shadow: 0 1px 5px rgba(0, 0, 0, 0.35);
}
.map-tool-btn {
  width: 34px; height: 34px; padding: 0; border: 0; border-bottom: 1px solid var(--t-line);
  background: var(--t-panel); color: var(--t-strong); font-size: 1.2rem; font-weight: 700; font-family: var(--cond); line-height: 1;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.map-tool-btn:last-child { border-bottom: 0; }
.map-tool-btn:hover { background: var(--t-soft); }
.map-tool-btn svg { display: block; }
.map-tool-mgrs { font-size: 0.55rem; font-weight: 800; letter-spacing: 0.02em; }
/* active toggles (MGRS, call-outs, info, full screen while active): the same fill and ink as a selected sub-tab */
.map-tool-btn.active, .map-tool-btn[aria-pressed="true"], .map-tool-btn.active:hover { background: var(--t-sub-on-bg); color: var(--t-sub-on-ink); }
.map-tool-btn:disabled, .map-tool-btn:disabled:hover { background: var(--t-panel); color: var(--t-muted); opacity: 0.5; cursor: not-allowed; }
/* track-up: the map element is turned (js/map.js); the frame around it clips the corners */
.map-wrap { overflow: hidden; }
.wc-map-controls { position: absolute; inset: 0; z-index: 400; pointer-events: none; background: transparent; outline: none; }
.map-north {
  position: absolute; top: 10px; left: 54px; z-index: 1000; width: 34px; height: 44px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--t-panel); color: var(--t-strong); border: 1px solid var(--t-line); border-radius: var(--radius); box-shadow: 0 1px 5px rgba(0, 0, 0, 0.35); pointer-events: none;
}
.map-north[hidden] { display: none; }
.map-north svg { transform: rotate(var(--wc-north, 0deg)); transition: transform 0.2s; }
.map-north span { font-family: var(--cond); font-size: 0.62rem; font-weight: 800; line-height: 1; margin-top: -1px; }
/* Settings > Display preview toggles (same buttons and active fill as the map toolbar) */
.pv-tools { display: inline-flex; border: 1px solid var(--t-line); border-radius: var(--radius); overflow: hidden; margin-left: auto; margin-right: 0.75rem; }
.pv-tools .map-tool-btn { width: auto; height: 28px; padding: 0 0.6rem; gap: 0.35rem; border-bottom: 0; border-right: 1px solid var(--t-line); font-size: 0.72rem; font-weight: 700; letter-spacing: 0.02em; }
.pv-tools .map-tool-btn:last-child { border-right: 0; }
.map-shell.info-off :is(.dz-card, .map-coords) { display: none !important; }
.map-shell.info-off .dz-marker { display: none !important; }   /* stage 4h.3: the "i" button also hides the PI and IP labels */
.leaflet-top.leaflet-left { display: none; }

.map-type-control {
  position: absolute; bottom: 0.45rem; left: 0.75rem; z-index: 1000; display: flex;
  background: var(--t-panel); border: 1px solid var(--t-line); border-radius: var(--radius); overflow: hidden; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}
.map-type-btn { border: 0; border-right: 1px solid var(--t-line); padding: 0.4rem 0.7rem; font-size: 0.82rem; font-weight: 600; font-family: var(--cond); background: transparent; color: var(--t-strong); cursor: pointer; white-space: nowrap; }
.map-type-btn:last-child { border-right: 0; }
.map-type-btn:hover { background: var(--t-soft); }
.map-type-btn.active { background: var(--t-strong); color: var(--t-page); }

.map-card, .map-coords {
  position: absolute; z-index: 1000; background: var(--t-overlay); color: var(--t-ink);
  border: 1px solid var(--t-line); border-radius: var(--radius); box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
}
.map-coords { bottom: 2.95rem; left: 0.75rem; display: flex; flex-direction: column; gap: 0.15rem; max-width: calc(100% - 1.5rem); padding: 0.3rem 0.55rem; font-family: var(--tech); font-size: 0.72rem; pointer-events: none; }
.map-coords-row { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.map-coords-label { font-family: var(--cond); font-size: 0.65rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--t-muted); }
.coords-sep { color: var(--t-line); }
.leaflet-container .leaflet-control-attribution { font-family: var(--cond); font-size: 0.7rem; max-width: var(--wc-attr-max, 40vw); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.leaflet-container .leaflet-control-attribution:hover { white-space: normal; }
.leaflet-bottom.leaflet-right { margin-bottom: 0.25rem; }

.map-card { padding: 0.55rem 0.8rem; font-size: 0.8rem; }
.map-card-title { font-weight: 600; margin-bottom: 0.35rem; color: var(--t-muted); text-transform: uppercase; letter-spacing: 0.05em; font-size: 0.68rem; }
.dz-card { top: 0.75rem; right: 0.75rem; min-width: 14rem; max-width: 18rem; }
.dz-card-name { font-size: 0.95rem; font-weight: 600; color: var(--t-accent-ink); margin-bottom: 0.4rem; line-height: 1.2; overflow-wrap: anywhere; }
.dz-card-params { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 0.2rem 0.65rem; }
.dz-card-params dt { color: var(--t-muted); font-weight: 600; }
.dz-card-params dd { margin: 0; font-family: var(--tech); font-size: 0.75rem; text-align: right; }
.dz-card-edits { display: grid; grid-template-columns: 1fr 1fr; gap: 0.45rem; margin-top: 0.5rem; padding-top: 0.45rem; border-top: 1px solid var(--t-line); }
.dz-card-edits label { margin: 0; font-size: 0.7rem; color: var(--t-muted); }
.dz-card-edits input { padding: 0.25rem 0.4rem; font-size: 0.85rem; margin-top: 0.15rem; }
.map-context-menu { position: fixed; z-index: 2000; min-width: 10rem; background: var(--t-panel); border: 1px solid var(--t-line); border-radius: var(--radius); box-shadow: var(--t-dialog-shadow); overflow: hidden; }
.context-menu-item { display: block; width: 100%; padding: 0.55rem 0.85rem; border: 0; background: transparent; color: var(--t-ink); font-family: var(--cond); font-size: 0.9rem; text-align: left; cursor: pointer; }
.context-menu-item:hover { background: var(--t-soft); color: var(--t-accent-ink); }

#map.survey-active { cursor: crosshair; }
.survey-hint { position: fixed; bottom: 1.25rem; left: 50%; transform: translateX(-50%); z-index: 2600; padding: 0.55rem 1.1rem; background: #fbbf24; color: #1a1200; border: 2px solid #b45309; border-radius: var(--radius); font-size: 0.85rem; font-weight: 700; letter-spacing: 0.02em; text-transform: uppercase; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45); pointer-events: none; }
.touch-map-hint { display: none; position: absolute; bottom: 4.6rem; left: 50%; transform: translateX(-50%); z-index: 900; padding: 0.3rem 0.7rem; background: var(--t-overlay); color: var(--t-muted); border: 1px solid var(--t-line); border-radius: var(--radius); font-size: 0.78rem; pointer-events: none; white-space: nowrap; }
@media (hover: none) and (pointer: coarse) { .touch-map-hint { display: block; } }
/* stage 4g: fades out 3 s after the Map tab opens (js/shell.js showMapHint), then hidden */
.touch-map-hint { opacity: 1; transition: opacity 0.9s ease-in-out, transform 0.9s ease-in-out; }
.touch-map-hint.is-faded { opacity: 0; transform: translateX(-50%) translateY(0.35rem); }
.touch-map-hint.is-gone { visibility: hidden; }

/* dialogs from the original app */
.modal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 0.75rem; }
.modal-check-row { display: flex; gap: 1.2rem; }
.form-error { color: var(--t-danger); font-size: 0.85rem; min-height: 1.2em; }
.dz-list-wrap { max-height: 60dvh; overflow: auto; padding: 0.6rem 1rem 0; }
.dz-list-table tbody tr { cursor: pointer; }
.dz-list-table td:first-child { font-weight: 600; color: var(--t-accent-ink); }

@media (max-width: 768px) {
  .content { padding: 0 0.75rem 0.75rem; }
  .dz-card { top: 0.5rem; right: 0.5rem; max-width: 13rem; font-size: 0.72rem; }
  .map-coords { left: 0.5rem; }
  .brand-text .user-name { max-width: 11rem; }
}

/* ================= map drawing labels — house style (round 3b) =================
   Fonts from the house type scale: --cond for labels and call-outs, --tech (mono) for times and grid references.
   Text labels keep the colour of the line they belong to and get a dark halo, so they stay readable on the
   street map, the terrain map and satellite imagery in both themes. Boxes (PI/IP pins, call-outs, MGRS tags)
   use the house radius and the theme's panel / ink / strong colours. Size: --map-label-size (sidebar). */
.map-label-text {
  font-size: var(--map-label-size); font-weight: 700; font-family: var(--cond); letter-spacing: 0.02em; white-space: nowrap;
  text-shadow: 0 0 2px var(--wc-halo, #000), 0 0 3px var(--wc-halo, #000), 0 1px 3px var(--wc-halo, rgba(0, 0, 0, 0.9));
}
.circle-label .map-label-text { color: var(--wc-text-ring, #4ade80); }
.radial-label .map-label-text { color: var(--wc-text-radial, #00ffff); }
.runin-label .map-label-text { color: var(--wc-text-nm, #fff); }
.tot-label-marker { background: transparent !important; border: none !important; width: auto !important; height: auto !important; }
.tot-label-offset { display: inline-block; color: var(--wc-text-tot, #fbbf24); font-family: var(--tech); font-weight: 600; letter-spacing: 0; }
.dz-marker { background: transparent !important; border: none !important; }
#map.hide-pi-ip .dz-marker { display: none !important; }   /* stage 4g: Display › IP and PI labels off */
.dz-pin {
  display: inline-block; color: var(--wc-pin-text, #fff); padding: 2px 7px; border-radius: var(--radius); border: 1px solid rgba(255, 255, 255, 0.85);
  letter-spacing: 0.06em; text-shadow: 0 1px 1px rgba(0, 0, 0, 0.5); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
}
.mgrs-label .map-label-text { font-family: var(--tech); font-weight: 600; }
#map[data-map-layer="roadmap"] .mgrs-label .map-label-text,
#map[data-map-layer="topo"] .mgrs-label .map-label-text { color: #1e3a5f; text-shadow: 0 0 2px #fff, 0 0 4px #fff, 0 1px 2px rgba(255, 255, 255, 0.9); }
#map[data-map-layer="satellite"] .mgrs-label .map-label-text,
#map[data-map-layer="hybrid"] .mgrs-label .map-label-text { color: #fbbf24; text-shadow: 0 0 3px #000, 0 1px 3px #000; }
.callout-marker { background: transparent !important; border: none !important; width: auto !important; height: auto !important; }
.callout-wrap { display: flex; flex-direction: column; align-items: center; width: max-content; transform: translate(-50%, 0); pointer-events: none; }
.callout-bubble {
  display: inline-block; background: var(--wc-callout-fill, var(--t-panel)); color: var(--wc-callout-text, var(--t-ink)); border: 2px solid var(--wc-callout-border, var(--t-strong)); border-radius: var(--radius);
  padding: 3px 10px; font-family: var(--cond); font-size: var(--map-label-size); font-weight: 700; letter-spacing: 0.02em; line-height: 1.2;
  white-space: nowrap; box-sizing: border-box; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45); overflow: visible;
}
.callout-tail { width: 0; height: 0; flex-shrink: 0; border-left: 6px solid transparent; border-right: 6px solid transparent; border-top: 8px solid var(--wc-callout-border, var(--t-strong)); }
.mgrs-gzd-marker, .mgrs-100km-marker { background: transparent !important; border: none !important; width: auto !important; height: auto !important; }
.mgrs-gzd-label, .mgrs-100km-label {
  display: inline-block; border-radius: var(--radius); font-family: var(--tech); font-size: var(--map-label-size); font-weight: 700; line-height: 1.2; white-space: nowrap;
}
.mgrs-gzd-label { padding: 1px 4px; }
.mgrs-100km-label { padding: 2px 5px; }
#map[data-map-layer="roadmap"] :is(.mgrs-gzd-label, .mgrs-100km-label),
#map[data-map-layer="topo"] :is(.mgrs-gzd-label, .mgrs-100km-label) { background: rgba(255, 255, 255, 0.92); color: #1e3a5f; border: 1px solid #1e3a5f; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2); }
#map[data-map-layer="satellite"] :is(.mgrs-gzd-label, .mgrs-100km-label),
#map[data-map-layer="hybrid"] :is(.mgrs-gzd-label, .mgrs-100km-label) { background: rgba(0, 0, 0, 0.78); color: #fbbf24; border: 1px solid #fbbf24; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5); }

/* ================= Settings › Display (stage 2): preview + drawing colours ================= */
.display-layout { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 1rem; align-items: start; max-width: 96rem; }
.display-preview-card { position: sticky; top: calc(var(--wc-topbar-h, 56px) + var(--wc-tabbar-h, 48px) + 3.2rem); }
.style-preview { height: min(30rem, 60dvh); border: 1px solid var(--t-line); border-radius: var(--radius); overflow: hidden; font-family: var(--cond); }
.style-preview.leaflet-container { background: #e9e6dc; }
.style-preview:is([data-bg="street"], [data-bg="roadmap"]).leaflet-container {
  background: linear-gradient(rgba(0, 0, 0, 0.05) 1px, transparent 1px) 0 0 / 100% 32px, linear-gradient(90deg, rgba(0, 0, 0, 0.05) 1px, transparent 1px) 0 0 / 32px 100%, #e9e6dc;
}
.style-preview[data-bg="satellite"].leaflet-container {
  background: radial-gradient(60% 50% at 30% 40%, #4a5a3a 0%, transparent 70%), radial-gradient(50% 60% at 75% 70%, #2f3b2a 0%, transparent 70%), #384431;
}
.style-preview[data-bg="hybrid"].leaflet-container {
  background: linear-gradient(90deg, transparent 49.6%, rgba(255, 230, 150, 0.35) 50%, transparent 50.4%) 0 0 / 180px 100%,
    radial-gradient(60% 50% at 30% 40%, #4a5a3a 0%, transparent 70%), radial-gradient(50% 60% at 75% 70%, #2f3b2a 0%, transparent 70%), #384431;
}
.style-preview[data-bg="topo"].leaflet-container {
  background: radial-gradient(closest-side, transparent 88%, rgba(140, 100, 60, 0.25) 90%, transparent 93%) 0 0 / 120px 120px,
    radial-gradient(40% 40% at 30% 60%, #cfe3b5 0%, transparent 70%), #e6ecd6;
}
.ds-group[hidden] { display: none; }
.inline-select { display: flex !important; align-items: center; gap: 0.4rem; margin: 0 !important; font-size: 0.82rem; }
.inline-select select { width: auto; padding: 0.2rem 0.4rem; font-size: 0.85rem; }
.ds-group { border: 1px solid var(--t-line); border-radius: var(--radius); padding: 0.4rem 0.75rem 0.6rem; margin: 0 0 0.7rem; }
.ds-group legend { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--t-strong); padding: 0 0.3rem; }
.ds-row { display: grid; grid-template-columns: 11rem 1fr; align-items: center; gap: 0.6rem; margin: 0.3rem 0; }
.ds-row > label { margin: 0 !important; font-size: 0.85rem; }
.ds-ctl { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; min-width: 0; }
.ds-ctl input[type="color"] { width: 2.4rem; height: 1.9rem; padding: 0.1rem; border: 1px solid var(--t-field-line); border-radius: var(--radius); background: var(--t-field); cursor: pointer; }
.ds-ctl input[type="range"] { width: 7rem; padding: 0; }
.ds-ctl .ds-num { width: 5.5rem; }
.ds-ctl select { width: auto; }
.ds-hex { font-size: 0.78rem; color: var(--t-muted); min-width: 4.6rem; }
.ds-pct { font-size: 0.78rem; color: var(--t-muted); min-width: 2.8rem; }
.ds-bool { grid-template-columns: none; }
.ds-ctl :disabled, .ds-bool input:disabled { opacity: 0.55; cursor: not-allowed; }
.display-actions { position: sticky; bottom: 0; background: var(--t-panel); padding: 0.6rem 0 0.2rem; border-top: 1px solid var(--t-line); }
@media (max-width: 980px) {
  .display-layout { grid-template-columns: 1fr; }
  .display-preview-card { position: static; }
  .style-preview { height: 22rem; }
  .ds-row { grid-template-columns: 9.5rem 1fr; }
}
@media (max-width: 600px) { .brand-copy { display: none; } }

/* ================= Settings › Map Data (stage 3) ================= */
.badge-warn { background: var(--t-warn-soft, rgba(251, 191, 36, 0.18)); border-color: var(--t-warn, #b45309); color: var(--t-warn-ink, #92400e); }
.mapdata-layers td { vertical-align: top; }
.mapdata-layers select { min-width: 14rem; }
.ml-pkgs { display: flex; flex-direction: column; gap: 0.25rem; }
.ml-pkg { display: flex; align-items: center; gap: 0.4rem; font-size: 0.88rem; }
.ml-pkg.ml-off { opacity: 0.6; }
.ml-order { display: inline-flex; align-items: center; justify-content: center; min-width: 1.15rem; height: 1.15rem; border-radius: 999px; background: var(--t-sub-on-bg); color: var(--t-sub-on-ink); font-family: var(--tech); font-size: 0.7rem; font-weight: 700; }
#mapdata-pkg-table td { vertical-align: top; }
.pkg-src { max-width: 18rem; font-size: 0.85rem; }
.pkg-src .hint, .pkg-msg { margin: 0.15rem 0 0; font-size: 0.75rem; }
.pkg-msg { max-width: 16rem; }
.pkg-enable { display: inline-flex; align-items: center; gap: 0.25rem; margin-right: 0.35rem; font-size: 0.8rem; }
.mapdata-manage h4 { margin: 0.4rem 0 0.2rem; }
.mapdata-upload-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem 0.9rem; margin: 0.5rem 0; }
.mapdata-upload-grid label { display: flex; flex-direction: column; gap: 0.2rem; font-size: 0.85rem; font-weight: 600; }
.mapdata-upload-grid .span2 { grid-column: 1 / -1; }
.mapdata-progress { display: flex; align-items: center; gap: 0.75rem; margin: 0.4rem 0; }
.mapdata-progress progress { flex: 1 1 auto; height: 14px; accent-color: var(--t-accent); }
.mapdata-progress[hidden] { display: none; }
.mapdata-unfinished { margin: 0.2rem 0 0; padding-left: 1.1rem; font-size: 0.85rem; }
@media (max-width: 700px) { .mapdata-upload-grid { grid-template-columns: 1fr; } }
html[data-theme="dark"] .badge-warn { color: #fbbf24; border-color: #b45309; }

/* stage 3b: Map Data layer rows */
.ml-pkg.ml-na { opacity: 0.55; }
.ml-state { margin-top: 0.25rem; }
.ml-hidden { color: var(--t-warn-ink, #a16207); font-weight: 600; }
.map-type-control[hidden], .map-type-btn[hidden] { display: none !important; }
html[data-theme="dark"] .ml-hidden { color: #fbbf24; }

/* ================= stage 4: GeoTIFF export (house style §7.6) ================= */
/* stage 4f: the placement card sits bottom right, sized and styled like the Drop zone card (title · size · rotation · buttons stacked) */
.export-toolbar { bottom: 2.95rem; right: 0.75rem; z-index: 1200; min-width: 14rem; max-width: 18rem; display: flex; flex-direction: column; gap: 0.2rem; }
.export-toolbar[hidden] { display: none; }
.export-toolbar .map-card-title { margin-bottom: 0.15rem; }
.export-toolbar-size { font-size: 0.95rem; font-weight: 600; color: var(--t-accent-ink); line-height: 1.25; overflow-wrap: anywhere; }
.export-toolbar-rot { font-family: var(--tech); font-size: 0.8rem; color: var(--t-ink); }
.export-toolbar-rot[hidden] { display: none; }
.export-toolbar-actions { display: flex; flex-direction: column; gap: 0.35rem; margin-top: 0.45rem; padding-top: 0.45rem; border-top: 1px solid var(--t-line); }
.export-toolbar-actions .btn { width: 100%; justify-content: center; }
@media (max-width: 768px) { .export-toolbar { bottom: 2.95rem; right: 0.5rem; min-width: 11rem; max-width: 13rem; font-size: 0.72rem; } }
.export-pick-active .leaflet-container, .export-pick-active #map { cursor: crosshair !important; }
.export-pt { width: 12px !important; height: 12px !important; margin: -6px 0 0 -6px !important; border-radius: 50%; background: #fbbf24; border: 2px solid #1a1200; box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.85); }
.export-result-card { bottom: 2.95rem; right: 0.75rem; display: flex; flex-direction: column; gap: 0.25rem; min-width: 12rem; }
.export-result-card[hidden] { display: none; }
.export-opacity { display: flex; align-items: center; gap: 0.4rem; font-size: 0.8rem; }
.export-modal { max-width: 46rem; }
.export-layers { display: flex; flex-wrap: wrap; gap: 0 1.2rem; }
.export-choices { display: flex; flex-direction: column; gap: 0.15rem; }
.export-choice { display: flex; align-items: baseline; gap: 0.5rem; padding: 0.3rem 0.4rem; border-radius: var(--radius); cursor: pointer; font-size: 0.9rem; }
.export-choice:hover { background: var(--t-soft); }
.export-choice.disabled { cursor: not-allowed; opacity: 0.6; }
.export-choice .muted { font-size: 0.8rem; }
.export-sub { margin-left: 1.5rem !important; }
.export-cap-warn { color: var(--t-warn-ink, #92400e); background: var(--t-warn-soft, rgba(251, 191, 36, 0.18)); border: 1px solid var(--t-warn, #b45309); border-radius: var(--radius); padding: 0.4rem 0.6rem; font-weight: 600; }
html[data-theme="dark"] .export-cap-warn { color: #fbbf24; }
.export-cap-warn[hidden] { display: none; }
.export-done img { display: block; max-width: 100%; max-height: 40vh; margin: 0.5rem auto; border: 1px solid var(--t-line); border-radius: var(--radius);
  background: repeating-conic-gradient(var(--t-soft) 0% 25%, transparent 0% 50%) 50% / 16px 16px; }
.export-done[hidden], #export-progress[hidden], #export-options[hidden] { display: none; }
/* while picking, the drawing and the cards over the map must not swallow the clicks */
.export-pick-active #map .leaflet-marker-icon, .export-pick-active #map .leaflet-interactive { pointer-events: none !important; }
/* adjusting the rectangle: handles (≥ 24 px for touch), house colours: amber fill, dark ink ring */
.export-pick-active #map .export-handle, .export-pick-active #map path.export-editable { pointer-events: auto !important; }
.export-pick-active #map path.export-editable { cursor: move; }
.export-handle { width: 28px !important; height: 28px !important; box-sizing: border-box; border-radius: var(--radius); background: #fbbf24; border: 2px solid #1a1200;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.9), 0 2px 6px rgba(0, 0, 0, 0.45); display: flex; align-items: center; justify-content: center;
  color: #1a1200; font: 700 16px/1 var(--cond); touch-action: none; user-select: none; }
.export-handle-corner { border-radius: 3px; cursor: nwse-resize; }
.export-handle-edge { width: 24px !important; height: 24px !important; margin-left: -12px !important; margin-top: -12px !important; border-radius: 50%; background: #fff7d6; cursor: ns-resize; }
.export-handle-move { border-radius: 50%; cursor: move; }
.export-handle-rot { border-radius: 50%; cursor: grab; background: #1a1200; color: #fbbf24; border-color: #fbbf24; }
/* stage 4f: two rotate handles (beyond the top and the bottom edge), finger-sized (44 px) */
.export-handle.export-handle-rot { width: 44px !important; height: 44px !important; margin-left: -22px !important; margin-top: -22px !important; font-size: 24px; }
.export-handle-rot svg { width: 26px; height: 26px; }
/* stage 4f: the Base map section of the export options folds open / closed */
.export-bases-group > summary { cursor: pointer; font-weight: 600; padding: 0.15rem 0; list-style: revert; }
.export-bases-group > summary .export-bases-legend { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--t-strong); }
.export-bases-group > summary .muted { font-weight: 400; font-size: 0.85rem; }
.export-bases-group[open] > summary { margin-bottom: 0.35rem; }
.export-dragging, .export-dragging * { cursor: grabbing !important; }
.export-handle:hover { filter: brightness(1.08); box-shadow: 0 0 0 3px rgba(255, 255, 255, 1), 0 2px 8px rgba(0, 0, 0, 0.5); }
.export-modal { display: flex; flex-direction: column; max-height: calc(100dvh - 2rem); }
.export-modal > .modal-form { overflow: auto; min-height: 0; flex: 1 1 auto; }
.export-modal > .modal-actions { flex: 0 0 auto; flex-wrap: wrap; }

/* ================= stage 4b: touch-and-hold on the map shows only the app's own menu =================
   No OS callout (copy / look up / translate / share), no text selection or magnifier on the map, its panes, markers,
   labels, call-outs and the map cards/toolbars. Inputs inside the map cards (and the side pane, dialogs) select normally. */
.map-wrap, .map-wrap *, .leaflet-container, .leaflet-container *, .map-context-menu, .map-context-menu * {
  -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent;
}
.map-wrap input, .map-wrap textarea, .map-wrap select, .map-wrap [contenteditable="true"] {
  -webkit-touch-callout: default; -webkit-user-select: text; user-select: text;
}
.map-wrap img { -webkit-user-drag: none; }

/* ---- Stage 4c: export zoom, source notes, several files ---- */
.export-zoom-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.75rem; margin: 0.25rem 0; }
.export-zoom-row label { font-weight: 600; font-size: 0.9rem; }
.export-zoom-row select { width: auto; min-width: 7rem; }
.export-src-notes, .export-files { list-style: none; margin: 0.35rem 0 0; padding: 0; display: flex; flex-direction: column; gap: 0.2rem; font-size: 0.88rem; }
.export-src-notes li, .export-files li { padding: 0.25rem 0.4rem; border-radius: var(--radius); background: var(--t-soft); }
.export-src-notes li.src-note-warn { border-left: 3px solid var(--t-amber-bar); }
.export-files[hidden] { display: none; }
.export-cap-warn.form-error { color: var(--t-danger, #b91c1c); border-color: var(--t-danger, #b91c1c); }

/* stage 4h: banner EXPORT menu */
.export-menu-wrap { position: relative; display: inline-flex; }
.export-menu { position: fixed; top: 3.5rem; right: 0.5rem; z-index: 3000;   /* fixed: the banner row scrolls sideways (overflow) and would clip it */
   display: flex; flex-direction: column; min-width: 10rem; padding: 0.25rem; background: var(--t-panel); border: 1px solid var(--t-line); border-radius: 0.5rem; box-shadow: 0 6px 18px rgba(0,0,0,0.18); }
.export-menu[hidden] { display: none; }
.export-menu-item { appearance: none; border: 0; background: transparent; color: var(--t-ink); font: inherit; font-size: 0.9rem; text-align: left; padding: 0.55rem 0.75rem; border-radius: 0.35rem; cursor: pointer; white-space: nowrap; min-height: 2.5rem; }
.export-menu-item:hover:not(:disabled), .export-menu-item:focus-visible { background: var(--t-line); }
.export-menu-item:disabled { opacity: 0.5; cursor: default; }
/* stage 4h: export progress → Share card */
.export-run-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.export-run-x { appearance: none; border: 0; background: transparent; color: var(--t-ink); font-size: 1.35rem; line-height: 1; width: 2.2rem; height: 2.2rem; margin: -0.4rem -0.4rem -0.4rem 0; border-radius: 50%; cursor: pointer; }
.export-run-x:hover { background: var(--t-line); }
.export-run .mapdata-progress[hidden], .export-run .export-toolbar-actions[hidden] { display: none; }
.export-run #export-msg { margin: 0.15rem 0 0; overflow-wrap: anywhere; }
.export-run-link { text-align: center; font-size: 0.85rem; }
.export-run-link[hidden] { display: none; }
.export-run .export-share-hint { margin: 0; font-size: 0.75rem; }
.export-run .export-share-hint[hidden] { display: none; }
