/*
  Carnet d'anglais : gris froid, un seul accent cobalt, cartes qui se retournent.
  Formes : surfaces 24px, champs 14px, éléments interactifs en pilule.
  Polices hébergées sur le site (Bricolage Grotesque, Geist, Geist Mono) ; icônes Phosphor.
*/

@font-face {
  font-family: "Bricolage";
  src: url("/vendor/fonts/bricolage-grotesque.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
}
@font-face {
  font-family: "Geist";
  src: url("/vendor/fonts/geist.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "Geist Mono";
  src: url("/vendor/fonts/geist-mono.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --bg: #F1F2F6;
  --surface: #FBFBFD;
  --surface-2: #E8EAF0;
  --surface-3: #DADDE6;
  --ink: #12141A;
  --ink-2: #444A58;
  --muted: #646A78;
  --line: rgba(18, 20, 26, .08);
  --line-strong: rgba(18, 20, 26, .15);
  --accent: #2E4AD6;
  --accent-hover: #2640BF;
  --accent-soft: #E1E6FB;
  --accent-ink: #1E35A6;
  --on-accent: #F5F7FF;
  --yes: #17855A;
  --yes-soft: #DAEFE4;
  --on-yes: #F3FBF7;
  --no: #C03A27;
  --no-soft: #F6DFDA;
  --on-no: #FFF6F4;
  --shadow-1: 0 1px 2px rgba(22, 28, 52, .05), 0 6px 16px -8px rgba(22, 28, 52, .12);
  --shadow-2: 0 2px 4px rgba(22, 28, 52, .04), 0 26px 50px -22px rgba(22, 28, 52, .30);
  --shadow-3: 0 30px 80px -24px rgba(22, 28, 52, .45);
  --r-surface: 24px;
  --r-inner: 16px;
  --r-input: 14px;
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --f-display: "Bricolage", "Segoe UI", system-ui, sans-serif;
  --f-ui: "Geist", "Segoe UI", system-ui, sans-serif;
  --f-mono: "Geist Mono", ui-monospace, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0D0F14;
    --surface: #161920;
    --surface-2: #1F232C;
    --surface-3: #2A2F3A;
    --ink: #ECEEF4;
    --ink-2: #B5BAC6;
    --muted: #8E94A2;
    --line: rgba(236, 238, 244, .08);
    --line-strong: rgba(236, 238, 244, .15);
    --accent: #7D92FF;
    --accent-hover: #95A6FF;
    --accent-soft: rgba(125, 146, 255, .15);
    --accent-ink: #B2BEFF;
    --on-accent: #0A0D1A;
    --yes: #47C48C;
    --yes-soft: rgba(71, 196, 140, .15);
    --on-yes: #06140D;
    --no: #F07A65;
    --no-soft: rgba(240, 122, 101, .15);
    --on-no: #1C0A06;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 18px -10px rgba(0, 0, 0, .5);
    --shadow-2: 0 2px 4px rgba(0, 0, 0, .25), 0 28px 56px -24px rgba(0, 0, 0, .75);
    --shadow-3: 0 30px 80px -20px rgba(0, 0, 0, .85);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.5 var(--f-ui);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input, textarea, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.ph, .ph-fill { line-height: 1; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (hover: hover) { .only-touch { display: none !important; } }
@media (hover: none) { .only-mouse, kbd { display: none !important; } }

@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes breathe { 50% { transform: scale(.93); opacity: .7; } }

h1, h2, h3 { margin: 0; font-family: var(--f-display); letter-spacing: -.03em; text-wrap: balance; }
h1 { font-size: clamp(2.3rem, 4.4vw, 3.6rem); font-weight: 650; line-height: 1.04; }
.lead { margin: 14px 0 0; max-width: 46ch; color: var(--ink-2); font-size: 1.075rem; line-height: 1.55; }
.label { display: block; margin: 0 0 8px; padding: 0; font-size: 13.5px; font-weight: 500; color: var(--ink-2); }

/* ---------- Marque, barre du haut, onglets ---------- */

.mark {
  display: inline-grid;
  flex: none;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--accent);
  color: var(--on-accent);
  font: 700 15px/1 var(--f-display);
  letter-spacing: -.03em;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .14);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 68px;
  padding: 0 clamp(16px, 4vw, 40px);
  background: color-mix(in srgb, var(--bg) 84%, transparent);
  backdrop-filter: blur(14px) saturate(150%);
  -webkit-backdrop-filter: blur(14px) saturate(150%);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; font: 600 16.5px/1 var(--f-display); letter-spacing: -.015em; }

.nav { display: flex; gap: 2px; padding: 4px; background: var(--surface-2); border-radius: 999px; }
.nav a {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 16px;
  color: var(--ink-2);
  font-size: 15px;
  font-weight: 500;
  text-decoration: none;
  border-radius: 999px;
  transition: background-color .2s, color .2s, box-shadow .2s;
}
.nav a .ph, .nav a .ph-fill { font-size: 18px; }
.nav a:hover { color: var(--ink); }
.nav a.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }
.tabbar { display: none; }

@media (max-width: 767px) {
  .topbar { height: 60px; }
  .topbar .nav { display: none; }
  .tabbar {
    position: fixed;
    z-index: 30;
    left: 50%;
    bottom: calc(12px + env(safe-area-inset-bottom));
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    width: min(420px, calc(100% - 24px));
    padding: 6px;
    background: color-mix(in srgb, var(--surface) 80%, transparent);
    backdrop-filter: blur(20px) saturate(170%);
    -webkit-backdrop-filter: blur(20px) saturate(170%);
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    box-shadow: var(--shadow-2);
    transform: translateX(-50%);
  }
  .tabbar a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    height: 52px;
    color: var(--muted);
    font-size: 11.5px;
    font-weight: 500;
    text-decoration: none;
    border-radius: 999px;
    -webkit-tap-highlight-color: transparent;
  }
  .tabbar a .ph, .tabbar a .ph-fill { font-size: 22px; }
  .tabbar a.active { background: var(--accent-soft); color: var(--accent-ink); }
  .page { padding-bottom: calc(112px + env(safe-area-inset-bottom)) !important; }
}
@media (prefers-reduced-transparency: reduce) {
  .topbar, .tabbar { background: var(--surface); backdrop-filter: none; -webkit-backdrop-filter: none; }
}
body[data-route="reviser"] .topbar,
body[data-route="reviser"] .tabbar { display: none; }

.page { width: 100%; max-width: 1240px; margin: 0 auto; padding: clamp(28px, 5vw, 60px) clamp(16px, 4vw, 40px) 72px; }

/* ---------- Boutons & champs ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 48px;
  padding: 0 22px;
  color: var(--ink);
  font-size: 15.5px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  background: var(--surface);
  border: 1px solid transparent;
  border-radius: 999px;
  cursor: pointer;
  transition: transform .15s var(--ease-out), background-color .2s, box-shadow .2s, color .2s, border-color .2s;
  -webkit-tap-highlight-color: transparent;
}
.btn .ph, .btn .ph-fill { font-size: 1.2em; }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: default; }
.btn-primary {
  color: var(--on-accent);
  background: var(--accent);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .16), 0 12px 26px -14px color-mix(in srgb, var(--accent) 80%, transparent);
}
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-ghost { background: transparent; border-color: var(--line-strong); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-quiet { height: 44px; padding: 0 14px; color: var(--muted); font-weight: 500; background: transparent; }
.btn-quiet:hover { color: var(--ink); }
.btn-danger { color: var(--no); background: transparent; border-color: color-mix(in srgb, var(--no) 35%, transparent); }
.btn-danger:hover { background: var(--no-soft); }
.btn-icon { width: 44px; height: 44px; padding: 0; }
.btn-lg { height: 60px; padding: 0 28px; font-size: 17px; }
kbd {
  padding: 4px 6px;
  font: 500 11px/1 var(--f-mono);
  letter-spacing: .02em;
  background: color-mix(in srgb, currentColor 12%, transparent);
  border-radius: 6px;
}

.field {
  display: block;
  width: 100%;
  padding: 12px 14px;
  color: var(--ink);
  font: 400 16px/1.4 var(--f-ui);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-input);
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.field::placeholder { color: var(--muted); }
.field:focus { border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent); }
textarea.field { resize: vertical; }

.seg { display: grid; grid-auto-columns: 1fr; grid-auto-flow: column; gap: 4px; padding: 4px; background: var(--surface-2); border-radius: 999px; }
.seg button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 42px;
  padding: 0 10px;
  color: var(--ink-2);
  font-size: 14.5px;
  font-weight: 500;
  white-space: nowrap;
  background: transparent;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  transition: background-color .2s, color .2s, box-shadow .2s;
  -webkit-tap-highlight-color: transparent;
}
.seg button .ph { font-size: 15px; color: var(--muted); }
.seg button:hover { color: var(--ink); }
.seg button.on { color: var(--ink); background: var(--surface); box-shadow: var(--shadow-1); }
.seg button.on .ph { color: var(--accent); }
@media (prefers-color-scheme: dark) {
  /* En sombre, l'élément actif doit rester plus clair que son rail */
  .seg button.on, .nav a.active { background: var(--surface-3); }
}

