/* =========================================================================
   Whisper Studio — the student asset maker.
   Same voice as the site: warm near-black, white type, TeX Gyre Heros 400,
   pills for actions. The chrome stays dark and quiet so the design is the
   only colour on screen. Phone first: the editor is a bottom sheet over a
   tab bar; from 1000px it becomes a rail + panel beside a large stage.
   ========================================================================= */

@font-face {
  font-family: "TeX Gyre Heros";
  src: url("fonts/texgyreheros-regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "TeX Gyre Heros";
  src: url("fonts/texgyreheros-italic.woff2") format("woff2");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --bg: #130F0C;
  --fg: #FFFFFF;
  --panel: #1B1713;
  /* frosted surfaces floating over the stage */
  --glass: rgba(27, 23, 19, .78);
  --glass-hi: rgba(27, 23, 19, .95);
  --glass-hover: rgba(48, 42, 36, .9);
  --well: color-mix(in srgb, var(--fg) 7%, var(--panel));
  --line: color-mix(in srgb, var(--fg) 12%, transparent);
  --muted: color-mix(in srgb, var(--fg) 62%, transparent);
  --focus: #00D9FF;
  --font: "TeX Gyre Heros", Helvetica, "Helvetica Neue", Arial, sans-serif;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --r-card: 20px;
  --tabs-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

/* Light: chosen from the ⋯ menu, remembered on the device. The design
   itself never changes with it — only the editor around it. */
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #F2EEE8;
  --fg: #130F0C;
  --panel: #FFFFFF;
  --glass: rgba(255, 255, 255, .82);
  --glass-hi: rgba(255, 255, 255, .96);
  --glass-hover: rgba(255, 255, 255, 1);
}
:root[data-theme="light"] .stage__art { box-shadow: 0 24px 50px -22px rgba(19,15,12,.45), 0 2px 8px rgba(19,15,12,.12); }
:root[data-theme="light"] .pane { box-shadow: 0 -18px 40px -24px rgba(19,15,12,.25); }
:root[data-theme="light"] .checks,
:root[data-theme="light"] .menu { box-shadow: inset 0 0 0 1px var(--line), 0 18px 40px -16px rgba(19,15,12,.3); }
:root[data-theme="light"] .xport::backdrop { background: rgba(19,15,12,.35); }

/* System (the default) follows the device until Light or Dark is picked */
@media (prefers-color-scheme: light) {
:root:not([data-theme="dark"]) {
  color-scheme: light;
  --bg: #F2EEE8;
  --fg: #130F0C;
  --panel: #FFFFFF;
  --glass: rgba(255, 255, 255, .82);
  --glass-hi: rgba(255, 255, 255, .96);
  --glass-hover: rgba(255, 255, 255, 1);
}
:root:not([data-theme="dark"]) .stage__art { box-shadow: 0 24px 50px -22px rgba(19,15,12,.45), 0 2px 8px rgba(19,15,12,.12); }
:root:not([data-theme="dark"]) .pane { box-shadow: 0 -18px 40px -24px rgba(19,15,12,.25); }
:root:not([data-theme="dark"]) .checks,
:root:not([data-theme="dark"]) .menu { box-shadow: inset 0 0 0 1px var(--line), 0 18px 40px -16px rgba(19,15,12,.3); }
:root:not([data-theme="dark"]) .xport::backdrop { background: rgba(19,15,12,.35); }
}

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }
body.studio {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 400 15px/1.4 var(--font);
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
  overscroll-behavior: none;
}
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
button, input, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ── Top bar ───────────────────────────────────────────────────────────── */

