/* Nova Studio: phone-first layout. Portrait: top bar / canvas / tool options / tools.
   Landscape phones and wide screens: the tools become a left rail; very wide screens also dock the layers on the right. */
:root {
  --bg: #0b0b12;
  --panel: #14141d;
  --panel-2: #1c1c28;
  --line: #2a2a3a;
  --text: #ecebf7;
  --muted: #8f8eaa;
  --accent: #7DFABC;
  --accent-ink: #08080E;
  --danger: #ff6b6b;
  --stage: #0f0f17;
  --radius: 12px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); overscroll-behavior: none; }
body { font: 14px/1.4 'DM Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; -webkit-text-size-adjust: 100%; overflow: hidden; }
button, select, input, textarea, a { font: inherit; color: inherit; touch-action: manipulation; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.st-sr { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ic { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }

#st-app {
  position: fixed; inset: 0;
  height: 100vh; height: 100dvh; height: var(--st-h, 100dvh);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "top" "stage" "options" "tools";
  padding: env(safe-area-inset-top) calc(env(safe-area-inset-right) + var(--st-low-w, 0px)) calc(env(safe-area-inset-bottom) + var(--st-low, 0px)) env(safe-area-inset-left);
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}

/* ── Top bar ── */
#st-top { grid-area: top; display: flex; align-items: center; gap: 4px; padding: 6px 8px; background: var(--panel); border-bottom: 1px solid var(--line); min-width: 0; }
.st-title { font-weight: 700; font-size: 15px; letter-spacing: .01em; white-space: nowrap; margin-left: 2px; }
.st-title span { color: var(--accent); }
.st-grow { flex: 1; min-width: 0; }
.st-ibtn { width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 10px; background: transparent; color: var(--text); text-decoration: none; flex-shrink: 0; }
.st-ibtn:active { background: var(--panel-2); }
.st-ibtn:disabled { opacity: .35; cursor: default; }
.st-primary { display: inline-flex; align-items: center; justify-content: center; height: 40px; padding: 0 16px; border: 0; border-radius: 10px; background: var(--accent); color: var(--accent-ink); font-weight: 700; text-decoration: none; }
.st-primary:active { filter: brightness(.9); }
.st-primary:disabled { opacity: .5; }
.st-ghost { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 8px 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); color: var(--text); font-weight: 600; text-decoration: none; }
.st-ghost:active { background: var(--line); }
.st-ghost[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.st-wide { width: 100%; min-height: 46px; }

/* ── Canvas ── */
#st-stage { grid-area: stage; position: relative; overflow: hidden; background: var(--stage); touch-action: none; min-height: 0; }
#st-world { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; box-shadow: 0 0 0 1px rgba(255,255,255,.08), 0 8px 30px rgba(0,0,0,.5);
  background-color: #cfcfd6; background-image: linear-gradient(45deg, #b9b9c2 25%, transparent 25%, transparent 75%, #b9b9c2 75%), linear-gradient(45deg, #b9b9c2 25%, transparent 25%, transparent 75%, #b9b9c2 75%);
  background-size: 16px 16px; background-position: 0 0, 8px 8px; }
#st-view { display: block; width: 100%; height: 100%; pointer-events: none; }
#st-world.pixelated #st-view { image-rendering: pixelated; }
#st-ui { position: absolute; left: 0; top: 0; width: 100%; height: 100%; pointer-events: none; }
#st-layer-chip { position: absolute; left: 8px; top: 8px; max-width: calc(100% - 118px); }
#st-layer-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#st-fit { position: absolute; right: 8px; top: 8px; }
.st-chip { display: inline-flex; align-items: center; gap: 4px; height: 32px; padding: 0 10px; border: 1px solid var(--line); border-radius: 16px; background: rgba(20,20,29,.9); color: var(--text); font-size: 12px; font-weight: 600; }
.st-chip .ic { width: 15px; height: 15px; }
.st-chip[aria-pressed="true"], .st-chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
#st-toast { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); max-width: calc(100% - 24px); padding: 8px 14px; border-radius: 18px; background: rgba(28,28,40,.96); border: 1px solid var(--line); font-size: 13px; text-align: center; z-index: 5; pointer-events: none; }

/* ── Tool options ── */
#st-options { grid-area: options; display: flex; align-items: center; gap: 12px; padding: 6px 10px; background: var(--panel); border-top: 1px solid var(--line); overflow-x: auto; overflow-y: hidden; min-height: 52px; scrollbar-width: none; touch-action: pan-x; }
#st-options::-webkit-scrollbar { display: none; }
.st-opt { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; color: var(--muted); font-size: 12px; font-weight: 600; }
.st-opt input[type="range"] { width: 110px; height: 32px; accent-color: var(--accent); }
.st-opt output { min-width: 28px; color: var(--text); font-variant-numeric: tabular-nums; text-align: right; }
.st-opt .st-chip { background: var(--panel-2); }
.st-opt .st-chip.big { height: 38px; padding: 0 12px; border-radius: 10px; font-size: 13px; }
.st-opt .st-dot { width: 16px; height: 16px; }
.st-opt-hint { color: var(--muted); font-size: 13px; white-space: nowrap; }
/* Crop and Apply stay at the right edge of the bar while the other chips slide under them */
#st-options .st-opt-apply { position: sticky; right: 0; z-index: 2; margin-left: auto; padding-left: 10px; background: var(--panel); box-shadow: -12px 0 10px -2px var(--panel); }
#st-options .st-opt-apply::after { content: ''; position: absolute; left: 100%; top: 0; bottom: 0; width: 10px; background: var(--panel); }   /* hides the chips that slide past the bar's right padding */
#st-options .st-opt-apply .st-chip { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.st-opt .st-seg { margin: 0; }
.st-opt .st-seg button { min-height: 36px; padding: 0 12px; font-size: 12px; white-space: nowrap; }
.st-dot { display: inline-block; width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--text); background: #111; flex-shrink: 0; vertical-align: middle; }
.st-dot.none { background: linear-gradient(135deg, transparent 45%, var(--danger) 45%, var(--danger) 55%, transparent 55%), #fff; }

/* ── Tools ── */
#st-tools { grid-area: tools; display: flex; gap: 4px; padding: 6px 8px; background: var(--panel); border-top: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
#st-tools::-webkit-scrollbar { display: none; }
.st-tool { flex: 1 0 58px; min-width: 58px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; height: 54px; padding: 4px 1px; border: 1px solid transparent; border-radius: 10px; background: transparent; color: var(--muted); font-size: 10.5px; font-weight: 600; }
.st-tool[aria-pressed="true"] { color: var(--accent-ink); background: var(--accent); }
.st-tool:not([aria-pressed="true"]):active { background: var(--panel-2); }
#st-copies[hidden] { display: none; }
.st-tool-go { color: var(--accent); border-color: var(--accent); }   /* an action, not a tool: it opens Export on a print sheet */
#st-color-dot { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--text); background: #111; display: block; box-shadow: 0 0 0 3px var(--panel), 0 0 0 4px var(--line); }

/* ── Layers dock (wide screens) ── */
#st-dock { display: none; grid-area: dock; background: var(--panel); border-left: 1px solid var(--line); min-width: 0; min-height: 0; overflow-y: auto; }
.st-dock-head { padding: 12px 14px 4px; }
.st-dock-head h2 { margin: 0; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
#st-dock-body { padding: 8px; }

/* ── Sheets ── */
#st-sheets { position: fixed; left: 0; right: 0; top: 0; height: 100vh; height: 100dvh; height: var(--st-h, 100dvh); z-index: 50; }
#st-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.55); }
.st-sheet { position: absolute; left: 0; right: 0; bottom: 0; max-height: 88vh; max-height: 88dvh; overflow-y: auto; background: var(--panel); border-radius: 18px 18px 0 0; border-top: 1px solid var(--line); padding: 14px 16px calc(18px + env(safe-area-inset-bottom)); overscroll-behavior: contain; }
.st-sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.st-sheet-head h2 { margin: 0; font-size: 17px; }
.st-x { width: 40px; height: 40px; border: 0; border-radius: 10px; background: var(--panel-2); font-size: 16px; }
.st-label { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; margin: 12px 0 8px; }
.st-hint { color: var(--muted); font-size: 13px; margin: 8px 0; text-align: center; }
.st-warn { color: var(--danger); }
.st-row { display: flex; gap: 8px; margin-bottom: 8px; }
.st-row > * { flex: 1; }
.st-seg { display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin-bottom: 8px; }
.st-seg button { flex: 1; min-height: 44px; border: 0; background: var(--panel-2); color: var(--muted); font-weight: 600; }
.st-seg button + button { border-left: 1px solid var(--line); }
.st-seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.st-seg button small { display: block; margin-top: 2px; font-size: 11px; font-weight: 600; opacity: .8; }
.st-seg-5 button { padding: 0 2px; font-size: 13px; }
.st-tabs { display: flex; gap: 6px; overflow-x: auto; margin: 4px 0 10px; padding-bottom: 2px; scrollbar-width: none; }
.st-tabs::-webkit-scrollbar { display: none; }
.st-tab { flex: 0 0 auto; min-height: 40px; padding: 0 14px; border: 1px solid var(--line); border-radius: 20px; background: var(--panel-2); color: var(--text); font-size: 15px; white-space: nowrap; }
.st-tab[aria-selected="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.st-check { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 2px; }
.st-check input { width: 22px; height: 22px; accent-color: var(--accent); flex-shrink: 0; }
.st-slider { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.st-slider > span { width: 74px; flex-shrink: 0; color: var(--muted); font-size: 12px; font-weight: 600; }
.st-slider input[type="range"] { flex: 1; min-width: 0; height: 32px; accent-color: var(--accent); }
.st-slider output { width: 44px; text-align: right; font-variant-numeric: tabular-nums; }
.st-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.st-list button, .st-list a { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 0 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); color: var(--text); text-decoration: none; text-align: left; }
.st-list button:active, .st-list a:active { background: var(--line); }
.st-list em { margin-left: auto; font-style: normal; color: var(--accent); font-size: 12px; font-weight: 700; }

/* new / presets */
.st-presets { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; margin-bottom: 12px; }
.st-preset { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 84px; padding: 8px 4px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); text-align: center; }
.st-preset i { display: block; border: 2px solid var(--muted); border-radius: 3px; background: transparent; }
.st-preset b { font-size: 12px; }
.st-preset small { color: var(--muted); font-size: 11px; }
.st-preset[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.st-custom-size { display: flex; align-items: flex-end; gap: 10px; margin-bottom: 8px; }
.st-custom-size label { flex: 1; display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 12px; font-weight: 600; }
.st-custom-size input { min-height: 44px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); color: var(--text); font-size: 16px; }
.st-custom-size span { padding-bottom: 12px; color: var(--muted); }
.st-anchor { display: grid; grid-template-columns: repeat(3, 44px); gap: 6px; margin-bottom: 8px; }
.st-anchor button { width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2); }
.st-anchor button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); }

