/* ═══════════════════════════════════════════════════
   Tutor — Scholar's Study Design System
   Fonts: Fraunces (display) + Plus Jakarta Sans (body)
   ═══════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght@0,9..144,300;0,9..144,400;0,9..144,600;0,9..144,700;1,9..144,400&family=Plus+Jakarta+Sans:wght@400;500;600&display=swap');

/* ─── Tokens ──────────────────────────────────────── */
:root {
  --paper:        #F7F4EE;
  --surface:      #FFFFFF;
  --surface-2:    #F9F7F3;
  --ink:          #1A1714;
  --ink-mid:      #4A4640;
  --ink-muted:    #7C776F;
  --ink-faint:    #B6B0A8;
  --green:        #1E5C38;
  --green-hover:  #185030;
  --green-light:  #EBF3EE;
  --green-border: #C4DDD0;
  --red:          #B23B3B;
  --red-light:    #FDF0F0;
  --amber:        #92500E;
  --amber-light:  #FEF5E7;
  --border:       #E3DDD3;
  --border-dark:  #C7C1B7;
  --shadow-xs:    0 1px 2px rgba(26, 23, 20, 0.06);
  --shadow-sm:    0 1px 4px rgba(26, 23, 20, 0.08), 0 1px 2px rgba(26, 23, 20, 0.04);
  --shadow:       0 3px 12px rgba(26, 23, 20, 0.10), 0 1px 3px rgba(26, 23, 20, 0.06);
  --shadow-lg:    0 8px 28px rgba(26, 23, 20, 0.12), 0 2px 8px rgba(26, 23, 20, 0.06);
  --radius:       9px;
  --radius-sm:    6px;
  --radius-lg:    14px;
  --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;
  --font-body:    'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --nav-h:        56px;
}

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

/* ─── Base ────────────────────────────────────────── */
html { font-size: 15px; }

body {
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ─── Animations ──────────────────────────────────── */
@keyframes fade-up {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ─── Navigation ──────────────────────────────────── */
nav {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--nav-h);
  background: var(--green);
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1.5rem;
}

.nav-brand {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 600;
  color: #fff;
  text-decoration: none;
  letter-spacing: -0.02em;
  flex: 1;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.nav-name {
  font-size: 0.875rem;
  color: rgba(255, 255, 255, 0.72);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-role {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.85);
}

.nav-signout {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.28);
  color: rgba(255, 255, 255, 0.72);
  font-family: var(--font-body);
  font-size: 0.8rem;
  padding: 0.3rem 0.7rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
}
.nav-signout:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.5);
}

/* ─── Main content ────────────────────────────────── */
main {
  max-width: 960px;
  margin: 2.25rem auto;
  padding: 0 1.25rem;
  animation: fade-up 0.3s ease both;
}

/* ─── Page header ─────────────────────────────────── */
.page-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.75rem;
  flex-wrap: wrap;
}

.page-head h1 {
  font-family: var(--font-display);
  font-size: 2.1rem;
  font-weight: 600;
  letter-spacing: -0.04em;
  line-height: 1.15;
  color: var(--ink);
}

.page-head-meta {
  font-size: 0.875rem;
  color: var(--ink-muted);
  margin-top: 0.2rem;
}

.page-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ─── Section heading ─────────────────────────────── */
.section-head {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  color: var(--ink);
  margin-bottom: 1rem;
}

/* ─── Cards ───────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

/* ─── Course grid (CP2+) ──────────────────────────── */
.course-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}

.course-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  transition: box-shadow 0.15s, border-color 0.15s, transform 0.12s;
}
.course-card:hover {
  box-shadow: var(--shadow);
  border-color: var(--border-dark);
  transform: translateY(-1px);
}

.course-card-subject {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--green);
}

.course-card-name {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
  line-height: 1.3;
}

.course-card-meta {
  font-size: 0.8rem;
  color: var(--ink-muted);
  margin-top: auto;
  padding-top: 0.5rem;
}

/* ─── Empty state ─────────────────────────────────── */
.empty-state {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 4rem 2rem;
  text-align: center;
  box-shadow: var(--shadow-xs);
}

