@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap");

/* No flash of the original page: stay hidden until live-studio.js has built the
   layout (it adds body.ls). If the script never runs, reveal after 3 s anyway. */
html { background: #09090b; }
@media (prefers-color-scheme: light) { html { background: #f6f6f7; } }
body:not(.ls) { opacity: 0; animation: ls-reveal 0s linear 3s forwards; }
@keyframes ls-reveal { to { opacity: 1; } }
body.ls { animation: ls-fade-in .18s ease-out; }
@keyframes ls-fade-in { from { opacity: 0; } }

/* =====================================================================
   Beehive Live — showcase shell (dark-first)
   Layers on top of the Space page + tryon.css. Scoped to body.ls so it
   wins over the older layers without touching their files.
   ===================================================================== */

body.ls {
  --ls-bg: #09090b;
  --ls-surface: #121215;
  --ls-surface-2: #1a1a1f;
  --ls-surface-3: #232329;
  --ls-line: #27272e;
  --ls-line-strong: #3a3a43;
  --ls-text: #f4f4f5;
  --ls-muted: #a1a1aa;
  --ls-dim: #71717a;
  --ls-accent: #ff4f00;
  --ls-accent-hover: #ff6a26;
  --ls-accent-soft: rgba(255, 79, 0, .14);
  --ls-accent-text: #ffb08a;
  --ls-live: #ff3b30;
  --ls-ok: #34d399;
  --ls-radius: 16px;
  --ls-radius-sm: 10px;
  --ls-pip-w: 240px;
  --ls-ease: cubic-bezier(.2, .7, .2, 1);

  /* Re-map the page's own tokens so its components follow the theme. */
  --bg: var(--ls-bg);
  --panel: var(--ls-surface);
  --panel-2: var(--ls-surface-2);
  --line: var(--ls-line);
  --text: var(--ls-text);
  --muted: var(--ls-muted);
  --accent: var(--ls-accent);
  --accent-2: var(--ls-accent);
  --media-bg: #000;
  --shadow: none;

  color-scheme: dark;
  margin: 0;
  height: auto;
  min-height: 100vh;
  overflow-x: clip;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  background: var(--ls-bg);
  color: var(--ls-text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
body.ls *:focus-visible { outline: 2px solid var(--ls-accent); outline-offset: 2px; }
body.ls button { font-family: inherit; }

/* ---------- Top bar ---------- */
body.ls .topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  flex: 0 0 auto;
  height: 60px;
  padding: 0 24px;
  gap: 14px;
  background: color-mix(in srgb, var(--ls-bg) 86%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--ls-line);
}
body.ls .topbar .brand-dot {
  width: 10px; height: 10px; border-radius: 3px;
  background: var(--ls-accent);
  box-shadow: 0 0 14px rgba(255, 79, 0, .7);
}
body.ls .topbar .brand { font-size: 16px; font-weight: 700; letter-spacing: -.01em; color: var(--ls-text); }
body.ls .topbar .tagline { font-size: 13px; color: var(--ls-dim); }
body.ls .lang-seg {
  margin-left: auto;
  padding: 3px;
  gap: 2px;
  border: 1px solid var(--ls-line);
  border-radius: 999px;
  background: var(--ls-surface);
}
body.ls .lang-seg button {
  padding: 5px 12px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ls-muted);
  font-size: 12px;
  font-weight: 600;
}
body.ls .lang-seg button:hover { color: var(--ls-text); border: 0; }
body.ls .lang-seg button.on { background: var(--ls-surface-3); color: var(--ls-text); }
.ls-icon-btn {
  display: inline-grid;
  place-items: center;
  width: 36px; height: 36px;
  border: 1px solid var(--ls-line);
  border-radius: 999px;
  background: var(--ls-surface);
  color: var(--ls-muted);
  cursor: pointer;
  transition: color .15s, border-color .15s, background .15s;
}
.ls-icon-btn:hover { color: var(--ls-text); border-color: var(--ls-line-strong); background: var(--ls-surface-2); }
.ls-icon-btn svg { width: 18px; height: 18px; }

/* ---------- Main layout ---------- */
.ls-main {
  flex: 0 0 auto;
  /* The app fills the screen. */
  height: calc(100vh - 60px);
  min-height: 560px;
  max-height: 1000px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 20px;
  padding: 20px 24px 24px;
}
.ls-stage-col { min-width: 0; min-height: 0; display: flex; }

body.ls .stage {
  flex: 1 1 auto;
  width: 100%;
  height: auto !important;
  min-height: 0 !important;
  display: flex !important;
  padding: 0 !important;
  gap: 0 !important;
  background: none !important;
}
/* Source panel keeps rendering (frames are captured from #camera) but stays out of view. */
body.ls .stage > .vpanel:first-child {
  position: absolute !important;
  width: 1px !important; height: 1px !important;
  opacity: 0 !important; overflow: hidden !important; pointer-events: none !important;
}
body.ls .stage > .vpanel:last-child {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--ls-surface);
  border: 1px solid var(--ls-line);
  border-radius: 20px;
  overflow: hidden;
}
body.ls .vpanel-head {
  min-height: 56px;
  padding: 0 14px 0 16px;
  border-bottom: 0;
}
body.ls .vpanel-head .vp-title { display: none; }
body.ls .media-box {
  flex: 1 1 auto;
  margin: 0 10px 10px;
  border-radius: 14px;
  background: #000;
  aspect-ratio: auto;
  max-height: none;
}
body.ls .media-box video,
body.ls .media-box canvas,
body.ls .media-box img { background: #000; }

/* Status pill (stage toolbar, left) */
.ls-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 10px;
  border-radius: 999px;
  background: var(--ls-surface-2);
  border: 1px solid var(--ls-line);
  color: var(--ls-muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .02em;
}
.ls-status::before {
  content: "";
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--ls-dim);
}
body.ls[data-ls-state="starting"] .ls-status { color: var(--ls-text); }
body.ls[data-ls-state="starting"] .ls-status::before { background: #fbbf24; animation: ls-blink 1s ease-in-out infinite; }
body.ls[data-ls-state="live"] .ls-status { color: var(--ls-text); border-color: rgba(255, 59, 48, .45); background: rgba(255, 59, 48, .12); }
body.ls[data-ls-state="live"] .ls-status::before { background: var(--ls-live); box-shadow: 0 0 10px var(--ls-live); animation: ls-blink 1.4s ease-in-out infinite; }
body.ls[data-ls-state="ready"][data-ls-cam="on"] .ls-status::before { background: var(--ls-ok); }
@keyframes ls-blink { 50% { opacity: .35; } }

/* Server-side download bubble is replaced by the result dialog. */
body.ls .download-bubble { display: none !important; }

/* Page overlays restyled for the dark stage. */
body.ls .overlay { color: var(--ls-muted); }
body.ls .overlay .hint { color: var(--ls-muted); font-size: 14px; }
body.ls .wait-overlay { background: transparent; z-index: 8; }
body.ls .wait-overlay .hint { color: #fff; font-size: 15px; font-weight: 600; max-width: 420px; text-shadow: 0 1px 12px rgba(0, 0, 0, .6); }
body.ls .wait-overlay .idle-ico { display: none; }
body.ls #outputStartOverlay::before {
  content: "";
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, .18);
  border-top-color: var(--ls-accent);
  animation: ls-spin .9s linear infinite;
}
@keyframes ls-spin { to { transform: rotate(360deg); } }
body.ls .toast {
  z-index: 9;
  background: rgba(18, 18, 21, .92);
  color: var(--ls-text);
  border: 1px solid var(--ls-line);
  border-radius: 12px;
}
/* In ready/starting the camera fills the stage, so the idle text is not needed. */
body.ls:not([data-ls-state="live"]) #outputIdleOverlay { display: none !important; }

/* ---------- Camera: full stage when ready, picture-in-picture when live ---------- */
.ls-pip {
  position: absolute;
  z-index: 6;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  border-radius: 0;
  overflow: hidden;
  background: #000;
  opacity: 0;
  pointer-events: none;
  transition: top .5s var(--ls-ease), left .5s var(--ls-ease), width .5s var(--ls-ease),
              height .5s var(--ls-ease), border-radius .5s var(--ls-ease), opacity .3s ease,
              box-shadow .5s ease;
}
.ls-pip.show { opacity: 1; }
.ls-pip video {
  width: 100%; height: 100%;
  object-fit: cover;
  background: #000;
  transition: filter .4s ease;
}
body.ls[data-ls-state="starting"] .ls-pip video { filter: brightness(.38) saturate(.7) blur(2px); }
body.ls[data-ls-state="live"] .ls-pip {
  top: 14px; left: 14px;
  width: var(--ls-pip-w);
  height: calc(var(--ls-pip-w) * 9 / 16);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .55), 0 0 0 1px rgba(255, 255, 255, .2);
}
.ls-pip-label {
  position: absolute;
  left: 8px; bottom: 7px;
  display: none;
  align-items: center;
  gap: 5px;
  color: rgba(255, 255, 255, .9);
  font-size: 10px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
}
.ls-pip-label::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--ls-live); }
body.ls[data-ls-state="live"] .ls-pip-label { display: flex; }

