/* VECO Outage Map — UX round 3 visual system (SPEC §19.3).
   Tier colours are the only saturated hues; chrome stays neutral so red/orange/yellow/green read at a glance. */

:root {
  --collapsed-sheet-height: 92px;
  --sidebar-w: 400px;

  --ink: #0f172a;
  --ink-2: #334155;
  --ink-3: #5b6b7c;
  --paper: #f4f6f9;
  --card: #ffffff;
  --line: #e2e8f0;
  --line-2: #c7d2de;
  --accent: #1d4ed8;
  --accent-ink: #1e3a8a;
  --accent-soft: #e0e9ff;

  --tier-off: #e5484d;
  --tier-soon: #f97316;
  --tier-later: #eab308;
  --tier-clear: #22c55e;
  --tier-unknown: #64748b;
  --tier-off-ink: #9f1239;
  --tier-soon-ink: #9a3412;
  --tier-later-ink: #854d0e;
  --tier-clear-ink: #166534;
  --tier-unknown-ink: #334155;
  --tier-off-soft: #fde7e8;
  --tier-soon-soft: #ffe8d6;
  --tier-later-soft: #fdf5c8;
  --tier-clear-soft: #dcf7e5;
  --tier-unknown-soft: #e6ebf1;

  --glass: rgb(255 255 255 / 86%);
  --glass-border: rgb(255 255 255 / 75%);
  --shadow-1: 0 1px 2px rgb(15 23 42 / 6%), 0 10px 28px rgb(15 23 42 / 12%);
  --shadow-2: 0 2px 8px rgb(15 23 42 / 12%);
  --radius: 14px;
  --radius-sm: 10px;

  color: var(--ink);
  background: var(--paper);
  color-scheme: light;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

* {
  box-sizing: border-box;
}

/* Display rules on classes must never outrank the hidden attribute. */
[hidden] {
  display: none !important;
}

html,
body,
#app,
.app-layout {
  min-height: 100%;
  height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
}

button,
input {
  min-height: 44px;
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 16px;
}

button {
  border: 1px solid var(--line-2);
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
  transition:
    background-color 120ms ease,
    box-shadow 120ms ease,
    transform 120ms ease;
}

button:hover {
  background: #f1f5f9;
}

a {
  color: var(--accent);
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
[tabindex]:focus-visible,
.area-list-item:focus-visible,
summary:focus-visible {
  outline: 3px solid #111827;
  outline-offset: 3px;
}

.selected-area:focus-visible {
  outline-offset: -3px;
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 10000;
  transform: translateY(-150%);
  background: var(--card);
  padding: 10px 14px;
  border: 2px solid #111827;
  border-radius: var(--radius-sm);
}

.skip-link:focus {
  transform: translateY(0);
}

.sr-only,
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* ---------- Layout ---------- */

.app-layout {
  display: grid;
  grid-template-areas: "map";
}

.map-pane {
  grid-area: map;
  min-width: 0;
  min-height: 0;
}

.map {
  width: 100%;
  height: 100%;
  background: #e6ecf1;
}

/* ---------- Tier vocabulary ---------- */

[data-tier="off"] {
  --tier: var(--tier-off);
  --tier-ink: var(--tier-off-ink);
  --tier-soft: var(--tier-off-soft);
}

[data-tier="soon"] {
  --tier: var(--tier-soon);
  --tier-ink: var(--tier-soon-ink);
  --tier-soft: var(--tier-soon-soft);
}

[data-tier="later"] {
  --tier: var(--tier-later);
  --tier-ink: var(--tier-later-ink);
  --tier-soft: var(--tier-later-soft);
}

[data-tier="clear"] {
  --tier: var(--tier-clear);
  --tier-ink: var(--tier-clear-ink);
  --tier-soft: var(--tier-clear-soft);
}

[data-tier="unknown"],
[data-tier="restored"],
[data-tier="cancelled"] {
  --tier: var(--tier-unknown);
  --tier-ink: var(--tier-unknown-ink);
  --tier-soft: var(--tier-unknown-soft);
}

.tier-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: fit-content;
  padding: 3px 10px 3px 8px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--tier-soft, var(--tier-unknown-soft));
  color: var(--tier-ink, var(--tier-unknown-ink));
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
  white-space: nowrap;
}

