/* =========================================
   LOOP — Personal Learning Operating System
   Theme: Dark professional, amber accent
   Typography: DM Mono + DM Sans
   ========================================= */

@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=DM+Sans:wght@400;500;600;700&display=swap');

:root {
  --bg: #0B0F1A;
  --surface: #111827;
  --surface-2: #1a2235;
  --surface-3: #1e2a40;
  --border: #1e2d4a;
  --border-bright: #2a3f60;
  --text-primary: #E8ECF4;
  --text-secondary: #7A8FAF;
  --text-muted: #4A5F7A;
  --accent: #F59E0B;
  --accent-dim: rgba(245, 158, 11, 0.15);
  --accent-glow: rgba(245, 158, 11, 0.06);
  --green: #22c55e;
  --red: #ef4444;
  --green-dim: rgba(34, 197, 94, 0.15);
  --red-dim: rgba(239, 68, 68, 0.15);
  --font-mono: 'DM Mono', 'Fira Code', monospace;
  --font-sans: 'DM Sans', system-ui, sans-serif;
  --radius: 10px;
  --radius-sm: 6px;
}

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

html { scroll-behavior: smooth; scrollbar-width: thin; scrollbar-color: var(--border) var(--bg); }

body {
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  min-height: 100vh;
}

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::selection { background: var(--accent-dim); color: var(--accent); }

/* ── NAV ── */
.nav {
  position: sticky; top: 0; z-index: 100;
  border-bottom: 1px solid var(--border);
  background: rgba(11, 15, 26, 0.85);
  backdrop-filter: blur(12px);
}
.nav-inner {
  max-width: 1100px; margin: 0 auto;
  padding: 0 2rem; height: 56px;
  display: flex; align-items: center; gap: 2rem;
}
.nav-logo {
  display: flex; align-items: center; gap: 0.5rem;
  text-decoration: none; color: var(--text-primary);
}
.logo-mark {
  width: 28px; height: 28px;
  background: var(--accent); border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-weight: 700; font-size: 14px; color: #0B0F1A;
}
.logo-text { font-family: var(--font-mono); font-size: 15px; font-weight: 500; }
.nav-links { display: flex; gap: 0.5rem; margin-left: auto; }
.nav-btn {
  padding: 6px 14px; border-radius: var(--radius-sm);
  font-family: var(--font-sans); font-size: 13px; font-weight: 500;
  cursor: pointer; border: none; transition: all 0.15s;
}
.nav-btn.ghost { background: transparent; color: var(--text-secondary); }
.nav-btn.ghost:hover { background: var(--surface); color: var(--text-primary); }
.nav-btn.primary { background: var(--accent); color: #0B0F1A; }
.nav-btn.primary:hover { filter: brightness(1.1); }

/* ── LAYOUT ── */
.container { max-width: 860px; margin: 0 auto; padding: 3rem 2rem; }
.page-header { margin-bottom: 2rem; }
.page-title { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.page-subtitle { color: var(--text-secondary); font-size: 14px; }

/* ── CARDS ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}
.card + .card { margin-top: 1rem; }

/* ── BUTTONS ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px; border-radius: var(--radius-sm);
  font-family: var(--font-sans); font-size: 14px; font-weight: 500;
  cursor: pointer; border: none; transition: all 0.15s;
  text-decoration: none;
}
.btn-primary { background: var(--accent); color: #0B0F1A; }
.btn-primary:hover { filter: brightness(1.1); }
.btn-secondary { background: var(--surface-2); color: var(--text-primary); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--surface-3); border-color: var(--border-bright); }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--surface); color: var(--text-primary); }
.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── BADGE ── */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 99px;
  font-size: 11px; font-weight: 600; font-family: var(--font-mono);
  letter-spacing: 0.03em;
}
.badge-amber { background: var(--accent-dim); color: var(--accent); }
.badge-green { background: var(--green-dim); color: var(--green); }
.badge-red { background: var(--red-dim); color: var(--red); }
.badge-muted { background: var(--surface-2); color: var(--text-muted); }

/* ── INPUTS ── */
.form-group { margin-bottom: 1rem; }
label { display: block; font-size: 13px; font-weight: 500; color: var(--text-secondary); margin-bottom: 6px; }
input, textarea, select {
  width: 100%; padding: 9px 12px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-primary);
  font-family: var(--font-sans); font-size: 14px;
  transition: border-color 0.15s;
  outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
input::placeholder { color: var(--text-muted); }
select { cursor: pointer; }

/* ── DROP ZONE ── */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 3rem 2rem; text-align: center;
  transition: all 0.2s; cursor: pointer;
}
.drop-zone:hover, .drop-zone.drag-over { border-color: var(--accent); background: var(--accent-glow); }
.drop-zone-icon { font-size: 32px; margin-bottom: 0.75rem; }
.drop-zone-text { font-size: 14px; color: var(--text-secondary); margin-bottom: 0.5rem; }
.drop-zone-hint { font-size: 12px; color: var(--text-muted); font-family: var(--font-mono); }