.cat-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 32px;
  padding: 0 12px 0 10px;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  background: var(--surface-2);
  border-radius: 999px;
}
.cat-chip .ph { font-size: 16px; }
.lang {
  display: inline-flex;
  flex: none;
  align-items: center;
  align-self: flex-start;
  height: 24px;
  padding: 0 9px;
  color: var(--accent-ink);
  font: 600 11.5px/1 var(--f-mono);
  letter-spacing: .06em;
  background: var(--accent-soft);
  border-radius: 999px;
}
.note { display: flex; align-items: flex-start; gap: 10px; margin: 14px 0 0; color: var(--ink-2); font-size: 14px; }
.note .ph { flex: none; margin-top: 2px; font-size: 17px; color: var(--muted); }

/* ---------- Accueil ---------- */

.home { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); align-items: start; gap: clamp(32px, 5vw, 72px); }
.home-left { display: grid; gap: 34px; }
@media (min-width: 1024px) and (min-height: 760px) {
  .home-left { position: sticky; top: 108px; }
}
.stats { display: grid; grid-template-columns: repeat(3, auto); justify-content: start; gap: 12px 40px; margin-top: 28px; padding-top: 22px; border-top: 1px solid var(--line); }
.stat b { display: block; font: 650 clamp(1.8rem, 2.6vw, 2.3rem)/1 var(--f-display); letter-spacing: -.035em; font-variant-numeric: tabular-nums; }
.stat span { display: block; margin-top: 7px; color: var(--muted); font-size: 13.5px; }
.stat.accent b { color: var(--accent); }
.setup { display: grid; gap: 20px; }
.start { width: 100%; }
.start small { font-size: 14px; font-weight: 500; opacity: .78; }

