/* Nova Animate — phone-first layout. Portrait: top bar / canvas / tools / frames.
   Landscape (and desktop): tools become a left rail so the canvas keeps its height. */
:root {
  --bg: #0b0b12;
  --panel: #14141d;
  --panel-2: #1c1c28;
  --line: #2a2a3a;
  --text: #ecebf7;
  --muted: #8f8eaa;
  --accent: #7DFABC;
  --accent-ink: #08080E;
  --danger: #ff6b6b;
  --stage: #0f0f17;
  --radius: 12px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); overscroll-behavior: none; }
body { font: 14px/1.4 'DM Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; -webkit-text-size-adjust: 100%; overflow: hidden; }
button, select, input, a { font: inherit; color: inherit; touch-action: manipulation; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.an-sr { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ic { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }

#an-app {
  position: fixed; inset: 0;
  height: 100vh; height: 100dvh; height: var(--an-h, 100dvh);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  grid-template-areas: "top" "stage" "tools" "frames";
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}

/* ── Top bar ── */
#an-top { grid-area: top; display: flex; align-items: center; gap: 4px; padding: 6px 8px; background: var(--panel); border-bottom: 1px solid var(--line); min-width: 0; }
.an-title { font-weight: 700; font-size: 15px; letter-spacing: .01em; white-space: nowrap; margin-left: 2px; }
.an-title span { color: var(--accent); }
.an-grow { flex: 1; min-width: 0; }
.an-ibtn { width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 10px; background: transparent; color: var(--text); text-decoration: none; flex-shrink: 0; }
.an-ibtn:active { background: var(--panel-2); }
.an-ibtn:disabled { opacity: .35; cursor: default; }
.an-primary { display: inline-flex; align-items: center; justify-content: center; height: 40px; padding: 0 16px; border: 0; border-radius: 10px; background: var(--accent); color: var(--accent-ink); font-weight: 700; text-decoration: none; flex-shrink: 0; }
.an-primary:active { filter: brightness(.9); }
.an-primary:disabled { opacity: .5; }
.an-ghost { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 8px 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); color: var(--text); font-weight: 600; text-align: center; }
.an-wide { width: 100%; min-height: 46px; }

/* ── Stage ── */
#an-stage { grid-area: stage; position: relative; overflow: hidden; background: var(--stage); touch-action: none; cursor: crosshair; min-height: 0; }
#an-world { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; box-shadow: 0 0 0 1px rgba(255,255,255,.08), 0 8px 30px rgba(0,0,0,.5); }
#an-world canvas { position: absolute; left: 0; top: 0; width: 100%; height: 100%; display: block; pointer-events: none; }
#an-world.playing .an-frame, #an-world.playing .an-trace { visibility: hidden; }
#an-onion-btn { position: absolute; right: 8px; top: 8px; }
#an-move-chip { position: absolute; right: 8px; top: 48px; }
#an-fit { position: absolute; right: 8px; top: 88px; }
#an-trace-chip { position: absolute; left: 8px; top: 48px; }
#an-cam-chip { position: absolute; left: 8px; top: 88px; }
#an-cam-chip[hidden] { display: none; }
#an-world.camview { overflow: hidden; }
@media (max-width: 399px) { #an-trace-chip, #an-cam-chip { width: 32px; padding: 0; justify-content: center; } #an-trace-chip span, #an-cam-chip span { display: none; } }
.an-chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
#an-layer-chip { position: absolute; left: 8px; top: 8px; max-width: calc(100% - 118px); }
#an-layer-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.an-chip { display: inline-flex; align-items: center; gap: 4px; height: 32px; padding: 0 10px; border: 1px solid var(--line); border-radius: 16px; background: rgba(20,20,29,.9); color: var(--text); font-size: 12px; font-weight: 600; }
.an-chip .ic { width: 15px; height: 15px; }
#an-toast { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); max-width: calc(100% - 24px); padding: 8px 14px; border-radius: 18px; background: rgba(28,28,40,.96); border: 1px solid var(--line); font-size: 13px; text-align: center; pointer-events: none; z-index: 5; }

/* ── Tools ── */
#an-tools { grid-area: tools; display: flex; gap: 4px; padding: 6px 8px; background: var(--panel); border-top: 1px solid var(--line); }
.an-tool { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; height: 54px; padding: 4px 1px; border: 1px solid transparent; border-radius: 10px; background: transparent; color: var(--muted); font-size: 11px; font-weight: 600; }
.an-tool[aria-pressed="true"] { color: var(--accent-ink); background: var(--accent); }
.an-tool:not([aria-pressed="true"]):active { background: var(--panel-2); }
#an-color-dot { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--text); background: #1b1b1f; display: block; }

/* ── Frames ── */
#an-frames { grid-area: frames; background: var(--panel); border-top: 1px solid var(--line); padding: 6px 8px 8px; min-width: 0; }
#an-actions { display: flex; gap: 4px; }
.an-fbtn { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; height: 46px; padding: 2px 0; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); color: var(--text); font-size: 10px; font-weight: 600; white-space: nowrap; overflow: hidden; }
.an-fbtn .ic { width: 20px; height: 20px; }
.an-fbtn:active { background: var(--line); }
.an-fbtn:disabled { opacity: .35; }
.an-playbtn { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.an-playbtn:active { background: var(--accent); filter: brightness(.9); }
#an-info { display: flex; align-items: center; gap: 6px; padding: 6px 2px 4px; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.an-dot { opacity: .5; }
.an-fps select { appearance: none; -webkit-appearance: none; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 0 12px; min-height: 34px; color: var(--text); font-size: 13px; font-weight: 600; }
#an-strip { position: relative; display: flex; gap: 6px; overflow-x: auto; overflow-y: hidden; padding: 2px 2px 4px; scroll-snap-type: none; -webkit-overflow-scrolling: touch; touch-action: pan-x; scrollbar-width: thin; }
.an-fr { position: relative; flex: 0 0 auto; padding: 0; border: 2px solid var(--line); border-radius: 8px; background: #fff; overflow: hidden; display: block; line-height: 0; }
.an-fr canvas { display: block; height: 56px; width: auto; max-width: 112px; }
.an-fr[aria-selected="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(125,250,188,.25); }
.an-fr .n { position: absolute; left: 0; bottom: 0; padding: 1px 5px; border-top-right-radius: 6px; background: rgba(8,8,14,.85); color: var(--text); font-size: 10px; font-weight: 700; line-height: 1.4; }
.an-fr .h { position: absolute; right: 0; top: 0; padding: 1px 5px; border-bottom-left-radius: 6px; background: var(--accent); color: var(--accent-ink); font-size: 10px; font-weight: 700; line-height: 1.4; }

/* ── Sheets ── */
#an-sheets { position: fixed; inset: 0; z-index: 50; }
#an-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.55); }
.an-sheet { position: absolute; left: 0; right: 0; bottom: 0; max-height: 88vh; max-height: 88dvh; overflow-y: auto; background: var(--panel); border-radius: 18px 18px 0 0; border-top: 1px solid var(--line); padding: 14px 16px calc(18px + env(safe-area-inset-bottom)); overscroll-behavior: contain; }
.an-sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.an-sheet-head h2 { margin: 0; font-size: 17px; }
.an-x { width: 40px; height: 40px; border: 0; border-radius: 10px; background: var(--panel-2); font-size: 16px; }
.an-label { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; margin: 4px 0 8px; }
.an-hint { color: var(--muted); font-size: 13px; margin: 8px 0; text-align: center; }
.an-warn { color: var(--danger); font-size: 13px; margin: 10px 0; text-align: center; }
.an-row { display: flex; gap: 8px; margin-bottom: 8px; }
.an-row > * { flex: 1; }

.an-swatches { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; margin-bottom: 14px; }
.an-sw { aspect-ratio: 1; min-height: 44px; border-radius: 50%; border: 2px solid var(--line); padding: 0; }
.an-swatches .an-sw { min-height: 0; width: 100%; min-width: 0; }
.an-sw[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(125,250,188,.3); }
.an-custom { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); }
.an-custom input { width: 56px; height: 36px; padding: 0; border: 0; background: transparent; }

.an-sizeprev { height: 84px; display: flex; align-items: center; justify-content: center; background: #fff; border-radius: 12px; margin-bottom: 12px; overflow: hidden; }
@media (max-width: 430px) { .an-tool { font-size: 9.5px; } }
@media (max-width: 400px) { #an-tools { gap: 1px; padding: 6px 2px; } .an-tool { font-size: 9.5px; padding: 4px 0; border-width: 0; } .an-tool span { max-width: 100%; overflow: hidden; text-overflow: clip; white-space: nowrap; } }
@media (max-width: 355px) { .an-tool span { display: none; } }
.an-size-label { display: flex; justify-content: space-between; margin-top: 14px; }
.an-size-label b { color: var(--text); font-variant-numeric: tabular-nums; }
#an-size-dot { display: block; border-radius: 50%; background: #1b1b1f; }
#an-size-range, #an-smooth-range { width: 100%; height: 36px; accent-color: var(--accent); }

.an-bgs { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.an-bgs .an-sw { width: 44px; flex: 0 0 44px; }
.an-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.an-list button, .an-list a { display: flex; align-items: center; min-height: 48px; padding: 0 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); color: var(--text); text-decoration: none; text-align: left; }
.an-list button:active, .an-list a:active { background: var(--line); }
.an-list button { gap: 10px; }
.an-list button em { margin-left: auto; font-style: normal; color: var(--accent); font-size: 12px; font-weight: 700; }
.an-tips { color: var(--muted); font-size: 13px; }
.an-tips b { color: var(--text); }
.an-tips ul { margin: 6px 0 0; padding-left: 18px; }
.an-tips li { margin-bottom: 4px; }

.an-presets { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 10px; }
.an-preset { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; min-height: 104px; padding: 10px; border: 2px solid var(--line); border-radius: 12px; background: var(--panel-2); color: var(--text); font-weight: 600; font-size: 13px; }
.an-preset i { display: block; background: #fff; border-radius: 3px; }
.an-preset small { color: var(--muted); font-weight: 400; }
.an-preset[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(125,250,188,.2); }

.an-ghost { gap: 4px; }
#an-ex-sound { margin-bottom: 8px; }
.an-sounds { display: flex; flex-direction: column; gap: 10px; margin: 12px 0 4px; }
.an-snd { padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel-2); }
.an-snd-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.an-snd-head .ic { color: var(--accent); }
.an-snd-name { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.an-snd-len { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; flex-shrink: 0; }
.an-snd-del { width: 36px; height: 36px; flex-shrink: 0; border: 0; border-radius: 10px; background: transparent; color: var(--danger); }
.an-snd-del:active { background: var(--line); }
.an-snd-row { display: flex; align-items: center; gap: 10px; min-height: 40px; }
.an-snd-row > span:first-child { width: 64px; flex-shrink: 0; color: var(--muted); font-size: 12px; }
.an-snd-row input[type="range"] { flex: 1; min-width: 0; height: 32px; accent-color: var(--accent); }
.an-snd-val { width: 46px; text-align: right; font-variant-numeric: tabular-nums; font-size: 12px; flex-shrink: 0; }
.an-step { display: flex; align-items: center; gap: 6px; }
.an-step button { width: 40px; height: 36px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); font-size: 18px; line-height: 1; }
.an-step button:active { background: var(--line); }
.an-step output { min-width: 56px; text-align: center; font-variant-numeric: tabular-nums; font-weight: 600; }
.an-check { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 2px; }
.an-check input { width: 22px; height: 22px; accent-color: var(--accent); flex-shrink: 0; }
.an-snd-row .an-check { min-height: 40px; }
#an-rec.recording { background: var(--danger); border-color: var(--danger); color: #fff; }
#an-rec.recording .ic { animation: an-pulse 1s infinite; }
@keyframes an-pulse { 50% { opacity: .35; } }
.an-layers { display: flex; flex-direction: column; gap: 8px; margin: 12px 0 8px; }
.an-lyr { border: 1px solid var(--line); border-radius: 12px; background: var(--panel-2); overflow: hidden; }
.an-lyr[aria-current="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(125,250,188,.2); }
.an-lyr-main { display: flex; align-items: center; gap: 2px; padding: 4px; }
.an-lyr-ic { width: 44px; height: 44px; flex-shrink: 0; border: 0; border-radius: 10px; background: transparent; color: var(--text); display: inline-flex; align-items: center; justify-content: center; }
.an-lyr-ic:active { background: var(--line); }
.an-lyr-ic[aria-pressed="false"][data-act="vis"] { color: var(--muted); }
.an-lyr-ic[aria-pressed="true"][data-act="lock"] { color: var(--accent); }
.an-lyr-name { flex: 1; min-width: 0; min-height: 44px; padding: 0 8px; border: 0; background: transparent; color: var(--text); text-align: left; display: flex; flex-direction: column; justify-content: center; }
.an-lyr-name b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.an-lyr-name small { color: var(--muted); font-size: 11px; }
.an-lyr-more { padding: 4px 10px 10px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.an-lyr-more .an-snd-row { min-height: 36px; }
.an-lyr-more input[type="text"] { flex: 1; min-width: 0; height: 38px; padding: 0 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--text); font: inherit; user-select: text; -webkit-user-select: text; }
.an-lyr-acts { display: flex; gap: 6px; }
.an-lyr-acts button { flex: 1; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 4px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--text); font-size: 13px; font-weight: 600; }
.an-lyr-acts button:active { background: var(--line); }
.an-lyr-acts button:disabled { opacity: .35; }
.an-lyr-acts button[data-act="del"] { color: var(--danger); }
.an-shapegrid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-bottom: 12px; }
.an-shp { aspect-ratio: 1; min-height: 52px; display: flex; align-items: center; justify-content: center; padding: 0; border: 2px solid var(--line); border-radius: 12px; background: var(--panel-2); }
.an-shp canvas { width: 70%; height: 70%; display: block; }
.an-shp[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(125,250,188,.25); }
.an-shp:active { background: var(--line); }
.an-seg { display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin-bottom: 4px; }
.an-seg button { flex: 1; min-height: 44px; border: 0; background: var(--panel-2); color: var(--muted); font-weight: 600; }
.an-seg button + button { border-left: 1px solid var(--line); }
.an-seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.an-tabs { display: flex; gap: 6px; overflow-x: auto; margin: 12px 0 8px; padding-bottom: 2px; scrollbar-width: none; }
.an-tabs::-webkit-scrollbar { display: none; }
.an-tab { flex: 0 0 auto; min-height: 40px; padding: 0 14px; border: 1px solid var(--line); border-radius: 20px; background: var(--panel-2); color: var(--muted); font-weight: 600; font-size: 13px; }
.an-tab[aria-selected="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.an-stickergrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 6px; max-height: 40vh; max-height: 40dvh; overflow-y: auto; overscroll-behavior: contain; }
.an-stk { aspect-ratio: 1; min-height: 48px; border: 0; border-radius: 10px; background: transparent; font-size: 30px; line-height: 1; padding: 0; font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif; }
.an-stk:active { background: var(--line); }
.an-stickergrid.chars { grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 8px; }
.an-chr { font-size: 0; min-height: 72px; padding: 4px; background: #fff; border-radius: 12px; }
.an-chr img { width: 100%; height: 100%; object-fit: contain; display: block; pointer-events: none; }
.an-chr:active { background: #e6e6f0; }
.an-depth { display: flex; align-items: center; gap: 8px; margin: 8px 0; }
.an-depth > span { flex: 0 0 auto; width: 52px; font-size: 13px; color: var(--muted); }
.an-depth .an-seg { flex: 1 1 auto; min-width: 0; }
.an-depth .an-seg button { font-size: 12px; padding: 0 2px; min-width: 0; }
.an-cam-acts { margin-top: 10px; }
.an-talkgrid { grid-template-columns: repeat(3, 1fr); }
.an-tstyle canvas { width: 72px; height: 45px; background: #f3d8b0; border-radius: 8px; }
.an-tstyle[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.an-voices { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.an-voice { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 48px; padding: 0 14px; border: 2px solid var(--line); border-radius: 12px; background: var(--panel-2); color: var(--text); text-align: left; }
.an-voice[aria-pressed="true"] { border-color: var(--accent); }
.an-voice b { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.an-voice small { color: var(--muted); font-size: 12px; flex: 0 0 auto; }
.an-artgrid .an-chr { position: relative; }
.an-animgrid .an-chr span { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; text-align: center; line-height: 1.15; min-height: 24px; }
.an-tpl-label { margin-top: 16px; }
.an-tpls { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.an-tpl { display: flex; flex-direction: column; align-items: flex-start; justify-content: flex-start; gap: 3px; min-height: 96px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel-2); color: var(--text); text-align: left; }
.an-tpl i { font-style: normal; font-size: 26px; line-height: 1; margin-bottom: 4px; font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif; }
.an-tpl b { font-size: 14px; }
.an-tpl small { color: var(--muted); font-size: 12px; line-height: 1.25; }
.an-tpl:active { background: var(--line); }
.an-badge { position: absolute; right: 5px; top: 5px; width: 18px; height: 18px; border-radius: 9px; background: var(--accent); color: var(--accent-ink); font-size: 8px; font-style: normal; display: flex; align-items: center; justify-content: center; line-height: 1; padding-left: 1px; }
.an-ex-zipinfo { margin: 8px 0 12px; padding: 16px; border: 1px dashed var(--line); border-radius: 12px; text-align: center; font-size: 14px; color: var(--text); }
#an-ex-img { display: block; max-width: 100%; max-height: 40vh; max-height: 40dvh; margin: 0 auto 8px; border-radius: 10px; background: #fff; }
#an-ex-fmt, #an-ex-gifsize { margin-bottom: 6px; }
.an-liblist { display: flex; flex-direction: column; gap: 10px; max-height: 52vh; max-height: 52dvh; overflow-y: auto; overscroll-behavior: contain; margin-bottom: 8px; }
.an-anim { border: 1px solid var(--line); border-radius: 12px; background: var(--panel-2); overflow: hidden; }
.an-anim[data-cur="1"] { border-color: var(--accent); }
.an-anim-open { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 64px; padding: 8px 12px; border: 0; background: transparent; color: var(--text); text-align: left; }
.an-anim-open:active { background: var(--line); }
.an-anim-th { flex: 0 0 auto; display: flex; align-items: center; justify-content: center; width: 84px; height: 52px; border-radius: 8px; background: #fff; overflow: hidden; }
.an-anim-th img { max-width: 100%; max-height: 100%; display: block; pointer-events: none; }
.an-anim-t { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.an-anim-t b { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.an-anim-t small { color: var(--muted); font-size: 12px; }
.an-anim[data-cur="1"] .an-anim-t small { color: var(--accent); }
.an-anim-acts { display: flex; align-items: center; gap: 6px; padding: 0 8px 8px; }
.an-anim-acts button { flex: 1 1 0; min-height: 44px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--text); font-weight: 600; font-size: 13px; }
.an-anim-acts button[data-act="del"] { color: var(--danger); }
.an-anim-acts button.danger { background: var(--danger); border-color: var(--danger); color: #1a0505; }
.an-anim-acts button:active { filter: brightness(.9); }
.an-anim-name { flex: 2 1 0; min-width: 0; min-height: 44px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--text); font: inherit; font-size: 16px; user-select: text; -webkit-user-select: text; }
.an-anim-name:focus { outline: 2px solid var(--accent); outline-offset: 0; }
.an-anim-q { flex: 2 1 0; font-size: 13px; color: var(--danger); line-height: 1.25; }
#an-art-q { width: 100%; min-height: 46px; padding: 0 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel-2); color: var(--text); font: inherit; font-size: 16px; -webkit-appearance: none; appearance: none; user-select: text; -webkit-user-select: text; }
#an-art-q:focus { outline: 2px solid var(--accent); outline-offset: 0; }
.an-artgrid { max-height: 42vh; max-height: 42dvh; }
.an-artgrid .an-chr { display: flex; flex-direction: column; align-items: center; justify-content: flex-start; min-height: 0; aspect-ratio: auto; padding: 6px 4px 4px; gap: 2px; }
.an-artgrid .an-chr img { aspect-ratio: 1; height: auto; }
.an-artgrid .an-chr span { font-size: 10.5px; line-height: 1.15; color: #4a4a60; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-weight: 600; }
.an-art-cta { margin-bottom: 8px; border-color: var(--accent); color: var(--accent); }
.an-scenegrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; max-height: 44vh; max-height: 44dvh; overflow-y: auto; overscroll-behavior: contain; }
.an-scenegrid[data-shape="tall"] { grid-template-columns: repeat(4, 1fr); }
.an-scn { display: flex; flex-direction: column; gap: 4px; padding: 0; border: 0; background: transparent; color: var(--muted); font-size: 11px; font-weight: 600; text-align: center; min-width: 0; }
.an-scn canvas { width: 100%; height: auto; display: block; border-radius: 8px; border: 1px solid var(--line); }
.an-scn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.an-scn:active canvas { border-color: var(--accent); }
#sheet-scenes .an-seg { margin-bottom: 4px; }

/* the sticker being placed: controls float over the bottom of the canvas */
#an-float-bar, #an-path-bar { position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); width: max-content; display: flex; gap: 4px; padding: 5px; border: 1px solid var(--line); border-radius: 16px; background: rgba(20,20,29,.96); z-index: 6; max-width: calc(100% - 12px); }
#an-float-bar button, #an-path-bar button { width: 42px; flex: 0 1 auto; min-width: 30px; height: 44px; border: 0; border-radius: 12px; background: transparent; color: var(--text); display: inline-flex; align-items: center; justify-content: center; }
#an-float-bar button:active, #an-path-bar button:active { background: var(--line); }
#an-float-bar button.ok, #an-path-bar button.ok { background: var(--accent); color: var(--accent-ink); }
#an-path-bar button:disabled { opacity: .4; }
#an-path-bar button.ok:disabled { background: transparent; color: var(--muted); }
#an-float-bar button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
/* Draw a path: a line of words over the bottom of the canvas says what to do, and the entry in the Move sheet */
#an-path-hint { position: absolute; left: 50%; bottom: 68px; transform: translateX(-50%); width: max-content; max-width: calc(100% - 24px); margin: 0; padding: 6px 12px; border-radius: 16px; background: rgba(28,28,40,.96); border: 1px solid var(--line); font-size: 13px; text-align: center; pointer-events: none; z-index: 5; }
#an-path-hint[hidden], #an-path-bar[hidden] { display: none; }
.an-bigbtn { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 60px; margin: 2px 0 12px; padding: 8px 14px; border: 1px solid var(--accent); border-radius: 12px; background: var(--panel-2); color: var(--text); text-align: left; }
.an-bigbtn:active { background: var(--line); }
.an-bigbtn i { font-style: normal; font-size: 26px; line-height: 1; flex-shrink: 0; font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif; }
.an-bigbtn span { min-width: 0; }
.an-bigbtn b { display: block; font-size: 15px; }
.an-bigbtn small { display: block; color: var(--muted); font-size: 12px; font-weight: 400; margin-top: 2px; }
#an-path-with .an-mv[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
#an-path-speed button { font-size: 13px; padding: 0 4px; min-width: 0; }
#an-path-speed button:disabled { opacity: .4; }
.an-path-actions { display: grid; grid-template-columns: 1fr 1.5fr; gap: 8px; margin-top: 12px; position: sticky; bottom: 0; z-index: 1; padding: 10px 0 calc(4px + env(safe-area-inset-bottom, 0px)); background: var(--panel); box-shadow: 0 -10px 12px -10px rgba(0,0,0,.5); }
.an-path-actions .an-ghost, .an-path-actions .an-primary { min-height: 46px; height: auto; }
.an-sel-actions { margin-top: 12px; }
.an-sel-actions .an-ghost:disabled { opacity: .4; }
.an-textprev { height: 96px; display: flex; align-items: center; justify-content: center; background: #fff; border-radius: 12px; margin-bottom: 10px; overflow: hidden; padding: 6px; }
.an-textprev canvas { max-width: 100%; max-height: 100%; display: block; }
#an-text-input { width: 100%; min-height: 64px; resize: none; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel-2); color: var(--text); font: inherit; font-size: 16px; line-height: 1.35; user-select: text; -webkit-user-select: text; }
#an-text-input:focus { outline: 2px solid var(--accent); outline-offset: 0; }
#an-fonts { display: grid; grid-template-columns: repeat(3, 1fr); overflow: visible; }
#an-fonts .an-tab { font-size: 15px; min-height: 44px; min-width: 0; padding: 0 6px; }
.an-seg-3 { margin-top: 12px; }
.an-seg-3 button { min-width: 0; font-size: 17px; }
#an-text-size { width: 100%; height: 36px; accent-color: var(--accent); }
#an-text-swatches { margin-bottom: 4px; }
.an-trace-name { margin: 12px 0 0; overflow-wrap: anywhere; }
#sheet-trace input[type="range"] { width: 100%; height: 36px; accent-color: var(--accent); }
#sheet-trace .an-seg + .an-label { margin-top: 14px; }
#sheet-trace .an-seg button { font-size: 13px; padding: 0 6px; }
.an-trace-actions { margin-top: 10px; }
.an-sticky { position: sticky; bottom: 0; margin: 10px -16px calc(-18px - env(safe-area-inset-bottom)); padding: 10px 16px calc(14px + env(safe-area-inset-bottom)); background: var(--panel); border-top: 1px solid var(--line); }
.an-bar { height: 10px; border-radius: 5px; background: var(--panel-2); overflow: hidden; margin: 8px 0; }
.an-bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .15s; }
#an-ex-video { width: 100%; max-height: 40vh; max-height: 40dvh; background: #000; border-radius: 10px; margin-bottom: 4px; }

/* ── Landscape phones and desktop: tools on the left ── */
@media (orientation: landscape) and (min-width: 560px) {
  #an-app {
    grid-template-columns: 68px minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) auto;
    grid-template-areas: "top top" "tools stage" "frames frames";
  }
  #an-tools { flex-direction: column; justify-content: flex-start; overflow-y: auto; border-top: 0; border-right: 1px solid var(--line); padding: 6px 4px; }
  .an-tool { flex: 0 0 auto; height: 54px; }
  #an-frames { display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "actions strip" "info strip"; column-gap: 10px; align-items: center; }
  #an-actions { grid-area: actions; width: min(440px, 52vw); }
  #an-info, #an-frames #an-selbar { grid-area: info; padding: 2px 2px 0; }
  #an-strip { grid-area: strip; }
}
@media (orientation: landscape) and (max-height: 520px) {
  /* Short screens: two columns of tools so all six fit without scrolling. */
  #an-app { grid-template-columns: 132px minmax(0, 1fr); }
  #an-tools { display: grid; grid-template-columns: 1fr 1fr; align-content: start; gap: 4px; }
  #an-top { padding: 3px 8px; }
  .an-ibtn, .an-primary { height: 36px; }
  .an-ibtn { width: 36px; }
  .an-fbtn { height: 40px; }
  .an-fr canvas { height: 44px; }
  .an-tool { height: 46px; }
  .an-sheet { max-width: 520px; left: 50%; right: auto; transform: translateX(-50%); width: 100%; }
}
/* Wide screens: sheets float in the middle instead of spanning the width. */
@media (min-width: 700px) {
  .an-sheet { left: 50%; right: auto; width: 460px; transform: translateX(-50%); border-radius: 18px 18px 0 0; }
}
@media (max-width: 400px) {
  .an-nova { display: none; }
  .an-primary { padding: 0 12px; }
}
@media (max-width: 359px) {
  .an-title { display: none; }
  .an-fbtn span { display: none; }
  .an-fbtn { height: 42px; }
}

/* ── several frames at once ── */
.an-fsel-btn { margin-left: auto; height: 34px; padding: 0 10px; }
#an-selbar { display: flex; align-items: center; gap: 6px; padding: 6px 2px 4px; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
#an-selbar[hidden] { display: none; }
#an-selbar .an-chip { height: 34px; padding: 0 12px; flex: 0 0 auto; }
#an-selbar .an-chip:disabled { opacity: .4; }
#an-selbar .an-chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
#an-fm-count { color: var(--text); font-weight: 700; white-space: nowrap; }
#an-fm-hint { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.an-fr .ck { position: absolute; left: 3px; top: 3px; width: 20px; height: 20px; border-radius: 50%; border: 2px solid rgba(255,255,255,.9); background: rgba(8,8,14,.55); color: var(--accent-ink); font-size: 13px; font-weight: 800; line-height: 16px; text-align: center; box-shadow: 0 0 0 1px rgba(0,0,0,.4); }
.an-fr[data-pick="1"] { border-color: var(--accent); }
.an-fr[data-pick="1"] .ck { background: var(--accent); border-color: var(--accent); }
.an-fr[data-pick="0"] canvas { opacity: .72; }
.an-fr.lift { transform: scale(1.08); box-shadow: 0 6px 18px rgba(0,0,0,.55); z-index: 2; }
.an-drop { position: absolute; top: 2px; bottom: 6px; width: 4px; margin-left: 0; border-radius: 2px; background: var(--accent); box-shadow: 0 0 6px rgba(125,250,188,.8); pointer-events: none; }
@media (max-width: 380px) { .an-fsel-btn span { display: none; } .an-fsel-btn { padding: 0 9px; } #an-fm-hint { display: none; } #an-selbar { gap: 4px; } #an-selbar .an-chip { padding: 0 8px; } }

/* ── make it move ── */
.an-movegrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 8px; }
.an-mv { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 68px; padding: 6px 2px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel-2); color: var(--text); font-size: 11px; font-weight: 600; min-width: 0; }
.an-mv i { font-style: normal; font-size: 24px; line-height: 1; font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif; }
.an-mv span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.an-mv:active { background: var(--line); }
.an-move-intro { text-align: left; margin-top: 0; }
#sheet-move .an-seg button, #sheet-fx .an-seg button { font-size: 13px; padding: 0 4px; }
#an-tx-how button, #an-tx-stay button { font-size: 12.5px; padding: 0 2px; min-width: 0; }
@media (max-width: 340px) { .an-movegrid { grid-template-columns: repeat(3, 1fr); } }

/* sound library */
.an-sfx-open { margin: 8px 0 4px; }
.an-sfx-sub { color: var(--muted); font-size: 12px; font-weight: 500; }
.an-sfxlist { display: flex; flex-direction: column; gap: 6px; margin: 6px 0 12px; }
.an-sfxrow { display: flex; align-items: center; gap: 8px; min-height: 52px; padding: 4px 6px 4px 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel-2); }
.an-sfx-ico { font-size: 22px; width: 30px; text-align: center; flex-shrink: 0; }
.an-sfx-name { flex: 1; min-width: 0; font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.an-sfx-name small { display: block; color: var(--muted); font-weight: 500; font-size: 11px; }
.an-sfxrow button { min-height: 44px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--text); font-weight: 600; font-size: 13px; flex-shrink: 0; }
.an-sfx-play { width: 44px; }
.an-sfx-play[aria-pressed="true"] { background: var(--accent) !important; border-color: var(--accent) !important; color: var(--accent-ink) !important; }
.an-sfx-add { padding: 0 14px; background: var(--accent) !important; border-color: var(--accent) !important; color: var(--accent-ink) !important; }
.an-sfxrow button:disabled { opacity: .5; }

/* share */
.an-sh-label { margin-top: 18px; }
.an-sh-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 8px; }
.an-sh-grid .an-ghost { display: flex; align-items: center; justify-content: center; min-height: 48px; text-decoration: none; }

/* assistant */
.an-new-assist { margin-top: 10px; }
.an-as-log { display: flex; flex-direction: column; gap: 8px; max-height: 42vh; max-height: 42dvh; min-height: 120px; overflow-y: auto; padding: 2px 2px 8px; overscroll-behavior: contain; }
.an-as-msg { max-width: 88%; padding: 10px 13px; border-radius: 14px; font-size: 14px; line-height: 1.4; white-space: pre-line; overflow-wrap: anywhere; }
.an-as-msg.bot { align-self: flex-start; background: var(--panel-2); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.an-as-msg.user { align-self: flex-end; background: var(--accent); color: var(--accent-ink); border-bottom-right-radius: 4px; font-weight: 600; }
.an-as-card { align-self: stretch; padding: 12px; border: 1px solid var(--accent); border-radius: 14px; background: var(--panel-2); }
.an-as-card.done { border-color: var(--line); opacity: .6; }
.an-as-card-h { font-weight: 700; font-size: 13px; color: var(--accent); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .04em; }
.an-as-card ul { margin: 0 0 8px; padding-left: 18px; font-size: 14px; line-height: 1.5; }
.an-as-card .an-row { margin-top: 8px; }
.an-as-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0; }
.an-as-chip { min-height: 40px; padding: 0 14px; border: 1px solid var(--line); border-radius: 20px; background: var(--panel-2); color: var(--text); font-size: 13px; font-weight: 600; text-align: left; }
.an-as-chip:active { background: var(--line); }
.an-as-form { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.an-as-form textarea { flex: 1; min-width: 0; min-height: 46px; max-height: 120px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 23px; background: var(--panel-2); color: var(--text); font: inherit; font-size: 16px; line-height: 20px; resize: none; overflow-y: auto; }
.an-as-form { align-items: flex-end; }
.an-as-card ul { max-height: 34vh; overflow-y: auto; }
.an-as-ico { width: 46px; height: 46px; flex-shrink: 0; border: 1px solid var(--line); border-radius: 50%; background: var(--panel-2); color: var(--text); font-size: 13px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.an-as-ico[hidden] { display: none; }
.an-as-ico[aria-pressed="true"] { background: var(--danger); border-color: var(--danger); color: #fff; }
.an-as-go { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.an-as-go:disabled { opacity: .5; }
@media (max-height: 700px) { .an-as .an-hint { display: none; } .an-as-log { max-height: 50vh; max-height: 50dvh; } }

/* Smart mode switch in the assistant header */
.an-as-smart { margin-left: auto; margin-right: 8px; min-height: 36px; padding: 0 12px; border: 1px solid var(--line); border-radius: 18px; background: var(--panel-2); color: var(--muted); font-size: 13px; font-weight: 700; }
.an-as-smart[hidden] { display: none; }
.an-as-smart[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* While a saved animation is being opened its layers and frames are not there yet, so the screen takes no touches for that moment (the page starts
   this way, in its markup; animate.js lifts it). Only the way back to the editor stays. */
#an-app.an-loading * { pointer-events: none; }
#an-app.an-loading #an-back { pointer-events: auto; }

/* ── Soft screens ──
   Sheets rise and fade in (the same as Forms and Audio); the backdrop, the toast and the floating bars fade in; buttons and tools ease between
   their states and give a little when pressed. Only translate, scale, opacity and colours move (the separate `translate` and `scale` properties, so
   they never fight with the transform a sheet or the toast already has to sit in the middle), nothing on the page re-flows. Leaving is instant, so
   a tap right after a sheet closes is never lost. With "reduce motion" on, nothing moves. */
.an-sheet { animation: an-rise .18s ease-out; }
@keyframes an-rise { from { translate: 0 24px; opacity: 0; } to { translate: 0 0; opacity: 1; } }
#an-backdrop { animation: an-fade .18s ease-out; }
@keyframes an-fade { from { opacity: 0; } to { opacity: 1; } }
#an-toast, #an-path-hint { animation: an-pop .16s ease-out; }
@keyframes an-pop { from { translate: 0 8px; opacity: 0; } to { translate: 0 0; opacity: 1; } }
#an-float-bar, #an-path-bar { animation: an-pop .16s ease-out; }
.an-ibtn, .an-primary, .an-ghost, .an-tool, .an-fbtn, .an-chip, .an-x, .an-sw, .an-seg button, .an-mv, #an-float-bar button, #an-path-bar button { transition: background-color .12s ease, border-color .12s ease, color .12s ease, box-shadow .12s ease, opacity .12s ease, filter .12s ease, scale .1s ease; }
.an-fr { transition: border-color .12s ease, box-shadow .12s ease, transform .12s ease; }
.an-playing .an-fr { transition: none; }                 /* while it plays the frame strip follows the picture at once */
.an-tool:active, .an-fbtn:active, .an-chip:active, .an-mv:active, .an-sw:active { scale: .95; }
@media (prefers-reduced-motion: reduce) {
  .an-sheet, #an-backdrop, #an-toast, #an-path-hint, #an-float-bar, #an-path-bar { animation: none; }
  .an-ibtn, .an-primary, .an-ghost, .an-tool, .an-fbtn, .an-chip, .an-x, .an-sw, .an-seg button, .an-mv, #an-float-bar button, #an-path-bar button, .an-fr { transition: none; }
  .an-tool:active, .an-fbtn:active, .an-chip:active, .an-mv:active, .an-sw:active { scale: none; }
}

/* ── What is new: the site announcement, the New labels, the What's new sheet and the idea of the day ── */
#an-menu-btn { position: relative; }
.an-pip { position: absolute; top: 6px; right: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px var(--panel); pointer-events: none; }
.an-newpill, .an-list button em.an-newpill { margin-left: auto; padding: 2px 8px; border-radius: 10px; background: var(--accent); color: var(--accent-ink); font-style: normal; font-size: 11px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.an-list a { gap: 10px; }
#an-move-chars { position: relative; }
#an-move-chars .an-newpill { position: absolute; right: 0; top: -2px; margin: 0; }
#an-move-chars.an-hasnew .an-label { padding-right: 56px; }

/* The announcement written in the admin dashboard, as a card at the top of the Menu and of the New animation sheet (it is never pushed into a sheet that is open). */
.an-ann { --an-tone: #8b7bff; display: flex; align-items: flex-start; gap: 8px; margin: 0 0 12px; padding: 10px 4px 10px 12px; border: 1px solid var(--line); border-left: 4px solid var(--an-tone); border-radius: 10px; background: var(--panel-2); font-size: 14px; line-height: 1.4; }
.an-ann[data-tone="success"] { --an-tone: var(--accent); }
.an-ann[data-tone="warn"] { --an-tone: #E8A33D; }
.an-ann-text { flex: 1 1 auto; min-width: 0; padding-top: 2px; overflow-wrap: anywhere; user-select: text; -webkit-user-select: text; }
.an-ann-text a { margin-left: 6px; color: var(--text); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; white-space: nowrap; }
.an-ann-x { flex: 0 0 auto; width: 44px; height: 44px; margin: -8px 0 -8px 0; border: 0; border-radius: 10px; background: transparent; color: var(--muted); font-size: 20px; line-height: 1; }
.an-ann-x:active { background: var(--line); }

/* What's new */
.an-news-pic { margin: 0 0 12px; border-radius: 12px; overflow: hidden; background: var(--panel-2); line-height: 0; }
.an-news-pic img { display: block; width: 100%; height: auto; aspect-ratio: 8 / 5; object-fit: cover; }
@media (max-height: 520px) { .an-news-pic img { max-height: 34vh; max-height: 34dvh; object-fit: contain; } }
.an-news-title { margin: 0 0 6px; font-size: 17px; line-height: 1.3; }
.an-news-line { margin: 0 0 8px; color: var(--muted); font-size: 14px; line-height: 1.45; }
#an-news-try { margin-top: 6px; }
#an-news-wa { margin-top: 8px; text-decoration: none; }
.an-stk-news { margin: 8px 0 10px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); color: var(--text); text-align: left; }

/* The idea of the day, under "Or describe it" */
.an-idea { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "label go" "text go"; align-items: center; column-gap: 10px; width: 100%; min-height: 56px; margin-top: 8px; padding: 8px 12px; border: 1px dashed var(--accent); border-radius: 10px; background: transparent; color: var(--text); text-align: left; }
.an-idea:active { background: var(--panel-2); }
.an-idea-label { grid-area: label; color: var(--accent); font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.an-idea-text { grid-area: text; font-size: 14px; font-weight: 600; line-height: 1.35; overflow-wrap: anywhere; }
.an-idea .ic { grid-area: go; color: var(--muted); }
