:root {
  color-scheme: light;
  --ink: #17221e;
  --muted: #6c7671;
  --paper: rgba(250, 252, 249, 0.94);
  --line: rgba(23, 34, 30, 0.12);
  --green: #12684f;
  --green-dark: #0b4d3a;
  --mint: #d9eee6;
  --amber: #ffbd3e;
  --red: #ef5b4f;
  --shadow: 0 22px 55px rgba(33, 47, 41, 0.16);
}

* {
  box-sizing: border-box;
}

html,
body,
.app-shell,
#map {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  color: var(--ink);
  font-family:
    Pretendard, "Noto Sans KR", "Apple SD Gothic Neo", Inter, system-ui,
    -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #e9eeea;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  position: relative;
  isolation: isolate;
}

#map {
  z-index: 0;
  background: #080d12;
  cursor: crosshair;
}

.signal-play-toggle {
  position: absolute;
  z-index: 900;
  top: 20px;
  left: 24px;
  width: 46px;
  height: 46px;
  padding: 0;
  border: 1px solid rgba(211, 226, 232, 0.2);
  border-radius: 50%;
  background: rgba(5, 10, 14, 0.9);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(9px) saturate(1.15);
  cursor: pointer;
}

.signal-play-toggle::before {
  position: absolute;
  top: 50%;
  left: 52%;
  width: 0;
  height: 0;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
  border-left: 13px solid #5ce1ad;
  content: "";
  transform: translate(-50%, -50%);
}

.signal-play-toggle.playing::before {
  left: 50%;
  width: 5px;
  height: 17px;
  border: 0;
  background: #ffca45;
  box-shadow: 9px 0 0 #ffca45;
  transform: translate(-7px, -50%);
}

.signal-play-toggle:focus-visible {
  outline: 2px solid #dce7eb;
  outline-offset: 3px;
}

.guide-card,
.selection-card,
.signals-panel {
  position: absolute;
  z-index: 700;
  left: 24px;
  width: min(350px, calc(100vw - 48px));
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 22px;
  background: var(--paper);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px) saturate(1.1);
}

/* 신호는 지도 마커에 직접 표시하므로 기존 단계형 패널은 숨긴다. */
.guide-card,
.selection-card,
.signals-panel,
.coverage-legend,
.map-hint {
  display: none !important;
}

.signals-panel {
  top: 100px;
  right: 24px;
  left: auto;
  width: min(370px, calc(100vw - 48px));
  max-height: calc(100vh - 190px);
  padding: 22px;
  overflow-y: auto;
  animation: card-in 180ms ease-out;
  scrollbar-width: thin;
  scrollbar-color: rgba(18, 104, 79, 0.3) transparent;
}

.signals-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.signals-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.refresh-signals {
  display: grid;
  width: 28px;
  height: 28px;
  padding: 0;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--green);
  font-size: 16px;
  background: rgba(255, 255, 255, 0.8);
  cursor: pointer;
}

.refresh-signals:hover {
  background: var(--mint);
}

.refresh-signals:disabled {
  cursor: wait;
  opacity: 0.55;
}

.signals-header h2 {
  margin: 7px 0 0;
  font-size: 22px;
  letter-spacing: -0.045em;
}

.live-badge {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 6px;
  padding: 7px 9px;
  border-radius: 999px;
  color: #806013;
  font-size: 9px;
  font-weight: 850;
  background: #fff2cf;
}

.live-badge i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--amber);
}

.live-badge.loading i {
  animation: pulse 1s infinite;
}

.live-badge.live {
  color: #0d6848;
  background: #daf2e7;
}

.live-badge.live i {
  background: #27ad73;
  box-shadow: 0 0 0 3px rgba(39, 173, 115, 0.13);
}

.live-badge.unavailable {
  color: #6c7671;
  background: #edf1ef;
}

.live-badge.unavailable i {
  background: #939d98;
}

.live-badge.stalled {
  color: #8a4b43;
  background: #fff0ed;
}

.live-badge.stalled i {
  background: var(--red);
  animation: pulse 1.6s infinite;
}

.signals-description {
  margin: 12px 0 16px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
}

.signal-list {
  display: grid;
  gap: 11px;
}

.signal-card {
  position: relative;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.74);
}

.signal-card-heading {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
}

.signal-rank {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 50%;
  color: white;
  font-size: 12px;
  font-weight: 900;
  background: var(--green);
  box-shadow: 0 5px 13px rgba(11, 77, 58, 0.24);
}

.signal-card:nth-child(2) .signal-rank {
  color: var(--green-dark);
  background: var(--mint);
  box-shadow: none;
}

.signal-name {
  min-width: 0;
}

.signal-name strong,
.signal-name small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.signal-name strong {
  font-size: 14px;
  letter-spacing: -0.025em;
}

.signal-name small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
}

