:root {
  --bg-dark: #0b0f19;
  --card-bg: rgba(22, 29, 45, 0.75);
  --card-border: rgba(255, 255, 255, 0.08);
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --accent: #f59e0b;
  --success: #10b981;
  --danger: #ef4444;
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --radius-lg: 16px;
  --radius-md: 10px;
}

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

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-dark);
  background-image: 
    radial-gradient(at 15% 15%, rgba(99, 102, 241, 0.15) 0px, transparent 50%),
    radial-gradient(at 85% 85%, rgba(245, 158, 11, 0.12) 0px, transparent 50%);
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.5;
}

.hidden { display: none !important; }

/* MODAL */
.modal-backdrop {
  position: fixed;
  top: 0; left: 0; width: 100vw; height: 100vh;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(12px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
}

.login-card {
  width: 100%;
  max-width: 420px;
  padding: 2.5rem;
}

.brand-header {
  text-align: center;
  margin-bottom: 2rem;
}

.logo-icon {
  font-size: 3rem;
  margin-bottom: 0.5rem;
}

.logo-icon-sm {
  font-size: 1.5rem;
}

/* CARDS & GLASSMORPHISM */
.glass-card {
  background: var(--card-bg);
  backdrop-filter: blur(16px);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 1.8rem;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

.card-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
}

.card-desc {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

/* NAVBAR */
.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem;
  background: rgba(15, 23, 42, 0.8);
  border-bottom: 1px solid var(--card-border);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 700;
  font-size: 1.1rem;
}

.nav-tabs {
  display: flex;
  gap: 0.5rem;
}

.nav-tab {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 0.6rem 1.2rem;
  font-weight: 600;
  font-size: 0.95rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s;
}

.nav-tab:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}

.nav-tab.active {
  color: #fff;
  background: var(--primary);
}

/* LAYOUT & GRIDS */
.app-wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.main-content {
  padding: 2rem;
  max-width: 1300px;
  width: 100%;
  margin: 0 auto;
  flex: 1;
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
}

.grid {
  display: grid;
  gap: 1.5rem;
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.gap-sm { gap: 1rem; }
.flex-col { display: flex; flex-direction: column; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }

@media (max-width: 900px) {
  .grid-2 { grid-template-columns: 1fr; }
}

/* FORM CONTROLS */
.form-group {
  margin-bottom: 1.2rem;
}

.music-library-panel {
  padding: 14px;
  border: 1px solid rgba(168, 195, 160, 0.35);
  border-radius: 12px;
  background: rgba(250, 247, 242, 0.04);
}

.music-library-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
}

.music-library-panel select:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
  color: var(--text-main);
}

.form-input, .form-select {
  width: 100%;
  padding: 0.8rem 1rem;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  color: #fff;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
}

.form-input:focus, .form-select:focus {
  border-color: var(--primary);
}

.form-divider {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin: 1rem 0;
  font-weight: 700;
}

.slider-wrapper {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.form-range {
  flex: 1;
  accent-color: var(--primary);
}

/* BUTTONS & BADGES */
.btn {
  padding: 0.75rem 1.4rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.95rem;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

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

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

.btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.btn-danger {
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.4);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.4);
  color: #fff;
}

.btn-warning {
  background: rgba(245, 158, 11, 0.2);
  color: #fcd34d;
  border: 1px solid rgba(245, 158, 11, 0.4);
}

.btn-warning:hover {
  background: rgba(245, 158, 11, 0.4);
  color: #fff;
}

.flex-1 { flex: 1; }
.mt-sm { margin-top: 0.5rem; }
.mt-md { margin-top: 1rem; }
.mb-sm { margin-bottom: 0.5rem; }

.source-link-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid rgba(239, 68, 68, 0.3);
  word-break: break-all;
}

.source-link-badge:hover {
  background: rgba(239, 68, 68, 0.3);
  color: #fff;
}

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

.btn-ghost:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.05);
}

.btn-block { width: 100%; }
.btn-lg { padding: 1rem 1.5rem; font-size: 1.05rem; }

.badge {
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 700;
}

