:root {
  --bg0: #0a0a0f;
  --bg1: #12121a;
  --bg2: #1a1a26;
  --line: rgba(255, 255, 255, 0.08);
  --text: #f4f4f8;
  --muted: #9a9ab0;
  --accent: #ff2d55;
  --accent2: #5b8cff;
  --ok: #2dd4a8;
  --danger: #ff5c7a;
  --radius: 16px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font-ui: "Segoe UI", "Heebo", system-ui, sans-serif;
  --font-cap: "Impact", "Arial Black", "Heebo", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg0);
  color: var(--text);
  font-family: var(--font-ui);
  overflow: hidden;
}

body {
  display: flex;
  flex-direction: column;
}

/* —— top bar —— */
.app-bar {
  position: relative;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px 10px 36px;
  background: linear-gradient(180deg, #161622, #0e0e16);
  border-bottom: 1px solid var(--line);
  z-index: 20;
}

/* Physical top-left (LTR coords) even when page is RTL */
.ready-dot {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 22px;
  padding: 0;
  border: 2px solid rgba(255, 255, 255, 0.28);
  border-radius: 50%;
  cursor: default;
  background: transparent;
  box-shadow: none;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  color: transparent;
}

.ready-dot[data-state="booting"],
.ready-dot[data-state="loading"] {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.22);
  border-top-color: #f5a524;
  color: transparent;
  animation: ready-spin-header 0.75s linear infinite;
}

.ready-dot[data-state="ready"] {
  background: #2dd4a8;
  border-color: #2dd4a8;
  color: #04120e;
  box-shadow: 0 0 0 2px rgba(45, 212, 168, 0.35), 0 0 10px rgba(45, 212, 168, 0.45);
  animation: none;
}

.ready-dot[data-state="error"] {
  background: #ff5c7a;
  border-color: #ff5c7a;
  color: #fff;
  animation: none;
}

@keyframes ready-spin-header {
  to { transform: translateY(-50%) rotate(360deg); }
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.brand h1 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.brand .tag {
  font-size: 11px;
  color: var(--muted);
}

.badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(255, 45, 85, 0.15);
  color: var(--accent);
  border: 1px solid rgba(255, 45, 85, 0.35);
  white-space: nowrap;
}

/* —— stage (TikTok fullscreen player) —— */
.stage-wrap {
  flex: 1 1 auto;
  min-height: 0;
  display: block;
  height: 100%;
  position: relative;
}

.player-column {
  position: absolute;
  inset: 0;
  min-height: 0;
  background: #000;
  display: flex;
  flex-direction: column;
}

.phone-frame {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  margin: 0;
  width: 100%;
  max-width: none;
  height: 100%;
  background: #000;
  overflow: hidden;
  border-radius: 0;
}

.video-layer {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
}

#video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.caption-overlay {
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: 18%;
  z-index: 5;
  pointer-events: none;
  text-align: center;
  transition: bottom 0.15s ease;
}

.caption-overlay[data-position="top"] { top: 12%; bottom: auto; }
.caption-overlay[data-position="middle"] { top: 42%; bottom: auto; }
.caption-overlay[data-position="bottom"] { bottom: 18%; top: auto; }

.caption-text {
  display: inline-block;
  max-width: 100%;
  margin: 0;
  padding: 0;
  font-family: var(--font-cap);
  font-size: var(--cap-font-size, clamp(20px, 5vw, 30px));
  line-height: 1.25;
  word-wrap: break-word;
  white-space: pre-wrap;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.08s ease, font-size 0.15s ease;
}

.phone-frame[data-cap-size="sm"] {
  --cap-font-size: clamp(15px, 3.6vw, 20px);
}
.phone-frame[data-cap-size="md"] {
  --cap-font-size: clamp(20px, 5vw, 30px);
}
.phone-frame[data-cap-size="lg"] {
  --cap-font-size: clamp(26px, 6.5vw, 38px);
}
.phone-frame[data-cap-size="xl"] {
  --cap-font-size: clamp(32px, 8vw, 48px);
}

.caption-text.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.caption-text.is-typing::after {
  content: '';
  display: inline-block;
  width: 0.08em;
  height: 0.9em;
  margin-inline-start: 2px;
  background: currentColor;
  vertical-align: -0.05em;
  animation: caret-blink 0.7s step-end infinite;
}

