/* Subway Atlas: colours follow the Cupertino theme so the pages match the map. */
:root {
  --land: #222e3b; --panel: #1b2337; --panel-2: #283950; --line: #3a4d62;
  --ink: #dae4ee; --dim: #9eb0c4; --accent: #ffa300; --danger: #ee352e; --ok: #00933c;
  color-scheme: dark;
}
* { box-sizing: border-box; min-width: 0; }
html, body { height: 100%; }
body { margin: 0; background: var(--land); color: var(--ink);
  font: 16px/1.5 "Noto Sans", system-ui, -apple-system, "Segoe UI", sans-serif; }
a { color: inherit; }
code { font: 0.9em ui-monospace, Consolas, monospace; background: var(--panel); padding: 1px 6px; border-radius: 5px; overflow-wrap: anywhere; }
small { color: var(--dim); font-size: 13px; font-weight: 400; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* top bar */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(env(safe-area-inset-top) + 10px) max(env(safe-area-inset-right), 18px) 10px max(env(safe-area-inset-left), 18px);
  border-bottom: 1px solid var(--line); background: var(--panel); }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; text-decoration: none; }
.brand svg { width: 34px; height: 20px; }
.brand path { fill: none; stroke: var(--accent); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
.brand circle { fill: #fff; stroke: var(--panel); stroke-width: 2; }

/* controls */
.btn { appearance: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--ink); font: 600 15px/1 inherit; font-family: inherit;
  text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:hover { filter: brightness(1.15); }
.btn:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn.primary { background: var(--accent); color: #111; border-color: transparent; }
.btn.ghost { background: transparent; }
.btn.danger { color: #ff9b96; }
.btn.danger-solid { background: var(--danger); border-color: transparent; color: #fff; }
input[type=text], input[type=password], input:not([type]), select, input[type=file] {
  width: 100%; min-height: 44px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--land); color: var(--ink); font: 16px inherit; font-family: inherit; }
input[type=file] { padding: 9px; }
label { display: grid; gap: 6px; font-weight: 600; font-size: 15px; }
.stack { display: grid; gap: 16px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; }
.hint { margin: 0; color: var(--dim); font-size: 14px; }

/* flash messages */
.flashes { max-width: 1100px; margin: 16px auto 0; padding: 0 18px; display: grid; gap: 6px; }
.flash { margin: 0; padding: 10px 14px; border-radius: 10px; background: var(--panel); border-left: 4px solid var(--dim); }
.flash.error { border-color: var(--danger); }
.flash.success { border-color: var(--ok); }

/* home */
.home { max-width: 1100px; margin: 0 auto; padding: 28px 18px 48px; display: grid; gap: 28px;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); align-items: start; }
h1 { font-size: clamp(28px, 4vw, 38px); line-height: 1.1; margin: 0 0 16px; }
h2 { font-size: 20px; margin: 0 0 14px; }
.map-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.map-row { display: flex; align-items: center; gap: 8px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 6px 6px 6px 0; }
.map-open { flex: 1; display: grid; gap: 2px; padding: 10px 16px; text-decoration: none; }
.map-open:hover .map-name { color: var(--accent); }
.map-name { font-weight: 700; font-size: 17px; }
.map-meta { color: var(--dim); font-size: 14px; }
.empty { background: var(--panel); border: 1px dashed var(--line); border-radius: 14px; padding: 22px; color: var(--dim); }
.empty p { margin: 0; }
.upload { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 20px; }
@media (max-width: 760px) { .home { grid-template-columns: minmax(0, 1fr); } }

/* centred pages: login, confirm, errors */
.page.center main { max-width: 440px; margin: 10vh auto 0; padding: 0 18px; }
.login form { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 22px; }
.confirm p { color: var(--dim); }

/* viewer */
body.viewer { overflow: hidden; }
#map { position: fixed; inset: 0; background: var(--land); }
.viewer-panel { position: fixed; z-index: 2; top: calc(env(safe-area-inset-top) + 12px); left: max(env(safe-area-inset-left), 12px);
  display: flex; align-items: center; gap: 10px; max-width: calc(100vw - 80px);
  background: rgba(27, 35, 55, .92); border: 1px solid var(--line); border-radius: 14px; padding: 6px 8px 6px 6px;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.viewer-panel .back { min-width: 44px; padding: 0; font-size: 20px; }
.viewer-title { display: grid; line-height: 1.25; }
.viewer-title strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.viewer-title span { color: var(--dim); font-size: 13px; white-space: nowrap; }
.theme-pick select { min-height: 40px; padding: 6px 10px; width: auto; font-size: 14px; }
.viewer-error { position: fixed; z-index: 3; left: 50%; bottom: 40px; transform: translateX(-50%); margin: 0;
  background: var(--panel); border: 1px solid var(--danger); border-radius: 10px; padding: 10px 14px; max-width: 90vw; }
.maplibregl-ctrl-group { background: var(--panel) !important; }
.maplibregl-ctrl-group button + button { border-top-color: var(--line) !important; }
.maplibregl-ctrl-group button .maplibregl-ctrl-icon { filter: invert(.9); }
.maplibregl-ctrl-scale { background: rgba(27, 35, 55, .8) !important; color: var(--ink) !important; border-color: var(--ink) !important; }
.maplibregl-ctrl-attrib { background: rgba(27, 35, 55, .8) !important; color: var(--ink) !important; }
.maplibregl-ctrl-attrib a { color: var(--ink) !important; }
@media (max-width: 600px) { .theme-pick { display: none; } }
