/* PulseAI Studio — dark studio theme.
   Spacing scale: 4 / 8 / 12 / 16 / 24 / 32 / 48. Type scale: 12 / 13 / 14 / 16 / 20 / 28 / 40. */
:root {
  --bg: #0a0912;
  --bg2: #0d0b17;
  --panel: #13111f;
  --raise: #1a1729;
  --raise2: #221e35;
  --line: rgba(255,255,255,.07);
  --line2: rgba(255,255,255,.12);
  --line3: rgba(255,255,255,.2);
  --text: #f1effa;
  --muted: #a39dbf;
  --dim: #6f6990;
  --accent: #7b3dff;      /* logo violet */
  --accent2: #ff2d9b;     /* logo magenta */
  --accent3: #1e9bff;     /* logo blue */
  --accent-soft: rgba(123,61,255,.16);
  --grad: linear-gradient(100deg, #7b3dff 0%, #b23cf2 50%, #ff2d9b 100%);
  --grad3: linear-gradient(90deg, #7b3dff, #1e9bff 45%, #ff2d9b);
  --ok: #3ddc97;
  --warn: #ffc24d;
  --err: #ff5d6c;
  --r-sm: 10px;
  --r: 14px;
  --r-lg: 18px;
  --shadow: 0 1px 0 rgba(255,255,255,.03) inset, 0 8px 24px rgba(0,0,0,.28);
  --shadow-lg: 0 24px 64px rgba(0,0,0,.55);
  --ring: 0 0 0 3px rgba(123,61,255,.45);
  --ease: cubic-bezier(.2,.7,.2,1);
  --t: 180ms;
  --font: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --tabbar-h: 0px;
  --side-w: 232px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body { min-height: 100vh; min-height: 100dvh; overflow-x: hidden;
  background: radial-gradient(1200px 600px at 85% -10%, rgba(123,61,255,.09), transparent 60%),
              radial-gradient(900px 500px at 10% 110%, rgba(255,45,155,.05), transparent 60%), var(--bg);
  background-attachment: fixed; }
body.locked { overflow: hidden; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; }
a { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
:focus { outline: none; }
:focus-visible { outline: none; box-shadow: var(--ring); }
.ico { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round; }
.ico.fill { fill: currentColor; stroke: none; }
.muted { color: var(--muted); }

/* ---------------------------------------------------------------- shell */
.shell { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100vh; }
.topbar, .tabbar { display: none; }

.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px; min-height: 44px; border-radius: var(--r-sm); cursor: pointer;
  -webkit-tap-highlight-color: transparent; text-decoration: none; }
.brand:active { opacity: .7; }
.brand-mark { width: 26px; height: 30px; object-fit: contain; display: block; }
.wordmark { font-size: 18px; font-weight: 700; letter-spacing: -.02em; }
.wordmark b { font-weight: 700; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; margin-left: 1px; }

.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 24px;
  padding: 20px 12px 16px; background: rgba(13,11,23,.7); border-right: 1px solid var(--line); }
.side-nav { display: flex; flex-direction: column; gap: 4px; }
.side-nav a { position: relative; display: flex; align-items: center; gap: 12px; height: 44px; padding: 0 12px;
  border-radius: var(--r-sm); color: var(--muted); font-weight: 500;
  transition: background var(--t) var(--ease), color var(--t) var(--ease); }
.side-nav a .ico { width: 20px; height: 20px; }
.side-nav a:hover { background: var(--raise); color: var(--text); }
.side-nav a.on { background: var(--raise); color: var(--text); }
.side-nav a.on::before { content: ""; position: absolute; left: -12px; top: 10px; bottom: 10px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--grad); }
.side-nav a.on .ico { color: #c9a8ff; }
.side-foot { margin-top: auto; }
.status-card { display: grid; gap: 2px; padding: 12px; border: 1px solid var(--line); border-radius: var(--r);
  background: var(--panel); }
.engine-pill { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 500; color: var(--text); min-width: 0; }
.engine-pill span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.engine-pill i, .status-chip i { width: 8px; height: 8px; border-radius: 50%; background: var(--dim); flex: none; }
.engine-pill.ok i, .status-chip.ok i { background: var(--ok); box-shadow: 0 0 0 3px rgba(61,220,151,.15); }
.engine-pill.bad i, .status-chip.bad i { background: var(--err); box-shadow: 0 0 0 3px rgba(255,93,108,.15); }
.status-chip.busy i { background: var(--accent); box-shadow: 0 0 0 3px rgba(123,61,255,.25); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .45; } }
.queue-note { font-size: 12px; color: var(--dim); padding-left: 16px; min-height: 0; }
.queue-note:empty { display: none; }
.queue-note.spend { color: var(--muted); }
.queue-note.warn { color: #ffb43d; }

main { min-width: 0; padding: 32px 40px 64px; max-width: 1440px; width: 100%; }
.view { display: none; }
.view.on { display: block; animation: fadeIn 220ms var(--ease); }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } }

/* ---------------------------------------------------------------- buttons */
.btn-primary { position: relative; display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  min-height: 52px; padding: 12px 16px; border: 0; border-radius: var(--r); font-weight: 600; font-size: 16px;
  cursor: pointer; color: #fff; background: var(--grad);
  box-shadow: 0 8px 24px rgba(160,60,240,.28), inset 0 1px 0 rgba(255,255,255,.18);
  transition: filter var(--t), opacity var(--t), transform var(--t) var(--ease), box-shadow var(--t); }
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); box-shadow: 0 10px 30px rgba(160,60,240,.38), inset 0 1px 0 rgba(255,255,255,.18); }
.btn-primary:active:not(:disabled) { transform: scale(.985); }
.btn-primary:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; filter: saturate(.55); }
.btn-primary kbd { font: 500 11px var(--font); padding: 2px 6px; border-radius: 6px; background: rgba(0,0,0,.22); opacity: .85; }
.btn-primary .ico { width: 18px; height: 18px; }
.btn-primary:focus-visible { box-shadow: var(--ring), 0 8px 24px rgba(160,60,240,.28); }
.cost { padding: 2px 8px; border-radius: 999px; font-size: 13px; font-weight: 600; background: rgba(255,255,255,.18);
  font-variant-numeric: tabular-nums; }

.btn-ghost, .btn-danger { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px;
  padding: 8px 14px; border: 1px solid var(--line2); background: var(--raise); border-radius: var(--r-sm);
  cursor: pointer; font-weight: 500; font-size: 14px; color: var(--text); white-space: nowrap;
  transition: background var(--t), border-color var(--t), color var(--t), transform var(--t) var(--ease); }
