/* ── Dark theme (default) ── */
[data-theme="dark"] {
  --bg: #08080c;
  --mesh-1: rgba(99, 102, 241, 0.22);
  --mesh-2: rgba(139, 92, 246, 0.15);
  --mesh-3: rgba(52, 211, 153, 0.08);
  --surface: rgba(18, 18, 24, 0.78);
  --surface-2: rgba(26, 26, 34, 0.95);
  --surface-3: #1f1f28;
  --border: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.16);
  --text: #f4f4f5;
  --muted: #a1a1aa;
  --dim: #71717a;
  --hero-bg: linear-gradient(135deg, rgba(99, 102, 241, 0.12), rgba(139, 92, 246, 0.06));
  --hero-border: rgba(99, 102, 241, 0.2);
  --prompt-bg: #0c0c10;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
  --overlay: rgba(8, 8, 12, 0.8);
}

/* ── Light theme ── */
[data-theme="light"] {
  --bg: #f8fafc;
  --mesh-1: rgba(99, 102, 241, 0.08);
  --mesh-2: rgba(139, 92, 246, 0.06);
  --mesh-3: rgba(52, 211, 153, 0.05);
  --surface: rgba(255, 255, 255, 0.9);
  --surface-2: #ffffff;
  --surface-3: #f1f5f9;
  --border: rgba(15, 23, 42, 0.08);
  --border-hover: rgba(15, 23, 42, 0.16);
  --text: #0f172a;
  --muted: #475569;
  --dim: #64748b;
  --hero-bg: linear-gradient(135deg, rgba(99, 102, 241, 0.08), rgba(139, 92, 246, 0.04));
  --hero-border: rgba(99, 102, 241, 0.15);
  --prompt-bg: #f1f5f9;
  --shadow: 0 20px 60px rgba(15, 23, 42, 0.1);
  --overlay: rgba(248, 250, 252, 0.85);
}

:root {
  --primary: #6366f1;
  --primary-2: #8b5cf6;
  --green: #10b981;
  --green-bg: rgba(16, 185, 129, 0.12);
  --amber: #f59e0b;
  --amber-bg: rgba(245, 158, 11, 0.12);
  --blue: #3b82f6;
  --radius: 16px;
  --radius-sm: 10px;
  --font: "Plus Jakarta Sans", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  transition: background 0.3s, color 0.3s;
}

.bg-mesh {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 80% 50% at 20% -10%, var(--mesh-1), transparent 55%),
    radial-gradient(ellipse 60% 40% at 90% 10%, var(--mesh-2), transparent 50%),
    radial-gradient(ellipse 50% 30% at 50% 100%, var(--mesh-3), transparent 50%);
}

.app {
  position: relative;
  z-index: 1;
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px 20px 80px;
}

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 14px 18px;
  background: var(--surface);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 4px);
  box-shadow: var(--shadow);
  margin-bottom: 24px;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-icon {
  width: 42px; height: 42px;
  display: grid; place-items: center;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: white;
}
.brand strong { display: block; font-size: 15px; font-weight: 700; }
.brand span { font-size: 12px; color: var(--muted); }

.topbar-actions { display: flex; align-items: flex-end; gap: 8px; flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field span { font-size: 10px; font-weight: 700; color: var(--dim); text-transform: uppercase; letter-spacing: 0.06em; }

.model-select {
  min-width: 220px;
  background: var(--surface-3);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font: 500 13px var(--font);
  cursor: pointer;
}

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 0; border-radius: var(--radius-sm);
  padding: 9px 14px; font: 600 13px var(--font);
  cursor: pointer; transition: all 0.15s; white-space: nowrap;
}
.btn-icon { padding: 9px 12px; font-size: 16px; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--text); border-color: var(--border-hover); background: var(--surface-3); }
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: white; box-shadow: 0 6px 20px rgba(99, 102, 241, 0.3);
}
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

/* Stats */
.filter-panel {
  margin-bottom: 20px; padding: 16px 18px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius);
}
.filter-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.filter-head h2 { margin: 0; font-size: 15px; font-weight: 700; }
.filter-head p { margin: 4px 0 0; font-size: 12px; color: var(--dim); }
.filter-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.field-grow { flex: 1; min-width: 200px; }
.input-num {
  width: 100%; min-width: 90px; padding: 10px 12px;
  background: var(--surface-3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text);
  font-family: var(--font); font-size: 13px;
}
.btn-sm { padding: 8px 14px; font-size: 12px; }

.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
.stat {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
}
.stat-icon {
  width: 40px; height: 40px; display: grid; place-items: center;
  border-radius: 10px; background: var(--surface-3); border: 1px solid var(--border);
}
.stat p { margin: 0 0 2px; font-size: 11px; color: var(--dim); }
.stat strong { font-size: 1.4rem; font-weight: 800; }
.stat .mono { font-family: var(--mono); font-size: 0.65rem; font-weight: 500; display: block; max-width: 120px; word-break: break-all; }