.bento { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); grid-auto-rows: minmax(132px, auto); gap: 14px; }
.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  overflow: hidden;
  padding: 18px;
  color: inherit;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-surface);
  box-shadow: var(--shadow-1);
  cursor: pointer;
  transition: transform .4s var(--ease-out), box-shadow .4s var(--ease-out), border-color .2s, background-color .2s;
  -webkit-tap-highlight-color: transparent;
}
.tile:hover { transform: translateY(-3px); box-shadow: var(--shadow-2); }
.tile:active { transform: scale(.985); }
.tile-icon { position: relative; z-index: 1; display: grid; place-items: center; width: 42px; height: 42px; font-size: 21px; color: var(--ink); background: var(--surface-2); border-radius: 13px; transition: background-color .25s, color .25s; }
.tile-body { position: relative; z-index: 1; display: grid; gap: 4px; margin-top: auto; padding-top: 16px; }
.tile-count { font: 650 clamp(2.6rem, 5vw, 4.6rem)/.95 var(--f-display); letter-spacing: -.05em; font-variant-numeric: tabular-nums; margin-bottom: 6px; }
.tile-label { font: 600 1.07rem/1.2 var(--f-display); letter-spacing: -.01em; }
.tile-meta { color: var(--muted); font-size: 13px; }
.tile-meta b { color: var(--accent); font-weight: 600; }
.tile-check { position: absolute; z-index: 1; top: 16px; right: 16px; font-size: 26px; color: var(--accent); opacity: 0; transform: scale(.5); transition: opacity .25s, transform .4s var(--ease-out); }
.tile-mark { position: absolute; right: -26px; bottom: -44px; font-size: 220px; color: var(--ink); opacity: .045; pointer-events: none; }
.tile.selected { background: color-mix(in srgb, var(--accent-soft) 65%, var(--surface)); border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), var(--shadow-2); }
.tile.selected .tile-check { opacity: 1; transform: none; }
.tile.selected .tile-icon { color: var(--on-accent); background: var(--accent); }

