:root {
  color-scheme: light;
  --ink: #172033;
  --muted: #64748b;
  --line: #dbe7f5;
  --line-soft: #eff5ff;
  --line-medium: #bfd7f8;
  --line-intense: #7eaef6;
  --paper: #f8fbff;
  --panel: #eef6ff;
  --stage: #f7fbff;
  --surface: #ffffff;
  --surface-2: #eaf3ff;
  --accent: #3b82f6;
  --accent-soft: rgba(59, 130, 246, 0.18);
  --accent-bright: #2563eb;
  --director-red: #ef4444;
  --green: #16a34a;
  --puppet-skin: #dbeafe;
  --puppet-core: #bfdbfe;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  height: 100vh;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

button,
select,
input {
  font: inherit;
}

button,
select,
input,
label,
.eyebrow,
.control-group h2,
.state-readout h2,
.frame-cell span,
#selectedLabel,
pre {
  font-family: "JetBrains Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

.app-shell {
  --side-width: 360px;
  position: relative;
  display: grid;
  grid-template-columns: var(--side-width) minmax(0, 1fr);
  min-height: 0;
  overflow: hidden;
}

.side-panel-resizer {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--side-width);
  width: 11px;
  transform: translateX(-6px);
  z-index: 15;
  cursor: col-resize;
  background: transparent;
  border: 0;
  padding: 0;
  touch-action: none;
}

.side-panel-resizer::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 1px;
  transform: translateX(-0.5px);
  background: transparent;
  transition: background 0.12s ease, width 0.12s ease;
}

.side-panel-resizer:hover::before,
.side-panel-resizer:focus-visible::before,
.side-panel-resizer.is-dragging::before {
  width: 3px;
  background: var(--accent);
}

.side-panel-resizer:focus-visible {
  outline: none;
}

body.is-resizing-side {
  cursor: col-resize;
  user-select: none;
}

.file-bar {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-bottom: 1px solid #d5e5f8;
  background: #fbfdff;
}

.file-menu {
  position: relative;
  font-family: "JetBrains Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

.file-menu-trigger {
  display: grid;
  place-items: center;
  min-height: 22px;
  padding: 0 9px;
  border-radius: 3px;
  color: #1d4ed8;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
  list-style: none;
}

.file-menu-trigger::-webkit-details-marker {
  display: none;
}

.file-menu[open] .file-menu-trigger,
.file-menu-trigger:hover {
  background: #eaf3ff;
}

.file-bar-button {
  display: grid;
  place-items: center;
  min-height: 22px;
  padding: 0 9px;
  border: none;
  border-radius: 3px;
  background: transparent;
  color: #1d4ed8;
  font-family: "JetBrains Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
}

.file-bar-button:hover {
  background: #eaf3ff;
}

.file-menu-panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  display: grid;
  gap: 2px;
  width: 112px;
  padding: 4px;
  border: 1px solid #bdd5f6;
  border-radius: 4px;
  background: #ffffff;
}

.file-menu-command {
  display: block;
  min-height: 24px;
  width: 100%;
  border: 0;
  border-radius: 2px;
  padding: 0 8px;
  color: #172033;
  background: transparent;
  text-align: left;
  font-size: 10px;
  font-weight: 800;
}

.file-menu-command:hover {
  color: #fff;
  background: #2563eb;
}

.file-menu-command:disabled {
  cursor: default;
  opacity: 0.48;
}


.side-panel {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 24px;
  position: relative;
  border-right: 1px solid transparent;
  background: var(--panel);
  overflow: auto;
}

.side-panel::after {
  content: "";
  position: absolute;
  inset: 0;
  inset-inline-end: -1px;
  width: 1px;
  background: linear-gradient(180deg, transparent 0, var(--line-soft) 24%, var(--line-medium) 54%, var(--line-soft) 84%, transparent 100%);
  pointer-events: none;
}

.brand-block h1,
.control-group h2,
.state-readout h2 {
  margin: 0;
}

.brand-block h1 {
  font-size: 28px;
  line-height: 1.05;
  color: #0f172a;
  font-weight: 760;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.control-group,
.state-readout {
  display: grid;
  gap: 12px;
}

.state-readout[hidden] {
  display: none;
}

.settings-card {
  display: grid;
  gap: 11px;
  padding: 10px;
  border: 1px solid #cfe0f6;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.68);
}

.settings-card[hidden] {
  display: none;
}

.settings-card h2 {
  color: #1d4ed8;
  font-size: 10px;
  font-weight: 850;
}

.keyframe-motion-settings {
  border-color: #bfdbfe;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.82) 0%, rgba(248, 251, 255, 0.72) 100%);
}

.arc-settings {
  gap: 8px;
}

.control-group h2,
.state-readout h2 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0;
  color: var(--muted);
}

.control-group .settings-card h2 {
  color: #1d4ed8;
  font-size: 10px;
  font-weight: 850;
}

.keyframe-delete-button {
  min-height: 24px;
  justify-self: start;
  padding: 0 7px;
  border-color: #fecaca;
  border-radius: 3px;
  color: #b91c1c;
  background: #fff;
  font-size: 10px;
  font-weight: 800;
}

.keyframe-delete-button:hover:not(:disabled) {
  border-color: #fca5a5;
  background: #fff7f7;
}

.keyframe-delete-button:disabled {
  opacity: 0.36;
  cursor: not-allowed;
}

.keyframe-timing-control {
  display: grid;
  gap: 7px;
  --keyframe-hold: 0%;
  --keyframe-duration: 14%;
}

.keyframe-timing-readout {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: #64748b;
  font-family: "JetBrains Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 9px;
  font-weight: 800;
  white-space: nowrap;
}

.keyframe-timing-readout span {
  display: inline-flex;
  gap: 4px;
  align-items: baseline;
}

.keyframe-timing-readout strong {
  color: #334155;
  font: inherit;
}

.keyframe-timing-bar {
  position: relative;
  height: 22px;
  border-radius: 3px;
  cursor: ew-resize;
  background:
    linear-gradient(90deg, rgba(148, 163, 184, 0.22), rgba(148, 163, 184, 0.22)) 0 50% / 100% 2px no-repeat;
}

.keyframe-hold-fill,
.keyframe-duration-line {
  position: absolute;
  left: 0;
  top: 50%;
  height: 2px;
  pointer-events: none;
  transform: translateY(-50%);
}

.keyframe-hold-fill {
  width: var(--keyframe-hold);
  background: rgba(124, 58, 237, 0.45);
}

.keyframe-duration-line {
  width: var(--keyframe-duration);
  background: #7c3aed;
}

.keyframe-timing-handle {
  position: absolute;
  top: 50%;
  width: 10px;
  height: 10px;
  border: 2px solid #fff;
  border-radius: 50%;
  pointer-events: none;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.12);
}

.keyframe-timing-handle-hold {
  left: var(--keyframe-hold);
  background: #a78bfa;
}

.keyframe-timing-handle-duration {
  left: var(--keyframe-duration);
  background: #7c3aed;
}

.keyframe-timing-bar input[type="range"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 22px;
  margin: 0;
  opacity: 0;
  pointer-events: none;
}

.keyframe-timing-bar #keyframeHoldInput {
  z-index: 2;
}

.keyframe-timing-bar #durationInput {
  z-index: 1;
}

