:root {
  --bg: #0f1117;
  --surface: #1a1d26;
  --surface2: #242736;
  --border: #2e3149;
  --primary: #6366f1;
  --primary-hover: #4f52cc;
  --primary-muted: #6366f120;
  --text: #e8eaf0;
  --text-muted: #8b90a7;
  --text-dim: #555b78;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius: 10px;
  --radius-sm: 6px;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.6;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout ── */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
}

.auth-card h1 { font-size: 1.6rem; margin-bottom: 0.4rem; }
.auth-card .subtitle { color: var(--text-muted); margin-bottom: 2rem; }

/* ── App shell ── */
.app-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  grid-template-rows: 56px 1fr;
  min-height: 100vh;
}

.topbar {
  grid-column: 1 / -1;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-brand { font-weight: 700; font-size: 1.05rem; color: var(--text); }
.topbar-brand span { color: var(--primary); }

.topbar-right { display: flex; align-items: center; gap: 1rem; }

.mode-toggle {
  display: flex;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.mode-toggle button {
  padding: 0.3rem 0.8rem;
  font-size: 0.8rem;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}

.mode-toggle button.active {
  background: var(--primary);
  color: #fff;
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1.5rem 0;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 1.5rem;
  color: var(--text-muted);
  font-size: 0.9rem;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: all 0.15s;
  text-decoration: none;
}

.nav-item:hover { color: var(--text); background: var(--surface2); text-decoration: none; }
.nav-item.active { color: var(--text); border-left-color: var(--primary); background: var(--primary-muted); }
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }

.nav-section-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  padding: 1rem 1.5rem 0.4rem;
}

.main-content {
  padding: 2rem;
  overflow-y: auto;
  max-height: calc(100vh - 56px);
}

.page { display: none; }
.page.active { display: block; }

/* ── Forms ── */
.form-group { margin-bottom: 1.2rem; }
.form-group label { display: block; font-size: 0.85rem; color: var(--text-muted); margin-bottom: 0.4rem; }

input, textarea, select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 0.6rem 0.9rem;
  font-size: 0.95rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}

input:focus, textarea:focus, select:focus { border-color: var(--primary); }
textarea { min-height: 100px; resize: vertical; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.2rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-family: inherit;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  text-decoration: none;
  font-weight: 500;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); text-decoration: none; }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); text-decoration: none; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { color: var(--text); background: var(--surface2); text-decoration: none; }
.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.8rem; }
.btn-full { width: 100%; justify-content: center; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}

.card + .card { margin-top: 1rem; }

.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1rem; }

/* ── Badges ── */
.badge {
  display: inline-block;
  font-size: 0.72rem;
  padding: 0.2rem 0.55rem;
  border-radius: 20px;
  background: var(--surface2);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.badge-primary { background: var(--primary-muted); color: var(--primary); border-color: var(--primary); }
.badge-success { background: #22c55e20; color: var(--success); }
.badge-warning { background: #f59e0b20; color: var(--warning); }

/* ── Stars ── */
.stars { display: flex; gap: 0.3rem; }
.star {
  font-size: 1.6rem;
  cursor: pointer;
  color: var(--text-dim);
  transition: color 0.1s, transform 0.1s;
  line-height: 1;
}
.star:hover, .star.active { color: #fbbf24; transform: scale(1.15); }

/* ── Score bar ── */
.score-bar {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin: 0.5rem 0;
}
.score-fill { height: 100%; border-radius: 3px; background: var(--primary); transition: width 0.6s ease; }

/* ── Chat ── */
.chat-container { display: flex; flex-direction: column; height: calc(100vh - 140px); }
.chat-messages { flex: 1; overflow-y: auto; padding: 1rem 0; display: flex; flex-direction: column; gap: 1rem; }
.chat-bubble { max-width: 80%; padding: 0.8rem 1.1rem; border-radius: var(--radius); line-height: 1.6; }
.chat-bubble.user { background: var(--primary); color: #fff; align-self: flex-end; }
.chat-bubble.assistant { background: var(--surface2); align-self: flex-start; }
.chat-input-row { display: flex; gap: 0.75rem; margin-top: 1rem; }
.chat-input-row input { flex: 1; }

/* ── Status ── */
.status-done { color: var(--success); }
.status-pending { color: var(--warning); }
.status-error { color: var(--danger); }
.status-processing { color: var(--primary); }

/* ── Alerts ── */
.alert {
  padding: 0.8rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}
.alert-error { background: #ef444420; border: 1px solid var(--danger); color: #fca5a5; }
.alert-success { background: #22c55e20; border: 1px solid var(--success); color: #86efac; }
.alert-info { background: var(--primary-muted); border: 1px solid var(--primary); color: #a5b4fc; }

/* ── Progress ── */
.progress-bar { height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 4px; background: var(--primary); }

/* ── Utility ── */
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-4 { margin-top: 2rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 2rem; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.85rem; }
.text-center { text-align: center; }
.hidden { display: none !important; }
.divider { border: none; border-top: 1px solid var(--border); margin: 1.5rem 0; }

/* ── Spinner ── */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Review card ── */
.review-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 2rem; max-width: 700px; margin: 0 auto; }
.review-card .problem { background: var(--surface2); border-radius: var(--radius-sm); padding: 1.2rem; white-space: pre-wrap; margin: 1rem 0; }

/* ── Step indicator ── */
.steps { display: flex; gap: 0.5rem; margin-bottom: 1.5rem; }
.step-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--border); }
.step-dot.active { background: var(--primary); }
.step-dot.done { background: var(--success); }

/* ── Responsive ── */
@media (max-width: 768px) {
  .app-layout { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .card-grid { grid-template-columns: 1fr; }
}
