/* app.css — Exam Editor UI, restyled to the MCQ-generator wireframe
   prototypes: fixed sidebar, topbar, white bordered panels, dark primary
   buttons, outlined pill badges, stat cards, exam-sheet paper preview. */

[hidden] { display: none !important; }

* { box-sizing: border-box; }

:root {
  --bg: #f5f6f8;
  --ink: #20252b;
  --muted: #6b7280;
  --border: #ddd;
  --border-soft: #eee;
  --panel: #ffffff;
  --dark: #15181c;
  --radius: 8px;
  --sidebar-w: 240px;
  --topbar-h: 70px;
}

body {
  margin: 0;
  font: 14px Arial, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

a { color: var(--ink); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 23px; margin: 0 0 5px; }
h2 { font-size: 17px; margin: 1.1rem 0 0.6rem; }
h3 { font-size: 15px; margin: 0 0 0.5rem; }

/* =========================
   APP SHELL
========================= */

.app { min-height: 100vh; }

/* ---- sidebar ---- */

.sidebar {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  width: 240px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 40;
}

.logo {
  min-height: 70px;
  padding: 10px 20px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  border-bottom: 1px solid var(--border-soft);
  font-weight: bold;
  font-size: 15px;
  letter-spacing: 0.04em;
}
.logo a { color: var(--ink); }
.logo span { font-size: 11px; color: #888; font-weight: normal; margin-top: 2px; }

.side-nav { padding: 14px; flex: 1; overflow-y: auto; }

.side-nav a {
  display: block;
  padding: 11px 14px;
  margin: 2px 0;
  border-radius: 7px;
  color: #555;
  font-size: 14px;
}
.side-nav a:hover { background: var(--border-soft); color: #111; text-decoration: none; }
.side-nav a.active { background: var(--border-soft); color: #111; font-weight: bold; }

.userbox {
  border-top: 1px solid var(--border-soft);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.user-name { font-weight: bold; }
.user-role { display: flex; }

/* ---- main column ---- */

.main {
  margin-left: 240px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.app.no-nav .main { margin-left: 0; }
.app.no-nav .sidebar { display: none; }
.app.no-nav .nav-toggle { display: none; }

/* ---- topbar ---- */

.topbar {
  height: 70px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 28px;
}

.pagetitle { font-size: 16px; }

.nav-toggle {
  display: none;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 7px;
  padding: 6px 10px;
  font: inherit;
  cursor: pointer;
}

/* ---- content ---- */

.content {
  padding: 28px;
  max-width: 1500px;
  width: 100%;
  margin: 0 auto;
  flex: 1;
}

.page-head { margin-bottom: 20px; }
.page-head .btn { margin-bottom: 12px; }

.section-title { margin-top: 1.2rem; }
.content .section-title:first-child { margin-top: 0; }

.muted { color: var(--muted); }
.small { font-size: 12px; }

/* =========================
   CARDS & GRIDS
========================= */

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 18px;
}

.form-card { max-width: 560px; }

.grid-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 16px;
}

.stat-card { display: block; color: inherit; }
.stat-card:hover { text-decoration: none; border-color: #bbb; }

.stat-value { font-size: 28px; font-weight: bold; margin-top: 8px; }
.stat-label { font-weight: bold; }
.stat-hint { color: var(--muted); font-size: 12px; margin-top: 2px; }

.grid-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 16px;
}

.action-card { display: block; color: inherit; }
.action-card:hover { text-decoration: none; border-color: #bbb; }
.action-title { font-weight: bold; margin-bottom: 6px; }
.action-text { color: var(--muted); font-size: 13px; }

.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-top: 16px;
  align-items: start;
}

/* =========================
   TABLES
========================= */

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

.table th, .table td {
  text-align: left;
  padding: 12px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: top;
  font-size: 14px;
}

.table th {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  background: #fafafa;
  border-bottom: 1px solid var(--border);
}

.table tr:last-child td { border-bottom: none; }

.row-title { font-weight: bold; }
.cell-preview { max-width: 480px; }
.cell-actions { white-space: nowrap; text-align: right; }
.cell-actions .btn { margin-left: 6px; }

/* =========================
   BUTTONS
========================= */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid #d4d7db;
  background: #fff;
  color: var(--ink);
  padding: 10px 15px;
  border-radius: 7px;
  font: inherit;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: #f2f2f2; text-decoration: none; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--dark);
  border-color: var(--dark);
  color: #fff;
}
.btn-primary:hover { background: #000; }

.btn-danger { color: #b42318; }
.btn-danger:hover { background: #fef2f1; }

.btn-ghost { border-color: #d4d7db; background: #fff; }
.btn-ghost:hover { background: #f2f2f2; }

.btn-sm { padding: 6px 10px; font-size: 13px; }
.btn-block { width: 100%; justify-content: center; }

/* =========================
   BADGES
========================= */

.badge {
  display: inline-block;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 9px;
  font-size: 11px;
  background: #fff;
}

.badge-admin { background: var(--dark); border-color: var(--dark); color: #fff; }
.badge-faculty { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.badge-mine { background: #eff6ff; border-color: #bfdbfe; color: #1d4ed8; }
.badge-correct { background: #f0fdf4; border-color: #bbf7d0; color: #166534; font-weight: bold; }

.badge-diff-easy { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.badge-diff-medium { background: #fefce8; border-color: #fde68a; color: #92400e; }
.badge-diff-hard { background: #fef2f1; border-color: #fecaca; color: #b42318; }

.badge-status-draft { background: #f8f9fa; border-color: #e0e3e8; color: #555; }
.badge-status-published { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.badge-status-archived { background: #f8f9fa; border-color: #e0e3e8; color: #888; }

.ready {
  display: inline-block;
  padding: 5px 10px;
  border-radius: 20px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #166534;
  font-size: 11px;
}

/* =========================
   FORMS
========================= */

input, select, textarea {
  font: inherit;
  padding: 10px;
  border: 1px solid #d2d5da;
  border-radius: 6px;
  background: #fff;
  width: 100%;
}

input[type="checkbox"], input[type="radio"], input[type="file"] { width: auto; }
input:focus, select:focus, textarea:focus { outline: 2px solid #c7cdd6; }

.field { display: block; margin-bottom: 15px; }
.field-label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  color: #777;
  margin-bottom: 6px;
}
.field-hint { display: block; font-size: 11px; color: #888; margin-top: 5px; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}

.form-row { display: flex; gap: 14px; }
.form-row .field { flex: 1; }

.form-actions { display: flex; gap: 10px; margin-top: 4px; }
.form-section { margin-bottom: 16px; }

/* =========================
   PANEL HEADERS
========================= */

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding-bottom: 10px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--border-soft);
  font-weight: bold;
}

.panel-head .btn { flex-shrink: 0; }

/* =========================
   QUESTION FORM LAYOUT
========================= */

.question-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 18px;
  align-items: start;
}

.qmain { min-width: 0; }

.rail { display: flex; flex-direction: column; gap: 16px; }

.rail .btn-block + .btn-block { margin-top: 10px; }

.checklist { list-style: none; margin: 0; padding: 0; }
.checklist li { padding: 4px 0; font-size: 13px; }
.checklist li.ok { color: #166534; }
.checklist li.bad { color: #b42318; }

/* ---- question form page head (wireframe: title + status + actions) ---- */

.qf-page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}
.qf-page-head .btn { margin-bottom: 0; }
.qf-page-head-main h1 { margin-top: 8px; }
.qf-sub { margin-top: 3px; }

.qf-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.panel-hint { font-size: 12px; font-weight: normal; }

.qf-code { font-weight: bold; margin: 2px 0 10px; }
.rail .card p { margin: 4px 0; }

.solution-body[hidden] { display: none; }

/* =========================
   EQUATION PALETTE MODAL
   (Math / Physics / Chemistry symbol & formula categories)
========================= */

.eq-modal-preview {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  margin-bottom: 12px;
  background: #fafafa;
  border: 1px dashed #d5d7da;
  border-radius: 6px;
  overflow-x: auto;
}

.eq-modal-input {
  font-family: Consolas, Menlo, "Courier New", monospace;
  font-size: 13px;
  resize: vertical;
}

.eq-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 10px; }

.eq-tab {
  padding: 6px 11px;
  font-size: 12px;
  font-family: inherit;
  border: 1px solid var(--border);
  background: #f7f7f7;
  border-radius: 6px;
  cursor: pointer;
}
.eq-tab:hover { background: #ececee; }
.eq-tab.active { background: var(--dark); color: #fff; border-color: var(--dark); }

.eq-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 300px;
  overflow-y: auto;
  padding: 2px;
}

.eq-item {
  min-width: 42px;
  min-height: 38px;
  padding: 4px 9px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 6px;
  cursor: pointer;
  font: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.eq-item:hover { background: #eef4ff; border-color: #93b4f0; }
.eq-item:active { transform: scale(0.96); }
.eq-item .katex { font-size: 0.95em; }
.eq-item-txt { font-size: 12px; }

.eq-hint { margin: 10px 0 0; }

/* =========================
   CONTENT BLOCKS
   (wireframe-style: "☰ Text Block" toolbar, centred add-row)
========================= */

.block-editor { display: flex; flex-direction: column; gap: 10px; }
.block-editor:focus { outline: none; }
.block-empty { padding: 6px 2px; }

.content-block {
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #fff;
  overflow: hidden;
}
.content-block:focus-within { border-color: #b9c2cc; }

.block-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-bottom: 1px solid var(--border-soft);
  background: #fafafa;
  border-radius: 7px 7px 0 0;
  font-size: 12px;
  color: #777;
}

.block-grip { color: #9aa0a6; font-size: 13px; }
.block-type { width: auto; font-size: 13px; padding: 5px 8px; }
.block-tools { margin-left: auto; display: flex; gap: 4px; }
.block-tool { padding: 3px 9px; line-height: 1.3; font-size: 13px; }

.block-body { padding: 10px; }

.qf-text-editor {
  border: none;
  border-radius: 0 0 7px 7px;
  padding: 12px 14px;
  min-height: 85px;
  line-height: 1.6;
  resize: vertical;
  background: #fff;
}
.qf-text-editor:focus { outline: none; }

/* equation blocks: inline LaTeX input + palette button + live preview */
.eq-field { padding: 10px; }
.eq-input-row { display: flex; gap: 8px; align-items: center; }
.eq-input-row .eq-inline-input {
  flex: 1;
  min-width: 0;
  font-family: Consolas, Menlo, "Courier New", monospace;
  font-size: 13px;
}
.eq-input-row .btn { flex-shrink: 0; }

.block-add {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--border-soft);
  flex-wrap: wrap;
  justify-content: center;
}

.latex-preview {
  margin: 10px 0 0;
  padding: 10px;
  background: #fafafa;
  border: 1px dashed #d5d7da;
  border-radius: 6px;
  overflow-x: auto;
  min-height: 34px;
}

.latex-raw { font-family: monospace; color: #b42318; }

/* image blocks: dashed placeholder until uploaded, then the real preview */
.imagebox { text-align: center; }
.imagebox-placeholder {
  height: 130px;
  background: #f1f2f4;
  border: 1px dashed #c9cdd3;
  border-radius: 6px;
  display: grid;
  place-items: center;
  color: #98a0a8;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.imagebox-preview {
  display: block;
  max-width: 100%;
  max-height: 260px;
  margin: 0 auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
}
.imagebox-status { margin-top: 8px; }
.imagebox-actions {
  margin-top: 8px;
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}

.content-image { max-width: 100%; }
.content-image-thumb { max-height: 120px; border: 1px solid var(--border); border-radius: 6px; }

.error-text { color: #b42318; font-size: 12px; }

/* =========================
   OPTIONS EDITOR / VIEWER
========================= */

.options-editor { display: flex; flex-direction: column; gap: 10px; }

/* form row: [A letter box] [block editor] [correct-answer radio] */
.option-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 44px;
  gap: 10px;
  align-items: start;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 10px;
  background: #fff;
}
.option-row.option-correct { border-color: #bbf7d0; background: #f0fdf4; }

.correct-pick {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding-top: 7px;
  font-size: 10px;
  color: #777;
  cursor: pointer;
  text-align: center;
}
.correct-pick input { cursor: pointer; accent-color: #14532d; }

.option-label {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fafafa;
  font-weight: bold;
}
.option-row.option-correct .option-label {
  border-color: #bbf7d0;
  background: #dcfce7;
  color: #166534;
}

.option-row .block-add { margin-top: 8px; padding-top: 8px; }
.option-row .block-add .btn { padding: 4px 9px; font-size: 12px; }

.option-view {
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 10px;
  margin-bottom: 8px;
}
.paper-options .option-view {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 10px;
  align-items: start;
  margin-bottom: 0;
}
.option-correct { border-color: #bbf7d0; background: #f0fdf4; }

/* =========================
   QUESTION DETAIL
========================= */

.qdetail-content, .qdetail-options, .qdetail-solution { margin: 10px 0; }
.content-text { margin: 4px 0; white-space: pre-wrap; line-height: 1.6; }
.content-equation { padding: 4px 0; }

.detail-actions { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }

.bank-head { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.bank-head-main { min-width: 0; }
.bank-head-actions { display: flex; gap: 8px; align-items: flex-start; flex-wrap: wrap; }

/* =========================
   POOL FILTERS
========================= */

.pool { margin-top: 4px; }

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 12px 14px;
  margin-bottom: 14px;
}

.filters select, .filters input { width: auto; min-width: 150px; }
.filter-check { display: flex; align-items: center; gap: 6px; font-size: 13px; white-space: nowrap; }
.filter-check input { width: auto; }
.pool-search { flex: 1; min-width: 200px; }

.footer-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  position: sticky;
  bottom: 10px;
  background: var(--dark);
  color: #e5e7eb;
  padding: 10px 14px;
  border-radius: 8px;
  margin-top: 14px;
}
.footer-bar input { width: 170px; }

.pagination {
  display: flex;
  gap: 14px;
  align-items: center;
  justify-content: center;
  margin-top: 16px;
}

/* =========================
   PAPER BUILDER (testpapergeneration prototype)
========================= */

.steps {
  display: flex;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.step {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #888;
  font-size: 13px;
}

.step.active { color: #111; font-weight: bold; }

.step-number {
  width: 28px;
  height: 28px;
  border: 1px solid #ccc;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}

.step.active .step-number { background: #111; color: #fff; border-color: #111; }

.step-line { height: 1px; background: var(--border); width: 60px; margin: 0 12px; }

.builder {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 20px;
  align-items: start;
}

.question-list {
  border: 1px solid var(--border);
  border-radius: 7px;
  overflow: hidden;
  background: #fff;
}

.question-row {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  gap: 12px;
  padding: 13px 14px;
  border-bottom: 1px solid var(--border-soft);
  align-items: center;
}
.question-row:last-child { border-bottom: 0; }
.question-row:hover { background: #fafafa; }

.q-num { font-size: 11px; font-weight: bold; color: #777; }

.q-text { min-width: 0; line-height: 1.5; }
.q-text .q-bank { font-size: 11px; color: #777; margin-top: 3px; }

.q-side { display: flex; align-items: center; gap: 8px; }
.q-marks { font-size: 12px; color: #555; white-space: nowrap; }

.icon-btn {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 6px;
  padding: 4px 8px;
  font: inherit;
  cursor: pointer;
}
.icon-btn:hover { background: #f2f2f2; }
.icon-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.summary-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-soft);
}
.summary-row:last-child { border-bottom: 0; }

/* =========================
   EXAM-SHEET PAPER PREVIEW
========================= */

.paper-view {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 30px;
}

.paper-header {
  text-align: center;
  border-bottom: 2px solid #111;
  padding-bottom: 18px;
  margin-bottom: 18px;
}
.paper-header h2 { font-size: 21px; margin: 0 0 6px; }
.paper-header .muted { font-size: 13px; }

.paper-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin: 15px 0;
  flex-wrap: wrap;
  font-weight: bold;
}

.instructions {
  border: 1px solid var(--border);
  padding: 14px;
  margin-bottom: 20px;
}
.instructions ol { margin: 8px 0 0; padding-left: 20px; color: #444; }

.paper-question {
  margin-bottom: 25px;
  border-bottom: 1px solid var(--border-soft);
  padding-bottom: 18px;
}
.paper-question:last-child { border-bottom: 0; }

.paper-question-text { margin-bottom: 10px; line-height: 1.6; }

.paper-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 10px 0;
}
.paper-options .option-view { margin-bottom: 0; }

.paper-solution { margin-top: 10px; }
.paper-solution summary { cursor: pointer; color: var(--muted); font-size: 13px; }

/* =========================
   TOASTS & STATES
========================= */

#toasts {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: #111;
  color: #fff;
  padding: 10px 14px;
  border-radius: 6px;
  max-width: 340px;
  font-size: 13px;
  transition: opacity 0.3s, transform 0.3s;
}
.toast-success { background: #14532d; }
.toast-error { background: #7f1d1d; }
.toast.gone { opacity: 0; transform: translateY(-6px); }

.loading { color: var(--muted); padding: 24px 0; }
.spin {
  display: inline-block;
  width: 13px;
  height: 13px;
  border: 2px solid #bbb;
  border-top-color: transparent;
  border-radius: 50%;
  animation: ee-spin 0.8s linear infinite;
  vertical-align: -2px;
}
@keyframes ee-spin { to { transform: rotate(360deg); } }

.empty {
  text-align: center;
  color: var(--muted);
  padding: 34px 20px;
  background: var(--panel);
  border: 1px dashed #d5d7da;
  border-radius: 9px;
}

.error-box {
  background: #fef2f1;
  color: #b42318;
  border: 1px solid #fecaca;
  border-radius: 7px;
  padding: 10px 13px;
  margin-bottom: 14px;
}

.warn-box {
  background: #fefce8;
  color: #92400e;
  border: 1px solid #fde68a;
  border-radius: 7px;
  padding: 10px 13px;
  margin-bottom: 14px;
}

/* =========================
   MODALS
========================= */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 200;
  overflow-y: auto;
  padding: 40px 16px;
}

.modal {
  background: #fff;
  border-radius: 10px;
  max-width: 520px;
  width: 100%;
  margin: 0 auto;
  overflow: hidden;
}

.modal-wide { max-width: 960px; }

.modal-head {
  padding: 15px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: bold;
}

.modal-body { padding: 18px; }

.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 14px; }

/* =========================
   AUTH (LOGIN) PAGE
========================= */

.app.no-nav .content { display: flex; justify-content: center; }

.auth-wrap {
  width: 100%;
  max-width: 400px;
  padding: 6vh 0 40px;
}

.auth-card { padding: 22px; }
.auth-title { margin: 0 0 4px; }
.auth-sub { margin: 0 0 16px; color: var(--muted); font-size: 13px; }
.auth-switch { font-size: 12px; color: var(--muted); margin-bottom: 0; }

/* =========================
   PRINT (complete-paper view + preview/answer-key modal)
========================= */

/* A4 sheets for every printed view. */
@page { size: A4; margin: 12mm; }

@media print {
  .sidebar, .topbar, .detail-actions, .page-head, .filters, .footer-bar, #toasts, .steps { display: none !important; }
  body { background: #fff; }
  .main { margin-left: 0; }
  .content { padding: 0; }
  .paper-view { border: none; padding: 0; }

  /* Printing the paper preview / answer key modal: the page chrome is
     hidden and the modal becomes a plain A4 flow container. The
     print-modal body class is set in generate.js printNow(). */
  body.print-modal .app { display: none !important; }
  body:not(.print-modal) #modal-root { display: none !important; }
  body.print-modal #modal-root { display: block !important; }
  body.print-modal .modal-overlay {
    position: static;
    display: block;
    background: none;
    padding: 0;
    overflow: visible;
  }
  body.print-modal .modal {
    max-width: none;
    width: 100%;
    margin: 0;
    border: none;
    border-radius: 0;
    box-shadow: none;
    overflow: visible;
  }
  body.print-modal .modal-head,
  body.print-modal .modal-actions { display: none !important; }
  body.print-modal .modal-body { padding: 0; overflow: visible; }

  /* Keep each question (and its images/options) together on one page. */
  .paper-question,
  .option-view,
  .paper-header,
  .instructions { break-inside: avoid; page-break-inside: avoid; }
  .content-image { max-width: 100% !important; max-height: 60mm; }
}

/* =========================
   RESPONSIVE
========================= */

@media (max-width: 1000px) {
  .question-layout, .builder { grid-template-columns: 1fr; }
  .grid2 { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .sidebar { transition: left 0.2s; left: -240px; }
  .sidebar.open { left: 0; box-shadow: 8px 0 25px rgba(0, 0, 0, 0.15); }
  .main { margin-left: 0; }
  .nav-toggle { display: block; }
  .content { padding: 15px; }
  .form-grid { grid-template-columns: 1fr 1fr; }
  .paper-options { grid-template-columns: 1fr; }
  .paper-meta { flex-direction: column; gap: 6px; }
  .topbar { padding: 0 15px; }
}

@media (max-width: 560px) {
  .form-grid { grid-template-columns: 1fr; }
  .question-row { grid-template-columns: 26px 1fr; }
  .q-side { display: none; }
  .option-row { grid-template-columns: 30px minmax(0, 1fr) 38px; padding: 8px; }
  .option-label { width: 28px; height: 28px; font-size: 13px; }
}

/* =========================
   SUBJECTS PAGE
========================= */

.head-split {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}

/* =========================
   GENERATE TEST PAPER (wireframe layout)
========================= */

.head-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.checkbox-row {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 5px 0;
  font-size: 14px;
}

.distribution {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 15px;
}

.distribution-box {
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 14px;
}

.distribution-number {
  font-size: 25px;
  font-weight: bold;
  margin: 6px 0;
}

.selected-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-soft);
  padding: 9px 0;
  font-size: 13px;
}
.selected-item:last-child { border-bottom: 0; }

.remove {
  border: 0;
  background: none;
  color: #999;
  cursor: pointer;
  font: inherit;
  padding: 0 4px;
}
.remove:hover { color: #b42318; }

.q-code { font-size: 11px; font-weight: bold; color: #777; }

.difficulty {
  font-size: 11px;
  padding: 4px 9px;
  border: 1px solid var(--border);
  border-radius: 20px;
  display: inline-block;
  background: #fff;
  white-space: nowrap;
}

@media (max-width: 1000px) {
  .distribution { grid-template-columns: 1fr; }
}
