:root {
  --bg: #080e17;
  --bg-glow: radial-gradient(1100px 520px at 15% -10%, rgba(37, 211, 102, 0.08), transparent 60%),
    radial-gradient(900px 480px at 88% 4%, rgba(56, 189, 248, 0.07), transparent 58%);
  --topbar-bg: rgba(10, 15, 24, 0.82);
  --surface: #121821;
  --surface-alt: #18202c;
  --surface-elevated: #1e2633;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #e9eefb;
  --muted: #94a3b8;
  --accent: #25d366;
  --accent-hover: #1fb858;
  --on-accent: #031b0c;
  --primary: #38bdf8;
  --primary-hover: #0ea5e9;
  --on-primary: #041d2e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --chat-bg: #0b141a;
  --chat-bar: #1f2c34;
  --chat-bubble: #005c4b;
  --checker-a: #18222c;
  --checker-b: #111820;
  --playhead: #f8fafc;
  --shadow-card: 0 10px 30px rgba(0, 0, 0, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.03);
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 18px;
  --font-display: 'Space Grotesk', system-ui, -apple-system, sans-serif;
  --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

[data-theme="light"] {
  --bg: #f3f6fa;
  --bg-glow: radial-gradient(1000px 460px at 15% -10%, rgba(22, 163, 74, 0.08), transparent 60%),
    radial-gradient(800px 420px at 88% 0%, rgba(2, 132, 199, 0.07), transparent 55%);
  --topbar-bg: rgba(255, 255, 255, 0.86);
  --surface: #ffffff;
  --surface-alt: #f1f5f9;
  --surface-elevated: #e2e8f0;
  --border: rgba(15, 23, 42, 0.1);
  --border-strong: rgba(15, 23, 42, 0.2);
  --text: #0f172a;
  --muted: #475569;
  --accent: #25d366;
  --accent-hover: #1fb858;
  --on-accent: #031b0c;
  --primary: #0284c7;
  --primary-hover: #0369a1;
  --on-primary: #ffffff;
  --warning: #d97706;
  --danger: #dc2626;
  --chat-bg: #efeae2;
  --chat-bar: #f0f2f5;
  --chat-bubble: #d9fdd3;
  --checker-a: #e2e8f0;
  --checker-b: #f8fafc;
  --playhead: #0f172a;
  --shadow-card: 0 8px 24px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 84px;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  background-color: var(--bg);
  background-image: var(--bg-glow);
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.2s ease, color 0.2s ease;
}

h1,
h2,
h3,
strong {
  font-family: var(--font-display);
  letter-spacing: -0.015em;
}

/* Sticky Topbar */
.topbar-shell {
  position: sticky;
  top: 0;
  z-index: 900;
  background: var(--topbar-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

.topbar {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(37, 211, 102, 0.2), rgba(56, 189, 248, 0.16));
  border: 1px solid rgba(37, 211, 102, 0.35);
  color: var(--accent);
  overflow: hidden;
  padding: 3px;
  flex-shrink: 0;
}

.brand-mascot {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-text strong {
  font-size: 1.05rem;
  font-weight: 700;
}

.brand-text small {
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 500;
}

.topbar-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 999px;
}

.nav-pill {
  text-decoration: none;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 999px;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.nav-pill:hover {
  color: var(--text);
  background: var(--surface-elevated);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.lang-select {
  width: auto;
  padding: 6px 12px;
  font-size: 0.82rem;
  font-weight: 600;
  font-family: var(--font-mono);
  border-radius: 999px;
  background: var(--surface-alt);
  color: var(--text);
  border: 1px solid var(--border);
  cursor: pointer;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(37, 211, 102, 0.1);
  border: 1px solid rgba(37, 211, 102, 0.3);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent);
  line-height: 1.25;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.badge.busy {
  background: rgba(56, 189, 248, 0.12);
  border-color: rgba(56, 189, 248, 0.38);
  color: var(--primary);
}

.badge.busy::before {
  animation: pulseDot 1.1s ease-in-out infinite;
}

.badge.error {
  background: rgba(239, 68, 68, 0.14);
  border-color: rgba(239, 68, 68, 0.42);
  color: var(--danger);
  max-width: 440px;
  white-space: normal;
}

@keyframes pulseDot {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.35;
    transform: scale(0.75);
  }
}

/* Main Shell & Intro */
.app-shell {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 22px 20px 64px;
}

.hero-intro {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.hero-kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 11px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--primary);
}

.kicker-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

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

.studio-layout {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.workbench-split {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 1fr);
  gap: 20px;
  align-items: start;
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: var(--shadow-card);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.card-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.step-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 26px;
  padding: 0 7px;
  border-radius: 8px;
  background: rgba(37, 211, 102, 0.14);
  border: 1px solid rgba(37, 211, 102, 0.34);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
}

.card h2 {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 700;
}

.format-badges {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.tech-tag {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--muted);
}

.accent-tag {
  color: var(--primary);
  border-color: rgba(56, 189, 248, 0.3);
  background: rgba(56, 189, 248, 0.08);
}

/* Inputs & Buttons */
input[type="text"],
input[type="url"],
select,
textarea {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-family: var(--font-sans);
  font-size: 0.92rem;
  width: 100%;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.18);
}

.btn {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 16px;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  white-space: nowrap;
  transition: transform 0.12s ease, background-color 0.15s ease, border-color 0.15s ease, opacity 0.15s ease, box-shadow 0.15s ease;
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:disabled,
.btn.disabled {
  opacity: 0.42;
  pointer-events: none;
}

.btn.small {
  padding: 7px 12px;
  font-size: 0.81rem;
  border-radius: 8px;
}

.btn.primary {
  background: var(--primary);
  color: var(--on-primary);
}

.btn.primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn.accent {
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 700;
  box-shadow: 0 4px 16px rgba(37, 211, 102, 0.22);
}

.btn.accent:hover:not(:disabled) {
  background: var(--accent-hover);
  color: var(--on-accent);
  box-shadow: 0 6px 20px rgba(37, 211, 102, 0.32);
}

.btn.secondary {
  background: var(--surface-alt);
  border-color: var(--border);
  color: var(--text);
}

.btn.secondary:hover:not(:disabled) {
  background: var(--surface-elevated);
  border-color: var(--border-strong);
}

.btn.ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}

.btn.ghost:hover:not(:disabled) {
  background: var(--surface-alt);
  border-color: var(--border-strong);
}

.btn.danger {
  background: var(--danger);
  color: #fff;
}

.btn.danger:hover:not(:disabled) {
  filter: brightness(0.92);
}

.theme-btn {
  border-radius: 999px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.81rem;
  font-weight: 600;
  color: var(--muted);
}

.inline-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.wrap-actions {
  flex-wrap: wrap;
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

/* Step 1: Source Card */
.source-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(240px, 1fr);
  gap: 14px;
  align-items: stretch;
}

.source-url-col {
  display: flex;
  flex-direction: column;
  gap: 12px;
  justify-content: space-between;
}

.yt-form {
  display: flex;
  gap: 8px;
  align-items: center;
}

.input-icon-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
}