.empty-icon {
  width: 52px;
  height: 52px;
  background: var(--green-light);
  border-radius: var(--radius-lg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.25rem;
  color: var(--green);
}

.empty-title {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
  margin-bottom: 0.4rem;
}

.empty-text {
  font-size: 0.875rem;
  color: var(--ink-muted);
  max-width: 300px;
  margin: 0 auto 1.5rem;
  line-height: 1.6;
}

/* ─── Table ───────────────────────────────────────── */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  padding: 0.7rem 1rem;
  text-align: left;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}

tbody td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid #F2EFE8;
  font-size: 0.9rem;
  color: var(--ink);
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #FDFCF9; }

/* ─── Buttons ─────────────────────────────────────── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 1.1rem;
  background: var(--green);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, transform 0.1s;
  white-space: nowrap;
}
.btn-primary:hover  { background: var(--green-hover); }
.btn-primary:active { transform: scale(0.98); }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 1.1rem;
  background: var(--surface);
  color: var(--ink-mid);
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 0.875rem;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.btn-secondary:hover { background: var(--surface-2); border-color: var(--ink-faint); }

.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.75rem;
  background: transparent;
  color: var(--ink-muted);
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.12s, color 0.12s;
}
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }

.btn-danger {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.9rem;
  background: transparent;
  color: var(--red);
  border: 1px solid #E8C0C0;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s;
}
.btn-danger:hover { background: var(--red-light); }

/* ─── Google sign-in button ───────────────────────── */
.btn-google {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  width: 100%;
  padding: 0.72rem 1rem;
  background: var(--surface);
  color: var(--ink-mid);
  border: 1.5px solid var(--border-dark);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 0.925rem;
  text-decoration: none;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.btn-google:hover {
  border-color: var(--ink-faint);
  box-shadow: var(--shadow-sm);
}

/* ─── Badges ──────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.badge-admin   { background: var(--green-light); color: var(--green); }
.badge-student { background: var(--amber-light); color: var(--amber); }

/* ─── Status pills ────────────────────────────────── */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
}
.pill::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.6;
}
.pill-queued     { color: var(--amber); background: var(--amber-light); }
.pill-processing { color: #1852A4; background: #EDF2FC; }
.pill-ready      { color: var(--green); background: var(--green-light); }
.pill-error      { color: var(--red);   background: var(--red-light); }

/* ─── Forms ───────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 1.1rem;
}

.form-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-mid);
  letter-spacing: 0.01em;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 0.6rem 0.85rem;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.9rem;
  color: var(--ink);
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(30, 92, 56, 0.1);
}
.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--ink-faint);
}

.form-textarea { resize: vertical; min-height: 100px; }

.form-select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%237C776F' d='M6 8L1.5 3.5h9z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 0.75rem center; padding-right: 2rem; }

.form-file {
  width: 100%;
  padding: 0.6rem 0.85rem;
  background: var(--surface-2);
  border: 1.5px dashed var(--border-dark);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.875rem;
  color: var(--ink-muted);
  cursor: pointer;
  transition: border-color 0.15s;
}
.form-file:hover { border-color: var(--green); color: var(--ink); }

.form-hint {
  font-size: 0.78rem;
  color: var(--ink-faint);
  margin-top: 0.15rem;
}

/* ─── Flash messages ──────────────────────────────── */
.flash {
  padding: 0.7rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  margin-bottom: 1.25rem;
  line-height: 1.5;
}
.flash-error   { background: var(--red-light);   border: 1px solid #EAC8C8; color: var(--red); }
.flash-success { background: var(--green-light);  border: 1px solid var(--green-border); color: var(--green); }
.flash-info    { background: #EDF2FC; border: 1px solid #C0D4F5; color: #1852A4; }

/* ─── Divider ─────────────────────────────────────── */
.divider {
  height: 1px;
  background: var(--border);
  margin: 1.5rem 0;
}

/* ─── Login / center-card pages ───────────────────── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  background: var(--paper);
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.75rem 2.25rem;
  width: 100%;
  max-width: 370px;
  box-shadow: var(--shadow-lg);
  text-align: center;
  animation: fade-up 0.35s ease both;
}

.login-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  background: var(--green);
  border-radius: var(--radius);
  margin-bottom: 1.25rem;
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.03em;
}

.login-title {
  font-family: var(--font-display);
  font-size: 1.7rem;
  font-weight: 600;
  letter-spacing: -0.04em;
  color: var(--ink);
  margin-bottom: 0.35rem;
  line-height: 1.15;
}

.login-sub {
  font-size: 0.875rem;
  color: var(--ink-muted);
  margin-bottom: 2rem;
  line-height: 1.5;
}

.login-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--ink-faint);
  font-size: 0.78rem;
  margin-bottom: 1.25rem;
}
.login-divider::before,
.login-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.login-error {
  background: var(--red-light);
  border: 1px solid #EAC8C8;
  border-radius: var(--radius-sm);
  color: var(--red);
  font-size: 0.85rem;
  padding: 0.6rem 0.85rem;
  margin-top: 1rem;
}

/* ─── Upload source link ──────────────────────────── */
.source-link {
  font-size: 0.78rem;
  color: var(--ink-faint);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  transition: color 0.12s;
}
.source-link:hover { color: var(--ink-muted); }

/* ─── Syllabus link ───────────────────────────────── */
.syllabus-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--green);
  text-decoration: none;
  padding: 0.3rem 0.65rem;
  background: var(--green-light);
  border-radius: 4px;
  transition: background 0.12s;
}
.syllabus-link:hover { background: var(--green-border); }

/* ─── Button size variant ─────────────────────────── */
.btn-sm { padding: 0.38rem 0.8rem; font-size: 0.8rem; }

/* ─── Dialog / Modal ──────────────────────────────── */
dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 0;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 420px;
  outline: none;
}

