*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
input[type="checkbox"] { accent-color: #4a90c4; }
select {
  -webkit-appearance: none;
  appearance: none;
  background-color: #fff;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath fill='%236b7280' d='M0 0l5 6 5-6z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.6rem center;
  background-size: auto 0.35rem;
  padding: 0.35rem 2rem 0.35rem 0.65rem;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.83rem;
  font-family: inherit;
  color: #374151;
  cursor: pointer;
}
select:hover { border-color: #9ca3af; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #fafafa;
  color: #1a1a1a;
  min-height: 100vh;
}

/* ── Login card ── */
.center-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  gap: 1rem;
}

.center-card h1 { font-size: 2rem; }
.center-card p  { color: #555; }

.center-card form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 280px;
}

.center-card input {
  padding: 0.6rem 0.8rem;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 1rem;
}

.center-card button {
  padding: 0.65rem;
  background: #3fa8e8;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 1rem;
  cursor: pointer;
}

.center-card button:hover { background: #2d9ad8; }

/* ── General page layout ── */
.page { display: flex; flex-direction: column; min-height: 100vh; }

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1.5rem;
  background: #3fa8e8;
  color: #fff;
}

.top-bar a { color: #cfe0ff; text-decoration: none; }
.top-bar a:hover { text-decoration: underline; }

main {
  padding: 2rem 1.5rem;
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
}

main h2 { margin-bottom: 1rem; }

/* ── Admin forms & tables ── */
.inline-form {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.inline-form input {
  padding: 0.5rem 0.75rem;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.95rem;
  flex: 1;
  min-width: 160px;
}

.inline-form button {
  display: inline-flex;
  align-items: center;
  padding: 0.5rem 1rem;
  background: #3fa8e8;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 0.9rem;
  font-family: inherit;
  line-height: 1.4;
  cursor: pointer;
  white-space: nowrap;
}

.inline-form button:hover { background: #2d9ad8; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.data-table th, .data-table td {
  padding: 0.65rem 1rem;
  text-align: left;
  border-bottom: 1px solid #eee;
  font-size: 0.9rem;
}

.data-table th { background: #f8f9fb; font-weight: 600; }
.data-table tr:last-child td { border-bottom: none; }
.data-table a { color: #2d6a87; text-decoration: none; }
.data-table a:hover { text-decoration: underline; }

.btn-danger {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.75rem;
  background: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fca5a5;
  border-radius: 5px;
  font-size: 0.85rem;
  font-family: inherit;
  line-height: 1.4;
  cursor: pointer;
}

.btn-danger:hover { background: #fecaca; border-color: #f87171; }

.muted { color: #888; margin-top: 0.5rem; }

/* ── Admin sections ── */
.admin-section { margin-bottom: 2.5rem; }
.admin-section h2 { margin-bottom: 1rem; }

/* ── Add-question collapsible ── */
.btn-primary-link {
  display: inline-block;
  background: #3fa8e8;
  color: #fff;
  padding: 0.5rem 1.1rem;
  border-radius: 0.5rem;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
  transition: background 0.15s;
}
.btn-primary-link:hover { background: #2d9ad8; }

.add-question-box {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 8px;
  margin-bottom: 1.5rem;
}

.add-question-box summary {
  padding: 0.75rem 1rem;
  cursor: pointer;
  font-weight: 600;
  color: #3fa8e8;
  list-style: none;
}

.add-question-box summary::-webkit-details-marker { display: none; }
.add-question-box[open] summary { border-bottom: 1px solid #eee; }

/* ── Question form (add & edit) ── */
.question-form {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  padding: 1rem;
}

.question-form label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.9rem;
  font-weight: 600;
}

.question-form textarea,
.question-form input[type="text"],
.question-form select {
  border-color: #d1d5db;
  font-size: 0.88rem;
  width: 100%;
}

.choices-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}

/* ── RTE field-group (replaces <label> wrapper to prevent bold-button focus bug) ── */
.field-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.9rem;
}

.field-group .field-label {
  font-weight: 600;
}

/* ── Choice RTEs (vertical list, each on its own line) ── */
.choices-list {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  margin-bottom: 0.5rem;
}

.choice-rte-row {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}

.choice-rte-row > .field-label {
  width: 1.4rem;
  padding-top: 0.55rem;
  flex-shrink: 0;
}

.choice-rte-row .rte-wrap {
  flex: 1;
}

.choice-rte-row .rte-editor {
  min-height: 72px;
}

.math-choice-input {
  flex: 1;
  padding: 0.45rem 0.65rem;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.95rem;
  font-family: inherit;
  width: 100%;
}
.math-choice-input:focus {
  outline: none;
  border-color: #4f46e5;
  box-shadow: 0 0 0 2px rgba(79,70,229,0.15);
}

.question-form button[type="submit"] {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  padding: 0.5rem 1rem;
  background: #3fa8e8;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 0.9rem;
  font-family: inherit;
  line-height: 1.4;
  cursor: pointer;
}

.question-form button[type="submit"]:hover { background: #2d9ad8; }

/* ── Question list ── */
.question-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 0;
}

.question-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 1rem 1.2rem;
  counter-increment: question-counter;
}

.q-stem { font-weight: 500; margin-bottom: 0.6rem; white-space: pre-wrap; }

.q-choices {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.92rem;
  margin-bottom: 0.6rem;
}

.q-choices li { padding: 0.15rem 0.4rem; border-radius: 4px; }
.q-choices li.correct { background: #dcfce7; color: #15803d; font-weight: 600; }

.q-explanation { font-size: 0.88rem; color: #555; margin-bottom: 0.6rem; }

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

.btn-edit {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.75rem;
  background: #f1f5f9;
  color: #374151;
  border: 1px solid #cbd5e1;
  border-radius: 5px;
  font-size: 0.85rem;
  font-family: inherit;
  text-decoration: none;
  cursor: pointer;
  line-height: 1.4;
}

.btn-edit:hover { background: #e2e8f0; }

/* ── Question type badge ── */
.q-type-badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-mc { background: #dbeafe; color: #1e40af; }
.badge-fr { background: #dcfce7; color: #166534; }

.q-fr-answer { font-size: 0.92rem; color: #374151; margin-bottom: 0.5rem; }

/* ── check-label (admin test creation) ── */
/* ── Table builder (admin) ── */
/* ── Graph / Table top section ── */
.graph-table-toggle-row,
.question-form .graph-table-toggle-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  align-self: flex-start;
  gap: 0.5rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.graph-table-toggle-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.graph-table-panel {
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 0.9rem 1rem;
  background: #f8faff;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.graph-table-panel .field-hint {
  margin-top: 0.2rem;
}

.tbl-builder-wrap { margin-bottom: 0.5rem; }

.tbl-toggle-btn {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.75rem;
  background: #f1f5f9;
  color: #374151;
  border: 1px solid #cbd5e1;
  border-radius: 5px;
  font-size: 0.85rem;
  font-family: inherit;
  line-height: 1.4;
  cursor: pointer;
}
.tbl-toggle-btn:hover { background: #e2e8f0; }

.tbl-builder-panel {
  margin-top: 0.5rem;
  padding: 0.85rem 1rem;
  background: #f8f9fb;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
}

.tbl-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 0.75rem;
  font-size: 0.88rem;
}

.tbl-num {
  width: 56px;
  padding: 0.3rem 0.4rem;
  border: 1px solid #d1d5db;
  border-radius: 5px;
  font-size: 0.88rem;
  margin-left: 0.3rem;
}

.tbl-check {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  cursor: pointer;
}

.tbl-gen-btn {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.75rem;
  background: #3fa8e8;
  color: #fff;
  border: none;
  border-radius: 5px;
  font-size: 0.85rem;
  font-family: inherit;
  line-height: 1.4;
  cursor: pointer;
}
.tbl-gen-btn:hover { background: #2d9ad8; }

.tbl-grid { overflow-x: auto; }

.tbl-preview {
  border-collapse: collapse;
  margin-bottom: 0.75rem;
}
.tbl-preview td {
  border: 1px solid #d1d5db;
  padding: 0.2rem;
}
.tbl-cell {
  width: 110px;
  padding: 0.35rem 0.5rem;
  border: none;
  font-size: 0.88rem;
  background: #fff;
  outline: none;
}
.tbl-cell:focus { background: #eff6ff; }

.tbl-apply-btn {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.75rem;
  background: #79cb79;
  color: #fff;
  border: none;
  border-radius: 5px;
  font-size: 0.85rem;
  font-family: inherit;
  line-height: 1.4;
  cursor: pointer;
}
.tbl-apply-btn:hover { background: #5fb85f; }

/* Preview in question card (admin list) */
.admin-stem-preview .q-table {
  border-collapse: collapse;
  font-size: 0.88rem;
  margin: 0.4rem auto;
}
.admin-stem-preview .q-table th,
.admin-stem-preview .q-table td {
  border: 1px solid #6b7280;
  padding: 0.3rem 0.6rem;
  text-align: center;
}
.admin-stem-preview .q-table thead th { background: #f3f4f6; font-weight: 700; }

/* ── check-label (admin test creation) ── */
.check-label {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.88rem;
  white-space: nowrap;
  cursor: pointer;
  align-self: center;
}

/* ── Difficulty & category badges (shared: admin + exam + practice) ── */
.q-diff-badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}
.diff-easy   { background: #dcfce7; color: #166534; }
.diff-medium { background: #fef9c3; color: #854d0e; }
.diff-hard   { background: #fee2e2; color: #991b1b; }

.q-cat-badge {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
  background: #e0e7ff;
  color: #3730a3;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.q-meta-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-bottom: 0.6rem;
}

/* ── Dashboard sections ── */
.dashboard-section { margin-bottom: 2.5rem; }

.dashboard-section-header {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 1rem;
}

/* ── Practice CTA card ── */
.practice-cta-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  padding: 1.1rem 1.4rem;
}

.practice-cta-title { font-weight: 600; font-size: 1rem; margin-bottom: 0.2rem; }
.practice-cta-desc  { font-size: 0.85rem; color: #374151; }
.practice-cta-btn   { white-space: nowrap; flex-shrink: 0; }

/* ── Practice filter form ── */
.practice-filter-form { max-width: 680px; }

.filter-section {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 1.1rem 1.25rem;
  margin-bottom: 1.1rem;
}

.filter-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}
.filter-header h3 { font-size: 0.95rem; }

.filter-actions { display: flex; align-items: center; gap: 0.3rem; }
.filter-link {
  background: none;
  border: none;
  font-size: 0.82rem;
  color: #3fa8e8;
  cursor: pointer;
  padding: 0;
}
.filter-link:hover { text-decoration: underline; }
.filter-sep { color: #d1d5db; font-size: 0.82rem; }

.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.4rem;
}

.cat-check {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.88rem;
  cursor: pointer;
  padding: 0.25rem 0.3rem;
  border-radius: 5px;
}
.cat-check:hover { background: #f8f9fb; }

.diff-checks {
  display: flex;
  gap: 1rem;
}

.diff-check {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
}

.practice-start-btn {
  padding: 0.65rem 2rem;
  background: #3fa8e8;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}
.practice-start-btn:hover { background: #2d9ad8; }

/* ── two-col-fields (admin question forms) ── */
.two-col-fields {
  display: grid;
  grid-template-columns: 1fr 160px;
  gap: 0.75rem;
  align-items: start;
}

/* ── three-col-fields (position + category + difficulty) ── */
.three-col-fields {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.75rem;
  align-items: start;
}

/* ── Dashboard test cards ── */
.test-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  margin-top: 0.5rem;
}

.test-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.test-card-title { font-weight: 600; font-size: 1rem; }
.test-card-meta  { font-size: 0.82rem; color: #6b7280; }
.test-card-prev  { font-size: 0.85rem; color: #374151; }

.test-card-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.45rem 1rem;
  background: #3fa8e8;
  color: #fff;
  border-radius: 6px;
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  font-family: inherit;
  line-height: 1.4;
  border: none;
  cursor: pointer;
  box-sizing: border-box;
  white-space: nowrap;
}
.test-card-btn:hover   { background: #2d9ad8; }
.test-card-btn.disabled {
  background: #e5e7eb;
  color: #9ca3af;
  cursor: default;
}

/* ── Results page ── */
.score-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 1.5rem 2rem;
  margin-bottom: 2rem;
  text-align: center;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.score-big {
  font-size: 3rem;
  font-weight: 800;
  color: #1a1a1a;
  line-height: 1;
}
.score-total { font-size: 1.8rem; color: #6b7280; }
.score-pct   { font-size: 1.1rem; color: #374151; margin: 0.4rem 0 0.9rem; }

.score-bar-wrap {
  height: 10px;
  background: #e5e7eb;
  border-radius: 999px;
  overflow: hidden;
  max-width: 400px;
  margin: 0 auto;
}
.score-bar-fill {
  height: 100%;
  background: #3fa8e8;
  border-radius: 999px;
  transition: width 0.6s ease;
}

.result-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  margin-bottom: 0.5rem;
  overflow: hidden;
}
.result-card summary { list-style: none; }
.result-card summary::-webkit-details-marker { display: none; }
.result-correct { border-left: 4px solid #16a34a; }
.result-wrong   { border-left: 4px solid #dc2626; }
.result-blank   { border-left: 4px solid #d97706; }

.result-card-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.25rem;
  cursor: pointer;
  user-select: none;
}
.result-card-header:hover { background: #f8fafc; }
.result-time-spent {
  font-size: 0.78rem;
  color: #6b7280;
  margin-left: auto;
}
.result-expand-hint {
  font-size: 0.78rem;
  color: #94a3b8;
}
.result-expand-hint::after { content: '▸ Show'; }
details[open] .result-expand-hint::after { content: '▾ Hide'; }

.result-card-body {
  padding: 0 1.25rem 1.1rem;
  border-top: 1px solid #f1f5f9;
  padding-top: 0.9rem;
}

.result-q-num {
  font-weight: 700;
  font-size: 0.9rem;
  background: #f1f5f9;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
}
.result-verdict {
  font-weight: 600;
  font-size: 0.88rem;
}
.result-correct .result-verdict { color: #16a34a; }
.result-wrong   .result-verdict { color: #dc2626; }
.result-blank   .result-verdict { color: #d97706; }

.result-title {
  text-align: center;
  font-weight: 700;
  margin-bottom: 0.4rem;
}

.result-time-block {
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  overflow: hidden;
  margin-top: 0.6rem;
  font-size: 0.85rem;
}
.result-time-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.35rem 0.75rem;
  border-bottom: 1px solid #f1f5f9;
}
.result-time-row:last-child { border-bottom: none; }
.result-time-row:first-child {
  background: #f8fafc;
  font-weight: 600;
}
.result-time-visit { color: #6b7280; }
.result-time-label { flex: 1; }
.result-time-val {
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  color: #374151;
}

.serif-text {
  font-family: 'Droid Serif', Georgia, serif;
}

.result-image {
  display: block;
  max-width: 100%;
  max-height: 260px;
  object-fit: contain;
  border-radius: 6px;
  margin: 0 auto 0.75rem;
  border: 1px solid #e2e8f0;
}

.result-stem {
  font-size: 0.95rem;
  line-height: 1.6;
  margin-bottom: 0.75rem;
  white-space: pre-wrap;
}

/* Tables inside result stems */
.result-stem .q-table {
  border-collapse: collapse;
  margin: 0.75rem auto 1rem;
  font-family: 'Droid Serif', Georgia, serif;
  font-size: 0.95rem;
  width: auto;
}
.result-stem .q-table th,
.result-stem .q-table td {
  border: 1px solid #6b7280;
  padding: 0.45rem 0.85rem;
  text-align: center;
  white-space: nowrap;
}
.result-stem .q-table thead th {
  background: #f3f4f6;
  font-weight: 700;
}
.result-stem .q-table tbody tr:nth-child(even) td {
  background: #fafafa;
}

.result-answer-row { font-size: 0.92rem; margin-bottom: 0.5rem; }
.correct-val { color: #16a34a; }

.result-choices {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.6rem;
}
.result-choice {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 0.7rem;
  border-radius: 6px;
  font-size: 0.9rem;
  border: 1px solid #e5e7eb;
}
.rc-correct   { background: #dcfce7; border-color: #16a34a; }
.rc-wrong     { background: #fee2e2; border-color: #dc2626; }
.rc-letter    { font-weight: 700; min-width: 1.2rem; }
.rc-text      { flex: 1; }
.rc-tag       { font-size: 0.75rem; font-weight: 600; color: #16a34a; }
.rc-wrong-tag { color: #dc2626; }

.result-explanation {
  font-size: 0.87rem;
  color: #4b5563;
  background: #f8f9fb;
  border-radius: 6px;
  padding: 0.6rem 0.8rem;
  margin-top: 0.4rem;
  border: 1px solid #e5e7eb;
}

/* ── Question images ── */
.q-image {
  display: block;
  max-width: 100%;
  max-height: 340px;
  object-fit: contain;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  margin: 0 auto 0.75rem;
  background: #f8f9fb;
}

.current-image {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
}

.remove-check {
  flex-direction: row !important;
  align-items: center;
  gap: 0.4rem !important;
  font-weight: normal !important;
  font-size: 0.88rem;
  color: #dc2626;
  cursor: pointer;
}

.remove-check input { width: auto; }

.field-hint {
  font-size: 0.82rem;
  color: #888;
  font-weight: normal;
  margin-top: 0.2rem;
}

.field-hint a { color: #2d6a87; text-decoration: underline; }
.field-hint a:hover { color: #1e4f66; }

/* ── Multi-select dropdown (shared: mistakes + admin forms) ── */
.ms-wrap { position: relative; display: inline-block; }
.ms-btn {
  display: flex; align-items: center; gap: 0.4rem;
  padding: 0.35rem 0.65rem;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #fff;
  font-size: 0.83rem;
  color: #374151;
  cursor: pointer;
  white-space: nowrap;
  width: 9rem; min-width: 9rem; max-width: 9rem;
  justify-content: space-between; overflow: hidden;
  font-family: inherit;
}
.ms-btn .ms-label {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0;
}
.ms-btn:hover { border-color: #9ca3af; }
.ms-btn .ms-arrow { height: 0.35rem; width: auto; flex-shrink: 0; display: block; }
.ms-btn.has-value { border-color: #2d6a87; color: #2d6a87; background: #eff6ff; }
.ms-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 100%;
  background: #fff;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  z-index: 100;
  padding: 0.4rem 0;
  max-height: 240px;
  overflow-y: auto;
}
.ms-dropdown.open { display: block; }

.ms-option,
.question-form .ms-option {
  display: flex; flex-direction: row; align-items: flex-start; gap: 0.5rem;
  padding: 0.45rem 0.8rem;
  font-size: 0.83rem;
  font-weight: normal;
  cursor: pointer;
  color: #374151;
}
.ms-option:hover { background: #f8fafc; }
.ms-option input[type=checkbox] {
  accent-color: #4a90c4; cursor: pointer; width: auto;
  flex-shrink: 0; margin-top: 0.15rem;
}
.ms-option span { flex: 1; min-width: 0; }
.ms-option.checked { color: #1e293b; font-weight: 500; }

/* ── Group card (dashboard) ── */
.group-card { border-left: 3px solid #3fa8e8; }

.group-subtitle {
  font-size: 0.88rem;
  color: #6b7280;
  margin-bottom: 1.25rem;
}

/* ── Module list (test_group page) ── */
.module-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.module-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 1rem 1.25rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.module-num {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #3fa8e8;
  color: #fff;
  font-weight: 700;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.module-info { flex: 1; display: flex; flex-direction: column; gap: 0.3rem; }

.module-title { font-weight: 600; font-size: 1rem; }

.module-meta {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.82rem;
  color: #6b7280;
}

.module-score {
  font-size: 0.85rem;
  color: #374151;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.module-pct { color: #6b7280; }

.module-bar-wrap {
  height: 6px;
  width: 120px;
  background: #e5e7eb;
  border-radius: 999px;
  overflow: hidden;
}
.module-bar-fill {
  height: 100%;
  background: #3fa8e8;
  border-radius: 999px;
}

.module-action {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.5rem;
  flex-shrink: 0;
}

.btn-review-link {
  font-size: 0.78rem;
  color: #3fa8e8;
  text-decoration: underline;
  text-align: right;
}

/* ── Admin: inline rename form ── */
.module-title-view { display: inline-flex; align-items: center; gap: 0.5rem; }

.btn-rename-toggle {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  background: #f1f5f9;
  color: #374151;
  border: 1px solid #cbd5e1;
  border-radius: 5px;
  font-size: 0.8rem;
  font-family: inherit;
  line-height: 1.4;
  cursor: pointer;
}
.btn-rename-toggle:hover { background: #e2e8f0; }

.rename-form {
  align-items: center;
  gap: 0.35rem;
}

.rename-input {
  padding: 0.3rem 0.5rem;
  border: 1px solid #3fa8e8;
  border-radius: 5px;
  font-size: 0.9rem;
  min-width: 200px;
}

.btn-rename-cancel {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.75rem;
  background: #f1f5f9;
  color: #374151;
  border: 1px solid #cbd5e1;
  border-radius: 5px;
  font-size: 0.85rem;
  font-family: inherit;
  line-height: 1.4;
  cursor: pointer;
}
.btn-rename-cancel:hover { background: #e2e8f0; }

/* ── Admin: set-group inline form ── */
.set-group-form {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.set-group-form select {
  border-color: #d1d5db;
  max-width: 160px;
}

.pos-input {
  width: 42px;
  padding: 0.3rem 0.35rem;
  border: 1px solid #d1d5db;
  border-radius: 5px;
  font-size: 0.82rem;
  text-align: center;
}

.btn-set {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.75rem;
  background: #3fa8e8;
  color: #fff;
  border: none;
  border-radius: 5px;
  font-size: 0.85rem;
  font-family: inherit;
  line-height: 1.4;
  cursor: pointer;
  white-space: nowrap;
}
.btn-set:hover { background: #2d9ad8; }

/* ── Module type badge + select (admin) ── */
.module-badge {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
}
.badge-math    { background: #dbeafe; color: #1e40af; }
.badge-english { background: #f3e8ff; color: #7e22ce; }

.module-type-select {
  border-color: #d1d5db;
  align-self: center;
}

/* ── Score matrix (admin scores page) ── */
.score-matrix th { white-space: nowrap; }

.score-cell {
  text-align: center;
  vertical-align: middle;
}

.score-cell-taken { background: #eaf4fc; }
.score-cell-empty { background: #fafafa; }

.score-link {
  display: block;
  text-decoration: none;
  color: #2d6a87;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.25rem 0;
}
.score-link:hover { text-decoration: underline; }

.score-pct-small {
  display: block;
  font-size: 0.75rem;
  font-weight: 400;
  color: #6b7280;
}

.avg-row td {
  background: #dbeef8;
  border-top: 2px solid #a8d4ed;
  font-size: 0.9rem;
  font-weight: 600;
  color: #2d6a87;
  text-align: center;
}

/* ── Rich-text editor (question stem) ── */
.rte-wrap {
  border: 1px solid #d1d5db;
  border-radius: 6px;
  overflow: hidden;
  background: #fff;
}

.rte-toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0.35rem 0.5rem;
  background: #f8f9fb;
  border-bottom: 1px solid #e2e8f0;
  flex-wrap: wrap;
}

.rte-toolbar button {
  min-width: 30px;
  height: 28px;
  padding: 0 0.45rem;
  background: #fff;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  font-size: 0.88rem;
  cursor: pointer;
  color: #374151;
  line-height: 1;
}
.rte-toolbar button:hover   { background: #e2e8f0; }
.rte-toolbar button.rte-active {
  background: #dbeafe;
  border-color: #3fa8e8;
  color: #3fa8e8;
}

.rte-divider {
  width: 1px;
  height: 20px;
  background: #d1d5db;
  margin: 0 0.25rem;
  flex-shrink: 0;
}

.rte-editor {
  min-height: 90px;
  padding: 0.55rem 0.75rem;
  font-size: 0.95rem;
  font-family: "Droid Serif", Georgia, serif;
  line-height: 1.6;
  outline: none;
  white-space: pre-wrap;
}

/* Placeholder when editor is empty */
.rte-editor:empty::before {
  content: attr(data-placeholder);
  color: #9ca3af;
  pointer-events: none;
}

/* Indented block (from execCommand indent) */
.rte-editor blockquote {
  margin: 0.3rem 0 0.3rem 2rem;
  padding: 0;
  border: none;
  font-style: normal;
}

/* ── Flash messages ── */
.flash-messages { position: fixed; top: 1rem; left: 50%; transform: translateX(-50%); z-index: 999; }
.sp-flash-error {
  color: #b91c1c;
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}
.flash {
  background: #fef3c7;
  border: 1px solid #f59e0b;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  margin-bottom: 0.5rem;
}

/* ── Resume / Start Fresh button ─────────────────────────────────────────── */
.btn-secondary {
  background: #fff;
  border: 1.5px solid #d1d5db;
  color: #374151;
  cursor: pointer;
  font-family: inherit;
}
.btn-secondary:hover { background: #f3f4f6; }

/* ── Full-test button ──────────────────────────────────────────────────────── */
/* ── Resume / Start Fresh button group ────────────────────────────────────── */
.resume-group {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.3rem;
}
.resume-btn-row {
  display: flex;
  gap: 0.5rem;
}
.resume-btn-row form {
  display: flex;
}
.resume-time-left {
  font-size: 0.78rem;
  color: #6b7280;
}

/* ── Full-test button ──────────────────────────────────────────────────────── */
.btn-full-test {
  background: #79cb79;
  white-space: nowrap;
}
.btn-full-test:hover { background: #5fb85f; }

.group-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}
.full-test-resume-group {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.group-module-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.group-module-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.group-module-pos {
  font-size: 0.82rem;
  color: #6b7280;
  min-width: 1rem;
}
.copy-q-select {
  border-color: #d1d5db;
}

.manage-mods-heading {
  font-size: 0.78rem;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.35rem;
}
.manage-mod-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding: 0.3rem 0;
  border-bottom: 1px solid #f1f5f9;
}
.manage-mod-row:last-of-type { border-bottom: none; }

/* ── Break timer page ──────────────────────────────────────────────────────── */
.break-card {
  max-width: 480px;
  margin: 4rem auto;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 2.5rem 2rem;
  text-align: center;
  box-shadow: 0 2px 12px rgba(0,0,0,0.07);
}
.break-icon { font-size: 3rem; margin-bottom: 0.5rem; }
.break-heading { font-size: 1.6rem; font-weight: 700; margin: 0 0 0.5rem; }
.break-sub { color: #6b7280; font-size: 0.95rem; margin-bottom: 2rem; }
.break-timer-display {
  font-size: 4rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #3fa8e8;
  line-height: 1;
  margin-bottom: 0.25rem;
}
.break-timer-label { color: #6b7280; font-size: 0.85rem; margin-bottom: 2rem; }
.break-skip-link {
  display: block;
  margin-top: 1.25rem;
  font-size: 0.85rem;
  color: #6b7280;
  text-decoration: underline;
  cursor: pointer;
}
.break-skip-link:hover { color: #374151; }

/* ── Results: highlight mark colours (mirrors exam.css) ──────────────────── */
.result-stem-hl mark.hl-mark          { background: #fef08a; border-radius: 2px; padding: 0 1px; }
.result-stem-hl mark.hl-blue          { background: #bfdbfe; }
.result-stem-hl mark.hl-pink          { background: #fbcfe8; }
.result-stem-hl mark.hl-ul-solid      { text-decoration: underline solid; }
.result-stem-hl mark.hl-ul-dashed     { text-decoration: underline dashed; }
.result-stem-hl mark.hl-ul-dotted     { text-decoration: underline dotted; }

/* ── Results: student note cards ─────────────────────────────────────────── */
.result-note {
  margin-top: 0.75rem;
  padding: 0.6rem 0.85rem;
  border-radius: 6px;
  font-size: 0.9rem;
}
.result-note-math { background: #fffbeb; border: 1px solid #fde68a; }
.result-note-hl   { background: #f0fdf4; border: 1px solid #bbf7d0; }
.result-note-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6b7280;
  margin-bottom: 0.3rem;
}
.result-note p { margin: 0.2rem 0 0; color: #1a1a1a; }

/* ── Results: highlight note pairs ──────────────────────────────────────── */
.result-hl-pair {
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid #d1fae5;
}
.result-hl-pair:first-of-type { border-top: none; margin-top: 0.25rem; }
.result-hl-snippet {
  display: block;
  font-style: italic;
  color: #065f46;
  font-size: 0.88rem;
  margin-bottom: 0.2rem;
}
.result-hl-pair p { margin: 0; }
