/* ==========================================================================
   English Coach — design system « Trio »
   Inspiré de PRIMUS ERP (Zodiac) : surfaces planes, rayons nets, ombres sobres,
   titres Segoe UI Light, libellés espacés dorés, filet or → jaune → fuchsia.
   Règles d'interaction : fuchsia = survol / focus, jaune = élément actif.
   Un jeton, un usage : toute nouvelle règle réutilise un --*.
   Thèmes : data-theme="light|dark" (ou système), data-accent, data-density.
   ========================================================================== */
:root {
  /* Surfaces */
  --bg-body: #f4f5f7;
  --bg-sidebar: #ffffff;
  --bg-card: #ffffff;
  --bg-elev: #ffffff;
  --hover-bg: #f1f4f8;
  --icon-bg: #e8eef5;
  --zebra: #f8fafc;
  --border-subtle: #e4e7eb;
  --border-strong: #cbd2d9;
  /* Texte */
  --text-primary: #1f2933;
  --text-secondary: #52606d;
  --text-muted: #8a96a3;
  --text-on-brand: #ffffff;
  /* Marque (accent « trio » par défaut) */
  --brand: #1f4e79;
  --brand-dark: #173b5c;
  --brand-text: #1f4e79;
  --brand-soft: rgba(31, 78, 121, .10);
  --brand-gradient: linear-gradient(135deg, #1f4e79 0%, #2f5fa8 55%, #5457d6 100%);
  --accent: #c026d3;
  --accent-soft: rgba(192, 38, 211, .12);
  --yellow: #facc15;
  --yellow-soft: rgba(250, 204, 21, .22);
  --gold: #c9a24a;
  --gold-text: #a98123;
  --accent-line: linear-gradient(90deg, var(--gold) 0%, var(--yellow) 55%, var(--accent) 100%);
  /* Sémantique */
  --ok: #2f855a;    --ok-soft: #e6f4ec;
  --bad: #c53030;   --bad-soft: #fdecec;
  --warn: #b7791f;  --warn-soft: #fff6e0;
  --info: #2563eb;  --info-soft: #e8f0ff;
  /* Tuiles d'icônes par compétence */
  --g-reading: linear-gradient(135deg, #1f4e79, #3b78ad);
  --g-listening: linear-gradient(135deg, #4547c4, #6366f1);
  --g-writing: linear-gradient(135deg, #276749, #48bb78);
  --g-speaking: linear-gradient(135deg, #a16207, #f5b700);
  --g-conversation: linear-gradient(135deg, #1f4e79, #c026d3);
  --g-grammar: linear-gradient(135deg, #9b2c2c, #e05252);
  --g-vocab: linear-gradient(135deg, #0e7490, #22b8cf);
  /* Rayons, ombres, mouvement */
  --radius-card: 8px;
  --radius-small: 5px;
  --radius-tile: 12px;
  --shadow-soft: 0 1px 2px rgba(15, 23, 42, .06);
  --shadow-lift: 0 2px 10px rgba(15, 23, 42, .10);
  --shadow-pop: 0 18px 50px rgba(15, 23, 42, .22);
  --shadow-glow: 0 1px 2px rgba(31, 78, 121, .18), 0 4px 12px rgba(31, 78, 121, .22);
  --ease: cubic-bezier(.4, 0, .2, 1);
  --ease-bounce: cubic-bezier(.34, 1.56, .64, 1);
  /* Gabarit */
  --font-scale: 1;
  --pad-card: 18px;
  --gap: 16px;
  --sidebar-w: 256px;
  --nav-h: 62px;
  --font: "Segoe UI Variable Text", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-light: "Segoe UI Light", "Segoe UI Variable Display", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
  --font-mono: "Cascadia Code", Consolas, "SF Mono", Menlo, monospace;
  /* Alias historiques utilisés par les vues */
  --bg: var(--bg-body); --surface: var(--bg-card); --surface-2: var(--hover-bg); --text: var(--text-primary);
  --muted: var(--text-secondary); --border: var(--border-subtle); --primary: var(--brand); --primary-soft: var(--brand-soft);
  --radius: var(--radius-card); --shadow: var(--shadow-soft);
  color-scheme: light;
}

/* ---------- Thème sombre ---------- */
:root[data-theme="dark"] {
  --bg-body: #0e131a;
  --bg-sidebar: #121922;
  --bg-card: #151d27;
  --bg-elev: #1a2430;
  --hover-bg: #1c2632;
  --icon-bg: #1f2b39;
  --zebra: #17202b;
  --border-subtle: #243140;
  --border-strong: #34455a;
  --text-primary: #e6edf3;
  --text-secondary: #a9b5c3;
  --text-muted: #6d7c8d;
  --brand-text: #8db7ea;
  --brand-soft: rgba(91, 143, 208, .16);
  --accent: #e15ef0;
  --accent-soft: rgba(225, 94, 240, .16);
  --gold-text: #d9b45c;
  --ok: #52c08a;    --ok-soft: rgba(82, 192, 138, .14);
  --bad: #f07171;   --bad-soft: rgba(240, 113, 113, .14);
  --warn: #e9b44c;  --warn-soft: rgba(233, 180, 76, .14);
  --info: #6aa1ff;  --info-soft: rgba(106, 161, 255, .14);
  --shadow-soft: 0 1px 2px rgba(0, 0, 0, .35);
  --shadow-lift: 0 4px 14px rgba(0, 0, 0, .45);
  --shadow-pop: 0 20px 60px rgba(0, 0, 0, .6);
  color-scheme: dark;
}

/* ---------- Couleurs d'accent ---------- */
:root[data-accent="indigo"] { --brand: #4f46e5; --brand-dark: #3730a3; --brand-text: #4f46e5; --brand-soft: rgba(79, 70, 229, .10); --brand-gradient: linear-gradient(135deg, #4338ca, #6366f1 55%, #8b5cf6); --accent: #ec4899; --accent-soft: rgba(236, 72, 153, .12); --shadow-glow: 0 4px 12px rgba(79, 70, 229, .28); }
:root[data-accent="emerald"] { --brand: #047857; --brand-dark: #065f46; --brand-text: #047857; --brand-soft: rgba(4, 120, 87, .10); --brand-gradient: linear-gradient(135deg, #065f46, #059669 55%, #14b8a6); --accent: #0ea5e9; --accent-soft: rgba(14, 165, 233, .12); --shadow-glow: 0 4px 12px rgba(4, 120, 87, .28); }
:root[data-accent="ocean"] { --brand: #0369a1; --brand-dark: #075985; --brand-text: #0369a1; --brand-soft: rgba(3, 105, 161, .10); --brand-gradient: linear-gradient(135deg, #075985, #0284c7 55%, #06b6d4); --accent: #8b5cf6; --accent-soft: rgba(139, 92, 246, .12); --shadow-glow: 0 4px 12px rgba(3, 105, 161, .28); }
:root[data-accent="sunset"] { --brand: #c2410c; --brand-dark: #9a3412; --brand-text: #c2410c; --brand-soft: rgba(194, 65, 12, .10); --brand-gradient: linear-gradient(135deg, #9a3412, #ea580c 55%, #f59e0b); --accent: #db2777; --accent-soft: rgba(219, 39, 119, .12); --shadow-glow: 0 4px 12px rgba(194, 65, 12, .28); }
:root[data-theme="dark"][data-accent] { --brand-text: color-mix(in srgb, var(--brand) 55%, #ffffff); }

:root[data-density="compact"] { --pad-card: 13px; --gap: 11px; --nav-h: 56px; }

@keyframes fadeSlideUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes ctxPop { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { box-shadow: 0 0 0 8px color-mix(in srgb, var(--bad) 25%, transparent); } }
@keyframes blink { 50% { opacity: .2; } }
@keyframes caret { 50% { opacity: 0; } }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; font-size: calc(15px * var(--font-scale)); }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  color: var(--text-primary);
  background:
    radial-gradient(1100px 700px at 8% -12%, color-mix(in srgb, var(--brand) 6%, transparent), transparent 60%),
    radial-gradient(900px 600px at 70% 120%, rgba(250, 204, 21, .07), transparent 60%),
    var(--bg-body);
  background-attachment: fixed;
}
::selection { background: rgba(250, 204, 21, .45); color: inherit; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .6em; color: var(--text-primary); }
h1 { font-family: var(--font-light); font-weight: 300; font-size: 1.75rem; letter-spacing: -.01em; }
h2 { font-family: var(--font-light); font-weight: 300; font-size: 1.3rem; letter-spacing: -.005em; }
h3 { font-size: 1rem; font-weight: 600; }
h4 { font-size: .92rem; font-weight: 600; margin-top: .8em; }
b, strong, th { font-weight: 600; }
p { margin: 0 0 .8em; }
a { color: var(--brand-text); text-decoration-color: color-mix(in srgb, currentColor 35%, transparent); text-underline-offset: 3px; }
a:hover { color: var(--accent); }
code, kbd { font-family: var(--font-mono); background: var(--icon-bg); padding: 1px 6px; border-radius: 4px; font-size: .84em; word-break: break-all; }
kbd { border: 1px solid var(--border-strong); border-bottom-width: 2px; word-break: normal; }
ul, ol { padding-left: 1.2em; margin: 0 0 .8em; }
hr { border: none; border-top: 1px solid var(--border-subtle); margin: 16px 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.hidden { display: none !important; }
.muted { color: var(--text-secondary); }
.faint { color: var(--text-muted); }
.small { font-size: .86rem; }
.xsmall { font-size: .76rem; }
.center { text-align: center; justify-content: center; }
.pos, .ok { color: var(--ok); }
.neg, .error { color: var(--bad); }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* SVG des icônes (js/icons.js) */
.ico { width: 1.15em; height: 1.15em; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vertical-align: -.2em; }

/* ==========================================================================
   Cadre d'application
   ========================================================================== */
.app-shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100dvh; }

.sidebar {
  position: sticky; top: 0; height: 100dvh;
  display: flex; flex-direction: column;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  z-index: 30;
}
.sidebar-header { position: relative; display: flex; align-items: center; gap: 12px; padding: 20px 18px 18px; text-decoration: none; }
.sidebar-header::after { content: ""; position: absolute; left: 18px; bottom: 0; width: 40px; height: 3px; border-radius: 3px; background: var(--accent-line); }
.sidebar-logo { width: 42px; height: 42px; border-radius: var(--radius-tile); background: var(--brand-gradient); display: grid; place-items: center; color: #fff; box-shadow: var(--shadow-glow); flex: none; }
.sidebar-logo .ico { width: 24px; height: 24px; }
.sidebar-title { display: flex; flex-direction: column; line-height: 1.15; }
.sidebar-title-main { font-size: 1.08rem; font-weight: 700; letter-spacing: .14em; background: var(--brand-gradient); -webkit-background-clip: text; background-clip: text; color: transparent; }
:root[data-theme="dark"] .sidebar-title-main { background: linear-gradient(90deg, #e6edf3, var(--brand-text)); -webkit-background-clip: text; background-clip: text; }
.sidebar-title-sub { font-size: .64rem; text-transform: uppercase; letter-spacing: .2em; color: var(--gold-text); font-weight: 600; margin-top: 3px; }

.sidebar-level { margin: 16px 14px 4px; padding: 12px; border: 1px solid var(--border-subtle); border-radius: var(--radius-card); background: linear-gradient(135deg, var(--brand-soft), transparent); display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; transition: border-color .2s var(--ease); }
.sidebar-level:hover { border-color: var(--accent); color: inherit; }
.sidebar-level .lvl { font-family: var(--font-light); font-weight: 300; font-size: 1.9rem; line-height: 1; color: var(--brand-text); }
.sidebar-level .meta { flex: 1; min-width: 0; font-size: .78rem; color: var(--text-secondary); }
.sidebar-level .meta b { color: var(--text-primary); font-size: .84rem; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 6px 10px 12px; scrollbar-width: thin; }
.nav-section-label { margin: 16px 8px 6px; font-size: .64rem; font-weight: 600; letter-spacing: .22em; text-transform: uppercase; color: var(--text-muted); }
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 7px 10px; margin: 1px 0; border-radius: 0 6px 6px 0;
  border-left: 3px solid transparent;
  color: var(--text-secondary); text-decoration: none; font-size: .9rem; font-weight: 500;
  transition: background .18s var(--ease), border-color .18s var(--ease), color .18s var(--ease);
}
.nav-bullet { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: var(--icon-bg); color: var(--brand-text); transition: all .2s var(--ease); flex: none; }
.nav-bullet .ico { width: 16px; height: 16px; }
.nav-item:hover { background: var(--hover-bg); color: var(--text-primary); }
.nav-item:not(.active):hover { border-left-color: var(--accent); }
.nav-item.active { background: var(--hover-bg); border-left-color: var(--yellow); color: var(--text-primary); font-weight: 600; }
.nav-item:hover .nav-bullet, .nav-item.active .nav-bullet { background: var(--brand-gradient); color: #fff; box-shadow: 0 4px 10px color-mix(in srgb, var(--brand) 32%, transparent); }
.nav-badge { margin-left: auto; font-size: .68rem; font-weight: 700; padding: 1px 7px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }

.sidebar-footer { border-top: 1px solid var(--border-subtle); padding: 12px 14px; }
.user-row { display: flex; align-items: center; gap: 10px; }
.user-avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--brand-gradient); color: #fff; font-size: .78rem; font-weight: 700; box-shadow: 0 0 0 2px var(--bg-sidebar), 0 0 0 4px var(--yellow); flex: none; }
.user-meta { flex: 1; min-width: 0; line-height: 1.25; }
.user-name { font-size: .86rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-sub { font-size: .72rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.main { min-width: 0; padding: 22px 32px 40px; outline: none; }
.view { max-width: 1180px; margin: 0 auto; }
.view > * { animation: fadeSlideUp .35s var(--ease) backwards; }
.view > *:nth-child(2) { animation-delay: .04s; }
.view > *:nth-child(3) { animation-delay: .08s; }
.view > *:nth-child(4) { animation-delay: .12s; }

/* Barre du haut (mobile) */
.topbar { display: none; }

/* Navigation basse (mobile) */
.bottom-nav { display: none; }

/* ---------- En-tête de page (carte + filet signature) ---------- */
.page-header {
  position: relative; overflow: hidden;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  background: var(--bg-card); border: 1px solid var(--border-subtle); border-radius: var(--radius-card);
  box-shadow: var(--shadow-soft); padding: 18px 20px; margin: 0 auto var(--gap); max-width: 1180px;
}
.page-header::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--accent-line); }
.header-icon { width: 46px; height: 46px; border-radius: var(--radius-tile); display: grid; place-items: center; background: var(--brand-gradient); color: #fff; box-shadow: var(--shadow-glow); flex: none; }
.header-icon .ico { width: 24px; height: 24px; }
.header-text { flex: 1; min-width: 200px; }
.header-text h1 { margin: 0; font-size: 1.7rem; }
.header-subtitle { margin: 2px 0 0; color: var(--text-secondary); font-size: .9rem; }
.header-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.palette-trigger { display: inline-flex; align-items: center; gap: 8px; min-width: 220px; padding: 7px 10px 7px 12px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--bg-body); color: var(--text-muted); font: inherit; font-size: .84rem; cursor: pointer; transition: border-color .2s var(--ease), color .2s var(--ease); }
.palette-trigger:hover { border-color: var(--accent); color: var(--accent); }
.palette-trigger kbd { margin-left: auto; font-size: .7rem; }

/* ==========================================================================
   Composants
   ========================================================================== */
.card {
  background: var(--bg-card); border: 1px solid var(--border-subtle); border-radius: var(--radius-card);
  box-shadow: var(--shadow-soft); padding: var(--pad-card); margin-bottom: var(--gap);
}
.card > h2:first-child, .card > h3:first-child, .card > .card-head:first-child { margin-top: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2, .card-head h3 { margin: 0; display: flex; align-items: center; gap: 8px; }
.card.lift { transition: transform .2s var(--ease), box-shadow .2s var(--ease), border-color .2s var(--ease); }
.card.lift:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); border-color: var(--accent); }
.card.notice, .notice { background: var(--warn-soft); border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent); border-left: 3px solid var(--warn); padding: 12px 14px; border-radius: var(--radius-card); box-shadow: none; }
.notice.info { background: var(--info-soft); border-color: color-mix(in srgb, var(--info) 30%, transparent); border-left-color: var(--info); }
.card.error { background: var(--bad-soft); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 30%, transparent); }
.callout { border-left: 3px solid var(--yellow); }
.signature { position: relative; overflow: hidden; }
.signature::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--accent-line); }

.section-label, .section-title {
  display: flex; align-items: center; gap: 10px;
  margin: 22px 2px 10px; font-family: var(--font); font-size: .7rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .2em; color: var(--gold-text);
}
.section-label::after, .section-title::after { content: ""; flex: 1; height: 1px; background: var(--border-subtle); }

.grid { display: grid; gap: var(--gap); }
.grid.two { grid-template-columns: 1fr; }
.grid.three { grid-template-columns: 1fr; }
@media (min-width: 760px) { .grid.two { grid-template-columns: 1fr 1fr; } .grid.three { grid-template-columns: repeat(3, 1fr); } }
.grid.wide-left { grid-template-columns: 1fr; }
@media (min-width: 1060px) { .grid.wide-left { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); } }
.grid > .card { margin-bottom: 0; }
.row { display: flex; gap: 8px; align-items: center; margin: 8px 0; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.between h3 { margin: 0; }
.row.end { justify-content: flex-end; }
.stack { display: grid; gap: 8px; margin: 10px 0; }
.spacer { flex: 1; }

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 38px; padding: 7px 15px; border-radius: var(--radius-small);
  border: 1px solid var(--border-strong); background: var(--bg-card); color: var(--text-primary);
  font: inherit; font-size: .9rem; font-weight: 500; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: transform .15s var(--ease), background .2s var(--ease), border-color .2s var(--ease), color .2s var(--ease), box-shadow .2s var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn.primary {
  background: var(--brand-gradient); background-size: 180% 100%; background-position: 0 0;
  border-color: transparent; color: #fff; box-shadow: var(--shadow-glow);
}
.btn.primary:hover:not(:disabled) { background-position: 100% 0; color: #fff; transform: translateY(-1px); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-secondary); }
.btn.ghost:hover { background: var(--hover-bg); color: var(--accent); }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--border-strong)); }
.btn.danger:hover { background: var(--bad-soft); color: var(--bad); border-color: var(--bad); }
.btn.success { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, var(--border-strong)); }
.btn.success:hover { background: var(--ok-soft); color: var(--ok); border-color: var(--ok); }
.btn.small { min-height: 31px; padding: 4px 11px; font-size: .82rem; }
.btn.block { width: 100%; }
.btn.icon { width: 42px; padding: 0; flex: none; }
.btn.recording, .mic.recording { background: var(--bad); border-color: var(--bad); color: #fff; animation: pulse 1.2s infinite; }
.icon-btn { background: none; border: none; cursor: pointer; font-size: 1rem; padding: 5px; border-radius: 6px; color: var(--text-secondary); display: inline-grid; place-items: center; transition: background .15s var(--ease), color .15s var(--ease); }
.icon-btn:hover { background: var(--hover-bg); color: var(--accent); }
.btn .spinner, .btn-loading .spinner { width: 15px; height: 15px; border-width: 2px; }

/* ---------- Champs ---------- */
input, select, textarea {
  width: 100%; font: inherit; font-size: .92rem; color: var(--text-primary); background: var(--bg-card);
  border: 1px solid var(--border-strong); border-radius: var(--radius-small); padding: 8px 11px; min-height: 38px;
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
}
input::placeholder, textarea::placeholder { color: var(--text-muted); }
input:hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--border-strong)); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
select {
  appearance: none; -webkit-appearance: none; padding-right: 32px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2352606d' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center; background-size: 16px;
}
input[type="range"] { padding: 0; border: none; min-height: 28px; accent-color: var(--brand); box-shadow: none; background: transparent; }
input[type="checkbox"], input[type="radio"] { width: auto; min-height: 0; accent-color: var(--brand); box-shadow: none; }
textarea { resize: vertical; margin: 8px 0; line-height: 1.55; }
.row input { flex: 1 1 180px; width: auto; }
.field { display: grid; gap: 5px; margin: 12px 0; font-weight: 600; font-size: .8rem; color: var(--text-secondary); }
.field > input, .field > select, .field > textarea { font-weight: 400; }
.field-hint { font-size: .76rem; font-weight: 400; color: var(--text-muted); line-height: 1.4; }
.field-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 0 16px; }
.inline { display: inline-flex; gap: 6px; align-items: center; }
.inline select { width: auto; min-height: 32px; padding: 4px 30px 4px 8px; }
.switch { display: inline-flex; gap: 8px; align-items: center; cursor: pointer; font-size: .9rem; }

/* Interrupteur (toggle) */
.toggle { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: .9rem; font-weight: 500; color: var(--text-primary); }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle .track { width: 38px; height: 22px; border-radius: 999px; background: var(--border-strong); position: relative; transition: background .2s var(--ease); flex: none; }
.toggle .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .2s var(--ease-bounce); }
.toggle input:checked + .track { background: var(--brand-gradient); }
.toggle input:checked + .track::after { transform: translateX(16px); }
.toggle input:focus-visible + .track { box-shadow: 0 0 0 3px var(--accent-soft); }

/* Cartes d'options (radio / checkbox stylés) */
.opt-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; margin: 8px 0 4px; }
.opt-card { position: relative; display: flex; gap: 10px; align-items: flex-start; padding: 11px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-card); cursor: pointer; background: var(--bg-card); transition: border-color .2s var(--ease), background .2s var(--ease), box-shadow .2s var(--ease); font-weight: 400; color: var(--text-primary); }
.opt-card:hover { border-color: var(--accent); }
.opt-card input { position: absolute; opacity: 0; pointer-events: none; }
.opt-card .opt-ico { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: var(--icon-bg); color: var(--brand-text); flex: none; transition: all .2s var(--ease); }
.opt-card .opt-title { font-weight: 600; font-size: .88rem; display: block; }
.opt-card .opt-desc { font-size: .76rem; color: var(--text-secondary); display: block; line-height: 1.35; margin-top: 2px; }
.opt-card:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); box-shadow: inset 0 0 0 1px var(--brand); }
.opt-card:has(input:checked) .opt-ico { background: var(--brand-gradient); color: #fff; }
.opt-card:has(input:focus-visible) { box-shadow: 0 0 0 3px var(--accent-soft); }
.swatch { width: 32px; height: 32px; border-radius: 9px; flex: none; }

/* ---------- Pastilles, étiquettes ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px;
  background: var(--bg-card); border: 1px solid var(--border-subtle); font-size: .82rem; white-space: nowrap; color: var(--text-secondary);
}
.chip .ico { width: 14px; height: 14px; }
button.chip { cursor: pointer; font: inherit; font-size: .84rem; white-space: normal; text-align: left; transition: border-color .2s var(--ease), color .2s var(--ease); }
button.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip.small { font-size: .74rem; padding: 2px 8px; }
.chip.brand { background: var(--brand-soft); border-color: transparent; color: var(--brand-text); font-weight: 600; }
.chip.gold { background: var(--yellow-soft); border-color: transparent; color: var(--gold-text); font-weight: 600; }
.tag { display: inline-block; margin-top: 6px; font-size: .7rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--accent); background: var(--accent-soft); padding: 2px 8px; border-radius: 999px; }
.level-badge { display: inline-block; font-weight: 700; font-size: .82rem; color: var(--brand-text); background: var(--brand-soft); padding: 2px 9px; border-radius: 6px; letter-spacing: .02em; }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: .74rem; font-weight: 600; box-shadow: inset 0 0 0 1px currentColor; background: color-mix(in srgb, currentColor 10%, transparent); }
.pill.ok { color: var(--ok); } .pill.bad { color: var(--bad); } .pill.warn { color: var(--warn); } .pill.info { color: var(--info); } .pill.muted { color: var(--text-muted); }
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ---------- Onglets ---------- */
.segmented { display: inline-flex; background: var(--icon-bg); border-radius: 999px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.segmented button { border: none; background: transparent; color: var(--text-secondary); font: inherit; font-size: .86rem; padding: 6px 14px; border-radius: 999px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; transition: all .2s var(--ease); }
.segmented button:hover { color: var(--accent); }
.segmented button.active { background: var(--bg-card); color: var(--brand-text); font-weight: 600; box-shadow: var(--shadow-soft), inset 0 -2px 0 var(--yellow); }
.tabs { display: flex; gap: 4px; background: var(--icon-bg); padding: 3px; border-radius: 999px; margin-bottom: 10px; }
.tab { flex: 1; border: none; background: transparent; padding: 8px; border-radius: 999px; font: inherit; font-size: .88rem; color: var(--text-secondary); cursor: pointer; transition: all .2s var(--ease); }
.tab.active { background: var(--bg-card); color: var(--brand-text); font-weight: 600; box-shadow: var(--shadow-soft), inset 0 -2px 0 var(--yellow); }

/* ---------- Progression ---------- */
.progress { height: 7px; background: var(--icon-bg); border-radius: 99px; overflow: hidden; margin: 8px 0 6px; }
.progress > div { height: 100%; background: var(--brand-gradient); border-radius: 99px; transition: width .6s var(--ease); }
.progress.gold > div { background: linear-gradient(90deg, var(--gold), var(--yellow)); }
.ring { --p: 0; --size: 54px; width: var(--size); height: var(--size); border-radius: 50%; flex: none; display: grid; place-items: center;
  background: conic-gradient(var(--brand) calc(var(--p) * 1%), var(--icon-bg) 0); position: relative; }
.ring::before { content: ""; position: absolute; inset: 5px; border-radius: 50%; background: var(--bg-card); }
.ring > span { position: relative; font-size: .74rem; font-weight: 700; color: var(--text-primary); }

/* ---------- Chargement ---------- */
.loading { display: flex; align-items: center; gap: 10px; color: var(--text-secondary); padding: 12px 0; font-size: .92rem; }
.loading.center { justify-content: center; min-height: 60vh; }
.spinner { width: 20px; height: 20px; border: 3px solid var(--border-subtle); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; flex: none; }
.skel { border-radius: 6px; background: linear-gradient(90deg, var(--icon-bg) 25%, var(--hover-bg) 37%, var(--icon-bg) 63%); background-size: 200% 100%; animation: shimmer 1.3s linear infinite; }
.skel.line { height: 12px; margin: 8px 0; }
.skel.block { height: 90px; }

/* ---------- KPI ---------- */
.kpi-grid { display: grid; gap: var(--gap); grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: var(--gap); }
@media (min-width: 1000px) { .kpi-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.kpi { position: relative; overflow: hidden; display: flex; gap: 12px; align-items: center; background: var(--bg-card); border: 1px solid var(--border-subtle); border-radius: var(--radius-card); box-shadow: var(--shadow-soft); padding: 14px 16px 14px 18px; text-decoration: none; color: inherit; transition: transform .2s var(--ease), box-shadow .2s var(--ease), border-color .2s var(--ease); }
.kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: linear-gradient(180deg, var(--gold), var(--accent)); }
a.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); border-color: var(--accent); color: inherit; }
.kpi-ico { width: 40px; height: 40px; border-radius: var(--radius-tile); display: grid; place-items: center; background: var(--icon-bg); color: var(--brand-text); flex: none; }
.kpi-label { font-size: .66rem; font-weight: 600; text-transform: uppercase; letter-spacing: .14em; color: var(--text-muted); }
.kpi-value { font-family: var(--font-light); font-weight: 300; font-size: 1.85rem; line-height: 1.1; color: var(--text-primary); }
.kpi-value small { font-family: var(--font); font-size: .8rem; color: var(--text-muted); font-weight: 500; }
.kpi-sub { font-size: .76rem; color: var(--text-secondary); }

