:root {
  --bg: #121318;
  --panel: #1E2027;
  --panel2: #22242C;
  --chip: #2A2C35;
  --line: #2C2F39;
  --line2: #3A3D49;
  --text: #F2F2F5;
  --text2: #C9CBD3;
  --muted: #A9ACB8;
  --sun: #FFC93C;
  --mint: #3DD6A3;
  --danger-bg: #4A2320;
  --danger: #FFB4A6;
  --radius: 22px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: 'Nunito', system-ui, sans-serif; }
body { overscroll-behavior: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
button, input { font-family: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
button:focus-visible, [tabindex]:focus-visible, a:focus-visible { outline: 3px solid var(--sun); outline-offset: 2px; }
a { color: var(--sun); }
[hidden] { display: none !important; }

.app { height: 100vh; height: var(--app-h, 100vh); display: flex; flex-direction: column; gap: 12px; padding: max(14px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left)); overflow: hidden; }

/* Header */
.top { display: flex; align-items: center; gap: 12px; height: 56px; flex-shrink: 0; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); padding-right: 14px; border-right: 2px solid var(--line); height: 48px; }
.brand { border-radius: 16px 0 0 16px; padding-left: 6px; margin-left: -6px; transition: background .15s; }
.brand:hover, .brand:focus-visible { background: var(--panel2); }
.brand:active { transform: scale(0.97); }
.brand-mark { position: relative; display: flex; flex-shrink: 0; }
.brand-home { position: absolute; right: -5px; bottom: -4px; width: 20px; height: 20px; border-radius: 10px; background: var(--sun); color: #121318; border: 2px solid var(--bg); display: flex; align-items: center; justify-content: center; }
.brand-words { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-family: 'Fredoka', sans-serif; font-weight: 600; font-size: 17px; white-space: nowrap; }
.brand-by { font-size: 11px; font-weight: 700; letter-spacing: 0.03em; color: var(--muted); white-space: nowrap; }
.page-title { margin: 0; font-family: 'Fredoka', sans-serif; font-weight: 600; font-size: 22px; }
.spacer { flex: 1; }
.chip { height: 40px; padding: 0 14px; border-radius: 20px; background: var(--panel2); display: flex; align-items: center; font-size: 14px; font-weight: 800; white-space: nowrap; max-width: 46vw; overflow: hidden; text-overflow: ellipsis; }
.chip.flash { background: var(--sun); color: var(--bg); }
.saved { font-size: 13px; font-weight: 700; color: var(--muted); white-space: nowrap; }
.round { width: 48px; height: 48px; border-radius: 24px; background: var(--panel2); display: flex; align-items: center; justify-content: center; }
.pill { height: 44px; padding: 0 16px; border-radius: 22px; background: var(--panel2); font-size: 15px; font-weight: 800; }
.only-narrow { display: none; }

/* Work area */
.work { flex: 1; min-height: 0; display: flex; gap: 14px; }
.rail { width: 76px; flex-shrink: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 0; display: flex; flex-direction: column; align-items: center; gap: 6px; overflow-y: auto; }
.tool { width: 58px; height: 58px; border-radius: 16px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 11px; font-weight: 800; }
.tool[aria-pressed="true"] { background: var(--sun); color: var(--bg); }
.tool:disabled { opacity: 0.35; cursor: default; }
.rail-sep { width: 40px; height: 2px; background: var(--line); margin: 4px 0; flex-shrink: 0; }
.rail-color { margin-top: auto; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 11px; font-weight: 800; color: var(--muted); }
.rail-color i { width: 36px; height: 36px; border-radius: 18px; border: 3px solid var(--text); display: block; }

.stage { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.paper { flex: 1; min-height: 0; position: relative; border-radius: var(--radius); background: #3A3D49; overflow: hidden; }
.paper canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
#cvLive { cursor: crosshair; }
.paper.tool-eraser #cvLive { cursor: cell; }
.paper.tool-hand #cvLive { cursor: grab; }
.paper.tool-fill #cvLive { cursor: crosshair; }
.empty { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); font-size: 18px; font-weight: 700; color: #B4B9C6; pointer-events: none; white-space: nowrap; }
.zoom { position: absolute; right: 12px; bottom: 12px; height: 60px; padding: 0 6px; border-radius: 30px; background: rgba(30, 32, 39, 0.92); display: flex; align-items: center; gap: 4px; }
.zoom button { width: 48px; height: 48px; border-radius: 24px; background: var(--chip); display: flex; align-items: center; justify-content: center; }
.zoom .zoom-pct { width: auto; min-width: 60px; background: none; font-size: 14px; font-weight: 800; }
.focus-btn { position: absolute; right: 12px; top: 12px; height: 48px; padding: 0 14px; border-radius: 16px; background: rgba(30, 32, 39, 0.9); display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 800; }
.focusbar { display: none; position: absolute; left: 50%; top: 12px; transform: translateX(-50%); align-items: center; gap: 4px; padding: 6px; border-radius: 20px; background: rgba(30, 32, 39, 0.95); box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35); white-space: nowrap; max-width: calc(100% - 24px); overflow-x: auto; }
.focusbar .tool { width: 46px; height: 46px; border-radius: 13px; }
.focusbar .sw { width: 28px; height: 28px; border-radius: 14px; }
.focusbar .fb-label { min-width: 56px; text-align: center; font-size: 14px; font-weight: 800; }
.focusbar .fb-exit { height: 46px; padding: 0 12px; border-radius: 13px; background: var(--line2); display: flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 800; }
.vbar { width: 2px; height: 32px; background: var(--line2); margin: 0 4px; flex-shrink: 0; }

/* Flip */
.flip { flex-shrink: 0; height: 64px; border-radius: 18px; background: var(--panel); border: 1px solid var(--line); padding: 0 10px; display: flex; align-items: center; gap: 8px; }
.sq { width: 44px; height: 44px; flex-shrink: 0; border-radius: 14px; background: var(--chip); display: flex; align-items: center; justify-content: center; }
.flip-track { flex: 1; min-width: 0; height: 56px; position: relative; touch-action: none; cursor: grab; outline: none; }
.flip-track:focus-visible { outline: 3px solid var(--sun); border-radius: 12px; }
.flip-rail, .flip-fill { position: absolute; left: 18px; top: 50%; height: 10px; margin-top: -5px; border-radius: 5px; }
.flip-rail { right: 18px; background: var(--bg); box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.6); }
.flip-fill { background: linear-gradient(90deg, #8A6A1E, var(--sun)); }
.flip-ticks { position: absolute; left: 18px; right: 18px; top: 0; bottom: 0; }
.flip-ticks i { position: absolute; width: 4px; margin-left: -2px; border-radius: 2px; }
.flip-knob { position: absolute; top: 50%; width: 42px; height: 42px; margin: -21px 0 0 -21px; border-radius: 21px; background: radial-gradient(circle at 35% 30%, #FFE08A, var(--sun) 60%, #E0A820); color: var(--bg); box-shadow: 0 0 0 5px rgba(255, 201, 60, 0.22), 0 4px 10px rgba(0, 0, 0, 0.45); display: flex; align-items: center; justify-content: center; font-family: 'Fredoka', sans-serif; font-weight: 600; font-size: 17px; pointer-events: none; }
.flip-label { min-width: 118px; display: flex; flex-direction: column; align-items: flex-end; line-height: 1.2; font-size: 14px; font-weight: 800; white-space: nowrap; }
.kicker { margin: 0; font-size: 12px; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }

/* Side panel */
.side { width: 256px; flex-shrink: 0; display: flex; flex-direction: column; gap: 14px; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; touch-action: pan-y; }
/* Panels keep their full height so the side scrolls, instead of squashing the layer list */
.side > * { flex-shrink: 0; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; }
.layer-list { display: flex; flex-direction: column; gap: 6px; }
.layer { display: flex; align-items: center; gap: 4px; height: 54px; border-radius: 14px; border: 2px solid var(--line); }
.layer.active { background: var(--line); border-color: var(--sun); }
.layer-main { flex: 1; min-width: 0; height: 50px; padding: 0 10px; display: flex; flex-direction: column; justify-content: center; text-align: left; touch-action: pan-y; }
.layer-main b { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.layer-main small { font-size: 12px; font-weight: 700; color: var(--muted); }
.layer.hidden-layer .layer-main { opacity: 0.55; }
.bg-row { border-style: dashed; margin-top: 4px; }
.bg-main { flex: 1; min-width: 0; height: 50px; padding: 0 8px; display: flex; align-items: center; gap: 10px; text-align: left; color: inherit; }
.bg-main:disabled { cursor: default; opacity: 0.75; }
.bg-chip { flex: 0 0 auto; width: 54px; height: 38px; border-radius: 8px; overflow: hidden; border: 2px solid var(--line2); background: #fff; }
.bg-chip img, .bg-opt img { width: 100%; height: 100%; display: block; object-fit: cover; }
.bg-words { display: flex; flex-direction: column; min-width: 0; }
.bg-words b { font-size: 16px; }
.bg-words small { font-size: 12px; font-weight: 700; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bg-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.bg-opt { display: flex; flex-direction: column; gap: 4px; padding: 5px; border-radius: 14px; border: 2px solid var(--line2); color: var(--text); text-align: left; }
.bg-opt img { height: auto; aspect-ratio: 800 / 560; border-radius: 9px; }
.bg-opt span { font-size: 14px; font-weight: 800; padding: 0 3px 2px; }
.bg-opt i { font-style: normal; font-size: 12px; }
.bg-opt[aria-checked="true"] { border-color: var(--sun); background: var(--line); }
.bg-colors { display: flex; flex-direction: column; gap: 8px; }
.bg-colors[hidden] { display: none; }
.eye { width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center; }
.dashed { height: 46px; border: 2px dashed var(--line2); border-radius: 14px; color: var(--text2); font-size: 15px; font-weight: 800; }
.swatches { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.sw { height: 44px; border-radius: 14px; border: 3px solid var(--line2); box-shadow: inset 0 0 0 2px var(--panel); }
.sw[aria-checked="true"] { border-color: var(--sun); }
.size-row { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 800; }
.size-row input { flex: 1; accent-color: var(--sun); height: 32px; }
.size-row span:last-child { width: 28px; text-align: right; color: var(--text2); }
.hint { margin: 0; padding: 0 6px; font-size: 13px; line-height: 1.45; color: #8A8E9A; }

/* Timeline */
.timeline { height: 112px; flex-shrink: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 0 14px; display: flex; align-items: center; gap: 10px; }
.play { width: 72px; height: 72px; flex-shrink: 0; border-radius: 36px; background: var(--sun); color: var(--bg); display: flex; align-items: center; justify-content: center; }
.tbtn { height: 84px; flex-shrink: 0; padding: 0 10px; border-radius: 14px; background: var(--chip); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 12px; font-weight: 800; touch-action: none; }
.tbtn[aria-pressed="true"] { background: var(--sun); color: var(--bg); }
.tbtn small { font-size: 11px; font-weight: 700; opacity: 0.8; }
.onion { width: 100px; }
.vsep { width: 2px; height: 64px; background: var(--line); flex-shrink: 0; }
.frames { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; overflow-x: auto; padding: 14px 6px 4px; touch-action: none; scrollbar-width: thin; }
.frame { position: relative; flex-shrink: 0; width: 70px; height: 86px; padding: 4px; border: 3px solid transparent; border-radius: 14px; background: var(--chip); display: flex; flex-direction: column; align-items: center; gap: 3px; touch-action: none; }
.frame.cur { border-color: var(--sun); }
.frame.menu { border-color: #7FA6EE; }
.frame.lifted { opacity: 0.45; transform: translateY(-6px); }
.frame img, .frame .thumb { width: 58px; height: 41px; border-radius: 6px; background: #fff; display: block; }
.frame .meta { display: flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 800; }
.tag { min-width: 16px; height: 16px; padding: 0 3px; border-radius: 5px; color: var(--bg); font-size: 11px; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; }
.hold-badge { position: absolute; right: -8px; top: -11px; height: 22px; padding: 0 6px; border-radius: 11px; background: #4D8BFF; color: #0B1430; font-size: 12px; font-weight: 800; display: flex; align-items: center; }
.drop-mark { width: 4px; height: 86px; flex-shrink: 0; border-radius: 2px; background: var(--sun); }
.add-frame { width: 56px; height: 86px; flex-shrink: 0; border: 2px dashed var(--line2); border-radius: 14px; display: flex; align-items: center; justify-content: center; }
.fps { width: 200px; flex-shrink: 0; height: 84px; border-radius: 14px; background: var(--chip); display: flex; flex-direction: column; justify-content: center; padding: 0 12px; }
.fps-top { display: flex; align-items: baseline; justify-content: space-between; font-size: 12px; font-weight: 700; color: var(--text2); }
.fps-top b { font-family: 'Fredoka', sans-serif; font-size: 19px; font-weight: 600; color: var(--text); }
.fps input { width: 100%; height: 28px; margin: 0; accent-color: var(--sun); }
.fps-ticks { display: flex; justify-content: space-between; font-size: 12px; font-weight: 800; color: var(--muted); padding: 0 2px; }

/* Popovers and dialogs */
.overlay-host { position: fixed; inset: 0; pointer-events: none; z-index: 20; }
.overlay-host > * { pointer-events: auto; }
.pop { position: fixed; padding: 14px 16px; border-radius: 20px; background: var(--chip); border: 1px solid var(--line2); box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45); display: flex; flex-direction: column; gap: 12px; max-width: calc(100vw - 24px); max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px); overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; }
.pop > * { flex-shrink: 0; }
.pop h2 { margin: 0; flex: 1; font-size: 17px; font-weight: 800; }
.pop-head { display: flex; align-items: center; gap: 10px; }
.x { width: 44px; height: 44px; border-radius: 22px; background: var(--line2); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.seg { display: flex; gap: 6px; }
.seg button { flex: 1; height: 46px; border: 2px solid var(--line2); border-radius: 14px; background: var(--panel2); font-size: 15px; font-weight: 800; display: flex; align-items: center; justify-content: center; gap: 6px; }
.seg button[aria-checked="true"] { border-color: var(--sun); background: #3A3220; }
.row-box { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 14px; background: var(--panel2); flex-wrap: wrap; }
.row-box label { font-size: 15px; font-weight: 800; }
.step { width: 44px; height: 44px; border-radius: 12px; background: var(--line2); font-size: 22px; font-weight: 800; }
.num { width: 64px; height: 44px; border: 2px solid var(--line2); border-radius: 12px; background: var(--bg); font-size: 20px; font-weight: 800; text-align: center; }
.note { flex: 1; text-align: right; font-size: 13px; color: var(--muted); }
.acts { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.acts button { height: 52px; border-radius: 14px; background: var(--line2); font-size: 14px; font-weight: 800; }
.acts button.danger { background: var(--danger-bg); color: var(--danger); }
.acts button:disabled { opacity: 0.4; cursor: default; }
.scrim { position: fixed; inset: 0; background: rgba(8, 9, 12, 0.55); display: flex; align-items: center; justify-content: center; padding: 16px; overscroll-behavior: contain; }
.dialog { width: min(720px, 100%); max-height: calc(100dvh - 32px); overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; touch-action: pan-y; padding: 22px; border-radius: 24px; background: var(--chip); border: 1px solid var(--line2); box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5); display: flex; flex-direction: column; gap: 14px; }
/* Tall dialogs (like Settings) scroll inside the window instead of running off the screen */
.dialog > * { flex-shrink: 0; }
.settings .pop-head, .snd-dialog .pop-head { position: sticky; top: -22px; z-index: 2; margin: -22px -22px 0; padding: 16px 22px 10px; background: inherit; border-radius: 24px 24px 0 0; }
@media (max-width: 700px) and (orientation: portrait) { .settings .pop-head, .snd-dialog .pop-head { top: -16px; margin: -16px -16px 0; padding: 12px 16px 8px; } }
@media (max-height: 500px) and (orientation: landscape) { .settings .pop-head, .snd-dialog .pop-head { top: -14px; margin: -14px -14px 0; padding: 10px 14px 6px; } }
.dialog h2 { margin: 0; font-family: 'Fredoka', sans-serif; font-weight: 600; font-size: 24px; }
.suggest { display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; border-radius: 16px; background: linear-gradient(90deg, #3A2E12, var(--chip)); border: 2px solid var(--sun); font-size: 15px; line-height: 1.45; color: #F2E6C4; }
.suggest b { color: var(--sun); }
.cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.tcard { position: relative; min-height: 140px; padding: 16px; border: 3px solid var(--line2); border-radius: 18px; background: var(--panel2); display: flex; flex-direction: column; align-items: flex-start; gap: 8px; text-align: left; }
.tcard.sugg { border-color: var(--sun); background: #3A3220; box-shadow: 0 0 0 4px rgba(255, 201, 60, 0.18); }
.tcard .badge { position: absolute; right: 10px; top: -12px; height: 24px; padding: 0 10px; border-radius: 12px; background: var(--sun); color: var(--bg); font-size: 12px; font-weight: 800; display: flex; align-items: center; }
.tcard b { font-size: 19px; display: flex; align-items: center; gap: 8px; }
.tcard span { font-size: 14px; line-height: 1.45; color: var(--text2); }
.btn { height: 48px; padding: 0 20px; border-radius: 24px; background: var(--line2); font-size: 15px; font-weight: 800; }
.btn.main { background: var(--sun); color: var(--bg); }
.btn.danger { background: var(--danger-bg); color: var(--danger); }
.btn:disabled { opacity: 0.45; cursor: default; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.opacity-row { display: flex; align-items: baseline; justify-content: space-between; }
.opacity-row b { font-family: 'Fredoka', sans-serif; font-size: 22px; font-weight: 600; }
.pop input[type="range"] { width: 100%; height: 40px; accent-color: var(--sun); }
.presets { display: flex; gap: 6px; }
.presets button { flex: 1; height: 44px; border-radius: 12px; background: var(--line2); font-size: 14px; font-weight: 800; }
.dots { display: flex; justify-content: center; gap: 4px; }
.dots i { width: 24px; height: 24px; border-radius: 12px; border: 3px solid; }
.small { font-size: 13px; line-height: 1.45; color: var(--muted); margin: 0; }

/* Full screen drawing */
.app.focus .top, .app.focus .rail, .app.focus .side, .app.focus .timeline, .app.focus .focus-btn { display: none; }
/* The flip bar stays in full screen so you can still flip through your drawings */
.app.focus .focusbar { display: flex; }

/* Narrow screens: the side panel becomes a drawer */
@media (max-width: 1000px) {
  .only-narrow { display: inline-flex; align-items: center; }
  .side { position: fixed; right: 12px; top: 80px; bottom: 140px; z-index: 10; width: 280px; background: var(--bg); padding: 4px; border-radius: var(--radius); box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6); display: none; }
  .app.side-open .side { display: flex; }
  .brand-words, .saved { display: none; }
  .fps { width: 150px; }
  .onion { width: 84px; }
}
/* ---------- Phones ---------- */
.side-close { display: none; }
@media (max-width: 1000px) {
  .side { position: fixed; }
  .side-close { display: flex; position: absolute; right: 14px; top: 14px; width: 40px; height: 40px; z-index: 2; }
}
/* Phone held upright: paper, then the flip scrubber and the frames right under it, then play and speed, with the drawing tools along the bottom (easy for thumbs) */
@media (max-width: 700px) and (orientation: portrait) {
  .app { padding: max(8px, env(safe-area-inset-top)) 8px max(8px, env(safe-area-inset-bottom)); gap: 8px; }
  .top { height: 44px; gap: 6px; }
  .top .round { width: 40px; height: 40px; border-radius: 20px; }
  .brand { padding-right: 0; border-right: none; height: 40px; }
  .brand img { width: 30px; height: 30px; }
  .page-title { font-size: 18px; }
  .chip, .saved { display: none; }
  .pill { height: 40px; padding: 0 12px; font-size: 14px; }
  .pill .label { display: none; }
  .work { display: contents; }
  .stage { order: 1; flex: 1; min-height: 0; gap: 8px; }
  .timeline { order: 2; }
  .rail { order: 3; width: auto; flex-direction: row; padding: 4px 6px; border-radius: 16px; gap: 2px; overflow-x: auto; overflow-y: hidden; flex-shrink: 0; }
  .tool { width: 42px; height: 44px; flex-shrink: 0; font-size: 0; gap: 0; border-radius: 12px; }
  .rail-sep { width: 2px; height: 30px; margin: 0 4px; }
  .rail-color { margin: 0 0 0 auto; flex-direction: row; font-size: 0; padding: 0 4px; }
  .rail-color i { width: 30px; height: 30px; }
  .paper { border-radius: 16px; }
  .focus-btn { height: 40px; padding: 0 10px; top: 8px; right: 8px; }
  .focus-btn span { display: none; }
  .zoom { height: 48px; right: 8px; bottom: 8px; }
  .zoom button { width: 40px; height: 40px; }
  .zoom .zoom-pct { min-width: 48px; font-size: 13px; }
  .flip { height: 52px; padding: 0 6px; border-radius: 14px; gap: 4px; }
  .sq { width: 40px; height: 40px; }
  .flip-label { display: none; }
  .flip-knob { width: 36px; height: 36px; margin: -18px 0 0 -18px; font-size: 15px; }
  .timeline { height: auto; flex-wrap: wrap; padding: 8px; gap: 8px; border-radius: 16px; }
  .play { width: 52px; height: 52px; }
  .tbtn { height: 52px; width: 52px; padding: 0; }
  .tbtn span, .tbtn small { display: none; }
  .vsep { display: none; }
  .fps { flex: 1; width: auto; min-width: 0; height: 52px; padding: 0 10px; }
  .fps-ticks { display: none; }
  .fps-top b { font-size: 15px; }
  .frames { order: -1; flex-basis: 100%; padding: 10px 2px 0; }
  .fps-top { white-space: nowrap; gap: 4px; }
  .fps-top .kicker { font-size: 11px; letter-spacing: 0.06em; }
  .fps-top > span { font-size: 0; }
  .fps-top > span b { font-size: 15px; }
  .frame { width: 60px; height: 76px; }
  .frame img { width: 48px; height: 34px; }
  .add-frame { width: 48px; height: 76px; }
  .side { left: 8px; right: 8px; top: auto; bottom: 8px; width: auto; max-height: 72vh; padding: 8px; }
  .focusbar { top: 8px; padding: 4px; gap: 2px; }
  .focusbar .tool { width: 40px; height: 40px; }
  .focusbar .sw, .focusbar .vbar, .focusbar .sq, .focusbar .fb-label { display: none; }
  .focusbar .tool { width: 36px; height: 36px; }
  .focusbar .fb-exit { height: 36px; padding: 0 8px; font-size: 0; gap: 0; }
  .pop { width: calc(100vw - 16px) !important; left: 8px !important; }
  .acts { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .seg button { font-size: 13px; padding: 0 4px; }
  .cards { grid-template-columns: 1fr; }
  .tcard { min-height: 0; }
  .dialog { padding: 16px; max-height: calc(100dvh - 32px); overflow-y: auto; }
}
/* Phone held sideways: very little height, so everything gets slimmer */
@media (max-height: 500px) and (orientation: landscape) {
  .app { padding: 6px max(8px, env(safe-area-inset-right)) 6px max(8px, env(safe-area-inset-left)); gap: 6px; }
  .top { height: 36px; gap: 6px; }
  .top .round { width: 36px; height: 36px; }
  .brand { height: 36px; padding-right: 8px; }
  .brand img { width: 26px; height: 26px; }
  .page-title { font-size: 16px; }
  .chip { height: 32px; font-size: 12px; }
  .saved { display: none; }
  .pill { height: 36px; padding: 0 12px; font-size: 13px; }
  .pill .label { display: none; }
  .work { gap: 6px; }
  .rail { width: 52px; padding: 4px 0; gap: 2px; border-radius: 14px; }
  .tool { width: 44px; height: 40px; font-size: 0; gap: 0; border-radius: 10px; flex-shrink: 0; }
  .rail-sep { margin: 2px 0; }
  .rail-color { font-size: 0; }
  .rail-color i { width: 26px; height: 26px; }
  .stage { gap: 6px; }
  .paper { border-radius: 14px; }
  .focus-btn { height: 36px; padding: 0 10px; top: 6px; right: 6px; }
  .focus-btn span { display: none; }
  .zoom { height: 44px; right: 6px; bottom: 6px; }
  .zoom button { width: 36px; height: 36px; }
  .zoom .zoom-pct { min-width: 44px; font-size: 12px; }
  .flip { height: 44px; padding: 0 6px; border-radius: 12px; }
  .sq { width: 36px; height: 36px; }
  .flip-label { min-width: 70px; font-size: 12px; }
  .flip-label .kicker { display: none; }
  .flip-knob { width: 32px; height: 32px; margin: -16px 0 0 -16px; font-size: 14px; }
  .timeline { height: 68px; padding: 0 8px; gap: 6px; border-radius: 14px; }
  .play { width: 48px; height: 48px; }
  .tbtn { height: 48px; width: 48px; padding: 0; }
  .tbtn span, .tbtn small { display: none; }
  .vsep { display: none; }
  .frames { padding: 10px 2px 2px; }
  .frame { width: 52px; height: 56px; padding: 2px; }
  .frame img { width: 42px; height: 30px; }
  .frame .meta { font-size: 11px; }
  .hold-badge { height: 18px; font-size: 11px; top: -9px; }
  .add-frame { width: 44px; height: 56px; }
  .fps { width: 120px; height: 52px; padding: 0 8px; }
  .fps-ticks { display: none; }
  .fps-top b { font-size: 14px; }
  .side { top: 50px; bottom: 8px; right: 8px; width: 280px; }
  .focusbar { top: 6px; padding: 4px; gap: 2px; }
  .focusbar .tool { width: 38px; height: 38px; }
  .focusbar .sw { width: 22px; height: 22px; }
  .pop { max-height: calc(100dvh - 16px); overflow-y: auto; }
  .dialog { padding: 14px; max-height: calc(100dvh - 16px); overflow-y: auto; }
  .tcard { min-height: 0; padding: 10px; }
}

/* Accounts */
.account { display: inline-flex; align-items: center; gap: 8px; }
.account .initial { width: 30px; height: 30px; border-radius: 15px; background: var(--sun); color: var(--bg); display: inline-flex; align-items: center; justify-content: center; font-family: 'Fredoka', sans-serif; font-weight: 600; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 800; }
/* Any typing box in a .field (untyped inputs default to type="text" but don't match [type="text"]). Explicit colors so text is never light-on-white. */
.field input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="file"]) { height: 52px; border: 2px solid var(--line2); border-radius: 14px; background: var(--bg); color: var(--text); caret-color: var(--sun); padding: 0 14px; font-size: 17px; font-weight: 700; user-select: text; -webkit-user-select: text; }
.field input::placeholder, .mv-name::placeholder { color: var(--muted); opacity: 1; }
.field input:focus { outline: none; border-color: var(--sun); }
.check { display: flex; align-items: center; gap: 10px; font-size: 15px; font-weight: 700; }
.check input { width: 24px; height: 24px; accent-color: var(--sun); }
.err { color: var(--danger); font-size: 14px; font-weight: 700; margin: 0; }
.anim-list { display: flex; flex-direction: column; gap: 8px; max-height: 50vh; overflow-y: auto; }
.anim-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 14px; background: var(--panel2); }
.anim-row .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.anim-row b { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.anim-row small { color: var(--muted); font-size: 13px; font-weight: 700; }
.anim-row.current { outline: 2px solid var(--sun); }
.menu-list { display: flex; flex-direction: column; gap: 8px; }
.menu-list .btn { text-align: left; }
@media (max-width: 1000px) { .account .label { display: none; } }

/* Tool settings and color picker */
.rail-color { background: none; border: none; cursor: pointer; padding: 4px 0; border-radius: 12px; }
.tool-preview { height: 44px; border-radius: 12px; background: #fff; overflow: hidden; }
.slider-row { display: grid; grid-template-columns: 84px 1fr 44px; align-items: center; gap: 8px; font-size: 14px; font-weight: 800; }
.slider-row input[type="range"] { width: 100%; height: 36px; accent-color: var(--sun); margin: 0; }
.slider-row b { text-align: right; color: var(--text2); font-size: 14px; }
.slider-row input[type="color"] { width: 100%; height: 40px; border: 2px solid var(--line2); border-radius: 12px; background: var(--bg); padding: 2px; }

/* Settings */
.settings { gap: 12px; }
/* Focus music and nature sounds */
.amb-now { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 18px; background: var(--panel2); border: 2px solid var(--line2); }
.amb-play { width: 52px; height: 52px; flex-shrink: 0; border-radius: 26px; background: var(--sun); color: #121318; font-size: 18px; font-weight: 900; display: flex; align-items: center; justify-content: center; }
.amb-skip { width: 44px; height: 44px; flex-shrink: 0; border-radius: 22px; background: var(--line2); font-size: 16px; }
.amb-now-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.amb-now-txt b { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.amb-vol { display: flex; align-items: center; gap: 8px; }
.amb-vol input, .amb-nat input { flex: 1; min-width: 0; width: 100%; accent-color: var(--sun); height: 28px; }
.amb-tracks { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.amb-trk { position: relative; min-height: 52px; padding: 8px 10px; border: 2px solid var(--line2); border-radius: 14px; background: var(--panel2); display: flex; align-items: center; gap: 8px; text-align: left; font-size: 14px; }
.amb-trk > span:first-child { font-size: 20px; }
.amb-trk b { flex: 1; line-height: 1.2; }
.amb-trk[aria-pressed="true"] { border-color: var(--sun); }
.amb-eq { display: flex; align-items: flex-end; gap: 2px; height: 16px; }
.amb-eq i { width: 3px; background: var(--sun); border-radius: 2px; animation: amb-eq 0.9s ease-in-out infinite alternate; }
.amb-eq i:nth-child(2) { animation-delay: -0.3s; } .amb-eq i:nth-child(3) { animation-delay: -0.6s; }
@keyframes amb-eq { from { height: 3px; } to { height: 16px; } }
@media (prefers-reduced-motion: reduce) { .amb-eq i { animation: none; height: 10px; } }
.amb-nat { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.amb-nat-item { border: 2px solid var(--line2); border-radius: 14px; background: var(--panel2); display: flex; flex-direction: column; }
.amb-nat-item.on { border-color: var(--sun); }
.amb-nat-item button { min-height: 48px; padding: 8px 10px; display: flex; align-items: center; gap: 8px; text-align: left; font-size: 14px; background: none; }
.amb-nat-item button span { font-size: 20px; }
.amb-nat-item input { margin: 0 10px 8px; width: auto; }
.amb-stop { align-self: flex-start; }
@media (max-width: 340px) { .amb-tracks { grid-template-columns: 1fr; } }
.set-h { margin: 6px 0 0; font-size: 13px; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.look-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.look-card { padding: 12px; border: 3px solid var(--line2); border-radius: 18px; background: var(--panel2); display: flex; flex-direction: column; align-items: flex-start; gap: 6px; text-align: left; }
.look-card[aria-checked="true"] { border-color: var(--sun); }
.look-card b { font-size: 16px; }
.look-card span:last-child { font-size: 13px; line-height: 1.35; color: var(--text2); }
.look-swatch { width: 100%; height: 64px; border-radius: 12px; position: relative; overflow: hidden; display: block; }
.look-studio .look-swatch { background: #121318; }
.look-desk .look-swatch, .look-card.look-desk .look-swatch { background: repeating-linear-gradient(90deg, rgba(0,0,0,0.08) 0 2px, transparent 2px 11px), linear-gradient(180deg, #6E4A2C, #4F331D); }
.look-swatch i { position: absolute; display: block; }
.look-swatch i:nth-child(1) { left: 10px; top: 10px; bottom: 10px; width: 14px; border-radius: 5px; background: #1E2027; }
.look-swatch i:nth-child(2) { left: 32px; right: 10px; top: 10px; bottom: 10px; border-radius: 8px; background: #fff; }
.look-swatch i:nth-child(3) { left: 50%; bottom: 10px; width: 46px; height: 7px; margin-left: -12px; border-radius: 3px; background: #3A3D49; }
.look-card.look-desk .look-swatch i:nth-child(1) { background: #3A281A; }
.look-card.look-desk .look-swatch i:nth-child(2) { background: #FBF8EF; border-radius: 3px; transform: rotate(-2deg); box-shadow: 0 3px 6px rgba(0,0,0,0.4); }
.look-card.look-desk .look-swatch i:nth-child(3) { background: #8A8F96; }
.gear { flex-shrink: 0; }

/* Classic animator desk look: warm wood, paper and pins */
html.look-desk {
  --bg: #4F331D; --panel: #3A281A; --panel2: #4A3424; --chip: #4A3424; --line: #5A4330; --line2: #6E553D;
  --text: #FBF3E4; --text2: #EBDDC5; --muted: #D2BE9C;
}
html.look-desk body { background: repeating-linear-gradient(90deg, rgba(0,0,0,0.06) 0 2px, transparent 2px 11px), linear-gradient(180deg, #6E4A2C, #4F331D) fixed; }
html.look-desk .paper { background: #3B2817; box-shadow: inset 0 2px 10px rgba(0,0,0,0.35); }
html.look-desk .brand-name, html.look-desk .page-title, html.look-desk .hello { font-family: 'Patrick Hand', 'Fredoka', cursive; letter-spacing: 0.01em; }
html.look-desk .card, html.look-desk .panel, html.look-desk .rail, html.look-desk .timeline, html.look-desk .strip, html.look-desk .lrow { box-shadow: 0 4px 12px rgba(0,0,0,0.3); }
html.look-desk .lf:nth-child(4n+1) { transform: rotate(-2deg); }
html.look-desk .lf:nth-child(4n+2) { transform: rotate(1.5deg); }
html.look-desk .lf:nth-child(4n+3) { transform: rotate(-1deg); }
html.look-desk .lf:nth-child(4n) { transform: rotate(2deg); }
html.look-desk .lf.cur, html.look-desk .lf.showing { transform: none; }
/* Frames are sheets of animation paper, taped to the desk */
html.look-desk .lf, html.look-desk .frame { background: #FBF4DC; color: #2B2B2B; border-radius: 3px; border-color: transparent; box-shadow: 0 4px 8px rgba(0,0,0,0.4), inset 0 -10px 14px -12px rgba(120,90,40,0.35); overflow: visible; }
html.look-desk .lf::before, html.look-desk .frame::before { content: ''; position: absolute; top: -8px; left: 50%; width: 30px; height: 13px; margin-left: -15px; background: rgba(255, 236, 170, 0.78); box-shadow: 0 1px 2px rgba(0,0,0,0.2); transform: rotate(-4deg); pointer-events: none; }
html.look-desk .lf:nth-child(even)::before, html.look-desk .frame:nth-child(even)::before { transform: rotate(5deg); }
html.look-desk .lf.cur, html.look-desk .frame.cur { border-color: #E2A400; box-shadow: 0 0 0 3px rgba(255, 201, 60, 0.55), 0 6px 12px rgba(0,0,0,0.45); }
html.look-desk .lf.showing { border-color: #2BB585; }
html.look-desk .lf.locked { opacity: 1; background: #E9E0C6; color: #8C8270; }
html.look-desk .lf.locked::before { opacity: 0.5; }
html.look-desk .frame img, html.look-desk .frame .thumb { background: #FBF8EF; border-radius: 2px; }
html.look-desk .frame:nth-child(4n+1) { transform: rotate(-2deg); }
html.look-desk .frame:nth-child(4n+2) { transform: rotate(1.5deg); }
html.look-desk .frame:nth-child(4n+3) { transform: rotate(-1deg); }
html.look-desk .frame:nth-child(4n) { transform: rotate(2deg); }
html.look-desk .frame.cur { transform: none; }
html.look-desk .lframes, html.look-desk .frames { padding-top: 14px; }
html.look-desk .lf .lf-state.todo { border-color: #B8A88C; }
html.look-desk .lthumb canvas, html.look-desk .module-art { box-shadow: 0 3px 8px rgba(0,0,0,0.4); border-radius: 4px; }
html.look-desk .dialog, html.look-desk .pop { background: #3A281A; border-color: #6E553D; }
html.look-desk .focus-btn, html.look-desk .zoom, html.look-desk .focusbar { background: rgba(58, 40, 26, 0.94); }

.empty.on-course { white-space: normal; background: rgba(18,19,24,0.82); color: #fff; padding: 12px 18px; border-radius: 16px; max-width: 70%; text-align: center; }
.layer-name-row { display: flex; flex-direction: column; gap: 6px; font-size: 15px; font-weight: 800; }
.layer-name-row input { height: 46px; border-radius: 12px; border: 2px solid var(--line2); background: var(--panel2); color: var(--text); font: inherit; font-size: 17px; padding: 0 12px; }
.layer-name-row input:focus { outline: none; border-color: var(--sun); }

/* Membership */
.paywall { width: min(560px, 100%); }
.paywall .perks { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.paywall .perks li { display: flex; gap: 10px; align-items: flex-start; font-weight: 700; }
.paywall .perks li::before { content: '✓'; flex-shrink: 0; width: 24px; height: 24px; border-radius: 12px; background: var(--mint); color: #0E2A20; font-size: 14px; font-weight: 900; display: flex; align-items: center; justify-content: center; }
.paywall .price { margin: 4px 0 0; display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.paywall .price b { font-family: 'Fredoka', sans-serif; font-size: 34px; font-weight: 600; color: var(--sun); }
.paywall .price span { font-size: 14px; font-weight: 700; color: var(--muted); }
.paywall .grown { font-size: 15px; }
.m-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.m-row .small { margin: 0; flex: 1; min-width: 200px; }
.m-toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 1000; max-width: calc(100% - 32px); padding: 14px 20px; border-radius: 16px; background: var(--mint); color: #0E2A20; font-weight: 800; box-shadow: 0 8px 24px rgba(0,0,0,0.4); }
.voice-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.voice-row select { flex: 1; min-width: 180px; height: 46px; border-radius: 12px; border: 2px solid var(--line2); background: var(--panel2); color: var(--text); font: inherit; font-weight: 700; padding: 0 10px; }
.mha-plate { display: inline-flex; align-items: center; justify-content: center; padding: 10px 16px; border-radius: 14px; background: #FFFFFF; align-self: flex-start; }
.mha-plate img { display: block; height: 40px; width: auto; }
.mha-foot { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; padding: 22px 0 8px; border-top: 2px solid var(--line); margin-top: 8px; }
.mha-foot .small { flex: 1; min-width: 220px; }
.admin-link { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; align-self: flex-start; }
.help-btn { display: flex; flex-direction: column; gap: 2px; text-align: left; padding: 14px 16px; border-radius: 16px; background: linear-gradient(120deg, #4D8BFF, #9B7BFF); color: #fff; }
.help-btn b { font-size: 17px; font-weight: 800; }
.help-btn span { font-size: 14px; font-weight: 600; opacity: 0.92; }
.contact-btn { display: flex; align-items: center; gap: 12px; text-align: left; padding: 12px 16px; margin-top: 8px; border-radius: 16px; background: var(--panel2); border: 2px solid var(--line2); color: var(--text); width: 100%; }
.contact-btn > span:first-child { font-size: 24px; }
.contact-btn > span:last-child { display: flex; flex-direction: column; gap: 2px; }
.contact-btn b { font-size: 16px; font-weight: 800; }
.contact-btn span span { font-size: 14px; font-weight: 600; color: var(--muted); }
.field textarea, .field select { border: 2px solid var(--line2); border-radius: 14px; background: var(--bg); color: var(--text); caret-color: var(--sun); padding: 12px 14px; font: inherit; font-size: 17px; font-weight: 700; user-select: text; -webkit-user-select: text; }
.field select { height: 52px; padding: 0 12px; }
.field textarea { resize: vertical; min-height: 110px; line-height: 1.4; }
.field textarea::placeholder { color: var(--muted); opacity: 1; font-weight: 600; }
.field textarea:focus, .field select:focus { outline: none; border-color: var(--sun); }
.help { max-height: calc(100dvh - 32px); overflow-y: auto; }
.help-steps { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 10px; }
.help-steps li { padding-left: 4px; }
.help-steps b { display: block; font-size: 16px; }
.help-steps span { font-size: 14px; font-weight: 600; color: var(--text2); }
.faq { display: flex; flex-direction: column; gap: 8px; }
.faq details { border-radius: 14px; background: var(--panel2); border: 2px solid var(--line); padding: 0 14px; }
.faq summary { min-height: 48px; display: flex; align-items: center; font-weight: 800; cursor: pointer; list-style: none; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: '+'; margin-left: auto; font-size: 22px; color: var(--sun); }
.faq details[open] summary::after { content: '−'; }
.faq p { margin: 0 0 14px; font-size: 15px; font-weight: 600; color: var(--text2); line-height: 1.45; }
html.look-desk .faq details { background: #FBF3E4; color: #3B2817; border-color: #D9C3A0; }
html.look-desk .faq p { color: #5A4632; }
/* Mile High Animation logo in the header, flipped to white for the dark header (colors keep their hue) */
.mha-top { display: flex; align-items: center; flex-shrink: 0; padding: 0 6px; }
.mha-top img { display: block; height: 34px; width: auto; filter: invert(1) hue-rotate(180deg); }
.lesson-app .mha-top img, .app .mha-top img { height: 28px; }
@media (max-width: 900px) { .lesson-app .mha-top, .app .mha-top { display: none; } }
@media (max-width: 640px) { .mha-top { display: none; } }
/* The header brand is the Mile High Animation logo, flipped to white for the dark header (colors keep their hue) */
.mha-brand { padding-right: 14px; }
.mha-logo { display: block; height: 40px; width: auto; filter: invert(1) hue-rotate(180deg); }
.lesson-app .mha-logo, .app .mha-logo { height: 32px; }
@media (max-width: 640px) { .mha-logo { height: 30px; } .lesson-app .mha-logo, .app .mha-logo { height: 24px; } }
.brand img.mha-logo, .lesson-app .brand img.mha-logo { display: block !important; width: auto !important; }
.mha-brand { border-right: none; }

.check-row { display: flex; gap: 10px; align-items: flex-start; padding: 8px 2px 0; cursor: pointer; }
.check-row input { width: 22px; height: 22px; margin-top: 2px; accent-color: var(--sun); flex: 0 0 auto; }
.check-row span { display: flex; flex-direction: column; gap: 2px; }
.check-row b { font-size: 15px; }
.check-row small { font-size: 13px; color: var(--muted); font-weight: 600; line-height: 1.3; }

.bg-upload { justify-content: space-between; }
.bg-up-icon { display: flex; align-items: center; justify-content: center; aspect-ratio: 800 / 560; border-radius: 9px; border: 2px dashed var(--line2); color: var(--muted); padding: 0 !important; }
.bg-picture { display: flex; flex-direction: column; gap: 8px; }
.bg-picture[hidden] { display: none; }
.check.consent { align-items: flex-start; font-size: 14px; font-weight: 600; line-height: 1.4; }
.check.consent input { flex: 0 0 auto; margin-top: 1px; }
.check.consent a { color: var(--sun); }

/* Sounds: the picker, the timeline button, and the note on frames that have a sound */
.snd-dialog { width: min(680px, 100%); max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); overflow: auto; }
/* On phones: smaller sound tiles, so more fit and the window stays on screen */
@media (max-width: 700px), (max-height: 500px) {
  .snd-grid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 6px; }
  .snd-tile { min-height: 62px; padding: 6px 4px; border-radius: 12px; font-size: 13px; }
  .snd-emoji { font-size: 22px; }
  .snd-tabs { grid-template-columns: repeat(4, 1fr); gap: 4px; }
  .snd-tabs button { height: 36px; font-size: 12px; }
  .snd-dialog .pop-head h2 { font-size: 20px; }
  .snd-mic { width: 56px; height: 56px; }
}
.snd-tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.snd-tabs button { height: 42px; min-width: 0; padding: 0 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.snd-clear { color: var(--danger); }
.snd-trim { margin-top: 12px; padding: 12px; border-radius: 18px; background: var(--panel2); border: 2px solid var(--line2); display: flex; flex-direction: column; gap: 10px; }
.snd-trim-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.snd-wave { position: relative; height: 96px; border-radius: 12px; background: var(--bg); touch-action: none; cursor: ew-resize; user-select: none; -webkit-user-select: none; }
.snd-wave canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.snd-h { position: absolute; top: -6px; bottom: -6px; width: 4px; margin-left: -2px; border-radius: 2px; background: var(--sun); }
.snd-h::after { content: ''; position: absolute; left: 50%; top: 50%; width: 22px; height: 34px; margin: -17px 0 0 -11px; border-radius: 8px; background: var(--sun); box-shadow: 0 2px 6px rgba(0,0,0,0.35); }
.snd-h:focus-visible { outline: 3px solid var(--text); outline-offset: 2px; }
.snd-trim-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.snd-trim-btns .btn { flex: 1 1 100px; }
.snd-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; }
.snd-tile { position: relative; min-height: 84px; padding: 10px 8px; border-radius: 16px; border: 2px solid var(--line2); background: var(--panel2); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-weight: 800; font-size: 14px; text-align: center; }
.snd-tile.on { border-color: var(--sun); background: #3A3220; }
.snd-emoji { font-size: 28px; line-height: 1; }
.snd-mini { position: absolute; top: 4px; right: 4px; display: flex; gap: 2px; }
.snd-mini span { width: 26px; height: 26px; border-radius: 13px; display: flex; align-items: center; justify-content: center; font-size: 13px; background: var(--chip); }
.snd-fx { display: flex; flex-direction: column; gap: 6px; }
.snd-fx.off { opacity: 0.4; pointer-events: none; }
.snd-fx .seg { flex-wrap: wrap; }
.snd-fx .seg button { flex: 1 1 90px; height: 40px; font-size: 14px; }
.snd-foot { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.snd-foot .spacer { flex: 1; }
.snd-rec { display: flex; align-items: center; gap: 14px; padding: 12px; border-radius: 18px; background: var(--panel2); margin-bottom: 10px; }
.snd-mic { width: 72px; height: 72px; flex-shrink: 0; border-radius: 36px; background: #E0405A; color: #fff; display: flex; align-items: center; justify-content: center; }
.snd-mic.live { animation: snd-pulse 1s ease-in-out infinite; }
@keyframes snd-pulse { 50% { box-shadow: 0 0 0 10px rgba(224, 64, 90, 0.25); } }
.snd-rec-words { display: flex; flex-direction: column; gap: 4px; }
.snd-meter { display: inline-block; width: 120px; height: 10px; border-radius: 5px; background: var(--line); overflow: hidden; vertical-align: middle; }
.snd-meter i { display: block; height: 100%; width: 0; background: var(--mint); }
.snd-private { margin: 10px 0 0; }
.snd-badge { position: absolute; left: -8px; top: -11px; height: 22px; min-width: 22px; padding: 0 5px; border-radius: 11px; background: #B06CFF; color: #1A0B30; font-size: 13px; font-weight: 800; display: flex; align-items: center; justify-content: center; }
.tbtn.has-sound { background: #3A2A55; }
@media (max-width: 700px) { .snd-badge { height: 18px; min-width: 18px; font-size: 11px; top: -9px; } }
.snd-tile:has(.snd-mini) { padding-top: 32px; }

/* Color wheel for changing a palette swatch */
.wheel-pop { align-items: stretch; }
.wheel-box { position: relative; margin: 0 auto; touch-action: none; }
.wheel-box canvas { display: block; border-radius: 50%; touch-action: none; cursor: crosshair; }
.wheel-dot { position: absolute; width: 26px; height: 26px; margin: -13px 0 0 -13px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 2px rgba(0,0,0,.45), 0 2px 6px rgba(0,0,0,.4); pointer-events: none; }
.wheel-now { width: 30px; height: 30px; border-radius: 10px; border: 2px solid var(--line2); flex: none; }
.wheel-pop #wVal { -webkit-appearance: none; appearance: none; height: 14px; border-radius: 7px; border: 2px solid var(--line2); }
.wheel-pop #wVal::-webkit-slider-thumb { -webkit-appearance: none; width: 26px; height: 26px; border-radius: 50%; background: #fff; border: 3px solid var(--sun); }
.wheel-pop #wVal::-moz-range-thumb { width: 22px; height: 22px; border-radius: 50%; background: #fff; border: 3px solid var(--sun); }
.wheel-quick { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.wheel-quick .sw { height: 30px; border-radius: 10px; border-width: 2px; }
/* Watching one gallery post big, with sound */
.pv-dialog { width: min(860px, 100%); max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); overflow: auto; display: flex; flex-direction: column; gap: 12px; }
.pv-stage { position: relative; display: block; width: 100%; padding: 0; border: 0; border-radius: 14px; overflow: hidden; background: #fff; cursor: pointer; }
.pv-stage canvas { display: block; width: 100%; aspect-ratio: 800 / 560; }
.pv-big { position: absolute; left: 50%; top: 50%; width: 76px; height: 76px; margin: -38px 0 0 -38px; border-radius: 38px; background: rgba(18,19,24,0.78); color: #fff; font-size: 30px; display: flex; align-items: center; justify-content: center; padding-left: 5px; }
.pv-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pv-note { margin-left: auto; }

/* Perspective shots in the Background menu */
.bg-persp { display: flex; flex-direction: column; gap: 8px; }
.shot-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.shot-opt { display: flex; flex-direction: column; gap: 2px; padding: 4px; border-radius: 12px; border: 2px solid var(--line2); text-align: left; color: var(--text); }
.shot-opt img { width: 100%; aspect-ratio: 800 / 560; border-radius: 8px; display: block; }
.shot-opt b { font-size: 13px; padding: 0 3px; }
.shot-opt small { font-size: 11px; color: var(--muted); padding: 0 3px 2px; line-height: 1.2; }
.shot-opt[aria-checked="true"] { border-color: var(--sun); background: var(--line); }
/* The guide and perspective toolbar, floating on the paper */
.editbar { position: absolute; top: 10px; right: 10px; z-index: 6; width: min(300px, calc(100% - 20px)); max-height: calc(100% - 20px); overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y;
  padding: 12px; border-radius: 18px; background: var(--chip); border: 1px solid var(--line2); box-shadow: 0 10px 28px rgba(0,0,0,0.45); display: flex; flex-direction: column; gap: 8px; color: var(--text); }
.editbar > * { flex-shrink: 0; }
.eb-head { display: flex; align-items: center; gap: 8px; }
.eb-head b { flex: 1; font-family: 'Fredoka', sans-serif; font-weight: 600; font-size: 18px; }
.eb-done { height: 38px; padding: 0 16px; border-radius: 19px; background: var(--sun); color: #121318; font-weight: 900; font-size: 14px; }
.eb-min { width: 38px; height: 38px; border-radius: 19px; background: var(--line2); font-size: 14px; }
.eb-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.eb-row .btn { height: 40px; padding: 0 14px; font-size: 14px; flex: 1; }
.eb-row.seg button { height: 40px; }
.eb-lbl { width: 78px; font-size: 13px; font-weight: 800; color: var(--text2); }
.eb-step { width: 40px; height: 40px; border-radius: 20px; background: var(--line2); font-size: 20px; font-weight: 900; }
.eb-val { min-width: 30px; text-align: center; font-size: 17px; }
.editbar select { flex: 1; height: 40px; border-radius: 12px; border: 2px solid var(--line2); background: var(--panel2); color: var(--text); font: inherit; font-weight: 800; padding: 0 8px; }
.editbar input[type="range"] { flex: 1; accent-color: var(--sun); height: 32px; }
.editbar .btn.main { width: 100%; }
.eb-sel { padding-top: 6px; border-top: 1px solid var(--line2); }
@media (max-width: 700px) and (orientation: portrait) { .editbar { top: 6px; right: 6px; padding: 10px; width: min(270px, calc(100% - 12px)); } }
.editbar.mini { width: auto; }
.eb-mini-info { font-size: 13px; font-weight: 800; color: var(--text2); white-space: nowrap; }
html.look-desk .editbar { background: #3A281A; border-color: #6E553D; }

/* Focus music button in the top bar: iPad and computer screens */
.focus-mini { display: flex; align-items: center; gap: 4px; height: 44px; padding: 3px; border-radius: 22px; background: var(--panel2); flex-shrink: 0; }
.focus-mini button { height: 38px; border-radius: 19px; display: flex; align-items: center; justify-content: center; gap: 6px; font-weight: 800; font-size: 13px; color: var(--text); }
.fm-play { width: 38px; background: var(--line2); font-size: 13px; }
.focus-mini.on .fm-play { background: var(--sun); color: #121318; }
.fm-open { padding: 0 10px 0 8px; }
.fm-open span { max-width: 150px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 1100px) { .fm-open span { display: none; } .fm-open { width: 38px; padding: 0; } }
@media (max-width: 700px) { .focus-mini { display: none; } }

/* Brush picker (sandbox and lessons) */
.brush-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(124px, 1fr)); gap: 8px; }
.brush-pick { display: flex; flex-direction: column; align-items: stretch; gap: 4px; padding: 6px 6px 8px; border-radius: 14px; background: var(--panel2); border: 2px solid var(--line); color: var(--text); font: inherit; font-size: 14px; font-weight: 800; cursor: pointer; }
.brush-pick canvas { width: 100%; height: 44px; border-radius: 8px; background: #fff; display: block; }
.brush-pick[aria-checked="true"] { border-color: var(--sun); background: #3A3220; }
.brush-pick:focus-visible { outline: 3px solid var(--sun); outline-offset: 2px; }
.brush-dlg { width: min(460px, 100%); }
.gap-demo { border-radius: 10px; background: #fff; overflow: hidden; line-height: 0; }
.eb-ease input[type="range"] { flex: 1; min-width: 90px; accent-color: var(--sun); }
.eb-end { font-size: 12px; font-weight: 700; color: var(--muted); }
.eb-count { margin: 0; }

/* Camera joystick (perspective backgrounds) */
.joy { display: flex; align-items: center; gap: 14px; padding: 10px; border-radius: 16px; background: var(--panel2); }
.joy-pad { position: relative; flex: 0 0 auto; width: 112px; height: 112px; border-radius: 56px; background: radial-gradient(circle at 50% 45%, #2E3140, #17181E); border: 2px solid var(--line2); touch-action: none; cursor: grab; box-shadow: inset 0 4px 14px rgba(0,0,0,0.5); }
.joy-knob { position: absolute; left: 50%; top: 50%; width: 46px; height: 46px; margin: -23px 0 0 -23px; border-radius: 23px; border: 0; background: radial-gradient(circle at 40% 35%, #FFE38A, #FFC93C 55%, #D99A0B); box-shadow: 0 4px 10px rgba(0,0,0,0.45), inset 0 2px 0 rgba(255,255,255,0.5); transition: transform 0.18s cubic-bezier(.3, 1.6, .5, 1); pointer-events: none; }
.joy-knob.held { transition: none; }
.joy-knob:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.joy-arrows { position: absolute; left: 50%; top: 6px; transform: translateX(-50%); font-size: 10px; color: var(--muted); pointer-events: none; }
.joy-arrows.b { top: auto; bottom: 6px; }
.joy-arrows.r { left: auto; right: 7px; top: 50%; transform: translateY(-50%); }
.joy-arrows.l { left: 7px; top: 50%; transform: translateY(-50%); }
.joy-side { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.joy-side small { color: var(--text2); font-weight: 700; font-size: 13px; }
.joy-side .btn { height: 38px; padding: 0 14px; font-size: 14px; align-self: flex-start; }

/* The Guide lessons' coach card (studio?coach=…) */
.coach { position: absolute; left: 10px; bottom: 10px; z-index: 5; width: min(340px, calc(100% - 20px)); max-height: calc(100% - 20px); overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 8px; padding: 12px 14px; border-radius: 18px; background: rgba(30, 32, 41, 0.97); border: 2px solid var(--sun); box-shadow: 0 12px 30px rgba(0,0,0,0.5); color: var(--text); }
.coach.mini { width: min(260px, calc(100% - 20px)); }
.co-head { display: flex; align-items: center; gap: 8px; }
.co-kicker { flex: 1; font-size: 11px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; color: var(--sun); }
.co-min { width: 32px; height: 32px; border-radius: 16px; background: var(--chip); color: var(--text); border: 0; font-size: 14px; }
.co-chips { display: flex; gap: 4px; flex-wrap: wrap; }
.co-chip { font-size: 11px; font-weight: 800; padding: 3px 8px; border-radius: 10px; background: var(--chip); color: var(--muted); }
.co-chip.now { background: var(--sun); color: var(--bg); }
.co-chip.done { background: #1E3A2F; color: var(--mint); }
.co-title { font-family: 'Fredoka', sans-serif; font-weight: 600; font-size: 18px; line-height: 1.25; }
.co-text { margin: 0; font-size: 15px; font-weight: 600; line-height: 1.45; color: var(--text2); }
.co-say { border: 0; background: none; padding: 0 2px; font-size: 15px; cursor: pointer; }
.co-count { margin: 0; font-weight: 800; color: var(--sun); }
.co-acts { display: flex; gap: 8px; flex-wrap: wrap; }
.co-acts .btn { height: 40px; padding: 0 14px; font-size: 14px; text-decoration: none; display: inline-flex; align-items: center; }
.co-pose { width: auto; height: 150px; max-width: 100%; align-self: center; aspect-ratio: 800 / 560; border-radius: 10px; background: #fff; flex-shrink: 0; }
.co-name { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 800; color: var(--text2); }
.co-name input { height: 42px; border-radius: 12px; border: 2px solid var(--line2); background: var(--bg); color: var(--text); font: inherit; font-size: 16px; padding: 0 10px; }
.coach > * { flex-shrink: 0; }
.paper .coach canvas.co-pose { position: static; inset: auto; display: block; width: auto; height: 150px; touch-action: auto; }

/* The project name in the studio's top bar: tap to rename */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.proj-title { display: flex; align-items: center; gap: 4px; min-width: 0; flex-shrink: 0; }
.proj-name { min-width: min(8.5em, 34vw); max-width: 40vw; height: 40px; padding: 0 8px; border-radius: 10px; border: 2px solid transparent; background: transparent; color: var(--text); font: inherit; font-size: inherit; font-weight: 600; text-overflow: ellipsis; }
.proj-name::placeholder { color: var(--muted); }
.proj-name:hover { border-color: var(--line2); }
.proj-name:focus { outline: none; border-color: var(--sun); background: var(--panel2); }
.proj-pen { color: var(--muted); flex-shrink: 0; pointer-events: none; }
.proj-name:focus + .proj-pen { display: none; }
.joy { flex-wrap: wrap; }
.joy-one { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.joy-name { font-size: 12px; font-weight: 800; color: var(--text2); }
.joy-pad { width: 96px; height: 96px; border-radius: 48px; }
.joy-pad.move { background: radial-gradient(circle at 50% 45%, #263446, #141A22); }
.joy-pad.move .joy-knob { background: radial-gradient(circle at 40% 35%, #A9D8FF, #4D8BFF 55%, #2C5FC0); }
.joy-knob { width: 40px; height: 40px; margin: -20px 0 0 -20px; }

/* App pages (studio, lessons) never scroll as a page: the app box is exactly the visible screen */
html.app-page, html.app-page body { height: 100%; overflow: hidden; overscroll-behavior: none; position: fixed; inset: 0; width: 100%; }
/* Short screens (an iPad with its toolbars, Split View, Stage Manager): tighter tools so the whole rail fits */
@media (max-height: 720px) and (min-height: 501px) {
  .rail { gap: 2px; padding: 6px 0; }
  .rail .tool { min-height: 0; height: auto; padding: 4px 0; font-size: 10.5px; gap: 1px; }
  .rail .tool svg { width: 20px; height: 20px; }
  .rail-sep { margin: 2px 0; }
}
/* The coach docked at the top of the side panel (wide screens): part of the panel, not over the paper */
.side .coach.docked { position: static; width: auto; max-height: none; overflow: visible; box-shadow: none; }
.coach.mini .co-text, .coach.mini .co-acts, .coach.mini .co-pose, .coach.mini .co-count { display: none; }
html.app-page body { touch-action: manipulation; }

/* The Storyboarding module plan (staging only) on the lessons page */
.sb-plan { margin-top: 28px; padding: 20px; border-radius: 22px; border: 2px dashed #7B61FF; background: rgba(123, 97, 255, 0.07); display: flex; flex-direction: column; gap: 10px; }
.sb-head h2 { margin: 2px 0 4px; font-family: 'Fredoka', sans-serif; font-weight: 600; font-size: 26px; }
.sb-part { margin: 10px 0 0; font-size: 15px; color: var(--sun); }
.sb-list { margin: 0; padding-left: 26px; display: flex; flex-direction: column; gap: 6px; }
.sb-list li { padding: 8px 10px; border-radius: 12px; background: var(--panel); }
.sb-list li b { display: block; }
.sb-list li span { color: var(--text2); font-size: 14px; font-weight: 600; }
.sb-list li i { float: right; font-style: normal; font-size: 11px; font-weight: 800; padding: 2px 8px; border-radius: 10px; background: #2A2440; color: #B8A6FF; }
.sb-list li a { display: block; color: var(--text); text-decoration: none; }
.sb-list li:hover { outline: 2px solid var(--sun); }
.sb-list li i.sb-stage { float: right; }
.sb-stage.s-drafting { background: #3A3220; color: var(--sun); }
.sb-stage.s-recording { background: #23324A; color: #9CC3FF; }
.sb-stage.s-ready { background: #1E3A2F; color: var(--mint); }

/* Frames with nothing drawn yet: a red outline, so missing drawings are easy to spot */
.frame.blank { border-color: #FF4D5E; background: rgba(255, 77, 94, 0.16); }
.frame.blank img { opacity: 0.7; }
.frame.blank.cur { border-color: var(--sun); box-shadow: 0 0 0 3px #FF4D5E; }
/* The Add button stays put beside the timeline */
.add-fixed { flex-direction: column; gap: 2px; border: 2px dashed var(--sun); color: var(--sun); background: rgba(255, 201, 60, 0.08); cursor: pointer; font: 800 12px/1 Nunito, sans-serif; }
.add-fixed span { font-size: 12px; }
.buy-row .small-btn { min-height: 32px; padding: 0 12px; font-size: 13px; margin-left: 8px; }
.quiet-link { display: block; margin-top: 4px; padding: 6px 0; background: none; border: 0; color: var(--muted); font: 600 12px/1.4 Nunito, sans-serif; text-decoration: underline; text-align: left; cursor: pointer; }