/* Hero */
.hero-panel {
  padding: 24px 28px; margin-bottom: 24px;
  background: var(--hero-bg); border: 1px solid var(--hero-border);
  border-radius: calc(var(--radius) + 4px); box-shadow: var(--shadow);
}
.hero-top { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.label { margin: 0 0 4px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--blue); }
.hero-panel h1 { margin: 0; font-size: 1.4rem; font-weight: 800; }
.hero-summary { margin: 0; color: var(--muted); line-height: 1.7; font-size: 14px; }

.chip {
  padding: 5px 11px; border-radius: 999px; font-size: 11px; font-weight: 600;
  background: rgba(99, 102, 241, 0.12); color: var(--primary);
  border: 1px solid rgba(99, 102, 241, 0.2);
}
.chip-muted { background: var(--surface-3); color: var(--dim); border-color: var(--border); }

/* Section */
.section { margin-bottom: 24px; }
.section-head { margin-bottom: 14px; }
.section-head h2 { margin: 0 0 4px; font-size: 1.1rem; font-weight: 800; }
.section-head p { margin: 0; color: var(--dim); font-size: 13px; }

/* Pick cards */
.picks-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }

.pick-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  cursor: pointer; transition: all 0.2s;
}
.pick-card:hover { border-color: var(--primary); transform: translateY(-3px); box-shadow: var(--shadow); }

.pick-header { padding: 16px 18px; }
.pick-meta { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.score-badge { padding: 4px 10px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.score-high { background: var(--green-bg); color: var(--green); }
.score-mid { background: var(--amber-bg); color: var(--amber); }
.score-low { background: var(--surface-3); color: var(--muted); }

.pick-card h3 { margin: 0; font-family: var(--mono); font-size: 0.88rem; }
.pick-desc { margin: 6px 0 0; font-size: 13px; color: var(--muted); line-height: 1.5; }

.mini-roadmap {
  display: flex; gap: 4px; margin-top: 12px; overflow-x: auto; padding-bottom: 4px;
}
.mini-step {
  flex: 1; min-width: 48px; text-align: center;
  padding: 6px 4px; border-radius: 8px;
  background: var(--surface-3); border: 1px solid var(--border);
  font-size: 10px; font-weight: 700; color: var(--dim);
}
.mini-step span { display: block; font-size: 9px; font-weight: 500; margin-top: 2px; color: var(--muted); }

.pick-footer {
  padding: 10px 18px; border-top: 1px solid var(--border);
  font-size: 12px; font-weight: 600; color: var(--primary);
  display: flex; justify-content: space-between; align-items: center;
}

/* Dual panels */
.dual-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.panel-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.panel-head h2 { margin: 0; font-size: 13px; font-weight: 700; }

.scroll-list { max-height: 400px; overflow-y: auto; padding: 8px; }

.clickable-item {
  display: block; padding: 12px 14px; border-radius: var(--radius-sm);
  border: 1px solid transparent; margin-bottom: 4px;
  text-decoration: none; color: inherit; cursor: pointer;
  transition: all 0.15s;
}
.clickable-item:hover { background: var(--surface-3); border-color: var(--border-hover); }
.clickable-item.active { background: rgba(99, 102, 241, 0.1); border-color: rgba(99, 102, 241, 0.3); }
.clickable-item strong { display: block; font-family: var(--mono); font-size: 12px; margin-bottom: 3px; }
.clickable-item .desc { display: block; font-size: 12px; color: var(--muted); line-height: 1.4; margin-bottom: 4px; }
.clickable-item .meta { font-size: 11px; color: var(--dim); }
.clickable-item .arrow { float: right; color: var(--primary); font-size: 14px; }

/* Mind Map */
.mind-map {
  display: flex; flex-direction: column; align-items: center;
  padding: 24px 16px; background: var(--surface-3);
  border-radius: var(--radius); border: 1px solid var(--border);
  overflow-x: auto;
}
.mind-center {
  padding: 14px 24px; border-radius: 999px;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: white; font-weight: 800; font-size: 14px;
  margin-bottom: 20px; text-align: center;
  box-shadow: 0 8px 24px rgba(99, 102, 241, 0.3);
}
.mind-branches { display: flex; flex-wrap: wrap; gap: 16px; justify-content: center; width: 100%; }
.mind-branch {
  flex: 1; min-width: 160px; max-width: 220px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px;
}
.mind-branch h4 {
  margin: 0 0 8px; font-size: 12px; font-weight: 700;
  color: var(--primary); text-align: center;
  padding-bottom: 8px; border-bottom: 1px solid var(--border);
}
.mind-branch ul { margin: 0; padding: 0; list-style: none; }
.mind-branch li {
  font-size: 12px; color: var(--muted); padding: 4px 0;
  padding-left: 12px; position: relative;
}
.mind-branch li::before {
  content: "•"; position: absolute; left: 0; color: var(--primary);
}

/* Roadmap */
.roadmap { display: flex; flex-direction: column; gap: 0; }
.road-step {
  display: flex; gap: 16px; position: relative;
  padding-bottom: 20px;
}
.road-step:not(:last-child)::before {
  content: ""; position: absolute; left: 17px; top: 36px; bottom: 0;
  width: 2px; background: var(--border);
}
.road-num {
  width: 36px; height: 36px; flex-shrink: 0;
  display: grid; place-items: center;
  border-radius: 50%; background: var(--primary); color: white;
  font-weight: 800; font-size: 14px;
}
.road-body {
  flex: 1; background: var(--surface-3);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 14px 16px;
}
.road-body h4 { margin: 0 0 4px; font-size: 14px; font-weight: 700; }
.road-phase { font-size: 10px; font-weight: 700; text-transform: uppercase; color: var(--primary); letter-spacing: 0.06em; }
.road-body p { margin: 6px 0 0; font-size: 13px; color: var(--muted); line-height: 1.5; }
.road-deliverables { margin: 8px 0 0; padding: 0; list-style: none; }
.road-deliverables li {
  font-size: 12px; color: var(--dim); padding: 2px 0;
  padding-left: 14px; position: relative;
}
.road-deliverables li::before { content: "✓"; position: absolute; left: 0; color: var(--green); }
.road-days { margin-top: 8px; font-size: 11px; font-weight: 600; color: var(--amber); }

/* Modal */
.modal { position: fixed; inset: 0; z-index: 300; display: grid; place-items: center; padding: 20px; }
.modal.hidden { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: var(--overlay); backdrop-filter: blur(6px); }
.modal-content {
  position: relative; width: 100%; max-width: 900px; max-height: 90vh;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 4px); box-shadow: var(--shadow);
  display: flex; flex-direction: column; overflow: hidden;
}
.modal-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 20px 24px; border-bottom: 1px solid var(--border);
}
.modal-header h2 { margin: 4px 0 0; font-family: var(--mono); font-size: 1rem; }
.modal-body { overflow-y: auto; padding: 20px 24px 28px; }
.modal-section { margin-bottom: 28px; }
.modal-section h3 { margin: 0 0 14px; font-size: 14px; font-weight: 700; }