@keyframes caret-blink {
  50% { opacity: 0; }
}

.caption-text.empty {
  opacity: 0 !important;
}

.caption-text.empty.is-typing::after {
  display: none;
}

/* styles */
.cap-style-classic .caption-text {
  color: #fff;
  text-shadow:
    0 0 4px #000,
    0 2px 0 #000,
    2px 2px 0 #000,
    -1px -1px 0 #000;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.cap-style-boxed .caption-text {
  color: #fff;
  background: rgba(0, 0, 0, 0.72);
  padding: 8px 12px;
  border-radius: 8px;
  font-weight: 700;
  text-shadow: none;
}

.cap-style-karaoke .caption-text {
  color: #ffe566;
  text-shadow: 0 0 8px rgba(255, 229, 102, 0.55), 0 2px 0 #000;
  font-weight: 900;
  letter-spacing: 0.04em;
}

.cap-style-neon .caption-text {
  color: #fff;
  text-shadow:
    0 0 6px #ff2d55,
    0 0 14px #ff2d55,
    0 0 28px #5b8cff;
  font-weight: 800;
}

.cap-style-minimal .caption-text {
  color: #f0f0f5;
  font-family: var(--font-ui);
  font-weight: 600;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
  letter-spacing: 0;
}

.caption-overlay[dir="rtl"] .caption-text {
  direction: rtl;
  unicode-bidi: plaintext;
}

/* empty / drop zone */
.drop-hint {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 24px;
  text-align: center;
  background: radial-gradient(ellipse at center, #1a1a28 0%, #050508 70%);
  color: var(--muted);
  cursor: pointer;
}

.drop-hint[hidden] { display: none !important; }

.drop-hint strong {
  color: var(--text);
  font-size: 18px;
}

.drop-hint.is-drag {
  outline: 2px dashed var(--accent);
  outline-offset: -12px;
  color: var(--text);
}

/* transport */
.transport {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px 12px calc(10px + var(--safe-bottom));
  background: rgba(10, 10, 16, 0.96);
  border-top: 1px solid var(--line);
  z-index: 10;
}

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg2);
  color: var(--text);
  border-radius: 12px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  min-height: 40px;
}

.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(135deg, #ff2d55, #ff5c7a);
  border-color: transparent;
  color: #fff;
}

.btn-ghost {
  background: transparent;
}

.scrub {
  flex: 1 1 120px;
  min-width: 100px;
  accent-color: var(--accent);
}

.time-label {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  min-width: 78px;
  text-align: center;
}

.select {
  appearance: none;
  background: var(--bg2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 28px 8px 10px;
  font-size: 13px;
  min-height: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%239a9ab0' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

.detected-pill {
  font-size: 11px;
  font-weight: 700;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(45, 212, 168, 0.15);
  color: var(--ok);
  border: 1px solid rgba(45, 212, 168, 0.35);
  white-space: nowrap;
  align-self: end;
  margin-bottom: 2px;
}

.detected-pill[hidden] {
  display: none !important;
}

/* —— editor sheet (overlay on all viewports) —— */
.editor-column {
  position: fixed;
  inset: 0;
  z-index: 50;
  max-height: none;
  height: 100%;
  width: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border: 0;
  border-radius: 0;
  background: rgba(8, 8, 12, 0.9);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  transform: translateY(110%);
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
  pointer-events: none;
}

.editor-column.is-open {
  transform: translateY(0);
  pointer-events: auto;
}

.editor-sheet-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px 10px;
  padding: calc(12px + env(safe-area-inset-top, 0px)) 14px 12px;
  border-bottom: 1px solid var(--line);
}

.editor-sheet-title {
  justify-self: center;
  text-align: center;
  font-size: 15px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.editor-sheet-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex: 0 0 auto;
}

.editor-toolbar {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 14px 14px 12px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent);
}

.toolbar-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.toolbar-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.toolbar-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  width: 100%;
}

.toolbar-row-langs label {
  flex: 1 1 140px;
  min-width: 130px;
}

.toolbar-row-langs .label-pos {
  flex: 0 1 110px;
  min-width: 100px;
}