/* Tuiles d'icônes */
.tile { width: 44px; height: 44px; border-radius: var(--radius-tile); display: grid; place-items: center; color: #fff; flex: none; box-shadow: 0 4px 12px rgba(15, 23, 42, .16); }
.tile .ico { width: 22px; height: 22px; }
.tile.reading { background: var(--g-reading); } .tile.listening { background: var(--g-listening); } .tile.writing { background: var(--g-writing); }
.tile.speaking { background: var(--g-speaking); } .tile.conversation { background: var(--g-conversation); } .tile.grammar { background: var(--g-grammar); }
.tile.vocab { background: var(--g-vocab); } .tile.brand { background: var(--brand-gradient); }
.tile.sm { width: 34px; height: 34px; border-radius: 9px; } .tile.sm .ico { width: 18px; height: 18px; }

/* ---------- Tableaux ---------- */
.table-wrap { overflow-x: auto; }
.data-table, .vocab-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.data-table th { text-align: left; font-size: .66rem; text-transform: uppercase; letter-spacing: .12em; color: var(--brand-text); background: var(--icon-bg); padding: 9px 10px; border-bottom: 2px solid var(--yellow); white-space: nowrap; }
.data-table td, .vocab-table td { padding: 9px 10px; border-bottom: 1px solid var(--border-subtle); vertical-align: top; }
.data-table tbody tr:nth-child(even) { background: var(--zebra); }
.data-table tbody tr:hover, .vocab-table tbody tr:hover { background: var(--hover-bg); }
.data-table td[colspan] { text-align: center; font-style: italic; color: var(--text-muted); padding: 20px; }

/* ---------- Toasts ---------- */
#toasts { position: fixed; z-index: 200; right: 20px; bottom: 20px; display: grid; gap: 8px; width: min(92vw, 380px); }
.toast { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius-card); background: #1f2933; color: #f5f7fa; box-shadow: var(--shadow-pop); border-left: 3px solid var(--yellow); font-size: .9rem; animation: toastIn .3s var(--ease); transition: opacity .3s, transform .3s; }
.toast .ico { margin-top: 2px; }
.toast-ok { border-left-color: #48bb78; } .toast-ok .ico { color: #48bb78; }
.toast-error { border-left-color: #f56565; } .toast-error .ico { color: #f56565; }
.toast-warn { border-left-color: var(--yellow); } .toast-warn .ico { color: var(--yellow); }
.toast.hide { opacity: 0; transform: translateY(8px); }

/* ---------- Modale & palette de commandes ---------- */
.overlay { position: fixed; inset: 0; z-index: 150; background: rgba(15, 30, 50, .42); backdrop-filter: blur(3px); display: flex; align-items: flex-start; justify-content: center; padding: 12vh 16px 16px; animation: fadeSlideUp .2s var(--ease); }
.modal { position: relative; overflow: hidden; width: min(480px, 100%); background: var(--bg-elev); border: 1px solid var(--border-subtle); border-radius: var(--radius-card); box-shadow: var(--shadow-pop); animation: ctxPop .2s var(--ease); }
.modal::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--accent-line); }
.modal header { padding: 18px 20px 6px; } .modal header h2 { margin: 0; }
.modal .body { padding: 6px 20px 14px; color: var(--text-secondary); }
.modal footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--border-subtle); background: var(--hover-bg); }

.palette { width: min(620px, 100%); }
.palette-input { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border-subtle); color: var(--text-muted); }
.palette-input input { border: none; box-shadow: none; padding: 0; min-height: 30px; font-size: 1.02rem; background: transparent; }
.palette-input input:focus { box-shadow: none; }
.palette-list { max-height: 52vh; overflow-y: auto; padding: 6px; }
.palette-group { font-size: .64rem; text-transform: uppercase; letter-spacing: .2em; color: var(--gold-text); font-weight: 600; padding: 10px 10px 4px; }
.palette-item { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 6px; cursor: pointer; color: var(--text-primary); }
.palette-item .tile { width: 30px; height: 30px; border-radius: 8px; box-shadow: none; } .palette-item .tile .ico { width: 16px; height: 16px; }
.palette-item .pi-label { flex: 1; font-size: .92rem; } .palette-item .pi-hint { font-size: .76rem; color: var(--text-muted); }
.palette-item.active { background: var(--hover-bg); box-shadow: inset 3px 0 0 var(--accent); }
.palette-foot { display: flex; gap: 14px; padding: 9px 14px; border-top: 1px solid var(--border-subtle); font-size: .74rem; color: var(--text-muted); background: var(--hover-bg); }

/* ---------- Connexion ---------- */
.auth-page { min-height: 100dvh; display: grid; grid-template-columns: 1fr; }
@media (min-width: 960px) { .auth-page { grid-template-columns: minmax(0, 1.1fr) minmax(420px, .9fr); } }
.auth-hero { display: none; position: relative; overflow: hidden; padding: 56px; color: #fff; background: var(--brand-gradient); }
@media (min-width: 960px) { .auth-hero { display: flex; flex-direction: column; justify-content: space-between; } }
.auth-hero::after { content: ""; position: absolute; width: 520px; height: 520px; right: -160px; bottom: -200px; border-radius: 50%; background: radial-gradient(circle, rgba(250, 204, 21, .35), transparent 65%); }
.auth-hero h1 { color: #fff; font-size: 2.6rem; max-width: 14ch; margin: 18px 0 12px; }
.auth-hero p { color: rgba(255, 255, 255, .82); max-width: 46ch; }
.auth-hero .line { width: 56px; height: 3px; border-radius: 3px; background: var(--accent-line); }
.auth-feats { display: grid; gap: 14px; position: relative; z-index: 1; }
.auth-feat { display: flex; gap: 12px; align-items: center; color: rgba(255, 255, 255, .92); font-size: .92rem; }
.auth-feat .ico { width: 34px; height: 34px; padding: 8px; border-radius: 10px; background: rgba(255, 255, 255, .14); }
.auth-side { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px; padding: 32px 16px; }
.auth-card { width: 100%; max-width: 410px; position: relative; overflow: hidden; }
.auth-card::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--accent-line); }
.auth-brand { text-align: center; margin-bottom: 14px; }
.auth-brand .sidebar-logo { margin: 4px auto 10px; width: 52px; height: 52px; }
.auth-brand h1 { margin: 0 0 4px; }
.form-error { background: var(--bad-soft); color: var(--bad); padding: 10px 12px; border-radius: var(--radius-small); margin: 8px 0; font-size: .88rem; border-left: 3px solid var(--bad); }
.qr-card { text-align: center; }
.qr-card img { background: #fff; padding: 8px; border-radius: 10px; border: 1px solid var(--border-subtle); }

/* ---------- Tableau de bord ---------- */
.hero { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.hero-level { font-family: var(--font-light); font-weight: 300; font-size: 2.6rem; line-height: 1; color: var(--brand-text); background: var(--brand-soft); border-radius: var(--radius-tile); padding: 10px 18px; }
.big-level { width: fit-content; margin: 8px auto; font-size: 3.4rem; }
.skills-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: var(--gap); }
@media (min-width: 900px) { .skills-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.skill-card { text-decoration: none; color: inherit; transition: transform .2s var(--ease), border-color .2s var(--ease), box-shadow .2s var(--ease); display: block; }
.skill-card:hover { transform: translateY(-3px); border-color: var(--accent); box-shadow: var(--shadow-lift); color: inherit; }
.skill-card.recommended { border-color: var(--yellow); box-shadow: inset 0 3px 0 var(--yellow), var(--shadow-soft); }
.skill-top { display: flex; justify-content: space-between; align-items: center; }
.skill-icon { font-size: 1.6rem; }
.skill-name { font-weight: 600; margin-top: 10px; }
.card.mini { text-align: center; padding: 12px; }
.list { list-style: none; padding: 0; margin: 0; }
.list li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border-subtle); }
.list li:last-child { border-bottom: none; }
.list .li-main { display: flex; align-items: center; gap: 10px; min-width: 0; }
.activity-cards { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.act-card { display: flex; gap: 12px; align-items: center; padding: 12px; border: 1px solid var(--border-subtle); border-radius: var(--radius-card); background: var(--bg-card); text-decoration: none; color: inherit; transition: all .2s var(--ease); min-height: 72px; }
.act-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow-lift); color: inherit; }
.act-card .act-name { font-weight: 600; font-size: .92rem; display: block; }
.act-card .act-meta { font-size: .76rem; color: var(--text-secondary); display: block; }
.act-card .go { margin-left: auto; color: var(--text-muted); }
.act-card:hover .go { color: var(--accent); transform: translateX(2px); }

