:root {
  color-scheme: dark;
  --bg: #0a0e1a;
  --bg-strong: #06090f;
  --panel: rgba(255, 255, 255, 0.05);
  --panel-solid: #111a2b;
  --ink: #e8edf6;
  --muted: #93a6c4;
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.16);
  --blue: #3b82f6;
  --blue-dark: #2563eb;
  --ember: #06b6d4;
  --green: #10b981;
  --red: #f0556a;
  --shadow: 0 28px 70px rgba(0, 0, 0, 0.5);
  --tight-shadow: 0 16px 30px rgba(0, 0, 0, 0.4);
  font-family: "Plus Jakarta Sans", "Noto Sans Myanmar", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

/* MOBILE PERFORMANCE — backdrop-filter blur() forces expensive GPU
   compositing wherever it's used, and is especially costly on elements that
   animate (the studio-rail drawer slide, sticky topbars during scroll, the
   landing hero/nav). The earlier dashboard-only fix missed those — kill
   blur everywhere on phones; panels keep their semi-opaque backgrounds so
   they still read as glass. Exception: .preview-cover-layer's blur is a
   functional live-preview of the rendered cover-blur effect, not decor —
   keep it so the preview matches the actual output. */
@media (max-width: 640px) {
  *:not(.preview-cover-layer) {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(ellipse 70% 50% at 12% -8%, rgba(59, 130, 246, 0.13), transparent 55%),
    radial-gradient(ellipse 60% 50% at 92% 4%, rgba(6, 182, 212, 0.11), transparent 50%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg) 60%, var(--bg-strong) 100%);
}

a,
button,
input,
select,
textarea {
  font: inherit;
}

a {
  color: inherit;
}

button {
  border: 0;
}

.button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 18px;
  border-radius: 8px;
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 800;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button-primary {
  color: #04121f;
  background: linear-gradient(135deg, var(--blue), var(--ember));
  box-shadow: 0 14px 32px rgba(6, 182, 212, 0.32);
}

.button-muted,
.button-ghost,
.button-secondary {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line-strong);
}

.button-block {
  width: 100%;
}

.button[hidden] {
  display: none;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  background: var(--ink);
  font-size: 0.82rem;
  font-weight: 900;
  letter-spacing: 0.04em;
}

.eyeline {
  margin: 0 0 8px;
  color: var(--blue);
  font-size: 0.74rem;
  font-weight: 900;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2,
h3 {
  letter-spacing: 0;
}

.landing-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 56px;
}

.landing-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 42px;
}

.landing-brand,
.rail-brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.landing-brand strong,
.landing-brand small,
.rail-brand strong,
.rail-brand small {
  display: block;
}

.landing-brand small,
.rail-brand small {
  color: var(--muted);
  font-size: 0.78rem;
}

.landing-nav nav {
  display: flex;
  gap: 24px;
  color: #4a5565;
  font-size: 0.9rem;
  font-weight: 700;
}

.landing-nav nav a {
  text-decoration: none;
}

.landing-hero {
  display: grid;
  min-height: 620px;
  grid-template-columns: minmax(0, 0.92fr) minmax(420px, 1.08fr);
  gap: 36px;
  align-items: center;
}

.hero-copy h1 {
  margin-bottom: 18px;
  font-size: clamp(4rem, 10vw, 8.5rem);
  line-height: 0.84;
  font-weight: 900;
}

.hero-copy p {
  max-width: 620px;
  color: #4c596b;
  font-size: clamp(1.06rem, 2vw, 1.35rem);
  line-height: 1.7;
}

.hero-actions,
.topbar-actions,
.inline-row,
.launch-band {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.hero-product {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.06);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
}

.product-topline,
.preview-toolbar,
.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.product-topline {
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 0.86rem;
}

.product-topline strong {
  color: var(--green);
}

.product-screen {
  display: grid;
  grid-template-columns: minmax(240px, 0.7fr) minmax(220px, 0.3fr);
  gap: 16px;
  min-height: 520px;
}

.phone-preview {
  position: relative;
  min-height: 520px;
  overflow: hidden;
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 24%),
    radial-gradient(circle at 50% 28%, rgba(47, 109, 246, 0.36), transparent 24%),
    linear-gradient(145deg, #090d16, #162032 48%, #05070c);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
}

.phone-preview::before {
  content: "";
  position: absolute;
  inset: 11% 13% auto;
  height: 46%;
  border-radius: 50%;
  background:
    linear-gradient(140deg, rgba(255, 255, 255, 0.2), transparent 45%),
    linear-gradient(135deg, #2f6df6, #f06b35);
  filter: blur(2px);
  opacity: 0.82;
}

.phone-watermark {
  position: absolute;
  top: 18px;
  right: 18px;
  padding: 8px 10px;
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.92);
  background: rgba(0, 0, 0, 0.34);
  font-size: 0.72rem;
  font-weight: 900;
}

.phone-subtitle {
  position: absolute;
  left: 24px;
  right: 24px;
  bottom: 58px;
  padding: 12px 14px;
  border-radius: 8px;
  color: #fff;
  background: rgba(0, 0, 0, 0.54);
  text-align: center;
  font-family: "Noto Sans Myanmar", sans-serif;
  font-weight: 800;
  line-height: 1.45;
}

.render-queue {
  display: grid;
  align-content: end;
  gap: 12px;
  padding: 18px;
  border-radius: 14px;
  color: #fff;
  background: linear-gradient(180deg, #151b25, #0d1119);
}

.render-queue span,
.render-queue strong {
  display: block;
}

.render-queue span {
  color: #91a0b7;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.queue-bars {
  display: grid;
  gap: 8px;
}

.queue-bars i {
  display: block;
  height: 7px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--blue), var(--ember));
}

.queue-bars i:nth-child(2) {
  width: 78%;
}

.queue-bars i:nth-child(3) {
  width: 54%;
}

.workflow-strip,
.feature-list {
  display: grid;
  gap: 14px;
}

.workflow-strip {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 12px 0 24px;
}

.workflow-strip article,
.feature-list article,
.panel,
.launch-band {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: var(--tight-shadow);
  backdrop-filter: blur(18px);
}

.workflow-strip article {
  padding: 18px;
}

.workflow-strip span,
.panel-number {
  color: var(--blue);
  font-size: 0.78rem;
  font-weight: 900;
}

.workflow-strip strong,
.feature-list strong {
  display: block;
  margin: 10px 0 8px;
}

.workflow-strip p,
.feature-list span,
.landing-section p,
.launch-band p {
  color: var(--muted);
  line-height: 1.6;
}

.landing-section {
  margin-top: 24px;
}

.split {
  display: grid;
  grid-template-columns: 0.9fr 1.1fr;
  gap: 24px;
  align-items: start;
}

.split h2,
.launch-band h2 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.7rem);
  line-height: 1;
}

.feature-list article {
  padding: 18px;
}

.launch-band {
  justify-content: space-between;
  margin-top: 24px;
  padding: 24px;
}

.studio-shell {
  width: min(1540px, calc(100% - 28px));
  margin: 0 auto;
  padding: 16px 0 28px;
  display: grid;
  grid-template-columns: 228px minmax(0, 1fr);
  gap: 16px;
}

.studio-rail {
  position: sticky;
  top: 16px;
  align-self: start;
  display: grid;
  gap: 18px;
  min-height: calc(100vh - 32px);
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
  box-shadow: var(--tight-shadow);
  backdrop-filter: blur(20px);
}

.rail-nav {
  display: grid;
  gap: 8px;
}

.rail-link,
.ghost-link {
  text-decoration: none;
}

.rail-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-radius: 8px;
  color: #4b5563;
  font-size: 0.88rem;
  font-weight: 800;
}

.rail-link span {
  color: #9aa4b2;
  font-size: 0.74rem;
}

.rail-link.active,
.rail-link:hover {
  color: var(--ink);
  background: var(--panel);
}

.rail-footer {
  display: grid;
  align-content: end;
  gap: 10px;
}

.system-pill {
  display: flex;
  min-height: 40px;
  align-items: center;
  gap: 9px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.06);
  font-size: 0.78rem;
  font-weight: 800;
}

.system-pill span,
.status-dot,
.dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--ember);
}

.system-pill.ready span,
.health-pill.ready .status-dot {
  background: var(--green);
}

.system-pill.warning span,
.health-pill.warning .status-dot {
  background: var(--red);
}

.ghost-link {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.studio-main {
  min-width: 0;
}

.studio-topbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 16px;
  padding: 4px 2px;
}

.studio-topbar h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.4rem);
  line-height: 0.96;
}

.studio-topbar p:last-child {
  max-width: 760px;
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.studio-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 500px);
  gap: 16px;
}

.control-stack,
.preview-stack,
.empty-state,
.result-stack {
  display: grid;
  gap: 16px;
}

.panel {
  padding: 18px;
}

.panel h2,
.preview-toolbar h2 {
  margin: 0;
  font-size: 1.18rem;
  line-height: 1.2;
}

.field-grid {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.field-grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.field-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.field,
.field label {
  display: grid;
  gap: 8px;
}

.field span,
.toggle-row,
.side-note,
.field-note {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.field input,
.field select,
.field textarea,
.upload-zone,
.copy-box {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.06);
  outline: none;
}

.field input,
.field select,
.field textarea {
  min-height: 42px;
  padding: 10px 12px;
}

.field textarea {
  min-height: 138px;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: rgba(47, 109, 246, 0.5);
  box-shadow: 0 0 0 4px rgba(47, 109, 246, 0.12);
}

.upload-zone {
  display: grid;
  gap: 6px;
  margin-top: 14px;
  padding: 18px;
  cursor: pointer;
  background:
    linear-gradient(135deg, rgba(47, 109, 246, 0.1), rgba(240, 107, 53, 0.07)),
    rgba(255, 255, 255, 0.82);
}

.upload-zone input {
  display: none;
}

.upload-zone span {
  color: var(--blue);
  font-size: 0.74rem;
  font-weight: 900;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.upload-zone small {
  color: var(--muted);
}

.inline-row {
  margin-top: 14px;
}

.toggle-row {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.toggle-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--blue);
}

.preview-panel {
  position: sticky;
  top: 16px;
  z-index: 2;
}

.preview-toolbar {
  margin-bottom: 14px;
}

.preview-toolbar > span,
.voice-library-status {
  padding: 7px 10px;
  border-radius: 999px;
  color: var(--blue-dark);
  background: rgba(47, 109, 246, 0.1);
  font-size: 0.74rem;
  font-weight: 900;
}

.video-preview-shell {
  position: relative;
  min-height: 620px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  background:
    radial-gradient(circle at 50% 20%, rgba(47, 109, 246, 0.25), transparent 24%),
    linear-gradient(145deg, #080c14, #151f30 48%, #07090e);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.video-preview {
  display: block;
  width: 100%;
  min-height: 620px;
  max-height: 760px;
  object-fit: contain;
  background: transparent;
}

.video-preview-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 8px;
  padding: 22px;
  color: #fff;
  text-align: center;
}

.video-preview-empty span {
  color: #8fa0bc;
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.video-preview-empty strong {
  font-size: 1.35rem;
}

.video-preview-empty small {
  color: #8fa0bc;
  font-size: 0.78rem;
}

.tg-progress-ring {
  position: relative;
  width: 60px;
  height: 60px;
  margin: 4px auto 0;
}

.tg-progress-ring svg {
  transform: rotate(-90deg);
}

.tg-progress-ring .ring-track {
  fill: none;
  stroke: rgba(255, 255, 255, 0.14);
  stroke-width: 5;
}

.tg-progress-ring .ring-fill {
  fill: none;
  stroke: var(--ember);
  stroke-width: 5;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.25s ease;
}

.tg-progress-ring .ring-pct {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  font-size: 0.82rem;
  font-weight: 800;
  color: #fff;
}

.preview-cover-layer {
  position: absolute;
  left: 18px;
  right: 18px;
  border-radius: 10px;
  background: rgba(2, 5, 10, 0.82);
  pointer-events: auto;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.preview-cover-layer.is-dragging {
  cursor: grabbing;
}

.preview-watermark {
  position: absolute;
  top: 16px;
  right: 16px;
  max-width: 52%;
  padding: 8px 11px;
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.92);
  background: rgba(4, 7, 12, 0.54);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  backdrop-filter: blur(8px);
  pointer-events: none;
}

.preview-subtitle {
  position: absolute;
  left: 50%;
  top: 86%;
  right: auto;
  width: min(86%, 680px);
  display: grid;
  gap: 4px;
  justify-items: center;
  color: #fff;
  text-align: center;
  font-family: "Noto Sans Myanmar", sans-serif;
  font-weight: 800;
  line-height: 1.35;
  text-shadow:
    0 2px 0 rgba(0, 0, 0, 0.95),
    -1px -1px 0 rgba(0, 0, 0, 0.95),
    1px -1px 0 rgba(0, 0, 0, 0.95),
    -1px 1px 0 rgba(0, 0, 0, 0.95),
    1px 1px 0 rgba(0, 0, 0, 0.95);
  transform: translate(-50%, -100%);
  cursor: grab;
  pointer-events: auto;
  touch-action: none;
  user-select: none;
}

.preview-subtitle.is-dragging {
  cursor: grabbing;
}

.preview-subtitle span {
  display: inline-block;
  max-width: min(100%, 34ch);
  padding: 3px 12px;
  border-radius: 8px;
  background: transparent;
}

.preview-note {
  margin: 12px 0 0;
  line-height: 1.55;
}

.voice-panel {
  display: grid;
  gap: 12px;
}

.voice-library {
  display: grid;
  gap: 10px;
}

.voice-item,
.voice-library-empty,
.progress-step {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.voice-item p,
.voice-library-empty span,
.progress-step span,
.download-card span {
  color: var(--muted);
  font-size: 0.84rem;
}

.output-panel {
  grid-column: 1 / -1;
}

.empty-state p,
.result-hero p,
.error-card p,
.warning-box,
.side-note {
  color: var(--muted);
  line-height: 1.6;
}

.progress-shell,
.result-card,
.warning-box,
.error-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
}

.progress-header {
  display: grid;
  gap: 8px;
}

.progress-meter {
  height: 10px;
  margin: 14px 0;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.progress-meter span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--blue), var(--ember));
}

.progress-steps,
.download-grid,
.clean-list {
  display: grid;
  gap: 10px;
}

.progress-step.active {
  border-color: rgba(47, 109, 246, 0.34);
  background: rgba(47, 109, 246, 0.08);
}

.progress-step.complete {
  border-color: rgba(15, 159, 122, 0.3);
}

.warning-box {
  border-color: rgba(240, 107, 53, 0.32);
  background: rgba(240, 107, 53, 0.08);
}

.error-card {
  border-color: rgba(219, 51, 72, 0.28);
  background: rgba(219, 51, 72, 0.08);
}

.copy-box {
  padding: 14px;
  line-height: 1.8;
  white-space: pre-wrap;
}

.download-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.download-card {
  display: grid;
  gap: 6px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-solid);
  text-decoration: none;
}

.result-video {
  width: min(100%, 420px);
  border-radius: 12px;
  background: #080c14;
}

audio {
  width: min(100%, 440px);
}

@media (max-width: 1180px) {
  .landing-hero,
  .product-screen,
  .workflow-strip,
  .split,
  .studio-grid {
    grid-template-columns: 1fr;
  }

  .landing-hero {
    min-height: auto;
  }

  .preview-panel {
    position: static;
  }

  .video-preview-shell,
  .video-preview {
    min-height: 520px;
  }
}

@media (max-width: 840px) {
  .landing-shell {
    width: min(100% - 22px, 100%);
    padding-top: 14px;
  }

  .landing-nav {
    align-items: flex-start;
  }

  .landing-nav nav {
    display: none;
  }

  .landing-hero {
    gap: 22px;
  }

  .workflow-strip {
    grid-template-columns: 1fr;
  }

  .studio-shell {
    width: min(100% - 12px, 100%);
    grid-template-columns: 76px minmax(0, 1fr);
    gap: 8px;
    padding-top: 8px;
  }

  .studio-rail {
    top: 8px;
    min-height: calc(100vh - 16px);
    padding: 9px 7px;
  }

  .rail-brand span:not(.brand-mark),
  .rail-link {
    font-size: 0;
  }

  .rail-link {
    justify-content: center;
    padding: 11px 6px;
  }

  .rail-link span {
    font-size: 0.7rem;
  }

  .brand-mark {
    width: 40px;
    height: 40px;
  }

  .system-pill,
  .ghost-link {
    display: none;
  }

  .studio-topbar,
  .panel-head,
  .preview-toolbar {
    flex-direction: column;
  }

  .studio-topbar h1 {
    font-size: 2rem;
  }

  .field-grid.two,
  .field-grid.three,
  .download-grid {
    grid-template-columns: 1fr;
  }

  .panel {
    padding: 14px;
  }

  .video-preview-shell,
  .video-preview {
    min-height: 430px;
  }
}

@media (max-width: 560px) {
  .landing-brand small,
  .landing-nav .button {
    display: none;
  }

  .hero-copy h1 {
    font-size: 4rem;
  }

  .phone-preview,
  .product-screen {
    min-height: 440px;
  }

  .studio-shell {
    grid-template-columns: 1fr;
  }

  .studio-rail {
    position: static;
    min-height: auto;
    grid-template-columns: auto 1fr;
    align-items: center;
  }

  .rail-nav {
    grid-template-columns: repeat(4, 1fr);
  }

  .video-preview-shell,
  .video-preview {
    min-height: 360px;
  }
}

/* Premium studio refresh */
.studio-body {
  background:
    linear-gradient(120deg, rgba(47, 109, 246, 0.08), transparent 32%),
    linear-gradient(180deg, #f7f9fc 0%, #eef2f7 100%);
}

.studio-shell {
  width: min(1600px, calc(100% - 24px));
  grid-template-columns: 236px minmax(0, 1fr);
  gap: 18px;
  padding: 12px 0 24px;
}

.studio-rail {
  padding: 18px 14px;
  border: 0;
  border-radius: 18px;
  color: #e7edf7;
  background:
    linear-gradient(180deg, rgba(47, 109, 246, 0.14), transparent 28%),
    #07111f;
  box-shadow: 0 26px 70px rgba(7, 17, 31, 0.24);
}

.rail-brand {
  color: #fff;
}

.rail-brand small {
  color: #8ea0bb;
}

.brand-mark {
  background: var(--panel-solid);
  color: #07111f;
  box-shadow: 0 10px 24px rgba(47, 109, 246, 0.22);
}

.rail-link {
  color: #9cadc4;
  border: 1px solid transparent;
}

.rail-link span {
  color: #61758f;
}

.rail-link.active,
.rail-link:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.08);
}

.ghost-link {
  color: #91a4bd;
}

.studio-topbar {
  min-height: 116px;
  align-items: center;
  margin-bottom: 14px;
  padding: 20px 22px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 18px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.9), rgba(246, 249, 253, 0.78)),
    #fff;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
}

.studio-topbar h1 {
  font-size: clamp(2.2rem, 3.8vw, 4rem);
  letter-spacing: -0.02em;
}

.studio-grid {
  grid-template-columns: minmax(0, 1fr) minmax(390px, 520px);
  gap: 18px;
  align-items: start;
}

.control-stack,
.preview-stack {
  gap: 14px;
}

.panel {
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.06);
  box-shadow: 0 16px 44px rgba(15, 23, 42, 0.07);
}

.panel-head {
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(15, 23, 42, 0.07);
}

.panel-number {
  display: grid;
  min-width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 999px;
  color: #1749bd;
  background: rgba(47, 109, 246, 0.1);
}

.eyeline {
  color: #1749bd;
  letter-spacing: 0.08em;
}

.field-grid {
  gap: 10px;
}