.sbar {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  height: 60px;
  padding: 0 max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
  padding-top: env(safe-area-inset-top, 0px);
  height: calc(60px + env(safe-area-inset-top, 0px));
}
.sbar__brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--fg);
  text-decoration: none;
}
.sbar__logo { width: 34px; height: 34px; fill: currentColor; }
.sbar__name {
  font-size: 17px;
  letter-spacing: -0.02em;
  padding-left: 10px;
  border-left: 1px solid var(--line);
  line-height: 20px;
}
.sbar__size {
  margin-left: auto;
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
@media (max-width: 520px) {
  .sbar__size { display: none; }
  .sbar { gap: 6px; }
  .sbar__logo { width: 32px; height: 32px; }
  .sbar__name { font-size: 16px; padding-left: 8px; }
  .sbar .pill { padding: 0 14px; }
  .sbar .ibtn { width: 36px; height: 36px; }
  .sbar__hist { gap: 0; }
}

/* ── Undo / redo ───────────────────────────────────────────────────────── */

.sbar__hist { display: flex; gap: 2px; margin-left: auto; }
.ibtn {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--fg);
  transition: background-color .2s var(--ease), opacity .2s;
}
.ibtn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.ibtn[disabled] { opacity: .3; }
.ibtn--light { background: var(--fg); color: var(--bg); margin-left: 4px; }
.ibtn svg .f { fill: currentColor; stroke: none; }

/* ⋯ menu */
.more { position: relative; }
.menu {
  /* pinned to the screen edge, not the button, so it never runs off a phone */
  position: fixed;
  right: 12px;
  top: calc(64px + env(safe-area-inset-top, 0px));
  z-index: 30;
  width: min(300px, calc(100vw - 24px));
  padding: 6px;
  border-radius: 18px;
  background: var(--glass-hi);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  box-shadow: inset 0 0 0 1px var(--line), 0 18px 40px -16px rgba(0,0,0,.8);
  animation: pop-in .25s var(--ease);
}
.menu__row { display: grid; gap: 10px; padding: 10px 12px 12px; }
.menu__row .seg { display: grid; grid-template-columns: repeat(3, 1fr); width: 100%; }
.menu__row .seg__btn { min-height: 32px; padding: 0 14px; font-size: 13.5px; }
.menu__sep { height: 1px; margin: 4px 8px; background: var(--line); }
.menu__item {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 12px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--fg);
  text-align: left;
}
@media (hover: hover) { .menu__item:hover { background: var(--well); } }
.menu__text { display: grid; gap: 3px; flex: 1; }
.menu__label { font-size: 15px; }
.menu__note { font-size: 12.5px; color: var(--muted); line-height: 1.35; }
.switch {
  flex: none;
  position: relative;
  width: 40px; height: 24px;
  border-radius: 999px;
  background: var(--line);
  transition: background-color .2s var(--ease);
}
.switch::after {
  content: "";
  position: absolute; left: 3px; top: 3px;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--fg);
  transition: transform .25s var(--ease);
}
[aria-checked="true"] > .switch { background: #00B8D9; }
[aria-checked="true"] > .switch::after { transform: translateX(16px); }
.ibtn--light svg { stroke-width: 1.9; }
@media (hover: hover) { .ibtn--light:hover { background: color-mix(in srgb, var(--fg) 86%, var(--bg)) !important; } }
@media (hover: hover) { .ibtn:not([disabled]):hover { background: var(--well); } }
.ibtn:active:not([disabled]) { transform: scale(.94); }

/* ── Pills ─────────────────────────────────────────────────────────────── */

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  background: var(--well);
  color: var(--fg);
  font-size: 15px;
  white-space: nowrap;
  transition: transform .2s var(--ease), background-color .2s var(--ease), opacity .2s;
}
.pill:active { transform: scale(.97); }
.pill svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.pill--light { background: var(--fg); color: var(--bg); }
.pill--ghost { background: transparent; box-shadow: inset 0 0 0 1px var(--line); }
.pill--big { min-height: 52px; padding: 0 28px; font-size: 17px; width: 100%; }
.pill[disabled] { opacity: .45; pointer-events: none; }
.pill--file { position: relative; cursor: pointer; }
.pill--file input { position: absolute; inset: 0; opacity: 0; width: 100%; cursor: pointer; }
.pill--file:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
@media (hover: hover) {
  .pill:hover { background: color-mix(in srgb, var(--fg) 14%, var(--panel)); }
  .pill--light:hover { background: color-mix(in srgb, var(--fg) 86%, var(--bg)); }
}

/* ── Frame ─────────────────────────────────────────────────────────────── */

.studio__main {
  width: 100%;
  overflow: hidden;
  height: calc(100% - 60px - env(safe-area-inset-top, 0px));
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) auto auto;
  grid-template-areas: "stage" "pane" "tabs";
}

/* The stage is a soft-lit table the design sits on; the dot grid reads as a
   cutting mat without competing with whatever colour the design is. */
