:root {
  --bg: #ffffff;
  --bg-page: #f7f7f8;
  --text: #1a1a1a;
  --text-muted: #6b7280;
  --text-faint: #9ca3af;
  --border: #e5e7eb;
  --border-light: #f3f4f6;
  --brand: #6B1D2A;
  --brand-light: #FFF0F0;
  --brand-border: #6B1D2A;
  --danger: #d32f2f;
  --danger-bg: #FFF0F0;
  --success: #16a34a;
  --radius: 16px;
  --radius-sm: 12px;
  --radius-xs: 8px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --sans: 'Inter', ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

[data-theme="dark"] {
  --bg: #1a1a2e;
  --bg-page: #0f0f1a;
  --text: #e8e8f0;
  --text-muted: #9ca3b8;
  --text-faint: #6b7290;
  --border: #2a2a40;
  --border-light: #222238;
  --brand: #a83248;
  --brand-light: rgba(168, 50, 72, 0.15);
  --brand-border: #a83248;
  --danger: #ef5350;
  --danger-bg: rgba(239, 83, 80, 0.12);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--sans);
  color: var(--text);
  background: var(--bg-page);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.container {
  width: min(720px, calc(100% - 32px));
  margin-inline: auto;
}

/* ── Header ── */
.header {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--brand);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.brand-title {
  font-weight: 800;
  font-size: 16px;
  line-height: 1.2;
}

.brand-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

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

.segmented {
  display: inline-flex;
  background: var(--bg-page);
  border: 1px solid var(--border);
  padding: 3px;
  border-radius: 999px;
}

.segmented-btn {
  border: 0;
  background: transparent;
  color: var(--text-muted);
  padding: 6px 14px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: var(--sans);
}

.segmented-btn:hover {
  color: var(--text);
}

.segmented-btn.is-active {
  background: var(--bg);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.btn-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-muted);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: all 0.15s ease;
}

.btn-icon:hover {
  border-color: var(--brand);
  color: var(--brand);
}

/* ── Main ── */
.main {
  padding: 20px 0 40px;
  display: grid;
  gap: 24px;
}

/* ── Step Section ── */
.step-section {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.step-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.step-badge {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.step-title {
  font-weight: 700;
  font-size: 17px;
  color: var(--text);
}

/* ── Tab Group (Section 1) ── */
.tab-group {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  background: var(--bg-page);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  overflow: hidden;
  margin-bottom: 20px;
}

.tab-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: var(--sans);
  position: relative;
}

.tab-btn+.tab-btn {
  border-left: 1px solid var(--border);
}

.tab-btn:hover {
  color: var(--text);
  background: rgba(0, 0, 0, 0.02);
}

.tab-btn.is-active {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}

.tab-btn.is-active+.tab-btn {
  border-left-color: var(--brand);
}

.tab-btn.is-active svg {
  stroke: #fff;
}

/* ── Source Panels ── */
.source-panel {
  display: grid;
  gap: 16px;
}

.form-stack {
  display: grid;
  gap: 14px;
}

.form-row {
  display: grid;
  gap: 14px;
  grid-template-columns: 1fr;
}

@media (min-width: 520px) {
  .form-row {
    grid-template-columns: 1fr 1fr;
  }
}

.field {
  display: grid;
  gap: 6px;
}

.label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

input,
textarea,
select {
  width: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  padding: 12px 14px;
  outline: none;
  font-size: 14px;
  font-family: var(--sans);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input::placeholder,
textarea::placeholder {
  color: var(--text-faint);
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(107, 29, 42, 0.08);
}

textarea {
  resize: vertical;
  min-height: 100px;
}

.search-input-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 14px;
  background: var(--bg);
  transition: border-color 0.15s ease;
}

.search-input-wrap:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(107, 29, 42, 0.08);
}

.search-input-wrap svg {
  flex-shrink: 0;
  color: var(--text-faint);
}

.search-input {
  border: none !important;
  padding: 12px 0 !important;
  box-shadow: none !important;
}

.search-input:focus {
  box-shadow: none !important;
}

