:root {
  --bg: #ffffff;
  --fg: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --soft: #f1f5f9;
  --blue: #2563eb;
  --red: #dc2626;
  --green: #16a34a;
  --orange: #ea580c;
  --shadow: 0 6px 24px rgba(15, 23, 42, 0.16);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111827;
    --fg: #f1f5f9;
    --muted: #94a3b8;
    --line: #334155;
    --soft: #1f2937;
    --shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); }
body { font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif; font-size: 15px; overflow: hidden; }
#map { position: fixed; inset: 0; z-index: 0; }

button, input, select { font: inherit; color: inherit; }
button {
  border: 1px solid var(--line); background: var(--soft); border-radius: 10px;
  padding: 9px 12px; cursor: pointer; white-space: nowrap;
}
button:disabled { opacity: 0.35; cursor: default; }
button.primary { background: var(--blue); border-color: var(--blue); color: #fff; font-weight: 600; }
button.danger { color: var(--red); }
input, select {
  border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: 9px 12px; min-width: 0;
}

.card { background: var(--bg); border-radius: 16px; box-shadow: var(--shadow); }
.muted { color: var(--muted); }
.small-text { font-size: 12px; margin-top: 6px; }

.topbar {
  position: fixed; top: calc(10px + env(safe-area-inset-top)); left: 10px; right: 10px; z-index: 1000;
  padding: 10px; display: flex; flex-direction: column; gap: 8px; max-width: 560px; margin: 0 auto;
}
.row { display: flex; gap: 8px; }
.row input { flex: 1; }
.results { list-style: none; margin: 0; padding: 0; max-height: 40vh; overflow: auto; }
.results li { padding: 9px 6px; border-top: 1px solid var(--line); cursor: pointer; display: flex; flex-direction: column; }
.results li small { color: var(--muted); font-size: 12px; }
.results li:hover { background: var(--soft); }

.sheet {
  position: fixed; left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 1000;
  padding: 14px; max-width: 560px; margin: 0 auto; max-height: 55vh; overflow: auto;
}
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0; }
.stats div { background: var(--soft); border-radius: 12px; padding: 8px 10px; display: flex; flex-direction: column; }
.stats span { font-size: 12px; color: var(--muted); }
.stats b { font-size: 18px; margin-top: 2px; }
.place { font-size: 14px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.actions .primary { flex: 1; }
.hint { font-size: 12px; color: var(--muted); margin: 8px 0 0; }

.stops { list-style: none; margin: 0; padding: 0; }
.stops li { display: flex; align-items: center; gap: 8px; padding: 5px 0; }
.stops .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
button.icon { padding: 3px 8px; font-size: 12px; }

.title-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.title-row h2 { font-size: 18px; margin: 0; }
.badge { font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; color: #fff; background: var(--muted); }
.badge.blue { background: var(--blue); }
.badge.green { background: var(--green); }
.badge.orange { background: var(--orange); }
.badge.gray { background: var(--muted); }

.fab {
  position: fixed; right: 12px; bottom: calc(50vh + 20px); z-index: 1000; width: 44px; height: 44px;
  border-radius: 50%; padding: 0; font-size: 20px; background: var(--bg); box-shadow: var(--shadow);
}
.chip {
  position: fixed; left: 50%; transform: translateX(-50%); top: calc(150px + env(safe-area-inset-top)); z-index: 1000;
  border-radius: 999px; font-size: 12px; background: var(--orange); color: #fff; border: 0; box-shadow: var(--shadow);
}

/* 지도 핀 */
.pin-me {
  width: 22px; height: 22px; border-radius: 50%; background: var(--blue); border: 3px solid #fff;
  box-shadow: 0 0 0 6px rgba(37, 99, 235, 0.25), 0 2px 6px rgba(0, 0, 0, 0.35);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.3), 0 2px 6px rgba(0, 0, 0, 0.35); }
  50% { box-shadow: 0 0 0 12px rgba(37, 99, 235, 0.08), 0 2px 6px rgba(0, 0, 0, 0.35); }
}
.pin-dest {
  width: 34px; height: 34px; border-radius: 50%; background: #fff; border: 3px solid var(--red);
  display: grid; place-items: center; font-size: 17px; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}
.pin-wp {
  width: 26px; height: 26px; border-radius: 50%; background: var(--orange); color: #fff; border: 2px solid #fff;
  display: grid; place-items: center; font-size: 13px; font-weight: 700; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}
.pin-wp.small, .pin-dest.small { width: 22px; height: 22px; font-size: 11px; border-width: 2px; flex: none; }
.name-tip { font-weight: 600; }

.popup-actions { display: flex; flex-direction: column; gap: 6px; }
.popup-actions button { text-align: left; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--bg); color: var(--fg); }

.modal { position: fixed; inset: 0; z-index: 2000; background: rgba(0, 0, 0, 0.4); display: grid; place-items: center; padding: 16px; }
.modal[hidden] { display: none; }
.modal-body { padding: 18px; width: 100%; max-width: 420px; }
.modal-body h3 { margin: 0 0 6px; }
.modal-body input { width: 100%; margin-top: 8px; }

.toast {
  position: fixed; left: 50%; bottom: calc(55vh + 20px); transform: translateX(-50%) translateY(10px); z-index: 3000;
  background: rgba(15, 23, 42, 0.92); color: #fff; padding: 10px 16px; border-radius: 999px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: 0.25s; max-width: calc(100% - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.results .tag { font-size: 11px; font-weight: 600; color: #fff; background: #16a34a; border-radius: 6px; padding: 1px 6px; margin-left: 6px; vertical-align: middle; }

.legend { display: flex; gap: 14px; font-size: 12px; color: #94a3b8; margin-top: 6px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .sw { display: inline-block; width: 18px; height: 4px; border-radius: 2px; }
.legend .sw.trail { background: #7c3aed; }
.legend .sw.route { background: #2563eb; }

.linklike { background: none; border: none; color: #60a5fa; padding: 0; margin-left: 4px; font: inherit; text-decoration: underline; cursor: pointer; }
a.button { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; border-radius: 10px; padding: 10px 14px; font-weight: 600; }
a.button.primary { background: #2563eb; color: #fff; }
.steps { padding-left: 20px; margin: 8px 0; line-height: 1.6; font-size: 14px; }
.warn { background: #7c2d12; color: #fed7aa; border-radius: 8px; padding: 8px 10px; font-size: 13px; }
.drawbar { position: fixed; left: 50%; transform: translateX(-50%); top: 120px; z-index: 1500; display: flex; gap: 8px; align-items: center; padding: 8px 10px; font-size: 14px; max-width: calc(100% - 24px); flex-wrap: wrap; justify-content: center; }
.drawbar[hidden] { display: none; }
.route-list { list-style: none; padding: 0; margin: 10px 0; max-height: 45vh; overflow: auto; }
.route-list li { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid rgba(148,163,184,.15); }
.route-list li .grow { flex: 1; min-width: 0; }
.route-list li small { display: block; color: #94a3b8; font-size: 12px; margin-top: 2px; }
.route-list li button.primary { padding: 6px 12px; }
.stops li.fixed-route { color: #f59e0b; }
a.button { border: 1px solid var(--line); background: var(--soft); color: var(--fg); font-weight: 400; padding: 9px 12px; white-space: nowrap; }
a.button.primary { background: var(--blue); border-color: var(--blue); color: #fff; font-weight: 600; }