.input-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

.input-icon-wrap input {
  padding-left: 36px;
}

.yt-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.platform-icons {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
}

.platform-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.platform-chip:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

.dropzone {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  color: var(--muted);
  background: var(--surface-alt);
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease;
}

.dropzone-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(56, 189, 248, 0.12);
  color: var(--primary);
}

.dropzone-copy {
  font-size: 0.84rem;
  font-weight: 500;
}

.dropzone.dragover,
.dropzone:hover {
  border-color: var(--primary);
  background: rgba(56, 189, 248, 0.08);
  color: var(--text);
}

.source-footer {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.source-footer:empty {
  display: none;
}

.video-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  border: 1px solid var(--border);
  font-size: 0.85rem;
}

.video-meta span {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--accent);
}

/* Step 2: Editor Workbench */
.player-wrap {
  position: relative;
  background: #04070c;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 270px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.player-stage {
  position: relative;
  display: none;
  max-width: 100%;
}

.player-stage.ready {
  display: inline-flex;
}

.player-stage video {
  display: block;
  max-height: 400px;
  max-width: 100%;
}

.crop-guide {
  position: absolute;
  top: 0;
  left: 0;
  border: 2px solid var(--accent);
  border-radius: 4px;
  box-shadow: 0 0 0 9999px rgba(4, 7, 12, 0.56);
  pointer-events: auto;
  cursor: grab;
  touch-action: none;
  z-index: 2;
}