.btn-fetch {
  width: 100%;
  padding: 14px 20px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--brand);
  opacity: 0.7;
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  transition: opacity 0.2s ease;
  font-family: var(--sans);
}

.btn-fetch:hover {
  opacity: 0.85;
}

.btn-fetch.btn-small {
  width: auto;
  padding: 8px 16px;
  font-size: 13px;
}

/* ── Video Info Card ── */
.video-info-card {
  margin-top: 16px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.video-info-header {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
}

.video-thumbnail {
  width: 120px;
  height: 68px;
  object-fit: cover;
  border-radius: 4px;
}

.video-info-content {
  flex: 1;
}

.video-title {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 4px 0;
  color: var(--text);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.video-channel {
  font-size: 13px;
  color: var(--text-2);
  margin: 0 0 8px 0;
}

.caption-badge {
  display: inline-block;
  padding: 2px 8px;
  background: var(--brand);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  border-radius: 999px;
}

.video-summary {
  font-size: 13px;
  color: var(--text-2);
  margin: 0 0 12px 0;
  line-height: 1.5;
  max-height: 80px;
  overflow-y: auto;
}

.btn-clear {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-2);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

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

/* ── Channel Results ── */
.channel-results {
  margin-top: 16px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.channel-name {
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 12px 0;
  color: var(--text);
}

.channel-videos-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.channel-video-item {
  display: flex;
  gap: 10px;
  padding: 8px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.2s ease;
}

.channel-video-item:hover {
  background: var(--surface);
}

.channel-video-thumb {
  width: 80px;
  height: 45px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
}

.channel-video-title {
  font-size: 12px;
  color: var(--text);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin: 0;
}

.channel-keywords {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.channel-keyword {
  padding: 3px 10px;
  background: var(--brand);
  color: #fff;
  font-size: 11px;
  font-weight: 500;
  border-radius: 999px;
}

/* ── Option Pills (Section 2) ── */
.option-row {
  display: grid;
  gap: 10px;
}

.option-row.three-col {
  grid-template-columns: repeat(3, 1fr);
}

@media (max-width: 520px) {
  .option-row.three-col {
    grid-template-columns: 1fr;
  }
}

.option-pill {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: var(--sans);
}

.option-pill:hover {
  border-color: var(--text-faint);
}

.option-pill.is-active {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}

.option-pill.is-active svg {
  stroke: #fff;
}

/* ── Option Cards (Section 3 & 4) ── */
.option-grid {
  display: grid;
  gap: 10px;
}

.option-grid.two-col {
  grid-template-columns: repeat(2, 1fr);
}

@media (max-width: 520px) {
  .option-grid.two-col {
    grid-template-columns: 1fr;
  }
}

.option-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
  font-family: var(--sans);
}

.option-card:hover {
  border-color: var(--text-faint);
  background: var(--bg-page);
}

.option-card.is-active {
  border-color: var(--brand-border);
  background: var(--brand-light);
}

.option-card-icon {
  flex-shrink: 0;
  color: var(--text-muted);
}

.option-card.is-active .option-card-icon {
  color: var(--brand);
}

.option-card-text {
  display: grid;
  gap: 2px;
}

.option-card-text strong {
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
}

.option-card-text span {
  font-size: 12px;
  color: var(--text-muted);
}

.sub-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 10px;
}

/* ── Select Wrap ── */
.select-wrap {
  position: relative;
}

.select-wrap select {
  appearance: none;
  padding-right: 40px;
}

.select-arrow {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: var(--text-muted);
}

/* ── Results Area ── */
.results-area {
  min-height: 80px;
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-faint);
  font-size: 14px;
}

/* ── Result Cards ── */
.result {
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 12px;
}

.result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-page);
}

.badge {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  font-weight: 700;
  font-size: 13px;
  color: var(--text);
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--brand);
}

.result-actions {
  display: flex;
  gap: 6px;
}

.mini {
  border-radius: var(--radius-xs);
  padding: 6px 10px;
  font-weight: 700;
  font-size: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: var(--sans);
}

.mini:hover {
  border-color: var(--brand);
  color: var(--brand);
}

.result-body {
  padding: 16px;
}

