:root {
  color-scheme: dark;
  --bg: #071229; --bg-2: #0A1834; --card: #0D1D3C; --card-2: #11254A; --line: #1B2F57; --line-2: #27427A;
  --fg: #F2F6FC; --muted: #A8B6D0; --faint: #6F81A3;
  --blue: #1F7AEC; --blue-2: #3A9BFF; --green: #3ED47E; --orange: #F2994A; --red: #F0524B; --amber: #F4C04A;
  --f: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --f-mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 15px/1.55 var(--f); -webkit-font-smoothing: antialiased; }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 30; background: var(--bg); }
a { color: var(--blue-2); }
h1, h2, h3 { margin: 0; letter-spacing: -0.02em; text-wrap: balance; }
p { margin: 0; }
:focus-visible { outline: 2px solid var(--blue-2); outline-offset: 2px; border-radius: 6px; }

.top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding-block: 12px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--fg); text-decoration: none; font-weight: 700; font-size: 18px; }
.brand img { width: 32px; height: 32px; }
.brand small { font: 500 11px/1 var(--f-mono); letter-spacing: .14em; text-transform: uppercase; color: var(--blue-2); padding: 5px 8px; border: 1px solid var(--line-2); border-radius: 999px; }
.top nav { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 9px 15px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--card-2);
  color: var(--fg); text-decoration: none; font: 600 14px/1.1 var(--f); cursor: pointer; white-space: nowrap; }
.btn:hover:not(:disabled) { border-color: var(--blue-2); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.sm { padding: 7px 12px; font-size: 13px; }
.btn.on { background: var(--red); border-color: var(--red); color: #fff; }
.btn[aria-pressed="true"] { border-color: var(--blue-2); color: var(--blue-2); }
.btn svg { width: 16px; height: 16px; }

.layout { display: grid; grid-template-columns: 330px minmax(0, 1fr); gap: 20px; padding-block: 20px 40px;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); max-width: 1600px; margin: 0 auto; }

.list { display: flex; flex-direction: column; gap: 6px; max-height: calc(100vh - 110px); overflow-y: auto; position: sticky; top: calc(74px + env(safe-area-inset-top, 0px)); padding-right: 4px; }
.list h2 { font: 500 12px/1 var(--f-mono); letter-spacing: .14em; text-transform: uppercase; color: var(--blue-2); margin: 14px 4px 4px; }
.list h2:first-child { margin-top: 0; }
.list button { text-align: left; display: grid; gap: 3px; padding: 11px 13px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--fg); cursor: pointer; font: inherit; }
.list button:hover { border-color: var(--line-2); }
.list button[aria-current="true"] { border-color: var(--blue-2); background: var(--card-2); box-shadow: inset 3px 0 0 var(--blue-2); }
.list b { font-size: 14.5px; font-weight: 600; }
.list span { font-size: 12.5px; color: var(--muted); line-height: 1.4; }

.main { min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.head { display: flex; gap: 16px; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; }
.head h1 { font-size: clamp(22px, 2.6vw, 30px); }
.head p { color: var(--muted); max-width: 70ch; margin-top: 4px; }
#viewerWrap { position: relative; border-radius: 18px; overflow: hidden; border: 1px solid var(--line); background: var(--bg-2); }
#viewerWrap:fullscreen { border-radius: 0; border: 0; }
#viewer { position: relative; width: 100%; aspect-ratio: 16 / 9; max-height: calc(100vh - 260px); min-height: 300px; }
#viewerWrap:fullscreen #viewer { aspect-ratio: auto; height: 100vh; max-height: none; }
#viewer canvas { display: block; width: 100% !important; height: 100% !important; touch-action: none; cursor: grab; }
#viewer[data-bg="transparent"] { background-color: #fff; background-image: linear-gradient(45deg, #d9dee8 25%, transparent 25%), linear-gradient(-45deg, #d9dee8 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #d9dee8 75%), linear-gradient(-45deg, transparent 75%, #d9dee8 75%); background-size: 22px 22px; background-position: 0 0, 0 11px, 11px -11px, -11px 0; }
#viewer[data-bg="light"] { background: #F3F5F8; }
.gl-fallback { position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; text-align: center; color: var(--muted); }
#overlay { position: absolute; left: 14px; top: 14px; display: flex; flex-direction: column; gap: 8px; pointer-events: none; max-width: calc(100% - 28px); }
.readout { pointer-events: auto; display: grid; gap: 6px; padding: 11px 14px; border-radius: 12px; background: rgba(7,18,41,.82); border: 1px solid var(--line-2); font-size: 13px; color: var(--muted); min-width: 210px; }
.readout b { color: var(--fg); }
.readout .mono, .mono { font-family: var(--f-mono); }
.bars { display: grid; gap: 5px; }
.bar { display: grid; grid-template-columns: 34px 1fr 38px; align-items: center; gap: 8px; }
.bar i { height: 8px; border-radius: 4px; background: var(--line); position: relative; overflow: hidden; }
.bar i::after { content: ""; position: absolute; inset: 0 auto 0 0; width: var(--w, 0%); max-width: 100%; background: var(--c); border-radius: 4px; transition: width .4s; }
.hint-drag { position: absolute; right: 14px; bottom: 12px; font-size: 12px; color: var(--faint); pointer-events: none; }
#viewer[data-bg="light"] ~ .hint-drag, #viewer[data-bg="transparent"] ~ .hint-drag { color: #4a5874; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--card); }
.toolbar .grp { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.toolbar .sep { width: 1px; align-self: stretch; background: var(--line); }
.toolbar label { font-size: 12.5px; color: var(--muted); }
select { font: 500 13px var(--f); color: var(--fg); background: var(--card-2); border: 1px solid var(--line-2); border-radius: 9px; padding: 7px 9px; }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 999px; overflow: hidden; }
.seg button { border: 0; background: transparent; color: var(--muted); font: 600 12.5px var(--f); padding: 7px 11px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--blue); color: #fff; }
#sceneControls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
#sceneControls:empty { display: none; }
.yr { width: min(320px, 60vw); accent-color: var(--blue-2); }

.guide { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; }
.guide div { padding: 14px 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--card); }
.guide h3 { font-size: 14.5px; margin-bottom: 4px; }
.guide p { font-size: 13.5px; color: var(--muted); }
.foot { color: var(--faint); font-size: 12.5px; }
.foot a { color: var(--muted); }

.toast { position: fixed; left: 50%; bottom: calc(22px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 40; background: var(--card-2); border: 1px solid var(--line-2); padding: 11px 16px; border-radius: 12px; font-size: 14px; box-shadow: 0 20px 40px -20px #000; max-width: calc(100% - 32px); }

@media (max-width: 980px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .list { position: static; max-height: none; flex-direction: row; overflow-x: auto; padding-bottom: 6px; order: 2; }
  .list h2 { display: none; }
  .list button { min-width: 220px; }
  .list span { display: none; }
  #viewer { aspect-ratio: 4 / 3; max-height: 70vh; }
}
@media (max-width: 560px) {
  .brand small, .hint-drag { display: none; }
  .toolbar .sep { display: none; }
  .readout { min-width: 0; font-size: 12px; }
}

.top .partner-logo { height: 30px; width: auto; max-width: 160px; }

img[data-optional][hidden] { display: none !important; }