.editor-toolbar label {
  font-size: 11px;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Primary choice: movie vs dictation */
.display-choice {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  width: 100%;
}

.display-choice-btn {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  margin: 0;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.28);
  color: var(--text);
  cursor: pointer;
  text-align: start;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.display-choice-btn:hover {
  border-color: rgba(255, 255, 255, 0.2);
}

.display-choice-btn.is-active {
  border-color: rgba(45, 212, 168, 0.65);
  background: rgba(45, 212, 168, 0.12);
  box-shadow: 0 0 0 1px rgba(45, 212, 168, 0.25);
}

.display-choice-btn[data-display="typing"].is-active {
  border-color: rgba(255, 45, 85, 0.65);
  background: rgba(255, 45, 85, 0.12);
  box-shadow: 0 0 0 1px rgba(255, 45, 85, 0.28);
}

.display-choice-icon {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.06);
  font-size: 14px;
  line-height: 1;
}

.display-choice-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.display-choice-text strong {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.25;
}

.display-choice-text small {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.3;
}

.display-choice-sheet {
  margin-bottom: 14px;
}

@media (max-width: 420px) {
  .display-choice {
    grid-template-columns: 1fr;
  }
}

.mode-toggle,
.mode-btn {
  display: none !important;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  border: 1px solid var(--line);
  background: var(--bg2);
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.chip.is-active {
  color: #fff;
  border-color: rgba(91, 140, 255, 0.5);
  background: rgba(91, 140, 255, 0.2);
}

.cards-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 10px 12px 20px;
  -webkit-overflow-scrolling: touch;
}

.cap-card {
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease;
}

.cap-card.is-active {
  border-color: rgba(255, 45, 85, 0.55);
  background: rgba(255, 45, 85, 0.08);
}

.cap-card .meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 6px;
  font-variant-numeric: tabular-nums;
}

.cap-card .meta .chip {
  padding: 4px 8px;
  min-height: 0;
}

.cap-card textarea {
  width: 100%;
  min-height: 52px;
  resize: vertical;
  border: 1px solid transparent;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.25);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  padding: 8px 10px;
}

.cap-card textarea:focus {
  outline: none;
  border-color: rgba(91, 140, 255, 0.5);
}

.cap-card[dir="rtl"] textarea {
  direction: rtl;
  text-align: right;
}

.status-bar {
  flex: 0 0 auto;
  padding: 8px 12px calc(8px + var(--safe-bottom));
  font-size: 11px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.status-bar .ok { color: var(--ok); }

.asr-log {
  display: none !important;
}

.size-preview-box {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 72px;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.35), rgba(0, 0, 0, 0.55)),
    radial-gradient(ellipse at 50% 0%, rgba(91, 140, 255, 0.15), transparent 60%);
  text-align: center;
}

.size-preview-box .size-preview-sample.caption-text {
  opacity: 1;
  transform: none;
  margin: 0;
  max-width: 100%;
  font-size: var(--cap-preview-size, 24px);
  transition: font-size 0.15s ease, color 0.15s ease, text-shadow 0.15s ease, background 0.15s ease;
}

.size-preview-box .size-preview-sample.caption-text.is-typing::after {
  display: none;
}

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

.size-chip {
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.28);
  color: var(--muted);
  border-radius: 12px;
  padding: 10px 6px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.size-chip.is-active {
  color: #fff;
  border-color: rgba(45, 212, 168, 0.65);
  background: rgba(45, 212, 168, 0.14);
  box-shadow: 0 0 0 1px rgba(45, 212, 168, 0.25);
}

.size-preview-sheet {
  margin-bottom: 0;
  min-height: 56px;
  padding: 10px 12px;
}

.editor-list-hint {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.35;
}

.cards-empty {
  margin: 24px 12px;
  padding: 20px 14px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  border: 1px dashed var(--line);
  border-radius: 14px;
}

.pos-label {
  display: block;
  width: 100%;
}

.select-full {
  width: 100%;
}

.status-bar-compact #activeId[hidden] {
  display: none !important;
}

#fileInput { display: none; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* —— floating TikTok controls —— */
.float-top {
  position: absolute;
  top: calc(10px + env(safe-area-inset-top, 0px));
  left: 0;
  right: 0;
  z-index: 12;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  min-height: 42px;
}

.float-top-actions {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
}

.float-top > .ready-cluster,
.float-top > .ready-dot-float {
  pointer-events: auto;
}

