/* ════════════════════════════════════════════════════════════════════════
   STUDIO.CSS — layout shared by Studio (sites) and Studio Pro (stores)
   Builds on lpm.css tokens and components; nothing here restyles them.
   ════════════════════════════════════════════════════════════════════════ */

.studio-body { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
.studio { flex: 1; min-height: 0; display: grid; grid-template-columns: 372px minmax(0, 1fr); }

/* ── Switch between the two Studios (top bar) ──────────────────────────── */
.studio-switch { flex: none; }
.studio-switch a { display: inline-block; padding: 6px 14px; border-radius: 999px; font-size: 13px; line-height: 1.4; color: var(--ink-2); text-decoration: none; white-space: nowrap; }
.studio-switch a:hover { color: var(--ink); }
.studio-switch a[aria-current="page"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); font-weight: 500; }

/* ── Controls ──────────────────────────────────────────────────────────── */
.studio-side { min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 4px 22px 48px; background: var(--surface); border-right: 1px solid var(--line); }
.side-sec { padding: 22px 0; border-top: 1px solid var(--line); }
.side-sec:first-of-type, .side-banner + .side-sec, .side-banner + .side-banner + .side-sec { border-top: 0; }
.side-banner { margin-top: 18px; }
.side-banner p + .link { margin-top: 6px; display: inline-block; }
.side-h { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; font: 500 12px/1.2 var(--sans); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.step { width: 22px; height: 22px; flex: none; display: grid; place-items: center; border-radius: 50%; background: var(--ink); color: var(--surface); font: 500 11px/1 var(--mono); letter-spacing: 0; }
.studio-side .field + .field { margin-top: 14px; }
.studio-side .switch-row h4 { font-size: 14px; }
.link.small { font-size: 13px; }

.edition-list { display: grid; gap: 10px; }
.edition { display: flex; gap: 14px; align-items: flex-start; width: 100%; padding: 14px; text-align: left; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); transition: border-color .15s ease, box-shadow .15s ease; }
.edition:hover { border-color: var(--ink-2); }
.edition[aria-checked="true"] { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
.edition-swatch { width: 34px; height: 34px; flex: none; border-radius: 10px; border: 6px solid; }
.edition strong { display: block; font-weight: 600; font-size: 15px; }
.edition .small { display: block; margin-top: 2px; line-height: 1.45; }

.swatches { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.swatch { width: 34px; height: 34px; padding: 0; border-radius: 50%; border: 1px solid var(--line-strong); background: var(--paper, #fff); position: relative; }
.swatch::after { content: ""; position: absolute; inset: 7px; border-radius: 50%; background: var(--accent, #111); }
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--ink); }
.color-row { display: grid; grid-template-columns: 96px minmax(0, 1fr); align-items: center; gap: 12px; margin-bottom: 10px; }
.color-row .label { margin: 0; }
.color-pick { display: flex; gap: 8px; align-items: center; }
.color-pick .input-mono { text-transform: uppercase; }
.contrast-note { margin: 4px 0 12px; padding: 8px 12px; border-radius: 8px; background: var(--wash); color: var(--ink-2); line-height: 1.45; }
.contrast-note:empty { display: none; }
.contrast-note.warn { background: var(--warn-wash); color: var(--warn); }

/* Studio (sites): template, sections, photos */
.tpl-current { display: grid; gap: 4px; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); }
.tpl-current strong { font-size: 15px; }
.tpl-current .tpl-swatches { display: flex; gap: 4px; margin-top: 6px; }
.tpl-swatches span { width: 18px; height: 18px; border-radius: 50%; border: 1px solid var(--line-strong); }
.section-list { display: grid; gap: 6px; }
.section-item { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 8px 8px 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.section-item.off { background: var(--wash); }
.section-item.off .section-name { color: var(--muted); text-decoration: line-through; }
.section-item input { width: 18px; height: 18px; margin: 0; accent-color: var(--ink); }
.section-name { font-size: 14px; }
.section-name small { color: var(--muted); margin-left: 6px; font-size: 12px; }
.section-moves { display: flex; gap: 2px; }
.section-moves button { width: 30px; height: 30px; border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--ink-2); font-size: 14px; line-height: 1; }
.section-moves button:hover:not(:disabled) { border-color: var(--line-strong); background: var(--bg); }
.section-moves button:disabled { opacity: .3; cursor: default; }
.photo-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.photo { display: grid; gap: 6px; }
.photo-thumb { position: relative; aspect-ratio: 4 / 3; overflow: hidden; border-radius: 10px; border: 1px dashed var(--line-strong); background: var(--wash); display: grid; place-items: center; color: var(--muted); font-size: 12px; }
.photo-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.photo-thumb.has { border-style: solid; }
.photo-label { font-size: 13px; font-weight: 500; }
.photo-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.photo-actions .btn { min-height: 30px; padding: 0 10px; font-size: 12px; }
.reopen { padding: 14px; border-radius: var(--radius); border: 1px dashed var(--line-strong); }
.stage-title { margin: 0; font-weight: 500; font-size: 14px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Template picker */
.dialog-xl { width: min(1040px, 100%); }
.tpl-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; min-height: 240px; }
.tpl-card { display: grid; gap: 0; padding: 0; overflow: hidden; text-align: left; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); transition: border-color .15s ease, box-shadow .15s ease; }
.tpl-card:hover { border-color: var(--ink-2); box-shadow: var(--shadow); }
.tpl-card[aria-current="true"] { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
.tpl-card .tpl-thumb { position: relative; aspect-ratio: 16 / 11; overflow: hidden; background: var(--wash); border-bottom: 1px solid var(--line); }
.tpl-card .tpl-thumb iframe { position: absolute; top: 0; left: 0; width: 1280px; height: 880px; border: 0; transform-origin: 0 0; transform: scale(var(--s, .25)); pointer-events: none; background: #fff; }
.tpl-card .tpl-info { display: grid; gap: 2px; padding: 12px 14px 14px; }
.tpl-card strong { font-size: 15px; }
.tpl-card .small { line-height: 1.45; }

.buy-card { background: var(--bg); }
.buy-price { margin: 4px 0 8px; font: 400 40px/1 var(--serif); }
.buy-price .small { font-family: var(--sans); }

/* ── Preview stage ─────────────────────────────────────────────────────── */
.studio-stage { min-width: 0; min-height: 0; display: flex; flex-direction: column; gap: 12px; padding: 16px 20px 20px; background: var(--bg-2); }
.stage-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.stage-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; }
.edit-toggle { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 500; cursor: pointer; white-space: nowrap; }
.stage-hint { margin: -2px 0 0; font-size: 13px; color: var(--ink-2); }
.stage-frame { position: relative; flex: 1; min-height: 0; width: 100%; margin: 0 auto; overflow: hidden; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow); transition: width .25s ease, border-radius .25s ease; }
.stage-frame.phone { width: 400px; max-width: 100%; border: 8px solid var(--ink); border-radius: 30px; }
.stage-frame iframe { display: block; width: 100%; height: 100%; border: 0; background: #FFFFFF; }
.stage-loading { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(255, 255, 255, .72); }
.stage-loading[hidden] { display: none; }
.stage-error { position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; text-align: center; background: var(--surface); }

/* ── Mobile: one panel at a time ───────────────────────────────────────── */
.studio-tabs { display: none; }

/* ── Dialog content ────────────────────────────────────────────────────── */
.summary { padding: 14px 16px; border-radius: var(--radius); background: var(--wash); }
.summary .spread { font-weight: 500; }
.summary .num { font-size: 17px; }
.purchase-list { display: grid; gap: 10px; }
.purchase { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius); }
.purchase-title { font-weight: 600; overflow-wrap: anywhere; }
.purchase-meta { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; margin-top: 4px; font-size: 13px; color: var(--muted); }
.purchase-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.btn .count, .tab .count { font-family: var(--mono); font-size: 11px; padding: 1px 6px; border-radius: 999px; background: var(--ink); color: var(--surface); }
.tab .count { margin-left: 6px; }          /* a .btn spaces its children with gap */

/* ── Download overlay ──────────────────────────────────────────────────── */
#bundle-overlay .overlay-card { width: min(460px, 100%); }
#bundle-overlay .progress { width: 220px; margin: 6px auto 0; }
.done-mark { width: 52px; height: 52px; margin: 0 auto; display: grid; place-items: center; border-radius: 50%; background: var(--ok-wash); color: var(--ok); font-size: 26px; }
.next-steps { margin: 4px 0 0; padding-left: 20px; text-align: left; color: var(--ink-2); display: grid; gap: 6px; }
.center-row { justify-content: center; flex-wrap: wrap; }

@media (max-width: 1080px) {
  .studio { grid-template-columns: 320px minmax(0, 1fr); }
  .studio-side { padding: 4px 18px 40px; }
  .tpl-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
  .studio-body { height: auto; min-height: 100vh; overflow: visible; }
  .studio { display: block; }
  .studio-tabs { display: flex; gap: 4px; position: sticky; top: 60px; z-index: 30; padding: 0 var(--gutter); background: var(--bg); border-bottom: 1px solid var(--line); }
  .studio-tabs .tab { flex: 1; }
  .studio-side { border-right: 0; padding: 4px var(--gutter) 40px; overflow: visible; }
  .studio-stage { padding: 12px var(--gutter) 20px; }
  .stage-frame { flex: none; height: calc(100vh - 210px); height: calc(100dvh - 210px); min-height: 460px; }
  .studio[data-panel="design"] .studio-stage, .studio[data-panel="preview"] .studio-side { display: none; }
}

@media (max-width: 720px) {
  .studio-switch .sw-long { display: none; }
  .studio-switch a { padding: 6px 12px; }
  .appbar-end { gap: 6px; }
  .stage-frame.phone { width: 100%; border-width: 0; border-radius: 14px; }
  .purchase { grid-template-columns: minmax(0, 1fr); }
  .purchase-actions { justify-content: flex-start; }
  .tpl-grid { grid-template-columns: minmax(0, 1fr); }
}

.pe-icon { display: none; }

@media (max-width: 480px) {
  .appbar { gap: 8px; }
  .appbar .co-price { display: none; }
  #btn-purchases { padding: 0 10px; }
  #btn-purchases .pe-icon { display: block; }
  #btn-purchases .pe-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}