.tier-pill::before {
  content: "";
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--tier, var(--tier-unknown));
  box-shadow: 0 0 0 2px rgb(255 255 255 / 70%);
}

.tier-pill.tier-pill-small {
  padding: 1px 8px 1px 6px;
  font-size: 12px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  margin: 0;
  padding: 2px 9px;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 600;
}

.stale-tag {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  background: #fde68a;
  color: #5a3d00;
  font-size: 12px;
  font-weight: 700;
}

.rel-time {
  font-variant-numeric: tabular-nums;
}

/* ---------- Search (floating over the map) ---------- */

.search-shell {
  position: fixed;
  top: 12px;
  left: 12px;
  right: 12px;
  z-index: 1200;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 4px;
  align-items: center;
  padding: 6px 6px 6px 12px;
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  background: var(--glass);
  backdrop-filter: blur(14px) saturate(1.3);
  -webkit-backdrop-filter: blur(14px) saturate(1.3);
  box-shadow: var(--shadow-2);
}

.search-icon {
  display: inline-flex;
  color: var(--ink-3);
}

.search-shell input {
  width: 100%;
  min-width: 0;
  min-height: 40px;
  border: 0;
  padding: 0 8px;
  color: var(--ink);
  background: transparent;
}

.search-shell input::-webkit-search-cancel-button {
  cursor: pointer;
}

.search-shell input:focus-visible {
  outline: none;
}

.search-shell:focus-within {
  box-shadow:
    var(--shadow-2),
    0 0 0 3px var(--accent-soft);
}

.locate-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 40px;
  min-height: 40px;
  padding: 0 10px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 700;
}

.locate-button:hover {
  background: var(--accent-ink);
}

.locate-label {
  display: none;
}

.status-message {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--ink-2);
}

.search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  z-index: 1;
  max-height: 50dvh;
  overflow: auto;
  margin: 0;
  padding: 8px;
  color: var(--ink-2);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
}

.search-results-list,
.search-results-list li {
  padding: 0;
  margin: 0;
  list-style: none;
}

.search-group + .search-group {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--line);
}

.search-group-label {
  margin: 4px 10px 2px;
  color: var(--ink-3);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.search-result {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  height: auto;
  min-height: 44px;
  margin-top: 4px;
  padding: 8px 10px;
  border-color: transparent;
  text-align: left;
}

.search-result-area {
  padding-left: 26px;
  position: relative;
}

.search-result-area::before {
  content: "";
  position: absolute;
  left: 10px;
  top: 15px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--tier, var(--tier-unknown));
  box-shadow: 0 0 0 2px var(--tier-soft, var(--tier-unknown-soft));
}

.search-result-name {
  font-weight: 700;
  color: var(--ink);
}

.search-result-detail {
  color: var(--ink-3);
  font-weight: 400;
  font-size: 14px;
}

.search-result:hover,
.search-result:focus {
  background: #f1f5f9;
}

/* ---------- Banners ---------- */

.stale-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 900;
  padding: 10px 14px;
  color: #211400;
  background: #ffd76a;
  border-bottom: 2px solid #7a5200;
  font-weight: 700;
}

.stale-banner a {
  color: #003e61;
  margin-left: 8px;
}

.api-error {
  position: fixed;
  z-index: 950;
  top: 72px;
  left: 12px;
  right: 12px;
  padding: 12px;
  border: 2px solid #9d3211;
  border-radius: var(--radius-sm);
  color: #381207;
  background: #fff7ed;
}

/* ---------- Floating legend ---------- */

.legend {
  position: fixed;
  top: 68px;
  left: 12px;
  right: 12px;
  z-index: 1150;
  pointer-events: none;
}

.legend-toggle {
  display: none;
}

.legend-body {
  display: contents;
}

.legend-title {
  margin: 0 0 6px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.legend-list {
  display: flex;
  gap: 6px;
  padding: 2px 0 6px;
  overflow-x: auto;
  scrollbar-width: none;
  pointer-events: auto;
}

.legend-list::-webkit-scrollbar {
  display: none;
}

.legend-item {
  position: relative;
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  padding: 0 11px 0 9px;
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  background: var(--glass);
  backdrop-filter: blur(12px) saturate(1.3);
  -webkit-backdrop-filter: blur(12px) saturate(1.3);
  box-shadow: var(--shadow-2);
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
  transition:
    opacity 120ms ease,
    transform 120ms ease;
}

.legend-item input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  opacity: 0;
  pointer-events: none;
}

