:root {
  color-scheme: dark;
  font-family: "Inter", system-ui, sans-serif;
  --page: #141518;
  --panel: #1b1d21;
  --control: #24262b;
  --line: #34363d;
  --text: #f1f1ed;
  --secondary: #a6a7ad;
  --accent: #f3e45a;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--page); color: var(--text); }
[hidden] { display: none !important; }
button, select, input { font: inherit; }
button, select, .text-input {
  background: var(--control);
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--text);
  min-height: 36px;
  padding: 6px 12px;
}
button { cursor: pointer; }
button:hover:not(:disabled), select:hover { border-color: #70737c; }
button:disabled { cursor: default; opacity: .42; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
input[type="range"], input[type="checkbox"] { accent-color: var(--accent); }
h1,h2,h3,p { margin: 0; }
h2 { font-size: 14px; font-weight: 650; }

.topbar {
  min-height: 68px;
  padding: 12px clamp(14px, 3vw, 46px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px 24px;
  border-bottom: 1px solid var(--line);
}
.identity, .file-actions { display: flex; align-items: center; gap: 10px; }
.identity { gap: 12px; }
.identity h1 { display: flex; align-items: baseline; gap: 13px; font-size: 15px; white-space: nowrap; }
.identity h1 strong { font-size: 23px; letter-spacing: .12em; }
.identity h1 span { color: var(--secondary); font-weight: 500; }
.logomark {
  width: 34px; height: 30px; border-radius: 11px;
  display: flex; align-items: center; justify-content: center; gap: 7px;
  background: var(--accent); transform: rotate(-8deg);
}
.logomark i { width: 4px; height: 9px; border-radius: 3px; background: #201e14; }
.file-actions button { font-size: 13px; }
.accent {
  background: var(--accent); border-color: var(--accent); color: #232015;
  font-weight: 700;
}
.accent span { margin-left: 5px; }
.accent:hover:not(:disabled) { background: #fff398; border-color: #fff398; }

.studio {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(245px, 296px);
  grid-template-areas: "stage inspector" "timeline inspector";
  gap: 14px;
  padding: 16px clamp(14px, 3vw, 46px) 24px;
  max-width: 1720px;
  margin: auto;
}
.stage, .inspector, .timeline { border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.stage {
  --stage-brand-width: clamp(80px, 12vw, 116px);
  position: relative; grid-area: stage; overflow: hidden;
  min-height: 390px; height: clamp(390px, calc(100svh - 285px), 820px);
  isolation: isolate;
  background: radial-gradient(ellipse at 50% 36%, #32363b, #1c1e23 58%, #17191d 91%);
}
.viewport, .viewport canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.viewport canvas { display: block; touch-action: none; cursor: grab; }
.viewport canvas:active { cursor: grabbing; }
.stage-brand {
  position: absolute; z-index: 6; top: 24px; left: 15px;
  width: var(--stage-brand-width); height: auto;
  opacity: .42; filter: invert(1) drop-shadow(0 1px 3px #0009); pointer-events: none;
}
.stage-top, .stage-bottom {
  position: absolute; inset: 14px 15px auto;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  pointer-events: none;
}
.stage-top button, .stage-actions select, .stage-bottom label { pointer-events: auto; }
.stage-top { flex-wrap: wrap; padding-inline-start: calc(var(--stage-brand-width) + 12px); }
.stage-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-left: auto; }
.stage-actions select { font-size: 12px; }
.stage-top h2 { display: flex; align-items: center; gap: 9px; }
.live-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.segmented {
  display: flex; gap: 2px; padding: 3px; border: 1px solid var(--line);
  background: #1b1d21; border-radius: 9px;
}
.segmented button { background: transparent; border-color: transparent; min-height: 29px; padding: 4px 10px; font-size: 12px; }
.segmented button[aria-pressed="true"] { background: #33363e; border-color: #42454f; }
.stage-bottom { inset: auto 15px 14px; color: #c0c1c7; font-size: 12px; }
.dot-divider { margin: 0 3px; }
.stage-switches { display: flex; gap: 6px; }
.stage-switch {
  display: inline-flex; gap: 6px; align-items: center; white-space: nowrap;
  border: 1px solid var(--line); border-radius: 7px; background: #1b1d21; padding: 6px 9px;
}
.stage-switch input { margin: 0; }
.viewport-loader {
  position: absolute; inset: 0; z-index: 5;
  display: grid; place-content: center; justify-items: center; gap: 14px;
  background: #111216; color: var(--text); padding: 24px; text-align: center;
}
.viewport-loader img { width: clamp(154px, 44vw, 222px); height: auto; filter: invert(1); margin-bottom: 9px; }
.viewport-loader p { color: var(--secondary); font-size: 14px; }
.viewport-loader progress {
  appearance: none; width: min(184px, 66vw); height: 5px;
  border: 0; border-radius: 5px; overflow: hidden; background: var(--line);
}
.viewport-loader progress::-webkit-progress-bar { background: var(--line); }
.viewport-loader progress::-webkit-progress-value { background: var(--accent); }
.viewport-loader progress::-moz-progress-bar { background: var(--accent); }
.viewport-message { position: absolute; inset: 45% 20px auto; text-align: center; color: var(--secondary); pointer-events: none; }
.film-fade { display: none; }
.film-mode,
.film-mode body { overflow: hidden; }
.film-mode .topbar,
.film-mode .inspector,
.film-mode .timeline,
.film-mode .stage-top,
.film-mode .stage-bottom { display: none; }
.film-mode .studio { display: block; max-width: none; padding: 0; }
.film-mode .stage {
  min-height: 0; height: 100svh; border: 0; border-radius: 0;
  background: radial-gradient(ellipse at 50% 43%, #323638, #191a1c 57%, #101113);
}
.film-mode .viewport canvas { cursor: default; }
.film-mode .stage-brand {
  top: max(18px, env(safe-area-inset-top));
  left: max(16px, env(safe-area-inset-left));
}
.film-mode .stage::after {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at center, transparent 50%, #06070a69 100%);
  pointer-events: none;
}
.film-mode .film-fade {
  display: block; position: absolute; inset: 0; z-index: 2;
  background: #000; pointer-events: none;
}
.film-mode .viewport-message { z-index: 3; }
.film-sound {
  position: absolute; z-index: 4; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  display: flex; align-items: center; gap: 13px;
  min-height: 64px; width: max-content; max-width: calc(100% - 32px);
  padding: 9px 21px 9px 10px; border-radius: 999px;
  border-color: #ffffff42; background: #191a1c;
  font-size: clamp(17px, 4vw, 20px); font-weight: 650;
}
.film-play-icon {
  display: grid; place-items: center; flex: 0 0 44px;
  height: 44px; border-radius: 50%; background: var(--accent);
}
.film-play-icon::before {
  content: ''; margin-left: 3px;
  border-block: 8px solid transparent; border-left: 13px solid #151619;
}
.film-share {
  position: absolute; z-index: 4; min-height: 44px;
  top: max(14px, env(safe-area-inset-top)); right: max(14px, env(safe-area-inset-right));
  border-color: #ffffff32; background: #191a1cdb;
}
.film-tilt,
.film-replay {
  position: absolute; z-index: 4; min-height: 44px; font-size: 13px;
  bottom: max(14px, env(safe-area-inset-bottom));
  border-color: #ffffff32; background: #191a1cdb;
}
.film-tilt { right: max(14px, env(safe-area-inset-right)); }
.film-replay { left: max(14px, env(safe-area-inset-left)); }
.film-songs {
  position: absolute; z-index: 4; left: 50%; transform: translateX(-50%);
  bottom: calc(70px + env(safe-area-inset-bottom));
  width: max-content; max-width: calc(100% - 24px);
  display: flex; justify-content: center; flex-wrap: wrap; gap: 6px;
}
.film-songs button {
  min-height: 44px; padding-inline: 10px; border-color: #ffffff45; background: #191a1ce8;
  font-size: 13px;
}
.film-sound:not([hidden]) ~ .film-tilt { display: none; }
@media (prefers-reduced-motion: reduce) {
  .film-tilt { display: none; }
}
.share-dialog {
  width: min(420px, calc(100% - 32px)); padding: 20px;
  border: 1px solid var(--line); border-radius: 12px; background: #1b1d21; color: inherit;
}
.share-dialog::backdrop { background: #090a0c99; }
.share-dialog form { display: grid; gap: 8px; }
.share-dialog header { display: flex; justify-content: space-between; align-items: center; }
.share-dialog h2 { margin: 0; font-size: 18px; }
.share-dialog label { margin-top: 6px; font-size: 13px; }
.share-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.share-dialog [role="status"] { margin: 0; color: var(--secondary); font-size: 13px; }

.inspector { grid-area: inspector; display: flex; flex-direction: column; min-width: 0; }
.panel-header { padding: 16px 16px 13px; }
.tabs { display: flex; gap: 3px; margin: 0 15px; padding: 3px; background: #151619; border: 1px solid #303238; border-radius: 9px; }
.tabs button {
  flex: 1; min-width: 0; background: transparent; border-color: transparent;
  font-size: 13px; color: var(--secondary); padding-inline: 4px;
}
.tabs button[aria-selected="true"] { color: var(--text); border-color: #41434a; background: #2c2e35; }
.pane { padding: 20px 16px; }
#pane-extras .scene-extras { display: grid; gap: 13px; margin-top: 16px; }
.text-input { width: 100%; }
.greeting-switch { width: fit-content; font-size: 13px; }
.bokeh-switch { width: fit-content; margin-top: 13px; font-size: 13px; }
#play-tune { justify-self: start; font-size: 13px; }
.field-label { display: block; font-size: 12px; font-weight: 550; color: var(--secondary); margin-bottom: 7px; }
#joint, #prop { width: 100%; }
.joint-controls { display: grid; gap: 16px; margin: 21px 0; }
.joint-control label { display: flex; justify-content: space-between; gap: 8px; align-items: center; font-size: 13px; }
.joint-control output, #timecode, .ruler { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.joint-control output { color: var(--accent); }
.joint-control input { width: 100%; margin: 7px 0 0; display: block; }
.pose-control { margin-bottom: 21px; }
.expressions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.expressions button { padding: 8px 4px; font-size: 12px; overflow-wrap: anywhere; }
.expressions button[aria-pressed="true"] { border-color: var(--accent); background: #393524; }
.expressions span { display: block; font: 21px var(--mono); color: var(--accent); margin-bottom: 4px; }
.ring-link {
  display: flex; align-items: center; gap: 8px; min-height: 36px;
  margin-bottom: 14px; padding-bottom: 10px; border-bottom: 1px solid var(--line);
  font-size: 13px; cursor: pointer;
}
.ring-link input { margin: 0; }
.ring-controls { display: grid; gap: 10px; margin-bottom: 16px; }
.ring-controls label { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13px; }
.ring-controls input { height: 32px; width: 44px; padding: 1px 3px; cursor: pointer; }
.muted-button { background: transparent; color: var(--secondary); font-size: 12px; }
.panel-footer { border-top: 1px solid var(--line); margin-top: auto; padding: 13px 16px; font-size: 12px; color: var(--secondary); overflow-wrap: anywhere; }

.timeline { grid-area: timeline; min-width: 0; }
.timeline-header, .timeline-footer { display: flex; justify-content: space-between; gap: 8px; align-items: center; padding: 9px 14px; }
.timeline-header { border-bottom: 1px solid var(--line); }
.timeline-header select { min-height: 30px; font-size: 12px; }
.timeline-body { display: flex; align-items: center; gap: 20px; padding: 10px 14px 6px; }
.transport { display: flex; align-items: center; gap: 5px; }
.icon-button { min-width: 33px; min-height: 33px; padding: 4px 7px; }
.icon-button[aria-pressed="true"] { color: var(--accent); border-color: #5d5637; }
.play-button { color: var(--accent); }
#timecode { font-size: 11px; color: var(--secondary); white-space: nowrap; margin-left: 4px; }
.track { flex: 1; min-width: 0; }
.ruler { display: flex; justify-content: space-between; color: var(--secondary); font-size: 11px; margin: 0 8px; }
#scrub { display: block; width: 100%; margin: 1px 0 0; }
.markers { height: 17px; position: relative; margin: 0 8px; }
.markers button {
  position: absolute; width: 17px; height: 18px; min-height: 0; padding: 0;
  border: 0; background: transparent; color: #aaaaaa;
  font-size: 13px; transform: translateX(-50%); line-height: 1;
}
.markers button:hover, .markers button[aria-current="true"] { color: var(--accent); }
.markers.dense button { width: 9px; font-size: 7px; }
.timeline-footer { border-top: 1px solid var(--line); color: var(--secondary); font-size: 12px; }
.timeline-footer div { display: flex; gap: 7px; }
.timeline-footer button { min-height: 30px; font-size: 12px; }
#add-key { color: var(--accent); }
@media (max-width: 760px) {
  .studio {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "stage" "timeline" "inspector";
  }
  .stage { height: clamp(350px, 59svh, 570px); min-height: 350px; }
}
@media (max-width: 480px) {
  .topbar { flex-wrap: wrap; }
  .file-actions { flex-wrap: wrap; }
  .stage-top { inset: 10px 10px auto; }
  .stage-top h2 {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip-path: inset(50%); white-space: nowrap;
  }
  .stage-brand { top: 21px; left: 10px; }
  .stage-bottom { inset: auto 10px 10px; }
  .stage-bottom > span { max-width: 165px; }
  .timeline-body { flex-wrap: wrap; gap: 8px; }
  .track { flex-basis: 100%; }
}