.stage {
  grid-area: stage;
  position: relative;
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 40%, color-mix(in srgb, var(--fg) 5%, transparent), transparent 70%),
    radial-gradient(color-mix(in srgb, var(--fg) 9%, transparent) 1px, transparent 1.2px) 0 0 / 18px 18px,
    var(--bg);
  touch-action: none;
}
.stage__art {
  display: block;
  transform-origin: 50% 50%;
  will-change: transform;
  border-radius: 6px;
  box-shadow: 0 1px 0 rgba(255,255,255,.06) inset, 0 24px 60px -18px rgba(0,0,0,.7), 0 2px 8px rgba(0,0,0,.4);
  touch-action: none;
  cursor: default;
  user-select: none;
  -webkit-user-select: none;
}
.stage__art.is-grab { cursor: grab; }
.stage__art.is-grabbing { cursor: grabbing; }
.stage__art.is-text { cursor: text; }
.stage__hint {
  position: absolute;
  left: 50%;
  bottom: 10px;
  transform: translateX(-50%);
  margin: 0;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--glass);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  pointer-events: none;
  transition: opacity .6s var(--ease);
}
.stage__hint.is-gone { opacity: 0; }

/* ── Stage tools ───────────────────────────────────────────────────────── */

.stage__tools {
  position: absolute;
  top: 12px;
  z-index: 3;
  display: flex;
  gap: 6px;
  align-items: flex-start;
}
.stage__tools--left { left: 12px; flex-direction: column; }
.stage__tools--right { right: 12px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: var(--glass);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  box-shadow: inset 0 0 0 1px var(--line);
  color: var(--fg);
  font-size: 13.5px;
  white-space: nowrap;
  transition: background-color .2s var(--ease), transform .2s var(--ease);
}
.chip:active { transform: scale(.96); }
.chip svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.chip--icon { width: 36px; padding: 0; justify-content: center; }
.chip--icon[aria-pressed="false"] { color: var(--muted); }
.chip--icon[aria-pressed="true"] { color: #00D9FF; }
@media (hover: hover) { .chip:hover { background: var(--glass-hover); } }
#remixBtn.is-spun svg { animation: spin-once .6s var(--ease); }
@keyframes spin-once { from { transform: rotate(-180deg) scale(.7); } }

.chip__dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #FFB020;
  box-shadow: 0 0 0 3px rgba(255,176,32,.2);
}
.chip--check.is-ok .chip__dot { background: #3DDC97; box-shadow: 0 0 0 3px rgba(61,220,151,.2); }
.checks {
  width: min(320px, calc(100vw - 24px));
  padding: 14px 16px 6px;
  border-radius: 18px;
  background: var(--glass-hi);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  box-shadow: inset 0 0 0 1px var(--line), 0 18px 40px -16px rgba(0,0,0,.7);
  animation: pop-in .3s var(--ease);
}
@keyframes pop-in { from { opacity: 0; transform: translateY(-6px) scale(.98); } }
.checks__head { margin: 0 0 8px; font-size: 13px; color: var(--muted); }
.checks__item { margin: 0 0 10px; padding-left: 16px; position: relative; font-size: 14px; line-height: 1.4; }
.checks__item::before { content: ""; position: absolute; left: 0; top: .5em; width: 6px; height: 6px; border-radius: 50%; background: #FFB020; }

/* slide switcher: just "Add slide" until there are two */
.slides {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border-radius: 999px;
  background: var(--glass);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  box-shadow: inset 0 0 0 1px var(--line);
}
.slides__btn, .slides__add {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  min-width: 32px;
  padding: 0 8px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--fg);
  font-size: 13px;
}
.slides__btn svg, .slides__add svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.slides__btn[disabled] { opacity: .3; }
.slides__add { padding: 0 12px 0 10px; }
.slides__add span:empty { display: none; }
.slides.is-multi .slides__add { padding: 0 8px; }
.slides__label { font-size: 13px; min-width: 40px; text-align: center; font-variant-numeric: tabular-nums; }
.slides:not(.is-multi) .slides__btn,
.slides:not(.is-multi) .slides__label { display: none; }
@media (hover: hover) { .slides__btn:not([disabled]):hover, .slides__add:hover { background: var(--well); } }
.stage__hint { bottom: 58px; }
.slides, .stage__hint, .stage__tools { transition: opacity .25s var(--ease); }
.stage.is-cramped .slides,
.stage.is-cramped .stage__hint,
.stage.is-cramped .stage__tools { opacity: 0; pointer-events: none; }

/* the neighbouring slide while swiping */
.ghost {
  position: absolute;
  z-index: 1;
  border-radius: 6px;
  overflow: hidden;
  pointer-events: none;
  box-shadow: 0 24px 60px -18px rgba(0,0,0,.7), 0 2px 8px rgba(0,0,0,.4);
}
.ghost canvas { display: block; width: 100%; height: 100%; }
.ghost__new {
  position: absolute; inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 14px;
  color: var(--muted);
  background: color-mix(in srgb, var(--fg) 6%, var(--bg));
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--fg) 18%, transparent);
  border-radius: inherit;
}
.ghost__new svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; }
.ghost.is-new canvas { display: none; }
.ghost.is-new .ghost__new { display: flex; }