.tile--big { grid-column: span 4; grid-row: span 2; padding: 24px; }
.tile--tall { grid-column: span 2; grid-row: span 2; background: var(--surface-2); }
.tile--tall .tile-icon { background: var(--surface); }
.tile--tall .tile-count { font-size: clamp(2.2rem, 3.4vw, 3.2rem); }
.tile--small { grid-column: span 2; }
.tile--wide {
  grid-column: span 6;
  flex-direction: row;
  align-items: center;
  gap: 16px;
  background-image: radial-gradient(color-mix(in srgb, var(--ink) 13%, transparent) 1px, transparent 1.3px);
  background-size: 14px 14px;
}
.tile--wide .tile-body { margin-top: 0; padding-top: 0; }
.tile--wide .tile-check { top: calc(50% - 13px); }

.enter .home-intro, .enter .setup { animation: rise .6s var(--ease-out) backwards; }
.enter .setup { animation-delay: .08s; }
.enter .tile { animation: rise .6s var(--ease-out) backwards; animation-delay: calc(var(--i) * 60ms + 60ms); }

@media (max-width: 1023px) {
  .home { grid-template-columns: minmax(0, 1fr); gap: 28px; }
  .home-left { display: contents; }
  .home-intro { order: 1; }
  .bento { order: 2; }
  .setup { order: 3; }
}
@media (max-width: 767px) {
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
  .bento { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: auto; gap: 10px; }
  .tile { min-height: 124px; padding: 14px; }
  .tile-icon { width: 38px; height: 38px; font-size: 19px; border-radius: 12px; }
  .tile-check { top: 12px; right: 12px; font-size: 23px; }
  .tile-label { font-size: 1rem; }
  .tile--big { grid-column: span 2; grid-row: auto; min-height: 176px; padding: 18px; }
  .tile--big .tile-count { font-size: 3rem; }
  .tile--tall, .tile--small { grid-column: span 1; grid-row: auto; }
  .tile--tall .tile-count { font-size: 2rem; }
  .tile--wide { grid-column: span 2; min-height: 0; }
  .tile--wide .tile-check { top: calc(50% - 11px); }
  .tile-mark { font-size: 170px; }
}

/* ---------- Révision ---------- */

.page-reviser { max-width: 680px; padding-top: 0 !important; padding-bottom: 0 !important; }
.session {
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 10px;
  min-height: 100dvh;
  padding: calc(14px + env(safe-area-inset-top)) 0 calc(18px + env(safe-area-inset-bottom));
}
.session-bar { display: flex; align-items: center; gap: 14px; }
.progress { flex: 1; height: 6px; overflow: hidden; background: var(--surface-2); border-radius: 999px; }
.progress i { display: block; width: 0; height: 100%; background: var(--accent); border-radius: inherit; transition: width .5s var(--ease-out); }
.counter { min-width: 54px; color: var(--muted); font: 500 13px var(--f-mono); text-align: right; font-variant-numeric: tabular-nums; }

.stage { display: grid; place-items: center; padding: 18px 0 30px; }
.deck { position: relative; width: 100%; isolation: isolate; perspective: 1600px; }
.deck::before, .deck::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-surface);
  box-shadow: var(--shadow-1);
  transition: opacity .3s;
}
/* Les cartes suivantes dépassent sous la carte active : on voit qu'il en reste */
.deck::before, .deck::after { transform-origin: 50% 100%; }
.deck::before { z-index: 0; opacity: .85; transform: translateY(12px) scale(.95); }
.deck::after { z-index: -1; opacity: .5; transform: translateY(24px) scale(.9); }
.deck[data-left="1"]::after, .deck[data-left="0"]::after, .deck[data-left="0"]::before { opacity: 0; }