.field-grid.four {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.compact-grid {
  align-items: end;
}

.field span,
.toggle-row,
.side-note,
.field-note {
  color: var(--muted);
  font-size: 0.78rem;
}

.field input,
.field select,
.field textarea,
.upload-zone,
.copy-box {
  border-color: rgba(15, 23, 42, 0.1);
  background: var(--panel-solid);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.field input,
.field select,
.field textarea {
  min-height: 40px;
  padding: 9px 11px;
  font-size: 0.88rem;
}

.field textarea {
  min-height: 118px;
}

.upload-zone {
  position: relative;
  overflow: hidden;
  padding: 20px;
  background:
    linear-gradient(135deg, rgba(47, 109, 246, 0.12), rgba(15, 23, 42, 0.02)),
    #f8fbff;
}

.upload-zone::after {
  content: "";
  position: absolute;
  inset: 10px;
  border: 1px dashed rgba(47, 109, 246, 0.26);
  border-radius: 12px;
  pointer-events: none;
}

.button-primary {
  min-height: 48px;
  background: linear-gradient(135deg, #0f172a 0%, #1749bd 100%);
  box-shadow: 0 18px 34px rgba(23, 73, 189, 0.22);
}

.preview-panel {
  top: 12px;
  padding: 16px;
  background: #07111f;
  color: #eef4ff;
}

.preview-panel .eyeline,
.preview-panel h2 {
  color: #fff;
}

.preview-toolbar {
  align-items: center;
}

.preview-toolbar > span,
.voice-library-status {
  color: #dbeafe;
  background: rgba(47, 109, 246, 0.24);
}

.video-preview-shell {
  min-height: 650px;
  border-radius: 18px;
  border-color: rgba(255, 255, 255, 0.12);
  background:
    radial-gradient(circle at 50% 18%, rgba(47, 109, 246, 0.22), transparent 26%),
    linear-gradient(180deg, #0b1628, #050912);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.06),
    0 18px 48px rgba(0, 0, 0, 0.24);
}

.video-preview {
  min-height: 650px;
}

.preview-cover-layer {
  left: 28px;
  right: 28px;
  border-radius: 14px;
  background: rgba(2, 6, 15, 0.78);
}

.preview-subtitle {
  width: min(88%, 700px);
  gap: 6px;
}

.preview-subtitle span {
  padding: 4px 14px;
  border-radius: 10px;
  background: transparent;
}

.preview-note {
  color: #9badc7;
}

.voice-panel {
  background: rgba(255, 255, 255, 0.06);
}

.output-panel {
  background:
    linear-gradient(135deg, rgba(15, 23, 42, 0.04), transparent),
    rgba(255, 255, 255, 0.9);
}

@media (max-width: 1180px) {
  .studio-shell,
  .studio-grid,
  .field-grid.four {
    grid-template-columns: 1fr;
  }

  .preview-panel {
    position: static;
  }
}

@media (max-width: 840px) {
  .studio-shell {
    width: min(100% - 12px, 100%);
    grid-template-columns: 74px minmax(0, 1fr);
  }

  .studio-topbar {
    min-height: auto;
    padding: 16px;
  }

  .video-preview-shell,
  .video-preview {
    min-height: 430px;
  }
}

@media (max-width: 560px) {
  .studio-shell {
    grid-template-columns: 1fr;
  }

  .studio-rail {
    position: static;
    min-height: auto;
  }
}

/* Concept-match production layout */
.studio-shell {
  width: 100%;
  min-height: 100vh;
  padding: 0;
  grid-template-columns: 184px minmax(0, 1fr);
  gap: 0;
  background: #f5f7fb;
}

.studio-rail {
  top: 0;
  min-height: 100vh;
  border-radius: 0;
  padding: 18px 12px;
  background: linear-gradient(180deg, #020817 0%, #061426 100%);
  box-shadow: none;
}

.rail-brand {
  padding: 0 6px 14px;
}

.rail-brand .brand-mark {
  width: 54px;
  height: 54px;
}

.rail-nav {
  gap: 6px;
}

.rail-link {
  min-height: 40px;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 0.82rem;
}

.studio-main {
  padding: 0 14px 22px;
}

.studio-topbar {
  min-height: 64px;
  margin: 0 -14px 0;
  padding: 0 18px;
  border: 0;
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 0;
  background: rgba(255, 255, 255, 0.06);
  box-shadow: none;
}

.command-title {
  display: flex;
  align-items: center;
  gap: 14px;
}

.icon-button {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 8px;
  color: var(--ink);
  background: transparent;
  cursor: pointer;
}

.icon-button:hover {
  background: #eef3fb;
}

.studio-topbar h1 {
  font-size: 1rem;
  line-height: 1.2;
}

.studio-topbar p:last-child {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 3px 0 0;
  color: #667085;
  font-size: 0.74rem;
}

.save-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: #2563eb;
}

.workflow-steps {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  padding: 16px 0 14px;
}

.workflow-steps a {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  color: #9fb0c6;
  text-decoration: none;
}

.workflow-steps span {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  background: var(--panel-solid);
}

.workflow-steps strong,
.workflow-steps small {
  display: block;
}

.workflow-steps strong {
  color: var(--ink);
  font-size: 0.82rem;
}

.workflow-steps small {
  color: var(--muted);
  font-size: 0.72rem;
}

.workflow-steps .active span {
  border-color: #00e5ff;
  color: #050c17;
  background: #00e5ff;
  box-shadow: 0 0 10px rgba(0, 229, 255, 0.5);
}

.studio-grid {
  display: grid;
  grid-template-columns: minmax(440px, 0.95fr) minmax(560px, 1.05fr);
  grid-template-areas:
    "source preview"
    "ai encode"
    "voice output";
  gap: 12px;
}

.control-stack,
.preview-stack {
  display: contents;
}

.source-panel {
  grid-area: source;
}

.preview-panel {
  grid-area: preview;
}

.ai-panel {
  grid-area: ai;
}

.encode-panel {
  grid-area: encode;
}

.voice-panel {
  grid-area: voice;
}

.output-panel {
  grid-area: output;
}

.panel {
  padding: 16px;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
}

.panel-head {
  padding-bottom: 10px;
}

.upload-zone {
  min-height: 164px;
  place-content: center;
  text-align: center;
}

.field textarea {
  min-height: 86px;
}

.preview-panel {
  position: static;
  padding: 0;
  overflow: hidden;
  color: var(--ink);
  background: var(--panel-solid);
}

.preview-toolbar {
  padding: 14px 16px 8px;
  margin: 0;
}

.preview-panel .eyeline,
.preview-panel h2 {
  color: var(--ink);
}

.video-preview-shell {
  width: min(100%, 820px);
  min-height: 482px;
  margin: 0 auto;
  border: 0;
  border-radius: 0;
  background: var(--panel);
  box-shadow: none;
}

.video-preview {
  min-height: 482px;
  max-height: 620px;
  background: transparent;
}

.video-preview-empty {
  color: var(--ink);
}

.preview-watermark {
  top: 18px;
  right: 18px;
}

.preview-note {
  margin: 10px 16px 14px;
  color: var(--muted);
}

.voice-panel,
.output-panel {
  min-height: 170px;
}

.button-primary {
  background: #0f63ff;
  box-shadow: 0 12px 28px rgba(15, 99, 255, 0.22);
}

@media (max-width: 1180px) {
  .studio-grid {
    grid-template-columns: 1fr;
    grid-template-areas:
      "source"
      "preview"
      "ai"
      "encode"
      "voice"
      "output";
  }

  .workflow-steps {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 840px) {
  .studio-shell {
    width: 100%;
    max-width: 100%;
    grid-template-columns: 1fr;
    overflow-x: hidden;
  }

  .studio-rail {
    position: static;
    display: block;
    min-height: auto;
    border-radius: 0 0 16px 16px;
  }

  .rail-nav {
    grid-template-columns: 1fr;
  }

  .studio-main {
    width: 100%;
    min-width: 0;
    padding-inline: 10px;
  }

  .studio-topbar {
    margin-inline: -10px;
    width: auto;
    max-width: none;
  }

  .workflow-steps,
  .studio-grid,
  .panel,
  .video-preview-shell {
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }

  .workflow-steps,
  .field-grid.two,
  .field-grid.three,
  .field-grid.four {
    grid-template-columns: 1fr;
  }
}

/* Reference studio layout — Cyber Security: Cyan + Dark Navy */
.app-layout {
  --studio-rail: #030b16;
  --studio-rail-soft: #050e1c;
  --studio-blue: #00e5ff;
  --studio-border: rgba(0, 229, 255, 0.15);
  --studio-text: #d0eaf8;
  --studio-muted: #4a7090;
  grid-template-columns: 184px minmax(0, 1fr);
  background: #060d1c;
}

.app-layout .studio-rail {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 100vh;
  padding: 18px 12px;
  color: #c8e6f5;
  background:
    radial-gradient(circle at 85% 6%, rgba(0, 229, 255, 0.1), transparent 30%),
    linear-gradient(180deg, #030b16 0%, #050e1c 100%);
  border-right: 1px solid rgba(0, 229, 255, 0.1);
}

.rail-logo {
  display: grid;
  gap: 0;
  padding: 0 8px 12px;
  color: #fff;
  text-decoration: none;
  line-height: 0.82;
}

.rail-logo strong {
  font-size: 1.72rem;
  font-weight: 900;
  letter-spacing: -0.04em;
}

.rail-logo span {
  color: #00e5ff;
  font-size: 0.74rem;
  font-weight: 900;
  letter-spacing: 0.42em;
  text-shadow: 0 0 12px rgba(0, 229, 255, 0.6);
}

.app-layout .rail-nav,
.rail-tools {
  display: grid;
  gap: 5px;
}

.rail-tools {
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.09);
}

.rail-tools p {
  margin: 0 10px 8px;
  color: #6f7f95;
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.app-layout .rail-link {
  display: flex;
  min-height: 40px;
  align-items: center;
  gap: 10px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 6px;
  color: #d9e5f5;
  font-size: 0.82rem;
  font-weight: 700;
  text-decoration: none;
}

.app-layout .rail-link.active {
  background: linear-gradient(135deg, rgba(0, 229, 255, 0.18), rgba(0, 229, 255, 0.06));
  border-color: rgba(0, 229, 255, 0.4);
  color: #00e5ff;
  box-shadow: 0 0 10px rgba(0, 229, 255, 0.08);
}

.app-layout .rail-link:hover {
  background: rgba(0, 229, 255, 0.07);
  color: #a8dff0;
}

.rail-icon {
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  color: #fff;
  font-size: 0.82rem;
}

.app-layout .rail-footer {
  margin-top: auto;
  display: grid;
  gap: 10px;
}

.storage-card {
  display: grid;
  gap: 7px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.storage-card span,
.storage-card small {
  color: #b2c0d3;
  font-size: 0.76rem;
}

.storage-card strong {
  color: #fff;
  font-size: 0.78rem;
}

.storage-card i {
  display: block;
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.2);
}

.storage-card b {
  display: block;
  width: 24%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #00e5ff, #007a8a);
  box-shadow: 0 0 8px rgba(0, 229, 255, 0.5);
}

.upgrade-button {
  display: flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(0, 229, 255, 0.35);
  border-radius: 8px;
  color: #7ad8ec;
  background: rgba(0, 229, 255, 0.08);
  font-size: 0.82rem;
  font-weight: 800;
  text-decoration: none;
  transition: background 160ms ease, box-shadow 160ms ease;
}

.upgrade-button:hover {
  background: rgba(0, 229, 255, 0.16);
  box-shadow: 0 0 14px rgba(0, 229, 255, 0.15);
  color: #fff;
}

.app-layout .studio-main {
  padding: 0 16px 18px;
  overflow: hidden;
}

.app-layout .studio-topbar {
  min-height: 64px;
  margin: 0 -16px;
  padding: 0 20px;
  border-bottom: 1px solid var(--studio-border);
  background: rgba(255, 255, 255, 0.06);
}

.app-layout .command-title {
  align-items: center;
}

.app-layout .studio-topbar h1 {
  color: var(--studio-text);
  font-size: 0.98rem;
  font-weight: 800;
}

.app-layout .studio-topbar p:last-child {
  margin: 3px 0 0;
  color: #7b8799;
  font-size: 0.72rem;
}

.app-layout .topbar-actions {
  flex-wrap: nowrap;
}

.app-layout .button {
  min-height: 38px;
  padding: 0 14px;
  border-radius: 6px;
  font-size: 0.8rem;
}

.app-layout .button-muted {
  background: var(--panel-solid);
}

.shortcuts-button kbd {
  min-width: 24px;
  padding: 2px 5px;
  border: 1px solid #cbd5e1;
  border-radius: 5px;
  color: var(--muted);
  background: var(--panel);
  font-size: 0.72rem;
}

.round-action {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-left: 1px solid #dce3ee;
  color: #b8c4d6;
  background: transparent;
  cursor: pointer;
}

.notify-action {
  position: relative;
  color: #b8c4d6;
  overflow: visible;
}

.notify-action svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.notify-action span {
  position: absolute;
  right: 1px;
  top: 1px;
  display: grid;
  min-width: 19px;
  height: 19px;
  padding: 0 4px;
  place-items: center;
  border: 2px solid var(--line-strong);
  border-radius: 999px;
  color: #fff;
  background: #ef4444;
  font-size: 0.7rem;
  font-weight: 800;
  line-height: 1;
  box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.6);
  animation: notify-pulse 2s ease-out infinite;
}

.notify-action span[hidden] {
  display: none;
}

@keyframes notify-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.55); }
  70%  { box-shadow: 0 0 0 7px rgba(239, 68, 68, 0); }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.notify-action::before {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 999px;
  background: transparent;
  transition: background 160ms ease;
  z-index: -1;
}

.notify-action:hover::before {
  background: rgba(255, 255, 255, 0.08);
}

.account-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-left: 12px;
  border-left: 1px solid #dce3ee;
}

.account-chip > span {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(135deg, #111827, #99624e);
  font-size: 0.72rem;
  font-weight: 900;
}

.account-chip strong,
.account-chip small {
  display: block;
}

.account-chip strong {
  font-size: 0.78rem;
}

.account-chip small {
  color: var(--muted);
  font-size: 0.68rem;
}

.app-layout .top-create {
  min-width: 136px;
  background: #0f63ff;
}

.app-layout .workflow-steps {
  display: grid;
  grid-template-columns: repeat(4, minmax(190px, 1fr)) 160px;
  gap: 16px;
  align-items: center;
  padding: 14px 2px 16px;
}

.app-layout .workflow-steps a {
  grid-template-columns: 32px minmax(0, max-content);
  align-items: start;
}

.app-layout .workflow-steps strong,
.app-layout .workflow-steps small {
  white-space: nowrap;
}

.ratio-select {
  display: grid;
  gap: 4px;
}

.ratio-label {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.ratio-select select {
  width: 100%;
  min-height: 36px;
  border: 1px solid #cfd8e6;
  border-radius: 7px;
  color: var(--ink);
  background: var(--panel-solid);
  font-size: 0.78rem;
  font-weight: 700;
}

.studio-dashboard-grid {
  grid-template-columns: minmax(430px, 0.96fr) minmax(520px, 1.04fr);
  grid-template-areas:
    "source preview"
    "ai preview"
    "encode encode"
    "output output"
    "voice voice";
  gap: 12px 14px;
}

.studio-dashboard-grid .source-panel {
  grid-area: source;
}

.studio-dashboard-grid .preview-panel {
  grid-area: preview;
}

.studio-dashboard-grid .ai-panel {
  grid-area: ai;
}

.studio-dashboard-grid .encode-panel {
  grid-area: encode;
}

.studio-dashboard-grid .output-panel {
  grid-area: output;
}

.studio-dashboard-grid .voice-panel {
  grid-area: voice;
}

.app-layout .panel {
  padding: 14px;
  border: 1px solid var(--studio-border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  box-shadow: none;
}

.compact-head {
  padding-bottom: 8px;
  border-bottom: 0;
}

.compact-head h2,
.app-layout .preview-toolbar h2 {
  font-size: 0.98rem;
}

.app-layout .eyeline {
  margin-bottom: 6px;
  color: #0e4fd6;
  font-size: 0.68rem;
}

.pro-upload {
  min-height: 120px;
  margin-top: 8px;
  align-items: center;
  justify-items: center;
  gap: 5px;
  border-style: dashed;
  text-align: center;
  background: linear-gradient(180deg, #fbfdff, #f7faff);
}

.pro-upload::after {
  display: none;
}

.upload-cloud {
  color: #11243e;
  font-size: 1.25rem;
  letter-spacing: 0;
  text-transform: none;
}

.pro-upload strong {
  color: #748199;
  font-size: 0.8rem;
  font-weight: 600;
}

.pro-upload em {
  padding: 8px 14px;
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  color: var(--ink);
  background: var(--panel-solid);
  font-style: normal;
  font-size: 0.78rem;
  font-weight: 800;
}

.telegram-upload-box {
  margin-top: 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.telegram-upload-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--ink);
}

.telegram-upload-hint {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.74rem;
}

.telegram-upload-hint a {
  color: inherit;
  text-decoration: underline;
}

.telegram-code-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.telegram-code-row input {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-solid);
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.telegram-code-row input::placeholder {
  color: var(--muted);
  letter-spacing: normal;
  text-transform: none;
  font-weight: 600;
}

.telegram-code-row button {
  flex-shrink: 0;
  padding: 8px 14px;
  font-size: 0.74rem;
}

.telegram-upload-result[hidden] {
  display: none;
}

.telegram-upload-result {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-solid);
  font-size: 0.78rem;
}

.telegram-upload-result.error {
  border-color: rgba(225, 29, 72, 0.45);
  color: #ffb4c2;
}

.telegram-upload-result .telegram-result-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.telegram-upload-result .telegram-result-meta strong {
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.telegram-upload-result .telegram-result-meta small {
  color: var(--muted);
  font-size: 0.7rem;
}

.telegram-upload-result .telegram-result-clear {
  flex-shrink: 0;
  padding: 3px 8px;
  font-size: 0.85rem;
  line-height: 1.4;
}

.app-layout .field span {
  color: #26364f;
  font-size: 0.72rem;
  font-weight: 800;
}

.app-layout .field input,
.app-layout .field select,
.app-layout .field textarea {
  min-height: 34px;
  border-color: #cfd8e6;
  border-radius: 6px;
  color: var(--ink);
  font-size: 0.76rem;
}

.app-layout .field textarea {
  min-height: 58px;
}

.app-layout .field-grid {
  gap: 8px;
  margin-top: 8px;
}

.app-layout .preview-panel {
  padding: 0;
  overflow: hidden;
}

.pro-preview-toolbar {
  position: absolute;
  z-index: 4;
  width: 100%;
  padding: 12px;
  pointer-events: none;
}

.segmented-control {
  display: inline-flex;
  padding: 2px;
  border: 1px solid #ccd6e4;
  border-radius: 6px;
  background: #edf2f8;
  pointer-events: auto;
}

.segmented-control button {
  min-width: 56px;
  height: 28px;
  border-radius: 5px;
  color: #b8c4d6;
  background: transparent;
  font-size: 0.76rem;
  font-weight: 800;
  cursor: pointer;
}

.segmented-control .active {
  color: #0f63ff;
  background: var(--panel-solid);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
}

.pro-preview-toolbar p {
  margin: 0;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
}

.video-stage {
  display: grid;
  min-height: 462px;
  place-items: center;
  padding: 8px 24px 0;
  background: linear-gradient(180deg, var(--panel-solid), var(--bg));
}

.phone-frame {
  position: relative;
  width: min(236px, 48vw);
  min-height: 0;
  aspect-ratio: 9 / 16;
  overflow: hidden;
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% 25%, rgba(15, 99, 255, 0.22), transparent 28%),
    linear-gradient(145deg, #121923, #333b45);
  box-shadow: 0 18px 42px rgba(15, 23, 42, 0.22);
}

.phone-frame .video-preview {
  width: 100%;
  height: 100%;
  min-height: 0;
  max-height: none;
  object-fit: cover;
  background: transparent;
}

.phone-notch {
  position: absolute;
  top: 9px;
  left: 50%;
  width: 68px;
  height: 18px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.74);
  transform: translateX(-50%);
  pointer-events: none;
}

.phone-frame .preview-cover-layer {
  left: 14px;
  right: 14px;
  border-radius: 6px;
}

.movie-watermark {
  top: 18px;
  right: 16px;
  padding: 0;
  border-radius: 0;
  color: #fff;
  background: transparent;
  font-size: 0.78rem;
  line-height: 0.9;
  text-align: right;
}

.movie-watermark::first-line {
  font-size: 1rem;
}

.phone-frame .preview-subtitle {
  width: min(88%, 320px);
  font-size: 22px;
}

.phone-frame .preview-subtitle span {
  padding: 4px 12px;
  border-radius: 6px;
  background: transparent;
}

.phone-frame .video-preview-empty {
  color: #fff;
  background: rgba(15, 23, 42, 0.42);
}

.video-preview-shell.is-empty .preview-cover-layer,
.video-preview-shell.is-empty .preview-watermark {
  display: none !important;
}

.preview-note {
  margin: 0;
  padding: 10px 14px;
  border-top: 1px solid #dbe3ee;
  color: var(--muted);
  font-size: 0.72rem;
}

.voice-card {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 8px;
  padding: 10px;
  border: 1px solid #d6dfeb;
  border-radius: 7px;
  background: var(--panel-solid);
}

.avatar-dot {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(135deg, #182337, #0f63ff);
  font-size: 0.7rem;
  font-weight: 900;
}

.voice-card strong,
.voice-card small {
  display: block;
}

.voice-card strong {
  font-size: 0.86rem;
}

.voice-card small {
  color: #697991;
  font-size: 0.72rem;
}

.ai-controls.field-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.sr-row {
  margin-top: 10px;
}

.setting-columns {
  display: grid;
  grid-template-columns: 1.05fr 1fr 1fr;
  gap: 16px;
}

.setting-columns > section {
  min-width: 0;
  padding-right: 16px;
  border-right: 1px solid #dce4ef;
}

.setting-columns > section:last-child {
  padding-right: 0;
  border-right: 0;
}

.switch-row {
  margin-bottom: 10px;
}

.switch-row input[type="checkbox"] {
  width: 34px;
  height: 20px;
  appearance: none;
  border-radius: 999px;
  background: #cbd5e1;
  cursor: pointer;
  transition: background 150ms ease;
}

.switch-row input[type="checkbox"]::before {
  content: "";
  display: block;
  width: 16px;
  height: 16px;
  margin: 2px;
  border-radius: 999px;
  background: var(--panel-solid);
  transition: transform 150ms ease;
}

.switch-row input[type="checkbox"]:checked {
  background: #0f63ff;
}

.switch-row input[type="checkbox"]:checked::before {
  transform: translateX(14px);
}

/* Output panel — recent exports */
.output-panel {
  position: relative;
}

.output-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.output-header h2 {
  margin: 0 0 4px;
  font-size: 1rem;
}

.output-sub {
  margin: 0;
  color: var(--muted);
  font-size: 0.76rem;
}

/* Encode info panel (floating overlay) */
.encode-info-panel {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 10;
  width: 260px;
  border: 1px solid #d8e0ec;
  border-radius: 8px;
  background: var(--panel-solid);
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.13);
  overflow: hidden;
}

.encode-info-panel[hidden] {
  display: none;
}

.encode-info-inner {
  padding: 14px;
}

.encode-info-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--ink);
}

.encode-close {
  padding: 4px 10px;
  border: 1px solid #d0d9e6;
  border-radius: 6px;
  color: #b8c4d6;
  background: #f6f8fb;
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
}

.encode-close:hover {
  background: var(--panel);
}

.encode-specs {
  display: grid;
  gap: 8px;
  margin: 0;
}

.encode-specs > div {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.encode-specs dt {
  color: var(--muted);
  font-size: 0.76rem;
}

.encode-specs dd {
  margin: 0;
  color: #b8c4d6;
  font-size: 0.76rem;
  font-weight: 800;
  text-align: right;
}

/* Export cards grid */
.exports-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.export-card {
  position: relative;
  border: 1px solid #dce4ef;
  border-radius: 8px;
  overflow: hidden;
  background: var(--panel-solid);
  cursor: pointer;
  transition: box-shadow 160ms ease, border-color 160ms ease;
}

.export-card:hover {
  border-color: rgba(15, 99, 255, 0.36);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.1);
}

.export-thumb {
  position: relative;
  aspect-ratio: 9 / 16;
  background: linear-gradient(160deg, #0c1e38 0%, #1a3558 60%, #0a1628 100%);
  overflow: hidden;
}

.export-thumb-label {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: rgba(255, 255, 255, 0.55);
  font-size: 1.5rem;
  font-weight: 900;
  letter-spacing: -0.02em;
}

.export-thumb-label small {
  color: rgba(255, 255, 255, 0.35);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.export-thumb img,
.export-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.export-badge {
  position: absolute;
  top: 7px;
  left: 7px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.export-badge.expired {
  color: var(--muted);
  background: rgba(226, 232, 240, 0.92);
}

.export-badge.pending {
  color: #0e7a57;
  background: rgba(16, 185, 129, 0.16);
}

.export-badge.ready {
  color: #1749bd;
  background: rgba(47, 109, 246, 0.14);
}

.export-action {
  position: absolute;
  bottom: 7px;
  right: 7px;
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 999px;
  border: 0;
  color: #fff;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  backdrop-filter: blur(6px);
}

.export-action.delete {
  background: rgba(30, 40, 60, 0.72);
}

.export-action.delete:hover {
  background: rgba(219, 51, 72, 0.82);
}

.export-action.download {
  background: rgba(15, 99, 255, 0.82);
}

.export-action.download:hover {
  background: rgba(15, 99, 255, 1);
}

.export-meta {
  padding: 8px 10px;
}

.export-ratio {
  color: var(--ink);
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1.2;
}

.export-ratio small {
  display: block;
  color: #8898ae;
  font-size: 0.64rem;
  font-weight: 600;
}

.export-date {
  margin-top: 3px;
  color: #8898ae;
  font-size: 0.64rem;
}

.export-card-empty {
  grid-column: 1 / -1;
  padding: 28px 20px;
  text-align: center;
  color: #8898ae;
  border: 1px dashed rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.export-card-empty span {
  display: block;
  margin-bottom: 6px;
  color: #c8d8f0;
  font-size: 0.88rem;
  font-weight: 800;
}

.export-card-empty p {
  margin: 0;
  font-size: 0.78rem;
}

/* Dark mode overrides for export cards — Cyber */
.theme-dark .export-card {
  border-color: rgba(0, 229, 255, 0.14);
  background: #0c1929;
}

.theme-dark .export-card-empty {
  border-color: rgba(0, 229, 255, 0.1);
  background: #081422;
  color: #4a7090;
}

.theme-dark .encode-info-panel {
  border-color: rgba(0, 229, 255, 0.18);
  background: #0c1929;
  color: #d0eaf8;
}

.theme-dark .encode-info-head {
  color: #e8f6ff;
}

.theme-dark .encode-specs dt {
  color: #4a7090;
}

.theme-dark .encode-specs dd {
  color: #9ecde4;
}

.theme-dark .encode-close {
  border-color: rgba(0, 229, 255, 0.2);
  color: #7abdd4;
  background: #0d1e35;
}

@media (max-width: 840px) {
  .exports-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .encode-info-panel {
    position: fixed;
    top: auto;
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    border-radius: 14px 14px 0 0;
  }
}

@media (max-width: 480px) {
  .exports-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.voice-panel {
  display: none;
}

.feature-panel {
  margin-bottom: 12px;
  padding: 14px;
  border: 1px solid var(--studio-border);
  border-radius: 8px;
  background: var(--panel-solid);
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.08);
}

.feature-panel[hidden] {
  display: none;
}

.feature-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid #dce4ef;
}

.feature-panel-head h2 {
  margin: 0;
  font-size: 1.2rem;
}

.feature-panel-head p:last-child {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.feature-panel-body {
  padding-top: 12px;
}

.feature-cards,
.template-grid {
  display: grid;
  gap: 10px;
}

.feature-cards.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.feature-cards.three,
.template-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.feature-cards.four {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.feature-card,
.template-card {
  display: grid;
  gap: 7px;
  min-height: 92px;
  padding: 12px;
  border: 1px solid #d8e0ec;
  border-radius: 8px;
  background: var(--panel);
  text-align: left;
}

.template-card {
  cursor: pointer;
}

.template-card:hover,
.feature-card:hover {
  border-color: rgba(15, 99, 255, 0.44);
  box-shadow: 0 10px 22px rgba(15, 99, 255, 0.08);
}

.feature-card span,
.template-card span,
.feature-card small,
.feature-note {
  color: var(--muted);
  font-size: 0.76rem;
}

.feature-card strong,
.template-card strong {
  color: var(--ink);
  font-size: 0.92rem;
}

.feature-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.feature-actions + .feature-list {
  margin-top: 14px;
}

.notification-item {
  position: relative;
}

.notification-item small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.74rem;
}

.notification-item.unread {
  border-color: rgba(15, 99, 255, 0.4);
}

.notification-item.unread::before {
  content: "";
  position: absolute;
  top: 20px;
  left: -7px;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #0f63ff;
}

.shortcut-list {
  display: grid;
  gap: 8px;
}

.shortcut-list p {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: #b8c4d6;
}

.shortcut-list kbd {
  min-width: 32px;
  padding: 4px 8px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: var(--panel);
  text-align: center;
  font-size: 0.74rem;
  font-weight: 800;
}

.panel-highlight {
  animation: panelPulse 1.1s ease;
}

@keyframes panelPulse {
  0%,
  100% {
    box-shadow: none;
  }

  45% {
    border-color: rgba(15, 99, 255, 0.6);
    box-shadow: 0 0 0 4px rgba(15, 99, 255, 0.14);
  }
}

.rail-collapsed .app-layout {
  grid-template-columns: 72px minmax(0, 1fr);
}

.rail-collapsed .rail-logo span,
.rail-collapsed .app-layout .rail-link,
.rail-collapsed .rail-tools p,
.rail-collapsed .upgrade-button {
  font-size: 0;
}

.rail-collapsed .storage-card {
  display: none;
}

.upgrade-icon { display: none; }
.upgrade-text { display: inline; }
.rail-collapsed .upgrade-button {
  font-size: 1.4rem !important;
  padding: 8px !important;
  text-align: center !important;
  justify-content: center !important;
  display: flex !important;
}
.rail-collapsed .upgrade-text { display: none; }
.rail-collapsed .upgrade-icon { display: inline; }

.storage-card strong,
.storage-card small,
.storage-card span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

.rail-collapsed .rail-logo strong {
  font-size: 1.1rem;
}

.rail-collapsed .app-layout .rail-link {
  justify-content: center;
  padding: 0;
}

/* ── Cyber Security Dark Theme ── */
body.theme-dark {
  background: #050c17;
  color: #d0eaf8;
}

.theme-dark .app-layout {
  background:
    radial-gradient(ellipse at 15% 0%, rgba(0, 229, 255, 0.04), transparent 40%),
    #060d1c;
}

.theme-dark .app-layout .studio-topbar,
.theme-dark .feature-panel,
.theme-dark .app-layout .panel {
  border-color: rgba(0, 229, 255, 0.14);
  background: #0c1929;
  color: #d0eaf8;
}

.theme-dark .app-layout .studio-topbar h1,
.theme-dark .feature-card strong,
.theme-dark .template-card strong,
.theme-dark .compact-head h2,
.theme-dark .encode-summary h3 {
  color: #e8f6ff;
}

.theme-dark .feature-card,
.theme-dark .template-card,
.theme-dark .voice-card,
.theme-dark .app-layout .field input,
.theme-dark .app-layout .field select,
.theme-dark .app-layout .field textarea,
.theme-dark .ratio-select select,
.theme-dark .app-layout .button-muted {
  border-color: rgba(0, 229, 255, 0.14);
  color: #d0eaf8;
  background: #091422;
}

/* Progress / result / download cards default to a light-theme white background
   (rgba(255,255,255,.62)) which left light text unreadable in dark mode. Give
   them dark surfaces with high-contrast text. */
.theme-dark .progress-shell,
.theme-dark .result-card,
.theme-dark .progress-step,
.theme-dark .voice-item,
.theme-dark .download-card {
  background: #0c1929;
  border-color: rgba(0, 229, 255, 0.14);
  color: #d0eaf8;
}
.theme-dark .progress-shell h2,
.theme-dark .progress-step strong,
.theme-dark .result-card strong,
.theme-dark .result-hero h2,
.theme-dark .download-card strong {
  color: #e8f6ff;
}
.theme-dark .progress-shell p,
.theme-dark .progress-step span,
.theme-dark .result-card p,
.theme-dark .result-hero p,
.theme-dark .download-card span,
.theme-dark .side-note {
  color: #9fc0d4;
}
.theme-dark .progress-step.active {
  background: rgba(47, 109, 246, 0.20);
  border-color: rgba(0, 229, 255, 0.45);
}
.theme-dark .progress-step.complete {
  border-color: rgba(15, 159, 122, 0.45);
}
.theme-dark .progress-meter {
  background: rgba(0, 229, 255, 0.10);
}
.theme-dark .error-card {
  background: rgba(219, 51, 72, 0.16);
  border-color: rgba(219, 51, 72, 0.5);
  color: #ffd9de;
}
.theme-dark .warning-box {
  background: rgba(240, 107, 53, 0.16);
  border-color: rgba(240, 107, 53, 0.5);
  color: #ffe3d4;
}

.theme-dark .app-layout .field input:focus,
.theme-dark .app-layout .field textarea:focus,
.theme-dark .app-layout .field select:focus {
  border-color: rgba(0, 229, 255, 0.45);
  box-shadow: 0 0 0 3px rgba(0, 229, 255, 0.07);
  outline: none;
}

.theme-dark .app-layout .field input::placeholder,
.theme-dark .app-layout .field textarea::placeholder {
  color: #2a4a62;
}

.theme-dark .app-layout .button-primary {
  background: linear-gradient(135deg, #005566, #007a8a 48%, #009bae);
  box-shadow: 0 8px 24px rgba(0, 229, 255, 0.18);
}

.theme-dark .app-layout .button-primary:hover {
  box-shadow: 0 12px 32px rgba(0, 229, 255, 0.28);
}

.theme-dark .account-chip {
  background: rgba(0, 229, 255, 0.07);
  border: 1px solid rgba(0, 229, 255, 0.2);
  border-radius: 8px;
  padding: 6px 10px;
}

.theme-dark .video-stage {
  background: linear-gradient(180deg, #0c1929, #060d1c);
}

.theme-dark .feature-panel-head {
  border-bottom-color: rgba(0, 229, 255, 0.12);
}

.theme-dark .feature-panel-head p:last-child {
  color: #4a7090;
}

.theme-dark .rail-tools {
  border-top-color: rgba(0, 229, 255, 0.1);
}

.theme-dark .rail-tools p {
  color: #00e5ff;
  opacity: 0.5;
}

.theme-dark .round-action {
  border-left-color: rgba(0, 229, 255, 0.1);
  color: #7abdd4;
}

.theme-dark .round-action:hover {
  color: #00e5ff;
}

.theme-dark .notify-action span {
  border-color: #060d1c;
}

.theme-dark .account-chip {
  border-left-color: rgba(0, 229, 255, 0.12);
}

.theme-dark .account-chip > span {
  background: linear-gradient(135deg, #003344, #005566);
  color: #00e5ff;
  box-shadow: 0 0 10px rgba(0, 229, 255, 0.2);
}

.theme-dark .account-chip strong {
  color: #d0eaf8;
}

.theme-dark .account-chip small {
  color: #4a7090;
}

.theme-dark .workflow-steps a {
  color: #4a7090;
}

.theme-dark .workflow-steps a.active {
  color: #d0eaf8;
}

.theme-dark .workflow-steps .active span {
  border-color: #00e5ff;
  color: #050c17;
  background: #00e5ff;
}

.theme-dark .workflow-steps a:not(.active) span {
  border-color: rgba(0, 229, 255, 0.2);
  color: #4a7090;
  background: rgba(0, 229, 255, 0.04);
}

.theme-dark .button-muted {
  border: 1px solid rgba(0, 229, 255, 0.2);
  color: #7abdd4;
  background: rgba(0, 229, 255, 0.06);
}

.theme-dark .button-muted:hover {
  background: rgba(0, 229, 255, 0.12);
  color: #00e5ff;
}

.theme-dark .app-layout .studio-topbar p {
  color: #4a7090;
}

.theme-dark .upload-zone {
  border-color: rgba(0, 229, 255, 0.2);
  background: rgba(0, 229, 255, 0.03);
  color: #4a7090;
}

.theme-dark .upload-zone:hover {
  border-color: rgba(0, 229, 255, 0.4);
  background: rgba(0, 229, 255, 0.06);
}

.theme-dark .panel-head {
  border-bottom-color: rgba(0, 229, 255, 0.1);
}

.theme-dark .eyeline {
  color: #00e5ff;
  opacity: 0.6;
}

.theme-dark .save-dot {
  background: #00e5ff;
  box-shadow: 0 0 6px rgba(0, 229, 255, 0.6);
}

.phone-frame.is-wide {
  width: min(520px, 82vw);
  aspect-ratio: 16 / 9;
}

/* Admin panel */
.admin-body {
  min-height: 100vh;
  background: #f5f7fb;
}

.admin-shell {
  display: grid;
  min-height: 100vh;
  grid-template-columns: 220px minmax(0, 1fr);
}

.admin-rail {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 20px 14px;
  color: #fff;
  background: linear-gradient(180deg, #020817, #071629);
}

.admin-nav {
  display: grid;
  gap: 6px;
}

.admin-nav a {
  padding: 11px 12px;
  border-radius: 7px;
  color: #dbe7f7;
  font-size: 0.88rem;
  font-weight: 800;
  text-decoration: none;
}

.admin-nav a:hover {
  background: rgba(255, 255, 255, 0.08);
}

.admin-price-card {
  display: grid;
  gap: 8px;
  margin-top: auto;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.admin-price-card span,
.admin-price-card small {
  color: #aebdd3;
  font-size: 0.78rem;
}

.admin-main {
  display: grid;
  gap: 14px;
  align-content: start;
  padding: 18px;
}

.admin-topbar,
.admin-panel,
.admin-stat {
  border: 1px solid #d8e0ec;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.admin-topbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  padding: 18px;
}

.admin-topbar h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.4rem);
  line-height: 0.95;
}

.admin-topbar p:last-child {
  max-width: 680px;
  margin: 10px 0 0;
  color: var(--muted);
}

.admin-pin {
  display: grid;
  gap: 7px;
  min-width: 260px;
  color: #b8c4d6;
  font-size: 0.78rem;
  font-weight: 800;
}

.admin-pin input {
  min-height: 40px;
  border: 1px solid #cfd8e6;
  border-radius: 7px;
  padding: 8px 10px;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.admin-stat {
  display: grid;
  gap: 8px;
  padding: 16px;
}

.admin-stat span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.admin-stat strong {
  color: var(--ink);
  font-size: 1.55rem;
}

.admin-panels {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  gap: 14px;
}

.admin-panel {
  padding: 16px;
}

.admin-panel-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 12px;
}

.admin-panel-head h2 {
  margin: 0;
  font-size: 1.1rem;
}

.admin-panel-head > span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.admin-form {
  display: grid;
  gap: 10px;
}

.price-grid {
  display: grid;
  gap: 10px;
}

.price-card {
  display: grid;
  gap: 6px;
  padding: 13px;
  border: 1px solid #d8e0ec;
  border-radius: 8px;
  background: var(--panel);
}

.price-card span,
.price-card small {
  color: var(--muted);
  font-size: 0.76rem;
}

.price-card strong {
  color: #0f63ff;
  font-size: 1.45rem;
}

.price-card p {
  margin: 0;
  color: var(--ink);
  font-weight: 800;
}

.admin-table-wrap {
  overflow-x: auto;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

.admin-table th,
.admin-table td {
  padding: 12px 10px;
  border-bottom: 1px solid #e2e8f0;
  text-align: left;
  vertical-align: top;
  font-size: 0.82rem;
}

.admin-table th {
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.admin-table td span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.74rem;
}

.admin-table mark {
  display: inline-flex;
  padding: 4px 8px;
  border-radius: 999px;
  background: #e2e8f0;
  color: #b8c4d6;
  font-weight: 800;
}

.admin-table .status-pending {
  color: #9a3412;
  background: #ffedd5;
}

.admin-table .status-approved {
  color: #047857;
  background: #d1fae5;
}

.admin-table .status-rejected {
  color: #be123c;
  background: #ffe4e6;
}

.mini-action {
  min-height: 30px;
  margin: 0 5px 5px 0;
  padding: 0 10px;
  border-radius: 6px;
  color: #fff;
  background: #0f63ff;
  font-weight: 800;
  cursor: pointer;
}

.mini-action.reject {
  background: #e11d48;
}

.ledger-list {
  display: grid;
  gap: 8px;
}

.ledger-list article {
  display: grid;
  gap: 4px;
  padding: 11px;
  border: 1px solid #e2e8f0;
  border-radius: 7px;
  background: var(--panel);
}

.ledger-list span,
.ledger-list small,
.muted {
  color: var(--muted);
  font-size: 0.78rem;
}

.admin-toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: 360px;
  padding: 13px 16px;
  border-radius: 8px;
  color: #fff;
  background: #0f766e;
  box-shadow: 0 16px 38px rgba(15, 23, 42, 0.18);
  font-weight: 800;
}

.admin-toast.is-error {
  background: #be123c;
}

@media (max-width: 980px) {
  .admin-shell,
  .admin-panels,
  .admin-grid {
    grid-template-columns: 1fr;
  }

  .admin-rail {
    min-height: auto;
  }

  .admin-topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .admin-pin {
    min-width: 0;
  }
}

@media (max-width: 640px) {
  .admin-body {
    overflow-x: hidden;
  }

  .admin-shell {
    display: block;
    width: 100%;
  }

  .admin-rail {
    position: sticky;
    top: 0;
    z-index: 20;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 10px;
    padding: 10px;
  }

  .admin-rail .rail-logo {
    align-self: center;
  }

  .admin-nav {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .admin-nav::-webkit-scrollbar {
    display: none;
  }

  .admin-nav a {
    flex: 0 0 auto;
    min-height: 36px;
    padding: 9px 12px;
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.06);
    white-space: nowrap;
  }

  .admin-price-card {
    display: none;
  }

  .admin-main {
    width: 100%;
    min-width: 0;
    padding: 10px;
    gap: 10px;
  }

  .admin-topbar {
    padding: 14px;
    overflow: hidden;
  }

  .admin-topbar h1 {
    font-size: 2.25rem;
  }

  .admin-topbar p:last-child {
    max-width: 100%;
    font-size: 0.9rem;
  }

  .admin-grid,
  .admin-panels,
  .price-grid,
  .admin-form .field-grid.two,
  .admin-form .field-grid.three {
    grid-template-columns: 1fr;
  }

  .admin-panel,
  .admin-stat {
    min-width: 0;
    padding: 14px;
  }

  .admin-panel-head {
    flex-direction: column;
  }

  .admin-table {
    min-width: 680px;
  }

  .admin-table-wrap {
    margin: 0 -4px;
    padding-bottom: 4px;
    overflow-x: auto;
  }
}

/* ACT Movie premium Blu-ray theme from approved concept */
.app-layout {
  --studio-rail: #020817;
  --studio-rail-soft: #061a33;
  --studio-blue: #126fff;
  --studio-cyan: #38bdf8;
  --studio-border: #d8e5f6;
  --studio-text: #0f172a;
  --studio-muted: #64748b;
  background:
    radial-gradient(circle at 82% 0%, rgba(56, 189, 248, 0.14), transparent 34%),
    linear-gradient(180deg, #0f1828 0%, #101a2b 48%, #0d1626 100%);
}

.app-layout .studio-rail {
  background:
    radial-gradient(circle at 78% 5%, rgba(56, 189, 248, 0.22), transparent 27%),
    radial-gradient(circle at 20% 46%, rgba(18, 111, 255, 0.16), transparent 28%),
    linear-gradient(180deg, #020817 0%, #061a33 58%, #020817 100%);
  box-shadow: inset -1px 0 rgba(56, 189, 248, 0.12), 18px 0 44px rgba(15, 23, 42, 0.08);
}

.rail-logo strong {
  letter-spacing: -0.055em;
}

.rail-logo span {
  color: var(--studio-cyan);
  text-shadow: 0 0 18px rgba(56, 189, 248, 0.44);
}

.app-layout .rail-link {
  border-radius: 8px;
  color: #dbeafe;
}

.app-layout .rail-link.active {
  color: #fff;
  background:
    linear-gradient(135deg, rgba(18, 111, 255, 0.92), rgba(18, 111, 255, 0.36)),
    rgba(255, 255, 255, 0.04);
  border-color: rgba(56, 189, 248, 0.46);
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.12), 0 16px 34px rgba(18, 111, 255, 0.26);
}

.app-layout .rail-link:hover {
  color: #fff;
  border-color: rgba(56, 189, 248, 0.25);
  background: rgba(255, 255, 255, 0.08);
}

.storage-card {
  border-color: rgba(56, 189, 248, 0.18);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.035));
}

.storage-card b {
  background: linear-gradient(90deg, #126fff, #38bdf8);
}

.upgrade-button {
  border-color: rgba(15, 99, 255, 0.5);
  background: rgba(15, 99, 255, 0.18);
  color: #c8d8f5;
}

.app-layout .studio-main {
  background: transparent;
}

.app-layout .studio-topbar {
  border-color: rgba(15, 23, 42, 0.08);
  background: rgba(248, 251, 255, 0.88);
  backdrop-filter: blur(18px);
}

.app-layout .studio-topbar h1 {
  color: #07111f;
  letter-spacing: -0.02em;
}

.app-layout .button {
  border-radius: 8px;
}

.app-layout .button-primary,
.app-layout .top-create {
  color: #fff;
  background: linear-gradient(180deg, #1877ff, #0b55db);
  box-shadow: 0 18px 34px rgba(18, 111, 255, 0.26);
}

.app-layout .button-muted,
.app-layout .field input,
.app-layout .field select,
.app-layout .field textarea,
.ratio-select select {
  border-color: #d6e3f5;
  background: var(--panel-solid);
}

.round-action,
.account-chip {
  border-color: #dbe7f7;
}

.account-chip > span {
  background: linear-gradient(135deg, #0f172a, #263753);
}

.app-layout .workflow-steps {
  grid-template-columns: repeat(4, minmax(160px, 1fr)) 150px;
  gap: 12px;
}

.app-layout .workflow-steps a {
  min-height: 54px;
  padding: 6px 8px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
}

.app-layout .workflow-steps a:hover,
.app-layout .workflow-steps a.active {
  border-color: #d8e5f6;
  background: rgba(255, 255, 255, 0.06);
}

.app-layout .workflow-steps span {
  color: var(--ink);
  border-color: #cbd9ee;
  background: var(--panel-solid);
}

.app-layout .workflow-steps .active span {
  color: #fff;
  border-color: var(--studio-blue);
  background: var(--studio-blue);
  box-shadow: 0 10px 22px rgba(18, 111, 255, 0.22);
}

.studio-dashboard-grid {
  grid-template-columns: minmax(360px, 0.98fr) minmax(330px, 0.9fr) minmax(360px, 1.02fr);
  grid-template-areas:
    "source ai preview"
    "source encode preview"
    "output output voice";
  gap: 14px;
  align-items: stretch;
}

.app-layout .panel,
.feature-panel {
  border: 1px solid rgba(165, 184, 212, 0.52);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  box-shadow: 0 18px 44px rgba(15, 23, 42, 0.055);
}

.app-layout .panel:hover {
  border-color: rgba(18, 111, 255, 0.22);
}

.app-layout .eyeline {
  color: var(--studio-blue);
  letter-spacing: 0.09em;
}

.compact-head h2,
.app-layout .preview-toolbar h2 {
  color: #0b1220;
  letter-spacing: -0.02em;
}

.pro-upload {
  border-color: rgba(18, 111, 255, 0.24);
  background:
    radial-gradient(circle at 50% 38%, rgba(56, 189, 248, 0.08), transparent 34%),
    linear-gradient(180deg, #fcfdff, #f7fbff);
}

.pro-upload:hover {
  border-color: rgba(18, 111, 255, 0.48);
  box-shadow: 0 14px 32px rgba(18, 111, 255, 0.08);
}

.upload-cloud {
  color: #14315a;
}

.voice-card,
.setting-columns > section,
.encode-summary,
.output-card,
.feature-card,
.template-card {
  border-color: #d8e5f6;
  background: rgba(255, 255, 255, 0.06);
}

.toggle-row input:checked,
.switch-row input:checked {
  accent-color: var(--studio-blue);
}

.segmented-control {
  border-color: #cfddef;
  background: #edf5ff;
}

.segmented-control .active {
  color: var(--studio-blue);
}

.video-stage {
  min-height: 520px;
  background:
    radial-gradient(circle at 50% 8%, rgba(18, 111, 255, 0.08), transparent 28%),
    linear-gradient(180deg, #ffffff, #0f1828);
}

.phone-frame {
  width: min(292px, 48vw);
  border-radius: 16px;
  box-shadow: 0 26px 64px rgba(15, 23, 42, 0.24);
}

.phone-frame::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
}

.phone-notch {
  top: 10px;
  background: rgba(0, 0, 0, 0.82);
}

.movie-watermark {
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.56);
}

.phone-frame .preview-cover-layer {
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.68);
}

.preview-subtitle {
  text-shadow:
    0 2px 0 rgba(0, 0, 0, 0.94),
    -1px -1px 0 rgba(0, 0, 0, 0.78),
    1px -1px 0 rgba(0, 0, 0, 0.78),
    -1px 1px 0 rgba(0, 0, 0, 0.78),
    1px 1px 0 rgba(0, 0, 0, 0.78);
}

@media (max-width: 1280px) {
  .studio-dashboard-grid {
    grid-template-columns: minmax(0, 1fr) minmax(360px, 0.95fr);
    grid-template-areas:
      "source preview"
      "ai preview"
      "encode preview"
      "output output"
      "voice voice";
  }

  .video-stage {
    min-height: 480px;
  }
}

@media (max-width: 640px) {
  .app-layout {
    background:
      radial-gradient(circle at 86% 0%, rgba(56, 189, 248, 0.16), transparent 42%),
      linear-gradient(180deg, #0f1828 0%, #101a2b 100%);
  }

  .app-layout .studio-rail {
    background:
      radial-gradient(circle at 50% 3%, rgba(56, 189, 248, 0.22), transparent 30%),
      linear-gradient(180deg, #020817, #061a33 58%, #020817);
  }

  .app-layout .studio-main {
    padding: 0 9px 18px;
  }

  .app-layout .studio-topbar {
    background: rgba(248, 251, 255, 0.94);
  }

  .app-layout .workflow-steps a {
    flex-basis: 132px;
  }

  .studio-dashboard-grid {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "source"
      "preview"
      "ai"
      "encode"
      "output"
      "voice";
  }

  .app-layout .panel,
  .feature-panel:not([hidden]) {
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.06);
  }

  .video-stage {
    min-height: auto;
    padding-top: 46px;
  }

  .phone-frame {
    width: min(282px, calc(100vw - 104px));
    border-radius: 14px;
  }
}

/* Highest-priority concept layout pass */
@media (min-width: 1281px) {
  .app-layout .studio-dashboard-grid {
    display: grid;
    grid-template-columns: minmax(360px, 0.98fr) minmax(330px, 0.9fr) minmax(360px, 1.02fr) !important;
    grid-template-areas:
      "source ai preview"
      "source encode preview"
      "output output voice" !important;
    gap: 14px;
  }
}

@media (min-width: 901px) and (max-width: 1280px) {
  .app-layout .studio-dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(360px, 0.92fr) !important;
    grid-template-areas:
      "source preview"
      "ai preview"
      "encode preview"
      "output output"
      "voice voice" !important;
    gap: 14px;
  }
}

@media (min-width: 901px) {
  .app-layout .preview-panel {
    min-height: 100%;
  }

  .app-layout .video-stage {
    min-height: 520px;
  }
}

@media (max-width: 900px) {
  .app-layout .studio-dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) !important;
    grid-template-areas:
      "source"
      "preview"
      "ai"
      "encode"
      "output"
      "voice" !important;
    gap: 12px;
  }
}

/* Mobile repair: readable rail, inline workflow, normal preview size */
@media (max-width: 640px) {
  .app-layout {
    grid-template-columns: 58px minmax(0, 1fr) !important;
  }

  .app-layout .studio-rail {
    width: 58px !important;
    padding: 10px 6px;
  }

  .app-layout .rail-link,
  .app-layout .rail-link:not(.active),
  .app-layout .rail-link:nth-child(n+6),
  .rail-icon {
    width: 42px;
    min-width: 42px;
    height: 42px;
    min-height: 42px;
  }

  .rail-collapsed .app-layout {
    grid-template-columns: 58px minmax(0, 1fr) !important;
  }

  .rail-collapsed .app-layout .studio-rail {
    position: fixed !important;
    left: 0;
    top: 0;
    z-index: 80;
    width: min(220px, 72vw) !important;
    align-items: stretch;
    padding: 12px;
    box-shadow: 18px 0 42px rgba(2, 8, 23, 0.28);
  }

  .rail-collapsed .app-layout .rail-logo {
    justify-items: start;
    text-align: left;
  }

  .rail-collapsed .rail-logo span {
    font-size: 0.48rem;
  }

  .rail-collapsed .app-layout .rail-primary {
    gap: 7px;
  }

  .rail-collapsed .app-layout .rail-link,
  .rail-collapsed .app-layout .rail-link:not(.active),
  .rail-collapsed .app-layout .rail-link:nth-child(n+6) {
    display: flex !important;
    width: 100%;
    min-width: 0;
    height: 42px;
    min-height: 42px;
    justify-content: flex-start;
    gap: 10px;
    padding: 0 10px;
    color: #eaf5ff;
    font-size: 0.78rem;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .rail-collapsed .rail-icon {
    flex: 0 0 30px;
    width: 30px;
    min-width: 30px;
    height: 30px;
    min-height: 30px;
  }

  .app-layout .workflow-steps {
    display: grid !important;
    grid-template-columns: repeat(4, max-content) !important;
    gap: 8px;
    align-items: center;
    overflow-x: auto;
    padding-block: 8px;
  }

  .app-layout .workflow-steps a {
    display: inline-flex;
    flex: none;
    min-height: 36px;
    min-width: max-content;
    align-items: center;
    gap: 7px;
    padding: 7px 10px;
    border-radius: 999px;
  }

  .app-layout .workflow-steps span {
    width: 22px;
    height: 22px;
    font-size: 0.68rem;
  }

  .app-layout .workflow-steps strong {
    font-size: 0.76rem;
    white-space: nowrap;
  }

  .app-layout .workflow-steps small,
  .ratio-select {
    display: none;
  }

  .video-stage {
    width: 100%;
    padding: 42px 0 12px;
  }

  .phone-frame,
  .phone-frame.is-wide {
    width: calc(100vw - 104px) !important;
    max-width: 420px;
  }
}

@media (min-width: 641px) {
  .phone-frame {
    width: min(420px, 58vw);
  }

  .phone-frame.is-wide {
    width: min(620px, 64vw);
  }
}

/* EOF phone fix: no permanent left rail, no side-by-side preview on phones. */
@media (max-width: 640px) {
  html,
  body {
    overflow-x: hidden !important;
  }

  .app-layout {
    display: block !important;
    grid-template-columns: none !important;
    width: 100% !important;
    min-height: 100dvh;
  }

  .app-layout .studio-rail {
    position: fixed !important;
    inset: 0 auto 0 0;
    z-index: 80;
    width: min(232px, 78vw) !important;
    height: 100dvh !important;
    min-height: 100dvh !important;
    align-items: stretch !important;
    padding: 14px 12px !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    transform: translateX(-105%) !important;
    transition: transform 180ms ease;
    box-shadow: 18px 0 42px rgba(2, 8, 23, 0.28);
  }

  .rail-collapsed .app-layout .studio-rail {
    transform: translateX(0) !important;
  }

  .app-layout .rail-link,
  .app-layout .rail-link:not(.active),
  .app-layout .rail-link:nth-child(n+6) {
    display: flex !important;
    width: 100% !important;
    min-width: 0 !important;
    height: 44px !important;
    min-height: 44px !important;
    justify-content: flex-start !important;
    gap: 10px;
    padding: 0 10px !important;
    color: #eaf5ff;
    font-size: 0.82rem !important;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .rail-icon {
    flex: 0 0 30px;
    width: 30px !important;
    min-width: 30px !important;
    height: 30px !important;
    min-height: 30px !important;
  }

  .app-layout .rail-logo {
    justify-items: start !important;
    text-align: left !important;
  }

  .app-layout .rail-logo span {
    display: block !important;
    font-size: 0.52rem !important;
    letter-spacing: 0.2em;
  }

  .app-layout .rail-tools {
    display: grid !important;
    gap: 7px !important;
    margin-top: 10px !important;
    padding-top: 12px !important;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
  }

  .app-layout .rail-tools p {
    display: block !important;
    margin: 0 10px 4px !important;
    color: rgba(234, 245, 255, 0.62) !important;
    font-size: 0.62rem !important;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }

  .app-layout .rail-footer {
    display: grid !important;
    gap: 10px !important;
    margin-top: auto !important;
  }

  .app-layout .storage-card {
    display: grid !important;
    gap: 7px !important;
    padding: 10px !important;
  }

  .app-layout .upgrade-button {
    display: flex !important;
    min-height: 42px !important;
    align-items: center !important;
    justify-content: center !important;
  }

  .app-layout .studio-main {
    grid-column: auto !important;
    width: 100% !important;
    min-width: 0 !important;
    padding: 0 10px 18px !important;
    overflow-x: hidden !important;
  }

  .app-layout .studio-topbar {
    margin: 0 -10px !important;
  }

  .app-layout .workflow-steps {
    display: flex !important;
    grid-template-columns: none !important;
    gap: 8px !important;
    margin: 0 -10px !important;
    padding: 10px !important;
    overflow-x: auto !important;
    scrollbar-width: none;
  }

  .app-layout .workflow-steps::-webkit-scrollbar {
    display: none;
  }

  .app-layout .workflow-steps a {
    display: inline-flex !important;
    flex: 0 0 auto !important;
    min-height: 38px !important;
    min-width: max-content !important;
    align-items: center !important;
    gap: 7px !important;
    padding: 7px 11px !important;
    border-radius: 999px !important;
  }

  .app-layout .workflow-steps span {
    width: 22px !important;
    height: 22px !important;
    font-size: 0.68rem !important;
  }

  .app-layout .workflow-steps strong {
    font-size: 0.78rem !important;
    white-space: nowrap !important;
  }

  .app-layout .workflow-steps small,
  .ratio-select {
    display: none !important;
  }

  .app-layout .studio-dashboard-grid {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    grid-template-areas:
      "source"
      "preview"
      "ai"
      "encode"
      "output"
      "voice" !important;
    gap: 12px !important;
    width: 100% !important;
    min-width: 0 !important;
  }

  .app-layout .panel,
  .app-layout .preview-panel {
    width: 100% !important;
    min-width: 0 !important;
  }

  .video-stage {
    width: 100% !important;
    min-height: auto !important;
    padding: 46px 10px 14px !important;
  }

  .phone-frame,
  .phone-frame.is-wide {
    width: min(100%, 320px) !important;
    max-width: 100% !important;
    margin-inline: auto !important;
  }
}

/* EOF source-ratio preview override. */
.app-layout .video-stage {
  min-height: auto !important;
  padding: 12px !important;
}

.app-layout .phone-frame,
.app-layout .phone-frame.is-wide {
  width: min(100%, var(--preview-max-width, 520px)) !important;
  max-width: 100% !important;
  height: auto !important;
  min-height: 0 !important;
  aspect-ratio: var(--source-aspect-ratio, 9 / 16) !important;
  margin-inline: auto !important;
  background: #000 !important;
}

.app-layout .phone-frame .video-preview {
  width: 100% !important;
  height: 100% !important;
  min-height: 0 !important;
  max-height: none !important;
  object-fit: contain !important;
}

.app-layout .phone-frame .preview-cover-layer,
.app-layout .phone-frame .preview-subtitle,
.app-layout .phone-frame .preview-watermark {
  max-width: calc(100% - 24px);
}

.result-video {
  width: min(100%, 760px) !important;
  height: auto !important;
  max-height: min(78vh, 760px);
  object-fit: contain;
  background: #000;
}

@media (max-width: 640px) {
  .app-layout .video-stage {
    padding: 10px !important;
  }

  .app-layout .phone-frame,
  .app-layout .phone-frame.is-wide {
    width: min(100%, var(--preview-max-width, calc(100vw - 96px))) !important;
  }
}

/* Final source-ratio preview override. Keep this at EOF so fixed mobile rules cannot win. */
.app-layout .video-stage {
  min-height: auto !important;
  padding: 12px !important;
}

.app-layout .phone-frame,
.app-layout .phone-frame.is-wide {
  width: min(100%, var(--preview-max-width, 520px)) !important;
  max-width: 100% !important;
  height: auto !important;
  min-height: 0 !important;
  aspect-ratio: var(--source-aspect-ratio, 9 / 16) !important;
  margin-inline: auto !important;
  background: #000 !important;
}

.app-layout .phone-frame .video-preview {
  width: 100% !important;
  height: 100% !important;
  min-height: 0 !important;
  max-height: none !important;
  object-fit: contain !important;
}

.app-layout .phone-frame .preview-cover-layer,
.app-layout .phone-frame .preview-subtitle,
.app-layout .phone-frame .preview-watermark {
  max-width: calc(100% - 24px);
}

.result-video {
  width: min(100%, 760px) !important;
  height: auto !important;
  max-height: min(78vh, 760px);
  object-fit: contain;
  background: #000;
}

@media (max-width: 640px) {
  .app-layout .video-stage {
    padding: 10px !important;
  }

  .app-layout .phone-frame,
  .app-layout .phone-frame.is-wide {
    width: min(100%, var(--preview-max-width, calc(100vw - 96px))) !important;
  }
}

/* Final source-ratio preview override. Keep this at EOF so fixed mobile rules cannot win. */
.app-layout .video-stage {
  min-height: auto !important;
  padding: 12px !important;
}

.app-layout .phone-frame,
.app-layout .phone-frame.is-wide {
  width: min(100%, var(--preview-max-width, 520px)) !important;
  max-width: 100% !important;
  height: auto !important;
  min-height: 0 !important;
  aspect-ratio: var(--source-aspect-ratio, 9 / 16) !important;
  margin-inline: auto !important;
  background: #000 !important;
}

.app-layout .phone-frame .video-preview {
  width: 100% !important;
  height: 100% !important;
  min-height: 0 !important;
  max-height: none !important;
  object-fit: contain !important;
}

.app-layout .phone-frame .preview-cover-layer,
.app-layout .phone-frame .preview-subtitle,
.app-layout .phone-frame .preview-watermark {
  max-width: calc(100% - 24px);
}

.result-video {
  width: min(100%, 760px) !important;
  height: auto !important;
  max-height: min(78vh, 760px);
  object-fit: contain;
  background: #000;
}

@media (max-width: 640px) {
  .app-layout .video-stage {
    padding: 10px !important;
  }

  .app-layout .phone-frame,
  .app-layout .phone-frame.is-wide {
    width: min(100%, var(--preview-max-width, calc(100vw - 96px))) !important;
  }
}

/* Source-ratio preview: keep uploaded media and exported output visually matched. */
.app-layout .video-stage {
  min-height: auto !important;
  padding: 12px !important;
}

.app-layout .phone-frame,
.app-layout .phone-frame.is-wide {
  width: min(100%, var(--preview-max-width, 520px)) !important;
  max-width: 100% !important;
  height: auto !important;
  min-height: 0 !important;
  aspect-ratio: var(--source-aspect-ratio, 9 / 16) !important;
  border-radius: 8px;
  background: #000 !important;
}

.app-layout .phone-frame .video-preview {
  width: 100% !important;
  height: 100% !important;
  min-height: 0 !important;
  max-height: none !important;
  object-fit: contain !important;
}

.app-layout .phone-frame .preview-cover-layer,
.app-layout .phone-frame .preview-subtitle,
.app-layout .phone-frame .preview-watermark {
  max-width: calc(100% - 24px);
}

.result-video {
  width: min(100%, 760px) !important;
  height: auto !important;
  max-height: min(78vh, 760px);
  object-fit: contain;
  background: #000;
}

@media (max-width: 640px) {
  .app-layout .video-stage {
    padding: 10px !important;
  }

  .app-layout .phone-frame,
  .app-layout .phone-frame.is-wide {
    width: min(100%, var(--preview-max-width, calc(100vw - 96px))) !important;
  }
}

/* Landing page: muted Blu-ray glass theme. */
.landing-body {
  color: #eef6fb;
  background:
    linear-gradient(90deg, rgba(8, 17, 25, 0.92), rgba(16, 32, 43, 0.72) 48%, rgba(8, 14, 20, 0.96)),
    linear-gradient(180deg, #162533 0%, #0b1722 48%, #071018 100%);
}

.landing-body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.06) 0 1px, transparent 1px 100%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.04) 0 1px, transparent 1px 100%);
  background-size: 92px 92px;
  mask-image: linear-gradient(180deg, black, transparent 72%);
  opacity: 0.28;
}

.landing-body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(115deg, rgba(165, 194, 208, 0.14), transparent 42%),
    linear-gradient(270deg, rgba(219, 229, 235, 0.09), transparent 34%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), transparent 58%);
  pointer-events: none;
}

.landing-body .landing-shell {
  width: min(1180px, calc(100% - 44px));
  padding-top: 22px;
}

.landing-body .landing-nav {
  margin-bottom: 38px;
  padding: 12px 14px;
  border: 1px solid rgba(208, 226, 236, 0.16);
  border-radius: 18px;
  background: rgba(18, 32, 43, 0.42);
  box-shadow: 0 22px 80px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(24px);
}

.landing-body .landing-brand {
  color: #f8fbff;
}

.landing-body .brand-mark {
  color: #0e1c27;
  background: linear-gradient(180deg, #f7fbff, #b7c9d6);
  box-shadow: inset 0 -8px 18px rgba(47, 67, 80, 0.22);
}

.landing-body .landing-brand small,
.landing-body .product-topline,
.landing-body .workflow-strip p,
.landing-body .feature-list span,
.landing-body .landing-section p,
.landing-body .launch-band p,
.landing-body .hero-copy p {
  color: #b7c5cf;
}

.landing-body .landing-nav nav a {
  color: #c8d5de;
}

.landing-body .button {
  border-radius: 14px;
}

.landing-body .button-primary {
  color: #f7fbff;
  background: linear-gradient(135deg, rgba(213, 229, 238, 0.28), rgba(83, 116, 139, 0.52));
  border: 1px solid rgba(218, 235, 246, 0.38);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.22),
    0 18px 46px rgba(3, 10, 16, 0.34);
}

.landing-body .button-muted {
  color: #e7f1f8;
  background: rgba(9, 20, 30, 0.2);
  border: 1px solid rgba(210, 229, 240, 0.22);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.landing-body .landing-hero {
  min-height: 660px;
  grid-template-columns: minmax(0, 0.82fr) minmax(430px, 1.18fr);
  gap: 42px;
}

.landing-body .hero-copy h1 {
  color: #f8fbff;
  text-shadow: 0 20px 70px rgba(0, 0, 0, 0.34);
}

.landing-body .hero-product,
.landing-body .workflow-strip article,
.landing-body .feature-list article,
.landing-body .launch-band {
  border: 1px solid rgba(211, 229, 239, 0.22);
  background:
    linear-gradient(180deg, rgba(218, 232, 240, 0.13), rgba(14, 28, 39, 0.32)),
    rgba(12, 25, 36, 0.48);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    0 24px 80px rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(26px);
}

.landing-body .hero-product {
  padding: 16px;
  border-radius: 24px;
}

.landing-body .product-topline strong {
  color: #8ce7ca;
}

.landing-body .product-screen {
  grid-template-columns: 1fr;
  min-height: 0;
}

.landing-body .phone-preview {
  min-height: 430px;
  border: 1px solid rgba(224, 238, 247, 0.28);
  border-radius: 22px;
  background:
    linear-gradient(180deg, rgba(8, 13, 18, 0.06), rgba(4, 8, 12, 0.6)),
    url("/assets/landing-cinema-still.png") center / cover no-repeat;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.08),
    0 22px 58px rgba(0, 0, 0, 0.36);
}

.landing-body .phone-preview::before {
  display: none;
}

.landing-body .phone-watermark {
  top: 18px;
  right: 20px;
  padding: 0;
  color: #ffffff;
  background: transparent;
  font-size: 1.7rem;
  line-height: 0.88;
  text-align: right;
  text-transform: uppercase;
  text-shadow: 0 3px 12px rgba(0, 0, 0, 0.62);
}

.landing-body .phone-watermark::after {
  content: "MOVIE";
  display: block;
  color: #9bd7ff;
  font-size: 0.58rem;
  letter-spacing: 0.42em;
}

.landing-body .phone-subtitle {
  left: 7%;
  right: 7%;
  bottom: 70px;
  border-radius: 12px;
  background: rgba(3, 7, 10, 0.72);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.32);
}

.player-controls {
  position: absolute;
  left: 7%;
  right: 7%;
  bottom: 24px;
  display: grid;
  grid-template-columns: auto auto minmax(70px, 1fr) auto;
  gap: 12px;
  align-items: center;
  color: #dbe8ef;
  font-size: 0.88rem;
  font-weight: 700;
}

.player-controls i {
  display: block;
  height: 5px;
  border-radius: 999px;
  background: linear-gradient(90deg, #dce8f1 42%, rgba(220, 232, 241, 0.26) 42%);
}

.play-dot {
  width: 0;
  height: 0;
  border-top: 9px solid transparent;
  border-bottom: 9px solid transparent;
  border-left: 14px solid #f7fbff;
}

.landing-body .render-queue {
  min-height: 128px;
  border: 1px solid rgba(212, 230, 241, 0.16);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(8, 16, 24, 0.84), rgba(6, 10, 16, 0.94));
}

.landing-body .queue-bars i {
  background: linear-gradient(90deg, #b8cbd8, #6d8495);
}

.landing-body .workflow-strip {
  margin-top: 8px;
}

.landing-body .workflow-strip span {
  color: #d6e7f1;
}

.landing-body .workflow-strip strong,
.landing-body .feature-list strong,
.landing-body .split h2,
.landing-body .launch-band h2 {
  color: #f3f8fb;
}

.landing-body .eyeline {
  color: #9fc1d5;
}

@media (max-width: 820px) {
  .landing-body .landing-shell {
    width: min(100% - 28px, 680px);
    padding-top: 12px;
  }

  .landing-body .landing-nav nav {
    display: none;
  }

  .landing-body .landing-nav .button {
    min-height: 40px;
    padding: 0 12px;
    font-size: 0.78rem;
  }

  .landing-body .landing-hero {
    min-height: auto;
    grid-template-columns: minmax(0, 1fr);
    gap: 18px;
    align-items: start;
  }

  .landing-body .hero-copy h1 {
    margin-bottom: 12px;
    font-size: clamp(3.65rem, 17vw, 5.9rem);
  }

  .landing-body .hero-copy p {
    margin-bottom: 18px;
    font-size: 0.98rem;
    line-height: 1.55;
  }

  .landing-body .hero-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .landing-body .hero-actions .button {
    min-height: 52px;
    padding: 0 12px;
    text-align: center;
  }

  .landing-body .phone-preview {
    min-height: min(70vw, 320px);
  }

  .landing-body .render-queue {
    min-height: 84px;
    padding: 14px;
  }

  .landing-body .workflow-strip,
  .landing-body .split {
    grid-template-columns: minmax(0, 1fr);
  }

  .landing-body .workflow-strip {
    margin-top: 14px;
  }

  .landing-body .launch-band {
    align-items: stretch;
  }
}

@media (max-width: 420px) {
  .landing-body .landing-shell {
    width: calc(100% - 24px);
  }

  .landing-body .landing-brand small {
    display: none;
  }

  .landing-body .hero-actions {
    gap: 10px;
  }

  .landing-body .button {
    font-size: 0.86rem;
  }

  .landing-body .hero-product {
    padding: 10px;
    border-radius: 20px;
  }

  .landing-body .product-topline {
    margin-bottom: 10px;
  }

  .landing-body .render-queue {
    display: none;
  }
}

/* Final preview/output alignment pass. */
.phone-frame .preview-subtitle {
  display: grid;
  place-items: center;
  text-align: center;
}

.phone-frame .preview-subtitle span {
  max-width: 100%;
  line-height: 1.26;
  text-align: center;
}

.app-layout .feature-panel {
  scroll-margin-top: 92px;
}

@media (max-width: 640px) {
  .app-layout .feature-panel:not([hidden]) {
    position: static !important;
    inset: auto !important;
    z-index: auto !important;
    width: 100% !important;
    max-height: none !important;
    margin: 10px 0 12px !important;
    padding: 14px !important;
    overflow: visible !important;
    border-radius: 14px !important;
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.12) !important;
  }

  .app-layout .feature-panel-head {
    grid-template-columns: minmax(0, 1fr) auto !important;
    gap: 10px !important;
  }

  .app-layout .feature-panel-head h2 {
    font-size: 1.15rem !important;
    line-height: 1.15 !important;
  }

  .app-layout .feature-panel-head p:last-child {
    font-size: 0.82rem !important;
    line-height: 1.35 !important;
  }

  .app-layout .feature-panel-body .feature-actions {
    display: grid !important;
    gap: 10px !important;
  }

  .app-layout .feature-panel-body .button {
    width: 100% !important;
    min-height: 46px !important;
    white-space: normal !important;
  }

  .phone-frame .preview-subtitle {
    width: min(84%, 300px) !important;
    min-height: 0;
  }

  .phone-frame .preview-subtitle span {
    font-size: clamp(18px, 5vw, 24px);
  }
}

/* Absolute final phone layout: hide the rail until the menu opens. */
@media (max-width: 640px) {
  html,
  body {
    overflow-x: hidden !important;
  }

  .app-layout {
    display: block !important;
    width: 100% !important;
    min-height: 100dvh;
  }

  .app-layout .studio-rail {
    position: fixed !important;
    inset: 0 auto 0 0;
    z-index: 80;
    width: min(232px, 78vw) !important;
    height: 100dvh !important;
    min-height: 100dvh !important;
    align-items: stretch !important;
    padding: 14px 12px !important;
    transform: translateX(-105%);
    transition: transform 180ms ease;
    box-shadow: 18px 0 42px rgba(2, 8, 23, 0.28);
  }

  .rail-collapsed .app-layout .studio-rail {
    transform: translateX(0);
  }

  .app-layout .rail-link,
  .app-layout .rail-link:not(.active),
  .app-layout .rail-link:nth-child(n+6) {
    display: flex !important;
    width: 100% !important;
    min-width: 0 !important;
    height: 44px !important;
    min-height: 44px !important;
    justify-content: flex-start !important;
    gap: 10px;
    padding: 0 10px !important;
    color: #eaf5ff;
    font-size: 0.82rem !important;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .rail-icon {
    flex: 0 0 30px;
    width: 30px !important;
    min-width: 30px !important;
    height: 30px !important;
    min-height: 30px !important;
  }

  .app-layout .studio-main {
    width: 100% !important;
    min-width: 0 !important;
    padding: 0 10px 18px !important;
    overflow-x: hidden !important;
  }

  .app-layout .studio-topbar {
    margin: 0 -10px !important;
  }

  .app-layout .workflow-steps {
    display: flex !important;
    gap: 8px !important;
    margin: 0 -10px !important;
    padding: 10px !important;
    overflow-x: auto !important;
    scrollbar-width: none;
  }

  .app-layout .workflow-steps::-webkit-scrollbar {
    display: none;
  }

  .app-layout .workflow-steps a {
    display: inline-flex !important;
    flex: 0 0 auto !important;
    min-height: 38px !important;
    min-width: max-content !important;
    align-items: center !important;
    gap: 7px !important;
    padding: 7px 11px !important;
    border-radius: 999px !important;
  }

  .app-layout .workflow-steps span {
    width: 22px !important;
    height: 22px !important;
    font-size: 0.68rem !important;
  }

  .app-layout .workflow-steps strong {
    font-size: 0.78rem !important;
    white-space: nowrap !important;
  }

  .app-layout .workflow-steps small,
  .ratio-select {
    display: none !important;
  }

  .app-layout .studio-dashboard-grid {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    grid-template-areas:
      "source"
      "preview"
      "ai"
      "encode"
      "output"
      "voice" !important;
    gap: 12px !important;
    width: 100% !important;
    min-width: 0 !important;
  }

  .app-layout .panel,
  .app-layout .preview-panel {
    width: 100% !important;
    min-width: 0 !important;
  }

  .video-stage {
    width: 100% !important;
    min-height: auto !important;
    padding: 46px 10px 14px !important;
  }

  .phone-frame,
  .phone-frame.is-wide {
    width: min(100%, 320px) !important;
    max-width: 100% !important;
    margin-inline: auto !important;
  }
}

/* Phone layout correction: content first, sidebar on demand */
@media (max-width: 640px) {
  html,
  body {
    overflow-x: hidden !important;
  }

  .app-layout {
    display: block !important;
    width: 100%;
    min-height: 100dvh;
  }

  .app-layout .studio-rail {
    position: fixed !important;
    inset: 0 auto 0 0;
    z-index: 80;
    width: min(232px, 78vw) !important;
    height: 100dvh;
    min-height: 100dvh;
    align-items: stretch;
    padding: 14px 12px !important;
    transform: translateX(-105%);
    transition: transform 180ms ease;
    box-shadow: 18px 0 42px rgba(2, 8, 23, 0.28);
  }

  .rail-collapsed .app-layout .studio-rail {
    transform: translateX(0);
  }

  .rail-logo {
    justify-items: start !important;
    text-align: left !important;
  }

  .rail-logo span {
    font-size: 0.52rem !important;
  }

  .app-layout .rail-primary {
    gap: 8px;
  }

  .app-layout .rail-link,
  .app-layout .rail-link:not(.active),
  .app-layout .rail-link:nth-child(n+6) {
    display: flex !important;
    width: 100% !important;
    min-width: 0 !important;
    height: 44px !important;
    min-height: 44px !important;
    justify-content: flex-start;
    gap: 10px;
    padding: 0 10px !important;
    color: #eaf5ff;
    font-size: 0.82rem !important;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .rail-icon {
    flex: 0 0 30px;
    width: 30px !important;
    min-width: 30px !important;
    height: 30px !important;
    min-height: 30px !important;
  }

  .app-layout .studio-main {
    width: 100%;
    min-width: 0;
    padding: 0 10px 18px !important;
    overflow-x: hidden;
  }

  .app-layout .studio-topbar {
    margin: 0 -10px !important;
  }

  .app-layout .workflow-steps {
    display: flex !important;
    gap: 8px;
    margin: 0 -10px;
    padding: 10px;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .app-layout .workflow-steps::-webkit-scrollbar {
    display: none;
  }

  .app-layout .workflow-steps a {
    display: inline-flex !important;
    flex: 0 0 auto;
    min-height: 38px;
    min-width: max-content;
    align-items: center;
    gap: 7px;
    padding: 7px 11px !important;
    border-radius: 999px;
  }

  .app-layout .workflow-steps span {
    width: 22px !important;
    height: 22px !important;
    font-size: 0.68rem;
  }

  .app-layout .workflow-steps strong {
    font-size: 0.78rem !important;
    white-space: nowrap;
  }

  .app-layout .workflow-steps small,
  .ratio-select {
    display: none !important;
  }

  .app-layout .studio-dashboard-grid {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    grid-template-areas:
      "source"
      "preview"
      "ai"
      "encode"
      "output"
      "voice" !important;
    gap: 12px;
    width: 100%;
    min-width: 0;
  }

  .app-layout .panel {
    width: 100%;
    min-width: 0;
  }

  .app-layout .preview-panel {
    overflow: hidden;
  }

  .video-stage {
    width: 100%;
    min-height: auto !important;
    padding: 46px 10px 14px !important;
  }

  .phone-frame,
  .phone-frame.is-wide {
    width: min(100%, 320px) !important;
    max-width: 100% !important;
    margin-inline: auto;
  }
}

/* EOF phone override: wins over every earlier mobile/tablet block. */
@media (max-width: 640px) {
  .app-layout {
    grid-template-columns: 52px minmax(0, 1fr) !important;
  }

  .app-layout .studio-rail {
    width: 52px !important;
    padding: 8px 5px !important;
  }

  .app-layout .studio-dashboard-grid {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) 128px !important;
    grid-template-areas:
      "source preview"
      "ai preview"
      "encode encode"
      "output output"
      "voice voice" !important;
    gap: 8px !important;
  }

  .source-panel .field-grid.two {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  .source-panel > .field:last-child,
  .preview-note {
    display: none !important;
  }

  .phone-frame,
  .phone-frame.is-wide {
    width: 112px !important;
    max-width: 112px !important;
  }
}

/* Absolute final phone rule: keep this at EOF so mobile does not fall back to one column. */
@media (max-width: 640px) {
  .app-layout {
    grid-template-columns: 52px minmax(0, 1fr) !important;
  }

  .app-layout .studio-rail {
    width: 52px !important;
    padding: 8px 5px !important;
  }

  .app-layout .rail-link,
  .app-layout .rail-link:not(.active),
  .app-layout .rail-link:nth-child(n+6),
  .rail-icon {
    width: 38px !important;
    min-width: 38px !important;
    height: 38px !important;
    min-height: 38px !important;
  }

  .app-layout .studio-dashboard-grid {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) 128px !important;
    grid-template-areas:
      "source preview"
      "ai preview"
      "encode encode"
      "output output"
      "voice voice" !important;
    gap: 8px !important;
  }

  .source-panel .field-grid.two {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  .source-panel > .field:last-child,
  .preview-note {
    display: none !important;
  }

  .app-layout .preview-panel {
    align-self: start !important;
  }

  .phone-frame,
  .phone-frame.is-wide {
    width: 112px !important;
    max-width: 112px !important;
  }

  .app-layout .ai-controls.field-grid.three,
  .app-layout .setting-columns {
    grid-auto-columns: minmax(118px, 47%) !important;
  }
}

/* Last phone rule: this must stay after the tablet one-column rule above. */
@media (max-width: 640px) {
  .app-layout {
    grid-template-columns: 52px minmax(0, 1fr) !important;
  }

  .app-layout .studio-rail {
    width: 52px !important;
    padding: 8px 5px !important;
  }

  .app-layout .rail-link,
  .app-layout .rail-link:not(.active),
  .app-layout .rail-link:nth-child(n+6),
  .rail-icon {
    width: 38px !important;
    min-width: 38px !important;
    height: 38px !important;
    min-height: 38px !important;
  }

  .app-layout .studio-dashboard-grid {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) 128px !important;
    grid-template-areas:
      "source preview"
      "ai preview"
      "encode encode"
      "output output"
      "voice voice" !important;
    gap: 8px !important;
  }

  .source-panel .field-grid.two {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  .source-panel > .field:last-child,
  .preview-note {
    display: none !important;
  }

  .app-layout .preview-panel {
    align-self: start !important;
  }

  .phone-frame,
  .phone-frame.is-wide {
    width: 112px !important;
    max-width: 112px !important;
  }

  .app-layout .ai-controls.field-grid.three,
  .app-layout .setting-columns {
    grid-auto-columns: minmax(118px, 47%) !important;
  }
}

/* Hard phone layout: keep the desktop composition instead of a tall form stack */
@media (max-width: 640px) {
  html,
  body {
    overflow-x: hidden !important;
    background: #f4f8ff;
  }

  .app-layout {
    grid-template-columns: 52px minmax(0, 1fr) !important;
    min-height: 100dvh;
  }

  .app-layout .studio-rail {
    width: 52px !important;
    padding: 8px 5px !important;
    gap: 7px !important;
  }

  .rail-logo {
    padding-bottom: 8px !important;
  }

  .rail-logo strong {
    font-size: 0.78rem !important;
    line-height: 0.9 !important;
  }

  .rail-logo span {
    font-size: 0.3rem !important;
    letter-spacing: 0.2em !important;
  }

  .app-layout .rail-primary {
    gap: 6px !important;
  }

  .app-layout .rail-link,
  .app-layout .rail-link:not(.active),
  .app-layout .rail-link:nth-child(n+6) {
    width: 38px !important;
    min-width: 38px !important;
    height: 38px !important;
    min-height: 38px !important;
    border-radius: 11px !important;
  }

  .rail-icon {
    width: 38px !important;
    height: 38px !important;
  }

  .rail-icon::before {
    font-size: 0.92rem !important;
  }

  .app-layout .studio-main {
    padding: 0 6px 14px !important;
  }

  .app-layout .studio-topbar {
    min-height: 48px !important;
    margin: 0 -6px !important;
    padding: 6px !important;
  }

  .command-title {
    grid-template-columns: 30px minmax(0, 1fr) !important;
    gap: 6px !important;
  }

  .icon-button {
    width: 30px !important;
    height: 30px !important;
    border-radius: 9px !important;
    font-size: 0.9rem !important;
  }

  .app-layout .studio-topbar h1 {
    font-size: 0.78rem !important;
    line-height: 1.05 !important;
  }

  .app-layout .studio-topbar p {
    font-size: 0.58rem !important;
  }

  .app-layout .top-create {
    min-width: 82px !important;
    min-height: 32px !important;
    padding: 0 8px !important;
    border-radius: 10px !important;
    font-size: 0.66rem !important;
  }

  .app-layout .workflow-steps {
    gap: 6px !important;
    margin: 0 -4px !important;
    padding: 7px 4px !important;
  }

  .app-layout .workflow-steps a {
    flex: 0 0 104px !important;
    min-height: 58px !important;
    grid-template-columns: 22px minmax(0, 1fr) !important;
    gap: 6px !important;
    padding: 7px !important;
    border-radius: 11px !important;
  }

  .app-layout .workflow-steps span {
    width: 22px !important;
    height: 22px !important;
    font-size: 0.72rem !important;
  }

  .app-layout .workflow-steps strong {
    font-size: 0.62rem !important;
    line-height: 1.12 !important;
  }

  .app-layout .workflow-steps small {
    font-size: 0.52rem !important;
    line-height: 1.1 !important;
  }

  .ratio-select {
    flex: 0 0 96px !important;
  }

  .ratio-select select {
    min-height: 32px !important;
    font-size: 0.64rem !important;
  }

  .app-layout .studio-dashboard-grid {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) 128px !important;
    grid-template-areas:
      "source preview"
      "ai preview"
      "encode encode"
      "output output"
      "voice voice" !important;
    gap: 8px !important;
  }

  .app-layout .panel {
    padding: 10px !important;
    border-radius: 12px !important;
  }

  .compact-head {
    margin-bottom: 8px !important;
  }

  .eyeline {
    font-size: 0.62rem !important;
    letter-spacing: 0.14em !important;
  }

  .panel h2 {
    font-size: 0.86rem !important;
  }

  .source-panel .pro-upload {
    min-height: 78px !important;
    padding: 9px !important;
  }

  .pro-upload .upload-cloud {
    font-size: 0.9rem !important;
  }

  .pro-upload strong,
  .pro-upload small,
  .pro-upload em {
    font-size: 0.58rem !important;
    line-height: 1.15 !important;
  }

  .source-panel .field-grid.two {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 7px !important;
  }

  .field {
    gap: 4px !important;
  }

  .field span,
  .toggle-row {
    font-size: 0.62rem !important;
    line-height: 1.15 !important;
  }

  .field input,
  .field select,
  .field textarea {
    min-height: 30px !important;
    padding: 6px 8px !important;
    border-radius: 9px !important;
    font-size: 0.66rem !important;
  }

  .field textarea {
    max-height: 70px !important;
  }

  .source-panel > .field:last-child {
    display: none !important;
  }

  .app-layout .preview-panel {
    align-self: start !important;
    padding: 8px !important;
  }

  .pro-preview-toolbar {
    margin-bottom: 6px !important;
  }

  .segmented-control button {
    min-height: 24px !important;
    padding: 0 8px !important;
    font-size: 0.58rem !important;
  }

  .pro-preview-toolbar p,
  .preview-note {
    display: none !important;
  }

  .video-stage {
    min-height: 0 !important;
    padding: 28px 2px 8px !important;
  }

  .phone-frame,
  .phone-frame.is-wide {
    width: 112px !important;
    max-width: 112px !important;
    border-radius: 12px !important;
  }

  .phone-notch {
    top: 6px !important;
    width: 42px !important;
    height: 12px !important;
  }

  .movie-watermark {
    top: 11px !important;
    right: 9px !important;
    font-size: 0.42rem !important;
  }

  .phone-frame .preview-subtitle {
    width: 90% !important;
    font-size: 0.42rem !important;
  }

  .phone-frame .preview-subtitle span {
    padding: 2px 5px !important;
    border-radius: 4px !important;
  }

  .video-preview-empty strong,
  .video-preview-empty span {
    font-size: 0.48rem !important;
  }

  .voice-card {
    gap: 7px !important;
    padding: 7px !important;
  }

  .avatar-dot {
    width: 28px !important;
    height: 28px !important;
    font-size: 0.52rem !important;
  }

  .voice-card strong,
  .voice-card small,
  .field-note {
    font-size: 0.58rem !important;
  }

  .app-layout .ai-controls.field-grid.three,
  .app-layout .setting-columns {
    grid-auto-columns: minmax(118px, 47%) !important;
    gap: 7px !important;
    padding-bottom: 6px !important;
  }

  .app-layout .setting-columns > section,
  .app-layout .setting-columns > section:last-child {
    padding: 8px !important;
    border-radius: 10px !important;
  }

  .switch-row {
    margin-bottom: 6px !important;
  }

  .toggle-row input[type="checkbox"] {
    width: 32px !important;
    height: 18px !important;
  }

  .output-layout {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .empty-state,
  .encode-summary {
    padding: 10px !important;
  }

  .empty-state h2,
  .live-history-overview h2 {
    font-size: 0.92rem !important;
  }

  .empty-state p,
  .encode-summary p,
  .live-history-overview p {
    font-size: 0.66rem !important;
  }

  .output-history-grid {
    grid-template-columns: minmax(0, 1fr) !important;
  }
}

/* Final mobile and output polish */
.output-history-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.live-history-overview {
  display: grid;
  gap: 14px;
}

.result-card-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.result-card-head h2,
.result-card-head h3 {
  margin: 4px 0;
}

.output-job-card {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid #dbe7f7;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
}

.output-thumb {
  display: grid;
  width: 72px;
  height: 92px;
  place-items: end center;
  padding: 8px;
  border-radius: 10px;
  color: #fff;
  background:
    linear-gradient(180deg, rgba(2, 8, 23, 0.1), rgba(2, 8, 23, 0.7)),
    linear-gradient(135deg, #0f172a, #1d4ed8 52%, #111827);
  font-weight: 900;
}

.output-job-card h3 {
  margin: 8px 0 4px;
  overflow: hidden;
  color: var(--ink);
  font-size: 0.9rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.output-job-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.72rem;
}

.status-pill {
  display: inline-grid;
  min-height: 22px;
  place-items: center;
  padding: 0 8px;
  border-radius: 999px;
  color: #047857;
  background: #dff8ea;
  font-size: 0.68rem;
  font-weight: 800;
}

.status-pill.expired {
  color: #b45309;
  background: #fff1d6;
}

.icon-download {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid #cbd9ee;
  border-radius: 8px;
  color: #0f63ff;
  background: var(--panel-solid);
  font-weight: 900;
  text-decoration: none;
}

.icon-download.disabled {
  color: #94a3b8;
}

.rail-icon {
  font-size: 0 !important;
}

.rail-icon::before {
  font-size: 1rem;
  font-weight: 800;
}

.rail-icon svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.rail-link[data-feature="dashboard"] .rail-icon::before { content: "⌂"; }
.rail-link[data-feature="projects"] .rail-icon::before { content: "□"; }
.rail-link[data-feature="templates"] .rail-icon::before { content: "▣"; }
.rail-link[data-feature="media"] .rail-icon::before { content: "▤"; }
.rail-link[data-feature="voices"] .rail-icon::before { content: "◉"; }
.rail-link[data-feature="subtitles"] .rail-icon::before { content: "T"; }
.rail-link[data-feature="watermarks"] .rail-icon::before { content: "◇"; }
.rail-link[data-feature="exports"] .rail-icon::before { content: "↗"; }
.rail-link[data-feature="team"] .rail-icon::before { content: "☻"; }
.rail-link[data-feature="script"] .rail-icon::before { content: "✧"; }
.rail-link[data-feature="translate"] .rail-icon::before { content: "文"; }
.rail-link[data-feature="clone"] .rail-icon::before { content: "≋"; }
.rail-link[data-feature="audio"] .rail-icon::before { content: "⌁"; }
.rail-link[data-feature="crop"] .rail-icon::before { content: "⌗"; }

@media (max-width: 640px) {
  body {
    font-size: 12px;
  }

  .app-layout {
    grid-template-columns: 56px minmax(0, 1fr) !important;
  }

  .app-layout .studio-rail {
    width: 56px !important;
    padding: 10px 6px;
    gap: 8px;
  }

  .rail-logo strong {
    font-size: 0.92rem !important;
  }

  .rail-logo span {
    font-size: 0.36rem !important;
  }

  .app-layout .rail-link,
  .app-layout .rail-link:not(.active),
  .app-layout .rail-link:nth-child(n+6) {
    width: 40px !important;
    min-width: 40px !important;
    height: 40px !important;
    min-height: 40px !important;
    border-radius: 12px;
  }

  .rail-icon {
    width: 40px !important;
    height: 40px !important;
    color: #dbeafe !important;
    font-size: 0 !important;
  }

  .rail-icon::before {
    font-size: 1rem;
    font-weight: 800;
  }

  .rail-link[data-feature="dashboard"] .rail-icon::before { content: "⌂"; }
  .rail-link[data-feature="projects"] .rail-icon::before { content: "□"; }
  .rail-link[data-feature="templates"] .rail-icon::before { content: "▣"; }
  .rail-link[data-feature="media"] .rail-icon::before { content: "▤"; }
  .rail-link[data-feature="voices"] .rail-icon::before { content: "◉"; }
  .rail-link[data-feature="subtitles"] .rail-icon::before { content: "T"; }
  .rail-link[data-feature="watermarks"] .rail-icon::before { content: "◇"; }
  .rail-link[data-feature="exports"] .rail-icon::before { content: "↗"; }
  .rail-link[data-feature="team"] .rail-icon::before { content: "☻"; }

  .app-layout .studio-main {
    padding: 0 8px 16px;
  }

  .app-layout .studio-topbar {
    min-height: 52px;
    margin: 0 -8px;
    padding: 7px 8px;
  }

  .command-title {
    grid-template-columns: 34px minmax(0, 1fr);
    gap: 7px;
  }

  .icon-button {
    width: 34px;
    height: 34px;
  }

  .app-layout .studio-topbar h1 {
    font-size: 0.9rem;
  }

  .app-layout .studio-topbar p {
    font-size: 0.64rem;
  }

  .app-layout .top-create {
    min-width: 94px;
    min-height: 36px;
    padding: 0 10px;
    border-radius: 12px;
    font-size: 0.72rem;
  }

  .app-layout .workflow-steps {
    gap: 6px;
    margin: 0 -4px;
    padding: 8px 4px;
  }

  .app-layout .workflow-steps a {
    flex: 0 0 124px;
    min-height: 74px;
    padding: 8px;
    border-radius: 13px;
  }

  .app-layout .workflow-steps span {
    width: 26px;
    height: 26px;
  }

  .app-layout .workflow-steps strong {
    font-size: 0.72rem;
  }

  .app-layout .workflow-steps small {
    font-size: 0.62rem;
  }

  .panel {
    padding: 14px;
    border-radius: 14px;
  }

  .panel h2 {
    font-size: 1.06rem;
  }

  .pro-upload {
    min-height: 112px;
    padding: 14px 10px;
  }

  .field input,
  .field select,
  .field textarea {
    min-height: 38px;
    padding: 8px 10px;
    font-size: 0.82rem;
  }

  .field span,
  .toggle-row {
    font-size: 0.74rem;
  }

  .app-layout .setting-columns,
  .app-layout .ai-controls.field-grid.three {
    grid-auto-columns: minmax(150px, 66%) !important;
  }

  .output-history-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .output-job-card {
    grid-template-columns: 58px minmax(0, 1fr) auto;
    padding: 10px;
  }

  .output-thumb {
    width: 58px;
    height: 76px;
  }
}

/* Blu-ray mobile shell: keep the sidebar on the left */
@media (max-width: 640px) {
  .studio-body,
  .admin-body {
    background:
      linear-gradient(180deg, rgba(15, 99, 255, 0.08), transparent 260px),
      #f6f9ff;
  }

  .app-layout {
    display: grid !important;
    grid-template-columns: 64px minmax(0, 1fr);
    align-items: start;
    min-height: 100dvh;
    background: transparent;
  }

  .app-layout .studio-rail {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex !important;
    grid-column: 1;
    grid-row: 1;
    width: 64px;
    height: 100dvh;
    min-height: 100dvh;
    flex-direction: column;
    gap: 10px;
    padding: 10px 8px;
    overflow-y: auto;
    border-right: 1px solid rgba(82, 164, 255, 0.16);
    background:
      linear-gradient(180deg, rgba(18, 111, 255, 0.28), transparent 190px),
      linear-gradient(180deg, #020817, #061426 62%, #020817);
    box-shadow: 12px 0 32px rgba(2, 8, 23, 0.16);
    scrollbar-width: none;
  }

  .app-layout .studio-rail::-webkit-scrollbar {
    display: none;
  }

  .rail-logo {
    justify-items: center;
    padding: 2px 0 8px;
  }

  .rail-logo strong {
    font-size: 1rem;
    letter-spacing: -0.03em;
  }

  .rail-logo span {
    display: block;
    font-size: 0.44rem;
    letter-spacing: 0.2em;
  }

  .app-layout .rail-primary,
  .app-layout .rail-tools {
    display: grid;
    gap: 7px;
    overflow: visible;
    padding: 0;
  }

  .app-layout .rail-tools {
    padding-top: 8px;
  }

  .app-layout .rail-tools p {
    display: none;
  }

  .app-layout .rail-link,
  .app-layout .rail-link:not(.active),
  .app-layout .rail-link:nth-child(n+6) {
    display: grid;
    width: 42px;
    min-width: 42px;
    height: 42px;
    min-height: 42px;
    flex: none;
    place-items: center;
    padding: 0;
    border-radius: 12px;
    color: transparent;
    font-size: 0;
    white-space: nowrap;
  }

  .app-layout .rail-link.active {
    border-color: rgba(77, 166, 255, 0.42);
    background:
      radial-gradient(circle at 50% 16%, rgba(124, 202, 255, 0.32), transparent 42%),
      linear-gradient(180deg, rgba(15, 99, 255, 0.82), rgba(10, 52, 128, 0.78));
    box-shadow: 0 10px 22px rgba(15, 99, 255, 0.26);
  }

  .app-layout .rail-link:hover {
    background: rgba(255, 255, 255, 0.1);
  }

  .rail-icon {
    display: grid;
    width: 42px;
    height: 42px;
    place-items: center;
    color: #eaf5ff;
    font-size: 0.86rem;
  }

  .rail-footer {
    display: none;
  }

  .app-layout .studio-main {
    grid-column: 2;
    grid-row: 1;
    width: 100%;
    min-width: 0;
    padding: 0 10px 16px;
  }

  .app-layout .studio-topbar {
    position: sticky;
    top: 0;
    z-index: 18;
    margin: 0 -10px 0;
    padding: 10px;
    border-bottom: 1px solid rgba(15, 99, 255, 0.1);
    background: rgba(246, 249, 255, 0.94);
    backdrop-filter: blur(16px);
  }

  .icon-button {
    width: 34px;
    height: 34px;
    border: 1px solid #d6e2f2;
    background: var(--panel-solid);
  }

  .app-layout .top-create {
    min-width: 104px;
    border-radius: 12px;
    background: linear-gradient(180deg, #1877ff, #0b55db);
  }

  .app-layout .workflow-steps {
    margin: 0 -10px;
    padding: 10px;
    background: transparent;
  }

  .app-layout .workflow-steps a {
    flex-basis: 166px;
    border-color: rgba(15, 99, 255, 0.14);
    border-radius: 14px;
    background:
      linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(248, 251, 255, 0.94));
    box-shadow: 0 10px 24px rgba(15, 99, 255, 0.08);
  }

  .app-layout .panel,
  .feature-panel {
    border-color: rgba(15, 99, 255, 0.14);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.06);
    box-shadow: 0 12px 28px rgba(15, 99, 255, 0.08);
  }

  .app-layout .field input,
  .app-layout .field select,
  .app-layout .field textarea,
  .upload-zone {
    border-color: #d5e2f2;
    border-radius: 12px;
    background: #fbfdff;
  }

  .pro-upload {
    background:
      radial-gradient(circle at 50% 0%, rgba(38, 130, 255, 0.12), transparent 44%),
      #fbfdff;
  }

  .phone-frame {
    border-radius: 18px;
    box-shadow:
      0 18px 42px rgba(2, 8, 23, 0.22),
      0 0 0 1px rgba(85, 176, 255, 0.14);
  }

  .admin-shell {
    display: grid !important;
    grid-template-columns: 64px minmax(0, 1fr);
    align-items: start;
    min-height: 100dvh;
  }

  .admin-rail {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex !important;
    grid-column: 1;
    grid-row: 1;
    width: 64px;
    height: 100dvh;
    min-height: 100dvh;
    flex-direction: column;
    gap: 12px;
    padding: 10px 8px;
    overflow-y: auto;
    background:
      linear-gradient(180deg, rgba(18, 111, 255, 0.28), transparent 190px),
      linear-gradient(180deg, #020817, #061426 62%, #020817);
    scrollbar-width: none;
  }

  .admin-rail::-webkit-scrollbar {
    display: none;
  }

  .admin-nav {
    display: grid;
    gap: 8px;
    overflow: visible;
  }

  .admin-nav a {
    display: grid;
    width: 42px;
    height: 42px;
    place-items: center;
    padding: 0;
    border-radius: 12px;
    overflow: hidden;
    color: transparent;
    background: rgba(255, 255, 255, 0.06);
    font-size: 0;
  }

  .admin-nav a::before {
    content: attr(data-short);
    color: #eaf5ff;
    font-size: 0.86rem;
    font-weight: 900;
  }

  .admin-main {
    grid-column: 2;
    grid-row: 1;
    min-width: 0;
    padding: 10px;
  }

  .admin-topbar,
  .admin-panel,
  .admin-stat {
    border-color: rgba(15, 99, 255, 0.14);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.06);
    box-shadow: 0 12px 28px rgba(15, 99, 255, 0.08);
  }
}

@media (max-width: 1280px) {
  .app-layout .topbar-actions .shortcuts-button,
  .app-layout .topbar-actions .round-action:not(.notify-action),
  .account-chip {
    display: none;
  }

  .studio-dashboard-grid {
    grid-template-columns: 1fr;
    grid-template-areas:
      "source"
      "preview"
      "ai"
      "encode"
      "output"
      "voice";
  }

  .video-stage {
    min-height: 480px;
  }
}

@media (max-width: 980px) {
  .app-layout {
    grid-template-columns: 72px minmax(0, 1fr);
  }

  .rail-logo span,
  .app-layout .rail-link:not(.active) {
    font-size: 0;
  }

  .rail-logo strong {
    font-size: 1.1rem;
  }

  .app-layout .rail-link {
    justify-content: center;
    padding: 0;
  }

  .rail-tools p,
  .storage-card,
  .upgrade-button {
    display: none;
  }

  .app-layout .workflow-steps {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .ratio-select {
    grid-column: 1 / -1;
  }

  .setting-columns,
  .output-layout,
  .feature-cards.two,
  .feature-cards.three,
  .feature-cards.four,
  .template-grid {
    grid-template-columns: 1fr;
  }

  .setting-columns > section,
  .encode-summary {
    padding: 0;
    border: 0;
  }
}

@media (max-width: 640px) {
  html,
  body {
    overflow-x: hidden;
  }

  .app-layout {
    display: block;
    width: 100%;
    min-width: 0;
  }

  .app-layout .studio-rail {
    position: sticky;
    top: 0;
    z-index: 20;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 10px;
    min-height: auto;
    padding: 10px;
    border-radius: 0;
  }

  .rail-logo {
    align-self: center;
    padding: 0;
  }

  .rail-logo strong {
    font-size: 1.18rem;
  }

  .rail-logo span {
    display: block;
    font-size: 0.5rem;
    letter-spacing: 0.28em;
  }

  .app-layout .rail-primary {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
  }

  .app-layout .rail-primary::-webkit-scrollbar {
    display: none;
  }

  .app-layout .rail-link,
  .app-layout .rail-link:not(.active) {
    flex: 0 0 auto;
    min-height: 36px;
    justify-content: center;
    gap: 7px;
    padding: 0 12px;
    font-size: 0.78rem;
    white-space: nowrap;
  }

  .app-layout .rail-link:nth-child(n+6) {
    display: none;
  }

  .rail-icon {
    width: auto;
    height: auto;
    font-size: 0.74rem;
  }

  .rail-tools,
  .rail-footer {
    display: none;
  }

  .app-layout .studio-main {
    width: 100%;
    min-width: 0;
    padding: 0 10px 14px;
  }

  .app-layout .studio-topbar {
    position: static;
    flex-direction: row;
    min-height: auto;
    margin: 0 -10px;
    padding: 10px;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    background: rgba(255, 255, 255, 0.06);
  }

  .command-title {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr);
    min-width: 0;
  }

  .app-layout .studio-topbar h1 {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .app-layout .topbar-actions {
    margin-left: auto;
  }

  .app-layout .topbar-actions .button-muted,
  .app-layout .topbar-actions .round-action:not(.notify-action),
  .account-chip {
    display: none;
  }

  .app-layout .top-create {
    min-width: 112px;
    min-height: 38px;
    padding: 0 12px;
  }

  .app-layout .workflow-steps {
    display: flex;
    gap: 8px;
    margin: 0 -10px;
    overflow-x: auto;
    padding: 10px 10px 12px;
    background: #f5f7fb;
    scrollbar-width: none;
  }

  .app-layout .workflow-steps::-webkit-scrollbar {
    display: none;
  }

  .app-layout .workflow-steps a {
    flex: 0 0 178px;
    grid-template-columns: 28px minmax(0, 1fr);
    padding: 10px;
    border: 1px solid #d8e0ec;
    border-radius: 8px;
    background: var(--panel-solid);
  }

  .app-layout .workflow-steps span {
    opacity: 1;
  }

  .app-layout .workflow-steps strong,
  .app-layout .workflow-steps small {
    white-space: normal;
  }

  .ratio-select {
    flex: 0 0 150px;
  }

  .studio-dashboard-grid {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-areas:
      "source"
      "preview"
      "ai"
      "encode"
      "output"
      "voice";
    gap: 10px;
  }

  .app-layout .panel,
  .feature-panel {
    width: 100%;
    min-width: 0;
    padding: 12px;
    border-radius: 8px;
  }

  .app-layout .field-grid.two,
  .app-layout .field-grid.three,
  .ai-controls.field-grid.three,
  .setting-columns,
  .output-layout,
  .feature-cards.two,
  .feature-cards.three,
  .feature-cards.four,
  .template-grid {
    grid-template-columns: 1fr;
  }

  .setting-columns > section,
  .encode-summary {
    padding: 0;
    border: 0;
  }

  .pro-upload {
    min-height: 116px;
  }

  .video-stage {
    min-height: auto;
    padding: 48px 8px 12px;
  }

  .phone-frame {
    width: min(260px, 82vw);
  }

  .phone-frame.is-wide {
    width: min(350px, 92vw);
  }

  .preview-note {
    font-size: 0.68rem;
  }

  .feature-panel-head {
    flex-direction: column;
  }
}

/* Final phone override: compact desktop-like studio with a real left rail */
@media (max-width: 640px) {
  html,
  body {
    width: 100%;
    overflow-x: hidden;
    background: #f4f8ff;
  }

  .app-layout {
    display: grid !important;
    grid-template-columns: 66px minmax(0, 1fr) !important;
    width: 100%;
    min-width: 0;
    min-height: 100dvh;
    overflow-x: hidden;
    background:
      linear-gradient(180deg, rgba(18, 111, 255, 0.08), transparent 280px),
      #f4f8ff;
  }

  .app-layout .studio-rail {
    position: sticky !important;
    top: 0;
    grid-column: 1;
    width: 66px !important;
    height: 100dvh;
    min-height: 100dvh;
    display: flex !important;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 12px 8px;
    border-radius: 0;
    overflow-y: auto;
    overflow-x: hidden;
    background:
      linear-gradient(180deg, rgba(15, 99, 255, 0.2), transparent 220px),
      #020817;
    box-shadow: 10px 0 30px rgba(2, 8, 23, 0.16);
    scrollbar-width: none;
  }

  .app-layout .studio-rail::-webkit-scrollbar {
    display: none;
  }

  .rail-logo {
    width: 100%;
    padding: 0 0 10px;
    justify-items: center;
    text-align: center;
  }

  .rail-logo strong {
    font-size: 1rem;
    line-height: 0.9;
  }

  .rail-logo span {
    display: block;
    font-size: 0.42rem;
    letter-spacing: 0.22em;
  }

  .app-layout .rail-primary {
    display: grid !important;
    grid-template-columns: 1fr;
    gap: 8px;
    width: 100%;
    overflow: visible;
    padding: 0;
  }

  .rail-tools,
  .rail-footer {
    display: none !important;
  }

  .app-layout .rail-link,
  .app-layout .rail-link:not(.active),
  .app-layout .rail-link:nth-child(n+6) {
    display: grid !important;
    width: 46px;
    min-width: 46px;
    height: 46px;
    min-height: 46px;
    place-items: center;
    padding: 0;
    border-radius: 14px;
    color: transparent;
    font-size: 0;
    white-space: nowrap;
  }

  .rail-icon {
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    color: #eaf5ff;
    font-size: 0.86rem;
  }

  .app-layout .rail-link.active {
    border-color: rgba(98, 178, 255, 0.48);
    background:
      radial-gradient(circle at 50% 14%, rgba(125, 211, 252, 0.34), transparent 44%),
      linear-gradient(180deg, #126fff, #0b3f9f);
    box-shadow: 0 12px 28px rgba(15, 99, 255, 0.24);
  }

  .app-layout .studio-main {
    grid-column: 2;
    width: 100%;
    min-width: 0;
    padding: 0 10px 18px;
    overflow-x: hidden;
  }

  .app-layout .studio-topbar {
    position: sticky;
    top: 0;
    z-index: 18;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
    min-height: 58px;
    margin: 0 -10px;
    padding: 8px 10px;
    border-bottom: 1px solid rgba(15, 99, 255, 0.1);
    background: rgba(248, 251, 255, 0.96);
    backdrop-filter: blur(14px);
  }

  .command-title {
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr);
    align-items: center;
    gap: 8px;
    min-width: 0;
  }

  .app-layout .studio-topbar h1 {
    max-width: 100%;
    overflow: hidden;
    font-size: 1rem;
    line-height: 1.05;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .app-layout .studio-topbar p {
    overflow: hidden;
    font-size: 0.74rem;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .app-layout .topbar-actions {
    display: flex;
    min-width: 0;
    justify-content: flex-end;
  }

  .app-layout .topbar-actions .button-muted,
  .app-layout .topbar-actions .round-action:not(.notify-action),
  .account-chip {
    display: none !important;
  }

  .app-layout .top-create {
    width: auto;
    min-width: 102px;
    min-height: 40px;
    padding: 0 12px;
    border-radius: 14px;
    font-size: 0.86rem;
  }

  .app-layout .workflow-steps {
    display: flex;
    gap: 8px;
    width: auto;
    margin: 0 -10px;
    padding: 10px;
    overflow-x: auto;
    background: transparent;
    scrollbar-width: none;
  }

  .app-layout .workflow-steps::-webkit-scrollbar {
    display: none;
  }

  .app-layout .workflow-steps a {
    flex: 0 0 138px;
    grid-template-columns: 30px minmax(0, 1fr);
    gap: 8px;
    min-width: 0;
    padding: 10px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.06);
  }

  .app-layout .workflow-steps strong {
    font-size: 0.8rem;
    line-height: 1.15;
  }

  .app-layout .workflow-steps small {
    font-size: 0.68rem;
    line-height: 1.15;
  }

  .ratio-select {
    flex: 0 0 124px;
  }

  .studio-dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "source"
      "preview"
      "ai"
      "encode"
      "output"
      "voice";
    gap: 12px;
    width: 100%;
    min-width: 0;
  }

  .app-layout .panel {
    width: 100%;
    min-width: 0;
    padding: 14px;
    border-radius: 14px;
    overflow: hidden;
  }

  .feature-panel:not([hidden]) {
    position: fixed;
    left: 76px;
    right: 10px;
    top: 70px;
    z-index: 40;
    max-height: calc(100dvh - 88px);
    overflow: auto;
    padding: 14px;
    border-radius: 16px;
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.28);
  }

  .feature-panel-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    gap: 10px;
  }

  .feature-panel-head h2 {
    font-size: 1.3rem;
  }

  .feature-panel-body .button {
    width: 100%;
  }

  .app-layout .field-grid.two,
  .app-layout .field-grid.three,
  .ai-controls.field-grid.three,
  .setting-columns,
  .output-layout,
  .feature-cards.two,
  .feature-cards.three,
  .feature-cards.four,
  .template-grid {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .pro-upload {
    min-height: 132px;
    padding: 18px 14px;
    text-align: center;
  }

  .pro-upload strong,
  .pro-upload small {
    max-width: 100%;
  }

  .video-stage {
    min-height: auto;
    padding: 44px 8px 14px;
  }

  .phone-frame {
    width: min(270px, calc(100vw - 106px));
    max-width: 100%;
  }

  .phone-frame.is-wide {
    width: min(330px, calc(100vw - 96px));
  }

  .preview-note {
    font-size: 0.68rem;
    line-height: 1.35;
  }
}

/* Keep AI / subtitle / cover controls in tidy 1 1 1 rows */
@media (min-width: 641px) {
  .app-layout .ai-controls.field-grid.three,
  .app-layout .setting-columns {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 12px;
  }
}

@media (max-width: 640px) {
  .app-layout .ai-panel,
  .app-layout .encode-panel {
    overflow: hidden;
  }

  .app-layout .ai-controls.field-grid.three,
  .app-layout .setting-columns {
    display: grid !important;
    grid-auto-flow: column;
    grid-auto-columns: minmax(176px, 72%);
    grid-template-columns: none !important;
    gap: 10px;
    margin-inline: -4px;
    padding: 2px 4px 10px;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
  }

  .app-layout .ai-controls.field-grid.three::-webkit-scrollbar,
  .app-layout .setting-columns::-webkit-scrollbar {
    display: none;
  }

  .app-layout .ai-controls.field-grid.three > .field,
  .app-layout .setting-columns > section {
    min-width: 0;
    scroll-snap-align: start;
  }

  .app-layout .setting-columns > section,
  .app-layout .setting-columns > section:last-child {
    padding: 12px;
    border: 1px solid #d8e5f6;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.06);
  }

  .app-layout .setting-columns .field-grid.two {
    grid-template-columns: minmax(0, 1fr) !important;
  }
}

/* Highest-priority concept layout pass */
@media (min-width: 1281px) {
  .app-layout .studio-dashboard-grid {
    display: grid;
    grid-template-columns: minmax(360px, 0.98fr) minmax(330px, 0.9fr) minmax(360px, 1.02fr) !important;
    grid-template-areas:
      "source ai preview"
      "source encode preview"
      "output output voice" !important;
    gap: 14px;
  }
}

@media (min-width: 901px) and (max-width: 1280px) {
  .app-layout .studio-dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(360px, 0.92fr) !important;
    grid-template-areas:
      "source preview"
      "ai preview"
      "encode preview"
      "output output"
      "voice voice" !important;
    gap: 14px;
  }
}

@media (min-width: 901px) {
  .app-layout .preview-panel {
    min-height: 100%;
  }

  .app-layout .video-stage {
    min-height: 520px;
  }
}

@media (min-width: 641px) and (max-width: 900px) {
  .app-layout .studio-dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) !important;
    grid-template-areas:
      "source"
      "preview"
      "ai"
      "encode"
      "output"
      "voice" !important;
    gap: 12px;
  }
}

/* Final mobile repair: readable rail, inline workflow, normal preview size */
@media (max-width: 640px) {
  .app-layout {
    grid-template-columns: 58px minmax(0, 1fr) !important;
  }

  .app-layout .studio-rail {
    width: 58px !important;
    padding: 10px 6px !important;
  }

  .app-layout .rail-link,
  .app-layout .rail-link:not(.active),
  .app-layout .rail-link:nth-child(n+6),
  .rail-icon {
    width: 42px !important;
    min-width: 42px !important;
    height: 42px !important;
    min-height: 42px !important;
  }

  .rail-collapsed .app-layout {
    grid-template-columns: 58px minmax(0, 1fr) !important;
  }

  .rail-collapsed .app-layout .studio-rail {
    position: fixed !important;
    left: 0;
    top: 0;
    z-index: 80;
    width: min(220px, 72vw) !important;
    align-items: stretch;
    padding: 12px !important;
    box-shadow: 18px 0 42px rgba(2, 8, 23, 0.28);
  }

  .rail-collapsed .app-layout .rail-logo {
    justify-items: start;
    text-align: left;
  }

  .rail-collapsed .rail-logo span {
    font-size: 0.48rem !important;
  }

  .rail-collapsed .app-layout .rail-primary {
    gap: 7px;
  }

  .rail-collapsed .app-layout .rail-link,
  .rail-collapsed .app-layout .rail-link:not(.active),
  .rail-collapsed .app-layout .rail-link:nth-child(n+6) {
    display: flex !important;
    width: 100% !important;
    min-width: 0 !important;
    height: 42px !important;
    min-height: 42px !important;
    justify-content: flex-start;
    gap: 10px;
    padding: 0 10px !important;
    color: #eaf5ff;
    font-size: 0.78rem !important;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .rail-collapsed .rail-icon {
    flex: 0 0 30px;
    width: 30px !important;
    min-width: 30px !important;
    height: 30px !important;
    min-height: 30px !important;
  }

  .app-layout .workflow-steps {
    display: grid !important;
    grid-template-columns: repeat(4, max-content) !important;
    gap: 8px;
    align-items: center;
    overflow-x: auto;
    padding-block: 8px;
  }

  .app-layout .workflow-steps a {
    display: inline-flex !important;
    flex: none;
    min-height: 36px;
    min-width: max-content;
    align-items: center;
    gap: 7px;
    padding: 7px 10px !important;
    border-radius: 999px;
  }

  .app-layout .workflow-steps span {
    width: 22px !important;
    height: 22px !important;
    font-size: 0.68rem;
  }

  .app-layout .workflow-steps strong {
    font-size: 0.76rem !important;
    white-space: nowrap;
  }

  .app-layout .workflow-steps small,
  .ratio-select {
    display: none !important;
  }

  .video-stage {
    width: 100%;
    padding: 42px 0 12px !important;
  }

  .phone-frame,
  .phone-frame.is-wide {
    width: calc(100vw - 104px) !important;
    max-width: 420px !important;
  }
}

@media (min-width: 641px) {
  .phone-frame {
    width: min(420px, 58vw);
  }

  .phone-frame.is-wide {
    width: min(620px, 64vw);
  }
}

/* EOF phone fix: no permanent left rail, no side-by-side preview on phones. */
@media (max-width: 640px) {
  html,
  body {
    overflow-x: hidden !important;
  }

  .app-layout {
    display: block !important;
    grid-template-columns: none !important;
    width: 100% !important;
    min-height: 100dvh;
  }

  .app-layout .studio-rail {
    position: fixed !important;
    inset: 0 auto 0 0;
    z-index: 80;
    width: min(232px, 78vw) !important;
    height: 100dvh !important;
    min-height: 100dvh !important;
    align-items: stretch !important;
    padding: 14px 12px !important;
    transform: translateX(-105%) !important;
    transition: transform 180ms ease;
    box-shadow: 18px 0 42px rgba(2, 8, 23, 0.28);
  }

  .rail-collapsed .app-layout .studio-rail {
    transform: translateX(0) !important;
  }

  .app-layout .rail-link,
  .app-layout .rail-link:not(.active),
  .app-layout .rail-link:nth-child(n+6) {
    display: flex !important;
    width: 100% !important;
    min-width: 0 !important;
    height: 44px !important;
    min-height: 44px !important;
    justify-content: flex-start !important;
    gap: 10px;
    padding: 0 10px !important;
    color: #eaf5ff;
    font-size: 0.82rem !important;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .rail-icon {
    flex: 0 0 30px;
    width: 30px !important;
    min-width: 30px !important;
    height: 30px !important;
    min-height: 30px !important;
  }

  .app-layout .studio-main {
    grid-column: auto !important;
    width: 100% !important;
    min-width: 0 !important;
    padding: 0 10px 18px !important;
    overflow-x: hidden !important;
  }

  .app-layout .studio-topbar {
    margin: 0 -10px !important;
  }

  .app-layout .workflow-steps {
    display: flex !important;
    grid-template-columns: none !important;
    gap: 8px !important;
    margin: 0 -10px !important;
    padding: 10px !important;
    overflow-x: auto !important;
    scrollbar-width: none;
  }

  .app-layout .workflow-steps::-webkit-scrollbar {
    display: none;
  }

  .app-layout .workflow-steps a {
    display: inline-flex !important;
    flex: 0 0 auto !important;
    min-height: 38px !important;
    min-width: max-content !important;
    align-items: center !important;
    gap: 7px !important;
    padding: 7px 11px !important;
    border-radius: 999px !important;
  }

  .app-layout .workflow-steps span {
    width: 22px !important;
    height: 22px !important;
    font-size: 0.68rem !important;
  }

  .app-layout .workflow-steps strong {
    font-size: 0.78rem !important;
    white-space: nowrap !important;
  }

  .app-layout .workflow-steps small,
  .ratio-select {
    display: none !important;
  }

  .app-layout .studio-dashboard-grid {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    grid-template-areas:
      "source"
      "preview"
      "ai"
      "encode"
      "output"
      "voice" !important;
    gap: 12px !important;
    width: 100% !important;
    min-width: 0 !important;
  }

  .app-layout .panel,
  .app-layout .preview-panel {
    width: 100% !important;
    min-width: 0 !important;
  }

  .video-stage {
    width: 100% !important;
    min-height: auto !important;
    padding: 46px 10px 14px !important;
  }

  .phone-frame,
  .phone-frame.is-wide {
    width: min(100%, 320px) !important;
    max-width: 100% !important;
    margin-inline: auto !important;
  }
}

/* ============================================================
   CINEMA DARK THEME — blue/cyan + deep dark studio
   ============================================================ */

.app-layout {
  --cinema-bg:        #090c14;
  --cinema-surface:   #0f1623;
  --cinema-surface2:  #141d2e;
  --cinema-border:    rgba(255, 255, 255, 0.07);
  --cinema-border2:   rgba(255, 255, 255, 0.11);
  --cinema-gold:      #06b6d4;
  --cinema-gold-dim:  rgba(6, 182, 212, 0.18);
  --cinema-gold-glow: rgba(6, 182, 212, 0.10);
  --cinema-blue:      #3b82f6;
  --cinema-text:      #e2e8f0;
  --cinema-muted:     #5a7090;
  --cinema-muted2:    #8aa0bb;
  background: var(--cinema-bg) !important;
}

/* Topbar */
.app-layout .studio-topbar {
  background: var(--cinema-surface) !important;
  border-bottom: 1px solid var(--cinema-border) !important;
  color: var(--cinema-text) !important;
}
.app-layout .studio-topbar h1 { color: var(--cinema-text) !important; }
.app-layout .studio-topbar p:last-child { color: var(--cinema-muted) !important; }
.app-layout .icon-button { color: var(--cinema-muted2) !important; background: transparent !important; }
.app-layout .icon-button:hover { background: var(--cinema-surface2) !important; color: var(--cinema-text) !important; }

/* Workflow steps */
.app-layout .workflow-steps a { color: var(--cinema-muted) !important; }
.app-layout .workflow-steps strong { color: var(--cinema-muted2) !important; }
.app-layout .workflow-steps span { border-color: var(--cinema-border2) !important; color: var(--cinema-muted) !important; background: var(--cinema-surface2) !important; }
.app-layout .workflow-steps .active span { border-color: var(--cinema-gold) !important; color: #0a0d14 !important; background: var(--cinema-gold) !important; }
.app-layout .workflow-steps .active strong { color: var(--cinema-gold) !important; }
.app-layout .ratio-select select { border-color: var(--cinema-border2) !important; color: var(--cinema-text) !important; background: var(--cinema-surface2) !important; }

/* Panels */
.app-layout .panel { border-color: var(--cinema-border) !important; background: var(--cinema-surface) !important; color: var(--cinema-text) !important; }
.app-layout .compact-head h2, .app-layout h2, .app-layout h3 { color: var(--cinema-text) !important; }
.app-layout .eyeline { color: var(--cinema-gold) !important; }

/* Form inputs */
.app-layout .field span { color: var(--cinema-muted2) !important; }
.app-layout .field input,
.app-layout .field select,
.app-layout .field textarea { border-color: var(--cinema-border2) !important; color: var(--cinema-text) !important; background: var(--cinema-surface2) !important; }
.app-layout .field input:focus,
.app-layout .field select:focus,
.app-layout .field textarea:focus { border-color: rgba(6, 182, 212, 0.5) !important; box-shadow: 0 0 0 3px var(--cinema-gold-glow) !important; }

/* Upload zone */
.app-layout .pro-upload { border-color: var(--cinema-border2) !important; background: var(--cinema-surface2) !important; }
.app-layout .pro-upload strong { color: var(--cinema-muted2) !important; }
.app-layout .pro-upload em { border-color: var(--cinema-border2) !important; color: var(--cinema-text) !important; background: var(--cinema-surface) !important; }
.app-layout .upload-cloud { color: var(--cinema-gold) !important; }

/* Buttons */
.app-layout .button-primary, .app-layout .top-create {
  background: linear-gradient(135deg, var(--cinema-blue), var(--cinema-gold)) !important;
  color: #04121f !important;
  box-shadow: 0 8px 24px rgba(6, 182, 212, 0.30) !important;
}
.app-layout .button-muted { border-color: var(--cinema-border2) !important; color: var(--cinema-muted2) !important; background: var(--cinema-surface2) !important; }
.app-layout .button-muted:hover { color: var(--cinema-text) !important; border-color: var(--cinema-gold) !important; }
.app-layout .shortcuts-button kbd { border-color: var(--cinema-border2) !important; color: var(--cinema-muted) !important; background: var(--cinema-surface2) !important; }
.app-layout .round-action { border-color: var(--cinema-border) !important; color: var(--cinema-muted2) !important; }
.app-layout .round-action:hover { color: var(--cinema-gold) !important; }
.app-layout .account-chip { border-color: var(--cinema-border) !important; }
.app-layout .account-chip strong { color: var(--cinema-text) !important; }
.app-layout .account-chip small { color: var(--cinema-muted) !important; }
.app-layout .save-dot { background: var(--cinema-gold) !important; }

/* Voice card */
.app-layout .voice-card { border-color: var(--cinema-border2) !important; background: var(--cinema-surface2) !important; }
.app-layout .voice-card strong { color: var(--cinema-text) !important; }
.app-layout .voice-card small { color: var(--cinema-muted) !important; }
.app-layout .avatar-dot { background: linear-gradient(135deg, #1e293b, var(--cinema-gold)) !important; color: #0a0d14 !important; }

/* Encode panel */
.app-layout .setting-columns > section { border-color: var(--cinema-border) !important; }
.app-layout .encode-info-panel { border-color: var(--cinema-border2) !important; background: var(--cinema-surface) !important; }
.app-layout .encode-info-head { color: var(--cinema-text) !important; }
.app-layout .encode-close { border-color: var(--cinema-border2) !important; color: var(--cinema-muted2) !important; background: var(--cinema-surface2) !important; }
.app-layout .encode-specs dt { color: var(--cinema-muted) !important; }
.app-layout .encode-specs dd { color: var(--cinema-text) !important; }

/* Switch toggle */
.app-layout .switch-row input[type="checkbox"] { background: var(--cinema-surface2) !important; }
.app-layout .switch-row input[type="checkbox"]:checked { background: var(--cinema-gold) !important; }

/* Output panel */
.app-layout .output-header h2 { color: var(--cinema-text) !important; }
.app-layout .output-sub { color: var(--cinema-muted) !important; }
.app-layout .export-card-empty { border-color: var(--cinema-border2) !important; background: var(--cinema-surface2) !important; color: var(--cinema-muted) !important; }
.app-layout .export-card-empty span { color: var(--cinema-muted2) !important; }
.app-layout .export-card { border-color: var(--cinema-border2) !important; background: var(--cinema-surface) !important; }
.app-layout .export-ratio { color: var(--cinema-text) !important; }
.app-layout .export-date { color: var(--cinema-muted) !important; }
.app-layout .export-badge.pending { color: var(--cinema-gold) !important; background: var(--cinema-gold-dim) !important; }
.app-layout .export-badge.ready { color: #34d399 !important; background: rgba(52, 211, 153, 0.15) !important; }
.app-layout .encode-info-toggle { border-color: var(--cinema-border2) !important; color: var(--cinema-muted2) !important; background: var(--cinema-surface2) !important; }
.app-layout .encode-info-toggle:hover { color: var(--cinema-gold) !important; border-color: var(--cinema-gold) !important; }

/* Feature panel */
.app-layout .feature-panel { border-color: var(--cinema-border) !important; background: var(--cinema-surface) !important; color: var(--cinema-text) !important; }
.app-layout .feature-panel-head { border-color: var(--cinema-border) !important; }
.app-layout .feature-panel-head h2 { color: var(--cinema-text) !important; }
.app-layout .feature-panel-head p:last-child { color: var(--cinema-muted) !important; }
.app-layout .feature-card, .app-layout .template-card { border-color: var(--cinema-border2) !important; background: var(--cinema-surface2) !important; }
.app-layout .feature-card strong, .app-layout .template-card strong { color: var(--cinema-text) !important; }
.app-layout .feature-card span, .app-layout .template-card span, .app-layout .feature-card small { color: var(--cinema-muted) !important; }
.app-layout .feature-card:hover, .app-layout .template-card:hover { border-color: var(--cinema-gold) !important; box-shadow: 0 8px 20px var(--cinema-gold-glow) !important; }

/* Preview panel */
.app-layout .preview-panel { background: var(--cinema-surface) !important; }
.app-layout .video-stage { background: var(--cinema-bg) !important; }
.app-layout .pro-preview-toolbar p { color: var(--cinema-muted) !important; }
.app-layout .segmented-control { border-color: var(--cinema-border2) !important; background: var(--cinema-surface2) !important; }
.app-layout .segmented-control button { color: var(--cinema-muted2) !important; }
.app-layout .segmented-control .active { color: var(--cinema-gold) !important; background: var(--cinema-surface) !important; }
.app-layout .preview-note { border-color: var(--cinema-border) !important; color: var(--cinema-muted) !important; }

/* Sidebar rail */
.app-layout .studio-rail { background: linear-gradient(180deg, #06080f 0%, #0b1018 100%) !important; border-right: 1px solid var(--cinema-border) !important; }
.app-layout .rail-logo strong { color: #ffffff !important; }
.app-layout .rail-logo span { color: var(--cinema-gold) !important; }
.app-layout .rail-link { color: var(--cinema-muted2) !important; }
.app-layout .rail-link:hover { color: var(--cinema-text) !important; background: rgba(6, 182, 212, 0.08) !important; border-color: rgba(6, 182, 212, 0.2) !important; }
.app-layout .rail-link.active { color: var(--cinema-gold) !important; background: var(--cinema-gold-dim) !important; border-color: rgba(6, 182, 212, 0.3) !important; }
.app-layout .rail-tools p { color: rgba(6, 182, 212, 0.55) !important; }
.app-layout .rail-tools { border-color: var(--cinema-border) !important; }
.app-layout .storage-card { border-color: var(--cinema-border) !important; background: rgba(255, 255, 255, 0.03) !important; }
.app-layout .storage-card span, .app-layout .storage-card small { color: var(--cinema-muted) !important; }
.app-layout .storage-card strong { color: var(--cinema-text) !important; }
.app-layout .storage-card i { background: rgba(255, 255, 255, 0.1) !important; }
.app-layout .storage-card b { background: linear-gradient(90deg, var(--cinema-blue), var(--cinema-gold)) !important; }
.app-layout .upgrade-button { border-color: rgba(6, 182, 212, 0.4) !important; color: var(--cinema-gold) !important; background: var(--cinema-gold-dim) !important; font-size: 0.82rem !important; }
.app-layout .upgrade-button:hover { background: rgba(6, 182, 212, 0.28) !important; border-color: var(--cinema-gold) !important; }

/* Notifications */
.app-layout .notify-action span { background: #ef4444 !important; color: #fff !important; border-color: var(--cinema-surface) !important; }

/* ============================================================ */

/* Ratio select — cinema theme */
.app-layout .ratio-select select {
  border-color: var(--cinema-border2) !important;
  color: var(--cinema-text) !important;
  background: var(--cinema-surface2) !important;
  padding: 0 10px;
}
.app-layout .ratio-label {
  color: var(--cinema-muted) !important;
}

/* Encode panel — new 2-row layout */
.encode-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}

.encode-section {
  min-width: 0;
  padding: 0 20px 0 0;
  border-right: 1px solid var(--cinema-border, #dce4ef);
}

.encode-section:last-child {
  padding: 0 0 0 20px;
  border-right: 0;
}

.encode-watermark-row {
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 20px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--cinema-border, #dce4ef);
}

.encode-watermark-row .encode-section {
  padding: 0;
  border-right: 0;
}

.encode-submit {
  flex-shrink: 0;
  min-width: 160px;
}

@media (max-width: 640px) {
  .encode-row {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .encode-section {
    padding: 0;
    border-right: 0;
    border-bottom: 1px solid var(--cinema-border, #dce4ef);
    padding-bottom: 16px;
  }
  .encode-section:last-child {
    padding: 0;
    border: 0;
  }
  .encode-watermark-row {
    grid-template-columns: 1fr;
  }
  .encode-submit {
    min-width: 0;
    width: 100%;
  }
}

.app-layout .encode-watermark-row {
  border-color: var(--cinema-border) !important;
}

.app-layout .encode-section {
  border-color: var(--cinema-border) !important;
}

/* ============================================================
   SIDE TABS (stabs) — AI/Voice, Subtitles, Cover, Watermark
   ============================================================ */

.settings-panel {
  padding: 0 !important;
  overflow: hidden;
}

.stabs-layout {
  display: grid;
  grid-template-columns: 130px 1fr;
  min-height: 280px;
}

.stabs-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 8px;
  border-right: 1px solid var(--cinema-border, #dce4ef);
  background: var(--cinema-surface2, #f4f7fb);
}

.stab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border: 0;
  border-radius: 7px;
  color: var(--muted);
  background: transparent;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  text-align: left;
  transition: background 140ms ease, color 140ms ease;
  white-space: nowrap;
}

.stab:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.05);
}

.stab.active {
  color: #04121f;
  background: linear-gradient(135deg, var(--blue), var(--ember));
  font-weight: 800;
}

.stab-icon {
  width: 18px;
  text-align: center;
  font-size: 0.76rem;
  flex-shrink: 0;
}

.stabs-spacer {
  flex: 1;
}

.stab-submit {
  min-height: 38px !important;
  padding: 0 10px !important;
  font-size: 0.76rem !important;
  border-radius: 7px !important;
  width: 100%;
}

.stabs-body {
  padding: 16px;
  min-width: 0;
}

.stab-pane {
  display: none;
}

.stab-pane.active {
  display: block;
}

@media (max-width: 560px) {
  .stabs-layout {
    grid-template-columns: 1fr;
  }
  .stabs-nav {
    flex-direction: row;
    flex-wrap: wrap;
    border-right: 0;
    border-bottom: 1px solid var(--cinema-border, #dce4ef);
    padding: 8px;
  }
  .stabs-spacer { display: none; }
  .stab-submit { width: auto; }
}

/* Overlay tab pane */
.stab-pane-hint {
  margin: 0 0 4px;
  color: var(--cinema-muted, #64748b);
  font-size: 0.76rem;
  line-height: 1.5;
}

.stab-pane input[type="range"] {
  width: 100%;
  accent-color: var(--cinema-gold, #06b6d4);
}

.stab-pane input[type="color"] {
  width: 100%;
  min-height: 34px;
  padding: 2px 4px;
  border-radius: 6px;
  cursor: pointer;
}

/* ============================================================
   HISTORY TABLE — row-based export log with delete
   ============================================================ */

.history-table {
  margin-top: 12px;
  border: 1px solid var(--cinema-border, #dce4ef);
  border-radius: 8px;
  overflow: hidden;
}

/* Single-line col widths: thumb+title | format | date | status | actions */
.history-head,
.history-row {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0 14px;
}

.history-head {
  height: 34px;
  border-bottom: 1px solid var(--cinema-border, #dce4ef);
  background: var(--cinema-surface2, rgba(255,255,255,0.04));
  color: var(--cinema-muted, #64748b);
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.history-row {
  height: 48px;
  border-bottom: 1px solid var(--cinema-border, #dce4ef);
  transition: background 140ms ease;
}

.history-row:last-child { border-bottom: 0; }
.history-row:hover { background: rgba(6,182,212,0.05); }

/* Column widths */
.history-col-title  { flex: 1 1 0; min-width: 0; }
.history-col-format { flex: 0 0 60px; }
.history-col-date   { flex: 0 0 120px; }
.history-col-status { flex: 0 0 90px; }
.history-col-action { flex: 0 0 72px; display: flex; gap: 5px; justify-content: flex-end; }

.history-thumb-cell {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.history-thumb {
  display: grid;
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  place-items: center;
  border-radius: 5px;
  background: linear-gradient(140deg, #0c1e38, #1a3558);
  color: rgba(255,255,255,0.65);
  font-size: 0.52rem;
  font-weight: 900;
}

.history-title-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--cinema-text, #e2e8f0);
  font-size: 0.8rem;
  font-weight: 700;
}

.history-format,
.history-date {
  color: var(--cinema-muted2, #8aa0bb);
  font-size: 0.74rem;
}

.history-actions {
  display: flex;
  align-items: center;
  gap: 5px;
}

.hist-btn {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 1px solid var(--cinema-border2, rgba(255,255,255,0.11));
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: background 140ms, border-color 140ms, color 140ms;
}

.hist-download {
  color: #60a5fa;
  background: rgba(59,130,246,0.12);
  border-color: rgba(59,130,246,0.28);
}
.hist-download:hover { background: rgba(59,130,246,0.24); }

.hist-delete {
  color: #f87171;
  background: rgba(239,68,68,0.1);
  border-color: rgba(239,68,68,0.24);
}
.hist-delete:hover { background: rgba(239,68,68,0.22); border-color: rgba(239,68,68,0.44); }

.history-empty {
  padding: 20px;
  text-align: center;
  color: var(--cinema-muted, #5a7090);
  font-size: 0.82rem;
}

@media (max-width: 560px) {
  .history-col-format,
  .history-col-status { display: none; }
  .history-col-date { flex: 0 0 90px; font-size: 0.66rem; }
}

/* ============================================================
   RECAP CARD GRID — 4 columns with video thumbnails
   ============================================================ */

.recap-card-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.recap-card {
  border: 1px solid var(--cinema-border, rgba(255,255,255,0.07));
  border-radius: 8px;
  overflow: hidden;
  background: var(--cinema-surface, #0f1623);
  transition: border-color 160ms ease, box-shadow 160ms ease;
  cursor: pointer;
}

.recap-card:hover {
  border-color: rgba(6,182,212,0.35);
  box-shadow: 0 8px 24px rgba(6,182,212,0.12);
}

/* Thumbnail area — 9:16 aspect */
.recap-thumb {
  position: relative;
  aspect-ratio: 9 / 16;
  overflow: hidden;
  background: linear-gradient(160deg, #0c1e38 0%, #1a3558 60%, #0a1628 100%);
}

.recap-thumb-video,
.recap-thumb-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.recap-thumb-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.recap-thumb-placeholder span {
  color: rgba(255,255,255,0.6);
  font-size: 1.4rem;
  font-weight: 900;
  letter-spacing: -0.02em;
}

.recap-thumb-placeholder small {
  color: rgba(255,255,255,0.3);
  font-size: 0.52rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

/* Badge — top left */
.recap-thumb .export-badge {
  position: absolute;
  top: 7px;
  left: 7px;
  z-index: 2;
}

/* Action buttons — bottom right, show on hover */
.recap-card-actions {
  position: absolute;
  bottom: 7px;
  right: 7px;
  display: flex;
  gap: 5px;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 160ms ease, transform 160ms ease;
  z-index: 2;
}

.recap-card:hover .recap-card-actions {
  opacity: 1;
  transform: translateY(0);
}

/* Meta below thumbnail */
.recap-card-meta {
  padding: 8px 10px;
}

.recap-card-title {
  margin: 0 0 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--cinema-text, #e2e8f0);
  font-size: 0.76rem;
  font-weight: 700;
}

.recap-card-info {
  margin: 0;
  color: var(--cinema-muted, #5a7090);
  font-size: 0.66rem;
}

@media (max-width: 700px) {
  .recap-card-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 480px) {
  .recap-card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Ratio select — prominent in workflow steps */
.ratio-select-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-left: auto;
}

.ratio-select-input {
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--cinema-gold, #06b6d4) !important;
  border-radius: 8px;
  color: var(--cinema-gold, #06b6d4) !important;
  background: var(--cinema-gold-dim, rgba(6,182,212,0.12)) !important;
  font-size: 0.78rem;
  font-weight: 800;
  cursor: pointer;
  outline: none;
  min-width: 130px;
}

.ratio-select-input:focus {
  box-shadow: 0 0 0 3px rgba(6,182,212,0.2);
}

.ratio-select-input option {
  background: #141d2e;
  color: #e2e8f0;
}

/* Ratio select compact fix */
.ratio-select-input {
  min-width: 90px !important;
  max-width: 90px !important;
  min-height: 34px !important;
  padding: 0 6px !important;
  font-size: 0.8rem !important;
  white-space: nowrap;
}

.ratio-select-wrap { display: none !important; }

/* ============================================================
   MOBILE SIDEBAR OVERLAY FIX — upgrade text + overlay backdrop
   On mobile (≤640px), rail-collapsed opens full-panel overlay,
   so upgrade text must show and credits must be visible.
   ============================================================ */
@media (max-width: 640px) {
  /* Show upgrade text when sidebar is open as full panel */
  .rail-collapsed .upgrade-text { display: inline !important; }
  .rail-collapsed .upgrade-icon { display: inline !important; }
  .upgrade-button {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 8px !important;
    font-size: 0.82rem !important;
  }

  /* Credits card visible */
  .rail-collapsed .storage-card { display: grid !important; }

  /* Dim overlay behind open sidebar */
  .rail-collapsed::before {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 79;
    pointer-events: none;
  }
}

/* ============================================================
   LIVE SUPPORT CHAT WIDGET (floating, bottom-right)
   ============================================================ */

.support-chat {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 1200;
  font-family: inherit;
}

.support-fab {
  position: relative;
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  color: #fff;
  background: linear-gradient(135deg, #3b82f6, #06b6d4);
  box-shadow: 0 10px 28px rgba(6, 182, 212, 0.45);
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.support-fab:hover { transform: translateY(-2px); box-shadow: 0 14px 34px rgba(6, 182, 212, 0.55); }

.support-fab svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.support-fab .support-fab-close { display: none; }
.support-chat.open .support-fab .support-fab-open { display: none; }
.support-chat.open .support-fab .support-fab-close { display: block; }

.support-fab-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  display: grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 999px;
  border: 2px solid #0f1623;
  background: #ef4444;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 800;
  line-height: 1;
}
.support-fab-badge[hidden] { display: none; }

.support-window {
  position: absolute;
  right: 0;
  bottom: 70px;
  display: flex;
  flex-direction: column;
  width: min(360px, calc(100vw - 32px));
  height: min(520px, calc(100vh - 120px));
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  background: #0f1623;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
  animation: support-pop 160ms ease;
}
.support-window[hidden] { display: none; }

@keyframes support-pop {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.support-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  color: #fff;
  background: linear-gradient(135deg, #3b82f6, #06b6d4);
}
.support-head strong { display: block; font-size: 0.95rem; }
.support-head small { display: block; opacity: 0.85; font-size: 0.72rem; margin-top: 2px; }
.support-x { background: none; border: none; color: #fff; font-size: 1.5rem; line-height: 1; cursor: pointer; opacity: 0.9; }
.support-x:hover { opacity: 1; }

.support-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #0b1018;
}

.support-empty { margin: auto; text-align: center; color: #8aa0bb; font-size: 0.85rem; line-height: 1.6; padding: 0 10px; }

.support-msg {
  max-width: 80%;
  padding: 8px 12px;
  border-radius: 14px;
  font-size: 0.86rem;
  line-height: 1.45;
  word-wrap: break-word;
  white-space: pre-wrap;
}
.support-msg.user {
  align-self: flex-end;
  color: #04121f;
  background: linear-gradient(135deg, #60a5fa, #22d3ee);
  border-bottom-right-radius: 4px;
}
.support-msg.agent {
  align-self: flex-start;
  color: #e2e8f0;
  background: #1d2738;
  border-bottom-left-radius: 4px;
}
.support-msg .support-meta { display: block; margin-top: 4px; font-size: 0.62rem; opacity: 0.7; }

.support-input {
  display: flex;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: #0f1623;
}
.support-input input {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  background: #0b1018;
  color: #e2e8f0;
  font-size: 0.86rem;
  outline: none;
}
.support-input input:focus { border-color: #06b6d4; }
.support-input button {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  color: #04121f;
  background: linear-gradient(135deg, #3b82f6, #06b6d4);
}
.support-input button:disabled { opacity: 0.5; cursor: default; }
.support-input button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