/* slide dots (phones): the current slide is a stretched pill */
.slides__dots { display: none; align-items: center; gap: 6px; padding: 0 8px; }
.dot {
  width: 7px; height: 7px; padding: 0; border: 0; border-radius: 999px;
  background: color-mix(in srgb, var(--fg) 30%, transparent);
  transition: width .3s var(--ease), background-color .3s var(--ease);
}
.dot.is-on { width: 20px; background: var(--fg); }
@media (pointer: coarse) and (max-width: 999px) {
  .slides { background: transparent; box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none; padding: 6px; }
  .slides .slides__btn:not(.slides__del), .slides .slides__label, .slides .slides__add { display: none !important; }
  .slides__dots { display: inline-flex; }
  .slides:not(.is-multi) .slides__del { display: none; }
  .slides__del { width: 30px; height: 30px; min-width: 30px; opacity: .7; }
}

/* the hidden input behind on-design editing: it holds the keyboard and the
   caret position; the canvas draws what you see */
.ghost-input {
  position: absolute;
  z-index: 1;
  height: 1.4em;
  padding: 0;
  border: 0;
  background: transparent;
  color: transparent;
  caret-color: transparent;
  font-size: 16px;
  opacity: 0;
  resize: none;
  outline: none;
  pointer-events: none;
  overflow: hidden;
}

/* ── Tabs ──────────────────────────────────────────────────────────────── */

.tabs {
  grid-area: tabs;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  padding: 4px 6px calc(4px + var(--safe-b));
  background: var(--panel);
  border-top: 1px solid var(--line);
  position: relative;
  z-index: 2;
}
.tab {
  display: grid;
  justify-items: center;
  gap: 3px;
  padding: 8px 0 6px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0;
  transition: color .2s var(--ease), background-color .2s var(--ease);
}
.tab svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.tab svg .soft { opacity: .45; }
.tab svg .fill { fill: currentColor; stroke: none; }
.tab[aria-selected="true"] { color: var(--fg); }
.tab[aria-selected="true"] svg { stroke-width: 1.9; }

/* ── Pane (bottom sheet on phones) ────────────────────────────────────── */

.pane {
  grid-area: pane;
  position: relative;
  z-index: 2;
  background: var(--panel);
  border-radius: 24px 24px 0 0;
  box-shadow: 0 -18px 40px -24px rgba(0,0,0,.8);
  height: var(--sheet, 46dvh);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: height .42s var(--ease);
}
.pane.is-dragging { transition: none; }
.pane.is-closed .pane__body { visibility: hidden; }
.pane.is-closed { box-shadow: none; }
/* the handle is the whole top strip: drag between peek, half and full,
   or tap to toggle */
.pane__grab {
  flex: none;
  display: grid;
  place-items: center;
  height: 30px;
  width: 100%;
  border: 0;
  background: transparent;
  touch-action: none;
  cursor: grab;
}
.pane__grab span { width: 40px; height: 5px; border-radius: 3px; background: color-mix(in srgb, var(--fg) 26%, transparent); }
.pane__body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0 16px 20px;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}
.pane__h {
  margin: 18px 0 10px;
  font-size: 13px;
  font-weight: 400;
  color: var(--muted);
  letter-spacing: 0;
}
.pane__body > .pane__h:first-child { margin-top: 4px; }
.pane__note { margin: 12px 0 0; font-size: 13px; color: var(--muted); line-height: 1.45; }

