/* ── Reset & Base ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:         #0f1117;
  --surface:    #1a1d27;
  --surface2:   #22263a;
  --border:     #2e3249;
  --primary:    #4f8ef7;
  --primary-dk: #3a72d8;
  --success:    #3ecf8e;
  --danger:     #f76f6f;
  --warning:    #f5a623;
  --text:       #e8eaf0;
  --muted:      #7b80a0;
  --radius:     10px;
  --shadow:     0 4px 24px rgba(0,0,0,.4);
}

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

/* ── Layout ────────────────────────────────────────────────────────────────── */
.container { max-width: 860px; margin: 0 auto; padding: 2rem 1.5rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem 2rem;
  box-shadow: var(--shadow);
}

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

/* ── Header ────────────────────────────────────────────────────────────────── */
.app-header {
  text-align: center;
  padding: 2.5rem 1rem 1.5rem;
}
.app-header h1 {
  font-size: 1.9rem;
  font-weight: 700;
  letter-spacing: -.5px;
  color: var(--primary);
}
.app-header p { color: var(--muted); margin-top: .4rem; font-size: .95rem; }

/* ── Section titles ────────────────────────────────────────────────────────── */
.section-title {
  font-size: 1rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  margin-bottom: 1rem;
}
h2 { font-size: 1.25rem; font-weight: 600; margin-bottom: .75rem; }

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  padding: .65rem 1.4rem;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-size: .95rem;
  font-weight: 600;
  transition: background .15s, transform .1s, opacity .15s;
  text-decoration: none;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn-primary   { background: var(--primary);   color: #fff; }
.btn-primary:hover:not(:disabled)   { background: var(--primary-dk); }
.btn-success   { background: var(--success);   color: #fff; }
.btn-success:hover:not(:disabled)   { background: #2fb87a; }
.btn-danger    { background: var(--danger);    color: #fff; }
.btn-danger:hover:not(:disabled)    { background: #e85555; }
.btn-outline   { background: transparent; border: 1.5px solid var(--border); color: var(--text); }
.btn-outline:hover:not(:disabled)   { border-color: var(--primary); color: var(--primary); }
.btn-ghost     { background: transparent; color: var(--muted); }
.btn-ghost:hover:not(:disabled)     { color: var(--text); }
.btn-full { width: 100%; justify-content: center; }

/* ── Load Options ──────────────────────────────────────────────────────────── */
.load-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.load-option {
  background: var(--surface2);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem 1.25rem;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  text-align: center;
}
.load-option:hover { border-color: var(--primary); background: #1e2338; }
.load-option.active { border-color: var(--primary); background: #1e2a45; }
.load-option .icon { font-size: 2rem; margin-bottom: .5rem; }
.load-option h3 { font-size: 1rem; font-weight: 700; }
.load-option p  { font-size: .85rem; color: var(--muted); margin-top: .3rem; }

/* ── File List ─────────────────────────────────────────────────────────────── */
.file-list { display: flex; flex-direction: column; gap: .6rem; }
.file-item {
  display: flex;
  align-items: center;
  gap: .85rem;
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: .85rem 1rem;
  cursor: pointer;
  transition: border-color .15s;
}
.file-item:hover   { border-color: var(--primary); }
.file-item.selected { border-color: var(--primary); background: #1e2a45; }
.file-item input[type=checkbox] { accent-color: var(--primary); width: 16px; height: 16px; cursor: pointer; }
.file-meta { flex: 1; }
.file-meta strong { display: block; font-size: .95rem; }
.file-meta span   { font-size: .82rem; color: var(--muted); }
.file-badge {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .2rem .55rem;
  font-size: .8rem;
  color: var(--muted);
  white-space: nowrap;
}

/* ── Type Chips ────────────────────────────────────────────────────────────── */
.chip-grid { display: flex; flex-wrap: wrap; gap: .5rem; }
.chip {
  padding: .4rem .9rem;
  border-radius: 999px;
  border: 1.5px solid var(--border);
  background: var(--surface2);
  font-size: .85rem;
  cursor: pointer;
  transition: border-color .15s, background .15s, color .15s;
  user-select: none;
}
.chip:hover   { border-color: var(--primary); }
.chip.selected { border-color: var(--primary); background: var(--primary); color: #fff; }
.chip.select-all { border-color: var(--muted); }
.chip.select-all.selected { border-color: var(--success); background: var(--success); }

/* ── Form Controls ─────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 1.25rem; }
.form-group label { display: block; font-size: .9rem; font-weight: 600; margin-bottom: .5rem; color: var(--muted); }
.form-control {
  width: 100%;
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: .65rem .9rem;
  color: var(--text);
  font-size: .95rem;
  outline: none;
  transition: border-color .15s;
}
.form-control:focus { border-color: var(--primary); }
select.form-control option { background: var(--surface2); }

.radio-group { display: flex; gap: .75rem; flex-wrap: wrap; }
.radio-card {
  flex: 1;
  min-width: 140px;
  background: var(--surface2);
  border: 2px solid var(--border);
  border-radius: 8px;
  padding: .85rem 1rem;
  cursor: pointer;
  transition: border-color .15s;
}
.radio-card input { display: none; }
.radio-card.selected { border-color: var(--primary); }
.radio-card strong { display: block; font-size: .95rem; }
.radio-card span { font-size: .82rem; color: var(--muted); }

/* ── Alert ─────────────────────────────────────────────────────────────────── */
.alert {
  padding: .8rem 1.1rem;
  border-radius: 8px;
  font-size: .9rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: flex-start;
  gap: .6rem;
}
.alert-warning { background: #2e2310; border: 1px solid #6b4c10; color: #f5c842; }
.alert-danger  { background: #2e1010; border: 1px solid #6b1010; color: #f76f6f; }
.alert-info    { background: #0f1f3a; border: 1px solid #1e3a6b; color: #7bb3f7; }

/* ── Question Card ─────────────────────────────────────────────────────────── */
.question-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}
.q-counter { font-size: .9rem; color: var(--muted); }
.q-type-badge {
  font-size: .78rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .2rem .6rem;
  color: var(--muted);
}

.progress-bar {
  height: 4px;
  background: var(--surface2);
  border-radius: 999px;
  margin-bottom: 1.75rem;
  overflow: hidden;
}
.progress-fill { height: 100%; background: var(--primary); transition: width .3s ease; }

.question-text { font-size: 1.05rem; font-weight: 500; margin-bottom: 1.25rem; line-height: 1.7; }

.choices { display: flex; flex-direction: column; gap: .6rem; }
.choice {
  display: flex;
  align-items: flex-start;
  gap: .85rem;
  background: var(--surface2);
  border: 2px solid var(--border);
  border-radius: 8px;
  padding: .85rem 1rem;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  font-size: .95rem;
}
.choice:hover:not(.disabled) { border-color: var(--primary); background: #1e2338; }
.choice.selected  { border-color: var(--primary); background: #1e2a45; }
.choice.correct   { border-color: var(--success); background: #0e2b1e; }
.choice.incorrect { border-color: var(--danger);  background: #2b0e0e; }
.choice.disabled  { cursor: default; }
.choice-letter {
  width: 26px;
  min-width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .8rem;
  font-weight: 700;
}
.choice.correct   .choice-letter { border-color: var(--success); color: var(--success); }
.choice.incorrect .choice-letter { border-color: var(--danger);  color: var(--danger); }
.choice.selected  .choice-letter { border-color: var(--primary); color: var(--primary); }

.feedback-box {
  margin-top: 1.25rem;
  background: var(--surface2);
  border-radius: 8px;
  padding: 1rem 1.1rem;
  border-left: 3px solid var(--primary);
  font-size: .9rem;
  line-height: 1.65;
}
.feedback-box.correct   { border-color: var(--success); }
.feedback-box.incorrect { border-color: var(--danger); }
.feedback-box .fb-label { font-weight: 700; margin-bottom: .35rem; font-size: .85rem; text-transform: uppercase; letter-spacing: .05em; }
.feedback-box.correct   .fb-label { color: var(--success); }
.feedback-box.incorrect .fb-label { color: var(--danger); }
.feedback-box .misconception { margin-top: .6rem; color: var(--muted); font-style: italic; font-size: .87rem; }

/* ── Results ───────────────────────────────────────────────────────────────── */
.score-hero {
  text-align: center;
  padding: 1.5rem 0;
}
.score-circle {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  border: 6px solid var(--primary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1rem;
}
.score-circle .score-num { font-size: 2rem; font-weight: 800; color: var(--primary); line-height: 1; }
.score-circle .score-den { font-size: .85rem; color: var(--muted); }
.score-pct { font-size: 2.5rem; font-weight: 800; }
.score-label { color: var(--muted); font-size: .9rem; margin-top: .25rem; }

.breakdown-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.breakdown-table th, .breakdown-table td {
  padding: .65rem .9rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.breakdown-table th { color: var(--muted); font-weight: 600; font-size: .82rem; text-transform: uppercase; letter-spacing: .06em; }
.breakdown-table tr:last-child td { border-bottom: none; }
.bar-cell { width: 140px; }
.mini-bar { height: 8px; background: var(--surface2); border-radius: 999px; overflow: hidden; }
.mini-bar-fill { height: 100%; border-radius: 999px; background: var(--primary); }
.mini-bar-fill.low  { background: var(--danger); }
.mini-bar-fill.mid  { background: var(--warning); }
.mini-bar-fill.high { background: var(--success); }

.weak-tag {
  display: inline-block;
  background: #2e1010;
  border: 1px solid #6b1010;
  color: var(--danger);
  border-radius: 6px;
  padding: .25rem .65rem;
  font-size: .82rem;
  margin: .25rem;
}

/* ── Session history ───────────────────────────────────────────────────────── */
.session-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .85rem 1.1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  cursor: pointer;
  transition: border-color .15s;
}
.session-item:hover { border-color: var(--primary); }
.session-score { font-size: 1.35rem; font-weight: 800; min-width: 60px; text-align: center; }
.session-meta { flex: 1; }
.session-meta strong { display: block; font-size: .9rem; }
.session-meta span { font-size: .82rem; color: var(--muted); }

/* ── Review accordion ──────────────────────────────────────────────────────── */
.review-item { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; margin-bottom: .5rem; }
.review-header {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .85rem 1rem;
  cursor: pointer;
  background: var(--surface2);
  transition: background .15s;
}
.review-header:hover { background: #2a2e45; }
.review-status { font-size: 1rem; }
.review-q { flex: 1; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.review-body { padding: 1rem 1.1rem; border-top: 1px solid var(--border); display: none; font-size: .9rem; line-height: 1.65; }
.review-body.open { display: block; }

/* ── Utility ───────────────────────────────────────────────────────────────── */
.flex          { display: flex; }
.flex-between  { display: flex; justify-content: space-between; align-items: center; }
.gap-sm        { gap: .5rem; }
.gap-md        { gap: 1rem; }
.mt-sm         { margin-top: .5rem; }
.mt-md         { margin-top: 1rem; }
.mt-lg         { margin-top: 1.75rem; }
.mb-sm         { margin-bottom: .5rem; }
.mb-md         { margin-bottom: 1rem; }
.text-muted    { color: var(--muted); }
.text-success  { color: var(--success); }
.text-danger   { color: var(--danger); }
.text-warning  { color: var(--warning); }
.text-center   { text-align: center; }
.hidden        { display: none !important; }
.divider       { border: none; border-top: 1px solid var(--border); margin: 1.25rem 0; }