/* Framing guide over the full-stage camera (ready state) */
.ls-guide {
  position: absolute;
  z-index: 7;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity .4s ease;
}
body.ls[data-ls-state="ready"][data-ls-cam="on"] .ls-guide { opacity: 1; }
.ls-guide::before {
  content: "";
  position: absolute;
  left: 50%; bottom: 0;
  width: min(46%, 520px);
  aspect-ratio: 1 / 1.05;
  transform: translateX(-50%);
  border: 2px dashed rgba(255, 255, 255, .35);
  border-bottom: 0;
  border-radius: 48% 48% 0 0 / 38% 38% 0 0;
}
.ls-guide span {
  position: absolute;
  left: 50%; top: 16px;
  transform: translateX(-50%);
  padding: 7px 14px;
  border-radius: 999px;
  background: rgba(0, 0, 0, .55);
  backdrop-filter: blur(8px);
  color: #fff;
  font-size: 13px; font-weight: 500;
  white-space: nowrap;
}

/* Camera prompt (no camera yet) */
.ls-camprompt {
  position: absolute;
  z-index: 7;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px;
  text-align: center;
  background: radial-gradient(ellipse at 50% 40%, #1c1c22 0%, #000 70%);
}
body.ls[data-ls-cam="off"] .ls-camprompt { display: flex; }
.ls-camprompt-ico {
  width: 64px; height: 64px;
  display: grid; place-items: center;
  border-radius: 20px;
  background: var(--ls-accent-soft);
  color: var(--ls-accent);
}
.ls-camprompt-ico svg { width: 30px; height: 30px; }
.ls-camprompt h3 { margin: 4px 0 0; font-size: 20px; font-weight: 600; color: #fff; letter-spacing: -.01em; }
.ls-camprompt p { margin: 0; max-width: 380px; color: var(--ls-muted); font-size: 14px; line-height: 1.55; }
.ls-camprompt .ls-err { color: #fca5a5; }

/* ---------- Buttons ---------- */
.ls-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  padding: 0 20px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s, transform .1s;
}
.ls-btn:active { transform: scale(.98); }
.ls-btn-primary { background: var(--ls-accent); color: #fff; }
.ls-btn-primary:hover { background: var(--ls-accent-hover); }
.ls-btn-ghost { background: var(--ls-surface-2); border-color: var(--ls-line); color: var(--ls-text); }
.ls-btn-ghost:hover { border-color: var(--ls-line-strong); background: var(--ls-surface-3); }

/* ---------- Soft countdown (bottom right) ---------- */
.ls-countdown {
  position: absolute;
  right: 16px; bottom: 16px;
  z-index: 8;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 14px 7px 7px;
  border-radius: 999px;
  background: rgba(10, 10, 12, .55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, .1);
  color: rgba(255, 255, 255, .92);
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity .35s ease, transform .35s ease, background .6s ease, border-color .6s ease;
  pointer-events: none;
}
.ls-countdown.show { opacity: 1; transform: none; }
.ls-countdown svg { width: 26px; height: 26px; transform: rotate(-90deg); }
.ls-countdown .ls-ring-bg { stroke: rgba(255, 255, 255, .16); }
.ls-countdown .ls-ring { stroke: rgba(255, 255, 255, .92); transition: stroke-dashoffset .25s linear; }
.ls-countdown.ending { background: rgba(255, 79, 0, .8); border-color: transparent; }
.ls-countdown.ending .ls-time { animation: ls-breathe 1s ease-in-out infinite; }
@keyframes ls-breathe { 50% { opacity: .55; } }

/* ---------- Stop session (stage toolbar, right) ---------- */
.ls-stop {
  display: none;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--ls-line);
  border-radius: 999px;
  background: var(--ls-surface-2);
  color: var(--ls-text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.ls-stop.show { display: inline-flex; }
.ls-stop::before { content: ""; width: 9px; height: 9px; border-radius: 2px; background: var(--ls-live); }
.ls-stop:hover { background: var(--ls-surface-3); border-color: var(--ls-line-strong); }
.ls-stop:disabled { opacity: .5; cursor: default; }

/* ---------- Right rail ---------- */
.ls-rail {
  position: relative;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.ls-rail-scroll {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 2px;
  scrollbar-width: thin;
  scrollbar-color: var(--ls-line-strong) transparent;
  /* Fade the gallery into the pinned footer. */
  mask-image: linear-gradient(to bottom, #000 calc(100% - 24px), transparent);
}
.ls-rail-scroll > * { flex: 0 0 auto; }
.ls-effects {
  padding: 16px;
  background: var(--ls-surface);
  border: 1px solid var(--ls-line);
  border-radius: var(--ls-radius);
}
html, body.ls { overflow-x: clip; }
.ls-drawer:not(:focus-within) { visibility: hidden; transition: transform .3s var(--ls-ease), visibility 0s .3s; }
body.ls.ls-drawer-open .ls-drawer { visibility: visible; transition: transform .3s var(--ls-ease); }
.ls-rail-intro h1 { margin: 2px 0 6px; font-size: 22px; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; }
.ls-rail-intro p { margin: 0; color: var(--ls-muted); font-size: 13px; line-height: 1.55; }

/* Outfit section as a rail card */
body.ls .outfit-section {
  display: block !important;
  margin: 0;
  padding: 16px;
  background: var(--ls-surface);
  border: 1px solid var(--ls-line);
  border-radius: var(--ls-radius);
}
body.ls .outfit-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  min-height: 0;
  margin-bottom: 14px;
  border: 0;
}
body.ls .outfit-step { display: none; }
body.ls .outfit-copy { padding: 0; }
body.ls .outfit-copy h2 { margin: 0; font-size: 15px; font-weight: 600; color: var(--ls-text); letter-spacing: -.01em; }
body.ls .outfit-copy p { margin: 4px 0 0; color: var(--ls-dim); font-size: 12px; line-height: 1.5; }
body.ls .outfit-upload {
  flex: 0 0 auto;
  margin: 0;
  padding: 7px 12px;
  border: 1px solid var(--ls-line);
  border-radius: 999px;
  background: var(--ls-surface-2);
  color: var(--ls-text);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
body.ls .outfit-upload:hover { background: var(--ls-surface-3); border-color: var(--ls-line-strong); color: var(--ls-text); }
body.ls .outfit-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
body.ls .outfit-card {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--ls-line);
  border-radius: 12px;
  background: var(--ls-surface-2);
  color: var(--ls-text);
  box-shadow: none;
  transition: border-color .15s, transform .15s;
}
body.ls .outfit-card:last-child { grid-column: auto; border-bottom: 1px solid var(--ls-line); }
body.ls .outfit-card:hover { border-color: var(--ls-line-strong); transform: translateY(-1px); box-shadow: none; }
body.ls .outfit-card.active { border-color: var(--ls-accent); box-shadow: 0 0 0 1px var(--ls-accent); }
body.ls .outfit-card img {
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  padding: 0;
  object-fit: cover;
  background: #fff;
}
body.ls .outfit-card-copy { display: block; border: 0; padding: 9px 10px 10px; }
body.ls .outfit-index { display: none; }
body.ls .outfit-name { padding: 0; font-size: 12.5px; font-weight: 600; line-height: 1.3; }
body.ls .outfit-card.active .outfit-name { color: var(--ls-accent); }

/* Command card */
body.ls .cmdbar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 0;
  padding: 16px;
  background: var(--ls-surface);
  border: 1px solid var(--ls-line);
  border-radius: var(--ls-radius);
}
body.ls .cmd-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; order: 2; }
body.ls .scene-row { order: 1; margin: 0; gap: 6px; }
body.ls .scene-row .scene-label {
  flex: 0 0 100%;
  margin: 0 0 4px;
  color: var(--ls-text);
  font-size: 13px;
  font-weight: 600;
}
body.ls .chip,
body.ls .chip.chip-ref {
  padding: 6px 12px;
  border: 1px solid var(--ls-line);
  border-radius: 999px;
  background: var(--ls-surface-2);
  color: var(--ls-muted);
  font-size: 12px;
  font-weight: 500;
}
body.ls .chip.chip-ref::before { content: none; }
body.ls .chip:hover { border-color: var(--ls-line-strong); color: var(--ls-text); }
body.ls .chip.active { background: var(--ls-accent-soft); border-color: var(--ls-accent); color: var(--ls-accent-text); }
body.ls .chip .badge, body.ls .chip span { filter: none; }

body.ls .ref-slot { flex: 0 0 auto; }
body.ls .ref-add, body.ls .ref-thumb {
  width: 44px; height: 44px;
  border-radius: 10px;
  border: 1px dashed var(--ls-line-strong);
  background: var(--ls-surface-2);
  color: var(--ls-muted);
}
body.ls .ref-thumb { border-style: solid; }
body.ls .cmd-input {
  flex: 1 1 0;
  min-width: 0;
  min-height: 44px;
  max-height: 120px;
  padding: 11px 12px;
  border: 1px solid var(--ls-line);
  border-radius: 10px;
  background: var(--ls-surface-2);
  color: var(--ls-text);
  font: 13px/1.45 inherit;
  font-family: inherit;
  resize: none;
}
body.ls .cmd-input::placeholder { color: var(--ls-dim); }
body.ls .cmd-input:focus { outline: none; border-color: var(--ls-line-strong); }
body.ls .send-fab {
  flex: 1 0 100%;
  width: 100%;
  height: 50px;
  min-width: 0;
  margin-top: 2px;
  padding: 0 20px;
  border-radius: 999px;
  background: var(--ls-accent);
  box-shadow: 0 8px 24px rgba(255, 79, 0, .25);
  transition: background .15s, transform .1s, box-shadow .15s;
}
body.ls .send-fab:hover { background: var(--ls-accent-hover); filter: none; }
body.ls .send-fab:active { transform: scale(.99); }
body.ls .send-fab::before { content: attr(data-label); font-size: 15px; font-weight: 600; letter-spacing: 0; }
body.ls .send-fab.busy::before { content: attr(data-busy-label); }
body.ls .send-fab:disabled, body.ls .send-fab.busy { opacity: .55; box-shadow: none; }
.ls-hint {
  order: 3;
  min-height: 18px;
  color: var(--ls-muted);
  font-size: 12px;
  line-height: 1.5;
  text-align: center;
}
body.ls .ls-hint .send-hint { color: var(--ls-muted); font-weight: 500; }
.ls-hint:has(.send-hint:empty) { display: none; }
body.ls .pe-result { order: 4; margin: 0; background: var(--ls-surface-2); border-color: var(--ls-line); }
body.ls .cards-pop { z-index: 30; }

/* ---------- Showcase modes ---------- */
body.ls .scene-row { display: none !important; }

.ls-tabs {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: inline-flex;
  gap: 2px;
  padding: 4px;
  border: 1px solid var(--ls-line);
  border-radius: 999px;
  background: var(--ls-surface);
}
.ls-tab {
  height: 34px;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ls-muted);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.ls-tab:hover { color: var(--ls-text); }
.ls-tab.on { background: var(--ls-text); color: var(--ls-bg); }

.ls-mode-body { display: flex; flex-direction: column; gap: 22px; }
.ls-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.ls-section-head h2 {
  margin: 0;
  color: var(--ls-dim);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.ls-more {
  padding: 0;
  border: 0;
  background: none;
  color: var(--ls-muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}
.ls-more:hover { color: var(--ls-text); }

.ls-grid { display: grid; gap: 10px; }
.ls-grid-image { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.ls-grid-swatch { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.ls-grid-portrait { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }

.ls-preset {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--ls-line);
  border-radius: 12px;
  background: var(--ls-surface);
  color: var(--ls-text);
  text-align: left;
  cursor: pointer;
  transition: border-color .15s, transform .15s, box-shadow .15s;
}
.ls-preset:hover { border-color: var(--ls-line-strong); transform: translateY(-1px); }
.ls-preset.active { border-color: var(--ls-accent); box-shadow: 0 0 0 1px var(--ls-accent); }
.ls-preset.active::after {
  content: "";
  position: absolute;
  top: 7px; right: 7px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--ls-accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E") center / 12px no-repeat;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .4);
}
.ls-preset img { display: block; width: 100%; height: auto; object-fit: cover; background: #fff; }
.ls-preset-image img { aspect-ratio: 1 / 1; }
.ls-preset-portrait img { aspect-ratio: 2 / 3; background: var(--ls-surface-2); }
.ls-swatch { display: block; width: 100%; aspect-ratio: 16 / 9; }
.ls-preset-copy { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px 9px; }
.ls-preset-title { font-size: 12.5px; font-weight: 600; line-height: 1.3; }
.ls-preset-desc { color: var(--ls-dim); font-size: 11.5px; line-height: 1.35; }
.ls-preset-image .ls-preset-copy { padding: 7px 8px 8px; }
.ls-preset-image .ls-preset-title {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 12px;
}
.ls-preset.active .ls-preset-title { color: var(--ls-accent-text); }

/* Upload tiles */
.ls-upload {
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px;
  border-style: dashed;
  border-color: var(--ls-line-strong);
  background: transparent;
  color: var(--ls-muted);
  text-align: center;
}
.ls-upload:hover { color: var(--ls-text); border-color: var(--ls-muted); }
.ls-upload-ico {
  display: grid;
  place-items: center;
  width: 34px; height: 34px;
  border-radius: 10px;
  background: var(--ls-surface-2);
}
.ls-upload-ico svg { width: 18px; height: 18px; }
.ls-upload .ls-preset-title { font-size: 11.5px; }
.ls-preset-image.ls-upload { aspect-ratio: 1 / 1.24; }
.ls-preset-portrait.ls-upload { aspect-ratio: 2 / 3; padding: 6px; }
.ls-preset-portrait.ls-upload .ls-upload-ico { width: 28px; height: 28px; }

/* Custom prompt card */
.ls-custom {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--ls-line);
  border-radius: 12px;
  background: var(--ls-surface);
  color: var(--ls-text);
  text-align: left;
  cursor: pointer;
  transition: border-color .15s;
}
.ls-custom:hover { border-color: var(--ls-line-strong); }
.ls-custom > span:last-child { display: flex; flex-direction: column; gap: 2px; }
.ls-custom-ico {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 36px; height: 36px;
  border-radius: 10px;
  background: var(--ls-accent-soft);
  color: var(--ls-accent);
}
.ls-custom-ico svg { width: 18px; height: 18px; }

/* ---------- Start-up progress ---------- */
/* The page's own one-line start/error overlay is replaced by the cards below. */
body.ls #outputStartOverlay { display: none !important; }
.ls-progress {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  pointer-events: none;
}
body.ls[data-ls-state="starting"] .ls-progress { display: flex; animation: ls-fade .3s ease; }
.ls-progress ol {
  margin: 0;
  padding: 20px 22px;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: min(320px, 100%);
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 18px;
  background: rgba(12, 12, 15, .7);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .5);
}
.ls-progress li { display: flex; align-items: flex-start; gap: 12px; color: var(--ls-dim); transition: color .3s; }
.ls-progress li > span:last-child { display: flex; flex-direction: column; gap: 3px; }
.ls-progress b { font-size: 14px; font-weight: 600; }
.ls-progress small { min-height: 0; color: var(--ls-muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.ls-progress small:empty { display: none; }
.ls-step-dot {
  position: relative;
  flex: 0 0 auto;
  width: 20px; height: 20px;
  margin-top: 0;
  border-radius: 50%;
  border: 2px solid var(--ls-line-strong);
}
.ls-progress li.active { color: #fff; }
.ls-progress li.active .ls-step-dot {
  border-color: rgba(255, 79, 0, .25);
  border-top-color: var(--ls-accent);
  animation: ls-spin .8s linear infinite;
}
.ls-progress li.done { color: var(--ls-muted); }
.ls-progress li.done .ls-step-dot {
  border-color: var(--ls-ok);
  background: var(--ls-ok) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2309090b' stroke-width='3.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E") center / 12px no-repeat;
}

/* ---------- Error card ---------- */
.ls-alert {
  position: absolute;
  inset: 0;
  z-index: 9;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, .55);
}
.ls-alert.show { display: flex; animation: ls-fade .25s ease; }
.ls-alert-card {
  width: min(420px, 100%);
  padding: 26px 24px 22px;
  border: 1px solid var(--ls-line);
  border-radius: 20px;
  background: var(--ls-surface);
  text-align: center;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .6);
}
.ls-alert-ico {
  display: grid;
  place-items: center;
  width: 48px; height: 48px;
  margin: 0 auto 14px;
  border-radius: 14px;
  background: var(--ls-accent-soft);
  color: var(--ls-accent);
}
.ls-alert-ico svg { width: 24px; height: 24px; }
.ls-alert h3 { margin: 0 0 8px; font-size: 18px; font-weight: 600; letter-spacing: -.01em; }
.ls-alert p { margin: 0; color: var(--ls-muted); font-size: 14px; line-height: 1.55; }
.ls-alert code {
  display: block;
  margin-top: 12px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--ls-surface-2);
  color: var(--ls-dim);
  font: 11.5px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace;
  text-align: left;
  word-break: break-word;
}
.ls-alert-actions { display: flex; justify-content: center; gap: 10px; margin-top: 20px; }

/* ---------- Settings drawer ---------- */
.ls-drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 900;
  background: rgba(0, 0, 0, .5);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease;
}
.ls-drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  z-index: 901;
  width: min(420px, 100vw);
  display: flex;
  flex-direction: column;
  background: var(--ls-surface);
  border-left: 1px solid var(--ls-line);
  transform: translateX(100%);
  transition: transform .3s var(--ls-ease);
}
body.ls.ls-drawer-open .ls-drawer { transform: none; }
body.ls.ls-drawer-open .ls-drawer-backdrop { opacity: 1; pointer-events: auto; }
.ls-drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
  padding: 0 16px 0 20px;
  border-bottom: 1px solid var(--ls-line);
}
.ls-drawer-head h2 { margin: 0; font-size: 15px; font-weight: 600; }
.ls-drawer-body { flex: 1 1 auto; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 22px; }
.ls-drawer-sec h3 { margin: 0 0 12px; color: var(--ls-dim); font-size: 11px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; }
body.ls .ls-drawer .latency-row {
  display: grid !important;
  grid-template-columns: 1fr;
  gap: 6px;
  margin: 0;
  padding: 12px;
  border-radius: 10px;
  background: var(--ls-surface-2);
  color: var(--ls-muted);
  font-size: 12px;
}
body.ls .ls-drawer .cmd-foot {
  display: flex !important;
  flex-direction: column;
  align-items: stretch;
  gap: 14px;
  margin: 0;
  color: var(--ls-muted);
  font-size: 13px;
}
/* Toggles as switch rows */
body.ls .ls-drawer .cmd-foot .pe-toggle {
  display: flex;
  flex-direction: row-reverse;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--ls-line);
  border-radius: 12px;
  background: var(--ls-surface-2);
  color: var(--ls-text);
  font-size: 13.5px;
}
body.ls .ls-drawer .cmd-foot .pe-toggle + .pe-toggle { margin-top: -8px; }
body.ls .ls-drawer .cmd-foot input[type=checkbox] {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  flex: 0 0 auto;
  width: 38px !important;
  height: 22px;
  margin: 0;
  border-radius: 999px;
  background: var(--ls-line-strong);
  cursor: pointer;
  transition: background .2s;
}
body.ls .ls-drawer .cmd-foot input[type=checkbox]::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform .2s var(--ls-ease);
}
body.ls .ls-drawer .cmd-foot input[type=checkbox]:checked { background: var(--ls-accent); }
body.ls .ls-drawer .cmd-foot input[type=checkbox]:checked::after { transform: translateX(16px); }
body.ls .ls-drawer .cmd-foot input[type=checkbox]:disabled { opacity: .45; cursor: not-allowed; }
/* Segmented rows */
body.ls .ls-drawer .kvreset-field {
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  margin-top: 4px;
  color: var(--ls-text);
  font-size: 13px;
  font-weight: 500;
}
body.ls .ls-drawer .qtier {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--ls-line);
  border-radius: 10px;
  background: var(--ls-surface-2);
}
body.ls .ls-drawer .qtier button {
  padding: 7px 0;
  border: 0;
  border-radius: 7px;
  background: transparent;
  text-align: center;
}
body.ls .ls-drawer .qtier button.on { background: var(--ls-accent); color: #fff; }
body.ls .ls-drawer .qtier button.auto-active { background: var(--ls-accent-soft); color: var(--ls-accent-text); }
body.ls .ls-drawer .latency-row span:empty { display: none; }
body.ls .ls-drawer .latency-row #sendHint { display: none; }
body.ls .qtier button {
  padding: 5px 11px;
  border: 1px solid var(--ls-line);
  background: var(--ls-surface-2);
  color: var(--ls-muted);
}
body.ls .qtier button:hover { border-color: var(--ls-line-strong); color: var(--ls-text); }
body.ls .qtier button.on { background: var(--ls-accent); border-color: var(--ls-accent); color: #fff; }
body.ls .qtier button.auto-active { border-color: var(--ls-accent); color: var(--ls-accent-text); box-shadow: none; }
body.ls .qtier { flex-wrap: wrap; }
body.ls .stage-timings-wrap { margin: 0 10px 10px; }

/* ---------- Result dialog ---------- */
.ls-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: rgba(0, 0, 0, .7);
  backdrop-filter: blur(6px);
}
.ls-modal.open { display: flex; animation: ls-fade .25s ease; }
@keyframes ls-fade { from { opacity: 0; } }
.ls-card {
  position: relative;
  width: min(1180px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(240px, 1fr);
  gap: 40px;
  align-items: center;
  padding: 36px;
  border: 1px solid var(--ls-line);
  border-radius: 24px;
  background: var(--ls-surface);
  color: var(--ls-text);
  box-shadow: 0 40px 100px rgba(0, 0, 0, .6);
}
.ls-close {
  position: absolute;
  top: 14px; right: 14px;
  width: 36px; height: 36px;
  border: 1px solid var(--ls-line);
  border-radius: 50%;
  background: var(--ls-surface-2);
  color: var(--ls-muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.ls-close:hover { color: var(--ls-text); }
.ls-preview { width: 100%; aspect-ratio: 16 / 9; border-radius: 16px; background: #000; object-fit: contain; }
.ls-layouts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.ls-layouts button {
  height: 40px;
  padding: 0 18px;
  border: 1px solid var(--ls-line);
  border-radius: 999px;
  background: var(--ls-surface-2);
  color: var(--ls-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}
.ls-layouts button:hover { color: var(--ls-text); }
.ls-layouts button.on { border-color: var(--ls-text); background: var(--ls-surface-3); color: var(--ls-text); }
.ls-side h2 { margin: 0 0 12px; font-size: clamp(26px, 3vw, 38px); font-weight: 700; line-height: 1.1; letter-spacing: -.025em; }
.ls-side p { margin: 0 0 24px; color: var(--ls-muted); font-size: 15px; line-height: 1.6; }
.ls-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.ls-actions .ls-btn { height: 48px; padding: 0 24px; font-size: 15px; }
.ls-actions .ls-btn:disabled { opacity: .45; cursor: default; }
.ls-note { margin-top: 14px; color: var(--ls-dim); font-size: 12px; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .ls-main { grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; padding: 16px; }
  body.ls { --ls-pip-w: 190px; }
  body.ls .topbar .tagline { display: none; }
  .ls-grid-portrait { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1000px) {
  body.ls .topbar { height: auto; flex-wrap: wrap; row-gap: 10px; padding-top: 10px; padding-bottom: 10px; }
  .ls-tabs { position: static; transform: none; order: 10; flex: 1 0 100%; }
  .ls-tab { flex: 1 1 0; }
}
@media (max-width: 860px) {
  body.ls { height: auto; min-height: 100vh; overflow: auto; --ls-pip-w: 120px; }
  body.ls .topbar { padding: 10px 16px; }
  body.ls .topbar .tagline { display: none; }
  .ls-main { display: flex; flex-direction: column; gap: 14px; height: auto; min-height: 0; padding: 12px 16px 96px; }
  .ls-stage-col { flex: 0 0 auto; }
  body.ls .media-box { flex: 0 0 auto; aspect-ratio: 16 / 9; }
  .ls-rail { overflow: visible; }
  .ls-rail-scroll { overflow: visible; mask-image: none; padding-right: 0; }
  body.ls .outfit-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  body.ls .send-fab {
    position: fixed;
    left: 16px; right: 16px; bottom: 16px;
    z-index: 50;
    width: auto;
    margin: 0;
  }
  .ls-guide span { font-size: 11px; }
  .ls-countdown { right: 10px; bottom: 10px; }
  body.ls[data-ls-state="live"] .ls-pip { top: 8px; left: 8px; }
  .ls-card { grid-template-columns: 1fr; gap: 20px; padding: 20px 16px; }
}
@media (max-width: 420px) {
  body.ls .outfit-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) {
  body.ls *, body.ls *::before, body.ls *::after { transition: none !important; animation: none !important; }
}

/* ---------- Light theme ---------- */
body.ls[data-ls-theme="light"] {
  --ls-bg: #f6f6f7;
  --ls-surface: #ffffff;
  --ls-surface-2: #f2f2f4;
  --ls-surface-3: #e7e7eb;
  --ls-line: #e4e4e8;
  --ls-line-strong: #cfcfd6;
  --ls-text: #0b0b0f;
  --ls-muted: #55555f;
  --ls-dim: #85858f;
  --ls-accent-soft: rgba(255, 79, 0, .1);
  --ls-accent-text: #c93c00;
  color-scheme: light;
}
body.ls[data-ls-theme="light"] .ls-status::before { background: #b4b4bc; }
body.ls[data-ls-theme="light"] .ls-progress ol,
body.ls[data-ls-theme="light"] .ls-countdown { color: #fff; }
body.ls[data-ls-theme="light"] .ls-preset,
body.ls[data-ls-theme="light"] .stage > .vpanel:last-child {
  box-shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 6px 20px rgba(0, 0, 0, .04);
}
body.ls[data-ls-theme="light"] .ls-modal { background: rgba(20, 20, 24, .45); }
body.ls[data-ls-theme="light"] .ls-drawer-backdrop { background: rgba(20, 20, 24, .3); }

/* Generated results on cards */
.ls-preset img.ls-result-img { object-fit: cover; object-position: 50% 30%; background: #000; }
.ls-inset {
  position: absolute;
  top: 6px; left: 6px;
  width: 34% !important;
  aspect-ratio: 1 / 1 !important;
  height: auto;
  object-fit: contain !important;
  padding: 2px;
  border-radius: 8px;
  background: #fff !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .45);
}

/* Enhanced prompt: read-only footer under the video */
body.ls .stage .pe-result {
  flex: 0 0 auto;
  order: 0;
  margin: 0 10px 10px;
  padding: 10px 14px;
  max-height: 4.6em;
  overflow-y: auto;
  border: 1px solid var(--ls-line);
  border-radius: 12px;
  background: var(--ls-surface-2);
  color: var(--ls-muted);
  font-size: 12.5px;
  line-height: 1.5;
  scrollbar-width: thin;
}
body.ls .stage .pe-result .pe-result-label {
  color: var(--ls-text);
  font-weight: 600;
  margin-right: 6px;
}

/* Main button becomes "Stop session" during a session */
body.ls .send-fab.ls-stop-mode {
  background: var(--ls-surface-3);
  color: var(--ls-text);
  box-shadow: inset 0 0 0 1px var(--ls-line-strong);
  opacity: 1;
  cursor: pointer;
}
body.ls .send-fab.ls-stop-mode:hover { background: var(--ls-line-strong); }
body.ls .send-fab.ls-stop-mode::before {
  content: attr(data-label);
  padding-left: 22px;
  background: linear-gradient(var(--ls-live), var(--ls-live)) left center / 11px 11px no-repeat;
}
body.ls .send-fab.ls-stop-mode.busy::before { content: attr(data-label); }

/* Countdown pill while waiting for the first edited frame */
.ls-countdown.waiting { font-size: 13px; font-weight: 500; }
.ls-countdown.waiting .ls-ring {
  stroke-dasharray: 18 100;
  stroke-dashoffset: 0 !important;
  transform-origin: 13px 13px;
  animation: ls-spin .9s linear infinite;
  transition: none;
}

/* Character cards: result fills the card, original portrait inset */
.ls-preset-portrait img.ls-result-img { object-position: 50% 25%; }
.ls-preset-portrait .ls-inset { width: 38% !important; aspect-ratio: 2 / 3 !important; object-fit: cover !important; padding: 0; }

/* Switching looks mid-session: show the live camera (dimmed) instead of a black
   frame and caption, with a small "Applying look…" pill. */
body.ls[data-ls-switching] #outputWaitOverlay { display: none !important; }
body.ls[data-ls-state="live"][data-ls-switching] .ls-pip {
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  border-radius: 0;
  box-shadow: none;
}
body.ls[data-ls-switching] .ls-pip video { filter: brightness(.6) saturate(.85); }
body.ls[data-ls-switching] .ls-pip-label { display: none; }
.ls-applying {
  position: absolute;
  top: 16px; left: 50%;
  z-index: 8;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px 7px 10px;
  border-radius: 999px;
  background: rgba(10, 10, 12, .6);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, .12);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  opacity: 0;
  transform: translate(-50%, -6px);
  transition: opacity .25s ease, transform .25s ease;
  pointer-events: none;
}
.ls-applying::before {
  content: "";
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .25);
  border-top-color: var(--ls-accent);
  animation: ls-spin .8s linear infinite;
}
body.ls[data-ls-switching] .ls-applying { opacity: 1; transform: translate(-50%, 0); }
.ls-preset-portrait .ls-inset { top: auto; left: auto; right: 5px; bottom: 5px; width: 32% !important; border-radius: 6px; box-shadow: 0 0 0 1.5px rgba(255,255,255,.85), 0 2px 8px rgba(0,0,0,.5); }

/* Previously injected by the localhost proxy; needed when served by the Space itself. */
body.ls #resBanner, body.ls #quotaBanner, body.ls .team-strip,
body.ls .release-dialog, body.ls .release-footer { display: none !important; }
body.ls .stage .pe-result[style*="display: block"] { display: block !important; }

/* Prompt-enhancement toggle in the command footer (replaces the drawer switch) */
body.ls #peToggle { display: none !important; }
.ls-pe-row {
  order: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 2px 2px 0;
  cursor: pointer;
}
.ls-pe-copy { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ls-pe-copy b { font-size: 13px; font-weight: 600; color: var(--ls-text); }
.ls-pe-copy small { font-size: 11.5px; color: var(--ls-dim); }
.ls-switch {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  flex: 0 0 auto;
  width: 38px;
  height: 22px;
  margin: 0;
  border-radius: 999px;
  background: var(--ls-line-strong);
  cursor: pointer;
  transition: background .2s;
}
.ls-switch::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform .2s var(--ls-ease);
}
.ls-switch:checked { background: var(--ls-accent); }
.ls-switch:checked::after { transform: translateX(16px); }
.ls-switch:disabled { opacity: .45; cursor: not-allowed; }

/* Optional sharpening of the edited video (Settings → Sharpen video) */
body.ls.ls-sharpen #outputCanvas,
body.ls.ls-sharpen #outputImg { filter: url(#ls-sharpen); }

/* =====================================================================
   Phone layout (max 760px): full-height vertical video, floating controls.
   ===================================================================== */
.ls-mob, .ls-sheet-backdrop { display: none; }

/* Phone-only Fit/Fill helpers, shown by the 760px block below. */
.ls-backdrop, .ls-fit-label { display: none; }
@media (max-width: 760px) {
  body.ls {
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
    --ls-pip-w: 92px;
    --ls-top: calc(env(safe-area-inset-top, 0px) + 104px);
    --ls-bottom: calc(env(safe-area-inset-bottom, 0px) + 236px);
  }

  /* Top bar floats over the video. */
  body.ls .topbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 40;
    height: auto;
    padding: calc(env(safe-area-inset-top, 0px) + 10px) 12px 10px;
    border: 0;
    background: linear-gradient(rgba(0, 0, 0, .55), rgba(0, 0, 0, 0));
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    color: #fff;
  }
  body.ls .topbar .brand { color: #fff; font-size: 15px; }
  body.ls .topbar .tagline { display: none; }
  body.ls .lang-seg { background: rgba(0, 0, 0, .35); border-color: rgba(255, 255, 255, .18); }
  body.ls .lang-seg button { color: rgba(255, 255, 255, .75); }
  body.ls .lang-seg button.on { background: rgba(255, 255, 255, .22); color: #fff; }
  body.ls .topbar .ls-icon-btn {
    width: 34px; height: 34px;
    background: rgba(0, 0, 0, .35);
    border-color: rgba(255, 255, 255, .18);
    color: #fff;
  }
  body.ls .topbar > .ls-icon-btn:not(.ls-theme-btn) { display: none; } /* settings sits by the shutter */
  .ls-tabs {
    order: 10;
    flex: 1 0 100%;
    position: static;
    transform: none;
    margin-top: 2px;
    background: rgba(0, 0, 0, .35);
    border-color: rgba(255, 255, 255, .15);
  }
  .ls-tab { flex: 1 1 0; height: 30px; color: rgba(255, 255, 255, .8); }
  .ls-tab.on { background: #fff; color: #111; }

  /* Video fills the screen. */
  .ls-main {
    position: fixed;
    inset: 0;
    display: block;
    height: auto;
    max-height: none;
    min-height: 0;
    padding: 0;
  }
  .ls-stage-col { height: 100%; }
  body.ls .stage > .vpanel:last-child {
    border: 0;
    border-radius: 0;
    background: #000;
  }
  body.ls .media-box {
    flex: 1 1 auto;
    margin: 0;
    border-radius: 0;
    aspect-ratio: auto;
    max-height: none;
  }
  body.ls .media-box video,
  body.ls .media-box canvas,
  body.ls .media-box img { object-fit: cover; }
  /* A wide camera (laptop webcam in a narrow window) on a tall screen. "Fit" (default)
     shows the whole frame over a blurred, enlarged copy of the same video, so the screen
     stays full height; double-tap switches to "Fill" (body.ls-fill, the close-up).
     Upright phone cameras keep cover: their frames carry the full upright view in the
     middle (see live-studio.js). */
  body.ls .stage > .vpanel:last-child .media-box { isolation: isolate; }
  body.ls:not(.ls-cam-portrait):not(.ls-fill) .ls-backdrop {
    display: block; position: absolute; inset: 0; width: 100%; height: 100%; z-index: -1;
    filter: blur(22px) brightness(.5) saturate(1.15); transform: scale(1.2); pointer-events: none;
  }
  body.ls:not(.ls-cam-portrait):not(.ls-fill) .media-box canvas:not(.ls-backdrop),
  body.ls:not(.ls-cam-portrait):not(.ls-fill) .media-box > img,
  body.ls:not(.ls-cam-portrait):not(.ls-fill):not([data-ls-state="live"]) .ls-pip video {
    object-fit: contain; background: transparent;
  }
  body.ls:not(.ls-cam-portrait):not(.ls-fill):not([data-ls-state="live"]) .ls-pip { background: transparent; }
  .ls-fit-label {
    display: block; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 30;
    padding: 9px 16px; border-radius: 999px; background: rgba(0,0,0,.62); color: #fff; font-weight: 600;
    font-size: 14px; opacity: 0; transition: opacity .2s; pointer-events: none; backdrop-filter: blur(8px);
  }
  .ls-fit-label.show { opacity: 1; }
  body.ls .stage .pe-result,
  body.ls .stage-timings-wrap { display: none !important; }

  /* Status pill floats under the tabs; Stop moves to the shutter. */
  body.ls .vpanel-head {
    position: absolute;
    top: var(--ls-top);
    left: 12px;
    z-index: 12;
    min-height: 0;
    padding: 0;
    background: none;
  }
  body.ls .vpanel-head .ls-stop { display: none !important; }
  .ls-status { background: rgba(0, 0, 0, .45); border-color: rgba(255, 255, 255, .15); color: #fff; }

  /* Overlays positioned around the floating chrome. */
  body.ls[data-ls-state="live"] .ls-pip {
    top: calc(var(--ls-top) + 40px);
    left: 12px;
    height: calc(var(--ls-pip-w) * 16 / 9);
    border-radius: 14px;
  }
  .ls-countdown { top: var(--ls-top); bottom: auto; right: 12px; }
  .ls-applying { top: calc(var(--ls-top) + 44px); }
  .ls-guide span { top: calc(var(--ls-top) + 44px); font-size: 12px; }
  .ls-guide::before { width: 70%; bottom: var(--ls-bottom); }
  .ls-progress, .ls-alert, .ls-camprompt { padding-bottom: var(--ls-bottom); }
  body.ls .wait-overlay { padding-bottom: var(--ls-bottom); }
  body.ls .toast { top: 42%; }

  /* Bottom controls: product card, preset carousel, shutter row. */
  .ls-mob {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 30;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 28px 0 calc(env(safe-area-inset-bottom, 0px) + 16px);
    background: linear-gradient(rgba(0, 0, 0, 0), rgba(0, 0, 0, .6) 45%);
    pointer-events: none;
  }
  .ls-mob > * { pointer-events: auto; }
  .ls-mob-card {
    align-self: center;
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: calc(100% - 32px);
    padding: 6px 14px 6px 6px;
    border-radius: 14px;
    background: rgba(20, 20, 24, .72);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, .12);
    color: #fff;
  }
  .ls-mob-card[hidden] { display: none; }
  .ls-mob-card-thumb {
    flex: 0 0 auto;
    width: 44px; height: 44px;
    border-radius: 10px;
    background-size: cover;
    background-position: center;
  }
  .ls-mob-card-copy { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
  .ls-mob-card-copy b { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .ls-mob-card-copy small { font-size: 11px; color: rgba(255, 255, 255, .65); text-transform: uppercase; letter-spacing: .06em; }

  .ls-mob-rail {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding: 4px calc(50% - 30px);
    scroll-snap-type: x proximity;
    scrollbar-width: none;
  }
  .ls-mob-rail::-webkit-scrollbar { display: none; }
  .ls-mob-item {
    flex: 0 0 auto;
    width: 60px; height: 60px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, .55);
    background: #333 center / cover no-repeat;
    box-shadow: 0 3px 10px rgba(0, 0, 0, .35);
    scroll-snap-align: center;
    cursor: pointer;
    transition: transform .15s, border-color .15s;
  }
  .ls-mob-item.active { border-color: var(--ls-accent); border-width: 3px; transform: scale(1.12); }
  .ls-mob-item.is-upload {
    display: grid;
    place-items: center;
    background: rgba(0, 0, 0, .45);
    border-style: dashed;
    color: #fff;
  }
  .ls-mob-item.is-upload svg { width: 22px; height: 22px; }

  .ls-mob-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 44px;
  }
  .ls-mob-side {
    display: grid;
    place-items: center;
    width: 46px; height: 46px;
    border: 0;
    border-radius: 50%;
    background: rgba(0, 0, 0, .45);
    color: #fff;
    cursor: pointer;
  }
  .ls-mob-side svg { width: 22px; height: 22px; }
  .ls-mob-shutter {
    position: relative;
    width: 76px; height: 76px;
    padding: 0;
    border: 5px solid #fff;
    border-radius: 50%;
    background: transparent;
    cursor: pointer;
  }
  .ls-mob-shutter span {
    position: absolute;
    inset: 5px;
    border-radius: 50%;
    background: var(--ls-accent);
    transition: inset .2s var(--ls-ease), border-radius .2s var(--ls-ease), background .2s;
  }
  .ls-mob-shutter[data-state="starting"] span,
  .ls-mob-shutter[data-state="live"] span { inset: 20px; border-radius: 6px; background: var(--ls-live); }
  .ls-mob-shutter[data-state="starting"] { animation: ls-breathe 1.2s ease-in-out infinite; }

  /* Custom-edit bottom sheet: the desktop command panel, re-housed. The rail is
     kept in the DOM (its cards drive the carousel) but only the panel shows. */
  .ls-rail { display: block; position: static; }
  .ls-rail > .ls-rail-scroll { display: none; }
  .ls-sheet-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 55;
    background: rgba(0, 0, 0, .45);
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s ease;
  }
  body.ls.ls-sheet-open .ls-sheet-backdrop { opacity: 1; pointer-events: auto; }
  body.ls .cmdbar {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 60;
    margin: 0;
    padding: 16px 16px calc(env(safe-area-inset-bottom, 0px) + 16px);
    border-radius: 20px 20px 0 0;
    border-bottom: 0;
    transform: translateY(105%);
    transition: transform .3s var(--ls-ease);
  }
  body.ls.ls-sheet-open .cmdbar { transform: none; }
  body.ls.ls-sheet-open .ls-mob { opacity: 0; pointer-events: none; }
  body.ls.ls-sheet-open .ls-mob > * { pointer-events: none; }
  body.ls .send-fab { position: static; width: 100%; margin-top: 2px; }
}

/* Desktop: keep the live video near its real size (the model outputs ~960 px wide),
   so it isn't stretched 1.5-2x on large screens. Phones keep the full-screen layout. */
@media (min-width: 761px) {
  .ls-stage-col { justify-content: center; }
  body.ls .stage { justify-content: center; }
  body.ls .stage > .vpanel:last-child { flex: 0 1 auto; width: 100%; max-width: 1120px; }
}
@media (min-width: 761px) {
  .ls-stage-col { align-items: center; }
  body.ls .stage { align-items: center; }
  body.ls .stage > .vpanel:last-child {
    height: auto;
    max-width: min(1120px, calc((100vh - 230px) * 960 / 552));
  }
  body.ls .media-box { flex: 0 0 auto; aspect-ratio: 960 / 552; }
}

/* Phone carousel: the centred circle drives the info card. */
@media (max-width: 760px) {
  .ls-mob-item.centered:not(.active) { border-color: #fff; transform: scale(1.06); }
  .ls-mob-card-thumb.is-upload {
    display: grid;
    place-items: center;
    background: rgba(255, 255, 255, .12) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 16V4M7 9l5-5 5 5M5 20h14'/%3E%3C/svg%3E") center / 22px no-repeat;
  }
  .ls-mob-card.is-active { border-color: rgba(255, 79, 0, .6); }
}

/* Reference crop tool */
.ls-crop {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px 16px;
  background: rgba(0, 0, 0, .7);
  backdrop-filter: blur(6px);
}
.ls-crop.open { display: flex; animation: ls-fade .2s ease; }
.ls-crop-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: min(560px, 100%);
  max-height: calc(100dvh - 40px);
  padding: 20px;
  border: 1px solid var(--ls-line);
  border-radius: 20px;
  background: var(--ls-surface);
  color: var(--ls-text);
}
.ls-crop-head h3 { margin: 0 0 6px; font-size: 17px; font-weight: 600; }
.ls-crop-head p { margin: 0; color: var(--ls-muted); font-size: 13px; line-height: 1.5; }
.ls-crop-stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  border-radius: 12px;
  overflow: hidden;
  background: repeating-conic-gradient(#2a2a30 0 25%, #222228 0 50%) 0 0 / 16px 16px;
  touch-action: none;
  user-select: none;
}
.ls-crop-stage img { display: block; max-width: 100%; max-height: min(56dvh, 520px); object-fit: contain; }
.ls-crop-box {
  position: absolute;
  border: 2px solid #fff;
  border-radius: 4px;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, .55);
  cursor: move;
  touch-action: none;
}
.ls-crop-box span {
  position: absolute;
  width: 22px; height: 22px;
  border: 3px solid var(--ls-accent);
  background: transparent;
}
.ls-crop-box span[data-h="nw"] { left: -4px; top: -4px; border-right: 0; border-bottom: 0; cursor: nwse-resize; }
.ls-crop-box span[data-h="ne"] { right: -4px; top: -4px; border-left: 0; border-bottom: 0; cursor: nesw-resize; }
.ls-crop-box span[data-h="sw"] { left: -4px; bottom: -4px; border-right: 0; border-top: 0; cursor: nesw-resize; }
.ls-crop-box span[data-h="se"] { right: -4px; bottom: -4px; border-left: 0; border-top: 0; cursor: nwse-resize; }
.ls-crop-actions { display: flex; justify-content: flex-end; gap: 10px; }


/* GPU offline: the page still loads; a notice sits over the video and Start explains it. */
.ls-offline-bar { display: none; }
body.ls.ls-offline:not([data-ls-state="live"]) .ls-offline-bar {
  display: grid; gap: 4px; position: absolute; left: 50%; bottom: 24px; transform: translateX(-50%);
  z-index: 25; width: min(440px, calc(100% - 32px)); padding: 14px 18px; border-radius: 14px;
  background: rgba(14, 14, 17, .82); backdrop-filter: blur(10px); color: #f4f4f5; text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .35); pointer-events: none;
}
.ls-offline-bar b { font-size: 15px; }
.ls-offline-bar b::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 8px;
  border-radius: 50%; background: #9ca3af; vertical-align: 1px; }
.ls-offline-bar span { font-size: 13px; color: #c4c4cc; line-height: 1.4; }
@media (max-width: 760px) {
  body.ls.ls-offline:not([data-ls-state="live"]) .ls-offline-bar { top: calc(var(--ls-top, 104px) + 44px); bottom: auto; }
}
