:root {
  --c-oneway: #ffd400;
  --c-oneway-arrow: #e3000f;
  --c-phase2: #e6007e;
  --c-twoway: #16a34a;
  --c-priority: #0ea5e9;
  --c-limiter: #d7141a;

  --bg: #ffffff;
  --bg-soft: #f3f4f6;
  --fg: #111827;
  --fg-muted: #4b5563;
  --border: #e5e7eb;
  --accent: #1e5bb8;
  --on-accent: #ffffff;
  --shadow: 0 10px 30px rgba(15, 23, 42, .18), 0 2px 6px rgba(15, 23, 42, .12);
  --radius: 14px;
  --panel-w: 360px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111827;
    --bg-soft: #1f2937;
    --fg: #f3f4f6;
    --fg-muted: #9ca3af;
    --border: #374151;
    --accent: #60a5fa;
    --on-accent: #0b1220;
    --shadow: 0 10px 30px rgba(0, 0, 0, .5), 0 2px 6px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; background: var(--bg); color: var(--fg); }
#map { position: fixed; inset: 0; background: #dfe3e8; }

/* ---------- panel ---------- */
.panel {
  position: absolute; z-index: 1000;
  top: 12px; left: 12px; bottom: 12px;
  width: var(--panel-w);
  display: flex; flex-direction: column;
  background: var(--bg); color: var(--fg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.panel-handle { display: none; }
.panel-head {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 14px 14px 10px 16px;
  border-bottom: 1px solid var(--border);
}
.title-wrap { flex: 1; min-width: 0; }
.panel-head h1 { font-size: 18px; line-height: 1.25; margin: 0; font-weight: 700; letter-spacing: -.01em; }
.subtitle { margin: 3px 0 0; font-size: 12.5px; color: var(--fg-muted); }
.head-actions { display: flex; gap: 6px; }
.icon-btn {
  width: 32px; height: 32px; border-radius: 9px;
  border: 1px solid var(--border); background: var(--bg-soft); color: var(--fg);
  font: 600 12px/1 inherit; cursor: pointer;
}
.icon-btn:hover { border-color: var(--accent); }
#infoBtn { font-family: Georgia, serif; font-style: italic; font-size: 16px; }

.panel-body { flex: 1; overflow-y: auto; padding: 4px 16px 14px; overscroll-behavior: contain; }
.section-title {
  font-size: 11.5px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--fg-muted); margin: 14px 0 8px; font-weight: 700;
}

/* legend */
.layer-toggle {
  display: flex; align-items: center; gap: 10px;
  padding: 5px 2px; font-size: 14px; cursor: pointer; user-select: none;
}
.layer-toggle input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
.swatch { flex: 0 0 38px; height: 8px; border-radius: 4px; position: relative; }
.swatch-oneway { background: var(--c-oneway); box-shadow: inset 0 0 0 1px rgba(0,0,0,.25); }
.swatch-oneway::after, .swatch-phase2::after {
  content: ""; position: absolute; right: 7px; top: 50%;
  border-left: 9px solid var(--c-oneway-arrow);
  border-top: 6px solid transparent; border-bottom: 6px solid transparent;
  transform: translateY(-50%);
}
.swatch-phase2 { background: var(--c-phase2); }
.swatch-phase2::after { border-left-color: #6b0038; }
.swatch-twoway { background: var(--c-twoway); }
.swatch-priority { background: var(--c-priority); }
.swatch-limiter {
  flex: 0 0 22px; height: 22px; margin: 0 8px; border-radius: 50%;
  background: #fff; color: #111; border: 3px solid var(--c-limiter);
  font: 700 9px/16px system-ui, sans-serif; text-align: center;
}
.swatch-plan {
  height: 16px; border-radius: 4px;
  background: repeating-linear-gradient(45deg, #6b8e23 0 6px, #3f5a14 6px 12px);
}
.plan-toggle { margin-top: 4px; }
#planOpacity { width: calc(100% - 50px); margin: 2px 0 0 50px; accent-color: var(--accent); }

/* places */
.places { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.chip {
  border: 1px solid var(--border); background: var(--bg-soft); color: var(--fg);
  border-radius: 999px; padding: 6px 11px; font: 500 13px/1 inherit; cursor: pointer;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }

/* streets */
.search {
  width: 100%; padding: 9px 11px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--bg-soft); color: var(--fg);
  font: 14px inherit; outline: none;
}
.search:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.street-list { list-style: none; margin: 8px 0 0; padding: 0; }
.street-list li button {
  width: 100%; display: flex; align-items: center; gap: 10px; text-align: left;
  padding: 7px 6px; border: 0; border-radius: 9px; background: none; color: var(--fg);
  font: 14px inherit; cursor: pointer;
}
.street-list li button:hover, .street-list li button.active { background: var(--bg-soft); }
.street-list .name { flex: 1; min-width: 0; }
.street-list .name small { display: block; color: var(--fg-muted); font-size: 12px; margin-top: 1px; }
.badge {
  flex: 0 0 auto; min-width: 28px; height: 28px; padding: 0 5px; border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
  font: 700 12.5px/1 system-ui, sans-serif; color: #111; background: #fff;
  border: 3px solid var(--c-oneway);
}
.badge.k-phase2 { border-color: var(--c-phase2); }
.badge.k-twoway { border-color: var(--c-twoway); }
.badge.k-priority { border-color: var(--c-priority); color: #0369a1; }
.badge.k-limiter { border-color: var(--c-limiter); }
.empty { color: var(--fg-muted); font-size: 13px; padding: 8px 6px; }

.disclaimer {
  margin: 16px 0 0; padding: 10px 12px; border-radius: 10px;
  background: var(--bg-soft); color: var(--fg-muted); font-size: 12.5px; line-height: 1.45;
}

/* ---------- map elements ---------- */
.num-label {
  width: 26px; height: 26px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: #fff; color: #b3001b; border: 2px solid #1f2937;
  font: 700 12px/1 Georgia, "Times New Roman", serif;
  box-shadow: 0 1px 4px rgba(0,0,0,.35);
}
.num-label.k-priority { color: #0b5cad; }
.limiter-icon {
  width: 26px; height: 26px; border-radius: 50%;
  background: #fff; border: 4px solid var(--c-limiter); color: #111;
  display: flex; align-items: center; justify-content: center;
  font: 800 10px/1 system-ui, sans-serif; box-shadow: 0 1px 5px rgba(0,0,0,.45);
}
.leaflet-popup-content-wrapper { border-radius: 12px; }
.leaflet-popup-content { margin: 12px 14px; font: 13.5px/1.45 system-ui, sans-serif; min-width: 200px; }
.pop-title { font-weight: 700; font-size: 15px; margin: 0 0 4px; display: flex; gap: 8px; align-items: center; }
.pop-kind { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; margin-bottom: 6px; }
.pop-kind.k-oneway { background: #fff3b0; color: #7a5b00; }
.pop-kind.k-phase2 { background: #ffd6ec; color: #8a0049; }
.pop-kind.k-twoway { background: #d7f5e1; color: #0f6b32; }
.pop-kind.k-priority { background: #d9f1fd; color: #075985; }
.pop-kind.k-limiter { background: #fde2e2; color: #9b1c1c; }
.pop-row { margin: 2px 0; color: #374151; }
.pop-row b { color: #111827; }
.pop-dir { font-size: 14px; color: #111827; font-weight: 600; margin: 4px 0; }

.leaflet-control-layers, .leaflet-bar { border-radius: 10px !important; }

/* ---------- about dialog ---------- */
.about {
  max-width: 560px; width: calc(100% - 32px);
  border: 0; border-radius: var(--radius); padding: 22px 22px 18px;
  background: var(--bg); color: var(--fg); box-shadow: var(--shadow);
  font-size: 14.5px; line-height: 1.55;
}
.about::backdrop { background: rgba(15, 23, 42, .45); }
.about h2 { margin: 0 0 10px; font-size: 19px; }
.about p { margin: 0 0 10px; }
.about ul { margin: 0 0 10px; padding-left: 20px; }
.about .primary {
  margin-top: 6px; border: 0; border-radius: 10px; padding: 9px 16px;
  background: var(--accent); color: var(--on-accent); font: 600 14px inherit; cursor: pointer;
}

/* ---------- mobile: bottom sheet ---------- */
@media (max-width: 720px) {
  .panel {
    top: auto; left: 0; right: 0; bottom: 0; width: auto;
    max-height: 78vh; border-radius: 18px 18px 0 0;
    padding-bottom: env(safe-area-inset-bottom);
    transition: transform .25s ease;
  }
  .panel.collapsed .panel-body { display: none; }
  .panel-handle {
    display: flex; justify-content: center; align-items: center;
    width: 100%; height: 22px; padding: 0; border: 0; background: none; cursor: pointer;
  }
  .handle-bar { width: 42px; height: 5px; border-radius: 3px; background: var(--border); }
  .panel-head { padding-top: 2px; }
  .panel-head h1 { font-size: 16px; }
  .leaflet-bottom.leaflet-right { bottom: 96px; }
  .leaflet-top.leaflet-right { top: 4px; }
}
