/* FlashingFace — inspiré de l'esthétique sobre « hub » : blanc, gris, accents jaune/orange. */
:root {
  --bg: #ffffff; --bg-soft: #f9fafb; --bg-muted: #f3f4f6; --border: #e5e7eb; --border-strong: #d1d5db;
  --text: #111827; --text-soft: #4b5563; --text-faint: #9ca3af;
  --yellow: #ffd21e; --orange: #ff9d00; --accent: #ff9d00;
  --primary: #111827; --primary-text: #ffffff;
  --ok: #16a34a; --ok-bg: #dcfce7; --ko: #dc2626; --ko-bg: #fee2e2;
  --radius: 12px; --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 14px rgba(0,0,0,.05);
  --shadow-lg: 0 20px 50px -12px rgba(0,0,0,.25);
  --font: 'Source Sans 3', 'Source Sans Pro', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --topbar-h: 60px;
  color-scheme: light;
}
html.dark {
  --bg: #0b0f19; --bg-soft: #101623; --bg-muted: #1a2130; --border: #1f2937; --border-strong: #374151;
  --text: #f3f4f6; --text-soft: #b6bfcc; --text-faint: #6b7280;
  --primary: #f3f4f6; --primary-text: #0b0f19;
  --ok-bg: rgba(22,163,74,.15); --ko-bg: rgba(220,38,38,.15);
  --shadow: 0 1px 2px rgba(0,0,0,.3); --shadow-lg: 0 20px 50px -12px rgba(0,0,0,.7);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 16px; line-height: 1.5; color: var(--text); background: var(--bg); min-height: 100vh; display: flex; flex-direction: column; }
a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
code, pre, .mono { font-family: var(--mono); font-size: .88em; }
code { background: var(--bg-muted); padding: .1em .35em; border-radius: 5px; }
pre { background: var(--bg-muted); padding: .8em 1em; border-radius: var(--radius-sm); overflow-x: auto; text-align: left; }
pre code { background: none; padding: 0; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.75rem; font-weight: 700; }
h2 { font-size: 1.25rem; font-weight: 700; }
h3 { font-size: 1.05rem; font-weight: 600; }
.muted { color: var(--text-soft); }
.faint { color: var(--text-faint); }
.small { font-size: .875rem; }
.center { text-align: center; }
.link-btn { border: 0; background: none; padding: 0; font: inherit; font-weight: 600; color: var(--text); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.link-btn:hover { color: var(--orange); }
.link-btn:disabled { opacity: .5; cursor: default; }
.auth-tabs { margin-bottom: 14px; }
.form-msg .alert { margin: 0 0 12px; }
.modal p.center { margin: 14px 0 0; }
.xs { font-size: .78rem; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--orange) 70%, transparent); outline-offset: 2px; border-radius: 6px; }
.input:focus-visible, .select:focus-visible, .textarea:focus-visible, .search input:focus-visible { outline: none; }

.container { width: 100%; max-width: 1280px; margin: 0 auto; padding: 0 20px; }
main.container { flex: 1; padding-top: 24px; padding-bottom: 120px; outline: none; }

