/* App-specific styles — extends theme.css design tokens */
:root {
  --bg: #0d1117;
  --bg-surface: #161b22;
  --bg-surface2: #1c2128;
  --fg: #e6edf3;
  --fg-muted: #7d8590;
  --fg-subtle: #484f58;
  --accent: #f59e0b;
  --accent-dim: rgba(245,158,11,0.12);
  --accent-border: rgba(245,158,11,0.3);
  --border: rgba(240,246,252,0.1);
  --success: #3fb950;
  --danger: #f85149;
  --font-sans: 'IBM Plex Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'IBM Plex Mono', 'Courier New', monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; font-size: 16px; }
body { background: var(--bg); color: var(--fg); font-family: var(--font-sans); line-height: 1.6; }

/* Header */
.site-header { position: fixed; top: 0; left: 0; right: 0; z-index: 100; background: rgba(13,17,23,0.85); backdrop-filter: blur(12px); border-bottom: 1px solid var(--border); }
.header-inner { max-width: 1200px; margin: 0 auto; padding: 0 2rem; height: 60px; display: flex; align-items: center; justify-content: space-between; }
.logo { font-family: var(--font-mono); font-size: 1.1rem; font-weight: 600; color: var(--fg); letter-spacing: -0.02em; cursor: pointer; }
.logo-accent { color: var(--accent); }
.header-nav { display: flex; gap: 1.5rem; }
.header-nav a { color: var(--fg-muted); text-decoration: none; font-size: 0.875rem; font-weight: 500; transition: color 0.2s; }
.header-nav a:hover, .header-nav a.active { color: var(--fg); }

/* Layout */
.app-container { max-width: 800px; margin: 0 auto; padding: 7rem 2rem 4rem; }
.page-title { font-size: 1.75rem; font-weight: 700; margin-bottom: 0.25rem; color: var(--fg); }
.page-subtitle { color: var(--fg-muted); margin-bottom: 2.5rem; font-size: 0.95rem; }

/* Auth Panel */
.auth-panel { display: flex; gap: 1rem; }
.auth-form { background: var(--bg-surface); border: 1px solid var(--border); border-radius: 12px; padding: 1.5rem; width: 280px; }
.auth-form h3 { font-size: 0.9rem; font-weight: 600; margin-bottom: 1rem; color: var(--fg-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.input { width: 100%; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; color: var(--fg); padding: 0.6rem 0.875rem; font-family: var(--font-sans); font-size: 0.9rem; outline: none; transition: border-color 0.2s; }
.input:focus { border-color: var(--accent); }
.input-group { margin-bottom: 0.75rem; }
.input-label { display: block; font-size: 0.8rem; color: var(--fg-muted); margin-bottom: 0.35rem; }
.btn { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.6rem 1.25rem; border-radius: 8px; font-size: 0.875rem; font-weight: 500; font-family: var(--font-sans); cursor: pointer; border: none; transition: all 0.2s; }
.btn-primary { background: var(--accent); color: #0d1117; }
.btn-primary:hover { background: #d97706; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--fg-muted); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn-full { width: 100%; justify-content: center; }
.auth-error { font-size: 0.8rem; color: var(--danger); margin-top: 0.5rem; }
.user-badge { display: flex; align-items: center; gap: 0.75rem; padding: 0.5rem 0; }

/* Start Screen */
.start-panel { text-align: center; padding: 3rem 0; }
.start-panel h2 { font-size: 2rem; font-weight: 700; margin-bottom: 0.75rem; }
.start-panel p { color: var(--fg-muted); max-width: 480px; margin: 0 auto 2rem; }
.domain-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 0.75rem; margin-bottom: 1.5rem; }
.domain-chip { background: var(--bg-surface); border: 1px solid var(--border); border-radius: 8px; padding: 0.75rem 1rem; font-size: 0.85rem; color: var(--fg-muted); cursor: pointer; transition: all 0.2s; text-align: left; }
.domain-chip:hover { border-color: var(--accent); color: var(--accent); }
.domain-chip.selected { border-color: var(--accent); background: var(--accent-dim); color: var(--accent); }
.difficulty-row { display: flex; gap: 0.75rem; justify-content: center; margin-bottom: 1.5rem; }
.diff-btn { padding: 0.5rem 1.5rem; border-radius: 8px; border: 1px solid var(--border); background: var(--bg-surface); color: var(--fg-muted); font-size: 0.875rem; cursor: pointer; transition: all 0.2s; }
.diff-btn.selected { border-color: var(--accent); background: var(--accent-dim); color: var(--accent); }

/* Quiz Card */
.quiz-card { background: var(--bg-surface); border: 1px solid var(--border); border-radius: 16px; padding: 2rem; animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
.quiz-meta { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }
.quiz-domain { font-family: var(--font-mono); font-size: 0.8rem; color: var(--accent); background: var(--accent-dim); border: 1px solid var(--accent-border); padding: 0.25rem 0.75rem; border-radius: 20px; }
.quiz-progress { font-family: var(--font-mono); font-size: 0.8rem; color: var(--fg-muted); }
.question-text { font-size: 1.1rem; font-weight: 500; line-height: 1.6; margin-bottom: 1.5rem; }
.options { display: flex; flex-direction: column; gap: 0.75rem; }
.option-btn { display: flex; align-items: center; gap: 1rem; padding: 1rem 1.25rem; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; cursor: pointer; transition: all 0.2s; text-align: left; width: 100%; }
.option-btn:hover { border-color: var(--accent); }
.option-btn.selected { border-color: var(--accent); background: var(--accent-dim); }
.option-btn.correct { border-color: var(--success); background: rgba(63,185,80,0.1); }
.option-btn.wrong { border-color: var(--danger); background: rgba(248,81,73,0.1); }
.option-btn:disabled { cursor: not-allowed; }
.option-letter { font-family: var(--font-mono); font-size: 0.8rem; font-weight: 600; color: var(--fg-muted); width: 24px; }
.option-text { font-size: 0.95rem; color: var(--fg); }
.explanation { margin-top: 1.25rem; padding: 1rem; background: var(--bg); border-radius: 10px; border-left: 3px solid var(--accent); font-size: 0.9rem; color: var(--fg-muted); line-height: 1.6; animation: fadeIn 0.3s ease; }
.explanation strong { color: var(--accent); }
.quiz-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 1.5rem; }

/* Result Screen */
.result-panel { text-align: center; padding: 2rem 0; }
.result-score { font-size: 4rem; font-weight: 700; font-family: var(--font-mono); color: var(--accent); }
.result-label { color: var(--fg-muted); font-size: 0.9rem; margin-bottom: 1.5rem; }
.result-actions { display: flex; gap: 1rem; justify-content: center; margin-top: 1.5rem; }

/* Dashboard */
.stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-bottom: 2rem; }
.stat-card { background: var(--bg-surface); border: 1px solid var(--border); border-radius: 12px; padding: 1.25rem; text-align: center; }
.stat-value { font-size: 2rem; font-weight: 700; font-family: var(--font-mono); color: var(--accent); }
.stat-label { font-size: 0.8rem; color: var(--fg-muted); margin-top: 0.25rem; }
.mastery-section h3 { font-size: 1rem; font-weight: 600; margin-bottom: 1rem; color: var(--fg); }
.domain-row { display: flex; align-items: center; gap: 1rem; margin-bottom: 0.75rem; }
.domain-name { font-family: var(--font-mono); font-size: 0.85rem; width: 120px; color: var(--fg-muted); }
.progress-bar-wrap { flex: 1; height: 8px; background: var(--bg); border-radius: 4px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 4px; transition: width 0.6s ease; }
.progress-bar.high { background: var(--success); }
.progress-bar.medium { background: var(--accent); }
.progress-bar.low { background: var(--danger); }
.domain-pct { font-family: var(--font-mono); font-size: 0.85rem; width: 40px; text-align: right; color: var(--fg-muted); }
.recent-sessions { margin-top: 2rem; }
.session-item { display: flex; justify-content: space-between; align-items: center; padding: 0.75rem 0; border-bottom: 1px solid var(--border); }
.session-item:last-child { border-bottom: none; }
.session-domain { font-family: var(--font-mono); font-size: 0.85rem; }
.session-score { font-family: var(--font-mono); font-size: 0.85rem; color: var(--fg-muted); }
.session-date { font-size: 0.8rem; color: var(--fg-subtle); }
.empty-state { text-align: center; padding: 2rem; color: var(--fg-muted); font-size: 0.9rem; }

/* Loading */
.loading-spinner { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 4rem 0; color: var(--fg-muted); }
.spinner { width: 40px; height: 40px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { margin-top: 1rem; font-size: 0.9rem; }

/* Slide-in animation */
.slide-in { animation: slideIn 0.25s ease; }
@keyframes slideIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }