:root {
  --bg: #f6f4ef;
  --panel: #ffffff;
  --side: #1f2a37;
  --side-text: #d9e1ea;
  --side-muted: #8b98a8;
  --side-hover: #2b3949;
  --ink: #1f2a37;
  --muted: #6b7684;
  --line: #e3dfd6;
  --accent: #b5452f;          /* rouge brique, comme vos vignettes */
  --accent-soft: #f6e4df;
  --blue: #1f3f74;            /* MidnightBlue */
  --ok: #2f7d4f;
  --err: #b42318;
  --radius: 8px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15191f;
    --panel: #1c2128;
    --side: #0f1318;
    --side-hover: #1d242d;
    --ink: #e6e9ee;
    --muted: #96a0ad;
    --line: #2c333d;
    --accent-soft: #3a211b;
    --blue: #8fb1ec;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body { font: 14px/1.45 var(--font); color: var(--ink); background: var(--bg); }
button, input, select { font: inherit; color: inherit; }

button {
  border: 1px solid var(--accent); background: var(--accent); color: #fff;
  border-radius: 6px; padding: 6px 12px; cursor: pointer;
}
button:hover { filter: brightness(1.08); }
button.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
button.ghost:hover { border-color: var(--muted); filter: none; }
button.danger { color: var(--err); }
button.icon {
  background: transparent; border: 1px solid transparent; color: inherit;
  padding: 2px 7px; line-height: 1.2;
}
button.icon:hover { border-color: currentColor; filter: none; }

input[type=text], input[type=password], input[type=search], select {
  border: 1px solid var(--line); background: var(--panel); border-radius: 6px; padding: 6px 9px;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

/* ---------- Connexion ---------- */
body.login { display: grid; place-items: center; padding: 16px; }
.login-card {
  width: min(340px, 100%); background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 28px; display: grid; gap: 10px;
}
.login-card h1 { margin: 0; font-size: 22px; color: var(--accent); }
.login-card p { margin: 0 0 8px; color: var(--muted); }
.login-card .error { color: var(--err); margin: 0; }

/* ---------- Mise en page ---------- */
.app { display: grid; grid-template-columns: 300px 1fr; height: 100vh; }

.sidebar {
  background: var(--side); color: var(--side-text); display: flex; flex-direction: column;
  padding: 14px 10px; gap: 10px; min-height: 0;
}
.brand { display: flex; justify-content: space-between; align-items: baseline; padding: 0 6px; }
.brand span { font-weight: 700; font-size: 17px; letter-spacing: .3px; }
.logout { color: var(--side-muted); font-size: 12px; text-decoration: none; }
.logout:hover { color: var(--side-text); }
.sidebar input[type=search] {
  background: var(--side-hover); border-color: transparent; color: var(--side-text);
}
#tree { flex: 1; overflow: auto; min-height: 0; }
.chapter { margin-bottom: 6px; }
.chapter-head {
  display: flex; align-items: center; gap: 2px; padding: 4px 4px; border-radius: 6px;
  font-weight: 600; font-size: 13px;
}
.chapter-head:hover { background: var(--side-hover); }
.chapter-head .caret { background: none; border: 0; padding: 0 4px; color: var(--side-muted); }
.ch-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: default; }
.ch-actions { display: none; }
.chapter-head:hover .ch-actions { display: flex; }
.ch-actions .icon { color: var(--side-muted); padding: 0 5px; }
.ch-actions .icon:hover { color: var(--side-text); }
.chapter ul { list-style: none; margin: 2px 0 0; padding: 0 0 0 18px; }
.chapter li {
  padding: 5px 8px; border-radius: 6px; cursor: pointer; display: flex; justify-content: space-between;
  gap: 8px; color: var(--side-text);
}
.chapter li:hover { background: var(--side-hover); }
.chapter li.active { background: var(--accent); color: #fff; }
.chapter li.none { color: var(--side-muted); cursor: default; font-style: italic; }
.chapter li.none:hover { background: none; }
.badge {
  font-size: 11px; background: rgba(255,255,255,.12); border-radius: 10px; padding: 0 7px;
  align-self: center;
}
.side-actions { display: flex; gap: 6px; }
.side-actions button { flex: 1; }
.side-actions .ghost { color: var(--side-text); border-color: var(--side-hover); }
.side-actions .ghost.active { background: var(--side-hover); }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.toolbar {
  display: flex; align-items: center; gap: 12px; padding: 12px 18px;
  border-bottom: 1px solid var(--line); background: var(--panel); flex-wrap: wrap;
}
.title-zone { flex: 1; min-width: 220px; display: grid; }
.crumb { font-size: 12px; color: var(--muted); }
#tpl-name { border-color: transparent; font-size: 18px; font-weight: 600; padding: 2px 6px; margin-left: -6px; }
#tpl-name:hover { border-color: var(--line); }
.tool-buttons { display: flex; gap: 6px; align-items: center; }
.tool-buttons select { max-width: 200px; }
.status { font-size: 12px; color: var(--muted); min-width: 150px; text-align: right; }
.status.ok { color: var(--ok); }
.status.dirty { color: var(--muted); }
.status.error { color: var(--err); }

.tabs { display: flex; gap: 2px; padding: 8px 18px 0; }
.tabs button {
  background: transparent; color: var(--muted); border: 0; border-bottom: 2px solid transparent;
  border-radius: 0; padding: 6px 12px;
}
.tabs button.active { color: var(--ink); border-bottom-color: var(--accent); }

.workspace { flex: 1; display: grid; grid-template-columns: 1fr 300px; min-height: 0; }
.editor-zone { position: relative; min-width: 0; min-height: 0; padding: 12px 18px 18px; display: flex; }
#editor, #final { flex: 1; min-width: 0; display: flex; }
.CodeMirror {
  flex: 1; height: auto; border: 1px solid var(--line); border-radius: var(--radius);
  font: 13.5px/1.55 var(--mono); background: var(--panel); color: var(--ink);
}
.CodeMirror-gutters { background: var(--bg); border-right: 1px solid var(--line); }
.CodeMirror-cursor { border-left-color: var(--ink); }
.cm-tpl-var {
  background: var(--accent-soft); color: var(--accent); border-radius: 3px; font-weight: 600;
}
#final .CodeMirror { background: var(--bg); }
@media (prefers-color-scheme: dark) {
  .cm-s-default .cm-tag, .cm-s-default .cm-keyword { color: #e0a36a; }
  .cm-s-default .cm-bracket { color: #9aa5b1; }
  .cm-s-default .cm-comment { color: #7c8794; }
  .cm-s-default .cm-atom, .cm-s-default .cm-number { color: #8fb1ec; }
  .CodeMirror-linenumber { color: #5d6774; }
  .CodeMirror-selected { background: #2c3644 !important; }
}

.empty { margin: auto; text-align: center; color: var(--muted); }
.empty h2 { color: var(--ink); font-size: 18px; margin-bottom: 4px; }

.vars {
  border-left: 1px solid var(--line); background: var(--panel); padding: 16px; overflow: auto;
}
.vars h3 { margin: 0 0 4px; font-size: 14px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.hint { color: var(--muted); font-size: 12.5px; margin: 0 0 12px; }
code { font-family: var(--mono); font-size: 12px; background: var(--bg); padding: 1px 4px; border-radius: 3px; }
.var-row { display: grid; gap: 3px; margin-bottom: 10px; }
.var-row span { font-family: var(--mono); font-size: 12px; color: var(--accent); }
.var-row input { width: 100%; font-family: var(--mono); }
.export { display: grid; gap: 6px; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.warn { color: var(--err); font-size: 12.5px; margin-top: 10px; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; height: auto; }
  .sidebar { max-height: 45vh; }
  .workspace { grid-template-columns: 1fr; }
  .editor-zone { min-height: 60vh; }
  .vars { border-left: 0; border-top: 1px solid var(--line); }
}

/* ---------- Barre latérale : sections ---------- */
:root { --lvl0: #2f6fd6; --lvl1: #2f8f4e; --lvl2: #e08a1e; --lvl3: #8e3fb5; }
.side-scroll { flex: 1; overflow: auto; min-height: 0; }
#tree { overflow: visible; }
.side-title {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 6px 4px; font-size: 11px; letter-spacing: .8px; text-transform: uppercase;
  color: var(--side-muted); font-weight: 600;
}
.side-title .icon { color: var(--side-muted); font-size: 15px; padding: 0 6px; }
.side-title .icon:hover { color: var(--side-text); }
.ex-list { list-style: none; margin: 0 0 6px; padding: 0; }
.ex-list li {
  padding: 6px 8px; border-radius: 6px; cursor: pointer; display: flex; justify-content: space-between;
  gap: 8px; color: var(--side-text);
}
.ex-list li:hover { background: var(--side-hover); }
.ex-list li.active { background: var(--accent); color: #fff; }
.ex-list li.none { color: var(--side-muted); cursor: default; font-style: italic; }
.ex-list li.none:hover { background: none; }

/* ---------- Éditeur d'exercice ---------- */
.exercise { flex: 1; overflow: auto; min-width: 0; padding-right: 4px; }
.start-level { margin-bottom: 14px; }
.start-title { display: block; font-weight: 600; margin-bottom: 6px; }
.start-buttons { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.lvl {
  background: var(--panel); color: var(--ink); border: 1.5px solid var(--line); font-weight: 600;
}
.lvl:hover { filter: none; }
.lvl.lvl-none.active { background: #5b6470; border-color: #5b6470; color: #fff; }
.lvl.lvl-0 { border-color: var(--lvl0); color: var(--lvl0); }
.lvl.lvl-1 { border-color: var(--lvl1); color: var(--lvl1); }
.lvl.lvl-2 { border-color: var(--lvl2); color: var(--lvl2); }
.lvl.lvl-3 { border-color: var(--lvl3); color: var(--lvl3); }
.lvl.lvl-0.active { background: var(--lvl0); color: #fff; }
.lvl.lvl-1.active { background: var(--lvl1); color: #fff; }
.lvl.lvl-2.active { background: var(--lvl2); color: #fff; }
.lvl.lvl-3.active { background: var(--lvl3); color: #fff; }

.q-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; margin-bottom: 10px; box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.q-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.q-label {
  min-width: 30px; height: 30px; padding: 0 6px; border-radius: 15px; display: grid; place-items: center;
  color: #fff; font-weight: 700; font-size: 12px; background: #5b6470;
}
.q-label.lvl-0 { background: var(--lvl0); }
.q-label.lvl-1 { background: var(--lvl1); }
.q-label.lvl-2 { background: var(--lvl2); }
.q-label.lvl-3 { background: var(--lvl3); }
.q-title { font-weight: 600; }
.q-count { color: var(--muted); font-size: 12.5px; }
.q-tools, .item-tools { margin-left: auto; display: flex; gap: 2px; color: var(--muted); }
.icon.danger { color: var(--err); }

.q-items { display: grid; gap: 8px; margin: 10px 0 8px; }
.q-items > .hint { margin: 0; }
.item { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: var(--bg); }
.item-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.item-head .model-select { max-width: 340px; flex: 0 1 auto; }
.item-kind { font-weight: 600; font-size: 13px; }
.item-count { font-size: 12px; color: var(--muted); }
.item-vars {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 6px 10px; margin-top: 8px;
}
.item-vars .var-row { margin: 0; }
.item-vars input.missing { border-color: var(--err); }
.libre-code {
  width: 100%; margin-top: 8px; font: 13px/1.5 var(--mono); border: 1px solid var(--line);
  border-radius: 6px; padding: 8px; background: var(--panel); color: var(--ink); resize: vertical; tab-size: 4;
}
.q-add { display: flex; gap: 6px; flex-wrap: wrap; }
.q-add .model-select { max-width: 300px; }
.add-question { display: flex; align-items: center; gap: 12px; margin: 6px 0 24px; }
.add-question .hint { margin: 0; }

.total { font-size: 22px; font-weight: 700; margin: 4px 0 10px; color: var(--accent); }
.ex-summary { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; }
.ex-summary li { display: flex; justify-content: space-between; font-size: 13px; border-bottom: 1px dashed var(--line); padding-bottom: 3px; }
.sum-label { font-weight: 600; }
.sum-range { font-family: var(--mono); color: var(--muted); }

/* ---------- Onglets de la barre latérale ---------- */
.side-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; background: var(--side-hover); border-radius: 8px; padding: 3px; }
.side-tabs button {
  background: transparent; border: 0; color: var(--side-muted); padding: 6px 4px; font-size: 13px; border-radius: 6px;
}
.side-tabs button.active { background: var(--side); color: var(--side-text); font-weight: 600; }
.tag-filter { display: flex; flex-wrap: wrap; gap: 4px; max-height: 92px; overflow: auto; }
.chip-filter { background: transparent !important; color: var(--side-muted) !important; border: 1px solid var(--side-hover) !important; }
.chip-filter.on { background: #5fb3a8 !important; border-color: #5fb3a8 !important; color: #0f1318 !important; }
.chip-clear { background: none; border: 0; color: var(--side-muted); font-size: 12px; text-decoration: underline; padding: 2px 4px; }

.tree-row {
  display: flex; align-items: center; gap: 4px; padding: 4px 6px; border-radius: 6px; cursor: pointer;
  color: var(--side-text); min-height: 30px;
}
.tree-row:hover { background: var(--side-hover); }
.tree-row.active { background: var(--accent); color: #fff; }
.tree-row .caret {
  background: none; border: 0; padding: 0; width: 16px; color: var(--side-muted); flex: none; font-size: 12px;
}
.tree-row .caret:disabled { cursor: default; }
.tree-row.active .caret { color: #fff; }
.row-icon { flex: none; font-size: 13px; width: 18px; text-align: center; }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { font-size: 11.5px; color: var(--side-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-row.active .row-sub { color: rgba(255,255,255,.8); }
.tree-row .badge { flex: none; }
.side-empty { color: var(--side-muted); font-style: italic; font-size: 13px; padding: 6px 8px; margin: 0; }
.side-empty.indent { padding-left: 28px; }
.side-actions .ghost.active { background: var(--side-hover); }

/* ---------- Puces de tags ---------- */
.chips { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.chip {
  display: inline-flex; align-items: center; gap: 2px; border-radius: 12px; padding: 2px 9px;
  background: #cfe9e5; color: #155e57; font-size: 12.5px; font-weight: 600; border: 0; line-height: 1.5;
}
.chips.small .chip { font-size: 10.5px; padding: 0 6px; }
.tree-row .chips.small { margin-top: 2px; }
.tree-row .chips.small .chip { background: rgba(95,179,168,.22); color: #9fd8d0; }
.tree-row.active .chips.small .chip { background: rgba(255,255,255,.25); color: #fff; }
.chip .chip-x { padding: 0 2px 0 4px; font-size: 13px; line-height: 1; color: inherit; }
.chip-add { background: #e9ecf3; color: #3b4a6b; font-weight: 500; cursor: pointer; }
.chip-add:hover { filter: none; background: #dbe1ee; }
.chip-devoir { background: #e5ebf7; color: #24427a; }
.chip-devoir a { color: inherit; text-decoration: none; }
.chip-devoir a:hover { text-decoration: underline; }
@media (prefers-color-scheme: dark) {
  .chip { background: #1f3b38; color: #9fd8d0; }
  .chip-add { background: #262e3a; color: #b8c4d8; }
  .chip-devoir { background: #222f45; color: #a9c1ee; }
}

.tag-editor { margin-bottom: 12px; display: grid; gap: 6px; }
.tag-row { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.tag-editor .tag-row { margin-bottom: 0; }
.tag-title { font-weight: 600; min-width: 70px; }
.tag-sub { font-size: 11.5px; color: var(--muted); min-width: 70px; }
.tag-input { width: 170px; padding: 3px 8px !important; font-size: 13px; }
.hint.inline { margin: 0; }
.model-select.small { font-size: 12.5px; padding: 3px 6px; }

/* ---------- Vues dossier / devoir ---------- */
.view-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.section-title { margin: 16px 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.card-list { display: grid; gap: 8px; margin-bottom: 12px; }
.list-card {
  display: flex; align-items: center; gap: 10px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 14px; cursor: pointer; flex-wrap: wrap;
}
.list-card:hover { border-color: var(--muted); }
.list-name { font-weight: 600; }
.list-meta { color: var(--muted); font-size: 12.5px; margin-left: auto; }
.ex-card {
  display: flex; align-items: center; gap: 12px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 10px 14px;
}
.ex-num {
  width: 30px; height: 30px; border-radius: 15px; display: grid; place-items: center; flex: none;
  background: var(--lvl1); color: #fff; font-weight: 700; font-size: 13px;
}
.ex-main { flex: 1; min-width: 0; display: grid; gap: 3px; }
.ex-main .list-meta { margin-left: 0; }
.ex-name { font-weight: 600; color: var(--ink); text-decoration: none; }
.ex-name:hover { text-decoration: underline; }
button.small { padding: 3px 9px; font-size: 12.5px; }
.workspace.no-panel { grid-template-columns: 1fr; }
.crumb-link { color: var(--muted); text-decoration: none; }
.crumb-link:hover { color: var(--accent); text-decoration: underline; }

/* ---------- Fenêtre modale ---------- */
.modal {
  border: 0; border-radius: 14px; padding: 0; width: min(440px, calc(100vw - 32px));
  background: var(--panel); color: var(--ink); box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.modal::backdrop { background: rgba(15,19,24,.45); }
.modal form { padding: 20px 22px 18px; display: grid; gap: 10px; }
.modal h3 { margin: 0; font-size: 17px; }
.modal-msg { margin: 0; color: var(--muted); }
.modal-label { font-size: 13px; color: var(--muted); }
.modal input, .modal select { width: 100%; font-size: 15px; padding: 8px 10px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
button.danger-fill { background: var(--err); border-color: var(--err); }

/* ---------- Numéro de question saisi ---------- */
.q-label-input {
  width: 110px; font-weight: 700; font-size: 15px; padding: 4px 8px !important;
  border: 1.5px solid var(--lvl1) !important; color: var(--lvl1); border-radius: 16px !important; text-align: center;
}
.q-label-input.missing { border-color: var(--err) !important; }
#tpl-name.invalid { border-color: var(--err); }

/* ---------- Aperçu ---------- */
.preview { margin: 8px 0 30px; border-top: 1px solid var(--line); padding-top: 6px; }
.preview-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.preview-head .section-title { margin: 10px 0; }
.preview-status { color: var(--muted); font-size: 12.5px; flex: 1; }
.preview-status.busy::before {
  content: ''; display: inline-block; width: 10px; height: 10px; margin-right: 6px; vertical-align: -1px;
  border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.preview-auto { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 4px; cursor: pointer; }
.preview-strip {
  display: flex; gap: 22px; overflow-x: auto; overflow-y: hidden; padding: 4px 2px 14px;
  scroll-snap-type: x proximity; transition: opacity .2s; overscroll-behavior-x: contain;
}
.preview-strip.stale { opacity: .45; }
.pv-group { flex: none; display: flex; flex-direction: column; gap: 6px; }
.pv-group + .pv-group { border-left: 2px dashed var(--line); padding-left: 22px; }
.pv-group-title { font-weight: 700; font-size: 13px; color: var(--lvl1); position: sticky; left: 0; }
.pv-row { display: flex; gap: 14px; }
.vign { margin: 0; flex: none; scroll-snap-align: start; }
.vign img {
  height: min(var(--vh, 380px), calc(var(--pvh, 62vh) - 150px)); width: auto; aspect-ratio: 95 / 140; display: block; background: #fff;
  border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 2px 6px rgba(0,0,0,.10); cursor: zoom-in;
}
.vign figcaption { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); margin-top: 5px; }
.vign-num {
  min-width: 20px; height: 20px; border-radius: 10px; background: var(--lvl0); color: #fff; font-weight: 700;
  font-size: 11px; display: grid; place-items: center; padding: 0 5px;
}
.preview-error {
  border: 1px solid var(--err); background: #fdf1ef; border-radius: 10px; padding: 12px 14px; color: var(--ink);
}
.preview-error.stale { opacity: .55; }
.preview-error p { margin: 6px 0; }
.preview-error pre {
  margin: 4px 0; padding: 8px; background: var(--panel); border-radius: 6px; font: 12px/1.45 var(--mono);
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.preview-error summary { cursor: pointer; font-size: 12.5px; color: var(--muted); margin-top: 6px; }
@media (prefers-color-scheme: dark) { .preview-error { background: #2c1b19; } }
.lightbox {
  position: fixed; inset: 0; background: rgba(10,12,16,.82); display: flex; flex-direction: column;
  align-items: center; justify-content: center; z-index: 50; cursor: zoom-out; padding: 16px;
}
.lightbox img { max-height: 86vh; max-width: 100%; background: #fff; border-radius: 10px; }
.lightbox p { color: #fff; margin-top: 10px; }

/* ---------- Choix des questions dans l'aperçu ---------- */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.seg button { background: var(--panel); color: var(--muted); border: 0; border-radius: 0; padding: 3px 10px; font-size: 12.5px; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--ink); color: var(--panel); }
.seg button:hover { filter: none; }
.pv-chooser { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 12px; }
.pv-chip {
  background: transparent; color: var(--muted); border: 1.5px dashed var(--line); border-radius: 14px;
  padding: 2px 11px; font-weight: 700; font-size: 13px;
}
.pv-chip.on { background: var(--lvl1); border: 1.5px solid var(--lvl1); color: #fff; }
.pv-chip:hover { filter: none; border-color: var(--lvl1); }
.chip-clear { color: var(--muted) !important; }
.pv-eye { font-size: 12px; border: 1px solid var(--line) !important; border-radius: 12px; padding: 2px 8px !important; margin-right: 4px; color: var(--muted); }
.pv-eye.on { background: var(--lvl1); border-color: var(--lvl1) !important; color: #fff; }
.q-card.pv-off .pv-eye { text-decoration: line-through; }

/* ---------- Exercice : questions défilantes, aperçu fixé en bas ---------- */
#exercise { display: flex; flex-direction: column; overflow: hidden; padding-right: 0; min-height: 0; }
#exercise .ex-edit { flex: 1 1 auto; min-height: 140px; overflow: auto; padding-right: 6px; }
#exercise .preview-dock {
  flex: none; display: flex; flex-direction: column; max-height: 75vh; min-height: 0;
  background: var(--bg); box-shadow: 0 -6px 12px -10px rgba(0,0,0,.25);
}
#exercise .preview { flex: 1; min-height: 0; margin: 0; padding: 2px 4px 0; overflow-y: auto; border-top: 0; }
.preview-handle {
  flex: none; height: 10px; cursor: row-resize; border-top: 2px solid var(--line); position: relative; touch-action: none;
}
.preview-handle::after {
  content: ''; position: absolute; left: 50%; top: 2px; width: 44px; height: 4px; margin-left: -22px;
  border-radius: 2px; background: var(--line);
}
.preview-handle:hover::after { background: var(--muted); }
#exercise .preview .section-title { margin: 8px 0; }
#exercise .pv-chooser { margin-bottom: 8px; }
#exercise .preview-strip { padding-bottom: 10px; }

.q-card.collapsed { padding: 6px 14px; background: transparent; border-style: dashed; box-shadow: none; cursor: default; }
.q-card.collapsed .q-head { opacity: .7; }
.q-card.collapsed:hover .q-head { opacity: 1; }
.q-card.collapsed .q-label-input { font-size: 13px; padding: 2px 8px !important; width: 90px; }
.hidden-note { font-size: 12.5px; color: var(--muted); }
.hidden-note:hover { color: var(--accent); }

/* ---------- Zone d'aperçu : fond distinct ---------- */
:root { --dock: #dfe4ec; --dock-line: #c3cbd8; }
@media (prefers-color-scheme: dark) { :root { --dock: #10151c; --dock-line: #2f3a48; } }
#exercise .preview-dock {
  background: var(--dock); border-radius: 12px 12px 0 0; margin: 6px -6px 0;
  border: 1px solid var(--dock-line); border-bottom: 0; box-shadow: 0 -8px 16px -12px rgba(0,0,0,.35);
}
#exercise .preview { background: transparent; padding: 2px 14px 0; }
#exercise .preview-handle { border-top: 0; height: 12px; }
#exercise .preview-handle::after { background: var(--dock-line); top: 4px; }
#exercise .preview-handle:hover::after { background: var(--muted); }
#exercise .pv-group + .pv-group { border-left-color: var(--dock-line); }
#exercise .vign img { border-color: var(--dock-line); box-shadow: 0 2px 8px rgba(20,30,50,.14); }
#exercise .seg button { background: rgba(255,255,255,.7); }
#exercise .seg button.on { background: var(--ink); color: var(--panel); }
@media (prefers-color-scheme: dark) { #exercise .seg button { background: rgba(255,255,255,.05); } }
