/* Matria City map: full-screen 3D view with a small glass UI. Works on phones first (touch, safe areas). */
:root {
  --glass: rgba(16, 19, 26, .78); --line: rgba(255, 255, 255, .14); --text: #eef1f6; --muted: #a7b0bf;
  --accent: #6c8cff; --ok: #4cc38a; --warn: #f0b44c; --bad: #ff6b6b;
  --planned: #9aa3ad; --build: #f2a93b; --live: #19a974; --active: #ffd257; --link: #29d3ff;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0f1115; color: var(--text);
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
#stage { position: fixed; inset: 0; }
#stage canvas { display: block; width: 100%; height: 100%; touch-action: none; }

.bar { position: fixed; left: 8px; right: 8px; top: max(8px, env(safe-area-inset-top)); display: flex; align-items: center; gap: 10px;
  padding: 6px 8px; background: var(--glass); border: 1px solid var(--line); border-radius: 12px; backdrop-filter: blur(10px); }
.back { color: var(--text); text-decoration: none; font-weight: 600; padding: 6px 8px; border-radius: 8px; }
.back:hover { background: rgba(255, 255, 255, .08); }
.title { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.seg button { font: inherit; font-size: 13px; font-weight: 600; color: var(--muted); background: transparent; border: 0; padding: 7px 10px; min-height: 34px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--accent); color: #0b0d12; }

.status { position: fixed; left: 8px; right: 8px; top: calc(max(8px, env(safe-area-inset-top)) + 56px); display: flex; flex-wrap: wrap; gap: 6px; pointer-events: none; }
.chip { background: var(--glass); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; font-size: 12.5px; backdrop-filter: blur(8px);
  font-variant-numeric: tabular-nums; }
.chip.warn { background: var(--warn); color: #111; border-color: var(--warn); font-weight: 700; }
.chip.bad { background: var(--bad); color: #fff; border-color: var(--bad); font-weight: 700; }
.chip.ok { color: var(--ok); }

.tools { position: fixed; right: 8px; bottom: calc(max(8px, env(safe-area-inset-bottom)) + 44px); display: flex; gap: 6px; align-items: center; }
.tools button, .toggle { font: inherit; font-size: 13px; font-weight: 600; color: var(--text); background: var(--glass); border: 1px solid var(--line);
  border-radius: 9px; padding: 7px 10px; min-height: 36px; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; backdrop-filter: blur(8px); }
.toggle input { margin: 0; }

.legend { position: fixed; left: 8px; right: 8px; bottom: max(8px, env(safe-area-inset-bottom)); display: flex; flex-wrap: wrap; gap: 4px 12px;
  padding: 6px 10px; background: var(--glass); border: 1px solid var(--line); border-radius: 10px; font-size: 12px; color: var(--muted); backdrop-filter: blur(8px); }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.sw.planned { border: 1.5px dashed var(--planned); }
.sw.build { background: var(--build); }
.sw.live { background: var(--live); }
.sw.active { background: var(--active); box-shadow: 0 0 6px var(--active); }
.sw.link { background: var(--link); height: 3px; width: 14px; }

#labels { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.label { position: absolute; transform: translate(-50%, -100%); white-space: nowrap; font-size: 11.5px; font-weight: 600; padding: 2px 6px;
  border-radius: 6px; background: rgba(10, 12, 18, .72); color: #fff; border: 1px solid var(--line); }
.label.sel { background: var(--accent); color: #0b0d12; border-color: var(--accent); }
.label.active::before { content: "● "; color: var(--active); }
.label.blink { animation: matria-blink 1.6s ease-out 1; }
@keyframes matria-blink { 0% { background: var(--accent); color: #0b0d12; transform: translate(-50%, -100%) scale(1.25); } 100% { transform: translate(-50%, -100%) scale(1); } }
.chip.event { max-width: 70vw; overflow: hidden; text-overflow: ellipsis; }

.sheet { position: fixed; left: 8px; right: 8px; bottom: calc(max(8px, env(safe-area-inset-bottom)) + 92px); max-height: 55vh; overflow: auto;
  padding: 14px 16px; background: rgba(16, 19, 26, .94); border: 1px solid var(--line); border-radius: 14px; backdrop-filter: blur(12px); }
@media (min-width: 760px) { .sheet { left: auto; width: 380px; top: 120px; bottom: auto; max-height: calc(100vh - 220px); } }
.sheet h2 { margin: 0 30px 4px 0; font-size: 17px; }
.sheet .close { position: absolute; right: 8px; top: 6px; font-size: 22px; line-height: 1; color: var(--muted); background: transparent; border: 0; cursor: pointer; min-width: 36px; min-height: 36px; }
.muted { color: var(--muted); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 10px 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.floors { margin: 6px 0 0; padding-left: 20px; color: var(--muted); }
.floors li { margin: 3px 0; }
details summary { cursor: pointer; color: var(--accent); font-weight: 600; }

.error { position: fixed; left: 50%; top: 45%; transform: translate(-50%, -50%); background: var(--bad); color: #fff; padding: 10px 14px; border-radius: 10px; max-width: 90vw; }
.updated { position: fixed; right: 12px; bottom: calc(max(8px, env(safe-area-inset-bottom)) + 86px); margin: 0; font-size: 11px; color: var(--muted); pointer-events: none; }
@media (max-width: 520px) { .updated { display: none; } }
