/* Mêmes couleurs et polices que les fiches de révision : indigo 藍, vermillon 朱 */
:root {
  color-scheme: light;
  --bg: #f6f7fb; --paper: #ffffff; --ink: #1d2233; --muted: #5d6478; --line: #dde1ec;
  --ai: #2b3f8c; --ai-soft: #e6eaf7; --shu: #c2412d; --ok: #23804f; --ko: #c62a2a;
  /* Titres et boutons : ce qu'un thème de professeur peut changer (couleurs et image de fond seulement) */
  --title: var(--ink); --bg-image: none;
  --btn-bg: var(--paper); --btn-fg: var(--ink);
  --btn-hover-bg: var(--ai-soft); --btn-hover-fg: var(--ai);
  --f-jp-display: "Klee One", "Hiragino Mincho ProN", "Yu Mincho", serif;
  --f-jp: "Zen Kaku Gothic New", "Hiragino Sans", "Yu Gothic", "Meiryo", sans-serif;
  --f-fr: "Atkinson Hyperlegible", "Segoe UI", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #12141c; --paper: #1a1d28; --ink: #e8eaf2; --muted: #a2a8bb; --line: #2d3242;
    --ai: #9fb1f0; --ai-soft: #252c47; --shu: #f08a74; --ok: #6fd39c; --ko: #ff8f86;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #12141c; --paper: #1a1d28; --ink: #e8eaf2; --muted: #a2a8bb; --line: #2d3242;
  --ai: #9fb1f0; --ai-soft: #252c47; --shu: #f08a74; --ok: #6fd39c; --ko: #ff8f86;
}

* { box-sizing: border-box; }
body { margin: 0; background-color: var(--bg); background-image: var(--bg-image); background-size: cover; background-position: center; background-attachment: fixed; color: var(--ink); font: 16px/1.5 var(--f-fr); }
a { color: var(--ai); }
.wrap { max-width: 860px; margin: 0 auto; padding: 16px 16px 48px; }
h1 { font-size: 1.4rem; margin: 16px 0 8px; color: var(--title); }
h2 { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 24px 0 8px; }
h3 { color: var(--title); }
.muted { color: var(--muted); }
.jp { font-family: var(--f-jp-display); }

header.site { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 10px 16px; background: var(--paper); border-bottom: 1px solid var(--line); }
header.site .brand { font-weight: 700; color: var(--title); text-decoration: none; }
header.site .brand .jp { color: var(--ai); font-size: 1.2rem; }
header.site nav { display: flex; flex-wrap: wrap; gap: 12px; flex: 1; }
header.site nav a { text-decoration: none; font-weight: 500; }
header.site .who { color: var(--muted); font-size: .9rem; }
header.site .logout { font-size: .9rem; }