.result-body pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
}

.meta {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
  display: grid;
  gap: 4px;
  color: var(--text-muted);
  font-size: 12px;
}

.meta code {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text);
}

/* ── Token Info ── */
.token-info {
  margin-top: 20px;
  display: grid;
  gap: 10px;
}

.token-required {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text);
  flex-wrap: wrap;
}

.token-count {
  color: var(--brand);
}

.token-current {
  margin-left: auto;
  color: var(--text-muted);
  font-size: 13px;
}

.token-current-val {
  color: var(--danger);
}

.token-warning {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  background: var(--danger-bg);
  font-size: 13px;
}

.token-warning svg {
  flex-shrink: 0;
  margin-top: 2px;
}

.token-warning strong {
  display: block;
  color: var(--danger);
  font-size: 14px;
  margin-bottom: 2px;
}

.token-warning span {
  color: var(--text-muted);
  line-height: 1.4;
}

/* ── CTA Button ── */
.cta-area {
  display: flex;
  justify-content: center;
  margin-top: 24px;
}

.btn-generate {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px 48px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--brand);
  color: #fff;
  font-weight: 700;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: var(--sans);
  box-shadow: 0 4px 14px rgba(107, 29, 42, 0.25);
}

.btn-generate:hover {
  opacity: 0.9;
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(107, 29, 42, 0.3);
}

.btn-generate:active {
  transform: translateY(0px);
}

.btn-generate:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* ── Footer ── */
.footer {
  padding: 16px 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  color: var(--text-faint);
  font-size: 12px;
}

.link {
  color: var(--brand);
  text-decoration: none;
  font-weight: 700;
}

.link:hover {
  text-decoration: underline;
}

/* ── Toast ── */
.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%) translateY(20px);
  background: var(--text);
  border: 1px solid var(--border);
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  box-shadow: var(--shadow-md);
  z-index: 10000;
}

.toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0px);
}

/* ── Results Head (for copy all button) ── */
.results-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

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

.btn-secondary {
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--bg);
  color: var(--text);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: var(--sans);
}

.btn-secondary:hover {
  border-color: var(--brand);
  color: var(--brand);
}

/* ── Responsive ── */
@media (max-width: 480px) {
  .header-inner {
    flex-wrap: wrap;
  }

  .step-section {
    padding: 18px;
  }

  .token-required {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .token-current {
    margin-left: 0;
  }

  .btn-generate {
    width: 100%;
  }
}

/* ── Animations ── */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.step-section {
  animation: fadeIn 0.3s ease forwards;
}

.step-section:nth-child(2) {
  animation-delay: 0.05s;
}

.step-section:nth-child(3) {
  animation-delay: 0.1s;
}

.step-section:nth-child(4) {
  animation-delay: 0.15s;
}

.step-section:nth-child(5) {
  animation-delay: 0.2s;
}

/* ── Dark Mode Overrides ── */
[data-theme="dark"] body {
  background: var(--bg-page);
}

[data-theme="dark"] .logo {
  background: var(--brand);
  box-shadow: 0 0 20px rgba(168, 50, 72, 0.3);
}

[data-theme="dark"] .tab-btn.is-active {
  background: var(--brand);
  border-color: var(--brand);
}

[data-theme="dark"] .option-pill.is-active {
  background: var(--brand);
  border-color: var(--brand);
}

[data-theme="dark"] .btn-fetch {
  background: var(--brand);
}

[data-theme="dark"] .btn-generate {
  background: var(--brand);
  box-shadow: 0 4px 14px rgba(168, 50, 72, 0.4);
}

[data-theme="dark"] .btn-generate:hover {
  box-shadow: 0 6px 20px rgba(168, 50, 72, 0.5);
}

[data-theme="dark"] input,
[data-theme="dark"] textarea,
[data-theme="dark"] select {
  background: var(--bg);
  border-color: var(--border);
  color: var(--text);
}

[data-theme="dark"] select option {
  background: var(--bg);
  color: var(--text);
}

[data-theme="dark"] .toast {
  background: #2a2a40;
  border-color: var(--border);
}

[data-theme="dark"] .token-warning {
  background: var(--danger-bg);
}

[data-theme="dark"] .search-input-wrap {
  background: var(--bg);
  border-color: var(--border);
}

/* Smooth theme transition */
body,
.header,
.step-section,
.option-card,
.option-pill,
.tab-btn,
input,
textarea,
select,
.token-required,
.token-warning,
.btn-icon,
.segmented,
.segmented-btn,
.result,
.result-head,
.footer {
  transition: background-color 0.25s ease, border-color 0.25s ease, color 0.25s ease;
}

/* Theme toggle icon visibility */
[data-theme="dark"] .icon-moon {
  display: none !important;
}

[data-theme="dark"] .icon-sun {
  display: block !important;
}

/* ── Auth & Modals ── */
.auth-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-right: 12px;
  border-right: 1px solid var(--border);
  padding-right: 12px;
}

