:root {
  --navy: #0b1f4d;
  --ink: #111827;
  --muted: #5b6475;
  --line: #e3e6ec;
  --bg: #ffffff;
  --soft: #f4f6f9;
  --accent: #0b5fff;
  --r: 12px;
  --shadow: 0 6px 24px rgba(11, 31, 77, .18);
}
* { box-sizing: border-box; min-width: 0; }
html, body { margin: 0; height: 100%; }
body { font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink); overflow: hidden; }
#map { position: fixed; inset: 0; }
button { font: inherit; cursor: pointer; }
a { color: var(--accent); }

/* Search */
.search { position: fixed; top: 12px; left: 12px; width: 360px; z-index: 3; }
#q {
  width: 100%; height: 48px; padding: 0 16px; font-size: 16px;
  border: 0; border-radius: var(--r); background: var(--bg); box-shadow: var(--shadow); outline: none;
}
#q:focus-visible { box-shadow: var(--shadow), 0 0 0 3px rgba(11, 95, 255, .35); }
#results {
  list-style: none; margin: 6px 0 0; padding: 6px; background: var(--bg);
  border-radius: var(--r); box-shadow: var(--shadow); max-height: 60vh; overflow: auto;
}
#results li { padding: 9px 10px; border-radius: 8px; cursor: pointer; display: flex; gap: 8px; align-items: center; justify-content: space-between; }
#results li[aria-selected="true"], #results li:hover { background: var(--soft); }
#results .nm { font-weight: 600; }
#results .bd { display: flex; gap: 3px; flex-wrap: wrap; justify-content: flex-end; }

/* Line badges */
.badge {
  display: inline-flex; align-items: center; justify-content: center; min-width: 24px; height: 22px; padding: 0 6px;
  border-radius: 11px; font-size: 12px; font-weight: 700; white-space: nowrap;
  background: #6b7280; color: #fff;
}
.badge.METRO { border-radius: 50%; padding: 0; width: 22px; min-width: 22px; }
.badge.TRAMWAY, .badge.VAL, .badge.CABLE { border-radius: 4px; }

/* Panel */
#panel {
  position: fixed; top: 72px; left: 12px; width: 360px; max-height: calc(100% - 84px); overflow: auto; z-index: 2;
  background: var(--bg); border-radius: var(--r); box-shadow: var(--shadow); padding: 16px 16px 12px;
}
#panel h2 { margin: 0 32px 8px 0; font-size: 22px; line-height: 1.15; color: var(--navy); }
#panel h3 { margin: 18px 0 8px; font-size: 13px; color: var(--muted); font-weight: 600; }
#panel .close {
  position: absolute; top: 10px; right: 10px; width: 36px; height: 36px; border: 0; border-radius: 50%;
  background: var(--soft); font-size: 20px; line-height: 1; color: var(--muted);
}
.lines { display: flex; gap: 5px; flex-wrap: wrap; }
.btn {
  display: inline-flex; align-items: center; gap: 8px; height: 44px; padding: 0 16px; margin-top: 14px;
  border: 0; border-radius: 10px; background: var(--navy); color: #fff; font-weight: 600;
}
.btn[aria-pressed="true"] { background: var(--accent); }
.ents { list-style: none; margin: 0; padding: 0; }
.ents li { display: flex; gap: 10px; align-items: flex-start; padding: 8px 6px; border-radius: 8px; cursor: pointer; }
.ents li:hover, .ents li.on { background: var(--soft); }
.num {
  flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--ink); color: #fff;
  display: grid; place-items: center; font-size: 12px; font-weight: 700;
}
.ents .t { font-weight: 600; }
.ents .d { color: var(--muted); font-size: 13px; }
.acc { list-style: none; margin: 0; padding: 0; }
.acc li { display: flex; justify-content: space-between; gap: 10px; padding: 4px 0; border-bottom: 1px solid var(--line); }
.acc li:last-child { border-bottom: 0; }
.acc .v { text-align: right; color: var(--muted); font-size: 13px; }
.links { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.links a {
  display: inline-flex; align-items: center; min-height: 36px; padding: 0 12px; border-radius: 18px;
  background: var(--soft); text-decoration: none; font-size: 14px; font-weight: 500;
}
.note { color: var(--muted); font-size: 13px; margin: 6px 0 0; }
.src { color: var(--muted); font-size: 12px; margin-top: 16px; border-top: 1px solid var(--line); padding-top: 8px; }

/* Floor switcher + legend */
.levels {
  position: fixed; right: 12px; top: 50%; transform: translateY(-50%); z-index: 2;
  display: flex; flex-direction: column; gap: 4px; background: var(--bg); padding: 6px; border-radius: var(--r); box-shadow: var(--shadow);
}
.levels .h { font-size: 11px; color: var(--muted); text-align: center; font-weight: 600; }
.levels button {
  width: 44px; height: 40px; border: 0; border-radius: 8px; background: var(--soft); font-weight: 700; color: var(--ink);
}
.levels button[aria-pressed="true"] { background: var(--navy); color: #fff; }
.legend {
  position: fixed; right: 12px; bottom: 34px; z-index: 2; display: grid; gap: 3px; font-size: 12px;
  background: var(--bg); padding: 8px 10px; border-radius: 10px; box-shadow: var(--shadow);
}
.legend span { display: flex; align-items: center; gap: 6px; }
.sw { width: 14px; height: 10px; border-radius: 2px; display: inline-block; }
.sw.room { background: #fde7b0; border: 1px solid #c9a24a; }
.sw.corridor { background: #eef1f5; border: 1px solid #b8c0cc; }
.sw.platform { background: #c9d4ff; border: 1px solid #5b6cf0; }
.ln { width: 16px; height: 0; display: inline-block; border-top: 3px solid; }
.ln.steps { border-color: #f97316; }
.ln.esc { border-color: #16a34a; border-top-style: dashed; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot.lift { background: #0284c7; }

.msg {
  position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%); z-index: 4; max-width: min(520px, 92vw);
  background: var(--navy); color: #fff; padding: 12px 16px; border-radius: 10px; box-shadow: var(--shadow);
}

:focus-visible { outline: 3px solid rgba(11, 95, 255, .5); outline-offset: 2px; }

/* Phone: search on top, panel as bottom sheet */
@media (max-width: 700px) {
  .search { left: 10px; right: 10px; width: auto; top: 10px; }
  #panel {
    top: auto; left: 0; right: 0; bottom: 0; width: auto; max-height: 48vh;
    border-radius: 16px 16px 0 0; padding-top: 18px;
  }
  .levels {
    top: 66px; left: 10px; right: 10px; transform: none; flex-direction: row; align-items: center;
    overflow-x: auto; padding: 5px;
  }
  .levels .h { padding: 0 4px; }
  .levels button { flex: none; height: 36px; }
  .legend { display: none !important; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
