/* TH EYES — Apple-style glass design layer (loaded after style.css; remove the <link> to roll back). */
:root {
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Sukhumvit Set", "Segoe UI Variable Text", "Segoe UI", "Leelawadee UI", "Noto Sans Thai", system-ui, sans-serif;
  --glass: rgba(28, 28, 32, 0.52);
  --glass-strong: rgba(28, 28, 32, 0.72);
  --glass-hover: rgba(255, 255, 255, 0.12);
  --glass-edge: rgba(255, 255, 255, 0.16);
  --glass-hi: inset 0 1px 0 rgba(255, 255, 255, 0.14);
  --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.28), 0 1px 2px rgba(0, 0, 0, 0.2);
  --blur: blur(24px) saturate(180%);
  --fg: #f5f5f7;
  --muted: rgba(235, 235, 245, 0.7);
  --accent: #e11d48;
  --tint: #0a84ff;
  --tint-text: #4da3ff;
  --tint-solid: #0064d2;
  --tint-soft: rgba(10, 132, 255, 0.22);
  --ok: #30d158;
  --r-pill: 999px;
  --r-card: 20px;
  --r-row: 12px;
  --ease: cubic-bezier(0.25, 0.1, 0.25, 1);
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);
  --bg: var(--glass);
  --border: var(--glass-edge);
}
[data-theme='light'] {
  --glass: rgba(255, 255, 255, 0.58);
  --glass-strong: rgba(255, 255, 255, 0.8);
  --glass-hover: rgba(0, 0, 0, 0.06);
  --glass-edge: rgba(255, 255, 255, 0.7);
  --glass-hi: inset 0 1px 0 rgba(255, 255, 255, 0.9);
  --glass-shadow: 0 8px 30px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.08);
  --fg: #1d1d1f;
  --muted: rgba(60, 60, 67, 0.82);
  --accent: #d70f3d;
  --tint: #007aff;
  --tint-text: #0058b8;
  --tint-soft: rgba(0, 122, 255, 0.14);
  --ok: #166534;
}

html, body { font-family: var(--font); font-size: 14px; -webkit-font-smoothing: antialiased; }
button, a, input, select { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.small, .player-meta, .chip .n, .badge { letter-spacing: 0.01em; }

/* Shared glass material */
button, .pill, .actions input, .panel, .player, .results, .forecast-strip, .dams,
.maplibregl-ctrl-group, .maplibregl-popup-content {
  background: var(--glass);
  border: 0.5px solid var(--glass-edge);
  box-shadow: var(--glass-hi), var(--glass-shadow);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  color: var(--fg);
}

button {
  border-radius: var(--r-pill);
  padding: 7px 14px;
  font-weight: 500;
  transition: transform 140ms var(--ease-out), background-color 180ms ease, color 180ms ease, box-shadow 180ms ease, opacity 180ms ease;
}
@media (hover: hover) and (pointer: fine) {
  button:hover { border-color: var(--glass-edge); background: var(--glass-strong); }
}
button:active { transform: scale(0.97); transition-duration: 100ms; }
:focus-visible { outline: 2px solid var(--tint); outline-offset: 2px; }

/* Top bar */
.topbar, .actions { top: 14px; }
.brand { font-weight: 700; letter-spacing: -0.02em; }
.pill { padding: 7px 14px; border-radius: var(--r-pill); font-weight: 500; font-variant-numeric: tabular-nums; }

/* Toolbar as one glass capsule (Apple segmented toolbar) */
.actions {
  gap: 2px; padding: 4px; align-items: center;
  background: var(--glass); border: 0.5px solid var(--glass-edge); border-radius: var(--r-pill);
  box-shadow: var(--glass-hi), var(--glass-shadow);
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
}
.actions > button { background: transparent; border-color: transparent; box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none; padding: 6px 12px; }
.actions > button:hover { background: var(--glass-hover); }
.actions > button.primary { background: var(--accent); color: #fff; box-shadow: 0 2px 10px rgba(255, 45, 85, 0.35); }
.actions > button.primary:hover { filter: brightness(1.08); }
#radar.on { background: var(--tint-soft); color: var(--tint-text); border-color: transparent; }
.actions input {
  width: 220px; padding: 6px 14px 6px 32px; box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none;
  background: var(--glass-hover) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238e8e93' stroke-width='2.5' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-4-4'/%3E%3C/svg%3E") no-repeat 12px center;
  border-color: transparent; outline: none;
}
.actions input:focus { box-shadow: 0 0 0 3px var(--tint-soft); }

/* Map controls sit under the toolbar */
.maplibregl-ctrl-top-right { top: 64px; right: 4px; }
.maplibregl-ctrl-group { border-radius: 14px; overflow: hidden; }
.maplibregl-ctrl-group button { background: transparent; border: 0; box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none; border-radius: 0; padding: 0; }
.maplibregl-ctrl-group button:hover { background: var(--glass-hover); }
[data-theme='dark'] .maplibregl-ctrl-group button .maplibregl-ctrl-icon { filter: invert(1); }
.maplibregl-ctrl-attrib { background: var(--glass) !important; -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); border-radius: var(--r-pill) 0 0 0; }

/* Filter chips: quiet when off, tinted when on */
.filters { right: 260px; bottom: 34px; gap: 8px; }
.maplibregl-ctrl-bottom-right { bottom: 52px; }
.filters .row { gap: 6px; }
.chip { opacity: 1; color: var(--muted); padding: 6px 12px; font-size: 13px; }
.chip.on { color: var(--fg); border-color: var(--glass-edge); background: var(--glass-strong); box-shadow: var(--glass-hi), var(--glass-shadow), inset 0 0 0 1.5px var(--tint); }
.chip .n { color: var(--muted); font-variant-numeric: tabular-nums; }
.filters .row { align-items: center; }
.row-items { display: contents; }
.row-label { width: 56px; flex: none; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6); }
.row-sep { width: 1px; height: 18px; margin: 0 4px; background: var(--glass-edge); flex: none; }
#radar.on, #radar[aria-pressed='true'] { background: var(--tint-soft); color: var(--tint-text); }