.auth-guest {
  display: flex;
  gap: 8px;
}

.auth-user {
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
}

.token-balance {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--brand-light);
  color: var(--brand);
  padding: 6px 12px;
  border-radius: 20px;
  font-weight: 600;
  font-size: 14px;
}

.user-avatar {
  width: 36px;
  height: 36px;
  background: var(--brand);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  user-select: none;
}

.user-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  width: 200px;
  display: none;
  z-index: 100;
  overflow: hidden;
}

.user-dropdown.is-open {
  display: block;
}

.dropdown-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
}

.dropdown-header strong {
  font-size: 14px;
  color: var(--text);
}

.dropdown-header span {
  font-size: 12px;
  color: var(--text-muted);
}

.dropdown-item {
  width: 100%;
  text-align: left;
  padding: 10px 16px;
  background: none;
  border: none;
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s;
}

.dropdown-item:hover {
  background: var(--bg-page);
}

.dropdown-divider {
  height: 1px;
  background: var(--border-light);
  margin: 4px 0;
}

.text-danger {
  color: var(--danger);
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 998;
  display: none;
  backdrop-filter: blur(4px);
}

.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.95);
  background: var(--bg);
  width: 100%;
  max-width: 400px;
  border-radius: var(--radius);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  z-index: 999;
  display: none;
  opacity: 0;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
  padding: 24px;
}

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

.modal.is-visible {
  display: block;
  /* Makes modal visible in DOM so CSS transitions can animate opacity/transform */
}

.modal-header {
  display: flex;
  flex-direction: column;
  margin-bottom: 20px;
  text-align: center;
}

.modal-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}

.modal-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 4px;
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--bg-page);
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover {
  background: var(--border);
  color: var(--text);
}

.modal-footer-text {
  margin-top: 16px;
  text-align: center;
  font-size: 14px;
  color: var(--text-muted);
}

.modal-footer-text a {
  color: var(--brand);
  text-decoration: none;
  font-weight: 600;
}

/* Password Toggle */
.password-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.password-wrapper input {
  width: 100%;
  padding-right: 40px;
}

.password-toggle {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: color 0.2s;
}

.password-toggle:hover {
  color: var(--text);
}

/* Token Packages */
.token-packages {
  display: grid;
  gap: 12px;
}

.package-card {
  display: flex;
  align-items: center;
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  text-align: left;
}

.package-card:hover {
  border-color: var(--brand);
  background: var(--brand-light);
}

.package-card.popular {
  border-color: var(--brand);
  background: linear-gradient(to right, var(--bg), var(--brand-light));
}

.pkg-tag {
  position: absolute;
  top: -10px;
  right: 10px;
  background: var(--brand);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 12px;
  text-transform: uppercase;
}

.pkg-icon {
  font-size: 24px;
  margin-right: 16px;
}

.pkg-amount {
  flex: 1;
  font-weight: 600;
  font-size: 16px;
  color: var(--text);
}

.pkg-price {
  font-weight: 700;
  font-size: 16px;
  color: var(--brand);
}

/* Dark Mode Overrides for Auth */
[data-theme="dark"] .token-balance {
  background: rgba(168, 50, 72, 0.2);
  color: #ff8fa3;
}