dialog::backdrop {
  background: rgba(26, 23, 20, 0.45);
  backdrop-filter: blur(2px);
}

dialog > form {
  padding: 1.75rem 1.75rem 1.5rem;
}

.dlg-title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.025em;
  color: var(--ink);
  margin-bottom: 1.25rem;
}

.dlg-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1.5rem;
}

/* ─── Course subject label ────────────────────────── */
.course-subject-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--green);
  margin-bottom: 0.2rem;
}

/* ─── Section block (card with header) ───────────── */
.section-block {
  padding: 1.25rem 1.5rem;
}

.section-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

/* ─── Section list ────────────────────────────────── */
.section-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-top: 0.5rem;
}

.section-item {
  display: flex;
  align-items: baseline;
  gap: 0.65rem;
  padding: 0.45rem 0.25rem;
  border-bottom: 1px solid #F2EFE8;
  font-size: 0.9rem;
}

.section-item:last-child { border-bottom: none; }

.section-num {
  min-width: 1.5rem;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--green);
  font-variant-numeric: tabular-nums;
}

.section-name { color: var(--ink); }

/* ─── Upload mode tabs ────────────────────────────── */
.upload-mode-tabs {
  display: flex;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 1.25rem;
}

.mode-tab {
  flex: 1;
  padding: 0.45rem 1rem;
  background: transparent;
  border: none;
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--ink-muted);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}

.mode-tab + .mode-tab { border-left: 1px solid var(--border); }
.mode-tab.active { background: var(--green-light); color: var(--green); font-weight: 600; }
.mode-tab:hover:not(.active) { background: var(--surface-2); }

/* ─── Type chip ───────────────────────────────────── */
.type-chip {
  display: inline-block;
  padding: 0.1rem 0.45rem;
  border-radius: 3px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--surface-2);
  color: var(--ink-muted);
}

/* ─── Drop zone ──────────────────────────────────── */
.drop-zone {
  border: 2px dashed var(--border-dark);
  border-radius: var(--radius);
  padding: 1.75rem 1rem;
  text-align: center;
  cursor: pointer;
  background: var(--surface-2);
  transition: border-color 0.15s, background 0.15s;
  user-select: none;
}
.drop-zone:hover,
.drop-zone.dragover {
  border-color: var(--green);
  background: var(--green-light);
}
.drop-zone.dragover { border-style: solid; }

.drop-zone-icon { color: var(--ink-faint); margin-bottom: 0.5rem; }

.drop-zone-label {
  font-size: 0.875rem;
  color: var(--ink-muted);
  line-height: 1.5;
}
.drop-zone-label button {
  background: none;
  border: none;
  color: var(--green);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}
.drop-zone-hint {
  font-size: 0.75rem;
  color: var(--ink-faint);
  margin-top: 0.25rem;
}

.drop-zone-files { text-align: left; }

.drop-zone-file-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-bottom: 0.75rem;
}
.drop-zone-file-list li {
  font-size: 0.85rem;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.drop-zone-file-list li::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  flex-shrink: 0;
}

/* ─── Study guide ─────────────────────────────────────── */
.study-guide {
  display: flex;
  flex-direction: column;
  gap: 2.75rem;
}