/* Graphique (SVG dessiné à la main) */
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart .bar { fill: url(#barGrad); transition: opacity .2s; }
.chart .bar.today { fill: var(--accent); }
.chart .bar:hover { opacity: .75; }
.chart .goal { stroke: var(--gold); stroke-dasharray: 4 4; stroke-width: 1.2; }
.chart .axis { fill: var(--text-muted); font-size: 10px; font-family: var(--font); }
.chart .grid-line { stroke: var(--border-subtle); stroke-width: 1; }
.chart-legend { display: flex; gap: 14px; font-size: .76rem; color: var(--text-secondary); flex-wrap: wrap; }
.chart-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.chart-tip { position: fixed; z-index: 100; pointer-events: none; background: #1f2933; color: #fff; font-size: .76rem; padding: 6px 9px; border-radius: 6px; box-shadow: var(--shadow-lift); }

.bars-h { display: grid; gap: 9px; }
.bar-h { display: grid; grid-template-columns: 110px 1fr 44px; align-items: center; gap: 10px; font-size: .84rem; }
.bar-h .track { height: 8px; border-radius: 99px; background: var(--icon-bg); overflow: hidden; }
.bar-h .track > div { height: 100%; border-radius: 99px; background: var(--brand-gradient); }

/* Coach IA */
.coach-card { position: relative; overflow: hidden; }
.coach-card::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--accent-line); }
.coach-headline { font-family: var(--font-light); font-weight: 300; font-size: 1.25rem; margin: 2px 0 8px; }
.focus-list { display: grid; gap: 10px; margin: 10px 0; }
.focus-item { display: flex; gap: 12px; padding: 10px 12px; border-radius: var(--radius-card); background: var(--hover-bg); border-left: 3px solid var(--accent); }
.focus-item .n { font-family: var(--font-light); font-size: 1.4rem; line-height: 1; color: var(--accent); }
.plan { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); margin-top: 8px; }
.plan-day { border: 1px solid var(--border-subtle); border-radius: var(--radius-card); padding: 10px; font-size: .84rem; text-decoration: none; color: inherit; background: var(--bg-card); transition: border-color .2s var(--ease); }
.plan-day:hover { border-color: var(--accent); color: inherit; }
.plan-day .d { font-size: .64rem; text-transform: uppercase; letter-spacing: .16em; color: var(--gold-text); font-weight: 600; }