.card-shell {
  position: relative;
  z-index: 1;
  transform-origin: 50% 100%;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: pan-y;
  transition: transform .5s var(--ease-out), opacity .35s ease;
}
.card-shell.enter { animation: deal .55s var(--ease-out) backwards; }
@keyframes deal { from { opacity: .5; transform: translateY(12px) scale(.95); } }
.card-shell.revealed { cursor: grab; }
.card-shell.dragging { cursor: grabbing; transition: none; }
.card-shell.fly-right { opacity: 0; transform: translateX(125%) rotate(16deg); }
.card-shell.fly-left { opacity: 0; transform: translateX(-125%) rotate(-16deg); }
.card-shell.fly-up { opacity: 0; transform: translateY(-70px) scale(.92); }

.card-inner { display: grid; min-height: min(54dvh, 440px); transform-style: preserve-3d; transition: transform .7s var(--ease-out); }
.card-shell.revealed .card-inner { transform: rotateY(180deg); }
.face {
  grid-area: 1 / 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 20px 24px 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-surface);
  box-shadow: var(--shadow-2);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.face-back { transform: rotateY(180deg); }
.face-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 32px; }
.level { display: flex; gap: 4px; }
.level i { width: 14px; height: 5px; background: var(--surface-3); border-radius: 999px; }
.level i.on { background: var(--accent); }
.retry { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 11px; color: var(--no); font-size: 12.5px; font-weight: 600; background: var(--no-soft); border-radius: 999px; }
.face-body { display: flex; flex: 1; flex-direction: column; justify-content: center; gap: 14px; min-width: 0; padding: 30px 0 20px; }
.word { margin: 0; font: 650 clamp(2.2rem, 7.5vw, 3.7rem)/1.06 var(--f-display); letter-spacing: -.04em; overflow-wrap: anywhere; text-wrap: balance; }
.card-shell.medium .word { font-size: clamp(1.7rem, 5.2vw, 2.5rem); line-height: 1.12; }
.card-shell.long .word { font-size: clamp(1.25rem, 3.8vw, 1.7rem); font-weight: 560; line-height: 1.3; letter-spacing: -.02em; }
.face-back .word { color: var(--accent); }
.asked { display: flex; align-items: baseline; gap: 10px; margin: 0 0 8px; padding-bottom: 16px; color: var(--muted); font-size: 15.5px; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.face-foot { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 22px; margin: 0; color: var(--muted); font-size: 13px; text-align: center; }
.face-foot .ph { font-size: 16px; }

.swipe-tag {
  position: absolute;
  z-index: 3;
  top: 22px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 38px;
  padding: 0 15px;
  font-size: 14.5px;
  font-weight: 700;
  border-radius: 999px;
  pointer-events: none;
}
.swipe-tag.yes { left: 20px; color: var(--on-yes); background: var(--yes); opacity: var(--lean-yes, 0); transform: rotate(-7deg); }
.swipe-tag.no { right: 20px; color: var(--on-no); background: var(--no); opacity: var(--lean-no, 0); transform: rotate(7deg); }

.actions { display: grid; gap: 8px; }
.grade { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; animation: rise .3s var(--ease-out) backwards; }
.grade .btn { padding: 0 14px; }
.btn-no { color: var(--no); background: var(--no-soft); }
.btn-no:hover { background: color-mix(in srgb, var(--no-soft) 72%, var(--no)); }
.btn-yes { color: var(--on-yes); background: var(--yes); }
.btn-yes:hover { background: color-mix(in srgb, var(--yes) 86%, var(--ink)); }
.master { justify-self: center; }
@media (max-width: 440px) {
  .grade .btn { font-size: 15.5px; }
  .grade .ph { display: none; }
  .face { padding: 18px 20px 20px; }
}

.done { display: grid; grid-row: 1 / -1; align-self: center; justify-items: center; padding: 40px 0; text-align: center; animation: rise .5s var(--ease-out) backwards; }
.done-icon { display: grid; place-items: center; width: 68px; height: 68px; margin-bottom: 22px; color: var(--accent); font-size: 34px; background: var(--accent-soft); border-radius: 22px; }
.done h1 { font-size: clamp(2.2rem, 6vw, 3.2rem); }
.done .lead { margin-inline: auto; }
.score { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); width: 100%; margin: 32px 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-surface); box-shadow: var(--shadow-1); }
.score div { padding: 22px 8px; }
.score div + div { border-left: 1px solid var(--line); }
.score b { display: block; font: 650 2.5rem/1 var(--f-display); letter-spacing: -.04em; }
.score span { display: block; margin-top: 8px; color: var(--muted); font-size: 13px; }
.score .known b { color: var(--yes); }
.score .unknown b { color: var(--no); }
.done-actions { display: grid; gap: 10px; width: min(360px, 100%); }

