/* Studio page: scoped under #studio (the stage, the panel, the bars, the sheets). Tokens come from site.css. */
body:has(#studio) { overflow: hidden; }
body:has(#studio) > header.top, body:has(#studio) > footer.site { display: none; }
#studio { --bar: 56px; --amber-100: color-mix(in srgb, var(--warn) 12%, var(--surface)); --blue-100: color-mix(in srgb, var(--focus) 12%, var(--surface));
  --overlay: rgba(10,15,29,.6); display: grid; grid-template-rows: var(--bar) minmax(0, 1fr); height: 100dvh; font-size: 15px; }
#studio button { font-family: inherit; }
#studio .btn { min-height: 40px; }
#studio .btn.secondary { background: var(--fg); color: var(--surface); border-color: transparent; }
#studio .btn.secondary:hover { background: var(--fg); filter: brightness(1.15); }
#studio .btn.tonal { background: var(--soft); border-color: transparent; }
#studio .btn.icon { width: 44px; height: 44px; padding: 0; border-radius: 10px; }
#studio .btn.icon svg, #studio .btn svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; flex: none; }
#studio .num { font-variant-numeric: tabular-nums; }
#studio .label { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
#studio .sr-live { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* studio bar */
.sbar { display: flex; align-items: center; gap: 8px; padding: 0 12px; border-bottom: 1px solid var(--line); background: var(--surface); min-width: 0; }
.sbar .logo { font-size: 20px; } .sbar .logo svg { width: 24px; height: 24px; }
.sbar .crumb { display: flex; align-items: center; gap: 6px; min-width: 0; flex: 1; }
.sbar .title { font: 600 15px var(--body); color: var(--fg); background: transparent; border: 1px solid transparent; border-radius: 8px; padding: 6px 8px; min-width: 0; width: min(100%, 36ch); }
.sbar .title:hover, .sbar .title:focus { border-color: var(--line); background: var(--bg); }
.sbar .status { font-size: 13px; color: var(--muted); white-space: nowrap; }
.sbar .status.ok { color: var(--ok); }
.sbar .hist { display: flex; gap: 2px; }
.sbar .actions { display: flex; gap: 8px; align-items: center; margin-left: auto; }
.sbar .menu .pop { top: 46px; z-index: 30; }
.phone-only { display: none !important; }

/* body */
.sbody { display: grid; grid-template-columns: 380px minmax(0, 1fr); min-height: 0; }
@media (max-width: 1199px) { .sbody { grid-template-columns: 360px minmax(0, 1fr); } }
.panel { overflow: auto; border-right: 1px solid var(--line); background: var(--surface); padding: 16px; display: flex; flex-direction: column; gap: 0; min-width: 0; overscroll-behavior: contain; }
.panel > section { padding: 18px 0; border-top: 1px solid var(--line); display: grid; gap: 12px; align-content: start; }
.panel > section:first-child { border-top: 0; padding-top: 0; }
.panel > section.ask { margin-top: auto; }
.design-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.design-head strong { font-size: 17px; font-weight: 600; display: block; line-height: 1.3; }
.design-head .label { display: block; margin-bottom: 2px; }
.stagecol { overflow: auto; padding: 16px; display: grid; gap: 14px; align-content: start; min-width: 0; }
.busy-note { display: none; }

/* fields */
.fields { display: grid; gap: 12px; }
.field { display: grid; gap: 5px; }
.field .label { font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .9px; color: var(--muted); }
.field .count { font-weight: 500; text-transform: none; letter-spacing: 0; font-size: 12.5px; }
.field .count.warn { color: var(--warn); } .field .count.bad { color: var(--accent); font-weight: 600; }
.field .box { position: relative; display: flex; align-items: center; }
.field input, .field textarea { background: var(--bg); min-height: 40px; padding: 8px 12px; }
.field.bad input, .field.bad textarea { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 7%, var(--surface)); }
.field .sample { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); font: italic 600 11.5px var(--body); background: var(--soft); color: var(--muted); padding: 3px 8px; border-radius: 999px; pointer-events: none; }
.field .hint { font-size: 13.5px; color: var(--muted); }
.field .err { font-size: 13.5px; color: var(--accent); font-weight: 600; }

