/* ═══════════════════════════════════════════════
   ASKAI — FULL DESIGN SYSTEM
   Deep Space · Violet/Cyan · Outfit + Space Mono
═══════════════════════════════════════════════ */

:root {
  --bg:        #0A0F1E;
  --bg2:       #0F1628;
  --bg3:       #141C35;
  --card:      #161E38;
  --card2:     #1C2545;
  --border:    rgba(124,58,237,0.18);
  --border2:   rgba(255,255,255,0.06);
  --p1:        #7C3AED;
  --p2:        #00D4FF;
  --p1-soft:   rgba(124,58,237,0.15);
  --p2-soft:   rgba(0,212,255,0.12);
  --text:      #E8EEFF;
  --text2:     #8B9CC8;
  --text3:     #4A5580;
  --success:   #10B981;
  --warning:   #F59E0B;
  --danger:    #EF4444;
  --radius:    16px;
  --radius-sm: 10px;
  --radius-lg: 24px;
  --shadow:    0 8px 32px rgba(0,0,0,0.4);
  --shadow-p:  0 4px 20px rgba(124,58,237,0.3);
  --font:      'Outfit', sans-serif;
  --font-mono: 'Space Mono', monospace;
  --nav-h:     72px;
  --status-h:  28px;
  --header-h:  56px;
  --transition: 0.25s cubic-bezier(0.4,0,0.2,1);
}

/* ── RESET ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  max-width: 430px;
  margin: 0 auto;
  overflow: hidden;
  position: relative;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
button { font-family: var(--font); cursor: pointer; border: none; outline: none; }
input, textarea, select { font-family: var(--font); outline: none; }
textarea { resize: none; }

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 3px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--p1-soft); border-radius: 2px; }

/* ══════════════════════════════════════════════
   SPLASH
══════════════════════════════════════════════ */
#splash {
  position: fixed; inset: 0; z-index: 9999;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  transition: opacity 0.5s ease, transform 0.5s ease;
}
#splash.hidden { opacity: 0; transform: scale(1.05); pointer-events: none; }
.splash-inner { text-align: center; }
.splash-logo {
  position: relative; width: 90px; height: 90px;
  margin: 0 auto 20px;
  display: flex; align-items: center; justify-content: center;
}
.splash-orb {
  position: absolute; inset: 0; border-radius: 50%;
  background: radial-gradient(circle, rgba(124,58,237,0.6) 0%, rgba(0,212,255,0.2) 60%, transparent 100%);
  animation: pulse-orb 2s ease-in-out infinite;
}
.splash-icon { font-size: 2.5rem; position: relative; z-index: 1; }
.splash-title { font-size: 2.8rem; font-weight: 800; letter-spacing: -1px; background: linear-gradient(135deg, #fff 0%, var(--p2) 100%); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.splash-sub { color: var(--text2); font-size: 0.9rem; margin: 6px 0 28px; letter-spacing: 2px; text-transform: uppercase; }
.splash-bar { width: 160px; height: 3px; background: var(--bg3); border-radius: 2px; margin: 0 auto; overflow: hidden; }
.splash-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--p1), var(--p2)); border-radius: 2px; animation: splash-load 2s ease forwards; }
@keyframes splash-load { to { width: 100%; } }
@keyframes pulse-orb { 0%,100%{transform:scale(1);opacity:0.8} 50%{transform:scale(1.15);opacity:1} }

/* ══════════════════════════════════════════════
   STATUS BAR
══════════════════════════════════════════════ */
.status-bar {
  position: fixed; top: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 430px;
  height: var(--status-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 18px;
  background: var(--bg);
  z-index: 100;
  font-size: 0.72rem; font-weight: 600; color: var(--text);
}
.status-icons { display: flex; align-items: center; gap: 6px; }

/* ══════════════════════════════════════════════
   APP WRAPPER + SCREENS
══════════════════════════════════════════════ */
.app-wrapper {
  position: fixed;
  top: var(--status-h);
  left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 430px;
  height: calc(100vh - var(--status-h) - var(--nav-h));
  overflow: hidden;
}
.screen {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  opacity: 0; pointer-events: none;
  transform: translateX(30px);
  transition: opacity var(--transition), transform var(--transition);
}
.screen.active {
  opacity: 1; pointer-events: all;
  transform: translateX(0);
}
.screen-scroll {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  padding: 12px 16px 0;
  -webkit-overflow-scrolling: touch;
}

/* ── SCREEN HEADER ── */
.screen-header {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border2);
  flex-shrink: 0;
}
.back-btn {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--card); color: var(--text);
  font-size: 1.4rem; display: flex; align-items: center; justify-content: center;
  transition: background var(--transition);
}
.back-btn:hover { background: var(--card2); }
.screen-title { flex: 1; font-size: 1.05rem; font-weight: 700; }
.header-action-btn {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--p1-soft); color: var(--p2);
  font-size: 1rem; display: flex; align-items: center; justify-content: center;
  transition: background var(--transition);
}
.header-action-btn:hover { background: var(--p1); }
.header-action-btn.danger { background: rgba(239,68,68,0.15); color: var(--danger); }