[data-theme="dark"] .user-dropdown {
  background: var(--bg);
  border-color: var(--border);
}

[data-theme="dark"] .dropdown-header {
  border-bottom-color: var(--border-light);
}

[data-theme="dark"] .dropdown-item:hover {
  background: var(--border-light);
}

[data-theme="dark"] .dropdown-divider {
  background: var(--border-light);
}

[data-theme="dark"] .modal {
  background: var(--bg);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .modal-close {
  background: var(--border);
}

[data-theme="dark"] .package-card {
  background: rgba(255, 255, 255, 0.03);
  border-color: var(--border);
}

[data-theme="dark"] .package-card:hover {
  background: rgba(168, 50, 72, 0.15);
  border-color: var(--brand);
}

/* ── General Buttons ── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 24px;
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--sans);
}

.btn-primary:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.btn-primary.full-width {
  width: 100%;
}

.btn-primary.small {
  padding: 8px 16px;
  font-size: 13px;
}

.btn-primary.mini {
  padding: 6px 14px;
  font-size: 12px;
  border-radius: var(--radius-xs);
  margin-top: 8px;
  /* specific for warning box spacing */
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--sans);
}

.btn-secondary:hover {
  border-color: var(--brand);
  color: var(--brand);
}

.btn-text {
  background: none;
  border: none;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  padding: 8px;
  font-family: var(--sans);
}

.btn-text:hover {
  color: var(--text);
}

/* AI Toggle & Settings */
.ai-toggle-wrap {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  user-select: none;
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 8px 16px;
  border-radius: 999px;
  transition: all 0.2s ease;
  margin-bottom: 12px;
}

.ai-toggle-wrap:hover {
  border-color: var(--brand);
}

.ai-toggle-wrap input {
  display: none;
}

.ai-slider {
  width: 40px;
  height: 22px;
  background: var(--border);
  border-radius: 999px;
  position: relative;
  transition: background 0.3s ease;
}

.ai-slider::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.3s ease, background 0.3s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.ai-toggle-wrap input:checked~.ai-slider {
  background: var(--brand);
}

.ai-toggle-wrap input:checked~.ai-slider::after {
  transform: translateX(18px);
}

.ai-label {
  display: flex;
  align-items: center;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.ai-toggle-wrap input:checked~.ai-label {
  color: var(--brand);
}

/* Modals z-index fix */
.modal {
  z-index: 2000;
}

.modal-overlay {
  z-index: 1050;
}

/* ── Shopier Checkout Overlay ── */
.shopier-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: shopierFadeIn 0.25s ease;
}

@keyframes shopierFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.shopier-checkout-modal {
  width: 95vw;
  max-width: 520px;
  height: 90vh;
  max-height: 780px;
  background: var(--bg-primary, #fff);
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.4);
  animation: shopierSlideUp 0.3s ease;
}

