/* =============================================================
   FIP ARMENIA — flood information platform
   Layout: fixed header, left filter rail, right detail rail,
           full-bleed map underneath. Rails become sheets on mobile.
   ============================================================= */

/* ---------- Tokens ---------- */
:root {
  --c-bg:          #eef2f6;
  --c-surface:     #ffffff;
  --c-surface-2:   #f4f7fa;
  --c-border:      #dde5ee;
  --c-border-soft: #e8eef5;
  --c-text:        #101b28;
  --c-text-muted:  #607085;
  --c-accent:      #0b6fa4;
  --c-accent-weak: #e5f1f8;
  --c-accent-text: #ffffff;
  --c-danger:      #b4351f;
  --c-danger-weak: #fdeceb;

  --shadow-sm: 0 1px 2px rgba(16, 27, 40, .06), 0 1px 3px rgba(16, 27, 40, .05);
  --shadow-md: 0 4px 6px rgba(16, 27, 40, .05), 0 10px 24px rgba(16, 27, 40, .10);
  --shadow-lg: 0 10px 20px rgba(16, 27, 40, .08), 0 24px 48px rgba(16, 27, 40, .16);

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;

  --header-h: 60px;
  --rail-gap: 14px;
  --tile-filter: none;

  --font: 'Noto Sans Armenian', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

[data-theme="dark"] {
  --c-bg:          #070c14;
  --c-surface:     #111a27;
  --c-surface-2:   #17222f;
  --c-border:      #253243;
  --c-border-soft: #1d2836;
  --c-text:        #e7eef7;
  --c-text-muted:  #93a5ba;
  --c-accent:      #3ba7dd;
  --c-accent-weak: #14293a;
  --c-accent-text: #04121c;
  --c-danger:      #f2837a;
  --c-danger-weak: #331a19;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .5);
  --shadow-md: 0 6px 16px rgba(0, 0, 0, .55);
  --shadow-lg: 0 18px 46px rgba(0, 0, 0, .65);

  /* OpenStreetMap ships no dark raster style, so the tiles are
     inverted and re-hued to sit under a dark interface. */
  --tile-filter: invert(1) hue-rotate(185deg) brightness(.92) contrast(.92) saturate(.75);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

/* Several elements below are toggled through the `hidden` attribute while
   also carrying an id/class `display` rule, which would otherwise win. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  color: var(--c-text);
  background: var(--c-bg);
  -webkit-text-size-adjust: 100%;
}

body.modal-open { overflow: hidden; }

button, input, select, textarea { font: inherit; color: inherit; }

:focus-visible {
  outline: 2px solid var(--c-accent);
  outline-offset: 2px;
}

.only-mobile { display: none !important; }

/* ---------- Map ---------- */
#map {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: var(--c-bg);
}

.leaflet-tile-pane { filter: var(--tile-filter); }

.leaflet-container {
  font-family: var(--font);
  background: var(--c-bg);
}

.leaflet-control-attribution {
  background: rgba(255, 255, 255, .82) !important;
  color: #40506a !important;
  font-size: 10px !important;
  padding: 2px 7px !important;
  border-radius: 6px 0 0 0;
}
.leaflet-control-attribution a { color: #2c6d97 !important; }
[data-theme="dark"] .leaflet-control-attribution {
  background: rgba(10, 16, 24, .82) !important;
  color: #93a5ba !important;
}
[data-theme="dark"] .leaflet-control-attribution a { color: #62b7e6 !important; }

.leaflet-bar a {
  background: var(--c-surface) !important;
  color: var(--c-text) !important;
  border-color: var(--c-border) !important;
}
.leaflet-bar a:hover { background: var(--c-surface-2) !important; }

body.picking #map { cursor: crosshair; }
body.picking .leaflet-container { cursor: crosshair; }

/* Marker + cluster */
.flood-pin {
  background: none !important;
  border: none !important;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .35));
  transition: transform .12s ease;
}
.flood-pin:hover { transform: translateY(-2px) scale(1.06); }

.flood-cluster {
  background: none !important;
  border: none !important;
  display: grid;
  place-items: center;
}
.flood-cluster span {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--c-accent);
  color: #fff;
  font-weight: 600;
  font-size: 13px;
  border: 3px solid rgba(255, 255, 255, .9);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .35);
}
[data-theme="dark"] .flood-cluster span {
  border-color: rgba(10, 20, 30, .8);
  color: #04121c;
}