/* colour */
.st-swatches { display: grid; grid-template-columns: repeat(8, 1fr); gap: 8px; margin-bottom: 8px; }
.st-sw { aspect-ratio: 1; min-width: 0; min-height: 0; width: 100%; border-radius: 50%; border: 2px solid var(--line); padding: 0; }
.st-sw[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(125,250,188,.3); }
.st-recent { min-height: 38px; }
.st-hexrow { display: flex; gap: 8px; margin: 10px 0; }
.st-custom, .st-hex { flex: 1; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); font-size: 12px; color: var(--muted); font-weight: 600; }
.st-custom input { width: 56px; height: 34px; padding: 0; border: 0; background: transparent; }
.st-hex input { width: 90px; min-height: 36px; padding: 0 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--text); font-size: 15px; text-transform: lowercase; }

/* text */
#st-text-input { width: 100%; min-height: 64px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); color: var(--text); font-size: 17px; resize: vertical; user-select: text; -webkit-user-select: text; }
.st-colors { flex-wrap: wrap; margin-top: 8px; }
.st-colors > * { flex: 1 1 calc(50% - 8px); }

/* shapes */
.st-shapegrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 8px; }
.st-shape { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 76px; padding: 6px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); color: var(--text); font-size: 11px; }
.st-shape svg { width: 34px; height: 34px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.st-shape[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }

/* layers list */
.st-layers { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.st-layer { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); min-height: 56px; }
.st-layer[aria-selected="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.st-layer.hidden-l .st-lthumb, .st-layer.hidden-l .st-lname { opacity: .45; }
.st-lthumb { width: 44px; height: 44px; flex-shrink: 0; border-radius: 6px; overflow: hidden; background-color: #cfcfd6; background-image: linear-gradient(45deg, #b9b9c2 25%, transparent 25%, transparent 75%, #b9b9c2 75%), linear-gradient(45deg, #b9b9c2 25%, transparent 25%, transparent 75%, #b9b9c2 75%); background-size: 10px 10px; background-position: 0 0, 5px 5px; display: flex; align-items: center; justify-content: center; }
.st-lthumb canvas { max-width: 100%; max-height: 100%; display: block; }
.st-lname { flex: 1; min-width: 0; text-align: left; border: 0; background: transparent; padding: 6px 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; font-size: 13px; }
.st-lname small { display: block; color: var(--muted); font-weight: 500; font-size: 11px; }
.st-lbtn { width: 38px; height: 38px; display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 8px; background: transparent; color: var(--muted); flex-shrink: 0; }
.st-lbtn[aria-pressed="true"] { color: var(--accent); }
.st-lbtn .ic { width: 18px; height: 18px; }
.st-lbtn:active { background: var(--line); }
.st-lprops { padding: 8px 4px 4px; }
.st-lprops select { width: 100%; min-height: 44px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); color: var(--text); }
.st-lactions { display: grid; grid-template-columns: repeat(auto-fit, minmax(64px, 1fr)); gap: 6px; margin-top: 8px; }
.st-lactions button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 50px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); font-size: 10.5px; color: var(--text); }
.st-lactions button:disabled { opacity: .35; }
.st-lactions .ic { width: 18px; height: 18px; }