.crop-guide:active {
  cursor: grabbing;
}

.crop-grid {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(to right, rgba(255, 255, 255, 0.16) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.16) 1px, transparent 1px);
  background-size: 33.333% 33.333%;
}

.crop-guide.locked {
  pointer-events: none;
  cursor: default;
}

.crop-guide.locked .crop-grid {
  display: none;
}

.crop-resize-handle {
  position: absolute;
  right: -10px;
  bottom: -10px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  border: 2.5px solid #031b0c;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.6);
  cursor: nwse-resize;
  touch-action: none;
  z-index: 3;
}

.crop-resize-handle::after {
  content: "";
  position: absolute;
  inset: -10px;
}

.crop-guide.locked .crop-resize-handle {
  display: none;
}

.empty-hint {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.88rem;
  padding: 28px 20px;
  text-align: center;
  max-width: 360px;
}

.empty-hint svg {
  opacity: 0.45;
  color: var(--primary);
}

.empty-hint p {
  margin: 0;
}

.timeline-player {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.timeline-player.disabled {
  opacity: 0.48;
  pointer-events: none;
}

.player-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.time-readout {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.8rem;
  color: var(--muted);
}

.range-badge {
  background: rgba(37, 211, 102, 0.12);
  border: 1px solid rgba(37, 211, 102, 0.34);
  border-radius: 6px;
  padding: 3px 9px;
  color: var(--accent);
  font-weight: 600;
}

.timeline-track {
  position: relative;
  height: 46px;
  background-color: var(--bg);
  background-image: repeating-linear-gradient(
    to right,
    var(--border) 0,
    var(--border) 1px,
    transparent 1px,
    transparent 16px
  );
  background-size: 100% 10px;
  background-position: bottom;
  background-repeat: no-repeat;
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  user-select: none;
  touch-action: none;
  overflow: visible;
}

.timeline-selection {
  position: absolute;
  top: 2px;
  bottom: 2px;
  background: rgba(37, 211, 102, 0.22);
  border-top: 3px solid var(--accent);
  border-bottom: 3px solid var(--accent);
  border-radius: 7px;
  cursor: grab;
  min-width: 16px;
}

.timeline-selection:active {
  cursor: grabbing;
}

.timeline-handle {
  position: absolute;
  top: -4px;
  bottom: -4px;
  width: 16px;
  background: var(--accent);
  border: 2px solid #031b0c;
  border-radius: 6px;
  cursor: ew-resize;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
}

.timeline-handle::after {
  content: "";
  width: 2px;
  height: 16px;
  border-radius: 2px;
  background: rgba(3, 27, 12, 0.65);
}

.timeline-handle.left {
  left: -8px;
}

.timeline-handle.right {
  right: -8px;
}

.timeline-playhead {
  position: absolute;
  top: -4px;
  bottom: -4px;
  width: 2.5px;
  background: var(--playhead);
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.75);
  pointer-events: none;
  z-index: 4;
}

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

.audio-studio {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.custom-audio-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rec-progress-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.rec-progress-bar {
  flex: 1;
  height: 9px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.rec-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--danger);
  transition: width 0.06s linear;
}

.custom-audio-player {
  width: 100%;
  height: 36px;
}

.editor-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding-top: 4px;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.86rem;
  color: var(--text);
  cursor: pointer;
}

.toggle input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

.convert-cta {
  padding: 12px 22px;
  font-size: 0.94rem;
}

/* Step 3: Result & WhatsApp Chat Simulator */
.result-card {
  position: sticky;
  top: 80px;
}

.wa-preview-frame {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.wa-preview-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--chat-bar);
  border-bottom: 1px solid var(--border);
}

.wa-preview-contact {
  display: flex;
  align-items: center;
  gap: 10px;
}

.wa-preview-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(37, 211, 102, 0.18);
  border: 1px solid rgba(37, 211, 102, 0.4);
  overflow: hidden;
  padding: 2px;
}

.wa-preview-avatar img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.wa-preview-contact strong {
  display: block;
  font-size: 0.84rem;
  line-height: 1.15;
}

.wa-preview-contact small {
  display: block;
  font-size: 0.7rem;
  color: var(--muted);
}

.wa-preview-online {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.22);
}