/* ---------- Header ---------- */
#main-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 900;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 14px;
  padding-left: max(14px, env(safe-area-inset-left));
  padding-right: max(14px, env(safe-area-inset-right));
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  box-shadow: var(--shadow-sm);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 0 1 auto;
}

.logo {
  width: 34px;
  height: 34px;
  object-fit: contain;
  flex: none;
}

.platform-title {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-bar {
  position: relative;
  flex: 1 1 auto;
  max-width: 380px;
  margin-inline: auto;
}

.search-icon {
  position: absolute;
  left: 11px; top: 50%;
  transform: translateY(-50%);
  width: 16px; height: 16px;
  color: var(--c-text-muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  height: 38px;
  padding: 0 12px 0 34px;
  border: 1px solid var(--c-border);
  border-radius: 999px;
  background: var(--c-surface-2);
  font-size: 13.5px;
  transition: border-color .15s, background .15s;
}
.search-input::placeholder { color: var(--c-text-muted); }
.search-input:focus {
  outline: none;
  border-color: var(--c-accent);
  background: var(--c-surface);
}
.search-input::-webkit-search-cancel-button { cursor: pointer; }

.header-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: none;
  margin-left: auto;
}

/* ---------- Buttons ---------- */
.icon-btn {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--c-text-muted);
  cursor: pointer;
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--c-surface-2); color: var(--c-text); }
.icon-btn svg { width: 19px; height: 19px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, border-color .15s, opacity .15s;
}
.btn svg { width: 14px; height: 14px; flex: none; }
.btn:disabled { opacity: .6; cursor: not-allowed; }

.btn-primary {
  background: var(--c-accent);
  color: var(--c-accent-text);
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); }

.btn-ghost {
  background: var(--c-surface);
  border-color: var(--c-border);
  color: var(--c-text);
}
.btn-ghost:hover { background: var(--c-surface-2); }

.btn-block { width: 100%; }

.link-btn {
  border: none;
  background: none;
  padding: 4px 2px;
  color: var(--c-accent);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}
.link-btn:hover { text-decoration: underline; }

.close-btn {
  display: grid;
  place-items: center;
  width: 30px; height: 30px;
  flex: none;
  border: none;
  border-radius: var(--r-sm);
  background: var(--c-surface-2);
  color: var(--c-text-muted);
  cursor: pointer;
}
.close-btn:hover { background: var(--c-border); color: var(--c-text); }
.close-btn svg { width: 13px; height: 13px; }

.chip {
  padding: 6px 11px;
  border: 1px solid var(--c-border);
  border-radius: 999px;
  background: var(--c-surface);
  color: var(--c-text-muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.chip:hover {
  border-color: var(--c-accent);
  color: var(--c-accent);
  background: var(--c-accent-weak);
}

/* ---------- Rails (filter + detail) ---------- */
#filter-panel,
#detail-panel,
#list-panel {
  position: fixed;
  top: calc(var(--header-h) + var(--rail-gap));
  bottom: var(--rail-gap);
  z-index: 800;
  display: flex;
  flex-direction: column;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

#filter-panel {
  left: var(--rail-gap);
  width: 306px;
}

#detail-panel {
  right: var(--rail-gap);
  width: min(410px, 34vw);
  transform: translateX(calc(100% + var(--rail-gap) + 10px));
  opacity: 0;
  pointer-events: none;
  transition: transform .28s cubic-bezier(.22, .61, .36, 1), opacity .2s;
}
#detail-panel.active {
  transform: none;
  opacity: 1;
  pointer-events: auto;
}

#list-panel {
  right: var(--rail-gap);
  width: min(410px, 34vw);
  transform: translateX(calc(100% + var(--rail-gap) + 10px));
  opacity: 0;
  pointer-events: none;
  transition: transform .28s cubic-bezier(.22, .61, .36, 1), opacity .2s;
  z-index: 810;
}
#list-panel.active {
  transform: none;
  opacity: 1;
  pointer-events: auto;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--c-border-soft);
  flex: none;
}

.panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}
.panel-title svg { width: 16px; height: 16px; color: var(--c-accent); }

.panel-head-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: none;
}