.keyframe-timing-bar.is-duration-active #durationInput,
.keyframe-timing-bar:not(.is-hold-active) #durationInput {
  z-index: 3;
}

.keyframe-timing-bar.is-hold-active #keyframeHoldInput {
  z-index: 4;
}

.inline-stat {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  color: #64748b;
  font-size: 10px;
}

.inline-stat span {
  color: #1d4ed8;
  font-size: 10px;
  font-weight: 850;
  white-space: nowrap;
}

button {
  min-height: 40px;
  border: 1px solid #2563eb;
  border-radius: 7px;
  color: #eff6ff;
  background: var(--accent);
  cursor: pointer;
}

button.secondary {
  color: #1d4ed8;
  background: #fff;
}

button.is-active {
  border-color: var(--accent);
  color: #eff6ff;
  background: var(--accent);
}

button:hover {
  background: #2563eb;
}

button.secondary:hover {
  color: #1d4ed8;
  background: #eaf3ff;
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.button-row.single {
  grid-template-columns: 1fr;
}

.figure-menu {
  display: grid;
  grid-template-columns: minmax(92px, 1fr) auto;
  gap: 6px;
  align-items: center;
}

.figure-menu .toolbar-button {
  min-height: 32px;
  padding: 0 10px;
}

.layout-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.detail-row {
  display: grid;
  grid-template-columns: minmax(80px, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.detail-row input {
  width: 100%;
  min-height: 26px;
  border-radius: 7px;
  border: 1px solid #b9d1f7;
  background: #f5faff;
  color: #0f172a;
  padding: 5px 8px;
  letter-spacing: 0;
  font-weight: 650;
  font-size: 11px;
}

.detail-row input:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 1px;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.14);
}

.detail-row input::-webkit-outer-spin-button,
.detail-row input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.detail-row input[type="number"] {
  appearance: textfield;
}

.arc-timing-control {
  --arc-delay: 0%;
  --arc-end: 100%;
  display: grid;
  gap: 7px;
  margin: -1px 0 6px;
  padding: 8px 9px 7px;
  border: 1px solid #cfe0f6;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}

.arc-timing-control[hidden] {
  display: none;
}

.arc-timing-readout {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  color: #7c8aa0;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
  white-space: nowrap;
}

.arc-timing-readout strong {
  color: #1d4ed8;
  font-family: "JetBrains Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 10px;
  font-weight: 900;
  text-transform: none;
}

.arc-timing-bar {
  position: relative;
  height: 22px;
  cursor: pointer;
}

.arc-timing-bar::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 10px;
  height: 2px;
  border: 1px solid #cfe0f6;
  background: #f8fbff;
}

.arc-timing-fill {
  position: absolute;
  left: var(--arc-delay);
  right: calc(100% - var(--arc-end));
  top: 10px;
  height: 2px;
  background: #2563eb;
  pointer-events: none;
}

.arc-timing-bar input[type="range"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.arc-timing-handle {
  position: absolute;
  top: 11px;
  width: 11px;
  height: 11px;
  border: 1px solid #1d4ed8;
  border-radius: 50%;
  background: #ffffff;
  cursor: grab;
  transform: translate(-50%, -50%);
}

.arc-timing-handle:focus-visible {
  outline: 2px solid rgba(37, 99, 235, 0.35);
  outline-offset: 2px;
}

.arc-timing-handle:active {
  cursor: grabbing;
}

.arc-timing-handle-delay {
  left: var(--arc-delay);
  border-color: #93c5fd;
  background: #f8fbff;
}

.arc-timing-handle-end {
  left: var(--arc-end);
}

#bezierValue {
  color: rgba(100, 116, 139, 0.72);
  font-size: 9px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.speed-graph {
  position: relative;
  display: grid;
  gap: 0;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0;
}

.speed-graph svg {
  display: block;
  width: 100%;
  aspect-ratio: 230 / 106;
  height: auto;
  border: 1px solid #cfe0f6;
  border-radius: 4px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}

.speed-grid {
  fill: none;
  stroke: rgba(59, 130, 246, 0.12);
  stroke-width: 0.8;
}

.speed-axis-label {
  fill: rgba(29, 78, 216, 0.58);
  font-family: "JetBrains Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 5.5px;
  font-weight: 700;
  letter-spacing: 0;
  pointer-events: none;
  text-transform: uppercase;
}

.speed-axis-time {
  text-anchor: end;
  dominant-baseline: text-after-edge;
}

.speed-axis-progress {
  text-anchor: start;
  dominant-baseline: text-before-edge;
}

.speed-graph-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.bezier-control-line {
  stroke: rgba(239, 68, 68, 0.28);
  stroke-width: 0.9;
  stroke-dasharray: 3 4;
}

.bezier-endpoint {
  fill: var(--director-red);
}

.bezier-handle {
  fill: #fff;
  stroke: var(--director-red);
  stroke-width: 1.3;
  cursor: grab;
}

.bezier-handle:active {
  cursor: grabbing;
}

.bezier-handle:focus-visible {
  outline: 2px solid var(--accent-bright);
  outline-offset: 3px;
}

.timing-shape {
  display: grid;
  gap: 8px;
  padding: 10px 0 2px;
}

.timing-label-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-family: "JetBrains Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 11px;
}

.timing-label-row strong {
  color: #1d4ed8;
  font-weight: 800;
}

.timing-rail {
  --anticipation-pos: 18%;
  --overshoot-pos: 82%;
  position: relative;
  height: 24px;
  cursor: pointer;
}

.timing-rail::before {
  content: "";
  position: absolute;
  top: 11px;
  left: 0;
  right: 0;
  height: 2px;
  border-radius: 999px;
  background: #bfdbfe;
}

.timing-rail::after {
  content: "";
  position: absolute;
  top: 9px;
  left: var(--anticipation-pos);
  width: calc(var(--overshoot-pos) - var(--anticipation-pos));
  height: 6px;
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.16);
}

.timing-marker {
  position: absolute;
  top: 7px;
  z-index: 1;
  width: 10px;
  height: 10px;
  border: 2px solid #1d4ed8;
  background: #fff;
  cursor: grab;
  transform: translateX(-50%) rotate(45deg);
}

.timing-marker:active {
  cursor: grabbing;
}

.timing-marker:focus-visible {
  outline: 2px solid var(--accent-bright);
  outline-offset: 4px;
}

.anticipation-marker {
  left: var(--anticipation-pos);
}

.overshoot-marker {
  left: var(--overshoot-pos);
}

.timing-note {
  margin: 0;
  color: var(--muted);
  font-family: "JetBrains Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 10px;
  line-height: 1.45;
}

select,
input[type="range"] {
  width: 100%;
}

select {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 10px;
  color: var(--ink);
  background: #fff;
}

.state-readout {
  margin-top: auto;
}

pre {
  min-height: 132px;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  overflow: auto;
  color: #1e3a8a;
  background: rgba(255, 255, 255, 0.82);
  font-size: 12px;
  line-height: 1.45;
}

.stage-wrap {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-height: 0;
  min-width: 0;
  background: #f8fbff;
}

.timeline-panel {
  display: grid;
  gap: 10px;
  padding: 10px 16px 12px;
  position: relative;
  border-top: 1px solid transparent;
  background: rgba(255, 255, 255, 0.92);
}

