/* ── Noise Map — dark mobile theme (portfolio standard) ─────────────────────── */
:root {
  --bg: #121216;
  --card: #1c1c22;
  --inset: #15151a;
  --border: #2a2a33;
  --text: #e8e8ee;
  --text2: #9a9aa5;
  --accent: #ff9f1c;   /* recording / live */
  --cyan: #40e0d0;     /* GPS */
  --danger: #ff5c5c;
  --ok: #4cd964;
  --radius: 14px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  touch-action: manipulation;
  overscroll-behavior-y: none;
}
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 15px; margin: 0 0 4px; }
h3 { font-size: 14px; margin: 10px 0 4px; }
a { color: var(--cyan); }

/* ── screens ────────────────────────────────────────────────────────────────── */
.screen {
  display: none;
  max-width: 520px;
  margin: 0 auto;
  padding: 16px 14px calc(96px + env(safe-area-inset-bottom, 0px));
}
.screen.active { display: block; }
.scr-head { margin-bottom: 12px; }
.scr-head .sub { color: var(--text2); font-size: 13px; margin: 4px 0 0; }

/* ── cards & common blocks ──────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}
.hint { color: var(--text2); font-size: 12px; margin: 8px 0 0; }
.center { text-align: center; }
.kv {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.kv:last-of-type { border-bottom: 0; }
.kv b { font-variant-numeric: tabular-nums; text-align: right; }

/* ── Live tab ───────────────────────────────────────────────────────────────── */
.db-card { text-align: center; }
.db-row { display: flex; align-items: baseline; justify-content: center; gap: 6px; }
.db-big {
  font-size: 64px;
  font-weight: 800;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  color: var(--text2);
}
.db-big.ok { color: var(--ok); }
.db-big.warn { color: var(--accent); }
.db-big.hot { color: var(--danger); }
.db-unit { font-size: 20px; color: var(--text2); }
.db-now-label { color: var(--text2); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
.stat-row { display: flex; gap: 8px; margin-top: 12px; }
.stat {
  flex: 1;
  min-width: 0;
  background: var(--inset);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 4px;
  text-align: center;
}
.stat b { display: block; font-size: 16px; font-variant-numeric: tabular-nums; }
.stat span { color: var(--text2); font-size: 11px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; justify-content: center; }
.chip {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  color: var(--text2);
  background: var(--inset);
}
.chip.gps { color: var(--cyan); border-color: #274d49; }
.chip.gps.ok { color: var(--ok); border-color: #2c5c33; }
.chip.gps.warn { color: var(--accent); border-color: #5c4420; }
.chip.gps.bad { color: var(--danger); border-color: #5c2c2c; }
.chip.tonal { color: var(--accent); border-color: #5c4420; }
.bands { display: flex; gap: 6px; height: 120px; margin-top: 10px; }
.band { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; min-width: 0; }
.bar {
  flex: 1;
  width: 100%;
  max-width: 28px;
  background: var(--inset);
  border: 1px solid var(--border);
  border-radius: 6px;
  display: flex;
  align-items: flex-end;
  overflow: hidden;
}
.bar-fill { width: 100%; height: 0%; background: linear-gradient(180deg, var(--accent), #b06a00); transition: height .15s linear; }
.band span { font-size: 9px; color: var(--text2); text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; overflow: hidden; max-width: 100%; }
.band-db { font-size: 8px; font-weight: 400; color: var(--text2); line-height: 1; font-variant-numeric: tabular-nums; }

/* ── spectrogram ────────────────────────────────────────────────────────────── */
.spectro-wrap { position: relative; }
.spectro-mini, .spectro-full {
  width: 100%;
  display: block;
  background: #000;
  border: 1px solid var(--border);
  border-radius: 10px;
}
.spectro-mini { height: 90px; }
.spectro-full { height: 300px; }
.spectrum-line { width: 100%; height: 140px; display: block; border-radius: 8px; background: #0a0a0e; }
.freq-lbl {
  position: absolute;
  left: 8px;
  transform: translateY(-50%);
  font-size: 9px;
  color: #cfcfd8;
  opacity: .8;
  pointer-events: none;
  text-shadow: 0 1px 2px #000;
  font-variant-numeric: tabular-nums;
}

/* ── map ────────────────────────────────────────────────────────────────────── */
.map-wrap { position: relative; }
#map {
  height: 62vh;
  min-height: 320px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: #0d0d10;
}
.map-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 20px;
  color: var(--text2);
  font-size: 13px;
  pointer-events: none;
  z-index: 400; /* above leaflet panes, below controls */
}
.map-legend {
  position: absolute;
  left: 10px;
  bottom: 10px;
  z-index: 500;
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(18, 18, 22, .85);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 10px;
  color: var(--text2);
}
.legend-bar {
  width: 70px;
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--cyan), var(--accent), var(--danger));
}
.map-center { position: absolute; right: 10px; top: 10px; z-index: 500; margin: 0; }
.layer-switch {
  position: absolute;
  right: 10px;
  top: 50px;
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: rgba(18, 18, 22, .88);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px;
}
.layer-switch button {
  background: var(--inset);
  border: 1px solid var(--border);
  color: var(--text2);
  border-radius: 8px;
  font-size: 11px;
  padding: 5px 10px;
  cursor: pointer;
  margin: 0;
}
.layer-switch button.on { color: #221a05; background: var(--accent); border-color: var(--accent); font-weight: 700; }
.layer-switch .bld-check {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--text2); padding: 3px 4px 0; cursor: pointer;
}
.layer-switch .bld-check input { width: 14px; height: 14px; accent-color: var(--cyan); margin: 0; }
/* heatmap canvas (custom L.Layer pane) */
.nm-heat { pointer-events: none; }
/* hotspot markers */
.hs-marker span {
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  color: #1a1204; font-weight: 800; font-size: 12px;
  border: 2px solid rgba(255, 255, 255, .75);
  box-shadow: 0 2px 10px rgba(0, 0, 0, .55);
}
/* source estimate crosshair + tags */
.src-cross-wrap { background: none; border: 0; }
.src-cross {
  width: 34px; height: 34px; position: relative;
  display: flex; align-items: center; justify-content: center;
  color: var(--cyan); font-weight: 800; font-size: 12px;
  text-shadow: 0 0 4px #000, 0 0 4px #000;
}
.src-cross::before, .src-cross::after {
  content: ""; position: absolute; background: var(--cyan);
  box-shadow: 0 0 6px rgba(0, 0, 0, .8);
}
.src-cross::before { left: 16px; top: 2px; width: 2px; height: 30px; }
.src-cross::after { top: 16px; left: 2px; height: 2px; width: 30px; }
/* hotspot list */
.hs-list { display: flex; flex-direction: column; gap: 6px; }
.hs-item {
  display: flex; align-items: center; gap: 8px;
  background: var(--inset);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  cursor: pointer;
  font-size: 12.5px;
}
.hs-item:active { border-color: var(--accent); }
.hs-item b { color: var(--accent); font-size: 13px; }
.hs-prof { color: var(--text2); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hs-a { font-variant-numeric: tabular-nums; font-weight: 700; }
.hs-d { color: var(--text2); font-variant-numeric: tabular-nums; }
/* session filter chips */
.map-filter { display: flex; gap: 8px; align-items: center; margin: 10px 0 0; }
.map-filter .chip-x {
  background: var(--inset);
  border: 1px solid var(--border);
  color: var(--text2);
  border-radius: 999px;
  font-size: 12px;
  padding: 5px 12px;
  cursor: pointer;
  margin: 0;
}
.map-filter .chip-on {
  background: rgba(64, 224, 208, .12);
  border: 1px solid #274d49;
  color: var(--cyan);
  border-radius: 999px;
  font-size: 12px;
  padding: 5px 12px;
  max-width: 60%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.src-row b { color: var(--cyan); }
.sheet {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-top: 12px;
}

/* ── sessions tab ───────────────────────────────────────────────────────────── */
.card-list { display: flex; flex-direction: column; gap: 10px; }
.sess-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  cursor: pointer;
}
.sess-item:active { border-color: var(--accent); }
.sess-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.sess-top b { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sess-max { color: var(--accent); font-weight: 700; font-variant-numeric: tabular-nums; font-size: 13px; white-space: nowrap; }
.sess-sub {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--text2);
  font-size: 11.5px;
  margin-top: 2px;
}
.sess-sub span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spark { width: 100%; height: 28px; margin-top: 8px; display: block; }
#sessName {
  font-size: 16px;
  min-height: 24px;
  border-bottom: 1px dashed var(--border);
  outline: none;
  padding: 2px 0 4px;
  margin-bottom: 6px;
}

/* ── buttons / forms ────────────────────────────────────────────────────────── */
.btn-primary {
  display: inline-block;
  width: 100%;
  text-align: center;
  background: var(--accent);
  color: #221a05;
  border: 0;
  border-radius: 10px;
  padding: 12px 14px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  margin-top: 8px;
}
.btn-ghost {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  cursor: pointer;
  margin-top: 8px;
}
.btn-danger {
  background: transparent;
  border: 1px solid var(--danger);
  color: var(--danger);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  cursor: pointer;
  margin-top: 8px;
}
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.btn-row .btn-ghost, .btn-row .btn-danger { flex: 1 1 auto; margin-top: 8px; }
.row-label { display: block; font-size: 13px; color: var(--text2); margin-bottom: 8px; }
select, input[type="range"], input[type="email"], input[type="text"], textarea {
  width: 100%;
  background: var(--inset);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 10px;
  font-size: 14px;
  font-family: inherit;
}
textarea { resize: vertical; }
input[type="range"] { padding: 0; accent-color: var(--accent); }
.row-check { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.row-check input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--accent); margin-top: 4px; flex: none; }

/* ── Pro / about / legal ────────────────────────────────────────────────────── */
.pro-card { border-color: #5c4420; }
.pro-feats { margin: 8px 0; padding-left: 18px; color: var(--text2); font-size: 13px; }
.pro-badge {
  display: inline-block;
  background: var(--accent);
  color: #221a05;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .08em;
  border-radius: 6px;
  padding: 2px 6px;
  vertical-align: 2px;
}
.pro-on { color: var(--ok); font-weight: 600; }
.pro-act { margin-top: 10px; }
.pro-act input { margin-top: 0; }
#proActBtn { display: block; width: 100%; }
#proActStatus.ok { color: var(--ok); }
#proActStatus.err { color: var(--danger); }
.pro-gdpr { font-size: 11px; opacity: .8; }
/* free-tier pill on Pro-only export buttons (::after survives applyLang) */
.pro-lock::after {
  content: "PRO";
  display: inline-block;
  background: var(--accent);
  color: #221a05;
  font-size: 9px;
  font-weight: 800;
  border-radius: 5px;
  padding: 1px 4px;
  margin-left: 6px;
  vertical-align: 1px;
}
.legal { text-align: center; font-size: 12px; margin: 18px 0 8px; }

/* ── bottom nav (5 tabs) ────────────────────────────────────────────────────── */
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: flex;
  background: #17171c;
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.nav-btn {
  flex: 1;
  background: none;
  border: 0;
  color: var(--text2);
  font-size: 10px;
  padding: 8px 2px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  cursor: pointer;
}
.nav-btn .ico { font-size: 20px; line-height: 1; }
.nav-btn.active { color: var(--accent); }

/* ── floating REC button ────────────────────────────────────────────────────── */
.rec-btn {
  position: fixed;
  right: 16px;
  bottom: calc(92px + env(safe-area-inset-bottom, 0px));
  z-index: 40;
  width: 66px;
  height: 66px;
  border-radius: 50%;
  border: 0;
  background: var(--danger);
  color: #fff;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .5);
}
body.rec-visible .rec-btn { display: flex; }
.rec-dot { width: 20px; height: 20px; border-radius: 50%; background: #fff; }
.rec-hud { display: none; font-size: 10px; font-weight: 700; font-variant-numeric: tabular-nums; }
.rec-btn.recording .rec-dot { width: 12px; height: 12px; border-radius: 3px; }
.rec-btn.recording .rec-hud { display: block; }
.rec-btn.recording { animation: pulse 1.2s infinite; }
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(255, 92, 92, .55); }
  70%  { box-shadow: 0 0 0 18px rgba(255, 92, 92, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 92, 92, 0); }
}

/* ── P5: pause / spot side buttons ──────────────────────────────────────────── */
.side-btn {
  position: fixed;
  right: 16px;
  z-index: 40;
  display: none;
  align-items: center;
  justify-content: center;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .45);
  touch-action: manipulation;
}
#recPauseBtn {
  bottom: calc(170px + env(safe-area-inset-bottom, 0px));
  width: 48px;
  height: 48px;
  font-size: 14px;
  letter-spacing: -2px;
}
#recPauseBtn.paused { color: var(--accent); border-color: #5c4420; letter-spacing: 0; }
#spotBtn {
  bottom: calc(228px + env(safe-area-inset-bottom, 0px));
  min-height: 40px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 700;
  color: var(--cyan);
  border-color: #274d49;
}
body.rec-visible.rec-on .side-btn { display: flex; }
.chip.paused { color: var(--accent); border-color: #5c4420; }
.chip.moving { color: var(--cyan); border-color: #274d49; }
.spot-card { display: flex; align-items: center; gap: 8px; border-color: #274d49; color: var(--cyan); }

/* ── P5: segmented settings control (auto-pause) ────────────────────────────── */
.seg { display: flex; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; }
.seg-btn {
  flex: 1;
  background: none;
  border: 0;
  border-right: 1px solid var(--border);
  color: var(--text2);
  font-size: 13px;
  padding: 9px 4px;
  cursor: pointer;
}
.seg-btn:last-child { border-right: 0; }
.seg-btn.on { background: var(--accent); color: #16161a; font-weight: 700; }

/* ── toast + modal ──────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(170px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 60;
  background: #26262e;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  max-width: 88vw;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s;
}
.toast.show { opacity: 1; }
.modal {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(0, 0, 0, .6);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
}
.modal.open { display: flex; }
.modal-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  width: 100%;
  max-width: 400px;
}
.modal-box input, .modal-box textarea { margin-top: 8px; }