/* ── QUESTION CARD ── */
.q-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.q-header { padding: 1.5rem 1.5rem 1rem; border-bottom: 1px solid var(--border); }
.q-meta { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 0.75rem; }
.q-number { font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); }
.q-text { font-size: 17px; font-weight: 500; line-height: 1.5; }
.q-options { padding: 0; list-style: none; }
.q-option {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.9rem 1.5rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer; transition: background 0.1s;
  font-size: 14px;
}
.q-option:last-child { border-bottom: none; }
.q-option:hover { background: var(--surface-2); }
.q-option.selected { background: var(--accent-dim); color: var(--accent); }
.q-option.correct { background: var(--green-dim); color: var(--green); }
.q-option.wrong { background: var(--red-dim); color: var(--red); }
.q-option-key {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--surface-3); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-size: 12px; color: var(--text-muted);
  flex-shrink: 0; transition: all 0.15s;
}
.q-option.selected .q-option-key { background: var(--accent); color: #0B0F1A; border-color: var(--accent); }
.q-option.correct .q-option-key { background: var(--green); color: white; border-color: var(--green); }
.q-option.wrong .q-option-key { background: var(--red); color: white; border-color: var(--red); }
.q-footer { padding: 1rem 1.5rem; display: flex; align-items: center; justify-content: space-between; border-top: 1px solid var(--border); background: var(--surface-2); }

/* ── PRACTICE ── */
.practice-header { text-align: center; padding: 1.5rem 0; }
.practice-progress { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.5rem; }
.progress-bar { flex: 1; height: 4px; background: var(--surface-3); border-radius: 2px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 2px; transition: width 0.4s ease; }
.progress-text { font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); white-space: nowrap; }

/* ── SUMMARY ── */
.summary-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; margin-bottom: 2rem; }
.summary-stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.5rem; text-align: center;
}
.summary-stat-value { font-size: 40px; font-weight: 700; font-family: var(--font-mono); line-height: 1; }
.summary-stat-label { font-size: 12px; color: var(--text-muted); margin-top: 6px; text-transform: uppercase; letter-spacing: 0.05em; }
.summary-stat-value.green { color: var(--green); }
.summary-stat-value.red { color: var(--red); }
.summary-stat-value.accent { color: var(--accent); }

/* ── TOPIC LIST ── */
.topic-list { display: flex; flex-direction: column; gap: 0.5rem; }
.topic-row {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.6rem 0.75rem; border-radius: var(--radius-sm);
  background: var(--surface); border: 1px solid var(--border);
}
.topic-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.topic-dot.correct { background: var(--green); }
.topic-dot.wrong { background: var(--red); }
.topic-name { flex: 1; font-size: 13px; }
.topic-count { font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); }

/* ── SEARCH (Cmd+K) ── */
.search-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,0.7);
  display: flex; align-items: flex-start; justify-content: center;
  padding-top: 15vh;
}
.search-modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); width: 100%; max-width: 560px;
  overflow: hidden; box-shadow: 0 24px 64px rgba(0,0,0,0.5);
}
.search-input-wrap { display: flex; align-items: center; gap: 0.75rem; padding: 1rem; border-bottom: 1px solid var(--border); }
.search-input-wrap svg { color: var(--text-muted); flex-shrink: 0; }
.search-input {
  flex: 1; background: none; border: none; outline: none;
  font-family: var(--font-sans); font-size: 16px; color: var(--text-primary);
}
.search-input::placeholder { color: var(--text-muted); }
.search-results { max-height: 400px; overflow-y: auto; }
.search-result {
  padding: 0.75rem 1rem; cursor: pointer; display: flex;
  align-items: center; gap: 1rem; transition: background 0.1s;
}
.search-result:hover { background: var(--surface-2); }
.search-result-meta { flex: 1; }
.search-result-title { font-size: 14px; font-weight: 500; }
.search-result-sub { font-size: 12px; color: var(--text-muted); font-family: var(--font-mono); }
.search-empty { padding: 2rem; text-align: center; color: var(--text-muted); font-size: 14px; }

/* ── TABLES ── */
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th { text-align: left; padding: 0.6rem 1rem; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); border-bottom: 1px solid var(--border); }
.data-table td { padding: 0.75rem 1rem; border-bottom: 1px solid var(--border); }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--surface-2); }

/* ── UTILITY ── */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 0.5rem; }
.gap-4 { gap: 1rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.text-muted { color: var(--text-muted); font-size: 13px; }
.text-sm { font-size: 13px; }
.font-mono { font-family: var(--font-mono); }
.hidden { display: none !important; }
.w-full { width: 100%; }
.tag-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 0.5rem; }

/* ── FLASH MESSAGE ── */
.flash {
  padding: 0.75rem 1rem; border-radius: var(--radius-sm);
  font-size: 14px; margin-bottom: 1rem;
}
.flash-success { background: var(--green-dim); color: var(--green); border: 1px solid rgba(34,197,94,0.3); }
.flash-error { background: var(--red-dim); color: var(--red); border: 1px solid rgba(239,68,68,0.3); }

/* ── DIVIDER ── */
.divider { border: none; border-top: 1px solid var(--border); margin: 1.5rem 0; }

/* ── VIEW TRANSITIONS ── */
.view { display: none; }
.view.active { display: block; }