/* ══════════════════════════════════════════════
   HOME SCREEN
══════════════════════════════════════════════ */
.home-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 14px 0 10px;
}
.greeting-sub { font-size: 0.82rem; color: var(--text2); margin-bottom: 4px; }
.greeting-title { font-size: 1.25rem; font-weight: 700; line-height: 1.3; }
.gradient-text { background: linear-gradient(135deg, var(--p1), var(--p2)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.avatar-btn {
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--card2); border: 2px solid var(--border);
  font-size: 1.2rem; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: border-color var(--transition);
}
.avatar-btn:hover { border-color: var(--p1); }

/* ── QUOTE CARD ── */
.quote-card {
  background: linear-gradient(135deg, rgba(124,58,237,0.12), rgba(0,212,255,0.08));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 14px;
  position: relative;
  overflow: hidden;
}
.quote-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, var(--p1), var(--p2));
}
.quote-icon { font-size: 1.1rem; display: block; margin-bottom: 6px; }
.quote-text { font-size: 0.88rem; line-height: 1.5; color: var(--text); font-style: italic; padding-right: 28px; }
.quote-author { font-size: 0.75rem; color: var(--text2); display: block; margin-top: 6px; }
.quote-refresh {
  position: absolute; top: 12px; right: 12px;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--p1-soft); color: var(--p2);
  font-size: 0.9rem; display: flex; align-items: center; justify-content: center;
  transition: transform 0.3s ease;
}
.quote-refresh:hover { transform: rotate(180deg); }