/* ---------- Ajouter ---------- */

.narrow { max-width: 760px; margin: 0 auto; }
.composer {
  margin-top: 32px;
  padding: 18px 18px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-surface);
  box-shadow: var(--shadow-1);
  transition: border-color .2s, box-shadow .2s;
}
.composer:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 16%, transparent), var(--shadow-2); }
.composer label { color: var(--ink-2); font-size: 13.5px; font-weight: 500; }
.composer textarea {
  display: block;
  width: 100%;
  min-height: 92px;
  margin-top: 8px;
  padding: 0;
  color: var(--ink);
  font: 600 clamp(1.4rem, 3.4vw, 1.9rem)/1.25 var(--f-display);
  letter-spacing: -.02em;
  background: transparent;
  border: 0;
  outline: none;
  resize: none;
}
.composer textarea::placeholder { color: var(--muted); }
.composer-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 10px; }
.help { color: var(--muted); font-size: 13px; }
.add-result { margin-top: 18px; }
.result { padding: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-surface); box-shadow: var(--shadow-1); animation: rise .4s var(--ease-out) backwards; }
.result-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 16px; }
.status { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; font-size: 13px; font-weight: 600; border-radius: 999px; }
.status.ok { color: var(--yes); background: var(--yes-soft); }
.status.dup { color: var(--accent-ink); background: var(--accent-soft); }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pair > div { min-width: 0; padding: 16px; background: var(--surface-2); border-radius: var(--r-inner); }
.word-sm { margin: 12px 0 0; font: 600 1.35rem/1.25 var(--f-display); letter-spacing: -.02em; overflow-wrap: anywhere; }
.result-actions { display: flex; gap: 8px; margin-top: 16px; }
.form-error { display: flex; align-items: center; gap: 8px; margin: 0; padding: 12px 16px; color: var(--no); font-size: 14.5px; background: var(--no-soft); border-radius: var(--r-inner); }
.skeleton .sk { display: block; background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 40%, var(--surface-2) 60%); background-size: 200% 100%; border-radius: 999px; animation: shimmer 1.4s linear infinite; }
.skeleton .pair > div { background: transparent; border: 1px solid var(--line); }
.sk-chip { width: 130px; height: 32px; margin-bottom: 16px; }
.sk-tag { width: 34px; height: 24px; }
.sk-line { width: 80%; height: 16px; margin-top: 14px; }
.sk-line.short { width: 48%; }
.section-head { margin: 52px 0 14px; }
.section-head h2 { font-size: 1.35rem; font-weight: 600; letter-spacing: -.02em; }
.empty { display: grid; justify-items: center; gap: 10px; padding: 36px 20px; color: var(--muted); text-align: center; border: 1px dashed var(--line-strong); border-radius: var(--r-surface); }
.empty .ph { font-size: 28px; }
@media (max-width: 640px) {
  .pair { grid-template-columns: 1fr; }
  .composer-foot .btn { width: 100%; }
}

/* ---------- Liste ---------- */