.timeline-panel::before {
  content: "";
  position: absolute;
  top: 0;
  left: 16px;
  right: 16px;
  height: 1px;
  background: linear-gradient(90deg, transparent 0, var(--line-soft) 12%, var(--line-medium) 50%, var(--line-soft) 88%, transparent 100%);
}

.timeline-header {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  margin: 0;
  gap: 0;
}

.timeline-toolbar {
  display: inline-flex;
  align-items: center;
  align-self: stretch;
  gap: 0;
  height: 22px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 0;
  overflow: hidden;
  background: #fff;
}

.timeline-panel {
  gap: 4px;
  padding: 0 0 10px;
}

.playback-options {
  display: flex;
  gap: 6px;
}

.playback-option {
  display: grid;
  place-items: center;
  width: 24px;
  min-width: 24px;
  height: 22px;
  min-height: 22px;
  padding: 0;
  border-color: var(--line);
  border-radius: 0;
  border-left: 0;
  color: #1d4ed8;
  background: #fff;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease, transform 120ms ease;
}

.playback-option svg {
  width: 12px;
  height: 12px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.65;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.playback-option[aria-pressed="true"] {
  border-color: var(--accent);
  color: #eff6ff;
  background: var(--accent);
}

.playback-option:hover {
  border-color: var(--accent);
  color: #eff6ff;
  background: #2563eb;
}

.play-toggle {
  display: grid;
  place-items: center;
  width: 24px;
  min-width: 24px;
  height: 22px;
  min-height: 22px;
  border-radius: 0;
  border: 1px solid transparent;
  padding: 0;
  color: #3b82f6;
  background: #fff;
  transition: background 120ms ease, border-color 120ms ease, transform 120ms ease;
}

.play-toggle:hover {
  border-color: transparent;
  background: #f8fbff;
}

.play-toggle:active {
  transform: scale(0.96);
}

.play-toggle:focus-visible {
  outline: 2px solid var(--accent-bright);
  outline-offset: 3px;
}

.play-toggle.is-playing {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.play-icon {
  display: block;
  width: 0;
  height: 0;
  margin-left: 2px;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-left: 7px solid #3b82f6;
}

.play-toggle.is-playing .play-icon {
  width: 10px;
  height: 12px;
  margin-left: 0;
  border: 0;
  border-left: 3px solid #fff;
  border-right: 3px solid #fff;
}

.timeline-track {
  --frame-cell-width: 54px;
  --frame-cell-height: 66px;
  --frame-cell-between-height: 48px;
  --frame-cell-star-gap: 8px;
  --timeline-gap: 3px;
  display: grid;
  gap: 0;
  overflow-x: auto;
  overflow-y: visible;
  padding: 0 8px 23px;
  scrollbar-color: #93c5fd #eff6ff;
  scrollbar-width: thin;
  touch-action: pan-x;
}

.timeline-track::-webkit-scrollbar {
  height: 8px;
}

.timeline-track::-webkit-scrollbar-track {
  background: #eff6ff;
}

.timeline-track::-webkit-scrollbar-thumb {
  border: 2px solid #eff6ff;
  border-radius: 999px;
  background: #93c5fd;
}

.timeline-ruler {
  position: relative;
  height: 18px;
  min-width: 100%;
  margin: 0 0 2px;
  border-bottom: 1px solid #d8e6f7;
}

.timeline-ruler-marker {
  position: absolute;
  bottom: 0;
  width: 1px;
  height: 6px;
  background: #aac4e8;
  transform: translateX(-0.5px);
}

.timeline-ruler-marker.is-major {
  height: 10px;
  background: #3b82f6;
}

.timeline-ruler-marker span {
  position: absolute;
  left: 4px;
  top: 0;
  color: #2563eb;
  font-family: "JetBrains Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 9px;
  font-weight: 800;
  white-space: nowrap;
}

.timeline-cel-row {
  display: flex;
  align-items: center;
  gap: var(--timeline-gap);
  min-width: max-content;
}

.frame-cell {
  position: relative;
  display: grid;
  grid-template-rows: 1fr;
  place-items: center;
  min-height: var(--frame-cell-height);
  height: var(--frame-cell-height);
  width: var(--frame-cell-width);
  min-width: var(--frame-cell-width);
  border: 1px solid #cbdff6;
  border-radius: 3px;
  padding: 3px 2px;
  color: var(--muted);
  background: #f8fbff;
  cursor: pointer;
}

.frame-cell:hover:not(.is-current):not(.is-anchor-add) {
  border-color: #b9d4f4;
  color: #3f5874;
  background: #f1f7ff;
}

.frame-cell.is-directed:hover:not(.is-current):not(.is-anchor-add) {
  border-color: #c4b5fd;
  color: #6d28d9;
  background: #f8f5ff;
}

.frame-cell.is-current:hover {
  color: #fff;
  background: var(--accent);
}

.frame-cell:not(.is-anchor):not(.is-anchor-add) {
  min-height: var(--frame-cell-between-height);
  height: var(--frame-cell-between-height);
}

.frame-cell.starts-hold-run::before,
.frame-cell.starts-hold-run::after,
.frame-cell.continues-hold-run::before,
.frame-cell.continues-hold-run.ends-hold-run::after {
  content: "";
  position: absolute;
  z-index: 0;
  background: rgba(100, 116, 139, 0.36);
  pointer-events: none;
}

.frame-cell.starts-hold-run::before,
.frame-cell.continues-hold-run.ends-hold-run::after {
  left: 50%;
  top: 100%;
  width: 1px;
  height: 8px;
}

.frame-cell.starts-hold-run::after,
.frame-cell.continues-hold-run::before {
  top: calc(100% + 7px);
  height: 1px;
}

.frame-cell.starts-hold-run::after {
  left: 50%;
  right: calc(var(--timeline-gap) * -1 - 1px);
}

.frame-cell.continues-hold-run::before {
  left: calc(var(--timeline-gap) * -1 - 1px);
  right: calc(var(--timeline-gap) * -1 - 1px);
}

.frame-cell.continues-hold-run:not(.is-anchor)::before {
  top: calc(100% + 7px + ((var(--frame-cell-height) - var(--frame-cell-between-height)) / 2));
}

.frame-cell.continues-hold-run.ends-hold-run:not(.is-anchor)::after {
  height: calc(8px + ((var(--frame-cell-height) - var(--frame-cell-between-height)) / 2));
}

.frame-cell.continues-hold-run.ends-hold-run::before {
  right: 50%;
}

.frame-cell span {
  position: relative;
  z-index: 1;
  font-size: 10px;
  font-weight: 800;
}

.frame-cell-source svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.frame-cell .frame-cell-tag {
  display: grid;
  place-items: center;
  align-self: center;
  justify-self: center;
  min-height: 18px;
  color: currentColor;
  line-height: 1;
  white-space: nowrap;
  font-size: 11px;
}

.frame-cell .frame-cell-source {
  display: grid;
  place-items: center;
  position: absolute;
  left: 50%;
  top: calc(100% + var(--frame-cell-star-gap));
  width: 13px;
  height: 13px;
  color: transparent;
  pointer-events: none;
  transform: translateX(-50%);
}

.frame-cell.is-current {
  border-color: var(--accent);
  color: #fff;
  background: var(--accent);
}

.frame-cell.is-key {
  border-color: #94a3b8;
}

.frame-cell.is-anchor.is-current {
  border-color: var(--accent);
  color: #fff;
  background: var(--accent);
}

.frame-cell.is-anchor {
  background: #eef4ff;
  border-color: #94a3b8;
}

.frame-cell.is-anchor .frame-cell-tag {
  font-size: 16px;
  font-weight: 900;
}

.frame-cell.is-directed {
  border-color: #7c3aed;
  color: #7c3aed;
}

.frame-cell.is-directed .frame-cell-source {
  color: #7c3aed;
}

.frame-cell.is-directed .frame-cell-source svg {
  fill: #7c3aed;
  stroke: #7c3aed;
}

.frame-cell.is-current.is-directed .frame-cell-source {
  color: #7c3aed;
}

.frame-cell.is-anchor-add {
  display: grid;
  place-items: center;
  align-self: center;
  padding: 0;
  border-color: transparent;
  color: #98a3b3;
  background: #f4f7fb;
}

.frame-cell.is-anchor-add .frame-cell-label {
  display: grid;
  place-items: center;
  color: #98a3b3;
  font-size: 17px;
  font-weight: 550;
  line-height: 1;
}

.frame-cell.is-anchor-add:hover {
  border-color: transparent;
  color: #aab4c2;
  background: #eef3f8;
}

.frame-cell.is-anchor-add:hover .frame-cell-label {
  color: #aab4c2;
}

.frame-cell-label {
  font-size: 22px;
  font-weight: 800;
  line-height: 1;
}

.frame-cell-subtitle {
  font-size: 9px;
  line-height: 1;
}

.timeline-track.is-compact {
  --frame-cell-height: 52px;
  --frame-cell-between-height: 38px;
  --frame-cell-star-gap: 7px;
}

.timeline-track.is-tiny {
  --frame-cell-height: 42px;
  --frame-cell-between-height: 32px;
  --frame-cell-star-gap: 6px;
}

.timeline-track.is-micro {
  --frame-cell-height: 34px;
  --frame-cell-between-height: 27px;
  --frame-cell-star-gap: 5px;
}

.timeline-track.is-tiny .timeline-ruler-marker span,
.timeline-track.is-micro .timeline-ruler-marker span {
  font-size: 8px;
}

.timeline-track.is-compact .frame-cell,
.timeline-track.is-tiny .frame-cell,
.timeline-track.is-micro .frame-cell {
  padding: 2px;
}

.timeline-track.is-tiny .frame-cell span {
  font-size: 8px;
}

.timeline-track.is-tiny .frame-cell.is-anchor .frame-cell-tag {
  font-size: 12px;
}

.timeline-track.is-tiny .frame-cell-source {
  width: 10px;
  height: 10px;
}

.timeline-track.is-tiny .frame-cell-label {
  font-size: 15px;
}

.timeline-track.is-tiny .frame-cell-subtitle {
  display: none;
}

.timeline-track.is-micro .frame-cell {
  border-radius: 2px;
  padding: 1px 0;
}

.timeline-track.is-micro .frame-cell span {
  font-size: 7px;
  line-height: 1;
}

.timeline-track.is-micro .frame-cell-tag {
  writing-mode: horizontal-tb;
  transform: none;
}

.timeline-track.is-micro .frame-cell.is-anchor .frame-cell-tag {
  font-size: 9px;
}

.timeline-track.is-micro .frame-cell-source {
  width: 8px;
  height: 8px;
}

.timeline-track.is-micro .frame-cell-label {
  font-size: 12px;
}

.timeline-track.is-micro .frame-cell-subtitle {
  display: none;
}

.stage-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 52px;
  padding: 16px 20px;
  position: relative;
  border-bottom: 1px solid transparent;
  color: var(--muted);
  font-size: 13px;
  background: rgba(248, 251, 255, 0.92);
}

.stage-toolbar::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 20px;
  right: 20px;
  height: 1px;
  background: linear-gradient(90deg, transparent 0, var(--line-soft) 12%, var(--line-medium) 50%, var(--line-soft) 88%, transparent 100%);
}