/* Radar timeline */
.radar-bar { display: flex; align-items: center; gap: 2px; padding: 0 14px 0 4px; border-radius: var(--r-pill); background: var(--glass); border: 0.5px solid var(--glass-edge); box-shadow: var(--glass-hi), var(--glass-shadow); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); color: var(--fg); }
.radar-bar[hidden] { display: none; }
.radar-bar button { background: transparent; border: 0; box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none; padding: 6px 8px; display: inline-flex; align-items: center; color: var(--fg); }
.radar-bar button svg { width: 16px; height: 16px; fill: currentColor; display: block; }
.radar-bar button:hover { color: var(--tint-text); }
.radar-bar .ic-pause, .radar-bar.playing .ic-play { display: none; }
.radar-bar.playing .ic-pause { display: block; }
.radar-bar input[type='range'] { width: 130px; margin: 0 8px; accent-color: var(--tint); }
.radar-time { min-width: 118px; font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Hover preview on camera pins */
.cam-pop .maplibregl-popup-content { padding: 0; overflow: hidden; border-radius: 14px; background: #000; }
.cam-pop.maplibregl-popup-anchor-bottom .maplibregl-popup-tip { border-top-color: #000; }
.cam-pop.maplibregl-popup-anchor-top .maplibregl-popup-tip { border-bottom-color: #000; }
.cam-preview { width: 320px; color: #fff; }
.cam-preview-media { aspect-ratio: 16 / 9; background: #000; }
.cam-preview-media img, .cam-preview-media video { width: 100%; height: 100%; object-fit: cover; display: block; }
.cam-preview-cap { display: flex; justify-content: space-between; gap: 8px; padding: 7px 10px; font-size: 12px; }
.cam-preview-cap strong { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cam-preview-cap span { color: rgba(255, 255, 255, 0.6); flex: none; }

/* Larger player (not full screen) */
.player { transition-property: opacity, transform, width, display, overlay; }
.player.large { width: min(960px, calc(100vw - 28px)); }

/* Floating corner buttons */
.corner-btns { position: fixed; z-index: 6; right: 14px; bottom: 14px; display: flex; flex-wrap: wrap-reverse; justify-content: flex-end; gap: 8px; max-width: calc(100vw - 28px); }
.corner-btns > button { position: static; font-size: 13px; white-space: nowrap; }
body:has(.player:not([hidden])) .corner-btns { display: none; }
.legend { width: min(300px, calc(100vw - 24px)); }
.legend-row { display: grid; gap: 4px; }
.legend-title { font-size: 12px; font-weight: 600; color: var(--muted); }
.legend-items { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; }
.legend-items span { display: inline-flex; align-items: center; gap: 5px; }
.sos-btn { background: rgba(255, 59, 48, 0.9); color: #fff; border-color: transparent; font-weight: 600; }
.sos-list { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 4px; }
.sos-list a { display: flex; gap: 12px; align-items: baseline; padding: 8px 10px; border-radius: 10px; background: var(--glass-hover); color: var(--fg); text-decoration: none; }
.sos-list a:hover { background: var(--glass-strong); }
.sos-list strong { min-width: 44px; font-size: 16px; color: #ff453a; font-variant-numeric: tabular-nums; }
.sos-links { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 13px; }
.sos-links a { color: var(--tint-text); }
#sosList h4 { margin: 6px 0; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.filters .row[hidden] { display: none; }
.filter-tabs .tab[aria-expanded='true']::after { content: ' ▾'; }
.filter-tabs .tab[aria-expanded='false']::after { content: ' ▴'; }

/* Cards & panels */
.panel, .player, .dams, .results { border-radius: var(--r-card); }
.panel { top: 66px; background: var(--glass-strong); }
.sources, .social { top: auto; bottom: 58px; max-height: calc(100vh - 140px); }
.contact { top: 66px; left: 14px; right: auto; z-index: 9; width: min(340px, calc(100vw - 24px)); transform-origin: top left; }
.contact p { margin: 0; font-size: 13px; line-height: 1.5; }
.contact-mail { color: var(--tint-text); font-weight: 600; word-break: break-all; }
.contact .feedback-form { border-top-color: var(--glass-edge); }
.panel { scrollbar-width: thin; scrollbar-color: var(--glass-edge) transparent; }
.panel-head { padding: 12px 14px; border-bottom: 0.5px solid var(--glass-edge); }
.panel-head strong { font-weight: 600; letter-spacing: -0.01em; }
.panel-head button, .player-head button {
  width: 28px; height: 28px; padding: 0; display: inline-grid; place-items: center;
  background: var(--glass-hover); border-color: transparent; box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none; font-size: 12px;
}
.panel-head #logout { width: auto; padding: 0 12px; }
.panel-body { padding: 14px; gap: 12px; }
.panel input:not([type=checkbox]), .panel select, .panel textarea {
  background: var(--glass-hover); border: 0.5px solid var(--glass-edge); border-radius: var(--r-row); padding: 9px 12px;
  transition: box-shadow 0.18s var(--ease);
}
.panel input:focus, .panel select:focus, .panel textarea:focus { outline: none; box-shadow: 0 0 0 3px var(--tint-soft); border-color: var(--tint); }
.panel select {
  appearance: none; -webkit-appearance: none; padding-right: 34px; text-overflow: ellipsis;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none' stroke='%238e8e93' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1.5 1.5 6 6l4.5-4.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 13px center; background-size: 12px 8px;
}
.panel .loc button { box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none; background: var(--glass-hover); border-color: transparent; }
button.primary { background: var(--accent); color: #fff; border-color: transparent; font-weight: 600; }
.panel button[type=submit].primary { border-radius: var(--r-row); padding: 11px; }

.results { top: 66px; padding: 6px; background: var(--glass-strong); }
.results li button, .results li { border-radius: 10px; }
.results li button { box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none; }
.results li button:hover, .results li:hover { background: var(--glass-hover); }

/* Player */
.player { right: 14px; bottom: 14px; background: var(--glass-strong); }
.player { max-height: calc(100dvh - 24px); overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.player-head { padding: 10px 12px; position: sticky; top: 0; z-index: 2; background: var(--glass-strong); }
.player-head strong { font-weight: 600; }
.player-body { margin: 0 8px; border-radius: 14px; overflow: hidden; }
.player-meta { padding: 10px 12px 12px; line-height: 1.5; }
.badge { border-radius: var(--r-pill); padding: 3px 9px; letter-spacing: 0.02em; }

/* Status strips and dams */
.forecast-strip { top: 76px; left: 16px; width: min(380px, calc(100vw - 24px)); max-height: min(60vh, calc(100vh - 160px)); overflow: auto; border-radius: 16px; border: 0.5px solid var(--glass-edge); box-shadow: var(--glass-hi), var(--glass-shadow); padding: 6px; display: flex; flex-direction: column; gap: 2px; }
.forecast-strip.collapsed { width: auto; }
.forecast-strip button, .forecast-strip a { box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none; background: transparent; border: 0; color: var(--fg); text-align: left; }
.fc-head { display: flex; align-items: center; }
.fc-title { flex: 1; font-weight: 600; padding: 4px 8px; }
.fc-x { padding: 2px 8px; color: var(--muted) !important; }
.fc-official { display: block; margin: 2px 4px; padding: 6px 8px !important; border-radius: 10px; background: rgba(220, 38, 38, 0.1) !important; text-decoration: none; font-size: 12px; line-height: 1.4; }
.fc-label { font-size: 11px; color: var(--muted); padding: 2px 8px 4px; }
.fc-tag { display: inline-block; font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 999px; letter-spacing: 0.02em; }
.fc-tag.official { background: #dc2626; color: #fff; }
.fc-tag.model { background: var(--glass-hover); color: var(--fg); }
.fc-row { display: grid; grid-template-columns: 10px 1fr auto; column-gap: 8px; align-items: center; padding: 6px 8px; border-radius: 10px; font-size: 13px; }
.fc-row:hover { background: var(--glass-hover) !important; }
.fc-dot { width: 10px; height: 10px; border-radius: 50%; }
.fc-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fc-you { margin-left: 6px; font-size: 10px; font-weight: 700; color: #fff; background: var(--tint); border-radius: 999px; padding: 1px 6px; }
.fc-risk { font-size: 12px; color: var(--muted); }
.fc-meta { grid-column: 2 / 4; font-size: 11px; color: var(--muted); }
.fc-more { font-size: 12px; color: var(--tint-text) !important; padding: 4px 8px; }
.dams { top: 76px; left: auto; right: 56px; width: 290px; max-height: min(50vh, calc(100vh - 160px)); }
.dam-row, .dam-row:hover { box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none; border-color: transparent; }
.dam-row { background: transparent; border-radius: 8px; }
.dam-row:hover { background: var(--glass-hover); }
.dam-bar { height: 6px; border-radius: 3px; background: var(--glass-hover); }

/* Lists inside panels: flat rows, no nested glass */
.social-tabs button, .social-out a, .mine li .b button, .near-cams button, .cam-status button, .results .linkish, .tt-card a {
  box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none;
}
.social-tabs button { background: var(--glass-hover); border-color: transparent; }
.social-tabs button.on { background: var(--tint-solid); color: #fff; }
.social-list li a { border-radius: 10px; }
.social-list li a:hover { background: var(--glass-hover); }
.social-list .new { color: var(--ok); }
.mine li { border: 0.5px solid var(--glass-edge); border-radius: var(--r-row); background: var(--glass-hover); }
.near-cams button { border-radius: var(--r-row); }
.sources-list a { color: var(--tint-text); }
.verified { color: var(--ok); }

/* Popups */
.maplibregl-popup-content { border-radius: 12px; padding: 8px 12px; font-size: 13px; background: var(--glass-strong); }
.maplibregl-popup-anchor-bottom .maplibregl-popup-tip { border-top-color: var(--glass-strong); }
.maplibregl-popup-anchor-top .maplibregl-popup-tip { border-bottom-color: var(--glass-strong); }
.offline-pop .maplibregl-popup-content { background: rgba(0, 0, 0, 0.82); color: #fff; }

/* Pin hint */
.pin-hint { top: 70px; padding: 6px 6px 6px 16px; background: rgba(255, 45, 85, 0.88); border: 0.5px solid rgba(255, 255, 255, 0.3); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); box-shadow: 0 8px 28px rgba(255, 45, 85, 0.35); }
.pin-hint button { box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none; padding: 5px 14px; }

/* Surfaces materialize from their trigger; exit is faster than enter. Transitions (not keyframes) so rapid toggles retarget. */
.panel, .player, .results, .dams, .pin-hint {
  transition: opacity 220ms var(--ease-out), transform 220ms var(--ease-out), display 220ms allow-discrete, overlay 220ms allow-discrete;
}
.panel, .results { transform-origin: top right; }
.sources, .social, .player { transform-origin: bottom right; }
.dams { transform-origin: top right; }
.pin-hint { transform-origin: top center; }
.panel[hidden], .player[hidden], .results[hidden], .dams[hidden], .pin-hint[hidden] {
  display: none; opacity: 0; transform: scale(0.96);
  transition-duration: 140ms;
}
.pin-hint[hidden] { transform: translateX(-50%) translateY(-8px); }
@starting-style {
  .panel:not([hidden]), .player:not([hidden]), .results:not([hidden]), .dams:not([hidden]) { opacity: 0; transform: scale(0.96); }
  .pin-hint:not([hidden]) { opacity: 0; transform: translateX(-50%) translateY(-8px); }
}
.chip { transition: transform 140ms var(--ease-out), background-color 180ms ease, color 180ms ease, box-shadow 180ms ease; }
.maplibregl-popup { animation: pop-in 150ms var(--ease-out); }
@keyframes pop-in { from { opacity: 0; } }

/* Reduced motion keeps comprehension-aiding fades but drops movement. */
@media (prefers-reduced-motion: reduce) {
  button:active { transform: none; }
  .panel, .player, .results, .dams, .pin-hint { transition-property: opacity, display, overlay; }
  .panel[hidden], .player[hidden], .results[hidden], .dams[hidden] { transform: none; }
  .pin-hint[hidden] { transform: translateX(-50%); }
  @starting-style {
    .panel:not([hidden]), .player:not([hidden]), .results:not([hidden]), .dams:not([hidden]) { transform: none; }
    .pin-hint:not([hidden]) { transform: translateX(-50%); }
  }
}
@media (prefers-reduced-transparency: reduce) {
  :root { --glass: rgba(28, 28, 32, 0.95); --glass-strong: rgba(28, 28, 32, 0.98); --blur: none; }
  [data-theme='light'] { --glass: rgba(255, 255, 255, 0.96); --glass-strong: #fff; }
}
@media (prefers-contrast: more) {
  :root { --glass: rgba(10, 10, 12, 0.94); --glass-strong: rgba(10, 10, 12, 0.97); --glass-edge: rgba(255, 255, 255, 0.55); --muted: rgba(235, 235, 245, 0.85); }
  [data-theme='light'] { --glass: rgba(255, 255, 255, 0.97); --glass-strong: #fff; --glass-edge: rgba(0, 0, 0, 0.5); --muted: rgba(60, 60, 67, 0.9); }
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  :root { --glass: rgba(28, 28, 32, 0.92); --glass-strong: rgba(28, 28, 32, 0.96); }
  [data-theme='light'] { --glass: rgba(255, 255, 255, 0.94); --glass-strong: rgba(255, 255, 255, 0.97); }
}

@media (max-width: 1100px) {
  .actions { border-radius: 22px; }
  .maplibregl-ctrl-top-right { top: 108px; }
}
@media (max-width: 1250px), (pointer: coarse) and (max-width: 1400px) {
  .filters { right: 12px; bottom: 60px; }
  .corner-btns { left: 8px; right: 8px; bottom: 12px; max-width: none; flex-wrap: nowrap; justify-content: flex-start; overflow-x: auto; scrollbar-width: none; }
  .corner-btns::-webkit-scrollbar { display: none; }
  .corner-btns > button { flex: none; }
  .radar-bar { position: fixed; z-index: 6; bottom: calc(68px + var(--filters-h, 36px)); left: 8px; right: 8px; padding-right: 10px; }
  .radar-bar input[type='range'] { flex: 1; min-width: 0; width: auto; }
  .radar-time { min-width: 0; font-size: 12px; }
  .filters .row { flex-wrap: nowrap; overflow-x: auto; max-width: 100%; scrollbar-width: none; padding: 2px; }
  .filters .row::-webkit-scrollbar { display: none; }
  .chip { flex: none; }
  .row-label { display: none; }
  #pExpand { display: none; }
  .topbar { top: 10px; left: 8px; }
  .actions { top: 60px; left: 8px; right: 8px; flex-wrap: nowrap; justify-content: flex-start; overflow-x: auto; scrollbar-width: none; border-radius: var(--r-pill); }
  .actions::-webkit-scrollbar { display: none; }
  .actions > * { flex: none; }
  .actions input { width: 140px; }
  .forecast-strip { top: 124px; left: 8px; right: 8px; width: auto; max-width: none; max-height: 40vh; }
  .forecast-strip.collapsed { right: auto; }
  .maplibregl-ctrl-top-right { top: 190px; }
  .results { top: 124px; }
  .player { left: 8px; right: 8px; bottom: 8px; width: auto; max-height: calc(100dvh - 16px); }
  .panel { top: auto; bottom: 8px; left: 8px; right: 8px; width: auto; max-height: 75vh; transform-origin: bottom center; transition-timing-function: var(--ease-drawer); }
  .panel[hidden], .player[hidden] { transform: translateY(24px); }
  @starting-style {
    .panel:not([hidden]), .player:not([hidden]) { transform: translateY(24px); }
  }
}

/* Wider than a portrait phone, the toolbar is a single row, so the zoom controls sit closer to it. */
@media (min-width: 701px) and ((max-width: 1250px) or ((pointer: coarse) and (max-width: 1400px))) {
  .maplibregl-ctrl-top-right { top: 110px; }
  .forecast-strip { max-height: calc(100dvh - 200px); right: auto; width: min(380px, calc(100vw - 16px)); }
  .results { right: auto; width: min(420px, calc(100vw - 24px)); }
  .panel { left: auto; width: min(420px, calc(100vw - 16px)); }
  .player:not(.large) { left: auto; width: min(560px, calc(100vw - 16px)); }
}

/* User posts */
.post-tabs { display: flex; gap: 6px; padding: 10px 14px 0; }
.post-tabs button { flex: 1; box-shadow: none; background: transparent; border: 0.5px solid var(--glass-edge); color: var(--muted); }
.post-tabs button[aria-selected='true'] { background: var(--glass-hover); color: var(--fg); box-shadow: inset 0 0 0 1.5px var(--tint); }
.drop { display: grid !important; place-items: center; gap: 4px; text-align: center; padding: 16px; border: 1.5px dashed var(--glass-edge); border-radius: var(--r-row); cursor: pointer; }
.drop:hover, .drop:focus-within { border-color: var(--tint); background: var(--glass-hover); }
.drop-preview:empty { display: none; }
.drop-preview img, .drop-preview video { max-width: 100%; max-height: 180px; border-radius: 10px; display: block; }
.tag-pick { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-pick .chip { padding: 5px 10px; }
.use-gps.pulse { animation: gps-pulse 1.2s ease-in-out 3; }
@keyframes gps-pulse { 50% { box-shadow: 0 0 0 4px var(--tint-soft); } }
#postProgress { width: 100%; height: 6px; accent-color: var(--accent); }
.player-body:has(.post-view) { aspect-ratio: auto; display: block; background: transparent; }
.post-view { background: #000; display: grid; place-items: center; max-height: 55vh; }
.post-view img, .post-view video { width: 100%; max-height: 55vh; object-fit: contain; display: block; }
.post-info { color: var(--fg); padding: 10px 4px 4px; }
.player-body:has(> .gauge-rows) { aspect-ratio: auto; display: block; place-items: normal; background: transparent; }
.gauge-rows { color: var(--fg); }
.gauge-rows a { color: var(--tint-text); }
.gauge-row { border-bottom-color: var(--glass-edge); }
.gauge-rows .near-cams button { color: var(--fg); border-color: var(--glass-edge); background: var(--glass-hover); }
.gauge-rows .row-items { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.aerial { position: relative; display: block; height: 200px; margin: 0 0 10px; border-radius: 12px; overflow: hidden; background: #1c1c1e; }
.aerial-grid { position: absolute; display: grid; grid-template-columns: repeat(3, 256px); width: 768px; }
.aerial-grid img { width: 256px; height: 256px; display: block; }
.aerial-pin { position: absolute; left: 50%; top: 50%; width: 16px; height: 16px; margin: -8px 0 0 -8px; border-radius: 50%; background: #ef4444; border: 3px solid #fff; box-shadow: 0 0 0 6px rgba(239, 68, 68, 0.35); }
.aerial-cap { position: absolute; right: 6px; bottom: 6px; font-size: 10px; color: #fff; background: rgba(0, 0, 0, 0.55); padding: 2px 6px; border-radius: 6px; }
.post-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.post-tag { font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: var(--r-pill); background: color-mix(in srgb, var(--c) 22%, transparent); border: 1px solid var(--c); }
.post-caption { margin: 8px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.post-acts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.badge.post { background: #f472b6; color: #000; }
.toast { position: fixed; left: 50%; bottom: 72px; transform: translateX(-50%); z-index: 12; max-width: calc(100vw - 32px); padding: 10px 18px; border-radius: var(--r-pill); background: var(--glass-strong); color: var(--fg); border: 0.5px solid var(--glass-edge); box-shadow: var(--glass-hi), var(--glass-shadow); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); font-weight: 600; cursor: pointer; }
.toast[hidden] { display: none; }
.panel-body[hidden] { display: none; }
.player-head button[hidden] { display: none; }
.post-info .near-cams button { color: var(--fg); border-color: var(--glass-edge); background: var(--glass-hover); }

/* Rain outlook strip */
.wx[hidden] { display: none; }
.wx { padding: 8px 12px 0; color: var(--fg); }
.wx-sum { font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.wx-hours { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(34px, 1fr); gap: 3px; overflow-x: auto; scrollbar-width: none; }
.wx-h { position: relative; display: grid; justify-items: center; gap: 1px; padding: 4px 0 3px; border-radius: 8px; font-size: 11px; background: var(--glass-hover); overflow: hidden; }
.wx-h::before { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: var(--p); background: rgba(10, 132, 255, 0.28); z-index: 0; }
.wx-h > span { position: relative; z-index: 1; }
.wx-h.storm { box-shadow: inset 0 0 0 1.5px #ffd60a; }
.wx-t { color: var(--fg); opacity: 0.85; }
.wx-i { font-size: 15px; line-height: 1.2; }
.wx-p { font-weight: 600; }
.wx-mm { color: var(--fg); opacity: 0.85; font-size: 10px; min-height: 12px; }
.wx-src { margin-top: 4px; font-size: 10px; }
.wx-days-h { margin-top: 8px; }
.wx-days { grid-auto-columns: minmax(40px, 1fr); }

/* Desktop: keep side panels clear of the map zoom/compass column */
@media (min-width: 1251px) and (not ((pointer: coarse) and (max-width: 1400px))) {
  .panel { right: 56px; }
}


/* Consistency pass: one type scale, one row radius, one emphasis weight, form controls inherit the UI font. */
button, input, select, textarea, option { font-family: inherit; }
.corner-btns > button, .radar-time, .legend-items { font-size: 13px; }
.radar-time { font-size: 13px; }
.social-list .meta, .fc-meta, .fc-label, .social-tabs button, .social-out a { font-size: 12px; }
.fc-tag, .fc-you, .badge, .social-list .new, .corner-btns > .more-btn, .rc-x.now { font-weight: 600; }
.results li, .results li button, .fc-row, .fc-official, .sos-list a, .social-list li a, .dam-row, .ai-alert, .near-cams button, .mine li { border-radius: var(--r-row); }
.cam-report button, .badge { border-radius: var(--r-pill); }
.sources, .social { max-height: calc(100dvh - 140px); }

/* Tablet toolbar is one row (60-103px): start the AI stack below it, like the other top-left cards. */
@media (min-width: 701px) and ((max-width: 1250px) or ((pointer: coarse) and (max-width: 1400px))) {
  .tl-stack { top: 116px; max-height: calc(100dvh - 190px); }
}
/* Phones: keep the AI card clear of the zoom/compass column on the right. */
@media (max-width: 700px) {
  .tl-stack { right: 54px; }
}

/* Safe areas (notch / home bar): bottom- and side-anchored UI clears the iPhone insets. Needs viewport-fit=cover. */
:root { --sab: env(safe-area-inset-bottom, 0px); --sal: env(safe-area-inset-left, 0px); --sar: env(safe-area-inset-right, 0px); }
.g-logo { bottom: calc(8px + var(--sab)); left: max(10px, var(--sal)); }
.g-copy { bottom: calc(8px + var(--sab)); left: calc(max(10px, var(--sal)) + 72px); }
.topbar { left: max(12px, var(--sal)); }
.filters { bottom: calc(34px + var(--sab)); left: max(12px, var(--sal)); }
.corner-btns { bottom: calc(14px + var(--sab)); right: max(14px, var(--sar)); }
.player { bottom: calc(14px + var(--sab)); right: max(14px, var(--sar)); }
.sources, .social, #forecast { bottom: calc(58px + var(--sab)); }
.maplibregl-ctrl-bottom-right { bottom: calc(52px + var(--sab)); }
.maplibregl-ctrl-bottom-left { bottom: var(--sab); }
.toast { bottom: calc(72px + var(--sab)); }
@media (min-width: 1251px) and (not ((pointer: coarse) and (max-width: 1400px))) {
  .panel { right: max(56px, var(--sar)); }
}
@media (max-width: 1250px), (pointer: coarse) and (max-width: 1400px) {
  .filters { right: max(12px, var(--sar)); bottom: calc(60px + var(--sab)); left: max(12px, var(--sal)); }
  .corner-btns { left: max(8px, var(--sal)); right: max(8px, var(--sar)); bottom: calc(12px + var(--sab)); }
  .radar-bar { left: max(8px, var(--sal)); right: max(8px, var(--sar)); bottom: calc(68px + var(--filters-h, 36px) + var(--sab)); }
  .topbar { left: max(8px, var(--sal)); }
  .actions { left: max(8px, var(--sal)); right: max(8px, var(--sar)); }
  .forecast-strip { left: max(8px, var(--sal)); }
  .player { left: max(8px, var(--sal)); right: max(8px, var(--sar)); bottom: calc(8px + var(--sab)); max-height: calc(100dvh - 16px - var(--sab)); }
  .panel { bottom: calc(8px + var(--sab)); left: max(8px, var(--sal)); right: max(8px, var(--sar)); max-height: calc(75vh - var(--sab)); }
  .tl-stack { left: max(8px, var(--sal)); }
}
@media (min-width: 701px) and ((max-width: 1250px) or ((pointer: coarse) and (max-width: 1400px))) {
  .player:not(.large) { left: auto; }
  .panel { left: auto; }
}
@media (max-width: 700px) {
  #forecast { bottom: calc(8px + var(--sab)); left: max(8px, var(--sal)); right: max(8px, var(--sar)); }
  .tl-stack { right: max(54px, var(--sar)); }
}
:root { --sat: env(safe-area-inset-top, 0px); }
.topbar { top: calc(12px + var(--sat)); }
@media (max-width: 1250px), (pointer: coarse) and (max-width: 1400px) {
  .topbar { top: calc(10px + var(--sat)); }
  .actions { top: calc(60px + var(--sat)); }
}

/* Inline SVG icon set (icons.js): currentColor strokes aligned with the label. */
.ic { width: 15px; height: 15px; vertical-align: -2.5px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.brand .ic { width: 17px; height: 17px; vertical-align: -3.5px; }
.chip .ic, .sources-btn .ic, .social-btn .ic, .sos-btn .ic { width: 14px; height: 14px; vertical-align: -2px; }
.lb:not(:empty) { margin-left: 6px; }
.panel-head .ic { vertical-align: -2.5px; }

/* ── Air quality layer (2026-10-03) ─────────────────────────────────────────
   The legend lives inside .filters (bottom-left column), so it stacks above the
   chip rows instead of floating over them; --filters-h (ResizeObserver) then
   lifts the mobile radar bar, and the AI/timeline stack is capped to end above it. */
.aqi-legend {
  pointer-events: auto; width: min(320px, 100%); padding: 9px 12px 8px; border-radius: 16px;
  background: var(--glass-strong); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  border: 1px solid var(--glass-edge); box-shadow: var(--glass-hi), var(--glass-shadow);
  color: var(--fg); font-size: 12px; line-height: 1.35;
}
.aqi-legend[hidden] { display: none; }
.aqi-legend-t { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.aqi-legend-t span { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.aqi-legend-bar, .aqi-legend-lb { display: grid; grid-template-columns: repeat(5, 1fr); gap: 3px; }
.aqi-legend-bar i { height: 6px; border-radius: 3px; }
.aqi-legend-lb { margin-top: 4px; color: var(--muted); font-size: 10.5px; font-variant-numeric: tabular-nums; }
.aqi-legend-src { margin-top: 5px; color: var(--muted); font-size: 11px; }
/* Station card */
.aqi-head { display: flex; align-items: center; gap: 10px; margin: 2px 0 8px; }
.aqi-val { font-size: 30px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.aqi-pill { padding: 2px 10px; border-radius: var(--r-pill); color: #111; font-size: 12px; font-weight: 600; }
/* Keep the top-left AI/timeline stack clear of the bottom-left column, whatever its height. */
@media (min-width: 1251px) and (not ((pointer: coarse) and (max-width: 1400px))) {
  .tl-stack { max-height: max(160px, calc(100vh - 76px - 34px - 16px - var(--filters-h, 36px) - var(--sab))); }
}
@media (max-width: 1250px), (pointer: coarse) and (max-width: 1400px) {
  .aqi-legend { width: 100%; padding: 7px 10px; }
  .aqi-legend-lb, .aqi-legend-src { display: none; }
  .tl-stack { max-height: max(140px, calc(100dvh - 116px - 68px - 56px - var(--filters-h, 36px) - var(--sab))); }
}
@media (prefers-reduced-transparency: reduce) {
  .aqi-legend { -webkit-backdrop-filter: none; backdrop-filter: none; }
}