/* ── SEARCH ── */
.home-search { margin-bottom: 14px; }
.search-box {
  display: flex; align-items: center; gap: 10px;
  background: var(--card); border: 1px solid var(--border2);
  border-radius: 50px; padding: 10px 14px;
  transition: border-color var(--transition);
}
.search-box:focus-within { border-color: var(--p1); }
.search-icon { font-size: 1rem; flex-shrink: 0; }
.search-box input {
  flex: 1; background: none; border: none; color: var(--text);
  font-size: 0.9rem;
}
.search-box input::placeholder { color: var(--text3); }
.search-send-btn {
  width: 30px; height: 30px; border-radius: 50%;
  background: linear-gradient(135deg, var(--p1), var(--p2));
  color: #fff; font-size: 1rem;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

/* ── CHIPS ── */
.chips-row {
  display: flex; gap: 8px; overflow-x: auto; padding-bottom: 10px; margin-bottom: 4px;
  scrollbar-width: none;
}
.chips-row::-webkit-scrollbar { display: none; }
.cat-chip, .topic-chip {
  flex-shrink: 0; padding: 6px 14px; border-radius: 50px;
  background: var(--card); border: 1px solid var(--border2);
  color: var(--text2); font-size: 0.8rem; font-weight: 500;
  transition: all var(--transition);
}
.cat-chip.active, .topic-chip.active {
  background: var(--p1); border-color: var(--p1); color: #fff;
}

/* ── FEATURE GRID ── */
.feature-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 10px; margin: 12px 0;
}
.feat-card {
  background: var(--card); border: 1px solid var(--border2);
  border-radius: var(--radius); padding: 14px;
  display: flex; align-items: center; gap: 10px;
  cursor: pointer; transition: all var(--transition);
  position: relative; overflow: hidden;
}
.feat-card::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(135deg, transparent, rgba(255,255,255,0.03));
  pointer-events: none;
}
.feat-card:hover { transform: translateY(-2px); border-color: var(--p1); box-shadow: var(--shadow-p); }
.feat-card__icon { font-size: 1.5rem; flex-shrink: 0; }
.feat-card__info h3 { font-size: 0.85rem; font-weight: 700; margin-bottom: 2px; }
.feat-card__info p { font-size: 0.72rem; color: var(--text2); }
.feat-card__arrow { margin-left: auto; color: var(--text3); font-size: 1.2rem; }
.feat-qa { border-left: 3px solid var(--p1); }
.feat-img { border-left: 3px solid #EC4899; }
.feat-vid { border-left: 3px solid #F59E0B; }
.feat-solve { border-left: 3px solid var(--success); }

/* ── STATS ROW ── */
.stats-row {
  display: flex; gap: 8px; margin-bottom: 16px;
}
.stat-pill {
  flex: 1; background: var(--card); border: 1px solid var(--border2);
  border-radius: 50px; padding: 6px 10px;
  text-align: center; font-size: 0.78rem; color: var(--text2);
}
.stat-pill span { font-weight: 700; color: var(--p2); font-family: var(--font-mono); }

/* ── SECTION HEADER ── */
.section-header { margin-bottom: 10px; }
.section-title { font-size: 0.95rem; font-weight: 700; }
.section-label {
  font-size: 0.75rem; font-weight: 600; color: var(--text2);
  text-transform: uppercase; letter-spacing: 1px;
  margin: 14px 0 8px;
}

/* ── TRENDING ── */
.trending-item {
  background: var(--card); border: 1px solid var(--border2);
  border-radius: var(--radius-sm); padding: 12px 14px;
  margin-bottom: 8px; cursor: pointer;
  display: flex; align-items: center; gap: 10px;
  transition: all var(--transition);
}
.trending-item:hover { border-color: var(--p1); background: var(--card2); }
.trending-num { font-family: var(--font-mono); font-size: 0.7rem; color: var(--p1); font-weight: 700; min-width: 20px; }
.trending-q { font-size: 0.85rem; flex: 1; }
.trending-cat { font-size: 0.7rem; color: var(--text2); background: var(--bg3); padding: 2px 8px; border-radius: 50px; }

/* ══════════════════════════════════════════════
   ASK AI SCREEN
══════════════════════════════════════════════ */
.ask-input-wrap {
  background: var(--card); border: 1px solid var(--border2);
  border-radius: var(--radius); padding: 14px;
  margin: 10px 0;
  transition: border-color var(--transition);
}
.ask-input-wrap:focus-within { border-color: var(--p1); }
#ask-textarea {
  width: 100%; background: none; border: none;
  color: var(--text); font-size: 0.92rem; line-height: 1.5;
  min-height: 80px;
}
#ask-textarea::placeholder { color: var(--text3); }
.ask-actions { display: flex; gap: 8px; margin-top: 10px; }
.ask-btn {
  flex: 1; padding: 11px 16px; border-radius: 50px;
  background: linear-gradient(135deg, var(--p1), var(--p2));
  color: #fff; font-size: 0.9rem; font-weight: 600;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  transition: opacity var(--transition), transform var(--transition);
}
.ask-btn:hover { opacity: 0.9; transform: scale(0.98); }
.ask-btn:disabled { opacity: 0.5; }
.ask-btn__icon { font-size: 1rem; }
.solve-mode-btn {
  padding: 11px 14px; border-radius: 50px;
  background: rgba(16,185,129,0.15); border: 1px solid rgba(16,185,129,0.3);
  color: var(--success); font-size: 0.82rem; font-weight: 600;
  transition: all var(--transition);
}
.solve-mode-btn:hover { background: rgba(16,185,129,0.25); }

/* ── THINKING ── */
.thinking-wrap {
  text-align: center; padding: 24px 16px;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.thinking-orb {
  width: 50px; height: 50px; border-radius: 50%;
  background: radial-gradient(circle, var(--p1) 0%, transparent 70%);
  animation: pulse-orb 1.5s ease-in-out infinite;
}
.thinking-label { font-size: 0.85rem; color: var(--text2); }
.thinking-dots { display: flex; gap: 6px; }
.thinking-dots span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--p1); animation: dot-bounce 1.2s ease-in-out infinite;
}
.thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes dot-bounce { 0%,80%,100%{transform:scale(0.8);opacity:0.5} 40%{transform:scale(1.2);opacity:1} }

