/* ── Design tokens ── */
:root {
  color-scheme: light;
  --ink: #172033;
  --muted: #5c667a;
  --line: #d8deea;
  --panel: #fff;
  --bg: #f3f6fb;
  --accent: #2459c4;
  --good: #18794e;
  --bad: #b42318;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}

/* ── Header ── */
header {
  background: #172b4d;
  color: white;
  padding: 24px 16px;
}
header .wrap,
main { max-width: 900px; margin: auto; }
h1 { margin: 0 0 6px; font-size: clamp(1.5rem, 4vw, 2.2rem); }
header p { margin: 0; color: #e0e8f7; }

/* ── Home page module grid ── */
.home-main { padding: 28px 14px 48px; }
.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 18px;
  margin-top: 8px;
}
.module-card {
  display: block;
  text-decoration: none;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 5px 18px rgba(20, 40, 80, .05);
  color: var(--ink);
  transition: box-shadow .2s, transform .15s;
}
.module-card:hover {
  box-shadow: 0 8px 26px rgba(20, 40, 80, .12);
  transform: translateY(-2px);
}
.module-number {
  font-size: .82rem;
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 6px;
}
.module-card h2 { margin: 0 0 8px; font-size: 1.15rem; }
.module-card p { margin: 0; font-size: .9rem; color: var(--muted); }
.empty-notice {
  color: var(--muted);
  background: var(--panel);
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 24px;
  font-size: .95rem;
}
.empty-notice code {
  background: #edf1f8;
  padding: 2px 6px;
  border-radius: 5px;
  font-size: .9em;
}

/* ── Quiz page shared ── */
main { padding: 20px 14px 40px; }
.toolbar, .card, .summary {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 5px 18px rgba(20, 40, 80, .05);
}
.toolbar {
  padding: 14px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: end;
  margin-bottom: 16px;
}
label {
  display: block;
  font-size: .85rem;
  color: var(--muted);
  font-weight: 650;
  margin-bottom: 5px;
}
select, button {
  font: inherit;
  border-radius: 10px;
  padding: 10px 13px;
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
}
select { min-width: 190px; }
button { cursor: pointer; font-weight: 650; }
button.primary { background: var(--accent); border-color: var(--accent); color: white; }
button:disabled { opacity: .45; cursor: not-allowed; }

.statline {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: .9rem;
  margin: 0 2px 10px;
}
.progress {
  height: 8px;
  background: #e1e7f1;
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 16px;
}
.progress > div { height: 100%; width: 0; background: var(--accent); transition: width .2s; }

.card { padding: clamp(18px, 4vw, 30px); }

.tag {
  display: inline-block;
  background: #eaf0ff;
  color: #234b9a;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 750;
  margin-bottom: 12px;
}

.question-image {
  display: none;
  width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  margin: 0 0 18px;
}
.question {
  font-size: clamp(1.1rem, 2.8vw, 1.4rem);
  font-weight: 750;
  margin: 0 0 18px;
}

.options { display: grid; gap: 10px; }
.option {
  width: 100%;
  text-align: left;
  display: flex;
  gap: 11px;
  align-items: flex-start;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}
.option .letter {
  flex: 0 0 27px;
  width: 27px;
  height: 27px;
  border-radius: 7px;
  background: #edf1f8;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: .85rem;
}
.option.selected { border-color: var(--accent); background: #f1f5ff; }
.option.correct { border-color: var(--good); background: #ecfdf3; }
.option.wrong { border-color: var(--bad); background: #fff1f0; }

.feedback {
  margin-top: 15px;
  padding: 12px 14px;
  border-radius: 10px;
  display: none;
}
.feedback.show { display: block; }
.feedback.good { background: #ecfdf3; color: #145c3b; }
.feedback.bad { background: #fff1f0; color: #8e1d16; }

.controls {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 22px;
}
.controls .group { display: flex; gap: 8px; flex-wrap: wrap; }

.summary { padding: 22px; margin-top: 16px; display: none; }
.summary.show { display: block; }
.summary h2 { margin-top: 0; }
.small { font-size: .88rem; color: var(--muted); }
.notice { font-size: .88rem; color: var(--muted); margin: 14px 3px 0; }

/* ── Tabs ── */
.tabs { display: flex; gap: 8px; margin: 0 0 18px; flex-wrap: wrap; }
.tab-button { border-radius: 999px; padding: 10px 18px; }
.tab-button[aria-selected="true"] {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
.spotlight-panel { display: none; }
.spotlight-panel.active { display: block; }
.spotlight-tip {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: #fff5f5;
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 20px;
  font-size: .84rem;
  color: #9b1c1c;
  line-height: 1.5;
}
.spotlight-tip-icon {
  font-size: 1rem;
  line-height: 1.4;
  flex-shrink: 0;
  opacity: .7;
}
.spotlight-intro { color: var(--muted); margin-top: 0; }
.spotlight-item {
  background: white;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 18px;
  margin: 0 0 12px;
}
.spotlight-item h3 { font-size: 1rem; margin: 0 0 7px; }
.spotlight-item p { margin: 0; }
.spotlight-item .answer { margin-top: 7px; color: #145c3b; }

/* ── Back link ── */
.back-link {
  display: inline-block;
  margin: 0 0 18px;
  color: var(--accent);
  text-decoration: none;
  font-size: .9rem;
  font-weight: 600;
}
.back-link:hover { text-decoration: underline; }

@media (max-width: 520px) {
  .toolbar > div { width: 100%; }
  select { width: 100%; }
  .controls button { flex: 1; }
}

/* ── Spotlight class notes ── */
.item-notes {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.notes-divider {
  font-size: .78rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 10px;
}
.note-card {
  background: #f5f8ff;
  border: 1px solid #dce6f5;
  border-radius: 10px;
  padding: 11px 13px;
  margin-bottom: 8px;
}
.note-meta {
  font-size: .8rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 5px;
}
.note-body {
  font-size: .9rem;
  color: var(--ink);
  white-space: pre-wrap;
}
.note-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  margin-top: 8px;
}
.note-btn {
  font: inherit;
  font-size: .8rem;
  font-weight: 650;
  padding: 5px 11px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: white;
  cursor: pointer;
  color: var(--ink);
}
.note-btn-primary { background: var(--accent); border-color: var(--accent); color: white; }
.note-btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.note-btn-danger { color: var(--bad); border-color: #f5c6c2; }
.note-btn-danger:hover { background: #fff1f0; }
.note-input {
  display: block;
  width: 100%;
  font: inherit;
  font-size: .9rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 8px;
  color: var(--ink);
}
.note-textarea {
  display: block;
  width: 100%;
  font: inherit;
  font-size: .9rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  resize: vertical;
  margin-bottom: 8px;
  color: var(--ink);
}
.note-form-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.add-note-wrapper { margin-top: 8px; }
.add-note-btn {
  font: inherit;
  font-size: .85rem;
  font-weight: 650;
  color: var(--accent);
  background: none;
  border: 1px dashed #b0c4e8;
  border-radius: 8px;
  padding: 7px 13px;
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: background .15s;
}
.add-note-btn:hover { background: #eef3ff; }
.add-note-form {
  background: #f5f8ff;
  border: 1px solid #dce6f5;
  border-radius: 10px;
  padding: 12px;
  margin-top: 6px;
}
