:root {
  color-scheme: light;
  --ink: #172126;
  --muted: #607179;
  --panel: #f8faf9;
  --line: #d6dfdc;
  --map-bg: #e5ece8;
  --green: #168c7f;
  --red: #d84f2a;
  --amber: #c68424;
  --blue: #5967c9;
  --violet: #7d4ea8;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  background: #eef3f1;
  color: var(--ink);
}

button,
input {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  min-height: 100vh;
}

.map-stage {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 24px;
}

.top-bar {
  z-index: 3;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 5px;
  color: #52656d;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(2rem, 5vw, 4.8rem);
  line-height: 0.92;
  max-width: 720px;
}

h2 {
  font-size: 1.15rem;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 8px;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid rgba(23, 33, 38, 0.14);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: #34454c;
  font-size: 0.82rem;
  font-weight: 700;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #19a06e;
  box-shadow: 0 0 0 5px rgba(25, 160, 110, 0.13);
}

.live-dot.live {
  animation: dot-pulse 2.4s ease-in-out infinite;
}

.live-dot.connecting {
  background: #d99a2b;
  box-shadow: 0 0 0 5px rgba(217, 154, 43, 0.16);
  animation: dot-pulse 1.1s ease-in-out infinite;
}

/* Some feeds live, some not: amber, but breathing at the calm live pace —
   distinct from connecting's quicker flutter. */
.live-dot.degraded {
  background: #d99a2b;
  box-shadow: 0 0 0 5px rgba(217, 154, 43, 0.16);
  animation: dot-pulse 2.4s ease-in-out infinite;
}

.live-dot.error {
  background: #c93d3d;
  box-shadow: 0 0 0 5px rgba(201, 61, 61, 0.16);
  animation: none;
}

@keyframes dot-pulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.35);
    opacity: 0.72;
  }
}

.map-wrap {
  position: relative;
  flex: 1;
  min-height: 520px;
}

.map-switch {
  margin-left: 10px;
  font-size: 0.78rem;
  font-weight: 700;
  color: #34454c;
  text-decoration: none;
  border-bottom: 1px dotted currentColor;
}

.city-map {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border: 1px solid rgba(23, 33, 38, 0.18);
  border-radius: 8px;
  background:
    radial-gradient(circle at 52% 54%, rgba(255, 255, 255, 0.4), transparent 24%),
    var(--map-bg);
  box-shadow: 0 28px 80px rgba(52, 72, 82, 0.16);
}

.city-map.placing {
  cursor: crosshair;
}

.base-map,
.route-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.river {
  fill: none;
  stroke: rgba(54, 117, 148, 0.28);
  stroke-width: 7;
}

.road {
  fill: none;
  stroke: rgba(79, 92, 98, 0.22);
  stroke-width: 0.9;
}

.arterial {
  fill: none;
  stroke: rgba(41, 52, 58, 0.38);
  stroke-linecap: round;
  stroke-width: 1.7;
}

.arterial.vertical {
  stroke-width: 1.5;
}

.venue {
  fill: rgba(89, 103, 201, 0.22);
  stroke: rgba(89, 103, 201, 0.55);
  stroke-width: 0.7;
}

.downtown {
  fill: rgba(35, 49, 56, 0.08);
  stroke: rgba(35, 49, 56, 0.2);
  stroke-width: 0.4;
}

.heat-layer,
.avoid-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.heat-zone,
.avoid-zone {
  position: absolute;
  display: grid;
  place-items: center;
  transform: translate(-50%, -50%);
  border: 0;
  border-radius: 50%;
  color: #162126;
  pointer-events: auto;
}

.heat-zone {
  --zone-color: 216, 79, 42;
  background: radial-gradient(
    circle,
    rgba(var(--zone-color), calc(0.36 * var(--intensity))) 0%,
    rgba(var(--zone-color), calc(0.18 * var(--intensity))) 43%,
    rgba(var(--zone-color), 0) 72%
  );
  animation: pulse 2.8s ease-in-out infinite;
}

.heat-zone.event {
  --zone-color: 89, 103, 201;
}

.heat-zone.safety {
  --zone-color: 198, 132, 36;
}

.heat-zone.closure {
  --zone-color: 125, 78, 168;
}

.heat-zone.compact {
  min-width: 22px;
  min-height: 22px;
}

.heat-zone.compact .zone-label {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.heat-zone.compact:hover .zone-label,
.heat-zone.compact:focus-visible .zone-label {
  opacity: 1;
}

.zone-label,
.avoid-zone span {
  max-width: 118px;
  padding: 5px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.8);
  box-shadow: 0 8px 22px rgba(31, 41, 55, 0.13);
  font-size: 0.72rem;
  font-weight: 800;
  text-align: center;
  white-space: normal;
}

.avoid-zone {
  border: 1px dashed rgba(216, 79, 42, 0.75);
  background: radial-gradient(circle, rgba(216, 79, 42, 0.22), rgba(216, 79, 42, 0.04) 70%);
}

.companion {
  position: absolute;
  left: 16px;
  bottom: 16px;
  z-index: 4;
  max-width: 320px;
  padding: 12px 14px;
  border: 1px solid rgba(23, 33, 38, 0.14);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 18px 46px rgba(31, 41, 55, 0.18);
  backdrop-filter: blur(6px);
  animation: companion-in 0.35s ease;
}

.companion.hidden {
  display: none;
}