.badge-accent { background: rgba(245, 158, 11, 0.2); color: var(--accent); }
.badge-secondary { background: rgba(99, 102, 241, 0.2); color: var(--primary); }

/* LOG CONSOLE */
.log-console {
  background: #060911;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 1rem;
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.85rem;
  height: 380px;
  overflow-y: auto;
  color: #a7f3d0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.log-line {
  word-break: break-word;
}

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

.reference-panel {
  margin: 1rem 0 1.25rem;
  padding: 1rem;
  border: 1px solid rgba(168, 195, 160, 0.34);
  border-radius: var(--radius-md);
  background:
    linear-gradient(145deg, rgba(168, 195, 160, 0.08), rgba(232, 180, 184, 0.06)),
    rgba(9, 13, 24, 0.45);
}

.reference-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.reference-subtitle {
  margin-top: 0.25rem;
  font-size: 0.8rem;
  line-height: 1.45;
}

.reference-url-stack {
  display: grid;
  gap: 0.55rem;
}

.reference-file-list {
  margin-top: 0.45rem;
  font-size: 0.76rem;
  line-height: 1.45;
}

.reference-discovery {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.9rem;
  border: 1px solid rgba(232, 180, 184, 0.34);
  border-radius: 14px;
  background: rgba(232, 180, 184, 0.07);
  cursor: pointer;
}

.reference-discovery input {
  width: 20px;
  height: 20px;
  margin-top: 0.1rem;
  flex: 0 0 auto;
}

.reference-discovery span {
  display: grid;
  gap: 0.25rem;
}

.reference-discovery small {
  color: var(--text-muted);
  line-height: 1.45;
}

.advanced-kicker {
  margin-bottom: 0.45rem;
  color: #A8C3A0;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.16em;
}

.advanced-details {
  margin-top: 0.8rem;
  padding: 0.9rem 1rem;
  border: 1px solid rgba(168, 195, 160, 0.25);
  border-radius: var(--radius-md);
  background: rgba(168, 195, 160, 0.05);
}

.advanced-details summary {
  color: var(--text-main);
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
}

.advanced-status {
  min-height: 1.4rem;
  margin-top: 0.9rem;
  font-size: 0.82rem;
  line-height: 1.45;
}

.advanced-output-card {
  display: flex;
  flex-direction: column;
}

.advanced-prompt-output {
  min-height: 520px;
  margin-top: 0.8rem;
  resize: vertical;
  color: #FAF7F2;
  line-height: 1.65;
  background:
    linear-gradient(145deg, rgba(168, 195, 160, 0.08), rgba(232, 180, 184, 0.05)),
    rgba(6, 9, 17, 0.82);
}

.advanced-analyzed-shorts,
.analyzed-shorts-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.85rem;
  font-size: 0.8rem;
}

.analyzed-shorts-links > span {
  color: var(--text-muted);
  font-weight: 700;
}

