/* ==========================================================
   Kurso – feuille de style commune (même univers que login.css)
   ========================================================== */
:root {
  --bg: #1c1c1c;
  --side: #171717;
  --input-bg: #191919;
  --border: #353535;
  --border-hover: #4a4a4a;
  --line: #4a4a4a;
  --muted: #8c8c8c;
  --faint: #555555;
  --text: #ffffff;
  --text-soft: #dfe6ff;
  --btn-bg: #cccccc;
  --btn-bg-hover: #dddddd;
  --btn-text: #0a0a0a;
  --danger: #e58a8a;
  --ok: #8fc99a;
  --radius: 10px;
  --radius-lg: 14px;
  /* Variables pilotées par js/theme.js (valeurs de repli ci-dessous) */
  --hover: #212121;
  --active: #262626;
  --divider: #2a2a2a;
  --accent: #cccccc;
  --accent-text: #0a0a0a;
  --grid: #2e2e2e;
  --toast-bg: #e6e6e6;
  --toast-text: #111111;
  --focus: #ffffff;
  --font: "Outfit", system-ui, -apple-system, "Segoe UI", sans-serif;
  --fs: 1;
  --row-y: 12px;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  line-height: 1.4;
}
body:has(dialog[open]) { overflow: hidden; }

a { color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Structure : menu latéral + contenu ---------- */
.app { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }

.side {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  padding: 28px 18px;
  background: var(--side);
  border-right: 1px solid var(--divider);
}
.side__logo { display: block; padding: 0 12px; }
.side__logo img { display: block; width: 116px; height: auto; }
.side__nav { display: flex; flex-direction: column; gap: 2px; margin-top: 40px; }
.side__nav a {
  padding: 9px 12px; border-radius: var(--radius);
  color: var(--muted); font-size: calc(14px * var(--fs)); text-decoration: none;
  transition: color .15s ease, background .15s ease;
}
.side__nav a:hover { color: var(--text); background: var(--hover); }
.side__nav a[aria-current="page"] { color: var(--text); background: var(--active); }
.side__foot { margin-top: auto; padding: 0 12px; display: flex; flex-direction: column; gap: 4px; font-size: calc(12px * var(--fs)); color: var(--muted); }
.side__foot a { color: var(--text); text-decoration: none; }
.side__foot a:hover { text-decoration: underline; }

.main { width: 100%; max-width: 1080px; padding: 44px clamp(20px, 5vw, 56px) 80px; }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 36px; }
h1 { margin: 0; font-size: calc(28px * var(--fs)); font-weight: 400; letter-spacing: -0.01em; }
.lead { margin: 8px 0 0; max-width: 56ch; font-size: calc(14px * var(--fs)); line-height: 1.55; color: var(--muted); }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* Titre de section : même trait que le séparateur du login */
.section-title {
  display: flex; align-items: center; gap: 12px;
  margin: 40px 0 18px; font-size: calc(12px * var(--fs)); font-weight: 500; color: var(--text-soft);
}
.section-title::after { content: ""; flex: 1; height: 1px; background: var(--line); order: 1; }
.section-title a { order: 2; font-weight: 400; color: var(--muted); text-decoration: none; }
.section-title a:hover { color: var(--text); }

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 18px;
  background: var(--btn-bg); color: var(--btn-text);
  border: 1px solid transparent; border-radius: var(--radius);
  font: inherit; font-size: calc(13px * var(--fs)); font-weight: 500; text-decoration: none; cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}