.legend-item:has(input:focus-visible) {
  outline: 3px solid #111827;
  outline-offset: 2px;
}

/* R-629: with nothing selected every row reads normally; once a filter is active, unselected rows dim. */
.legend[data-filter-active="true"] .legend-item:has(input:not(:checked)) {
  opacity: 0.45;
}

.legend[data-filter-active="true"] .legend-item:has(input:not(:checked)) .legend-swatch {
  background: transparent !important;
}

.legend-item:has(input:checked) {
  box-shadow:
    var(--shadow-2),
    0 0 0 2px var(--ink);
}

.legend-hint {
  margin: 0 0 6px;
  color: var(--ink-3);
  font-size: 12px;
}

.legend-clear {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--ink);
  border-radius: 999px;
  background: var(--ink);
  color: #ffffff;
  font-size: 13px;
  font-weight: 700;
  pointer-events: auto;
}

.legend-clear:hover {
  background: #1e293b;
}

.legend-clear[hidden] {
  display: none;
}

.legend-item.is-empty:has(input:checked) {
  opacity: 0.8;
}

.legend-item:active {
  transform: scale(0.98);
}

.legend-swatch {
  flex: 0 0 auto;
  width: 14px;
  height: 14px;
  border: 2px solid var(--tier-ink, var(--tier-unknown-ink));
  border-radius: 50%;
  background: var(--tier, var(--tier-unknown));
}

.legend-swatch.tier-later {
  border-style: dashed;
}

.legend-swatch.tier-off {
  box-shadow: 0 0 0 3px rgb(229 72 77 / 25%);
}

.legend-swatch.tier-clear {
  border-width: 1px;
}

.legend-swatch.tier-unknown {
  border-style: dotted;
}

.legend-tag-swatch {
  border-radius: 4px;
  background: var(--card);
  border: 1.5px solid var(--ink-3);
  position: relative;
}

.legend-tag-swatch.tag-restored::after {
  content: "✓";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--tier-clear-ink);
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
}

.legend-tag-swatch.tag-cancelled::after {
  content: "";
  position: absolute;
  left: 1px;
  right: 1px;
  top: 50%;
  height: 2px;
  background: var(--tier-unknown-ink);
  transform: rotate(-25deg);
}

.legend-text {
  display: inline-flex;
  flex-direction: column;
  min-width: 0;
}

.legend-sub {
  display: none;
  color: var(--ink-3);
  font-size: 12px;
  font-weight: 500;
}

.legend-count {
  min-width: 2ch;
  text-align: right;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.legend-tag {
  font-weight: 600;
}

.legend-help {
  position: relative;
  font-size: 14px;
  pointer-events: auto;
}

.legend-help-toggle {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  background: var(--glass);
  backdrop-filter: blur(12px) saturate(1.3);
  -webkit-backdrop-filter: blur(12px) saturate(1.3);
  box-shadow: var(--shadow-2);
  color: var(--ink-2);
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}

.legend-help-toggle::-webkit-details-marker {
  display: none;
}

.legend-help-toggle::before {
  content: "▸";
  margin-right: 8px;
}

details[open] > .legend-help-toggle::before {
  content: "▾";
}

.legend-help dl {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  z-index: 2;
  display: grid;
  gap: 8px;
  max-height: 46dvh;
  overflow: auto;
  margin: 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow-1);
}

.legend-help dt {
  font-weight: 700;
}

.legend-help dd {
  margin: 0 0 4px;
  color: var(--ink-2);
}

/* ---------- Map polygons (Leaflet SVG) ---------- */

.status-polygon {
  transition:
    fill-opacity 200ms ease,
    stroke-opacity 200ms ease;
}

.status-polygon.tier-off:not(.is-filtered) {
  filter: drop-shadow(0 0 7px rgb(229 72 77 / 75%));
  animation: tier-off-pulse 2.4s ease-in-out infinite;
}

.status-polygon.tier-soon:not(.is-filtered) {
  filter: drop-shadow(0 0 5px rgb(249 115 22 / 55%));
}

.status-polygon.is-selected {
  stroke: #0b0f14;
  stroke-width: 5;
  filter: drop-shadow(0 0 9px rgb(15 23 42 / 45%));
}