/* ── ANSWER AREA ── */
.answer-area {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  animation: slide-up 0.4s ease;
}
@keyframes slide-up { from{opacity:0;transform:translateY(16px)} to{opacity:1;transform:translateY(0)} }
.answer-header {
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border2);
  display: flex; align-items: flex-start; justify-content: space-between; gap: 10px;
}
.answer-question { font-size: 0.88rem; color: var(--text2); font-style: italic; flex: 1; }
.answer-topic-badge {
  font-size: 0.7rem; font-weight: 600; padding: 3px 10px; border-radius: 50px;
  background: var(--p1-soft); color: var(--p2); flex-shrink: 0;
}
.answer-body-wrap { padding: 14px 16px; }
.answer-body { font-size: 0.92rem; line-height: 1.65; color: var(--text); }
.answer-facts {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 0 16px 12px;
}
.fact-tag {
  font-size: 0.75rem; padding: 4px 10px; border-radius: 50px;
  background: var(--bg3); border: 1px solid var(--border2); color: var(--text2);
}
.answer-actions {
  display: flex; gap: 8px; padding: 10px 16px;
  border-top: 1px solid var(--border2);
}
.ans-action-btn {
  flex: 1; padding: 8px 6px; border-radius: var(--radius-sm);
  background: var(--bg3); color: var(--text2); font-size: 0.75rem; font-weight: 600;
  transition: all var(--transition);
}
.ans-action-btn:hover { background: var(--p1-soft); color: var(--p2); }
.related-section { padding: 12px 16px; border-top: 1px solid var(--border2); }
.related-title { font-size: 0.78rem; font-weight: 600; color: var(--text2); margin-bottom: 8px; }
.related-item {
  font-size: 0.82rem; color: var(--p2); padding: 6px 0;
  border-bottom: 1px solid var(--border2); cursor: pointer;
  transition: color var(--transition);
}
.related-item:hover { color: var(--p1); }
.related-item:last-child { border-bottom: none; }

/* ── PROBLEM SOLVER ── */
.solver-area {
  background: var(--card); border: 1px solid rgba(16,185,129,0.3);
  border-radius: var(--radius); overflow: hidden;
  animation: slide-up 0.4s ease;
}
.solver-header { padding: 14px 16px; border-bottom: 1px solid var(--border2); }
.solver-badge {
  display: inline-block; font-size: 0.72rem; font-weight: 700;
  padding: 3px 10px; border-radius: 50px;
  background: rgba(16,185,129,0.15); color: var(--success);
  margin-bottom: 8px;
}
.solver-problem { font-size: 0.88rem; color: var(--text2); font-style: italic; }
.solver-steps { padding: 14px 16px; }
.solver-step {
  display: flex; gap: 12px; margin-bottom: 14px;
  animation: slide-up 0.3s ease both;
}
.step-num {
  width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, var(--p1), var(--p2));
  display: flex; align-items: center; justify-content: center;
  font-size: 0.72rem; font-weight: 700; color: #fff;
}
.step-content { flex: 1; }
.step-title { font-size: 0.88rem; font-weight: 600; margin-bottom: 3px; }
.step-desc { font-size: 0.8rem; color: var(--text2); line-height: 1.5; }
.solver-tip {
  margin: 0 16px 16px;
  background: rgba(245,158,11,0.1); border: 1px solid rgba(245,158,11,0.25);
  border-radius: var(--radius-sm); padding: 10px 12px;
  font-size: 0.8rem; color: var(--warning); line-height: 1.5;
}

/* ══════════════════════════════════════════════
   IMAGE GENERATOR SCREEN
══════════════════════════════════════════════ */
.style-row {
  display: flex; gap: 8px; overflow-x: auto; padding-bottom: 8px;
  scrollbar-width: none;
}
.style-row::-webkit-scrollbar { display: none; }
.style-btn {
  flex-shrink: 0; padding: 7px 14px; border-radius: 50px;
  background: var(--card); border: 1px solid var(--border2);
  color: var(--text2); font-size: 0.8rem; font-weight: 500;
  transition: all var(--transition);
}
.style-btn.active { background: var(--p1); border-color: var(--p1); color: #fff; }

.qp-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 8px; margin-bottom: 4px;
}
.qp-card {
  background: var(--card); border: 1px solid var(--border2);
  border-radius: var(--radius-sm); padding: 10px 12px;
  cursor: pointer; transition: all var(--transition);
}
.qp-card:hover { border-color: var(--p1); background: var(--card2); }
.qp-card__icon { font-size: 1.2rem; display: block; margin-bottom: 4px; }
.qp-card__text { font-size: 0.78rem; color: var(--text2); }