.analyzed-shorts-links a {
  color: #FAF7F2;
  padding: 0.35rem 0.55rem;
  border: 1px solid rgba(168, 195, 160, 0.48);
  border-radius: 999px;
  background: rgba(168, 195, 160, 0.12);
  text-decoration: none;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.analyzed-shorts-links a:hover {
  background: rgba(232, 180, 184, 0.18);
  border-color: rgba(232, 180, 184, 0.72);
}

/* ALERTS */
.alert {
  padding: 0.8rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

.alert-error { background: rgba(239, 68, 68, 0.2); color: #fca5a5; border: 1px solid rgba(239, 68, 68, 0.4); }
.alert-success { background: rgba(16, 185, 129, 0.2); color: #6ee7b7; border: 1px solid rgba(16, 185, 129, 0.4); }

/* GALLERY & VIDEO PLAYER */
.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
}

.video-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.video-player-wrapper {
  position: relative;
  width: 100%;
  padding-top: 177.77%; /* 9:16 vertical ratio */
  background: #000;
}

.video-player-wrapper video {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  object-fit: cover;
}

.video-card-body {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.video-card-title {
  font-weight: 700;
  font-size: 0.95rem;
}

.video-card-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
}

.video-transcript {
  margin-top: 0.35rem;
  padding: 0.75rem;
  border: 1px solid rgba(168, 195, 160, 0.28);
  border-radius: 10px;
  background: rgba(250, 247, 242, 0.045);
}

.video-transcript-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  color: var(--text-primary);
  font-size: 0.8rem;
  font-weight: 700;
}

.video-transcript p {
  margin: 0.55rem 0 0;
  color: var(--text-muted);
  font-size: 0.82rem;
  line-height: 1.55;
  white-space: normal;
}

.advanced-history-card {
  margin-top: 1.5rem;
}

.advanced-history-list {
  display: grid;
  gap: 0.85rem;
  margin-top: 1rem;
}

.advanced-history-item {
  padding: 1rem;
  border: 1px solid rgba(168, 195, 160, 0.28);
  border-radius: 12px;
  background: rgba(250, 247, 242, 0.045);
}

.advanced-history-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.advanced-history-topic {
  color: var(--text-primary);
  font-size: 0.9rem;
  font-weight: 700;
}

.advanced-history-date {
  color: var(--text-muted);
  font-size: 0.76rem;
  margin-top: 0.2rem;
}

.advanced-history-item p {
  margin: 0.7rem 0 0;
  color: var(--text-muted);
  font-size: 0.84rem;
  line-height: 1.6;
  white-space: pre-wrap;
}

/* --- TEMPLATE PICKER GRID & HOVER PREVIEWS --- */
.template-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 0.9rem;
  margin-top: 0.6rem;
  margin-bottom: 1.2rem;
}

.template-card {
  position: relative;
  background: rgba(15, 23, 42, 0.65);
  border: 1.5px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 1.1rem 1rem;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  user-select: none;
  overflow: hidden;
}

.template-card:hover {
  border-color: rgba(0, 229, 255, 0.4);
  transform: translateY(-3px);
  box-shadow: 0 10px 25px rgba(0, 229, 255, 0.1);
  background: rgba(15, 23, 42, 0.9);
}

.template-card.active {
  border-color: #00e5ff;
  background: rgba(0, 229, 255, 0.08);
  box-shadow: 0 0 22px rgba(0, 229, 255, 0.25);
}

.template-card.active::after {
  content: '✓';
  position: absolute;
  top: 10px;
  right: 10px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #00e5ff;
  color: #000;
  font-size: 13px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tpl-card-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 0.65rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 6px;
  background: rgba(0, 229, 255, 0.15);
  color: #00e5ff;
  border: 1px solid rgba(0, 229, 255, 0.3);
  letter-spacing: 0.5px;
}

.tpl-badge-orange { background: rgba(234, 88, 12, 0.2); color: #ea580c; border-color: rgba(234, 88, 12, 0.4); }
.tpl-badge-amber { background: rgba(245, 158, 11, 0.2); color: #f59e0b; border-color: rgba(245, 158, 11, 0.4); }
.tpl-badge-cyan { background: rgba(6, 182, 212, 0.2); color: #06b6d4; border-color: rgba(6, 182, 212, 0.4); }
.tpl-badge-green { background: rgba(16, 185, 129, 0.2); color: #10b981; border-color: rgba(16, 185, 129, 0.4); }
.tpl-badge-purple { background: rgba(168, 85, 247, 0.2); color: #a855f7; border-color: rgba(168, 85, 247, 0.4); }

.template-card.active .tpl-card-badge { display: none; }

.tpl-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
}

.tpl-title { font-size: 0.92rem; font-weight: 800; color: #f8fafc; }
.tpl-desc { font-size: 0.74rem; color: #94a3b8; line-height: 1.45; }

.tpl-hover-preview {
  margin-top: 0.2rem;
  height: 0;
  opacity: 0;
  transform: scale(0.95);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
  overflow: hidden;
}

.template-card:hover .tpl-hover-preview,
.template-card.active .tpl-hover-preview {
  height: 75px;
  opacity: 1;
  transform: scale(1);
  margin-top: 0.5rem;
}

.mini-mockup {
  width: 100%;
  height: 72px;
  border-radius: 8px;
  padding: 5px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.creator-mockup { background: #f8fafc; }
.creator-mockup .mini-title-line { font-size: 8px; font-weight: 900; text-align: center; line-height: 1.1; }
.creator-mockup .m-black { color: #0f172a; }
.creator-mockup .m-orange { color: #ea580c; }
.creator-mockup .mini-video-rounded { width: 70%; height: 30px; background: #cbd5e1; border-radius: 6px; margin: 0 auto; box-shadow: 0 3px 6px rgba(0,0,0,0.15); }
.creator-mockup .mini-caption-pill { width: fit-content; margin: -8px auto 0 auto; background: #ea580c; color: #fff; font-size: 6px; font-weight: 900; padding: 1px 5px; border-radius: 3px; }

.story-mockup { background: radial-gradient(circle, #241e1b 0%, #0c0a09 100%); }
.story-mockup .mini-story-title { width: 60%; height: 4px; background: #e5c4a9; border-radius: 2px; margin: 2px auto; }
.story-mockup .mini-video-box.warm-box { width: 80%; height: 30px; background: #78716c; border-radius: 4px; margin: 0 auto; border: 1px solid #aeac7c; }
.story-mockup .mini-warm-badge { width: 40%; height: 5px; background: rgba(229, 196, 169, 0.3); border: 1px solid #e5c4a9; border-radius: 3px; margin: 0 auto; }

.cyber-mockup { background: #050811; border-color: #00e5ff33; }
.cyber-mockup .mini-cyber-grid { width: 50%; height: 4px; background: #00e5ff; border-radius: 2px; margin: 2px auto; box-shadow: 0 0 6px #00e5ff; }
.cyber-mockup .mini-video-box.cyber-box { width: 80%; height: 30px; background: #0f172a; border-radius: 2px; margin: 0 auto; border: 1px solid #00e5ff88; }
.cyber-mockup .mini-telemetry-bar { width: 90%; height: 4px; background: linear-gradient(90deg, #00e5ff, #10b981); border-radius: 2px; margin: 0 auto; }

.data-mockup { background: #0f172a; }
.data-mockup .mini-data-header { width: 55%; height: 4px; background: #10b981; border-radius: 2px; margin: 2px auto; }
.data-mockup .mini-video-box { width: 80%; height: 30px; background: #1e293b; border-radius: 4px; margin: 0 auto; }
.data-mockup .mini-ladder-bars { width: 70%; height: 5px; background: #f59e0b; border-radius: 3px; margin: 0 auto; }

.dark-mockup { background: #09090b; }
.dark-mockup .mini-gold-title { width: 60%; height: 4px; background: linear-gradient(90deg, #fef08a, #eab308); border-radius: 2px; margin: 2px auto; }
.dark-mockup .mini-video-box.dark-box { width: 80%; height: 30px; background: #18181b; border-radius: 4px; margin: 0 auto; border: 1px solid #eab30866; }
.dark-mockup .mini-glow-footer { width: 40%; height: 5px; background: #a855f7; border-radius: 2px; margin: 0 auto; box-shadow: 0 0 6px #a855f7; }

.auto-mockup { background: linear-gradient(135deg, #0f172a, #1e1b4b); }
.auto-mockup .mini-top-bar { width: 50%; height: 4px; background: #38bdf8; border-radius: 2px; margin: 2px auto; }
.auto-mockup .mini-video-box { width: 80%; height: 30px; background: #334155; border-radius: 4px; margin: 0 auto; }
.auto-mockup .mini-bottom-card { width: 60%; height: 5px; background: #818cf8; border-radius: 3px; margin: 0 auto; }

.badge-template { background: rgba(0, 229, 255, 0.12); color: #00e5ff; border: 1px solid rgba(0, 229, 255, 0.3); font-size: 0.72rem; font-weight: 700; padding: 3px 8px; border-radius: 6px; display: inline-flex; align-items: center; gap: 4px; }
.btn-use-template { background: rgba(0, 229, 255, 0.08); border: 1px solid #00e5ff88; color: #00e5ff; font-weight: 700; font-size: 0.78rem; padding: 5px 10px; border-radius: 6px; cursor: pointer; transition: all 0.2s ease; }
.btn-use-template:hover { background: #00e5ff; color: #000; box-shadow: 0 0 12px rgba(0, 229, 255, 0.4); }