@keyframes tier-off-pulse {
  0%,
  100% {
    fill-opacity: 0.62;
  }

  50% {
    fill-opacity: 0.44;
  }
}

@media (prefers-reduced-motion: reduce) {
  .status-polygon.tier-off:not(.is-filtered) {
    animation: none;
  }

  .details-panel,
  button,
  .legend-item {
    transition: none;
  }
}

.map.is-low-zoom .status-polygon:not(.is-selected) {
  stroke-width: 1;
}

.status-polygon.is-filtered {
  pointer-events: none;
  filter: none;
}

.leaflet-container {
  font-family: inherit;
}

/* R-613: mute the basemap so only the tier colours are saturated. */
.leaflet-tile-pane {
  filter: grayscale(0.9) saturate(0.7) brightness(1.04) contrast(0.92);
}

.leaflet-bar {
  border: 1px solid var(--glass-border) !important;
  border-radius: 12px !important;
  box-shadow: var(--shadow-2) !important;
  overflow: hidden;
}

.leaflet-bar a {
  background: var(--glass) !important;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--ink) !important;
  border-bottom-color: var(--line) !important;
}

.leaflet-control-attribution {
  background: rgb(255 255 255 / 75%) !important;
  color: var(--ink-3) !important;
  font-size: 11px !important;
  border-top-left-radius: 8px;
}

/* ---------- Sheet / sidebar ---------- */

.details-panel {
  position: fixed;
  z-index: 1100;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 88dvh;
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow: auto;
  padding: 0 16px 24px;
  border-top: 1px solid var(--line-2);
  border-radius: 20px 20px 0 0;
  background: var(--paper);
  box-shadow: 0 -12px 32px rgb(15 23 42 / 20%);
  transition: transform 180ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.details-panel.is-dragging {
  transition: none;
  cursor: grabbing;
}

.details-panel[data-state="collapsed"] {
  transform: translateY(calc(100% - var(--collapsed-sheet-height)));
}

.details-panel[data-state="half"] {
  transform: translateY(42dvh);
}

.details-panel[data-state="expanded"] {
  transform: translateY(0);
}

.sheet-handle {
  display: block;
  width: 44px;
  height: 5px;
  align-self: center;
  border-radius: 999px;
  background: var(--line-2);
}

.sheet-grabber {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  flex: 0 0 auto;
  justify-content: center;
  align-items: center;
  width: 100%;
  min-height: 36px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: var(--paper);
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.sheet-grabber:hover {
  background: var(--paper);
}

.details-panel.is-dragging .sheet-grabber {
  cursor: grabbing;
}

.sheet-summary-row {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 52px;
  padding: 0 0 6px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
  touch-action: none;
  user-select: none;
}

.sheet-summary-row:hover {
  background: transparent;
}

.sheet-summary-row[data-tier] {
  padding-left: 12px;
  border-left: 4px solid var(--tier);
}

.sheet-summary-text {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  min-width: 0;
  overflow: hidden;
  font-weight: 700;
}

.sheet-summary-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 17px;
}

.sheet-summary-status {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 600;
}

.peek-count {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.peek-count::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--tier);
  box-shadow: 0 0 0 2px var(--tier-soft);
}

.sheet-content {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-top: 4px;
}