/* ---------- Exercices ---------- */
.steps { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; font-size: .78rem; }
.steps span { padding: 3px 11px; border-radius: 99px; background: var(--icon-bg); color: var(--text-secondary); }
.steps .current { background: var(--brand-gradient); color: #fff; }
.steps .done { background: var(--ok-soft); color: var(--ok); }
.question-text, .prompt { font-size: 1.12rem; font-weight: 500; }
.choices { display: grid; gap: 8px; margin: 12px 0; }
@media (min-width: 600px) { .choices { grid-template-columns: 1fr 1fr; } }
.choice { justify-content: flex-start; text-align: left; min-height: 48px; white-space: normal; }

.mcq .question { border: 1px solid var(--border-subtle); border-radius: var(--radius-card); padding: 12px 14px; margin: 0 0 12px; background: var(--bg-card); }
.mcq legend { font-weight: 600; padding: 0 4px; }
.option { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border-radius: 6px; cursor: pointer; font-weight: 400; color: var(--text-primary); }
.option:hover { background: var(--hover-bg); }
.question.right { border-color: var(--ok); background: var(--ok-soft); }
.question.wrong { border-color: var(--bad); background: var(--bad-soft); }
.option.is-correct { font-weight: 600; color: var(--ok); }
.explain { margin-top: 6px; font-size: .88rem; }

.reading-text { font-size: 1.08rem; line-height: 1.8; margin: 12px 0; font-family: Georgia, "Iowan Old Style", "Palatino Linotype", serif; }
.reading-text p { margin-bottom: 1em; }
.w { cursor: pointer; border-radius: 4px; transition: background .15s; }
.w:hover { background: var(--yellow-soft); }
.glossary dt { font-weight: 600; margin-top: 8px; }
.glossary dd { margin: 0 0 4px; color: var(--text-secondary); }
details summary { cursor: pointer; padding: 6px 0; font-weight: 500; }
details summary:hover { color: var(--accent); }

.sentence { font-size: 1.12rem; font-weight: 500; margin: 6px 0; }
.repeat-list { padding-left: 1.2em; }
.repeat-list li { padding: 10px 0; border-bottom: 1px solid var(--border-subtle); }
.diff { margin-top: 6px; line-height: 2; }
.diff .ok, span.ok { color: var(--ok); }
.diff .miss, span.miss { color: var(--bad); text-decoration: underline wavy; }
.diff .extra, span.extra { color: var(--warn); text-decoration: line-through; }
.improved { background: var(--ok-soft); padding: 12px 14px; border-radius: var(--radius-card); border-left: 3px solid var(--ok); }
.example { font-style: italic; color: var(--text-secondary); margin-top: 4px; }

.result-banner { display: flex; gap: 16px; align-items: center; padding: 14px 16px; border-radius: var(--radius-card); margin: 12px 0; background: var(--ok-soft); border-left: 3px solid var(--ok); }
.result-banner.neg { background: var(--warn-soft); border-left-color: var(--warn); }
.result-banner .big { font-family: var(--font-light); font-weight: 300; font-size: 2.2rem; line-height: 1; }

.criteria { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin: 10px 0; }
.criterion { padding: 10px 12px; border: 1px solid var(--border-subtle); border-radius: var(--radius-card); }
.criterion .kpi-label { display: block; margin-bottom: 4px; }

.corrections { list-style: none; padding: 0; margin: 6px 0; }
.corrections li { padding: 7px 0; border-bottom: 1px dashed var(--border-subtle); }
.corrections li:last-child { border-bottom: none; }
.from { color: var(--bad); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--bad) 60%, transparent); }
.to { color: var(--ok); font-weight: 600; }
.cat { font-size: .64rem; text-transform: uppercase; letter-spacing: .1em; font-weight: 700; color: var(--text-muted); margin-left: 6px; }

