/* mapQ – full-screen map, see-through corner buttons, bottom sheets. */
:root {
  --ink: #0f1a22; --muted: #5d7080; --line: #d5e0e8; --bg: #ffffff; --card: #f4f7f9;
  --accent: #1f7a3a; --accent-ink: #fff; --stop: #d93036; --link: #1a63b8;
  --glass: rgba(255, 255, 255, .38); --glass-line: rgba(15, 26, 34, .18);
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
  --fab: 58px; --gap: 16px;
}
@media (prefers-color-scheme: dark) {
  :root { --ink: #e7eef3; --muted: #9db0bf; --line: #2a3843; --bg: #121b22; --card: #1a252e; --link: #8cc2ff; --glass: rgba(18, 27, 34, .42); --glass-line: rgba(255, 255, 255, .22); }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Arial, sans-serif; overflow: hidden; }
#map { position: fixed; inset: 0; background: #dfe5e9; }
.muted { color: var(--muted); } .small { font-size: 13px; } .error { color: var(--stop); font-size: 14px; }

/* ---------- see-through corner buttons */
.fab {
  position: fixed; bottom: calc(var(--gap) + var(--safe-b)); z-index: 1000;
  width: var(--fab); height: var(--fab); border-radius: 50%; padding: 0; cursor: pointer;
  background: var(--glass); border: 1px solid var(--glass-line); color: var(--ink);
  backdrop-filter: blur(6px) saturate(1.2); -webkit-backdrop-filter: blur(6px) saturate(1.2);
  box-shadow: 0 2px 10px rgba(0, 0, 0, .12); display: grid; place-items: center;
  transition: background .15s, transform .1s;
}
.fab:hover { background: rgba(255, 255, 255, .6); } .fab:active { transform: scale(.95); }
.fab svg { width: 28px; height: 28px; }
.fab-left { left: var(--gap); } .fab-right { right: var(--gap); }
.fab-right .rec-dot { color: var(--stop); }
.fab-right.recording { border-color: var(--stop); box-shadow: 0 0 0 3px rgba(217, 48, 54, .35); }
.fab-right.recording .rec-dot { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }
@media (prefers-color-scheme: dark) { .fab:hover { background: rgba(18, 27, 34, .65); } }


/* ---------- Leaflet: ruler as in iceq-lab, lifted above the corner button */
.leaflet-bottom.leaflet-left { bottom: calc(var(--fab) + var(--gap) + 6px + var(--safe-b)); }
.leaflet-bottom.leaflet-right { bottom: calc(var(--fab) + var(--gap) + 6px + var(--safe-b)); }
.leaflet-control-scale-line {
  position: relative; border-color: #172b3c; border-width: 0 2px 2px; color: #172b3c; font-weight: 600;
  background: rgba(255, 255, 255, .4); text-shadow: 0 0 2px #fff, 0 0 2px #fff, 0 0 3px #fff;
}
.leaflet-control-scale-line::after { content: ''; position: absolute; left: 50%; bottom: 0; height: 6px; border-left: 2px solid #172b3c; }
.leaflet-top.leaflet-left, .leaflet-top.leaflet-right { top: var(--safe-t); }
.leaflet-control-attribution { font-size: 10px; }
/* Opaque raster tiles: overlap 0.5 px to hide seams (from iceq-lab). */
.leaflet-container .leaflet-topoMap-pane img.leaflet-tile { mix-blend-mode: normal; width: 256.5px !important; height: 256.5px !important; }

/* ---------- live figures while recording */
.hud {
  position: fixed; top: calc(12px + var(--safe-t)); left: 50%; transform: translateX(-50%); z-index: 1000;
  display: grid; grid-template-columns: repeat(4, auto); gap: 14px; padding: 8px 14px; border-radius: 14px;
  background: rgba(0, 0, 0, .72); color: #fff; font-variant-numeric: tabular-nums; text-align: center; max-width: calc(100vw - 24px);
}
.hud b { display: block; font-size: 18px; } .hud span { font-size: 11px; opacity: .75; }
@media (max-width: 380px) { .hud { gap: 8px; padding: 6px 10px; } .hud b { font-size: 15px; } }

/* ---------- bottom sheet */
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1100; max-height: 78vh; overflow: auto;
  background: var(--bg); border-radius: 18px 18px 0 0; box-shadow: 0 -6px 30px rgba(0, 0, 0, .25);
  padding: 4px 16px calc(16px + var(--safe-b)); transform: translateY(100%); transition: transform .18s ease-out;
  max-width: 560px; margin: 0 auto;
}
.sheet.open { transform: none; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; background: var(--bg); padding: 10px 0 6px; }
.sheet-head h2 { margin: 0; font-size: 18px; }
.icon-btn { border: 0; background: transparent; color: var(--ink); font-size: 20px; cursor: pointer; padding: 6px 10px; }
button, .button-link, select, input { font: inherit; }
button, .button-link {
  color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 9px 14px; cursor: pointer; text-decoration: none; display: inline-block;
}
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.danger { color: var(--stop); }
button.big { display: block; width: 100%; font-size: 22px; font-weight: 700; padding: 20px; border: 0; border-radius: 16px; margin: 12px 0; min-height: 16vh; }
button.big.start { background: #3ccf5a; color: #06310f; } button.big.stop { background: var(--stop); color: #fff; }
.field { display: grid; gap: 4px; margin: 10px 0; font-size: 14px; color: var(--muted); }
.field input, .field select { color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 9px; }
.switch { display: flex; gap: 8px; align-items: center; margin: 8px 0; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; }
.row-card { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin: 10px 0; }
.row-title { font-weight: 600; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.badge { font-size: 12px; font-weight: 500; border-radius: 10px; padding: 1px 8px; background: #e1ecf7; color: #1f5c8f; }
.badge.ok { background: #d8f0dc; color: #1d6b2c; }
progress { width: 100%; height: 10px; }
.big-figures { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; margin: 8px 0; }
.sim-box { border-left: 3px solid #c77700; padding-left: 10px; }

/* ---------- choosing squares */
.grid-bar {
  position: fixed; top: calc(12px + var(--safe-t)); left: 50%; transform: translateX(-50%); z-index: 1050;
  background: var(--bg); border-radius: 14px; padding: 10px 12px; box-shadow: 0 4px 18px rgba(0, 0, 0, .25); width: min(520px, calc(100vw - 24px));
}
.grid-bar-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--fab) + 28px + var(--safe-b)); transform: translateX(-50%); z-index: 1200;
  background: rgba(0, 0, 0, .82); color: #fff; padding: 9px 14px; border-radius: 10px; font-size: 14px; max-width: calc(100vw - 32px);
}

/* ---------- login */
.login { position: fixed; inset: 0; z-index: 2000; display: grid; place-items: center; padding: 16px;
  background: linear-gradient(160deg, #0f1a22, #1f3a4d); }
.login-card { background: var(--bg); border-radius: 18px; padding: 28px 24px; width: min(380px, 100%); text-align: center; }
.login-card h1 { margin: 0 0 8px; font-size: 30px; }
button.google { display: inline-flex; gap: 10px; align-items: center; background: #fff; color: #1f1f1f; border: 1px solid #dadce0; padding: 11px 18px; font-weight: 600; }