.details-panel h1,
.details-panel h2,
.details-panel h3 {
  margin: 0;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.details-panel h1 {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 24px;
  font-weight: 800;
}

.title-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(145deg, #fbbf24, #f97316 60%, #e5484d);
  color: #ffffff;
  box-shadow: 0 4px 12px rgb(249 115 22 / 35%);
}

.unofficial-note,
.map-credit {
  margin: 0;
  color: var(--ink-3);
}

.unofficial-note {
  font-size: 13px;
  line-height: 1.45;
}

.freshness {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 6px;
  margin: -6px 0 0;
  color: var(--ink-2);
  font-size: 13px;
}

.freshness .rel-time {
  font-weight: 700;
  color: var(--ink);
}

.freshness a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

.map-credit {
  font-size: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.details-panel h2 {
  font-size: 19px;
  font-weight: 800;
}

.details-panel h3 {
  font-size: 15px;
  font-weight: 700;
}

/* ---------- Global views (Up next + All areas) ---------- */

.global-views {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.section-head {
  display: grid;
  gap: 2px;
  margin-bottom: 10px;
}

.section-sub {
  margin: 0;
  color: var(--ink-3);
  font-size: 13px;
}

.area-directory {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--card);
  padding: 0 12px 12px;
}

.area-directory:not([open]) {
  padding-bottom: 0;
}

.area-directory-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  margin: 0 -12px;
  padding: 0 12px;
  cursor: pointer;
  list-style: none;
}

.area-directory-toggle::-webkit-details-marker {
  display: none;
}

.area-directory-toggle::before {
  content: "▸";
  color: var(--ink-3);
}

.area-directory[open] > .area-directory-toggle::before {
  content: "▾";
}

.area-directory-toggle h2 {
  font-size: 16px;
}

.area-directory-count {
  margin-left: auto;
  color: var(--ink-3);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

/* ---------- Up next ---------- */

.upnext {
  display: grid;
  gap: 8px;
}

.upnext-slot {
  border: 1px solid var(--line);
  border-left: 4px solid var(--tier, var(--line-2));
  border-radius: var(--radius-sm);
  background: var(--card);
  box-shadow: 0 1px 2px rgb(15 23 42 / 4%);
}

.upnext-slot[data-phase="now"] {
  background: var(--tier-soft);
}

.upnext-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "time count" "rel count";
  gap: 2px 10px;
  align-items: center;
  min-height: 52px;
  padding: 8px 12px;
  cursor: pointer;
  list-style: none;
}

.upnext-summary::-webkit-details-marker {
  display: none;
}

.upnext-time {
  grid-area: time;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px;
}

.upnext-clock {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.upnext-day {
  color: var(--ink-3);
  font-size: 13px;
  font-weight: 600;
}

.upnext-duration {
  color: var(--ink-3);
  font-size: 12px;
  font-weight: 600;
}

.upnext-duration::before {
  content: "· ";
}

.timeline-duration {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  background: #eef2f6;
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.5;
  vertical-align: middle;
}

.upnext-summary .rel-time {
  grid-area: rel;
  color: var(--tier-ink, var(--ink-2));
  font-size: 14px;
  font-weight: 700;
}

.upnext-count {
  grid-area: count;
  padding: 3px 9px;
  border-radius: 999px;
  background: #eef2f6;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.upnext-areas {
  display: grid;
  gap: 6px;
  padding: 0 8px 8px;
}

.upnext-empty {
  padding: 12px;
  border: 1px dashed var(--line-2);
  border-radius: var(--radius-sm);
}

/* ---------- Area directory ---------- */

.area-list,
.unmapped-list,
.feed-list,
.unmatched-list {
  display: grid;
  gap: 8px;
  padding: 0;
  margin: 10px 0 0;
}

.area-filter {
  width: 100%;
  margin-top: 10px;
  border: 1px solid var(--line-2);
  padding: 0 12px;
  color: var(--ink);
  background: var(--card);
}

.area-group {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--card);
}

.area-group summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  cursor: pointer;
  min-height: 44px;
  padding: 8px 12px;
  font-weight: 700;
}

.area-group-badges {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tier-dot-count {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 700;
  color: var(--tier-ink);
}

.tier-dot-count::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--tier);
}

.area-list-inner {
  display: grid;
  gap: 6px;
  max-height: 220px;
  overflow: auto;
}

.area-group .area-list-inner {
  max-height: none;
  padding: 0 8px 8px;
}

.area-list-item,
.unmapped-list button {
  display: grid;
  gap: 6px;
  width: 100%;
  height: auto;
  min-height: 44px;
  padding: 9px 10px 9px 12px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--tier, var(--line-2));
  border-radius: var(--radius-sm);
  line-height: 1.35;
  overflow-wrap: anywhere;
  text-align: left;
  white-space: normal;
}

.area-list-item:hover {
  border-color: var(--line-2);
  border-left-color: var(--tier, var(--line-2));
  box-shadow: var(--shadow-2);
}

.area-name {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  min-width: 0;
  overflow: hidden;
  font-weight: 600;
}

.area-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
}

.area-when {
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 600;
}

.area-unmapped {
  color: var(--ink-3);
  font-size: 12px;
}

.area-status {
  flex: 0 0 auto;
}

.selected-area,
.unmapped-panel,
.unmatched-panel,
.health-panel,
.area-directory {
  padding-top: 0;
}