/* ---------- Leçons ---------- */
.topic-grid { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.topic-btn { display: flex; align-items: center; gap: 10px; text-align: left; padding: 10px 12px; border: 1px solid var(--border-subtle); border-radius: var(--radius-card); background: var(--bg-card); color: var(--text-primary); font: inherit; font-size: .88rem; cursor: pointer; transition: all .2s var(--ease); }
.topic-btn:hover { border-color: var(--accent); color: var(--accent); transform: translateX(2px); }
.topic-btn .level-badge { font-size: .7rem; }
.rule { padding: 10px 12px; border-left: 3px solid var(--brand); background: var(--hover-bg); border-radius: 0 6px 6px 0; margin: 8px 0; }
.rule .example { margin-top: 4px; }

/* ---------- Conversation ---------- */
.scenarios { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 760px) { .scenarios { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1100px) { .scenarios { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.scenario { display: flex; align-items: center; gap: 12px; cursor: pointer; font: inherit; color: inherit; text-align: left; padding: 13px; transition: all .2s var(--ease); }
.scenario:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow-lift); }
.scenario .emoji { font-size: 1.5rem; width: 40px; height: 40px; border-radius: var(--radius-tile); background: var(--icon-bg); display: grid; place-items: center; flex: none; }

.chat-page { display: flex; flex-direction: column; min-height: calc(100dvh - 190px); }
.chat-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; position: sticky; top: 8px; z-index: 5; }
.chat-head > div { flex: 1; min-width: 0; }
.chat-log { flex: 1; display: flex; flex-direction: column; gap: 12px; padding: 4px 0 12px; }
.msg { display: flex; flex-direction: column; max-width: 86%; animation: fadeSlideUp .25s var(--ease); }
.msg.user { align-self: flex-end; align-items: flex-end; }
.msg.assistant { align-self: flex-start; }
.msg.summary { max-width: 100%; align-self: stretch; }
.msg-who { font-size: .66rem; text-transform: uppercase; letter-spacing: .14em; color: var(--text-muted); margin: 0 4px 3px; font-weight: 600; }
.bubble { padding: 10px 14px; border-radius: 14px; background: var(--bg-card); border: 1px solid var(--border-subtle); box-shadow: var(--shadow-soft); }
.msg.user .bubble { background: var(--brand-gradient); color: #fff; border-color: transparent; border-bottom-right-radius: 4px; }
.msg.assistant .bubble { border-bottom-left-radius: 4px; }
.msg.error .bubble { background: var(--bad-soft); }
.bubble .text.streaming::after { content: "▍"; color: var(--accent); animation: caret 1s steps(1) infinite; margin-left: 1px; }
.bubble-tools { display: flex; justify-content: flex-end; margin: 2px -6px -6px 0; }
.tip { margin-top: 8px; padding-top: 7px; border-top: 1px dashed var(--border-subtle); color: var(--text-secondary); }
.vocab-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.feedback { margin-top: 5px; padding: 8px 12px; border-radius: var(--radius-card); background: var(--warn-soft); border-left: 3px solid var(--warn); font-size: .88rem; max-width: 100%; color: var(--text-primary); }
.feedback.ok { background: var(--ok-soft); border-left-color: var(--ok); }
.suggestions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 8px; }
.chat-input { display: flex; gap: 8px; align-items: flex-end; padding: 8px; position: sticky; bottom: 12px; margin: 0; box-shadow: var(--shadow-lift); }
.chat-input textarea { margin: 0; min-height: 42px; max-height: 140px; resize: none; }
.translation { margin-top: 4px; padding: 6px 10px; border-left: 3px solid var(--accent); background: var(--accent-soft); border-radius: 6px; color: var(--text-secondary); }
.free-card { margin-bottom: var(--gap, 16px); }
.pattern-card { border: 1px solid var(--border-subtle); border-left: 3px solid var(--accent); border-radius: var(--radius-card); padding: 12px; margin: 10px 0; }
.pattern { font-family: ui-monospace, Consolas, monospace; font-weight: 600; color: var(--brand-text); margin-bottom: 6px; }
.pattern-examples { margin: 4px 0; padding-left: 18px; }
.your-turn { color: var(--text-secondary); }
.topic-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.topic-chips .chip.selected { background: var(--brand); border-color: var(--brand); color: #fff; }
.msg.debrief .bubble { max-width: 100%; width: 100%; }
.debrief-steps { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 12px; }
.debrief-body { min-height: 120px; }
.debrief-nav { margin-top: 12px; }
.debrief-praise { font-weight: 600; }
.flip-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; margin: 10px 0; }
.flip-card { border: 1px solid var(--border-subtle); border-radius: var(--radius-card); padding: 12px; display: grid; gap: 8px; background: var(--bg-card, transparent); }
.flip-front { display: flex; align-items: center; gap: 8px; font-size: 1.1rem; }
.flip-emoji { font-size: 1.6rem; }
.flip-back { display: grid; gap: 4px; }
.flip-back .trick { color: var(--text-secondary); }
.session-steps { display: grid; gap: 8px; margin: 10px 0; padding: 0; list-style: none; }
.session-steps li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--border-subtle); border-radius: var(--radius-card); }
.session-steps li.done { opacity: .6; }
.session-steps li.next { border-color: var(--accent); background: var(--accent-soft); }
.session-steps .n { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand-text); font-weight: 700; font-size: .8rem; flex: none; }
.session-steps li.done .n { background: var(--brand); color: #fff; }
.session-steps .go { margin-left: auto; }
.voice-bar { display: grid; grid-template-columns: 1fr auto auto auto; gap: 10px 12px; align-items: center; padding: 10px 12px; margin: 0; }
.voice-wave { width: 100%; height: 48px; display: block; color: var(--text-secondary); }
.voice-time { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 2.6em; text-align: right; }
.voice-hint { grid-column: 1 / -1; }
@media (max-width: 700px) { .voice-bar { grid-template-columns: 1fr auto auto; } .voice-wave { grid-column: 1 / -1; } }
.typing { display: inline-flex; gap: 4px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--text-muted); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; }
.typing i:nth-child(3) { animation-delay: .4s; }