#selectedLabel {
  color: #1d4ed8;
  font-weight: 800;
}

.stage-toolbar-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  min-width: 0;
}

.toolbar-toggle,
.character-toggle,
.zoom-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.toolbar-button,
.toolbar-icon-button {
  min-height: 28px;
  border-color: #bfdbfe;
  border-radius: 999px;
  padding: 0 11px;
  color: #1d4ed8;
  background: #fff;
  font-family: "JetBrains Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.toolbar-icon-button {
  min-width: 32px;
  padding: 0 9px;
}

.toolbar-button:hover,
.toolbar-icon-button:hover {
  color: #1d4ed8;
  background: #eaf3ff;
}

.toolbar-icon-button.is-active {
  color: #fff;
  background: var(--accent);
}

.toolbar-toggle span,
.character-toggle span,
.zoom-toggle span {
  text-transform: uppercase;
}

.toolbar-toggle select,
.character-toggle select {
  width: auto;
  min-height: 28px;
  border-color: #bfdbfe;
  border-radius: 999px;
  padding: 0 26px 0 10px;
  color: #1d4ed8;
  background: #fff;
  font-size: 11px;
  font-weight: 800;
}

.character-toggle select {
  min-width: 96px;
}

.fps-toggle select {
  min-width: 58px;
  padding-right: 20px;
}

.zoom-toggle input {
  width: 72px;
  accent-color: var(--accent);
}

.stage-viewport {
  position: relative;
  display: grid;
  align-items: stretch;
  justify-items: stretch;
  min-height: 0;
  overflow: hidden;
  background:
    linear-gradient(rgba(59, 130, 246, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(59, 130, 246, 0.045) 1px, transparent 1px),
    var(--stage);
  background-size: 36px 36px, 36px 36px, 100% 100%;
}

.canvas-tool-palette {
  position: absolute;
  top: 52px;
  left: 12px;
  z-index: 6;
  display: grid;
  gap: 4px;
  width: 116px;
  padding: 4px;
  border: 1px solid rgba(148, 163, 184, 0.42);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.9);
}

.canvas-tool-button,
.canvas-tool-collapse {
  display: grid;
  align-items: center;
  min-height: 30px;
  border: 0;
  border-radius: 2px;
  color: #475569;
  background: transparent;
}

.canvas-tool-button {
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 7px;
  padding: 0 6px;
}

.canvas-tool-button:hover,
.canvas-tool-collapse:hover {
  color: #1d4ed8;
  background: #eff6ff;
}

.canvas-tool-button.is-active {
  color: #fff;
  background: #2563eb;
}

.canvas-tool-icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
  justify-self: center;
}