@keyframes shopierSlideUp {
  from { transform: translateY(30px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.shopier-checkout-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-secondary, #f5f5f5);
  border-bottom: 1px solid var(--border, #e0e0e0);
  flex-shrink: 0;
}

.shopier-checkout-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary, #333);
  display: flex;
  align-items: center;
}

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

.shopier-copy-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border: 1px solid var(--accent, #6366f1);
  background: transparent;
  color: var(--accent, #6366f1);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.shopier-copy-btn:hover {
  background: var(--accent, #6366f1);
  color: #fff;
}

.shopier-copy-btn.copied {
  background: #4CAF50;
  border-color: #4CAF50;
  color: #fff;
}

.shopier-close-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: var(--bg-tertiary, #eee);
  color: var(--text-secondary, #666);
  border-radius: 8px;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  line-height: 1;
}

.shopier-close-btn:hover {
  background: #ef4444;
  color: #fff;
}

.shopier-email-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: #FFF3E0;
  border-bottom: 1px solid #FFE0B2;
  font-size: 12px;
  color: #E65100;
  flex-shrink: 0;
  line-height: 1.4;
}

[data-theme="dark"] .shopier-email-banner {
  background: rgba(255, 152, 0, 0.1);
  border-bottom-color: rgba(255, 152, 0, 0.2);
  color: #FFB74D;
}

.shopier-iframe-container {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #fff;
}

.shopier-iframe-loading {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: var(--bg-primary, #fff);
  color: var(--text-secondary, #666);
  font-size: 14px;
  z-index: 1;
}

.shopier-iframe-loading .spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border, #e0e0e0);
  border-top-color: var(--accent, #6366f1);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

#shopierIframe {
  width: 100%;
  height: 100%;
  border: none;
  position: relative;
  z-index: 2;
}

/* Mobile responsive */
@media (max-width: 600px) {
  .shopier-checkout-modal {
    width: 100vw;
    height: 100vh;
    max-width: none;
    max-height: none;
    border-radius: 0;
  }
  
  .shopier-copy-btn span {
    display: none;
  }
  
  .shopier-copy-btn {
    padding: 6px 8px;
  }
}

/* ── Dashboard ── */
.dashboard {
  padding-top: 40px;
}

.dashboard-hero {
  text-align: center;
  margin-bottom: 40px;
}

.dashboard-hero h1 {
  font-size: 32px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 8px;
}

.dashboard-hero p {
  font-size: 16px;
  color: var(--text-muted);
}

.tools-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

@media (max-width: 640px) {
  .tools-grid {
    grid-template-columns: 1fr;
  }
  
  .dashboard-hero h1 {
    font-size: 24px;
  }
}

.tool-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 24px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  transition: all 0.2s ease;
}

.tool-card:hover {
  border-color: var(--brand);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.tool-icon {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.tool-content {
  flex: 1;
}

.tool-content h3 {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.tool-content p {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.4;
}

.tool-arrow {
  color: var(--text-faint);
  transition: all 0.2s ease;
}

.tool-card:hover .tool-arrow {
  color: var(--brand);
  transform: translateX(4px);
}

/* Dashboard dark mode */
[data-theme="dark"] .tool-card:hover {
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
}

/* Brand link */
.brand {
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Mini button */
.btn-secondary.mini {
  padding: 6px 14px;
  font-size: 13px;
}

/* ── Video Editor Layout ── */
.editor-layout {
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100vh;
  overflow: hidden;
}

.editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: 56px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.editor-header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.editor-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.project-title-input input {
  background: transparent;
  border: none;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
}

.project-title-input input:focus {
  background: var(--bg-page);
  outline: none;
}

.save-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--success);
}

.circle-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.round-pill {
  border-radius: 99px;
}

/* ── Editor Main Area ── */
.editor-main {
  display: grid;
  grid-template-columns: auto 1fr auto;
  overflow: hidden;
  background: var(--bg-page);
}

/* Sidebar */
.editor-sidebar {
  width: 72px;
  background: var(--bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.sidebar-tabs {
  display: flex;
  flex-direction: column;
  padding: 8px;
  gap: 4px;
}

.sidebar-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 4px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}

.sidebar-tab:hover {
  background: var(--bg-page);
  color: var(--text);
}

.sidebar-tab.is-active {
  background: var(--brand-light);
  color: var(--brand);
}

/* Panels */
.editor-panel {
  width: 320px;
  background: var(--bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
}

.panel-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.panel-title {
  font-size: 16px;
  font-weight: 700;
  margin: 0;
}

.panel-header-actions {
  display: flex;
  gap: 4px;
}

.scenes-list {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.scene-item {
  background: var(--bg-page);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
}

.scene-item.is-active {
  border-color: var(--brand);
  background: var(--brand-light);
}

.scene-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.scene-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 13px;
}

.scene-voice {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-muted);
  cursor: pointer;
}

.scene-voice:hover {
  color: var(--brand);
}

.scene-body {
  padding: 12px;
}

.scene-textarea {
  width: 100%;
  min-height: 80px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px;
  font-size: 13px;
  resize: vertical;
  background: var(--bg);
  color: var(--text);
}

.scene-textarea:focus {
  outline: none;
  border-color: var(--brand);
}

.panel-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
  background: var(--bg);
}

/* Preview Area */
.editor-preview-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: #111;
  position: relative;
  overflow: hidden;
}

.preview-toolbar {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 10;
}

.preview-badge {
  background: rgba(0,0,0,0.6);
  color: #fff;
  padding: 4px 12px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 600;
}

.preview-player-wrapper {
  width: 100%;
  max-width: 800px;
  aspect-ratio: 16/9;
  background: #000;
  border-radius: var(--radius-sm);
  overflow: hidden;
  position: relative;
}

.preview-player {
  width: 100%;
  height: 100%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.preview-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: rgba(255,255,255,0.4);
}

.player-controls {
  width: 100%;
  max-width: 800px;
  height: 56px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-top: 16px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 16px;
}

.time-display {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.player-right-controls {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.zoom-slider {
  width: 100px;
}

/* Properties Panel */
.editor-properties {
  width: 280px;
  background: var(--bg);
  border-left: 1px solid var(--border);
  overflow-y: auto;
}

.properties-empty {
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

/* Timeline */
.editor-timeline {
  height: 140px;
  background: var(--bg);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.timeline-toolbar {
  height: 40px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
}

.timeline-tools {
  display: flex;
  gap: 8px;
}

.timeline-tracks-container {
  flex: 1;
  position: relative;
  overflow-x: auto;
  overflow-y: hidden;
  background: var(--bg-page);
}

.timeline-track {
  height: 40px;
  position: relative;
  border-bottom: 1px solid var(--border-light);
}

.timeline-clip {
  position: absolute;
  top: 4px;
  height: 32px;
  border-radius: 4px;
  overflow: hidden;
  cursor: pointer;
}

.clip-video {
  background: #3b82f6;
  background-size: cover;
  background-position: center;
}

.clip-video.empty {
  background: #94a3b8;
}

.clip-label {
  position: absolute;
  top: 4px;
  left: 6px;
  background: rgba(0,0,0,0.5);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
  z-index: 2;
  color: #fff;
}

.clip-audio {
  background: #10b981;
  opacity: 0.8;
}

/* Media Grid */
.media-tabs {
  display: flex;
  padding: 0 16px;
  gap: 16px;
  border-bottom: 1px solid var(--border);
}

.media-tab {
  padding: 12px 4px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}

.media-tab.active {
  color: var(--brand);
  border-bottom-color: var(--brand);
}

.media-grid {
  padding: 16px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  overflow-y: auto;
}

.media-item {
  aspect-ratio: 16/9;
  background: var(--bg-page);
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  position: relative;
}

.media-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.media-item-duration {
  position: absolute;
  bottom: 4px;
  right: 4px;
  background: rgba(0,0,0,0.7);
  color: #fff;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
}

/* Text Presets */
.text-preset-btn {
  background: #f1f5f9;
  border-radius: 8px;
  padding: 16px 20px;
  cursor: pointer;
  transition: background 0.2s;
  display: flex;
  align-items: center;
}

.text-preset-btn:hover {
  background: #e2e8f0;
}

/* Subtitle Overlay */
.subtitle-overlay {
  position: absolute;
  bottom: 10%;
  left: 0;
  width: 100%;
  text-align: center;
  padding: 0 20px;
  pointer-events: none;
}

.subtitle-text {
  display: inline-block;
  background: rgba(0,0,0,0.6);
  color: #fff;
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 20px;
  font-weight: 600;
  font-family: var(--sans);
  text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
}

/* Playhead */
.timeline-playhead {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--danger);
  z-index: 5;
  pointer-events: none;
}

.playhead-head {
  position: absolute;
  top: -8px;
  left: -4px;
  width: 10px;
  height: 10px;
  background: var(--danger);
}

.playhead-line {
  width: 2px;
  height: 100%;
  background: var(--danger);
}

.timeline-ruler {
  height: 24px;
  border-bottom: 1px solid var(--border);
  position: relative;
}

/* Media Search */
.search-input-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 14px;
  background: var(--bg);
}

.search-input {
  border: none !important;
  padding: 12px 0 !important;
  box-shadow: none !important;
}

.full-width {
  width: 100%;
}

/* Circle button */
.btn-icon.circle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
}