/* ───────── Barre supérieure ───────── */
.topbar { position: sticky; top: 0; z-index: 40; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.topbar-inner { height: var(--topbar-h); display: flex; align-items: center; gap: 18px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 1.15rem; white-space: nowrap; }
.brand:hover { color: inherit; }
.brand .tld { color: var(--text-faint); font-weight: 600; }
.search { flex: 1; max-width: 380px; display: flex; align-items: center; gap: 8px; background: var(--bg-soft); border: 1px solid var(--border); border-radius: 10px; padding: 0 10px; height: 36px; }
.search:focus-within { border-color: var(--border-strong); box-shadow: 0 0 0 3px color-mix(in srgb, var(--yellow) 35%, transparent); }
.search svg { width: 16px; height: 16px; fill: var(--text-faint); flex: none; }
.search input { border: 0; outline: 0; background: transparent; width: 100%; font-size: .92rem; }
.nav { display: flex; gap: 4px; margin-left: auto; }
.nav a { display: flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 8px; font-weight: 600; color: var(--text-soft); font-size: .95rem; }
.nav a:hover { color: var(--text); background: var(--bg-muted); }
.nav a.active { color: var(--text); }
.nav a.active .nav-ico { filter: none; }
.nav-ico { font-size: .95rem; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
#demo-badge { gap: .28em; }
.icon-btn { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 10px; border: 1px solid var(--border); background: var(--bg); cursor: pointer; }
.lang-toggle { width: auto; min-width: 36px; padding: 0 8px; font: 700 12.5px/1 var(--mono, monospace); letter-spacing: .02em; color: var(--muted, inherit); }
.icon-btn:hover { background: var(--bg-muted); }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; background: linear-gradient(135deg, var(--yellow), var(--orange)); color: #111; border: 0; cursor: pointer; }

/* ───────── Boutons ───────── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 38px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--border); background: linear-gradient(to bottom, var(--bg), var(--bg-muted)); font-weight: 600; font-size: .95rem; cursor: pointer; white-space: nowrap; transition: transform .05s, box-shadow .15s, background .15s; }
.btn:hover { box-shadow: var(--shadow); color: var(--text); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }
.btn-primary { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }
.btn-primary:hover { color: var(--primary-text); opacity: .92; }
.btn-accent { background: linear-gradient(to bottom, #ffe066, var(--yellow)); color: #111; border-color: #f5c400; }
.btn-accent:hover { color: #111; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--bg-muted); box-shadow: none; }
.btn-danger { color: var(--ko); }
.btn-sm { height: 30px; padding: 0 10px; font-size: .85rem; border-radius: 8px; }
.btn-lg { height: 46px; padding: 0 22px; font-size: 1.05rem; border-radius: 12px; }
.btn-block { width: 100%; }

/* ───────── Formulaires ───────── */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label, .label { font-weight: 600; font-size: .9rem; }
.input, .select, .textarea { width: 100%; border: 1px solid var(--border); background: var(--bg); border-radius: var(--radius-sm); padding: 8px 11px; font-size: .95rem; outline: none; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--border-strong); box-shadow: 0 0 0 3px color-mix(in srgb, var(--yellow) 35%, transparent); }
.textarea { min-height: 84px; resize: vertical; line-height: 1.45; }
.textarea.mono { font-family: var(--mono); font-size: .82rem; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1 1 180px; }
.hint { font-size: .8rem; color: var(--text-faint); }

/* ───────── Tags / pastilles ───────── */
.tag { display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 8px; border-radius: 7px; background: var(--bg-muted); border: 1px solid var(--border); font-size: .8rem; color: var(--text-soft); cursor: pointer; white-space: nowrap; }
.tag:hover { border-color: var(--border-strong); color: var(--text); }
.tag.active { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.badge { display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 6px; font-size: .72rem; font-weight: 700; background: var(--bg-muted); color: var(--text-soft); }
.badge-mcq { background: color-mix(in srgb, #8b5cf6 15%, transparent); color: #7c3aed; }
.badge-d1 { color: var(--ok); } .badge-d2 { color: #d97706; } .badge-d3 { color: var(--ko); }

/* ───────── Couleurs de deck ───────── */
.c-yellow { --c1: #fef3c7; --c2: #fde68a; } .c-orange { --c1: #ffedd5; --c2: #fed7aa; }
.c-red { --c1: #fee2e2; --c2: #fecaca; } .c-pink { --c1: #fce7f3; --c2: #fbcfe8; }
.c-purple { --c1: #ede9fe; --c2: #ddd6fe; } .c-blue { --c1: #dbeafe; --c2: #bfdbfe; }
.c-cyan { --c1: #cffafe; --c2: #a5f3fc; } .c-green { --c1: #dcfce7; --c2: #bbf7d0; }
.c-gray { --c1: #f3f4f6; --c2: #e5e7eb; }
html.dark [class*="c-"] { --c1: color-mix(in srgb, var(--c2) 22%, #0b0f19); --c2: color-mix(in srgb, var(--c2) 40%, #0b0f19); }
.deck-ico { flex: none; width: 44px; height: 44px; border-radius: 11px; display: grid; place-items: center; font-size: 1.4rem; background: linear-gradient(135deg, var(--c1), var(--c2)); }
.deck-ico.lg { width: 64px; height: 64px; font-size: 2rem; border-radius: 16px; }

/* ───────── Page d'exploration ───────── */
.explore { display: grid; grid-template-columns: 250px 1fr; gap: 32px; }
.sidebar { position: sticky; top: calc(var(--topbar-h) + 20px); align-self: start; display: flex; flex-direction: column; gap: 22px; }
.sidebar h3 { font-size: .9rem; font-weight: 600; color: var(--text-soft); margin-bottom: 8px; }
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h1 { margin: 0; font-size: 1.35rem; }
.count-pill { font-family: var(--mono); font-size: .85rem; color: var(--text-faint); }
.spacer { flex: 1; }
.hero { border: 1px solid var(--border); border-radius: 16px; padding: 26px 28px; margin-bottom: 22px; background: radial-gradient(120% 140% at 100% 0%, color-mix(in srgb, var(--yellow) 30%, transparent), transparent 55%), var(--bg-soft); display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.hero h1 { font-size: 1.6rem; font-weight: 800; margin-bottom: 4px; }
.hero p { margin: 0; color: var(--text-soft); max-width: 640px; }
.hero .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.hero-live { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 420px); gap: 48px; align-items: center; }
.hero-live .hero-text { display: flex; flex-direction: column; gap: 16px; }
.hero-live .hero-text h1 { font-size: clamp(1.6rem, 3.2vw, 2.25rem); line-height: 1.1; letter-spacing: -.01em; margin: 0; max-width: 20ch; }
.hero-live .actions { margin-left: 0; }

/* Carte d'exemple : le seul élément « spectaculaire » de l'accueil */
.hero-card { position: relative; height: 236px; margin-right: 12px; perspective: 1200px; cursor: pointer; outline-offset: 6px; border-radius: 16px; }
.hero-card::before, .hero-card::after { content: ''; position: absolute; inset: 0; border-radius: 16px; border: 1px solid var(--border-strong); background: var(--bg); }
.hero-card::before { transform: rotate(5deg) translate(10px, 4px); background: color-mix(in srgb, var(--orange) 55%, var(--bg)); border-color: transparent; }
.hero-card::after { transform: rotate(2deg) translate(4px, 2px); }
.hc-inner { position: relative; z-index: 1; height: 100%; transform-style: preserve-3d; transition: transform .55s cubic-bezier(.2,.8,.2,1); }
.hero-card.flipped .hc-inner { transform: rotateY(180deg); }
.hc-face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; border-radius: 16px; border: 1.5px solid var(--text); background: var(--bg); box-shadow: 0 14px 30px -14px rgba(0,0,0,.35); display: flex; flex-direction: column; padding: 14px 16px; }
.hc-back { transform: rotateY(180deg); background: var(--yellow); color: #111827; border-color: #111827; }
.hc-face .deck-chip { align-self: flex-start; display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px 2px 4px; border-radius: 99px; background: linear-gradient(135deg, var(--c1), var(--c2)); font-size: .8rem; font-weight: 600; max-width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.hc-body { flex: 1; display: flex; align-items: center; justify-content: center; text-align: center; font-size: 1.4rem; font-weight: 700; line-height: 1.25; overflow: hidden; color: var(--text); }
.hc-back .hc-body { color: #111827; }
.hero-card .hc-body p { margin: 0; color: inherit; max-width: none; }
.hc-body pre { font-size: .75rem; font-weight: 400; text-align: left; margin: 0; }
.hc-foot { font-size: .78rem; color: var(--text-faint); text-align: center; }
.hc-back .hc-foot { color: #4b5563; }

.deck-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 12px; }
.deck-card { position: relative; display: flex; gap: 12px; align-items: flex-start; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius); background: linear-gradient(to bottom, var(--bg-soft), var(--bg)); cursor: pointer; }
.deck-card:hover { border-color: var(--border-strong); }
.deck-card.selected { border-color: var(--orange); box-shadow: 0 0 0 2px color-mix(in srgb, var(--orange) 35%, transparent); }
.deck-card .body { flex: 1; min-width: 0; }
.deck-card .title { font-weight: 700; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.deck-card .path { font-family: var(--mono); font-size: .78rem; color: var(--text-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.deck-card .meta { display: flex; gap: 10px; flex-wrap: wrap; font-size: .8rem; color: var(--text-soft); margin-top: 6px; align-items: center; }
.deck-card .meta span { display: inline-flex; align-items: center; gap: 3px; }
.check { flex: none; width: 24px; height: 24px; border-radius: 7px; border: 1.5px solid var(--border-strong); background: var(--bg); display: grid; place-items: center; cursor: pointer; color: transparent; font-size: .85rem; font-weight: 800; }
.selected .check, .check.on { background: var(--orange); border-color: var(--orange); color: #fff; }
.mini-progress { height: 4px; border-radius: 4px; background: var(--bg-muted); overflow: hidden; margin-top: 9px; }
.mini-progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--yellow), var(--orange)); }

.empty { text-align: center; padding: 60px 20px; color: var(--text-soft); border: 1px dashed var(--border-strong); border-radius: 16px; }
.empty .big { font-size: 2.5rem; }

/* Barre de sélection flottante */
.selection-bar { position: fixed; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 45; display: flex; align-items: center; gap: 12px; padding: 10px 10px 10px 18px; background: var(--primary); color: var(--primary-text); border-radius: 16px; box-shadow: var(--shadow-lg); width: min(680px, calc(100% - 24px)); animation: rise .2s ease-out; }
.selection-bar .info { flex: 1; min-width: 0; font-weight: 600; line-height: 1.2; }
.selection-bar .info small { display: block; font-weight: 400; opacity: .7; }
.selection-bar .btn-ghost { color: var(--primary-text); }
.selection-bar .btn-ghost:hover { background: rgba(127,127,127,.2); }
@keyframes rise { from { transform: translate(-50%, 20px); opacity: 0; } }

/* ───────── Page deck ───────── */
.deck-header { display: flex; gap: 16px; align-items: flex-start; padding-bottom: 18px; border-bottom: 1px solid var(--border); margin-bottom: 18px; flex-wrap: wrap; }
.deck-header .path { font-family: var(--mono); color: var(--text-soft); font-size: .95rem; }
.deck-header h1 { margin: 2px 0 8px; }
.deck-header .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.deck-layout { display: grid; grid-template-columns: 1fr 300px; gap: 28px; }
.panel { border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; background: var(--bg); }
.panel + .panel { margin-top: 14px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--bg-soft); border: 1px solid var(--border); border-radius: 10px; padding: 10px; text-align: center; }
.stat b { display: block; font-size: 1.35rem; line-height: 1.1; }
.stat span { font-size: .75rem; color: var(--text-soft); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; font-size: .9rem; }
.kv dt { color: var(--text-faint); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.card-list { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.card-row { display: grid; grid-template-columns: 34px 1fr 1fr auto; gap: 14px; padding: 11px 14px; border-top: 1px solid var(--border); align-items: start; font-size: .92rem; }
.card-row:first-child { border-top: 0; }
.card-row:nth-child(even) { background: var(--bg-soft); }
.card-row .n { font-family: var(--mono); color: var(--text-faint); font-size: .78rem; padding-top: 2px; }
.card-row .rich p { margin: 0; }
.card-row .rich pre { font-size: .75rem; margin: 4px 0; }
.box-dots { display: flex; gap: 3px; padding-top: 6px; }
.box-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--bg-muted); border: 1px solid var(--border-strong); }
.box-dots i.on { background: var(--orange); border-color: var(--orange); }
.description { color: var(--text-soft); margin: 0 0 6px; }
.description p { margin: 0 0 .5em; }

/* ───────── Onglets ───────── */
.tabs { display: flex; gap: 4px; box-shadow: inset 0 -1px 0 var(--border); margin-bottom: 18px; overflow-x: auto; overflow-y: hidden; }
.tabs button { background: none; border: 0; padding: 10px 14px; font-weight: 600; color: var(--text-soft); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.active { color: var(--text); border-bottom-color: var(--orange); }

/* ───────── Import ───────── */
.narrow { max-width: 860px; margin: 0 auto; }
.dropzone { display: block; border: 2px dashed var(--border-strong); border-radius: 16px; padding: 34px 20px; text-align: center; background: var(--bg-soft); cursor: pointer; transition: background .15s, border-color .15s; }
.dropzone.over { border-color: var(--orange); background: color-mix(in srgb, var(--yellow) 12%, var(--bg)); }
.dropzone .big { font-size: 2.2rem; }
.alert { border-radius: 10px; padding: 10px 14px; font-size: .9rem; margin: 12px 0; border: 1px solid; }
.alert ul { margin: 4px 0 0; padding-left: 18px; }
.alert-ko { background: var(--ko-bg); border-color: color-mix(in srgb, var(--ko) 35%, transparent); }
.alert-ok { background: var(--ok-bg); border-color: color-mix(in srgb, var(--ok) 35%, transparent); }
.alert-warn { background: color-mix(in srgb, var(--yellow) 18%, transparent); border-color: color-mix(in srgb, var(--orange) 40%, transparent); }
.or { display: flex; align-items: center; gap: 12px; color: var(--text-faint); margin: 18px 0; font-size: .85rem; }
.or::before, .or::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* ───────── Éditeur ───────── */
.editor-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; margin-bottom: 10px; background: var(--bg); }
.editor-card.dirty { border-color: var(--orange); }
.editor-card .head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.editor-card .head .n { font-family: var(--mono); color: var(--text-faint); font-size: .8rem; }
.choice-row { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }
.choice-row input[type=radio] { width: 18px; height: 18px; accent-color: var(--ok); }

/* ───────── Session de révision ───────── */
.study { max-width: 720px; margin: 0 auto; display: flex; flex-direction: column; min-height: calc(100vh - var(--topbar-h) - 120px); }
.study-top { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.progress { flex: 1; height: 8px; border-radius: 8px; background: var(--bg-muted); overflow: hidden; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--yellow), var(--orange)); transition: width .3s; }
.study-count { font-family: var(--mono); font-size: .85rem; color: var(--text-soft); white-space: nowrap; }
.scene { perspective: 1400px; flex: 1; display: flex; min-height: 340px; touch-action: pan-y; }
.flashcard { position: relative; width: 100%; flex: 1; transform-style: preserve-3d; transition: transform .5s cubic-bezier(.2,.8,.2,1); cursor: pointer; }
.flashcard.flipped { transform: rotateY(180deg); }
.flashcard.swipe-left { transform: translateX(-120%) rotate(-12deg); opacity: 0; transition: transform .3s, opacity .3s; }
.flashcard.swipe-right { transform: translateX(120%) rotate(12deg); opacity: 0; transition: transform .3s, opacity .3s; }
.flashcard.flipped.swipe-left { transform: rotateY(180deg) translateX(120%) rotate(12deg); }
.flashcard.flipped.swipe-right { transform: rotateY(180deg) translateX(-120%) rotate(-12deg); }
.face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; border-radius: 20px; border: 1px solid var(--border); background: var(--bg); box-shadow: var(--shadow-lg); display: flex; flex-direction: column; padding: 22px; overflow: hidden; }
.face.back { transform: rotateY(180deg); background: linear-gradient(to bottom, var(--bg), var(--bg-soft)); }
.face .face-top { display: flex; align-items: center; gap: 8px; font-size: .8rem; color: var(--text-faint); }
.face .deck-chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px 3px 4px; border-radius: 99px; background: linear-gradient(135deg, var(--c1), var(--c2)); color: var(--text); font-weight: 600; max-width: 70%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.face .content { flex: 1; display: flex; flex-direction: column; justify-content: flex-start; align-items: center; text-align: center; font-size: clamp(1.2rem, 3.6vw, 1.7rem); font-weight: 600; overflow-y: auto; padding: 12px 4px; }
/* Centrage vertical qui reste défilable quand le contenu déborde (justify-content: center couperait le haut) */
.face .content > :first-child { margin-top: auto; }
.face .content > :last-child { margin-bottom: auto; }
.face .content p { margin: 0 0 .4em; }
.face .content pre { font-size: .9rem; font-weight: 400; max-width: 100%; }
.face .content ul, .face .content ol { text-align: left; }
.face .question-small { font-size: .95rem; color: var(--text-faint); font-weight: 400; text-align: center; margin-bottom: 4px; }
.face .explain { font-size: .95rem; color: var(--text-soft); font-weight: 400; border-top: 1px dashed var(--border-strong); padding-top: 10px; margin-top: 6px; text-align: left; overflow-y: auto; max-height: 40%; }
.face .explain p { margin: 0 0 .4em; }
.face .tap { text-align: center; font-size: .8rem; color: var(--text-faint); }
.hint-box { font-size: .95rem; font-weight: 400; color: #b45309; background: color-mix(in srgb, var(--yellow) 18%, transparent); padding: 6px 12px; border-radius: 10px; margin-top: 12px; }
html.dark .hint-box { color: #fcd34d; }
.choices { display: grid; gap: 8px; width: 100%; margin-top: 16px; font-size: 1rem; font-weight: 500; }
.choice { display: flex; gap: 10px; align-items: center; text-align: left; padding: 11px 14px; border-radius: 12px; border: 1px solid var(--border); background: var(--bg-soft); cursor: pointer; }
.choice:hover:not(:disabled) { border-color: var(--border-strong); background: var(--bg-muted); }
.choice .k { font-family: var(--mono); font-size: .75rem; color: var(--text-faint); width: 18px; }
.choice.correct { background: var(--ok-bg); border-color: var(--ok); }
.choice.wrong { background: var(--ko-bg); border-color: var(--ko); }
.choice:disabled { cursor: default; }
.study-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 18px; }
.study-actions .btn { height: 54px; font-size: 1.02rem; border-radius: 14px; }
.btn-ko { background: var(--ko-bg); color: var(--ko); border-color: color-mix(in srgb, var(--ko) 35%, transparent); }
.btn-ok { background: var(--ok-bg); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 35%, transparent); }
.btn-ko:hover { color: var(--ko); } .btn-ok:hover { color: var(--ok); }
.kbd { font-family: var(--mono); font-size: .7rem; padding: 1px 5px; border-radius: 4px; border: 1px solid currentColor; opacity: .55; }
.study-help { text-align: center; font-size: .8rem; color: var(--text-faint); margin-top: 10px; }

.results { text-align: center; max-width: 640px; margin: 0 auto; }
.score-ring { width: 150px; height: 150px; margin: 10px auto 16px; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--orange) calc(var(--p) * 1%), var(--bg-muted) 0); }
.score-ring > div { width: 120px; height: 120px; border-radius: 50%; background: var(--bg); display: grid; place-items: center; font-size: 2rem; font-weight: 800; }
.results .actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin: 18px 0; }
.missed { text-align: left; }

/* ───────── Modale ───────── */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 60; display: flex; align-items: center; justify-content: center; padding: 16px; animation: fade .15s; }
.modal { background: var(--bg); border: 1px solid var(--border); border-radius: 18px; width: min(520px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; box-shadow: var(--shadow-lg); padding: 22px; }
.modal-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.modal-head h2 { margin: 0; flex: 1; }
.seg { display: flex; background: var(--bg-muted); border-radius: 10px; padding: 3px; gap: 3px; }
.seg button { flex: 1; border: 0; background: transparent; border-radius: 8px; padding: 7px 6px; font-weight: 600; font-size: .9rem; cursor: pointer; color: var(--text-soft); }
.seg button.on { background: var(--bg); color: var(--text); box-shadow: var(--shadow); }
.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: .95rem; }
.switch input { width: 18px; height: 18px; accent-color: var(--orange); }
@keyframes fade { from { opacity: 0; } }

/* ───────── Divers ───────── */
.toasts { position: fixed; top: calc(var(--topbar-h) + 10px); right: 16px; z-index: 70; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--primary); color: var(--primary-text); padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow-lg); font-size: .92rem; animation: fade .2s; max-width: 340px; }
.toast.ko { background: var(--ko); color: #fff; }
.loading { display: grid; place-items: center; padding: 80px 0; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--bg-muted); border-top-color: var(--orange); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.footer { padding: 22px 20px; border-top: 1px solid var(--border); font-size: .85rem; color: var(--text-faint); }
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 18px 0 26px; }
.step { border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; background: linear-gradient(to bottom, var(--bg-soft), var(--bg)); }
.step .num { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; font-weight: 800; background: var(--yellow); color: #111; margin-bottom: 8px; }
.step p { margin: 0; color: var(--text-soft); font-size: .92rem; }
.prose { max-width: 820px; }
.prose table { border-collapse: collapse; width: 100%; font-size: .88rem; margin: 10px 0 18px; display: block; overflow-x: auto; }
.prose th, .prose td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; vertical-align: top; }
.prose th { background: var(--bg-soft); }
.copy-wrap { position: relative; }
.copy-wrap .btn { position: absolute; top: 8px; right: 8px; }
.filter-toggle { display: none; }

/* ───────── Responsive ───────── */
@media (max-width: 1000px) {
  .deck-layout { grid-template-columns: 1fr; }
  .deck-layout aside { order: -1; }
}
@media (max-width: 860px) {
  .hero-live { grid-template-columns: 1fr; gap: 24px; }
  .hero-card { max-width: 420px; width: calc(100% - 14px); }
  .explore { grid-template-columns: 1fr; gap: 0; }
  .sidebar { position: static; display: none; margin-bottom: 16px; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius); }
  .sidebar.open { display: flex; }
  .filter-toggle { display: inline-flex; }
  .steps { grid-template-columns: 1fr; }
  .search { max-width: none; }
  .nav-label { display: none; }
}
@media (max-width: 640px) {
  .container { padding: 0 14px; }
  main.container { padding-top: 16px; }
  .topbar-inner { gap: 10px; }
  .brand span { display: none; }
  .nav { gap: 0; }
  .nav a { padding: 6px 8px; }
  .deck-grid { grid-template-columns: 1fr; }
  .hero { padding: 16px; }
  .hero h1 { font-size: 1.3rem; }
  .hero .actions { margin-left: 0; width: 100%; }
  .hero .actions .btn { flex: 1; }
  .deck-header .actions { margin-left: 0; width: 100%; }
  .deck-header .actions .btn { flex: 1; }
  .card-row { grid-template-columns: 1fr; gap: 4px; }
  .card-row .n { display: none; }
  .card-row .back-cell { color: var(--text-soft); }
  .scene { min-height: 52vh; }
  .face { padding: 16px; border-radius: 18px; }
  .study-help { display: none; }
  .modal { padding: 18px; border-radius: 18px 18px 0 0; }
  .modal-backdrop { align-items: flex-end; padding: 0; }
  .selection-bar { padding: 8px 8px 8px 14px; border-radius: 14px; }
  .selection-bar .hide-sm { display: none; }
  .toasts { left: 14px; right: 14px; }
  .kbd, .hide-sm { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ───────── Images de cartes (FFD v1.1) ───────── */
.card-img { margin: 14px auto 4px; max-width: 100%; display: flex; justify-content: center; }
/* Largeur explicite : un SVG sans width/height n'a pas de taille propre ; la hauteur suit le viewBox */
.card-img { width: 100%; }
.card-img img { display: block; width: min(100%, 360px); height: auto; max-height: 32vh; object-fit: contain; border-radius: 10px; background: #fff; }
.face .content:has(.choices) .card-img img { max-height: 22vh; }
.card-img.sm img { width: min(100%, 140px); max-height: 12vh; opacity: .9; }
.thumb { float: right; width: 44px; height: 44px; object-fit: contain; margin: 0 0 4px 8px; border-radius: 6px; background: #fff; border: 1px solid var(--border); }
.img-block { margin: 2px 0 12px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.img-add { cursor: pointer; }
.img-edit { display: flex; gap: 12px; align-items: flex-start; width: 100%; }
.img-prev { width: 120px; height: 90px; object-fit: contain; border: 1px solid var(--border); border-radius: 8px; background: #fff; flex: none; }
.img-fields { flex: 1; min-width: 0; }
.img-fields .field { margin-bottom: 6px; }
.img-actions { display: flex; gap: 8px; align-items: center; }
@media (max-width: 560px) { .img-edit { flex-direction: column; } .img-prev { width: 100%; height: 140px; } }
