/* Compact frame/layer rail shared by the Draw and Audio animation modes. */
.animation-controls,
.animation-controls * { box-sizing: border-box; }
.animation-controls {
  position: relative;
  z-index: 18;
  min-width: 0;
  max-width: 100%;
  color: var(--creation-ink, #f4f0e4);
  font: 600 12px/1.3 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  pointer-events: auto;
}
.animation-controls [hidden] { display: none !important; }
.animation-controls__toolbar {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
  touch-action: pan-x;
}
.animation-controls__button {
  display: inline-grid;
  flex: 0 0 44px;
  place-items: center;
  width: 44px;
  min-width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  border: 1px solid var(--creation-panel-edge, #39454e);
  border-radius: 11px;
  background: var(--creation-panel, #202a33);
  color: var(--creation-ink, #f4f0e4);
  font: inherit;
  font-size: 18px;
  cursor: pointer;
  touch-action: manipulation;
}
.animation-controls__button:disabled { opacity: .48; cursor: default; }
.animation-controls__button svg { display: block; width: 22px; height: 22px; overflow: visible; }
.animation-controls__button[aria-pressed="true"],
.animation-controls__button.is-selected { border-color: var(--creation-yellow, #ffd35a); color: var(--creation-yellow, #ffd35a); }
.animation-controls__button:focus-visible,
.animation-controls__duration-input:focus-visible,
.animation-controls__fps-preset:focus-visible,
.animation-controls__rename:focus-visible { outline: 3px solid var(--creation-yellow, #ffd35a); outline-offset: 2px; }
.animation-controls__play { font-size: 16px; }
.animation-controls__export { flex-basis: 50px; width: 50px; font-size: 11px; }
.animation-controls__frames {
  display: flex;
  gap: 6px;
  max-width: 100%;
  min-width: 0;
  margin-top: 6px;
  padding: 2px 1px 6px;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
  touch-action: pan-x;
}
.animation-controls__frame {
  position: relative;
  flex: 0 0 56px;
  width: 56px;
  height: 56px;
  min-width: 56px;
  min-height: 56px;
  overflow: hidden;
  border-radius: 10px;
  background: #111920;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.animation-controls__frame[aria-selected="true"] { outline: 2px solid var(--creation-yellow, #ffd35a); outline-offset: 1px; }
.animation-controls__preview { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated; opacity: .75; pointer-events: none; }
.animation-controls__frame-number { position: absolute; z-index: 1; right: 3px; bottom: 3px; min-width: 20px; padding: 2px 4px; border-radius: 6px; background: #111d; color: #fff; text-align: center; }
.animation-controls__frame:not([aria-selected="true"]) { color: #fff; }
.animation-controls__frames.is-cel-grid {
  position: relative;
  display: grid;
  grid-template-columns: 44px repeat(var(--animation-frame-count), 44px);
  grid-auto-rows: 44px;
  gap: 0;
  width: 100%;
  max-width: 100%;
  max-height: min(132px, 20dvh);
  margin-top: 6px;
  padding: 0;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  touch-action: pan-x pan-y;
  isolation: isolate;
}
.animation-controls__grid-corner,
.animation-controls__layer-number,
.animation-controls__cel {
  display: grid;
  position: relative;
  place-items: center;
  width: 44px;
  min-width: 44px;
  height: 44px;
  min-height: 44px;
  border: 1px solid #ffffff20;
  border-radius: 0;
  font-variant-numeric: tabular-nums;
  font-size: 12px;
}
.animation-controls__grid-corner { position: sticky; z-index: 4; top: 0; left: 0; background: var(--creation-panel, #202a33); }
.animation-controls__frames.is-cel-grid .animation-controls__frame {
  position: sticky;
  z-index: 2;
  top: 0;
  flex: none;
  width: 44px;
  min-width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  border-radius: 0;
  background: #111920;
}
.animation-controls__frames.is-cel-grid .animation-controls__frame[aria-selected="true"] { outline: none; box-shadow: inset 0 -3px var(--creation-yellow, #ffd35a); }
.animation-controls__frames.is-cel-grid .animation-controls__frame-number { position: static; z-index: auto; min-width: 0; padding: 0; border-radius: 0; background: transparent; color: inherit; }
.animation-controls__layer-number { position: sticky; z-index: 3; left: 0; padding: 0; background: var(--creation-panel, #202a33); }
.animation-controls__layer-number.is-selected { color: var(--creation-yellow, #ffd35a); }
.animation-controls__frames.is-cel-grid .animation-controls__frame,
.animation-controls__frames.is-cel-grid .animation-controls__layer-number { touch-action: none; user-select: none; -webkit-user-select: none; }
#draw-animation-controls .animation-controls__frames.is-cel-grid .animation-controls__frame,
#draw-animation-controls .animation-controls__frames.is-cel-grid .animation-controls__layer-number,
#draw-animation-controls .animation-controls__frames.is-cel-grid .animation-controls__cel { border-radius: 0; }
#draw-animation-controls .animation-controls__frames.is-cel-grid .animation-controls__cel { padding: 0; border-radius: 0; background: #17212a; color: #fff; }
#draw-animation-controls .animation-controls__frames.is-cel-grid .animation-controls__cel[data-has-content="true"] { color: #c9d4db; }
#draw-animation-controls .animation-controls__frames.is-cel-grid .animation-controls__cel.is-selected,
#draw-animation-controls .animation-controls__frames.is-cel-grid .animation-controls__cel[aria-selected="true"] {
  z-index: 1;
  background: var(--creation-yellow, #ffd35a);
  color: #17212a;
  box-shadow: inset 0 0 0 2px #17212a;
}
.animation-controls__cel-mark { display: block; font-size: 13px; line-height: 1; }
.animation-controls__workspace-launcher { position: relative; }
.animation-controls__workspace-badge {
  position: absolute;
  right: 1px;
  bottom: 1px;
  padding: 0 2px;
  border-radius: 3px;
  background: var(--creation-panel, #202a33);
  color: var(--creation-yellow, #ffd35a);
  font-size: 7px;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}
.animation-controls__workspace-panel,
.animation-controls__workspace-panel * { box-sizing: border-box; }
.animation-controls__workspace-panel {
  position: fixed;
  z-index: 60;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: 44px minmax(88px, 1fr);
  gap: 4px;
  overflow: hidden;
  padding: 8px;
  border: 1px solid var(--creation-panel-edge, #52606a);
  border-radius: 16px;
  background: #202a33f5;
  color: var(--creation-ink, #f4f0e4);
  box-shadow: 0 12px 36px #0009;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 140ms ease, transform 140ms ease;
  pointer-events: none;
  font: 600 12px/1.3 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
.animation-controls__workspace-panel[hidden] { display: none !important; }
.animation-controls__workspace-panel [hidden] { display: none !important; }
.animation-controls__workspace-panel.is-open { opacity: 1; transform: translateY(0); pointer-events: auto; }
.animation-controls__workspace-heading { display: flex; align-items: center; gap: 8px; min-width: 0; }
.animation-controls__workspace-heading strong { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.animation-controls__workspace-selection { overflow: hidden; min-width: 0; margin-left: auto; color: var(--creation-muted, #b8c0c2); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.animation-controls__workspace-heading .animation-controls__button { margin-left: 0; }
.animation-controls__workspace-panel .animation-controls__toolbar { display: none; }
.animation-controls__workspace-heading .animation-controls__play { margin-left: auto; }
.animation-controls__workspace-panel .animation-controls__frames.is-cel-grid {
  height: var(--animation-workspace-grid-height, 88px);
  min-height: 0;
  max-height: var(--animation-workspace-grid-height, 88px);
}
.animation-controls__workspace-panel .animation-controls__frames.is-cel-grid .animation-controls__frame,
.animation-controls__workspace-panel .animation-controls__frames.is-cel-grid .animation-controls__layer-number,
.animation-controls__workspace-panel .animation-controls__frames.is-cel-grid .animation-controls__cel { border-radius: 0; }
.animation-controls__workspace-panel .animation-controls__frames.is-cel-grid .animation-controls__cel { padding: 0; background: #17212a; color: #fff; }
.animation-controls__workspace-panel .animation-controls__frames.is-cel-grid .animation-controls__cel.is-selected,
.animation-controls__workspace-panel .animation-controls__frames.is-cel-grid .animation-controls__cel[aria-selected="true"] {
  background: var(--creation-yellow, #ffd35a);
  color: #17212a;
  box-shadow: inset 0 0 0 2px #17212a;
}
.animation-controls__workspace-panel .animation-controls__status { position: absolute; }
.animation-controls__grid-add { z-index: 1; border-radius: 0; background: #26323b; color: var(--creation-yellow, #ffd35a); }
.animation-controls__frame-add { position: sticky; z-index: 2; top: 0; }
.animation-controls__layer-add { position: sticky; z-index: 3; left: 0; }
.animation-controls__frames.is-cel-grid .animation-controls__frame.is-lifted,
.animation-controls__frames.is-cel-grid .animation-controls__layer-number.is-lifted { z-index: 8; opacity: .72; transform: translateY(-4px) scale(1.06); box-shadow: 0 7px 14px #000a; }
.animation-controls__frames.is-cel-grid .animation-controls__frame.is-drop-target,
.animation-controls__frames.is-cel-grid .animation-controls__layer-number.is-drop-target { z-index: 7; box-shadow: inset 0 0 0 3px var(--creation-yellow, #ffd35a); }
.animation-controls__frame-menu {
  box-sizing: border-box;
  position: fixed;
  z-index: 62;
  display: flex;
  gap: 4px;
  max-width: calc(100vw - 16px);
  padding: 4px;
  border: 1px solid var(--creation-panel-edge, #52606a);
  border-radius: 13px;
  max-height: min(70dvh, 320px);
  overflow: auto;
  background: var(--creation-panel, #202a33);
  color: var(--creation-ink, #f4f0e4);
  box-shadow: 0 10px 28px #0008;
}
.animation-controls__frame-menu[hidden],
.animation-controls__layers[hidden],
.animation-controls__timing[hidden] { display: none !important; }
.animation-controls__frame-menu .animation-controls__button { background: #26323b; }
.animation-controls__frame-menu.is-cel-menu { display: flex; flex-wrap: wrap; width: min(252px, calc(100vw - 16px)); }
.animation-controls__frame-menu .animation-controls__context-action { display: grid; grid-template-rows: 20px auto; gap: 2px; flex: 1 1 64px; width: auto; min-width: 44px; height: 54px; padding: 3px; font-size: 16px; }
.animation-controls__context-label { overflow: hidden; max-width: 100%; font-size: 9px; line-height: 1.1; text-overflow: ellipsis; white-space: nowrap; }
.animation-controls__frame-menu.is-layer-menu { display: grid; grid-template-columns: repeat(2, minmax(44px, 1fr)); width: min(220px, calc(100vw - 16px)); }
.animation-controls__frame-menu.is-layer-menu .animation-controls__context-action { width: 100%; }
.animation-controls__context-rename { grid-column: 1 / -1; width: 100%; min-width: 0; height: 44px; padding: 6px 8px; border: 1px solid var(--creation-panel-edge, #52606a); border-radius: 8px; background: #141c22; color: inherit; font: inherit; }
.animation-controls__layers,
.animation-controls__timing {
  position: fixed;
  z-index: 61;
  /* Keep the close control below the fixed project selector bar. */
  top: calc(var(--creation-editor-header, 64px) + 62px + env(safe-area-inset-top, 0px));
  right: 10px;
  width: min(300px, calc(100vw - 20px));
  max-height: calc(100dvh - var(--creation-editor-header, 64px) - 62px - var(--creation-editor-bottom, 84px) - 24px);
  overflow: auto;
  overscroll-behavior: contain;
  padding: 9px;
  border: 1px solid var(--creation-panel-edge, #52606a);
  border-radius: 14px;
  background: var(--creation-panel, #202a33);
  color: var(--creation-ink, #f4f0e4);
  box-shadow: 0 12px 34px #0009;
}
.animation-controls__timing { top: auto; bottom: calc(var(--creation-editor-bottom, 84px) + 9px + env(safe-area-inset-bottom, 0px)); width: min(250px, calc(100vw - 20px)); overflow: visible; }
.animation-controls__panel-heading { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 44px; margin: 0 0 5px; background: var(--creation-panel, #202a33); font-size: 13px; font-weight: 800; }
.animation-controls__panel-heading .animation-controls__button { flex-basis: 44px; }
.animation-controls__layer-list { display: grid; gap: 5px; max-height: min(55dvh, 430px); overflow: auto; overscroll-behavior: contain; }
.animation-controls__layer { display: grid; grid-template-columns: minmax(0, 1fr) repeat(5, 44px); align-items: center; gap: 3px; min-width: 0; padding: 2px; border: 1px solid transparent; border-radius: 10px; }
.animation-controls__layer.is-selected { border-color: var(--creation-yellow, #ffd35a); background: #ffffff0b; }
.animation-controls__layer-name { display: block; overflow: hidden; min-width: 0; padding: 0 4px; border: 0; background: transparent; color: inherit; font-size: 11px; text-align: left; text-overflow: ellipsis; white-space: nowrap; }
.animation-controls__rename { grid-column: 1 / -1; grid-row: 2; width: 100%; min-width: 0; height: 44px; min-height: 44px; padding: 4px 6px; border: 1px solid var(--creation-panel-edge, #52606a); border-radius: 8px; background: #141c22; color: inherit; font: inherit; font-size: 11px; }
.animation-controls__layer .animation-controls__button { flex-basis: 44px; width: 44px; min-width: 44px; height: 44px; min-height: 44px; border-radius: 9px; font-size: 15px; }
.animation-controls__wide-button { display: flex; width: 100%; min-height: 44px; margin-top: 6px; font-size: 12px; }
.animation-controls__duration-input { width: 100%; min-height: 44px; padding: 7px 10px; border: 1px solid var(--creation-panel-edge, #52606a); border-radius: 9px; background: #141c22; color: inherit; font: inherit; font-size: 15px; font-variant-numeric: tabular-nums; }
.animation-controls__fps-preset { width: 100%; min-height: 44px; padding: 7px 10px; border: 1px solid var(--creation-panel-edge, #52606a); border-radius: 9px; background: #141c22; color: inherit; font: inherit; font-size: 14px; }
.animation-controls__unit { display: block; margin-top: 4px; color: var(--creation-muted, #b8c0c2); text-align: right; }
.animation-controls__timing-note { margin: 6px 0 0; color: var(--creation-muted, #b8c0c2); font-size: 11px; line-height: 1.45; }
.animation-controls__status { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.animation-controls.is-audio { color: var(--audio-ink, #193b4a); }
.animation-controls.is-audio .animation-controls__button { border-color: #193b4a26; background: var(--audio-paper, #fffdf8); color: var(--audio-ink, #193b4a); }
.animation-controls.is-audio .animation-controls__button[aria-pressed="true"],
.animation-controls.is-audio .animation-controls__button.is-selected { border-color: var(--audio-accent, #ce654d); color: var(--audio-ink, #193b4a); }
.animation-controls.is-audio .animation-controls__frames { scrollbar-color: #193b4a55 transparent; }
.animation-controls.is-audio .animation-controls__frame { background: #e9e7df; color: #193b4a; }
.animation-controls__layers.is-audio,
.animation-controls__timing.is-audio,
.animation-controls__frame-menu.is-audio { border-color: #193b4a26; background: var(--audio-paper, #fffdf8); color: var(--audio-ink, #193b4a); }
.animation-controls__layers.is-audio .animation-controls__button,
.animation-controls__timing.is-audio .animation-controls__button,
.animation-controls__frame-menu.is-audio .animation-controls__button { border-color: #193b4a26; background: var(--audio-paper, #fffdf8); color: var(--audio-ink, #193b4a); }
.animation-controls.is-audio .animation-controls__rename,
.animation-controls.is-audio .animation-controls__duration-input { border-color: #193b4a26; background: #fff; color: var(--audio-ink, #193b4a); }
@media (max-width: 600px) {
  .animation-controls__toolbar { gap: 4px; }
  .animation-controls__export { flex-basis: 44px; width: 44px; font-size: 10px; }
  .animation-controls__layers { top: calc(var(--creation-editor-header, 64px) + 62px + env(safe-area-inset-top, 0px)); }
  .animation-controls__layer { gap: 2px; }
}
@media (max-height: 500px) and (orientation: landscape) {
  .animation-controls__frames.is-cel-grid { max-height: min(88px, 24dvh); }
}
@media (max-width: 360px) and (orientation: portrait) {
  body.creation-editor[data-page="draw"] .creation-editor__controls { gap: 2px !important; padding: 4px !important; overflow-y: hidden !important; }
  body.creation-editor[data-page="draw"] .draw-toolbar { flex-wrap: nowrap !important; justify-content: flex-start !important; gap: 4px !important; min-width: 0; overflow-x: auto; overflow-y: hidden; touch-action: pan-x; }
  body.creation-editor[data-page="draw"] .draw-tools,
  body.creation-editor[data-page="draw"] .draw-toggles { flex: 0 0 auto; flex-wrap: nowrap !important; gap: 4px !important; }
  body.creation-editor[data-page="draw"] .draw-actions { flex-wrap: nowrap !important; justify-content: flex-start !important; gap: 4px !important; margin: 0 !important; padding: 0 !important; border-top: 0 !important; overflow-x: auto; overflow-y: hidden; touch-action: pan-x; }
  body.creation-editor[data-page="draw"] .draw-actions > *,
  body.creation-editor[data-page="draw"] #draw-animation-controls { flex: 0 0 44px; }
}
@media (max-height: 500px) and (orientation: landscape) {
  body.creation-editor[data-page="draw"] .creation-editor__controls { gap: 2px !important; padding: 4px !important; overflow-y: hidden !important; }
  body.creation-editor[data-page="draw"] .draw-toolbar { flex-wrap: nowrap !important; justify-content: flex-start !important; gap: 4px !important; min-width: 0; overflow-x: auto; overflow-y: hidden; touch-action: pan-x; }
  body.creation-editor[data-page="draw"] .draw-tools,
  body.creation-editor[data-page="draw"] .draw-toggles { flex: 0 0 auto; flex-wrap: nowrap !important; gap: 4px !important; }
  body.creation-editor[data-page="draw"] .draw-actions { flex-wrap: nowrap !important; justify-content: flex-start !important; gap: 4px !important; margin: 0 !important; padding: 0 !important; border-top: 0 !important; overflow-x: auto; overflow-y: hidden; touch-action: pan-x; }
  body.creation-editor[data-page="draw"] .draw-actions > *,
  body.creation-editor[data-page="draw"] #draw-animation-controls { flex: 0 0 44px; }
}
@media (max-width: 380px) {
  .animation-controls__toolbar { gap: 2px; }
  .animation-controls__layer { gap: 2px; }
}
@media (prefers-reduced-motion: reduce) { .animation-controls * { scroll-behavior: auto !important; transition: none !important; } }
@media (prefers-reduced-motion: reduce) { .animation-controls__workspace-panel { transition: none; } }