.canvas-tool-copy {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.canvas-tool-name {
  overflow: hidden;
  font-size: 10px;
  font-weight: 850;
  line-height: 1;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.canvas-tool-copy kbd {
  min-width: 15px;
  padding: 1px 4px;
  border: 1px solid rgba(100, 116, 139, 0.32);
  border-radius: 2px;
  color: inherit;
  background: rgba(255, 255, 255, 0.56);
  font-family: "JetBrains Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 9px;
  font-weight: 850;
  line-height: 1.2;
  text-align: center;
}

.canvas-tool-button.is-active kbd {
  border-color: rgba(255, 255, 255, 0.44);
  background: rgba(255, 255, 255, 0.18);
}

.canvas-tool-collapse {
  position: absolute;
  left: -1px;
  bottom: -18px;
  width: 18px;
  min-width: 18px;
  min-height: 18px;
  padding: 0;
  border: 1px solid rgba(148, 163, 184, 0.42);
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.92);
  font-size: 10px;
  line-height: 1;
}

.canvas-tool-palette.is-compact {
  width: auto;
  padding: 3px;
}

.canvas-tool-palette.is-compact .canvas-tool-button {
  grid-template-columns: 24px;
  width: 30px;
  min-height: 30px;
  padding: 0;
}

.canvas-tool-palette.is-compact .canvas-tool-copy {
  display: none;
}

.canvas-tool-palette.is-compact .canvas-tool-collapse span {
  transform: rotate(180deg);
}

.ideate-dock {
  --idea: #f5a623;
  --idea-deep: #d6850c;
  position: absolute;
  right: 18px;
  bottom: 18px;
  z-index: 7;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 14px;
  pointer-events: none;
}

.ideate-dock > * {
  pointer-events: auto;
}

/* ---- the lightbulb button ---- */
.ideate-fab {
  position: relative;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background:
    radial-gradient(120% 120% at 30% 22%, #4f92ff 0%, var(--accent-bright) 46%, #1d4ed8 100%);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.35) inset,
    0 10px 24px rgba(37, 99, 235, 0.34);
  cursor: pointer;
  transition: transform 0.16s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.16s ease;
}

.ideate-fab:hover {
  transform: translateY(-2px);
}

.ideate-fab:active {
  transform: translateY(0) scale(0.96);
}

/* soft idle "thinking" halo to draw the eye without nagging */
.ideate-fab-glow {
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(245, 166, 35, 0.5) 0%, transparent 68%);
  opacity: 0;
  transform: scale(0.6);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.ideate-fab:hover .ideate-fab-glow {
  opacity: 0.85;
  transform: scale(1);
}

.ideate-fab-icon {
  position: relative;
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: filter 0.18s ease;
}

/* when open, the bulb "switches on" — warm fill + glow */
.ideate-fab[aria-expanded="true"] {
  background:
    radial-gradient(120% 120% at 30% 22%, #ffd27a 0%, var(--idea) 52%, var(--idea-deep) 100%);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.5) inset,
    0 0 0 4px rgba(245, 166, 35, 0.18),
    0 10px 26px rgba(214, 133, 12, 0.42);
}

.ideate-fab[aria-expanded="true"] .ideate-fab-icon {
  filter: drop-shadow(0 0 4px rgba(255, 255, 255, 0.75));
}

.ideate-fab[aria-expanded="true"] .ideate-fab-icon path:last-child {
  fill: rgba(255, 255, 255, 0.32);
}

/* ---- the idea bubble ---- */
/* Author display:grid below would otherwise beat the UA [hidden] rule, leaving
   the bubble permanently visible — so re-assert the hide explicitly. */
.ideate-popover[hidden] {
  display: none;
}

.ideate-popover {
  position: relative;
  width: 276px;
  display: grid;
  gap: 12px;
  padding: 16px 16px 14px;
  border: 1px solid var(--line);
  border-radius: 16px 16px 6px 16px;
  background:
    linear-gradient(180deg, #ffffff 0%, var(--paper) 100%);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.8) inset,
    0 22px 50px -12px rgba(23, 32, 51, 0.34);
  transform-origin: bottom right;
  animation: ideate-pop 0.22s cubic-bezier(0.34, 1.4, 0.5, 1);
}

@keyframes ideate-pop {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.94);
  }
}

/* staggered reveal of the inner pieces */
.ideate-popover > * {
  animation: ideate-rise 0.32s both cubic-bezier(0.22, 0.8, 0.3, 1);
}
.ideate-popover > .ideate-head { animation-delay: 0.04s; }
.ideate-popover > .ideate-input { animation-delay: 0.09s; }
.ideate-popover > .ideate-actions { animation-delay: 0.14s; }

@keyframes ideate-rise {
  from {
    opacity: 0;
    transform: translateY(7px);
  }
}

.ideate-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ideate-spark {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 7px;
  color: var(--idea-deep);
  background: rgba(245, 166, 35, 0.16);
}

.ideate-spark svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ideate-title {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--muted);
  text-transform: uppercase;
}

.ideate-input {
  width: 100%;
  resize: vertical;
  min-height: 70px;
  padding: 10px 11px;
  border: 1px solid var(--line-medium);
  border-radius: 10px;
  color: var(--ink);
  background: var(--surface);
  font-size: 12.5px;
  line-height: 1.5;
  transition: border-color 0.14s ease, box-shadow 0.14s ease;
}

.ideate-input::placeholder {
  color: #9aa9bd;
}

.ideate-input:focus {
  outline: none;
  border-color: var(--idea);
  box-shadow: 0 0 0 3px rgba(245, 166, 35, 0.18);
}

.ideate-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.ideate-hint {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: #9aa9bd;
  white-space: nowrap;
}

.ideate-status:empty {
  display: none;
}

.ideate-status {
  margin: 8px 0 0;
  font-size: 11px;
  line-height: 1.35;
  color: #7c89a0;
}

.ideate-hint kbd {
  display: inline-grid;
  place-items: center;
  min-width: 16px;
  height: 16px;
  padding: 0 3px;
  border: 1px solid var(--line-medium);
  border-radius: 4px;
  background: var(--surface);
  font-size: 10px;
  color: var(--muted);
}

.ideate-submit {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 15px;
  border: 0;
  border-radius: 10px;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.01em;
  background: linear-gradient(180deg, var(--idea) 0%, var(--idea-deep) 100%);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.4) inset,
    0 6px 16px rgba(214, 133, 12, 0.34);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
}

.ideate-submit:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.4) inset,
    0 9px 20px rgba(214, 133, 12, 0.42);
}

.ideate-submit:active {
  transform: translateY(0) scale(0.98);
}

.ideate-submit:disabled {
  cursor: default;
  filter: grayscale(0.4);
  opacity: 0.55;
}

.ideate-submit-icon {
  width: 15px;
  height: 15px;
  fill: currentColor;
}

#stage {
  --pose-stroke: #7c3aed;
  --pose-soft-stroke: rgba(124, 58, 237, 0.42);
  --pose-soft-node: #a78bfa;
  --pose-node-fill: #faf5ff;
  --pose-selected-stroke: #6d28d9;
  --pose-fill: rgba(255, 255, 255, 0.18);
  display: block;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  border: 1px solid transparent;
  touch-action: none;
}

#stage.motion-mode:not(.is-panning-frame) {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='28' viewBox='0 0 28 28'%3E%3Cdefs%3E%3Cfilter id='motionGlow' x='-40%25' y='-40%25' width='180%25' height='180%25'%3E%3CfeDropShadow dx='0' dy='0' stdDeviation='1.7' flood-color='%23ef4444' flood-opacity='.52'/%3E%3C/filter%3E%3C/defs%3E%3Cpath d='M5 3.5 5 22.4 10.8 16.9 14.8 25 18.4 23.3 14.5 15.4 22.2 15.4Z' fill='%23ef4444' stroke='%23ffffff' stroke-width='1.25' stroke-linejoin='round' filter='url(%23motionGlow)'/%3E%3Cpath d='M5 3.5 5 22.4 10.8 16.9 14.8 25 18.4 23.3 14.5 15.4 22.2 15.4Z' fill='none' stroke='%23b91c1c' stroke-width='.8' stroke-linejoin='round'/%3E%3C/svg%3E") 5 4, default;
}