.chat-sim {
  background-color: var(--chat-bg);
  background-image: radial-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px);
  background-size: 16px 16px;
  padding: 22px 18px;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 230px;
}

[data-theme="light"] .chat-sim {
  background-image: radial-gradient(rgba(15, 23, 42, 0.05) 1px, transparent 1px);
}

.sticker-bubble {
  position: relative;
  width: 196px;
  height: 196px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: repeating-conic-gradient(var(--checker-a) 0% 25%, var(--checker-b) 0% 50%) 50% / 20px 20px;
  border-radius: 14px;
  border: 1px solid var(--border);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.25);
  overflow: hidden;
}

.sticker-bubble img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.sound-pill {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: rgba(11, 20, 26, 0.88);
  color: #f8fafc;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 0.76rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  backdrop-filter: blur(6px);
}

.sound-pill.playing {
  border-color: var(--accent);
  color: var(--accent);
}

.placeholder-text {
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
  padding: 14px;
}

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 0.78rem;
}

.stat-chip {
  font-family: var(--font-mono);
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 4px 8px;
  color: var(--text);
}

.download-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.download-row .full-span {
  grid-column: 1 / -1;
}

.publish-box {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.publish-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.publish-row input {
  flex: 1 1 160px;
}

.pack-draft {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pack-draft-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.82rem;
  font-weight: 600;
}

.pack-draft-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pack-thumb {
  position: relative;
  width: 54px;
  height: 54px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: repeating-conic-gradient(var(--checker-a) 0% 25%, var(--checker-b) 0% 50%) 50% / 14px 14px;
  overflow: hidden;
}

.pack-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.pack-thumb button {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.78);
  color: #fff;
  font-size: 0.72rem;
  line-height: 1;
  cursor: pointer;
}

.format-note {
  font-size: 0.78rem;
  line-height: 1.4;
}

/* Step 4: WhatsApp Hub */
.wa-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  align-items: start;
}

.wa-col-link,
.wa-col-send {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.wa-status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  padding: 12px 14px;
  border-radius: var(--radius);
}

.wa-status-identity {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 0.9rem;
}

.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
}

.dot.connected {
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(37, 211, 102, 0.2);
}

.dot.qr {
  background: var(--warning);
  box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.2);
}

.qr-box {
  background: #ffffff;
  color: #0f172a;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.qr-box img {
  width: 210px;
  height: 210px;
  border-radius: 8px;
}

.qr-box p {
  margin: 0;
  font-size: 0.82rem;
}

.pair-box {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.pair-title {
  font-size: 0.85rem;
  font-weight: 600;
}

.pair-form {
  display: flex;
  gap: 8px;
}

.country-select {
  width: auto;
  min-width: 105px;
  flex-shrink: 0;
}

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

.phone-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 10px;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--text);
}

.phone-chip button {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  padding: 0;
  font: inherit;
}

.phone-chip .phone-del {
  color: var(--muted);
  font-weight: 700;
}

.phone-chip .phone-del:hover {
  color: var(--danger);
}

.pair-code-wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.pair-code {
  font-family: var(--font-mono);
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  background: var(--bg);
  border: 1px solid var(--accent);
  color: var(--accent);
  padding: 7px 14px;
  border-radius: 10px;
}

.wa-send-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.wa-send-cta {
  width: 100%;
  padding: 12px 16px;
}

.cookies-box {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
}

.cookies-box summary {
  cursor: pointer;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--muted);
}

.cookies-body {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cookies-body textarea {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  resize: vertical;
}

/* Step 5: Global Gallery */
.gallery-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.gallery-title-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sort-select {
  width: auto;
  padding: 7px 12px;
  font-size: 0.82rem;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(232px, 1fr));
  gap: 16px;
}

.gallery-item {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.gallery-item:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.22);
}

.gallery-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 10px;
  border: 1px solid var(--border);
  overflow: hidden;
  background: repeating-conic-gradient(var(--checker-a) 0% 25%, var(--checker-b) 0% 50%) 50% / 18px 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.pack-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(8, 14, 23, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #f8fafc;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
}