.prompt-input-wrap {
  background: var(--card); border: 1px solid var(--border2);
  border-radius: var(--radius); padding: 12px;
  transition: border-color var(--transition);
}
.prompt-input-wrap:focus-within { border-color: var(--p1); }
#prompt-textarea {
  width: 100%; background: none; border: none;
  color: var(--text); font-size: 0.9rem; line-height: 1.5;
}
#prompt-textarea::placeholder { color: var(--text3); }
.prompt-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.prompt-tag {
  font-size: 0.72rem; padding: 3px 10px; border-radius: 50px;
  background: var(--p1-soft); color: var(--p2); cursor: pointer;
  transition: background var(--transition);
}
.prompt-tag:hover { background: var(--p1); color: #fff; }

.generate-btn {
  width: 100%; margin: 14px 0;
  padding: 14px; border-radius: 50px;
  background: linear-gradient(135deg, var(--p1), var(--p2));
  color: #fff; font-size: 1rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: opacity var(--transition), transform var(--transition);
  box-shadow: var(--shadow-p);
}
.generate-btn:hover { opacity: 0.9; transform: scale(0.98); }
.generate-btn:disabled { opacity: 0.5; }

.image-result { margin-top: 8px; }
.image-generating {
  text-align: center; padding: 30px 16px;
  background: var(--card); border-radius: var(--radius);
}
.gen-orb {
  width: 60px; height: 60px; border-radius: 50%; margin: 0 auto 14px;
  background: radial-gradient(circle, var(--p1) 0%, var(--p2) 60%, transparent 100%);
  animation: pulse-orb 1.5s ease-in-out infinite;
}
.image-generating p { font-size: 0.85rem; color: var(--text2); margin-bottom: 14px; }
.gen-progress {
  height: 4px; background: var(--bg3); border-radius: 2px; overflow: hidden;
}
.gen-progress-fill {
  height: 100%; width: 0;
  background: linear-gradient(90deg, var(--p1), var(--p2));
  border-radius: 2px; transition: width 0.3s ease;
}
.image-display {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  animation: slide-up 0.4s ease;
}
.image-display img {
  width: 100%; aspect-ratio: 1; object-fit: cover; display: block;
}
.image-prompt-echo {
  padding: 10px 14px; font-size: 0.78rem; color: var(--text2);
  border-bottom: 1px solid var(--border2);
}
.image-actions {
  display: flex; gap: 8px; padding: 10px 14px;
}
.img-action-btn {
  flex: 1; padding: 8px 6px; border-radius: var(--radius-sm);
  background: var(--bg3); color: var(--text2); font-size: 0.75rem; font-weight: 600;
  transition: all var(--transition);
}
.img-action-btn:hover { background: var(--p1-soft); color: var(--p2); }

/* ══════════════════════════════════════════════
   VIDEO CREATOR SCREEN
══════════════════════════════════════════════ */
.vid-template-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 8px; margin-bottom: 4px;
}
.vid-template {
  background: var(--card); border: 1px solid var(--border2);
  border-radius: var(--radius-sm); padding: 12px 8px;
  text-align: center; cursor: pointer;
  transition: all var(--transition);
}
.vid-template.active { border-color: var(--p1); background: var(--p1-soft); }
.vid-template:hover { border-color: var(--p1); }
.vt-icon { font-size: 1.4rem; display: block; margin-bottom: 4px; }
.vt-label { font-size: 0.72rem; color: var(--text2); font-weight: 500; }
.vid-template.active .vt-label { color: var(--p2); }