.unmatched-panel-shell,
.health-panel {
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.unmapped-panel {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--line-2);
}

.unmapped-panel h2 {
  font-size: 15px;
}

/* ---------- Selected area ---------- */

.area-panel-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-top: 4px solid var(--tier, var(--line-2));
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow-1);
}

.clear-selection {
  justify-self: start;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
}

.clear-selection::before {
  content: "←";
  margin-right: 6px;
}

.area-head {
  display: grid;
  gap: 4px;
}

.area-key,
.feed-meta,
.feed-window,
.muted {
  color: var(--ink-3);
}

.area-key {
  margin: 0;
  font-size: 12px;
}

.notice {
  padding: 8px 10px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  background: #eef2f6;
  margin: 0;
}

.glance-hero {
  display: grid;
  gap: 4px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--tier-soft), #ffffff 140%);
  border: 1px solid color-mix(in srgb, var(--tier) 35%, white);
}

.glance-kicker {
  margin: 0 0 2px;
  color: var(--ink-3);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.glance-label {
  margin: 0;
  color: var(--tier-ink);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.glance-countdown {
  margin: 0;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.glance-when {
  margin: 0;
  color: var(--ink-2);
  font-weight: 600;
}

.glance-duration {
  margin: 0;
  color: var(--ink-3);
  font-size: 13px;
  font-weight: 600;
}

.glance-said {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 6px 0 0;
  color: var(--ink-3);
  font-size: 13px;
}

.source-links {
  margin: 0;
  font-size: 14px;
}

/* ---------- Timeline ---------- */

.area-timeline {
  display: grid;
  gap: 8px;
}

.timeline-list.timeline-vertical {
  position: relative;
  padding-left: 22px;
}

.timeline-list.timeline-vertical::before {
  content: "";
  position: absolute;
  left: 7px;
  top: 10px;
  bottom: 10px;
  width: 2px;
  border-radius: 2px;
  background: var(--line-2);
}

.timeline-marker {
  position: absolute;
  left: -21px;
  top: 14px;
  width: 12px;
  height: 12px;
  border: 2px solid #ffffff;
  border-radius: 50%;
  background: var(--tier, var(--tier-unknown));
  box-shadow: 0 0 0 2px var(--tier-soft, var(--line-2));
}

.timeline-slot[data-phase="past"] .timeline-marker {
  background: #9aa8b8;
  box-shadow: 0 0 0 2px #e6ebf1;
}

.timeline-slot[data-now="true"] .timeline-marker {
  box-shadow:
    0 0 0 3px var(--tier-soft),
    0 0 12px var(--tier);
}

.timeline-now {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  min-height: 32px;
  padding: 4px 0;
}

.timeline-now::before {
  content: "";
  position: absolute;
  left: -22px;
  right: 0;
  top: 50%;
  height: 2px;
  background: var(--ink);
  opacity: 0.8;
}

.timeline-now > * {
  position: relative;
  background: var(--card);
}

.timeline-marker-now {
  top: 50%;
  transform: translateY(-50%);
  background: var(--ink);
  box-shadow: 0 0 0 3px rgb(15 23 42 / 15%);
}

.timeline-now-label {
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--ink);
  color: #ffffff;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.timeline-now-state {
  padding: 0 4px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
}

.timeline-now-state:empty {
  display: none;
}

.timeline-now-said {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 4px;
  color: var(--ink-3);
  font-size: 13px;
}

.timeline-now-said:empty {
  display: none;
}

.timeline-now-said .glance-said {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
}

.timeline-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.timeline-slot {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  align-items: center;
  padding: 8px 10px 8px 12px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--tier, var(--line-2));
  border-radius: var(--radius-sm);
  background: var(--card);
}

.timeline-slot[data-phase="past"] {
  color: var(--ink-3);
  border-left-color: #b8c3d0;
}

.timeline-slot[data-phase="past"] .tier-pill {
  background: #eef2f6;
  color: var(--ink-3);
}

.timeline-slot[data-phase="past"] .tier-pill::before {
  background: #9aa8b8;
}

.timeline-slot[data-phase="now"] {
  background: var(--tier-soft);
}

.timeline-slot[data-focus="true"] {
  border-color: var(--tier);
  box-shadow: 0 0 0 2px var(--tier-soft);
}

.timeline-when {
  flex: 1 1 100%;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 6px;
  margin: 0;
}

.timeline-day-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-3);
}