/* ── Unit header ── */
.study-unit-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 0.65rem;
  border-bottom: 1.5px solid var(--border);
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.study-unit-title {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  color: var(--ink);
}

.study-unit-count {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--ink-faint);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.study-unit-empty {
  font-size: 0.875rem;
  color: var(--ink-faint);
  font-style: italic;
  padding: 0.5rem 0;
}

/* ── Section list ── */
.guide-section-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

/* ── Guide section card ── */
.guide-section-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s, border-left-color 0.15s;
  border-left: 3px solid transparent;
}
.guide-section-card:has(details[open]) {
  border-color: var(--border-dark);
  border-left-color: var(--green);
  box-shadow: var(--shadow-sm);
}

/* ── Summary row ── */
.guide-section-summary {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.85rem 1.1rem;
  cursor: pointer;
  user-select: none;
  list-style: none;
  transition: background 0.12s;
}
.guide-section-summary::-webkit-details-marker { display: none; }
.guide-section-summary:hover { background: var(--surface-2); }

/* Section index number */
.gs-index {
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--green);
  min-width: 1.25rem;
  flex-shrink: 0;
  line-height: 1;
  opacity: 0.7;
}

.guide-section-chevron {
  color: var(--ink-faint);
  display: inline-flex;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}
details[open] .guide-section-chevron { transform: rotate(90deg); }

/* Fraunces for section titles — gives each entry scholarly weight */
.guide-section-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: -0.015em;
  color: var(--ink);
  line-height: 1.4;
}

/* ── Section body ── */
.guide-section-body {
  padding: 0 1.1rem 1.1rem;
  border-top: 1px solid var(--border);
}

.guide-section-content {
  padding: 0.9rem 0 0.6rem;
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--ink-mid);
}
.guide-section-content p {
  margin-bottom: 0.65rem;
}
.guide-section-content p:last-child { margin-bottom: 0; }
.guide-section-content ul {
  padding-left: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.guide-section-content li { color: var(--ink); }

/* ── Explain zone ── */
.explain-zone {
  margin-top: 0.8rem;
  border-top: 1px solid #F0EDE6;
  padding-top: 0.8rem;
}

.btn-explain {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.32rem 0.75rem;
  background: var(--green-light);
  color: var(--green);
  border: 1px solid var(--green-border);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.btn-explain:hover:not(:disabled) {
  background: var(--green-border);
  border-color: #AACFBB;
}
.btn-explain:disabled { opacity: 0.6; cursor: default; }

/* ── Expansion area (Claude's explanation) ── */
.expansion-area {
  margin-top: 0.8rem;
  background: linear-gradient(135deg, #F1F7F4 0%, var(--surface-2) 100%);
  border: 1px solid var(--green-border);
  border-left: 3px solid var(--green);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem 0.85rem 0.9rem;
  animation: fade-in 0.22s ease both;
}

.expansion-label {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--green);
  margin-bottom: 0.55rem;
  opacity: 0.9;
}

.expansion-text {
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--ink);
  white-space: pre-wrap;
  min-height: 1.2em;
}
/* When markdown is rendered into expansion-text, pre-wrap conflicts with block elements */
.expansion-text p,
.expansion-text ul,
.expansion-text ol,
.expansion-text h1,
.expansion-text h2,
.expansion-text h3 {
  white-space: normal;
}
.expansion-text p { margin-bottom: 0.6rem; }
.expansion-text p:last-child { margin-bottom: 0; }
.expansion-text ul, .expansion-text ol { padding-left: 1.25rem; margin-bottom: 0.6rem; }
.expansion-text li { margin-bottom: 0.25rem; }
.expansion-text strong { color: var(--ink); }

/* ── Follow-up input row ── */
.followup-row {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.9rem;
  align-items: center;
  border-top: 1px solid var(--green-border);
  padding-top: 0.8rem;
}
.followup-row .form-input {
  flex: 1;
  padding: 0.42rem 0.72rem;
  font-size: 0.875rem;
  background: var(--surface);
}

/* ── Follow-up answer area ── */
.followup-answer {
  margin-top: 0.85rem;
  border-top: 1px solid var(--green-border);
  padding-top: 0.8rem;
  animation: fade-in 0.18s ease both;
}

.followup-question-display {
  font-size: 0.78rem;
  color: var(--ink-muted);
  font-style: italic;
  margin-bottom: 0.55rem;
  padding: 0.35rem 0.6rem;
  background: rgba(30, 92, 56, 0.05);
  border-radius: 4px;
}
.followup-question-display::before {
  content: 'You: ';
  font-weight: 700;
  font-style: normal;
  color: var(--ink-mid);
}

.followup-text {
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--ink);
  white-space: pre-wrap;
  min-height: 1.2em;
}
.followup-text p,
.followup-text ul,
.followup-text ol { white-space: normal; }
.followup-text p { margin-bottom: 0.5rem; }
.followup-text p:last-child { margin-bottom: 0; }
.followup-text ul, .followup-text ol { padding-left: 1.25rem; }

