:root {
  color-scheme: dark;
  font-family: var(--font-sans);
  --edge: clamp(16px, 2vw, 30px);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }
body { color: var(--paper); background: var(--ink); }
button, select, input { font: inherit; }
button { color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: default; opacity: .38; }
button:focus-visible, summary:focus-visible, input:focus-visible, select:focus-visible { outline: 1px solid var(--accent); outline-offset: 2px; }
button svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; }
#view { display: block; width: 100vw; height: 100vh; height: 100dvh; touch-action: none; }
#view:focus-visible { outline: 1px solid rgb(var(--accent-rgb) / .2078); outline-offset: -2px; }
.screen-shade { position: fixed; inset: 0; pointer-events: none; z-index: 1; background: radial-gradient(ellipse at center, rgb(var(--shade-rgb) / .502) 0%, rgb(var(--shade-rgb) / .3137) 32%, rgb(var(--shade-rgb) / .1451) 70%, rgb(var(--shade-rgb) / .0824) 100%); opacity: 0; transition: opacity 1s ease; }
body[data-title-state="intro"] .screen-shade { opacity: 1; }
.scene-mark { position: fixed; z-index: 2; left: max(var(--edge), env(safe-area-inset-left)); top: max(18px, env(safe-area-inset-top)); max-width: calc(100vw - 100px); pointer-events: none; text-shadow: 0 1px 3px #000c, 0 2px 14px #0009; opacity: 0; }
.scene-mark p, .scene-mark h1 { margin: 0; }
#scene-title { font-family: var(--serif-ja); font-size: 16px; font-weight: 600; line-height: 1.35; letter-spacing: .12em; }
.scene-title-en { font-size: 9px; line-height: 1.5; letter-spacing: .15em; }
.scene-mark::after { content: ""; display: block; width: 38px; height: 5px; margin-top: 8px; border-top: 1px solid var(--accent); border-radius: 50%; opacity: .8; }
body[data-title-state="intro"] .scene-mark, body[data-title-state="settling"] .scene-mark, body[data-title-state="loading"] .scene-mark { opacity: 0; transition: none; }
body[data-title-state="docked"] .scene-mark { opacity: 1; transition: opacity .75s ease .15s; }
.title-intro { position: fixed; z-index: 2; left: 50%; top: 50%; width: min(88vw, 880px); transform: translate(-50%, -50%); color: var(--title-ink); text-align: center; pointer-events: none; text-shadow: 0 2px 5px #000c, 0 5px 30px #0009; will-change: opacity; }
.title-intro p, .title-intro h2 { margin: 0; }
#intro-title-ja { font-family: var(--serif-ja); font-size: clamp(36px, 4.2vw, 72px); font-weight: 600; line-height: 1.4; letter-spacing: .16em; padding-left: .16em; }
.intro-title-en { font-size: clamp(14px, 1.4vw, 20px); font-weight: 400; line-height: 1.5; letter-spacing: .22em; padding-left: .22em; margin-top: 12px !important; }
.title-intro .intro-series { position: absolute; left: 0; right: 0; top: 100%; display: flex; align-items: center; justify-content: center; gap: 1.4em; margin-top: 34px; padding-left: .3em; font-size: clamp(10px, 1vw, 13px); letter-spacing: .3em; opacity: .85; }
.intro-series span:first-child { font-family: var(--serif-en); letter-spacing: .24em; }
.intro-series span + span { display: flex; align-items: center; gap: 1.4em; font-family: var(--serif-ja); }
.intro-series span + span::before { content: ""; width: 1px; height: .9em; background: currentColor; opacity: .55; }
body[data-title-state="loading"] .title-intro { opacity: 0; }
body[data-title-state="docked"] .title-intro { opacity: 0; visibility: hidden; }
.menu-toggle { position: fixed; z-index: 6; top: max(18px, env(safe-area-inset-top)); right: max(var(--edge), env(safe-area-inset-right)); display: flex; align-items: center; justify-content: center; gap: 7px; height: 30px; padding: 0; border: 0; color: var(--paper); background: none; font-size: 9px; letter-spacing: .07em; text-shadow: 0 1px 4px rgb(var(--shade-rgb) / .8); transition: color .2s; }
.menu-icon { display: grid; place-items: center; width: 29px; height: 29px; border: 1px solid rgb(var(--accent-rgb) / .8); border-radius: 50%; background: rgb(var(--glass-rgb) / .2); }
.menu-icon svg { width: 15px; height: 15px; }
.menu-toggle:hover { color: var(--accent); }
body[data-menu-open="true"] .menu-toggle { opacity: 0; pointer-events: none; }
.settings-panel { position: fixed; z-index: 8; top: max(16px, env(safe-area-inset-top)); right: max(var(--edge), env(safe-area-inset-right)); width: 286px; max-width: calc(100vw - 24px); max-height: min(65vh, 520px); max-height: min(65dvh, 520px); overflow-y: auto; overscroll-behavior: contain; padding: 0 16px 10px; border: 1px solid rgb(var(--accent-rgb) / .3216); border-radius: var(--corner-panel); color: var(--paper); background: rgb(var(--ink-rgb) / .9608); box-shadow: 0 12px 40px rgb(var(--shadow-rgb) / .2314); scrollbar-width: thin; scrollbar-color: var(--scrollbar) transparent; }
.panel-title { position: sticky; z-index: 1; top: 0; display: flex; align-items: center; justify-content: space-between; gap: 8px; height: 48px; margin: 0 -16px; padding: 0 16px 9px 20px; background: rgb(var(--ink-rgb) / .9804); }
.panel-title h2 { display: flex; flex-direction: column; gap: 1px; margin: 0; font-size: 11px; font-weight: 400; letter-spacing: .15em; }
.panel-title h2 small { color: var(--dim); font-size: 9px; line-height: 1.3; letter-spacing: .15em; }
.panel-wave { position: absolute; bottom: 0; left: 0; width: 100%; height: 15px; fill: none; stroke: var(--accent); stroke-width: 1; opacity: .55; pointer-events: none; }
.icon-button { width: 24px; height: 24px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 2px; background: transparent; }
.icon-button:hover { color: var(--accent); background: rgb(var(--accent-rgb) / .0471); }
.setting-section { border-bottom: 1px solid var(--line); }
summary { position: relative; display: flex; align-items: center; min-height: 30px; padding: 5px 18px 5px 0; list-style: none; font-size: 11px; font-weight: 400; line-height: 1.5; cursor: pointer; }
summary::-webkit-details-marker { display: none; }
summary::after { content: "+"; position: absolute; right: 1px; top: 50%; transform: translateY(-50%); font-size: 13px; font-weight: 300; color: var(--accent); }
details[open] > summary::after { content: "−"; }
.section-body { padding: 0 0 8px; }
label { display: block; color: var(--label); font-size: 11px; line-height: 1.4; margin: 7px 0; }
output { float: right; color: var(--accent); font-size: 10px; font-variant-numeric: tabular-nums; }
input[type="range"] { display: block; appearance: none; width: 100%; height: 12px; margin: 4px 0 0; background: none; accent-color: var(--accent); cursor: pointer; }
input[type="range"]::-webkit-slider-runnable-track { height: 2px; background: var(--track); }
input[type="range"]::-webkit-slider-thumb { appearance: none; width: 8px; height: 8px; margin-top: -3px; border: 0; border-radius: 50%; background: var(--accent); }
input[type="range"]::-moz-range-track { height: 2px; background: var(--track); }
input[type="range"]::-moz-range-thumb { width: 8px; height: 8px; border: 0; border-radius: 50%; background: var(--accent); }
input[type="checkbox"] { flex-shrink: 0; width: 12px; height: 12px; margin: 0 7px 0 0; accent-color: var(--accent); }
.check { display: flex; align-items: center; min-height: 20px; }
kbd { margin-left: auto; color: var(--dim); padding: 0 4px; font: inherit; font-size: 8px; }
.buttons { display: flex; gap: 5px; }
.buttons button, .source-editor button, select { border: 0; border-bottom: 1px solid rgb(var(--accent-rgb) / .2392); border-radius: 0; background: none; color: var(--label); min-height: 26px; padding: 4px 6px; font-size: 10px; font-weight: 400; line-height: 1.4; }
.buttons button { flex: 1; }
.buttons button:hover, .source-editor button:hover { background: rgb(var(--accent-rgb) / .0392); color: var(--paper); border-color: rgb(var(--accent-rgb) / .549); }
.buttons button.selected { background: rgb(var(--accent-rgb) / .0314); color: var(--accent); border-color: rgb(var(--accent-rgb) / .651); }
.buttons.views button { border-bottom: 0; position: relative; background: none; padding-bottom: 6px; }
.buttons.views button[aria-pressed="true"]::after { content: ""; position: absolute; bottom: 0; left: 20%; width: 60%; height: 5px; border-top: 1px solid var(--accent); border-radius: 50%; }
select { display: block; width: 100%; margin-top: 4px; height: 28px; background: var(--field); border-color: var(--field-line); cursor: pointer; }
option { color: var(--paper); background: var(--field); }
.select-line { margin: 4px 0 7px; }
.scene-actions { margin-top: 5px; }
.scene-actions button { display: flex; align-items: center; justify-content: center; gap: 5px; }
.scene-actions svg { width: 12px; height: 12px; }
.note { margin: 8px 0 0; color: var(--dim); font-size: 10px; line-height: 1.6; }
.source-editor { margin-top: 10px; border-top: 1px solid var(--line); }
.source-editor > summary { color: var(--muted); font-size: 10px; min-height: 28px; }
.source-name { margin: 0 0 5px; font-size: 10px; line-height: 1.5; color: var(--muted); overflow-wrap: anywhere; }
.source-file input { display: block; width: 100%; margin-top: 5px; font-size: 9px; color: var(--dim); }
.source-file input::file-selector-button { margin-right: 5px; padding: 4px; border: 0; border-bottom: 1px solid rgb(var(--accent-rgb) / .4); color: var(--paper); background: var(--field); cursor: pointer; }
.source-editor > button { display: block; width: 100%; margin-top: 4px; }
#source-progress.error, #status.error { color: var(--warn-soft); }
.diagnostics { padding-top: 6px; margin-top: 9px; border-top: 1px solid var(--line); }
.diagnostics p { margin: 3px 0; font-size: 9px; line-height: 1.6; overflow-wrap: anywhere; color: var(--dim); }
#stats { font-variant-numeric: tabular-nums; }
.help { margin: 2px 0 0; font-size: 10px; line-height: 1.6; color: var(--muted); }
.help > div { display: flex; justify-content: space-between; gap: 15px; margin: 3px 0; }
.help dt, .help dd { margin: 0; font-weight: 400; }
.help dd { color: var(--dim); }
.footer-buttons { margin-top: 8px; }
.viewer-footer { pointer-events: none; }
.transport { position: fixed; z-index: 3; display: flex; align-items: center; gap: 14px; bottom: max(18px, env(safe-area-inset-bottom)); left: max(var(--edge), env(safe-area-inset-left)); max-width: calc(100vw - var(--edge) * 2); height: 34px; padding: 0; border: 0; color: var(--paper); background: none; pointer-events: auto; transition: opacity .7s ease; }
.transport-controls { position: relative; display: flex; align-items: center; gap: 5px; height: 30px; padding: 0 1px; }
.transport button { display: inline-flex; align-items: center; justify-content: center; height: 25px; padding: 0; border: 0; color: var(--paper); background: none; }
.transport .transport-button { position: relative; z-index: 1; width: 30px; height: 30px; border: 1px solid rgb(var(--accent-rgb) / .2); border-radius: 50%; background: rgb(var(--ink-rgb) / .6588); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); filter: drop-shadow(0 1px 3px rgb(var(--shadow-rgb) / .502)); }
.transport-button:hover, .transport-button[aria-pressed="true"] { color: var(--accent); }
.transport svg { width: 15px; height: 15px; }
.transport .transport-wave { position: absolute; inset: 0; width: 60px; height: 30px; transform: translateY(4px); fill: none; stroke: var(--accent); stroke-width: .8; opacity: .75; pointer-events: none; }
.transport .play-triangle, .transport .sound-on { display: none; }
#transport-pause[aria-pressed="true"] .pause-lines, #transport-audio[aria-pressed="true"] .sound-off { display: none; }
#transport-pause[aria-pressed="true"] .play-triangle, #transport-audio[aria-pressed="true"] .sound-on { display: block; }
.transport-views { display: flex; align-items: center; gap: 4px; height: 34px; padding: 0 8px; border: 1px solid rgb(var(--accent-rgb) / .2); border-radius: var(--corner-bar); background: rgb(var(--ink-rgb) / .6588); -webkit-backdrop-filter: blur(10px) saturate(1.15); backdrop-filter: blur(10px) saturate(1.15); box-shadow: 0 4px 18px rgb(var(--shadow-rgb) / .251); }
.transport-views button { position: relative; height: 34px; padding: 0 10px 2px; color: rgb(var(--paper-rgb) / .8588); font-size: 13px; font-weight: 500; letter-spacing: .06em; text-shadow: 0 1px 3px rgb(var(--shade-rgb) / .902); white-space: nowrap; }
.transport-views button:hover { color: var(--paper); }
.transport-views button[aria-pressed="true"] { color: var(--accent); }
.transport-views button[aria-pressed="true"]::before { content: ""; position: absolute; top: 15px; left: 2px; width: 4px; height: 4px; border-radius: 50%; background: var(--accent); }
.transport-views button[aria-pressed="true"]::after { content: ""; position: absolute; bottom: 3px; left: 10px; width: calc(100% - 20px); height: 6px; border-top: 1px solid var(--accent); border-radius: 50%; }
body[data-scene-ready="false"] .transport { opacity: .3; pointer-events: none; }
/* The controls: a "?" at the bottom right opens them in an overlay of their own (the touch group first on a touch screen). */
.help-toggle { position: fixed; z-index: 9; right: max(var(--edge), env(safe-area-inset-right)); bottom: max(18px, env(safe-area-inset-bottom)); display: grid; place-items: center; width: 30px; height: 30px; padding: 0; border: 1px solid rgb(var(--accent-rgb) / .2); border-radius: 50%; color: var(--paper); background: rgb(var(--ink-rgb) / .6588); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); filter: drop-shadow(0 1px 3px rgb(var(--shadow-rgb) / .502)); transition: color .2s; }
.help-toggle:hover, .help-toggle[aria-expanded="true"] { color: var(--accent); }
.help-toggle svg { width: 16px; height: 16px; }
.help-hint { position: fixed; z-index: 9; right: max(var(--edge), env(safe-area-inset-right)); bottom: calc(max(18px, env(safe-area-inset-bottom)) + 40px); width: max-content; max-width: min(300px, calc(100vw - var(--edge) * 2)); margin: 0; padding: 9px 13px; border: 1px solid rgb(var(--accent-rgb) / .3216); border-radius: var(--corner-toast); color: var(--muted); background: rgb(var(--ink-rgb) / .9216); font-size: 11px; line-height: 1.7; box-shadow: 0 8px 26px rgb(var(--shadow-rgb) / .2314); }
.help-overlay { position: fixed; z-index: 8; inset: 0; display: grid; place-items: center; padding: max(16px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) calc(max(18px, env(safe-area-inset-bottom)) + 42px) max(14px, env(safe-area-inset-left)); background: rgb(var(--shade-rgb) / .5); }
.help-card { width: min(780px, 100%); max-height: 100%; overflow-y: auto; overscroll-behavior: contain; padding: 0 16px 14px; border: 1px solid rgb(var(--accent-rgb) / .3216); border-radius: var(--corner-panel); color: var(--paper); background: rgb(var(--ink-rgb) / .9608); box-shadow: 0 12px 40px rgb(var(--shadow-rgb) / .2314); scrollbar-width: thin; scrollbar-color: var(--scrollbar) transparent; }
.help-columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 4px 28px; }
.help-group { display: flex; flex-direction: column; }
.help-group h3 { margin: 12px 0 2px; color: var(--paper); font-size: 11px; font-weight: 400; letter-spacing: .1em; }
body[data-touch="true"] .help-group[data-input="touch"] { order: -1; }
.help-card .help { font-size: 11px; }
/* The loading caption: top centre (the scene's title is hidden while loading), a line of text over a progress line. */
.loading-caption { position: fixed; z-index: 3; left: 50%; top: max(28px, calc(env(safe-area-inset-top) + 20px)); transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 10px; width: min(86vw, 560px); text-align: center; color: var(--muted); font-size: 13px; line-height: 1.6; letter-spacing: .08em; pointer-events: none; text-shadow: 0 1px 10px #000a; }
.loading-text { display: flex; align-items: center; justify-content: center; gap: 10px; }
.loading-line { flex: 0 0 auto; width: 22px; height: 1px; background: var(--accent); }
/* How far the loading has come (viewer.js renderCaption sets the inner bar's width): a hairline that fills. */
.loading-progress { flex: 0 0 auto; width: min(60vw, 220px); height: 2px; background: rgb(var(--accent-rgb) / .22); }
.loading-progress > span { display: block; width: 0; height: 100%; background: var(--accent); transition: width .4s ease-out; }
body[data-load-state="ready"] .loading-progress { display: none; }
.error-toast { position: fixed; z-index: 10; left: 50%; bottom: max(65px, calc(env(safe-area-inset-bottom) + 50px)); transform: translateX(-50%); width: min(80vw, 520px); padding: 10px 14px; border: 1px solid var(--toast-line); border-radius: var(--corner-toast); color: var(--toast-ink); background: var(--toast-bg); font-size: 11px; line-height: 1.7; }
body[data-load-state="error"] .loading-caption { color: var(--warn); }
body[data-load-state="error"] .loading-line { background: var(--warn); }
.camera-authoring { position: fixed; z-index: 7; right: max(var(--edge), env(safe-area-inset-right)); top: 58px; width: 290px; max-width: calc(100vw - 24px); padding: 10px 12px; border: 1px solid #8ecfc860; border-radius: 3px; color: #f4f3ed; background: #08181ef2; box-shadow: 0 5px 24px #0004; }
.camera-authoring-heading { display: flex; align-items: center; justify-content: space-between; font-size: 11px; }
.camera-authoring-heading button { border: 0; background: none; font-size: 18px; line-height: 1; padding: 0 2px; }
.camera-authoring pre { margin: 9px 0; font: 10px/1.8 Consolas, monospace; white-space: pre-wrap; color: #b7ded8; }
.camera-fov { margin: 5px 0; }
.camera-authoring-hint, #camera-authoring-status { font-size: 10px; line-height: 1.5; color: #a9c0c7; margin: 7px 0 0; }
.camera-authoring-slots { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-top: 6px; }
.camera-authoring-slots button, .camera-authoring-copy { min-height: 27px; padding: 4px; font-size: 10px; border: 1px solid #8ecfc838; border-radius: 2px; background: #8ecfc80a; }
.camera-authoring-slots button.saved { border-color: #8ecfc895; color: #a0ddd3; }
.camera-authoring-copy { width: 100%; margin-top: 7px; }
.camera-authoring textarea { width: 100%; height: 100px; margin-top: 7px; background: #061219; color: #d8eeec; font: 9px/1.4 Consolas, monospace; border: 1px solid #8ecfc840; }
.object-row { padding: 3px 0 5px; }
.object-row + .object-row { margin-top: 4px; padding-top: 8px; border-top: 1px solid var(--line); }
.object-row .check { margin: 0; }
.object-name { color: var(--paper); }
.object-detail { margin-left: 8px; color: var(--dim); font-size: 10px; }
input:disabled + .object-text { opacity: .45; }
.object-status { margin: 1px 0 0 19px; }
.object-actions { margin: 6px 0 0 19px; }
.object-actions button { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 7px; padding: 4px 12px; }
.object-actions kbd { margin-left: 0; padding: 0; }
@media (max-width: 650px) {
  body[data-menu-open="true"] .scene-mark { opacity: 0; transition: none; }
  :root { --edge: 14px; }
  .scene-mark { top: max(16px, env(safe-area-inset-top)); }
  #scene-title { font-size: 15px; letter-spacing: .09em; }
  .scene-title-en { font-size: 9px; }
  .menu-toggle { top: max(16px, env(safe-area-inset-top)); }
  .settings-panel { top: max(12px, env(safe-area-inset-top)); right: 12px; }
  #intro-title-ja { font-size: clamp(27px, 7.8vw, 45px); letter-spacing: .12em; padding-left: .12em; }
  .intro-title-en { font-size: clamp(13px, 3.8vw, 20px); letter-spacing: .10em; margin-top: 10px !important; }
  .title-intro .intro-series { margin-top: 24px; gap: 1em; font-size: 10px; letter-spacing: .2em; }
  .intro-series span:first-child { letter-spacing: .16em; }
  .intro-series span + span { gap: 1em; }
  .transport { bottom: max(14px, env(safe-area-inset-bottom)); }
  .transport-views { gap: 0; padding: 0 4px; }
  .transport-views button { padding: 0 8px 2px; font-size: 11px; letter-spacing: .03em; }
  .transport-views button[aria-pressed="true"]::after { left: 8px; width: calc(100% - 16px); }
  /* The view bar takes the width: the "?" sits above its right end. */
  .help-toggle { bottom: calc(max(14px, env(safe-area-inset-bottom)) + 44px); }
  .help-hint { bottom: calc(max(14px, env(safe-area-inset-bottom)) + 84px); }
  .help-overlay { padding-bottom: calc(max(14px, env(safe-area-inset-bottom)) + 84px); }
}
@media (max-height: 500px) {
  .scene-mark, .menu-toggle { top: 12px; }
  .settings-panel { top: 10px; }
  .transport { bottom: 12px; }
  #intro-title-ja { font-size: 36px; }
  .intro-title-en { font-size: 16px; }
  .title-intro .intro-series { margin-top: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
  .scene-mark, .screen-shade, .transport, .menu-toggle { transition: none !important; }
  .title-intro { will-change: auto; }
}
.lp-link { flex: 1; display: block; min-height: 26px; padding: 4px 6px; border-bottom: 1px solid rgb(var(--accent-rgb) / .2392); color: var(--label); font-size: 10px; line-height: 1.4; text-align: center; text-decoration: none; }
.lp-link:hover { background: rgb(var(--accent-rgb) / .0392); color: var(--paper); border-color: rgb(var(--accent-rgb) / .549); }
.site-copyright { margin: 10px 0 4px; color: var(--dim); font-size: 9px; letter-spacing: .06em; text-align: center; }
.help-heading { margin: 8px 0 2px; color: var(--accent); font-size: 10px; letter-spacing: .06em; }