/* Option tiles share one selected treatment: a white ring with a gap, so the
   ring never fights the tile's own colour. */
.opt {
  position: relative;
  min-width: 0;
  display: grid;
  gap: 8px;
  justify-items: center;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: center;
  color: var(--fg);
  font-size: 13px;
}
.opt__face {
  display: grid;
  place-items: center;
  width: 100%;
  border-radius: 14px;
  background: var(--well);
  box-shadow: 0 0 0 0 var(--panel), 0 0 0 0 var(--fg);
  transition: box-shadow .25s var(--ease), transform .25s var(--ease);
  overflow: hidden;
}
.opt[aria-checked="true"] .opt__face,
.opt[aria-pressed="true"] .opt__face {
  box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--fg);
}
.opt:active .opt__face { transform: scale(.97); }
.opt__name { line-height: 1.2; }
.opt__note { display: block; font-size: 11.5px; color: var(--muted); margin-top: 2px; }

/* Size: platform chips over a grid of named formats */
.fchips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin: 0 -16px;
  padding: 2px 16px 4px;
  scrollbar-width: none;
}
.fchips::-webkit-scrollbar { display: none; }
.fchip {
  flex: none;
  height: 36px;
  padding: 0 15px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  box-shadow: inset 0 0 0 1px var(--line);
  color: var(--fg);
  font-size: 14px;
  transition: background-color .2s var(--ease), color .2s var(--ease), box-shadow .2s var(--ease);
}
.fchip { display: inline-flex; align-items: center; gap: 7px; padding: 0 15px 0 12px; }
.fchip svg { width: 17px; height: 17px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.fchip svg .f { fill: currentColor; stroke: none; }
/* Heros sits low in its line box; lift the label to the optical centre */
.fchip span { position: relative; top: -1px; }
.fchip[aria-checked="true"] { background: var(--fg); color: var(--bg); box-shadow: none; }
@media (hover: hover) { .fchip:not([aria-checked="true"]):hover { background: var(--well); } }
.presets { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 16px 12px; }
.presets .opt__face { height: 104px; }
.presets .opt__name { font-size: 12.5px; line-height: 1.25; }
/* the sample sits in a frame that hints where it's going */
.pv { display: block; line-height: 0; box-shadow: 0 8px 18px -8px rgba(0,0,0,.7); }
.pv canvas { display: block; }
.pv--phone { padding: 3px; border-radius: 9px; background: #2B2622; box-shadow: inset 0 0 0 1px rgba(255,255,255,.12), 0 8px 18px -8px rgba(0,0,0,.7); }
.pv--phone canvas { border-radius: 6px; }
.pv--card { padding: 7px 4px 4px; border-radius: 7px; background: #F4F1EC; position: relative; }
.pv--card::before { content: ""; position: absolute; left: 6px; top: 3px; width: 22px; height: 2px; border-radius: 1px; background: rgba(19,15,12,.18); }
.pv--card canvas { border-radius: 3px; }
.pv--paper { border-radius: 1px; }

/* Layout */
.layouts { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 14px 12px; }
.layouts .opt__face { padding: 8px; aspect-ratio: 1; }
.layouts canvas { display: block; max-width: 100%; max-height: 100%; border-radius: 3px; box-shadow: 0 4px 12px -4px rgba(0,0,0,.6); }

/* Colour */
.palettes { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 14px 12px; }
.swatch {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-size: 26px;
  letter-spacing: -0.04em;
}
.swatch i {
  position: absolute;
  right: 10px;
  bottom: 10px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
}

/* Photo */
.photo-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.photo-actions--gap { margin-top: 12px; }

.samples {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin: -6px -16px 0;
  /* room for the selected tile's ring, which a scroller would clip */
  padding: 6px 16px 8px;
  scrollbar-width: none;
}
.samples::-webkit-scrollbar { display: none; }
.samples .opt { flex: none; width: 76px; }
.samples .opt__face { height: 76px; }
/* upload is the first tile in the strip, not a separate row of buttons */
.opt--upload { cursor: pointer; }
.opt--upload .opt__face {
  position: relative;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 4px;
  background: transparent;
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--fg) 28%, transparent);
  font-size: 12.5px;
}
.opt--upload svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }
.opt--upload input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.opt--upload:focus-within .opt__face { box-shadow: inset 0 0 0 2px var(--focus); }
.photo-tools { display: flex; gap: 8px; margin-top: 12px; }
.pill--sm { min-height: 34px; padding: 0 14px; font-size: 14px; gap: 6px; }
.pill--sm svg { width: 16px; height: 16px; }
.pill.is-busy, .opt.is-busy { opacity: .7; }
/* a section heading with a quiet action on the right */
.pane__row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.pane__row .pane__h { margin-bottom: 10px; }
.pane__body > .pane__row:first-child .pane__h { margin-top: 4px; }
.textbtn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
  border: 0;
  background: transparent;
  color: var(--fg);
  font-size: 13px;
  white-space: nowrap;
  opacity: .85;
}
.textbtn svg, .pill--sm svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; }
.textbtn[disabled] { opacity: .45; }
@media (hover: hover) { .textbtn:hover { opacity: 1; } }
.samples img { width: 100%; height: 100%; object-fit: cover; display: block; }
.effects { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 14px 10px; }
.effects .opt__face { aspect-ratio: 1; }
.effects canvas { width: 100%; height: 100%; max-width: 100%; display: block; }