/* ── Streaming cursor animation ── */
@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}
.streaming::after {
  content: '▋';
  display: inline;
  margin-left: 1px;
  font-size: 0.85em;
  color: var(--green);
  animation: blink 0.75s ease infinite;
  vertical-align: baseline;
}

/* ─── Diagnostic (CP5) ────────────────────────────── */

/* ── Progress bar ── */
.diag-progress-wrap {
  margin-bottom: 1.75rem;
}

.diag-progress-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.45rem;
  flex-wrap: wrap;
}

.diag-progress-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-mid);
}

.diag-missed-note {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--amber);
  background: var(--amber-light);
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
}

.diag-progress-track {
  height: 5px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.diag-progress-fill {
  height: 100%;
  background: var(--green);
  border-radius: 999px;
  transition: width 0.35s ease;
}

/* ── Question card ── */
.diag-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 1.75rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.diag-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.diag-q-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  background: var(--green-light);
  color: var(--green);
  border-radius: 50%;
  font-size: 0.72rem;
  font-weight: 700;
  flex-shrink: 0;
}

.diag-type-chip {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.18rem 0.55rem;
  border-radius: 3px;
  background: var(--surface-2);
  color: var(--ink-muted);
  border: 1px solid var(--border);
}

.diag-type-mc  { background: #EDF2FC; color: #1852A4; border-color: #C0D4F5; }
.diag-type-sa  { background: var(--green-light); color: var(--green); border-color: var(--green-border); }

.diag-missed-badge {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--amber);
  background: var(--amber-light);
  border: 1px solid #E8C89A;
  padding: 0.15rem 0.55rem;
  border-radius: 4px;
}

.diag-question-text {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.45;
  color: var(--ink);
}

