:root {
  --bg: #05060a;
  --panel: rgba(255,255,255,.04);
  --panel-2: rgba(255,255,255,.07);
  --border: rgba(255,255,255,.09);
  --text: #e8ecf4;
  --text-2: #aab3c5;
  --text-3: #6b7488;
  --accent: #7aa2ff;
  --grad: linear-gradient(90deg,#7aa2ff,#b78cff,#5ee0ff);
  --radius: 14px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: "Inter", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
button { font-family: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input, textarea { font-family: inherit; color: var(--text); }
a { color: var(--accent); }
.hidden { display: none !important; }

#app { display: flex; height: 100vh; }

/* ---------- Sidebar ---------- */
#sidebar {
  width: 250px; flex: none; display: flex; flex-direction: column;
  background: rgba(10,12,20,.72); backdrop-filter: blur(18px);
  border-right: 1px solid var(--border); padding: 18px 14px; gap: 6px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; }
.brand img { width: 34px; height: 34px; border-radius: 8px; }
.brand span { font-family: "Orbitron", sans-serif; font-weight: 800; letter-spacing: 2px; font-size: 17px; }
.nav-main, .nav-sub { display: flex; flex-direction: column; gap: 2px; }
.nav-sub { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px;
  border-radius: 10px; font-size: 14px; color: var(--text-2); text-align: left;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--panel-2); color: var(--text); }
.nav-item.active { background: var(--panel-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--border); }
.premium-card {
  margin-top: auto; background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px;
}
.premium-title { display: flex; align-items: center; gap: 7px; font-weight: 600; font-size: 14px; }
.crown { width: 16px; height: 16px; stroke: #ffce54; }
.premium-sub { font-size: 11.5px; color: var(--text-3); margin: 5px 0 10px; }
#upgrade-btn {
  width: 100%; padding: 8px; border-radius: 9px; background: var(--panel-2);
  border: 1px solid var(--border); font-size: 13px; font-weight: 500;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
#upgrade-btn:hover { background: rgba(255,255,255,.12); }
#upgrade-btn .arr { font-size: 14px; }

/* ---------- Main / topbar ---------- */
#main { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; }
#main::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background: radial-gradient(900px 500px at 70% 115%, rgba(70,110,255,.16), transparent 60%),
              radial-gradient(700px 420px at 15% -10%, rgba(120,80,255,.08), transparent 55%);
}
#topbar {
  display: flex; align-items: center; gap: 14px; padding: 12px 20px;
  position: relative; z-index: 5;
}
#menu-btn { display: none; }
.search-box {
  flex: 1; max-width: 560px; display: flex; align-items: center; gap: 9px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 9px 13px; color: var(--text-3);
}
.search-box input { flex: 1; background: none; border: none; outline: none; font-size: 13.5px; }
.search-box input::placeholder { color: var(--text-3); }
.search-box kbd {
  font-family: inherit; font-size: 11px; color: var(--text-3);
  border: 1px solid var(--border); border-radius: 6px; padding: 2px 7px; white-space: nowrap;
}
.top-right { margin-left: auto; display: flex; align-items: center; gap: 10px; position: relative; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center;
  justify-content: center; color: var(--text-2); position: relative;
}
.icon-btn:hover { background: var(--panel-2); color: var(--text); }
#bell-dot { position: absolute; top: 8px; right: 9px; width: 7px; height: 7px; border-radius: 50%; background: #ff5d5d; }
#avatar-btn { width: 36px; height: 36px; border-radius: 50%; overflow: hidden; border: 1px solid var(--border); background: var(--panel-2); display: flex; align-items: center; justify-content: center; color: var(--text-2); }
#avatar-btn img { width: 100%; height: 100%; object-fit: cover; }
#avatar-menu, #notif-panel {
  position: absolute; top: 46px; right: 0; min-width: 230px; z-index: 50;
  background: #10131d; border: 1px solid var(--border); border-radius: 12px;
  padding: 12px; box-shadow: 0 12px 40px rgba(0,0,0,.5);
}
#notif-panel { right: 46px; }
.notif-head { font-weight: 600; font-size: 13px; margin-bottom: 8px; }
.notif-empty { font-size: 12.5px; color: var(--text-3); }
.avatar-name { font-size: 13.5px; font-weight: 600; }
.avatar-email { font-size: 12px; color: var(--text-3); margin: 2px 0 10px; word-break: break-all; }
.signout-btn { width: 100%; padding: 7px; border-radius: 8px; background: var(--panel-2); border: 1px solid var(--border); font-size: 12.5px; }
.signout-btn:hover { background: rgba(255,255,255,.12); }
.engine-pill { font-size: 11px; padding: 4px 11px; border-radius: 999px; border: 1px solid var(--border); white-space: nowrap; }
.engine-pill.on { color: #5ad19a; border-color: rgba(90,209,154,.4); background: rgba(90,209,154,.08); }
.engine-pill.off { color: #ff8585; border-color: rgba(255,133,133,.35); background: rgba(255,133,133,.07); }

/* ---------- Views ---------- */
.view { flex: 1; display: flex; flex-direction: column; min-height: 0; position: relative; z-index: 1; overflow-y: auto; }
#view-home { padding: 34px 44px; overflow-y: auto; }

.hero { display: flex; align-items: center; gap: 30px; margin: 10px 0 30px; }
.hero-left { flex: 1; min-width: 0; }
.hero-welcome { font-size: 22px; color: var(--text-2); }
.hero-word {
  font-family: "Orbitron", sans-serif; font-weight: 800; font-size: 64px; letter-spacing: 6px;
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
  line-height: 1.05;
}
.hero-tag { letter-spacing: 3.5px; font-size: 12.5px; color: var(--text-3); margin-top: 8px; }
.hero-right img {
  width: 240px; height: 240px; object-fit: contain; border-radius: 24px;
  filter: drop-shadow(0 0 45px rgba(122,162,255,.35));
}
.hero-ask {
  display: flex; align-items: center; gap: 10px; max-width: 640px; margin: 0 auto 34px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 999px; padding: 7px 8px 7px 18px;
}
.hero-ask .spark { color: var(--accent); }
.hero-ask input { flex: 1; background: none; border: none; outline: none; font-size: 14.5px; }
.hero-send {
  width: 40px; height: 40px; border-radius: 50%; background: #fff; color: #0a0c14;
  display: flex; align-items: center; justify-content: center;
}
.cards { display: flex; gap: 14px; flex-wrap: wrap; }
.card {
  flex: 1; min-width: 165px; max-width: 230px; text-align: left; position: relative;
  background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 18px;
  display: flex; flex-direction: column; gap: 6px; transition: background .15s, transform .15s;
}
.card:hover { background: var(--panel-2); transform: translateY(-2px); }
.card svg { width: 26px; height: 26px; color: var(--text); margin-bottom: 6px; }
.card-title { font-weight: 600; font-size: 14.5px; }
.card-sub { font-size: 12px; color: var(--text-3); }
.card-arrow {
  position: absolute; right: 14px; bottom: 14px; width: 26px; height: 26px;
  border-radius: 50%; border: 1px solid var(--border); display: flex; align-items: center;
  justify-content: center; font-size: 13px; color: var(--text-2);
}

/* ---------- Feeds & composer ---------- */
.feed { flex: 1; overflow-y: auto; padding: 22px 44px; display: flex; flex-direction: column; gap: 12px; }
.composer { padding: 10px 44px 18px; }
.composer-row {
  display: flex; align-items: flex-end; gap: 8px; background: var(--panel);
  border: 1px solid var(--border); border-radius: 999px; padding: 6px;
}
.c-input {
  flex: 1; background: none; border: none; outline: none; resize: none;
  font-size: 14.5px; padding: 9px 6px; max-height: 130px;
}
.c-input::placeholder { color: var(--text-3); }
.c-send {
  width: 40px; height: 40px; flex: none; border-radius: 50%;
  background: var(--grad); color: #0a0c14; display: flex; align-items: center; justify-content: center;
}
.c-mic.rec { color: #ff5d5d; animation: pulse 1.1s infinite; }
@keyframes pulse { 50% { opacity: .4; } }
#chips { display: none; gap: 8px; flex-wrap: wrap; padding: 0 6px 10px; }
#chips.open { display: flex; }
.chip {
  padding: 6px 14px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--panel); font-size: 12.5px; color: var(--text-2);
}
.chip.active { color: #fff; border-color: var(--accent); background: rgba(122,162,255,.15); }
.persona-bar { display: flex; gap: 8px; padding: 14px 44px 0; flex-wrap: wrap; }
.persona {
  padding: 6px 15px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--panel); font-size: 12.5px; color: var(--text-2);
}
.persona.active { color: #fff; border-color: var(--accent); background: rgba(122,162,255,.15); }

/* bubbles & jobs */
.chat-bubble, .user-bubble {
  max-width: 72%; padding: 11px 16px; border-radius: 16px; font-size: 14.5px; line-height: 1.5;
  white-space: pre-wrap; word-break: break-word;
}
.chat-bubble { background: var(--panel-2); border: 1px solid var(--border); border-bottom-left-radius: 4px; align-self: flex-start; }
.user-bubble { background: rgba(122,162,255,.18); border: 1px solid rgba(122,162,255,.35); border-bottom-right-radius: 4px; align-self: flex-end; }
.chat-bubble pre {
  background: #0b0e16; border: 1px solid var(--border); border-radius: 10px;
  padding: 12px; overflow-x: auto; margin: 8px 0; font-size: 13px; white-space: pre;
}
.chat-bubble code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 13px; }
.job { background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.job-head { display: flex; align-items: center; gap: 10px; }
.job-idea { font-weight: 600; font-size: 14.5px; flex: 1; }
.job-badge { font-size: 11px; padding: 3px 10px; border-radius: 999px; }
.job-badge.run { background: rgba(122,162,255,.15); color: var(--accent); }
.job-badge.done { background: rgba(90,209,154,.12); color: #5ad19a; }
.job-badge.fail { background: rgba(255,133,133,.12); color: #ff8585; }
.job-status { font-size: 12.5px; color: var(--text-2); display: flex; align-items: center; gap: 8px; }
.spinner { width: 13px; height: 13px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.scene-row { display: flex; align-items: center; gap: 9px; font-size: 12.5px; color: var(--text-2); padding: 3px 0; }
.scene-num { width: 19px; height: 19px; border-radius: 50%; background: var(--panel-2); display: flex; align-items: center; justify-content: center; font-size: 10.5px; flex: none; }
.scene-text { flex: 1; }
.scene-state.wait { color: var(--text-3); }
.scene-state.run { color: var(--accent); }
.scene-state.done { color: #5ad19a; }
.scene-state.fail { color: #ff8585; }
.retry-link { color: var(--accent); font-size: 12px; text-decoration: underline; }
.err-note { font-size: 12.5px; color: #ffb46b; }
.job-videos { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.vid-card { background: #0b0e16; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.vid-card video { width: 100%; display: block; }
.vid-meta { display: flex; align-items: center; justify-content: space-between; padding: 8px 11px; font-size: 12px; color: var(--text-3); }
.dl-btn { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--accent); }
.dl-btn svg { width: 13px; height: 13px; }
.history-empty { color: var(--text-3); font-size: 13px; padding: 12px; text-align: center; }

/* images */
.img-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.img-card { background: #0b0e16; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; position: relative; }
.img-card img { width: 100%; display: block; aspect-ratio: 1; object-fit: cover; }
.img-card .img-loading { aspect-ratio: 1; display: flex; flex-direction: column; gap: 8px; align-items: center; justify-content: center; color: var(--text-3); font-size: 12.5px; }
.img-card .vid-meta { justify-content: space-between; }
.img-prompt { font-size: 11.5px; color: var(--text-3); padding: 0 11px 9px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Help ---------- */
.help-body { padding: 30px 44px; max-width: 760px; overflow-y: auto; }
.help-body h2 { font-size: 22px; margin-bottom: 18px; }
.help-body h3 { font-size: 15.5px; margin: 20px 0 8px; }
.help-body li { font-size: 13.5px; color: var(--text-2); line-height: 1.6; margin: 5px 0 5px 20px; }
.help-body p { font-size: 13.5px; color: var(--text-2); line-height: 1.6; }
.help-body code { background: var(--panel-2); border-radius: 5px; padding: 1px 6px; font-size: 12px; }

/* ---------- Modals ---------- */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); backdrop-filter: blur(4px); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-card {
  width: 100%; max-width: 430px; background: #10131d; border: 1px solid var(--border);
  border-radius: 18px; padding: 22px; display: flex; flex-direction: column; gap: 10px;
  max-height: 88vh; overflow-y: auto;
}
.modal-card.wide { max-width: 860px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.modal-head h3 { font-size: 17px; }
.modal-card label { font-size: 13px; color: var(--text-2); display: flex; flex-direction: column; gap: 2px; }
.modal-card label small { color: var(--text-3); font-size: 11.5px; }
.modal-card input, .modal-card select {
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; font-size: 13.5px; outline: none; color: inherit;
}
.modal-card input:focus, .modal-card select:focus { border-color: var(--accent); }
.modal-text { font-size: 13.5px; color: var(--text-2); line-height: 1.55; }
.primary-btn { background: var(--grad); color: #0a0c14; font-weight: 600; border-radius: 10px; padding: 11px; font-size: 14px; margin-top: 6px; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  #sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: 60; transform: translateX(-100%); transition: transform .2s; }
  #sidebar.open { transform: none; box-shadow: 0 0 60px rgba(0,0,0,.6); }
  #menu-btn { display: flex; }
  .hero-right img { width: 140px; height: 140px; }
  .hero-word { font-size: 42px; }
  #view-home { padding: 20px; }
  .feed, .composer, .help-body, .persona-bar { padding-left: 18px; padding-right: 18px; }
  .search-box kbd { display: none; }
  .engine-pill { display: none; }
}

/* ---------- Login gate ---------- */
#login-gate { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; background: var(--bg); }
#login-gate::before { content: ""; position: absolute; inset: 0; background: radial-gradient(700px 420px at 50% 110%, rgba(70,110,255,.18), transparent 60%); }
.gate-card { position: relative; display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 40px; text-align: center; }
.gate-card img { width: 88px; height: 88px; border-radius: 18px; filter: drop-shadow(0 0 35px rgba(122,162,255,.4)); }
.gate-word { font-family: "Orbitron", sans-serif; font-weight: 800; font-size: 34px; letter-spacing: 5px; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.gate-tag { letter-spacing: 3px; font-size: 11px; color: var(--text-3); margin-bottom: 14px; }
.gate-note { max-width: 300px; font-size: 12px; color: var(--text-3); line-height: 1.55; margin-top: 12px; }

/* typing indicator */
.chat-bubble.typing { padding: 12px 16px; }
.dots { display: inline-flex; gap: 5px; align-items: center; height: 14px; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); opacity: .35; animation: dotbounce 1.1s infinite ease-in-out; }
.dots i:nth-child(2) { animation-delay: .15s; }
.dots i:nth-child(3) { animation-delay: .3s; }
@keyframes dotbounce { 0%, 80%, 100% { transform: translateY(0); opacity: .35; } 40% { transform: translateY(-5px); opacity: 1; } }
/* subtle glow */
.hero-right img { animation: logoglow 4.5s ease-in-out infinite; }
@keyframes logoglow { 0%, 100% { filter: drop-shadow(0 0 10px rgba(122,162,255,.18)); } 50% { filter: drop-shadow(0 0 22px rgba(122,162,255,.38)); } }
.brand img { animation: logoglow 4.5s ease-in-out infinite; }
.nav-item.active { box-shadow: inset 0 0 0 1px var(--border), 0 0 14px rgba(122,162,255,.14); }
.card { transition: background .2s, transform .2s, box-shadow .25s, border-color .25s; }
.card:hover { box-shadow: 0 0 18px rgba(122,162,255,.18); border-color: rgba(122,162,255,.35); }
.hero-ask, .composer-row { transition: box-shadow .25s, border-color .25s; }
.hero-ask:focus-within, .composer-row:focus-within { box-shadow: 0 0 16px rgba(122,162,255,.22); border-color: rgba(122,162,255,.4); }
.chat-bubble { animation: bubbleIn .25s ease-out; }
.user-bubble { animation: bubbleIn .2s ease-out; }
@keyframes bubbleIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.premium-card { animation: premglow 5s ease-in-out infinite; }
@keyframes premglow { 0%, 100% { box-shadow: 0 0 0 rgba(255,200,90,0); } 50% { box-shadow: 0 0 16px rgba(255,200,90,.16); } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; } }

.join-btn { align-self: flex-start; margin: 10px 0 2px; padding: 9px 16px; border-radius: 10px; font-size: 13px; font-weight: 600; color: #fff; background: linear-gradient(135deg, #7aa2ff, #a78bfa); box-shadow: 0 0 14px rgba(122,162,255,.25); }
.join-btn:disabled { opacity: .6; }
.join-msg { display: block; font-size: 12px; color: var(--text-2); margin-top: 6px; }

.att-tray { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 6px 8px; }
.att-tray:empty { display: none; }
.att-chip { display: flex; align-items: center; gap: 8px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; padding: 4px 8px 4px 4px; max-width: 220px; }
.att-chip img { width: 30px; height: 30px; border-radius: 6px; object-fit: cover; }
.att-doc { width: 30px; height: 30px; border-radius: 6px; display: grid; place-items: center; font-size: 9px; font-weight: 700; background: rgba(122,162,255,.18); color: var(--accent); }
.att-name { font-size: 12px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-chip button { color: var(--text-3); font-size: 13px; padding: 0 2px; }
.att-msg { font-size: 12px; color: #ffb46b; align-self: center; }