.signal-distance {
  color: var(--green-dark);
  font-size: 11px;
  font-weight: 850;
}

.signal-message {
  margin: 13px 0 0;
  padding: 11px 12px;
  border-radius: 10px;
  color: #64706a;
  font-size: 10px;
  line-height: 1.5;
  background: #f0f3f1;
}

.signal-message.error {
  color: #8a4b43;
  background: #fff0ed;
}

.signal-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 11px;
}

.signal-meta span {
  padding: 4px 7px;
  border-radius: 999px;
  color: #64706a;
  font-size: 8px;
  font-weight: 800;
  background: #edf1ef;
}

.signal-meta .quality-live {
  color: #0d6848;
  background: #daf2e7;
}

.signal-meta .quality-state-only {
  color: #806013;
  background: #fff2cf;
}

.signal-meta .quality-stale,
.signal-meta .quality-unavailable,
.signal-meta .quality-error {
  color: #7e5550;
  background: #fff0ed;
}

.movement-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  margin-top: 13px;
}

.movement-item {
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid rgba(23, 34, 30, 0.08);
  border-radius: 10px;
  background: #f7f9f7;
}

.movement-item span,
.movement-item strong {
  display: block;
}

.movement-item span {
  overflow: hidden;
  color: var(--muted);
  font-size: 9px;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.movement-item strong {
  margin-top: 4px;
  color: #57615c;
  font-size: 11px;
}

.movement-item.go strong {
  color: #12825c;
}

.movement-item.stop strong {
  color: #c64f45;
}

.movement-item.wait strong {
  color: #9b6c0e;
}

.movement-item.unavailable {
  border-style: dashed;
  opacity: 0.72;
}

.movement-item small {
  display: block;
  margin-top: 3px;
  color: #87908c;
  font-size: 8px;
}

.signals-source {
  margin: 14px 0 0;
  color: #87908c;
  font-size: 9px;
  line-height: 1.45;
}

.coverage-notice,
.feed-notice {
  margin: 0 0 12px;
  padding: 10px 11px;
  border: 1px solid rgba(198, 79, 69, 0.2);
  border-radius: 11px;
  color: #87433d;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.5;
  background: rgba(239, 91, 79, 0.08);
}

.feed-notice {
  margin: 0 0 12px;
  border-color: rgba(198, 79, 69, 0.24);
  color: #87433d;
  background: rgba(239, 91, 79, 0.09);
}

.coverage-notice.weak {
  border-color: rgba(198, 137, 18, 0.23);
  color: #76530d;
  background: rgba(255, 189, 62, 0.11);
}

.coverage-legend {
  position: absolute;
  z-index: 680;
  bottom: 28px;
  left: 398px;
  width: 260px;
  padding: 13px 14px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 15px;
  color: #45534d;
  background: rgba(250, 252, 249, 0.92);
  box-shadow: 0 12px 32px rgba(33, 47, 41, 0.12);
  backdrop-filter: blur(14px);
}

.coverage-legend-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.coverage-legend-heading strong {
  color: var(--ink);
  font-size: 11px;
}

.coverage-legend-heading label {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  font-size: 9px;
  cursor: pointer;
}

.coverage-legend-heading input {
  accent-color: var(--green);
}

.coverage-legend p {
  margin: 7px 0 8px;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.4;
}

.coverage-legend-items {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 10px;
  font-size: 8px;
  font-weight: 700;
}

.coverage-legend-items span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.coverage-legend-items i {
  width: 7px;
  height: 7px;
  border: 1px solid white;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(23, 34, 30, 0.2);
}

.coverage-legend-items .covered {
  background: #16805c;
}

.coverage-legend-items .weak {
  background: #e4a129;
}

.coverage-legend-items .missing {
  background: #d84c43;
}

.coverage-popup .maplibregl-popup-content {
  max-width: 250px;
  padding: 12px 14px;
  border-radius: 13px;
  color: var(--ink);
  font-size: 10px;
  line-height: 1.5;
  box-shadow: 0 14px 34px rgba(33, 47, 41, 0.18);
}

.coverage-popup strong,
.coverage-popup small {
  display: block;
}

.coverage-popup small {
  margin-top: 4px;
  color: var(--muted);
}

.intersection-marker {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 3px solid white;
  border-radius: 50%;
  color: white;
  font-size: 11px;
  font-weight: 900;
  background: var(--green);
  box-shadow:
    0 0 0 2px var(--green),
    0 7px 18px rgba(11, 77, 58, 0.3);
  pointer-events: none;
}

.intersection-marker.rank-2 {
  color: var(--green-dark);
  background: var(--mint);
  box-shadow:
    0 0 0 2px var(--green),
    0 7px 18px rgba(11, 77, 58, 0.24);
}

.intersection-signal-marker {
  position: relative;
  display: block;
  width: 340px;
  height: 280px;
  place-items: initial;
  padding: 0;
  border: 0;
  border-radius: 0;
  color: #e7eff2;
  background: transparent;
  box-shadow: none;
  pointer-events: none;
  user-select: none;
}

.intersection-signal-heading {
  position: absolute;
  z-index: 4;
  top: 50%;
  left: 50%;
  display: block;
  width: max-content;
  max-width: 190px;
  margin: 0;
  padding: 5px 6px;
  border: 1px solid rgba(211, 226, 232, 0.2);
  border-radius: 999px;
  background: rgba(5, 10, 14, 0.9);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.26),
    0 7px 18px rgba(0, 0, 0, 0.46);
  backdrop-filter: blur(9px) saturate(1.15);
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.intersection-signal-heading strong {
  display: block;
  overflow: hidden;
  font-size: 11px;
  letter-spacing: -0.03em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.approach-signal-grid {
  position: absolute;
  z-index: 3;
  inset: 0;
  pointer-events: none;
}

.approach-signal {
  position: absolute;
  display: flex;
  width: max-content;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  filter: drop-shadow(0 5px 9px rgba(0, 0, 0, 0.62));
}

.approach-signal.direction-nt {
  top: 0;
  left: 50%;
  transform: translateX(-50%);
}

.approach-signal.direction-ne {
  top: 36px;
  right: 0;
}

.approach-signal.direction-et {
  top: 108px;
  right: 0;
}

.approach-signal.direction-se {
  right: 0;
  bottom: 36px;
}

.approach-signal.direction-st {
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
}

.approach-signal.direction-sw {
  bottom: 36px;
  left: 0;
}

.approach-signal.direction-wt {
  top: 108px;
  left: 0;
}

.approach-signal.direction-nw {
  top: 36px;
  left: 0;
}

.approach-signal-label {
  display: flex;
  min-height: 16px;
  align-items: center;
  gap: 3px;
  padding: 2px 5px;
  border: 1px solid rgba(211, 226, 232, 0.16);
  border-radius: 999px;
  color: #dce7eb;
  font-size: 8px;
  font-weight: 850;
  line-height: 1;
  background: rgba(5, 10, 14, 0.82);
  white-space: nowrap;
}

.approach-signal-label small {
  color: #7f949c;
  font-size: 7px;
}

.approach-signal-label i {
  color: #5ce1ad;
  font-size: 10px;
  font-style: normal;
}

.traffic-lamp-row {
  display: flex;
  gap: 2px;
  min-height: 32px;
  padding: 3px 4px 2px;
  border-radius: 8px;
  background: rgba(2, 4, 5, 0.94);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.traffic-lamp-unit {
  display: grid;
  width: 25px;
  flex: 0 0 25px;
  grid-template-rows: 19px 10px;
  justify-items: center;
}

.traffic-lamp {
  display: grid;
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 50%;
  color: rgba(255, 255, 255, 0.22);
  font-size: 7px;
  font-style: normal;
  font-weight: 950;
  line-height: 1;
  background: #161a1c;
}

.traffic-lamp.red.active {
  color: white;
  background: #f0443a;
  box-shadow: 0 0 9px rgba(240, 68, 58, 0.9);
}

.traffic-lamp.yellow.active {
  color: #261c00;
  background: #ffc928;
  box-shadow: 0 0 9px rgba(255, 201, 40, 0.9);
}

.traffic-lamp.left.active,
.traffic-lamp.green.active {
  color: #03150e;
  background: #35dc84;
  box-shadow: 0 0 9px rgba(53, 220, 132, 0.88);
}

.traffic-countdown {
  min-width: 25px;
  color: transparent;
  font-size: 8px;
  font-weight: 900;
  line-height: 10px;
  text-align: center;
  white-space: nowrap;
}

.traffic-countdown.active {
  color: #dce7eb;
}

.traffic-lamp-unit.red .traffic-countdown.active {
  color: #ff8d85;
}

.traffic-lamp-unit.yellow .traffic-countdown.active {
  color: #ffe074;
}

.traffic-lamp-unit.left .traffic-countdown.active,
.traffic-lamp-unit.green .traffic-countdown.active {
  color: #79efad;
}

.traffic-lamp-unit .traffic-countdown.active.unavailable {
  color: #8a9aa0;
}


.guide-card {
  top: 100px;
  padding: 25px 25px 22px;
}

.eyebrow,
.selection-label {
  color: var(--green);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.14em;
}

.guide-card h1 {
  margin: 10px 0 13px;
  font-size: clamp(25px, 3vw, 34px);
  line-height: 1.16;
  letter-spacing: -0.055em;
}

.guide-card > p {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
  word-break: keep-all;
}

.gesture-row {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-top: 9px;
  color: #52605a;
  font-size: 12px;
}

.gesture-row strong {
  color: var(--ink);
}

.gesture-icon {
  display: grid;
  width: 29px;
  height: 29px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--green);
  font-weight: 900;
  background: white;
}

.query-status {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
}

.status-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #36b77d;
}

.query-status.loading .status-dot {
  background: var(--amber);
  animation: pulse 1s infinite;
}

.query-status.error .status-dot {
  background: var(--red);
}

@keyframes pulse {
  50% {
    opacity: 0.35;
    transform: scale(0.7);
  }
}

.selection-card {
  bottom: 30px;
  padding: 22px;
  animation: card-in 180ms ease-out;
}

@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

.close-button {
  position: absolute;
  top: 14px;
  right: 14px;
  display: grid;
  width: 30px;
  height: 30px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: #53625b;
  font-size: 21px;
  line-height: 1;
  background: #edf2ef;
  cursor: pointer;
}

.close-button:hover {
  background: #e3eae6;
}

.selection-card h2 {
  max-width: calc(100% - 36px);
  margin: 8px 0 18px;
  overflow: hidden;
  font-size: 22px;
  letter-spacing: -0.045em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.selection-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.selection-grid > div,
.coordinate-row {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.7);
}

.selection-grid span,
.coordinate-row span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.selection-grid strong {
  font-size: 13px;
}

.coordinate-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
}

