/* ============================================================
   Vocab COMEX — design system minimaliste
   ============================================================ */
:root {
  --bg: #f6f6f3;
  --surface: #ffffff;
  --surface-2: #eeeeea;
  --text: #191b22;
  --text-2: #5b6070;
  --line: #e3e3dd;
  --accent: #4f46e5;
  --accent-soft: #eef0ff;
  --accent-text: #3f38c9;
  --green: #16a34a;
  --orange: #ea8a1f;
  --red: #dc2626;
  --blue: #2563eb;
  --shadow: 0 1px 2px rgba(20, 22, 40, .06), 0 12px 32px -12px rgba(20, 22, 40, .18);
  --radius: 18px;
  color-scheme: light;
}
html[data-theme="dark"] {
  --bg: #0e1015;
  --surface: #171a22;
  --surface-2: #1f2330;
  --text: #eceef4;
  --text-2: #9aa1b5;
  --line: #262b3a;
  --accent: #818cf8;
  --accent-soft: #232645;
  --accent-text: #a5adff;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 14px 40px -14px rgba(0, 0, 0, .6);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background .25s, color .25s;
}
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

/* ---------- Barre supérieure ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1080px; margin: 0 auto; padding: 10px 20px;
  display: flex; align-items: center; gap: 18px;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 17px; letter-spacing: -.02em; }
.brand em { font-style: normal; color: var(--accent-text); }
.brand-icon { font-size: 20px; }
.tabs { display: flex; gap: 4px; margin-left: 8px; }
.tab {
  border: 0; background: transparent; padding: 8px 14px; border-radius: 999px;
  font-weight: 600; color: var(--text-2);
  display: inline-flex; align-items: center; gap: 7px;
}
.tab:hover { background: var(--surface-2); }
.tab.is-active { background: var(--accent-soft); color: var(--accent-text); }
.due-badge {
  background: var(--accent); color: #fff; font-size: 11px; font-weight: 700;
  border-radius: 999px; padding: 1px 7px; line-height: 1.5;
}
.topbar-actions { margin-left: auto; }
.icon-btn {
  border: 1px solid var(--line); background: var(--surface); border-radius: 10px;
  width: 34px; height: 34px; font-size: 16px; line-height: 1;
}
.icon-btn:hover { background: var(--surface-2); }

main { flex: 1; width: 100%; max-width: 1080px; margin: 0 auto; padding: 26px 20px 40px; }

/* ---------- Vue Révision ---------- */
.review-toolbar {
  display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end;
  margin-bottom: 22px;
}
.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-2); font-weight: 600; }
.field select, .lib-controls select, #libSearch {
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  border-radius: 10px; padding: 8px 12px; font-size: 14px; font-family: inherit;
}
.session-meta { margin-left: auto; font-size: 13px; color: var(--text-2); font-weight: 600; text-align: right; }

.card-stage { perspective: 1400px; max-width: 640px; margin: 0 auto; }
.flashcard {
  display: grid; width: 100%; min-height: 340px;
  transform-style: preserve-3d;
  transition: transform .55s cubic-bezier(.35,.9,.3,1);
  cursor: pointer;
}
.flashcard.flipped { transform: rotateY(180deg); }
.face {
  grid-area: 1 / 1;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 30px;
  display: flex; flex-direction: column;
}
.face.back { transform: rotateY(180deg); }

