/* ============================================================
   CAROUSEL STUDIO — full-screen phone editor. Everything under .studio
   Dark stage so the white slides pop; same navy + orange-dot language.
   z-index 55: above the dock (40), below sheets (61) and toasts (80).
   ============================================================ */
body.studio-open{ overflow:hidden; }
.studio{
  --s-bg:#0A0F1B; --s-card:#151C2C; --s-card2:#1F2840; --s-line:rgba(241,243,248,.10);
  --s-ink:#F1F3F8; --s-ink2:#A9B4C8; --s-ink3:#76819A;
  position:fixed; left:0; right:0; top:0; bottom:0; z-index:55; margin:0 auto; max-width:520px;
  display:flex; flex-direction:column; background:var(--s-bg); color:var(--s-ink);
  padding-top:var(--safe-t); overflow:hidden; opacity:0; transform:translateY(18px);
  transition:opacity .3s var(--ease-out), transform .35s var(--ease-out);
}
.studio.ready{ opacity:1; transform:none; }
.studio.out{ opacity:0; transform:translateY(24px); transition-duration:.2s; }
.studio:not(.ready):not(.out){ opacity:1; transform:none; }  /* never leave a blank screen while fonts load */
.studio svg.i{ width:1.2em; height:1.2em; }
.studio button{ color:inherit; }
.studio :focus-visible{ outline:2.5px solid var(--dot); outline-offset:2px; }