.coordinate-row span {
  margin: 0;
}

.coordinate-row code {
  color: #44534c;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 11px;
}

.osm-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 13px;
  color: var(--green);
  font-size: 11px;
  font-weight: 800;
  text-decoration: none;
}

.osm-link:hover {
  color: var(--green-dark);
  text-decoration: underline;
}

.map-hint {
  position: absolute;
  z-index: 650;
  right: 24px;
  bottom: 28px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 13px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 999px;
  color: #53625b;
  font-size: 11px;
  font-weight: 750;
  background: rgba(250, 252, 249, 0.88);
  box-shadow: 0 8px 24px rgba(33, 47, 41, 0.1);
  backdrop-filter: blur(12px);
}

.map-hint span {
  width: 9px;
  height: 9px;
  border: 3px solid var(--green);
  border-radius: 50%;
}

.maplibregl-ctrl-group {
  overflow: hidden;
  border: 1px solid rgba(203, 220, 228, 0.14) !important;
  border-radius: 12px !important;
  box-shadow: 0 9px 24px rgba(33, 47, 41, 0.13) !important;
}

.maplibregl-ctrl-group button {
  color: #dce7eb !important;
  background: rgba(13, 20, 27, 0.94) !important;
}

.maplibregl-ctrl-group .maplibregl-ctrl-icon {
  filter: invert(1) brightness(1.8);
}

