/* Interface tokens: ink-black canvas, smoked glass, pearl type, prismatic details. */
:root {
  color-scheme: dark;
  --page: #08070d;
  --surface: #1c1d25;
  --surface-raised: #262730;
  --ink: #f3f2f6;
  --muted: #a1a4b4;
  --dim: #8d91a1;
  --line: rgba(235, 233, 249, .12);
  --line-bright: rgba(235, 233, 249, .22);
  --pearl: #ded6e6;
  --focus: #c7b9ec;
  --prism: linear-gradient(100deg, #ffca43 0%, #f5a251 22%, #c2a5c5 48%, #7e86cb 72%, #58b8b5 100%);
  --font-display: "Avenir Next", -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
  --font-body: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "PingFang TC", sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-family: var(--font-body);
  font-synthesis: none;
  color: var(--ink);
  background: var(--page);
}
* { box-sizing: border-box; }
body { margin: 0; background: radial-gradient(ellipse at 66% 32%, rgba(57, 37, 59, .11), transparent 56%), var(--page); }
button, input, select { font: inherit; }
button, a, input, select { -webkit-tap-highlight-color: transparent; outline-offset: 4px; }
button { cursor: pointer; color: inherit; border: 0; }
button:disabled, input:disabled, fieldset:disabled { opacity: .42; cursor: wait; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--focus); }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
[hidden] { display: none !important; }
.svg-definitions, .sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
h1, h2, h3, p { margin: 0; }
::selection { background: #655773; color: white; }

.topbar { height: 80px; max-width: 1600px; margin: 0 auto; padding: 0 36px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.brand { min-width: 0; }
.brand h1 { color: var(--ink); font: 500 13px/1.5 var(--font-mono); letter-spacing: 1.8px; white-space: nowrap; }
.header-actions { display: flex; align-items: center; gap: 10px; }
.quiet-button, .outline-button { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 39px; padding: 0 16px; border-radius: 24px; font-size: 11px; font-weight: 450; background: transparent; color: var(--muted); transition: background .18s, color .18s, border-color .18s; }
.quiet-button svg, .outline-button svg { width: 15px; height: 15px; }
.outline-button { color: var(--ink); background: rgba(255,255,255,.025); border: 1px solid var(--line); box-shadow: inset 0 1px 0 rgba(255,255,255,.025); }
.quiet-button:hover, .outline-button:hover { background: rgba(255,255,255,.065); color: white; border-color: var(--line-bright); }

.workspace { display: grid; grid-template-columns: minmax(0,1fr) 352px; gap: 28px; max-width: 1600px; margin: 0 auto; padding: 0 36px; align-items: start; }
.preview-area { min-width: 0; min-height: 720px; height: calc(100dvh - 80px); position: relative; isolation: isolate; }
.preview-area::before { content: ""; position: absolute; inset: 55px 5% 185px; z-index: -1; pointer-events: none; background: radial-gradient(ellipse at 50% 15%, rgba(123, 87, 111, .19), transparent 56%), radial-gradient(ellipse at 28% 68%, rgba(28, 103, 92, .17), transparent 51%), radial-gradient(ellipse at 75% 70%, rgba(35, 65, 115, .19), transparent 52%); }
.preview-meta { position: absolute; z-index: 3; top: 27px; left: 0; display: flex; align-items: center; gap: 9px; font: 9px/1.4 var(--font-mono); letter-spacing: 1.25px; color: var(--muted); }
.live-dot { width: 6px; height: 6px; border-radius: 50%; background: #b9b1cb; box-shadow: 0 0 10px rgba(207,184,235,.3); }
.meta-divider { width: 1px; height: 10px; background: var(--line); margin: 0 2px; }
#phase-label { font: 10px/1.4 var(--font-body); letter-spacing: .1px; color: var(--dim); }
#viewport { position: absolute; z-index: 1; inset: 90px -8px 218px; touch-action: none; }
canvas { display: block; width: 100%; height: 100%; outline: none; }
.orbit-hint { position: absolute; left: 0; right: 0; bottom: 192px; text-align: center; font-size: 10px; color: var(--dim); letter-spacing: .2px; }
.orbit-hint span { color: #575563; margin: 0 10px; }
.control-dock { position: absolute; z-index: 2; bottom: 66px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 24px; width: min(670px,100%); padding: 20px 24px; border: 1px solid var(--line); border-radius: 23px; background: linear-gradient(125deg, rgba(38,38,47,.8), rgba(22,22,29,.86)); box-shadow: inset 0 1px 0 rgba(255,255,255,.035), 0 16px 45px rgba(0,0,0,.22); backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px); }
.screen-panel { width: 116px; flex-shrink: 0; }
.control-label { display: block; margin-bottom: 10px; color: var(--muted); font: 9px/1.3 var(--font-mono); letter-spacing: 1.4px; }
.screen-mode { display: inline-flex; align-items: center; justify-content: center; min-width: 67px; min-height: 32px; padding: 5px 12px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); background: rgba(255,255,255,.035); font: 10px/1.4 var(--font-mono); }
.fold-controls { display: flex; align-items: center; gap: 18px; flex: 1; min-width: 0; padding-left: 24px; border-left: 1px solid var(--line); }
.play-button { display: grid; place-items: center; width: 43px; height: 43px; flex-shrink: 0; border: 1px solid var(--line-bright); border-radius: 50%; color: var(--ink); background: rgba(255,255,255,.045); transition: background .18s, border-color .18s; }
.play-button:hover { background: rgba(255,255,255,.11); border-color: rgba(233,220,246,.45); }
#play-icon { fill: currentColor; stroke: none; width: 16px; height: 16px; }
#pause-icon { width: 17px; height: 17px; }
.fold-slider { flex: 1; min-width: 0; }
.fold-labels, .fold-endpoints { display: flex; justify-content: space-between; align-items: center; color: var(--muted); }
.fold-labels { font: 9px/1.2 var(--font-mono); letter-spacing: .7px; }
.fold-labels output { color: var(--ink); font-size: 10px; letter-spacing: 0; font-variant-numeric: tabular-nums; }
.fold-endpoints button { background: transparent; padding: 1px 0; min-height: 23px; color: var(--dim); font-size: 9px; }
.fold-endpoints button:hover { color: white; text-decoration: underline; }
.preview-footer { position: absolute; left: 0; right: 0; bottom: 26px; display: flex; justify-content: space-between; align-items: center; gap: 16px; color: var(--dim); }
.keyboard-hint { display: flex; align-items: center; gap: 8px; font-size: 9px; }
kbd { border: 1px solid var(--line); border-radius: 5px; padding: 4px 6px; font: 8px/1 var(--font-mono); letter-spacing: .8px; color: var(--muted); background: rgba(255,255,255,.025); }
.footer-caption { font: 8px/1.4 var(--font-mono); letter-spacing: 1.3px; }

input[type=range] { --progress: 0%; appearance: none; -webkit-appearance: none; display: block; width: 100%; height: 29px; margin: 0; background: transparent; cursor: ew-resize; touch-action: none; }
input[type=range]::-webkit-slider-runnable-track { height: 4px; background: linear-gradient(to right, #b3a4c1 var(--progress), #41414e var(--progress)); border-radius: 4px; }
input[type=range]::-moz-range-track { height: 4px; background: linear-gradient(to right, #b3a4c1 var(--progress), #41414e var(--progress)); border-radius: 4px; }
input[type=range]::-webkit-slider-thumb { appearance: none; -webkit-appearance: none; width: 12px; height: 12px; margin-top: -4px; border: 2px solid #e4d9ee; border-radius: 50%; background: #30303b; box-shadow: 0 0 0 3px rgba(196,171,214,.08); }
input[type=range]::-moz-range-thumb { width: 8px; height: 8px; border: 2px solid #e4d9ee; border-radius: 50%; background: #30303b; }
#angle { --progress: 100%; }
#angle::-webkit-slider-runnable-track { background: linear-gradient(to right, transparent var(--progress), #41414e var(--progress)), var(--prism); }
#angle::-moz-range-track { background: linear-gradient(to right, transparent var(--progress), #41414e var(--progress)), var(--prism); }

.inspector { position: relative; z-index: 4; min-width: 0; margin: 24px 0 28px; padding: 26px 24px 22px; border: 1px solid var(--line); border-radius: 25px; background: linear-gradient(135deg, rgba(43,44,53,.79) 0%, rgba(27,28,35,.92) 47%, rgba(31,30,40,.91) 100%); box-shadow: inset 0 1px 0 rgba(255,255,255,.045), 0 28px 72px rgba(0,0,0,.28); backdrop-filter: blur(28px); -webkit-backdrop-filter: blur(28px); }
.inspector-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.eyebrow { color: var(--muted); font: 9px/1.3 var(--font-mono); letter-spacing: 1.8px; margin-bottom: 11px; }
.inspector h2 { font: 500 23px/1.25 var(--font-display); letter-spacing: -.7px; color: #faf8fc; }
.ab-mark { display: flex; align-items: center; gap: 3px; font: 400 20px/1 var(--font-display); color: #c2b7ca; letter-spacing: -.7px; }
.ab-mark span { font-size: 13px; transform: translateY(-5px); }
.intro { margin: 12px 0 24px; color: var(--muted); font-size: 12px; line-height: 1.75; }
.uploads { display: flex; gap: 16px; position: relative; }
.upload-card { flex: 1; min-width: 0; }
.upload-heading { display: flex; align-items: center; gap: 7px; margin-bottom: 11px; }
.slot-label { display: grid; place-items: center; width: 24px; height: 26px; border: 1px solid rgba(195,190,216,.2); border-radius: 7px; background: rgba(142,133,163,.11); color: #d7cfe3; font: 11px/1 var(--font-mono); flex-shrink: 0; }
.slot-b { background: rgba(145,130,153,.14); border-color: rgba(200,177,201,.23); }
.upload-heading h3 { color: var(--ink); font-size: 11px; font-weight: 500; line-height: 1.3; }
.upload-heading p { color: var(--muted); font-size: 8px; line-height: 1.5; margin-top: 2px; }
.upload-button { position: relative; display: block; width: 100%; height: 123px; overflow: hidden; border: 1px solid var(--line-bright); border-radius: 13px; padding: 0; background: var(--surface-raised); }
.upload-button img { display: block; width: 100%; height: 100%; object-fit: cover; transition: opacity .18s; }
.upload-button:hover img { opacity: .8; }
.upload-button::after { content: ""; position: absolute; inset: 0; pointer-events: none; border-radius: inherit; box-shadow: inset 0 1px 0 rgba(255,255,255,.15); }
.upload-overlay { position: absolute; inset: auto 0 0; display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 43px; padding: 10px 4px 0; background: linear-gradient(transparent, rgba(8,7,13,.9)); color: #fff; font-size: 10px; }
.upload-overlay svg { width: 12px; height: 12px; }
.upload-card.drag-over .upload-button { outline: 2px dashed var(--focus); outline-offset: 4px; }
.file-meta { display: flex; align-items: center; justify-content: space-between; gap: 7px; margin-top: 9px; color: var(--muted); font-size: 9px; }
.file-meta span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-meta span:last-child { flex-shrink: 0; font: 7px/1.4 var(--font-mono); letter-spacing: .6px; color: var(--dim); }
.swap-button { position: absolute; left: 50%; top: 88px; transform: translateX(-50%); width: 29px; height: 29px; display: grid; place-items: center; border: 1px solid var(--line-bright); border-radius: 50%; background: #24232d; color: #e5ddeb; z-index: 1; box-shadow: 0 2px 6px rgba(0,0,0,.3); }
.swap-button svg { width: 13px; height: 13px; }
.swap-button:hover { background: #393440; }
.file-help { margin: 14px 0 22px; color: var(--dim); font-size: 9px; line-height: 1.65; }
.video-export { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.animation-settings > #preview { background: rgba(255,255,255,.035); border: 1px solid var(--line-bright); color: var(--ink); box-shadow: none; }
.animation-settings > #preview:hover { background: rgba(255,255,255,.09); }
.video-export .video-button { margin-top: 0; background: #e7e1ec; }
.video-help { margin-top: 9px; color: var(--dim); text-align: center; font: 8px/1.5 var(--font-mono); letter-spacing: .35px; }
.video-progress-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; }
#video-status { color: var(--muted); font-size: 10px; line-height: 1.5; }
.cancel-button { padding: 6px 0 6px 8px; font-size: 10px; background: transparent; color: var(--ink); }
.cancel-button:hover { text-decoration: underline; }
#video-progress { appearance: none; -webkit-appearance: none; display: block; width: 100%; height: 4px; margin-top: 6px; border: 0; border-radius: 3px; overflow: hidden; background: #41414e; }
#video-progress::-webkit-progress-bar { background: #41414e; border-radius: 3px; }
#video-progress::-webkit-progress-value { background: var(--prism); border-radius: 3px; }
#video-progress::-moz-progress-bar { background: var(--prism); border-radius: 3px; }
.video-result { display: grid; gap: 8px; justify-items: center; margin-top: 13px; padding: 12px 10px; border-radius: 10px; background: rgba(8,7,13,.28); border: 1px solid var(--line); }
#video-details { font: 8px/1.5 var(--font-mono); color: var(--dim); letter-spacing: .2px; }
.video-download { display: inline-flex; align-items: center; gap: 7px; padding: 5px; font-size: 11px; color: var(--ink); text-underline-offset: 4px; }
.video-download svg { width: 13px; height: 13px; }
body[data-exporting=true] #viewport canvas { object-fit: contain; }
fieldset { border: 0; border-top: 1px solid var(--line); margin: 0; padding: 20px 0 0; min-width: 0; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 15px; font-size: 11px; }
select { min-height: 35px; max-width: 100%; padding: 5px 24px 5px 11px; border: 1px solid var(--line); border-radius: 8px; background: #1b1b23; color: #e3e0ea; font-size: 11px; cursor: pointer; }
select:hover { border-color: var(--line-bright); }
.setting-row select { width: 147px; }
.setting-range { margin: 0 0 15px; }
.setting-range>div { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; font-size: 11px; }
.setting-range output { color: var(--muted); font: 10px/1.3 var(--font-mono); font-variant-numeric: tabular-nums; }
.primary-button { display: flex; align-items: center; justify-content: center; gap: 9px; width: 100%; min-height: 44px; margin-top: 19px; border: 1px solid rgba(255,255,255,.2); border-radius: 12px; background: #e7e1ec; color: #201c26; font-size: 12px; font-weight: 550; box-shadow: 0 3px 15px rgba(209,185,225,.07); transition: background .18s; }
.primary-button:hover { background: #f6effb; }
.primary-button svg { width: 13px; height: 13px; fill: currentColor; stroke: none; }
.sequence-key { display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--muted); font: 8px/1 var(--font-mono); letter-spacing: .4px; margin-top: 17px; }
.sequence-step { display: grid; place-items: center; width: 21px; height: 22px; border: 1px solid var(--line); border-radius: 6px; font-size: 10px; }
.sequence-step.is-current { color: #f5eafa; border-color: rgba(209,182,228,.4); background: rgba(182,141,209,.14); }
.sequence-key i { width: 27px; height: 2px; border-radius: 2px; background: #41404e; }
.sequence-key [data-phase=opening].is-current { color: #ede2f5; }
.sequence-key:has([data-phase=b].is-current) i { background: var(--prism); }
.text-button { display: block; min-height: 28px; padding: 4px 8px; margin: 15px auto 0; background: transparent; color: var(--muted); font-size: 9px; }
.text-button:hover { color: var(--ink); text-decoration: underline; }
.privacy-note { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 10px; color: var(--dim); font-size: 9px; line-height: 1.5; }
.privacy-note svg { width: 11px; height: 11px; }

.loading-state, .load-error { position: absolute; z-index: 3; inset: 90px 0 218px; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 12px; text-align: center; background: rgba(8,7,13,.92); border-radius: 24px; }
.loading-state strong, .load-error strong { font-size: 14px; font-weight: 500; }
.loading-state>span:last-child, .load-error p { color: var(--muted); max-width: 260px; font-size: 11px; line-height: 1.6; }
.loading-ring { width: 27px; height: 27px; border: 2px solid var(--line); border-top-color: #d6bfdc; border-radius: 50%; animation: spin 1s linear infinite; }
.load-error .primary-button { width: 180px; }
.toast { position: fixed; z-index: 20; bottom: 22px; left: 50%; transform: translateX(-50%); max-width: calc(100% - 32px); padding: 12px 20px; border: 1px solid var(--line-bright); border-radius: 14px; background: #28252f; color: var(--ink); box-shadow: 0 8px 32px rgba(0,0,0,.45); font-size: 12px; line-height: 1.5; text-align: center; }
.noscript { position: fixed; z-index: 50; inset: 40%; min-width: 250px; padding: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (min-width:1500px) {
  .topbar { padding: 0 48px; }
  .workspace { padding: 0 48px; gap: 40px; grid-template-columns: minmax(0,1fr) 365px; }
  .inspector { padding: 28px 27px 24px; }
}
@media (max-width:1100px) {
  .topbar { padding: 0 24px; }
  .workspace { padding: 0 24px; gap: 20px; grid-template-columns: minmax(0,1fr) 312px; }
  .inspector { padding: 23px 19px 20px; }
  .inspector h2 { font-size: 21px; }
  .screen-panel { width: 98px; }
  .control-dock { padding: 17px; gap: 16px; }
  .fold-controls { padding-left: 16px; gap: 12px; }
  .play-button { width: 36px; height: 36px; }
  .upload-heading { gap: 6px; }
  .upload-heading h3 { font-size: 10px; }
  .upload-heading p { font-size: 7px; }
  .upload-overlay { font-size: 9px; }
  .setting-row select { width: 135px; }
}
@media (max-width:900px) {
  .workspace { display: block; max-width: 780px; }
  .preview-area { height: 590px; min-height: 590px; }
  #viewport { inset: 72px -8px 196px; }
  .preview-meta { top: 20px; }
  .orbit-hint { bottom: 175px; }
  .control-dock { bottom: 57px; width: min(660px,100%); }
  .screen-panel { width: 116px; }
  .preview-footer { bottom: 20px; }
  .inspector { display: grid; grid-template-columns: 1fr 1fr; column-gap: 28px; margin: 16px 0 28px; padding: 26px; }
  .inspector-heading, .intro { grid-column: 1 / -1; }
  .image-settings { grid-column: 1; min-width: 0; }
  .animation-settings { grid-column: 2; min-width: 0; }
  .inspector h2 { font-size: 24px; }
  .intro { margin-bottom: 24px; }
  .upload-heading h3 { font-size: 11px; }
  .upload-heading p { font-size: 8px; }
  .upload-button { height: 154px; }
  .swap-button { top: 102px; }
  .upload-overlay { font-size: 10px; }
  fieldset { border-top: 0; padding-top: 0; }
  .setting-row { margin-bottom: 13px; }
  .setting-range { margin: 0 0 13px; }
  .primary-button { margin-top: 16px; }
  .loading-state, .load-error { inset: 72px 0 196px; }
}
@media (max-width:540px) {
  .topbar { height: 72px; padding: 0 16px; gap: 12px; }
  .brand h1 { font-size: 11px; letter-spacing: 1px; }
  .header-actions { gap: 3px; }
  .quiet-button, .outline-button { min-height: 36px; padding: 0 12px; gap: 6px; font-size: 10px; }
  .quiet-button { width: 36px; padding: 0; }
  .quiet-button span { display: none; }
  .workspace { padding: 0 16px; }
  .preview-area { height: 516px; min-height: 516px; }
  .preview-meta { top: 14px; font-size: 8px; gap: 7px; letter-spacing: .9px; }
  #phase-label { font-size: 9px; }
  #viewport { inset: 69px -8px 211px; }
  .preview-area::before { inset: 40px -4px 150px; }
  .orbit-hint { bottom: 191px; font-size: 9px; }
  .orbit-hint span { margin: 0 6px; }
  .control-dock { bottom: 40px; flex-direction: column; align-items: stretch; gap: 13px; padding: 15px 16px; border-radius: 20px; }
  .screen-panel { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
  .control-label { margin: 0; font-size: 8px; letter-spacing: .7px; white-space: nowrap; }
  .screen-mode { min-height: 29px; font-size: 9px; }
  .fold-controls { border-left: 0; border-top: 1px solid var(--line); padding: 11px 0 0; gap: 16px; }
  .play-button { width: 37px; height: 37px; }
  .fold-labels { font-size: 8px; }
  .fold-labels output { font-size: 10px; }
  .fold-endpoints button { min-height: 18px; font-size: 8px; }
  .preview-footer { bottom: 6px; gap: 10px; }
  .keyboard-hint { gap: 6px; font-size: 8px; }
  kbd { font-size: 7px; padding: 4px; }
  .footer-caption { font-size: 6px; letter-spacing: 1px; }
  .inspector { display: block; margin: 24px 0 24px; padding: 24px 20px; border-radius: 23px; }
  .inspector h2 { font-size: 24px; }
  .intro { font-size: 12px; }
  .upload-heading h3 { font-size: 11px; }
  .upload-heading p { font-size: 8px; }
  .upload-button { height: 139px; }
  .swap-button { top: 94px; }
  .file-help { margin-bottom: 22px; }
  fieldset { border-top: 1px solid var(--line); padding-top: 20px; }
  .setting-row, .setting-range>div { font-size: 12px; }
  select { min-height: 40px; font-size: 16px; padding-left: 10px; }
  .setting-row select { width: 56%; }
  .setting-range { margin: 0 0 18px; }
  .primary-button { min-height: 46px; margin-top: 18px; }
  .privacy-note { font-size: 8px; }
  .loading-state, .load-error { inset: 69px 0 211px; }
}
@media (max-width:350px) {
  .workspace { padding: 0 12px; }
  .topbar { padding: 0 12px; }
  .inspector { padding: 23px 16px; }
  .control-dock { padding: 14px 13px; }
  .screen-panel { gap: 8px; }
  .control-label { font-size: 7px; }
  .upload-heading { gap: 5px; }
  .upload-heading h3 { font-size: 10px; }
  .upload-heading p { font-size: 7px; }
  .setting-row select { width: 145px; }
  .setting-row { gap: 8px; }
}
@media (prefers-reduced-motion:reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
