@font-face {
  font-family: "Bricolage Grotesque";
  src: url("/fonts/bricolage.woff2") format("woff2-variations");
  font-weight: 200 800;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("/fonts/jetbrains-mono-500.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
}

:root {
  --bg: #EDF0F4;
  --surface: #FFFFFF;
  --ink: #14213D;
  --muted: #5B6477;
  --line: #D5DAE3;
  --accent: #2344D6;
  --accent-ink: #FFFFFF;
  --amber: #E8A317;
  --again: #C23B3B;
  --hard: #A86400;
  --good: #2344D6;
  --easy: #11845B;
  --font: "Bricolage Grotesque", "Segoe UI", Roboto, system-ui, sans-serif;
  --mono: "JetBrains Mono", "Cascadia Mono", Consolas, ui-monospace, monospace;
  --nav-h: 64px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #10151F;
    --surface: #1A2130;
    --ink: #E6EBF3;
    --muted: #93A0B5;
    --line: #2B3446;
    --accent: #7B93FF;
    --accent-ink: #0E1530;
    --amber: #F4BE45;
    --again: #F06A6A;
    --hard: #E9A23B;
    --good: #7B93FF;
    --easy: #3CC592;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
  min-height: 100dvh;
}
main {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(20px + env(safe-area-inset-top)) 20px calc(var(--nav-h) + 32px + env(safe-area-inset-bottom));
  outline: none;
}
body.in-session main { padding-bottom: 32px; }
h1, h2 { font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; margin: 0 0 12px; }
h1 { font-size: 30px; }
h2 { font-size: 21px; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; }

/* ---------- Navigation ---------- */
#tabs {
  position: fixed; left: 0; right: 0; bottom: 0;
  display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface);
  border-top: 1px solid var(--line);
  z-index: 10;
}
body.in-session #tabs { display: none; }
#tabs a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); text-decoration: none; font-size: 12.5px; font-weight: 500;
}
#tabs a.active { color: var(--accent); }
#tabs svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Boutons & champs ---------- */
button, .btn {
  font: inherit; font-weight: 600; font-size: 17px;
  border: 0; border-radius: 12px; padding: 14px 18px;
  cursor: pointer; touch-action: manipulation;
}
.btn-primary { background: var(--accent); color: var(--accent-ink); width: 100%; }
.btn-ghost { background: transparent; color: var(--ink); border: 1.5px solid var(--line); }
.btn-danger { background: transparent; color: var(--again); border: 1.5px solid currentColor; }
.btn-link { background: none; color: var(--accent); padding: 6px 0; font-weight: 500; font-size: 15px; }
button:disabled { opacity: .45; cursor: default; }
.row { display: flex; gap: 10px; align-items: center; }
.row > .grow { flex: 1; }
.stack > * + * { margin-top: 14px; }

label.field { display: block; }
label.field > span { display: block; font-size: 14px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
input[type=text], input[type=search], input[type=number], textarea, select {
  width: 100%; font: inherit; font-size: 18px; color: var(--ink);
  background: var(--surface); border: 1.5px solid var(--line); border-radius: 12px;
  padding: 13px 14px;
}
textarea { min-height: 84px; resize: vertical; font-size: 16px; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); outline: none; }

.icon-btn {
  width: 48px; height: 48px; padding: 0; flex: none;
  display: inline-grid; place-items: center;
  background: var(--surface); color: var(--accent); border: 1.5px solid var(--line); border-radius: 12px;
}
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Tags */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  font-size: 15px; font-weight: 500; padding: 8px 13px; border-radius: 999px;
  background: var(--surface); color: var(--ink); border: 1.5px solid var(--line);
}
.chip[aria-pressed=true] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.tag { font-size: 13px; font-weight: 600; color: var(--muted); }

/* ---------- Accueil ---------- */
.today { margin: 28px 0 26px; }
.today .count { font-size: 88px; font-weight: 800; letter-spacing: -0.05em; line-height: .9; font-variation-settings: "opsz" 96; }
.today .what { font-size: 22px; font-weight: 600; margin-top: 8px; }
.today .detail { color: var(--muted); margin-top: 4px; }
.streak { display: flex; gap: 6px; margin: 30px 0 8px; }
.streak i { flex: 1; height: 8px; border-radius: 4px; background: var(--line); }
.streak i.on { background: var(--amber); }
.panel { background: var(--surface); border-radius: 16px; padding: 18px; }
.notice { border-left: 4px solid var(--amber); padding: 10px 14px; background: var(--surface); border-radius: 0 12px 12px 0; font-size: 15px; }