.panel-scroll {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.sheet-grip { display: none; }

/* ---------- Filter panel content ---------- */
#stats-bar {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 12px 16px;
  background: var(--c-accent-weak);
  border-bottom: 1px solid var(--c-border-soft);
}
#stats-count { font-size: 15px; font-weight: 700; color: var(--c-accent); }
#stats-total { font-size: 12px; color: var(--c-text-muted); }

.filter-group {
  padding: 16px;
  border-bottom: 1px solid var(--c-border-soft);
}
.filter-group:last-child { border-bottom: none; }

.filter-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.filter-group-title {
  margin: 0 0 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--c-text-muted);
}
.filter-group-head .filter-group-title { margin-bottom: 0; }

.range-readout {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 16px;
  padding: 9px 12px;
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm);
  background: var(--c-surface-2);
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.range-arrow { width: 16px; height: 8px; color: var(--c-text-muted); flex: none; }

.preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 22px;
}

/* Region list */
.region-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.region-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 8px;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background .12s;
}
.region-item:hover { background: var(--c-surface-2); }
.region-item.is-empty { opacity: .45; }

.region-item input {
  width: 16px;
  height: 16px;
  margin: 0;
  flex: none;
  accent-color: var(--c-accent);
  cursor: pointer;
}

.region-name {
  flex: 1;
  font-size: 13.5px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.region-count {
  flex: none;
  min-width: 26px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--c-surface-2);
  color: var(--c-text-muted);
  font-size: 11.5px;
  font-weight: 600;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.region-item:hover .region-count { background: var(--c-border); }

/* ---------- noUiSlider ---------- */
#month-slider {
  height: 5px;
  margin: 0 12px 34px;
  border: none;
  border-radius: 999px;
  background: var(--c-border);
  box-shadow: none;
}
#month-slider.is-disabled { opacity: .4; pointer-events: none; }

#month-slider .noUi-connect { background: var(--c-accent); }

#month-slider .noUi-handle {
  width: 20px;
  height: 20px;
  top: -8px;
  right: -10px;
  border: 2px solid var(--c-accent);
  border-radius: 50%;
  background: var(--c-surface);
  box-shadow: var(--shadow-sm);
  cursor: grab;
}
#month-slider .noUi-handle::before,
#month-slider .noUi-handle::after { display: none; }
#month-slider .noUi-handle:active { cursor: grabbing; }
#month-slider .noUi-handle:hover { background: var(--c-accent-weak); }

#month-slider .noUi-pips { padding: 8px 0 0; color: var(--c-text-muted); height: auto; }
#month-slider .noUi-marker-horizontal.noUi-marker {
  height: 4px;
  background: var(--c-border);
}
#month-slider .noUi-value {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--c-text-muted);
  padding-top: 2px;
}
#month-slider .noUi-marker-horizontal.noUi-marker-large { height: 6px; }

/* ---------- Detail panel ---------- */
.detail-meta { min-width: 0; }

.detail-date {
  margin: 0 0 3px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--c-accent);
}

.detail-title {
  margin: 0;
  font-size: 16.5px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -.01em;
}

.detail-region {
  margin: 5px 0 0;
  font-size: 12.5px;
  color: var(--c-text-muted);
}

#detail-body { padding: 16px; }

.detail-desc {
  margin: 0 0 14px;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--c-text);
}

.detail-source {
  margin: 12px 0 0;
  font-size: 12px;
  color: var(--c-text-muted);
  font-style: italic;
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--c-border-soft);
}

.empty-note {
  margin: 0;
  padding: 18px 4px;
  font-size: 13px;
  color: var(--c-text-muted);
  text-align: center;
}

/* Video embeds — the wrapper's inline padding-top carries each video's
   own aspect ratio, so the box is reserved before the iframe loads. */
.videos-count {
  margin: 0 0 10px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--c-text-muted);
}

.video-wrapper {
  position: relative;
  width: 100%;
  height: 0;
  margin-bottom: 12px;
  border-radius: var(--r-md);
  overflow: hidden;
  background: #000;
  border: 1px solid var(--c-border);
}

.video-wrapper iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* ---------- List panel ---------- */
#incidents-list { padding: 8px; }