#stage.is-panning-frame {
  border-color: var(--accent);
  cursor: grab;
}

#stage.is-panning-frame:active {
  cursor: grabbing;
}

.camera-frame-badge {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 4;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  padding: 3px 4px 3px 9px;
  color: #1d4ed8;
  background: rgba(255, 255, 255, 0.94);
  font-family: "JetBrains Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 11px;
  font-weight: 800;
}

.camera-frame-badge[hidden] {
  display: none;
}

.camera-frame-icon {
  line-height: 1;
}

.camera-done-button {
  min-width: 22px;
  min-height: 22px;
  border: 0;
  border-radius: 999px;
  padding: 0;
  color: #fff;
  background: var(--accent);
  font-size: 12px;
  line-height: 1;
}

.camera-done-button:hover {
  background: #2563eb;
}

.pose-source-badge {
  position: absolute;
  top: 14px;
  left: 16px;
  z-index: 4;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 7px;
  border: 1px solid currentColor;
  border-radius: 3px;
  color: #2563eb;
  background: rgba(255, 255, 255, 0.84);
  font-family: "JetBrains Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0;
}

.pose-source-badge[hidden] {
  display: none;
}

.pose-source-star {
  width: 10px;
  height: 10px;
  fill: currentColor;
  stroke: currentColor;
  stroke-width: 1.4;
  stroke-linejoin: round;
  flex: 0 0 auto;
}

.pose-source-badge[data-source="directed"] {
  color: #7c3aed;
}

.pose-source-badge[data-source="computed"] {
  color: #2563eb;
}

.draw-over-hint {
  position: absolute;
  top: 11px;
  left: 50%;
  z-index: 5;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 24px;
  padding: 3px 8px;
  border: 1px solid rgba(107, 114, 128, 0.24);
  border-radius: 3px;
  color: #4b5563;
  background: rgba(249, 250, 251, 0.9);
  font-family: "JetBrains Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -4px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.draw-over-hint.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.draw-over-hint kbd {
  min-width: 14px;
  padding: 1px 4px;
  border: 1px solid rgba(107, 114, 128, 0.28);
  border-radius: 2px;
  color: #374151;
  background: rgba(255, 255, 255, 0.72);
  font: inherit;
  font-weight: 850;
  line-height: 1.2;
  text-align: center;
}

.stage-bg {
  fill: transparent;
  pointer-events: all;
}

.motion-draw-veil {
  fill: rgba(255, 255, 255, 0);
  pointer-events: none;
  transition: fill 120ms ease;
}

.shot-crop-marks {
  opacity: 0;
  pointer-events: none;
}

.shot-crop-marks.is-visible {
  opacity: 1;
}

.shot-crop-marks line {
  stroke: #0f172a;
  stroke-width: 1.25;
  stroke-linecap: square;
  vector-effect: non-scaling-stroke;
}

#stage.motion-mode.pen-ready .motion-draw-veil {
  fill: rgba(255, 255, 255, 0.34);
}

#stage.motion-mode.is-drawing .motion-draw-veil {
  fill: rgba(255, 255, 255, 0.48);
}

.torso-node-line {
  fill: none;
  stroke: #60a5fa;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
  vector-effect: non-scaling-stroke;
}

.node-handle {
  fill: #fff;
  stroke: #1d4ed8;
  stroke-width: 2.5;
  cursor: pointer;
  vector-effect: non-scaling-stroke;
  transition:
    fill 120ms ease,
    stroke 120ms ease,
    stroke-width 120ms ease,
    filter 120ms ease;
}

.node-handle.secondary-node {
  fill: #eff6ff;
  stroke: #60a5fa;
}

.node-handle.extremity-node {
  stroke-width: 3;
}

.node-handle.selected-node {
  fill: #fee2e2;
  stroke: var(--director-red);
  stroke-width: 3.5;
}

.node-handle:focus-visible {
  outline: 2px solid var(--accent-bright);
  outline-offset: 3px;
}

.shape-handle {
  fill: #fff7ed;
  stroke: #f59e0b;
  stroke-width: 1.6;
  cursor: grab;
  vector-effect: non-scaling-stroke;
}

.shape-handle:active {
  cursor: grabbing;
}

.torso-shape-handle {
  fill: #fef3c7;
  stroke: #f59e0b;
}

.shape-handle:focus-visible {
  outline: 2px solid #f59e0b;
  outline-offset: 3px;
}

#stage.layout-mode,
#stage.motion-mode {
  --pose-stroke: #7c3aed;
  --pose-soft-stroke: rgba(124, 58, 237, 0.42);
  --pose-soft-node: #a78bfa;
  --pose-node-fill: #faf5ff;
  --pose-selected-stroke: #6d28d9;
  --pose-fill: rgba(255, 255, 255, 0.18);
}

#stage.layout-mode.computed-pose,
#stage.motion-mode.computed-pose {
  --pose-stroke: #2563eb;
  --pose-soft-stroke: rgba(37, 99, 235, 0.42);
  --pose-soft-node: #93c5fd;
  --pose-node-fill: #f8fbff;
  --pose-selected-stroke: #1d4ed8;
}

#stage.motion-mode.directed-pose {
  --pose-fill: rgba(124, 58, 237, 0.5);
}

#stage.motion-mode.computed-pose {
  --pose-fill: rgba(37, 99, 235, 0.5);
}

#stage.layout-mode .anime-torso,
#stage.layout-mode .anime-head,
#stage.layout-mode .anime-neck,
#stage.layout-mode .anime-limb,
#stage.layout-mode .anime-hand,
#stage.layout-mode .anime-foot,
#stage.motion-mode .anime-torso,
#stage.motion-mode .anime-head,
#stage.motion-mode .anime-neck,
#stage.motion-mode .anime-limb,
#stage.motion-mode .anime-hand,
#stage.motion-mode .anime-foot {
  fill: rgba(255, 255, 255, 0.18);
  stroke: var(--pose-stroke);
  stroke-width: 1.4;
}

#stage.motion-mode .anime-torso,
#stage.motion-mode .anime-head,
#stage.motion-mode .anime-neck,
#stage.motion-mode .anime-limb,
#stage.motion-mode .anime-hand,
#stage.motion-mode .anime-foot {
  fill: var(--pose-fill);
}

#stage.layout-mode .anime-torso,
#stage.layout-mode .anime-head,
#stage.layout-mode .anime-neck,
#stage.layout-mode .anime-limb,
#stage.layout-mode .anime-hand,
#stage.layout-mode .anime-foot,
#stage.layout-mode .torso,
#stage.layout-mode .head,
#stage.layout-mode .joint,
#stage.layout-mode .limb {
  transition:
    fill 120ms ease,
    stroke 120ms ease,
    stroke-width 120ms ease,
    opacity 120ms ease,
    filter 120ms ease;
}