/* top bar */
.st-top{ display:flex; align-items:center; gap:10px; padding:8px 12px 6px; min-height:60px; }
.st-ib{ width:44px; height:44px; border-radius:50%; display:grid; place-items:center; background:var(--s-card); flex:none; transition:transform .18s var(--ease-spring); }
.st-ib:active{ transform:scale(.9); }
.st-title{ flex:1; min-width:0; display:grid; line-height:1.2; }
.st-title b{ font-family:var(--f-display); font-weight:580; font-size:19px; letter-spacing:-.01em; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.st-sub{ font-size:13px; color:var(--s-ink2); font-weight:600; }
.st-save{ display:inline-flex; align-items:center; gap:5px; height:32px; padding:0 12px; border-radius:var(--r-pill); font-size:13px; font-weight:650; background:var(--s-card); color:var(--s-ink2); flex:none; transition:background .25s, color .25s; }
.st-save.none{ display:none; }
.st-save .i{ width:14px; height:14px; stroke-width:3; }
.st-save.ok{ color:#7FD6AC; }
.st-save.warn{ color:#E8C566; }
.st-save.bad{ background:rgba(234,78,39,.2); color:#FF9B80; }
.st-save.busy::before{ content:""; width:11px; height:11px; border-radius:50%; border:2px solid currentColor; border-right-color:transparent; animation:spin .7s linear infinite; }

/* stage */
.st-frame{ position:relative; flex:1; min-height:0; overflow:hidden; touch-action:pan-y; }
.st-track{ position:absolute; inset:0; display:flex; width:300%; will-change:transform; }
.st-pane{ flex:0 0 33.3333%; height:100%; display:grid; place-items:center; padding:6px 16px; }
.st-pane canvas{ display:block; max-width:100%; max-height:100%; aspect-ratio:4/5; height:auto; width:auto; border-radius:14px; background:#fff; box-shadow:0 18px 50px rgba(0,0,0,.55); transition:opacity .25s; }
.st-pane.empty canvas{ opacity:0; }
.st-warn{ position:absolute; top:12px; left:50%; transform:translateX(-50%); max-width:calc(100% - 32px); padding:8px 14px; border-radius:var(--r-pill); background:var(--dot); color:#fff; font-size:13px; font-weight:650; text-align:center; box-shadow:0 6px 20px rgba(0,0,0,.4); animation:toast-in .35s var(--ease-spring) both; z-index:2; }
.st-arrow{ position:absolute; top:50%; width:44px; height:44px; margin-top:-22px; border-radius:50%; background:rgba(10,15,27,.62); backdrop-filter:blur(8px); display:grid; place-items:center; opacity:0; transition:opacity .2s; z-index:2; }
.st-arrow.l{ left:6px; } .st-arrow.r{ right:6px; }
@media (hover:hover){ .st-frame:hover .st-arrow{ opacity:1; } }
.st-arrow:focus-visible{ opacity:1; }

/* dots */
.st-dots{ display:flex; align-items:center; justify-content:center; gap:12px; height:24px; padding:0 16px; }
.st-dotrow{ display:flex; gap:5px; align-items:center; overflow:hidden; }
.st-dotrow i{ width:6px; height:6px; border-radius:3px; background:var(--s-card2); flex:none; transition:width .3s var(--ease-out), background .25s; }
.st-dotrow i.on{ width:20px; background:var(--dot); }
.st-count{ font-size:12.5px; font-weight:650; color:var(--s-ink2); font-variant-numeric:tabular-nums; flex:none; }

/* thumbnails */
.st-strip{ display:flex; gap:8px; overflow-x:auto; padding:6px 16px 10px; scrollbar-width:none; scroll-snap-type:x proximity; }
.st-strip::-webkit-scrollbar{ display:none; }
.st-th{ position:relative; flex:none; width:56px; display:grid; gap:4px; justify-items:center; scroll-snap-align:center; opacity:.6; transition:opacity .25s, transform .25s var(--ease-spring); padding:3px 0 0; }
.st-th canvas{ width:56px; height:70px; border-radius:9px; background:#fff; display:block; box-shadow:0 0 0 2px transparent; transition:box-shadow .25s; }
.st-th span{ font-size:11px; font-weight:650; color:var(--s-ink2); line-height:1; }
.st-th.on{ opacity:1; transform:translateY(-2px); }
.st-th.on canvas{ box-shadow:0 0 0 2.5px var(--dot); }
.st-th:active{ transform:scale(.94); }

/* panel */
.st-panel{ background:var(--s-card); border-radius:var(--r-xl) var(--r-xl) 0 0; max-height:44dvh; overflow-y:auto; overscroll-behavior:contain; box-shadow:0 -10px 40px rgba(0,0,0,.35); }
.st-panel.pop{ animation:st-pop .32s var(--ease-out); }
@keyframes st-pop{ from{ transform:translateY(24px); opacity:.4; } }
.st-pbody{ padding:16px 16px 12px; display:grid; gap:12px; }
.st-f{ display:grid; gap:6px; }
.st-f > span{ font-size:13.5px; font-weight:650; color:var(--s-ink2); }
.st-f em{ font-style:normal; font-size:12.5px; color:var(--s-ink3); font-weight:500; }
.studio textarea,.st-in{ width:100%; border:2px solid transparent; border-radius:var(--r-md); background:var(--s-card2); color:var(--s-ink); font-size:16px; line-height:1.45; padding:12px 14px; resize:none; transition:border-color .2s, background .2s; font-family:var(--f-ui); }
.st-in{ min-height:48px; padding:0 14px; }
.studio textarea:focus,.st-in:focus{ outline:0; border-color:var(--s-ink); background:var(--s-bg); }
.st-pwarn{ background:rgba(234,78,39,.18); color:#FFB29E; font-weight:600; font-size:14px; padding:10px 14px; border-radius:var(--r-md); }
.st-msg{ font-size:14px; font-weight:600; color:var(--s-ink2); line-height:1.4; }
.st-msg.bad{ color:#FF9B80; }
.st-note{ font-size:13.5px; color:var(--s-ink3); line-height:1.5; font-weight:500; }
.st-note b{ color:var(--s-ink2); }
.st-switch{ display:flex; align-items:center; justify-content:space-between; gap:12px; min-height:44px; font-weight:600; font-size:15px; }
.studio .switch{ background:var(--s-card2); }
.studio .switch[aria-checked="true"]{ background:var(--ok); }

.st-btn{ display:inline-flex; align-items:center; justify-content:center; gap:8px; min-height:48px; padding:0 16px; border-radius:var(--r-pill); background:var(--s-card2); color:var(--s-ink); font-weight:650; font-size:15px; transition:transform .18s var(--ease-spring), opacity .2s; position:relative; }
.st-btn:active{ transform:scale(.96); }
.st-btn[disabled]{ opacity:.38; pointer-events:none; }
.st-btn.primary{ background:#F1F3F8; color:#0E1525; }
.st-btn.danger{ color:#FF9B80; }
.st-btn.working::after{ content:""; width:15px; height:15px; border-radius:50%; border:2.5px solid currentColor; border-right-color:transparent; animation:spin .7s linear infinite; }
.st-btn .i{ flex:none; }
.st-btn.ai .i{ color:var(--dot); }
.st-chipbtn{ display:inline-flex; align-items:center; gap:8px; justify-self:start; min-height:44px; padding:0 16px 0 12px; border-radius:var(--r-pill); background:var(--s-card2); font-weight:650; font-size:14.5px; transition:transform .18s var(--ease-spring); }
.st-chipbtn:active{ transform:scale(.96); }
.st-chipbtn .i{ color:var(--dot); }
.st-row3{ display:grid; grid-template-columns:repeat(3,1fr); gap:8px; }
.st-row3 .st-btn{ flex-direction:column; gap:4px; padding:10px 6px; min-height:64px; font-size:13.5px; text-align:center; line-height:1.2; }
.st-grid2{ display:grid; grid-template-columns:1fr 1fr; gap:8px; }
.st-stack{ display:grid; gap:8px; }
.st-sliders{ display:grid; gap:10px; }
.st-sliders label{ display:grid; grid-template-columns:96px 1fr; align-items:center; gap:10px; font-size:14px; font-weight:650; color:var(--s-ink2); }
.st-sliders input[type=range]{ width:100%; accent-color:var(--dot); height:36px; }

/* tool bar */
.st-tools{ display:grid; grid-template-columns:repeat(4,1fr); gap:4px; padding:8px 10px calc(8px + var(--safe-b)); background:var(--s-card); border-top:1px solid var(--s-line); }
.st-panel:not([hidden]) + .st-tools{ border-top-color:transparent; }
.st-tools button{ position:relative; display:grid; justify-items:center; align-content:center; gap:3px; min-height:56px; border-radius:var(--r-lg); color:var(--s-ink3); font-size:12.5px; font-weight:650; transition:background .25s, color .25s, transform .15s; }
.st-tools button:active{ transform:scale(.94); }
.st-tools button .i{ width:23px; height:23px; }
.st-tools button[aria-pressed="true"]{ background:#F1F3F8; color:#0E1525; }
.st-tools button[aria-pressed="true"]::after{ content:""; position:absolute; top:6px; right:calc(50% - 20px); width:7px; height:7px; border-radius:50%; background:var(--dot); }

/* when the on-screen keyboard is up: give the text room, hide the extras */
.studio.kb .st-strip,.studio.kb .st-dots,.studio.kb .st-tools{ display:none; }
.studio.kb .st-frame{ flex:0 0 28%; }
.studio.kb .st-panel{ max-height:none; flex:1; border-radius:var(--r-xl) var(--r-xl) 0 0; padding-bottom:var(--safe-b); }
/* with a panel open, make room for it on short phones */
.studio.has-panel .st-strip{ padding-bottom:6px; }
@media (max-height:700px){ .studio.has-panel .st-strip{ display:none; } .st-panel{ max-height:50dvh; } }

@media (prefers-reduced-motion:reduce){
  .studio,.st-track,.st-panel.pop,.st-warn{ transition:none !important; animation:none !important; }
}