/* Stickers */
.stickers { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 10px; }
.stickers .opt__face { aspect-ratio: 1; padding: 10px; background: color-mix(in srgb, var(--fg) 5%, var(--panel)); }
.stickers img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; filter: drop-shadow(0 4px 6px rgba(0,0,0,.45)); }
.sel { margin-top: 6px; padding-top: 4px; border-top: 1px solid var(--line); }

/* Fields */
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 4px; }
.field { display: grid; gap: 6px; min-width: 0; }
.field--wide { grid-column: 1 / -1; }
.field__label { font-size: 13px; color: var(--muted); }
.field input,
.field textarea {
  width: 100%;
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--well);
  font-size: 16px;               /* 16px keeps iOS from zooming on focus */
  line-height: 1.35;
  resize: none;
  outline: none;
  transition: border-color .2s var(--ease), background-color .2s var(--ease);
}
.field input:focus,
.field textarea:focus { border-color: color-mix(in srgb, var(--fg) 55%, transparent); background: color-mix(in srgb, var(--fg) 10%, var(--panel)); }
.field input::placeholder,
.field textarea::placeholder { color: color-mix(in srgb, var(--fg) 30%, transparent); }
.field.is-flash input,
.field.is-flash textarea { border-color: var(--fg); }

/* Segmented control */
.seg {
  display: inline-grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  padding: 4px;
  border-radius: 999px;
  background: var(--well);
  gap: 2px;
}
.seg__btn {
  min-height: 36px;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  transition: background-color .2s var(--ease), color .2s var(--ease);
}
.seg__btn[aria-checked="true"] { background: var(--fg); color: var(--bg); }

/* Sliders */
.sliders { display: grid; gap: 14px; margin-top: 18px; }
.slider { display: grid; gap: 8px; }
.range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 28px;
  background: transparent;
  margin: 0;
}
.range::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: linear-gradient(to right, var(--fg) var(--p, 50%), var(--line) var(--p, 50%)); }
.range::-moz-range-track { height: 4px; border-radius: 2px; background: var(--line); }
.range::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--fg); }
.range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 24px; height: 24px; margin-top: -10px;
  border-radius: 50%;
  background: var(--fg);
  box-shadow: 0 2px 8px rgba(0,0,0,.5);
}
.range::-moz-range-thumb { width: 24px; height: 24px; border: 0; border-radius: 50%; background: var(--fg); }

/* ── Export dialog ─────────────────────────────────────────────────────── */

