*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
:root {
  --bg: #ffffff;
  --bg-2: #f8f9fb;
  --panel: #ffffff;
  --panel-2: #f4f6f9;
  --border: #e1e8ef;
  --text: #1a1d2e;
  --muted: #6b7785;
  --accent: #5b68f4;
  --accent-2: #00c2ff;
  --good: #10b981;
  --warn: #f59e0b;
  --danger: #ef4444;
  --radius: 16px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Inter", Helvetica, Arial, sans-serif;
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: linear-gradient(180deg, #fafbfc 0%, #f4f6f9 100%);
  -webkit-font-smoothing: antialiased;
}
code { background: rgba(255,255,255,0.06); padding: 1px 6px; border-radius: 6px; font-size: 0.9em; }
h1, h2, h3 { margin: 0; }

/* ---------- Buttons ---------- */
.btn {
  font: inherit; font-weight: 600; cursor: pointer; border: 1px solid transparent;
  border-radius: 12px; padding: 11px 20px; color: var(--text);
  transition: transform .06s ease, background .2s ease, border-color .2s ease, opacity .2s, box-shadow .2s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: white; box-shadow: 0 2px 8px rgba(91, 104, 244, 0.3); }
.btn-primary:hover:not(:disabled) { background: #4a59e8; box-shadow: 0 4px 12px rgba(91, 104, 244, 0.4); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--muted); }
.btn-ghost:hover { color: var(--text); background: var(--bg-2); border-color: var(--accent); }
.btn-block { width: 100%; display: block; }
.btn-sm { padding: 6px 10px; font-size: .85rem; }
.error { color: var(--danger); font-size: .9rem; margin: 8px 0 0; }
.badge { font-size: .68rem; text-transform: uppercase; letter-spacing: .04em; padding: 2px 8px; border-radius: 999px; background: rgba(109,94,252,.2); color: #c4bbff; border: 1px solid rgba(109,94,252,.4); }
.pill { font-size: .72rem; color: var(--good); border: 1px solid rgba(52,211,153,.4); background: rgba(52,211,153,.12); padding: 3px 10px; border-radius: 999px; }

/* Filled plan badge in nav — solid backgrounds, higher contrast */
#user-plan,
#account-plan {
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 999px;
  border: 0;
  color: #fff;
  line-height: 1;
  display: inline-flex;
  align-items: center;
}
#user-plan[data-plan="free"],
#account-plan[data-plan="free"]        { background: #6b7280; }               /* slate */
#user-plan[data-plan="pro"],
#user-plan[data-plan="pro-managed"],
#account-plan[data-plan="pro"],
#account-plan[data-plan="pro-managed"] { background: linear-gradient(135deg, #6d5efc, #8b7cff); box-shadow: 0 1px 2px rgba(109,94,252,.35); }
#user-plan[data-plan="pro-byok"],
#account-plan[data-plan="pro-byok"]    { background: linear-gradient(135deg, #0891b2, #06b6d4); box-shadow: 0 1px 2px rgba(6,182,212,.35); }
#user-plan[data-plan="admin"],
#account-plan[data-plan="admin"]       { background: linear-gradient(135deg, #b45309, #f59e0b); box-shadow: 0 1px 2px rgba(245,158,11,.35); }

/* ---------- Brand ---------- */
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark { font-size: 30px; filter: drop-shadow(0 0 12px rgba(109,94,252,.6)); }
.brand h1 { font-size: 22px; letter-spacing: -.02em; }
.brand .dot { color: var(--accent-2); }
.brand.small .brand-mark { font-size: 22px; }
.brand.small h1 { font-size: 17px; }
.tagline { margin: 4px 0 0; color: var(--muted); font-size: .9rem; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.login-card {
  align-self: center; justify-self: center; width: min(400px, 90vw);
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 34px; box-shadow: var(--shadow);
}
.login-card form { margin-top: 26px; display: grid; gap: 14px; }
.login-card label { display: grid; gap: 6px; font-size: .85rem; color: var(--muted); }
.login-card input, .composer textarea, select {
  font: inherit; color: var(--text); background: var(--bg-2);
  border: 1px solid var(--border); border-radius: 10px; padding: 11px 12px; outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.login-card input:focus, .composer textarea:focus, select:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px rgba(109,94,252,.25);
}
.hint { margin-top: 18px; color: var(--muted); font-size: .82rem; text-align: center; }
.login-aside {
  background: linear-gradient(160deg, rgba(109,94,252,.16), rgba(34,211,238,.08));
  border-left: 1px solid var(--border); display: flex; align-items: center; padding: 40px;
}
.aside-inner { max-width: 420px; }
.aside-inner h2 { font-size: 30px; letter-spacing: -.02em; line-height: 1.15; }
.aside-inner p { color: var(--muted); line-height: 1.6; margin-top: 14px; }
.aside-list { list-style: none; padding: 0; margin: 22px 0 0; display: grid; gap: 10px; }
.aside-list li { padding: 10px 14px; background: rgba(255,255,255,.04); border: 1px solid var(--border); border-radius: 10px; font-size: .92rem; }
@media (max-width: 820px) { .login-wrap { grid-template-columns: 1fr; } .login-aside { display: none; } }

/* ---------- App layout ---------- */
#app-view { display: grid; grid-template-columns: 280px 1fr; min-height: 100vh; }
.sidebar { background: var(--bg-2); border-right: 1px solid var(--border); padding: 22px; display: flex; flex-direction: column; gap: 20px; }
.history { flex: 1; overflow: auto; }
.history h3 { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 10px; }
#history-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
#history-list li { padding: 9px 11px; border: 1px solid var(--border); border-radius: 9px; font-size: .84rem; color: var(--muted); cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; transition: background .15s, color .15s; }
#history-list li:hover { background: var(--panel); color: var(--text); }
.user-box { border-top: 1px solid var(--border); padding-top: 16px; display: grid; gap: 8px; }
.user-meta { display: flex; align-items: center; gap: 8px; }
.user-name { font-weight: 600; }
.credits { color: var(--muted); font-size: .85rem; }
.credits strong { color: var(--good); }

.main { padding: 34px clamp(20px, 4vw, 56px); overflow: auto; }
.composer { max-width: 820px; }
.composer h2 { font-size: 26px; letter-spacing: -.02em; }
.composer textarea { width: 100%; margin-top: 16px; resize: vertical; line-height: 1.5; }
.composer-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-top: 14px; flex-wrap: wrap; }
.provider { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.provider label { font-size: .8rem; color: var(--muted); }
.note { color: var(--muted); font-size: .82rem; margin-top: 14px; }

/* ---------- BYOK ---------- */
.byok { margin-top: 16px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 4px 14px; }
.byok > summary { cursor: pointer; padding: 10px 2px; font-weight: 600; font-size: .92rem; list-style: none; }
.byok > summary::-webkit-details-marker { display: none; }
.byok-body { padding: 6px 0 14px; }
.byok-grid { display: grid; grid-template-columns: 1.4fr 1.4fr 1fr; gap: 12px; }
.byok-grid label { display: grid; gap: 6px; font-size: .78rem; color: var(--muted); }
.byok-grid input { font: inherit; color: var(--text); background: var(--bg-2); border: 1px solid var(--border); border-radius: 9px; padding: 9px 11px; outline: none; }
.byok-grid input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(109,94,252,.22); }
.byok-actions { display: flex; align-items: center; gap: 12px; margin-top: 12px; flex-wrap: wrap; }
.byok-hint { color: var(--muted); font-size: .76rem; }
.byok-presets { margin-top: 10px; color: var(--muted); font-size: .78rem; display: flex; align-items: center; gap: 8px; }
.link { background: none; border: none; color: var(--accent-2); cursor: pointer; font: inherit; padding: 0; text-decoration: underline; }
@media (max-width: 720px) { .byok-grid { grid-template-columns: 1fr; } }

/* ---------- Pipeline ---------- */
.pipeline { max-width: 980px; }
.pipeline-head { display: flex; align-items: center; gap: 12px; }
.pipeline-head h2 { font-size: 22px; }
.log { margin: 16px 0; font-size: .85rem; color: var(--muted); display: grid; gap: 4px; }
.log div::before { content: "› "; color: var(--accent-2); }
.agent-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.agent-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; transition: border-color .3s, transform .2s, box-shadow .3s; position: relative; overflow: hidden;
}
.agent-card.active { border-color: var(--accent); box-shadow: 0 0 0 1px rgba(109,94,252,.5), 0 10px 30px rgba(109,94,252,.15); }
.agent-card.done { border-color: rgba(52,211,153,.4); }
.agent-card .agent-top { display: flex; align-items: center; gap: 10px; }
.agent-emoji { font-size: 22px; }
.agent-name { font-weight: 600; }
.agent-blurb { color: var(--muted); font-size: .78rem; }
.agent-status { margin-left: auto; font-size: .72rem; padding: 3px 9px; border-radius: 999px; }
.status-waiting { background: rgba(255,255,255,.05); color: var(--muted); }
.status-working { background: rgba(109,94,252,.18); color: #c4bbff; }
.status-done { background: rgba(52,211,153,.15); color: var(--good); }
.agent-output { margin-top: 12px; max-height: 0; overflow: hidden; transition: max-height .4s ease; font-size: .82rem; }
.agent-card.expanded .agent-output { max-height: 460px; overflow: auto; }
.agent-output-inner { border-top: 1px solid var(--border); padding-top: 10px; margin-top: 4px; }
.spinner { width: 14px; height: 14px; border: 2px solid rgba(255,255,255,.2); border-top-color: var(--accent-2); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Result ---------- */
.result { margin-top: 26px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); padding: 8px 8px 0; }
.tab { background: transparent; border: none; color: var(--muted); padding: 10px 16px; cursor: pointer; font: inherit; border-radius: 8px 8px 0 0; }
.tab.active { color: var(--text); background: var(--panel-2); }
.tab-panel { padding: 22px; overflow: auto; }
.tab-panel pre { background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px; padding: 16px; overflow: auto; }

/* ---------- Markdown ---------- */
.md h1, .md h2 { letter-spacing: -.01em; margin: 18px 0 8px; }
.md h1 { font-size: 22px; } .md h2 { font-size: 18px; } .md h3 { font-size: 15px; margin: 14px 0 6px; }
.md p { line-height: 1.6; color: var(--text); margin: 8px 0; }
.md ul { margin: 8px 0; padding-left: 20px; color: var(--text); line-height: 1.6; }
.md code { font-size: .85em; }
.md pre { background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px; padding: 14px; overflow: auto; }
.md table { border-collapse: collapse; margin: 10px 0; width: 100%; font-size: .85rem; }
.md th, .md td { border: 1px solid var(--border); padding: 7px 10px; text-align: left; }
.md th { background: var(--panel-2); }
.md strong { color: var(--text); font-weight: 700; }

/* ---------- Top nav ---------- */
.topnav {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px clamp(16px, 4vw, 40px);
  background: rgba(255, 255, 255, 0.95); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topnav .brand { text-decoration: none; color: var(--text); display: flex; align-items: center; gap: 8px; }
.topnav .brand h1 { font-size: 20px; font-weight: 700; }
.brand-mark { 
  background: var(--accent); 
  color: white; 
  width: 32px; 
  height: 32px; 
  border-radius: 8px; 
  display: flex; 
  align-items: center; 
  justify-content: center; 
  font-weight: 700; 
  font-size: 16px; 
}
.dot { color: var(--accent); }
.nav-right, .nav-group { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.nav-group .credits { 
  color: var(--muted); 
  font-size: .82rem; 
  border: none;
  background: transparent;
  padding: 8px 12px;
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.2s, color 0.2s;
}
.nav-group .credits:hover {
  background: var(--bg-2);
  color: var(--text);
}
.nav-group .credits strong { color: var(--good); }
.nav-group .user-name { font-weight: 600; font-size: .9rem; }

/* ---------- Page / hero ---------- */
.page { max-width: 1100px; margin: 0 auto; padding: clamp(24px, 5vw, 80px) clamp(16px, 4vw, 40px) 80px; }
.hero { text-align: center; padding: 60px 0 40px; }

/* Agent avatars row */
.agent-avatars {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 32px;
}
.avatar-item {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ff9a56 0%, #ff6b6b 25%, #f64892 50%, #5b68f4 75%, #00c2ff 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  transition: transform 0.2s;
}
.avatar-item:hover {
  transform: translateY(-4px);
}
.avatar-item:nth-child(1) { background: #ff9a56; }
.avatar-item:nth-child(2) { background: #ffd966; }
.avatar-item:nth-child(3) { background: #b8956f; }
.avatar-item:nth-child(4) { background: #ff85bd; }
.avatar-item:nth-child(5) { background: #6db5f4; }
.avatar-item:nth-child(6) { background: #5ac8fa; }
.avatar-item:nth-child(7) { background: #8bc34a; }
.avatar-item:nth-child(8) { background: #ab8df6; }
.avatar-item:nth-child(9) { background: #4285f4; }

.hero-title-new {
  font-size: clamp(36px, 6vw, 64px);
  line-height: 1.1;
  letter-spacing: -.02em;
  margin: 0 0 20px;
  font-weight: 700;
  color: var(--text);
}

.hero-sub-new {
  color: var(--muted);
  max-width: 680px;
  margin: 0 auto 40px;
  font-size: clamp(16px, 2vw, 20px);
  line-height: 1.5;
}

.hero-eyebrow { display: inline-block; font-size: .78rem; color: #c4bbff; background: rgba(109,94,252,.15); border: 1px solid rgba(109,94,252,.35); padding: 5px 12px; border-radius: 999px; }
.hero-title { font-size: clamp(30px, 5vw, 52px); line-height: 1.08; letter-spacing: -.02em; margin: 18px 0 0; }
.grad { background: linear-gradient(120deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero-sub { color: var(--muted); max-width: 620px; margin: 16px auto 0; line-height: 1.6; }

/* ---------- Card / composer ---------- */
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.composer { padding: 24px; margin-top: 26px; max-width: none; background: white; }
.composer h2 { font-size: 20px; }
.pipeline { max-width: none; margin-top: 26px; }
.pipeline-head { display: flex; align-items: center; gap: 12px; }
.pipeline-head h2 { margin-right: auto; }

/* ---------- Result download button ---------- */
.tabs { align-items: center; }
.tab-action { margin-left: auto; margin-right: 8px; }

/* ---------- Drawer (My builds) ---------- */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 45; }
.drawer {
  position: fixed; top: 0; right: 0; height: 100vh; width: min(380px, 90vw); z-index: 46;
  background: var(--bg-2); border-left: 1px solid var(--border); padding: 20px; overflow: auto;
  box-shadow: -20px 0 60px rgba(0,0,0,.4);
}
.drawer-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.drawer-head h3 { font-size: 16px; }
#history-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
#history-list li { padding: 10px 12px; border: 1px solid var(--border); border-radius: 9px; font-size: .85rem; color: var(--muted); cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#history-list li:hover { background: var(--panel); color: var(--text); }
#history-list li.muted { cursor: default; }

/* ---------- Auth modal ---------- */
.modal { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal .overlay { z-index: 0; }
.modal-card {
  position: relative; z-index: 1; width: min(400px, 92vw);
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 30px; box-shadow: var(--shadow);
}
.modal-close { position: absolute; top: 14px; right: 14px; background: none; border: none; color: var(--muted); font-size: 18px; cursor: pointer; z-index: 10; }
.modal-close:hover { color: var(--text); }
.modal-card form { margin-top: 22px; display: grid; gap: 14px; }
.modal-card label { display: grid; gap: 6px; font-size: .85rem; color: var(--muted); }
.modal-card input { font: inherit; color: var(--text); background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px; padding: 11px 12px; outline: none; transition: border-color .2s, box-shadow .2s; }
.modal-card input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(109,94,252,.25); }
.hint { margin-top: 16px; color: var(--muted); font-size: .82rem; text-align: center; }

/* New split-screen auth modal */
.modal-fullscreen { padding: 0; }
.auth-split-card {
  position: relative;
  z-index: 1;
  width: min(1200px, 95vw);
  height: min(700px, 90vh);
  background: white;
  border-radius: 24px;
  overflow: hidden;
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}

.auth-left {
  padding: 40px 50px;
  display: flex;
  flex-direction: column;
  justify-content: safe center;
  overflow-y: auto;
  background: white;
}

.auth-form-container {
  max-width: 400px;
  width: 100%;
  margin: auto 0;
}

.auth-heading {
  font-size: 32px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 8px;
}

.auth-subheading {
  font-size: 16px;
  color: var(--muted);
  margin: 0 0 20px;
}

.oauth-buttons-new {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.btn-oauth {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 14px 20px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.2s;
  cursor: pointer;
}

.btn-oauth:hover {
  background: var(--bg-2);
  border-color: var(--accent);
}

.auth-divider-new {
  display: flex;
  align-items: center;
  margin: 18px 0;
  color: var(--muted);
  font-size: 14px;
}

.auth-divider-new::before,
.auth-divider-new::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.auth-divider-new span {
  padding: 0 16px;
}

.auth-form-new {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.auth-input {
  width: 100%;
  padding: 14px 16px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 15px;
  color: var(--text);
  outline: none;
  transition: all 0.2s;
}

.auth-input:focus {
  border-color: var(--accent);
  background: white;
  box-shadow: 0 0 0 3px rgba(91, 104, 244, 0.1);
}

.auth-input::placeholder {
  color: var(--muted);
}

/* ---------- Password Strength Indicator ---------- */
.password-strength {
  margin-top: 8px;
}
.password-strength-bar {
  height: 4px;
  background: #e0e0e0;
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 6px;
}
.password-strength-fill {
  height: 100%;
  width: 0%;
  border-radius: 2px;
  transition: width 0.3s ease, background 0.3s ease;
}
.password-strength-text {
  font-size: 0.75rem;
  font-weight: 500;
}
.password-strength-fill.weak { background: #ef4444; width: 33%; }
.password-strength-fill.fair { background: #f59e0b; width: 66%; }
.password-strength-fill.strong { background: #10b981; width: 100%; }
.password-strength-text.weak { color: #ef4444; }
.password-strength-text.fair { color: #f59e0b; }
.password-strength-text.strong { color: #10b981; }

/* ---------- Admin Dashboard Tabs ---------- */
.admin-tab {
  background: transparent;
  border: none;
  padding: 12px 18px;
  cursor: pointer;
  color: var(--muted);
  font-weight: 500;
  font-size: 14px;
  border-bottom: 3px solid transparent;
  transition: color 0.2s, border-color 0.2s;
  white-space: nowrap;
}
.admin-tab:hover {
  color: var(--text);
}
.admin-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.admin-tab-content {
  padding: 8px 0;
}

.auth-terms {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
  margin: -8px 0 0;
}

.link-inline {
  color: var(--accent);
  text-decoration: none;
}

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

.auth-continue {
  padding: 14px 20px;
  background: var(--accent);
  border: none;
  border-radius: 12px;
  color: white;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 8px;
  box-shadow: 0 2px 8px rgba(91, 104, 244, 0.3);
  transition: background .2s ease, box-shadow .2s ease, transform .06s ease;
}

.auth-continue:hover {
  background: #4a59e8;
  box-shadow: 0 4px 12px rgba(91, 104, 244, 0.4);
}

.auth-continue:active {
  transform: translateY(1px);
}

.auth-continue:disabled {
  opacity: .5;
  cursor: not-allowed;
  background: #d1d5db;
  color: #6b7785;
  box-shadow: none;
}

.auth-right {
  background: linear-gradient(135deg, #5b68f4 0%, #4a59e8 100%);
  padding: 60px 50px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  color: white;
  position: relative;
  overflow: hidden;
}

.auth-panel-content {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 48px;
}

.brand-mark-white {
  width: 36px;
  height: 36px;
  background: white;
  color: var(--accent);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
}

.brand-text-white {
  font-size: 20px;
  font-weight: 700;
  color: white;
}

.auth-panel-title {
  font-size: 42px;
  font-weight: 700;
  line-height: 1.2;
  margin: 0 0 32px;
  color: white;
}

.auth-benefits {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.auth-benefits li {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 16px;
  color: white;
}

.check-icon {
  flex-shrink: 0;
}

.auth-avatar-group {
  display: flex;
  gap: 12px;
  margin-top: 40px;
}

.auth-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  border: 3px solid rgba(255, 255, 255, 0.2);
}

@media (max-width: 900px) {
  .auth-split-card {
    grid-template-columns: 1fr;
    width: min(500px, 95vw);
    height: auto;
    max-height: 90vh;
    overflow-y: auto;
  }
  
  .auth-right {
    display: none;
  }
  
  .auth-left {
    padding: 40px 30px;
  }
}

/* ---------- OAuth (social login) ---------- */
.oauth-buttons { display: grid; gap: 8px; margin-top: 20px; }
.oauth-btn { text-decoration: none; text-align: center; }
.oauth-divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .78rem; margin: 14px 0 4px; }
.oauth-divider::before, .oauth-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.oauth-btn.oauth-off { opacity: .55; }
.cb-block { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; margin: 12px 0; }
.cb-block > strong { font-size: .9rem; }
.cb-block code { display: inline-block; margin: 4px 0 8px; font-size: .72rem; word-break: break-all; color: var(--accent-2); }

/* ---------- Hero prompt box ---------- */
.btn-lg { padding: 13px 22px; font-size: 1rem; }

/* Old prompt box (kept for compatibility) */
.prompt-box { max-width: 680px; margin: 30px auto 0; padding: 14px; text-align: left; }
.prompt-box textarea {
  width: 100%; border: none; background: transparent; color: var(--text);
  font: inherit; font-size: 1.05rem; line-height: 1.5; resize: none; outline: none; padding: 8px;
}
.prompt-box textarea::placeholder { color: var(--muted); }

/* New modern prompt box */
.prompt-box-new {
  max-width: 800px;
  margin: 0 auto;
  padding: 0;
  background: white;
  border: 2px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.prompt-box-new:focus-within {
  border-color: var(--accent);
  box-shadow: 0 8px 32px rgba(91, 104, 244, 0.15);
}
.prompt-box-new textarea {
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 16px;
  line-height: 1.5;
  resize: none;
  outline: none;
  padding: 20px 24px;
  min-height: 60px;
  max-height: 200px;
}
.prompt-box-new textarea::placeholder {
  color: var(--muted);
}

.prompt-actions-new {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

.btn-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-icon:hover {
  background: var(--bg-2);
  border-color: var(--accent);
  color: var(--accent);
}

.btn-start {
  padding: 12px 32px;
  font-size: 16px;
  font-weight: 600;
  border-radius: 12px;
}

.reassure-new {
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  margin: 20px auto 16px;
}

.link-advanced {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  padding: 8px 12px;
  border-radius: 8px;
  transition: all 0.2s;
  display: block;
  margin: 0 auto;
}
.link-advanced:hover {
  color: var(--accent);
  background: var(--bg-2);
}

.prompt-actions { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }
.link-quiet { background: none; border: none; color: var(--muted); cursor: pointer; font: inherit; font-size: .85rem; padding: 6px 8px; border-radius: 8px; }
.link-quiet:hover { color: var(--text); background: rgba(255,255,255,.05); }

/* ---------- Image Upload / Attachments ---------- */
.btn-attach {
  background: transparent; border: 1px solid var(--border); color: var(--muted);
  padding: 8px 14px; border-radius: 8px; cursor: pointer; font: inherit; font-size: .9rem;
  transition: all 0.2s;
}
.btn-attach:hover { border-color: var(--accent); color: var(--text); }

.btn-text {
  background: none; border: none; color: var(--accent-2); cursor: pointer;
  font: inherit; font-size: .85rem; padding: 0; text-decoration: underline;
}
.btn-text:hover { color: var(--text); }

.btn-clear-attach {
  background: none; border: none; color: var(--accent-2); cursor: pointer;
  font: inherit; font-size: .85rem; padding: 4px 8px; text-decoration: none;
  transition: all 0.2s;
}
.btn-clear-attach:hover { 
  color: var(--text); 
  background: rgba(91, 104, 244, 0.08);
  border-radius: 6px;
}

.attachments-area {
  margin-top: 14px; padding: 14px; background: var(--bg-2);
  border: 1px solid var(--border); border-radius: 10px;
}

.attachments-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px; font-size: 14px; font-weight: 600;
}

.attachment-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}

.attachment-thumb {
  position: relative; background: var(--panel); border: 1px solid var(--border);
  border-radius: 8px; overflow: hidden; transition: all 0.2s;
}
.attachment-thumb:hover {
  transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.attachment-thumb img {
  width: 100%; height: 110px; object-fit: cover; display: block;
}

.attachment-info {
  padding: 8px; display: flex; flex-direction: column; gap: 2px;
}

.attachment-name {
  font-size: 12px; font-weight: 500; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}

.attachment-size {
  font-size: 11px; color: var(--muted);
}

.attachment-remove {
  position: absolute; top: 6px; right: 6px; width: 26px; height: 26px;
  border-radius: 50%; background: rgba(0,0,0,0.8); color: white;
  border: none; cursor: pointer; font-size: 18px; line-height: 1;
  transition: background 0.2s; display: grid; place-items: center;
}
.attachment-remove:hover { background: var(--danger); }

/* Drag & drop overlay */
.drop-overlay {
  position: fixed; inset: 0; background: rgba(91, 104, 244, 0.95);
  backdrop-filter: blur(8px); z-index: 9999; display: flex;
  align-items: center; justify-content: center; pointer-events: none;
  opacity: 0; transition: opacity 0.2s;
}
.drop-overlay:not(.hidden) { opacity: 1; pointer-events: all; }

.drop-content {
  text-align: center; color: white; border: 3px dashed rgba(255,255,255,0.6);
  border-radius: 20px; padding: 60px 80px; background: rgba(0,0,0,0.2);
}

.drop-icon {
  font-size: 80px; margin-bottom: 20px; animation: bounce 1s infinite;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.drop-content h3 { font-size: 28px; margin-bottom: 12px; }
.drop-content p { font-size: 16px; margin-bottom: 8px; opacity: 0.9; }
.drop-content small { font-size: 14px; opacity: 0.7; }

.examples { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: center; margin: 18px auto 0; max-width: 680px; }
.examples-label { color: var(--muted); font-size: .85rem; }
.chip { background: var(--bg-2); border: 1px solid var(--border); color: var(--text); border-radius: 999px; padding: 7px 14px; font: inherit; font-size: .85rem; cursor: pointer; transition: border-color .2s, transform .1s, background .2s; }
.chip:hover { border-color: var(--accent); background: white; transform: translateY(-1px); }
.reassure { text-align: center; color: var(--muted); font-size: .82rem; margin-top: 20px; }

/* ---------- Marketing sections ---------- */
.section { margin-top: 90px; text-align: center; }
.section-title { font-size: clamp(24px, 4vw, 34px); letter-spacing: -.02em; }
.section-sub { color: var(--muted); margin: 10px auto 0; max-width: 560px; }
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin-top: 34px; text-align: left; }
.step { padding: 24px; }
.step-num { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-weight: 700; color: #fff; background: linear-gradient(135deg, var(--accent), #8b5cf6); margin-bottom: 12px; }
.step h3 { font-size: 17px; }
.step p { color: var(--muted); margin-top: 6px; line-height: 1.55; }

.team-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 34px; text-align: left; }
.role { padding: 18px; }
.role-emoji { font-size: 24px; }
.role h3 { font-size: 15px; margin-top: 8px; }
.role p { color: var(--muted); font-size: .85rem; margin-top: 4px; line-height: 1.5; }

.features { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; margin-top: 34px; text-align: left; }
.feature { padding: 22px; }
.feature-ico { font-size: 24px; }
.feature h3 { font-size: 16px; margin-top: 8px; }
.feature p { color: var(--muted); margin-top: 6px; line-height: 1.55; }

.cta-band { margin-top: 90px; padding: 44px; text-align: center; background: linear-gradient(160deg, rgba(109,94,252,.18), rgba(34,211,238,.08)); }
.cta-band h2 { font-size: clamp(22px, 4vw, 32px); }
.cta-band p { color: var(--muted); margin: 10px 0 22px; }

.footer { margin-top: 60px; padding-top: 26px; border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; color: var(--muted); }
.footer .brand strong { color: var(--text); }
.footer-note { font-size: .85rem; }

/* ---------- Settings modal extras ---------- */
.modal-title { font-size: 20px; margin-bottom: 6px; }
.modal-subtitle { color: var(--muted); font-size: .84rem; line-height: 1.5; margin: 0 0 12px; }
.modal-desc { color: var(--muted); font-size: .86rem; line-height: 1.5; margin: 8px 0 14px; }
.field { display: grid; gap: 6px; font-size: .82rem; color: var(--muted); margin-bottom: 14px; }
.field select, .field input { font: inherit; color: var(--text); background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px; padding: 11px 12px; outline: none; }
.field select:focus, .field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(109,94,252,.22); }
.modal-actions { display: flex; align-items: center; justify-content: flex-end; gap: 12px; margin-top: 8px; }

/* Benefits section in BYOK modal */
.byok-benefits { 
  background: linear-gradient(135deg, rgba(91, 104, 244, 0.06), rgba(139, 92, 246, 0.03)); 
  border: 1px solid rgba(91, 104, 244, 0.15); 
  border-radius: 12px; 
  padding: 12px 14px; 
  margin: 10px 0 12px; 
  display: grid; 
  gap: 6px;
}
.benefit-item { 
  font-size: .8rem; 
  line-height: 1.4; 
  color: var(--text); 
  display: flex; 
  align-items: center; 
  gap: 6px; 
}
.benefit-item strong { color: var(--accent); }

/* Value explainer in Connect API modal */
.value-explainer { 
  background: linear-gradient(135deg, rgba(91, 104, 244, 0.04), rgba(139, 92, 246, 0.02));
  border: 1px solid rgba(91, 104, 244, 0.15); 
  border-radius: 12px; 
  padding: 14px 16px; 
  margin: 12px 0 14px; 
  font-size: .8rem;
  line-height: 1.5;
}
.value-explainer strong { 
  color: var(--text); 
  font-weight: 600; 
  display: block;
  margin-bottom: 8px;
  font-size: .84rem;
}
.value-explainer ul { 
  margin: 0; 
  padding-left: 0; 
  list-style: none; 
  display: grid; 
  gap: 6px; 
}
.value-explainer li { 
  display: flex; 
  align-items: flex-start; 
  gap: 8px;
  line-height: 1.4;
}
.value-explainer li strong {
  display: inline;
  margin: 0;
  font-size: inherit;
}
.total-value { 
  margin: 10px 0 0; 
  padding-top: 10px; 
  border-top: 1px solid rgba(91, 104, 244, 0.15); 
  font-weight: 600; 
  font-size: .84rem;
  color: var(--accent);
  text-align: center;
}

/* ---------- AI model modal (revised) ---------- */
.mode-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 12px 0 4px; }
.mode-cards-3 { grid-template-columns: repeat(3, 1fr); }
.mode-card { 
  position: relative;
  text-align: left; 
  background: var(--bg-2); 
  border: 1px solid var(--border); 
  border-radius: 14px; 
  padding: 14px 16px; 
  cursor: pointer; 
  font: inherit; 
  color: var(--text); 
  transition: all .2s; 
  display: flex; 
  flex-direction: column;
  box-shadow: 0 1px 4px rgba(0,0,0,0.02);
  min-height: 130px;
}
.mode-card:hover { 
  border-color: var(--accent); 
  box-shadow: 0 2px 8px rgba(91, 104, 244, 0.1);
  transform: translateY(-1px);
}
.mode-card.active { 
  border-color: var(--accent); 
  background: rgba(91, 104, 244, 0.08); 
  box-shadow: 0 0 0 1px rgba(91, 104, 244, 0.3), 0 4px 12px rgba(91, 104, 244, 0.15);
}
.mode-card-head { 
  font-weight: 700; 
  font-size: .92rem; 
  display: flex; 
  align-items: center; 
  gap: 6px; 
  flex-wrap: wrap; 
  margin-bottom: 6px; 
  line-height: 1.3;
}
.mode-card-sub { 
  color: var(--muted); 
  font-size: .78rem; 
  margin-top: 0; 
  line-height: 1.4; 
  flex: 1; 
}
.mode-plan { 
  margin-top: auto; 
  padding-top: 14px; 
  font-size: .75rem; 
  text-transform: uppercase; 
  letter-spacing: .06em; 
  color: var(--muted); 
  opacity: .75;
  font-weight: 600;
}
.mode-card.locked { opacity: .72; }
.mode-card.locked:hover { border-color: var(--accent); }
.tag-lock { font-size: .62rem; text-transform: uppercase; letter-spacing: .04em; color: #fbbf24; background: rgba(251,191,36,.14); border: 1px solid rgba(251,191,36,.42); padding: 1px 7px; border-radius: 999px; }
.tag-free { font-size: .62rem; text-transform: uppercase; letter-spacing: .04em; color: var(--good); background: rgba(52,211,153,.14); border: 1px solid rgba(52,211,153,.4); padding: 1px 7px; border-radius: 999px; }

@media (max-width: 560px) { .mode-cards-3 { grid-template-columns: 1fr; } }

.provider-chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0 14px; }
.pchip { background: var(--bg-2); border: 1px solid var(--border); color: var(--muted); border-radius: 999px; padding: 6px 14px; font: inherit; font-size: .82rem; cursor: pointer; }
.pchip:hover { color: var(--text); }
.pchip.active { background: rgba(109,94,252,.18); border-color: var(--accent); color: #c4bbff; }

.field-row { display: flex; align-items: center; justify-content: space-between; }
#byok-fields .field { display: grid; gap: 4px; font-size: .8rem; color: var(--muted); margin-bottom: 10px; }
#byok-fields input { font: inherit; color: var(--text); background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px; padding: 9px 12px; outline: none; }
#byok-fields input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(109,94,252,.22); }
.adv-details { margin: 2px 0 10px; }
.adv-details > summary { cursor: pointer; color: var(--muted); font-size: .8rem; list-style: none; }
.adv-details > summary::-webkit-details-marker { display: none; }
.adv-details input { width: 100%; margin-top: 8px; font: inherit; color: var(--text); background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; outline: none; }
.byok-hint { color: var(--muted); font-size: .74rem; margin: 2px 0 0; line-height: 1.3; }
#byok-fields .remember-row { display: flex; align-items: center; gap: 10px; margin: 10px 0 6px; font-size: .78rem; cursor: pointer; }
#byok-fields .remember-row input[type="checkbox"] { -webkit-appearance: checkbox; appearance: checkbox; accent-color: var(--accent); width: 16px; height: 16px; min-width: 16px; max-width: 16px; flex: 0 0 16px; margin: 0; padding: 0; border: 0; border-radius: 0; background: none; box-shadow: none; }
#byok-fields .remember-row > span { line-height: 1.3; }
#byok-fields .remember-row small { display: block; color: var(--muted); font-size: .7rem; margin-top: 1px; }
.byok-saved { color: var(--good); }
.byok-saved .link { color: var(--muted); }

/* ---------- Model select ---------- */
#model-select { width: 100%; font: inherit; color: var(--text); background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px; padding: 11px 12px; outline: none; }
#model-select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(109,94,252,.22); }

/* ---------- Pricing ---------- */
.pricing-card { width: min(880px, 96vw); }
.price-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin: 18px 0 4px; }
.price-col { position: relative; background: var(--bg-2); border: 1px solid var(--border); border-radius: 14px; padding: 20px; display: flex; flex-direction: column; min-height: 180px; }
.price-col.featured { border-color: var(--accent); box-shadow: 0 0 0 1px rgba(109,94,252,.4); }
.price-badge { position: absolute; top: -10px; right: 14px; background: linear-gradient(135deg, var(--accent), #8b5cf6); color: #fff; font-size: .68rem; padding: 3px 10px; border-radius: 999px; }
.price-name { font-weight: 600; font-size: .9rem; color: var(--muted); }
.price-amt { font-size: 30px; font-weight: 700; margin: 6px 0 12px; color: var(--text); }
.price-amt span { font-size: .5em; color: var(--muted); font-weight: 500; }
.price-sublabel { 
  font-size: .8rem; 
  color: var(--muted); 
  margin: -8px 0 12px; 
  font-weight: 500; 
}
.price-feats { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 8px; font-size: .84rem; color: var(--text); line-height: 1.4; flex: 1; }
.price-cta { margin-top: auto; }
@media (max-width: 760px) { .price-grid { grid-template-columns: 1fr; } }

/* ---------- Onboarding slideshow ---------- */
.onboard-card { width: min(520px, 94vw); padding: 40px 34px 26px; text-align: center; overflow: hidden; }
.onboard-slides { position: relative; min-height: 210px; }
.onboard-slide { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; opacity: 0; transform: translateX(24px); transition: opacity .3s ease, transform .3s ease; pointer-events: none; }
.onboard-slide.active { position: relative; opacity: 1; transform: none; pointer-events: auto; }
.onboard-icon { font-size: 46px; line-height: 1; filter: drop-shadow(0 4px 16px rgba(109,94,252,.4)); }
.onboard-title { font-size: 1.35rem; font-weight: 700; margin: 4px 0 0; }
.onboard-text { color: var(--muted); font-size: .95rem; line-height: 1.6; max-width: 400px; margin: 0 auto; }
.onboard-text strong { color: var(--text); }
.onboard-nav { display: flex; align-items: center; justify-content: space-between; margin-top: 22px; gap: 14px; }
.onboard-dots { display: flex; gap: 7px; }
.onboard-dot { width: 8px; height: 8px; border-radius: 999px; background: var(--border); border: none; padding: 0; cursor: pointer; transition: background .2s, width .2s; }
.onboard-dot.active { background: var(--accent); width: 20px; }
.onboard-actions { display: flex; gap: 8px; }

@media (max-width: 780px) {
  .steps, .team-grid, .features { grid-template-columns: 1fr; }
}

/* ---------- Workspace (result) ---------- */
.result { margin-top: 22px; }
.workspace { display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr); gap: 16px; align-items: start; }
.ws-left { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.ws-right { position: sticky; top: 76px; background: #0f1117; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.viewer-bar { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border-bottom: 1px solid var(--border); background: var(--panel); }
.viewer-title { display: flex; align-items: center; gap: 8px; font-size: .88rem; font-weight: 600; }
.viewer-dot { color: var(--good); }
.viewer-tools { display: flex; align-items: center; gap: 8px; }
.icon-btn { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--border); background: transparent; color: var(--muted); cursor: pointer; text-decoration: none; font-size: 15px; }
.icon-btn:hover { color: var(--text); border-color: var(--accent); }
.gen-badge { font-size: .68rem; padding: 2px 8px; border-radius: 999px; text-transform: uppercase; letter-spacing: .03em; }
.gen-badge.real { color: var(--good); background: rgba(52,211,153,.14); border: 1px solid rgba(52,211,153,.4); }
.gen-badge.template { color: var(--warn); background: rgba(251,191,36,.12); border: 1px solid rgba(251,191,36,.35); }
.preview-frame { width: 100%; height: 620px; border: 0; background: #0f1117; display: block; }

.files-layout { display: grid; grid-template-columns: 170px 1fr; min-height: 420px; }
.file-list { list-style: none; margin: 0; padding: 10px; border-right: 1px solid var(--border); display: grid; gap: 4px; align-content: start; }
.file-item { padding: 8px 10px; border-radius: 8px; font-size: .8rem; color: var(--muted); cursor: pointer; font-family: ui-monospace, Menlo, Consolas, monospace; }
.file-item:hover { background: var(--bg-2); color: var(--text); }
.file-item.active { background: rgba(109,94,252,.18); color: #c4bbff; }
.file-content { margin: 0; padding: 16px; overflow: auto; max-height: 560px; background: var(--bg-2); font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .78rem; line-height: 1.5; white-space: pre; }

.db-label { padding: 14px 16px 0; color: var(--muted); font-size: .85rem; }
.db-view { padding: 16px; overflow: auto; max-height: 560px; }
.db-table { border-collapse: collapse; width: 100%; font-size: .82rem; }
.db-table th, .db-table td { border: 1px solid var(--border); padding: 7px 10px; text-align: left; white-space: nowrap; }
.db-table th { background: var(--panel-2); position: sticky; top: 0; }
.db-table tr:nth-child(even) td { background: rgba(255,255,255,.02); }
.muted { color: var(--muted); }

@media (max-width: 900px) {
  .workspace { grid-template-columns: 1fr; }
  .ws-right { position: static; }
}

/* ---------- Full-screen builder ---------- */
#builder-view { position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column; background: var(--bg); }
.builder-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 18px; border-bottom: 1px solid var(--border); background: var(--bg-2); flex-wrap: wrap; }
.builder-top-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.builder-brand { font-weight: 700; font-size: .95rem; white-space: nowrap; }
.builder-brand .dot { color: var(--accent-2); }
.builder-appname { color: var(--muted); font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 40vw; }
.builder-top-right { display: flex; align-items: center; gap: 10px; }
.builder-top-right .credits { color: var(--muted); font-size: .82rem; }
.builder-top-right .credits strong { color: var(--good); }

.builder-body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.08fr); }
.builder-left { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--border); }
.builder-left > .tabs { padding: 8px 10px 0; border-bottom: 1px solid var(--border); }
.builder-left > .tab-panel { flex: 1; min-height: 0; overflow: auto; }
.builder-left > .tab-panel[hidden] { display: none !important; }

/* Chat */
.chat-panel { display: flex; flex-direction: column; padding: 0 !important; }
.chat-scroll { flex: 1; min-height: 0; overflow: auto; padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.chat-system { align-self: center; color: var(--muted); font-size: .78rem; background: var(--panel); border: 1px solid var(--border); padding: 5px 12px; border-radius: 999px; }
.chat-msg { display: flex; gap: 10px; max-width: 92%; }
.chat-msg .avatar { width: 30px; height: 30px; flex: none; display: grid; place-items: center; background: var(--panel-2); border: 1px solid var(--border); border-radius: 9px; font-size: 16px; }
.chat-msg .bubble { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; font-size: .88rem; overflow: hidden; }
.chat-msg.agent { align-self: flex-start; }
.chat-msg.user { align-self: flex-end; flex-direction: row; }
.chat-msg.user .bubble { background: linear-gradient(135deg, rgba(109,94,252,.9), rgba(139,92,246,.9)); border: none; color: #fff; }
.chat-msg .who { font-weight: 600; font-size: .82rem; margin-bottom: 4px; display: flex; align-items: center; gap: 8px; }
.chat-msg .who-sub { color: var(--muted); font-weight: 400; font-size: .74rem; }
.chat-msg .body :first-child { margin-top: 0; }
.chat-msg .body { max-height: 320px; overflow: auto; }

.chat-input { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--border); background: var(--bg-2); align-items: flex-end; }
.chat-input textarea { flex: 1; resize: none; font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; outline: none; min-height: 42px; max-height: 120px; }
.chat-input textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(109,94,252,.22); }
.chat-input .icon-btn { flex: none; width: 42px; height: 42px; }

.chat-attachments { padding: 10px 12px 0; border-top: 1px solid var(--border); background: var(--bg-2); }
.chat-attachment-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 72px)); gap: 8px; }
.chat-attachment-thumb { position: relative; width: 72px; height: 72px; border-radius: 8px; overflow: hidden; border: 1px solid var(--border); background: var(--panel); }
.chat-attachment-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.chat-attachment-remove { position: absolute; top: 2px; right: 2px; width: 20px; height: 20px; border-radius: 50%; background: rgba(0,0,0,.75); color: #fff; border: none; cursor: pointer; font-size: 14px; line-height: 1; display: grid; place-items: center; }
.chat-attachment-remove:hover { background: var(--danger); }

/* Intake questions form */
.intake-qs { margin: 6px 0 12px; padding-left: 20px; display: grid; gap: 6px; color: var(--text); font-size: .86rem; }
.intake-form textarea { width: 100%; resize: vertical; font: inherit; color: var(--text); background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; outline: none; }
.intake-form textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(109,94,252,.22); }
.intake-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }

/* Right preview pane */
.builder-right { display: flex; flex-direction: column; min-height: 0; background: #0f1117; }
.viewer-stage { flex: 1; min-height: 0; position: relative; }
.builder-right .preview-frame { width: 100%; height: 100%; border: 0; }
/* Sits on .builder-right's dark (#0f1117) background — needs light text, not var(--text). */
.fullstack-banner { display: flex; align-items: center; gap: 12px; padding: 10px 14px; background: linear-gradient(90deg, rgba(99,102,241,.28), rgba(20,184,166,.22)); border-top: 1px solid rgba(255,255,255,.1); font-size: 13px; color: #f2f4f8; }
.fullstack-banner .fs-icon { font-size: 18px; }
.fullstack-banner .fs-text { flex: 1; line-height: 1.4; }
.fullstack-banner .fs-text strong { color: #fff; }
.fullstack-banner code { background: rgba(0,0,0,.35); color: #f2f4f8; padding: 1px 6px; border-radius: 5px; font-size: 12px; }
.fullstack-banner .btn { white-space: nowrap; }
.preview-placeholder { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; color: var(--muted); text-align: center; padding: 20px; }
.spinner-lg { width: 34px; height: 34px; border: 3px solid rgba(255,255,255,.15); border-top-color: var(--accent-2); border-radius: 50%; animation: spin .8s linear infinite; }

/* Intake questions shown one-by-one in the app viewer (sits on the dark #0f1117 bg) */
.intake-panel { max-width: 440px; width: 100%; text-align: left; color: #f2f4f8; }
.intake-panel .intake-head { font-weight: 600; font-size: .95rem; margin-bottom: 2px; display: flex; align-items: center; gap: 8px; }
.intake-panel .intake-sub { color: #aab0c0; font-weight: 400; font-size: .78rem; margin-bottom: 16px; }
.intake-panel .intake-progress { color: #aab0c0; font-size: .78rem; margin-bottom: 6px; }
.intake-panel .intake-question-text { color: #f2f4f8; font-size: 1.05rem; font-weight: 600; margin-bottom: 12px; line-height: 1.4; }
.intake-panel textarea { width: 100%; resize: vertical; font: inherit; color: #f2f4f8; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.16); border-radius: 10px; padding: 10px 12px; outline: none; }
.intake-panel textarea::placeholder { color: #7a8194; }
.intake-panel textarea:focus { border-color: var(--accent-2); box-shadow: 0 0 0 3px rgba(0,194,255,.2); }
.intake-panel .intake-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.intake-panel .intake-actions .btn-ghost { color: #cfd3e0; border-color: rgba(255,255,255,.18); }

@media (max-width: 900px) {
  .builder-body { grid-template-columns: 1fr; grid-template-rows: 1fr 1fr; }
  .builder-left { border-right: none; border-bottom: 1px solid var(--border); }
  .builder-appname { max-width: 30vw; }
}

/* ========== DASHBOARD VIEW (authenticated) ========== */
.dashboard-view {
  display: grid;
  grid-template-columns: 260px 1fr;
  height: 100vh;
  overflow: hidden;
}

/* Dashboard Sidebar */
.dashboard-sidebar {
  background: #f3f4f6;
  border-right: 1px solid #e5e7eb;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #e5e7eb;
}

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

.sidebar-brand-text {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.sidebar-toggle {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  color: var(--muted);
  padding: 4px;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid #e5e7eb;
  cursor: pointer;
}

.sidebar-user:hover {
  background: #e9ebee;
}

.sidebar-user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 600;
  font-size: 16px;
}

.sidebar-user-info {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-user-name {
  font-weight: 500;
  color: var(--text);
  font-size: 14px;
}

.sidebar-user-dropdown {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 10px;
}

.sidebar-nav {
  padding: 8px 12px;
  border-bottom: 1px solid #e5e7eb;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
}

.sidebar-nav-item:hover {
  background: #e9ebee;
  color: var(--text);
}

.sidebar-nav-item.active {
  background: white;
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.sidebar-nav-icon {
  font-size: 18px;
}

.sidebar-recents {
  flex: 1;
  padding: 16px 12px;
  overflow-y: auto;
}

.sidebar-section-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0 0 12px 12px;
}

.sidebar-recents-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

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

/* Dashboard Main Content */
.dashboard-main {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  background: white;
}

.dashboard-header {
  padding: 16px 24px;
  border-bottom: 1px solid #e5e7eb;
  text-align: right;
}

.dashboard-credits {
  font-size: 13px;
  color: var(--muted);
}

.dashboard-credits a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.dashboard-credits a:hover {
  text-decoration: underline;
}

.dashboard-content {
  flex: 1;
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
  padding: 60px 40px;
}

.dashboard-avatars {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-bottom: 32px;
}

.dashboard-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  transition: transform 0.2s;
}

.dashboard-avatar:hover {
  transform: translateY(-4px);
}

.dashboard-title {
  text-align: center;
  font-size: 36px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 32px;
  line-height: 1.3;
}

.dashboard-prompt-card {
  background: white;
  border: 2px solid #e5e7eb;
  border-radius: 16px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.04);
  margin-bottom: 24px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.dashboard-prompt-card:focus-within {
  border-color: var(--accent);
  box-shadow: 0 8px 24px rgba(91, 104, 244, 0.15);
}

#dashboard-prompt {
  width: 100%;
  border: none;
  outline: none;
  resize: none;
  font-family: var(--font);
  font-size: 16px;
  color: var(--text);
  padding: 24px;
  min-height: 120px;
  background: transparent;
}

#dashboard-prompt::placeholder {
  color: var(--muted);
}

.dashboard-prompt-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-top: 1px solid #e5e7eb;
}

.dashboard-btn-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: transparent;
  border: 1px solid #e5e7eb;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.dashboard-btn-icon:hover {
  background: var(--bg-2);
  border-color: var(--accent);
  color: var(--accent);
}

.dashboard-btn-text {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: 10px;
  background: transparent;
  border: 1px solid #e5e7eb;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.dashboard-btn-text:hover {
  background: var(--bg-2);
  border-color: var(--accent);
  color: var(--accent);
}

.dashboard-btn-build {
  margin-left: auto;
  padding: 10px 28px;
}

@media (max-width: 768px) {
  .dashboard-view {
    grid-template-columns: 1fr;
  }
  .dashboard-sidebar {
    display: none;
  }
  .dashboard-content {
    padding: 32px 20px;
  }
  .dashboard-title {
    font-size: 28px;
  }
}