.impersonation { background: var(--shu); color: #fff; padding: 8px 16px; font-size: .92rem; }
.impersonation a { color: #fff; font-weight: 700; margin-left: 8px; }

.list { list-style: none; margin: 0; padding: 0; background: var(--paper); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.list .row { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; padding: 10px 14px; border-top: 1px solid var(--line); }
.list .row:first-child { border-top: 0; }

.card { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 16px; display: grid; gap: 12px; }
label { display: grid; gap: 4px; font-weight: 500; }
label.check { display: flex; gap: 8px; align-items: center; font-weight: 400; }
input[type=email], input[type=password], input[type=text], select, textarea {
  font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
}
button { font: inherit; cursor: pointer; border-radius: 999px; padding: 8px 18px; border: 1px solid var(--line); background: var(--btn-bg); color: var(--btn-fg); }
button:not(.link):hover { background: var(--btn-hover-bg); color: var(--btn-hover-fg); }
button.primary { background: var(--ai); border-color: var(--ai); color: var(--paper); font-weight: 700; }
button.primary:hover { background: color-mix(in srgb, var(--ai) 85%, #000); color: var(--paper); }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 2px solid var(--ai); outline-offset: 2px; }

.flash { padding: 10px 14px; border-radius: 8px; background: var(--ai-soft); color: var(--ai); }
.flash-error { background: transparent; border: 1px solid var(--ko); color: var(--ko); }

.login { max-width: 380px; margin: 8vh auto 0; }
.login .jp-title { font-family: var(--f-jp-display); font-size: 2rem; color: var(--ai); }

/* Petits éléments communs */
.small { font-size: .85rem; }
.lead { max-width: 65ch; }
.badge { display: inline-block; font: 700 .75rem var(--f-fr); padding: 2px 8px; border-radius: 999px; background: var(--ai-soft); color: var(--ai); }
.badge-deb { background: var(--paper); border: 1px solid var(--ai); }
.mod { box-shadow: inset 0 -2px 0 var(--shu); }
.tag-en { font-size: .72rem; font-weight: 700; color: var(--shu); border: 1px solid var(--shu); border-radius: 4px; padding: 0 4px; margin-left: 4px; }
.credits { margin-top: 32px; }

/* Barre de recherche et onglets de niveau */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 12px 0; }
.toolbar input[type=search], .vocab-filters input[type=search], .lookup input[type=search] { flex: 1 1 240px; font: inherit; color: var(--ink); background: var(--paper); border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px; }
.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.tabs a { text-decoration: none; color: var(--ink); background: var(--paper); border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px; font-weight: 500; font-size: .9rem; }
.tabs a[aria-current] { background: var(--ai); border-color: var(--ai); color: var(--paper); }
.tabs a .count { opacity: .7; font-size: .8rem; }
.tabs .toggle { margin-left: auto; }
.pager { display: flex; flex-wrap: wrap; gap: 4px; margin: 16px 0; }
.pager a { min-width: 2.2em; text-align: center; padding: 4px 8px; border-radius: 6px; text-decoration: none; border: 1px solid var(--line); background: var(--paper); }
.pager a[aria-current] { background: var(--ai); color: var(--paper); border-color: var(--ai); }

/* Table des kanji */
.kanji-table .kanji-row { display: grid; grid-template-columns: 3.4rem minmax(0, 1fr) minmax(0, 1.6fr) auto; gap: 4px 16px; align-items: center; padding: 10px 14px; border-top: 1px solid var(--line); }
.kanji-table .kanji-row:first-child { border-top: 0; }
.kanji-table .is-custom { box-shadow: inset 3px 0 0 var(--shu); }
.k { font-family: var(--f-jp-display); font-size: 2.2rem; line-height: 1; text-align: center; }
.readings { display: grid; gap: 2px; font-family: var(--f-jp); min-width: 0; }
.readings .rl { display: flex; gap: 8px; align-items: baseline; }
.readings i { font: 700 .66rem var(--f-fr); font-style: normal; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); min-width: 2.2em; }
.meaning { display: grid; gap: 2px; min-width: 0; }
.meaning .example { font-size: .9rem; display: flex; flex-wrap: wrap; gap: 0 8px; }
.meaning .example [lang=ja] { font-family: var(--f-jp); }
.meaning .note { font-size: .85rem; font-style: italic; color: var(--muted); }
.side { display: grid; justify-items: end; gap: 2px; text-align: right; }
.side .edit { font-weight: 700; }
@media (max-width: 640px) {
  .kanji-table .kanji-row { grid-template-columns: 3rem minmax(0, 1fr); }
  .kanji-table .meaning, .kanji-table .side { grid-column: 2; }
  .side { justify-items: start; text-align: left; display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }
  .tabs .toggle { margin-left: 0; }
}

/* Formulaire de version du professeur */
.kanji-head { display: flex; gap: 16px; align-items: center; }
.kanji-head .k { font-size: 4.5rem; }
.kanji-head h1 { margin: 0; }
.form > div, .form fieldset > div > div { display: grid; gap: 4px; }
.form .help-text, .form [id$=_help] { font-size: .82rem; color: var(--muted); }
.form input::placeholder { color: var(--muted); opacity: .75; }
.form fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px 12px; margin: 0; }
.form legend { font-weight: 700; padding: 0 4px; }
.pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.pair.three { grid-template-columns: 1fr 1fr 2fr; }
@media (max-width: 640px) { .pair, .pair.three { grid-template-columns: minmax(0, 1fr); } }
.actions { display: flex; gap: 12px; align-items: center; }
.reset { margin-top: 12px; }
.reset button { color: var(--ko); border-color: var(--ko); }
.flash-success { background: var(--ai-soft); color: var(--ai); }

/* Explication repliable (lecture on / kun) */
.explain { background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 8px 14px; margin: 12px 0; max-width: 70ch; }
.explain summary { cursor: pointer; font-weight: 700; color: var(--ai); }
.explain dl { margin: 8px 0 0; }
.explain dt { font-weight: 700; margin-top: 8px; }
.explain dt [lang=ja] { font-family: var(--f-jp); color: var(--ai); margin-left: 4px; }
.explain dd { margin: 2px 0 0; color: var(--muted); }
.explain dd [lang=ja] { font-family: var(--f-jp); color: var(--ink); }
.badge-none { background: transparent; border: 1px dashed var(--muted); color: var(--muted); }
.common-value { margin: 2px 0 0; font-size: .82rem; color: var(--shu); }
.common-value [lang=ja] { font-family: var(--f-jp); }

/* Classes et élèves */
.title-row { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px; }
.list .student-row { align-items: center; }
.who-cell { flex: 1 1 260px; min-width: 0; }
form.inline { display: inline-flex; gap: 6px; align-items: center; margin: 0; }
button.link { border: 0; background: none; padding: 4px 6px; color: var(--ai); text-decoration: underline; border-radius: 4px; }
button.link.danger, .danger-text { color: var(--ko); }
a.button { display: inline-block; text-decoration: none; border-radius: 999px; padding: 8px 18px; background: var(--btn-bg); color: var(--btn-fg); border: 1px solid var(--line); }
a.button:hover { background: var(--btn-hover-bg); color: var(--btn-hover-fg); }
a.button.primary { background: var(--ai); color: var(--paper); font-weight: 700; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.flash-warning { background: transparent; border: 1px solid var(--shu); color: var(--shu); }
.form ul { margin: 0; padding-left: 18px; color: var(--ko); font-size: .88rem; }

/* Mes élèves */
.classes-cell { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { display: inline-block; font-size: .85rem; background: var(--ai-soft); color: var(--ink); border-radius: 999px; padding: 2px 10px; }
.enrollment-row { display: grid !important; gap: 8px; }
.enrollment-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; }
.enrollment-actions { display: flex; flex-wrap: wrap; gap: 8px 20px; align-items: center; }
.enrollment-actions label, .inline-card label { display: inline-flex; gap: 6px; align-items: center; font-weight: 500; }
.inline-card { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.inline-card p { flex: 0 0 100%; margin: 0; }

/* Furigana (comme dans les fiches) et exercices */
.furi { font-size: .72em; color: var(--muted); font-weight: 400; }
.blank { color: var(--ai); font-weight: 700; }
.case { display: inline-block; min-width: 2.4em; border-bottom: 2px solid var(--muted); margin: 0 3px; text-align: center; color: transparent; }
.case.star { color: var(--shu); border-color: var(--shu); }
.furigana-preview { display: block; font-size: .9rem; color: var(--ai); margin-top: 2px; font-family: var(--f-jp); }
[lang=ja] { font-family: var(--f-jp); }

/* Éditeur de fiches */
.button-outline { display: inline-block; text-decoration: none; border: 1px solid var(--ai); color: var(--ai); background: var(--btn-bg); border-radius: 999px; padding: 6px 14px; font-weight: 500; }
.button-outline:hover { background: var(--btn-hover-bg); color: var(--btn-hover-fg); }
.add-sections { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.add-sections button:disabled { opacity: .45; cursor: not-allowed; }
.add-sections .jp { color: var(--ai); margin-right: 4px; }
.kind-jp { color: var(--ai); margin-right: 6px; }
.section-row { display: grid !important; gap: 4px; }
.section-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.section-actions { margin-left: auto; display: inline-flex; gap: 8px; align-items: center; }
.kana-line { font-size: 1.3rem; letter-spacing: .1em; margin: 0; }
.recap-editor { min-height: 280px; background: var(--paper); color: var(--ink); border-radius: 8px; }
trix-toolbar .trix-button-group { background: var(--paper); }
.rename { margin: 8px 0 16px; }
.word-row, .exercise-row { display: grid !important; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: 4px 16px; align-items: start; }
.exercise-row { grid-template-columns: minmax(0, 1fr) auto; }
.word-main { display: grid; gap: 2px; }
.jp-big { font-size: 1.25rem; }
.spelling { font-size: .95rem; }
.word-meaning .note, .exercise-preview .note { display: block; font-size: .85rem; font-style: italic; color: var(--muted); }
.item-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: flex-end; }
.exercise-preview p { margin: 4px 0; }
.exercise-preview .answer { color: var(--ai); }
.choices { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.choice.correct { color: var(--ok); font-weight: 700; }
.spellings { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
@media (max-width: 640px) {
  .word-row, .exercise-row { grid-template-columns: minmax(0, 1fr); }
  .item-actions { justify-content: flex-start; }
  .section-actions { margin-left: 0; }
}
.assign-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; margin-top: 12px; }
.assign-grid .card { align-content: start; }

/* Tableau traditionnel des kana (五十音図) : colonnes de droite à gauche, kana en boutons */
.gojuon { display: flex; flex-direction: row-reverse; flex-wrap: wrap; justify-content: flex-start; gap: 6px; }
.gojuon-col { display: flex; flex-direction: column; gap: 4px; }
.gojuon .col-head { font: 700 .95rem var(--f-jp); padding: 4px 0; border-radius: 6px; border: 1px dashed var(--line); background: transparent; color: var(--muted); min-width: 3rem; }
.gojuon .col-head span { font-size: .7rem; margin-left: 1px; }
.gojuon .col-head[aria-pressed="true"] { border-style: solid; border-color: var(--ai); color: var(--ai); }
.kana-key { position: relative; display: grid; place-items: center; min-width: 3rem; padding: 0 4px; white-space: nowrap; height: 3rem; border-radius: 10px; border: 1px solid var(--line); background: var(--paper); font: 400 1.5rem var(--f-jp); cursor: pointer; box-shadow: 0 2px 0 var(--line); transition: transform .05s, box-shadow .05s; user-select: none; }
.kana-key input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.kana-key:has(input:checked) { background: var(--ai); border-color: var(--ai); color: var(--paper); box-shadow: inset 0 2px 4px rgb(0 0 0 / .25); transform: translateY(2px); }
.kana-key:has(input:focus-visible) { outline: 2px solid var(--ai); outline-offset: 2px; }
.kana-key.empty { border-color: transparent; background: transparent; box-shadow: none; cursor: default; }
@media (max-width: 640px) { .kana-key, .gojuon .col-head { min-width: 2.4rem; } .kana-key { height: 2.4rem; font-size: 1.2rem; } }

/* Mots : recherche dans le vocabulaire, proposition du mot existant, graphie imposée */
.flash-info { background: var(--ai-soft); border: 1px solid var(--ai); color: var(--ink); }
.lookup { display: grid; gap: 8px; margin-bottom: 12px; }
.lookup h2 { margin: 0; font-size: 1rem; }
.lookup-results:empty { display: none; }
.lookup-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding: 8px 12px; border-top: 1px solid var(--line); }
.lookup-row:first-child { border-top: 0; }
.lookup-row .what { flex: 1 1 220px; min-width: 0; }
.lookup-row .actions, .suggestion .actions { display: flex; flex-wrap: wrap; gap: 6px; }
.suggestion { display: grid; gap: 8px; }
.chip.forced { background: transparent; border: 1px solid var(--shu); color: var(--shu); }
.vocab-filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.vocab-filters input[type=search] { min-width: 0; }
.vocab-row { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 2fr) auto; gap: 6px 12px; align-items: center; padding: 10px 12px; border-top: 1px solid var(--line); }
.vocab-row:first-child { border-top: 0; }
.vocab-row .sheets { font-size: .85rem; color: var(--muted); }
@media (max-width: 640px) { .vocab-row { grid-template-columns: minmax(0, 1fr); } }

/* Ordre des éléments au glisser-déposer */
.sortable-list > li { position: relative; padding-left: 40px !important; }
.drag-handle { position: absolute; left: 0; top: 0; bottom: 0; width: 34px; display: flex; align-items: center; justify-content: center; font-size: 1.2rem; color: var(--muted); cursor: grab; touch-action: none; user-select: none; }
.drag-handle:hover { color: var(--ai); background: var(--ai-soft); }
.drag-chosen .drag-handle { cursor: grabbing; }
.drag-ghost { opacity: .45; background: var(--ai-soft); }
.sortable-list[aria-busy=true] { cursor: progress; }
/* Poignée : six points dessinés, sans dépendre d'une police */
.drag-handle::before { content: ""; width: 10px; height: 16px; background: radial-gradient(circle, currentColor 1.6px, transparent 1.9px) 0 0 / 5px 5.5px; }

/* Classe : choix entre ses cours et ses élèves */
.class-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 8px 0 16px; }
.class-tabs a { padding: 10px 18px; text-decoration: none; color: var(--muted); font-weight: 600; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.class-tabs a:hover { color: var(--ink); }
.class-tabs a[aria-current=page] { color: var(--ai); border-bottom-color: var(--ai); }
.class-tabs .count, .class-choice .count { display: inline-block; min-width: 1.6em; padding: 0 6px; margin-left: 4px; font-size: .8rem; line-height: 1.5; text-align: center; border-radius: 999px; background: var(--ai-soft); color: var(--ink); }
.class-row, .course-row { display: flex !important; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.class-row .who-cell, .course-row .who-cell { flex: 1 1 220px; min-width: 0; }
.class-choice { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.class-choice .button { border: 1px solid var(--line); color: var(--ai); font-weight: 600; padding: 6px 16px; }
.class-choice .button:hover { background: var(--ai-soft); }
.assign-sheet { align-items: center; margin-top: 12px; }
.assign-sheet select { flex: 1 1 220px; min-width: 0; }

/* Accès d'un élève suspendu */
.chip.suspended { background: transparent; border: 1px solid var(--shu); color: var(--shu); }
.is-suspended .who-cell a strong { color: var(--muted); }

/* Élève : choix de la classe, rubriques, progression */
.class-cards { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.class-card { display: grid; gap: 4px; padding: 16px; background: var(--paper); border: 1px solid var(--line); border-radius: 12px; text-decoration: none; color: var(--ink); }
a.class-card:hover { border-color: var(--ai); box-shadow: 0 2px 10px rgba(0, 0, 0, .06); }
a.class-card strong { color: var(--ai); font-size: 1.1rem; }
.student-tabs { flex-wrap: wrap; }
.student-tabs a { white-space: nowrap; padding: 10px 14px; }
.score-cell { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.meter { display: inline-block; width: 120px; height: 8px; border-radius: 999px; background: var(--ai-soft); overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--ok); border-radius: 999px; }
.progress-block { margin-top: 20px; }
.progress-block h3 { margin: 12px 0 6px; font-size: .95rem; color: var(--muted); }
.progress-row { display: flex !important; flex-wrap: wrap; align-items: center; gap: 6px 16px; }
.progress-row .who-cell { flex: 1 1 180px; min-width: 0; }
.progress-block .title-row { flex-wrap: wrap; gap: 8px; }
.score-cell { display: grid; gap: 2px; justify-items: start; }
.score-dir { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; }
.score-dir .dir-label { min-width: 9.5em; color: var(--muted); }

/* Professeur : progression des élèves d'une classe */
.table-scroll { overflow-x: auto; background: var(--paper); border: 1px solid var(--line); border-radius: 10px; }
.progress-table { border-collapse: collapse; width: 100%; min-width: 640px; font-size: .88rem; }
.progress-table th, .progress-table td { padding: 8px 10px; border-top: 1px solid var(--line); text-align: left; vertical-align: top; }
.progress-table thead th { border-top: 0; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.progress-table tbody th { font-weight: 600; }
.progress-table tbody th .small { display: block; font-weight: 400; }
.progress-table tfoot th, .progress-table tfoot td { background: var(--ai-soft); }
.progress-table .is-suspended th a { color: var(--muted); }
.pct { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.pct .dir { font-size: .72rem; color: var(--muted); min-width: 4.2em; }
.pct .meter { width: 36px; height: 6px; }
.progress-table tfoot .meter { background: var(--paper); }

/* Format d'échange XML */
.row-links { display: inline-flex; gap: 12px; margin-left: auto; }
.title-actions { display: inline-flex; flex-wrap: wrap; gap: 8px 16px; }
.exchange { margin: 4px 0 12px; }

/* Import d'une fiche */
.import-errors ul { margin: 6px 0 0; padding-left: 18px; }
.import-sections .row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.conflict { margin: 12px 0; display: grid; gap: 10px; }
.conflict legend { font-size: 1.3rem; padding: 0 6px; }
.conflict-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.conflict-table th, .conflict-table td { text-align: left; vertical-align: top; padding: 6px 8px; border-top: 1px solid var(--line); }
.conflict-table thead th { border-top: 0; color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; }
.conflict-table tbody th { width: 7em; color: var(--muted); font-weight: 600; }
.conflict-table td .spelling { display: inline-block; margin-right: 10px; }
.conflict .choices { display: grid; gap: 4px; }
@media (max-width: 640px) { .conflict-table tbody th { width: auto; } }
.conflict-table strong.diff { color: var(--ko); font-weight: 800; }
.conflict-table tr.differs th { color: var(--ko); }

/* Kanji d'une fiche : colonne des cases de largeur fixe, cases alignées à gauche ;
   en tête de liste, une case « tout » par colonne, exactement au-dessus de celles des kanji */
.sheet-kanji .kanji-row { grid-template-columns: 3.4rem minmax(0, 1fr) minmax(0, 1.6fr) 15rem; }
.sheet-kanji .side { justify-items: start; text-align: left; }
.sheet-kanji .kanji-head { display: grid; grid-template-columns: minmax(0, 1fr) 15rem; gap: 4px 16px; align-items: center; padding: 10px 14px; background: var(--ai-soft); border-bottom: 1px solid var(--line); }
.sheet-kanji .kanji-head + .kanji-row { border-top: 0; }
.kanji-head .head-label { font-weight: 700; }
.kanji-head .side { gap: 2px; }
.kanji-head .bulk { display: flex; align-items: center; gap: 10px; width: 100%; }
.kanji-head .bulk-count { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--muted); }
@media (max-width: 640px) {
  .sheet-kanji .kanji-row, .sheet-kanji .kanji-head { grid-template-columns: 3rem minmax(0, 1fr); }
  .sheet-kanji .kanji-head .head-label { grid-column: 1 / -1; }
  .sheet-kanji .kanji-head .side { grid-column: 2; display: grid; }
}
.kanji-row { scroll-margin-top: 80px; }
/* Message « Enregistré » flottant : il ne décale pas la page */
.kanji-status { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 40; background: var(--ink); color: var(--paper); border-radius: 999px; padding: 8px 18px; font-size: .9rem; box-shadow: 0 4px 16px rgba(0, 0, 0, .15); }
.kanji-status:empty { display: none; }

/* Thèmes des cours */
.theme-filter { margin: 4px 0 14px; }
a.chip.theme { text-decoration: none; }
a.chip.theme:hover { background: var(--ai); color: var(--paper); }

/* Exercice : aperçu élève en temps réel, au-dessus du formulaire (grand écran seulement) */
.live-preview { display: none; }
@media (min-width: 1000px) {
  .live-preview { display: block; margin-bottom: 16px; }
}
.live-preview h2 { margin: 0 0 8px; }
.live-card { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; display: grid; gap: 12px; }
.live-instructions { margin: 0; font-weight: 600; }
.live-type { margin: 0; font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.live-label { background: var(--ai); color: var(--paper); border-radius: 6px; padding: 1px 8px; letter-spacing: 0; }
.live-uncertain { border: 1px dashed var(--shu); color: var(--shu); border-radius: 6px; padding: 0 6px; text-transform: none; letter-spacing: 0; }
.live-question { font-size: 1.25rem; line-height: 2.1; }
.live-question .blank { color: var(--ai); font-weight: 700; }
.live-question .case { display: inline-block; min-width: 2.2em; border-bottom: 2px solid var(--ink); text-align: center; margin: 0 2px; }
.live-question .case.star { color: var(--shu); }
.live-choices { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; }
.live-choice-label { color: var(--muted); }
.live-choice { border: 1px solid var(--line); border-radius: 8px; padding: 4px 12px; background: var(--bg); font-size: 1.05rem; }
.live-answer { border-top: 1px dashed var(--line); padding-top: 10px; display: grid; gap: 4px; }
.live-answer-label { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ok); font-weight: 700; }
.live-answer > div { font-size: 1.1rem; }
.live-answer p { margin: 0; }
.live-error { margin: 0; padding: 12px 14px; border: 1px solid var(--shu); color: var(--shu); border-radius: 10px; background: var(--paper); }
/* Correction de l'aperçu, comme dans l'interface de l'élève */
.live-answer mark { background: var(--ai-soft); color: var(--ai); padding: 0 3px; border-radius: 4px; font-weight: 600; }
.live-answer .ans-n { font-weight: 700; font-size: .74rem; color: var(--ai); margin-left: 6px; }

/* Éditeur mis en forme des exercices */
.rich-editor { border: 1px solid var(--line); border-radius: 10px; background: var(--paper); overflow: hidden; }
.rich-editor:focus-within { border-color: var(--ai); box-shadow: 0 0 0 2px var(--ai-soft); }
.rich-toolbar { display: flex; flex-wrap: wrap; gap: 2px; padding: 4px; border-bottom: 1px solid var(--line); background: var(--bg); }
.rich-tool { border: 1px solid transparent; background: transparent; border-radius: 6px; min-width: 32px; height: 30px; padding: 0 8px; font: inherit; font-size: .9rem; color: var(--ink); cursor: pointer; }
.rich-tool:hover { background: var(--ai-soft); }
.rich-tool[data-command="hole"] { margin-left: auto; border-color: var(--ai); color: var(--ai); font-weight: 600; }
.swatch { display: inline-block; width: 14px; height: 14px; border-radius: 3px; vertical-align: middle; }
.swatch.rouge { background: #c62a2a; } .swatch.bleu { background: #2b3f8c; }
.rich-area { padding: 8px 12px; line-height: 1.9; outline: none; white-space: pre-wrap; word-break: break-word; }
.rich-area[lang="ja"] { font-family: var(--f-jp); font-size: 1.05rem; }
.hole-chip { display: inline-block; margin: 0 2px; padding: 0 6px; border-radius: 6px; background: var(--ai-soft); color: var(--ai); border: 1px solid var(--ai); cursor: pointer; line-height: 1.6; user-select: none; }
.hole-chip:hover { background: var(--ai); color: var(--paper); }
.hole-dialog { border: 0; border-radius: 14px; padding: 0; width: min(520px, calc(100vw - 32px)); box-shadow: 0 12px 40px rgba(0, 0, 0, .25); background: var(--paper); color: var(--ink); }
.hole-dialog::backdrop { background: rgba(20, 24, 40, .45); }
.hole-form { padding: 18px 20px; display: grid; gap: 8px; }
.hole-form h2 { margin: 0; font-size: 1.1rem; }
.hole-items { margin: 0; padding-left: 22px; display: grid; gap: 6px; }
.hole-item { display: flex; align-items: center; gap: 6px; }
.hole-item input[type=text] { flex: 1 1 auto; min-width: 0; font: inherit; font-family: var(--f-jp); padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--ink); }
.hole-mark { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; font-size: .85rem; color: var(--muted); margin: 0; }
.hole-error { margin: 0; color: var(--ko); }
/* Mise en forme : rouge et bleu, à l'élève comme au professeur */
.hl-rouge { color: #c62a2a; } .hl-bleu { color: #2b3f8c; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .hl-rouge { color: #ff8f86; } :root:not([data-theme="light"]) .hl-bleu { color: #9fb1f0; } }
:root[data-theme="dark"] .hl-rouge { color: #ff8f86; } :root[data-theme="dark"] .hl-bleu { color: #9fb1f0; }
/* Bouton de mise en forme actif : enfoncé ; un second clic l'enlève */
.rich-tool[aria-pressed="true"] { background: var(--ai); border-color: var(--ai); color: var(--paper); }
.rich-tool[aria-pressed="true"] .swatch { box-shadow: 0 0 0 2px var(--paper); }
/* Aperçu d'un texte à compléter : la zone de saisie de chaque trou */
.live-question .live-gap { display: inline-block; width: 6.5em; height: 1.7em; margin: 0 4px; vertical-align: middle; border: 2px solid var(--ai); border-radius: 6px; background: var(--ai-soft); }

/* Chapitres des cours, section Révisions */
.new-chapter { display: flex; flex-wrap: wrap; align-items: end; gap: 8px 14px; margin-bottom: 16px; }
.new-chapter label:first-of-type { flex: 1 1 240px; display: grid; gap: 4px; }
.chapter { margin: 18px 0; }
.chapter-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 12px; margin-bottom: 6px; }
.chapter-head h3 { margin: 0; font-size: 1.05rem; }
.chapter-actions { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.chapter-edit summary { cursor: pointer; color: var(--ai); text-decoration: underline; }
.chapter-edit[open] { flex-basis: 100%; }
.chapter-edit form { margin-top: 6px; }
.chip.revision { background: var(--shu); color: var(--paper); }
/* Cours en brouillon : invisible des élèves */
.chip.draft { background: var(--paper); border: 1px dashed var(--muted); color: var(--muted); text-transform: uppercase; font-size: .72rem; letter-spacing: .04em; }
.publication { margin: 0; }
.revisions-title { margin-top: 28px; padding-top: 12px; border-top: 2px solid var(--shu); color: var(--shu); }
.chapter.is-revision .list { border-color: color-mix(in srgb, var(--shu) 35%, var(--line)); }
.class-chapter { margin: 16px 0 6px; font-size: 1rem; }
.new-chapter .check { margin-bottom: 11px; }

/* Mes chapitres : glisser-déposer */
.chapter-list > li, .drop-list > li[data-id] { display: flex !important; flex-wrap: wrap; align-items: center; gap: 4px 12px; }
.chapter-list .who-cell, .drop-list .who-cell { flex: 1 1 220px; min-width: 0; }
.drop-list { min-height: 52px; }
.drop-list .empty-hint { display: none; padding: 14px; text-align: center; }
.drop-list .empty-hint:only-child { display: block; }
.drop-list.pool { background: var(--bg); border-style: dashed; }
.in-chapter .course-add, .pool .course-remove { display: none; }
.chapter-board h2 { margin-top: 20px; }
/* Élève : filtre par chapitre */
.chapter-filter { margin: 4px 0 12px; align-items: center; }
.chapter-filter .filter-sep { font-size: .8rem; font-weight: 700; color: var(--shu); margin-left: 6px; }
.chapter-filter a.is-revision { border-color: var(--shu); }
.chapter-filter a.is-revision[aria-current] { background: var(--shu); border-color: var(--shu); }

/* Tags en étiquettes : pastilles avec croix, puis la zone d'ajout, à la ligne quand il le faut */
.tag-input { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); cursor: text; }
.tag-input:focus-within { border-color: var(--ai); box-shadow: 0 0 0 2px var(--ai-soft); }
.tag-chips { display: contents; list-style: none; margin: 0; padding: 0; }
.tag-chip { display: inline-flex; align-items: center; gap: 2px; background: var(--ai-soft); color: var(--ink); border: 1px solid color-mix(in srgb, var(--ai) 35%, transparent); border-radius: 999px; padding: 2px 4px 2px 10px; font-size: .9rem; }
.tag-remove { border: 0; background: transparent; color: var(--muted); font-size: 1.05rem; line-height: 1; width: 22px; height: 22px; border-radius: 50%; cursor: pointer; padding: 0; }
.tag-remove:hover { background: var(--ai); color: var(--paper); }
.tag-entry { flex: 1 1 140px; min-width: 120px; border: 0 !important; background: transparent !important; box-shadow: none !important; padding: 4px !important; font: inherit; color: var(--ink); outline: none; }
.tag-entry:focus-visible { outline: none; }

/* Blocs repliables (ouverts par défaut) : le titre avec une flèche */
details.fold { margin: 18px 0; }
details.fold > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::before, .fold-toggle::before { content: ""; width: 8px; height: 8px; border-right: 2px solid var(--ai); border-bottom: 2px solid var(--ai); transform: rotate(45deg); transition: transform .15s; flex: none; margin: 0 4px; }
details.fold:not([open]) > summary::before, .fold-toggle[aria-expanded="false"]::before { transform: rotate(-45deg); }
details.fold > summary h2 { margin: 0; }
details.fold > summary:hover h2 { color: var(--ai); }
details.fold[open] > summary { margin-bottom: 10px; }
.fold-toggle { border: 0; background: transparent; width: 26px; height: 26px; border-radius: 6px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; }
.fold-toggle:hover { background: var(--ai-soft); }

/* Vue d'ensemble d'une fiche : un groupe d'exercices avec sa consigne, ses thèmes et ses exercices */
.summary-instructions { margin: 4px 0; font-weight: 600; }
.summary-tags { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0; }
.summary-exercises { margin: 6px 0 2px; padding-left: 22px; display: grid; gap: 4px; }
.summary-exercises li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; }
.summary-exercises .live-label { font-size: .75rem; background: var(--ai); color: var(--paper); border-radius: 6px; padding: 0 6px; }

/*
 * Actions d'un cours en icônes, sur une ligne au-dessus de son titre (listes des fiches,
 * d'un chapitre, d'une classe), et bandeau « Brouillon » au-dessus du titre de la fiche.
 */
.row-actions { flex: 0 0 100%; display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 6px 12px; margin-bottom: 2px; }
/* Tout est aligné à droite : le lien contextuel ne prend plus la marge automatique */
.row-actions .row-links { margin-left: 0; }
.icon-group { display: inline-flex; align-items: center; gap: 6px; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: 30px; height: 30px; padding: 0; border: 1px solid var(--line); border-radius: 8px; background: var(--btn-bg); color: var(--ai); text-decoration: none; cursor: pointer; font: inherit; font-size: .9rem; }
.icon-btn:hover { background: var(--btn-hover-bg); color: var(--btn-hover-fg); border-color: var(--ai); }
.icon-btn svg { display: block; }
/* Couleurs d'état : publié / accès ouvert (vert), brouillon / accès suspendu (orange) */
.icon-btn.is-ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 45%, var(--line)); }
.icon-btn.is-ok:hover { background: color-mix(in srgb, var(--ok) 12%, var(--paper)); border-color: var(--ok); }
.icon-btn.is-warn { color: var(--shu); border-color: color-mix(in srgb, var(--shu) 45%, var(--line)); }
.icon-btn.is-warn:hover { background: color-mix(in srgb, var(--shu) 10%, var(--paper)); border-color: var(--shu); }
/* Sortir un cours d'un chapitre : discret, rouge au survol */
.icon-btn.is-remove { color: var(--muted); }
.icon-btn.is-remove:hover { color: var(--shu); background: color-mix(in srgb, var(--shu) 10%, var(--paper)); border-color: var(--shu); }
.icon-btn.with-label { padding: 0 12px; }
.icon-btn.with-label span { font-weight: 600; }
.draft-banner { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 10px 14px; margin: 0 0 14px; background: color-mix(in srgb, var(--shu) 7%, var(--paper)); border: 1px solid color-mix(in srgb, var(--shu) 40%, var(--line)); border-left: 4px solid var(--shu); border-radius: 10px; }
.draft-banner > span:nth-child(2) { flex: 1 1 260px; min-width: 0; }
.draft-banner .publication { margin: 0; }

/* Poignée de glisser dans une ligne de titre (sections d'une fiche) : pas sur toute la hauteur */
.drag-handle.head { position: static; width: 26px; height: 26px; border-radius: 6px; flex: none; }
/* Actions d'une ligne : les icônes d'ordre, de modification et de suppression se suivent */
.section-actions, .item-actions { gap: 6px; }

/* Thèmes : pastilles du gestionnaire, champs de couleur et aperçu de l'éditeur */
.theme-swatches { display: inline-flex; gap: 4px; }
.theme-swatches .swatch { display: inline-block; width: 14px; height: 14px; border-radius: 50%; border: 1px solid var(--line); }
.color-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.color-field > div { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.color-field label, .color-field .help-text { flex: 0 0 100%; }
.color-field input[type=text] { flex: 1 1 110px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.color-swatch { flex: none; width: 34px; height: 34px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: var(--btn-bg); cursor: pointer; }
.theme-editor > .card { margin-bottom: 14px; }
.theme-editor h2 { margin-top: 0; }
.theme-manage { margin-top: 18px; }
.theme-current { margin-bottom: 14px; }
.theme-current p { margin: 0; }
.school-card { margin-bottom: 20px; }
.school-card h2, .theme-section h2 { margin-top: 0; }
.theme-section .title-row h2 { margin: 0; }
/* Miniature du fond d'un thème dans l'éditeur */
.theme-thumb { display: block; width: 240px; max-width: 100%; height: auto; margin: 0 0 10px; border: 1px solid var(--line); border-radius: 10px; }