.badges { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.badge {
  font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  padding: 3px 10px; border-radius: 999px;
  background: var(--surface-2); color: var(--text-2);
}
.badge.lang-en { background: #e0edff; color: #1d4ed8; }
.badge.lang-fr { background: #ffe4e6; color: #be123c; }
html[data-theme="dark"] .badge.lang-en { background: #1e2a4a; color: #93b4ff; }
html[data-theme="dark"] .badge.lang-fr { background: #3d1f2a; color: #ff9eb1; }
.badge.level { background: var(--accent-soft); color: var(--accent-text); }

.front .term-zone { margin: auto 0; text-align: center; padding: 10px 0 26px; }
.term-main {
  font-family: "Fraunces", Georgia, serif;
  font-size: clamp(28px, 5vw, 42px); font-weight: 700; letter-spacing: -.015em;
  line-height: 1.15;
}
.phonetic { color: var(--text-2); margin-top: 8px; font-size: 16px; }
.speak-btn {
  border: 1px solid var(--line); background: var(--surface-2);
  border-radius: 999px; padding: 7px 16px; font-size: 15px; margin-top: 16px;
}
.speak-btn:hover { background: var(--accent-soft); border-color: var(--accent); }
.speak-inline {
  border: 0; background: transparent; font-size: 15px; padding: 2px 6px;
  border-radius: 8px; vertical-align: middle;
}
.speak-inline:hover { background: var(--accent-soft); }
.flip-hint { text-align: center; color: var(--text-2); font-size: 12.5px; }

/* ---------- QCM du recto ---------- */
.quiz { width: 100%; max-width: 460px; margin: 0 auto 16px; }
.quiz-q {
  font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--text-2); text-align: center; margin-bottom: 9px;
}
.quiz-options { display: flex; flex-direction: column; gap: 7px; }
.quiz-opt {
  display: flex; align-items: flex-start; gap: 10px; width: 100%; text-align: left;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text);
  border-radius: 12px; padding: 9px 12px; font-size: 14px; font-weight: 600; line-height: 1.35;
  transition: border-color .15s, background .15s;
}
.quiz-opt:hover:not(:disabled) { border-color: var(--accent); background: var(--accent-soft); }
.quiz-opt:disabled { cursor: default; opacity: .7; }
.quiz-key {
  flex: 0 0 auto; font-size: 11px; font-weight: 700; color: var(--text-2);
  background: var(--surface); border: 1px solid var(--line); border-radius: 6px;
  min-width: 20px; text-align: center; padding: 1px 0; line-height: 1.5;
}
.quiz-label { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.quiz-opt.is-correct, .quiz-opt.is-wrong { opacity: 1; }
.quiz-opt.is-correct { border-color: var(--green); background: #ddf5e4; color: #12652f; }
.quiz-opt.is-wrong   { border-color: var(--red);   background: #fde8e8; color: #a4201f; }
html[data-theme="dark"] .quiz-opt.is-correct { background: #16351f; color: #7fe0a0; }
html[data-theme="dark"] .quiz-opt.is-wrong   { background: #3d2020; color: #ff9d9d; }
.quiz-result { font-size: 13px; font-weight: 700; margin: -2px 0 10px; }
.quiz-result.ok { color: var(--green); }
.quiz-result.ko { color: var(--red); }

.back .term-head {
  display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
  font-weight: 700; font-size: 17px;
}
.translation {
  font-family: "Fraunces", Georgia, serif;
  font-size: clamp(22px, 4vw, 30px); font-weight: 700; color: var(--accent-text);
  margin: 10px 0 4px; line-height: 1.2;
}
.definition { color: var(--text-2); margin-bottom: 14px; }
.example-block {
  background: var(--surface-2); border-radius: 12px; padding: 12px 16px; margin-bottom: 12px;
}
.example-en { font-weight: 600; }
.example-tr { color: var(--text-2); font-size: 13.5px; margin-top: 4px; }
.idiom-block {
  border-left: 3px solid var(--accent); padding: 4px 14px; margin: 2px 0 12px;
  color: var(--text-2); font-size: 14px; font-style: italic;
}
.dict-block { border-top: 1px dashed var(--line); padding-top: 12px; margin-top: auto; font-size: 13.5px; color: var(--text-2); }
.dict-block .dict-title { font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 6px; }
.dict-block audio { display: none; }

/* Boutons de notation */
.grades {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px;
  max-width: 640px; margin: 18px auto 0;
}
.grade {
  border: 1px solid var(--line); border-radius: 14px; padding: 10px 6px 8px;
  background: var(--surface); font-weight: 700; font-size: 14px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  transition: transform .08s, background .15s;
}
.grade small { font-weight: 600; font-size: 11px; color: var(--text-2); }
.grade:hover { transform: translateY(-2px); }
.grade-again:hover { border-color: var(--red);    color: var(--red); }
.grade-hard:hover  { border-color: var(--orange); color: var(--orange); }
.grade-good:hover  { border-color: var(--green);  color: var(--green); }
.grade-easy:hover  { border-color: var(--blue);   color: var(--blue); }
.kbd-hint { text-align: center; color: var(--text-2); font-size: 12px; margin-top: 14px; }

/* Fin de session */
.session-done {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 44px 30px; text-align: center;
}
.session-done h2 { font-family: "Fraunces", Georgia, serif; font-size: 28px; margin: 0 0 8px; }
.session-done p { color: var(--text-2); margin: 0 0 20px; }
.primary-btn {
  background: var(--accent); color: #fff; border: 0; border-radius: 12px;
  padding: 11px 22px; font-weight: 700; font-size: 15px;
}
.primary-btn:hover { filter: brightness(1.08); }

/* ---------- Vue Bibliothèque ---------- */
.lib-toolbar { display: flex; flex-direction: column; gap: 12px; margin-bottom: 18px; }
.lib-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.lib-actions-msg { font-size: 12.5px; font-weight: 600; color: var(--accent-text); }
.ghost-btn {
  border: 1px solid var(--line); background: var(--surface); color: var(--text-2);
  border-radius: 10px; padding: 8px 14px; font-size: 13.5px; font-weight: 600;
}
.ghost-btn:hover { border-color: var(--accent); color: var(--accent-text); }
.danger-btn {
  border: 1px solid var(--line); background: var(--surface); color: var(--red);
  border-radius: 10px; padding: 8px 14px; font-size: 13.5px; font-weight: 600;
}
.danger-btn:hover { border-color: var(--red); }
.primary-btn.small { padding: 8px 16px; font-size: 14px; border-radius: 10px; }
.badge.custom { background: #f1e6ff; color: #6d28d9; }
html[data-theme="dark"] .badge.custom { background: #2c2049; color: #c9b6ff; }
.row-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
#libSearch { width: 100%; font-size: 15px; padding: 11px 16px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px;
  padding: 6px 14px; font-size: 13px; font-weight: 600; color: var(--text-2);
}
.chip:hover { border-color: var(--accent); }
.chip.is-on { background: var(--accent); border-color: var(--accent); color: #fff; }
.lib-controls { display: flex; flex-wrap: wrap; gap: 10px; }
.lib-summary { font-size: 13px; color: var(--text-2); font-weight: 600; }

.lib-list { display: flex; flex-direction: column; gap: 8px; }
.lib-row {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 12px 18px; cursor: pointer; transition: border-color .15s;
}
.lib-row:hover { border-color: var(--accent); }
.lib-row-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.lib-term { font-weight: 700; font-size: 15.5px; }
.lib-tr { color: var(--text-2); flex: 1; min-width: 140px; }
.lib-tags { display: flex; gap: 6px; align-items: center; }
.srs-state { font-size: 11px; font-weight: 700; padding: 2px 9px; border-radius: 999px; }
.srs-new     { background: var(--surface-2); color: var(--text-2); }
.srs-due     { background: #fde8e8; color: #c02626; }
.srs-learning{ background: #fdf1dd; color: #b16a10; }
.srs-known   { background: #ddf5e4; color: #157a3a; }
html[data-theme="dark"] .srs-due      { background: #3d2020; color: #ff9d9d; }
html[data-theme="dark"] .srs-learning { background: #3b2f1a; color: #ffcf8a; }
html[data-theme="dark"] .srs-known    { background: #16351f; color: #7fe0a0; }

.lib-detail { border-top: 1px dashed var(--line); margin-top: 12px; padding-top: 12px; }
.lib-detail .definition { margin-bottom: 8px; }
.lib-empty { text-align: center; color: var(--text-2); padding: 50px 0; }

/* ---------- Vue Progrès ---------- */
.prog-section { margin-bottom: 28px; }
.prog-section h2 {
  font-family: "Fraunces", Georgia, serif; font-size: 20px; margin: 0 0 12px; font-weight: 700;
}
.prog-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px;
}
.stat-num {
  font-family: "Fraunces", Georgia, serif; font-size: 28px; font-weight: 700;
  line-height: 1.15; letter-spacing: -.02em;
}
.stat-lab {
  font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  color: var(--text-2); margin-top: 2px;
}
.prog-panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px;
}
.prog-panel-title {
  font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  color: var(--text-2); margin-bottom: 10px;
}
.prog-note { font-size: 12.5px; color: var(--text-2); font-weight: 600; margin-top: 10px; text-align: right; }
.prog-empty {
  background: var(--surface); border: 1px dashed var(--line); border-radius: 14px;
  padding: 26px 20px; text-align: center; color: var(--text-2); font-weight: 600;
}
.bar-row {
  display: grid; grid-template-columns: minmax(110px, 1.1fr) 2fr auto;
  gap: 12px; align-items: center; padding: 5px 0; font-size: 13.5px;
}
.bar-name { font-weight: 600; overflow-wrap: anywhere; }
.bar-track { background: var(--surface-2); border-radius: 999px; height: 9px; overflow: hidden; }
.bar-fill { display: block; background: var(--accent); height: 100%; border-radius: 999px; }
.bar-val { font-size: 12px; font-weight: 700; color: var(--text-2); white-space: nowrap; }
.hist { display: flex; align-items: stretch; gap: 6px; height: 150px; overflow-x: auto; }
.hist-col { flex: 1 0 22px; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.hist-bar-wrap { flex: 1; width: 100%; display: flex; align-items: flex-end; }
.hist-bar { width: 100%; background: var(--accent); border-radius: 6px 6px 0 0; min-height: 3px; }
.hist-bar.is-zero { background: var(--surface-2); }
.hist-n, .hist-lab { font-size: 10.5px; font-weight: 700; color: var(--text-2); white-space: nowrap; }
.hist-lab { font-weight: 600; }

/* ---------- Formulaire mot perso (modale) ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 50; background: rgba(10, 12, 22, .55);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 28px 16px; overflow-y: auto;
}
.modal {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); width: 100%; max-width: 620px; padding: 20px 22px 22px;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.modal-head h2 { font-family: "Fraunces", Georgia, serif; font-size: 21px; margin: 0; }
.word-form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.word-form .field.full { grid-column: 1 / -1; }
.word-form input, .word-form textarea, .word-form select {
  border: 1px solid var(--line); background: var(--bg); color: var(--text);
  border-radius: 10px; padding: 9px 12px; font-size: 14px; font-family: inherit; width: 100%;
}
.word-form textarea { resize: vertical; line-height: 1.45; }
.form-error {
  grid-column: 1 / -1; background: #fde8e8; color: #a4201f; border: 1px solid var(--red);
  border-radius: 10px; padding: 9px 12px; font-size: 13.5px; font-weight: 600;
}
html[data-theme="dark"] .form-error { background: #3d2020; color: #ff9d9d; }
.form-actions {
  grid-column: 1 / -1; display: flex; align-items: center; justify-content: flex-end;
  gap: 16px; margin-top: 4px;
}
.form-req { margin-right: auto; font-size: 12px; color: var(--text-2); font-weight: 600; }

/* ---------- Pied de page ---------- */
.foot {
  border-top: 1px solid var(--line); padding: 14px 20px 20px;
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  max-width: 1080px; margin: 0 auto; width: 100%;
  color: var(--text-2); font-size: 12.5px;
}
.link-btn { border: 0; background: transparent; color: var(--text-2); text-decoration: underline; font-size: 12.5px; padding: 0; }
.link-btn:hover { color: var(--red); }

/* Écran de chargement / erreur */
.loading { text-align: center; color: var(--text-2); padding: 70px 0; font-weight: 600; }

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  .topbar-inner { flex-wrap: wrap; gap: 10px; padding: 10px 14px; }
  .tabs { order: 3; width: 100%; justify-content: center; margin-left: 0; }
  main { padding: 18px 14px 32px; }
  .face { padding: 20px 18px; }
  .grades { grid-template-columns: repeat(2, 1fr); }
  .session-meta { margin-left: 0; text-align: left; }
  .word-form { grid-template-columns: 1fr; }
  .modal { padding: 16px 16px 18px; }
  .bar-row { grid-template-columns: minmax(90px, 1fr) 1.4fr auto; gap: 8px; font-size: 13px; }
}