/* ── MC options ── */
.mc-options {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.mc-option {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.9rem;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s, transform 0.1s;
}
.mc-option:hover:not(:disabled) { border-color: var(--border-dark); background: var(--surface-2); }
.mc-option.selected { border-color: var(--green); background: var(--green-light); }
.mc-option.opt-correct { border-color: var(--green); background: var(--green-light); color: var(--green); font-weight: 600; }
.mc-option.opt-incorrect { border-color: var(--red); background: var(--red-light); color: var(--red); }
.mc-option.opt-dimmed { opacity: 0.45; }
.mc-option:disabled { cursor: default; }

.mc-letter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.35rem;
  height: 1.35rem;
  border-radius: 3px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--ink-muted);
  flex-shrink: 0;
  margin-top: 0.05rem;
  transition: background 0.12s, color 0.12s;
}
.mc-option.selected  .mc-letter { background: var(--green); border-color: var(--green); color: #fff; }
.mc-option.opt-correct   .mc-letter { background: var(--green); border-color: var(--green); color: #fff; }
.mc-option.opt-incorrect .mc-letter { background: var(--red);   border-color: var(--red);   color: #fff; }

.mc-text { line-height: 1.45; }

/* ── SA area ── */
.sa-area {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.diag-sa-textarea {
  min-height: 120px;
  resize: vertical;
}

/* ── Feedback panel ── */
.diag-feedback {
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--surface-2);
  padding: 1rem 1.1rem;
  animation: fade-in 0.2s ease both;
}

.diag-feedback.correct  { border-color: var(--green-border); background: var(--green-light); }
.diag-feedback.incorrect { border-color: #EAC8C8; background: var(--red-light); }
.diag-feedback.grading  { border-color: #C0D4F5; background: #EDF2FC; }

.feedback-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.feedback-icon {
  font-size: 1rem;
  font-weight: 700;
  width: 1.5rem;
  height: 1.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  flex-shrink: 0;
}

.diag-feedback.correct  .feedback-icon { background: var(--green); color: #fff; }
.diag-feedback.incorrect .feedback-icon { background: var(--red);  color: #fff; }
.diag-feedback.grading  .feedback-icon { background: #C0D4F5; color: #1852A4; }

.feedback-verdict {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.diag-feedback.correct  .feedback-verdict { color: var(--green); }
.diag-feedback.incorrect .feedback-verdict { color: var(--red); }
.diag-feedback.grading  .feedback-verdict { color: #1852A4; }

.feedback-body {
  font-size: 0.9rem;
  line-height: 1.65;
  color: var(--ink-mid);
  white-space: pre-wrap;
  min-height: 1.2em;
}
.feedback-body p,
.feedback-body ul,
.feedback-body ol { white-space: normal; }
.feedback-body p { margin-bottom: 0.45rem; }
.feedback-body p:last-child { margin-bottom: 0; }
.feedback-body ul, .feedback-body ol { padding-left: 1.25rem; }
.feedback-body li { margin-bottom: 0.2rem; }

/* ── Confidence picker ── */
.confidence-area {
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}

.confidence-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 0.65rem;
}

.confidence-btns {
  display: flex;
  gap: 0.5rem;
}

.conf-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  padding: 0.65rem 0.5rem;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}
.conf-btn:hover { border-color: var(--border-dark); background: var(--surface-2); }
.conf-btn.selected { border-color: var(--green); background: var(--green-light); }

.conf-num {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--ink-mid);
  font-family: var(--font-display);
}
.conf-btn.selected .conf-num { color: var(--green); }

.conf-desc {
  font-size: 0.7rem;
  color: var(--ink-muted);
  text-align: center;
  line-height: 1.3;
}

/* ── Navigation ── */
.diag-nav {
  border-top: 1px solid var(--border);
  padding-top: 1rem;
  display: flex;
  justify-content: flex-end;
}

/* ─── Session Summary (CP5) ───────────────────────── */

.summary-score-card {
  padding: 2rem;
  display: flex;
  align-items: center;
  gap: 2rem;
  flex-wrap: wrap;
}

.summary-score-ring {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  border: 6px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.summary-score-ring.ring-green  { border-color: var(--green); }
.summary-score-ring.ring-amber  { border-color: #E8922A; }
.summary-score-ring.ring-red    { border-color: var(--red); }

.summary-score-pct {
  font-family: var(--font-display);
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: -0.04em;
  color: var(--ink);
}

.summary-score-label {
  font-size: 1rem;
  color: var(--ink-mid);
  margin-bottom: 0.3rem;
}

.summary-score-msg {
  font-size: 0.875rem;
  color: var(--ink-muted);
}

/* ── Missed list ── */
.missed-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.missed-item {
  padding: 1.25rem 1.5rem;
}

.missed-item-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.75rem;
}

.missed-q-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  background: var(--red-light);
  color: var(--red);
  border-radius: 50%;
  font-size: 0.68rem;
  font-weight: 700;
  flex-shrink: 0;
}

.missed-question {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--ink);
  line-height: 1.45;
  margin-bottom: 0.85rem;
}

.missed-your-answer,
.missed-correct-answer {
  display: flex;
  gap: 0.75rem;
  align-items: baseline;
  margin-bottom: 0.45rem;
  font-size: 0.875rem;
}

.missed-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ink-faint);
  white-space: nowrap;
  min-width: 90px;
}

.missed-your-answer .missed-text { color: var(--red); }
.missed-correct-answer .missed-text { color: var(--green); font-weight: 500; }
.missed-text { line-height: 1.5; color: var(--ink-mid); }

.missed-explanation {
  margin-top: 0.65rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--ink-muted);
  line-height: 1.6;
}

/* ─── Responsive ──────────────────────────────────── */
@media (max-width: 600px) {
  main { margin: 1.25rem auto; }
  .page-head h1 { font-size: 1.6rem; }
  .course-grid { grid-template-columns: 1fr; }
  .page-head { flex-direction: column; align-items: flex-start; gap: 0.75rem; }
  nav { padding: 0 1rem; }
  .nav-name { display: none; }
  .diag-card { padding: 1.25rem 1rem; }
  .confidence-btns { flex-direction: column; }
  .summary-score-card { flex-direction: column; align-items: flex-start; gap: 1.25rem; }
}