.timeline-clock {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.timeline-rel {
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}

.timeline-slot[data-phase="future"][data-focus="true"] .timeline-rel,
.timeline-slot[data-phase="now"] .timeline-rel {
  color: var(--tier-ink);
  font-weight: 700;
}

.timeline-title {
  flex: 1 1 100%;
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  color: var(--tier-ink, var(--ink));
  font-size: 15px;
  font-weight: 800;
}

.timeline-title::before {
  content: "";
  flex: 0 0 auto;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--tier, var(--tier-unknown));
  box-shadow: 0 0 0 2px var(--tier-soft, var(--line-2));
}

.timeline-slot[data-phase="past"] .timeline-title {
  color: var(--ink-2);
  font-weight: 700;
}

.timeline-slot[data-phase="past"] .timeline-title::before {
  background: #9aa8b8;
  box-shadow: 0 0 0 2px #e6ebf1;
}

.timeline-slot a {
  flex: 1 1 100%;
  font-size: 13px;
}

.timeline-earlier summary {
  cursor: pointer;
  min-height: 40px;
  display: flex;
  align-items: center;
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 600;
}

/* ---------- Feed ---------- */

.area-feed {
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.area-feed-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  cursor: pointer;
  list-style: none;
}

.area-feed-toggle::-webkit-details-marker {
  display: none;
}

.area-feed-toggle::before {
  content: "▸";
  color: var(--ink-3);
}

.area-feed[open] > .area-feed-toggle::before {
  content: "▾";
}

.feed-list li,
.unmatched-list li {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--card);
  font-size: 14px;
}

.feed-list p,
.unmatched-list p {
  margin: 0 0 4px;
}

.feed-history {
  margin-top: 8px;
}

.feed-history summary {
  cursor: pointer;
  min-height: 40px;
  display: flex;
  align-items: center;
}

.feed-history ol {
  display: grid;
  gap: 6px;
  margin: 8px 0 0;
  padding-left: 1.2em;
}

.feed-history li {
  padding: 6px 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.raw-update {
  font-weight: 700;
}

.feed-list li.is-superseded {
  background: #f4f6f9;
  color: var(--ink-3);
}

.feed-note {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  background: #e6ebf1;
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 700;
}

.warning-text {
  color: #71340a;
}

.health-panel p {
  margin: 4px 0 0;
  color: var(--ink-2);
  font-size: 14px;
}

/* ---------- Phone-only sheet rules ---------- */

@media (max-width: 767px) {
  .details-panel[data-state="collapsed"] {
    overflow: hidden;
  }

  .details-panel[data-state="collapsed"] .sheet-content,
  .details-panel:not([data-state="collapsed"]) .sheet-summary-row {
    display: none;
  }

  .map .leaflet-bottom.leaflet-right {
    right: 12px;
    bottom: var(--collapsed-sheet-height);
  }

  [data-app-shell][data-sheet-state="half"] .leaflet-bottom.leaflet-right {
    bottom: calc(46dvh + 12px);
  }

  [data-app-shell][data-sheet-state="expanded"] .leaflet-bottom {
    display: none;
  }

  .legend-hint,
  .legend-title,
  .legend-help-toggle span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
  }

  .legend-list {
    align-items: center;
  }

  /* Zero-count chips collapse to a dot and a count so the live tiers stay on screen. */
  .legend-item.is-empty .legend-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
  }

  .legend-item.is-empty {
    padding-right: 9px;
    opacity: 0.85;
  }

  .legend-help {
    display: none;
  }

  .legend {
    display: flex;
    align-items: center;
    gap: 6px;
  }

  .legend-list {
    flex: 1 1 auto;
    min-width: 0;
  }

  .legend-clear {
    flex: 0 0 auto;
    order: -1;
    min-height: 36px;
    padding: 0 11px;
    box-shadow: var(--shadow-2);
  }
}

/* ---------- Desktop ---------- */