.xport {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--fg);
  width: 100%;
  max-width: 100%;
  max-height: 100%;
  margin: auto 0 0;
}
.xport::backdrop { background: rgba(8,6,5,.6); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.xport[open] .xport__card { animation: xport-up .5s var(--ease); }
@keyframes xport-up { from { transform: translateY(40px); opacity: 0; } }
.xport__card {
  background: var(--panel);
  border-radius: 28px 28px 0 0;
  padding: 18px 18px calc(18px + var(--safe-b));
  box-shadow: 0 -20px 60px -20px rgba(0,0,0,.8);
}
.xport__head { display: flex; align-items: center; justify-content: space-between; }
.xport__title { margin: 0; font-size: 22px; font-weight: 400; letter-spacing: -0.03em; }
.xport__close { width: 40px; height: 40px; border: 0; border-radius: 50%; background: var(--well); display: grid; place-items: center; }
.xport__close svg { width: 18px; height: 18px; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; fill: none; }
.xport__meta { margin: 4px 0 16px; font-size: 13px; color: var(--muted); }
.xport__formats { display: grid; gap: 8px; }
.fmt {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 0;
  border-radius: 18px;
  background: var(--well);
  text-align: left;
  box-shadow: 0 0 0 0 var(--fg);
  transition: box-shadow .25s var(--ease);
}
.fmt[aria-checked="true"] { box-shadow: 0 0 0 2px var(--fg); }
.fmt__icon { width: 44px; height: 44px; border-radius: 12px; background: color-mix(in srgb, var(--fg) 10%, transparent); display: grid; place-items: center; font-size: 12px; letter-spacing: .02em; }
.fmt__name { font-size: 16px; }
.fmt__note { display: block; font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.fmt__dot { width: 20px; height: 20px; border-radius: 50%; box-shadow: inset 0 0 0 1.5px var(--line); }
.fmt[aria-checked="true"] .fmt__dot { box-shadow: inset 0 0 0 6px var(--fg); }
.xport__motion { margin-top: 6px; }
.xport__progress { margin-top: 18px; }
.xport__bar { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.xport__bar span { display: block; height: 100%; width: 0; background: var(--fg); border-radius: inherit; transition: width .15s linear; }
.xport__actions { margin-top: 20px; display: grid; gap: 8px; }

/* ── Toast ─────────────────────────────────────────────────────────────── */

.toast {
  position: fixed;
  left: 50%;
  top: calc(70px + env(safe-area-inset-top, 0px));
  transform: translate(-50%, -12px);
  z-index: 20;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--fg);
  color: var(--bg);
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s var(--ease), transform .3s var(--ease);
  max-width: calc(100% - 32px);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ── Tablet & desktop: rail + panel + stage ───────────────────────────── */

@media (min-width: 1000px) {
  .sbar { height: 68px; padding: 0 24px; }
  .sbar__size { margin-left: 24px; margin-right: auto; }
  .studio__main {
    height: calc(100% - 68px);
    grid-template-columns: 88px 380px minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    grid-template-areas: "tabs pane stage";
  }
  .tabs {
    grid-template-columns: none;
    grid-auto-rows: max-content;
    align-content: start;
    gap: 4px;
    padding: 8px 10px;
    border-top: 0;
    border-right: 1px solid var(--line);
    background: var(--bg);
  }
  .tab { padding: 12px 0 10px; font-size: 12px; }
  .tab[aria-selected="true"] { background: var(--well); }
  @media (hover: hover) { .tab:hover { color: var(--fg); } }
  .pane,
  .pane.is-closed {
    height: auto;
    max-height: none;
    border-radius: 0;
    box-shadow: none;
    border-right: 1px solid var(--line);
    background: var(--bg);
  }
  .pane__grab { display: none; }
  .pane__body { padding: 20px 22px 32px; }
  .pane__body > .pane__h:first-child { margin-top: 0; }
  .stage { border-radius: 0; }
  .stage__hint { bottom: 74px; }
  .stage__tools { top: 20px; }
  .stage__tools--left { left: 20px; }
  .stage__tools--right { right: 20px; }
  .slides { bottom: 20px; }
  .pane.is-closed .pane__body { visibility: visible; }
  .stage__art { border-radius: 8px; }

  .xport { max-width: 460px; margin: auto; }
  .xport__card { border-radius: 28px; padding: 24px; }
  .xport[open] .xport__card { animation-name: xport-in; }
  @keyframes xport-in { from { transform: scale(.96); opacity: 0; } }
}

@media (min-width: 1400px) {
  .studio__main { grid-template-columns: 88px 420px minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