.btn-ghost .ico, .btn-danger .ico { width: 16px; height: 16px; }
.btn-ghost:hover { background: var(--raise2); border-color: var(--line3); }
.btn-ghost:active, .btn-danger:active { transform: scale(.97); }
.btn-ghost.sm { min-height: 32px; padding: 4px 12px; font-size: 13px; }
.btn-ghost.danger:hover { border-color: rgba(255,93,108,.5); color: var(--err); background: rgba(255,93,108,.08); }
.btn-ghost.primary { background: #fff; color: #120f1f; border-color: #fff; font-weight: 600; }
.btn-ghost.primary:hover { background: #ece9f7; }
.btn-danger { background: var(--err); border-color: var(--err); color: #fff; font-weight: 600; }
.btn-danger:hover { filter: brightness(1.08); }
.btn-danger:disabled { opacity: .45; cursor: not-allowed; }

.icon-btn, .icon-close { display: grid; place-items: center; width: 36px; height: 36px; padding: 0; border-radius: 50%;
  border: 1px solid var(--line2); background: rgba(10,9,18,.7); color: var(--text); cursor: pointer;
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); transition: background var(--t), border-color var(--t); }
.icon-btn .ico, .icon-close .ico { width: 16px; height: 16px; }
.icon-btn:hover, .icon-close:hover { background: var(--raise2); border-color: var(--line3); }

/* segmented control */
.seg { display: inline-flex; gap: 2px; padding: 3px; background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; }
.seg button, .seg a { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 36px;
  border: 0; background: none; padding: 0 14px; border-radius: 9px; color: var(--muted); cursor: pointer;
  font-weight: 500; font-size: 13px; white-space: nowrap; transition: background var(--t), color var(--t); }
.seg button:hover, .seg a:hover { color: var(--text); }
.seg button.on, .seg a.on { background: var(--raise2); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.3), inset 0 0 0 1px var(--line); }
.seg .ico { width: 16px; height: 16px; }

/* ---------------------------------------------------------------- home */
.hero { padding: 24px 0 32px; }
.eyebrow { margin: 0 0 12px; font-size: 12px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase;
  color: #b99bff; }
.hero h1 { margin: 0; font-size: clamp(28px, 4vw, 40px); line-height: 1.12; letter-spacing: -.025em; font-weight: 700; }
.hero h1 em { font-style: normal; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero .sub { color: var(--muted); font-size: 16px; margin: 12px 0 0; }


.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0);
  clip-path: inset(50%); border: 0; white-space: nowrap; }

/* showreel: two stacked layers crossfade; the caption re-animates on every clip */
.reel { position: relative; margin: 0 0 24px; border-radius: 22px; overflow: hidden; background: #07060d;
  border: 1px solid var(--line); box-shadow: 0 24px 64px rgba(0,0,0,.45); isolation: isolate; }
.reel-stage { position: relative; display: block; aspect-ratio: 16 / 9; max-height: min(540px, 64vh); width: 100%;
  touch-action: pan-y; -webkit-user-select: none; user-select: none; cursor: pointer; }
.reel-stage:focus-visible { box-shadow: inset 0 0 0 3px rgba(123,61,255,.7); }
.reel-layer { position: absolute; inset: 0; opacity: 0; transition: opacity 500ms ease; }
.reel-layer.on { opacity: 1; z-index: 1; }
.reel-layer video, .reel-layer img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.reel-layer img.still { animation: kenburns 3.6s linear both; }
.reel.paused .reel-layer img.still { animation-play-state: paused; }
@keyframes kenburns { from { transform: scale(1); } to { transform: scale(1.06); } }
.reel-ba { position: absolute; inset: 0; }
.reel-ba .ba-tag { bottom: auto; top: 44px; }
.reel-ba .ba-line { box-shadow: 0 0 0 1px rgba(0,0,0,.28), 0 0 16px rgba(0,0,0,.35); }
.reel-shade { position: absolute; inset: 0; z-index: 2; pointer-events: none;
  background: linear-gradient(0deg, rgba(7,6,13,.82) 0%, rgba(7,6,13,.35) 30%, transparent 55%),
              linear-gradient(180deg, rgba(7,6,13,.45), transparent 22%); }
.reel-cap { position: absolute; left: 32px; bottom: 28px; right: 160px; z-index: 3; display: flex; flex-direction: column;
  align-items: flex-start; gap: 12px; pointer-events: none; }
.reel-cap .sc-pill { position: static; }
.reel-title { margin: 0; font-size: clamp(28px, 4.2vw, 52px); line-height: 1.04; font-weight: 700; letter-spacing: -.03em;
  color: #fff; text-shadow: 0 2px 24px rgba(0,0,0,.45); text-wrap: balance; }
.reel-cap > * { transition: opacity 200ms ease, transform 200ms ease; }
.reel-cap.out > * { opacity: 0; transform: translateY(-6px); }
.reel-cap.in > * { animation: capIn 620ms var(--ease) both; }
.reel-cap.in > :nth-child(2) { animation-delay: 90ms; }
@keyframes capIn { from { opacity: 0; transform: translateY(14px); filter: blur(4px); } to { opacity: 1; transform: none; filter: none; } }
.reel-go { position: absolute; right: 24px; bottom: 28px; z-index: 3; display: inline-flex; align-items: center; gap: 6px;
  height: 40px; padding: 0 14px 0 16px; border-radius: 999px; font-size: 14px; font-weight: 600; color: #120f1f; background: #fff;
  box-shadow: 0 8px 24px rgba(0,0,0,.35); transition: transform var(--t) var(--ease); }
.reel-go .ico { width: 16px; height: 16px; }
@media (hover: hover) { .reel-stage:hover .reel-go { transform: translateX(2px); } }
.reel-bar { position: absolute; left: 20px; right: 20px; top: 16px; z-index: 4; display: flex; gap: 4px; }
.reel-bar button { flex: 1; position: relative; height: 20px; padding: 0; border: 0; background: none; cursor: pointer; }
.reel-bar button::before, .reel-bar button i { content: ""; position: absolute; left: 0; right: 0; top: 8px; height: 3px; border-radius: 3px; }
.reel-bar button::before { background: rgba(255,255,255,.28); }
.reel-bar button i { background: #fff; transform: scaleX(0); transform-origin: left; }
.reel-bar button.done i { transform: scaleX(1); }
.reel-bar button.cur i { animation: seg var(--d, 4s) linear both; }
.reel.paused .reel-bar button.cur i, .reel.still .reel-bar button.cur i { animation-play-state: paused; }
.reel.still .reel-bar button.cur i { animation: none; transform: scaleX(1); }
@keyframes seg { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.reel-bar button:focus-visible { box-shadow: var(--ring); border-radius: 4px; }

/* four-mode quick links */
.quick { display: grid; grid-template-columns: repeat(auto-fit, minmax(188px, 1fr)); gap: 12px; }
.quick a { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 8px 16px 8px 8px; border-radius: var(--r);
  background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow); font-weight: 600; font-size: 14px;
  white-space: nowrap; transition: border-color var(--t), background var(--t), transform var(--t) var(--ease); }
.q-ico { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; flex: none;
  background: var(--accent-soft); color: #c9a8ff; }
.q-ico .ico { width: 18px; height: 18px; }
@media (hover: hover) { .quick a:hover { border-color: var(--line3); background: var(--raise); transform: translateY(-1px); } }
.quick a:active { transform: scale(.98); }

/* showcase: every card is real output and a link into the matching mode */
.showcase { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.sc-card { position: relative; display: flex; flex-direction: column; min-width: 0; border-radius: var(--r-lg); overflow: hidden;
  background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow); isolation: isolate;
  transition: transform 240ms var(--ease), border-color var(--t), box-shadow 240ms var(--ease); }
.sc-media { position: relative; aspect-ratio: 16 / 9; overflow: hidden; background: #07060d; }
.sc-media video, .sc-media img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block;
  transition: transform 600ms var(--ease); }
.sc-media::after { content: ""; position: absolute; inset: 0; pointer-events: none;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.04); background: linear-gradient(180deg, rgba(0,0,0,.28), transparent 32%); }
.sc-pill { position: absolute; left: 12px; top: 12px; z-index: 2; padding: 4px 10px; border-radius: 999px; font-size: 11px;
  font-weight: 600; letter-spacing: .01em; color: #fff; background: rgba(10,9,18,.62); border: 1px solid rgba(255,255,255,.14);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); white-space: nowrap; }
.ba-line { position: absolute; top: 0; bottom: 0; left: var(--seam, 50%); z-index: 1; width: 2px; margin-left: -1px;
  background: rgba(255,255,255,.9); box-shadow: 0 0 0 1px rgba(0,0,0,.12), 0 0 12px rgba(0,0,0,.25); }
.ba-tag { position: absolute; bottom: 10px; z-index: 2; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600;
  color: #fff; background: rgba(10,9,18,.55); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.ba-l { right: calc(100% - var(--seam, 50%) + 8px); }
.ba-r { left: calc(var(--seam, 50%) + 8px); }
.sc-body { padding: 14px 64px 16px 16px; }
.sc-body h3 { margin: 0 0 4px; font-size: 16px; font-weight: 600; letter-spacing: -.01em; }
.sc-body p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.sc-go { position: absolute; right: 16px; bottom: 20px; display: grid; place-items: center; width: 34px; height: 34px;
  border-radius: 50%; background: var(--raise2); border: 1px solid var(--line2);
  transition: background var(--t), color var(--t), transform var(--t) var(--ease); }
.sc-go .ico { width: 16px; height: 16px; }
@media (hover: hover) {
  .sc-card:hover { transform: translateY(-3px); border-color: var(--line2); box-shadow: 0 20px 48px rgba(0,0,0,.45); }
  .sc-card:hover .sc-media video, .sc-card:hover .sc-media img { transform: scale(1.03); }
  .sc-card:hover .sc-go { background: #fff; color: #120f1f; transform: translateX(2px); }
}
.sc-card:active { transform: scale(.99); }
.sc-card:focus-visible { box-shadow: var(--ring); }
@media (min-width: 640px) {
  .showcase { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .showcase .sc-card:first-child { grid-column: span 2; }
}
@media (min-width: 1100px) {
  .showcase { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
  .showcase .sc-card:first-child { grid-column: auto; }
}

.section-head { display: flex; align-items: center; justify-content: space-between; margin: 40px 0 16px; gap: 12px; }
.section-head h2 { margin: 0; font-size: 16px; font-weight: 600; letter-spacing: -.01em; }
.link { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: 13px; font-weight: 500;
  min-height: 32px; padding: 0 8px; margin-right: -8px; border-radius: 8px; transition: color var(--t); }
.link .ico { width: 14px; height: 14px; }
.link:hover { color: var(--text); }

/* ---------------------------------------------------------------- tiles */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.tile { position: relative; aspect-ratio: 1; border-radius: 12px; overflow: hidden; background: var(--panel);
  border: 1px solid var(--line); cursor: pointer; isolation: isolate;
  transition: transform var(--t) var(--ease), border-color var(--t), box-shadow var(--t); }
.tile:hover { border-color: var(--line2); transform: translateY(-1px); box-shadow: 0 10px 24px rgba(0,0,0,.35); }
.tile img, .tile video { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 300ms var(--ease); }
/* video tile while its GIF preview is being made: the source still (or a soft gradient) + play mark */
.thumb-wait { position: absolute; inset: 0; display: block; }
.thumb-ph { position: absolute; inset: 0; display: block;
  background: radial-gradient(120% 90% at 20% 10%, rgba(123,61,255,.45), transparent 60%),
              radial-gradient(120% 90% at 90% 100%, rgba(255,45,155,.32), transparent 60%), #16132a; }
.thumb-play { position: absolute; left: 50%; top: 50%; z-index: 1; display: grid; place-items: center; width: 36px; height: 36px;
  margin: -18px 0 0 -18px; border-radius: 50%; background: rgba(10,9,18,.55); color: #fff;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.thumb-play .ico { width: 14px; height: 14px; margin-left: 2px; }
.strip .thumb-play { width: 28px; height: 28px; margin: -14px 0 0 -14px; }
.cost-val.est { color: var(--muted); }
.tile .tcost { position: absolute; right: 8px; bottom: 8px; z-index: 2; padding: 2px 7px; border-radius: 999px; font-size: 11px;
  font-weight: 600; color: #fff; background: rgba(10,9,18,.6); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  font-variant-numeric: tabular-nums; }
.tile .tcost.est { color: #d9d3f0; }
.strip .tile .tcost { display: none; }
.tile:hover img, .tile:hover video { transform: scale(1.03); }
.tile::after { content: ""; position: absolute; inset: auto 0 0 0; height: 40%; pointer-events: none;
  background: linear-gradient(transparent, rgba(0,0,0,.45)); z-index: 1; }
.tile .badge { position: absolute; left: 8px; bottom: 8px; z-index: 2; display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px 2px 6px; border-radius: 999px; font-size: 11px; font-weight: 600; color: #fff;
  background: rgba(10,9,18,.6); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.tile .badge .ico { width: 12px; height: 12px; }
.tile .age { position: absolute; left: 8px; top: 8px; z-index: 2; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 500;
  color: rgba(255,255,255,.92); background: rgba(10,9,18,.6); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); white-space: nowrap; }
.strip .tile .age { display: none; }
.tile .state { position: absolute; inset: 0; z-index: 2; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; text-align: center; padding: 12px; background: rgba(10,9,18,.7); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
  font-size: 12px; font-weight: 500; color: var(--text); }
.tile .state .ico { width: 20px; height: 20px; }
.tile .state.failed { color: #ff9aa4; }
.tile .state.canceled { color: var(--muted); }
.tile .mini-track { position: absolute; left: 10px; right: 10px; bottom: 10px; z-index: 3; height: 4px; border-radius: 99px;
  background: rgba(255,255,255,.14); overflow: hidden; }
.tile .mini-bar { display: block; height: 100%; width: 0; border-radius: 99px; background: var(--grad); transition: width 1s linear; }
/* queued: an indeterminate striped bar that drifts (static stripes under reduced motion) */
.bar i.indet, .mini-track.indet .mini-bar, .queue-bar.indet b, .chip-bar.indet b {
  width: 100% !important; transition: none;
  background: repeating-linear-gradient(-45deg, rgba(123,61,255,.75) 0 6px, rgba(255,45,155,.35) 6px 12px);
  background-size: 17px 17px; animation: stripes .8s linear infinite; opacity: .85; }
@keyframes stripes { to { background-position: 17px 0; } }
.tile:has(.mini-track) .badge { bottom: 22px; }
.strip .tile .mini-track { left: 8px; right: 8px; bottom: 8px; height: 3px; }
/* overall progress in the sidebar card and the phone chip */
.queue-bar { height: 4px; margin: 6px 0 2px 16px; border-radius: 99px; background: rgba(255,255,255,.1); overflow: hidden; }
.queue-bar b, .chip-bar b { display: block; height: 100%; width: 0; border-radius: 99px; background: var(--grad); transition: width 1s linear; }
.tile.sel { border-color: transparent; box-shadow: inset 0 0 0 2px var(--accent); }
.tile.sel::before { content: ""; position: absolute; inset: 0; z-index: 3; border-radius: inherit; box-shadow: inset 0 0 0 2px var(--accent); pointer-events: none; }
/* Delete from the tile itself. Hidden while multi-select is on so the two do not fight. */
.tile-x { position: absolute; right: 6px; top: 6px; z-index: 4; display: grid; place-items: center; width: 30px; height: 30px; padding: 0;
  border: 0; border-radius: 50%; background: rgba(10,9,18,.66); color: #fff; cursor: pointer; opacity: 0;
  transition: opacity var(--t), background var(--t); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.tile-x .ico { width: 14px; height: 14px; }
.tile:hover .tile-x, .tile:focus-within .tile-x, .tile-x:focus-visible { opacity: 1; }
.tile-x:hover { background: var(--err); }
.picking .tile-x { display: none; }
/* No hover on a touch screen, so the control has to be visible and thumb-sized. */
@media (hover: none) {
  .tile-x { opacity: 1; width: 32px; height: 32px; }
  .tile:hover { transform: none; }
  .tile:hover img, .tile:hover video { transform: none; }
}
.tile .pick { position: absolute; right: 8px; top: 8px; z-index: 4; width: 24px; height: 24px; border-radius: 50%;
  border: 2px solid #fff; background: rgba(0,0,0,.35); display: none; place-items: center; color: #fff; }
.tile .pick .ico { width: 14px; height: 14px; stroke-width: 2.6; opacity: 0; }
.picking .tile .pick { display: grid; }
.tile.picked .pick { background: var(--accent); border-color: var(--accent); }
.tile.picked .pick .ico { opacity: 1; }
.tile.picked { border-color: transparent; box-shadow: 0 0 0 2px var(--accent); }
.picking .tile.picked img, .picking .tile.picked video { transform: scale(.94); border-radius: 8px; }

/* skeleton + empty */
.skel { aspect-ratio: 1; border-radius: 12px; background: linear-gradient(100deg, var(--panel) 30%, var(--raise) 50%, var(--panel) 70%);
  background-size: 300% 100%; animation: shimmer 1.4s linear infinite; border: 1px solid var(--line); }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }
.empty-note { grid-column: 1 / -1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  padding: 40px 16px; border: 1px dashed var(--line2); border-radius: var(--r); color: var(--muted); text-align: center; font-size: 14px; }
.empty-note .ico { width: 24px; height: 24px; color: var(--dim); }

/* ---------------------------------------------------------------- generator */
.gen { display: grid; grid-template-columns: 400px minmax(0, 1fr); gap: 24px; align-items: start; }
.panel { position: sticky; top: 24px; display: flex; flex-direction: column; gap: 24px; padding: 16px 20px 0;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow);
  max-height: calc(100vh - 48px); overflow: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--raise2) transparent; }
.stage, .panel { min-width: 0; }
.mode-tabs { display: flex; width: 100%; }
.src-seg { display: flex; width: 100%; }
.src-seg a { flex: 1; }
.mode-tabs a { flex: 1; min-height: 40px; }

.field { display: flex; flex-direction: column; gap: 8px; }
.lbl { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--text); letter-spacing: -.005em; }
.step { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; font-size: 11px; font-weight: 700;
  background: var(--raise2); color: var(--muted); border: 1px solid var(--line); }
.hint { font-size: 12px; line-height: 1.5; color: var(--dim); }
.hint:empty { display: none; }
.hint.warn { color: var(--warn); }
.set-lbl { font-size: 12px; font-weight: 500; color: var(--muted); }

textarea, select, input[type=number] { width: 100%; background: var(--bg2); border: 1px solid var(--line2); border-radius: 12px;
  padding: 12px 14px; outline: none; resize: vertical; font-size: 16px; line-height: 1.5;
  transition: border-color var(--t), box-shadow var(--t), background var(--t); }
textarea::placeholder, input::placeholder { color: var(--dim); }
textarea:hover, input[type=number]:hover { border-color: var(--line3); }
textarea:focus, select:focus, input:focus, textarea:focus-visible, input:focus-visible { border-color: rgba(123,61,255,.7); box-shadow: 0 0 0 3px rgba(123,61,255,.2); background: #0f0d1b; }
/* The panel is a flex column, so a textarea will happily shrink to nothing when the
   source-image preview takes the space. flex: 0 0 auto stops that. */
#prompt, #negative { flex: 0 0 auto; }
#prompt { min-height: 132px; }
#negative { min-height: 72px; font-size: 14px; }
@media (min-width: 761px) { textarea, input[type=number] { font-size: 14px; } }

/* drop zone */
.drop { position: relative; border: 1.5px dashed var(--line3); border-radius: var(--r); min-height: 168px; display: grid;
  place-items: center; cursor: pointer; background: var(--bg2); overflow: hidden; outline: none;
  transition: border-color var(--t), background var(--t), box-shadow var(--t); }
.drop:hover, .drop.over { border-color: var(--accent); background: rgba(123,61,255,.06); }
.drop:focus-visible { border-color: var(--accent); box-shadow: var(--ring); }
.drop:has(.drop-full:not([hidden])) { border-style: solid; border-color: var(--line2); min-height: 220px; }
.drop-empty { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; color: var(--muted); padding: 24px 16px; }
.drop-ico { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 14px; margin-bottom: 8px;
  background: var(--accent-soft); color: #c9a8ff; transition: transform var(--t) var(--ease); }
.drop-ico .ico { width: 22px; height: 22px; }
.drop:hover .drop-ico { transform: translateY(-2px); }
.drop-empty p { margin: 0; font-size: 14px; }
.drop-empty b { color: var(--text); font-weight: 600; }
.drop-empty small { color: var(--dim); font-size: 12px; }
.drop-full { position: absolute; inset: 0; background:
  repeating-conic-gradient(#14121f 0 25%, #100e19 0 50%) 0 0 / 20px 20px; }
.drop-full img { width: 100%; height: 100%; object-fit: contain; display: block; }
.drop-full .icon-btn { position: absolute; right: 8px; top: 8px; z-index: 2; }
/* crop frame: the kept region of the source at the chosen ratio; the rest is dimmed */
.crop-frame { position: absolute; z-index: 1; pointer-events: none; border: 1.5px solid rgba(255,255,255,.9);
  border-radius: 2px; box-shadow: 0 0 0 9999px rgba(8,7,14,.55); transition: left var(--t) var(--ease), top var(--t) var(--ease),
  width var(--t) var(--ease), height var(--t) var(--ease); }
.crop-tag { position: absolute; left: 6px; top: 6px; padding: 1px 6px; border-radius: 6px; font-size: 11px; font-weight: 600;
  color: #fff; background: rgba(10,9,18,.7); font-variant-numeric: tabular-nums; }
.dims, .replace { position: absolute; z-index: 2; bottom: 8px; font-size: 11px; font-weight: 500; padding: 4px 8px; border-radius: 999px;
  background: rgba(10,9,18,.7); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); font-variant-numeric: tabular-nums; }
.dims { left: 8px; }
.replace { right: 8px; color: var(--muted); opacity: 0; transition: opacity var(--t); }
.drop:hover .replace { opacity: 1; }
@media (hover: none) { .replace { opacity: 1; } }
.drop-busy { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 12px;
  background: rgba(10,9,18,.82); font-weight: 500; }

.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid rgba(255,255,255,.18); border-top-color: #fff;
  animation: spin .8s linear infinite; flex: none; display: inline-block; }
.spinner.sm { width: 14px; height: 14px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* model picker button */
.model-btn { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 60px; padding: 10px 14px; text-align: left;
  background: var(--bg2); border: 1px solid var(--line2); border-radius: 12px; cursor: pointer;
  transition: border-color var(--t), background var(--t), box-shadow var(--t); }
.model-btn:hover:not(:disabled) { border-color: var(--line3); background: #100e1c; }
.model-btn:disabled { cursor: default; opacity: .6; }
.mb-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.mb-name { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mb-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-size: 12px; color: var(--muted); }
.mb-meta:empty { display: none; }
.mb-chev { color: var(--muted); width: 18px; height: 18px; }

.price { font-variant-numeric: tabular-nums; }

/* learned render time, shown before generating */
.eta-note { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); padding-left: 2px; }
.eta-note .ico { width: 14px; height: 14px; color: var(--dim); }

/* safety switch */
#safetyBox { display: grid; gap: 4px; margin-top: 4px; padding: 12px; border-radius: 12px; background: var(--bg2); border: 1px solid var(--line); }
#safetyBox .hint { margin-left: 50px; }
.check { position: relative; display: flex; gap: 12px; align-items: center; font-size: 13px; font-weight: 500; color: var(--text); cursor: pointer; min-height: 28px; }
.check input { position: absolute; opacity: 0; width: 38px; height: 22px; margin: 0; cursor: pointer; }
.switch { position: relative; flex: none; width: 38px; height: 22px; border-radius: 99px; background: var(--raise2);
  border: 1px solid var(--line2); transition: background var(--t), border-color var(--t); }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #cfc9e6;
  transition: transform var(--t) var(--ease), background var(--t); }
.check input:checked + .switch { background: var(--accent); border-color: var(--accent); }
.check input:checked + .switch::after { transform: translateX(16px); background: #fff; }
.check input:focus-visible + .switch { box-shadow: var(--ring); }
.check-text { display: flex; align-items: center; gap: 8px; }
.check-text .state { padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; letter-spacing: .02em; text-transform: uppercase;
  background: rgba(52, 211, 153, .16); color: #34d399; }
.check-text .state.off { background: rgba(255, 99, 132, .16); color: #ff6384; }

/* settings chips */
.set-rows { display: grid; gap: 12px; }
.set-row { display: grid; gap: 8px; }
.chips-seg { display: flex; flex-wrap: wrap; gap: 6px; }
.chips-seg button { min-width: 56px; min-height: 40px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line2);
  background: var(--bg2); color: var(--muted); font-weight: 500; font-size: 13px; cursor: pointer; font-variant-numeric: tabular-nums;
  transition: background var(--t), border-color var(--t), color var(--t); }
.chips-seg button:hover { color: var(--text); border-color: var(--line3); }
.chips-seg button[aria-checked="true"] { color: #fff; background: var(--accent-soft); border-color: rgba(123,61,255,.8);
  box-shadow: inset 0 0 0 1px rgba(123,61,255,.5); }
.sr-select { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0);
  clip-path: inset(50%); border: 0; white-space: nowrap; opacity: 0; }

/* advanced */
.adv { border-top: 1px solid var(--line); padding-top: 4px; margin-top: -8px; }
.adv summary { display: flex; align-items: center; gap: 8px; min-height: 44px; cursor: pointer; font-size: 13px; color: var(--muted);
  font-weight: 600; list-style: none; border-radius: 8px; transition: color var(--t); }
.adv summary::-webkit-details-marker { display: none; }
.adv summary:hover { color: var(--text); }
.adv summary .ico { width: 16px; height: 16px; }
.adv-chev { margin-left: auto; transition: transform var(--t) var(--ease); }
.adv[open] .adv-chev { transform: rotate(180deg); }
.adv-body { display: grid; gap: 8px; padding: 4px 0 8px; }
.adv-body .set-lbl + textarea, .adv-body .set-lbl + input { margin-bottom: 4px; }

/* generate bar */
.gen-bar { position: sticky; bottom: 0; z-index: 3; margin: -8px -20px 0; padding: 16px 20px 20px;
  background: var(--panel); border-top: 1px solid var(--line); box-shadow: 0 -12px 24px rgba(19,17,31,.9); }

/* ---------------------------------------------------------------- viewer */
.viewer { position: relative; width: 100%; aspect-ratio: 4 / 3; max-height: calc(100vh - 260px); min-height: 320px;
  border-radius: var(--r-lg); overflow: hidden; display: grid; place-items: center; border: 1px solid var(--line);
  background: radial-gradient(600px 300px at 50% 0%, rgba(123,61,255,.08), transparent 70%), #08070f; box-shadow: var(--shadow); }
.viewer-empty { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; color: var(--muted); padding: 32px 16px; }
.viewer-empty p { margin: 8px 0 0; font-size: 16px; font-weight: 500; color: var(--text); }
.viewer-empty small { color: var(--dim); font-size: 13px; }
.pulse-mark { width: 56px; height: auto; display: block; opacity: .6; animation: breathe 3.2s ease-in-out infinite; }
@keyframes breathe { 50% { opacity: .95; transform: scale(1.04); } }
.viewer-media { position: absolute; inset: 0; display: grid; place-items: center; padding: 12px; }
/* sized to the media: width follows the height cap so nothing letterboxes */
.viewer.fit { aspect-ratio: var(--ar); width: min(100%, calc(70vh * var(--arn))); min-height: 0; max-height: none; margin-inline: auto; }
.viewer.fit .viewer-media { padding: 0; }
.viewer.fit .viewer-media img, .viewer.fit .viewer-media video { width: 100%; height: 100%; max-width: none; max-height: none;
  object-fit: contain; border-radius: 0; }
.viewer-media img, .viewer-media video { max-width: 100%; max-height: 100%; display: block; border-radius: 10px; object-fit: contain;
  animation: fadeIn 260ms var(--ease); }
.viewer-progress { position: absolute; left: 50%; bottom: 20px; transform: translateX(-50%); width: min(440px, calc(100% - 32px));
  padding: 16px; background: rgba(19,17,31,.86); -webkit-backdrop-filter: blur(16px) saturate(1.3); backdrop-filter: blur(16px) saturate(1.3);
  border: 1px solid var(--line2); border-radius: var(--r); display: grid; grid-template-columns: 1fr auto; gap: 12px 16px;
  align-items: center; box-shadow: var(--shadow-lg); }
.vp-label { grid-column: 1 / -1; display: flex; justify-content: space-between; gap: 12px; font-size: 14px; color: var(--text); font-weight: 500; }
.vp-msg { display: flex; align-items: center; gap: 8px; min-width: 0; }
.vp-msg #vpMsg { overflow-wrap: anywhere; }
.vp-time { color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 500; }
.viewer-progress .bar { grid-column: 1; }
.viewer-progress .btn-ghost { grid-column: 2; }
.viewer-progress:has(#vpCancel[hidden]) .bar { grid-column: 1 / -1; }
.viewer-progress:has(#vpCancel[hidden]) .spinner { display: none; }
.bar { position: relative; height: 6px; border-radius: 99px; background: rgba(255,255,255,.08); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; border-radius: 99px; background: var(--grad); transition: width .6s var(--ease); }
.bar i.idle { background: linear-gradient(90deg, transparent, var(--accent), transparent);
  width: 40% !important; animation: sweep 1.4s ease-in-out infinite; }
@keyframes sweep { 0% { transform: translateX(-120%); } 100% { transform: translateX(320%); } }

.viewer-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.viewer-actions .btn-ghost { padding: 8px 12px; }
.viewer-actions .btn-ghost.danger { margin-left: auto; }
.strip { display: grid; grid-auto-flow: column; grid-auto-columns: 112px; gap: 10px; overflow-x: auto; padding: 2px 2px 12px;
  scroll-snap-type: x proximity; scrollbar-width: thin; scrollbar-color: var(--raise2) transparent; }
.strip .tile { scroll-snap-align: start; }
.strip .tile .badge { display: none; }
.strip .tile .state { font-size: 11px; padding: 8px; }
.strip .empty-note, .strip .skel { grid-column: auto; }
.strip:has(.empty-note) { grid-auto-flow: row; grid-auto-columns: auto; }
.strip .empty-note { padding: 24px 16px; }

/* ---------------------------------------------------------------- library */
.lib-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin: 8px 0 24px; }
.lib-head h1 { margin: 0; font-size: 28px; letter-spacing: -.02em; font-weight: 700; }
.lib-head .muted { margin: 4px 0 0; font-size: 13px; }
.head-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.lib-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.bulk-bar { position: fixed; left: calc(var(--side-w) + (100vw - var(--side-w)) / 2); bottom: 24px; z-index: 15;
  transform: translate(-50%, 16px); opacity: 0; pointer-events: none;
  display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 16px; border-radius: 16px;
  background: rgba(26,23,41,.9); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  border: 1px solid var(--line2); box-shadow: var(--shadow-lg); transition: opacity var(--t), transform var(--t) var(--ease); }
.picking .bulk-bar { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.bulk-hint { font-size: 13px; color: var(--muted); margin-right: 8px; white-space: nowrap; }
.picking #view-library { padding-bottom: 64px; }

/* ---------------------------------------------------------------- sheet (model picker) */
.sheet, .modal { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 24px;
  background: rgba(5,4,10,.62); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); animation: fade 180ms ease-out; }
@keyframes fade { from { opacity: 0; } }
.sheet-card { display: flex; flex-direction: column; width: min(560px, 100%); max-height: min(760px, calc(100vh - 48px));
  background: var(--panel); border: 1px solid var(--line2); border-radius: 20px; box-shadow: var(--shadow-lg); overflow: hidden;
  animation: rise 220ms var(--ease); }
@keyframes rise { from { opacity: 0; transform: translateY(16px) scale(.985); } }
.sheet-grip { display: none; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 20px 20px 12px; }
.sheet-head h2 { margin: 0; font-size: 20px; font-weight: 600; letter-spacing: -.015em; }
.sheet-filter { margin: 0 20px 12px; align-self: flex-start; }
.sheet-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 0 12px 16px;
  scrollbar-width: thin; scrollbar-color: var(--raise2) transparent; }
.ml-group { margin-top: 8px; }
.ml-head { position: sticky; top: 0; z-index: 1; display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
  padding: 12px 8px 8px; background: var(--panel); font-size: 12px; font-weight: 600; color: var(--muted);
  letter-spacing: .02em; }
.ml-head small { color: var(--dim); font-weight: 500; }
.model-row { display: grid; grid-template-columns: minmax(0, 1fr) auto 22px; gap: 10px; align-items: center; width: 100%;
  min-height: 48px; padding: 10px 12px; border: 1px solid transparent; border-radius: 12px; background: transparent; color: var(--text); text-align: left; cursor: pointer; }
@media (hover: hover) { .model-row:hover { background: var(--raise); } }
.model-row:active { background: var(--raise); }
.model-row[aria-selected="true"] { background: var(--accent-soft); border-color: rgba(123,61,255,.55); }
.mr-name { font-weight: 600; font-size: 15px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mr-meta { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.mr-price { font-size: 13px; font-weight: 500; color: var(--muted); font-variant-numeric: tabular-nums; }
.mr-check { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  border: 1.5px solid var(--line3); }
.mr-check .ico { width: 13px; height: 13px; stroke-width: 2.6; opacity: 0; }
.model-row[aria-selected="true"] .mr-check { background: var(--accent); border-color: var(--accent); }
.model-row[aria-selected="true"] .mr-check .ico { opacity: 1; }
.bdg { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 7px; }
.bdg .ico { width: 13px; height: 13px; }
.bdg.nf { background: rgba(52, 211, 153, .14); color: #34d399; }
.bdg.au { background: rgba(96, 165, 250, .14); color: #60a5fa; }

.ml-empty { padding: 32px 16px; text-align: center; color: var(--muted); }

/* ---------------------------------------------------------------- detail modal */
.modal-card { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) 340px; width: min(1200px, 100%);
  max-height: calc(100vh - 48px); background: var(--panel); border: 1px solid var(--line2); border-radius: 20px; overflow: hidden;
  box-shadow: var(--shadow-lg); animation: rise 220ms var(--ease); }
.modal-x { position: absolute; right: 12px; top: 12px; z-index: 2; }
.modal-media { display: grid; place-items: center; min-height: 320px; padding: 16px; background: #07060d; }
.modal-media img, .modal-media video { max-width: 100%; max-height: min(calc(100vh - 80px), 70vh); display: block; border-radius: 10px; object-fit: contain; }
.modal-media .muted { padding: 40px; text-align: center; }
.modal-side { padding: 24px; display: flex; flex-direction: column; gap: 16px; overflow: auto; border-left: 1px solid var(--line); }
.tag { align-self: flex-start; padding: 4px 10px; border-radius: 999px; font-size: 11px; font-weight: 600; letter-spacing: .06em;
  text-transform: uppercase; color: #c9a8ff; background: var(--accent-soft); }
.modal-prompt { margin: 0; font-size: 15px; line-height: 1.55; color: var(--text); padding-right: 32px; overflow-wrap: anywhere; }
.meta { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0; padding: 16px; font-size: 13px;
  background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; }
.meta dt { color: var(--dim); }
.meta dd { margin: 0; color: var(--text); word-break: break-word; }
.modal-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: auto; }
.modal-actions .btn-ghost { min-width: 0; padding: 8px 10px; }
.modal-actions .btn-ghost:first-child:nth-last-child(odd) { grid-column: 1 / -1; }
.modal-actions > :only-child { grid-column: 1 / -1; }

/* ---------------------------------------------------------------- toasts / update bar */
.toasts { position: fixed; right: 24px; bottom: 24px; display: grid; gap: 8px; z-index: 60; pointer-events: none; }
.toast { display: flex; align-items: flex-start; gap: 10px; padding: 12px 16px; border-radius: 12px; max-width: 380px; font-size: 14px;
  background: rgba(34,30,53,.94); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); border: 1px solid var(--line2);
  box-shadow: 0 12px 32px rgba(0,0,0,.45); animation: pop 220ms var(--ease); pointer-events: auto; }
.toast::before { content: ""; flex: none; width: 8px; height: 8px; margin-top: 7px; border-radius: 50%; background: var(--ok); }
.toast.err { border-color: rgba(255,93,108,.45); }
.toast.err::before { background: var(--err); }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }

/* Shown when the server has a newer build than the code this page is running. */
.update-bar { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 90;
  display: flex; align-items: center; gap: 12px; max-width: calc(100vw - 32px);
  padding: 8px 8px 8px 16px; border: 1px solid var(--line2); border-radius: 14px;
  background: rgba(26,23,41,.94); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  box-shadow: var(--shadow-lg); font-size: 14px; animation: pop 220ms var(--ease); }
.update-bar button { flex: none; min-height: 36px; border: 0; border-radius: 10px; padding: 0 16px; font: inherit; font-weight: 600;
  color: #fff; cursor: pointer; background: var(--grad); }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 1100px) {
  .gen { grid-template-columns: 360px minmax(0, 1fr); }
  main { padding: 24px 24px 56px; }
}
@media (max-width: 960px) {
  .gen { grid-template-columns: minmax(0, 1fr); }
  .panel { position: static; max-height: none; overflow: visible; }
  .viewer { max-height: 70vh; }
  .modal-card { grid-template-columns: minmax(0, 1fr); overflow: auto; }
  .modal-side { border-left: 0; border-top: 1px solid var(--line); }
  .modal-media img, .modal-media video { max-height: 62vh; }
}

/* phone */
@media (max-width: 760px) {
  :root { --tabbar-h: 64px; }
  .shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }   /* short pages must not stretch the top bar */
  .sidebar { display: none; }
  .topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 12px;
    height: calc(56px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 16px 0;
    background: rgba(10,9,18,.78); -webkit-backdrop-filter: blur(16px) saturate(1.4); backdrop-filter: blur(16px) saturate(1.4);
    border-bottom: 1px solid var(--line); }
  .topbar .brand { padding: 4px 0; }
  .topbar .brand-mark { width: 22px; height: 26px; }
  .topbar .wordmark { font-size: 17px; }
  .status-chip { display: inline-flex; align-items: center; gap: 8px; max-width: 60vw; height: 32px; padding: 0 12px;
    border: 1px solid var(--line2); border-radius: 999px; background: var(--panel); font-size: 12px; font-weight: 500; color: var(--text); }
  .status-chip { position: relative; overflow: hidden; }
  .status-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-variant-numeric: tabular-nums; }
  .status-chip .chip-bar { position: absolute; left: 12px; right: 12px; bottom: 4px; height: 2px; border-radius: 99px;
    background: rgba(255,255,255,.12); overflow: hidden; }
  .tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(4, 1fr);
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding: 6px 8px env(safe-area-inset-bottom);
    background: rgba(13,11,23,.88); -webkit-backdrop-filter: blur(16px) saturate(1.4); backdrop-filter: blur(16px) saturate(1.4);
    border-top: 1px solid var(--line); }
  .tabbar a { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
    min-height: 48px; border-radius: 12px; color: var(--dim); font-size: 11px; font-weight: 500; transition: color var(--t); }
  .tabbar a .ico { width: 22px; height: 22px; }
  .tabbar a.on { color: var(--text); }
  .tabbar a.on .ico { color: #c9a8ff; }
  .tabbar a.on::before { content: ""; position: absolute; top: -6px; left: 50%; width: 24px; height: 3px; margin-left: -12px;
    border-radius: 0 0 3px 3px; background: var(--grad); }

  main { padding: 16px 16px calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 24px); }
  .hero { padding: 16px 0 24px; }
  .hero h1 { font-size: 28px; }
  .hero .sub { font-size: 15px; margin-top: 8px; }
  .reel { margin: 0 0 16px; border-radius: 18px; }
  .reel-stage { aspect-ratio: 4 / 3; }
  .reel-cap { left: 16px; right: 64px; bottom: 18px; gap: 10px; }
  .reel-title { font-size: 26px; }
  .reel-go { right: 16px; bottom: 18px; width: 36px; height: 36px; padding: 0; justify-content: center; font-size: 0; gap: 0; }
  .reel-bar { left: 12px; right: 12px; top: 8px; gap: 3px; }
  .reel-ba .ba-tag { top: 36px; }
  .quick { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .quick a { gap: 10px; min-height: 52px; padding: 6px 10px 6px 6px; font-size: 13px; }
  .q-ico { width: 36px; height: 36px; }
  .showcase { gap: 12px; }
  .section-head { margin: 32px 0 12px; }

  .grid, .lib-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .tile { border-radius: 12px; }
  .tile .badge { left: 6px; bottom: 6px; font-size: 10px; }
  .tile .age { left: 6px; top: 6px; font-size: 10px; }
  .tile .state { font-size: 11px; line-height: 1.35; }

  .panel { padding: 16px 16px 0; gap: 20px; border-radius: var(--r-lg); }
  .gen-bar { position: sticky; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); margin: -8px -16px 0; padding: 12px 16px 16px;
    border-radius: 0 0 var(--r-lg) var(--r-lg); }
  .btn-primary kbd { display: none; }
  .drop { min-height: 148px; }
  .drop:has(.drop-full:not([hidden])) { min-height: 200px; }
  #prompt { min-height: 120px; }

  /* the progress card sits under the image on a phone instead of covering it */
  .viewer { display: block; aspect-ratio: auto; min-height: 0; max-height: none; }
  .viewer-media { position: static; padding: 8px; }
  .viewer-media img, .viewer-media video { max-height: 56vh; margin: 0 auto; }
  .viewer.fit { aspect-ratio: auto; width: 100%; }
  .viewer.fit .viewer-media { padding: 0; }
  .viewer.fit .viewer-media img, .viewer.fit .viewer-media video { width: min(100%, calc(62vh * var(--arn))); height: auto;
    aspect-ratio: var(--ar); max-height: 62vh; }
  .viewer-empty { padding: 40px 16px; }
  .viewer-progress { position: static; transform: none; width: calc(100% - 16px); margin: 0 8px 8px; box-shadow: none; }
  .viewer-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .viewer-actions .btn-ghost { min-height: 44px; }
  .viewer-actions .btn-ghost.danger { margin-left: 0; }
  .viewer-actions > :first-child:nth-last-child(odd) { grid-column: 1 / -1; }
  .strip { grid-auto-columns: 96px; margin: 0 -16px; padding: 2px 16px 12px; scroll-padding: 0 16px; }

  .lib-head { align-items: stretch; flex-direction: column; margin: 0 0 16px; gap: 12px; }
  .lib-head h1 { font-size: 24px; }
  .head-tools { justify-content: space-between; flex-wrap: nowrap; }
  .head-tools .seg { flex: 1; }
  .head-tools .seg button { flex: 1; padding: 0 8px; }
  .head-tools .btn-ghost { min-height: 44px; }
  .bulk-bar { left: 16px; right: 16px; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 12px); transform: translateY(16px); }
  .picking .bulk-bar { transform: none; }
  .bulk-bar .bulk-hint { flex: 1; }
  .bulk-bar button { min-height: 44px; }

  .sheet { place-items: end stretch; padding: 0; }
  .sheet-card { width: 100%; max-height: 88vh; max-height: 88dvh; border-radius: 20px 20px 0 0; border-bottom: 0;
    padding-bottom: env(safe-area-inset-bottom); animation: slideUp 260ms var(--ease); }
  @keyframes slideUp { from { transform: translateY(100%); } }
  .sheet-grip { display: block; width: 40px; height: 4px; border-radius: 99px; background: var(--line3); margin: 8px auto 0; }
  .sheet-head { padding: 12px 16px 8px; }
  .sheet-head h2 { font-size: 18px; }
  .sheet-filter { margin: 0 16px 8px; align-self: stretch; }
  .sheet-filter button { flex: 1; }
  .sheet-body { padding: 0 8px 16px; }
  .model-row { padding: 12px 10px; }

  .modal { padding: 0; place-items: end stretch; }
  .modal-card { width: 100%; max-height: 92vh; max-height: 92dvh; border-radius: 20px 20px 0 0; border-bottom: 0;
    animation: slideUp 260ms var(--ease); }
  .modal-media { min-height: 220px; padding: 12px; }
  .modal-side { padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); }
  .modal-actions .btn-ghost { min-height: 44px; }

  .toasts { left: 16px; right: 16px; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 12px); justify-items: center; }
  .toast { max-width: 100%; }
  .update-bar { bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 12px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important; scroll-behavior: auto !important; }
  .spinner { animation: spin 1.6s linear infinite !important; animation-iteration-count: infinite !important; animation-duration: 1.6s !important; }
  .bar i.idle { animation: none !important; transform: none; width: 100% !important; opacity: .5; }
  .bar i.indet, .mini-track.indet .mini-bar, .queue-bar.indet b, .chip-bar.indet b { animation: none !important; }
}

/* Ratio dropdown: a real <select>, styled like the other inputs with its own chevron. */
select.select { appearance: none; -webkit-appearance: none; min-height: 44px; padding-right: 40px; cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239a97b3' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat; background-position: right 14px center; }
select.select:hover { border-color: var(--line3); }

/* One-tap unmute over the result video (browsers block autoplay with sound). */
.viewer-media, #modalMedia { position: relative; }
.unmute { position: absolute; left: 12px; top: 12px; z-index: 3; display: inline-flex; align-items: center; gap: 6px; min-height: 36px;
  padding: 0 12px; border: 1px solid rgba(255,255,255,.18); border-radius: 999px; font-size: 13px; font-weight: 600; color: #fff;
  background: rgba(10,9,18,.7); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); cursor: pointer; }
.unmute .ico { width: 15px; height: 15px; }
.unmute:hover { background: rgba(124,61,255,.8); border-color: transparent; }