/* designs list */
.st-liblist { display: flex; flex-direction: column; gap: 8px; margin: 8px 0; }
.st-design { display: flex; gap: 10px; align-items: center; padding: 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel-2); }
.st-design[aria-current="true"] { border-color: var(--accent); }
.st-dthumb { width: 64px; height: 64px; flex-shrink: 0; border-radius: 8px; background: #cfcfd6; overflow: hidden; display: flex; align-items: center; justify-content: center; }
.st-dthumb img { max-width: 100%; max-height: 100%; display: block; }
.st-dmeta { flex: 1; min-width: 0; }
.st-dname { display: block; width: 100%; border: 0; background: transparent; padding: 0; font-weight: 700; font-size: 14px; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.st-dsub { color: var(--muted); font-size: 12px; }
.st-dbtns { display: flex; gap: 4px; }

/* export */
#st-ex-img { display: block; max-width: 100%; max-height: 38vh; margin: 0 auto 8px; border-radius: 8px; background: #cfcfd6; }

/* wide screens: tools rail on the left, layers docked on the right */
@media (orientation: landscape) and (max-height: 560px), (min-width: 820px) {
  #st-app { grid-template-columns: 64px minmax(0, 1fr); grid-template-rows: auto auto minmax(0, 1fr); grid-template-areas: "top top" "tools options" "tools stage"; }
  #st-tools { flex-direction: column; border-top: 0; border-right: 1px solid var(--line); overflow-y: auto; overflow-x: hidden; padding: 6px 4px; }
  .st-tool { flex: 0 0 auto; min-width: 0; width: 100%; height: 54px; }
  #st-options { border-top: 0; border-bottom: 1px solid var(--line); }
}
@media (min-width: 1000px) {
  #st-app { grid-template-columns: 64px minmax(0, 1fr) 300px; grid-template-areas: "top top top" "tools options dock" "tools stage dock"; }
  #st-dock { display: block; }
  #st-layer-chip { display: none; }
  #st-fit { right: 8px; }
}
@media (max-width: 380px) { .st-tool { flex-basis: 54px; min-width: 54px; font-size: 10px; } .st-title .st-nova { display: none; } }
@media (max-width: 340px) { .st-title { display: none; } #st-top { gap: 2px; padding: 6px 4px; } }

/* layer masks */
.st-lmask { border: 1px solid var(--line); padding: 0; cursor: pointer; background: #000; }
.st-lmask[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(125,250,188,.4); }
.st-lmask.off { opacity: .45; }
.st-lactions button { text-align: center; }
.st-list button:disabled { opacity: .38; }
.st-opt .st-chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* adjust: a sheet that leaves the picture visible */
#st-sheets.low { pointer-events: none; }
#st-sheets.low #st-backdrop { display: none; }
#st-sheets.low .st-sheet { pointer-events: auto; height: min(40dvh, 360px); max-height: none; display: flex; flex-direction: column; padding-top: 10px; padding-bottom: calc(8px + env(safe-area-inset-bottom)); box-shadow: 0 -6px 24px rgba(0,0,0,.4); }
#st-app.adjusting #st-top, #st-app.adjusting #st-tools, #st-app.adjusting #st-options { pointer-events: none; opacity: .45; }
.st-adj-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.st-adj-head h2 { margin: 0; font-size: 16px; }
.st-adj-btns { display: flex; gap: 8px; }
.st-adj-btns .st-ghost, .st-adj-btns .st-primary { min-height: 38px; height: 38px; padding: 0 14px; }
#st-hist { display: block; width: 100%; height: 44px; margin-bottom: 4px; border-radius: 8px; background: var(--panel-2); flex-shrink: 0; }
#st-sheet-adjust-tabs, #st-adj-tabs { flex-shrink: 0; margin: 2px 0 4px; }
#st-adj-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding-bottom: 6px; }
#st-adj-body .st-slider { min-height: 40px; }
#st-adj-body .st-row { margin-top: 6px; }
#st-adj-body .st-row .st-ghost { min-height: 40px; padding: 6px 10px; font-size: 13px; }
.st-looks { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 8px; margin-bottom: 8px; }
.st-look { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 4px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); color: var(--text); font-size: 11px; min-width: 0; }
.st-look canvas { width: 100%; height: auto; max-height: 64px; object-fit: cover; border-radius: 6px; background: #000; }
.st-look[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
@media (orientation: landscape) and (max-height: 560px), (min-width: 820px) {
  #st-sheets.low .st-sheet { left: auto; right: 0; top: 0; bottom: 0; width: min(360px, 46vw); height: auto; border-radius: 0; border-top: 0; border-left: 1px solid var(--line); box-shadow: -6px 0 24px rgba(0,0,0,.4); padding-top: calc(10px + env(safe-area-inset-top)); }
}

/* text: a sheet that leaves the picture visible. On a phone it has two parts, the words and the style (so the keyboard does not cover the
   picture); on a wide screen both parts are shown, beside the picture. */
#sheet-text .st-adj-head { flex-shrink: 0; }
#st-text-tabs { flex-shrink: 0; margin: 0 0 8px; }
#st-text-tabs button { min-height: 40px; }
#st-text-tabs button[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); }
#st-text-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding-bottom: 6px; }
#sheet-text[data-pane="words"] .st-pane-look, #sheet-text[data-pane="look"] .st-pane-words { display: none; }
#st-sheets.low #sheet-text[data-pane="words"] { height: auto; }
#sheet-text .st-label:first-child { margin-top: 0; }
#sheet-text .st-slider { min-height: 40px; }
@media (orientation: landscape) and (max-height: 560px), (min-width: 820px) {
  #st-text-tabs { display: none; }
  #sheet-text .st-pane-words, #sheet-text .st-pane-look { display: block !important; }
}
/* on a phone the tool rows wait while a text is edited, so they give their room to the picture */
@media (max-width: 819px) and (orientation: portrait), (max-width: 819px) and (min-height: 561px) {
  #st-app.texting #st-options, #st-app.texting #st-tools { display: none; }
}

/* layer styles */
#st-style-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding-bottom: 6px; }
.st-fx { border: 1px solid var(--line); border-radius: 12px; background: var(--panel-2); padding: 4px 12px 6px; margin-bottom: 10px; }
.st-fx:not(.on) .st-slider { opacity: .5; }
.st-fxhead { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.st-fxhead input[type="color"] { width: 44px; height: 34px; padding: 0; border: 1px solid var(--line); border-radius: 8px; background: transparent; }
.st-fx .st-slider > span { width: 70px; }

/* templates */
.st-templates { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; margin-bottom: 12px; align-items: end; }
.st-tpl { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); color: var(--text); text-align: center; min-width: 0; }
.st-tpl-pic { width: 100%; height: 92px; display: flex; align-items: center; justify-content: center; background: #1a1a26; border-radius: 6px; overflow: hidden; }
.st-tpl-pic canvas { max-width: 100%; max-height: 100%; display: block; }
.st-tpl b { font-size: 12px; }
.st-tpl small { color: var(--muted); font-size: 10.5px; }
.st-tpl:active { background: var(--line); }
.st-tpl b { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.st-tpl small { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.st-tpl .st-pro { margin: 0 0 0 4px; }
.st-search { width: 100%; box-sizing: border-box; min-height: 44px; padding: 0 14px; margin: 2px 0 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); color: var(--text); font-size: 15px; }
.st-search:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.st-chips { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 8px; margin: 0 -2px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.st-chips::-webkit-scrollbar { display: none; }
.st-chips[hidden] { display: none; }
.st-chips button { flex: 0 0 auto; min-height: 38px; padding: 0 14px; border: 1px solid var(--line); border-radius: 999px; background: transparent; color: var(--text); font-size: 12.5px; white-space: nowrap; }
.st-chips button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 700; }
.st-count { color: var(--muted); font-weight: 500; font-size: 12px; margin-left: 4px; }
.st-tpl-pic { min-height: 70px; }

/* PRO tags: everything is free for now, the tag only says what will be paid later */
.st-pro { display: inline-block; margin-left: 6px; padding: 1px 6px; border-radius: 999px; font-size: 9px; font-weight: 800; font-style: normal; letter-spacing: .06em; line-height: 1.5; vertical-align: middle; background: rgba(125,250,188,.16); color: var(--accent); }
.st-list .st-pro { margin-left: auto; }
.st-seg button[aria-pressed="true"] .st-pro { background: rgba(0,0,0,.18); color: var(--accent-ink); }
#st-ex-send { margin-top: 4px; }

/* gradient presets and the curve editor */
.st-grad { display: inline-block; width: 26px; height: 14px; border-radius: 4px; border: 1px solid var(--line); flex-shrink: 0; vertical-align: middle; margin-right: 6px; }
.st-curve-lay { display: flex; gap: 10px; align-items: flex-start; }
#st-curve { flex: 0 0 auto; width: clamp(150px, 46vw, 220px); aspect-ratio: 1; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; touch-action: none; cursor: crosshair; }
.st-curve-side { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.st-curve-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
#st-adj-body .st-curve-grid .st-ghost { min-height: 34px; height: 34px; padding: 2px 2px; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.st-curve-side .st-hint { margin: 0; font-size: 12px; }
.st-ghost[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* brand kit */
.st-brand-colors { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin-bottom: 8px; }
.st-brand-colors:empty { display: none; }
.st-brand-sw { position: relative; }
.st-brand-x { position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; padding: 0; border-radius: 50%; border: 1px solid var(--line); background: var(--panel); color: var(--text); font-size: 15px; line-height: 20px; }
.st-brand-pick { display: flex; align-items: center; justify-content: center; position: relative; cursor: pointer; }
.st-brand-pick input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.st-brand-logo { display: flex; align-items: center; justify-content: center; min-height: 84px; margin-bottom: 8px; border: 1px dashed var(--line); border-radius: 10px; background: repeating-conic-gradient(#8884 0 25%, transparent 0 50%) 50% / 16px 16px; }
.st-brand-logo img { max-width: 100%; max-height: 120px; object-fit: contain; }
.st-brand-logo p { margin: 0; }
.st-brand-corner { margin-bottom: 8px; flex-wrap: wrap; }
.st-brand-corner button { flex: 1 1 30%; min-height: 40px; font-size: 12px; }

/* batch edit */
.st-bt-list { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.st-bt-list::-webkit-scrollbar { display: none; }
.st-bt-th { position: relative; flex: 0 0 auto; width: 56px; height: 56px; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); background: var(--panel-2); }
.st-bt-th img { width: 100%; height: 100%; object-fit: cover; display: block; }
.st-bt-x { position: absolute; top: 0; right: 0; width: 24px; height: 24px; border: 0; border-radius: 0 0 0 8px; background: rgba(0,0,0,.6); color: #fff; font-size: 16px; line-height: 1; }
.st-bt-prevwrap { position: sticky; top: -14px; z-index: 3; margin: 6px 0; padding: 6px 0; background: var(--panel); display: flex; flex-direction: column; align-items: center; gap: 6px; }
.st-bt-prev { max-width: 100%; max-height: 28dvh; width: auto; height: auto; border-radius: 8px; border: 1px solid var(--line); background: repeating-conic-gradient(#8884 0 25%, transparent 0 50%) 50% / 16px 16px; }
.st-bt-compare { min-height: 36px; font-size: 13px; touch-action: none; user-select: none; -webkit-user-select: none; }
#st-bt-adj .st-slider { min-height: 40px; }

/* batch edit as the plain image resizer (studio.html?tool=resize) */
#sheet-batch.bt-simple .bt-adv { display: none !important; }

/* Soft screens: sheets rise and fade in (the same as Forms, Audio and Animate), the backdrop and the toast fade in, buttons ease between their states.
   Only translate (its own property, so it never fights with a transform), opacity and colours move. Leaving is instant. With "reduce motion" on, nothing moves. */
.st-sheet { animation: st-rise .18s ease-out; }
@keyframes st-rise { from { translate: 0 24px; opacity: 0; } to { translate: 0 0; opacity: 1; } }
#st-backdrop { animation: st-fade .18s ease-out; }
@keyframes st-fade { from { opacity: 0; } to { opacity: 1; } }
#st-toast { animation: st-pop .16s ease-out; }
@keyframes st-pop { from { translate: 0 8px; opacity: 0; } to { translate: 0 0; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .st-sheet, #st-backdrop, #st-toast { animation: none; } }