.incident-card {
  display: block;
  width: 100%;
  text-align: start;
  padding: 11px 12px;
  margin-bottom: 6px;
  border: 1px solid var(--c-border-soft);
  border-radius: var(--r-md);
  background: var(--c-surface);
  cursor: pointer;
  transition: border-color .14s, background .14s, transform .14s;
}
.incident-card:hover {
  border-color: var(--c-accent);
  background: var(--c-accent-weak);
  transform: translateX(-2px);
}

.incident-card-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.incident-card-date {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--c-accent);
  white-space: nowrap;
}

.incident-card-region {
  font-size: 11px;
  color: var(--c-text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.incident-card-title {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.35;
  margin-bottom: 3px;
}

.incident-card-desc {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 12px;
  line-height: 1.45;
  color: var(--c-text-muted);
}

.incident-card-badge {
  display: inline-block;
  margin-top: 7px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--c-surface-2);
  font-size: 10.5px;
  font-weight: 600;
  color: var(--c-text-muted);
}

/* ---------- Overlays ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 790;
  background: rgba(10, 20, 32, .35);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}
.overlay.active { opacity: 1; pointer-events: auto; }

/* ---------- Mobile filter FAB ---------- */
#filter-fab {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(18px + env(safe-area-inset-bottom));
  z-index: 780;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 42px;
  padding: 0 18px;
  border: 1px solid var(--c-border);
  border-radius: 999px;
  background: var(--c-surface);
  color: var(--c-text);
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  cursor: pointer;
}
#filter-fab svg { width: 16px; height: 16px; color: var(--c-accent); }

#filter-fab-badge {
  display: grid;
  place-items: center;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--c-accent);
  color: var(--c-accent-text);
  font-size: 11px;
  font-weight: 700;
}

/* ---------- Pick-a-location banner ---------- */
#pick-banner {
  position: fixed;
  top: calc(var(--header-h) + 12px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 1100;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: calc(100vw - 28px);
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--c-accent);
  color: var(--c-accent-text);
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
}
#pick-banner .link-btn { color: inherit; text-decoration: underline; }

/* ---------- Modals ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(8, 16, 26, .55);
  backdrop-filter: blur(3px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}
.modal.active { opacity: 1; pointer-events: auto; }

.modal-content {
  position: relative;
  width: 100%;
  max-width: 540px;
  max-height: min(86vh, 820px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 28px;
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  background: var(--c-surface);
  box-shadow: var(--shadow-lg);
  transform: translateY(10px) scale(.99);
  transition: transform .22s cubic-bezier(.22, .61, .36, 1);
}
.modal.active .modal-content { transform: none; }
.modal-content--form { max-width: 620px; }

.close-modal {
  position: absolute;
  top: 14px;
  inset-inline-end: 14px;
  display: grid;
  place-items: center;
  width: 30px; height: 30px;
  border: none;
  border-radius: var(--r-sm);
  background: var(--c-surface-2);
  color: var(--c-text-muted);
  cursor: pointer;
}
.close-modal:hover { background: var(--c-border); color: var(--c-text); }
.close-modal svg { width: 13px; height: 13px; }

.modal-content h2 {
  margin: 0 40px 14px 0;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -.01em;
}
.modal-content h3 {
  margin: 20px 0 8px;
  font-size: 14px;
  font-weight: 700;
}
.modal-content p,
.modal-content li {
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--c-text);
}
.modal-content ul { margin: 0; padding-inline-start: 20px; }
.modal-content li { margin-bottom: 5px; }

.modal-footer-note {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--c-border-soft);
  font-size: 11.5px !important;
  line-height: 1.6;
  color: var(--c-text-muted) !important;
}

/* ---------- Form ---------- */
.form-intro {
  margin: 0 0 20px;
  font-size: 13px !important;
  color: var(--c-text-muted) !important;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.field { margin-bottom: 14px; min-width: 0; }

.field label,
.field legend {
  display: block;
  margin-bottom: 5px;
  padding: 0;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--c-text);
}

.req { color: var(--c-danger); }

fieldset.field {
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  padding: 14px;
  margin-inline: 0;
}
fieldset.field legend { padding-inline: 6px; margin-bottom: 0; }
fieldset.field .field:last-child { margin-bottom: 0; }

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm);
  background: var(--c-surface-2);
  font-size: 13.5px;
  transition: border-color .15s, background .15s;
}
.field textarea { resize: vertical; min-height: 74px; line-height: 1.5; }
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--c-accent);
  background: var(--c-surface);
}
.field input::placeholder,
.field textarea::placeholder { color: var(--c-text-muted); }

