/* RS Street Mall 3D model viewer: dark UI, Bebas Neue + Inter like rsstreet.com/mall. No inline styles in the markup (CSP friendly). */
:root {
  --bg: #07060a; --panel: #0e0c12; --panel2: #15121b; --ink: #f4efe8; --muted: #9a948c; --line: rgba(244, 239, 232, .14); --line2: rgba(244, 239, 232, .07);
  --accent: #ff5a2d; --accent-ink: #1a0a05;
  --display: "Bebas Neue", Impact, "Arial Narrow", sans-serif; --ui: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --top-h: 52px; --panel-w: 372px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font-family: var(--ui); font-size: 14px; line-height: 1.45; -webkit-font-smoothing: antialiased; overscroll-behavior: none; }
body { display: flex; flex-direction: column; height: 100dvh; overflow: hidden; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
.dot { color: var(--accent); }

body.loading #toolbar, body.loading #panel, body.loading #embedBar { opacity: .35; pointer-events: none; }

/* ---- header */
.top { flex: 0 0 var(--top-h); display: flex; align-items: center; gap: 14px; padding: 0 16px; padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); border-bottom: 1px solid var(--line); background: var(--bg); z-index: 30; }
.wordmark { font-family: var(--display); font-size: 28px; letter-spacing: .04em; text-decoration: none; line-height: 1; }
.tag { font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); border: 1px solid var(--line); padding: 3px 8px; border-radius: 99px; }
.grow { flex: 1; }
.toplink { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; text-decoration: none; color: var(--muted); background: none; border: 0; padding: 8px 4px; }
.toplink:hover { color: var(--ink); }
.panel-toggle { display: none; }

/* ---- layout */
#app { flex: 1 1 auto; display: grid; grid-template-columns: minmax(0, 1fr) var(--panel-w); min-height: 0; }
#stage { position: relative; min-width: 0; min-height: 0; overflow: hidden; background: #0b0a10; }
#gl { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; outline: none; }
#gl:active { cursor: grabbing; }
#gl.measuring { cursor: crosshair; }