#stage.layout-mode .anime-torso:not(.selected):hover,
#stage.layout-mode .anime-head:not(.selected):hover,
#stage.layout-mode .anime-neck:not(.selected):hover,
#stage.layout-mode .anime-limb:not(.selected):hover,
#stage.layout-mode .anime-hand:not(.selected):hover,
#stage.layout-mode .anime-foot:not(.selected):hover,
#stage.layout-mode .torso:not(.selected):hover,
#stage.layout-mode .head:not(.selected):hover,
#stage.layout-mode .joint:not(.selected):hover {
  fill: rgba(239, 246, 255, 0.46);
  stroke: var(--pose-selected-stroke);
  stroke-width: 2;
  filter: drop-shadow(0 0 3px rgba(37, 99, 235, 0.24));
}

#stage.layout-mode .limb:not(.selected):hover {
  stroke: rgba(96, 165, 250, 0.9);
  filter: drop-shadow(0 0 3px rgba(37, 99, 235, 0.2));
}

#stage.layout-mode .front-leg,
#stage.layout-mode .back-leg,
#stage.motion-mode .front-leg,
#stage.motion-mode .back-leg {
  fill: rgba(255, 255, 255, 0.16);
  stroke: var(--pose-stroke);
}

#stage.motion-mode .front-leg,
#stage.motion-mode .back-leg {
  fill: var(--pose-fill);
}

#stage.layout-mode .back-limb,
#stage.layout-mode .back-leg,
#stage.motion-mode .back-limb,
#stage.motion-mode .back-leg {
  opacity: 0.54;
}

#stage.motion-mode .back-limb,
#stage.motion-mode .back-leg {
  opacity: 0.66;
}

#stage.layout-mode .torso,
#stage.layout-mode .head,
#stage.layout-mode .joint,
#stage.motion-mode .torso,
#stage.motion-mode .head,
#stage.motion-mode .joint {
  fill: rgba(255, 255, 255, 0.2);
  stroke: var(--pose-stroke);
  stroke-width: 2;
}

#stage.motion-mode .torso,
#stage.motion-mode .head,
#stage.motion-mode .joint {
  fill: var(--pose-fill);
}

#stage.layout-mode .limb,
#stage.motion-mode .limb {
  stroke: var(--pose-soft-stroke);
  stroke-width: 10;
}

#stage.layout-mode .leg,
#stage.motion-mode .leg {
  stroke: var(--pose-soft-stroke);
}

#stage.layout-mode .node-handle,
#stage.motion-mode .node-handle {
  fill: #fff;
  stroke: var(--pose-stroke);
  stroke-width: 2;
}

#stage.layout-mode .node-handle.secondary-node,
#stage.motion-mode .node-handle.secondary-node {
  fill: var(--pose-node-fill);
  stroke: var(--pose-soft-node);
}

#stage.layout-mode .node-handle.selected-node,
#stage.motion-mode .node-handle.selected-node {
  fill: #f5f3ff;
  stroke: var(--pose-selected-stroke);
  stroke-width: 3;
}

#stage.layout-mode .node-handle:not(.selected-node):hover {
  fill: #eff6ff;
  stroke: var(--pose-selected-stroke);
  stroke-width: 3;
  filter: drop-shadow(0 0 3px rgba(37, 99, 235, 0.28));
}

#stage.motion-mode .node-handle:not(.selected-node):hover {
  fill: #fee2e2;
  stroke: var(--director-red);
  stroke-width: 3;
  filter: drop-shadow(0 0 5px rgba(239, 68, 68, 0.52));
}

#stage.layout-mode .torso-node-line,
#stage.motion-mode .torso-node-line {
  stroke: var(--pose-soft-node);
}

#stage.layout-mode .motion-path,
#stage.layout-mode .path-arrow,
#stage.layout-mode .timing-tick,
#stage.layout-mode .path-delay-badge,
#stage.layout-mode .timing-arc-segment,
#stage.layout-mode .arc-timing-marker {
  opacity: 0.18;
}

.limb,
.torso,
.head,
.joint {
  cursor: pointer;
}

.limb {
  stroke: var(--pose-soft-stroke);
  stroke-width: 10;
  stroke-linecap: round;
}

.leg {
  stroke: var(--pose-soft-stroke);
}

.torso {
  fill: var(--pose-fill);
  stroke: var(--pose-stroke);
  stroke-width: 2;
}

.head,
.joint {
  fill: var(--pose-fill);
  stroke: var(--pose-stroke);
  stroke-width: 2;
}

.hand,
.foot {
  fill: var(--pose-fill);
}

.eye,
.mouth {
  fill: none;
  stroke: var(--pose-stroke);
  stroke-width: 2;
  stroke-linecap: round;
}

.selected {
  outline: none;
  stroke: var(--director-red);
}

.torso.selected,
.head.selected,
.joint.selected,
.anime-torso.selected,
.anime-head.selected,
.anime-neck.selected,
.anime-limb.selected,
.anime-hand.selected,
.anime-foot.selected {
  fill: #fee2e2;
  stroke: var(--director-red);
}

.limb.selected {
  stroke: rgba(239, 68, 68, 0.72);
}

#stage.layout-mode .torso.selected,
#stage.layout-mode .head.selected,
#stage.layout-mode .joint.selected,
#stage.layout-mode .anime-torso.selected,
#stage.layout-mode .anime-head.selected,
#stage.layout-mode .anime-neck.selected,
#stage.layout-mode .anime-limb.selected,
#stage.layout-mode .anime-hand.selected,
#stage.layout-mode .anime-foot.selected,
#stage.motion-mode .torso.selected,
#stage.motion-mode .head.selected,
#stage.motion-mode .joint.selected,
#stage.motion-mode .anime-torso.selected,
#stage.motion-mode .anime-head.selected,
#stage.motion-mode .anime-neck.selected,
#stage.motion-mode .anime-limb.selected,
#stage.motion-mode .anime-hand.selected,
#stage.motion-mode .anime-foot.selected {
  fill: var(--pose-fill);
  stroke: var(--pose-selected-stroke);
}

#stage.layout-mode .limb.selected,
#stage.motion-mode .limb.selected {
  stroke: var(--pose-soft-stroke);
}

.anime-torso,
.anime-head,
.anime-neck,
.anime-limb,
.anime-hand,
.anime-foot {
  cursor: pointer;
  stroke: var(--pose-stroke);
  stroke-width: 2.6;
  stroke-linejoin: round;
}

.anime-torso {
  fill: var(--pose-fill);
}

.anime-head,
.anime-neck {
  fill: var(--pose-fill);
}

.anime-limb,
.anime-hand,
.anime-foot {
  fill: var(--pose-fill);
}

.front-limb {
  fill: var(--pose-fill);
}

.front-leg,
.back-leg {
  fill: var(--pose-fill);
  stroke: var(--pose-stroke);
}

.back-limb,
.back-leg {
  opacity: 0.86;
}

.anime-hand,
.anime-foot {
  fill: var(--pose-fill);
}