/* colors */
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch { display: inline-flex; align-items: center; gap: 7px; min-height: 36px; padding: 5px 12px 5px 9px; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--fg); font: 500 13px var(--body); cursor: pointer; }
.swatch[aria-pressed="true"] { border-color: var(--fg); box-shadow: inset 0 0 0 1px var(--fg); }
.swatch i { width: 14px; height: 14px; border-radius: 50%; display: inline-block; box-shadow: 0 0 0 1px var(--line); margin-right: -5px; }
.swatch i:last-of-type { margin-right: 2px; }
.parts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.part { position: relative; display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 4px 8px 4px 4px; border: 1px solid var(--line); border-radius: 10px; background: transparent; color: var(--fg); font: 500 13.5px var(--body); cursor: pointer; text-align: left; }
.part:hover { border-color: var(--fg); }
.part i { width: 36px; height: 36px; border-radius: 8px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.12); flex: none; }
.part .bang { position: absolute; top: -6px; left: 30px; width: 18px; height: 18px; border-radius: 50%; background: var(--warn); color: #fff; font: 700 12px/18px var(--body); text-align: center; }
.part span { display: grid; line-height: 1.25; } .part small { color: var(--muted); font-size: 11.5px; }
.pop-colors { position: absolute; z-index: 25; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 10px; width: 236px; display: grid; gap: 10px; }
.pop-colors .dots { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.pop-colors .dots button { width: 32px; height: 32px; border-radius: 50%; border: 1px solid rgba(0,0,0,.15); cursor: pointer; padding: 0; }
.pop-colors .dots button[aria-pressed="true"] { outline: 2px solid var(--fg); outline-offset: 2px; }
.pop-colors .any { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.pop-colors .any input[type="color"] { width: 36px; height: 32px; padding: 0 2px; border: 1px solid var(--line); border-radius: 7px; background: var(--bg); }
.pop-colors .any input[type="text"] { width: 90px; padding: 5px 8px; font-size: 13px; }
.pop-colors .reset { font-size: 13px; padding: 6px 10px; }

/* chat */
.ask .head { display: flex; justify-content: space-between; align-items: center; }
.ask .head .btn.small { min-height: 32px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips .chip { border: 1px solid var(--line); color: var(--fg); background: var(--soft); min-height: 32px; border-style: solid; }
.chips .chip:hover { border-color: var(--muted); }
.msgs { display: grid; gap: 8px; max-height: 50vh; overflow: auto; }
.msg { padding: 9px 12px; border-radius: 12px; font-size: 14px; max-width: 92%; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.user { background: var(--fg); color: var(--surface); justify-self: end; border-bottom-right-radius: 4px; }
.msg.ai { background: var(--soft); justify-self: start; border-bottom-left-radius: 4px; }
.msg.sys { background: var(--amber-100); color: var(--warn); font-weight: 600; font-size: 13.5px; justify-self: start; }
.msg img { display: block; max-width: 160px; border-radius: 8px; margin-bottom: 6px; }
.msg .foot { display: flex; gap: 8px; align-items: center; margin-top: 6px; font-size: 12.5px; color: var(--muted); }
.msg .foot button, .msg .retry { background: none; border: 0; padding: 0; font: 600 12.5px var(--body); color: var(--focus); cursor: pointer; text-decoration: underline; }
.composer { display: grid; gap: 8px; }
.composer textarea { min-height: 44px; max-height: 120px; resize: none; background: var(--bg); }
.composer .row { display: flex; gap: 8px; align-items: center; }
.composer .row .btn.secondary { margin-left: auto; min-width: 88px; }
.composer .left { font-size: 12.5px; color: var(--muted); }
.attached { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.attached img { width: 44px; height: 44px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.stepper { display: grid; gap: 6px; background: var(--soft); border-radius: 12px; padding: 12px 14px; font-size: 13.5px; }
.stepper .ttl { font-weight: 600; display: flex; justify-content: space-between; gap: 8px; }
.stepper ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 3px; color: var(--muted); }
.stepper li::before { content: "○ "; } .stepper li.done::before { content: "● "; color: var(--ok); }
.stepper li.now { color: var(--fg); font-weight: 600; } .stepper li.now::before { content: "◐ "; color: var(--accent); animation: spin 1s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.stepper .bar { height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; }
.stepper .bar i { display: block; height: 100%; width: 0; background: var(--fg); transition: width .5s linear; }
.stepper .bar.indet i { width: 40%; animation: slide 1.2s ease-in-out infinite; }
@keyframes slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(260%); } }
.stepper .tail { display: flex; justify-content: space-between; align-items: center; gap: 8px; color: var(--muted); font-size: 12.5px; }
.dim { opacity: .55; pointer-events: none; }

/* stage */
.stage { position: relative; border-radius: 16px; overflow: hidden; height: clamp(300px, calc(100dvh - var(--bar) - 262px), 760px);
  background: radial-gradient(120% 90% at 50% 20%, var(--stage-top), var(--stage-bottom)); touch-action: pan-y; }
.stage:fullscreen { border-radius: 0; height: 100vh; }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline-offset: -3px; }
.stage .line { position: absolute; top: 0; left: 0; right: 0; height: 3px; background: linear-gradient(90deg, transparent, var(--accent), transparent); background-size: 50% 100%; animation: slide 1s linear infinite; z-index: 2; }
.stage .over { position: absolute; color: #e7ecf5; font-size: 12.5px; background: rgba(10,15,29,.55); padding: 4px 9px; border-radius: 999px; pointer-events: none; }
.stage .hint { left: 12px; bottom: 10px; animation: fade 4.5s forwards; }
@keyframes fade { 0%, 80% { opacity: 1; } 100% { opacity: 0; visibility: hidden; } }
.stage .size { right: 12px; bottom: 10px; font-variant-numeric: tabular-nums; }
.stage .busy { left: 12px; top: 12px; color: #ffd9a8; }
.stage .banner { left: 12px; bottom: 40px; pointer-events: auto; display: flex; gap: 8px; align-items: center; font-weight: 600; }
.stage .banner button { background: none; border: 0; color: #c9d3ea; font-size: 15px; cursor: pointer; padding: 0 2px; }
.stage .loading { position: absolute; inset: 0; display: grid; place-items: center; color: #c9d3ea; font-size: 14px; pointer-events: none; }
.stage .views { position: absolute; top: 10px; right: 10px; display: flex; gap: 6px; }
.stage .views button { background: rgba(255,255,255,.12); color: #e7ecf5; border: 1px solid rgba(255,255,255,.25); padding: 0 10px; min-height: 32px; font: 500 12.5px var(--body); border-radius: 8px; cursor: pointer; }
.stage .views button:hover, .stage .views button[aria-pressed="true"] { background: rgba(255,255,255,.26); }
.stage .views button svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; vertical-align: -3px; }

/* print strip */
.strip { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; display: grid; gap: 12px; }
.strip .row { display: grid; grid-template-columns: minmax(200px, 260px) minmax(0, 1fr); gap: 14px; align-items: start; }
.strip select { min-height: 40px; padding: 8px 12px; background: var(--bg); }
.facts { display: grid; gap: 2px; font-size: 14px; }
.facts b { font-weight: 600; }
.facts .i { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; border: 1px solid var(--muted); color: var(--muted); font-size: 11px; cursor: help; margin-left: 4px; }
.checks { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: 14px; }
.checks li { display: flex; gap: 8px; }
.checks li::before { content: "✓"; color: var(--ok); font-weight: 700; flex: none; }
.checks li.bad::before { content: "✗"; color: var(--accent); }
.checks li.warn::before { content: "!"; color: var(--warn); }
.dl { display: grid; gap: 8px; justify-items: start; }
.dl .btn.primary { min-width: 220px; min-height: 44px; font-size: 15.5px; }
.dl .two { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.free { font-size: 13px; color: var(--muted); margin: 0; }
.files { display: grid; gap: 8px; }
.file { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.file.rec { border-color: var(--ok); }
.file b { display: block; font-size: 14px; } .file small { color: var(--muted); font-size: 12.5px; display: block; }
.file .tag { font: 600 11px var(--body); color: var(--ok); text-transform: uppercase; letter-spacing: .6px; }
.file a { font: 600 13.5px var(--body); color: var(--accent); text-decoration: none; white-space: nowrap; padding: 8px 10px; border-radius: 8px; }
.file a:hover { background: var(--soft); }
.file .lock { font-size: 12.5px; color: var(--muted); white-space: nowrap; }

/* phone bars and tabs */
.tabs { display: none; }
.phonebar { display: none; }

/* sheets */
#studio dialog, .sheet { border: 0; padding: 0; background: var(--surface); color: var(--fg); border-radius: 16px; width: min(560px, calc(100% - 32px)); max-height: 92dvh; box-shadow: 0 12px 40px rgba(10,15,29,.25); }
#studio dialog::backdrop { background: var(--overlay); }
#studio dialog form.body, #studio dialog .body { padding: 20px; display: grid; gap: 14px; }
#studio dialog h3 { font: 400 24px var(--display); margin: 0; }
#studio dialog .x { position: absolute; top: 10px; right: 10px; }
#studio dialog .actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
#studio dialog p { margin: 0; }
#studio dialog.wide { width: min(1040px, calc(100% - 32px)); height: 90dvh; }
#studio dialog.wide .body { height: 100%; grid-template-rows: auto auto minmax(0, 1fr); }
.filters { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.dgrid { overflow: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; padding: 2px; align-content: start; }
.dcard { display: grid; gap: 4px; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 8px; text-align: left; color: var(--fg); font: 500 13px/1.3 var(--body); cursor: pointer; }
.dcard:hover { border-color: var(--fg); }
.dcard img { width: 100%; aspect-ratio: 1 / 1; object-fit: contain; background: #fff; border-radius: 8px; }
.dcard small { color: var(--muted); font-size: 12px; }
.vis { display: grid; gap: 8px; }
.vis label { display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; font-size: 14px; }
.vis label:has(input:checked) { border-color: var(--fg); background: var(--soft); }
.vis input { margin-top: 3px; } .vis b { display: block; } .vis small { color: var(--muted); }
.check { display: flex; gap: 10px; align-items: start; font-size: 14px; }
.warnbox { background: var(--amber-100); border: 1px solid color-mix(in srgb, var(--warn) 35%, var(--line)); border-radius: 12px; padding: 12px 14px; font-size: 14px; }
.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pcard { border: 1px solid var(--line); border-radius: 12px; padding: 16px; display: grid; gap: 8px; align-content: start; }
.pcard .amt { font: 400 30px var(--display); } .pcard .amt small { font: 500 14px var(--body); color: var(--muted); }
.pcard ul { margin: 0; padding-left: 18px; color: var(--muted); font-size: 14px; }
.pcard .btn { margin-top: auto; }
.link-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.link-row input { font-size: 14px; }
.share-row .btn { min-height: 40px; }
.est { font-size: 14px; color: var(--muted); }
.google { min-height: 44px; }
.auth-sent { display: grid; gap: 8px; }
.err { color: var(--accent); font-size: 14px; font-weight: 600; }

@media (max-width: 1023px) {
  #studio { --bar: 48px; display: flex; flex-direction: column; height: auto; min-height: 100dvh; }
  body:has(#studio) { overflow: auto; }
  .sbar { position: sticky; top: 0; z-index: 12; height: 48px; padding: 0 8px; }
  .sbar .logo, .sbar .status, .sbar .hist, .sbar .actions .desk { display: none; }
  .sbar .title { pointer-events: none; font-size: 15px; padding: 6px 4px; }
  .phone-only { display: inline-flex !important; }
  .sbody { display: contents; }
  .stagecol { display: contents; }
  .stage { position: sticky; top: 48px; z-index: 11; order: 1; border-radius: 0; height: 42dvh; min-height: 0; max-height: none; aspect-ratio: auto; transition: height .2s ease; }
  #studio.kbd .stage { height: 28dvh; }
  .stage .size { bottom: 10px; }
  .tabs { order: 2; position: sticky; top: calc(48px + 42dvh); z-index: 11; display: grid; grid-template-columns: 1fr 1fr 1fr; background: var(--surface); border-bottom: 1px solid var(--line); padding: 8px 12px; gap: 4px; }
  #studio.kbd .tabs { top: calc(48px + 28dvh); }
  .tabs button { min-height: 40px; border: 0; border-radius: 8px; background: var(--soft); color: var(--muted); font: 600 14px var(--body); cursor: pointer; }
  .tabs button[aria-selected="true"] { background: var(--fg); color: var(--surface); }
  .tabs button .spin { display: inline-block; margin-left: 4px; animation: spin 1s linear infinite; }
  .panel { order: 3; border-right: 0; overflow: visible; padding: 12px 16px 24px; }
  .panel > section { display: none; }
  #studio[data-tab="words"] .panel > .words, #studio[data-tab="words"] .panel > .design, #studio[data-tab="colors"] .panel > .colors, #studio[data-tab="ask"] .panel > .ask { display: grid; }
  .panel > section.design { padding-bottom: 12px; }
  .panel > section.words { border-top: 0; }
  .strip { order: 4; margin: 0 16px 16px; }
  .strip .row { grid-template-columns: minmax(0, 1fr); }
  .strip .dl { display: none; }
  .phonebar { display: grid; order: 5; position: sticky; bottom: 0; z-index: 12; gap: 4px; justify-items: center; padding: 8px 16px calc(8px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--line); margin-top: auto; }
  .phonebar .btn.primary { width: 100%; min-height: 48px; font-size: 16px; }
  .msgs { max-height: none; }
  #studio dialog { width: 100%; max-width: none; margin: auto 0 0; border-radius: 16px 16px 0 0; max-height: 92dvh; }
  #studio dialog::before { content: ""; display: block; width: 36px; height: 4px; border-radius: 2px; background: var(--line); margin: 8px auto -8px; }
  #studio dialog.wide { height: 92dvh; }
  .cards { grid-template-columns: 1fr; }
  .parts { grid-template-columns: 1fr 1fr; }
}
@media (prefers-reduced-motion: reduce) { .stage .hint { animation: none; opacity: 0; visibility: hidden; } .stage .line, .stepper li.now::before, .stepper .bar.indet i { animation: none; } }
