:root {
  --bg: #121417;
  --glass: rgba(22, 24, 28, 0.62);
  --glass-strong: rgba(20, 22, 26, 0.86);
  --line: rgba(255, 255, 255, 0.10);
  --text: #f4f1ea;
  --muted: rgba(244, 241, 234, 0.64);
  --accent: #c8a46a;
  --accent-2: #e2c48f;
  --radius: 16px;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: ui-serif, "New York", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--sans); overflow: hidden; overscroll-behavior: none; }
body { position: fixed; inset: 0; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
#scene { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; display: block; touch-action: none; cursor: grab; }
#scene:active { cursor: grabbing; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.glass { background: var(--glass); border: 1px solid var(--line); border-radius: var(--radius); backdrop-filter: blur(18px) saturate(140%); -webkit-backdrop-filter: blur(18px) saturate(140%); box-shadow: 0 10px 40px rgba(0, 0, 0, 0.28); }
.hidden, [hidden] { display: none !important; }

/* ---------------- ekran startowy */
.loader { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 24px; overflow-y: auto;
  background: radial-gradient(120% 90% at 50% 0%, #2a2c30 0%, #141619 55%, #0c0d0f 100%); transition: opacity .8s ease, visibility .8s; }
.loader.gone { opacity: 0; visibility: hidden; }
.loader-card { width: min(520px, 100%); text-align: center; }
.brand-mark { width: 64px; height: 64px; margin: 0 auto 18px; color: var(--accent); }
.brand-mark svg { width: 64px; height: 64px; stroke-width: 2.4; }
.eyebrow { letter-spacing: .28em; text-transform: uppercase; font-size: 11px; color: var(--accent-2); margin: 0 0 8px; }
.loader h1 { font-family: var(--serif); font-weight: 500; font-size: clamp(40px, 9vw, 68px); letter-spacing: .01em; margin: 0; line-height: 1.02; }
.lead { color: var(--muted); margin: 10px 0 26px; font-size: 15px; }
.facts { list-style: none; padding: 0; margin: 0 0 28px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.facts li { border: 1px solid var(--line); border-radius: 12px; padding: 12px 6px; font-size: 13px; color: var(--muted); }
.facts b { display: block; font-family: var(--serif); font-size: 22px; font-weight: 500; color: var(--text); }
.facts b small { font-size: 13px; color: var(--muted); font-family: var(--sans); }
.facts span { display: block; font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase; margin-top: 4px; }
.progress { height: 3px; background: rgba(255, 255, 255, .1); border-radius: 3px; overflow: hidden; margin: 0 auto 10px; width: 70%; }
.progress i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .4s ease; }
.status { font-size: 12px; color: var(--muted); margin: 0 0 20px; min-height: 16px; }
.loader.done .progress, .loader.done .status { opacity: .35; }
.note { font-size: 12px; color: var(--muted); line-height: 1.5; }
.ios-hint { margin-top: 18px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 999px; padding: 12px 22px; font-weight: 600; font-size: 14px; letter-spacing: .02em; transition: transform .15s ease, background .2s, opacity .2s; }
.btn.primary { background: linear-gradient(180deg, var(--accent-2), var(--accent)); color: #1b1814; box-shadow: 0 8px 24px rgba(200, 164, 106, .25); }
.btn.primary:disabled { opacity: .35; cursor: default; }
.btn.primary:not(:disabled):active { transform: scale(.97); }
.btn.ghost { border: 1px solid var(--line); background: rgba(255, 255, 255, .04); padding: 9px 14px; font-weight: 500; font-size: 13px; }
.btn.ghost:hover { background: rgba(255, 255, 255, .09); }

/* ---------------- instalacja aplikacji */
.install-tile { display: flex; align-items: center; gap: 12px; margin: 22px auto 0; max-width: 470px; padding: 12px; text-align: left;
  border: 1px solid rgba(200, 164, 106, .32); border-radius: 18px; background: linear-gradient(180deg, rgba(200, 164, 106, .10), rgba(255, 255, 255, .03)); }
.install-tile img { width: 52px; height: 52px; border-radius: 12px; flex: none; box-shadow: 0 6px 18px rgba(0, 0, 0, .45); }
.it-text { flex: 1; min-width: 0; }
.it-text b { display: block; font-size: 14px; font-weight: 600; }
.it-text span { display: block; font-size: 12px; color: var(--muted); line-height: 1.4; margin-top: 2px; }
.btn.small { padding: 8px 14px; font-size: 13px; flex: none; }
.install-x { flex: none; margin-left: -4px; }
.install-tile.in-panel { margin: 0; max-width: none; }
.sheet { position: fixed; inset: 0; z-index: 60; display: grid; place-items: end center; padding: 12px; padding-bottom: calc(12px + var(--sab));
  background: rgba(6, 7, 9, .5); opacity: 0; pointer-events: none; transition: opacity .3s ease; }
.sheet.open { opacity: 1; pointer-events: auto; }
.sheet-card { width: min(520px, 100%); padding: 18px 20px 16px; background: var(--glass-strong); transform: translateY(24px); transition: transform .4s cubic-bezier(.2, .8, .2, 1); }
.sheet.open .sheet-card { transform: none; }
.sheet header { display: flex; align-items: center; gap: 14px; }
.sheet header img { width: 64px; height: 64px; border-radius: 15px; box-shadow: 0 8px 22px rgba(0, 0, 0, .45); }
.sheet h2 { font-family: var(--serif); font-weight: 500; font-size: 21px; margin: 0 0 2px; }
.sheet header .note { margin: 0; }
.sheet header .close { margin-left: auto; align-self: flex-start; }
.steps { list-style: none; margin: 14px 0 6px; padding: 0; counter-reset: s; }
.steps li { counter-increment: s; display: flex; gap: 12px; align-items: flex-start; padding: 11px 0; border-bottom: 1px solid var(--line); font-size: 14px; line-height: 1.5; }
.steps li::before { content: counter(s); flex: none; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; margin-top: 1px;
  background: rgba(200, 164, 106, .2); color: var(--accent-2); font-size: 12px; font-weight: 600; }
.steps svg.inline { width: 18px; height: 18px; vertical-align: -4px; stroke: var(--accent-2); margin: 0 1px; }
@media (min-width: 761px) { .sheet { place-items: center; } }
@media (max-width: 520px) {
  .install-tile { display: grid; grid-template-columns: 52px 1fr auto; grid-template-areas: "img text x" "img go x"; column-gap: 12px; row-gap: 10px; align-items: start; }
  .install-tile img { grid-area: img; }
  .install-tile .it-text { grid-area: text; }
  .install-tile .install-go { grid-area: go; justify-self: start; }
  .install-tile .install-x { grid-area: x; margin: -6px -6px 0 0; }
}
body.standalone #installTileLoader { display: none; }

/* ---------------- HUD */
.hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
.hud > * { pointer-events: auto; }
.top { position: absolute; top: calc(12px + var(--sat)); left: calc(12px + var(--sal)); right: calc(12px + var(--sar)); display: flex; align-items: flex-start; gap: 10px; pointer-events: none; }
.top > * { pointer-events: auto; }
.brand { padding: 10px 14px; }
.brand-row { display: flex; align-items: center; gap: 10px; }
.brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px rgba(200, 164, 106, .18); }
.brand strong { display: block; font-family: var(--serif); font-weight: 500; font-size: 18px; letter-spacing: .01em; }
.brand small { color: var(--muted); font-size: 11.5px; }
.modes { margin-left: auto; display: flex; padding: 4px; gap: 2px; border-radius: 999px; }
.modes button { padding: 8px 14px; border-radius: 999px; font-size: 13px; font-weight: 500; color: var(--muted); transition: background .2s, color .2s; }
.modes button.on { background: rgba(255, 255, 255, .92); color: #17191c; }
.tools { display: flex; gap: 2px; padding: 4px; border-radius: 999px; }
.icon { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; transition: background .2s; }
.icon:hover { background: rgba(255, 255, 255, .1); }
.icon.small { width: 30px; height: 30px; }
.icon.small svg { width: 16px; height: 16px; }

.map { position: absolute; left: calc(12px + var(--sal)); bottom: calc(12px + var(--sab)); width: 232px; padding: 10px; transition: width .35s ease; }
.map canvas { display: block; width: 100%; height: 200px; border-radius: 10px; background: rgba(255, 255, 255, .03); cursor: crosshair; transition: height .35s ease; }
.map.big { width: min(520px, calc(100vw - 24px)); }
.map.big canvas { height: min(560px, calc(100vh - 220px)); }
.map-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.chip { font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--accent-2); padding: 3px 8px; border: 1px solid rgba(200, 164, 106, .35); border-radius: 999px; }
.map-foot { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-top: 8px; padding: 0 2px; }
.map-foot strong { font-family: var(--serif); font-weight: 500; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.map-foot span { color: var(--muted); font-size: 12px; white-space: nowrap; }

.bottom { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(12px + var(--sab)); display: flex; gap: 10px; align-items: center; }
.levels { display: flex; padding: 4px; gap: 2px; border-radius: 999px; }
.levels button { padding: 9px 14px; border-radius: 999px; font-size: 13px; color: var(--muted); }
.levels button.on { background: rgba(200, 164, 106, .22); color: var(--text); box-shadow: inset 0 0 0 1px rgba(200, 164, 106, .5); }
.levels button:disabled { opacity: .3; }
.actions { display: flex; align-items: center; padding: 4px; gap: 2px; border-radius: 999px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px 8px 10px; border-radius: 999px; font-size: 13px; font-weight: 500; }
.pill svg { width: 16px; height: 16px; fill: currentColor; stroke: none; }
.pill.on { background: var(--accent); color: #1b1814; }
#timeIcon.moon circle { fill: currentColor; }

.fov { position: absolute; right: calc(12px + var(--sar)); bottom: calc(12px + var(--sab)); width: 230px; padding: 12px 14px; }
.fov label, .field label { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.fov label b, .field label b { color: var(--text); font-weight: 600; }
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 22px; background: transparent; }
input[type=range]::-webkit-slider-runnable-track { height: 3px; background: rgba(255, 255, 255, .18); border-radius: 3px; }
input[type=range]::-moz-range-track { height: 3px; background: rgba(255, 255, 255, .18); border-radius: 3px; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%; background: var(--accent-2); margin-top: -7.5px; box-shadow: 0 2px 8px rgba(0, 0, 0, .4); }
input[type=range]::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: var(--accent-2); border: 0; }
body[data-mode="orbit"] .fov, body[data-mode="plan"] .fov { display: none; }

.joystick { display: none; position: absolute; left: calc(26px + var(--sal)); bottom: calc(86px + var(--sab)); width: 124px; height: 124px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, .10), rgba(255, 255, 255, .04)); border: 1px solid rgba(255, 255, 255, .22); touch-action: none; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.joystick .knob { position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px; border-radius: 50%; background: rgba(255, 255, 255, .85); box-shadow: 0 4px 14px rgba(0, 0, 0, .35); transition: transform .08s linear; }
body.touch[data-mode="walk"] .joystick { display: block; }

.hint { position: absolute; left: 50%; top: calc(76px + var(--sat)); transform: translate(-50%, -8px); max-width: min(680px, calc(100vw - 32px)); padding: 10px 16px; font-size: 12.5px; color: var(--text); text-align: center; opacity: 0; transition: opacity .5s, transform .5s; pointer-events: none; }
.hint.show { opacity: 1; transform: translate(-50%, 0); }
.toast { position: absolute; left: 50%; top: 42%; transform: translate(-50%, 10px); padding: 10px 16px; font-size: 13px; opacity: 0; transition: opacity .3s, transform .3s; pointer-events: none; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.room-label { position: absolute; left: 0; top: 0; pointer-events: auto; display: flex; flex-direction: column; align-items: center; padding: 6px 10px; border-radius: 10px;
  background: rgba(18, 20, 24, .72); border: 1px solid rgba(255, 255, 255, .14); color: var(--text); white-space: nowrap; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); transition: background .2s, opacity .2s; }
.room-label b { font-family: var(--serif); font-weight: 500; font-size: 13.5px; }
.room-label span { font-size: 10.5px; color: var(--muted); }
.room-label:hover { background: rgba(200, 164, 106, .85); color: #17191c; }
.room-label:hover span { color: #2c271f; }

.caption { position: absolute; left: 50%; bottom: calc(76px + var(--sab)); transform: translateX(-50%); width: min(640px, calc(100vw - 24px)); padding: 16px 18px 14px; text-align: center; }
.cap-text { font-family: var(--serif); font-size: clamp(17px, 2.4vw, 22px); line-height: 1.3; margin-bottom: 10px; }
.cap-dots { display: flex; justify-content: center; gap: 6px; margin-bottom: 12px; }
.cap-dots i { width: 6px; height: 6px; border-radius: 50%; background: rgba(255, 255, 255, .22); }
.cap-dots i.past { background: rgba(200, 164, 106, .55); }
.cap-dots i.on { background: var(--accent-2); width: 18px; border-radius: 6px; }
body.touring .map, body.touring .fov, body.touring .joystick, body.touring .levels { opacity: 0; pointer-events: none; }

.fader { position: fixed; inset: 0; background: #0b0c0e; opacity: 0; pointer-events: none; transition: opacity .45s ease; z-index: 40; }
.fader.on { opacity: 1; }

/* ---------------- panele */
.panel { position: fixed; z-index: 30; top: calc(10px + var(--sat)); right: calc(10px + var(--sar)); bottom: calc(10px + var(--sab)); width: min(460px, calc(100vw - 20px)); display: flex; flex-direction: column;
  background: var(--glass-strong); transform: translateX(calc(100% + 30px)); transition: transform .45s cubic-bezier(.2, .8, .2, 1); }
.panel.open { transform: none; }
.panel header { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 8px 20px; }
.panel h2 { font-family: var(--serif); font-weight: 500; font-size: 22px; margin: 0; }
.panel-body { overflow: auto; padding: 8px 20px 24px; -webkit-overflow-scrolling: touch; user-select: text; -webkit-user-select: text; }
.tabs { display: flex; align-items: center; gap: 4px; padding: 2px 16px 10px 18px; overflow-x: auto; flex: none; }
.tabs button { flex: none; display: inline-flex; align-items: center; line-height: 1.2; padding: 7px 12px; border-radius: 999px; font-size: 13px; color: var(--muted); border: 1px solid transparent; white-space: nowrap; }
.tabs button.on { color: var(--text); border-color: rgba(200, 164, 106, .5); background: rgba(200, 164, 106, .12); }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 8px 0 14px; }
.kpis div { border: 1px solid var(--line); border-radius: 12px; padding: 10px 8px; text-align: center; }
.kpis b { display: block; font-family: var(--serif); font-size: 20px; font-weight: 500; }
.kpis span { display: block; font-size: 10.5px; color: var(--muted); margin-top: 3px; line-height: 1.25; }
.lead-sm { color: var(--muted); font-size: 13px; line-height: 1.55; margin: 0 0 14px; }
.sum-plan { display: block; width: 100%; border-radius: 12px; background: rgba(255, 255, 255, .92); margin-bottom: 14px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; margin-bottom: 16px; }
th, td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; }
td.num, th.num { text-align: right; white-space: nowrap; }
tbody tr { cursor: pointer; transition: background .15s; }
tbody tr:hover { background: rgba(255, 255, 255, .05); }
tfoot td { font-weight: 600; border-bottom: 0; }
table.spec th { width: 46%; text-transform: none; letter-spacing: 0; font-size: 12.5px; }
table.spec tbody tr { cursor: default; }
.field { margin: 6px 0 18px; }
.lbl { display: block; font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.seg { display: flex; flex-wrap: wrap; gap: 4px; padding: 3px; border: 1px solid var(--line); border-radius: 12px; }
.seg button { flex: 1 1 auto; padding: 8px 10px; border-radius: 9px; font-size: 13px; color: var(--muted); }
.seg button.on { background: rgba(255, 255, 255, .9); color: #17191c; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.toggle { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; cursor: pointer; }
.toggle input { -webkit-appearance: none; appearance: none; width: 40px; height: 24px; border-radius: 12px; background: rgba(255, 255, 255, .18); position: relative; transition: background .2s; flex: none; cursor: pointer; }
.toggle input::after { content: ""; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .2s; }
.toggle input:checked { background: var(--accent); }
.toggle input:checked::after { transform: translateX(16px); }
.keys { display: grid; grid-template-columns: auto 1fr; gap: 10px 14px; font-size: 13.5px; margin: 6px 0 18px; }
.keys dt { color: var(--accent-2); font-weight: 600; }
.keys dd { margin: 0; color: var(--muted); }
.version { opacity: .5; }
.noscript { position: fixed; inset: 0; display: grid; place-items: center; }

/* ---------------- telefony */
@media (max-width: 760px) {
  .brand { display: none; }
  .modes { margin-left: 0; }
  .modes button { padding: 8px 11px; font-size: 12.5px; }
  .top { justify-content: space-between; }
  .map { left: auto; right: calc(10px + var(--sar)); top: calc(62px + var(--sat)); bottom: auto; width: 150px; padding: 8px; }
  .map canvas { height: 130px; }
  .map-foot strong { font-size: 13px; }
  .map-foot span { display: none; }
  .map.big { width: calc(100vw - 20px); }
  .map.big canvas { height: min(460px, calc(100vh - 260px)); }
  .fov { display: none; }
  .bottom { left: auto; right: calc(10px + var(--sar)); transform: none; flex-direction: column; align-items: flex-end; gap: 8px; }
  .levels button { padding: 8px 11px; font-size: 12.5px; }
  .caption { bottom: calc(16px + var(--sab)); }
  .hint { top: auto; bottom: calc(220px + var(--sab)); }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .facts { grid-template-columns: repeat(2, 1fr); }
  .panel { left: calc(8px + var(--sal)); width: auto; }
}
@media (max-width: 760px) and (orientation: landscape) {
  .map { top: calc(10px + var(--sat)); right: auto; left: calc(10px + var(--sal)); }
  .top { left: auto; width: auto; }
}
@media (hover: none) { .icon:hover, .btn.ghost:hover, tbody tr:hover { background: none; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