@media (min-width: 768px) {
  body {
    overflow: hidden;
  }

  .app-layout {
    display: grid;
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    grid-template-areas: "sidebar map";
  }

  .search-shell {
    left: calc(var(--sidebar-w) + (100vw - var(--sidebar-w)) / 2);
    right: auto;
    width: min(540px, calc(100vw - var(--sidebar-w) - 64px));
    transform: translateX(-50%);
    top: 16px;
  }

  .locate-label {
    display: inline;
  }

  .locate-button {
    padding: 0 14px 0 10px;
  }

  .legend {
    top: auto;
    bottom: 24px;
    left: calc(var(--sidebar-w) + 16px);
    right: auto;
    display: flex;
    flex-direction: column-reverse;
    align-items: flex-start;
    gap: 8px;
    width: auto;
    pointer-events: none;
  }

  .legend-toggle {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: 40px;
    padding: 0 12px 0 10px;
    border: 1px solid var(--glass-border);
    border-radius: 999px;
    background: var(--glass);
    backdrop-filter: blur(14px) saturate(1.3);
    -webkit-backdrop-filter: blur(14px) saturate(1.3);
    box-shadow: var(--shadow-2);
    color: var(--ink-2);
    font-size: 13px;
    font-weight: 700;
    pointer-events: auto;
  }

  .legend-toggle:hover {
    background: #ffffff;
  }

  .legend-summary {
    display: inline-flex;
    gap: 10px;
  }

  .legend-summary-item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
  }

  .legend-summary-item::before {
    content: "";
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--tier);
    box-shadow: 0 0 0 2px var(--tier-soft);
  }

  .legend-toggle-chevron {
    color: var(--ink-3);
    transition: transform 160ms ease;
  }

  .legend[data-legend-open="true"] .legend-toggle-chevron {
    transform: rotate(180deg);
  }

  .legend-body {
    display: none;
    width: 284px;
    padding: 12px 14px 10px;
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    background: var(--glass);
    backdrop-filter: blur(14px) saturate(1.3);
    -webkit-backdrop-filter: blur(14px) saturate(1.3);
    box-shadow: var(--shadow-1);
    pointer-events: auto;
  }

  .legend[data-legend-open="true"] .legend-body {
    display: block;
  }

  .legend-list {
    flex-direction: column;
    gap: 2px;
    padding: 0;
    overflow: visible;
  }

  .legend-item {
    display: grid;
    grid-template-columns: 16px minmax(0, 1fr) auto;
    gap: 10px;
    min-height: 40px;
    padding: 4px 6px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    box-shadow: none;
    font-size: 14px;
  }

  .legend-item:hover {
    background: rgb(255 255 255 / 70%);
  }

  .legend-item:has(input:checked) {
    background: #ffffff;
    box-shadow: inset 0 0 0 2px var(--ink);
  }

  .legend-clear {
    margin: 8px 0 2px;
  }

  .legend-item.legend-tag {
    border-top: 1px dashed var(--line-2);
    border-radius: 0;
    margin-top: 2px;
    padding-top: 6px;
  }

  .legend-item.legend-tag + .legend-tag {
    border-top: 0;
    margin-top: 0;
    padding-top: 4px;
  }

  .legend-sub {
    display: block;
  }

  .legend-help {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid var(--line);
  }

  .legend-help-toggle {
    min-height: 36px;
    padding: 0 6px;
    border: 0;
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    box-shadow: none;
    font-size: 13px;
  }

  .legend-help dl {
    position: static;
    max-height: 34dvh;
    margin-top: 6px;
    padding: 10px 12px;
    box-shadow: none;
    font-size: 13px;
  }

  .map-pane {
    grid-area: map;
  }

  .details-panel {
    grid-area: sidebar;
    position: relative;
    z-index: 1;
    max-height: none;
    min-height: 0;
    overflow: auto;
    padding: 16px 18px 24px;
    border-top: 0;
    border-right: 1px solid var(--line-2);
    border-radius: 0;
    box-shadow: 8px 0 24px rgb(15 23 42 / 6%);
    transform: none !important;
  }

  .sheet-summary-row,
  .sheet-grabber {
    display: none;
  }

  .sheet-content {
    padding-top: 0;
    gap: 16px;
  }

  .details-panel h1 {
    font-size: 26px;
  }

  .api-error {
    left: calc(var(--sidebar-w) + 12px);
    right: 12px;
  }
}

/* Leading summary separator: kept in text for screen readers and tests, hidden visually. */
.sheet-sep-leading {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

/* Keep the answer clear of the sticky grabber when it is scrolled into view. */
.selected-area {
  scroll-margin-top: 44px;
}
