:root {
  color-scheme: dark;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --text: #e6e2dc;
  --muted: #777673;
  --accent: #d5b184;
  --hairline: rgba(234, 222, 206, .13);
  --edge: clamp(22px, 3.4vw, 54px);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; width: 100%; height: 100%; background: #030303; }
body { overflow: hidden; color: var(--text); -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
button, select, input[type="range"] { touch-action: manipulation; }
button { cursor: pointer; }
button:focus-visible, select:focus-visible, input:focus-visible { outline: 1px solid var(--accent); outline-offset: 5px; }
button:disabled { cursor: wait; opacity: .4; }
button svg { width: 18px; height: 18px; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }

#app { position: fixed; inset: 0; overflow: hidden; isolation: isolate; }
#universe { position: absolute; inset: 0; display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; outline: none; }
#universe:active, #universe.is-dragging { cursor: grabbing; }
#universe:focus-visible { outline: 1px solid #d5b18499; outline-offset: -6px; }
.capture-frame { position: absolute; z-index: 1; top: 50%; left: 50%; width: min(100%, calc(100dvh * 16 / 9)); aspect-ratio: 16 / 9; transform: translate(-50%, -50%); border: 1px solid #e8dece30; box-shadow: 0 0 0 200vmax #0003; pointer-events: none; }
.hud { z-index: 2; transition: opacity .3s ease, visibility .3s ease; }
.topbar { position: absolute; top: 0; left: 0; right: 0; padding: max(30px, env(safe-area-inset-top)) max(var(--edge), env(safe-area-inset-right)) 30px max(var(--edge), env(safe-area-inset-left)); display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; pointer-events: none; background: linear-gradient(180deg, rgba(0,0,0,.28), transparent); }
.brand { display: flex; flex-direction: column; gap: 9px; padding-top: 9px; user-select: none; }
.brand-name { font-size: 12px; line-height: 1; font-weight: 500; letter-spacing: .3em; }
.brand-subtitle { color: #8b8680; font-size: 9px; line-height: 1; font-weight: 500; letter-spacing: .17em; }
.topbar-actions, .toolbar-actions, .scene-controls { display: flex; align-items: center; gap: 9px; pointer-events: auto; }
.icon-button { display: inline-flex; flex-shrink: 0; align-items: center; justify-content: center; width: 38px; height: 38px; padding: 0; color: #94918b; background: transparent; border: 1px solid transparent; border-radius: 50%; transition: color .2s ease, background .2s ease, border-color .2s ease; }
.icon-button:hover { color: #eee5d9; background: rgba(232,219,198,.06); border-color: rgba(232,219,198,.07); }
.icon-button:active { background: rgba(232,219,198,.1); }
.icon-button[aria-expanded="true"], .icon-button[aria-pressed="true"] { color: var(--accent); }
#pause .play-icon { display: none; }
#pause.is-paused .pause-icon { display: none; }
#pause.is-paused .play-icon { display: block; }
.action-divider { width: 1px; height: 15px; margin: 0 5px; background: var(--hairline); }
.exit-cinema { position: fixed; z-index: 4; top: max(22px, env(safe-area-inset-top)); right: max(var(--edge), env(safe-area-inset-right)); display: none; align-items: center; justify-content: center; gap: 8px; min-width: 88px; min-height: 44px; padding: 0 14px; color: #a6a098; font-size: 11px; border: 1px solid #c4b7a315; border-radius: 24px; background: #08070688; transition: color .2s ease, background .2s ease; }
.exit-cinema svg { width: 14px; height: 14px; }
.exit-cinema:hover { color: #ebdecb; background: #1b1712d9; }
body.cinema-mode .exit-cinema { display: inline-flex; }
.record-button { position: relative; color: #b97c6a; }
.record-button:hover, .record-button[aria-pressed="true"] { color: #e5a48b; }
.record-button .stop-icon { display: none; }
.record-button[aria-pressed="true"] .record-icon { display: none; }
.record-button[aria-pressed="true"] .stop-icon { display: block; }
.record-button[aria-pressed="true"] { border-color: #cb927430; background: #d39a8110; }
#record-time { position: absolute; bottom: calc(100% + 4px); left: 50%; transform: translateX(-50%); color: #dfae9d; font-size: 9px; line-height: 1.3; font-variant-numeric: tabular-nums; white-space: nowrap; pointer-events: none; }

.toolbar { position: absolute; bottom: 0; left: 0; right: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 20px; padding: 30px max(var(--edge), env(safe-area-inset-right)) max(28px, env(safe-area-inset-bottom)) max(var(--edge), env(safe-area-inset-left)); pointer-events: none; background: linear-gradient(0deg, rgba(0,0,0,.45), transparent); }
.scene-info { min-width: 0; user-select: none; }
.scene-status { display: flex; align-items: center; gap: 9px; color: #92908a; font-size: 9px; font-weight: 500; line-height: 1.3; letter-spacing: .17em; text-transform: uppercase; }
.status-dot { width: 3px; height: 3px; background: var(--accent); border-radius: 50%; box-shadow: 0 0 7px #b98f5840; }
.interaction-hint { margin: 8px 0 0; font-size: 9px; font-weight: 400; line-height: 1.5; letter-spacing: .03em; color: #858079; }
.touch-hint { display: none; }
.view-switcher { display: flex; align-items: center; gap: 3px; min-width: 0; padding: 4px; border: 1px solid rgba(235,220,200,.1); border-radius: 28px; background: rgba(11,10,9,.5); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); pointer-events: auto; }
.view-button { position: relative; flex: 0 0 auto; min-width: 70px; height: 32px; padding: 0 14px; color: #928b83; font-size: 11px; font-weight: 400; line-height: 1; letter-spacing: .035em; white-space: nowrap; background: transparent; border: 1px solid transparent; border-radius: 22px; transition: color .25s ease, border-color .25s ease, background .25s ease; }
.view-button:hover { color: #dfd3c1; }
.view-button[aria-pressed="true"] { color: #d8c1a3; border-color: rgba(213,177,132,.12); background: rgba(213,177,132,.09); }
.toolbar-actions { justify-self: end; gap: 16px; }
.zoom-control { display: flex; align-items: center; gap: 1px; padding: 0 2px; border: 1px solid var(--hairline); border-radius: 24px; background: #0b0a0955; }
.zoom-button { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 36px; padding: 0; color: #aaa093; border: 0; border-radius: 50%; background: transparent; transition: color .2s ease, background .2s ease; }
.zoom-button:hover { color: #ead9c2; background: #ead9c20c; }
.zoom-button svg { width: 15px; height: 15px; }
.zoom-label { color: #8c8173; font-size: 11px; letter-spacing: .02em; user-select: none; }

.settings-panel { position: absolute; z-index: 3; top: max(93px, calc(env(safe-area-inset-top) + 63px)); right: max(var(--edge), env(safe-area-inset-right)); width: 330px; max-height: calc(100dvh - 200px); overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: #4a4237 transparent; border: 1px solid var(--hairline); border-radius: 16px; background: rgba(16,15,14,.9); box-shadow: 0 20px 100px #0009, inset 0 1px 0 #ffffff03; backdrop-filter: blur(30px); -webkit-backdrop-filter: blur(30px); }
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 23px 20px 20px 26px; border-bottom: 1px solid rgba(234,222,206,.07); }
.eyebrow { display: block; color: #928a7e; font-size: 9px; line-height: 1.4; font-weight: 500; letter-spacing: .14em; text-transform: uppercase; }
.panel-header h1 { margin: 7px 0 0; color: #d8d2c9; font-size: 15px; font-weight: 400; letter-spacing: -.025em; }
.settings-body { padding: 25px 26px 23px; }
.settings-section + .settings-section { margin-top: 24px; padding-top: 23px; border-top: 1px solid rgba(234,222,206,.07); }
.settings-section-title { margin: 0 0 20px; color: #8f8372; font-size: 9px; font-weight: 500; line-height: 1.4; letter-spacing: .13em; text-transform: uppercase; }
.setting + .setting { margin-top: 23px; }
.setting-label { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 8px; }
.setting-label label, .quality-setting label { color: #bbb4aa; font-size: 11px; line-height: 1.5; }
.setting-label output { color: #8e8170; font-size: 10px; font-variant-numeric: tabular-nums; }
input[type="range"] { display: block; width: 100%; height: 18px; margin: 0; padding: 0; background: transparent; accent-color: var(--accent); cursor: pointer; -webkit-appearance: none; appearance: none; }
input[type="range"]::-webkit-slider-runnable-track { height: 2px; background: #40372d; border-radius: 2px; }
input[type="range"]::-webkit-slider-thumb { width: 9px; height: 9px; margin-top: -3.5px; border: 0; border-radius: 50%; background: #c5ab87; -webkit-appearance: none; transition: box-shadow .2s ease; }
input[type="range"]::-moz-range-track { height: 2px; background: #40372d; border-radius: 2px; }
input[type="range"]::-moz-range-thumb { width: 9px; height: 9px; border: 0; border-radius: 50%; background: #c5ab87; }
input[type="range"]:hover::-webkit-slider-thumb { box-shadow: 0 0 0 5px #c5ab8710; }
.quality-setting { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-top: 23px; padding-top: 21px; border-top: 1px solid rgba(234,222,206,.07); }
.quality-setting select { max-width: 155px; padding: 8px 10px; color: #c9beb0; font-size: 11px; background: #211e1a; border: 1px solid rgba(234,222,206,.09); border-radius: 6px; cursor: pointer; }
.capture-setting { margin-top: 0; padding-top: 0; border: 0; }
.capture-size { margin: 14px 0 0; color: #b7a68e; font-size: 11px; line-height: 1.5; font-variant-numeric: tabular-nums; }
.capture-note { margin: 6px 0 0; color: #8a8379; font-size: 10px; line-height: 1.7; }
.reset-button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: 100%; margin-top: 22px; padding: 10px 16px; color: #a59887; font-size: 11px; background: transparent; border: 1px solid rgba(234,222,206,.1); border-radius: 7px; transition: color .2s ease, border-color .2s ease; }
.reset-button:hover { color: #dfd0bb; border-color: #a08a6840; }
.reset-button svg { width: 13px; height: 13px; }
.science-note { margin: 21px 0 0; color: #8a8379; font-size: 10px; font-weight: 400; line-height: 1.8; }

.loading { position: absolute; inset: 0; z-index: 5; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 13px; background: #030303; transition: opacity .55s ease; }
.loading-orbit { width: 46px; height: 46px; margin-bottom: 16px; border: 1px solid #3c3022; border-top-color: #b58b58; border-radius: 50%; animation: orbit 2.4s linear infinite; box-shadow: 0 0 30px #ac70330a; }
.loading-title { color: #c8b8a1; font-size: 10px; letter-spacing: .34em; text-indent: .34em; }
.loading-description { color: #6c6255; font-size: 9px; letter-spacing: .03em; }
.error-card { position: absolute; z-index: 6; top: 50%; left: 50%; width: min(360px, calc(100% - 48px)); transform: translate(-50%, -50%); padding: 28px; border: 1px solid var(--hairline); border-radius: 12px; background: #14110ef5; }
.error-card p { margin: 12px 0 0; color: #b7ac9d; font-size: 13px; line-height: 1.7; }
.toast { position: absolute; z-index: 8; bottom: max(102px, calc(env(safe-area-inset-bottom) + 78px)); left: 50%; max-width: calc(100% - 40px); transform: translateX(-50%); padding: 11px 18px; color: #c9bdac; font-size: 11px; line-height: 1.5; text-align: center; border: 1px solid var(--hairline); border-radius: 8px; background: #191611ed; box-shadow: 0 5px 30px #0005; pointer-events: none; }
.export-progress { position: absolute; inset: 0; z-index: 10; display: grid; place-items: center; padding: 24px; background: #050403b8; backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.export-card { width: min(360px, 100%); padding: 29px; border: 1px solid var(--hairline); border-radius: 14px; background: #15120ff5; box-shadow: 0 25px 100px #0008; }
.export-card h2 { margin: 9px 0 0; color: #d8d2c9; font-size: 18px; font-weight: 400; letter-spacing: -.02em; }
#export-status { min-height: 2.8em; margin: 18px 0; color: #a99b88; font-size: 11px; line-height: 1.7; }
#export-bar { display: block; width: 100%; height: 3px; overflow: hidden; border: 0; border-radius: 3px; background: #382f25; accent-color: #c6a16e; -webkit-appearance: none; appearance: none; }
#export-bar::-webkit-progress-bar { background: #382f25; }
#export-bar::-webkit-progress-value { background: #c6a16e; }
#export-bar::-moz-progress-bar { background: #c6a16e; }
.export-card .reset-button { min-height: 44px; margin-top: 25px; }
body.cinema .hud, body.cinema-mode .hud, body.is-cinema .hud { opacity: 0; visibility: hidden; pointer-events: none; }
body.cinema #universe, body.cinema-mode #universe, body.is-cinema #universe { cursor: none; }

@keyframes orbit { to { transform: rotate(360deg); } }
@media (hover: none) {
  .desktop-hint { display: none; }
  .touch-hint { display: inline; }
  .icon-button { width: 44px; height: 44px; }
  .view-button { height: 44px; }
  .zoom-button { width: 44px; height: 44px; }
  input[type="range"] { height: 28px; }
  input[type="range"]::-webkit-slider-thumb { width: 12px; height: 12px; margin-top: -5px; }
  input[type="range"]::-moz-range-thumb { width: 12px; height: 12px; }
}
@media (max-width: 960px) {
  .toolbar { grid-template-columns: minmax(0, 1fr); gap: 18px; padding-top: 24px; }
  .scene-info { position: absolute; left: max(var(--edge), env(safe-area-inset-left)); right: max(var(--edge), env(safe-area-inset-right)); bottom: max(151px, calc(env(safe-area-inset-bottom) + 139px)); }
  .scene-status { display: none; }
  .interaction-hint { margin-top: 0; }
  .view-switcher { grid-row: 1; width: 100%; max-width: 560px; justify-self: center; overflow-x: auto; overscroll-behavior-x: contain; touch-action: pan-x; scrollbar-width: none; scroll-padding: 4px; }
  .view-switcher::-webkit-scrollbar { display: none; }
  .view-button { flex: 1 0 70px; }
  .toolbar-actions { grid-row: 2; width: 100%; max-width: 560px; justify-self: center; justify-content: space-between; }
  .toast { bottom: max(195px, calc(env(safe-area-inset-bottom) + 171px)); }
}
@media (max-width: 480px) {
  :root { --edge: 20px; }
  .topbar { padding-top: max(22px, env(safe-area-inset-top)); padding-right: max(15px, env(safe-area-inset-right)); }
  .brand { gap: 8px; padding-top: 11px; }
  .brand-name { font-size: 11px; letter-spacing: .25em; }
  .brand-subtitle { font-size: 9px; letter-spacing: .1em; }
  .topbar-actions { gap: 1px; }
  .action-divider { margin: 0 2px; }
  .toolbar { padding-top: 24px; padding-bottom: max(22px, env(safe-area-inset-bottom)); gap: 18px; }
  .toolbar-actions { gap: 14px; }
  .scene-controls { gap: 2px; }
  .view-switcher { gap: 0; padding: 3px; }
  .view-button { flex-basis: 60px; min-width: 60px; padding: 0 8px; font-size: 11px; }
  .settings-panel { top: max(84px, calc(env(safe-area-inset-top) + 61px)); right: max(16px, env(safe-area-inset-right)); width: min(330px, calc(100% - 32px)); max-height: calc(100dvh - 185px); border-radius: 14px; }
  .settings-body { padding: 20px 24px; }
  .setting + .setting { margin-top: 16px; }
  .scene-info { bottom: max(151px, calc(env(safe-area-inset-bottom) + 129px)); }
  .interaction-hint { font-size: 9px; line-height: 1.5; }
}
@media (max-height: 530px) and (orientation: landscape) {
  .topbar { padding-top: max(14px, env(safe-area-inset-top)); padding-bottom: 14px; }
  .toolbar { padding-bottom: max(12px, env(safe-area-inset-bottom)); padding-top: 15px; }
  .scene-info { display: none; }
  .toolbar { grid-template-columns: minmax(0, 1fr) auto; gap: 14px; }
  .view-switcher { grid-row: 1; width: 100%; }
  .view-button { flex-basis: 58px; min-width: 58px; padding-right: 9px; padding-left: 9px; }
  .toolbar-actions { grid-row: 1; width: auto; justify-self: end; gap: 10px; }
  .scene-controls { gap: 1px; }
  .zoom-label { display: none; }
  .settings-panel { top: 68px; max-height: calc(100dvh - 142px); }
  .toast { bottom: 72px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* Export library: native top-layer dialog, independently of the cinema HUD. */
.library-button { display:inline-flex;align-items:center;gap:7px;min-height:44px;padding:0 12px;color:#d3c4ad;border:1px solid #bda27c35;border-radius:8px;background:#171512bb;font:inherit;font-size:11px; }
.library-button svg { width:17px;height:17px;stroke:currentColor;stroke-width:1.3; }
.library-count { min-width:17px;padding:2px 4px;border-radius:5px;background:#bda27c22;font-size:10px; }
.media-dialog { color-scheme:dark;width:min(1040px,calc(100vw - 32px));max-height:calc(100dvh - 32px);padding:0;margin:auto;overflow:auto;color:#d9d2c8;background:#151412;border:1px solid #c9b89d30;border-radius:16px;box-shadow:0 30px 120px #000b; }
.media-dialog::backdrop { background:#020202dd; }
.media-header { display:flex;justify-content:space-between;align-items:center;gap:20px;padding:22px 24px;border-bottom:1px solid #ffffff10; }
.media-header h2 { margin:6px 0 0;font-size:19px;font-weight:400;letter-spacing:-.02em; }
.media-layout { display:grid;grid-template-columns:218px minmax(0,1fr); }
.media-list { max-height:65dvh;overflow-y:auto;border-right:1px solid #ffffff10;padding:10px; }
.media-item { display:block;width:100%;text-align:left;margin:0 0 6px;padding:13px 10px;border:1px solid transparent;border-radius:8px;color:#bcb4a7;background:transparent;font:inherit; }
.media-item[aria-pressed="true"] { background:#c0a58010;border-color:#c0a58040;color:#eadcc7; }
.media-item:hover { background:#c0a58013; }
.media-item-title,.media-item-meta { display:block;font-size:11px;line-height:1.6; }
.media-item-meta { color:#9c9487;font-size:10px;margin-top:4px; }
.media-detail { min-width:0;padding:20px; }
.media-preview { display:grid;place-items:center;min-height:150px;height:min(39dvh,380px);border:1px solid #ffffff0b;border-radius:8px;overflow:hidden;background:#000; }
.media-preview img,.media-preview video { width:100%;height:100%;max-height:min(39dvh,380px);object-fit:contain; }
.media-meta { margin:15px 0 5px;color:#d2c3ae;font-size:12px;font-variant-numeric:tabular-nums; }
.media-filename { margin:0;color:#a39a8d;font-size:10px;overflow-wrap:anywhere;line-height:1.5; }
.media-actions { display:flex;flex-wrap:wrap;gap:8px;margin-top:18px; }
.media-action { display:inline-flex;align-items:center;justify-content:center;min-height:44px;padding:10px 14px;border:1px solid #c9b89d35;border-radius:7px;color:#dfd5c6;background:#ffffff04;font:inherit;font-size:12px;line-height:1.4;text-decoration:none;cursor:pointer; }
.media-action:hover { background:#c9b89d15; }
.media-action:focus-visible,.library-button:focus-visible,.media-item:focus-visible { outline:2px solid #d7bd96;outline-offset:3px; }
.media-primary { background:#d1b58c;border-color:#d1b58c;color:#15120e; }
.media-primary:hover { background:#e1c9a6; }
.media-delete { margin-left:auto;color:#b7aaa0; }
.media-message { color:#aaa195;font-size:11px;line-height:1.65;margin:12px 0 0; }
.media-footer { display:flex;flex-wrap:wrap;justify-content:space-between;align-items:center;gap:10px;padding:14px 24px;border-top:1px solid #ffffff10;color:#a1988b;font-size:11px; }
.media-empty { padding:40px 24px;text-align:center;font-size:14px; }
.media-empty p+p { max-width:430px;margin:12px auto 0;color:#aaa195;font-size:12px;line-height:1.7; }
@media (max-width:620px) {
 .media-dialog { width:calc(100vw - 20px);max-height:calc(100dvh - 20px);border-radius:12px; }
 .media-header { padding:16px; }.media-layout { grid-template-columns:minmax(0,1fr); }
 .media-list { display:flex;gap:6px;max-height:none;overflow-x:auto;border-right:0;border-bottom:1px solid #ffffff10; }
 .media-item { flex:0 0 175px;margin:0; }.media-detail { padding:16px; }
 .media-preview { height:min(34dvh,300px); }.media-preview img,.media-preview video { max-height:min(34dvh,300px); }.media-footer { padding:12px 16px; }
}
@media (max-width:480px) {
 .brand-subtitle { display:none; }.brand-name { font-size:10px;letter-spacing:.13em; }
 .library-button { padding:0 8px;gap:5px;font-size:10px; }.topbar-actions .action-divider { display:none; }
 .media-actions { gap:6px; }.media-action { padding:10px 12px; }
}