.field-hint {
  display: block;
  margin-top: 5px;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--c-text-muted);
}
.field-location .field-hint { margin: 0 0 12px; }

/* --- mode switch: new incident vs. adding to an existing one --- */
.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin-bottom: 18px;
  padding: 4px;
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  background: var(--c-surface-2);
}

.mode-tab {
  padding: 8px 10px;
  border: none;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--c-text-muted);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.mode-tab:hover { color: var(--c-text); }
.mode-tab.is-active {
  background: var(--c-surface);
  color: var(--c-accent);
  box-shadow: var(--shadow-sm);
}

.mode-is-new .only-addition { display: none; }
.mode-is-addition .only-new { display: none; }

/* --- picking the incident an addition belongs to --- */
.target-results {
  max-height: 232px;
  overflow-y: auto;
  overscroll-behavior: contain;
  margin-top: 8px;
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  background: var(--c-surface-2);
}

.target-option {
  display: block;
  width: 100%;
  text-align: start;
  padding: 9px 11px;
  border: none;
  border-bottom: 1px solid var(--c-border-soft);
  background: transparent;
  cursor: pointer;
  transition: background .12s;
}
.target-option:last-child { border-bottom: none; }
.target-option:hover { background: var(--c-accent-weak); }

.target-option-date {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--c-accent);
}
.target-option-title {
  display: block;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
  margin: 2px 0;
}
.target-option-region {
  display: block;
  font-size: 11.5px;
  color: var(--c-text-muted);
}

.target-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 12px;
  border: 1px solid var(--c-accent);
  border-radius: var(--r-md);
  background: var(--c-accent-weak);
}
.target-card-body { min-width: 0; }
.target-card-date {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--c-accent);
}
.target-card-title {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.35;
  margin: 2px 0;
}
.target-card-region {
  display: block;
  font-size: 11.5px;
  color: var(--c-text-muted);
}

/* --- one video link row, with its live check and preview --- */
.video-input-row {
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px dashed var(--c-border-soft);
}
.video-input-row:last-child { border-bottom: none; margin-bottom: 4px; }

.video-input-line {
  display: flex;
  align-items: center;
  gap: 6px;
}
.video-input-row .video-url { flex: 1; min-width: 0; }
.video-input-row.is-valid   .video-url { border-color: var(--c-accent); }
.video-input-row.is-invalid .video-url { border-color: var(--c-danger); }

.remove-video { width: 32px; height: 32px; flex: none; }
.remove-video svg { width: 12px; height: 12px; }

.video-status {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin-top: 6px;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--c-text-muted);
}
.video-status .status-icon { font-weight: 700; flex: none; }
.is-valid   .video-status .status-icon { color: var(--c-accent); }
.is-invalid .video-status { color: var(--c-danger); }

.video-preview { margin-top: 8px; }

.video-preview-box {
  position: relative;
  max-width: 100%;
  border-radius: var(--r-sm);
  overflow: hidden;
  background: #000;
  border: 1px solid var(--c-border);
}
.video-preview-box iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.form-error {
  margin: 4px 0 14px;
  padding: 10px 12px;
  border: 1px solid var(--c-danger);
  border-radius: var(--r-sm);
  background: var(--c-danger-weak);
  color: var(--c-danger);
  font-size: 12.5px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

/* Pinned to the bottom of the dialog: the live link previews grow and
   shrink above it, and the primary action must not move under the cursor. */
.form-actions {
  position: sticky;
  bottom: 0;
  z-index: 2;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
  padding: 16px 0 28px;
  border-top: 1px solid var(--c-border-soft);
  background: var(--c-surface);
}
.modal-content--form { padding-bottom: 0; }
.submit-success { padding-bottom: 28px; }

.submit-success {
  padding: 20px 0 8px;
  text-align: center;
}
.submit-success svg {
  width: 52px; height: 52px;
  color: var(--c-accent);
  margin-bottom: 12px;
}
.submit-success h3 { margin: 0 0 8px; font-size: 17px; }
.submit-success p { margin: 0 auto 20px; max-width: 40ch; color: var(--c-text-muted) !important; }

/* ---------- Loading overlay ---------- */
#loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: var(--c-bg);
  transition: opacity .4s;
}
#loading-overlay.hidden { opacity: 0; pointer-events: none; }
#loading-overlay p {
  margin: 0;
  max-width: 30ch;
  text-align: center;
  font-size: 13.5px;
  color: var(--c-text-muted);
}