/* ---- HUD */
#hud { position: absolute; left: 12px; top: 12px; display: flex; gap: 6px; flex-wrap: wrap; z-index: 6; pointer-events: none; max-width: calc(100% - 24px); }
.chip { background: rgba(7, 6, 10, .66); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); border: 1px solid var(--line); padding: 5px 10px; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; border-radius: 6px; }
.chip-warn { border-color: rgba(255, 90, 45, .6); color: #ffb9a3; }
#hint { position: absolute; left: 12px; bottom: 10px; margin: 0; font-size: 11px; letter-spacing: .06em; color: var(--muted); z-index: 4; pointer-events: none; text-shadow: 0 1px 4px #000; }

/* ---- toolbar */
#toolbar { position: absolute; right: 12px; top: 12px; z-index: 7; display: flex; flex-direction: column; gap: 6px; align-items: stretch; }
#toolbar button, #embedBar button, #embedBar a { background: rgba(7, 6, 10, .72); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); border: 1px solid var(--line); color: var(--ink); padding: 8px 12px; min-height: 36px; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; border-radius: 6px; text-decoration: none; text-align: center; }
#toolbar button:hover, #embedBar button:hover, #embedBar a:hover { border-color: var(--ink); }
button[aria-pressed="true"] { background: var(--accent) !important; border-color: var(--accent) !important; color: var(--accent-ink) !important; }
#embedBar { position: absolute; left: 50%; transform: translateX(-50%); bottom: 12px; z-index: 7; display: flex; gap: 6px; max-width: calc(100% - 24px); }
body.embed #toolbar, body.embed #hint, body.embed #hud { display: none; }
body.embed #embedBar { display: flex; }
body.embed.bare #embedBar { display: none; }

/* ---- labels */
#labels { position: absolute; inset: 0; z-index: 5; pointer-events: none; overflow: hidden; }
#labels.off { display: none; }
.lab { position: absolute; left: 0; top: 0; pointer-events: auto; display: flex; flex-direction: column; align-items: flex-start; gap: 0; max-width: 220px; text-align: left; background: rgba(7, 6, 10, .78); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 4px; padding: 3px 8px 4px; color: var(--ink); line-height: 1.15; will-change: transform; white-space: nowrap; }
.lab b { font-family: var(--display); font-weight: 400; font-size: 17px; letter-spacing: .05em; }
.lab small { font-size: 10.5px; letter-spacing: .04em; color: #cfc8be; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }
.lab:hover { border-color: var(--ink); border-left-color: var(--accent); }
.lab-concept { opacity: .8; } .lab-concept b { font-size: 14px; }
.lab.hide { display: none; }
.lab.compact { padding: 2px 7px; }
.lab.compact b { font-size: 13px; }
.lab.compact small { display: none; }
#labels .lab-stage { background: rgba(20, 8, 14, .8); }

/* ---- loader */
#loader { position: absolute; inset: 0; z-index: 20; display: flex; align-items: flex-end; justify-content: center; pointer-events: none; padding: 0 16px 8vh; background: linear-gradient(to top, rgba(7, 6, 10, .88), rgba(7, 6, 10, 0) 70%); transition: opacity .6s; }
#loader.done { opacity: 0; }
.loader-box { width: min(420px, 100%); text-align: center; }
.loader-mark { font-family: var(--display); font-size: 40px; letter-spacing: .05em; margin: 0 0 4px; }
.loader-text { margin: 0 0 10px; font-size: 13px; letter-spacing: .08em; text-transform: uppercase; }
.loader-bar { height: 4px; background: rgba(244, 239, 232, .14); border-radius: 4px; overflow: hidden; }
.loader-bar span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.loader-sub { margin: 10px 0 0; font-size: 11px; color: var(--muted); }
#loader.error .loader-bar span { background: #c0392b; }

/* ---- info card */
#card { position: absolute; left: 12px; bottom: 34px; z-index: 12; width: min(360px, calc(100% - 24px)); background: rgba(14, 12, 18, .94); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border: 1px solid var(--line); border-top: 3px solid var(--accent); border-radius: 8px; padding: 14px 16px 14px; box-shadow: 0 10px 40px rgba(0, 0, 0, .5); }
#card .x { position: absolute; right: 8px; top: 6px; width: 36px; height: 36px; background: none; border: 0; font-size: 22px; color: var(--muted); }
#card .eyebrow { margin: 0 0 2px; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
#card h3 { margin: 0 28px 6px 0; font-family: var(--display); font-weight: 400; font-size: 30px; letter-spacing: .04em; line-height: 1; }
#card p { margin: 0 0 10px; color: #d9d3c9; }
#card ul { list-style: none; margin: 0 0 10px; padding: 0; }
#card li { display: flex; justify-content: space-between; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line2); }
#card li span { color: var(--muted); font-size: 12px; }
#card .actions { display: flex; flex-wrap: wrap; gap: 6px; }
#card .actions a, #card .actions button { padding: 9px 12px; min-height: 38px; border: 1px solid var(--line); background: transparent; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; text-decoration: none; border-radius: 6px; }
#card .actions .go { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }

/* ---- measure */
#measureLabel { position: absolute; z-index: 9; transform: translate(-50%, -140%); background: var(--accent); color: var(--accent-ink); font-weight: 600; font-size: 12px; padding: 4px 8px; border-radius: 4px; pointer-events: none; white-space: nowrap; left: 0; top: 0; }
#measureTip { position: absolute; z-index: 9; left: 50%; top: 14px; transform: translateX(-50%); background: rgba(7, 6, 10, .8); border: 1px solid var(--accent); padding: 6px 12px; border-radius: 6px; font-size: 12px; pointer-events: none; }

/* ---- panel */
#panel { display: flex; flex-direction: column; min-height: 0; background: var(--panel); border-left: 1px solid var(--line); }
.sheet-handle { display: none; }
.tabs { flex: 0 0 auto; display: flex; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { flex: 1 0 auto; background: none; border: 0; border-bottom: 2px solid transparent; padding: 13px 12px 11px; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); background: none !important; }
.pane { flex: 1 1 auto; overflow-y: auto; padding: 14px 18px 40px; -webkit-overflow-scrolling: touch; }
h2 { margin: 18px 0 8px; font-size: 11px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
h2:first-child { margin-top: 2px; }
.note { margin: 8px 0 0; font-size: 12px; color: var(--muted); }
.btns { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.btns button, .layers-top button { background: var(--panel2); border: 1px solid var(--line); color: var(--ink); padding: 9px 11px; min-height: 38px; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; border-radius: 6px; }
.btns button:hover, .layers-top button:hover { border-color: var(--ink); }
.btns button.accent { border-color: var(--accent); color: var(--accent); }
.check { display: flex; align-items: center; gap: 10px; padding: 8px 0; cursor: pointer; border-bottom: 1px solid var(--line2); }
.check input, .sub input, .grp-head input { accent-color: var(--accent); width: 18px; height: 18px; margin: 0; flex: none; }
.slider { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.slider label { flex: 0 0 82px; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.slider input[type=range] { flex: 1; min-width: 0; accent-color: var(--accent); height: 32px; }
.slider output { flex: 0 0 56px; text-align: right; font-size: 12px; font-variant-numeric: tabular-nums; color: var(--muted); }
.readout { font-size: 13px; margin: 8px 0; padding: 8px 10px; background: var(--panel2); border-radius: 6px; border: 1px solid var(--line2); }

/* layers */
.layers-top { display: flex; align-items: center; justify-content: space-between; }
.layers-top h2 { margin: 2px 0; }
.iso-note { margin: 8px 0; padding: 8px 10px; background: rgba(255, 90, 45, .12); border: 1px solid rgba(255, 90, 45, .5); border-radius: 6px; font-size: 12px; }
.grp { border-bottom: 1px solid var(--line2); }
.grp-head { display: flex; align-items: center; gap: 10px; padding: 7px 0; }
.grp-head label { flex: 1; display: flex; align-items: center; gap: 10px; cursor: pointer; min-width: 0; }
.grp-head .name { flex: 1; min-width: 0; }
.sw { width: 12px; height: 12px; border-radius: 3px; flex: none; border: 1px solid rgba(255, 255, 255, .25); }
.count { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.twist { background: none; border: 0; width: 34px; height: 34px; color: var(--muted); font-size: 12px; transition: transform .15s; }
.twist[aria-expanded="true"] { transform: rotate(90deg); color: var(--ink); }
.subs { padding: 0 0 8px 22px; }
.sub { display: flex; align-items: center; gap: 9px; padding: 4px 0; font-size: 13px; }
.sub label { flex: 1; display: flex; align-items: center; gap: 9px; cursor: pointer; min-width: 0; }
.sub .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sub button { background: none; border: 1px solid var(--line); color: var(--muted); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; padding: 5px 8px; border-radius: 5px; min-height: 30px; }
.sub button:hover, .sub button[aria-pressed="true"] { color: var(--ink); border-color: var(--ink); }

/* ---- debug */
#debugPanel { position: fixed; z-index: 50; right: 10px; bottom: 10px; width: min(780px, calc(100% - 20px)); height: min(60vh, 520px); display: flex; flex-direction: column; background: rgba(10, 8, 14, .97); border: 1px solid var(--accent); border-radius: 8px; font-size: 12px; }
.debug-head { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.debug-head input { flex: 1; background: var(--panel2); border: 1px solid var(--line); border-radius: 5px; padding: 6px 8px; }
.debug-head button { background: none; border: 1px solid var(--line); border-radius: 5px; padding: 5px 9px; }
.debug-sum { padding: 6px 10px; color: var(--muted); border-bottom: 1px solid var(--line2); }
.debug-scroll { overflow: auto; flex: 1; }
#debugTable { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
#debugTable th, #debugTable td { text-align: left; padding: 3px 8px; border-bottom: 1px solid var(--line2); white-space: nowrap; }
#debugTable th { position: sticky; top: 0; background: #17131d; color: var(--muted); font-weight: 600; }
#debugTable .n { text-align: right; }
.noscript { padding: 24px; }

/* ---- embed: no chrome */
body.embed .top, body.embed #panel { display: none; }
body.embed #app { grid-template-columns: minmax(0, 1fr); }
body.embed { --top-h: 0px; }

/* ---- phones and the Fold7 cover screen: the panel becomes a bottom sheet */
@media (max-width: 960px) {
  .tag, #backLink { display: none; }
  .panel-toggle { display: inline-block; }
  #app { grid-template-columns: minmax(0, 1fr); position: relative; }
  #panel { position: absolute; left: 0; right: 0; bottom: 0; z-index: 25; max-height: 54%; border-left: 0; border-top: 1px solid var(--line); border-radius: 14px 14px 0 0; box-shadow: 0 -10px 40px rgba(0, 0, 0, .5); padding-bottom: env(safe-area-inset-bottom); transition: transform .25s ease; }
  #panel.collapsed { transform: translateY(calc(100% - 46px - env(safe-area-inset-bottom))); }
  .sheet-handle { display: block; flex: 0 0 auto; background: none; border: 0; padding: 8px 0 2px; width: 100%; }
  .sheet-handle span { display: block; width: 44px; height: 4px; border-radius: 4px; background: var(--line); margin: 0 auto; }
  .tabs button { padding: 11px 12px 9px; }
  #toolbar { flex-direction: row; left: 0; right: 0; top: 46px; padding: 0 12px; overflow-x: auto; scrollbar-width: none; justify-content: flex-start; }
  #toolbar::-webkit-scrollbar { display: none; }
  #toolbar button { flex: 0 0 auto; }
  #hud { top: 8px; }
  #hint { display: none; }
  #card { bottom: 60px; left: 8px; width: calc(100% - 16px); max-height: 46%; overflow: auto; z-index: 28; }
  .lab b { font-size: 15px; }
  .lab small { font-size: 9.5px; }
  body.embed #app { position: static; }
}
@media (max-width: 960px) and (min-height: 700px) { #panel { max-height: 46%; } }
/* tall narrow cover screens: keep labels small */
@media (max-width: 420px) { .lab { max-width: 150px; } .lab small { max-width: 130px; } .wordmark { font-size: 24px; } .chip { font-size: 10px; padding: 4px 8px; } }
@media (prefers-reduced-motion: reduce) { #panel, #loader, .loader-bar span { transition: none; } }