/* ---------- Popup mot ---------- */
.word-popup { position: absolute; z-index: 60; background: var(--bg-elev); border: 1px solid var(--border-subtle); border-top: 3px solid var(--accent); border-radius: var(--radius-card); box-shadow: var(--shadow-pop); padding: 10px 12px; animation: ctxPop .15s var(--ease); }
.wp-head { display: flex; justify-content: space-between; align-items: center; font-size: 1.08rem; }
.wp-body { margin: 6px 0; }
.wp-actions { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------- Carnet ---------- */
.flashcard { text-align: center; padding: 30px 18px; position: relative; overflow: hidden; }
.flashcard::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--accent-line); }
.fc-word { font-family: var(--font-light); font-size: 2.3rem; font-weight: 300; margin: 12px 0; display: flex; align-items: center; justify-content: center; gap: 8px; }
.fc-tr { font-size: 1.3rem; font-weight: 600; color: var(--brand-text); }
.fc-back { margin-bottom: 16px; }
.danger-zone { margin-top: 12px; color: var(--bad); }

/* ---------- Réglages ---------- */
.settings-layout { display: grid; gap: var(--gap); grid-template-columns: 1fr; }
@media (min-width: 980px) { .settings-layout { grid-template-columns: 230px minmax(0, 1fr); align-items: start; } }
.settings-nav { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; padding: 6px; }
@media (min-width: 980px) { .settings-nav { flex-direction: column; position: sticky; top: 16px; } }
.settings-nav button { display: flex; align-items: center; gap: 10px; border: none; background: transparent; color: var(--text-secondary); font: inherit; font-size: .9rem; padding: 8px 10px; border-radius: 0 6px 6px 0; border-left: 3px solid transparent; cursor: pointer; text-align: left; white-space: nowrap; transition: all .18s var(--ease); }
.settings-nav button:hover { background: var(--hover-bg); color: var(--text-primary); border-left-color: var(--accent); }
.settings-nav button.active { background: var(--hover-bg); color: var(--text-primary); font-weight: 600; border-left-color: var(--yellow); }
.settings-nav button.active .nav-bullet, .settings-nav button:hover .nav-bullet { background: var(--brand-gradient); color: #fff; }
.settings-nav .nav-bullet { width: 26px; height: 26px; }
.set-section { position: relative; }
.set-section + .set-section { margin-top: 0; }
.set-section h2 { display: flex; align-items: center; gap: 10px; }
.set-group { padding: 14px 0; border-top: 1px solid var(--border-subtle); }
.set-group:first-of-type { border-top: none; padding-top: 4px; }
.set-group > .group-title { font-size: .66rem; text-transform: uppercase; letter-spacing: .18em; font-weight: 600; color: var(--gold-text); margin-bottom: 6px; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 0; }
.set-row + .set-row { border-top: 1px dashed var(--border-subtle); }
.set-row .label { font-weight: 600; font-size: .92rem; }
.set-row .desc { font-size: .8rem; color: var(--text-secondary); }
.save-bar { position: sticky; bottom: 12px; z-index: 10; display: flex; align-items: center; gap: 10px; justify-content: flex-end; padding: 10px 14px; margin-top: var(--gap); border-radius: var(--radius-card); background: color-mix(in srgb, var(--bg-card) 86%, transparent); backdrop-filter: blur(10px); border: 1px solid var(--border-subtle); box-shadow: var(--shadow-lift); }
.save-bar .hint { margin-right: auto; font-size: .82rem; color: var(--text-muted); }
.save-bar.dirty .hint { color: var(--warn); font-weight: 600; }

/* Assistant de connexion IA (étapes) */
.stepper { display: flex; gap: 6px; margin: 4px 0 14px; flex-wrap: wrap; }
.stepper .st { flex: 1 1 120px; display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: var(--radius-card); border: 1px solid var(--border-subtle); font-size: .8rem; color: var(--text-secondary); }
.stepper .st .n { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--icon-bg); font-size: .72rem; font-weight: 700; flex: none; }
.stepper .st.done { border-color: color-mix(in srgb, var(--ok) 40%, var(--border-subtle)); color: var(--ok); }
.stepper .st.done .n { background: var(--ok); color: #fff; }
.stepper .st.current { border-color: var(--yellow); color: var(--text-primary); box-shadow: inset 0 -2px 0 var(--yellow); }
.stepper .st.current .n { background: var(--brand-gradient); color: #fff; }
.feature-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.test-result { margin-top: 10px; padding: 10px 12px; border-radius: var(--radius-card); font-size: .88rem; }
.test-result.ok { background: var(--ok-soft); border-left: 3px solid var(--ok); color: var(--text-primary); }
.test-result.bad { background: var(--bad-soft); border-left: 3px solid var(--bad); color: var(--text-primary); }
.key-input { display: flex; gap: 6px; }
.key-input input { flex: 1; }
.key-input input[data-pset="apiKey"] { font-family: var(--font-mono); font-size: .86rem; }

/* ==========================================================================
   Responsive : en dessous de 900 px, barre du haut + navigation basse
   ========================================================================== */
@media (max-width: 899px) {
  .app-shell { display: block; }
  .sidebar { display: none; }
  .topbar {
    display: flex; position: sticky; top: 0; z-index: 40; align-items: center; justify-content: space-between; gap: 8px;
    padding: 9px 14px; padding-top: max(9px, env(safe-area-inset-top));
    background: color-mix(in srgb, var(--bg-sidebar) 88%, transparent); backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-subtle);
  }
  .topbar::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--accent-line); opacity: .8; }
  .topbar .brand { display: flex; align-items: center; gap: 9px; text-decoration: none; }
  .topbar .sidebar-logo { width: 32px; height: 32px; border-radius: 9px; }
  .topbar .sidebar-logo .ico { width: 18px; height: 18px; }
  .topbar-right { display: flex; gap: 6px; align-items: center; }
  .bottom-nav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; overflow-x: auto; scrollbar-width: none;
    background: var(--bg-sidebar); border-top: 1px solid var(--border-subtle); padding-bottom: env(safe-area-inset-bottom);
  }
  .bottom-nav::-webkit-scrollbar { display: none; }
  .bottom-nav a { flex: 1 0 auto; min-width: 66px; height: var(--nav-h); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--text-muted); text-decoration: none; font-size: .68rem; position: relative; }
  .bottom-nav a .ico { width: 21px; height: 21px; }
  .bottom-nav a.active { color: var(--brand-text); font-weight: 600; }
  .bottom-nav a.active::before { content: ""; position: absolute; top: 0; left: 22%; right: 22%; height: 3px; border-radius: 0 0 3px 3px; background: var(--yellow); }
  .main { padding: 14px 14px calc(var(--nav-h) + 28px + env(safe-area-inset-bottom)); }
  .page-header { padding: 14px 16px; }
  .page-header .header-icon { width: 40px; height: 40px; }
  .header-text h1 { font-size: 1.4rem; }
  .palette-trigger { display: none; }
  #toasts { right: 50%; transform: translateX(50%); bottom: calc(var(--nav-h) + 14px); }
  .chat-input { bottom: calc(var(--nav-h) + 10px + env(safe-area-inset-bottom)); }
  .chat-head { top: 62px; }
}
@media (max-width: 480px) {
  .hide-sm { display: none !important; }
  .hero-level { font-size: 2rem; padding: 6px 12px; }
  .kpi-value { font-size: 1.5rem; }
  .kpi { padding: 12px 12px 12px 14px; gap: 9px; }
  .kpi-ico { display: none; }
  .msg { max-width: 94%; }
}