.spinner {
  width: 34px;
  height: 34px;
  border: 3px solid var(--c-border);
  border-top-color: var(--c-accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* =============================================================
   RESPONSIVE
   ============================================================= */

/* Narrower desktops: shrink the rails before stacking them. */
@media (max-width: 1180px) {
  #filter-panel { width: 274px; }
  #detail-panel, #list-panel { width: min(370px, 38vw); }
  .search-bar { max-width: 260px; }
}

@media (max-width: 980px) {
  .platform-title { font-size: 12.5px; max-width: 190px; }
  .btn-primary .btn-label { display: none; }
  .btn-primary { padding: 0; width: 36px; }
  .btn-primary svg { width: 15px; height: 15px; }
}

/* ---------- Mobile / tablet: rails become sheets ---------- */
@media (max-width: 860px) {
  :root { --header-h: 56px; --rail-gap: 0px; }

  .only-mobile { display: inline-flex !important; }

  /* Header: search collapses behind a toggle */
  #main-header { gap: 8px; padding-inline: 10px; }
  .platform-title { display: none; }

  .search-bar {
    position: absolute;
    inset-inline: 10px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 5;
    max-width: none;
    margin: 0;
    display: none;
  }
  body.search-open .search-bar { display: block; }
  body.search-open .header-left,
  body.search-open .header-right > *:not(#search-toggle) { visibility: hidden; }
  body.search-open #search-toggle { position: relative; z-index: 6; }

  /* Bottom sheets */
  #filter-panel,
  #detail-panel,
  #list-panel {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    max-height: 86vh;
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    border-inline: none;
    border-bottom: none;
    box-shadow: var(--shadow-lg);
    padding-bottom: env(safe-area-inset-bottom);
  }

  #filter-panel {
    transform: translateY(100%);
    transition: transform .3s cubic-bezier(.22, .61, .36, 1);
    z-index: 820;
  }
  #filter-panel.open { transform: none; }

  #detail-panel,
  #list-panel {
    transform: translateY(100%);
    opacity: 1;
    transition: transform .3s cubic-bezier(.22, .61, .36, 1);
  }
  #detail-panel.active,
  #list-panel.active { transform: none; }

  .sheet-grip {
    display: block;
    width: 40px;
    height: 4px;
    margin: 9px auto 2px;
    border-radius: 999px;
    background: var(--c-border);
    flex: none;
    cursor: grab;
  }

  .panel-head { padding: 12px 16px; }

  #detail-panel { max-height: 88vh; }

  /* Give the map's zoom buttons room above the FAB */
  .leaflet-bottom.leaflet-right { bottom: 68px; }
}

@media (max-width: 560px) {
  .modal { padding: 0; align-items: flex-end; }

  .modal-content {
    max-width: none;
    max-height: 94vh;
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    border-inline: none;
    border-bottom: none;
    padding: 22px 18px calc(22px + env(safe-area-inset-bottom));
    transform: translateY(100%);
  }
  .modal.active .modal-content { transform: none; }

  .form-row { grid-template-columns: 1fr; gap: 0; }
  .form-actions { padding-bottom: calc(18px + env(safe-area-inset-bottom)); }
  .form-actions .btn { flex: 1; height: 42px; }
  .modal-content--form { padding-bottom: 0; }
  .submit-success { padding-bottom: calc(18px + env(safe-area-inset-bottom)); }

  .field input,
  .field select,
  .field textarea {
    /* 16px keeps iOS Safari from zooming the viewport on focus */
    font-size: 16px;
    padding: 11px;
  }

  .modal-content h2 { font-size: 17px; }
  #detail-panel, #list-panel, #filter-panel { max-height: 90vh; }
  #pick-banner { font-size: 12px; padding: 9px 13px; gap: 9px; }
}

@media (max-height: 520px) and (max-width: 860px) {
  #filter-panel, #detail-panel, #list-panel { max-height: 94vh; }
}

/* ---------- Motion / print ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
