:root {
  --bg: #e9ecef;
  --card: rgba(255, 255, 255, 0.88);
  --card-border: rgba(20, 30, 40, 0.10);
  --text: #1c252d;
  --muted: #66727d;
  --accent: #1f6feb;
  --ok: #1a7f37;
  --warn: #b35900;
  --bad: #c62828;
  --bus: #e4002b;
  --train: #00867a;
  --shadow: 0 6px 24px rgba(15, 25, 35, 0.14);
  --radius: 12px;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --card: rgba(24, 30, 36, 0.86);
    --card-border: rgba(255, 255, 255, 0.10);
    --text: #e8edf2;
    --muted: #9aa6b1;
    --shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); }
#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; outline: none; }
button { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

#topbar { position: fixed; top: 14px; left: 14px; z-index: 5; pointer-events: none; }
.brand { display: flex; gap: 10px; align-items: center; background: var(--card); border: 1px solid var(--card-border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 10px 14px; backdrop-filter: blur(10px); }
.brand .dot { width: 10px; height: 10px; border-radius: 50%; background: #2ecc71; box-shadow: 0 0 0 4px rgba(46, 204, 113, 0.2); animation: pulse 2s infinite; }
.brand h1 { font-size: 16px; margin: 0; letter-spacing: 0.2px; }
.brand .sub { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
@keyframes pulse { 50% { box-shadow: 0 0 0 7px rgba(46, 204, 113, 0.05); } }

#panel { position: fixed; top: 14px; right: 14px; width: 330px; max-height: calc(100% - 110px); overflow: auto; z-index: 5; padding: 12px 14px;
  transition: transform 0.35s cubic-bezier(0.3, 0.7, 0.2, 1), opacity 0.35s; }
/* minimised menus slide out to the right; a thin tab on the edge brings them back */
#panel.collapsed { transform: translateX(calc(100% + 30px)); opacity: 0; pointer-events: none; }
.edge-tab { position: fixed; right: 0; z-index: 6; width: 7px; height: 64px; padding: 0; border: 0; cursor: pointer;
  border-radius: 7px 0 0 7px; background: var(--accent); opacity: 0; pointer-events: none; transform: translateX(8px);
  transition: opacity 0.3s 0.15s, transform 0.3s 0.15s, width 0.15s; box-shadow: -1px 0 6px rgba(0, 0, 0, 0.18); }
.edge-tab::before { content: ""; position: absolute; inset: -6px -2px -6px -16px; } /* a larger area to hit than to see */
.edge-tab.show { opacity: 0.85; pointer-events: auto; transform: none; }
.edge-tab.show:hover, .edge-tab.show:focus-visible { width: 13px; opacity: 1; }
#panelTab { top: 22px; }
#toolbarTab { bottom: 34px; height: 44px; }
#toolbar { transition: transform 0.35s cubic-bezier(0.3, 0.7, 0.2, 1), opacity 0.35s, left 0.35s; }
#toolbar.collapsed { left: 100%; transform: translateX(30px); opacity: 0; pointer-events: none; }
#toolbar .hide-btn { padding: 8px 8px; opacity: 0.55; font-size: 16px; line-height: 1; }
#toolbar .hide-btn:hover { opacity: 1; }

/* place / address search: a small button under the title that opens into a field */
.search { position: relative; margin-top: 8px; display: flex; align-items: center; pointer-events: auto; width: max-content; }
.search-btn { width: 34px; height: 34px; border-radius: 17px; border: 1px solid var(--card-border); background: var(--card); color: inherit;
  box-shadow: var(--shadow); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); cursor: pointer; display: grid; place-items: center; padding: 0; opacity: 0.8; }
.search-btn:hover { opacity: 1; }
#searchInput { width: 0; padding: 0; border: 0; margin-left: 0; opacity: 0; height: 34px; border-radius: 17px; font: inherit; font-size: 14px;
  background: var(--card); color: inherit; box-shadow: var(--shadow); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  transition: width 0.25s, opacity 0.2s, padding 0.25s; outline: none; }
.search.open #searchInput { width: 240px; padding: 0 14px; opacity: 1; margin-left: 6px; border: 1px solid var(--card-border); }
.search.open #searchInput:focus { border-color: var(--accent); }
#searchList { position: absolute; top: 40px; left: 40px; width: 280px; max-height: 60vh; overflow: auto; padding: 4px; z-index: 7; }
#searchList .hit { display: block; width: 100%; text-align: left; border: 0; background: transparent; color: inherit; padding: 7px 10px; border-radius: 8px; cursor: pointer; font: inherit; }
#searchList .hit:hover, #searchList .hit.sel { background: rgba(127, 127, 127, 0.15); }
#searchList .hit b { font-size: 14px; font-weight: 600; display: block; }
#searchList .hit small { color: var(--muted); font-size: 12px; }
#searchList .none { padding: 8px 10px; color: var(--muted); font-size: 13px; }
#labels .lbl.searchpin { background: var(--accent); color: #fff; font-weight: 600; text-shadow: none; padding: 3px 8px; border-radius: 6px; }
#areaNote { position: fixed; top: 14px; left: 50%; transform: translateX(-50%); z-index: 6; padding: 7px 14px; font-size: 13px; transition: opacity 0.3s; }
#areaNote.off { opacity: 0; pointer-events: none; }
.panel-head { display: flex; justify-content: space-between; align-items: center; }
.panel-head h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin: 0; }
.icon-btn { border: 0; background: transparent; cursor: pointer; font-size: 18px; line-height: 1; padding: 2px 6px; border-radius: 6px; }
.icon-btn:hover { background: rgba(127, 127, 127, 0.15); }
.section { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--card-border); }
.station h3 { font-size: 14px; margin: 12px 0 6px; display: flex; align-items: center; gap: 6px; cursor: pointer; }
.station h3:hover { color: var(--accent); }
.dep { display: grid; grid-template-columns: 44px 1fr auto; gap: 8px; align-items: center; padding: 5px 0; font-size: 13px; border-bottom: 1px dashed var(--card-border); }
.dep:last-child { border-bottom: 0; }
.badge { display: inline-block; min-width: 38px; text-align: center; font-weight: 700; font-size: 12px; color: #fff; border-radius: 5px; padding: 2px 5px; background: var(--bus); }
.badge.rail { background: var(--train); }
.badge.plane { background: #3a4a5c; min-width: 0; width: 100%; font-size: 11px; overflow: hidden; text-overflow: ellipsis; }
.dep.plane-row { grid-template-columns: 66px 1fr auto; }
.dep.plane-row .dest small { display: block; margin-left: 0; }
.lbl.plane { background: rgba(40, 55, 75, 0.85); }
.lbl.airport { color: #22405f; font-size: 14px; }
#info .addr { margin: 4px 0 6px; font-size: 14px; font-weight: 600; }
.dep .dest { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dep .dest small { color: var(--muted); margin-left: 4px; }
.dep .st { font-variant-numeric: tabular-nums; text-align: right; font-size: 12px; white-space: nowrap; }
.st.at { color: var(--ok); font-weight: 700; }
.st.late { color: var(--warn); }
.st.cancel { color: var(--bad); text-decoration: line-through; }
.st .delay { color: var(--bad); margin-left: 4px; }
.kv { display: flex; justify-content: space-between; font-size: 13px; padding: 2px 0; }
.bar { height: 6px; border-radius: 3px; background: rgba(127, 127, 127, 0.2); overflow: hidden; margin: 6px 0 2px; }
.bar > div { height: 100%; background: linear-gradient(90deg, #2ecc71, #f1c40f, #e74c3c); }

#toolbar { position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%); display: flex; gap: 4px; padding: 5px; z-index: 5; }
#toolbar button { border: 0; background: transparent; padding: 8px 14px; border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: 500; }
#toolbar button:hover { background: rgba(127, 127, 127, 0.14); }
#toolbar button.active { background: var(--accent); color: #fff; }
#toolbar button.toggle { opacity: 0.55; }
#toolbar button.toggle.on { opacity: 1; }
#toolbar button.toggle.on::before { content: "●"; margin-right: 6px; font-size: 9px; color: #2ecc71; vertical-align: 2px; }
#toolbar .sep { width: 1px; background: var(--card-border); margin: 4px 4px; }

#hint { position: fixed; bottom: 86px; left: 50%; transform: translateX(-50%); padding: 8px 14px; font-size: 13px; z-index: 6; white-space: nowrap; }
#info { position: fixed; left: 14px; bottom: 30px; padding: 10px 14px; font-size: 13px; z-index: 5; max-width: 280px; }
#info b { font-size: 14px; }

#labels { position: fixed; inset: 0; pointer-events: none; z-index: 2; overflow: hidden; }
.lbl { position: absolute; left: 0; top: 0; transform-origin: 0 0; white-space: nowrap; font-size: 11px; font-weight: 600;
  padding: 2px 6px; border-radius: 5px; color: #fff; background: rgba(20, 28, 36, 0.78); will-change: transform; }
.lbl.bus { background: var(--bus); }
.lbl.rail { background: var(--train); }
.lbl.gps::after { content: " ⦿"; font-size: 9px; opacity: 0.85; }
.lbl.stop { background: rgba(255, 255, 255, 0.92); color: #1c252d; font-weight: 500; border: 1px solid rgba(0, 0, 0, 0.12); }
.lbl.bname { background: rgba(255, 255, 255, 0.9); color: #1c252d; font-weight: 600; border: 1px solid rgba(0, 0, 0, 0.15); }
.lbl.bname::after { content: ""; position: absolute; left: 50%; bottom: -5px; margin-left: -4px; border: 4px solid transparent; border-top-color: rgba(255, 255, 255, 0.9); border-bottom: 0; }
.lbl.place { background: transparent; color: #1c252d; font-size: 13px; font-weight: 700; text-shadow: 0 0 3px #fff, 0 0 3px #fff; }

#walkOverlay { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(10, 15, 20, 0.35); z-index: 20; }
.walk-card { padding: 22px 26px; max-width: 440px; text-align: center; }
.walk-card h2 { margin: 0 0 8px; }
.walk-card p { color: var(--muted); font-size: 14px; line-height: 1.5; }
.row { display: flex; gap: 10px; justify-content: center; margin-top: 12px; }
.row button { border: 1px solid var(--card-border); background: transparent; padding: 9px 16px; border-radius: 8px; cursor: pointer; }
.row button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }

#touchControls #joy { position: fixed; left: 26px; bottom: 90px; width: 120px; height: 120px; border-radius: 50%; background: rgba(255, 255, 255, 0.25);
  border: 2px solid rgba(255, 255, 255, 0.6); z-index: 10; touch-action: none; }
#joyKnob { position: absolute; left: 35px; top: 35px; width: 50px; height: 50px; border-radius: 50%; background: rgba(255, 255, 255, 0.85); }
#touchExit { position: fixed; top: 14px; right: 14px; z-index: 10; padding: 8px 14px; border: 0; }

#loading { position: fixed; inset: 0; display: grid; place-items: center; z-index: 30; background: var(--bg); }
.loading-card { padding: 26px 30px; width: min(520px, calc(100% - 32px)); text-align: center; }
.loading-card h2 { font-size: 18px; margin: 12px 0 6px; }
#loadLog { text-align: left; font-size: 11px; color: var(--muted); max-height: 180px; overflow: auto; white-space: pre-wrap; margin: 8px 0 0; }
.spinner { width: 34px; height: 34px; margin: 0 auto; border-radius: 50%; border: 3px solid rgba(127, 127, 127, 0.25); border-top-color: var(--accent); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

#attribution { position: fixed; right: 8px; bottom: 4px; font-size: 10px; color: #4b5560; z-index: 4; background: rgba(255, 255, 255, 0.6); padding: 1px 6px; border-radius: 4px; }
#attribution a { color: inherit; }

@media (max-width: 720px) {
  #panel { top: auto; bottom: 88px; right: 8px; left: 8px; width: auto; max-height: 38%; }
  #panel.collapsed { transform: translateX(calc(100% + 16px)); }
  #panelTab { top: auto; bottom: 110px; }
  #toolbarTab { bottom: 26px; }
  .search.open #searchInput { width: calc(100vw - 70px); }
  #searchInput { transition: none; }
  #searchList { left: 0; top: 40px; width: calc(100vw - 16px); }
  #areaNote { top: auto; bottom: 90px; }
  #topbar { top: 8px; left: 8px; }
  #toolbar { bottom: 22px; max-width: calc(100% - 16px); overflow-x: auto; }
  #toolbar button { padding: 8px 10px; font-size: 13px; }
  #info { display: none; }
}

.lang-row { display: flex; justify-content: flex-end; margin-top: 10px; }
.lang-btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--card-border); background: transparent; border-radius: 6px; padding: 3px 8px; font-size: 12px; cursor: pointer; color: var(--muted); }
.lang-btn:hover { background: rgba(127, 127, 127, 0.12); color: var(--text); }
.lang-btn svg { border-radius: 2px; box-shadow: 0 0 0 1px rgba(0,0,0,0.15); }

.modal { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; background: rgba(10, 15, 20, 0.45); padding: 16px; }
.modal-card { width: min(520px, 100%); max-height: calc(100vh - 32px); overflow: auto; padding: 18px 20px; }
.modal-card h2 { margin: 0 0 4px; font-size: 18px; }
.fld { display: flex; flex-direction: column; gap: 4px; margin: 10px 0; font-size: 13px; font-weight: 600; }
.fld input, .fld select, .fld textarea { font: inherit; font-weight: 400; padding: 7px 9px; border-radius: 8px; border: 1px solid var(--card-border); background: var(--card); color: var(--text); }
.colors { display: flex; flex-wrap: wrap; gap: 8px 16px; margin: 10px 0; }
.clr { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.clr input[type=color] { width: 34px; height: 24px; border: 0; padding: 0; background: none; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.thumbs { display: flex; gap: 6px; flex-wrap: wrap; }
.thumbs img { width: 70px; height: 70px; object-fit: cover; border-radius: 6px; }
.hp { position: absolute; left: -9999px; }
#propBox .chk { display: flex; gap: 6px; align-items: baseline; font-weight: 600; cursor: pointer; }
#extraList { margin: 4px 0 0 22px; display: grid; gap: 2px; }
#extraList label { display: flex; gap: 6px; align-items: center; cursor: pointer; }
#info .btn-suggest { margin-top: 8px; border: 1px solid var(--accent); color: var(--accent); background: transparent; border-radius: 7px; padding: 5px 10px; cursor: pointer; font-size: 13px; }
#info .flag { margin-top: 6px; font-size: 12px; color: var(--warn); }
#info .flag.ok { color: var(--ok); }
#info { pointer-events: auto; }
#editStatus.ok { color: var(--ok); } #editStatus.err { color: var(--bad); }
#info .info-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
#info .info-actions .btn-suggest { margin-top: 0; }
#info .btn-sv { border: 1px solid #c9ccd0; color: inherit; border-radius: 7px; padding: 5px 10px; font-size: 13px; text-decoration: none; background: rgba(255,255,255,0.6); }
#info .btn-sv:hover { border-color: var(--accent); }
.station h3 .pin { font-size: 11px; opacity: 0; transition: opacity .15s; }
.station h3:hover .pin { opacity: 1; }
.dep .dest a.goto { color: inherit; text-decoration: underline dotted; text-underline-offset: 3px; cursor: pointer; }
.dep .dest a.goto:hover { color: var(--accent); text-decoration-style: solid; }

#info .lm { margin-top: 6px; font-size: 12px; opacity: .85; }

/* water name bubble */
#waterTip { position: fixed; left: 0; top: 0; z-index: 4; pointer-events: none; display: flex; align-items: baseline; gap: 6px;
  padding: 6px 11px; border-radius: 16px; background: rgba(255,255,255,.95); color: #12324a; font-size: 13px; white-space: nowrap;
  box-shadow: 0 2px 10px rgba(0,0,0,.18); border: 1px solid rgba(40,110,170,.35); }
#waterTip.hidden { display: none !important; }
#waterTip b { font-size: 14px; }
#waterTip .muted { font-size: 12px; opacity: .75; }
#waterTip .wt-icon { font-size: 13px; }
#waterTip::after { content: ''; position: absolute; left: 50%; bottom: -6px; margin-left: -6px; border: 6px solid transparent; border-bottom: 0; border-top-color: rgba(255,255,255,.95); }

/* names and places added on the admin map */
.lbl.waterName { background: transparent; color: #1b5d97; font-style: italic; font-size: 13px; font-weight: 600; text-shadow: 0 0 3px #fff, 0 0 3px #fff, 0 0 2px #fff; }
.lbl.userPlace { background: rgba(255, 250, 238, 0.95); color: #3b2a12; border: 1px solid rgba(120, 80, 20, 0.35); pointer-events: auto; cursor: pointer; font-weight: 600; }
.lbl.userPlace::after { content: ""; position: absolute; left: 50%; bottom: -5px; margin-left: -4px; border: 4px solid transparent; border-top-color: rgba(255, 250, 238, 0.95); border-bottom: 0; }
#info .pdesc { margin-top: 6px; white-space: pre-wrap; max-width: 260px; }

/* advertising/attention signs above buildings: a bubble with text and a link */
#promoTip { position: fixed; left: 0; top: 0; z-index: 6; width: min(300px, 80vw); padding: 12px 14px 12px; border-radius: 12px;
  background: rgba(255,255,255,.97); color: #1d2a33; font-size: 13px; box-shadow: 0 4px 18px rgba(0,0,0,.25); border: 1px solid rgba(0,0,0,.1); }
#promoTip.hidden { display: none !important; }
#promoTip::after { content: ''; position: absolute; left: 50%; bottom: -7px; margin-left: -7px; border: 7px solid transparent; border-bottom: 0; border-top-color: rgba(255,255,255,.97); }
#promoTip b { display: block; font-size: 15px; margin-bottom: 4px; padding-right: 18px; }
#promoTip .pd { white-space: pre-wrap; line-height: 1.35; }
#promoTip .pa { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
#promoTip .pa a { display: inline-block; padding: 6px 12px; border-radius: 16px; background: #1f6fb2; color: #fff; text-decoration: none; font-weight: 600; font-size: 13px; }
#promoTip .pa a.sec { background: #e7eef4; color: #1f4f7a; }
#promoTip .px { position: absolute; top: 6px; right: 8px; border: 0; background: none; font-size: 16px; cursor: pointer; color: #667; }