.btn:hover { background: var(--btn-bg-hover); }
.btn:disabled { opacity: .5; cursor: default; }
.btn--ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn--ghost:hover { background: var(--hover); border-color: var(--border-hover); }
.btn--sm { height: 34px; padding: 0 14px; font-size: calc(12px * var(--fs)); }
.btn--danger { background: transparent; color: var(--danger); }
.btn--danger:hover { background: color-mix(in srgb, var(--danger) 14%, var(--bg)); }
.btn--danger-solid { background: #c96a6a; color: #150a0a; }
.btn--danger-solid:hover { background: #d77b7b; }
.spacer { margin-right: auto; }

/* ---------- Champs ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > span { font-size: calc(12px * var(--fs)); color: var(--muted); }
.input, .select, .textarea {
  width: 100%;
  background: var(--input-bg); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); font: inherit; font-size: calc(13px * var(--fs)); outline: none;
  transition: border-color .15s ease;
}
.input, .select { height: 40px; padding: 0 12px; }
.textarea { min-height: 84px; padding: 10px 12px; line-height: 1.5; resize: vertical; }
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--border-hover); }
.input:focus-visible, .select:focus-visible, .textarea:focus-visible { border-color: var(--muted); outline: none; }
.select {
  appearance: none; padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238c8c8c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; font-size: calc(13px * var(--fs)); cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }

.note { margin: 0; font-size: calc(12px * var(--fs)); line-height: 1.5; color: var(--muted); }
.note--block { margin-bottom: 14px; }
.msg--error { margin: 0 0 12px; font-size: calc(12px * var(--fs)); color: var(--danger); }
.msg--ok { margin: 0; font-size: calc(13px * var(--fs)); color: var(--ok); }

/* ---------- Filtres ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.toolbar .input { flex: 1 1 220px; max-width: 320px; }
.toolbar .select { width: auto; min-width: 150px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 22px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  height: 32px; padding: 0 12px;
  background: transparent; border: 1px solid var(--border); border-radius: 999px;
  color: var(--muted); font: inherit; font-size: calc(12px * var(--fs)); cursor: pointer;
  transition: border-color .15s ease, color .15s ease;
}
.chip:hover { border-color: var(--border-hover); color: var(--text); }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.chip__n { opacity: .6; }

/* ---------- Liste de cours ---------- */
.list { display: flex; flex-direction: column; background: var(--input-bg); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.row {
  display: grid; grid-template-columns: 40px minmax(0, 1fr) 72px 130px; align-items: center; gap: 14px;
  width: 100%; padding: var(--row-y) 16px;
  background: none; border: 0; border-bottom: 1px solid var(--divider);
  color: inherit; font: inherit; text-align: left; text-decoration: none; cursor: pointer;
  transition: background .15s ease;
}
.row:last-child { border-bottom: 0; }
.row:hover { background: var(--hover); }
.row:focus-visible { outline-offset: -2px; }
.row__title { display: block; font-size: calc(14px * var(--fs)); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row__sub { display: flex; align-items: center; gap: 7px; margin-top: 2px; font-size: calc(12px * var(--fs)); color: var(--muted); }
.row__meta { font-size: calc(12px * var(--fs)); color: var(--muted); text-align: right; }

.badge {
  display: grid; place-items: center; width: 40px; height: 40px;
  background: var(--hover); border: 1px solid var(--border); border-radius: 8px;
  font-size: calc(10px * var(--fs)); font-weight: 500; color: var(--text-soft);
}
.badge--pdf { color: #e9a0a0; border-color: #4a3232; }
.badge--png { color: #a0c4e9; border-color: #2f3d4d; }
.badge--txt { color: #b5d9a8; border-color: #35422f; }
.badge--jpg { color: #a0c4e9; border-color: #2f3d4d; }
.badge--jpeg { color: #a0c4e9; border-color: #2f3d4d; }
.badge--docx { color: #9db8f0; border-color: #2f3a55; }
.badge--xlsx { color: #9fdcae; border-color: #2f4a38; }
.badge--pptx { color: #f0b690; border-color: #55392b; }
.badge--one { color: #cdaaf0; border-color: #433456; }
.badge--fiche { color: #e0cf9a; border-color: #4a4330; }

.dot { flex: none; width: 8px; height: 8px; border-radius: 50%; }
.dot--lg { width: 12px; height: 12px; }

.empty {
  padding: 40px 20px; text-align: center; font-size: calc(14px * var(--fs)); color: var(--muted);
  border: 1px dashed var(--border); border-radius: var(--radius-lg);
}
.empty a { color: var(--text); }

/* ---------- Cartes : matières et fiches ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.subject, .fiche {
  position: relative; display: flex; flex-direction: column; gap: 6px;
  min-height: 112px; padding: 18px;
  background: var(--input-bg); border: 1px solid var(--border); border-radius: var(--radius-lg);
  color: inherit; text-decoration: none;
  transition: border-color .15s ease;
}
.subject:hover, .fiche:hover, .subject:focus-within { border-color: var(--border-hover); }
.subject__name { display: flex; align-items: center; gap: 10px; font-size: calc(16px * var(--fs)); text-decoration: none; }
.subject__name::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }
.subject__name:focus-visible { outline: none; }
.subject:focus-within { border-color: var(--muted); }
.subject__stats { margin: auto 0 0; font-size: calc(12px * var(--fs)); color: var(--muted); }
.subject__edit {
  position: absolute; top: 12px; right: 12px; z-index: 1;
  background: none; border: 0; padding: 4px 6px; border-radius: 6px;
  color: var(--muted); font: inherit; font-size: calc(12px * var(--fs)); cursor: pointer;
}
.subject__edit:hover { color: var(--text); }
.subject--add { align-items: center; justify-content: center; border-style: dashed; color: var(--muted); font: inherit; font-size: calc(13px * var(--fs)); cursor: pointer; }
.subject--add:hover { color: var(--text); }

.fiche__subject { display: flex; align-items: center; gap: 8px; font-size: calc(12px * var(--fs)); color: var(--muted); }
.fiche__title { font-size: calc(16px * var(--fs)); line-height: 1.3; overflow-wrap: anywhere; }
.fiche__stats { margin-top: auto; font-size: calc(12px * var(--fs)); color: var(--muted); }

/* ---------- Zone d’import ---------- */
.drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  min-height: 220px; padding: 32px; text-align: center;
  background: var(--input-bg); border: 1px dashed var(--line); border-radius: var(--radius-lg);
  cursor: pointer; transition: border-color .15s ease, background .15s ease;
}
.drop:hover, .drop.is-over, .drop:focus-within { border-color: var(--muted); background: var(--hover); }
.drop:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
.drop__title { font-size: calc(16px * var(--fs)); }
.drop__hint { font-size: calc(12px * var(--fs)); color: var(--muted); }
.status { margin-top: 16px; display: flex; flex-direction: column; gap: 8px; }
.status ul { margin: 0; padding-left: 18px; font-size: calc(12px * var(--fs)); color: var(--danger); line-height: 1.6; }
.status a { color: var(--text); }

/* ---------- Popups ---------- */
.dlg {
  width: min(860px, calc(100% - 32px)); max-height: calc(100dvh - 32px);
  padding: 0; overflow: auto;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
}
.dlg--md { width: min(480px, calc(100% - 32px)); }
.dlg--sm { width: min(380px, calc(100% - 32px)); }
.dlg::backdrop { background: rgba(0, 0, 0, .65); }
.dlg[open] { animation: pop .16s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.dlg__head { display: flex; align-items: center; justify-content: space-between; padding: 16px 22px; border-bottom: 1px solid var(--divider); }
.dlg__title { margin: 0; font-size: calc(16px * var(--fs)); font-weight: 500; }
.dlg__x { width: 32px; height: 32px; background: none; border: 0; border-radius: 6px; color: var(--muted); font-size: calc(22px * var(--fs)); line-height: 1; cursor: pointer; }
.dlg__x:hover { color: var(--text); background: var(--active); }
.dlg__pad { padding: 20px 22px; }
.dlg__text { margin: 0 0 20px; font-size: calc(14px * var(--fs)); line-height: 1.5; }
.dlg__grid { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); }
.dlg__form { padding: 20px 22px; }
.dlg__tools { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.dlg__actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 10px; }

.preview {
  display: flex; align-items: center; justify-content: center; min-height: 320px; padding: 16px; overflow: hidden;
  background: var(--input-bg); border-right: 1px solid var(--divider);
}
.preview--text { align-items: flex-start; }
.preview img { max-width: 100%; max-height: 420px; object-fit: contain; border-radius: 6px; }
.preview iframe { width: 100%; height: 420px; border: 0; border-radius: 6px; background: #fff; }
.preview__text { width: 100%; max-height: 420px; margin: 0; overflow: auto; font: 12px/1.6 ui-monospace, Menlo, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text-soft); }

.info { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 6px 0 18px; font-size: calc(12px * var(--fs)); }
.info dt { color: var(--muted); }
.info dd { margin: 0; color: var(--text); overflow-wrap: anywhere; }

.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch { width: 26px; height: 26px; padding: 0; border: 2px solid transparent; border-radius: 50%; cursor: pointer; }
.swatch[aria-checked="true"] { border-color: var(--text); box-shadow: inset 0 0 0 2px var(--bg); }

.toasts { position: fixed; bottom: 20px; left: 50%; z-index: 100; display: flex; flex-direction: column; gap: 8px; transform: translateX(-50%); pointer-events: none; }
.toast { padding: 10px 16px; background: var(--toast-bg); color: var(--toast-text); border-radius: var(--radius); font-size: calc(13px * var(--fs)); animation: pop .16s ease-out; }

/* ---------- Page fiche ---------- */
.back { display: inline-block; margin-bottom: 18px; font-size: calc(13px * var(--fs)); color: var(--muted); text-decoration: none; }
.back:hover { color: var(--text); }
.title-input {
  width: 100%; padding: 4px 0;
  background: none; border: 0; border-bottom: 1px solid transparent; outline: none;
  color: var(--text); font: inherit; font-size: calc(28px * var(--fs)); font-weight: 400; letter-spacing: -0.01em;
}
.title-input:hover { border-bottom-color: var(--border); }
.title-input:focus-visible { border-bottom-color: var(--muted); }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 12px 0 0; }
.meta .select { width: auto; height: 34px; font-size: calc(12px * var(--fs)); }
.saved { margin-left: auto; font-size: calc(12px * var(--fs)); color: var(--muted); }
.tools { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }

.tabs { display: flex; gap: 4px; margin: 26px 0 8px; border-bottom: 1px solid var(--line); }
.tab {
  margin-bottom: -1px; padding: 10px 14px;
  background: none; border: 0; border-bottom: 2px solid transparent;
  color: var(--muted); font: inherit; font-size: calc(14px * var(--fs)); cursor: pointer;
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }

.item { display: grid; grid-template-columns: minmax(0, 1fr) 32px; gap: 8px; align-items: start; margin-bottom: 8px; }
.item--pair { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 32px; }
.textarea--auto { min-height: 40px; height: 40px; padding: 9px 12px; line-height: 1.45; overflow: hidden; resize: none; }
.x { width: 32px; height: 40px; background: none; border: 0; border-radius: 6px; color: var(--muted); font-size: calc(18px * var(--fs)); cursor: pointer; }
.x:hover { color: var(--danger); }
.block .note { margin-bottom: 12px; }
.block .add { margin-top: 6px; }

.deck { max-width: 560px; margin: 28px auto 0; text-align: center; }
.deck__count { margin: 0 0 14px; font-size: calc(13px * var(--fs)); color: var(--muted); }
.card {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  width: 100%; min-height: 260px; padding: 32px;
  background: var(--input-bg); border: 1px solid var(--border); border-radius: var(--radius-lg);
  color: var(--text); font: inherit; text-align: center; cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}
.card:hover { border-color: var(--border-hover); }
.card[data-side="back"] { background: var(--active); border-color: var(--muted); }
.card__kind { font-size: calc(12px * var(--fs)); color: var(--muted); }
.card__text { font-size: calc(20px * var(--fs)); line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.deck__actions { display: flex; justify-content: center; align-items: center; gap: 10px; min-height: 40px; margin-top: 16px; }
.deck__title { margin: 0 0 8px; font-size: calc(20px * var(--fs)); font-weight: 400; }

/* ---------- Mobile ---------- */
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .side {
    position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 12px 20px;
    padding: 16px 20px; border-right: 0; border-bottom: 1px solid var(--divider);
  }
  .side__logo { padding: 0; }
  .side__logo img { width: 96px; }
  .side__nav { flex-direction: row; flex-wrap: wrap; margin: 0; }
  .side__foot { flex-direction: row; gap: 12px; margin: 0 0 0 auto; padding: 0; }
  .main { padding-top: 28px; }
}
@media (max-width: 720px) {
  .dlg__grid { grid-template-columns: 1fr; }
  .preview { min-height: 200px; border-right: 0; border-bottom: 1px solid var(--divider); }
  .preview img, .preview__text { max-height: 240px; }
  .preview iframe { height: 240px; }
}
@media (max-width: 640px) {
  .row { grid-template-columns: 40px minmax(0, 1fr); }
  .row__meta { display: none; }
  .row__meta:last-child { display: block; grid-column: 2; text-align: left; }
  .row2 { grid-template-columns: 1fr; }
  .item--pair { grid-template-columns: minmax(0, 1fr) 32px; }
  .item--pair > .x { grid-column: 2; grid-row: 1; }
  .item--pair > .textarea { grid-column: 1; }
  h1, .title-input { font-size: calc(24px * var(--fs)); }
}
@media (prefers-reduced-motion: reduce) {
  .dlg[open], .toast { animation: none; }
  * { transition: none !important; }
}

/* ---------- Impression d’une fiche ---------- */
@media print {
  :root { color-scheme: light; --bg: #fff !important; --input-bg: #fff !important; --text: #000 !important; --text-soft: #222 !important; --muted: #555 !important; --faint: #777 !important; --border: #bbb !important; --line: #bbb !important; --divider: #ddd !important; --hover: #f3f3f3 !important; --active: #eee !important; }
  body { background: #fff; color: #000; }
  .side, .tabs, .tools, .back, .saved, .add, .x, .toasts, #f-course, .section-title::after { display: none !important; }
  .app { display: block; }
  .main { max-width: none; padding: 0; }
  .input, .textarea, .select, .title-input { background: #fff !important; color: #000 !important; border-color: #bbb !important; background-image: none !important; }
  .section-title { color: #000; }
  #panel-cards, #panel-quiz { display: none !important; }
  #panel-sheet { display: block !important; }
}

/* ---------- Tableau ---------- */
.main--wide { max-width: none; }
.tb { gap: 12px; margin-bottom: 14px; }
.tb .btn { position: relative; }
.tb .btn:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
.swatches--sm { gap: 8px; }
.swatch--note { border-radius: 5px; border-color: rgba(0, 0, 0, .3); transition: transform .12s ease; }
.swatch--note:hover { transform: translateY(-2px); }

.board-wrap { position: relative; }
.board {
  height: max(420px, calc(100vh - 300px)); overflow: auto;
  background: radial-gradient(var(--grid) 1px, transparent 1px) 0 0 / 24px 24px, var(--input-bg);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  transition: border-color .15s ease;
}
.board.is-over { border-color: var(--muted); }
/* Pas de barre de défilement : on se déplace en maintenant le clic gauche sur le fond */
.board { scrollbar-width: none; -ms-overflow-style: none; overscroll-behavior: contain; touch-action: none; }
.board::-webkit-scrollbar { display: none; }
html:not([data-cursor="cross"]):not([data-cursor="custom"]) .board { cursor: grab; }
html:not([data-cursor="cross"]):not([data-cursor="custom"]) .board.is-panning { cursor: grabbing; }
.board.is-panning { user-select: none; }

/* Plein écran */
.stage { display: block; }
.stage:fullscreen, .stage.is-pseudo-full { display: flex; flex-direction: column; padding: 12px; background: var(--bg); }
.stage.is-pseudo-full { position: fixed; inset: 0; z-index: 90; }
.stage:fullscreen .tb, .stage.is-pseudo-full .tb { flex: none; }
.stage:fullscreen .board-wrap, .stage.is-pseudo-full .board-wrap { flex: 1; min-height: 0; }
.stage:fullscreen .board, .stage.is-pseudo-full .board { height: 100%; }
.board__surface { position: relative; width: 2400px; height: 1600px; }
.board__hint { position: absolute; inset: 0; display: grid; place-items: center; margin: 0; font-size: calc(14px * var(--fs)); color: var(--faint); pointer-events: none; }

.it { position: absolute; display: flex; flex-direction: column; overflow: hidden; border-radius: 10px; box-shadow: 0 6px 18px rgba(0, 0, 0, .35); }
.it:focus-within { box-shadow: 0 0 0 2px var(--focus), 0 6px 18px rgba(0, 0, 0, .35); }
.it--file { background: var(--active); border: 1px solid var(--border); }
.it--note { background: var(--c, #f7e27a); color: #1a1a1a; }
.it__bar { display: flex; align-items: center; flex: none; gap: 4px; height: 30px; padding: 0 6px 0 10px; font-size: calc(12px * var(--fs)); cursor: grab; touch-action: none; user-select: none; }
.it__bar:active { cursor: grabbing; }
.it__bar:focus-visible { outline-offset: -2px; }
.it--file .it__bar { background: var(--border); color: var(--text); }
.it--note .it__bar { background: rgba(0, 0, 0, .1); }
.it__name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.it__btn {
  display: grid; place-items: center; flex: none; width: 22px; height: 22px; padding: 0;
  background: none; border: 0; border-radius: 5px; color: inherit;
  font: inherit; font-size: calc(16px * var(--fs)); line-height: 1; text-decoration: none; opacity: .7; cursor: pointer;
}
.it__btn:hover { opacity: 1; background: rgba(127, 127, 127, .25); }
.it__dot { width: 13px; height: 13px; border: 2px solid rgba(0, 0, 0, .5); border-radius: 50%; }
.it__body { display: flex; flex: 1; align-items: center; justify-content: center; min-height: 0; padding: 8px; }
.it__body img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 4px; -webkit-user-drag: none; user-select: none; }
.it__pdf { display: flex; flex-direction: column; align-items: center; gap: 8px; font-size: calc(12px * var(--fs)); color: var(--muted); }
.it__text { flex: 1; width: 100%; min-height: 0; padding: 10px 12px; background: none; border: 0; outline: none; resize: none; color: inherit; font: inherit; font-size: calc(14px * var(--fs)); line-height: 1.45; }
.it__text::placeholder { color: rgba(0, 0, 0, .45); }
.it__rs {
  position: absolute; right: 0; bottom: 0; width: 18px; height: 18px; cursor: nwse-resize; touch-action: none;
  background: linear-gradient(135deg, transparent 50%, rgba(127, 127, 127, .8) 50% 58%, transparent 58% 70%, rgba(127, 127, 127, .8) 70% 78%, transparent 78%);
}

/* Aperçu PDF, verrouillage et cartes de documents */
.it__body--pdf { position: relative; padding: 0; align-items: stretch; }
.it__frame { flex: 1; width: 100%; height: 100%; border: 0; background: #fff; }
.it__shield { position: absolute; inset: 0; cursor: pointer; }
.it__kind { font-weight: 500; color: var(--text); font-size: calc(13px * var(--fs)); }
.it__lock { font-size: calc(12px * var(--fs)); }
.it__lock:disabled { cursor: not-allowed; }
.it.is-locked .it__bar { cursor: default; }
.it.is-locked .it__rs { display: none; }
.it.is-locked { box-shadow: 0 0 0 1px color-mix(in srgb, var(--text) 25%, transparent), 0 6px 18px rgba(0, 0, 0, .35); }


/* ---------- Badges en thème clair ---------- */
html[data-scheme="light"] .badge--pdf { color: #a33a3a; border-color: #e3bcbc; }
html[data-scheme="light"] .badge--png, html[data-scheme="light"] .badge--jpg, html[data-scheme="light"] .badge--jpeg { color: #2f6aa3; border-color: #bcd3ea; }
html[data-scheme="light"] .badge--txt { color: #3f7a2f; border-color: #c5dfb9; }
html[data-scheme="light"] .badge--docx { color: #2f4fa3; border-color: #bccaea; }
html[data-scheme="light"] .badge--xlsx { color: #2f7a47; border-color: #b9dfc5; }
html[data-scheme="light"] .badge--pptx { color: #a34f1f; border-color: #eacdbc; }
html[data-scheme="light"] .badge--one { color: #6a3fa3; border-color: #d6c5ea; }
html[data-scheme="light"] .badge--fiche { color: #8a6d12; border-color: #e6d9a8; }

/* ---------- Curseur (réglage « Curseur ») : croix par défaut ---------- */
html[data-cursor="cross"], html[data-cursor="cross"] :where(body, a, button, label, summary, select, [role="button"], .btn, .chip, .drop, .it__bar, .it__btn, .it__shield, .it__rs, .it.is-locked .it__bar, .it__lock:disabled) { cursor: crosshair !important; }
html[data-cursor="custom"], html[data-cursor="custom"] :where(body, a, button, label, summary, select, [role="button"], .btn, .chip, .drop, .it__bar, .it__btn, .it__shield, .it__rs, .it.is-locked .it__bar, .it__lock:disabled) { cursor: url("../curseur.png") 4 4, crosshair !important; }
html[data-cursor="cross"] :where(input:not([type="file"]):not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]), textarea),
html[data-cursor="custom"] :where(input:not([type="file"]):not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]), textarea) { cursor: text !important; }

/* ---------- Animations coupées (réglage « Animations ») ---------- */
html[data-motion="off"] *, html[data-motion="off"] *::before, html[data-motion="off"] *::after { animation: none !important; transition: none !important; }

/* ==========================================================
   Nouvelles fonctions : réglages, statistiques, révision,
   quiz, agenda, minuteur
   ========================================================== */
.side__nav a { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.nav__badge { min-width: 20px; padding: 1px 6px; border-radius: 999px; background: var(--accent); color: var(--accent-text); font-size: calc(11px * var(--fs)); font-weight: 500; text-align: center; }

.panel { padding: 20px; background: var(--input-bg); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.row3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 32px; }
.chips--tight { margin-bottom: 0; }

/* Petites étiquettes */
.star { color: var(--accent); }
.tag { display: inline-block; padding: 1px 8px; border: 1px solid var(--border); border-radius: 999px; font-size: calc(11px * var(--fs)); color: var(--text-soft); }
.tag--todo { color: var(--muted); }
.tag--learning { color: #d9a441; border-color: color-mix(in srgb, #d9a441 45%, var(--border)); }
.tag--done { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 45%, var(--border)); }
.tag--type { margin-right: 4px; }
.tag--controle, .tag--examen { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); }
.fiche__due { color: var(--accent); }
.is-late { color: var(--danger) !important; }

/* Tuiles de statistiques */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 8px; }
.tiles--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.tile { display: flex; flex-direction: column; gap: 2px; padding: 16px 18px; background: var(--input-bg); border: 1px solid var(--border); border-radius: var(--radius-lg); color: inherit; text-decoration: none; transition: border-color .15s ease; }
.tile--link:hover { border-color: var(--border-hover); }
.tile__n { margin: 0; font-size: calc(26px * var(--fs)); font-weight: 400; letter-spacing: -0.01em; }
.tile__l { margin: 0; font-size: calc(13px * var(--fs)); color: var(--text-soft); }
.tile__h { margin: 4px 0 0; font-size: calc(12px * var(--fs)); color: var(--muted); }
.meter { height: 6px; margin-top: 10px; overflow: hidden; background: var(--border); border-radius: 999px; }
.meter > span { display: block; height: 100%; background: var(--accent); border-radius: inherit; transition: width .3s ease; }

/* Histogramme */
.bars { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 10px; align-items: end; height: 170px; padding: 14px 14px 10px; background: var(--input-bg); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.bar { display: grid; grid-template-rows: 16px 1fr 18px; justify-items: center; height: 100%; min-width: 0; }
.bar__val { font-size: calc(11px * var(--fs)); color: var(--muted); }
.bar__track { display: flex; align-items: flex-end; width: 100%; max-width: 34px; height: 100%; }
.bar__fill { display: block; width: 100%; min-height: 3px; background: color-mix(in srgb, var(--accent) 55%, var(--bg)); border-radius: 5px 5px 2px 2px; }
.bar.is-today .bar__fill { background: var(--accent); }
.bar__lbl { font-size: calc(11px * var(--fs)); color: var(--muted); text-transform: capitalize; }
.hbars { display: flex; flex-direction: column; gap: 10px; }
.hbar { display: grid; grid-template-columns: 130px minmax(0, 1fr) 64px; align-items: center; gap: 10px; font-size: calc(12px * var(--fs)); }
.hbar__name { display: flex; align-items: center; gap: 7px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-soft); }
.hbar__track { height: 8px; overflow: hidden; background: var(--border); border-radius: 999px; }
.hbar__track > span { display: block; height: 100%; border-radius: inherit; }
.hbar__val { text-align: right; color: var(--muted); }

/* Révision : boutons de notation et cartes */
.deck__actions { flex-wrap: wrap; }
.deck__actions .grade { flex-direction: column; gap: 2px; height: 52px; min-width: 96px; }
.grade small { font-size: calc(10px * var(--fs)); font-weight: 400; opacity: .7; }
.grade--again { background: transparent; color: var(--danger); border-color: color-mix(in srgb, var(--danger) 50%, var(--border)); }
.grade--again:hover { background: color-mix(in srgb, var(--danger) 14%, var(--bg)); }
.grade--hard { background: transparent; color: var(--text); border-color: var(--border); }
.grade--hard:hover { background: var(--hover); }
.card__sub { display: inline-flex; align-items: center; gap: 6px; }
.deck .note { margin-bottom: 8px; }

/* Quiz */
.deck--quiz { max-width: 640px; text-align: left; }
.deck--quiz .deck__count { text-align: center; }
.quiz__q { display: flex; flex-direction: column; gap: 10px; padding: 24px; margin-bottom: 14px; background: var(--input-bg); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.quiz__opts { display: flex; flex-direction: column; gap: 8px; }
.opt { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 46px; padding: 10px 14px; background: transparent; border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); font: inherit; font-size: calc(14px * var(--fs)); text-align: left; transition: border-color .15s ease, background .15s ease; }
.opt:hover:not(:disabled) { border-color: var(--border-hover); background: var(--hover); }
.opt:disabled { opacity: 1; }
.opt kbd { display: grid; place-items: center; flex: none; width: 22px; height: 22px; border: 1px solid var(--border); border-radius: 5px; font: inherit; font-size: calc(11px * var(--fs)); color: var(--muted); }
.opt.is-right { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 14%, var(--bg)); }
.opt.is-wrong { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 14%, var(--bg)); }

/* Agenda */
.task { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto 32px; align-items: center; gap: 12px; padding: var(--row-y) 16px; border-bottom: 1px solid var(--divider); }
.task:last-child { border-bottom: 0; }
.task__check input { width: 18px; height: 18px; accent-color: var(--accent); }
.task__title { display: block; font-size: calc(14px * var(--fs)); overflow-wrap: anywhere; }
.task.is-done .task__title { text-decoration: line-through; color: var(--muted); }
.task__count { font-size: calc(13px * var(--fs)); color: var(--text-soft); white-space: nowrap; }
.task.is-late .task__count { color: var(--danger); }
.task__link { margin-left: 8px; color: var(--text-soft); }
.task .row__sub { flex-wrap: wrap; }
.task .x { height: 32px; }
.row--deadline { grid-template-columns: 40px minmax(0, 1fr) 0 90px; }
.block { margin-bottom: 8px; }
.block .list { margin-bottom: 8px; }

/* Minuteur Focus */
.focus { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 24px; align-items: start; }
.timer { padding: 28px; text-align: center; background: var(--input-bg); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.timer__phase { margin: 0; font-size: calc(13px * var(--fs)); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.timer__phase[data-phase="break"] { color: var(--ok); }
.timer__time { margin: 8px 0 14px; font-size: calc(76px * var(--fs)); font-weight: 300; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.timer__bar { height: 6px; margin: 0 auto 22px; max-width: 360px; overflow: hidden; background: var(--border); border-radius: 999px; }
.timer__bar > span { display: block; width: 0; height: 100%; background: var(--accent); }
.timer__actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-bottom: 26px; }
.timer__opts { text-align: left; }
.timer .field { text-align: left; }
.focus .panel .tiles { margin-bottom: 0; }
.focus .section-title { margin-top: 28px; }

/* Réglages */
.set { margin-bottom: 8px; }
.set__grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 4px 24px; margin-bottom: 8px; }
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.theme-card { display: flex; flex-direction: column; gap: 8px; padding: 8px 8px 10px; background: var(--input-bg); border: 1px solid var(--border); border-radius: var(--radius-lg); color: var(--text); font: inherit; text-align: left; transition: border-color .15s ease; }
.theme-card:hover { border-color: var(--border-hover); }
.theme-card[aria-checked="true"] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.tc__prev { display: flex; height: 74px; overflow: hidden; border: 1px solid; border-radius: calc(var(--radius) - 2px); }
.tc__side { flex: none; width: 24%; border-right: 1px solid; }
.tc__main { display: flex; flex: 1; flex-direction: column; justify-content: center; gap: 6px; padding: 10px; }
.tc__line { display: block; height: 4px; border-radius: 2px; opacity: .85; }
.tc__btn { display: block; width: 36%; height: 10px; margin-top: 3px; border-radius: 4px; }
.tc__name { padding: 0 4px; font-size: calc(13px * var(--fs)); }
.color { width: 32px; height: 32px; padding: 0; background: none; border: 1px solid var(--border); border-radius: 50%; overflow: hidden; }
.color::-webkit-color-swatch-wrapper { padding: 0; }
.color::-webkit-color-swatch { border: 0; border-radius: 50%; }
.swatches { align-items: center; }
.range-row { display: flex; align-items: center; gap: 12px; height: 40px; }
.range { flex: 1; accent-color: var(--accent); }

@media (max-width: 900px) {
  .focus, .two { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .row3 { grid-template-columns: 1fr; }
  .task { grid-template-columns: 28px minmax(0, 1fr) 32px; }
  .task__count { grid-column: 2; grid-row: 2; }
  .hbar { grid-template-columns: 90px minmax(0, 1fr) 56px; }
  .timer__time { font-size: calc(60px * var(--fs)); }
  .row--deadline { grid-template-columns: 40px minmax(0, 1fr); }
}
@media print {
  #by-fiche, .tiles { display: none !important; }
}

/* Logo clair : inversé sur les thèmes clairs pour rester lisible */
html[data-scheme="light"] img[src$="kurso.png"] { filter: invert(1) brightness(.35); }

/* ---------- Nœuds ---------- */
.nview {
  position: relative; height: max(420px, calc(100vh - 300px)); overflow: hidden; touch-action: none;
  background: radial-gradient(var(--grid) 1px, transparent 1px) 0 0 / 24px 24px, var(--input-bg);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  transition: border-color .15s ease; user-select: none;
}
.nview.is-over { border-color: var(--muted); }
html:not([data-cursor="cross"]):not([data-cursor="custom"]) .nview { cursor: grab; }
html:not([data-cursor="cross"]):not([data-cursor="custom"]) .nview.is-panning { cursor: grabbing; }
html:not([data-cursor="cross"]):not([data-cursor="custom"]) .nview.is-wiring { cursor: crosshair; }
.nworld { position: absolute; left: 0; top: 0; width: 0; height: 0; transform-origin: 0 0; }
.nedges { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; }

.nd { position: absolute; }
.nd__card { position: absolute; inset: 0; display: flex; flex-direction: column; overflow: hidden; border-radius: 10px; background: var(--active); border: 1px solid var(--border); box-shadow: 0 6px 18px rgba(0, 0, 0, .35); }
.nd:focus-within .nd__card { box-shadow: 0 0 0 2px var(--focus), 0 6px 18px rgba(0, 0, 0, .35); }
.nd.is-target .nd__card { box-shadow: 0 0 0 2px var(--accent), 0 6px 18px rgba(0, 0, 0, .35); }
.nd__bar { display: flex; align-items: center; flex: none; gap: 6px; height: 30px; padding: 0 6px 0 10px; font-size: calc(12px * var(--fs)); cursor: grab; touch-action: none; user-select: none; background: var(--border); color: var(--text); }
.nd__bar:active { cursor: grabbing; }
.nd__bar:focus-visible { outline-offset: -2px; }
.nd--title .nd__bar, .nd--note .nd__bar { background: var(--c, #f7e27a); color: #1a1a1a; }
.nd--title .nd__card, .nd--note .nd__card { background: color-mix(in srgb, var(--c, #f7e27a) 14%, var(--active)); border-color: color-mix(in srgb, var(--c, #f7e27a) 55%, var(--border)); }
.nd__body { display: flex; flex: 1; align-items: center; justify-content: center; min-height: 0; padding: 8px; }
.nd__body img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 4px; -webkit-user-drag: none; user-select: none; }
.nd__title { flex: 1; min-height: 0; width: 100%; padding: 0 14px; background: none; border: 0; outline: none; color: var(--text); font: inherit; font-size: calc(26px * var(--fs)); font-weight: 500; user-select: text; }
.nd__title::placeholder { color: var(--faint); }
.nd__text { flex: 1; width: 100%; min-height: 0; padding: 10px 12px; background: none; border: 0; outline: none; resize: none; color: var(--text); font: inherit; font-size: calc(14px * var(--fs)); line-height: 1.45; user-select: text; }
.nd__text::placeholder { color: var(--faint); }
.nd .badge { flex: none; padding: 1px 6px; font-size: 10px; }

/* Points de connexion (entrée à gauche, sortie à droite) */
.nport {
  position: absolute; top: 50%; width: 16px; height: 16px; margin-top: -8px; border-radius: 50%;
  background: var(--bg); border: 2px solid var(--muted); cursor: crosshair; touch-action: none; z-index: 2;
  transition: transform .12s ease, background .12s ease, border-color .12s ease;
}
.nport::after { content: ""; position: absolute; inset: -8px; } /* zone de saisie plus large */
.nport--in { left: -8px; }
.nport--out { right: -8px; }
.nport:hover, .nd.is-target .nport { transform: scale(1.3); background: var(--accent); border-color: var(--accent); }
.nview.is-locked .nport { cursor: not-allowed; }

/* Fils */
.nedge { pointer-events: auto; cursor: pointer; }
.nedge__hit { fill: none; stroke: transparent; stroke-width: 18; }
.nedge__line { fill: none; stroke: var(--muted); stroke-width: 2.5; stroke-linecap: round; transition: stroke .12s ease; }
.nedge:hover .nedge__line { stroke: var(--text-soft); }
.nedge.is-selected .nedge__line { stroke: var(--accent); stroke-width: 3.5; }
.nedge__tmp { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-dasharray: 6 5; stroke-linecap: round; pointer-events: none; }
.nedge__del { display: none; }
.nedge.is-selected .nedge__del { display: block; }
.nedge__del circle { fill: var(--bg); stroke: var(--accent); stroke-width: 2; }
.nedge__del path { fill: none; stroke: var(--text); stroke-width: 2; stroke-linecap: round; }
.nedge__del:hover circle { fill: var(--danger); stroke: var(--danger); }

.stage:fullscreen .nview, .stage.is-pseudo-full .nview { height: 100%; }
.stage:fullscreen .board-wrap, .stage.is-pseudo-full .board-wrap { flex: 1; min-height: 0; }
html[data-cursor="cross"] :where(.nd__bar, .nport, .nedge), html[data-cursor="cross"] .nview { cursor: crosshair !important; }
html[data-cursor="custom"] :where(.nd__bar, .nport, .nedge), html[data-cursor="custom"] .nview { cursor: url("../curseur.png") 4 4, crosshair !important; }
