/* ==========================================================================
   Art Studio C (previews/storybook-home/art.html): the art room round the live drawing script.
   Every id, class and data- attribute the live script reads is kept (see
   docs/workstreams/studio-gallery-c/art/live-parts.md). Only transform and opacity move.
   Layouts: desktop 1001+ (rail | paper | tray), compact 1000 and narrower (the live script's
   own phone switch), phone 760 and narrower.
   ========================================================================== */

[hidden] { display: none !important; }
html { scrollbar-gutter: auto; height: 100%; }
body.studio-c {
  height: 100%; overflow: hidden; color: var(--ink);
  background: radial-gradient(ellipse 60% 60% at 50% 46%, #86c6f4 0, #6cb6ee 40%, #4ea3e6 85%);
  --big: clamp(50px, 7.9vh, 72px);
  --small: clamp(44px, 5.6vh, 52px);
  --tray-w: 206px;
}
.studio-c button { cursor: pointer; }
.studio-c button:disabled { cursor: default; }
.studio-c svg { fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.skip-link { position: fixed; left: 12px; top: -80px; z-index: 100; padding: 10px 16px; border-radius: 999px; background: var(--paper); border: 2.5px solid var(--ink); font: 700 15px/1 var(--font-display); }
.skip-link:focus { top: 10px; }
.eyebrow { font: 800 13px/1.1 var(--font-label); letter-spacing: .12em; text-transform: uppercase; color: #01639a; }

/* ---------- Shared buttons ---------- */
.pill {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; flex: none;
  min-height: 44px; padding: 0 18px; border-radius: 999px; border: 2.5px solid var(--ink);
  background: var(--paper); color: var(--ink); box-shadow: 0 4px 0 var(--ink);
  font: 700 16px/1 var(--font-display); white-space: nowrap; transition: transform .15s, box-shadow .15s;
}
.pill svg { width: 19px; height: 19px; flex: none; }
.pill:hover:not(:disabled) { transform: translateY(-2px); }
.pill:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.pill:disabled, .round:disabled { opacity: .45; }
.pill--gold { background: var(--gold); padding: 0 22px; font-size: 17px; }
.pill--dark { background: var(--ink); color: var(--cream); box-shadow: 0 4px 0 var(--ink-deep); }
.pill--small { padding: 0 16px; box-shadow: 0 3px 0 var(--ink); }
.pill--wide { width: 100%; }
.round {
  display: inline-flex; align-items: center; justify-content: center; flex: none; width: 44px; height: 44px; padding: 0;
  border-radius: 50%; border: 2.5px solid var(--ink); background: var(--paper); color: var(--ink);
  box-shadow: 0 3px 0 var(--ink); font: 800 24px/1 var(--font-display); transition: transform .15s;
}
.round svg { width: 20px; height: 20px; }
.round:active:not(:disabled) { transform: translateY(2px); }
.round-close {
  display: block; flex: none; width: 44px; height: 44px; border-radius: 50%; border: 2.5px solid var(--ink);
  background: var(--paper) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 6l12 12M18 6 6 18' fill='none' stroke='%2310244a' stroke-width='3' stroke-linecap='round'/%3E%3C/svg%3E") center/20px no-repeat;
  box-shadow: 0 4px 0 var(--ink); font-size: 0; color: transparent; overflow: hidden; white-space: nowrap;
}

/* ---------- Top row ---------- */
.studio-header { position: fixed; z-index: 10; top: 0; left: 0; right: 0; height: 64px; display: flex; align-items: center; gap: 14px; padding: 0 18px; }
.studio-brand { flex: none; line-height: 0; }
.studio-brand img { width: 80px; height: auto; }
.project-name { flex: none; }
#project-title {
  width: 300px; height: 44px; padding: 0 18px; border-radius: 999px; border: 2.5px solid var(--ink);
  background: var(--paper); box-shadow: 0 3px 0 var(--ink); font: 800 18px/1 var(--font-display); color: var(--ink);
}
.save-box { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; }
.save-state { margin-right: auto; min-width: 0; display: flex; align-items: center; gap: 6px; font: 700 var(--body-max)/1.3 var(--font-body); }
.save-state svg { width: 16px; height: 16px; flex: none; stroke-width: 3; }
#share-art { flex: none; }
#episode-link { margin-left: 4px; }

/* ---------- The studio grid (desktop) ---------- */
.studio-app {
  position: fixed; top: 64px; left: 0; right: 0; bottom: 0; z-index: 2;
  display: grid; padding: 12px 12px 0; column-gap: 10px; row-gap: 12px;
  grid-template-columns: 166px minmax(0, 1fr) var(--tray-w);
  grid-template-rows: minmax(0, 1fr) 56px 38px;
}
.room-floor {
  position: fixed; left: 0; right: 0; bottom: 0; height: 42px; z-index: 1;
  background: repeating-linear-gradient(90deg, #e7a64a 0 148px, #d4923a 148px 151px); border-top: 4px solid var(--ink);
}
.room-floor::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 6px; background: #f3c071; }
.room-floor span { position: absolute; border-radius: 50%; opacity: .9; }
.room-floor span:nth-child(1) { left: 60px; top: 12px; width: 46px; height: 14px; background: #ec1c24; transform: rotate(-8deg); }
.room-floor span:nth-child(2) { right: 56px; top: 8px; width: 54px; height: 16px; background: #0284ca; transform: rotate(6deg); }
.room-floor span:nth-child(3) { left: 21%; top: 20px; width: 18px; height: 8px; background: var(--gold); }

/* Rail of toy tools */
.tool-dock {
  grid-area: 1 / 1 / 2 / 2; align-self: start; z-index: 4; --focus: var(--gold-light);
  display: flex; flex-direction: column; padding: 16px 8px; border-radius: 30px;
  background: radial-gradient(circle at 7px 7px, #1f3d73 0 2.2px, transparent 2.8px) 0 0/16px 16px, var(--ink);
  box-shadow: 0 6px 0 var(--ink-deep);
}
.tool-group { display: grid; grid-template-columns: 75px 75px; justify-content: center; justify-items: center; row-gap: 12px; }
.rail-small { margin-top: 14px; padding-top: 14px; border-top: 2px dashed rgba(255, 247, 232, .35); row-gap: 10px; }
.dock-tool { display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 44px; padding: 0; margin: 0; border: 0; background: none; color: var(--cream); }
.dock-tool:focus-visible { outline: none; }
.dock-tool:focus-visible .toy { outline: 3px solid var(--focus); outline-offset: 5px; }
.toy {
  position: relative; display: flex; align-items: center; justify-content: center; width: var(--big); height: var(--big);
  border-radius: 50%; background: var(--paper); border: 2.5px solid var(--ink); box-shadow: 0 4px 0 var(--ink-deep);
  transition: transform .25s var(--ease-pop), box-shadow .2s, background-color .2s;
}
.toy img, .toy svg { width: 90%; height: 90%; object-fit: contain; transform: rotate(-8deg); filter: drop-shadow(0 3px 2px rgba(16, 36, 74, .25)); }
.dock-help .toy svg { width: 66%; height: 66%; transform: none; filter: none; }
.dock-tool--small .toy { width: var(--small); height: var(--small); }
.tool-name { display: inline-block; padding: 4px 8px 3px; border-radius: 999px; font: 800 13px/1 var(--font-label); letter-spacing: .08em; text-transform: uppercase; white-space: nowrap; transition: background-color .2s, color .2s; }
.dock-tool--small .tool-name { font-size: 12px; padding: 1px 6px; }
.dock-tool:hover .toy { transform: translateY(-3px); }
.dock-tool[aria-pressed="true"] .toy,
body[data-studio-panel="stickers"] .dock-tool[data-panel="stickers"] .toy,
body[data-studio-panel="text"] .dock-tool[data-panel="text"] .toy {
  background: #fff3d6; transform: translateY(-5px) scale(1.08);
  box-shadow: 0 0 0 4px var(--gold), 0 0 0 6.5px var(--ink), 0 14px 14px rgba(7, 22, 49, .45);
}
.dock-tool[aria-pressed="true"] .tool-name,
body[data-studio-panel="stickers"] .dock-tool[data-panel="stickers"] .tool-name,
body[data-studio-panel="text"] .dock-tool[data-panel="text"] .tool-name { background: var(--gold); color: var(--ink); }

/* The paper */
.work-area { grid-area: 1 / 2 / 2 / 3; position: relative; z-index: 1; min-width: 0; min-height: 0; }
/* The viewport bleeds 40px past the paper area so the live fit() padding (80px) is used up exactly. */
.canvas-viewport { position: absolute; inset: -40px; overflow: hidden; touch-action: none; }
.canvas-stage { position: absolute; top: 50%; left: 50%; transform-origin: 0 0; background: #fff; will-change: transform; box-shadow: 0 0 0 3px var(--ink), 0 20px 44px rgba(16, 36, 74, .32); }
.canvas-stage canvas { display: block; width: 100%; height: 100%; touch-action: none; outline-offset: 9px; }
.canvas-stage #selection { position: absolute; inset: 0; pointer-events: none; }
.canvas-stage #canvas:focus-visible { outline: 4px solid var(--gold); }
.drawing-trace { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.drawing-trace path { fill: none; stroke: #2176a5; stroke-width: 1.6; stroke-dasharray: 5 5; opacity: .7; }
.tape { position: absolute; width: 7%; height: 3.3%; pointer-events: none; box-shadow: 0 2px 3px rgba(16, 36, 74, .18); z-index: 2; }
.tape--tl { left: -2.6%; top: .2%; background: rgba(246, 163, 19, .82); transform: rotate(-38deg); }
.tape--tr { right: -2.6%; top: .2%; background: rgba(2, 132, 202, .72); transform: rotate(38deg); }
.tape--bl { left: -2.6%; bottom: .2%; background: rgba(236, 28, 36, .7); transform: rotate(38deg); }
.tape--br { right: -2.6%; bottom: .2%; background: rgba(246, 163, 19, .82); transform: rotate(-38deg); }
.canvas-loading { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.canvas-loading strong { padding: 12px 22px; border-radius: 999px; background: var(--paper); border: 2.5px solid var(--ink); font: 800 18px/1.2 var(--font-display); }
.art-status {
  position: absolute; z-index: 3; left: 50%; top: 14px; max-width: min(80%, 560px); padding: 8px 16px; border-radius: 999px;
  background: var(--paper); border: 2px solid var(--ink); box-shadow: 0 3px 0 var(--ink); font: 700 var(--body-max)/1.35 var(--font-body);
  text-align: center; pointer-events: none; opacity: 0; transform: translate(-50%, 8px); transition: opacity .35s, transform .35s;
}
.art-status.is-showing { opacity: 1; transform: translate(-50%, 0); }
.paper-bar {
  position: absolute; z-index: 3; left: 10px; bottom: 10px; display: flex; flex-wrap: wrap; gap: 6px; max-width: calc(100% - 20px);
  padding: 8px; border-radius: 18px; background: #fff3d6; border: 2.5px solid var(--ink); box-shadow: 0 4px 0 var(--ink);
}
.paper-bar button { min-width: 44px; height: 44px; padding: 0 12px; border-radius: 12px; border: 2px solid var(--ink); background: var(--paper); color: var(--ink); box-shadow: 0 2px 0 var(--ink); font: 700 15px/1 var(--font-display); }
.paper-bar button:disabled { opacity: .45; }
.paper-bar .paper-bar__dark { background: var(--ink); color: var(--cream); }
html.motion .paper-bar:not([hidden]) { animation: pop-in .35s var(--ease-pop) backwards; }

/* The slim strip under the paper */
.strip {
  grid-area: 2 / 2 / 3 / 3; z-index: 3; display: flex; align-items: center; gap: 6px; padding: 0 6px; min-width: 0;
  border-radius: 20px; background: var(--paper); border: 2.5px solid var(--ink); box-shadow: 0 4px 0 var(--ink);
}
.strip #reset-art { margin-left: 4px; }
.strip__rule { width: 2px; height: 30px; margin: 0 6px; background: rgba(16, 36, 74, .2); flex: none; }
.zoom-controls { display: flex; align-items: center; gap: 4px; }
#zoom-label { min-width: 54px; text-align: center; font: 800 17px/1 var(--font-display); }
#zoom-fit { margin-left: 4px; }
.mobile-panels { grid-area: 2 / 2 / 3 / 3; z-index: 4; justify-self: end; align-self: center; margin-right: 8px; display: flex; gap: 6px; }
.mobile-panels button {
  display: inline-flex; align-items: center; gap: 7px; height: 44px; padding: 0 16px 0 13px; border-radius: 14px;
  border: 2.5px solid var(--ink); background: var(--paper); color: var(--ink); box-shadow: 0 3px 0 var(--ink); font: 700 16px/1 var(--font-display);
}
.mobile-panels svg { width: 18px; height: 18px; stroke-width: 2.4; }
.mobile-panels button[aria-pressed="true"] { background: var(--ink); color: var(--cream); box-shadow: 0 3px 0 var(--ink-deep); }
@media (max-width: 1360px) and (min-width: 1001px) {
  .mobile-panels button { padding: 0 11px; }
  .mobile-panels svg { display: none; }
  .strip__rule { margin: 0 2px; }
}

/* ---------- The tray (narrow for colours, a wide drawer for everything else) ---------- */
.tray-bg { display: none; }
.inspector {
  position: absolute; z-index: 5; top: 12px; right: 12px; bottom: 50px; width: var(--tray-w);
  display: flex; flex-direction: column; padding: 10px; border-radius: 26px; background: var(--paper);
  border: 2.5px solid var(--ink); box-shadow: 0 6px 0 var(--ink); overflow: hidden;
}
body:not([data-studio-panel="colours"]) .inspector { width: 316px; bottom: 118px; padding: 58px 14px 12px; }
.inspector.is-arriving { animation: drawer-in .45s cubic-bezier(.2, .8, .2, 1) backwards; }
.inspector-tabs, .inspector-foot { display: none; }
.close-panel { display: none; }
.drawer-close { position: absolute; z-index: 3; top: 10px; right: 10px; display: none; }
.drawer-close svg { width: 20px; height: 20px; stroke-width: 3; }
body:not([data-studio-panel="colours"]):not([data-studio-panel="guide"]) .drawer-close { display: inline-flex; }
.drawer-close { width: 44px; height: 44px; align-items: center; justify-content: center; border-radius: 50%; border: 2.5px solid var(--ink); background: var(--paper); box-shadow: 0 3px 0 var(--ink); color: var(--ink); padding: 0; }
.inspector-scroll { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; scrollbar-width: thin; }
body[data-studio-panel="guide"] .inspector-scroll { display: none; }
.supply-panel { position: relative; }
.supply-panel h2 { margin: 4px 0 12px; font: 800 26px/1.05 var(--font-display); }
.supply-panel h2 em { font-style: normal; color: #01639a; }
.supply-panel h3 { margin: 14px 0 8px; font: 800 18px/1.1 var(--font-display); }
.panel-note { margin: 8px 0; font: 700 var(--body-max)/1.45 var(--font-body); color: var(--muted); }
.supply-link {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; min-height: 44px; margin-top: 10px; padding: 0 14px;
  border-radius: 14px; border: 2px solid var(--ink); background: var(--paper); color: var(--ink); box-shadow: 0 3px 0 var(--ink); font: 700 15px/1.1 var(--font-display); text-align: left;
}
.file-label { position: relative; cursor: pointer; }
.file-label input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.file-label:focus-within { outline: 3px solid var(--ink); outline-offset: 3px; }

/* Colours */
#panel-colours { min-height: 100%; }
.tray-head { display: flex; align-items: center; justify-content: space-between; height: 44px; }
.selected-colour { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
#colour-name { font: 800 18px/1.05 var(--font-display); min-width: 0; overflow-wrap: anywhere; }
.blob, .swatch, .custom-colour { position: relative; flex: none; width: 48px; height: 48px; padding: 0; border: 2.5px solid var(--ink); }
.blob, .swatch {
  border-radius: 50% 46% 52% 48% / 48% 52% 46% 50%; background-color: var(--swatch, #ffd85a);
  box-shadow: inset 0 -5px 0 rgba(16, 36, 74, .16), inset 4px 4px 0 rgba(255, 255, 255, .25), 0 3px 0 var(--ink);
}
.blob::after, .swatch::after { content: ""; position: absolute; left: 22%; top: 16%; width: 30%; height: 24%; border-radius: 50%; background: radial-gradient(circle, rgba(255, 255, 255, .95) 0 35%, rgba(255, 255, 255, 0) 72%); pointer-events: none; }
.swatch:nth-child(3n+2) { border-radius: 47% 53% 49% 51% / 52% 47% 53% 48%; }
.swatch:nth-child(3n) { border-radius: 52% 48% 47% 53% / 49% 51% 50% 50%; }
.swatch { transition: transform .2s var(--ease-pop); }
.swatch:hover { transform: translateY(-2px); }
.swatch[aria-pressed="true"] { box-shadow: inset 0 -5px 0 rgba(16, 36, 74, .16), 0 0 0 3px var(--paper), 0 0 0 6px var(--ink); }
.swatch.is-squish, [data-size-dots] button.is-squish { animation: squish .32s ease-out; }
.blob--big { width: 48px; height: 48px; }
.blob-grid { display: grid; grid-template-columns: repeat(3, 48px); justify-content: center; gap: 8px 10px; margin-top: 12px; }
.palette { display: contents; }
.custom-colour { display: flex; align-items: center; justify-content: center; border-radius: 50%; border-style: dashed; background: var(--paper); font: 800 24px/1 var(--font-display); cursor: pointer; }
.custom-colour input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.custom-colour:focus-within { outline: 3px solid var(--ink); outline-offset: 3px; }
.palette-tabs { display: flex; gap: 3px; margin-top: 12px; }
.palette-tabs button { flex: 1 1 0; min-width: 0; height: 44px; padding: 0 2px; border-radius: 14px; border: 2px solid var(--ink); background: var(--paper); color: var(--ink); font: 800 12px/1 var(--font-label); letter-spacing: .05em; text-transform: uppercase; }
.palette-tabs button[aria-pressed="true"] { background: var(--ink); color: var(--cream); }
.size-row { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; padding-top: 12px; border-top: 2px dashed rgba(16, 36, 74, .25); }
.size-row__label { font: 800 13px/1 var(--font-label); letter-spacing: .12em; text-transform: uppercase; }
.size-row__value { font: 800 15px/1 var(--font-display); }
.size-dots { display: flex; justify-content: space-between; margin-top: 6px; }
.size-dots button { display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; padding: 0; border-radius: 12px; border: 2px solid transparent; background: transparent; }
.size-dots button span { display: block; width: var(--d); height: var(--d); border-radius: 50%; background: var(--ink); }
.size-dots button[aria-pressed="true"] { border-color: var(--ink); background: #ffefce; }
.tray-note { margin-top: 8px; font: 700 var(--body-max)/1.4 var(--font-body); color: var(--muted); }
.tray-more {
  position: absolute; z-index: 4; left: 0; right: 0; top: 50px; padding: 12px; border-radius: 18px; background: var(--paper);
  border: 2.5px solid var(--ink); box-shadow: 0 5px 0 var(--ink); display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; font: 700 var(--body-max)/1.35 var(--font-body);
}
html.motion .tray-more:not([hidden]) { animation: pop-in .3s var(--ease-pop) backwards; }
.tray-more__now { display: grid; gap: 2px; overflow-wrap: anywhere; }
.tray-more__now strong { font: 800 16px/1.1 var(--font-display); }
.tool-indicator { display: none; }
.range-title { display: flex; justify-content: space-between; align-items: center; gap: 8px; font: 800 var(--body-max)/1 var(--font-label); letter-spacing: .08em; text-transform: uppercase; }
.range-title output { font: 800 14px/1 var(--font-display); letter-spacing: 0; text-transform: none; }
.brush-settings input[type="range"] { width: 100%; height: 44px; margin: 0; accent-color: var(--ink); }
.brush-preview { display: flex; justify-content: center; align-items: center; height: 36px; }
#brush-dot { display: block; width: 18px; height: 18px; border-radius: 50%; background: var(--ink); border: 1px solid rgba(16, 36, 74, .3); }
.tray-more__row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
#colour-hex { font: 800 14px/1 var(--font-display); }
.canvas-colour { display: flex; align-items: center; gap: 6px; font: 800 var(--body-max)/1 var(--font-label); text-transform: uppercase; letter-spacing: .08em; }
.canvas-colour input { width: 44px; height: 44px; padding: 0; border: 2px solid var(--ink); border-radius: 12px; background: none; }
.little-tip p { color: var(--muted); }

/* Pages: the three ways (live, from the guide module) and the pages */
#drawing-routes { display: none; }
body[data-studio-panel="pages"] #drawing-routes { display: block; margin-bottom: 10px; }
body[data-studio-panel="guide"] #drawing-routes { display: flex; flex-direction: column; flex: 1; min-height: 0; margin-top: -44px; }
body[data-studio-panel="guide"] .drawing-routes { display: none; }
.drawing-routes { display: grid; gap: 8px; }
.drawing-routes button { min-height: 48px; padding: 0 16px; border-radius: 14px; border: 2.5px solid var(--ink); background: #fff3d6; color: var(--ink); box-shadow: 0 3px 0 var(--ink); font: 800 17px/1 var(--font-display); text-align: left; }
.drawing-routes button[aria-pressed="true"] { background: var(--ink); color: var(--cream); }
.template-list { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.template-card { display: flex; flex-direction: column; gap: 6px; padding: 6px 6px 8px; border-radius: 14px; border: 2.5px solid var(--ink); background: var(--paper); color: var(--ink); box-shadow: 0 3px 0 var(--ink); text-align: left; }
.template-card img, .template-card .blank-paper { display: grid; place-items: center; width: 100%; aspect-ratio: 4 / 3; height: auto; object-fit: cover; border-radius: 9px; border: 2px solid var(--ink); background: #fff; }
.template-card .blank-paper { border-style: dashed; color: var(--gold); font: 800 34px/1 var(--font-display); }
.template-card strong { font: 800 14px/1.15 var(--font-display); }
.template-card div span { display: none; }
.template-card[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--gold), 0 0 0 5.5px var(--ink); }

/* The drawing guide, shown as a drawer over the tray */
.drawing-guide { flex: 1; min-height: 0; overflow-y: auto; display: grid; align-content: start; gap: 12px; padding-top: 2px; }
.drawing-guide-top { display: grid; grid-template-columns: 1fr auto; gap: 6px 8px; align-items: center; }
.drawing-guide-top label { grid-column: 1 / -1; font: 800 var(--body-max)/1 var(--font-label); letter-spacing: .12em; text-transform: uppercase; color: #01639a; }
.drawing-guide-top select { min-height: 44px; padding: 0 10px; border-radius: 12px; border: 2px solid var(--ink); background: var(--paper); font: 700 16px/1 var(--font-display); color: var(--ink); min-width: 0; }
.drawing-guide-top button, .drawing-guide-controls button { min-height: 44px; padding: 0 14px; border-radius: 999px; border: 2px solid var(--ink); background: var(--paper); box-shadow: 0 3px 0 var(--ink); font: 700 15px/1 var(--font-display); color: var(--ink); }
.drawing-guide-controls button[data-guide-next] { background: var(--ink); color: var(--cream); }
.drawing-example { width: 100%; height: auto; aspect-ratio: 3 / 2; border-radius: 14px; border: 2.5px solid var(--ink); background: #fff; }
.drawing-example path { fill: none; stroke: var(--ink); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.drawing-guide-body > div { display: grid; gap: 4px; margin-top: 10px; }
.guide-count { font: 800 12px/1 var(--font-label); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.guide-title { font: 800 22px/1.1 var(--font-display); }
.guide-prompt, .guide-permission, .trace-note { font: 700 var(--body-max)/1.45 var(--font-body); }
.guide-permission { color: #01639a; }
.trace-note { color: var(--muted); }
.drawing-guide-controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.drawing-guide-controls label { flex: 1 1 100%; display: flex; align-items: center; gap: 8px; min-height: 44px; font: 700 var(--body-max)/1.3 var(--font-body); }
.drawing-guide-controls input { width: 22px; height: 22px; accent-color: var(--ink); }

/* Stickers: the five friends (heights rule) and the shapes */
.sticker-poses { margin-bottom: 14px; padding: 8px; border-radius: 14px; background: var(--cream); }
.supply-panel .sticker-poses h3 { margin: 0 0 6px; }
.sticker-poses__options { display: flex; flex-wrap: wrap; gap: 6px; }
.sticker-poses__options button {
  width: 44px; height: 44px; padding: 0; overflow: hidden; border-radius: 50%;
  border: 2px solid var(--ink); background: #e9f5fe;
}
.sticker-poses__options button[aria-pressed="true"] { background: var(--gold-light); box-shadow: 0 0 0 2px var(--gold); }
.sticker-poses__options img { display: block; width: 100%; height: 100%; object-fit: contain; }
body[data-studio-panel="stickers"] .inspector.is-arriving { animation: none; }
.friend-shelf { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.character-stickers { display: contents; }
.character-stickers button {
  position: relative; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 132px; padding: 0 0 4px;
  border-radius: 16px; border: 2.5px solid var(--ink); box-shadow: 0 4px 0 var(--ink); color: var(--ink); overflow: hidden;
  background: linear-gradient(#d9effc 0 74%, #f6e4bf 74% 100%); transition: transform .2s var(--ease-pop);
}
.character-stickers button img { height: calc(var(--h, 1) * 98px); width: auto; max-width: 96%; object-fit: contain; object-position: 50% 100%; margin-bottom: -2px; }
.character-stickers button span { font: 800 13px/1 var(--font-label); letter-spacing: .1em; text-transform: uppercase; padding-top: 6px; }
.character-stickers button:hover { transform: translateY(-3px); }
.character-stickers button:active { transform: scale(.96); }
.make-friend {
  display: flex; flex-direction: column-reverse; align-items: center; justify-content: center; gap: 10px; height: 132px; padding: 8px;
  border-radius: 16px; border: 2.5px solid var(--ink); background: var(--ink); color: var(--cream); box-shadow: 0 4px 0 var(--ink-deep); font: 800 17px/1.05 var(--font-display);
}
.make-friend span { display: grid; place-items: center; width: 50px; height: 50px; border-radius: 50%; background: var(--gold); border: 2.5px solid var(--cream); color: var(--ink); font: 800 28px/1 var(--font-display); }
.shape-grid { display: grid; grid-template-columns: repeat(4, 52px); justify-content: space-between; gap: 10px; }
.shape-grid button { width: 52px; height: 52px; border-radius: 14px; border: 2.5px solid var(--ink); background: var(--paper); box-shadow: 0 3px 0 var(--ink); font: 400 26px/1 system-ui, sans-serif; }
.shape-grid button:nth-child(1) { color: #f6c343; } .shape-grid button:nth-child(2) { color: #ec1c24; }
.shape-grid button:nth-child(3) { color: #3e9bd6; } .shape-grid button:nth-child(4) { color: #ec5c99; }
.shape-grid button:nth-child(5) { color: #f6c343; } .shape-grid button:nth-child(6) { color: #2fa39a; }
.shape-grid button:nth-child(7) { color: #f49a4f; }
.shape-grid button:active { transform: translateY(2px); }

/* Text */
.field-label { display: block; margin-bottom: 6px; font: 800 var(--body-max)/1 var(--font-label); letter-spacing: .12em; text-transform: uppercase; }
#art-text { width: 100%; padding: 12px 14px; border-radius: 14px; border: 2.5px solid var(--ink); background: #fff; color: var(--ink); font: 700 18px/1.3 var(--font-display); resize: vertical; margin-bottom: 10px; }

/* Layers */
.layer-list { display: grid; gap: 6px; }
.layer-row { display: flex; gap: 6px; align-items: stretch; }
.layer-row > button:first-child { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 4px 10px 4px 4px; border-radius: 12px; border: 2px solid var(--ink); background: var(--paper); color: var(--ink); font: 700 15px/1.1 var(--font-display); text-align: left; }
.layer-row.selected > button:first-child { background: #fff3d6; box-shadow: 0 0 0 3px var(--gold); }
.layer-mini { display: grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: 9px; background: #eef6fc; font-size: 22px; overflow: hidden; }
.layer-mini img, .layer-mini canvas { width: 100%; height: 100%; object-fit: contain; }
.layer-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.layer-visible { flex: none; width: 44px; border-radius: 12px; border: 2px solid var(--ink); background: var(--paper); color: var(--ink); font-size: 18px; }
.locked-layer { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 10px; border-radius: 12px; background: rgba(16, 36, 74, .06); font: 700 var(--body-max)/1.2 var(--font-body); }
.locked-layer strong { flex: 1; font: 700 15px/1 var(--font-display); }
.locked-layer span:last-child { color: var(--muted); }

/* Saved */
.saved-top:empty { display: none; }
.saved-top { margin-bottom: 14px; }
.saved-list { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.saved-list > p { grid-column: 1 / -1; }
.saved-card { display: flex; flex-direction: column; gap: 6px; padding: 6px 6px 8px; border-radius: 14px; border: 2.5px solid var(--ink); background: var(--paper); color: var(--ink); box-shadow: 0 3px 0 var(--ink); text-align: left; }
.saved-card img { width: 100%; aspect-ratio: 3 / 2; height: auto; object-fit: cover; border-radius: 9px; border: 2px solid var(--ink); background: #fff; }
.saved-card strong { font: 800 14px/1.15 var(--font-display); overflow-wrap: anywhere; }

/* ---------- Jevika's corner ---------- */
.jevika-corner { position: absolute; z-index: 5; left: 10px; bottom: 4px; display: flex; flex-direction: column; align-items: flex-start; pointer-events: none; }
.jevika-corner > * { pointer-events: auto; }
.art-cheer-launch {
  position: relative; display: flex; align-items: center; gap: 7px; height: 46px; padding: 0 16px 0 12px; margin-left: 10px; border-radius: 24px;
  background: var(--paper); border: 2.5px solid var(--ink); box-shadow: 0 4px 0 var(--ink); color: var(--ink); font: 700 16px/1 var(--font-display); white-space: nowrap;
}
.art-cheer-launch svg { width: 20px; height: 20px; fill: var(--gold); stroke: var(--ink); stroke-width: 1.6; }
.art-cheer-launch::after { content: ""; position: absolute; left: 70px; bottom: -9px; width: 14px; height: 14px; background: var(--paper); border-right: 2.5px solid var(--ink); border-bottom: 2.5px solid var(--ink); transform: rotate(45deg); }
.jevika-frame { display: block; pointer-events: none; }
.jevika-host { display: block; width: auto; max-width: none; height: clamp(104px, 20vh, 196px); filter: drop-shadow(0 3px 0 #fff) drop-shadow(0 -3px 0 #fff) drop-shadow(3px 0 0 #fff) drop-shadow(-3px 0 0 #fff) drop-shadow(0 8px 8px rgba(16, 36, 74, .28)); }
.art-cheer-panel {
  position: fixed; z-index: 20; left: 14px; bottom: calc(clamp(104px, 20vh, 196px) + 64px); width: min(320px, calc(100vw - 28px));
  padding: 16px 16px 14px; border-radius: 22px; background: var(--paper); border: 2.5px solid var(--ink); box-shadow: 0 6px 0 var(--ink);
}
html.motion .art-cheer-panel:not([hidden]) { animation: pop-in .35s var(--ease-pop) backwards; }
.art-cheer-close { position: absolute; z-index: 2; top: 8px; right: 8px; width: 44px; height: 44px; border-radius: 50%; border: 2px solid var(--ink); background: var(--paper); font: 800 22px/1 var(--font-display); color: var(--ink); }
.character-cheers { display: grid; grid-template-columns: 72px 1fr; gap: 12px; align-items: start; position: relative; }
.character-cheers img { width: 72px; height: 72px; object-fit: contain; }
.character-cheers.is-cheering img { animation: hop .7s var(--ease-pop); }
.cheer-spark { position: absolute; left: 58px; top: -4px; color: var(--gold); font-size: 18px; }
.character-cheers strong { display: block; padding-right: 40px; font: 800 16px/1.15 var(--font-display); }
.character-cheers p { margin-top: 4px; padding-right: 36px; font: 700 var(--body-max)/1.45 var(--font-body); }
.cheer-controls { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.cheer-controls button { min-height: 44px; padding: 0 12px; border-radius: 999px; border: 2px solid var(--ink); background: var(--paper); color: var(--ink); font: 700 14px/1 var(--font-display); }
.cheer-controls button[aria-pressed="false"] { background: rgba(16, 36, 74, .08); }

/* ---------- Dialogs ---------- */
.studio-dialog { width: min(560px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); padding: 26px; border-radius: 26px; border: 3px solid var(--ink); background: var(--paper); color: var(--ink); box-shadow: 0 8px 0 var(--ink); }
.studio-dialog::backdrop, .finish::backdrop { background: rgba(7, 22, 49, .6); }
.studio-dialog h2 { margin: 4px 0 8px; font: 800 28px/1.1 var(--font-display); }
.studio-dialog p:not(.eyebrow), .studio-dialog dd { font: 700 var(--body-max)/1.5 var(--font-body); }
.dialog-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; margin-top: 18px; }
.help-dialog form { position: relative; }
.dialog-close { position: absolute; top: -8px; right: -8px; }
.help-dialog dl { display: grid; gap: 10px; margin: 14px 0 18px; }
.help-dialog dt { font: 800 16px/1.1 var(--font-display); }
.no-script { position: fixed; inset: auto 16px 16px; z-index: 50; padding: 16px; border-radius: 16px; background: var(--paper); border: 2.5px solid var(--ink); }

/* ---------- The opening ---------- */
.opening { position: fixed; inset: 0; z-index: 30; display: none; overflow-x: hidden; overflow-y: auto; background: #4ea3e6; }
html.has-opening .opening { display: block; }
.opening__room { position: fixed; inset: 0; width: 100%; height: 100%; max-width: none; object-fit: cover; object-position: 50% 62%; }
.opening__top { position: absolute; z-index: 3; top: 14px; left: 36px; right: 36px; display: flex; justify-content: space-between; align-items: center; pointer-events: none; }
.opening__top > * { pointer-events: auto; }
.opening__logo { display: block; padding: 8px 18px; border-radius: 26px; background: var(--paper); border: 2.5px solid var(--ink); box-shadow: 0 4px 0 var(--ink); line-height: 0; }
.opening__logo img { width: 84px; height: auto; }
.opening__close { width: 56px; height: 56px; background-size: 24px; }
.opening__body { position: relative; z-index: 1; width: min(940px, 100% - 500px); margin: 0 auto; padding: clamp(78px, 11vh, 96px) 0 32px; }
.opening__chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip { display: inline-block; padding: 8px 16px 7px; border-radius: 14px; background: var(--paper); border: 2.5px solid var(--ink); box-shadow: 0 4px 0 var(--ink); font: 800 15px/1 var(--font-label); letter-spacing: .12em; text-transform: uppercase; }
.chip--navy { background: var(--ink); color: var(--cream); box-shadow: 0 4px 0 var(--ink-deep); }
.opening h1 { margin: 12px 0 0; font: 800 clamp(44px, 7.6vh, 76px)/.98 var(--font-display); letter-spacing: -.01em; }
.opening h1 .underline { background: linear-gradient(#ec1c24, #ec1c24) 0 86%/96% 6px no-repeat; }
.opening__sheets { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: start; gap: 30px; margin-top: clamp(18px, 3.4vh, 34px); }
/* (.sheet is also a shared class in base.css with a negative top margin and a tall foot: undone here) */
.opening .sheet {
  --tilt: -3deg; position: relative; display: flex; flex-direction: column; gap: 10px; padding: 14px 14px 18px; text-align: left; color: var(--ink);
  margin: 0; z-index: auto; border-radius: 22px; border: 3px solid var(--ink); background: var(--paper); box-shadow: 0 8px 0 var(--ink); transform: rotate(var(--tilt));
  transition: transform .3s var(--ease-pop), box-shadow .2s;
}
.sheet:nth-child(2) { --tilt: 2deg; }
.sheet:nth-child(3) { --tilt: -1.5deg; }
.sheet:hover { transform: translateY(-6px) rotate(0deg); box-shadow: 0 12px 0 var(--ink); }
.sheet:active { transform: translateY(2px) rotate(0deg) scale(.98); box-shadow: 0 4px 0 var(--ink); }
.sheet:focus-visible { outline: 4px solid var(--ink); outline-offset: 5px; }
.sheet__tape { position: absolute; top: -14px; left: 50%; width: 90px; height: 26px; background: rgba(240, 190, 90, .88); transform: translateX(-50%) rotate(-2deg); box-shadow: 0 2px 3px rgba(16, 36, 74, .18); }
.sheet__art { display: block; aspect-ratio: 240 / 130; height: clamp(84px, 16vh, 150px); width: 100%; border-radius: 12px; border: 2.5px solid var(--ink); background: #fff; overflow: hidden; position: relative; }
.sheet__art svg { width: 100%; height: 100%; }
.sheet__art--build { background: linear-gradient(#cfe9fb 0 70%, #8ecdb4 70%); }
.sheet__art--build img { position: absolute; left: 14%; bottom: 4%; height: 92%; width: auto; }
.sheet__art--build svg { position: absolute; inset: 0; }
.sheet__label { font: 800 clamp(22px, 3.3vh, 28px)/1 var(--font-display); padding-right: 54px; }
.sheet__prop { position: absolute; right: -12px; bottom: -14px; width: 76px; height: 76px; transform: rotate(-10deg); filter: drop-shadow(0 4px 4px rgba(16, 36, 74, .3)); }
.opening__pages { margin-top: clamp(20px, 4vh, 40px); }
.chip--label { margin-bottom: 18px; }
.opening__row { display: flex; gap: 18px; }
.page-sheet {
  position: relative; flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: 8px; padding: 10px 10px 12px; text-align: left; color: var(--ink);
  border-radius: 16px; border: 3px solid var(--ink); background: var(--paper); box-shadow: 0 6px 0 var(--ink); transition: transform .3s var(--ease-pop);
}
.page-sheet::before { content: ""; position: absolute; top: -12px; left: 50%; width: 52px; height: 22px; background: rgba(236, 80, 120, .72); transform: translateX(-50%) rotate(2deg); }
.page-sheet:hover { transform: translateY(-5px); }
.page-sheet:active { transform: translateY(2px) scale(.98); }
.page-sheet__art { display: grid; place-items: center; width: 100%; aspect-ratio: 16 / 10; height: auto; border-radius: 10px; border: 2.5px solid var(--ink); background: #fff; overflow: hidden; }
.page-sheet__art img { width: 100%; height: 100%; object-fit: cover; }
.page-sheet__art--blank { border-style: dashed; color: var(--gold); font: 800 44px/1 var(--font-display); }
.page-sheet__art--folder { background: #fff3d6; }
.page-sheet__art--folder svg { width: 56%; height: auto; }
.page-sheet__label { font: 800 15px/1.12 var(--font-display); }
.opening__friends { position: fixed; inset: 0; z-index: 2; pointer-events: none; }
.opening__jevika, .opening__joy { position: absolute; bottom: 10px; width: auto; max-width: none; filter: drop-shadow(0 3px 0 #fff) drop-shadow(0 -3px 0 #fff) drop-shadow(3px 0 0 #fff) drop-shadow(-3px 0 0 #fff) drop-shadow(0 10px 10px rgba(16, 36, 74, .3)); }
/* Heights rule: Jevika and Joy the same height. Joy's picture fills .71 of its box, Jevika's .96, so Joy's box is 1.35x. */
.opening__jevika { left: -70px; height: clamp(240px, 46vh, 420px); }
.opening__joy { right: -150px; height: calc(clamp(240px, 46vh, 420px) * 1.35); transform-origin: 38% 96%; }
html.motion .opening__joy { animation: joy-tap 4.8s ease-in-out infinite; }
html.motion .opening:not(.is-ready) .sheet, html.motion .opening:not(.is-ready) .page-sheet { opacity: 0; }
html.motion .opening.is-ready .sheet { animation: sheet-drop .95s var(--ease-pop) backwards; animation-delay: calc(var(--i) * .16s + .05s); }
html.motion .opening.is-ready .page-sheet { animation: page-rise .7s cubic-bezier(.2, .8, .2, 1) backwards; animation-delay: calc(var(--i) * .07s + .5s); }
html.motion .opening__friends img { animation: fade-in .8s ease-out backwards; }
.opening.is-leaving { animation: lift-away .6s cubic-bezier(.5, 0, .7, .4) forwards; pointer-events: none; }

/* ---------- The finish: the live preview dialog in the art room, the picture in the gold frame ---------- */
.finish {
  position: fixed; inset: 0; width: 100%; height: 100%; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; color: var(--ink);
  background: #4ea3e6 url("../assets/studio/scene-artroom-wide-v1.webp") 50% 62% / cover no-repeat;
  overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain;
}
.finish[open] { display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 400px); align-items: center; gap: 4vw; padding: 60px 6vw 40px 6vw; }
.finish__stage { position: relative; align-self: center; justify-self: center; width: min(100%, calc(66vh * 1400 / 909)); }
.finish__frame { position: relative; width: 100%; aspect-ratio: 1400 / 909; background: url("../assets/studio/prop-frame-wide-v1.webp") center / 100% 100% no-repeat; filter: drop-shadow(0 18px 18px rgba(16, 36, 74, .3)); }
.finish [data-preview-pieces] { position: absolute; left: 10.2%; top: 21.8%; width: 79.7%; height: 63.7%; }
.finish [data-preview-pieces] > p { display: grid; place-items: center; height: 100%; padding: 16px; text-align: center; font: 700 var(--body-max)/1.45 var(--font-body); }
.preview-piece { position: absolute; inset: 0; }
.preview-piece-heading { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.preview-piece > img { display: block; width: 100%; height: 100%; max-width: none; object-fit: contain; }
.finish__links { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.finish__links:empty { display: none; }
.preview-download {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 14px; border-radius: 999px;
  background: var(--paper); border: 2px solid var(--ink); box-shadow: 0 2px 0 var(--ink); color: var(--ink);
  font: 700 14px/1 var(--font-display); text-decoration: none; white-space: nowrap;
}
.finish__friends { position: absolute; z-index: 2; left: -4%; bottom: -46%; width: 62%; height: auto; pointer-events: none; }
.finish__card { position: relative; z-index: 3; display: grid; gap: 12px; padding: 30px 28px 24px; border-radius: 28px; border: 3px solid var(--ink); background: var(--paper); box-shadow: 0 8px 0 var(--ink); transform: rotate(1deg); }
.finish__tape { position: absolute; top: -14px; left: 50%; width: 92px; height: 28px; background: rgba(240, 190, 90, .88); transform: translateX(-50%) rotate(-2deg); }
.finish__card h2 { margin-top: 4px; font: 800 clamp(28px, min(4.4vw, 6.5vh), 54px)/1 var(--font-display); overflow-wrap: anywhere; }
.preview-actions { display: grid; gap: 12px; margin-top: 6px; }
.preview-actions button, .keep-drawing {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 52px; padding: 0 18px; border-radius: 999px;
  border: 2.5px solid var(--ink); background: var(--paper); color: var(--ink); box-shadow: 0 4px 0 var(--ink); font: 700 17px/1.1 var(--font-display); transition: transform .15s;
}
.preview-actions .primary-button { background: var(--gold); }
.preview-actions svg, .keep-drawing svg { width: 20px; height: 20px; }
.preview-actions button:active, .keep-drawing:active { transform: translateY(3px); }
.preview-actions button:disabled { opacity: .5; }
.keep-drawing { border-color: transparent; box-shadow: none; background: transparent; min-height: 44px; }
.finish__note, .finish__status { font: 700 var(--body-max)/1.45 var(--font-body); color: var(--muted); }
.finish__status { color: var(--ink); }
.finish__status:empty { display: none; }
/* Confetti falls once, behind the paper card, and is gone at the end of its fall. */
.confetti { position: absolute; inset: 0; z-index: 1; pointer-events: none; overflow: hidden; }
.confetti span { position: absolute; top: -24px; left: var(--x); width: 10px; height: 16px; border-radius: 2px; background: var(--c); opacity: 0; animation: confetti-fall 3.4s var(--d) cubic-bezier(.3, .1, .6, 1) forwards; }
.finish__stage { z-index: 2; }
.finish.is-arriving .finish__frame { animation: frame-drop 1.1s var(--ease-pop) backwards; }
.finish.is-arriving .finish__friends { animation: friends-jump .9s .55s var(--ease-pop) backwards; }
.finish.is-arriving .finish__card { animation: card-in .7s .2s cubic-bezier(.2, .8, .2, 1) backwards; }

/* ---------- Studio arrival (motion only) ---------- */
body.arriving .work-area { animation: paper-settle .8s cubic-bezier(.2, .8, .2, 1) backwards; }
body.arriving .tool-dock { animation: from-left .7s .1s cubic-bezier(.2, .8, .2, 1) backwards; }
body.arriving .inspector { animation: from-right .7s .15s cubic-bezier(.2, .8, .2, 1) backwards; }
body.arriving .strip, body.arriving .mobile-panels { animation: fade-in .6s .3s ease-out backwards; }

@keyframes pop-in { from { opacity: 0; transform: scale(.92); } }
@keyframes drawer-in { from { opacity: 0; transform: translateX(28px); } }
@keyframes squish { 40% { transform: scale(1.14, .86); } 70% { transform: scale(.95, 1.05); } }
@keyframes hop { 40% { transform: translateY(-10px); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes paper-settle { from { opacity: 0; transform: translateY(18px) scale(.985); } }
@keyframes from-left { from { opacity: 0; transform: translateX(-40px); } }
@keyframes from-right { from { opacity: 0; transform: translateX(40px); } }
@keyframes sheet-drop { 0% { opacity: 0; transform: translateY(-70px) rotate(calc(var(--tilt) - 9deg)); } 55% { opacity: 1; transform: translateY(8px) rotate(calc(var(--tilt) + 2deg)); } 80% { transform: translateY(-2px) rotate(calc(var(--tilt) - .6deg)); } 100% { transform: rotate(var(--tilt)); } }
@keyframes page-rise { from { opacity: 0; transform: translateY(34px); } }
@keyframes lift-away { to { opacity: 0; transform: translateY(-36px); } }
@keyframes joy-tap { 0%, 100% { transform: rotate(0deg); } 45% { transform: rotate(-1.4deg); } 55% { transform: rotate(.6deg); } }
@keyframes frame-drop { 0% { opacity: 0; transform: translateY(-140px) rotate(-7deg); } 55% { opacity: 1; transform: translateY(10px) rotate(2.4deg); } 78% { transform: translateY(-3px) rotate(-.8deg); } 100% { transform: none; } }
@keyframes friends-jump { 0% { opacity: 0; transform: translateY(60px); } 50% { opacity: 1; transform: translateY(-26px); } 100% { transform: none; } }
@keyframes card-in { from { opacity: 0; transform: translateX(50px) rotate(4deg); } }
@keyframes confetti-fall { 0% { opacity: 1; transform: translateY(0) rotate(0deg); } 85% { opacity: 1; } 100% { opacity: 0; transform: translateY(112vh) rotate(var(--r)); } }

/* ==========================================================================
   Short desktop screens (1280x720 and similar)
   ========================================================================== */
@media (min-width: 1001px) and (max-height: 800px) {
  .studio-header { height: 56px; }
  .studio-app { top: 56px; padding-top: 10px; row-gap: 10px; grid-template-rows: minmax(0, 1fr) 52px 8px; }
  .room-floor { height: 30px; }
  .inspector { top: 10px; bottom: 18px; }
  body:not([data-studio-panel="colours"]) .inspector { bottom: 80px; }
  .tool-dock { padding: 12px 6px; }
  .tool-group { row-gap: 8px; }
  .rail-small { margin-top: 10px; padding-top: 10px; }
  .dock-tool { gap: 4px; }
  .tool-name { font-size: 12px; padding: 3px 7px 2px; }
  .selected-colour { margin-top: 2px; }
  .blob-grid { margin-top: 8px; gap: 6px 10px; }
  .blob, .swatch, .custom-colour { width: 46px; height: 46px; }
  .blob-grid { grid-template-columns: repeat(3, 46px); }
  .palette-tabs { margin-top: 8px; }
  .size-row { margin-top: 8px; padding-top: 8px; }
  .tray-note { display: none; }
  .art-cheer-launch { height: 44px; font-size: 15px; }
}

/* ==========================================================================
   Compact: 1000px and narrower (the live script's own phone switch)
   ========================================================================== */
@media (max-width: 1000px) {
  /* The rows round the paper, as variables so the paper's share can be worked out. The paper is promised its share
     first: the height at which it fills the width, at most 44% of the window, and never so much that the colours tray
     cannot show its top row and first colours. The tray gives way (it scrolls inside itself); once the tray is full,
     the paper takes whatever is left. */
  body.studio-c {
    --big: 58px; --small: 44px;
    --head: 56px; --pad: 6px; --gap: 6px;
    --r-strip: 52px; --r-small: 62px; --r-big: 88px; --r-tabs: 60px; --tray-max: 204px; --tray-min: 96px;
    --fixed: calc(var(--head) + var(--pad) + 5 * var(--gap) + var(--r-strip) + var(--r-small) + var(--r-big) + var(--r-tabs));
    --paper-min: max(120px, min(calc((100vw - 12px) * 2 / 3), 44vh, calc(100vh - var(--fixed) - var(--tray-min))));
  }
  /* While a piece is selected its bar takes the small-tools row (made taller); the tray gives that room, so the paper
     keeps its size (the live script would otherwise fit the paper again and lose the zoom). */
  body.studio-c.piece-bar { --r-small: 122px; --tray-max: 144px; --tray-min: 36px; }
  .studio-header { height: var(--head); gap: 8px; padding: 0 8px; }
  .studio-brand img { width: 56px; }
  /* the logo is a small picture here: its link is still a full-size place to tap */
  .studio-brand { position: relative; }
  .studio-brand::after { content: ""; position: absolute; inset: -10px 0; }
  .project-name { flex: 1 1 auto; min-width: 0; }
  #project-title { width: 100%; font-size: 17px; padding: 0 14px; }
  .save-box { flex: none; gap: 8px; }
  .save-state { max-width: 150px; }
  .save-box .pill { width: 44px; padding: 0; }
  .save-box .pill span { display: none; }
  #share-art { padding: 0 16px; font-size: 16px; }
  #episode-link { margin-left: 0; }

  .studio-app {
    top: var(--head); padding: var(--pad) 6px 0; row-gap: var(--gap); column-gap: 0;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(var(--paper-min), 1fr) var(--r-strip) var(--r-small) var(--r-big) minmax(0, var(--tray-max)) var(--r-tabs);
    grid-template-areas: "paper" "strip" "small" "big" "tray" "tabs";
  }
  .room-floor { display: none; }
  .tool-dock { display: contents; }
  .tool-group { display: flex; grid-template-columns: none; }
  .rail-small { grid-area: small; justify-self: start; align-self: center; gap: 10px; margin: 0; padding: 0 0 0 4px; border: 0; z-index: 3; }
  .rail-small .tool-name { color: var(--ink); font-size: 11px; padding: 0 4px; }
  .rail-small .dock-tool[aria-pressed="true"] .tool-name { background: var(--gold); }
  .rail-small .dock-tool { --focus: var(--ink); gap: 3px; }
  .rail-big { grid-area: big; z-index: 3; justify-content: space-around; align-items: center; padding: 6px 4px 0; }
  .rail-big .dock-tool { --focus: var(--ink); gap: 4px; }
  .rail-big .tool-name { color: var(--ink); font-size: 12px; padding: 2px 6px 1px; }
  .dock-tool[aria-pressed="true"] .toy, body[data-studio-panel="stickers"] .dock-tool[data-panel="stickers"] .toy, body[data-studio-panel="text"] .dock-tool[data-panel="text"] .toy { transform: translateY(-3px) scale(1.04); box-shadow: 0 0 0 3px var(--gold), 0 0 0 5.5px var(--ink); }
  .work-area { grid-area: paper; }
  .canvas-viewport { inset: -12px; }
  .art-status { top: 6px; max-width: 92%; }
  /* The paper bar sits under the paper in two rows, over the strip and the small tools (as the phone board). */
  body.piece-bar .work-area { z-index: 7; }
  /* While a piece is selected the bar takes the small-tools row (made taller, the tray gives the room),
     so the strip with Undo, Redo, Start fresh and the zoom stays visible. */
  body.piece-bar .rail-small, body.piece-bar .jevika-corner { visibility: hidden; }
  .paper-bar {
    top: calc(100% + var(--r-strip) + 2 * var(--gap)); bottom: auto; left: -2px; right: -2px; max-width: none;
    display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; padding: 6px;
  }
  .paper-bar button { min-width: 0; padding: 0 4px; font-size: 14px; white-space: nowrap; }
  #object-smaller { order: 1; } #object-larger { order: 2; } #layer-up { order: 3; } #layer-down { order: 4; }
  #edit-friend { order: 5; grid-column: span 2; } #duplicate-object { order: 6; } #delete-object { order: 7; }
  .strip { grid-area: strip; gap: 4px; padding: 0 4px; border-radius: 18px; }
  .strip .zoom-controls { margin-left: auto; }
  .strip__rule { display: none; }
  .mobile-panels { grid-area: tabs; justify-self: stretch; align-self: center; margin: 0 4px; z-index: 4; }
  .mobile-panels button { flex: 1 1 0; justify-content: center; min-width: 0; padding: 0 6px; height: 48px; font-size: 15px; }
  .tray-bg { display: block; grid-row: 4 / 7; grid-column: 1; margin: 0 -6px; border-radius: 26px 26px 0 0; background: var(--paper); border: 2.5px solid var(--ink); border-bottom: 0; box-shadow: 0 -4px 0 rgba(16, 36, 74, .12); z-index: 2; }
  .inspector { position: relative; inset: auto; grid-area: tray; width: auto; z-index: 3; padding: 2px 6px 0; border: 0; border-radius: 0; background: transparent; box-shadow: none; }
  body:not([data-studio-panel="colours"]) .inspector {
    grid-area: auto; grid-row: 4 / 6; grid-column: 1; width: auto; inset: auto; z-index: 6; margin: 0 -2px; padding: 54px 12px 8px;
    background: var(--paper); border: 2.5px solid var(--ink); border-radius: 22px; box-shadow: 0 4px 0 var(--ink);
  }
  .close-panel { position: absolute; z-index: 3; top: 6px; right: 8px; display: inline-flex; align-items: center; gap: 6px; height: 44px; padding: 0 14px; border-radius: 999px; border: 2.5px solid var(--ink); background: var(--paper); color: var(--ink); box-shadow: 0 3px 0 var(--ink); font: 700 15px/1 var(--font-display); }
  body[data-studio-panel="colours"] .close-panel { display: none !important; }
  body:not([data-studio-panel="colours"]):not([data-studio-panel="guide"]) .close-panel:not([hidden]) + .drawer-close { display: none; }
  .drawer-close { top: 6px; right: 8px; }
  body[data-studio-panel="guide"] #drawing-routes { margin-top: -46px; }
  .drawing-guide-top { padding-right: 0; }
  /* The drawing guide keeps to the tray row, so the big tools stay on screen; the tray grows to hold the step's words
     and Next idea (the paper gives way a little when it must). */
  body.studio-c[data-studio-panel="guide"] { --tray-min: 214px; --tray-max: 224px; }
  body[data-studio-panel="guide"] .inspector { grid-row: 5 / 6; padding: 8px 10px 4px; }
  body[data-studio-panel="guide"] #drawing-routes { margin-top: 0; }
  .drawing-guide { gap: 8px; }
  .drawing-guide-top { grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px; }
  .drawing-guide-top label { grid-column: auto; }
  .drawing-guide-body { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 12px; align-items: start; }
  .drawing-example { width: 112px; border-radius: 10px; }
  .drawing-guide-body > div { margin-top: 0; gap: 3px; }
  .guide-title { font-size: 19px; }
  .drawing-guide-controls { flex-wrap: nowrap; gap: 6px; }
  .drawing-guide-controls label { flex: 1 1 auto; min-width: 0; line-height: 1.2; }

  /* colours tray, compact: one head row, then blobs, then sets and sizes */
  #panel-colours { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "eye sel more" "grid grid grid" "sets sets dots"; align-items: center; column-gap: 10px; row-gap: 6px; }
  .tray-head { display: contents; }
  .tray-head .eyebrow { grid-area: eye; }
  .more-button { grid-area: more; justify-self: end; }
  .selected-colour { grid-area: sel; margin: 0; }
  .selected-colour .blob--big { width: 34px; height: 34px; }
  .blob-grid { grid-area: grid; grid-template-columns: repeat(8, 44px); gap: 6px 12px; margin: 0; justify-content: center; }
  .blob, .swatch, .custom-colour { width: 44px; height: 44px; }
  .palette-tabs { grid-area: sets; margin: 0; }
  .palette-tabs button { flex: 0 0 auto; padding: 0 12px; }
  .size-dots { grid-area: dots; margin: 0; gap: 0; }
  .size-row, .tray-note { display: none; }
  .tray-more { top: 50px; left: auto; right: 0; width: min(320px, 100%); }

  .jevika-corner { position: relative; left: auto; bottom: auto; grid-area: small; justify-self: end; align-self: stretch; flex-direction: row; align-items: center; gap: 4px; z-index: 3; }
  .art-cheer-launch { order: 0; height: 44px; margin: 0; padding: 0 12px 0 10px; font-size: 15px; }
  .art-cheer-launch::after { left: auto; right: -8px; bottom: 14px; transform: rotate(-45deg); }
  .jevika-frame { width: 66px; height: 62px; overflow: hidden; }
  .jevika-host { height: 150px; margin: -2px 0 0 -40px; }
  /* Jevika's idea opens over the top of the paper: never over its own button, the tools or the tray */
  .art-cheer-panel { left: 8px; right: 8px; width: auto; top: calc(var(--head) + 8px); bottom: auto; max-height: calc(100% - var(--head) - 16px); overflow-y: auto; overscroll-behavior: contain; }

  .opening__body { width: calc(100% - 48px); padding-top: 92px; }
  .opening__jevika { left: auto; right: 16px; top: 64px; bottom: auto; height: 300px; }
  .opening__joy { display: none; }
  .opening__head { padding-right: 220px; min-height: 250px; }
  .opening__friends { position: absolute; }
}
@media (max-width: 1000px) and (min-width: 761px) {
  .rail-big { justify-content: center; gap: 28px; }
  .rail-big .toy { width: 64px; height: 64px; }
  .palette-tabs button { padding: 0 18px; }
}

/* ==========================================================================
   Phone: 760px and narrower
   ========================================================================== */
@media (max-width: 760px) {
  body.studio-c {
    --big: 52px; --head: 54px; --pad: 4px; --gap: 5px;
    --r-strip: 50px; --r-small: 56px; --r-big: 76px; --r-tabs: 56px; --tray-max: 244px;
  }
  body.studio-c.piece-bar { --r-small: 112px; --tray-max: 188px; --tray-min: 40px; }
  body.studio-c[data-studio-panel="guide"] { --tray-min: 214px; --tray-max: 244px; }
  .studio-brand img { width: 46px; }
  #project-title { height: 44px; font-size: 16px; }
  #share-art { padding: 0 12px; gap: 5px; }
  #share-art svg { width: 17px; height: 17px; }
  .rail-big .dock-tool { gap: 3px; }
  .rail-small { gap: 6px; }
  .art-cheer-launch { max-width: 96px; height: auto; min-height: 44px; padding: 4px 10px 4px 8px; gap: 4px; white-space: normal; line-height: 1.02; font-size: 14px; text-align: left; }
  .art-cheer-launch svg { width: 16px; height: 16px; flex: none; }
  .jevika-frame { width: 58px; }
  .jevika-host { height: 140px; margin-left: -41px; }
  .mobile-panels button { height: 46px; }
  #panel-colours { row-gap: 4px; column-gap: 8px; }
  .tray-head .eyebrow { font-size: 12px; letter-spacing: .08em; }
  .selected-colour { gap: 6px; min-width: 0; }
  .selected-colour .blob--big { width: 30px; height: 30px; }
  #colour-name { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; overflow-wrap: normal; }
  .save-box { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .save-box .save-state { grid-column: 1 / -1; max-width: none; }
  .save-box .pill { width: auto; padding: 0 14px; }
  .save-box .pill span { display: inline; }
  .strip .round { width: 44px; }
  #reset-art { padding: 0 9px; font-size: 14px; margin-left: 0; }
  #zoom-label { min-width: 40px; font-size: 14px; }
  #zoom-fit { min-width: 44px; padding: 0 10px; font-size: 14px; margin-left: 0; }
  .zoom-controls { gap: 0; }
  .rail-big { justify-content: space-between; padding: 6px 2px 0; }
  .blob-grid { grid-template-columns: repeat(6, 44px); gap: 5px 10px; }
  .palette-tabs { gap: 3px; }
  .palette-tabs button { min-width: 44px; padding: 0 7px; font-size: 12px; }
  .size-dots button { width: 44px; }
  .mobile-panels { gap: 5px; }
  .mobile-panels button { font-size: 14px; gap: 5px; padding: 0 4px; }
  .mobile-panels svg { width: 16px; height: 16px; }
  .supply-panel h2 { font-size: 23px; }
  .character-stickers button, .make-friend { height: 120px; }
  .character-stickers button img { height: calc(var(--h, 1) * 88px); }
  .shape-grid { grid-template-columns: repeat(4, 48px); }
  .shape-grid button { width: 48px; height: 48px; }

  .opening__top { left: 14px; right: 14px; top: 12px; }
  .opening__logo { padding: 6px 12px; }
  .opening__logo img { width: 66px; }
  .opening__close { width: 48px; height: 48px; }
  .opening__body { width: calc(100% - 28px); padding-top: 78px; }
  .opening__head { padding-right: 150px; min-height: 210px; }
  .opening h1 { font-size: 42px; }
  .chip { font-size: 13px; }
  .opening__jevika { right: -4px; top: 60px; height: 230px; }
  .opening__sheets { grid-template-columns: 1fr; gap: 22px; margin-top: 10px; }
  .opening .sheet { flex-direction: row; align-items: center; gap: 12px; padding: 10px; }
  .sheet__art { width: 46%; height: auto; flex: none; }
  .sheet__label { font-size: 22px; padding-right: 40px; }
  .sheet__prop { width: 58px; height: 58px; right: 6px; bottom: auto; top: 50%; margin-top: -29px; }
  .opening__row { overflow-x: auto; padding: 14px 4px 14px; margin: -14px -4px 0; scroll-snap-type: x mandatory; }
  .page-sheet { flex: 0 0 150px; scroll-snap-align: start; }

  .finish[open] { grid-template-columns: 1fr; align-content: start; gap: 18px; padding: 56px 14px 24px; overflow-y: auto; }
  .finish__stage { width: 100%; margin-bottom: 96px; }
  .finish__friends { width: 56%; bottom: -50%; left: -4%; }
  .finish__card { padding: 26px 18px 20px; transform: none; }
}

/* The smallest common phones (360-380px wide): the zoom percentage gives way, so Fit and the other buttons of the
   strip stay on screen. */
@media (max-width: 380px) {
  #zoom-label { display: none; }
}

/* Where the browser knows its own visible height (a phone's bars come and go), the paper's share uses it. */
@supports (height: 100dvh) {
  @media (max-width: 1000px) {
    body.studio-c { --paper-min: max(120px, min(calc((100vw - 12px) * 2 / 3), 44dvh, calc(100dvh - var(--fixed) - var(--tray-min)))); }
  }
}

/* Phones up to 440px wide: the brush sizes join the selected colour's row and the colour sets get a row of their own,
   so no button lies over another (at 360-375px the size dots covered Earthy and took its taps). "Your colours" stays
   for screen readers; the pressed Colours tab already names the tray. */
@media (max-width: 440px) {
  #panel-colours { grid-template-columns: minmax(0, 1fr) auto auto; grid-template-areas: "sel dots more" "grid grid grid" "sets sets sets"; }
  .tray-head .eyebrow { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  #colour-name { font-size: 14px; }
  .palette-tabs button { flex: 1 1 0; min-width: 0; }
}
/* 400px and narrower: the small tools sit closer and Jevika's corner is a little narrower, so her button never lies
   over Help (it did at 360-375px). */
@media (max-width: 400px) {
  .rail-small { gap: 2px; padding-left: 2px; }
  .jevika-corner { gap: 2px; }
  .art-cheer-launch { max-width: 88px; padding: 4px 7px 4px 6px; }
  .jevika-frame { width: 50px; }
  .jevika-host { margin-left: -45px; }
}

/* Short phone windows held upright (a phone browser with its bars: 390x664, 360x640, 375x553): the rows round the
   paper get a little smaller, so the paper keeps a usable size and the tray still shows its first colours. */
@media (max-width: 760px) and (max-height: 700px) and (max-aspect-ratio: 5/4) {
  body.studio-c { --big: 46px; --small: 38px; --head: 50px; --gap: 4px; --r-strip: 48px; --r-small: 52px; --r-big: 68px; --r-tabs: 50px; --tray-min: 92px; }
  body.studio-c.piece-bar { --r-small: 112px; --tray-min: 32px; }
  .rail-big { padding-top: 4px; }
  .rail-small .dock-tool { gap: 2px; }
  .mobile-panels button { height: 44px; }
}
@media (max-width: 760px) and (max-height: 600px) and (max-aspect-ratio: 5/4) {
  body.studio-c { --big: 44px; --r-big: 64px; --tray-min: 84px; }
  body.studio-c.piece-bar { --tray-min: 24px; }
  .rail-big { padding-top: 2px; }
  /* The drawing guide on the shortest phones: the six big tools move up a row and the guide also takes the small
     tools' row (Select, Pick, Pan, Help and Jevika come back when the guide is hidden), so the step's words and Next
     idea fit beside a paper that is still a usable size. */
  body.studio-c[data-studio-panel="guide"] { --tray-min: calc(214px - var(--r-small) - var(--gap)); }
  body[data-studio-panel="guide"] .studio-app {
    grid-template-rows: minmax(var(--paper-min), 1fr) var(--r-strip) var(--r-big) var(--r-small) minmax(0, var(--tray-max)) var(--r-tabs);
    grid-template-areas: "paper" "strip" "big" "small" "tray" "tabs";
  }
  body[data-studio-panel="guide"] .inspector { grid-row: 4 / 6; }
  body[data-studio-panel="guide"] .tray-bg { grid-row: 3 / 7; }
  body[data-studio-panel="guide"] .rail-small, body[data-studio-panel="guide"] .jevika-corner { visibility: hidden; }
}

/* Short laptop windows (1366x617, 1280x577): Jevika gets smaller, so her corner never covers Pan and Help on the
   rail; below 600px only her button stays. */
@media (min-width: 1001px) and (max-height: 680px) {
  .jevika-host { height: max(64px, calc(100vh - 540px)); }
  .art-cheer-panel { bottom: calc(max(64px, 100vh - 540px) + 64px); }
}
@media (min-width: 1001px) and (max-height: 600px) {
  .jevika-frame { display: none; }
  .art-cheer-launch::after { display: none; }
  .art-cheer-panel { bottom: 64px; }
}

/* 1001-1220px wide: the strip under the paper is too short for Undo to Fit and the four drawer tabs, so the tabs
   stand on the floor below it (they covered + and Fit at 1024px). */
@media (min-width: 1001px) and (max-width: 1220px) {
  .studio-app { grid-template-rows: minmax(0, 1fr) 56px 48px; }
  .mobile-panels { grid-area: 3 / 2 / 4 / 3; justify-self: center; align-self: start; margin: 0; }
}
@media (min-width: 1001px) and (max-width: 1220px) and (max-height: 800px) {
  .studio-app { grid-template-rows: minmax(0, 1fr) 52px 48px; }
}

/* A short window (a laptop with its bars, a phone turned sideways): the finish scrolls (above), and its card is a
   little tighter so Keep drawing is close. */
@media (min-width: 761px) and (max-height: 640px) {
  .finish[open] { padding: 20px 4vw; gap: 3vw; }
  .finish__stage { width: min(100%, calc(80vh * 1400 / 909)); }
  .finish__card { padding: 22px 22px 16px; gap: 8px; }
  .preview-actions { gap: 8px; margin-top: 2px; }
  .preview-actions button { min-height: 46px; }
}

/* ==========================================================================
   Short and wide, 1000px and narrower (a phone turned sideways: 844x390, 915x412, 740x360): the tools in a column on
   the left, the paper in the middle with its strip, the colours on the right with the drawer tabs under them. The
   paper, every tool, the colours, the tabs, Finish and the close button are all on one screen; the colours and the
   drawers scroll inside the tray.
   ========================================================================== */
@media (max-width: 1000px) and (min-aspect-ratio: 5/4) {
  body.studio-c {
    --head: 50px;
    --big: clamp(36px, calc((100vh - 180px) / 4), 46px);
    --small: clamp(30px, calc(var(--big) - 8px), 38px);
    --rail-w: 168px; --tray-w: clamp(220px, 26vw, 264px);
  }
  .studio-header { height: var(--head); }
  .studio-brand img { width: 52px; }
  body.studio-c .studio-app, body.studio-c.piece-bar .studio-app {
    top: var(--head); padding: 4px 8px 0; column-gap: 8px; row-gap: 4px;
    grid-template-columns: var(--rail-w) minmax(0, 1fr) var(--tray-w);
    grid-template-rows: calc(2 * var(--big) + 40px) calc(2 * max(44px, var(--small) + 13px) + 4px) minmax(0, 1fr) 50px;
    grid-template-areas: "big paper tray" "small paper tray" "jev paper tray" "jev strip tabs";
  }
  .tray-bg { grid-area: 1 / 1 / 5 / 2; margin: 0 0 6px; border-radius: 22px; border: 2.5px solid var(--ink); box-shadow: 0 4px 0 var(--ink); }

  /* the rail: six big tools in two rows, the four small ones under them */
  .rail-big { grid-area: big; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); justify-items: center; align-content: start; gap: 4px 0; padding: 2px 0 0; }
  .rail-big .toy { width: var(--big); height: var(--big); }
  .rail-big .dock-tool, .rail-small .dock-tool { gap: 2px; }
  .rail-big .tool-name { font-size: 11px; letter-spacing: .05em; padding: 2px 5px 1px; }
  .rail-small, body.piece-bar .rail-small { grid-area: small; visibility: visible; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); justify-self: stretch; justify-items: center; align-self: start; gap: 4px 0; padding: 0; }
  .dock-tool--small { min-height: 44px; }
  .rail-small .tool-name { letter-spacing: .05em; }
  .jevika-corner, body.piece-bar .jevika-corner { grid-area: jev; visibility: visible; justify-self: stretch; align-self: end; justify-content: flex-start; margin: 0 0 8px; padding-left: 6px; }
  .art-cheer-launch { max-width: 92px; height: auto; min-height: 44px; padding: 4px 8px; gap: 4px; white-space: normal; line-height: 1.02; font-size: 14px; text-align: left; }
  .art-cheer-launch svg { width: 16px; height: 16px; flex: none; }
  .jevika-frame { width: 56px; height: 62px; }
  .jevika-host { height: 140px; margin-left: -41px; }
  .art-cheer-panel { top: auto; left: calc(var(--rail-w) + 16px); right: auto; bottom: 58px; width: min(320px, calc(100vw - var(--rail-w) - var(--tray-w) - 40px)); max-height: calc(100% - var(--head) - 70px); }

  /* the paper, its strip and, while a piece is selected, its bar along the paper's foot */
  .work-area { grid-area: paper; }
  .strip { grid-area: strip; gap: 2px; padding: 0 3px; }
  .strip .round { width: 44px; }
  #reset-art { padding: 0 9px; font-size: 14px; margin-left: 0; }
  #zoom-label { min-width: 40px; font-size: 14px; }
  #zoom-fit { min-width: 44px; padding: 0 10px; font-size: 14px; margin-left: 0; }
  .zoom-controls { gap: 0; }
  .paper-bar { top: auto; bottom: 4px; left: 4px; right: 4px; display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; padding: 4px; }
  .paper-bar button { flex: 0 1 auto; padding: 0 8px; }

  /* the tray: colours (or the open drawer) above the four tabs */
  .mobile-panels { grid-area: tabs; justify-self: stretch; align-self: center; margin: 0; gap: 3px; }
  .mobile-panels button { flex: 1 1 auto; height: 44px; padding: 0 3px; font-size: 13px; gap: 0; }
  .mobile-panels svg { display: none; }
  .inspector, body:not([data-studio-panel="colours"]) .inspector, body[data-studio-panel="guide"] .inspector {
    grid-area: tray; margin: 0; padding: 6px 8px 4px; z-index: 5;
    background: var(--paper); border: 2.5px solid var(--ink); border-radius: 22px; box-shadow: 0 4px 0 var(--ink);
  }
  body:not([data-studio-panel="colours"]):not([data-studio-panel="guide"]) .inspector { padding: 54px 10px 6px; }
  #panel-colours { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "sel more" "grid grid" "dots dots" "sets sets"; column-gap: 6px; row-gap: 6px; }
  .tray-head .eyebrow { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .selected-colour { gap: 6px; min-width: 0; }
  .selected-colour .blob--big { width: 30px; height: 30px; }
  #colour-name { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; overflow-wrap: normal; }
  .blob-grid { grid-template-columns: repeat(auto-fill, 44px); gap: 6px; justify-content: center; }
  .size-dots { justify-content: space-between; }
  .palette-tabs { gap: 3px; }
  .palette-tabs button { flex: 1 1 0; min-width: 0; padding: 0 2px; }
  .save-box { grid-template-columns: 1fr; }
  .supply-panel h2 { font-size: 21px; }
  .friend-shelf { gap: 8px; }
  .character-stickers button, .make-friend { height: 112px; }
  .character-stickers button img { height: calc(var(--h, 1) * 80px); }
  .shape-grid { grid-template-columns: repeat(auto-fill, 44px); justify-content: start; gap: 8px; }
  .shape-grid button { width: 44px; height: 44px; }
  /* the drawing guide in the tray: the example small beside its words */
  .drawing-guide-top { grid-template-columns: minmax(0, 1fr) auto; }
  .drawing-guide-top label { grid-column: 1 / -1; }
  .drawing-guide-body { grid-template-columns: 80px minmax(0, 1fr); gap: 8px; }
  .drawing-example { width: 80px; }
  .guide-title { font-size: 17px; }
  .drawing-guide-controls { flex-wrap: wrap; }
  .drawing-guide-controls label { flex-basis: 100%; }
}
/* Sideways on a smaller phone (740x360, 667x375): the strip runs under the paper and the tray together (Undo to Fit
   no longer fit under the paper alone), and the four tabs sit at the top of the tray. */
@media (max-width: 819px) and (min-aspect-ratio: 5/4) {
  body.studio-c .studio-app, body.studio-c.piece-bar .studio-app { grid-template-areas: "big paper tray" "small paper tray" "jev paper tray" "jev strip strip"; }
  .mobile-panels { grid-area: 1 / 3 / 2 / 4; align-self: start; }
  .inspector, body:not([data-studio-panel="colours"]) .inspector, body[data-studio-panel="guide"] .inspector { grid-area: tray; margin-top: 48px; }
}

/* Pages, 1000px and narrower: the three ways to draw sit above the pages, and the whole drawer scrolls, so on a short
   screen the pages and "Open a saved drawing" are never squeezed out of sight. Done stays at the top. */
@media (max-width: 1000px) {
  body.studio-c[data-studio-panel="pages"] .inspector { overflow-y: auto; overscroll-behavior: contain; padding-top: 6px; }
  body.studio-c[data-studio-panel="pages"] .inspector-scroll { flex: none; overflow: visible; }
  body.studio-c[data-studio-panel="pages"] .close-panel, body.studio-c[data-studio-panel="pages"] .drawer-close { position: sticky; top: 0; flex: none; align-self: flex-end; margin-bottom: 4px; }
}

@media (max-width: 1000px) {
  /* An open drawer covers the row of big tools: they are hidden while it is open, so neither a tap nor Tab lands on a
     tool under the drawer. They come back when the drawer closes. */
  body:not([data-studio-panel="colours"]):not([data-studio-panel="guide"]) .rail-big { visibility: hidden; }
  /* "More brush settings" stays inside the part of the tray that is on screen, beside its own button (which stays
     visible to close it), and scrolls inside itself when the tray is short. */
  #panel-colours { position: static; }
  .tray-more { top: 4px; bottom: 4px; left: 4px; right: 56px; width: auto; overflow-y: auto; overscroll-behavior: contain; }
}
/* Sideways the drawers sit in the tray column and cover no tools. */
@media (max-width: 1000px) and (min-aspect-ratio: 5/4) {
  body.studio-c:not([data-studio-panel="colours"]):not([data-studio-panel="guide"]) .rail-big { visibility: visible; }
}