.list-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 16px; }
.list-head .count { color: var(--muted); font-size: 15px; }
.toolbar { position: sticky; top: 68px; z-index: 10; display: grid; gap: 12px; margin: 22px 0 14px; padding: 12px 0; background: var(--bg); }
.toolbar-row { display: grid; grid-template-columns: minmax(0, 1fr) 220px; gap: 10px; }
.search, .select { position: relative; display: block; }
.search .ph { position: absolute; top: 50%; left: 15px; font-size: 18px; color: var(--muted); pointer-events: none; transform: translateY(-50%); }
.search .field { padding-left: 44px; }
.select .ph { position: absolute; top: 50%; right: 15px; color: var(--muted); pointer-events: none; transform: translateY(-50%); }
.select .field { padding-right: 42px; cursor: pointer; appearance: none; -webkit-appearance: none; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scroll-snap-type: x proximity; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 7px;
  height: 38px;
  padding: 0 14px;
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  cursor: pointer;
  scroll-snap-align: start;
  transition: background-color .2s, color .2s, border-color .2s;
  -webkit-tap-highlight-color: transparent;
}
.chip .ph { font-size: 16px; }
.chip:hover { color: var(--ink); }
.chips .chip.on { color: var(--bg); background: var(--ink); border-color: var(--ink); }

.rows { margin: 0; padding: 6px; list-style: none; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-surface); box-shadow: var(--shadow-1); }
.rows li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 14px; padding: 10px 12px; border-radius: var(--r-inner); cursor: pointer; transition: background-color .15s; }
.rows li + li { margin-top: 2px; }
.rows li:hover, .rows li:focus-visible { background: var(--surface-2); outline: none; }
.row-icon { display: grid; place-items: center; width: 36px; height: 36px; color: var(--ink-2); font-size: 18px; background: var(--surface-2); border-radius: 11px; transition: background-color .15s; }
.rows li:hover .row-icon { background: var(--surface); }
.row-text { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: baseline; gap: 2px 20px; }
.row-en { font: 600 1.02rem/1.3 var(--f-display); letter-spacing: -.01em; overflow-wrap: anywhere; }
.row-fr { color: var(--ink-2); font-size: 14.5px; overflow-wrap: anywhere; }
.tag { display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 10px; color: var(--muted); font-size: 12px; font-weight: 500; white-space: nowrap; background: var(--surface-2); border-radius: 999px; }
.tag.ok { color: var(--yes); background: var(--yes-soft); }
.tag.warn { color: var(--no); background: var(--no-soft); }
.rows .empty-row { display: flex; justify-content: center; gap: 10px; padding: 32px 12px; color: var(--muted); cursor: default; }
.rows .empty-row:hover { background: transparent; }
.more { display: flex; margin: 18px auto 0; }
.logout { display: flex; margin: 36px auto 0; }
@media (max-width: 767px) {
  .toolbar { top: 60px; }
  .toolbar-row { grid-template-columns: minmax(0, 1fr); }
  .row-text { grid-template-columns: minmax(0, 1fr); }
  .tag { padding: 0 8px; }
}

/* ---------- Fenêtre d'édition ---------- */