/* ---------- Défilement fin ---------- */
* { scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--text-muted) 40%, transparent) transparent; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--text-muted) 35%, transparent); border-radius: 9px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background-color: color-mix(in srgb, var(--text-muted) 60%, transparent); }

/* ==========================================================================
   Fluidité : transitions entre pages, apparitions douces, retours tactiles.
   Seuls transform et opacity sont animés (composités par le GPU, sans recalcul de mise en page).
   ========================================================================== */
:root { --ease-out: cubic-bezier(.22, 1, .36, 1); }

/* Le dégradé de fond « fixed » force un repaint complet à chaque défilement (très visible sur mobile) :
   on le porte par un calque fixe, composité à part. */
body { background: var(--bg-body); background-attachment: scroll; }
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(1100px 700px at 8% -12%, color-mix(in srgb, var(--brand) 6%, transparent), transparent 60%),
    radial-gradient(900px 600px at 70% 120%, rgba(250, 204, 21, .07), transparent 60%);
}

/* Changement de page : l'ancienne vue s'efface, la nouvelle entre en cascade. */
.view { transition: opacity .12s ease-in, transform .12s ease-in; }
.view.leaving { opacity: 0; transform: translateY(4px); pointer-events: none; }
.view > * { animation: fadeSlideUp .42s var(--ease-out) backwards; }
.view > *:nth-child(n+5) { animation-delay: .16s; }
.view > *:nth-child(n+8) { animation-delay: .2s; }
.route-skeleton { animation: fadeSlideUp .3s var(--ease-out) backwards; }
#ex > *, #tab-body > * { animation: fadeSlideUp .35s var(--ease-out) backwards; }

/* Éléments qui apparaissent après une action : fondu doux plutôt qu'apparition sèche. */
.translation, .feedback, .flip-back, .explain, .result-banner, .pattern-card, .debrief-body > *, .suggestions > *, .vocab-chips,
.word-popup, #quiz-end, #sugg > * { animation: fadeSlideUp .3s var(--ease-out) backwards; }
.msg.user { animation: bubbleIn .28s var(--ease-out); transform-origin: 100% 100%; }
.msg.assistant { animation: bubbleInLeft .28s var(--ease-out); transform-origin: 0 100%; }
@keyframes bubbleIn { from { opacity: 0; transform: translateY(8px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes bubbleInLeft { from { opacity: 0; transform: translateY(8px) scale(.97); } to { opacity: 1; transform: none; } }

/* Retours au toucher et au survol : courts, sur des propriétés précises (jamais « all »). */
.act-card, .skill-card, .scenario, .kpi, a.card, button.card, .flip-card, .pattern-card {
  transition: transform .22s var(--ease-out), box-shadow .22s var(--ease-out), border-color .2s var(--ease);
}
.act-card:hover, .skill-card:hover, .scenario:hover, button.card:hover, a.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); }
.act-card:active, .skill-card:active, .scenario:active, button.card:active, a.card:active { transform: scale(.985); transition-duration: .08s; }
.tab, .segmented button, .chip, .bottom-nav a, .icon-btn, .option { transition: background-color .2s var(--ease), color .2s var(--ease), border-color .2s var(--ease), transform .12s var(--ease); }
.bottom-nav a:active, .icon-btn:active, .chip:active, .segmented button:active { transform: scale(.94); }
.act-card .go { transition: transform .22s var(--ease-out), opacity .2s var(--ease); }
.act-card:hover .go { transform: translateX(3px); }

/* Barres de progression et anneaux : la valeur glisse au lieu de sauter. */
.progress > div { transition: width .7s var(--ease-out); }

/* Défilement doux dans les zones de discussion, sans rebond du reste de la page. */
.chat-log { scroll-behavior: smooth; overscroll-behavior: contain; }
.bottom-nav, .sidebar-nav { overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }

/* Bascule clair / sombre : fondu bref (classe posée par theme.js pendant 300 ms). */
:root.theme-fade, :root.theme-fade *, :root.theme-fade *::before, :root.theme-fade *::after {
  transition: background-color .28s ease, border-color .28s ease, color .28s ease, fill .28s ease, stroke .28s ease !important;
}

/* ---------- Mouvement réduit ---------- */
:root[data-motion="reduce"] *, :root[data-motion="reduce"] *::before, :root[data-motion="reduce"] *::after { animation: none !important; transition: none !important; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

@media print {
  .sidebar, .topbar, .bottom-nav, .header-actions, .chat-input, #toasts { display: none !important; }
  .app-shell { display: block; }
  .card { box-shadow: none; break-inside: avoid; }
}
