:root {
  --bg: #F1F6FC;
  --surface: #FFFFFF;
  --ink: #0F172A;
  --muted: #64748B;
  --border: #E2E8F0;
  --primary: #2563EB;
  --primary-dark: #1D4ED8;
  --success: #059669;
  --amber: #D97706;
  --danger: #DC2626;
  --radius: 16px;
  --shadow: 0 8px 28px rgba(15, 23, 42, 0.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Noto Sans TC', system-ui, -apple-system, sans-serif;
  background: radial-gradient(circle at 12% 8%, #DBEAFE 0%, transparent 40%),
              radial-gradient(circle at 88% 12%, #FEF3C7 0%, transparent 38%),
              var(--bg);
  color: var(--ink);
  min-height: 100vh;
}

.muted { color: var(--muted); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: 12px;
  padding: 10px 16px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .15s ease, background .15s ease;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-sm { padding: 8px 13px; font-size: 13px; border-radius: 10px; }
.btn-xs { padding: 5px 10px; font-size: 12px; border-radius: 8px; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 4px 12px rgba(37,99,235,.22); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; box-shadow: 0 4px 12px rgba(5,150,105,.22); }
.btn-amber { background: #F59E0B; color: #fff; box-shadow: 0 4px 12px rgba(245,158,11,.24); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger-soft { background: #FEE2E2; color: #B91C1C; }
.btn-soft { background: #EFF6FF; color: #1E3A8A; border: 1px solid #DBEAFE; }
.btn-dark { background: #1E293B; color: #fff; }
.btn-glass { background: rgba(255,255,255,.16); color: #fff; border: 1px solid rgba(255,255,255,.28); }
.btn-group { display: inline-flex; gap: 4px; }

/* Shell & Cover */
.app-shell { max-width: 1200px; margin: 0 auto; padding: 18px 18px 48px; }

.cover-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 14px 20px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}
.brand-area { display: flex; align-items: center; gap: 12px; }
.brand-logo {
  width: 46px; height: 46px; border-radius: 14px;
  background: linear-gradient(135deg, #2563EB, #4F46E5);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; box-shadow: 0 6px 14px rgba(37,99,235,.25);
}
.brand-title { font-size: 20px; font-weight: 900; letter-spacing: -.3px; }
.brand-sub { font-size: 13px; color: var(--muted); font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.cloud-pill {
  font-size: 12px; font-weight: 800; padding: 6px 11px; border-radius: 999px;
  background: #F1F5F9; color: #475569;
}
.cloud-pill.online { background: #DCFCE7; color: #166534; }
.cloud-pill.connecting { background: #FEF9C3; color: #854D0E; }
.cloud-pill.error { background: #FEE2E2; color: #991B1B; }

.cover-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 18px;
  align-items: start;
}

.cover-main-card, .cover-qr-card, .panel-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.panel-card { margin-bottom: 16px; }

/* Cover QR Card */
.cover-qr-card {
  text-align: center;
  position: sticky;
  top: 16px;
  background: linear-gradient(180deg, #FFFFFF 0%, #F8FAFC 100%);
  border: 2px solid #BFDBFE;
}
.qr-card-badge {
  display: inline-block;
  font-size: 12px; font-weight: 900;
  background: #DBEAFE; color: #1D4ED8;
  padding: 4px 10px; border-radius: 999px;
  margin-bottom: 8px;
}
.qr-card-title { margin: 2px 0; font-size: 22px; font-weight: 900; }
.qr-card-sub { font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.qr-box {
  background: #fff;
  border: 2px solid #E2E8F0;
  border-radius: 16px;
  padding: 12px;
  width: 226px;
  height: 226px;
  margin: 0 auto 10px;
  cursor: pointer;
  transition: transform .15s ease, border-color .15s ease;
}
.qr-box:hover { transform: scale(1.02); border-color: var(--primary); }
.qr-box svg { width: 100%; height: 100%; display: block; }
.qr-card-tip { font-size: 12px; color: #475569; font-weight: 700; margin-bottom: 12px; }
.qr-card-actions { display: flex; flex-direction: column; gap: 8px; }

/* Class switcher */
.class-switcher-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; flex-wrap: wrap;
  padding-bottom: 14px; border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
}
.class-switcher-left { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.switcher-label { font-weight: 900; font-size: 14px; }
.quick-code-box { display: inline-flex; gap: 4px; align-items: center; }

.open-exams-banner {
  background: linear-gradient(135deg, #EFF6FF, #EEF2FF);
  border: 1px solid #BFDBFE;
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 18px;
}
.open-exams-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.exam-chip {
  font-size: 13px; font-weight: 800; padding: 5px 11px; border-radius: 999px;
}
.chip-zh { background: #FEF3C7; color: #92400E; border: 1px solid #FDE68A; }
.chip-math { background: #DBEAFE; color: #1E40AF; border: 1px solid #BFDBFE; }
.chip-blue { display: inline-block; background: #DBEAFE; color: #1E40AF; padding: 3px 10px; border-radius: 999px; font-weight: 800; font-size: 14px; }

.student-pick-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; flex-wrap: wrap; margin-bottom: 14px;
}
.grade-filter-pills { display: flex; gap: 6px; flex-wrap: wrap; }
.pill-btn {
  border: 1px solid var(--border); background: #fff; color: var(--muted);
  border-radius: 999px; padding: 5px 12px; font-size: 12px; font-weight: 800; cursor: pointer;
}
.pill-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.student-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
  gap: 10px;
}
.student-card {
  display: flex; align-items: center; gap: 10px;
  background: #F8FAFC; border: 2px solid #E2E8F0; border-radius: 14px;
  padding: 12px; text-align: left; cursor: pointer; font-family: inherit;
  transition: all .15s ease;
}
.student-card:hover { background: #EFF6FF; border-color: var(--primary); transform: translateY(-2px); }
.student-card.all-done { background: #F0FDF4; border-color: #86EFAC; }
.stu-seat {
  width: 36px; height: 36px; border-radius: 11px; flex-shrink: 0;
  background: #2563EB; color: #fff; font-weight: 900; font-size: 16px;
  display: flex; align-items: center; justify-content: center;
}
.student-card.all-done .stu-seat { background: #059669; }
.stu-meta { flex: 1; min-width: 0; }
.stu-name { font-weight: 900; font-size: 16px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stu-sub { font-size: 12px; color: var(--muted); font-weight: 700; }
.stu-arrow { font-weight: 900; color: #94A3B8; }

/* Student Assigned Lobby */
.lobby-exam-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 16px;
}
.lobby-exam-card {
  background: var(--surface); border: 2px solid var(--border); border-radius: 18px;
  padding: 20px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px;
}
.lobby-exam-card.card-zh { border-top: 5px solid #F59E0B; }
.lobby-exam-card.card-math { border-top: 5px solid #2563EB; }
.lobby-card-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.year-pill { background: #1E293B; color: #fff; font-size: 12px; font-weight: 800; padding: 4px 10px; border-radius: 999px; }
.subj-badge { font-size: 12px; font-weight: 900; padding: 4px 10px; border-radius: 999px; }
.subj-zh { background: #FEF3C7; color: #92400E; }
.subj-math { background: #DBEAFE; color: #1E40AF; }
.lobby-card-title { margin: 2px 0; font-size: 20px; font-weight: 900; }
.lobby-score-strip { border-radius: 12px; padding: 10px 12px; font-size: 13px; }
.lobby-score-strip.ok { background: #DCFCE7; color: #166534; }
.lobby-score-strip.need { background: #FEF2F2; color: #991B1B; }
.lobby-score-strip.todo { background: #F8FAFC; color: #475569; border: 1px dashed #CBD5E1; }
.lobby-card-actions { display: flex; gap: 8px; margin-top: auto; padding-top: 4px; }

/* Quiz Shell */
.quiz-shell { max-width: 1180px; margin: 0 auto; padding: 14px 16px 48px; }
.quiz-topbar, .review-topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  padding: 12px 16px; box-shadow: var(--shadow); margin-bottom: 16px;
}
.quiz-topbar-left { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.quiz-topbar-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.quiz-title { font-weight: 900; font-size: 17px; }
.quiz-sub { font-size: 13px; color: var(--muted); }

.quiz-layout {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}
.quiz-nav-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  padding: 14px; box-shadow: var(--shadow); position: sticky; top: 14px;
}
.quiz-nav-head { display: flex; justify-content: space-between; align-items: center; font-weight: 900; margin-bottom: 10px; }
.quiz-num-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.qnum-btn {
  height: 36px; border-radius: 9px; border: 1.5px solid #CBD5E1; background: #fff;
  font-weight: 800; font-size: 13px; cursor: pointer; font-family: inherit;
}
.qnum-btn.done { background: #DCFCE7; border-color: #22C55E; color: #166534; }
.qnum-btn.active { background: #2563EB; border-color: #1D4ED8; color: #fff; transform: scale(1.06); }
.quiz-nav-legend { display: flex; justify-content: space-between; margin-top: 12px; font-size: 11px; color: var(--muted); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 4px; }
.dot-active { background: #2563EB; }
.dot-done { background: #22C55E; }
.dot-todo { background: #CBD5E1; }

.quiz-main-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 18px;
  padding: 22px; box-shadow: var(--shadow);
}
.q-meta-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.q-meta-left { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.q-pill { background: #1E293B; color: #fff; font-size: 13px; font-weight: 900; padding: 4px 11px; border-radius: 999px; }
.q-section-tag { background: #F1F5F9; color: #334155; font-size: 12px; font-weight: 800; padding: 4px 10px; border-radius: 999px; }
.q-pts-tag { background: #FEF3C7; color: #92400E; font-size: 12px; font-weight: 800; padding: 4px 10px; border-radius: 999px; }

.passage-box {
  background: #FFFBEB; border: 1.5px solid #FDE68A; border-radius: 14px;
  padding: 16px; margin-bottom: 18px;
}
.passage-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; color: #92400E; }
.passage-body { font-size: calc(17px * var(--quiz-scale, 1)); line-height: 1.85; color: #1E293B; }
.passage-body p { margin: 0 0 10px; text-indent: 2em; }
.passage-body p:last-child { margin-bottom: 0; }

.q-prompt-text {
  font-size: calc(20px * var(--quiz-scale, 1));
  font-weight: 800;
  line-height: 1.75;
  color: #0F172A;
}

.q-svg-wrap {
  margin: 14px 0;
  padding: 12px;
  background: #F8FAFC;
  border: 1px solid #E2E8F0;
  border-radius: 14px;
  display: flex;
  justify-content: center;
  overflow-x: auto;
}
.q-svg { max-width: 100%; height: auto; max-height: 280px; }

/* Special Inline Math/Chinese Elements */
.frac {
  display: inline-flex; flex-direction: column; align-items: center;
  vertical-align: middle; margin: 0 4px; font-size: .86em; line-height: 1.1; font-weight: 900;
}
.frac > span:first-child { border-bottom: 2px solid currentColor; padding: 0 4px 2px; }
.frac > span:last-child { padding: 2px 4px 0; }
.blank {
  display: inline-block; min-width: 1.3em; text-align: center;
  border: 2px solid #2563EB; border-radius: 6px; padding: 0 4px; margin: 0 2px;
  background: #EFF6FF; color: #1D4ED8; font-weight: 900;
}
.zy-box {
  display: inline-flex; align-items: center; justify-content: center;
  border: 2.5px solid #DC2626; background: #FEF2F2; color: #B91C1C;
  border-radius: 8px; padding: 1px 8px; margin: 0 4px; font-weight: 900;
}

/* Options */
.options-list { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }
.options-char-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-top: 18px; }

.opt-btn {
  display: flex; align-items: center; gap: 12px;
  width: 100%; text-align: left; font-family: inherit;
  font-size: calc(18px * var(--quiz-scale, 1)); font-weight: 700;
  background: #F8FAFC; border: 2px solid #CBD5E1; border-radius: 14px;
  padding: 14px 16px; cursor: pointer; color: var(--ink);
  transition: all .12s ease;
}
.opt-btn:hover { background: #EFF6FF; border-color: #60A5FA; }
.opt-btn.selected { background: #DBEAFE; border-color: #2563EB; box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
.opt-char-card { justify-content: center; padding: 22px 16px; font-size: calc(30px * var(--quiz-scale, 1)); font-weight: 900; }
.opt-label { font-weight: 900; color: #2563EB; flex-shrink: 0; }
.opt-content { flex: 1; line-height: 1.55; }
.opt-char-card .opt-content { flex: 0; }

.quiz-footer-nav {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--border);
}
.quiz-progress-mini { flex: 1; max-width: 260px; }
.progress-track { height: 10px; background: #E2E8F0; border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, #2563EB, #10B981); transition: width .2s ease; }

/* Review Screen */
.review-shell { max-width: 960px; margin: 0 auto; padding: 16px 16px 60px; }
.score-hero {
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
  border-radius: 20px; padding: 22px 24px; color: #fff; margin-bottom: 18px;
  box-shadow: 0 12px 28px rgba(15,23,42,.12);
}
.score-hero.score-pass { background: linear-gradient(135deg, #059669, #2563EB); }
.score-hero.score-need { background: linear-gradient(135deg, #EA580C, #E11D48); }
.score-circle {
  width: 104px; height: 104px; border-radius: 50%; background: rgba(255,255,255,.18);
  border: 4px solid rgba(255,255,255,.75);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.score-num { font-size: 38px; font-weight: 900; line-height: 1; }
.score-unit { font-size: 13px; font-weight: 800; }
.score-badge { display: inline-block; background: rgba(255,255,255,.22); padding: 4px 12px; border-radius: 999px; font-weight: 800; font-size: 13px; }
.score-metrics { display: flex; gap: 14px; flex-wrap: wrap; font-size: 14px; margin-top: 6px; }

.review-filter-bar { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.review-q-list { display: flex; flex-direction: column; gap: 14px; }
.review-q-card {
  background: var(--surface); border: 1.5px solid var(--border); border-radius: 16px;
  padding: 18px; box-shadow: var(--shadow);
}
.review-q-card.is-wrong { border-left: 6px solid var(--danger); }
.review-q-card.is-correct { border-left: 6px solid var(--success); }
.review-q-card.preview-card { border-left: 6px solid var(--primary); }
.review-opts { display: flex; flex-direction: column; gap: 7px; margin-top: 10px; }
.rev-opt {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px;
  border-radius: 10px; background: #F8FAFC; border: 1px solid #E2E8F0; font-size: 15px;
}
.rev-opt-ans { background: #DCFCE7; border-color: #22C55E; font-weight: 800; }
.rev-opt-wrong { background: #FEE2E2; border-color: #EF4444; }
.rev-mark { margin-left: auto; font-size: 12px; font-weight: 900; }
.rev-mark.ok { color: #166534; }
.rev-mark.bad { color: #B91C1C; }
.explain-box {
  margin-top: 12px; background: #EFF6FF; border: 1px solid #BFDBFE;
  border-radius: 12px; padding: 11px 14px; font-size: 14px; line-height: 1.65; color: #1E3A8A;
}
.passage-collapse { background: #FFFBEB; border: 1px solid #FDE68A; border-radius: 10px; padding: 8px 12px; margin: 10px 0; }
.passage-collapse summary { cursor: pointer; font-weight: 800; color: #92400E; font-size: 13px; }

/* Teacher Dashboard */
.teacher-shell { max-width: 1200px; margin: 0 auto; padding: 16px 16px 60px; }
.teacher-header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  background: linear-gradient(135deg, #0F172A, #1E3A8A); color: #fff;
  border-radius: 18px; padding: 18px 22px; margin-bottom: 16px;
}
.teacher-title { font-size: 21px; font-weight: 900; }
.teacher-sub { font-size: 13px; color: #CBD5E1; margin-top: 4px; }
.teacher-sub code { background: rgba(255,255,255,.16); padding: 2px 6px; border-radius: 6px; color: #FDE68A; }
.teacher-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.teacher-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.tab-btn {
  border: 1px solid var(--border); background: #fff; color: #334155;
  border-radius: 12px; padding: 10px 15px; font-weight: 800; font-size: 14px; cursor: pointer; font-family: inherit;
}
.tab-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); box-shadow: 0 4px 12px rgba(37,99,235,.22); }

.panel-head-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.year-group { margin-top: 18px; }
.year-group-title { font-weight: 900; font-size: 16px; margin-bottom: 10px; color: #1E293B; }
.exam-assign-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.assign-card {
  border: 2px solid #E2E8F0; border-radius: 14px; padding: 14px; background: #F8FAFC;
  display: flex; flex-direction: column; gap: 10px; transition: all .15s ease;
}
.assign-card.is-on { background: #F0FDF4; border-color: #22C55E; }
.assign-card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.assign-title { font-weight: 900; font-size: 15px; margin: 6px 0 3px; }
.assign-card-foot { display: flex; justify-content: space-between; align-items: center; padding-top: 8px; border-top: 1px solid rgba(15,23,42,.08); }
.assign-state { font-size: 12px; font-weight: 900; }
.assign-state.on { color: #15803D; }
.assign-state.off { color: #64748B; }

/* Toggle Switch */
.switch { position: relative; display: inline-block; width: 48px; height: 26px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; cursor: pointer; inset: 0; background: #CBD5E1; border-radius: 999px; transition: .2s;
}
.slider:before {
  content: ""; position: absolute; height: 20px; width: 20px; left: 3px; bottom: 3px;
  background: #fff; border-radius: 50%; transition: .2s;
}
.switch input:checked + .slider { background: #16A34A; }
.switch input:checked + .slider:before { transform: translateX(22px); }

.settings-grid { display: flex; flex-direction: column; gap: 10px; }
.setting-row {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 12px 14px; background: #F8FAFC; border: 1px solid #E2E8F0; border-radius: 12px;
}

/* KPI & Tables */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi-card { background: #F8FAFC; border: 1px solid #E2E8F0; border-radius: 14px; padding: 14px; }
.kpi-label { font-size: 12px; font-weight: 800; color: var(--muted); }
.kpi-val { font-size: 26px; font-weight: 900; margin-top: 4px; }

.data-table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th, .data-table td { padding: 10px 10px; border-bottom: 1px solid #E2E8F0; text-align: left; }
.data-table th { background: #F8FAFC; font-weight: 900; color: #334155; font-size: 13px; }

.status-pill { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 800; }
.status-pill.ok { background: #DCFCE7; color: #166534; }
.status-pill.bad { background: #FEE2E2; color: #B91C1C; }
.status-pill.idle { background: #F1F5F9; color: #64748B; }
.tag-chip { background: #EEF2FF; color: #4338CA; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 800; }
.badge { padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 800; }
.badge-blue { background: #DBEAFE; color: #1E40AF; }

/* Analysis Bars */
.tag-bars { display: flex; flex-direction: column; gap: 8px; }
.tag-bar-row { display: grid; grid-template-columns: 140px 1fr 52px; gap: 10px; align-items: center; font-size: 13px; }
.tag-bar-track { height: 14px; background: #E2E8F0; border-radius: 999px; overflow: hidden; }
.tag-bar-fill { height: 100%; border-radius: 999px; }
.tag-bar-fill.ok { background: #10B981; }
.tag-bar-fill.mid { background: #F59E0B; }
.tag-bar-fill.bad { background: #EF4444; }
.tag-bar-val { font-weight: 900; text-align: right; }

.ana-q-list { display: flex; flex-direction: column; gap: 10px; }
.ana-q-item { border: 1px solid #E2E8F0; border-radius: 12px; padding: 12px 14px; background: #F8FAFC; }
.ana-q-item.hot { background: #FEF2F2; border-color: #FECACA; }
.ana-q-top { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.ana-q-prompt { font-size: 13px; color: #334155; margin-bottom: 8px; }
.ana-opts-row { display: flex; gap: 6px; flex-wrap: wrap; }
.ana-opt-pill { font-size: 12px; padding: 3px 8px; border-radius: 8px; background: #fff; border: 1px solid #CBD5E1; font-weight: 700; }
.ana-opt-pill.is-ans { background: #DCFCE7; border-color: #22C55E; color: #166534; }
.ana-wrong-stu { margin-top: 6px; font-size: 12px; color: #B91C1C; font-weight: 700; }

/* Inputs & Forms */
.input, .select-input, .textarea {
  width: 100%; padding: 9px 12px; border: 1.5px solid #CBD5E1; border-radius: 10px;
  font-family: inherit; font-size: 14px; background: #fff;
}
.select-input { width: auto; min-width: 180px; font-weight: 700; }
.input-sm, .select-input-sm { padding: 6px 9px; border: 1.5px solid #CBD5E1; border-radius: 8px; font-family: inherit; font-size: 13px; }
.input-xs { padding: 4px 7px; border: 1px solid #CBD5E1; border-radius: 6px; font-family: inherit; font-size: 13px; }
.form-stack { display: flex; flex-direction: column; gap: 10px; }
.form-stack label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 800; color: #334155; }
.two-col-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.two-col-form { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.share-url-box {
  margin-top: 6px; background: #fff; border: 1px dashed #93C5FD; border-radius: 8px;
  padding: 6px 10px; font-size: 12px; color: #1E40AF; word-break: break-all;
}

/* Modals & Full-Screen QR Projection */
.modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(15, 23, 42, .65); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal-card {
  background: #fff; border-radius: 20px; padding: 24px; width: 100%; max-width: 440px;
  box-shadow: 0 24px 60px rgba(0,0,0,.28); max-height: 92vh; overflow-y: auto;
}
.modal-card.modal-wide { max-width: 600px; }
.modal-err { color: var(--danger); font-size: 13px; font-weight: 800; margin-top: 8px; min-height: 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.mini-exam-checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; margin-top: 4px; }
.mini-chk {
  display: flex !important; flex-direction: row !important; align-items: center; gap: 6px;
  background: #F8FAFC; border: 1px solid #E2E8F0; border-radius: 8px; padding: 6px 8px; font-weight: 700 !important;
}

.qr-proj-overlay { background: rgba(15, 23, 42, .88); }
.qr-proj-card {
  position: relative; background: #fff; border-radius: 28px;
  padding: 36px 40px; text-align: center; width: 100%; max-width: 620px;
  box-shadow: 0 30px 80px rgba(0,0,0,.45);
}
.qr-proj-close { position: absolute; top: 18px; right: 18px; }
.qr-proj-badge { display: inline-block; background: #DBEAFE; color: #1E40AF; padding: 6px 14px; border-radius: 999px; font-weight: 900; font-size: 14px; }
.qr-proj-title { margin: 10px 0 18px; font-size: 32px; font-weight: 900; }
.qr-proj-svg {
  width: min(360px, 72vw); height: min(360px, 72vw); margin: 0 auto 18px;
  border: 3px solid #E2E8F0; border-radius: 20px; padding: 14px; background: #fff;
}
.qr-proj-svg svg { width: 100%; height: 100%; display: block; }
.qr-proj-assigned { font-size: 15px; font-weight: 800; margin-bottom: 10px; }
.qr-proj-url { font-size: 13px; color: var(--muted); word-break: break-all; }

/* Inline Scratchpad (below question & options) */
.scratchpad-inline {
  margin-top: 18px;
  background: #fff;
  border: 2px solid #93C5FD;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 6px 20px rgba(37, 99, 235, .08);
}
.scratchpad-header {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap;
  padding: 10px 14px; background: #EFF6FF; border-bottom: 1px solid #BFDBFE;
}
.scratchpad-tools { display: flex; gap: 6px; flex-wrap: wrap; }
.scratchpad-canvas-wrap {
  height: 260px;
  position: relative;
  background-color: #FFFFFF;
  background-image: radial-gradient(#CBD5E1 1px, transparent 1px);
  background-size: 20px 20px;
}
.scratchpad-inline.is-tall .scratchpad-canvas-wrap { height: 420px; }
#scratchpadCanvas { width: 100%; height: 100%; display: block; touch-action: none; cursor: crosshair; }

.empty-card { text-align: center; padding: 32px 18px; background: #F8FAFC; border: 1.5px dashed #CBD5E1; border-radius: 16px; }

/* Numeric PIN Keypad Modal */
.pin-modal-card { max-width: 380px; }
.pin-display {
  height: 54px;
  background: #F1F5F9;
  border: 2px solid #CBD5E1;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 6px;
}
.pin-placeholder { font-size: 14px; color: #94A3B8; font-weight: 700; }
.pin-dot { font-size: 24px; color: #2563EB; line-height: 1; }
.pin-keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 8px;
}
.pin-key {
  height: 58px;
  border-radius: 14px;
  border: 2px solid #DBEAFE;
  background: #F8FAFC;
  color: #0F172A;
  font-family: inherit;
  font-size: 24px;
  font-weight: 900;
  cursor: pointer;
  transition: transform .08s ease, background .12s ease, border-color .12s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.pin-key:hover { background: #EFF6FF; border-color: #60A5FA; }
.pin-key:active { transform: scale(0.95); background: #DBEAFE; }
.pin-key-fn { font-size: 16px; background: #F1F5F9; border-color: #CBD5E1; color: #334155; }

@media (max-width: 860px) {
  .cover-hero { grid-template-columns: 1fr; }
  .cover-qr-card { position: static; order: -1; }
  .quiz-layout { grid-template-columns: 1fr; }
  .quiz-nav-card { position: static; }
  .quiz-num-grid { grid-template-columns: repeat(9, 1fr); }
  .two-col-form { grid-template-columns: 1fr; }
}