/* Status meter: circular + % only (hint text stays for a11y / status bar). */
.ready-cluster {
  position: absolute;
  left: calc(12px + env(safe-area-inset-left, 0px));
  top: calc(12px + env(safe-area-inset-top, 0px));
  transform: none;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  z-index: 40;
  max-width: none;
  pointer-events: auto;
  padding: 6px 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.ready-cluster .ready-dot-float {
  position: static;
  transform: none;
  left: auto;
  top: auto;
  flex: 0 0 auto;
}

.ready-progress[data-mode="bg"] {
  color: #7dd3c0;
}

.ready-progress,
.ready-timer {
  flex: 0 0 auto;
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.7);
  letter-spacing: 0.02em;
}

.ready-timer {
  color: rgba(255, 220, 120, 0.95);
  min-width: 2.4em;
  /* Time lives in status / title — cluster shows only circle + % */
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Hint text next to meter looks doubled with ✓ — hide visually, keep for screen readers via status. */
.ready-hint {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.sample-picker {
  position: absolute;
  top: calc(58px + env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 14;
  display: flex;
  gap: 8px;
  padding: 8px;
  border-radius: 14px;
  background: rgba(12, 12, 18, 0.82);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

.sample-picker[hidden] {
  display: none !important;
}

.sample-pick {
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.sample-pick:active {
  transform: scale(0.96);
}

/* Physical left status: spinner while loading, green ✓ when ready */
.ready-dot-float {
  position: absolute;
  left: calc(10px + env(safe-area-inset-left, 0px));
  top: 50%;
  transform: translateY(-50%);
  margin: 0;
  width: 26px;
  height: 26px;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
  color: #04120e;
  background: transparent;
  border: 2px solid rgba(255, 255, 255, 0.28);
  box-shadow: none;
  animation: none;
  --pct: 0;
}

.ready-dot-float[data-state="booting"],
.ready-dot-float[data-state="loading"] {
  background:
    radial-gradient(circle at center, rgba(0, 0, 0, 0.55) 58%, transparent 59%),
    conic-gradient(#f5a524 calc(var(--pct) * 1%), rgba(255, 255, 255, 0.18) 0);
  border-color: transparent;
  color: transparent;
  animation: none;
}

.ready-dot-float[data-state="loading"][data-busy="1"],
.ready-cluster .ready-dot-float[data-state="loading"][data-busy="1"] {
  background: transparent;
  border: 2px solid rgba(255, 255, 255, 0.22);
  border-top-color: #f5a524;
  animation: ready-spin-plain 0.75s linear infinite;
}

.ready-cluster .ready-dot-float[data-state="booting"],
.ready-cluster .ready-dot-float[data-state="loading"] {
  animation: none;
}

.ready-cluster .ready-dot-float[data-state="loading"][data-busy="1"] {
  animation: ready-spin-plain 0.75s linear infinite;
}

.ready-dot-float[data-state="ready"] {
  background: #2dd4a8;
  border-color: #2dd4a8;
  color: #04120e;
  box-shadow: 0 0 0 2px rgba(45, 212, 168, 0.28), 0 0 12px rgba(45, 212, 168, 0.4);
  animation: none;
}

.ready-dot-float[data-state="error"] {
  background: #ff5c7a;
  border-color: #ff5c7a;
  color: #fff;
  animation: none;
}

@keyframes ready-spin {
  to { transform: translateY(-50%) rotate(360deg); }
}

@keyframes ready-spin-plain {
  to { transform: rotate(360deg); }
}

.float-bottom {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: calc(14px + var(--safe-bottom));
  z-index: 12;
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.float-bottom > * { pointer-events: auto; }

.float-btn {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  background: rgba(20, 20, 28, 0.45);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
  flex: 0 0 auto;
}

.float-btn:disabled { opacity: 0.35; }
.float-btn:active { transform: scale(0.94); }

.float-btn-aa {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 16px;
  letter-spacing: -0.04em;
}

.float-btn-play {
  background: rgba(255, 45, 85, 0.75);
}

.scrub-float {
  flex: 1 1 auto;
  min-width: 0;
  height: 4px;
}

.time-float {
  color: rgba(255, 255, 255, 0.85);
  text-shadow: 0 1px 2px #000;
  min-width: 72px;
  font-size: 10px;
}

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.sheet-backdrop[hidden] { display: none !important; }

.sheet-ready {
  font-size: 11px;
  color: var(--muted);
}

.sheet-copy-btn,
.sheet-save-btn {
  appearance: none;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  padding: 7px 12px;
  border-radius: 999px;
  cursor: pointer;
  flex: 0 0 auto;
  min-height: 34px;
  line-height: 1.2;
}

.sheet-copy-btn {
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(45, 212, 168, 0.16);
  color: #9af0d4;
}

.sheet-copy-btn:hover {
  background: rgba(45, 212, 168, 0.28);
}

.sheet-copy-btn.is-done {
  background: rgba(45, 212, 168, 0.4);
  color: #04120e;
  border-color: #2dd4a8;
}

.sheet-save-btn {
  border: 1px solid transparent;
  background: linear-gradient(135deg, #ff2d55, #ff5c7a);
  color: #fff;
}

.sheet-save-btn:hover {
  filter: brightness(1.06);
}

.sheet-save-btn:active {
  transform: scale(0.97);
}

.editor-close {
  width: 36px;
  height: 36px;
}

/* —— Full-screen wizard (TikTok-style steps) —— */
.style-sheet,
.wizard-sheet {
  position: fixed;
  inset: 0;
  /* Above ready-cluster (desktop z-index 120) so full-screen steps receive taps */
  z-index: 200;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  pointer-events: none;
  background: rgba(0, 0, 0, 0.45);
}

.style-sheet[hidden] {
  display: none !important;
}

.style-sheet.is-open {
  pointer-events: auto;
}

/* Status cluster must not steal taps from wizard / top actions */
body.wizard-open .ready-cluster {
  pointer-events: none !important;
  opacity: 0.4;
}

.style-sheet-panel,
.wizard-panel {
  width: 100%;
  height: 100%;
  max-height: none;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: rgba(10, 10, 16, 0.97);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  border: none;
  border-radius: 0;
  padding: 0;
  box-shadow: none;
  transform: translateX(8%) scale(0.985);
  opacity: 0;
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.22s ease;
}

.style-sheet.is-open .style-sheet-panel {
  transform: none;
  opacity: 1;
}

.wizard-step {
  display: none;
  flex: 1;
  min-height: 0;
  flex-direction: column;
}

.wizard-step.is-active {
  display: flex;
}

.wizard-step[hidden] {
  display: none !important;
}

.wizard-head {
  flex: 0 0 auto;
  padding: calc(12px + env(safe-area-inset-top, 0px)) 16px 12px;
  border-bottom: 1px solid var(--line);
}

.wizard-step-dot {
  margin-inline-start: auto;
  margin-inline-end: 8px;
  font-size: 12px;
  color: var(--muted);
}

.wizard-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 16px 18px 8px;
  -webkit-overflow-scrolling: touch;
}

.wizard-footer {
  flex: 0 0 auto;
  padding: 12px 16px calc(16px + var(--safe-bottom));
  border-top: 1px solid var(--line);
  background: rgba(10, 10, 16, 0.98);
}

.wizard-footer-row {
  display: flex;
  gap: 10px;
  align-items: stretch;
}

.wizard-footer-row .btn-ghost {
  flex: 0 1 auto;
  min-height: 48px;
  white-space: nowrap;
}

.wizard-footer .wizard-next,
.wizard-footer-row .btn-primary {
  flex: 1;
  min-height: 48px;
  font-size: 16px;
  font-weight: 700;
}

/* Compact controls — avoid stretched full-bleed pills on wide screens */
.wizard-body .size-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.wizard-body .size-chip {
  flex: 0 0 auto;
  min-width: 72px;
  padding: 10px 16px;
}

.wizard-body .mode-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.wizard-body .mode-pill {
  flex: 0 1 auto;
  min-width: 140px;
  padding: 10px 14px;
}

.wizard-body .pos-label,
.wizard-body .wizard-lang-label {
  display: block;
  max-width: 360px;
}

.wizard-body .select-full {
  width: 100%;
  max-width: 360px;
}

.wizard-hint {
  margin: 0 0 10px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.35;
}

.req-star {
  color: var(--accent);
}

.wizard-lang-label {
  display: block;
  width: 100%;
}

.wizard-process-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 12px;
  padding-top: 20vh;
}

.wizard-process-spinner {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.12);
  border-top-color: var(--ok);
  animation: wizard-spin 0.85s linear infinite;
}

@keyframes wizard-spin {
  to { transform: rotate(360deg); }
}

.wizard-process-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.wizard-process-sub {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  max-width: 280px;
}

.float-btn-text {
  width: auto !important;
  min-width: 44px;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 700;
  border-radius: 999px;
}

.style-sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.style-sheet-head strong {
  font-size: 16px;
}

.sheet-section {
  margin-bottom: 14px;
}

.sheet-section-title {
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.style-sheet-hint {
  display: none;
}

.mode-toggle-sheet {
  display: none !important;
}

.mode-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.mode-pill {
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.28);
  color: var(--muted);
  border-radius: 12px;
  padding: 10px 8px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.mode-pill.is-active {
  color: #fff;
  border-color: rgba(45, 212, 168, 0.65);
  background: rgba(45, 212, 168, 0.14);
}

.style-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.style-pill {
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.28);
  color: var(--muted);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.style-pill.is-active {
  color: #fff;
  border-color: rgba(255, 45, 85, 0.55);
  background: rgba(255, 45, 85, 0.16);
}

/* legacy card styles unused — keep minimal so old class names don't break */
.style-grid,
.style-card,
.style-preview,
.style-name,
.style-desc {
  display: none !important;
}

.style-to-editor {
  width: 100%;
  margin-top: 4px;
  min-height: 44px;
}

@media (min-width: 900px) {
  .style-sheet,
  .wizard-sheet {
    align-items: center;
    justify-content: center;
    padding: 28px;
    background: rgba(0, 0, 0, 0.62);
  }

  .style-sheet-panel,
  .wizard-panel {
    width: min(520px, 100%);
    height: min(860px, calc(100vh - 56px));
    max-height: min(860px, calc(100vh - 56px));
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
  }

  .wizard-body {
    padding: 18px 22px 10px;
  }

  .wizard-footer {
    border-radius: 0 0 20px 20px;
  }

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

/* —— Fullscreen TikTok chrome (all sizes) —— */
.desktop-only { display: none !important; }
.desktop-only-block { display: none !important; }

body {
  background: #000;
}

.app-bar { display: none !important; }

#video {
  object-fit: contain;
  object-position: center center;
}

.caption-overlay[data-position="bottom"] {
  bottom: 22%;
}

.editor-toolbar {
  padding-inline: 16px;
}

.cards-scroll {
  padding-bottom: calc(24px + var(--safe-bottom));
}

.asr-log {
  display: none !important;
}

.status-bar {
  padding-bottom: calc(10px + var(--safe-bottom));
}

@media (min-width: 900px) {
  .editor-column {
    inset: auto;
    top: 50%;
    left: 50%;
    width: min(720px, calc(100vw - 48px));
    height: min(860px, calc(100vh - 48px));
    max-height: min(860px, calc(100vh - 48px));
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transform: translate(-50%, -46%) scale(0.96);
    opacity: 0;
    transition: transform 0.22s ease, opacity 0.22s ease;
  }

  .editor-column.is-open {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }

  .editor-sheet-head {
    padding-top: 14px;
  }

  .phone-frame {
    /* keep cinematic stage centered on wide monitors */
    max-width: min(520px, 100%);
    margin: 0 auto;
    height: 100%;
  }

  .player-column {
    display: flex;
    align-items: stretch;
    justify-content: center;
    background: #050508;
  }

  /* Desktop: meter in screen top-left — below float actions & wizard */
  .float-top {
    z-index: 130;
  }

  .ready-cluster {
    position: fixed;
    left: 20px;
    top: 20px;
    z-index: 50;
    padding: 8px 12px;
    gap: 10px;
    background: rgba(8, 8, 12, 0.78);
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
  }

  .ready-cluster .ready-dot-float {
    width: 30px;
    height: 30px;
    font-size: 15px;
  }

  .ready-progress {
    font-size: 14px;
  }

  /* When ready: only the green check — no empty pill clutter */
  .ready-cluster:has(.ready-dot-float[data-state="ready"]) {
    padding: 8px;
    gap: 0;
  }

  .ready-cluster:has(.ready-dot-float[data-state="ready"]) .ready-progress {
    display: none !important;
  }
}