/* ---------- Session ---------- */
.session-top { display: flex; align-items: center; gap: 12px; margin-bottom: 26px; }
.budget { flex: 1; height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.budget > div { height: 100%; background: var(--accent); transition: width .4s ease; }
.session-top .left { font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 64px; text-align: right; }
.close-btn { background: none; color: var(--muted); padding: 6px; font-size: 15px; font-weight: 500; }

.card-meta { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 18px; }
.dir { font-size: 14px; font-weight: 600; color: var(--muted); }
.word-line { display: flex; align-items: flex-start; gap: 12px; }
.word {
  flex: 1; font-size: clamp(40px, 12vw, 58px); font-weight: 750; letter-spacing: -0.035em;
  line-height: 1.02; overflow-wrap: anywhere; font-variation-settings: "opsz" 96;
}
.word.fr { font-weight: 600; }
.example { margin-top: 18px; font-size: 18px; color: var(--muted); line-height: 1.5; }
.example mark { background: none; color: var(--ink); font-weight: 700; }
.example .blank { display: inline-block; min-width: 3.2em; border-bottom: 2px solid var(--ink); }
.answer { margin-top: 28px; padding-top: 22px; border-top: 1.5px solid var(--line); }
.answer .translation { font-size: 28px; font-weight: 650; letter-spacing: -0.01em; line-height: 1.15; }
.reveal-zone { margin-top: 34px; }

/* L'invite de saisie : ton terminal pour l'anglais */
.prompt {
  display: flex; align-items: center; gap: 10px;
  background: var(--ink); color: var(--bg);
  border-radius: 14px; padding: 4px 16px; margin-top: 30px;
  font-family: var(--mono);
}
.prompt::before { content: "$"; color: var(--amber); font-size: 22px; }
.prompt input {
  flex: 1; min-width: 0; background: transparent; border: 0; padding: 14px 0;
  color: var(--bg); caret-color: var(--amber);
  font-family: var(--mono); font-size: 22px;
}
.prompt input::placeholder { color: color-mix(in srgb, var(--bg) 45%, transparent); }
.prompt input:focus { outline: none; }
.prompt.ok { box-shadow: 0 0 0 3px var(--easy); }
.prompt.typo { box-shadow: 0 0 0 3px var(--hard); }
.prompt.ko { box-shadow: 0 0 0 3px var(--again); }
.verdict { margin-top: 14px; font-weight: 600; }
.verdict.ok { color: var(--easy); }
.verdict.typo { color: var(--hard); }
.verdict.ko { color: var(--again); }
.verdict code { font-family: var(--mono); font-weight: 500; }

.ratings { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 26px; }
.ratings button {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 12px 4px; font-size: 15px; background: var(--surface); color: var(--ink);
  border: 1.5px solid var(--line);
}
.ratings button small { font-size: 12.5px; font-weight: 500; color: var(--muted); }
.ratings .r1 { color: var(--again); }
.ratings .r2 { color: var(--hard); }
.ratings .r3 { color: var(--good); }
.ratings .r4 { color: var(--easy); }
.ratings button.suggested { border-color: currentColor; border-width: 2.5px; }

.done { text-align: left; margin-top: 30px; }
.done .big { font-size: 64px; font-weight: 800; letter-spacing: -0.04em; line-height: 1; }

/* ---------- Ajout ---------- */
.dup { font-size: 15px; color: var(--hard); margin-top: 6px; }
details summary { cursor: pointer; font-weight: 600; color: var(--accent); padding: 4px 0; }
details[open] summary { margin-bottom: 10px; }

/* ---------- Liste des cartes ---------- */
.card-list { list-style: none; padding: 0; margin: 14px 0 0; }
.card-list li { border-bottom: 1px solid var(--line); }
.card-list button {
  width: 100%; text-align: left; background: none; color: var(--ink); border-radius: 0;
  padding: 13px 2px; display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; font-weight: 400;
}
.card-list .w { font-weight: 650; }
.card-list .t { color: var(--muted); font-size: 15px; grid-column: 1; }
.card-list .d { grid-row: 1 / 3; grid-column: 2; align-self: center; font-size: 13px; color: var(--muted); text-align: right; }
.card-list .missing { color: var(--hard); }

/* Feuille d'édition */
dialog {
  width: min(560px, 100vw); max-width: 100vw; margin: auto auto 0; border: 0; padding: 22px 20px calc(22px + env(safe-area-inset-bottom));
  border-radius: 20px 20px 0 0; background: var(--bg); color: var(--ink);
  max-height: 92dvh; overflow-y: auto;
}
dialog::backdrop { background: rgba(10, 16, 30, .55); }

/* Toast */
#toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + 18px + env(safe-area-inset-bottom));
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--ink); color: var(--bg); padding: 11px 18px; border-radius: 12px;
  font-weight: 600; font-size: 15px; transition: opacity .2s, transform .2s; max-width: calc(100vw - 40px);
  z-index: 20;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

.sync-state { font-size: 13px; color: var(--muted); }
.kbd-hint { display: none; }
@media (hover: hover) and (pointer: fine) { .kbd-hint { display: inline; } }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