.vid-style-row {
  display: flex; gap: 8px; overflow-x: auto; padding-bottom: 8px;
  scrollbar-width: none;
}
.vid-style-row::-webkit-scrollbar { display: none; }
.vid-style-btn {
  flex-shrink: 0; padding: 7px 14px; border-radius: 50px;
  background: var(--card); border: 1px solid var(--border2);
  color: var(--text2); font-size: 0.8rem; font-weight: 500;
  transition: all var(--transition);
}
.vid-style-btn.active { background: var(--p1); border-color: var(--p1); color: #fff; }

.duration-row { display: flex; gap: 8px; margin-bottom: 4px; }
.dur-btn {
  flex: 1; padding: 8px; border-radius: var(--radius-sm);
  background: var(--card); border: 1px solid var(--border2);
  color: var(--text2); font-size: 0.82rem; font-weight: 600;
  transition: all var(--transition);
}
.dur-btn.active { background: var(--p1); border-color: var(--p1); color: #fff; }

.script-input-wrap {
  background: var(--card); border: 1px solid var(--border2);
  border-radius: var(--radius); padding: 12px;
  transition: border-color var(--transition); position: relative;
}
.script-input-wrap:focus-within { border-color: var(--p1); }
#script-textarea {
  width: 100%; background: none; border: none;
  color: var(--text); font-size: 0.9rem; line-height: 1.5;
}
#script-textarea::placeholder { color: var(--text3); }
.script-char-count {
  text-align: right; font-size: 0.72rem; color: var(--text3);
  margin-top: 6px; font-family: var(--font-mono);
}

.vid-ideas-row {
  display: flex; gap: 8px; overflow-x: auto; padding-bottom: 8px;
  scrollbar-width: none;
}
.vid-ideas-row::-webkit-scrollbar { display: none; }
.vid-idea-chip {
  flex-shrink: 0; padding: 7px 14px; border-radius: 50px;
  background: var(--card); border: 1px solid var(--border2);
  color: var(--text2); font-size: 0.78rem; cursor: pointer;
  transition: all var(--transition);
}
.vid-idea-chip:hover { border-color: var(--p1); color: var(--p2); }

.create-vid-btn {
  width: 100%; margin: 14px 0;
  padding: 14px; border-radius: 50px;
  background: linear-gradient(135deg, #F59E0B, #EF4444);
  color: #fff; font-size: 1rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: opacity var(--transition), transform var(--transition);
  box-shadow: 0 4px 20px rgba(245,158,11,0.3);
}
.create-vid-btn:hover { opacity: 0.9; transform: scale(0.98); }
.create-vid-btn:disabled { opacity: 0.5; }

/* ── VIDEO RESULT ── */
.vid-result { margin-top: 8px; }
.vid-generating {
  text-align: center; padding: 30px 16px;
  background: var(--card); border-radius: var(--radius);
}
.vid-gen-orb {
  width: 60px; height: 60px; border-radius: 50%; margin: 0 auto 14px;
  background: radial-gradient(circle, #F59E0B 0%, #EF4444 60%, transparent 100%);
  animation: pulse-orb 1.5s ease-in-out infinite;
}
.vid-generating p { font-size: 0.85rem; color: var(--text2); margin-bottom: 14px; }
.vid-timeline {
  display: flex; gap: 4px; justify-content: center; margin-bottom: 12px;
}
.vid-timeline-seg {
  height: 4px; border-radius: 2px; flex: 1;
  background: var(--bg3); transition: background 0.3s ease;
}
.vid-timeline-seg.active { background: linear-gradient(90deg, #F59E0B, #EF4444); }

.vid-preview {
  background: var(--card); border: 1px solid rgba(245,158,11,0.3);
  border-radius: var(--radius); overflow: hidden;
  animation: slide-up 0.4s ease;
}
.vid-player {
  background: #000; position: relative;
  aspect-ratio: 16/9; overflow: hidden;
}
.vid-scene-display {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.9rem; text-align: center; padding: 20px;
  transition: all 0.5s ease;
}
.vid-controls {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: linear-gradient(transparent, rgba(0,0,0,0.8));
  padding: 20px 12px 10px;
  display: flex; align-items: center; gap: 10px;
}
.vid-play-btn {
  width: 32px; height: 32px; border-radius: 50%;
  background: rgba(255,255,255,0.2); color: #fff;
  font-size: 0.8rem; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.vid-progress-bar {
  flex: 1; height: 3px; background: rgba(255,255,255,0.2);
  border-radius: 2px; overflow: hidden;
}
.vid-progress-inner {
  height: 100%; width: 0;
  background: linear-gradient(90deg, #F59E0B, #EF4444);
  border-radius: 2px; transition: width 0.1s linear;
}
.vid-duration-label { font-size: 0.7rem; color: rgba(255,255,255,0.7); font-family: var(--font-mono); }
.vid-script-echo {
  padding: 10px 14px; font-size: 0.78rem; color: var(--text2);
  border-bottom: 1px solid var(--border2);
}
.vid-actions {
  display: flex; gap: 8px; padding: 10px 14px;
}
.vid-action-btn {
  flex: 1; padding: 8px 6px; border-radius: var(--radius-sm);
  background: var(--bg3); color: var(--text2); font-size: 0.75rem; font-weight: 600;
  transition: all var(--transition);
}
.vid-action-btn:hover { background: rgba(245,158,11,0.15); color: #F59E0B; }

/* ══════════════════════════════════════════════
   HISTORY SCREEN
══════════════════════════════════════════════ */
.hist-tabs {
  display: flex; gap: 0; margin-bottom: 14px;
  background: var(--card); border-radius: var(--radius-sm);
  padding: 4px;
}
.hist-tab {
  flex: 1; padding: 8px; border-radius: 8px;
  background: none; color: var(--text2); font-size: 0.85rem; font-weight: 600;
  transition: all var(--transition);
}
.hist-tab.active { background: var(--p1); color: #fff; }
.hist-panel { display: none; }
.hist-panel.active { display: block; }

.hist-qa-item {
  background: var(--card); border: 1px solid var(--border2);
  border-radius: var(--radius-sm); padding: 12px 14px;
  margin-bottom: 8px; cursor: pointer;
  transition: all var(--transition);
}
.hist-qa-item:hover { border-color: var(--p1); }
.hist-qa-q { font-size: 0.85rem; font-weight: 600; margin-bottom: 4px; }
.hist-qa-a { font-size: 0.78rem; color: var(--text2); line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.hist-qa-meta { display: flex; justify-content: space-between; margin-top: 6px; }
.hist-qa-cat { font-size: 0.7rem; color: var(--p2); }
.hist-qa-date { font-size: 0.7rem; color: var(--text3); }

.hist-img-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.hist-img-item {
  border-radius: var(--radius-sm); overflow: hidden;
  cursor: pointer; position: relative;
  transition: transform var(--transition);
}
.hist-img-item:hover { transform: scale(0.97); }
.hist-img-item img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.hist-img-label {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: linear-gradient(transparent, rgba(0,0,0,0.8));
  padding: 16px 8px 6px;
  font-size: 0.7rem; color: #fff;
}

.hist-vid-item {
  background: var(--card); border: 1px solid var(--border2);
  border-radius: var(--radius-sm); padding: 12px 14px;
  margin-bottom: 8px; cursor: pointer;
  display: flex; align-items: center; gap: 12px;
  transition: all var(--transition);
}
.hist-vid-item:hover { border-color: rgba(245,158,11,0.4); }
.hist-vid-thumb {
  width: 56px; height: 40px; border-radius: 6px;
  background: linear-gradient(135deg, #F59E0B22, #EF444422);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; flex-shrink: 0;
}
.hist-vid-info { flex: 1; }
.hist-vid-title { font-size: 0.85rem; font-weight: 600; margin-bottom: 3px; }
.hist-vid-meta { font-size: 0.72rem; color: var(--text2); }

.hist-empty {
  text-align: center; padding: 40px 20px;
  color: var(--text3);
}
.hist-empty span { font-size: 2.5rem; display: block; margin-bottom: 10px; opacity: 0.4; }
.hist-empty p { font-size: 0.85rem; }

/* ══════════════════════════════════════════════
   CONTROL PANEL SCREEN
══════════════════════════════════════════════ */
.ctrl-stats-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 8px; margin-bottom: 4px;
}
.ctrl-stat-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 14px;
  text-align: center;
}
.ctrl-stat-num {
  display: block; font-size: 1.8rem; font-weight: 800;
  font-family: var(--font-mono);
  background: linear-gradient(135deg, var(--p1), var(--p2));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.ctrl-stat-label { font-size: 0.72rem; color: var(--text2); margin-top: 2px; display: block; }

.ctrl-card {
  background: var(--card); border: 1px solid var(--border2);
  border-radius: var(--radius); padding: 14px;
  margin-bottom: 4px; display: flex; flex-direction: column; gap: 10px;
}
.ctrl-input {
  width: 100%; background: var(--bg3); border: 1px solid var(--border2);
  border-radius: var(--radius-sm); padding: 10px 12px;
  color: var(--text); font-size: 0.88rem;
  transition: border-color var(--transition);
}
.ctrl-input:focus { border-color: var(--p1); }
.ctrl-textarea {
  width: 100%; background: var(--bg3); border: 1px solid var(--border2);
  border-radius: var(--radius-sm); padding: 10px 12px;
  color: var(--text); font-size: 0.88rem; line-height: 1.5;
  transition: border-color var(--transition);
}
.ctrl-textarea:focus { border-color: var(--p1); }
.ctrl-select {
  width: 100%; background: var(--bg3); border: 1px solid var(--border2);
  border-radius: var(--radius-sm); padding: 10px 12px;
  color: var(--text); font-size: 0.88rem;
  appearance: none;
}
.ctrl-btn {
  width: 100%; padding: 11px; border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--p1), var(--p2));
  color: #fff; font-size: 0.88rem; font-weight: 600;
  transition: opacity var(--transition);
}
.ctrl-btn:hover { opacity: 0.9; }
.ctrl-hint { font-size: 0.75rem; color: var(--text3); text-align: center; }

.theme-grid {
  display: flex; gap: 10px; flex-wrap: wrap;
}
.theme-swatch {
  width: 44px; height: 44px; border-radius: 50%;
  cursor: pointer; border: 3px solid transparent;
  transition: all var(--transition);
}
.theme-swatch.active { border-color: #fff; transform: scale(1.1); }
.theme-swatch:hover { transform: scale(1.05); }

/* ── SETTINGS ROWS ── */
.setting-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 0;
}
.setting-info { flex: 1; }
.setting-name { display: block; font-size: 0.88rem; font-weight: 600; }
.setting-desc { display: block; font-size: 0.75rem; color: var(--text2); margin-top: 2px; }
.toggle-switch { position: relative; width: 44px; height: 24px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0; border-radius: 50px;
  background: var(--bg3); cursor: pointer;
  transition: background var(--transition);
}
.toggle-slider::before {
  content: ''; position: absolute;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--text3); left: 3px; top: 3px;
  transition: transform var(--transition), background var(--transition);
}
.toggle-switch input:checked + .toggle-slider { background: var(--p1); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(20px); background: #fff; }

/* ── CUSTOM QA LIST ── */
.custom-qa-item {
  background: var(--card); border: 1px solid var(--border2);
  border-radius: var(--radius-sm); padding: 10px 12px;
  margin-bottom: 8px; display: flex; align-items: flex-start; gap: 10px;
}
.custom-qa-text { flex: 1; }
.custom-qa-q { font-size: 0.82rem; font-weight: 600; margin-bottom: 2px; }
.custom-qa-cat { font-size: 0.7rem; color: var(--p2); }
.custom-qa-del {
  width: 26px; height: 26px; border-radius: 50%;
  background: rgba(239,68,68,0.1); color: var(--danger);
  font-size: 0.8rem; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: background var(--transition);
}
.custom-qa-del:hover { background: rgba(239,68,68,0.25); }

/* ── DANGER ZONE ── */
.danger-label { color: var(--danger) !important; }
.danger-card { border-color: rgba(239,68,68,0.2) !important; }
.danger-btn {
  background: rgba(239,68,68,0.15) !important;
  color: var(--danger) !important;
  border: 1px solid rgba(239,68,68,0.3);
}
.danger-btn:hover { background: rgba(239,68,68,0.25) !important; }

/* ══════════════════════════════════════════════
   BOTTOM NAV
══════════════════════════════════════════════ */
.bottom-nav {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 430px;
  height: var(--nav-h);
  background: rgba(10,15,30,0.95);
  backdrop-filter: blur(20px);
  border-top: 1px solid var(--border2);
  display: flex; align-items: center; justify-content: space-around;
  padding: 0 8px;
  z-index: 100;
}
.nav-item {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 3px;
  padding: 8px 4px; border-radius: var(--radius-sm);
  background: none; color: var(--text3);
  transition: color var(--transition);
}
.nav-item.active { color: var(--p2); }
.nav-icon { font-size: 1.3rem; }
.nav-label { font-size: 0.62rem; font-weight: 600; }
.nav-center {
  flex: 0 0 64px;
}
.nav-center-btn {
  width: 52px; height: 52px; border-radius: 50%;
  background: linear-gradient(135deg, #F59E0B, #EF4444);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  box-shadow: 0 4px 16px rgba(245,158,11,0.4);
  transition: transform var(--transition);
}
.nav-center:hover .nav-center-btn { transform: scale(1.08); }

/* ══════════════════════════════════════════════
   TOAST NOTIFICATION
══════════════════════════════════════════════ */
.toast {
  position: fixed; bottom: calc(var(--nav-h) + 12px);
  left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--card2); border: 1px solid var(--border);
  border-radius: 50px; padding: 10px 20px;
  font-size: 0.82rem; color: var(--text);
  z-index: 9998; opacity: 0;
  transition: all 0.3s ease;
  white-space: nowrap;
  max-width: 90%;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ══════════════════════════════════════════════
   THEME VARIANTS
══════════════════════════════════════════════ */
body.theme-rose   { --p1: #E11D48; --p2: #FB923C; --p1-soft: rgba(225,29,72,0.15); --p2-soft: rgba(251,146,60,0.12); --border: rgba(225,29,72,0.18); --shadow-p: 0 4px 20px rgba(225,29,72,0.3); }
body.theme-emerald{ --p1: #059669; --p2: #06B6D4; --p1-soft: rgba(5,150,105,0.15); --p2-soft: rgba(6,182,212,0.12); --border: rgba(5,150,105,0.18); --shadow-p: 0 4px 20px rgba(5,150,105,0.3); }
body.theme-gold   { --p1: #D97706; --p2: #FBBF24; --p1-soft: rgba(217,119,6,0.15); --p2-soft: rgba(251,191,36,0.12); --border: rgba(217,119,6,0.18); --shadow-p: 0 4px 20px rgba(217,119,6,0.3); }
body.theme-pink   { --p1: #DB2777; --p2: #A855F7; --p1-soft: rgba(219,39,119,0.15); --p2-soft: rgba(168,85,247,0.12); --border: rgba(219,39,119,0.18); --shadow-p: 0 4px 20px rgba(219,39,119,0.3); }
body.theme-blue   { --p1: #1D4ED8; --p2: #06B6D4; --p1-soft: rgba(29,78,216,0.15); --p2-soft: rgba(6,182,212,0.12); --border: rgba(29,78,216,0.18); --shadow-p: 0 4px 20px rgba(29,78,216,0.3); }

/* ══════════════════════════════════════════════
   UTILITY
══════════════════════════════════════════════ */
.no-anim * { transition: none !important; animation: none !important; }