dialog {
  width: min(560px, calc(100vw - 24px));
  max-width: none;
  max-height: calc(100dvh - 24px);
  padding: 0;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-surface);
  box-shadow: var(--shadow-3);
}
dialog::backdrop { background: rgba(9, 11, 18, .45); backdrop-filter: blur(4px); }
dialog[open] { animation: pop .35s var(--ease-out); }
@keyframes pop { from { opacity: 0; transform: translateY(16px) scale(.98); } }
.editor { display: grid; gap: 18px; padding: 22px; }
.editor-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.editor-head h2 { font-size: 1.4rem; font-weight: 600; letter-spacing: -.02em; }
.cat-picker { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; border: 0; }
.cat-picker legend { width: 100%; }
.cat-picker input { position: absolute; opacity: 0; pointer-events: none; }
.cat-picker .chip:has(input:checked) { color: var(--accent-ink); background: var(--accent-soft); border-color: var(--accent); }
.cat-picker .chip:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 16px; background: var(--surface-2); border-radius: var(--r-inner); cursor: pointer; }
.switch-row strong { display: block; font-size: 15px; font-weight: 600; }
.switch-row small { display: block; margin-top: 2px; color: var(--muted); font-size: 13px; }
.switch { position: relative; flex: none; width: 48px; height: 28px; margin: 0; background: var(--surface-3); border-radius: 999px; cursor: pointer; appearance: none; -webkit-appearance: none; transition: background-color .25s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; background: var(--surface); border-radius: 50%; box-shadow: 0 1px 3px rgba(0, 0, 0, .22); transition: transform .35s var(--ease-out); }
.switch:checked { background: var(--yes); }
.switch:checked::after { transform: translateX(20px); }
.meta-line { margin: 0; color: var(--muted); font-size: 13px; }
.editor-foot { display: flex; justify-content: space-between; gap: 10px; }
@media (max-width: 640px) {
  dialog { width: 100vw; max-height: 92dvh; margin: auto 0 0; padding-bottom: env(safe-area-inset-bottom); border-radius: var(--r-surface) var(--r-surface) 0 0; }
  dialog[open] { animation: sheet .4s var(--ease-out); }
  @keyframes sheet { from { opacity: .4; transform: translateY(60px); } }
}

/* ---------- Connexion, chargement, messages ---------- */

.login { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: center; gap: 56px; min-height: 100dvh; max-width: 1080px; margin: 0 auto; padding: 32px clamp(16px, 4vw, 40px); }
.login-form { display: grid; gap: 16px; max-width: 400px; animation: rise .5s var(--ease-out) backwards; }
.login-form .mark { width: 52px; height: 52px; margin-bottom: 8px; font-size: 22px; border-radius: 15px; }
.login-form .lead { margin: -4px 0 8px; }
.login-form .btn { width: 100%; }
.login-error { min-height: 1.4em; margin: 8px 0 0; color: var(--no); font-size: 14px; }
.login-deck { padding: 40px; animation: rise .7s var(--ease-out) .1s backwards; }
.login-deck .deck { max-width: 440px; margin: 0 auto; transform: rotate(-4deg); }
.login-deck .card-shell { cursor: default; }
.login-deck .card-inner { min-height: 340px; }
@media (max-width: 899px) {
  .login { grid-template-columns: minmax(0, 1fr); justify-items: center; }
  .login-deck { display: none; }
  .login-form { width: 100%; }
}

.boot { display: grid; place-items: center; min-height: 100dvh; }
.boot .mark { width: 52px; height: 52px; font-size: 22px; border-radius: 15px; animation: breathe 1.4s ease-in-out infinite; }

#toast {
  position: fixed;
  z-index: 50;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: calc(100vw - 24px);
  min-height: 52px;
  padding: 7px 7px 7px 18px;
  color: var(--bg);
  font-size: 14.5px;
  background: var(--ink);
  border-radius: 20px;
  box-shadow: var(--shadow-3);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 16px);
  transition: opacity .25s, transform .4s var(--ease-out);
}
#toast.show { opacity: 1; pointer-events: auto; transform: translate(-50%, 0); }
#toast:not(:has(button)) { padding-right: 18px; }
#toast button { flex: none; height: 38px; padding: 0 14px; color: var(--bg); font-weight: 600; background: color-mix(in srgb, var(--bg) 16%, transparent); border: 0; border-radius: 999px; cursor: pointer; }
@media (max-width: 767px) {
  body[data-route="accueil"] #toast, body[data-route="ajouter"] #toast, body[data-route="liste"] #toast { bottom: calc(96px + env(safe-area-inset-bottom)); }
}
body[data-route="reviser"] #toast { top: calc(64px + env(safe-area-inset-top)); bottom: auto; transform: translate(-50%, -16px); }
body[data-route="reviser"] #toast.show { transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0s !important; transition-duration: .01ms !important; }
  .card-shell.revealed .card-inner { transform: none; }
  .face-back { transform: none; visibility: hidden; }
  .card-shell.revealed .face-back { visibility: visible; }
  .card-shell.revealed .face-front { visibility: hidden; }
}