.prompt-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.prompt-head h3 { margin: 0; }
.prompt-full {
  background: var(--prompt-bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 18px;
  font-family: var(--mono); font-size: 12px; line-height: 1.7;
  color: var(--muted); white-space: pre-wrap; word-break: break-word;
  max-height: 400px; overflow-y: auto; margin: 0;
}

.traction-badge {
  font-size: 10px; font-weight: 700; padding: 3px 8px; border-radius: 999px;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.traction-very-high { background: rgba(239, 68, 68, 0.15); color: #ef4444; border: 1px solid rgba(239, 68, 68, 0.25); }
.traction-high { background: var(--green-bg); color: var(--green); border: 1px solid rgba(16, 185, 129, 0.25); }
.traction-medium { background: var(--amber-bg); color: var(--amber); border: 1px solid rgba(245, 158, 11, 0.25); }
.traction-low { background: rgba(113, 113, 122, 0.12); color: var(--dim); border: 1px solid var(--border); }

.social-panel { display: flex; flex-direction: column; gap: 12px; }
.social-score {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px;
  background: var(--surface-3); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.social-score strong { font-size: 1.5rem; font-family: var(--mono); }
.social-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; }
.social-card {
  padding: 12px 14px; background: var(--surface-3);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.social-card h4 { margin: 0 0 6px; font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--dim); }
.social-card p { margin: 0; font-size: 13px; color: var(--muted); }
.social-timeline { display: flex; flex-direction: column; gap: 8px; }
.social-item {
  padding: 10px 12px; background: var(--surface-3);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 12px;
}
.social-item a { color: var(--primary); text-decoration: none; font-weight: 600; }
.social-item a:hover { text-decoration: underline; }
.social-item .meta { display: block; margin-top: 4px; color: var(--dim); font-size: 11px; }

.tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.tag { font-size: 10px; font-weight: 600; padding: 3px 8px; border-radius: 999px; background: rgba(59, 130, 246, 0.1); color: var(--blue); border: 1px solid rgba(59, 130, 246, 0.15); }

.empty { text-align: center; padding: 40px; background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); }
.empty-icon { font-size: 32px; margin-bottom: 10px; }
.hidden { display: none !important; }

.toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 400;
  padding: 12px 18px; background: var(--surface-2);
  border: 1px solid var(--border-hover); border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 600; box-shadow: var(--shadow);
}
.toast.hidden { display: none; }

.loading-overlay {
  position: fixed; inset: 0; z-index: 500;
  display: grid; place-items: center; background: var(--overlay); backdrop-filter: blur(8px);
}
.loader-card { text-align: center; padding: 32px 40px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); }
.loader-card p { margin: 14px 0 4px; font-weight: 700; }
.loader-card span { font-size: 12px; color: var(--dim); }
.spinner {
  width: 36px; height: 36px; margin: 0 auto;
  border: 3px solid var(--border); border-top-color: var(--primary);
  border-radius: 50%; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 900px) {
  .stats-row, .dual-grid { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; align-items: stretch; }
  .topbar-actions { flex-direction: column; }
  .model-select { min-width: 100%; }
  .picks-grid { grid-template-columns: 1fr; }
}