.motion-path {
  fill: none;
  stroke: var(--director-red);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.motion-path-line {
  cursor: pointer;
  transition: filter 120ms ease, stroke-width 120ms ease, opacity 120ms ease;
}

.motion-path-line.is-hovered,
.motion-path-line.is-selected {
  filter: drop-shadow(0 0 5px rgba(239, 68, 68, 0.62));
}

.body-response-path {
  fill: none;
  stroke: #facc15;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.68;
  pointer-events: none;
  vector-effect: non-scaling-stroke;
}

.body-response-path.is-selected {
  opacity: 0.86;
  stroke-width: 2.2;
}

.body-response-path.is-subtle {
  opacity: 0.32;
  stroke-width: 1.2;
}

.body-response-point {
  fill: #fef9c3;
  stroke: #facc15;
  stroke-width: 1.3;
  opacity: 0.9;
  pointer-events: none;
  vector-effect: non-scaling-stroke;
}

.body-response-point.is-end {
  fill: #facc15;
}

.motion-guide-line {
  fill: none;
  stroke: var(--director-red);
  stroke-width: 3;
  stroke-dasharray: 1 8;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
  display: none;
}

.stored-motion-path {
  fill: none;
  stroke: rgba(239, 68, 68, 0.34);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.redraw-reference-path {
  fill: none;
  stroke: var(--director-red);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.24;
  pointer-events: none;
  vector-effect: non-scaling-stroke;
}

.stored-motion-path.is-selected {
  stroke: var(--director-red);
  stroke-opacity: 0.9;
  stroke-width: 3.2;
}

.motion-path.is-selected {
  stroke: var(--director-red);
  stroke-opacity: 1;
  stroke-width: 4.8;
}

.motion-path-bounds {
  pointer-events: none;
  fill: none;
  stroke: #0d99ff;
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
  shape-rendering: crispEdges;
}

.motion-path-bound-handle {
  pointer-events: none;
  fill: #fff;
  stroke: #0d99ff;
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
  shape-rendering: crispEdges;
}

.timing-arc-segment {
  fill: none;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 5 7;
  pointer-events: none;
}

.anticipation-segment {
  stroke: #2563eb;
}

.overshoot-segment {
  stroke: #f59e0b;
}

.arc-timing-marker {
  cursor: grab;
  stroke: #1e3a8a;
  stroke-width: 1.4;
  vector-effect: non-scaling-stroke;
}

.arc-timing-marker:active {
  cursor: grabbing;
}

.arc-timing-marker:focus-visible {
  outline: 2px solid var(--accent-bright);
  outline-offset: 3px;
}

.anticipation-arc-marker {
  fill: #bfdbfe;
}

.overshoot-arc-marker {
  fill: #fed7aa;
}

.path-arrow,
.timing-tick {
  stroke: var(--director-red);
  stroke-width: 1.6;
  stroke-linecap: round;
  pointer-events: none;
  vector-effect: non-scaling-stroke;
}

.response-timing-tick {
  stroke: #facc15;
  stroke-width: 1.4;
  stroke-linecap: round;
  pointer-events: none;
  vector-effect: non-scaling-stroke;
}

.path-arrow.is-subtle,
.timing-tick.is-subtle,
.response-timing-tick.is-subtle {
  opacity: 0.28;
  stroke-width: 0.9;
}

.path-delay-badge {
  fill: var(--director-red);
  font-family: "JetBrains Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0;
  paint-order: stroke;
  pointer-events: none;
  stroke: #fff;
  stroke-width: 3px;
  vector-effect: non-scaling-stroke;
}

.path-delay-badge.is-subtle {
  opacity: 0.42;
  font-size: 8px;
}

.minor-tick {
  opacity: 0.48;
  stroke-width: 1;
}

.major-tick {
  opacity: 0.92;
  stroke-width: 1.25;
}

.minor-tick.is-subtle {
  opacity: 0.2;
  stroke-width: 0.75;
}

.major-tick.is-subtle {
  opacity: 0.34;
  stroke-width: 0.95;
}

input[type="range"] {
  accent-color: var(--accent);
}

select:focus,
button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--accent-bright);
  outline-offset: 2px;
}

.modal-shell {
  width: min(420px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 24px 72px rgba(23, 32, 51, 0.28);
}

.modal-shell::backdrop {
  background: rgba(15, 23, 42, 0.28);
}

.modal-panel {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.file-modal {
  width: min(360px, calc(100vw - 32px));
}

.file-modal-status {
  min-height: 13px;
  margin: -4px 0 0;
  color: #64748b;
  font-family: "JetBrains Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 10px;
  line-height: 1.3;
}

.file-modal-presets {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.file-modal-presets-label {
  color: #64748b;
  font-size: 11px;
  font-weight: 600;
}

.file-modal-preset {
  font-size: 11px;
  padding: 5px 10px;
}

.demo-doc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.demo-doc-link {
  display: block;
  padding: 9px 11px;
  border: 1px solid #c9ddf6;
  border-radius: 4px;
  background: #f8fbff;
  color: #0f172a;
  font-size: 12px;
  text-decoration: none;
}

.demo-doc-link:hover {
  border-color: #7c3aed;
  background: #f3eeff;
}

.file-modal input[type="file"] {
  min-height: 32px;
  border: 1px solid #c9ddf6;
  border-radius: 4px;
  padding: 5px 7px;
  color: #0f172a;
  background: #f8fbff;
  font-size: 11px;
}

.button-row .danger {
  border-color: #fecaca;
  color: #b91c1c;
  background: #fff7f7;
}

.button-row .danger:hover {
  border-color: #fca5a5;
  background: #fee2e2;
}

.figure-preview {
  width: 100%;
  height: 220px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8fbff;
}

.preview-limb,
.preview-spine,
.preview-shoulder,
.preview-hip,
.preview-leg {
  fill: none;
  stroke: #1d4ed8;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.preview-spine,
.preview-shoulder,
.preview-hip {
  stroke: #60a5fa;
  stroke-width: 2.2;
}

.preview-leg {
  stroke: #16a34a;
}

.preview-head {
  fill: #dbeafe;
  stroke: #1d4ed8;
  stroke-width: 2.4;
}

.modal-header {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
}

.modal-header h2 {
  margin: 0;
  color: #0f172a;
  font-size: 14px;
  text-transform: uppercase;
}

.modal-close {
  width: 32px;
  min-height: 32px;
  padding: 0;
  border-color: var(--line);
  color: #1d4ed8;
  background: #fff;
  font-size: 18px;
  line-height: 1;
}

@media (max-width: 760px) {
  body {
    overflow: auto;
  }

  .app-shell {
    grid-template-columns: 1fr;
    height: auto;
    min-height: calc(100vh - 28px);
    overflow: visible;
  }

  .side-panel-resizer {
    display: none;
  }

  .stage-wrap {
    order: -1;
    min-height: calc(100vh - 28px);
  }

  .side-panel {
    border-right: 0;
    border-bottom: 1px solid transparent;
  }

  .side-panel::after {
    inset: auto 0 0;
    top: auto;
    width: 100%;
    height: 1px;
    left: 0;
    right: 0;
    background: linear-gradient(90deg, transparent 0, var(--line-soft) 8%, var(--line-medium) 50%, var(--line-soft) 92%, transparent 100%);
  }

  .stage-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .stage-toolbar-right {
    justify-content: space-between;
  }

  .timeline-track {
    padding-bottom: 6px;
  }

  #stage {
    width: 100%;
    height: 100%;
  }
}