.gallery-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.gallery-meta strong {
  font-size: 0.94rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gallery-meta span {
  font-size: 0.77rem;
  color: var(--muted);
}

.pack-strip {
  display: flex;
  gap: 5px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.pack-strip-btn {
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 7px;
  border: 1.5px solid var(--border);
  background: var(--bg);
  cursor: pointer;
  flex-shrink: 0;
  overflow: hidden;
}

.pack-strip-btn.active {
  border-color: var(--accent);
}

.pack-strip-btn img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.vote-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.vote-btn {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: 999px;
  padding: 4px 10px;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.vote-btn.active-up {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(37, 211, 102, 0.1);
}

.vote-btn.active-down {
  border-color: var(--danger);
  color: var(--danger);
  background: rgba(239, 68, 68, 0.1);
}

.gallery-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: auto;
}

.gallery-actions .btn.accent {
  flex: 1 0 100%;
  order: 10;
}

.gallery-actions .btn.danger {
  flex: 1 0 100%;
  order: 11;
}

/* Admin Panel & Dashboard */
.admin-panel {
  margin-bottom: 18px;
  border-color: rgba(56, 189, 248, 0.35);
}

.admin-shield {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(56, 189, 248, 0.12);
  color: var(--primary);
}

.status-pill-ok {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--accent);
  background: rgba(37, 211, 102, 0.12);
  border: 1px solid rgba(37, 211, 102, 0.3);
  padding: 5px 11px;
  border-radius: 999px;
}

.admin-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.admin-row input[type="text"] {
  width: 210px;
  font-family: var(--font-mono);
}

.dash-auth-card {
  max-width: 560px;
  margin: 24px auto;
}

.dash-content {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

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

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: var(--shadow-card);
}

.kpi-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
}

.kpi-value {
  font-family: var(--font-mono);
  font-size: 1.55rem;
  font-weight: 700;
  color: var(--primary);
}

.kpi-value.kpi-danger {
  color: var(--danger);
}

.kpi-value.kpi-warn {
  color: var(--warning);
}

.kpi-value.kpi-accent {
  color: var(--accent);
}

.dash-vpn-toggle {
  padding: 6px 10px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.81rem;
}

.admin-logs {
  margin: 10px 0 0;
  padding: 14px;
  max-height: 480px;
  overflow: auto;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.dash-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.dash-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}

.dash-table th,
.dash-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.dash-table td:nth-child(1),
.dash-table td:nth-child(2),
.dash-table td:nth-child(3),
.dash-table td:nth-child(4),
.dash-table td:nth-child(7) {
  font-family: var(--font-mono);
}

.dash-table th {
  background: var(--surface-alt);
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}

.dash-table tbody tr:hover {
  background: rgba(56, 189, 248, 0.04);
}

.vpn-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  background: rgba(239, 68, 68, 0.16);
  color: var(--danger);
}

.http-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  background: var(--surface-alt);
  color: var(--text);
}

.http-badge.http-2xx {
  background: rgba(37, 211, 102, 0.14);
  color: var(--accent);
}

.http-badge.http-4xx {
  background: rgba(245, 158, 11, 0.16);
  color: var(--warning);
}

.http-badge.http-5xx {
  background: rgba(239, 68, 68, 0.16);
  color: var(--danger);
}

.dash-gallery-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
}

.dash-gallery-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-alt);
  font-size: 0.82rem;
}

.dash-gallery-thumb {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  object-fit: contain;
  background: repeating-conic-gradient(var(--checker-a) 0% 25%, var(--checker-b) 0% 50%) 50% / 12px 12px;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.dash-gallery-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.hidden {
  display: none !important;
}

/* Responsive Breakpoints */
@media (max-width: 1024px) {
  .workbench-split {
    grid-template-columns: 1fr;
  }
  .result-card {
    position: static;
  }
  .source-grid,
  .wa-grid {
    grid-template-columns: 1fr;
  }
  .dash-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .topbar-nav {
    display: none;
  }
  .topbar {
    padding: 10px 14px;
  }
  .app-shell {
    padding: 16px 14px 56px;
  }
  .card {
    padding: 16px;
    border-radius: var(--radius);
  }
  .yt-form {
    flex-direction: column;
    align-items: stretch;
  }
  .yt-actions .btn {
    flex: 1 1 auto;
  }
}

@media (max-width: 540px) {
  .options-row,
  .download-row,
  .dash-kpis {
    grid-template-columns: 1fr;
  }
  .pair-form,
  .publish-row {
    flex-direction: column;
  }
  .admin-row input[type="text"] {
    width: 100%;
  }
}