@keyframes companion-in {
  from {
    transform: translateY(10px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.companion-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.companion-prompt {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 800;
  color: #172126;
}

.companion-dismiss {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 50%;
  background: rgba(23, 33, 38, 0.07);
  color: #34454c;
  font-size: 0.78rem;
  cursor: pointer;
}

.companion-dismiss:hover {
  background: rgba(23, 33, 38, 0.14);
}

.companion-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.companion-chip {
  padding: 7px 12px;
  border: 1px solid rgba(23, 33, 38, 0.16);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.85);
  color: #172126;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.companion-chip:hover {
  border-color: rgba(22, 140, 127, 0.7);
  background: rgba(22, 140, 127, 0.09);
}

.companion-chip.selected {
  border-color: rgba(22, 140, 127, 0.9);
  background: rgba(22, 140, 127, 0.14);
}

.route-layer {
  z-index: 2;
  pointer-events: none;
}

.route-line {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 1px 1px rgba(255, 255, 255, 0.75)) drop-shadow(0 7px 12px rgba(23, 33, 38, 0.2));
}

.map-hint {
  position: absolute;
  left: 50%;
  bottom: 18px;
  z-index: 5;
  transform: translateX(-50%);
  padding: 9px 12px;
  border-radius: 999px;
  background: #172126;
  color: #fff;
  font-size: 0.86rem;
  font-weight: 800;
}

.hidden {
  display: none;
}

.control-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  max-height: 100vh;
  padding: 16px;
  border-left: 1px solid var(--line);
  background: var(--panel);
}

.panel-section {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.guidance-section {
  border-color: rgba(22, 140, 127, 0.35);
}

.section-heading {
  margin-bottom: 12px;
}

.section-heading.inline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.guidance-copy {
  margin: 0 0 16px;
  color: #405159;
  line-height: 1.45;
}

.route-cards {
  display: grid;
  gap: 10px;
}

.route-card {
  padding: 12px;
  border: 1px solid #dce4e1;
  border-radius: 8px;
  background: #f9fbfa;
}

.route-card.selected {
  border-color: rgba(22, 140, 127, 0.5);
  background: #eef8f5;
}

.route-card-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-weight: 850;
}

.route-card p {
  margin: 6px 0 0;
  color: #607179;
  font-size: 0.8rem;
  line-height: 1.35;
}

.route-card .route-reason {
  color: #33464d;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid #c8d4d0;
  border-radius: 50%;
  background: #fff;
  color: #172126;
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}

.icon-button[aria-pressed="true"] {
  background: #172126;
  color: #fff;
}

.field-label {
  display: block;
  margin-bottom: 6px;
  color: #52656d;
  font-size: 0.78rem;
  font-weight: 800;
}

.text-input {
  width: 100%;
  height: 40px;
  margin-bottom: 12px;
  padding: 0 10px;
  border: 1px solid #c8d4d0;
  border-radius: 6px;
  color: var(--ink);
}

.avoid-list {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.avoid-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 6px;
  background: #f5f0ee;
  color: #41251e;
  font-size: 0.86rem;
  font-weight: 750;
}

.avoid-row small {
  color: #785a52;
}

.empty-note {
  margin: 0;
  color: #607179;
  font-size: 0.86rem;
}

.text-button,
.primary-button {
  width: 100%;
  min-height: 40px;
  border-radius: 6px;
  font-weight: 850;
  cursor: pointer;
}

.text-button {
  border: 1px solid #c8d4d0;
  background: #fff;
  color: #31434b;
}

.primary-button {
  margin-top: 14px;
  border: 0;
  background: #172126;
  color: #fff;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 34px;
  color: #31434b;
  font-size: 0.9rem;
  font-weight: 720;
}

.toggle-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--green);
}

.source-section ul {
  margin: 10px 0 0;
  padding-left: 18px;
  color: #475b63;
  line-height: 1.6;
}

.real-map {
  position: absolute;
  inset: 0;
  border: 1px solid rgba(23, 33, 38, 0.18);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 28px 80px rgba(52, 72, 82, 0.16);
}

.real-map.placing .maplibregl-canvas-container {
  cursor: crosshair;
}

.maplibregl-popup-content {
  border-radius: 10px;
  font: inherit;
  padding: 10px 12px;
  max-width: 240px;
}

.signal-details summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
}

.signal-details summary .eyebrow {
  margin: 0;
}

.signal-count {
  padding: 2px 8px;
  border-radius: 999px;
  background: #eef3f1;
  color: #31434b;
  font-size: 0.74rem;
  font-weight: 800;
}

.signal-list {
  display: grid;
  gap: 4px;
  margin: 12px 0 0;
  padding: 0;
  max-height: 240px;
  overflow-y: auto;
  list-style: none;
}

.signal-list-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 9px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: none;
  color: #405159;
  font-size: 0.78rem;
  line-height: 1.3;
  text-align: left;
  cursor: pointer;
}

.signal-list-item:hover,
.signal-list-item:focus-visible {
  border-color: #c8d4d0;
  background: #f9fbfa;
}

.signal-swatch {
  flex: none;
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

@keyframes pulse {
  0%,
  100% {
    transform: translate(-50%, -50%) scale(0.96);
  }
  50% {
    transform: translate(-50%, -50%) scale(1.06);
  }
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .map-stage {
    min-height: 72vh;
    padding: 18px;
  }

  .top-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .status-pill {
    align-self: flex-start;
  }

  .map-wrap {
    min-height: 460px;
  }

  .control-panel {
    max-height: none;
    border-top: 1px solid var(--line);
    border-left: 0;
  }
}

@media (max-width: 560px) {
  .map-stage {
    padding: 12px;
  }

  h1 {
    font-size: 2.25rem;
  }

  .map-wrap {
    min-height: 420px;
  }

  .zone-label,
  .avoid-zone span {
    max-width: 86px;
    font-size: 0.64rem;
  }
}
