:root {
  /* Surfaces */
  --bg: #f2f5f9;
  --card: #ffffff;
  --surface-low: #f2f3fd;
  --surface: #ecedf7;

  /* Brand */
  --navy: #1e293b;       /* Accent — sidebar, headings, publish */
  --navy-soft: #334155;
  --ink: #191c23;
  --muted: #64748b;

  --primary: #1a73e8;    /* Action blue */
  --on-primary: #ffffff;
  --primary-tint: #e8f0fe;
  --primary-soft: #d2e3fc;

  --indigo: #6366f1;
  --indigo-tint: #eef2ff;

  /* Lines */
  --line: #e2e8f0;
  --line-soft: #eef1f6;

  /* Tints (kept for back-compat) */
  --accent: var(--navy);
  --accent-tint: var(--primary-tint);

  /* Semantic */
  --success: #10b981;
  --success-tint: #d1fae5;
  --warning: #f59e0b;
  --warning-tint: #fef3c7;
  --danger: #ef4444;
  --danger-tint: #fee2e2;
  --good: var(--success);
  --good-tint: var(--success-tint);
  --warn: var(--warning);
  --warn-tint: var(--warning-tint);

  /* Radii — tightened for a refined authoring-tool feel (was 28/18/12/16) */
  --radius-card: 16px;
  --radius-block: 12px;
  --radius-input: 10px;
  --radius-button: 12px;

  /* Shadows */
  --shadow-card: 0 4px 20px rgba(30,41,59,0.05);
  --shadow-pop: 0 8px 32px rgba(30,41,59,0.12);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "ss01", "cv11";
  font-size: 15px;
  line-height: 1.45;
}
button { font-family: inherit; }
input, textarea { font-family: inherit; }
.app { display: grid; grid-template-columns: 296px 1fr; min-height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar {
  background: #fbfbfd;
  border-right: 1px solid var(--line);
  padding: 22px 18px;
  position: sticky; top: 0; height: 100vh; overflow: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 18px; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 10px;
  background: var(--navy);
  display: grid; place-items: center;
  color: #fff; font-weight: 800; font-size: 13px; letter-spacing: 0.04em;
}
.brand-name { font-weight: 700; letter-spacing: -0.01em; }
.brand-sub { font-size: 11.5px; color: var(--muted); font-weight: 500; }

.side-section { margin-top: 14px; }
.side-label {
  text-transform: uppercase; letter-spacing: 0.09em; font-size: 10.5px;
  color: var(--muted); font-weight: 700; padding: 6px 8px;
}
.side-item {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 8px; border-radius: 9px; color: #334155;
  font-size: 13.5px; font-weight: 500; cursor: pointer;
}
.side-item:hover { background: #f1f3f8; }
.side-item.active { background: var(--accent-tint); color: var(--ink); font-weight: 600; }
.side-item .ico { color: #94a3b8; font-size: 14px; width: 14px; display: inline-block; }

.outline { margin-top: 6px; }
.out-section { padding: 4px 0; }
.out-section-head {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 8px; border-radius: 8px; cursor: pointer;
  font-size: 13px; font-weight: 600; color: var(--ink);
}
.out-section-head:hover { background: #f1f3f8; }
.caret { display: inline-grid; place-items: center; width: 16px; height: 16px; color: #94a3b8; flex: none; }
.caret svg { transition: transform .15s; }
.caret.collapsed svg { transform: rotate(-90deg); }
.out-q-list { list-style: none; padding: 0; margin: 2px 0 6px 22px; border-left: 1px solid var(--line); }
.out-q {
  padding: 5px 10px; font-size: 12.5px; color: #475569;
  border-radius: 6px; cursor: pointer; display: flex; align-items: center; gap: 8px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.out-q:hover { background: #f1f3f8; color: var(--ink); }
.out-q.current { color: var(--ink); font-weight: 600; }
.out-q.current::before {
  content: ""; width: 6px; height: 6px; border-radius: 999px; background: var(--navy);
  margin-left: -3px; flex: none;
}
.out-q-num { color: #94a3b8; font-variant-numeric: tabular-nums; font-weight: 600; min-width: 18px; flex: none; }
.out-q-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.out-sub { padding-left: 26px; font-size: 12px; color: #64748b; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: rgba(246,247,249,0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 14px;
  padding: 12px 32px;
}
.crumbs { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12.5px; }
.crumbs b { color: var(--ink); font-weight: 600; }
.crumbs span.sep { color: #cbd5e1; }
.topbar-spacer { flex: 1; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); background: #fff;
  border-radius: 999px; padding: 6px 12px; font-size: 12.5px; font-weight: 600;
  color: var(--navy);
}
.pill.dot::before {
  content: ""; width: 6px; height: 6px; border-radius: 999px; background: #16a34a;
  box-shadow: 0 0 0 3px rgba(22,163,74,0.15);
}
.btn {
  border: 1px solid var(--line); background: #fff;
  border-radius: 10px; padding: 8px 12px; font-size: 13px; font-weight: 600;
  color: var(--ink); cursor: pointer; display: inline-flex; gap: 6px; align-items: center;
}
.btn:hover { background: #f8fafc; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.primary {
  background: var(--navy); color: #fff; border-color: var(--navy);
  box-shadow: 0 1px 0 rgba(15,23,42,0.2), 0 8px 24px -10px rgba(15,23,42,0.6);
}
.btn.primary:hover { background: #0f172a; }
.avatar-stack { display: flex; }
.avatar {
  width: 26px; height: 26px; border-radius: 999px; background: var(--accent-tint);
  color: var(--navy); font-size: 11px; font-weight: 700;
  display: grid; place-items: center; border: 2px solid #fbfbfd;
  margin-left: -6px;
}
.avatar:first-child { margin-left: 0; }

/* ---------- TopBar V2 ---------- */
.topbar2 {
  position: sticky; top: 0; z-index: 30;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 24px; gap: 16px; min-height: 56px;
  /* overflow stays visible so anchor dropdowns (Modèles, bloquant) can
     spill below the bar. .tb2-left has its own overflow:hidden to keep
     the title from bleeding into the right side. */
}
.tb2-left {
  display: flex; align-items: center; gap: 6px; min-width: 0; flex: 1; overflow: hidden;
}
.tb2-right {
  display: flex; align-items: center; gap: 8px; flex-shrink: 0;
}
.tb2-icon-btn {
  width: 32px; height: 32px; border-radius: 8px;
  border: 1px solid var(--line); background: #fff;
  color: var(--ink); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px; line-height: 1; transition: background .12s, border-color .12s;
  flex-shrink: 0;
}
.tb2-icon-btn:hover { background: #f1f5f9; border-color: #cbd5e1; }
.tb2-divider {
  width: 1px; height: 28px; background: var(--line);
  margin: 0 6px; flex-shrink: 0;
}
.tb2-title-block {
  display: flex; flex-direction: column; gap: 1px; min-width: 0;
}
.tb2-title {
  font-size: 15px; font-weight: 700; color: var(--ink);
  letter-spacing: -0.01em; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.tb2-subject {
  font-size: 11.5px; font-weight: 500; color: var(--muted);
  white-space: nowrap; text-transform: capitalize;
  overflow: hidden; text-overflow: ellipsis;
}
/* stat pills */
.tb2-pill {
  display: inline-flex; align-items: center; gap: 5px;
  border: 1px solid var(--line); background: #fff;
  border-radius: 999px; padding: 5px 11px;
  font-size: 12px; font-weight: 600; color: var(--navy);
  white-space: nowrap;
}
.tb2-pill--green {
  background: #f0fdf4; border-color: #bbf7d0; color: #16a34a;
}
.tb2-pill--red {
  background: #fff1f2; border-color: #fecdd3; color: #e11d48;
}
.tb2-pill--btn {
  cursor: pointer; transition: background .12s;
}
.tb2-pill--btn:hover { filter: brightness(0.96); }
/* dropdown anchor wrappers */
.tb2-blk-anchor, .tb2-tpl-anchor {
  position: relative;
}
/* shared dropdown panel */
.tb2-dropdown {
  position: absolute; top: calc(100% + 8px); right: 0;
  min-width: 240px; background: #fff;
  border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 4px 24px -4px rgba(15,23,42,0.14), 0 1px 4px rgba(15,23,42,0.06);
  padding: 6px; z-index: 200; animation: fadeUp .12s ease;
}
.tb2-dropdown-title {
  font-size: 10.5px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .06em;
  padding: 6px 8px 4px;
}
/* blocking issue rows */
.tb2-blk-panel { min-width: 260px; }
.tb2-blk-item {
  display: flex; align-items: flex-start; gap: 8px;
  font-size: 12.5px; color: var(--ink); font-weight: 500;
  padding: 6px 8px; border-radius: 8px;
}
.tb2-blk-item:hover { background: #fef2f2; }
/* Modèles button */
.tb2-tpl-btn {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--navy); color: #fff;
  border: 1px solid var(--navy); border-radius: 10px;
  padding: 7px 13px; font-size: 13px; font-weight: 600;
  cursor: pointer; white-space: nowrap;
  box-shadow: 0 1px 0 rgba(15,23,42,0.2), 0 6px 16px -8px rgba(15,23,42,0.5);
  transition: background .12s;
}
.tb2-tpl-btn:hover { background: #0f172a; border-color: #0f172a; }
.tb2-save-btn {
  display: inline-flex; align-items: center;
  border: 1px solid var(--line); background: #fff;
  color: var(--navy); border-radius: var(--radius-button);
  padding: 7px 13px; font-size: 13px; font-weight: 600;
  cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s;
}
.tb2-save-btn:hover { background: #f1f5f9; border-color: #cbd5e1; }
.tb2-publish-btn {
  display: inline-flex; align-items: center;
  background: var(--success); border: 1px solid var(--success);
  color: #fff; border-radius: var(--radius-button);
  padding: 7px 14px; font-size: 13px; font-weight: 700;
  cursor: pointer; white-space: nowrap;
  box-shadow: 0 1px 0 rgba(0,0,0,0.12), 0 4px 12px -6px rgba(16,185,129,0.5);
  transition: background .12s, border-color .12s;
}
.tb2-publish-btn:hover { background: #059669; border-color: #059669; }
.tb2-publish-btn--live {
  background: var(--success-tint); border-color: #6ee7b7; color: #065f46;
  box-shadow: none;
}
.tb2-publish-btn--live:hover { background: #a7f3d0; border-color: #34d399; }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Canvas ---------- */
.canvas { padding: 28px 40px 160px; max-width: 1080px; margin: 0 auto; }
.exam-head { padding: 8px 12px 28px; }
.exam-meta { display: flex; gap: 10px; align-items: center; color: var(--muted); font-size: 12.5px; font-weight: 500; margin-bottom: 14px; flex-wrap: wrap; }
.exam-meta .dot-sep { width: 3px; height: 3px; border-radius: 999px; background: #cbd5e1; }
.exam-title-input {
  width: 100%; border: 0; outline: none; background: transparent;
  font-size: 36px; font-weight: 800; letter-spacing: -0.02em;
  color: var(--ink); padding: 0;
}
.exam-sub {
  width: 100%; border: 0; outline: none; background: transparent;
  font-size: 15px; color: var(--muted); margin-top: 6px; padding: 0;
}
.exam-stats { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.stat {
  background: #fff; border: 1px solid var(--line);
  border-radius: 12px; padding: 8px 12px; font-size: 12.5px;
  display: inline-flex; gap: 8px; align-items: center;
}
.stat b { font-weight: 700; color: var(--ink); }
.stat .lbl { color: var(--muted); }

/* ---------- Blocks ---------- */
.blocks { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; position: relative; }

.block {
  position: relative;
  border-radius: var(--radius-block);
  padding: 8px 14px 8px 14px;
  transition: background .12s;
}
.block:hover { background: #fbfbfd; }
.block.focused { background: #f8fafc; }
.block.selected { background: var(--accent-tint); }
.block.dragging { opacity: 0.45; }
.block:hover .handle,
.block:hover .add-btn,
.block.focused .handle,
.block.focused .add-btn,
.block:focus-within .right-tools,
.block.focused .right-tools,
.block:hover .right-tools { opacity: 1; }

.handle {
  position: absolute; left: -28px; top: 11px;
  width: 22px; height: 22px; border-radius: 6px;
  display: grid; place-items: center;
  color: #94a3b8; cursor: grab; opacity: 0; transition: opacity .12s, background .12s, color .12s;
  background: transparent; border: 0; padding: 0;
}
.handle:hover { background: #eef2f7; color: var(--navy); }
.handle:active { cursor: grabbing; }
.handle.menu-open { opacity: 1; background: #e8edf5; color: var(--navy); }

/* ---------- Handle popover menu ---------- */
.handle-menu {
  position: fixed; z-index: 150;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 4px;
  box-shadow: 0 8px 24px rgba(15,23,42,0.12), 0 2px 6px rgba(15,23,42,0.06);
  min-width: 160px;
  animation: hm-pop 0.12s ease-out;
}
@keyframes hm-pop {
  from { opacity: 0; transform: scale(0.95) translateY(-4px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.hm-item {
  display: flex; align-items: center; gap: 9px;
  width: 100%; padding: 7px 10px; border: none; background: none;
  border-radius: 7px; cursor: pointer; font: inherit; font-size: 13px;
  font-weight: 500; color: var(--ink); text-align: left;
  transition: background 0.1s;
}
.hm-item:hover { background: #f1f5f9; }
.hm-item.danger { color: #dc2626; }
.hm-item.danger:hover { background: #fef2f2; }
.hm-sep { height: 1px; background: #f1f5f9; margin: 3px 0; }
.add-btn {
  position: absolute; left: -52px; top: 11px;
  width: 22px; height: 22px; border-radius: 6px;
  display: grid; place-items: center;
  color: #94a3b8; cursor: pointer; opacity: 0; transition: opacity .12s;
  background: transparent; border: 0; padding: 0;
  font-size: 16px;
}
.add-btn:hover { background: #eef2f7; color: var(--navy); }

.right-tools {
  position: absolute; right: 4px; top: 10px;
  display: flex; align-items: center; gap: 4px; opacity: 0; transition: opacity .12s;
  z-index: 5;
}
.right-tools .pts {
  display: inline-flex; align-items: center; gap: 4px;
  border: 1px solid var(--line); background: #fff;
  border-radius: 8px; padding: 4px 8px; font-size: 12px; font-weight: 700;
  color: var(--navy);
}
.right-tools .pts input {
  width: 40px; border: 0; outline: none; background: transparent;
  font: inherit; font-weight: 700; color: inherit; text-align: right;
  -moz-appearance: textfield;
}
.right-tools .pts input::-webkit-inner-spin-button,
.right-tools .pts input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.right-tools .pts .unit { color: var(--muted); font-weight: 500; }
.tool-btn {
  width: 26px; height: 26px; border-radius: 7px; border: 0; background: transparent;
  color: #64748b; display: grid; place-items: center; cursor: pointer;
}
.tool-btn:hover { background: #eef2f7; color: var(--ink); }
.tool-btn.active { background: var(--accent-tint); color: var(--navy); }
.tool-btn.danger:hover { background: var(--danger-tint); color: var(--danger); }
.tool-btn.sec-handle.menu-open { background: #e8edf5; color: var(--navy); }

.block-label {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 10.5px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.06em;
  margin-bottom: 4px;
}
.block-label .b-ico {
  display: inline-grid; place-items: center; width: 16px; height: 16px;
  border-radius: 4px; background: var(--accent-tint); color: var(--navy);
}
.block-label-wrap {
  margin-bottom: 4px;
  display: inline-block; position: relative;
}
.block-label-btn {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 10.5px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.06em;
  background: transparent; border: 1px solid transparent;
  padding: 3px 8px 3px 4px; border-radius: 7px;
  cursor: pointer; font-family: inherit;
  transition: background .1s, border-color .1s, color .1s;
}
.block-label-btn:hover {
  background: var(--accent-tint); color: var(--navy);
  border-color: #dde3ee;
}
.block-label-btn.open {
  background: var(--accent-tint); color: var(--navy);
  border-color: var(--navy);
}
.block-label-btn .b-ico {
  display: inline-grid; place-items: center; width: 16px; height: 16px;
  border-radius: 4px; background: var(--accent-tint); color: var(--navy);
}
.block-label-btn:hover .b-ico,
.block-label-btn.open .b-ico {
  background: #fff;
}
.block-label-caret {
  font-size: 10px; opacity: 0.6; margin-left: 2px;
}
.block-label-btn:hover .block-label-caret,
.block-label-btn.open .block-label-caret {
  opacity: 1;
}

/* Slash item marked as current */
.slash-item.current { background: rgba(30, 41, 59, 0.04); position: relative; }
.slash-item.current .meta b { color: var(--navy); }
.slash-item.current::before {
  content: ""; position: absolute; left: 0; top: 8px; bottom: 8px;
  width: 3px; background: var(--navy); border-radius: 0 3px 3px 0;
}
.block-num {
  font-variant-numeric: tabular-nums; color: var(--ink);
  font-weight: 700; font-size: 13.5px; margin-right: 6px;
}
.q-text {
  font-size: 15.5px; color: var(--ink); font-weight: 500;
  outline: none; line-height: 1.55;
  min-height: 24px;
  word-break: break-word; padding: 2px 0;
}
.q-text:empty::before {
  content: attr(data-placeholder);
  color: #94a3b8; pointer-events: none;
}
.q-text[contenteditable="true"]:focus { background: transparent; }

/* Inline math/chem node — rendered formula, never raw LaTeX */
.eb-math-node {
  display: inline-block;
  padding: 0 4px;
  margin: 0 1px;
  border-radius: 5px;
  background: var(--primary-tint);
  vertical-align: baseline;
  cursor: default;
  user-select: all;
}
.eb-math-node .katex { font-size: 1em; }

/* MCQ */
.mcq-options { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; padding-left: 22px; }
.mcq-opt { display: flex; align-items: center; gap: 10px; padding: 5px 8px; border-radius: 8px; }
.mcq-opt:hover { background: #f6f7f9; }
.mcq-opt .radio {
  width: 16px; height: 16px; border-radius: 999px;
  border: 1.5px solid #cbd5e1; flex: none; background: #fff; cursor: pointer;
  padding: 0;
}
.mcq-opt.correct {
  border-left: 3px solid #22c55e;
  padding-left: 5px; /* compensate for border so text stays aligned */
}
.mcq-opt.correct .radio {
  border-color: #22c55e;
  background: #22c55e;
  display: grid;
  place-items: center;
}
.mcq-opt.correct .radio::after {
  content: '';
  display: block;
  width: 6px;
  height: 10px;
  border: 2px solid #fff;
  border-top: none;
  border-left: none;
  transform: rotate(45deg) translate(-1px, -1px);
}
.mcq-opt .opt {
  border: 0; outline: none; background: transparent; font: inherit; flex: 1; padding: 2px 0;
}
.mcq-opt.correct .opt { color: var(--ink); font-weight: 600; }
/* .mcq-tag removed — correct answer indicated by radio checkmark + green left border */
.opt-del {
  opacity: 0; width: 22px; height: 22px; border-radius: 6px; border: 0;
  background: transparent; color: #94a3b8; cursor: pointer; display: grid; place-items: center;
}
.mcq-opt:hover .opt-del { opacity: 1; }
.opt-del:hover { background: var(--danger-tint); color: var(--danger); }
.add-opt {
  display: inline-flex; gap: 6px; align-items: center;
  color: var(--muted); font-size: 13px; font-weight: 500;
  background: transparent; border: 0; padding: 4px 8px; cursor: pointer;
  border-radius: 8px; margin-left: 14px; margin-top: 2px;
}
.add-opt:hover { background: #f1f3f8; color: var(--ink); }

/* Fill blank */
.fb-sentence {
  font-size: 15.5px; line-height: 1.95; color: var(--ink);
  outline: none; word-break: break-word; padding: 2px 0;
}
.fb-sentence .blank {
  display: inline-block; min-width: 70px;
  border: 0; outline: none;
  border-bottom: 2px solid var(--navy);
  padding: 0 8px 1px; margin: 0 2px;
  color: var(--navy); font-weight: 600;
  background: linear-gradient(transparent 60%, rgba(30,41,59,0.06) 60%);
  border-radius: 3px 3px 0 0;
  font: inherit;
  text-align: center;
}
.fb-sentence .blank::placeholder { color: rgba(30, 41, 59, 0.35); font-weight: 500; }
.fb-sentence .inline-formula {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 8px; border-radius: 6px; background: var(--accent-tint); color: var(--navy);
  font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 13.5px;
  border: 1px solid #dde3ee; vertical-align: middle;
}

/* Short / essay */
.short-input {
  margin-top: 8px; margin-left: 22px;
  border: 1px dashed #cbd5e1; border-radius: var(--radius-input);
  padding: 10px 12px; background: #fcfcfd; color: #94a3b8;
  font-size: 13.5px; font-style: italic;
}
.essay-input {
  margin-top: 8px; margin-left: 22px;
  border: 1px dashed #cbd5e1; border-radius: var(--radius-input);
  padding: 14px 14px; min-height: 110px;
  background: #fcfcfd;
  font-size: 13.5px;
}
.essay-input .note { color: var(--ink); font-weight: 500; }
.essay-lines {
  margin-top: 8px;
  background-image: repeating-linear-gradient(to bottom, transparent 0 26px, #eef1f6 26px 27px);
  height: 84px; border-radius: 8px;
}

/* Section header block */
.section-block {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 0;
  margin: 14px 0 6px;
  overflow: hidden;
  position: relative;
}
.section-block.sub {
  margin: 6px 0; box-shadow: none; background: #fff;
}
.section-block.dragging { opacity: 0.45; }
.section-head {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 20px; cursor: pointer; user-select: none;
}
.section-head .caret-lg { display: inline-grid; place-items: center; flex: none; }
.section-head .caret-lg svg { transition: transform .15s; }
.section-head.collapsed .caret-lg svg { transform: rotate(-90deg); }
.section-tag {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--muted);
  flex: none;
}
.section-tag .num {
  background: var(--navy); color: #fff; padding: 2px 8px; border-radius: 999px; font-size: 10.5px;
}
.section-title {
  font-size: 18px; font-weight: 700; letter-spacing: -0.01em; color: var(--ink);
  border: 0; outline: none; background: transparent; flex: 1; padding: 0; min-width: 0;
}
.section-block.sub .section-title { font-size: 16px; }
.section-points {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--accent-tint); color: var(--navy);
  padding: 5px 11px; border-radius: 999px;
  font-size: 12px; font-weight: 700; flex: none;
}
.section-points .lbl { color: var(--navy-soft); font-weight: 500; }
.section-instructions {
  padding: 0 20px 8px;
  font-size: 13.5px; color: var(--muted); font-style: italic; line-height: 1.5;
  outline: none;
}
.section-instructions:empty::before {
  content: "Ajouter une consigne (optionnel)";
  color: #c4cad6; font-style: italic;
}
.section-body {
  padding: 6px 20px 14px;
  border-top: 1px solid var(--line-soft);
  background: #fcfcfd;
}
.section-block.sub .section-body { background: #fff; }

/* Drag insertion line */
.drop-line {
  height: 2px; background: transparent; border-radius: 999px;
  margin: 1px 0; transition: background .1s;
  position: relative;
}
.drop-line.active {
  background: var(--navy);
  box-shadow: 0 0 0 3px rgba(30,41,59,0.15);
}
.drop-line.active::before {
  content: ""; position: absolute; left: -4px; top: -3px;
  width: 8px; height: 8px; border-radius: 999px; background: var(--navy);
}

/* Nested */
.nested {
  margin-left: 16px; padding-left: 14px;
  border-left: 2px solid var(--line);
  position: relative;
  margin-top: 8px;
}
.nested > .block { padding-left: 6px; }
.nested .handle { left: -36px; }
.nested .add-btn { left: -60px; }
.sub-label {
  display: inline-block; font-weight: 700; color: var(--navy);
  font-size: 14px; min-width: 22px;
}

/* Image */
.image-block {
  margin-top: 8px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 14px;
  overflow: hidden;
}
.image-frame {
  height: 180px; display: grid; place-items: center;
  background: repeating-linear-gradient(135deg, #f3f5f9 0 12px, #fbfcfe 12px 24px);
  color: #94a3b8; font-family: 'JetBrains Mono', monospace; font-size: 12px;
  position: relative;
}
.image-frame .caption {
  background: #fff; border: 1px solid var(--line);
  padding: 6px 12px; border-radius: 999px;
  color: var(--muted); font-size: 12px; font-family: 'Plus Jakarta Sans', sans-serif;
}
.image-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px; border-top: 1px solid var(--line-soft);
  font-size: 12.5px; color: var(--muted);
}
.image-toolbar .filename { font-family: 'JetBrains Mono', monospace; color: var(--ink); }
.image-frame--loaded { height: auto; min-height: 60px; padding: 12px; background: #f8fafc; }
.image-empty-cta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.img-sep { font-size: 12px; color: var(--muted); }
.img-btn {
  padding: 6px 14px; border-radius: 8px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); font-size: 12.5px; font-weight: 600;
  cursor: pointer; transition: background .12s;
}
.img-btn:hover { background: #f1f5f9; }
.img-btn.primary { background: var(--navy); color: #fff; border-color: var(--navy); }
.img-btn.primary:hover { background: #1e3a5f; }
.img-btn--replace { font-size: 12px; color: var(--muted); border: 0; background: transparent; padding: 0 4px; }
.img-btn--replace:hover { color: var(--danger); background: transparent; }
.image-url-row { display: flex; align-items: center; gap: 8px; padding: 0 16px; width: 100%; box-sizing: border-box; }
.image-url-input {
  flex: 1; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px;
  font-size: 13px; outline: none;
}
.image-url-input:focus { border-color: var(--navy); }
.image-caption-input {
  flex: 1; border: 0; outline: none; background: transparent;
  font-size: 12.5px; color: var(--muted); font-style: italic;
}
.image-caption-input::placeholder { color: #cbd5e1; }
/* Preview image */
.pv-image-img { display: block; max-width: 100%; border-radius: 10px; margin: 10px auto; }
.pv-image-caption-text { text-align: center; font-size: 12px; color: #64748b; margin-top: 4px; font-style: italic; }

/* Chart */
.chart-block {
  margin-top: 8px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 14px;
  padding: 14px 18px 8px;
}
.chart-editor-head {
  display: flex; gap: 8px; align-items: center; margin-bottom: 10px;
}
.chart-title-input {
  flex: 1; border: 0; outline: none; background: transparent;
  font: inherit; font-weight: 600; font-size: 13.5px; color: var(--ink);
}
.chart-title-input::placeholder { color: #cbd5e1; font-weight: 400; }
.chart-mode-select {
  font-size: 11.5px; font-weight: 600; color: var(--muted);
  border: 1px solid var(--line); border-radius: 8px; padding: 3px 8px;
  background: #fff; cursor: pointer; outline: none;
}
.chart-exprs { display: flex; flex-direction: column; gap: 5px; margin-bottom: 10px; }
.chart-expr-row { display: flex; gap: 6px; align-items: center; }
.chart-expr-input {
  flex: 1; padding: 5px 10px; border: 1px solid var(--line); border-radius: 8px;
  font-size: 13px; outline: none; font-family: 'JetBrains Mono', monospace;
}
.chart-expr-input:focus { border-color: var(--navy); }
.chart-preview { border-radius: 10px; overflow: hidden; margin-top: 4px; }

/* Publish panel */
.pub-anchor { position: relative; }
.pub-panel {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 200;
  background: #fff; border: 1px solid var(--line); border-radius: 14px;
  padding: 14px; box-shadow: 0 8px 28px rgba(15,23,42,0.13);
  min-width: 340px;
}
.pub-panel-title {
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .07em; color: var(--muted); margin-bottom: 10px;
}
.pub-row { display: flex; gap: 8px; align-items: center; }
.pub-url {
  flex: 1; font-size: 11.5px; font-family: 'JetBrains Mono', monospace;
  color: var(--ink); background: #f8fafc; border: 1px solid var(--line);
  border-radius: 8px; padding: 6px 10px; overflow: hidden;
  white-space: nowrap; text-overflow: ellipsis;
}
.pub-copy-btn {
  padding: 6px 14px; border-radius: 8px; border: 0;
  background: var(--navy); color: #fff; font-size: 12.5px; font-weight: 700;
  cursor: pointer; flex-shrink: 0;
}
.pub-copy-btn:hover { background: #1e3a5f; }
.pub-hint { font-size: 11.5px; color: var(--muted); margin-top: 8px; line-height: 1.4; }

/* LaTeX */
.latex-block {
  margin-top: 8px;
  background: #fcfcfd;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 18px;
  display: flex; align-items: center; gap: 18px;
  flex-wrap: wrap;
}
.latex-render {
  flex: 1; font-size: 22px; color: var(--ink); letter-spacing: 0.01em;
  min-width: 220px;
}
.latex-render .sub { font-size: 0.7em; vertical-align: sub; }
.latex-render .sup { font-size: 0.7em; vertical-align: super; }
.latex-source {
  font-family: 'JetBrains Mono', monospace; font-size: 12px; color: var(--muted);
  background: #fff; border: 1px solid var(--line); padding: 6px 10px; border-radius: 8px;
  outline: none; min-width: 220px;
}

/* Slash menu */
.slash-anchor { position: relative; }
.slash-menu {
  position: fixed; top: 0; left: 0;
  width: 520px; max-height: min(560px, calc(100vh - 60px)); overflow: auto;
  background: #fff; border-radius: 16px;
  box-shadow: var(--shadow-pop); border: 1px solid var(--line);
  z-index: 200;
}
.slash-search {
  padding: 10px 14px; border-bottom: 1px solid var(--line-soft);
  display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px;
  position: sticky; top: 0; background: #fff; z-index: 1;
}
.slash-search code {
  background: var(--accent-tint); color: var(--navy);
  padding: 1px 6px; border-radius: 4px; font-family: 'JetBrains Mono', monospace; font-size: 11.5px;
}
.slash-ico {
  width: 28px; height: 28px; border-radius: 8px; flex: none;
  display: grid; place-items: center;
  background: #fff; border: 1px solid var(--line);
  color: var(--navy);
}
.slash-group { padding: 8px; }
.slash-group-title {
  text-transform: uppercase; letter-spacing: 0.08em; font-size: 10.5px;
  color: var(--muted); padding: 4px 8px 6px; font-weight: 700;
}
.slash-group .slash-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px;
}
.slash-item {
  display: flex; align-items: center; gap: 10px; padding: 7px 8px;
  border-radius: 9px; cursor: pointer; min-width: 0;
}
.slash-item:hover, .slash-item.hover { background: var(--accent-tint); }
.slash-item .meta { min-width: 0; flex: 1; }
.slash-item .meta b {
  font-size: 13px; color: var(--ink); font-weight: 600; display: block;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.slash-item .meta span {
  font-size: 11px; color: var(--muted); display: block;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.slash-item .kbd {
  margin-left: auto; font-family: 'JetBrains Mono', monospace; font-size: 10.5px;
  color: var(--muted); flex: none;
}
.slash-empty {
  padding: 28px; text-align: center; color: var(--muted); font-size: 13px;
}

/* Expected answer drawer */
.answer-drawer {
  margin-top: 10px; margin-left: 22px;
  background: #fff; border: 1px solid var(--line);
  border-radius: 14px; overflow: hidden;
  display: flex; flex-direction: column;
}
.drawer-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 12px 8px;
  border-bottom: 1px solid var(--line-soft);
  background: #f8fafc; flex-shrink: 0;
}
.drawer-title {
  display: flex; align-items: center; gap: 7px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.07em;
  text-transform: uppercase; color: var(--navy);
}
.drawer-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--navy); flex-shrink: 0;
}
.drawer-close { color: #94a3b8; }
.drawer-close:hover { color: var(--danger); background: var(--danger-tint); }
.drawer-body {
  padding: 12px 14px; flex: 1; min-height: 0; overflow-y: auto;
}
.drawer-tabs-bar {
  display: flex; border-top: 1px solid var(--line-soft);
  background: #f8fafc; flex-shrink: 0;
}
.drawer-tab {
  flex: 1; padding: 8px 4px; font-size: 12px; font-weight: 600;
  color: var(--muted); cursor: pointer; background: transparent; border: 0;
  border-top: 2px solid transparent; transition: color .12s, border-color .12s;
}
.drawer-tab.active { color: var(--navy); border-top-color: var(--navy); background: #fff; }
.drawer-tab:hover:not(.active) { color: var(--ink); background: #f1f5f9; }

/* Chemistry rendering */
.chem-state { font-style: italic; color: var(--muted, #64748b); }

/* Expected answer row (short blocks) */
.expected-answer-row {
  display: flex; flex-direction: column; gap: 4px;
  margin-bottom: 10px; padding-bottom: 10px;
  border-bottom: 1px solid var(--line-soft);
}
.drawer-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; color: var(--muted);
}
.expected-answer-input {
  width: 100%; padding: 6px 10px; border-radius: 8px;
  border: 1px solid var(--line-soft); font-size: 13px;
  background: #fff; outline: none;
}
.expected-answer-input:focus { border-color: var(--navy); }

/* Solution tab */
.sol-body { display: flex; flex-direction: column; gap: 6px; }
.sol-empty { font-size: 13px; color: #94a3b8; line-height: 1.5; }
.sol-step {
  display: flex; align-items: flex-start; gap: 6px;
  padding: 6px 8px; border-radius: 8px; border: 1px solid var(--line-soft);
  background: #fafbfc;
}
.sol-num {
  min-width: 20px; font-size: 12px; font-weight: 700; color: var(--navy);
  padding-top: 3px; flex-shrink: 0;
}
.sol-step-main { flex: 1; min-width: 0; }
.sol-input {
  font-size: 13.5px; color: var(--ink); outline: none; min-height: 24px;
  line-height: 1.5; word-break: break-word;
}
.sol-input:empty:before {
  content: attr(data-placeholder); color: #94a3b8; pointer-events: none;
}
.sol-math-preview { margin-top: 4px; font-size: 13px; }
.sol-actions { display: flex; gap: 8px; margin-top: 6px; }
.sol-graph-editor {
  margin-top: 8px; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 10px; background: #f8fafc;
}
.sol-graph-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: var(--muted); margin-bottom: 8px;
}
.sol-graph-row { display: flex; align-items: center; gap: 6px; margin-bottom: 5px; }
.sol-graph-input {
  flex: 1; padding: 5px 10px; border: 1px solid var(--line); border-radius: 8px;
  font-size: 13px; outline: none; font-family: 'JetBrains Mono', monospace;
}
.sol-graph-input:focus { border-color: var(--navy); }
.sol-graph-preview { margin-top: 8px; border-radius: 8px; overflow: hidden; }
.sol-graph-placeholder {
  height: 180px; display: grid; place-items: center;
  background: repeating-linear-gradient(135deg,#f3f5f9 0 12px,#fbfcfe 12px 24px);
  color: var(--muted); font-size: 13px; border-radius: 8px;
}

.answer-line {
  font-size: 13.5px; padding: 6px 0;
  border-bottom: 1px dashed var(--line);
  color: var(--ink); outline: none;
}
.answer-line:last-of-type { border-bottom: 0; }
.answer-line .bn {
  display: inline-block; min-width: 22px; color: var(--navy); font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.rubric { margin-top: 6px; display: flex; flex-direction: column; gap: 6px; }
.rubric-row {
  display: grid; grid-template-columns: 60px 1fr 90px 24px;
  gap: 10px; align-items: center;
  padding: 8px 10px; border: 1px solid var(--line);
  border-radius: 10px; font-size: 13px; background: #fff;
}
.rubric-row .pts {
  font-weight: 700; color: var(--navy); font-variant-numeric: tabular-nums;
  background: var(--accent-tint); padding: 4px 8px; border-radius: 8px;
  text-align: center; font-size: 12px; border: 0; outline: none; width: 100%;
}
.rubric-row .crit {
  font-size: 13px; border: 0; outline: none; color: var(--ink);
  background: transparent; width: 100%; font-family: inherit;
}
.rubric-row .tag {
  font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px;
  border: 0; cursor: pointer;
  background: #f1f5f9; color: var(--muted);
}
.rubric-row .tag.full { background: #dcfce7; color: #166534; }
.rubric-row .tag.partial { background: #fef9c3; color: #854d0e; }
.rubric-row .tag.none { background: #fee2e2; color: #991b1b; }
.row-del {
  width: 22px; height: 22px; border-radius: 6px; border: 0; background: transparent;
  color: #94a3b8; display: grid; place-items: center; cursor: pointer; padding: 0;
}
.row-del:hover { background: var(--danger-tint); color: var(--danger); }
.add-rubric {
  margin-top: 6px; font-size: 12.5px; font-weight: 600; color: var(--navy);
  background: transparent; border: 1px dashed var(--line); border-radius: 8px;
  padding: 5px 12px; cursor: pointer; width: 100%;
}
.add-rubric:hover { background: var(--accent-tint); }
.add-rubric.active { background: var(--accent-tint); border-style: solid; }

/* Add block CTA */
.add-block-cta {
  display: flex; align-items: center; gap: 8px;
  margin-top: 6px; padding: 10px 12px;
  border-radius: 12px; color: var(--muted); font-size: 13px;
  cursor: pointer; background: transparent; border: 0; width: 100%;
  text-align: left;
}
.add-block-cta:hover { background: #f1f3f8; color: var(--ink); }
.add-block-cta .plus {
  width: 22px; height: 22px; border-radius: 6px;
  background: var(--accent-tint); color: var(--navy);
  display: grid; place-items: center; font-weight: 700;
}
/* ---------- Group block: sub-question type picker ---------- */
.group-add-row {
  display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap;
}
.group-add-btn {
  border: 1px solid var(--line); background: #fff; border-radius: 8px;
  padding: 5px 10px; font-size: 12px; font-weight: 600; color: #475569;
  cursor: pointer; transition: background 0.12s, color 0.12s;
}
.group-add-btn:hover { background: var(--accent-tint); color: var(--navy); border-color: var(--navy); }

/* ---------- Settings modal ---------- */
.settings-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(15,23,42,0.35);
  display: flex; align-items: center; justify-content: center;
}
.settings-modal {
  background: #fff; border-radius: 20px;
  box-shadow: var(--shadow-pop);
  width: 420px; max-width: calc(100vw - 32px);
  display: flex; flex-direction: column; overflow: hidden;
}
.settings-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px 14px; border-bottom: 1px solid var(--line);
}
.settings-title { font-size: 15px; font-weight: 700; color: var(--ink); }
.settings-close {
  border: 0; background: transparent; cursor: pointer; color: var(--muted);
  display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px;
}
.settings-close:hover { background: #f1f3f8; color: var(--ink); }
.settings-body { padding: 16px 20px; display: flex; flex-direction: column; gap: 14px; }
.settings-field { display: flex; flex-direction: column; gap: 5px; }
.settings-field--row { flex-direction: row; align-items: center; flex-wrap: wrap; gap: 8px; }
.settings-hint { font-size: 11px; color: var(--muted); line-height: 1.4; }
.settings-checkbox { width: 16px; height: 16px; cursor: pointer; accent-color: var(--navy); }
.settings-label { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); }
.settings-input {
  border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 12px; font-size: 13.5px; font-family: inherit; outline: none;
  transition: border-color 0.12s;
}
.settings-input:focus { border-color: var(--navy); }
.settings-footer { padding: 12px 20px 18px; display: flex; justify-content: flex-end; }
.settings-done {
  border: 0; background: var(--navy); color: #fff; border-radius: 10px;
  padding: 9px 20px; font-size: 13px; font-weight: 700; cursor: pointer;
  font-family: inherit;
}
.settings-done:hover { background: #334155; }

.add-section-cta {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px dashed var(--line); padding: 16px; border-radius: 18px;
  margin-top: 18px; color: var(--muted); cursor: pointer; background: transparent;
  font-size: 13px; width: 100%;
}
.add-section-cta:hover { background: #fbfbfd; color: var(--ink); border-color: #cbd5e1; }

/* Toast */
.focus-note {
  position: fixed; right: 24px; bottom: 24px; z-index: 40;
  background: var(--ink); color: #fff; border-radius: 14px;
  padding: 10px 14px; font-size: 12px;
  box-shadow: 0 24px 60px -24px rgba(0,0,0,0.5);
  display: flex; align-items: center; gap: 10px;
}
.focus-note kbd {
  font-family: 'JetBrains Mono', monospace; background: rgba(255,255,255,0.12);
  padding: 1px 6px; border-radius: 4px; font-size: 11px;
}

/* Selection */
::selection { background: rgba(30, 41, 59, 0.15); }

/* ==================== Split layout ==================== */
.app.split { grid-template-columns: 88px 1fr; height: 100vh; overflow: hidden; }
.app.split .sidebar { padding: 22px 10px; }
.app.split .sidebar .side-label,
.app.split .sidebar .brand-sub,
.app.split .sidebar .brand-name,
.app.split .sidebar .side-item-label,
.app.split .sidebar .outline,
.app.split .sidebar .out-section { display: none; }
.app.split .sidebar .side-item { justify-content: center; padding: 10px; }
.app.split .sidebar .side-item .ico { font-size: 16px; width: 18px; text-align: center; }
.app.split .sidebar .brand { padding: 6px 0 18px; justify-content: center; }
.app.split main { display: flex; flex-direction: column; min-width: 0; }
.app.split .split-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr;
  min-width: 0; flex: 1 1 0; min-height: 0;
}
.app.split .editor-pane { min-width: 0; min-height: 0; overflow: auto; }
.app.split .preview-pane {
  min-width: 0; min-height: 0;
  display: flex; flex-direction: column; overflow: hidden;
}
.app.split .topbar { padding: 12px 20px; }
.app.split .canvas { padding: 24px 28px 120px; max-width: none; }
.app.split .right-tools .pts { padding: 4px 8px; }
.app.split .right-tools .pts input { width: 40px; }

.app.split .editor-pane { border-right: 1px solid var(--line); background: var(--bg); }
.app.split .preview-pane { background: #fbfbfd; }

/* pv-topbar stays fixed; pv-pane + mobile-preview-bg scroll inside the pane */
.pv-topbar { flex-shrink: 0; }
.pv-pane { flex: 1 1 0; overflow-y: auto; min-height: 0; background: #f8fafc; }
.mobile-preview-bg { flex: 1 1 0; overflow-y: auto; min-height: 0; }

/* ==================== Preview pane ==================== */
/* ── Sticky exam header ─────────────────────────────── */
.pv-sticky {
  position: sticky; top: 0; z-index: 10;
  background: rgba(255,255,255,0.97); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 8px rgba(15,23,42,0.06);
}
.pv-sticky-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 20px;
}
.pv-sticky-title {
  font-size: 14px; font-weight: 700; color: var(--ink);
  flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  letter-spacing: -0.01em;
}
.pv-sticky-right {
  display: flex; align-items: center; gap: 8px; flex-shrink: 0;
}
.pv-flag-count {
  font-size: 11.5px; font-weight: 700; color: #b45309;
  background: #fffbeb; border: 1px solid #fde68a;
  padding: 3px 9px; border-radius: 999px; white-space: nowrap;
}
.pv-prog {
  font-size: 12px; color: var(--muted); font-weight: 600;
  white-space: nowrap;
}

/* Timer progress bar */
.pv-timer-track {
  position: relative; height: 4px; background: #e2e8f0;
  overflow: visible;
}
.pv-timer-fill {
  height: 100%; transition: width 1s linear, background 0.5s;
  border-radius: 0 2px 2px 0;
}
.pv-timer-text {
  position: absolute; right: 10px; top: -18px;
  font-size: 11px; font-weight: 700; color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.pv-timer-text.warn { color: #f59e0b; }
.pv-timer-text.crit { color: #ef4444; animation: pvpulse-red 1s infinite; }
@keyframes pvpulse-red { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }
.pv-timer-text.timer-warning { animation: pvpulse-red 0.8s infinite; }

/* Legacy pulse (green dot kept for mobile) */
.pv-dot {
  width: 8px; height: 8px; border-radius: 999px; background: #16a34a;
  box-shadow: 0 0 0 4px rgba(22,163,74,0.15);
  animation: pvpulse 2s infinite;
}
@keyframes pvpulse {
  0%,100% { box-shadow: 0 0 0 4px rgba(22,163,74,0.15); }
  50% { box-shadow: 0 0 0 8px rgba(22,163,74,0.05); }
}

/* ── Flag button ─────────────────────────────────────── */
.pv-q-wrap { position: relative; }
.pv-q-wrap.flagged { background: #fffdf0; border-radius: 12px; padding: 4px 4px 4px 0; }
.pv-flag-btn {
  float: right; clear: right;
  background: none; border: none; cursor: pointer;
  font-size: 15px; color: #cbd5e1; padding: 2px 4px;
  line-height: 1; border-radius: 6px; transition: color 0.15s, background 0.15s;
  margin-left: 6px;
}
.pv-flag-btn:hover { color: #f59e0b; background: #fffbeb; }
.pv-flag-btn.on { color: #f59e0b; }
.pv-btn {
  border: 1px solid var(--line); background: #fff;
  border-radius: 10px; padding: 7px 14px; font-size: 13px; font-weight: 600;
  color: var(--ink); cursor: pointer; transition: all 0.15s;
}
.pv-btn:hover:not(:disabled) { background: #f8fafc; border-color: #cbd5e1; }
.pv-btn.primary { background: #2563eb; color: #fff; border-color: #2563eb; }
.pv-btn.primary:hover:not(:disabled) { background: #1d4ed8; border-color: #1d4ed8; }
.pv-btn:disabled { opacity: 0.38; cursor: not-allowed; }

.pv-result {
  margin: 16px 32px 0;
  background: linear-gradient(135deg, #eff6ff 0%, #f0fdf4 100%);
  border: 1.5px solid #bfdbfe;
  border-radius: 14px;
  padding: 16px 20px;
  display: flex; flex-direction: column; gap: 8px;
}
.pv-result-row {
  display: flex; align-items: baseline; gap: 10px;
}
.pv-result-num {
  font-size: 20px; font-weight: 800; color: #1e293b;
  font-variant-numeric: tabular-nums; min-width: 100px;
}
.pv-result-num .muted { color: #64748b; font-weight: 600; font-size: 15px; }
.pv-result-label { font-size: 13px; color: #475569; }

/* Explanation card — shown after submission */
.pv-explanation {
  margin: 10px 0 4px;
  padding: 12px 14px;
  background: #fefce8;
  border: 1px solid #fde68a;
  border-radius: 10px;
}
.pv-explanation-label {
  display: inline-block;
  font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: #92400e; margin-bottom: 6px;
}
.pv-explanation-body {
  font-size: 13.5px; color: #1c1917; line-height: 1.6;
}

.pv-paper {
  margin: 20px auto 40px;
  max-width: 680px;
  background: #fff;
  border: 1px solid #e8edf3;
  border-radius: 16px;
  padding: 28px 32px 40px;
  box-shadow: 0 2px 12px rgba(15,23,42,0.06);
}
.pv-paper-head {
  border-bottom: 2px solid #f1f5f9;
  padding-bottom: 20px; margin-bottom: 24px;
}
.pv-meta {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  font-size: 11px; color: var(--muted); font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em;
}
.pv-meta span:not(:first-child):not(:last-child) {
  color: #cbd5e1;
}
.pv-title {
  font-size: 28px; margin: 10px 0 4px;
  letter-spacing: -0.025em; font-weight: 800; color: var(--ink);
  line-height: 1.2;
}
.pv-subtitle { color: var(--muted); font-size: 14px; line-height: 1.55; margin: 4px 0 0; }
.pv-student {
  display: flex; gap: 16px; padding-top: 10px;
  border-top: 1px dashed var(--line); flex-wrap: wrap;
}
.pv-student label { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 120px; }
.pv-student label span {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--muted); font-weight: 700;
}
.pv-student input {
  border: 0; border-bottom: 1px solid #cbd5e1; outline: none;
  background: transparent; font: inherit; padding: 4px 0; font-size: 13.5px;
  color: var(--ink);
}
.pv-student input:focus { border-bottom-color: var(--navy); }

/* ── Answer feedback states ──────────────────────────────────────────── */
.pv-student input.answer-correct {
  border-bottom: 2px solid #16a34a;
  color: #16a34a;
  background: transparent;
}
.pv-student input.answer-wrong {
  border-bottom: 2px solid #dc2626;
  color: #dc2626;
  animation: answer-shake 0.3s ease-in-out;
}
@keyframes answer-shake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-6px); }
  40%       { transform: translateX(6px); }
  60%       { transform: translateX(-4px); }
  80%       { transform: translateX(4px); }
}

/* MCQ option feedback */
.pv-option.answer-correct { border-color: #16a34a !important; background: #f0fdf4 !important; }
.pv-option.answer-wrong   { border-color: #dc2626 !important; background: #fef2f2 !important;
  animation: answer-shake 0.3s ease-in-out; }

/* ── Passage block — editor ─────────────────────────────────────────── */
.passage-editor {
  border: 1.5px solid #fde68a;
  border-left: 3px solid #f59e0b;
  border-radius: 0 10px 10px 0;
  overflow: hidden;
  background: #fff;
}
.passage-editor-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 14px;
  border-bottom: 1px solid #fde68a;
  background: #fffbeb;
}
.passage-rp-badge {
  display: flex; align-items: center; gap: 6px;
  font-size: 10.5px; font-weight: 800; letter-spacing: 1.2px; color: #92400e;
}
.passage-del-btn {
  font-size: 12px; font-weight: 500; color: #d97706;
  background: none; border: none; cursor: pointer; padding: 0;
}
.passage-del-btn:hover { color: #b45309; text-decoration: underline; }
.passage-toolbar {
  display: flex; align-items: center; gap: 1px;
  padding: 5px 10px;
  border-bottom: 1px solid #f1f5f9;
  flex-wrap: wrap;
}
.pe-tb-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border: none; background: none;
  border-radius: 6px; cursor: pointer; color: #475569; font-size: 13px;
  transition: background 0.1s;
}
.pe-tb-btn:hover { background: #f1f5f9; color: #1e293b; }
.pe-tb-sep { width: 1px; height: 18px; background: #e2e8f0; margin: 0 4px; flex-shrink: 0; }
.pe-tb-select {
  font-size: 12px; border: 1px solid #e2e8f0; border-radius: 6px;
  padding: 3px 6px; background: #fff; color: #475569;
  cursor: pointer; outline: none; font-family: inherit; height: 28px;
}
.pe-tb-select:hover { border-color: #cbd5e1; }
.passage-editor-body {
  padding: 14px 16px; min-height: 120px;
  font-size: 14px; line-height: 1.85; color: #1e293b; outline: none;
}
.passage-editor-body:empty::after { content: attr(data-placeholder); color: #94a3b8; pointer-events: none; }
.passage-editor-body p { margin: 0 0 0.75em; }
.passage-editor-body p:last-child { margin-bottom: 0; }
.passage-editor-body h2 { font-size: 16px; font-weight: 700; margin: 0 0 0.5em; }
.passage-editor-body h3 { font-size: 14px; font-weight: 700; margin: 0 0 0.5em; }
.passage-editor-footer {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 14px 10px;
  border-top: 1px solid #fde68a;
}
.passage-footer-icon { color: #b45309; font-size: 12px; flex-shrink: 0; }
.passage-footer-input {
  flex: 1; border: none; background: transparent; outline: none;
  font-size: 12px; font-style: italic; color: #92400e;
}

/* ── Passage block — desktop preview ───────────────────────────────── */
.pv-passage {
  border: 1px solid #fde68a;
  border-left: 3px solid #f59e0b;
  border-radius: 0 10px 10px 0;
  overflow: hidden;
  background: #fffbeb;
  margin: 4px 0 16px;
}
.pv-passage-header {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px 4px;
  font-size: 10.5px; font-weight: 800; letter-spacing: 1.2px; color: #92400e;
}
.pv-passage-doc-tag {
  font-size: 9.5px; font-weight: 800; letter-spacing: 1.5px;
  color: #92400e; background: #fde68a;
  padding: 2px 6px; border-radius: 4px;
}
.pv-passage-body {
  padding: 6px 16px 14px;
  font-size: 14px; line-height: 1.85; color: #1e293b;
}
.pv-passage-body p { margin: 0 0 0.75em; }
.pv-passage-body p:last-child { margin-bottom: 0; }
.pv-passage-body h2 { font-size: 16px; font-weight: 700; margin: 0 0 0.5em; }
.pv-passage-body h3 { font-size: 14px; font-weight: 700; margin: 0 0 0.5em; }
.pv-passage-footer {
  padding: 6px 14px 10px;
  border-top: 1px solid #fde68a;
  font-size: 12px; font-style: italic; color: #92400e;
}

/* ── Passage block — mobile student view ───────────────────────────── */
.mv-passage {
  border: 1px solid rgba(245,158,11,0.2);
  border-left: 3px solid #f59e0b;
  border-radius: 0 12px 12px 0;
  overflow: hidden;
  background: rgba(255,251,235,0.06);
  margin: 0 0 14px;
}
.mv-passage-header {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 14px 4px;
  font-size: 10.5px; font-weight: 800; letter-spacing: 1.2px; color: #fbbf24;
}
.mv-passage-doc-tag {
  font-size: 9.5px; font-weight: 800; letter-spacing: 1.5px;
  color: #92400e; background: #fde68a;
  padding: 2px 6px; border-radius: 4px;
}
.mv-passage-body {
  padding: 4px 16px 14px;
  font-size: 15px; line-height: 1.85; color: #e2e8f0;
}
.mv-passage-body p { margin: 0 0 0.75em; }
.mv-passage-body p:last-child { margin-bottom: 0; }
.mv-passage-body h2 { font-size: 17px; font-weight: 700; color: #f8fafc; margin: 0 0 0.5em; }
.mv-passage-body h3 { font-size: 15px; font-weight: 700; color: #f8fafc; margin: 0 0 0.5em; }
.mv-passage-footer {
  padding: 6px 14px 10px;
  border-top: 1px solid rgba(245,158,11,0.15);
  font-size: 12px; font-style: italic; color: #9ca3af;
}

@keyframes kbd-section-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.pv-empty-state {
  padding: 60px 20px; text-align: center; color: var(--muted);
}
.pv-empty-illustration {
  width: 80px; height: 80px; border-radius: 24px;
  background: var(--accent-tint); color: var(--navy);
  display: grid; place-items: center; font-size: 32px;
  margin: 0 auto 16px;
}
.pv-empty-state h4 { color: var(--ink); margin: 0 0 6px; font-size: 16px; }
.pv-empty-state p { margin: 0; font-size: 13.5px; max-width: 320px; margin: 0 auto; }

/* ── Section / Partie hierarchy ─────────────────────── */
.pv-section {
  margin-top: 28px;
  border: 1.5px solid #e2e8f0;
  border-radius: 14px;
  padding: 0;
  background: #fff;
  box-shadow: 0 2px 8px rgba(15,23,42,0.05), 0 0 0 0 transparent;
  transition: box-shadow 0.2s;
}
.pv-section:first-of-type { margin-top: 8px; }
.pv-section:hover { box-shadow: 0 4px 16px rgba(15,23,42,0.08); }
.pv-section-head {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: #1e293b; color: #fff;
  padding: 13px 20px; border-radius: 12px 12px 0 0;
}
.pv-section-body { padding: 20px 20px 24px; display: flex; flex-direction: column; gap: 0; }
.pv-section.sub {
  margin-top: 16px; margin-left: 0;
  border: 1px solid var(--line-soft); border-radius: 12px;
}
.pv-section.sub .pv-section-head {
  background: #f1f5f9; color: var(--ink);
  border-radius: 11px 11px 0 0; padding: 10px 16px;
}
.pv-section.sub .pv-section-title { font-size: 14.5px; color: var(--ink); }
.pv-section.locked { opacity: 0.5; pointer-events: none; }
.pv-section.chosen .pv-section-head { background: #1e3a5f; }
.pv-section-tag {
  background: rgba(255,255,255,0.15); color: rgba(255,255,255,0.9);
  padding: 3px 10px; border-radius: 999px; font-size: 10.5px; font-weight: 700;
  letter-spacing: 0.08em; flex: none; text-transform: uppercase;
}
.pv-section.sub .pv-section-tag { background: #e2e8f0; color: #475569; }
.pv-section-title { margin: 0; font-size: 16px; font-weight: 700; color: #fff; flex: 1; min-width: 0; }
.pv-section.sub .pv-section-title { font-size: 14.5px; color: var(--ink); }
.pv-section-pts {
  font-size: 12px; font-weight: 700; color: rgba(255,255,255,0.75);
  background: rgba(255,255,255,0.15); padding: 3px 10px; border-radius: 999px;
  flex: none;
}
.pv-section.sub .pv-section-pts { color: var(--muted); background: #f1f5f9; }
.pv-section-instructions {
  font-size: 13.5px; color: var(--muted); font-style: italic;
  padding: 8px 20px 0; line-height: 1.5;
}

/* Choose-N banner */
.pv-choose-banner {
  display: flex; align-items: center; gap: 8px;
  background: #eff6ff; border: 1px solid #bfdbfe;
  border-radius: 10px; padding: 8px 14px; margin: 10px 20px 0;
  font-size: 13px; color: #1e40af; font-weight: 500;
}
.pv-choose-banner .ico { font-size: 14px; flex: none; }
.pv-choose-banner b { font-weight: 800; }

/* Section pick checkbox (choose-N sub-sections) */
.pv-section-pick {
  display: flex; align-items: center; gap: 6px;
  cursor: pointer; flex: none;
  background: rgba(255,255,255,0.15); border-radius: 8px;
  padding: 3px 10px; color: #fff; font-size: 12px; font-weight: 600;
  user-select: none;
}
.pv-section-pick input[type=checkbox] { width: 14px; height: 14px; cursor: pointer; accent-color: #fff; }
.pv-section-pick.disabled { opacity: 0.45; cursor: not-allowed; }
.pv-section-pick-label { font-size: 12px; font-weight: 600; }

/* Question card in preview */
.pv-q {
  padding: 16px 0; border-bottom: 1px solid #f1f5f9;
}
.pv-q:last-child { border-bottom: 0; }
.pv-q-head {
  display: flex; align-items: flex-start; gap: 10px; margin-bottom: 10px;
  flex-wrap: wrap;
}
.pv-num {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 26px; height: 26px; padding: 0 6px;
  border-radius: 7px; background: #f1f5f9;
  font-weight: 800; color: #1e293b; font-size: 12.5px;
  font-variant-numeric: tabular-nums; flex-shrink: 0; margin-top: 1px;
}
.pv-sub-letter {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 6px;
  background: #eff6ff; color: #2563eb;
  font-weight: 700; font-size: 12px; flex-shrink: 0; margin-top: 2px;
}
.pv-prompt { flex: 1; min-width: 0; font-size: 14.5px; color: var(--ink); line-height: 1.6; }
.pv-empty { color: #94a3b8; font-style: italic; }
.pv-pts {
  font-size: 11px; font-weight: 700;
  background: #f8fafc; color: #64748b; border: 1px solid #e2e8f0;
  padding: 2px 8px; border-radius: 999px; flex: none; white-space: nowrap;
}

/* MCQ in preview */
.pv-opts { display: flex; flex-direction: column; gap: 7px; padding-left: 36px; margin-top: 8px; }
.pv-opt {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border: 1.5px solid #e2e8f0; border-radius: 10px;
  cursor: pointer; transition: all 0.15s; background: #fff; font-size: 14px;
}
.pv-opt:hover { border-color: #93c5fd; background: #f8faff; }
.pv-opt.sel { border-color: #2563eb; background: #eff6ff; }
.pv-opt.right { border-color: #16a34a; background: #f0fdf4; }
.pv-opt.wrong { border-color: #dc2626; background: #fef2f2; }
.pv-radio {
  width: 18px; height: 18px; border-radius: 999px;
  border: 1.5px solid #cbd5e1; flex: none;
  display: grid; place-items: center;
  background: #fff; transition: border-color 0.15s;
}
.pv-opt.sel .pv-radio { border-color: #2563eb; }
.pv-radio-dot { width: 10px; height: 10px; border-radius: 999px; background: #2563eb; }
.pv-opt-letter { font-weight: 700; color: #94a3b8; min-width: 16px; font-size: 13px; }
.pv-opt-text { flex: 1; }
.pv-tag {
  font-size: 11px; font-weight: 700;
  padding: 2px 8px; border-radius: 999px; flex: none;
}
.pv-tag.good { background: #16a34a; color: #fff; }
.pv-tag.bad { background: #dc2626; color: #fff; }

/* Fill blank in preview */
.pv-sentence { font-size: 15px; line-height: 2.1; color: var(--ink); padding-left: 28px; }
.pv-blank {
  border: 0; outline: none; padding: 2px 8px;
  border-bottom: 2px solid var(--navy);
  background: rgba(30,41,59,0.04);
  border-radius: 4px 4px 0 0;
  font: inherit; font-weight: 600; color: var(--navy);
  text-align: center;
  margin: 0 2px;
}
.pv-blank:focus { background: var(--accent-tint); }
.pv-blank.ok { border-bottom-color: #16a34a; background: var(--good-tint); color: var(--good); }
.pv-blank.bad { border-bottom-color: #dc2626; background: var(--danger-tint); color: var(--danger); }
.pv-formula {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 8px; border-radius: 6px; background: var(--accent-tint); color: var(--navy);
  font-family: 'JetBrains Mono', monospace; font-size: 13px;
  border: 1px solid #dde3ee; margin: 0 2px;
}

/* Short / essay in preview */
.pv-short {
  width: 100%; padding: 10px 14px; margin-top: 8px;
  border: 1.5px solid #e2e8f0; border-radius: 10px;
  font: inherit; font-size: 14px; outline: none; background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s; color: var(--ink);
}
.pv-short:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
.pv-short:disabled { background: #f8fafc; color: var(--muted); }
.pv-essay {
  width: 100%; padding: 12px 14px; margin-top: 8px;
  border: 1.5px solid #e2e8f0; border-radius: 10px;
  font: inherit; font-size: 14px; outline: none; resize: vertical;
  min-height: 96px; background: #fff; line-height: 1.65;
  transition: border-color 0.15s, box-shadow 0.15s; color: var(--ink);
}
.pv-essay:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
.pv-essay:disabled { background: #f8fafc; color: var(--muted); }
.pv-hint {
  font-size: 12px; color: var(--muted); font-style: italic; margin-top: 6px;
}
.pv-word-count {
  font-size: 11px; color: var(--muted); text-align: right; margin-top: 4px;
}

/* Group in preview */
.pv-group .pv-sub-list {
  display: flex; flex-direction: column; gap: 14px;
  margin-top: 12px; padding-left: 18px;
  border-left: 2px solid var(--line);
  margin-left: 12px;
}
.pv-group .pv-sub-list .pv-q { border-bottom: 0; padding: 4px 0; }

/* Correction info after submit */
.pv-correction {
  margin-top: 10px; padding: 10px 14px;
  background: #fbfbfd; border: 1px dashed var(--line); border-radius: 10px;
  font-size: 13px; color: var(--ink);
}
.pv-correction b { color: var(--navy); display: block; margin-bottom: 4px; }
.pv-correction code {
  font-family: 'JetBrains Mono', monospace; font-size: 12.5px;
  background: var(--accent-tint); color: var(--navy);
  padding: 1px 6px; border-radius: 4px;
}
.pv-correction-item { margin-right: 12px; }
.pv-correction ul { margin: 4px 0 0 18px; padding: 0; font-size: 13px; }

/* Media in preview */
.pv-image { margin: 10px 0; }
.pv-image-frame {
  height: 200px; border-radius: 12px; display: grid; place-items: center;
  background: repeating-linear-gradient(135deg, #f3f5f9 0 12px, #fbfcfe 12px 24px);
  border: 1px solid var(--line);
}
.pv-image-caption {
  background: #fff; border: 1px solid var(--line);
  padding: 6px 14px; border-radius: 999px;
  color: var(--muted); font-size: 12.5px;
}
.pv-chart {
  padding: 14px 18px 8px; margin: 10px 0;
  border: 1px solid var(--line); border-radius: 12px; background: #fff;
}
.pv-chart-title { font-size: 13px; font-weight: 600; color: var(--ink); margin-bottom: 4px; }
.pv-latex {
  padding: 18px 22px; margin: 10px 0;
  border: 1px solid var(--line); border-radius: 12px; background: #fff;
  font-size: 22px; color: var(--ink);
  text-align: center;
}

/* ==================== Mobile student view ==================== */
.mobile-preview-bg {
  min-height: 100%;
  background:
    radial-gradient(circle at 30% 0%, var(--primary-tint) 0%, transparent 40%),
    radial-gradient(circle at 80% 70%, var(--indigo-tint) 0%, transparent 50%),
    var(--bg);
  padding: 24px 16px;
  display: flex; justify-content: center;
}
.phone-frame {
  width: 380px;
  background: var(--card);
  border-radius: 44px;
  border: 10px solid #0f172a;
  box-shadow:
    0 30px 80px -20px rgba(15,23,42,0.4),
    0 0 0 1px rgba(15,23,42,0.06);
  overflow: hidden;
  position: relative;
  display: flex; flex-direction: column;
  height: 720px;
}
.phone-notch {
  position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
  width: 110px; height: 26px; border-radius: 14px;
  background: #0f172a; z-index: 5;
}
.mv-statusbar {
  height: 44px; padding: 8px 28px 0;
  display: flex; align-items: center; justify-content: space-between;
  font-size: 13px; font-weight: 700; color: var(--ink);
  font-variant-numeric: tabular-nums;
  flex: none;
}
.mv-statusbar .icons { display: flex; gap: 6px; align-items: center; color: var(--ink); font-size: 11px; }

.mv-topbar {
  position: sticky; top: 0; z-index: 4;
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line-soft);
  padding: 12px 16px 10px;
  display: flex; align-items: center; gap: 10px;
}
.mv-exam-title {
  font-size: 12.5px; font-weight: 700; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 110px;
}
.mv-timer {
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px; font-weight: 700;
  background: #fff; border: 1px solid var(--line);
  padding: 6px 12px; border-radius: 9999px;
  color: var(--ink); flex: none;
  font-variant-numeric: tabular-nums;
  margin: 0 auto;
}
.mv-timer.warn { background: var(--warning-tint); border-color: var(--warning); color: #92400e; }
.mv-timer.crit {
  background: var(--danger-tint); border-color: var(--danger); color: #991b1b;
  animation: mvPulse 1s infinite;
}
.mv-timer.timer-warning { animation: mvPulse 0.8s infinite; }
@keyframes mvPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}
.mv-progress-label {
  font-size: 11.5px; font-weight: 700; color: var(--muted); flex: none;
  white-space: nowrap;
}
.mv-flag {
  width: 32px; height: 32px; border-radius: 9999px;
  border: 1px solid var(--line); background: #fff;
  display: grid; place-items: center; cursor: pointer;
  color: var(--muted); flex: none;
}
.mv-flag.on { background: var(--warning-tint); border-color: var(--warning); color: #92400e; }

.mv-progress-strip {
  height: 8px; background: var(--line-soft); position: relative;
  flex: none;
}
.mv-progress-fill {
  position: absolute; left: 0; top: 0; bottom: 0;
  background: linear-gradient(90deg, var(--success) 0%, #34d399 100%);
  border-radius: 0 9999px 9999px 0;
  transition: width .3s ease;
}

.mv-scroll {
  flex: 1; overflow: auto;
  padding: 16px 14px 80px;
}

/* Section header at top of slide */
.mv-section-head {
  background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
  color: #fff;
  border-radius: 14px;
  padding: 18px 20px 16px;
  margin-bottom: 16px;
  box-shadow: 0 10px 24px -12px rgba(15,23,42,0.4);
}
.mv-section-tag-row { display: flex; align-items: center; gap: 6px; margin-bottom: 10px; }
.mv-section-head .mv-part-pill {
  background: rgba(255,255,255,0.18); color: #fff;
  backdrop-filter: blur(8px);
}
.mv-section-head .mv-pts-pill {
  background: var(--success); color: #fff;
}
.mv-section-title {
  margin: 0; font-size: 18px; font-weight: 800; color: #fff;
  letter-spacing: -0.01em; line-height: 1.3;
}
.mv-section-instructions {
  margin-top: 10px; font-size: 14px; color: rgba(255,255,255,0.75);
  line-height: 1.5;
}
.mv-section-prog {
  margin-top: 12px; padding-top: 10px;
  border-top: 1px solid rgba(255,255,255,0.1);
  font-size: 11px; font-weight: 700; color: rgba(255,255,255,0.85);
  text-transform: uppercase; letter-spacing: 0.06em;
}

/* Section blocks list */
.mv-section-blocks { display: flex; flex-direction: column; gap: 12px; }

/* Slide animation */
.mv-slide {
  animation: mvSlideIn 280ms cubic-bezier(0.16, 1, 0.3, 1);
}
.mv-slide[data-dir="-1"] { animation-name: mvSlideInPrev; }
@keyframes mvSlideIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes mvSlideInPrev {
  from { opacity: 0; transform: translateX(-20px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* Block question card on mobile */
.mv-q-card { padding: 16px 14px; }
.mv-q-card .mv-q-card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.mv-q-num {
  background: var(--primary-tint); color: var(--primary);
  padding: 4px 10px; border-radius: 9999px;
  font-size: 12px; font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.mv-group-card { background: #fbfcfe; }
.mv-q-card {
  background: #fff; border-radius: 16px;
  padding: 20px 18px;
  box-shadow: 0 1px 0 rgba(0,0,0,0.02), 0 8px 24px -16px rgba(30,41,59,0.1);
  border: 1px solid var(--line);
}
.mv-q-card-head {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-bottom: 12px;
}
.mv-part-pill {
  background: var(--indigo-tint); color: var(--indigo);
  padding: 4px 10px; border-radius: 9999px;
  font-size: 11px; font-weight: 700;
  white-space: nowrap; max-width: 220px;
  overflow: hidden; text-overflow: ellipsis;
}
.mv-pts-pill {
  background: var(--success-tint); color: var(--success);
  padding: 4px 10px; border-radius: 9999px;
  font-size: 11px; font-weight: 700;
  margin-left: auto;
  white-space: nowrap;
}
.mv-q-prompt {
  font-size: 15px; font-weight: 600; color: var(--ink);
  line-height: 1.5; margin-bottom: 14px;
}
.mv-q-prompt.parent { font-weight: 700; padding-bottom: 4px; }

.mv-sub-list {
  border-left: 4px solid rgba(26, 115, 232, 0.3);
  padding-left: 14px; margin-left: 4px;
  display: flex; flex-direction: column; gap: 16px;
}
.mv-sub-card {
  background: #fff; border: 1px solid var(--line);
  border-radius: 20px; padding: 16px;
  transition: all .15s;
  position: relative;
}
.mv-sub-card.focused {
  border-color: var(--primary); border-width: 2px;
  padding: 15px;
  box-shadow: 0 0 0 4px rgba(26, 115, 232, 0.1);
}
.mv-sub-head {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 10px;
}
.mv-sub-letter-pill {
  background: var(--primary-tint); color: var(--primary);
  padding: 4px 10px; border-radius: 9999px;
  font-size: 12px; font-weight: 700;
}
.mv-sub-flag {
  width: 28px; height: 28px; border-radius: 9999px;
  border: 0; background: transparent; cursor: pointer;
  color: var(--muted); margin-left: auto;
  display: grid; place-items: center;
}
.mv-sub-flag.on { color: var(--warning); }
.mv-sub-prompt {
  font-size: 14.5px; color: var(--ink); margin-bottom: 12px; line-height: 1.5;
}
.mv-input {
  width: 100%; min-height: 56px;
  padding: 14px 16px;
  border: 1.5px solid var(--line); border-radius: 16px;
  font: inherit; font-size: 15px; outline: none;
  background: #fff; color: #0f172a;
  caret-color: var(--primary);
}
.mv-input:focus { border-color: var(--primary); }
.mv-input:disabled { background: #f8fafc; color: var(--muted); }
textarea.mv-input { resize: vertical; line-height: 1.5; min-height: 100px; }

.mv-symbol-bar {
  display: flex; gap: 6px; overflow-x: auto;
  padding: 10px 4px 4px;
  scrollbar-width: none;
}
.mv-symbol-bar::-webkit-scrollbar { display: none; }
.mv-symbol-bar button {
  flex: none; padding: 0 12px; height: 36px;
  border: 1px solid var(--line);
  background: #fff; border-radius: 9999px;
  font-size: 14px; font-weight: 600;
  color: var(--ink); cursor: pointer;
  min-width: 44px;
}
.mv-symbol-bar button:hover { background: var(--primary-tint); border-color: var(--primary); color: var(--primary); }
.mv-symbol-bar button:active { transform: scale(0.95); }

/* MCQ in mobile */
.mv-mcq-opts { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.mv-mcq-opt {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; min-height: 56px;
  border: 1.5px solid var(--line); border-radius: 16px;
  background: #fff; cursor: pointer; transition: all .15s;
}
.mv-mcq-opt:hover { border-color: var(--primary-soft); }
.mv-mcq-opt.sel { border-color: var(--primary); background: var(--primary-tint); }
.mv-mcq-opt.right { border-color: var(--success); background: var(--success-tint); }
.mv-mcq-opt.wrong { border-color: var(--danger); background: var(--danger-tint); }
.mv-mcq-opt .pv-radio { width: 20px; height: 20px; }
.mv-mcq-opt.sel .pv-radio { border-color: var(--primary); }
.mv-mcq-opt.sel .pv-radio-dot { background: var(--primary); }
.mv-mcq-letter { font-weight: 700; color: var(--muted); min-width: 18px; }
.mv-mcq-text { flex: 1; font-size: 14.5px; }

/* Fill blank in mobile */
.mv-sentence { font-size: 15px; line-height: 2.4; color: var(--ink); }
.mv-blank-inline {
  display: inline-block; min-width: 80px;
  padding: 4px 12px;
  border: 0; border-bottom: 2px solid var(--primary);
  background: var(--primary-tint);
  border-radius: 8px 8px 0 0;
  font: inherit; font-weight: 600; color: var(--primary);
  outline: none; text-align: center;
  margin: 0 2px;
}
.mv-blank-inline:focus { background: #fff; border-bottom-width: 3px; }
.mv-blank-inline.ok { border-bottom-color: var(--success); background: var(--success-tint); color: var(--success); }
.mv-blank-inline.bad { border-bottom-color: var(--danger); background: var(--danger-tint); color: var(--danger); }

/* ── Structured template inputs (fraction, sqrt, etc.) ─────────────────── */
.math-tpl-wrap {
  cursor: text;
}
/* Slot input — the editable box inside a template */
.math-tpl-slot {
  border: none;
  border-bottom: 1.5px dashed #94a3b8;
  background: transparent;
  text-align: center;
  min-width: 24px;
  padding: 1px 4px;
  font-size: 14px;
  font-family: inherit;
  color: #1e293b;
  outline: none;
  border-radius: 3px 3px 0 0;
  transition: border-color 0.15s, background 0.15s;
}
.math-tpl-slot:focus {
  border-bottom-color: var(--primary);
  background: rgba(26,115,232,0.06);
}
.math-tpl-slot::placeholder { color: #94a3b8; font-size: 16px; }
.math-tpl-slot-rendered {
  display: inline-flex; align-items: center; justify-content: center;
  cursor: text; min-width: 24px; padding: 1px 4px;
  border-bottom: 1.5px dashed #94a3b8;
}

/* Fraction */
.math-tpl-frac {
  display: inline-flex; flex-direction: column; align-items: center;
  vertical-align: middle; gap: 1px;
}
.math-tpl-num, .math-tpl-den {
  display: flex; justify-content: center; align-items: center;
}
.math-tpl-bar {
  width: calc(100% + 8px); min-width: 32px; height: 1.5px;
  background: #1e293b; margin: 2px -4px;
}

/* Square root */
.math-tpl-sqrt {
  display: inline-flex; align-items: stretch; vertical-align: middle;
}
.math-tpl-radical {
  font-size: 22px; line-height: 1; color: #1e293b;
  display: flex; align-items: center; padding-right: 1px;
}
.math-tpl-radicand {
  border-top: 1.5px solid #1e293b;
  padding: 2px 4px 0;
  display: flex; align-items: center;
}
.math-tpl-nidx {
  font-size: 11px; color: #1e293b; align-self: flex-start; margin-right: -2px;
}

/* Super/subscript */
.math-tpl-script {
  display: inline-flex; align-items: baseline; vertical-align: middle;
}
.math-tpl-base-box {
  color: #94a3b8; font-size: 16px; line-height: 1;
}

/* Integral */
.math-tpl-int {
  display: inline-flex; align-items: center; vertical-align: middle; gap: 2px;
}
.math-tpl-int-sym {
  font-size: 28px; line-height: 1; color: #1e293b;
}
.math-tpl-int-bounds {
  display: flex; flex-direction: column; align-items: flex-start;
  font-size: 11px; gap: 2px;
}

/* Chemistry: reaction / equilibrium arrows */
.math-tpl-xarrow {
  display: inline-flex; flex-direction: column; align-items: center;
  vertical-align: middle; gap: 0;
}
.math-tpl-arrow-cond {
  font-size: 11px; display: flex; align-items: center; justify-content: center;
  min-width: 28px;
}
.math-tpl-arrow-sym {
  font-size: 20px; line-height: 1; color: #1e293b;
}

/* Chemistry: isotope ᴬ_B X */
.math-tpl-isotope {
  display: inline-flex; align-items: center; vertical-align: middle;
}
.math-tpl-iso-scripts {
  display: inline-flex; flex-direction: column;
  align-items: flex-end; font-size: 11px; margin-right: 1px;
}

/* Bottom nav */
.mv-nav {
  position: sticky; bottom: 0;
  display: flex; gap: 12px;
  padding: 12px 16px 24px;
  background: linear-gradient(180deg, rgba(255,255,255,0) 0%, var(--card) 30%);
  z-index: 3;
}
.mv-nav-btn {
  flex: 1; height: 56px;
  border-radius: 18px; border: 0;
  font: inherit; font-size: 15px; font-weight: 700;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.mv-nav-btn.ghost {
  background: var(--surface-low); color: var(--ink);
  border: 1px solid var(--line);
}
.mv-nav-btn.ghost:disabled { opacity: 0.4; cursor: not-allowed; }
.mv-nav-btn.primary { background: var(--navy); color: #fff; }
.mv-nav-btn.submit { background: var(--success); color: #fff; }

.mv-autosave {
  font-size: 11.5px; color: var(--muted); text-align: center;
  padding: 0 16px 14px;
  display: flex; gap: 6px; align-items: center; justify-content: center;
}
.mv-autosave .check {
  width: 14px; height: 14px; border-radius: 9999px;
  background: var(--success); color: #fff;
  display: grid; place-items: center; font-size: 9px;
}

/* Preview pane topbar */
.pv-topbar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 16px;
  background: #fff; border-bottom: 1px solid var(--line);
  flex-shrink: 0; flex-wrap: nowrap;
  position: relative;
}
.pv-label {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.06em;
  white-space: nowrap;
}
.pv-dot {
  width: 7px; height: 7px; border-radius: 9999px;
  background: var(--success); display: inline-block;
}
.pv-prog {
  font-size: 12px; font-weight: 600; color: var(--muted);
  white-space: nowrap;
}
.pv-timer-chip {
  font-size: 12px; font-weight: 700; color: var(--primary);
  background: var(--primary-tint); border-radius: 9999px;
  padding: 3px 10px; white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.pv-timer-chip.warn { color: #d97706; background: #fef3c7; }
.pv-timer-chip.crit { color: #ef4444; background: #fee2e2; animation: pvpulse-red 1s infinite; }
.pv-topbar-timer {
  position: absolute; bottom: 0; left: 0; right: 0; height: 3px;
  background: var(--line);
}
.pv-topbar-timer-fill {
  height: 100%; transition: width 1s linear, background 0.5s;
}

/* Mode toggle */
.pv-mode-toggle {
  display: flex; gap: 0; background: var(--surface-low);
  border-radius: 9999px; padding: 3px; border: 1px solid var(--line);
}
.pv-mode-toggle button {
  padding: 5px 10px; border: 0; background: transparent;
  border-radius: 9999px; font: inherit; font-size: 11.5px; font-weight: 600;
  color: var(--muted); cursor: pointer;
  display: flex; align-items: center; gap: 4px;
}
.pv-mode-toggle button.active {
  background: #fff; color: var(--ink);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* ==================== Submission modal ==================== */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(4px);
  display: grid; place-items: center;
  padding: 20px;
}
.modal-card {
  background: #fff; border-radius: 16px;
  padding: 32px 28px 24px;
  max-width: 440px; width: 100%;
  box-shadow: 0 30px 80px -20px rgba(15,23,42,0.4);
  text-align: center;
}
.modal-card .ico {
  width: 64px; height: 64px; border-radius: 9999px;
  background: var(--primary-tint); color: var(--primary);
  display: grid; place-items: center; margin: 0 auto 14px;
  font-size: 28px;
}
.modal-card h2 { margin: 0 0 6px; font-size: 22px; font-weight: 800; }
.modal-card p { margin: 0 0 12px; color: var(--muted); font-size: 14px; line-height: 1.5; }
.modal-warning {
  background: var(--warning-tint); color: #92400e;
  padding: 12px 14px; border-radius: 14px;
  font-size: 13px; margin: 12px 0;
  display: flex; gap: 10px; align-items: flex-start; text-align: left;
}
.modal-buttons {
  display: flex; gap: 10px; margin-top: 18px;
}
.modal-buttons .pv-btn { flex: 1; height: 50px; border-radius: 12px; font-size: 14px; }

/* ==================== Results screen ==================== */
.results-screen {
  padding: 32px 24px;
  max-width: 540px; margin: 0 auto;
}
.results-hero {
  background: linear-gradient(135deg, var(--navy) 0%, #334155 100%);
  color: #fff; border-radius: 16px;
  padding: 32px 24px; text-align: center;
  position: relative; overflow: hidden;
}
.results-hero::before {
  content: ""; position: absolute; top: -40px; right: -40px;
  width: 200px; height: 200px; border-radius: 9999px;
  background: rgba(255,255,255,0.04);
}
.results-hero h2 { margin: 0 0 4px; font-size: 13px; font-weight: 700; opacity: 0.7; letter-spacing: 0.08em; text-transform: uppercase; }
.results-ring {
  width: 180px; height: 180px; margin: 16px auto 8px; position: relative;
}
.results-ring svg { transform: rotate(-90deg); }
.results-ring .ring-bg { fill: none; stroke: rgba(255,255,255,0.1); stroke-width: 16; }
.results-ring .ring-fg { fill: none; stroke: var(--success); stroke-width: 16; stroke-linecap: round; transition: stroke-dashoffset .8s ease; }
.results-ring .center {
  position: absolute; inset: 0; display: grid; place-items: center;
  text-align: center;
}
.results-ring .score-num {
  font-size: 44px; font-weight: 800; line-height: 1; letter-spacing: -0.02em;
}
.results-ring .score-max { font-size: 14px; opacity: 0.7; margin-top: 4px; }
.results-grade {
  margin-top: 8px; font-size: 16px; font-weight: 600; opacity: 0.95;
}

.results-stats {
  display: grid; grid-template-columns: 1fr 1fr 1fr;
  gap: 10px; margin: 16px 0;
}
.results-stat {
  background: #fff; border: 1px solid var(--line);
  border-radius: 16px; padding: 12px;
  text-align: center;
}
.results-stat b { font-size: 22px; font-weight: 800; color: var(--ink); display: block; }
.results-stat span { font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }

.results-section {
  background: #fff; border: 1px solid var(--line);
  border-radius: 18px; padding: 14px 16px; margin-bottom: 10px;
  display: flex; align-items: center; gap: 12px;
}
.results-section .pill {
  background: var(--indigo-tint); color: var(--indigo);
  padding: 3px 9px; border-radius: 9999px; font-size: 11px; font-weight: 700;
}
.results-section .title { flex: 1; font-weight: 600; font-size: 14px; }
.results-section .bar {
  width: 80px; height: 8px; background: var(--line-soft); border-radius: 9999px;
  overflow: hidden;
}
.results-section .bar-fill { height: 100%; background: var(--success); border-radius: 9999px; }
.results-section .score {
  font-weight: 800; font-size: 14px; color: var(--ink);
  font-variant-numeric: tabular-nums; min-width: 60px; text-align: right;
}

.results-q-list { margin-top: 12px; }
.results-q {
  background: #fff; border: 1px solid var(--line);
  border-radius: 18px; padding: 14px 16px; margin-bottom: 8px;
  display: flex; gap: 12px;
}
.results-q .icon {
  width: 28px; height: 28px; border-radius: 9999px;
  display: grid; place-items: center;
  font-size: 14px; font-weight: 700;
  flex: none;
}
.results-q .icon.ok { background: var(--success-tint); color: var(--success); }
.results-q .icon.bad { background: var(--danger-tint); color: var(--danger); }
.results-q .icon.partial { background: var(--warning-tint); color: var(--warning); }
.results-q .icon.manual { background: var(--surface-low); color: var(--muted); }
.results-q .body { flex: 1; min-width: 0; }
.results-q .num { font-size: 11px; color: var(--muted); font-weight: 700; }
.results-q .q-prompt { font-size: 13.5px; color: var(--ink); font-weight: 600; margin: 2px 0 6px; }
.results-q .answer-row {
  font-size: 12.5px; color: var(--muted); margin-top: 4px;
  display: flex; gap: 6px; align-items: flex-start;
}
.results-q .answer-row b { color: var(--ink); font-weight: 600; }
.results-q .pts {
  font-weight: 800; font-size: 14px; color: var(--ink);
  font-variant-numeric: tabular-nums;
}

/* ==================== Math keyboard ==================== */
.results-back {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--muted); font-weight: 600;
  margin-bottom: 18px; cursor: pointer;
  background: transparent; border: 0; padding: 6px 0;
}
.results-back:hover { color: var(--primary); }

.math-kbd {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 8px 24px -10px rgba(15,23,42,0.15);
  margin-top: 8px;
  overflow: hidden;
}
.math-kbd.inline { margin-top: 8px; }
.math-kbd.docked {
  margin: 0; border-radius: 16px 16px 0 0;
  border-bottom: 0;
  box-shadow: 0 -8px 24px -10px rgba(15,23,42,0.15);
  flex: none;
  max-height: 280px;
  overflow: auto;
}
.math-kbd-tabs {
  display: flex; gap: 2px;
  padding: 6px 8px;
  background: var(--surface-low);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: none;
}
.math-kbd-tabs::-webkit-scrollbar { display: none; }
.math-tab {
  flex: none;
  padding: 6px 12px;
  border: 0; background: transparent;
  border-radius: 8px;
  font: inherit; font-size: 13px; font-weight: 600;
  color: var(--muted); cursor: pointer;
  white-space: nowrap;
  font-family: 'JetBrains Mono', monospace;
}
.math-tab:hover { background: rgba(26, 115, 232, 0.08); color: var(--primary); }
.math-tab.active {
  background: var(--danger); color: #fff;
}
.math-kbd-close {
  margin-left: 4px; padding: 6px 10px;
  border: 0; background: transparent;
  border-radius: 8px;
  font-size: 18px; color: var(--muted);
  cursor: pointer; flex: none;
}
.math-kbd-close:hover { background: var(--danger-tint); color: var(--danger); }
.math-kbd-back {
  margin-left: auto; padding: 6px 12px;
  border: 0; background: var(--surface);
  border-radius: 8px;
  color: var(--ink); cursor: pointer; flex: none;
  display: inline-flex; align-items: center; gap: 4px;
}
.math-kbd-back:hover { background: var(--danger-tint); color: var(--danger); }
.math-kbd-back:active { transform: scale(0.94); }

.math-kbd-keys {
  padding: 8px;
  display: flex; flex-direction: column; gap: 4px;
}
.math-kbd-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.math-key {
  flex: 1 1 auto;
  min-width: 36px;
  min-height: 38px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 14px; font-weight: 500;
  color: var(--ink); cursor: pointer;
  display: grid; place-items: center;
  white-space: nowrap; overflow: hidden;
  transition: all .08s;
}
.math-key:hover {
  background: var(--primary-tint);
  border-color: var(--primary);
  color: var(--primary);
}
.math-key:active {
  transform: scale(0.92);
  background: var(--primary); color: #fff;
}

/* Toggle button to open keyboard */
.kbd-toggle {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 9999px;
  font: inherit; font-size: 11.5px; font-weight: 600;
  color: var(--muted); cursor: pointer;
  margin-top: 6px;
}
.kbd-toggle:hover {
  background: var(--primary-tint);
  border-color: var(--primary);
  color: var(--primary);
}
.kbd-toggle.active {
  background: var(--primary); color: #fff;
  border-color: var(--primary);
}
.kbd-toggle .kbd-icon {
  display: inline-grid; place-items: center;
  font-family: 'JetBrains Mono', monospace; font-weight: 700;
  font-size: 11px;
}

/* ==================== Desmos graph ==================== */
.desmos-wrap {
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #fff;
  margin: 8px 0;
}
.desmos-loading, .desmos-error {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  background: var(--surface-low); color: var(--muted); font-size: 13px;
}
.desmos-error { background: var(--danger-tint); color: var(--danger); }
.desmos-block-toolbar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  background: #fbfbfd; border-top: 1px solid var(--line-soft);
  font-size: 12px; color: var(--muted);
}
.desmos-expr-list {
  padding: 8px 12px; display: flex; flex-direction: column; gap: 6px;
  background: var(--surface-low); border-top: 1px solid var(--line-soft);
}
.desmos-expr {
  display: flex; gap: 8px; align-items: center;
  background: #fff; border: 1px solid var(--line);
  border-radius: 8px; padding: 4px 6px 4px 10px;
}
.desmos-expr .idx {
  font-family: 'JetBrains Mono', monospace; color: var(--muted); font-size: 11px;
  min-width: 18px;
}
.desmos-expr input {
  flex: 1; border: 0; outline: none; background: transparent;
  font: inherit; font-family: 'JetBrains Mono', monospace; font-size: 13px;
  color: var(--ink); padding: 4px 0;
}
.desmos-expr-color {
  width: 12px; height: 12px; border-radius: 2px; flex: none;
}
.desmos-add-expr {
  font-size: 12px; color: var(--muted); background: transparent; border: 1px dashed var(--line);
  padding: 4px 10px; border-radius: 8px; cursor: pointer;
}
.desmos-add-expr:hover { color: var(--primary); border-color: var(--primary); }

.desmos-mode-row {
  display: flex; gap: 4px; padding: 6px 12px;
  background: var(--surface-low); border-bottom: 1px solid var(--line);
  align-items: center; font-size: 12px;
}
.desmos-mode-row label { font-weight: 600; color: var(--muted); margin-right: 6px; }
.desmos-mode-btn {
  padding: 4px 10px; border-radius: 8px; border: 1px solid var(--line);
  background: #fff; font: inherit; font-size: 12px; color: var(--muted); cursor: pointer; font-weight: 600;
}
.desmos-mode-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ====== SEED Graph — student phone preview ====== */
.pv-desmos-wrap {
  margin: 8px 0;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #FAFAF9;
}
.pv-desmos-hint {
  padding: 6px 12px;
  font-size: 11.5px;
  color: var(--muted);
  font-style: italic;
  background: var(--surface-low);
  border-top: 1px solid var(--line-soft);
}
.pv-desmos-hint code {
  background: var(--accent-tint);
  padding: 1px 6px;
  border-radius: 4px;
  font-style: normal;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
}

/* Canvas wrapper */
.sg-wrap { width: 100%; }
.sg-canvas { border-radius: 0; display: block; }
.sg-loading {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: #FAFAF9; color: var(--muted); font-size: 13px;
}

/* Zoom controls */
.sg-controls {
  position: absolute; bottom: 8px; right: 8px;
  display: flex; flex-direction: column; gap: 2px;
}
.sg-ctrl-btn {
  width: 28px; height: 28px; border-radius: 8px;
  border: 1px solid var(--line); background: rgba(250,250,249,0.92);
  color: var(--ink); font-size: 14px; font-weight: 600;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(4px); line-height: 1;
}
.sg-ctrl-btn:active { background: var(--surface); }

/* Interactive: expression input list */
.sg-expr-list {
  padding: 8px 10px; display: flex; flex-direction: column; gap: 6px;
  background: #fff; border-top: 1px solid var(--line-soft);
}
.sg-expr-row {
  display: flex; align-items: center; gap: 6px;
  background: var(--surface-low); border-radius: 8px; padding: 4px 8px;
}
.sg-expr-dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
}
.sg-expr-input {
  flex: 1; border: none; background: transparent;
  font-family: 'JetBrains Mono', monospace; font-size: 13px;
  color: var(--ink); outline: none; padding: 2px 0;
  min-width: 0;
}
.sg-expr-del {
  background: none; border: none; color: var(--muted);
  cursor: pointer; font-size: 16px; line-height: 1; padding: 0 2px; flex-shrink: 0;
}
.sg-add-expr {
  font-size: 12px; color: var(--muted); background: transparent;
  border: 1px dashed var(--line); padding: 5px 10px; border-radius: 8px;
  cursor: pointer; text-align: center;
}
.sg-add-expr:hover { color: var(--primary); border-color: var(--primary); }

/* Plot mode bar */
.sg-plot-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 7px 12px; background: #fff; border-top: 1px solid var(--line-soft);
  gap: 8px;
}
.sg-plot-hint { font-size: 12px; color: var(--muted); flex: 1; }
.sg-clear-pts {
  font-size: 11px; color: var(--danger); background: transparent;
  border: 1px solid var(--danger); border-radius: 6px; padding: 3px 8px; cursor: pointer;
}

/* Table mode */
.sg-table-wrap {
  background: #fff; border-top: 1px solid var(--line-soft);
  padding: 8px 10px; display: flex; gap: 10px; align-items: flex-start;
}
.sg-table { flex: 0 0 auto; min-width: 140px; }
.sg-table-head {
  display: grid; grid-template-columns: 1fr 1fr 24px;
  gap: 4px; padding: 0 0 4px; font-size: 11px;
  font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em;
}
.sg-table-head span { text-align: center; }
.sg-table-row {
  display: grid; grid-template-columns: 1fr 1fr 24px;
  gap: 4px; margin-bottom: 3px;
}
.sg-tbl-cell {
  width: 100%; border: 1px solid var(--line); border-radius: 6px;
  padding: 4px 6px; font-family: 'JetBrains Mono', monospace;
  font-size: 12px; text-align: center; outline: none;
  background: var(--surface-low);
}
.sg-tbl-cell:focus { border-color: var(--primary); background: #fff; }
.sg-tbl-add {
  font-size: 11px; color: var(--muted); background: transparent;
  border: 1px dashed var(--line); padding: 3px 8px; border-radius: 6px;
  cursor: pointer; margin-top: 4px; width: 100%;
}
.sg-table-eq {
  flex: 1; display: flex; flex-direction: column; gap: 4px; padding-top: 2px;
}
.sg-table-eq-label {
  font-size: 10px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.06em;
}

/* ==================== Explanation card ==================== */
.explanation-card {
  margin-top: 12px;
  padding: 14px 16px;
  background: #fbfbfd;
  border: 1px solid var(--line);
  border-left: 3px solid var(--primary);
  border-radius: 12px;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--ink);
}
.explanation-card .lbl {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 700; color: var(--primary);
  text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 6px;
}
.explanation-card .lbl::before {
  content: '💡'; font-size: 14px;
}
.explanation-card .body { color: #1e293b; }

.expl-textarea {
  width: 100%; min-height: 90px; resize: vertical; box-sizing: border-box;
  font-size: 13.5px; padding: 8px 10px; border: 1px solid var(--line);
  border-radius: 10px; outline: none; font-family: inherit; color: var(--ink);
  line-height: 1.6;
}
.expl-textarea:focus { border-color: var(--navy); }
.note-block {
  margin-top: 8px;
  border-radius: 14px;
  padding: 14px 16px;
  display: flex; gap: 12px;
  align-items: flex-start;
  background: var(--primary-tint);
  border: 1px solid var(--primary-soft);
  position: relative;
}
.note-block.warning { background: var(--warning-tint); border-color: #fcd34d; }
.note-block.tip { background: var(--success-tint); border-color: #6ee7b7; }
.note-block.rule { background: var(--indigo-tint); border-color: #c7d2fe; }
.note-icon {
  width: 32px; height: 32px; border-radius: 8px;
  background: #fff;
  color: var(--primary);
  display: grid; place-items: center;
  font-size: 18px; flex: none; font-weight: 700;
  border: 1px solid rgba(26, 115, 232, 0.15);
}
.note-block.warning .note-icon { color: var(--warning); border-color: rgba(245, 158, 11, 0.2); }
.note-block.tip .note-icon { color: var(--success); border-color: rgba(16, 185, 129, 0.2); }
.note-block.rule .note-icon { color: var(--indigo); border-color: rgba(99, 102, 241, 0.2); }
.note-content { flex: 1; min-width: 0; }
.note-title {
  font-size: 13px; font-weight: 700;
  color: var(--ink); margin-bottom: 4px;
  border: 0; outline: none; background: transparent;
  width: 100%; padding: 0;
}
.note-body {
  font-size: 13.5px; line-height: 1.5; color: #1e293b;
  outline: none; word-break: break-word;
}
.note-body:empty::before {
  content: "Saisissez la note pour l'élève…";
  color: rgba(15, 23, 42, 0.4);
}
.note-variant-tabs {
  display: flex; gap: 2px; margin-bottom: 6px;
}
.note-variant-tab {
  padding: 2px 8px; border-radius: 6px; border: 0; background: transparent;
  font: inherit; font-size: 11px; font-weight: 600; color: var(--muted);
  cursor: pointer;
}
.note-variant-tab.active { background: rgba(15, 23, 42, 0.08); color: var(--ink); }

/* Mobile note */
.mv-note {
  border-radius: 16px;
  padding: 14px 16px;
  background: var(--primary-tint);
  border: 1px solid var(--primary-soft);
  display: flex; gap: 12px; align-items: flex-start;
}
.mv-note.warning { background: var(--warning-tint); border-color: #fcd34d; }
.mv-note.tip { background: var(--success-tint); border-color: #6ee7b7; }
.mv-note.rule { background: var(--indigo-tint); border-color: #c7d2fe; }
.mv-note-icon {
  width: 28px; height: 28px; border-radius: 8px;
  background: #fff; color: var(--primary);
  display: grid; place-items: center;
  font-size: 16px; flex: none; font-weight: 700;
}
.mv-note.warning .mv-note-icon { color: var(--warning); }
.mv-note.tip .mv-note-icon { color: var(--success); }
.mv-note.rule .mv-note-icon { color: var(--indigo); }
.mv-note-title { font-size: 12px; font-weight: 700; color: var(--ink); margin-bottom: 2px; }
.mv-note-body { font-size: 13px; color: var(--ink); line-height: 1.5; }

/* ==================== Template menu ==================== */
.tpl-menu-anchor { position: relative; }
.tpl-menu {
  position: absolute; top: 38px; right: 0;
  width: 320px; background: #fff; border-radius: 16px;
  box-shadow: var(--shadow-pop); border: 1px solid var(--line);
  z-index: 60; padding: 8px; max-height: 420px; overflow: auto;
}
.tpl-menu-title {
  text-transform: uppercase; letter-spacing: 0.08em; font-size: 10.5px;
  color: var(--muted); padding: 8px 10px 4px; font-weight: 700;
}
.tpl-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px; border-radius: 10px; cursor: pointer;
  width: 100%; text-align: left; border: 0; background: transparent;
}
.tpl-item:hover { background: var(--accent-tint); }
.tpl-item-ico {
  width: 32px; height: 32px; border-radius: 8px; flex: none;
  background: var(--accent-tint); color: var(--navy);
  display: grid; place-items: center; font-weight: 800; font-size: 12px;
}
.tpl-item-meta { flex: 1; min-width: 0; }
.tpl-item-meta b { font-size: 13.5px; color: var(--ink); display: block; font-weight: 600; }
.tpl-item-meta span { font-size: 11.5px; color: var(--muted); }
.tpl-menu-sep { height: 1px; background: var(--line-soft); margin: 4px 0; }
.tpl-item--import .tpl-item-ico { background: #f0fdf4; color: #166534; font-size: 16px; }
.tpl-item--import:hover { background: #f0fdf4; }
.btn-icon {
  width: 32px; height: 32px; padding: 0; display: grid; place-items: center;
  border-radius: 10px; border: 1px solid var(--line); background: #fff; color: var(--muted);
  cursor: pointer; flex-shrink: 0; transition: background .12s, color .12s;
}
.btn-icon:hover { background: var(--accent-tint); color: var(--navy); border-color: var(--navy); }

/* ==================== Table preview (student view) ==================== */
.pv-table-wrap { margin: 10px 0; }
.pv-table-caption {
  font-size: 12px; color: var(--muted); font-style: italic;
  margin-bottom: 6px; text-align: center;
}
.pv-table-scroll { overflow-x: auto; border-radius: 10px; border: 1px solid var(--line); }
.pv-table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
.pv-table td, .pv-table th { border: 1px solid var(--line); padding: 8px 12px; }
.pv-th { background: var(--surface-low); font-weight: 700; color: var(--navy); text-align: left; }
.pv-td { background: #fff; color: var(--ink); }

/* ==================== Table block ==================== */
.table-block {
  display: flex; flex-direction: column; gap: 8px;
  margin-top: 8px;
}
.table-block-toolbar {
  display: flex; align-items: center; gap: 8px;
}
.table-caption {
  flex: 1; border: 0; border-bottom: 1px dashed var(--line);
  outline: none; background: transparent; font: inherit;
  font-size: 13px; font-style: italic; color: var(--muted);
  padding: 2px 0 4px;
}
.table-caption::placeholder { color: rgba(100,116,139,0.5); }
.table-caption:focus { border-bottom-color: var(--primary); }
.table-header-toggle {
  display: flex; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 600; color: var(--muted);
  cursor: pointer; white-space: nowrap; flex-shrink: 0;
}
.table-header-toggle input[type=checkbox] { accent-color: var(--primary); cursor: pointer; }

.table-scroll {
  overflow-x: auto;
  border-radius: 10px;
  border: 1px solid var(--line);
}
.data-table {
  border-collapse: collapse; width: 100%; min-width: 200px;
  font-size: 13.5px;
}
.data-table td, .data-table th { padding: 0; border: 1px solid var(--line); position: relative; }

/* col-tools row: sits above data rows, each th holds the column × button */
.col-tools-row th { border: 0 !important; background: transparent !important; padding: 0 0 2px; }
.col-tools-row .corner { width: 24px; }
.col-tool { text-align: center; }

/* shared × button for rows and columns */
.row-col-del {
  width: 18px; height: 18px; border-radius: 4px; border: 0;
  background: transparent; color: var(--muted);
  font-size: 14px; line-height: 1; cursor: pointer;
  display: none; align-items: center; justify-content: center; padding: 0; margin: 0 auto;
}
.col-tool:hover .row-col-del,
.row-tool:hover .row-col-del { display: flex; }
.row-col-del:hover { background: var(--danger-tint); color: var(--danger); }

/* + add column: last header cell in col-tools row */
.add-col-cell { width: 32px; border: 0 !important; background: transparent !important; }

/* shared + button (add col / add row) */
.add-rc-btn {
  border: 1px dashed var(--line); background: transparent;
  border-radius: 8px; cursor: pointer; color: var(--muted);
  font: inherit; font-weight: 700;
  transition: background .12s, border-color .12s, color .12s;
}
.add-rc-btn:hover { background: var(--primary-tint); border-color: var(--primary); color: var(--primary); }
.add-col-cell .add-rc-btn {
  width: 26px; height: 26px; font-size: 18px; padding: 0;
  display: flex; align-items: center; justify-content: center;
}
.add-row-btn {
  font-size: 12px; font-weight: 600; padding: 5px 12px; margin-top: 2px;
}

/* row-tool: leftmost cell in each data row — holds row × button */
.row-tool {
  border: 0 !important; background: transparent !important;
  width: 24px; padding: 0 !important; vertical-align: middle; text-align: center;
}

/* data cells */
.data-cell { min-width: 80px; }
.data-cell.is-header-cell { background: #f8fafc; }
.data-cell.is-blank { background: #fffbeb; }
.cell-input {
  width: 100%; border: 0; outline: none; background: transparent;
  font: inherit; font-size: 13px; color: var(--ink);
  padding: 8px 10px; min-width: 80px;
  display: block;
}
.is-header-cell .cell-input { font-weight: 700; color: var(--navy); }
.cell-input:focus { background: var(--primary-tint); }

/* answer hint shown below blank cell text */
.cell-answer {
  display: block; width: 100%; border: 0; border-top: 1px dashed var(--line);
  outline: none; background: transparent; font: inherit;
  font-size: 11.5px; color: var(--primary); padding: 4px 10px;
  font-style: italic;
}
.cell-answer::placeholder { color: rgba(100,116,139,0.45); }

/* toggle-blank button: appears on hover, top-right corner of cell */
.cell-blank-btn {
  position: absolute; top: 3px; right: 3px;
  width: 18px; height: 18px; border-radius: 5px;
  border: 1px solid var(--line); background: #fff; color: var(--muted);
  font-size: 11px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center; padding: 0;
  opacity: 0; transition: opacity .12s, background .12s, color .12s, border-color .12s;
}
.data-cell:hover .cell-blank-btn,
.cell-blank-btn.on { opacity: 1; }
.cell-blank-btn.on { background: #fef3c7; border-color: #f59e0b; color: #b45309; }
.cell-blank-btn:hover { background: var(--primary-tint); border-color: var(--primary); color: var(--primary); }

/* trailing cell (right padding column) */
.row-trailing { border: 0 !important; background: transparent !important; width: 0; padding: 0 !important; }
.add-row-row td { border: 0 !important; background: transparent !important; padding-top: 4px; }

/* info note below the table when blanks are present */
.table-help {
  display: flex; align-items: flex-start; gap: 6px;
  background: #f8fafc; border-radius: 10px; padding: 8px 12px;
  font-size: 12px; color: var(--muted); line-height: 1.45;
}
.table-help .ico { flex-shrink: 0; }

/* Rubric display in results */
.pv-rubric-list { margin-top: 8px; display: flex; flex-direction: column; gap: 4px; }
.pv-rubric-row {
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px; color: #475569; padding: 4px 8px;
  border-radius: 7px; background: #f8fafc;
}
.pv-rubric-pts {
  font-weight: 700; color: var(--navy); min-width: 32px;
  font-size: 11.5px;
}
.pv-rubric-tag {
  font-size: 10px; font-weight: 700; padding: 2px 6px;
  border-radius: 999px; flex-shrink: 0;
}
.pv-rubric-tag.full { background: #dcfce7; color: #166534; }
.pv-rubric-tag.partial { background: #fef9c3; color: #854d0e; }
.pv-rubric-tag.none { background: #fee2e2; color: #991b1b; }
.pv-manual-badge {
  display: inline-block; font-size: 10.5px; font-weight: 700;
  background: #fef3c7; color: #92400e; padding: 2px 8px;
  border-radius: 999px; margin-bottom: 6px;
}

/* ============================================================
   RESPONSIVE — appended
   ============================================================ */

/* ----------------------------------------------------------
   Tablets (≤768px) — collapse sidebar, full-width canvas
   ---------------------------------------------------------- */
@media (max-width: 768px) {
  /* Default (non-split) layout: hide sidebar, let main take full width */
  .app {
    grid-template-columns: 1fr;
  }
  .sidebar {
    display: none;
  }

  /* Split layout: collapse the split-grid to a single column (editor only) */
  .app.split {
    grid-template-columns: 1fr;
  }
  .app.split .sidebar {
    display: none;
  }
  .app.split .split-grid {
    grid-template-columns: 1fr;
  }
  /* Hide the preview pane on tablets — use the dedicated preview button */
  .app.split .preview-pane {
    display: none;
  }
  .app.split .editor-pane {
    border-right: none;
  }
}

/* ----------------------------------------------------------
   Mobile topbar (≤640px) — hide secondary actions
   ---------------------------------------------------------- */
@media (max-width: 640px) {
  .topbar {
    padding: 10px 16px;
    gap: 8px;
    flex-wrap: nowrap;
    overflow-x: auto;
  }
  /* Hide breadcrumbs and collaborator avatars to save space */
  .crumbs {
    display: none;
  }
  .avatar-stack {
    display: none;
  }
  /* Hide secondary .btn elements (undo/redo/export/status pill);
     keep only .btn.primary (Publier) and the split-toggle pill visible */
  .topbar .btn:not(.primary) {
    display: none;
  }
  .topbar .pill {
    display: none;
  }
  .topbar-spacer {
    display: none;
  }
}

/* ----------------------------------------------------------
   Mobile V2 topbar (.topbar2) — hide info pills, keep actions
   ---------------------------------------------------------- */
@media (max-width: 768px) {
  .topbar2 {
    padding: 10px 14px;
    gap: 10px;
  }
  /* Hide informational stat pills — the same counts appear in the
     canvas summary card. The bloquant pill (.tb2-pill--btn) stays. */
  .tb2-pill:not(.tb2-pill--btn) {
    display: none;
  }
  /* Hide the title block to give the action buttons room */
  .tb2-title-block,
  .tb2-left .tb2-divider {
    display: none;
  }
  /* Don't clip the right side — anchor dropdowns must spill below the
     bar. If content somehow overflows at very narrow widths, the page
     gets a horizontal scroll, which is preferable to invisible menus. */
}

/* ≤480px — drop undo/redo too, keep only the back button + actions */
@media (max-width: 480px) {
  .tb2-left .tb2-icon-btn:nth-of-type(2),
  .tb2-left .tb2-icon-btn:nth-of-type(3) {
    display: none;
  }
}

/* ----------------------------------------------------------
   Phone frame scaling (≤440px) — scale down to fit viewport
   ---------------------------------------------------------- */
@media (max-width: 440px) {
  .phone-frame {
    transform: scale(0.85);
    transform-origin: top center;
    /* Compensate for the space the scaled-down frame would leave */
    margin-bottom: calc((720px * -0.15) + 10px);
  }
}

/* ----------------------------------------------------------
   Drawer tabs (mobile) — scroll horizontally, no wrap
   ---------------------------------------------------------- */
@media (max-width: 640px) {
  .drawer-tabs-bar {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .drawer-tabs-bar::-webkit-scrollbar {
    display: none;
  }
  .drawer-tab {
    flex-shrink: 0;
  }
}

/* ----------------------------------------------------------
   Preview paper (mobile) — tighter padding and margin
   ---------------------------------------------------------- */
@media (max-width: 640px) {
  .pv-paper {
    padding: 16px;
    margin: 8px;
    border-radius: 12px;
  }
}

/* ── NEW BLOCK TYPES: multi_select · matching · ordering ── */

/* ── Multi-select (checkbox style) ── */
.checkbox {
  width: 16px; height: 16px;
  border-radius: 4px;           /* square not circle */
  border: 2px solid #cbd5e1;
  background: transparent;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s;
}
.mcq-opt.correct .checkbox {
  background: #22c55e;
  border-color: #22c55e;
}
/* After pseudo for checkmark — same as radio but adapted for square */
.mcq-opt.correct .checkbox::after {
  content: '';
  display: block;
  width: 4px; height: 8px;
  border: 2px solid white;
  border-top: none; border-left: none;
  transform: rotate(45deg) translate(1px, -1px);
  margin: 2px auto 0;
}
/* Student preview checkboxes */
.pv-ms-opt { /* multi-select option row */ }
.pv-ms-opt.selected .pv-ms-box { background: #1e293b; border-color: #1e293b; }
.pv-ms-opt.correct-ans .pv-ms-box { background: #22c55e; border-color: #22c55e; }
.pv-ms-opt.wrong-ans .pv-ms-box { background: #ef4444; border-color: #ef4444; }
.pv-ms-box {
  width: 18px; height: 18px; border-radius: 4px;
  border: 2px solid #cbd5e1; flex-shrink: 0;
  transition: all 0.15s;
}

/* ── Matching block editor ── */
.matching-pairs { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.matching-pair-row {
  display: grid; grid-template-columns: 1fr auto 1fr auto;
  gap: 8px; align-items: center;
}
.matching-input {
  padding: 6px 10px; border: 1px solid #e2e8f0;
  border-radius: 8px; font-size: 13px; outline: none;
  width: 100%;
}
.matching-input:focus { border-color: #1e293b; }
.matching-arrow { color: #94a3b8; font-size: 14px; }

/* Student preview */
.pv-matching { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.pv-matching-row { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; }
.pv-matching-left { font-size: 14px; font-weight: 500; }
.pv-matching-select {
  padding: 6px 10px; border: 1px solid #e2e8f0;
  border-radius: 8px; font-size: 13px; background: white;
  min-width: 140px;
}
.pv-matching-select:disabled { background: #f8fafc; }

/* ── Ordering block editor ── */
.ordering-items { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.ordering-item-row {
  display: grid; grid-template-columns: auto 1fr auto;
  gap: 8px; align-items: center;
}
.ordering-num {
  width: 24px; height: 24px; border-radius: 50%;
  background: #f1f5f9; color: #64748b;
  font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.ordering-input {
  padding: 6px 10px; border: 1px solid #e2e8f0;
  border-radius: 8px; font-size: 13px; outline: none; width: 100%;
}
.ordering-input:focus { border-color: #1e293b; }

/* Student preview */
.pv-ordering { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.pv-ordering-row {
  display: grid; grid-template-columns: auto 1fr;
  gap: 10px; align-items: center;
  padding: 8px 12px; background: #f8fafc;
  border: 1px solid #e2e8f0; border-radius: 10px;
}
.pv-ordering-pos {
  padding: 4px 8px; border: 1px solid #e2e8f0;
  border-radius: 6px; font-size: 13px; background: white;
  min-width: 52px;
}
.pv-ordering-text { font-size: 14px; }
.pv-ordering-row.correct-pos { border-color: #22c55e; background: #f0fdf4; }
.pv-ordering-row.wrong-pos { border-color: #ef4444; background: #fef2f2; }

/* ── Mobile student view: matching & ordering ── */
.mv-matching { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.mv-match-row {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; background: #f8fafc;
  border: 1px solid #e2e8f0; border-radius: 12px;
}
.mv-match-row.right { border-color: #22c55e; background: #f0fdf4; }
.mv-match-row.wrong { border-color: #ef4444; background: #fef2f2; }
.mv-match-left { flex: 1; font-size: 14px; font-weight: 500; color: #0f172a; min-width: 0; }
.mv-match-arrow { color: #94a3b8; font-size: 14px; flex-shrink: 0; }
.mv-match-select {
  flex: 1; padding: 6px 8px; border: 1px solid #cbd5e1;
  border-radius: 8px; font-size: 13px; background: white;
  min-width: 110px; max-width: 160px;
}
.mv-match-select:disabled { background: #f1f5f9; color: #64748b; }
.mv-match-correct { font-size: 12px; color: #22c55e; font-weight: 600; flex-shrink: 0; }

.mv-ordering { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.mv-order-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; background: #f8fafc;
  border: 1px solid #e2e8f0; border-radius: 12px;
}
.mv-order-row.right { border-color: #22c55e; background: #f0fdf4; }
.mv-order-row.wrong { border-color: #ef4444; background: #fef2f2; }
.mv-order-select {
  padding: 5px 8px; border: 1px solid #cbd5e1;
  border-radius: 8px; font-size: 13px; background: white;
  width: 56px; flex-shrink: 0; text-align: center;
}
.mv-order-select:disabled { background: #f1f5f9; color: #64748b; }
.mv-order-text { flex: 1; font-size: 14px; color: #0f172a; }

/* pv-checkbox used in multi_select desktop + mobile */
.pv-checkbox {
  width: 18px; height: 18px; border-radius: 4px;
  border: 2px solid #cbd5e1; display: inline-flex;
  align-items: center; justify-content: center;
  flex-shrink: 0; background: white; transition: all .15s;
}
.pv-opt.sel .pv-checkbox, label.mv-mcq-opt.sel .pv-checkbox {
  background: #1e293b; border-color: #1e293b;
}
.pv-checkbox-check { color: white; font-size: 11px; line-height: 1; }

/* ==================== Parts-as-Slides layout ==================== */
.sticky-header{position:sticky;top:0;z-index:20;background:var(--bg);
  padding:12px 0 10px;margin-bottom:8px;border-bottom:1px solid var(--line)}
.exam-line{display:flex;align-items:center;gap:10px;margin-bottom:11px}
.exam-name{font-size:18px;font-weight:800;letter-spacing:-.01em;color:var(--ink);
  flex:1;min-width:0;padding:3px 6px;border-radius:6px;cursor:text;
  border:0;background:transparent;font-family:inherit;
  transition:box-shadow .12s,background .12s}
.exam-name:hover{box-shadow:0 0 0 1px var(--line)}
.exam-name:focus{outline:none;box-shadow:0 0 0 2px var(--navy);background:#fff}
.exam-name:empty:before{content:attr(data-ph);color:#c2cad6}
.hdr-btn{display:flex;align-items:center;gap:6px;flex:none;font-family:inherit;
  font-size:12.5px;font-weight:700;color:var(--navy);background:var(--card);
  border:1px solid var(--line);border-radius:999px;padding:6px 12px;
  cursor:pointer;transition:all .12s}
.hdr-btn:hover{background:#f1f3f8}
.hdr-btn svg{width:14px;height:14px;color:var(--muted)}
.hdr-btn.eye.on{background:var(--navy);color:#fff;border-color:var(--navy)}
.hdr-btn.eye.on svg{color:#fff}
.rail{display:flex;align-items:center;gap:10px}
.rail .tabs{display:flex;gap:6px;background:var(--card);border:1px solid var(--line);
  border-radius:999px;padding:5px;box-shadow:var(--shadow-card)}
.rail .tab{width:34px;height:34px;border-radius:999px;border:0;cursor:pointer;
  font-family:inherit;font-weight:700;font-size:14px;color:var(--muted);
  background:transparent;transition:all .15s ease;display:grid;place-items:center}
.rail .tab:hover{background:#f1f3f8;color:var(--ink)}
.rail .tab.active{background:var(--navy);color:#fff}
.rail .tab.add{color:var(--muted);font-weight:500;font-size:18px}
.rail .counter{font-size:12.5px;color:var(--muted);font-weight:600;margin-left:auto;
  font-variant-numeric:tabular-nums}
.rail .arrow{width:34px;height:34px;border-radius:999px;border:1px solid var(--line);
  background:var(--card);cursor:pointer;display:grid;place-items:center;color:var(--ink);
  box-shadow:var(--shadow-card);transition:all .15s ease}
.rail .arrow:hover:not(:disabled){background:#f1f3f8}
.rail .arrow:disabled{opacity:.35;cursor:not-allowed}
.rail .arrow svg{width:16px;height:16px}
.slide.enter{animation:ebSlideIn .32s cubic-bezier(.22,.61,.36,1)}
.slide.enter-prev{animation:ebSlideInPrev .32s cubic-bezier(.22,.61,.36,1)}
@keyframes ebSlideIn{from{opacity:0;transform:translateX(34px)}to{opacity:1;transform:none}}
@keyframes ebSlideInPrev{from{opacity:0;transform:translateX(-34px)}to{opacity:1;transform:none}}
@media (max-width:1040px){
  .split-grid.preview-overlay .preview-pane{position:fixed;inset:0;z-index:60;
    background:rgba(15,23,42,.55);display:grid;place-items:center;padding:20px}
}

/* Answer-format selector (Texte / Maths / Chimie) on question blocks */
.answer-format-select{
  font-family:inherit;font-size:11px;font-weight:600;color:var(--muted);
  background:var(--card);border:1px solid var(--line);border-radius:8px;
  padding:3px 6px;cursor:pointer;outline:none;transition:border-color .12s}
.answer-format-select:hover{border-color:var(--navy)}
.answer-format-select:focus{border-color:var(--navy);color:var(--ink)}
