:root {
  color-scheme: dark;
  --ground: #1c1e20;
  --stage: #2b2d2f;
  --control: #292c2f;
  --line: #424649;
  --ink: #efede7;
  --muted: #b6b8b7;
  --accent: #e8d7b8;
  font-family: "Segoe UI", Arial, sans-serif;
  font-synthesis: none;
  color: var(--ink);
  background: var(--ground);
  accent-color: var(--accent);
  scrollbar-color: #656867 var(--ground);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 280px; font-size: 15px; line-height: 1.5; }
button, select, input { font: inherit; }
button, select { border-radius: 4px; }
button, select, a, input { -webkit-tap-highlight-color: transparent; }
button, select, input[type="range"], input[type="checkbox"] { cursor: pointer; }
button:disabled, select:disabled, input:disabled { cursor: default; }
button:focus-visible, select:focus-visible, input:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}
::selection { color: var(--ground); background: var(--accent); }
a { color: var(--ink); text-underline-offset: 5px; }
a:hover { color: var(--accent); }

.page-header, .workbench, .page-footer {
  width: min(1440px, calc(100% - 80px));
  margin-inline: auto;
}
.page-header { display: flex; justify-content: space-between; align-items: center; gap: 24px; padding-block: 28px 24px; }
h1 { margin: 0; font-size: 28px; font-weight: 600; line-height: 1.2; letter-spacing: -.025em; }
.page-header p { margin: 5px 0 0; color: var(--muted); font-size: 14px; }
.source-link { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; font-size: 14px; text-decoration: none; }
.source-link:hover { text-decoration: underline; }
.source-link svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.workbench { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 36px; align-items: start; }
.stage { position: relative; min-width: 0; height: min(72vh, 780px); min-height: 530px; background: var(--stage); overflow: hidden; }
#model-canvas { display: block; width: 100%; height: 100%; }
.stage-caption { position: absolute; inset: auto 24px 20px; display: flex; justify-content: space-between; gap: 16px; pointer-events: none; font-size: 13px; color: #cbccca; }
#stage-frame { font-variant-numeric: tabular-nums; white-space: nowrap; }
.stage-message { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 32px; background: var(--stage); text-align: center; }
.message-title { margin: 0; font-size: 20px; font-weight: 500; }
.message-detail { margin: 0; max-width: 34ch; color: var(--muted); font-size: 14px; }
.retry-button { margin-top: 12px; }
.no-script { position: absolute; inset: 0; display: grid; place-content: center; margin: 0; padding: 24px; background: var(--stage); text-align: center; }

.controls { min-width: 0; padding-top: 1px; }
.model-group { margin-bottom: 24px; padding-bottom: 24px; border-bottom: 1px solid var(--line); }
fieldset { min-width: 0; border: 0; padding: 0; margin: 0; }
fieldset:disabled { opacity: .5; }
label, .label-line { font-size: 14px; }
.control-group > label, .label-line { display: flex; margin-bottom: 9px; }
.label-line { align-items: baseline; justify-content: space-between; gap: 16px; }
output { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }
select { display: block; min-width: 0; width: 100%; min-height: 44px; padding: 9px 32px 9px 12px; border: 1px solid var(--line); color: var(--ink); background: var(--control); }
select:hover:not(:disabled) { border-color: #7c807f; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 9px; min-height: 44px; min-width: 44px; padding: 9px 14px; border: 1px solid var(--line); color: var(--ink); background: var(--control); line-height: 1.4; font-size: 14px; }
.button:hover:not(:disabled) { background: #383c3f; border-color: #7c807f; }
.button:active:not(:disabled) { background: #44484a; }
.button:disabled { opacity: .42; }
.button-primary { flex: 1; color: #242523; border-color: var(--accent); background: var(--accent); font-weight: 600; }
.button-primary:hover:not(:disabled) { color: #1c1e20; border-color: #f2e5cd; background: #f2e5cd; }
.button-primary:active:not(:disabled) { background: #d4c29f; border-color: #d4c29f; }
.button svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; }
.button .play-icon { fill: currentColor; stroke-width: 1; }
.icon-button { flex: 0 0 44px; padding-inline: 10px; }
.transport { display: flex; gap: 8px; margin-top: 16px; }
.frame-group { padding-block: 24px; margin-block: 24px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
input[type="range"] { display: block; width: 100%; height: 44px; margin: -8px 0 0; padding: 0; accent-color: var(--accent); }
.frame-buttons { display: flex; gap: 8px; margin-top: 5px; }
.frame-buttons .button { flex: 1; padding-inline: 8px; font-size: 13px; }
.zoom-group { margin-top: 22px; }
.check-control { display: flex; align-items: center; gap: 10px; min-height: 44px; margin-top: 8px; cursor: pointer; }
input[type="checkbox"] { flex: 0 0 auto; width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }
.motion-note { margin: 22px 0 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.keyboard-note { margin: 28px 0 0; color: var(--muted); font-size: 12px; line-height: 1.9; }
kbd { font: inherit; color: #d5d5d0; }
.page-footer { display: flex; justify-content: space-between; gap: 16px; padding-block: 19px 26px; color: var(--muted); font-size: 12px; }
.page-footer p { margin: 0; }
.page-footer span { margin-inline: 5px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }

@media (min-width: 1680px) { .stage { height: 780px; } }
@media (max-width: 1000px) {
  .page-header, .workbench, .page-footer { width: calc(100% - 48px); }
  .workbench { grid-template-columns: minmax(0, 1fr) 250px; gap: 24px; }
  .stage { min-height: 530px; }
}
@media (max-width: 720px) {
  .page-header, .workbench, .page-footer { width: calc(100% - 32px); }
  .page-header { padding-block: 20px 18px; gap: 16px; }
  h1 { font-size: 25px; }
  .page-header p { max-width: 19ch; font-size: 12px; }
  .source-link { flex-shrink: 0; font-size: 12px; gap: 6px; }
  .workbench { display: block; }
  .stage { height: 62svh; min-height: 350px; max-height: 600px; }
  .stage-caption { inset: auto 16px 14px; font-size: 12px; }
  .stage-message { padding: 24px; }
  .message-title { font-size: 18px; }
  .controls { padding-top: 24px; }
  .frame-group { padding-block: 20px; margin-block: 20px; }
  .keyboard-note { display: none; }
  .page-footer { flex-direction: column; gap: 5px; margin-top: 22px; padding-block: 18px 24px; border-top: 1px solid var(--line); font-size: 11px; }
  .page-footer span { margin-inline: 3px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; } }