.maplibregl-ctrl-attrib {
  padding: 4px 8px !important;
  color: #9aa9b1;
  font-size: 10px !important;
  background: rgba(8, 13, 18, 0.9) !important;
}

.maplibregl-ctrl-attrib a {
  color: #b8c7cd;
}

.maplibregl-ctrl-top-right {
  top: 8px;
  right: 14px;
}

.road-marker {
  width: 24px;
  height: 24px;
  border: 5px solid white;
  border-radius: 50%;
  background: #36d49a;
  box-shadow:
    0 0 0 2px var(--green),
    0 8px 18px rgba(11, 77, 58, 0.35);
}

@media (max-width: 720px) {
  .signal-play-toggle {
    top: 14px;
    left: 14px;
  }

  .guide-card,
  .selection-card,
  .signals-panel {
    left: 14px;
    width: calc(100vw - 28px);
  }

  .guide-card {
    top: 78px;
    padding: 18px;
  }

  .guide-card h1 {
    margin: 7px 0 8px;
    font-size: 23px;
  }

  .guide-card h1 br {
    display: none;
  }

  .guide-card > p {
    margin-bottom: 12px;
    font-size: 12px;
  }

  .gesture-row {
    display: none;
  }

  .query-status {
    margin-top: 12px;
    padding-top: 12px;
  }

  .selection-card {
    bottom: 34px;
  }

  .coverage-legend {
    right: 14px;
    bottom: 34px;
    left: 14px;
    width: auto;
  }

  .app-shell.has-selection .coverage-legend {
    display: none;
  }

  .app-shell.has-selection .guide-card {
    display: none;
  }

  .signals-panel {
    top: 78px;
    right: 14px;
    bottom: 238px;
    width: auto;
    max-height: none;
    padding: 17px;
  }

  .signals-header h2 {
    font-size: 19px;
  }

  .signals-description {
    margin-bottom: 12px;
  }

  .signal-card {
    padding: 12px;
  }

  .map-hint {
    display: none;
  }

  .maplibregl-ctrl-top-right {
    top: 8px;
    right: 4px;
  }
}
