/* en.amzur.be — feuille de style unique, mobile d'abord. */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --line: #dfe3ea;
  --text: #16202e;
  --muted: #64748b;
  --accent: #0d7d72;
  --accent-soft: #e3f4f1;
  --ok: #0f7a4f;
  --ok-soft: #e4f5ec;
  --warn: #9a6400;
  --warn-soft: #fdf2dc;
  --bad: #b02a2a;
  --bad-soft: #fcebeb;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 8px 24px rgba(16, 24, 40, .05);
  --radius: 14px;
  --maxw: 720px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1220;
    --surface: #131c2b;
    --surface-2: #1b2636;
    --line: #27354a;
    --text: #e8eef7;
    --muted: #93a3b8;
    --accent: #5eead4;
    --accent-soft: #10342f;
    --ok: #4ade80;
    --ok-soft: #10301f;
    --warn: #fbbf24;
    --warn-soft: #332508;
    --bad: #fca5a5;
    --bad-soft: #3a1a1a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .25);
  }
}

:root[data-theme="dark"] {
  --bg: #0b1220; --surface: #131c2b; --surface-2: #1b2636; --line: #27354a;
  --text: #e8eef7; --muted: #93a3b8; --accent: #5eead4; --accent-soft: #10342f;
  --ok: #4ade80; --ok-soft: #10301f; --warn: #fbbf24; --warn-soft: #332508;
  --bad: #fca5a5; --bad-soft: #3a1a1a;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .25);
}

* { box-sizing: border-box; }

/* L'attribut hidden doit gagner sur tout display: flex/grid déclaré plus bas. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}
body { padding-bottom: env(safe-area-inset-bottom); }

.view { max-width: var(--maxw); margin: 0 auto; padding: 14px 14px 90px; }
.view.center { min-height: 100dvh; display: grid; place-items: center; padding-bottom: 14px; }
.muted { color: var(--muted); }
.small { font-size: 13.5px; }
.accent { color: var(--accent); }
.error { color: var(--bad); font-size: 14px; margin: 4px 0 0; }

/* ------------------------------------------------------------------ cadres */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
}

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 10px max(14px, env(safe-area-inset-left)) 10px max(14px, env(safe-area-inset-right));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; background: none; border: 0; color: var(--text); font: inherit; font-weight: 650; cursor: pointer; padding: 2px 0; }
.brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); flex: none; }
.brand-text .muted { font-weight: 400; }
.topbar-right { margin-left: auto; display: flex; gap: 5px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }

.chip {
  font: inherit; font-size: 13px; line-height: 1;
  padding: 7px 10px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--muted);
  cursor: pointer;
}
.chip:hover { color: var(--text); }
.chip.icon { width: 32px; text-align: center; }
.chip.on { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.chip.off { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
.chip.timer { color: var(--accent); border-color: var(--accent); font-variant-numeric: tabular-nums; }
.chip.mode-chip { cursor: default; }

/* ----------------------------------------------------------------- boutons */

.btn {
  font: inherit; font-weight: 560;
  padding: 11px 16px; min-height: 44px;
  border-radius: 11px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--text); cursor: pointer;
}
.btn:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #04221f; }
:root[data-theme="dark"] .btn.primary, :root:not([data-theme="light"]) .btn.primary { color: #04221f; }
.btn.ghost { background: transparent; }
.btn.small { padding: 7px 11px; min-height: 36px; font-size: 14px; }
.btn[disabled] { opacity: .5; cursor: progress; }
.actions { display: flex; gap: 8px; margin-top: 12px; }
.actions.wrap { flex-wrap: wrap; }
.actions .btn { flex: 1; }
.actions.wrap .btn { flex: 1 1 auto; }

/* --------------------------------------------------------------- connexion */

.login { width: min(380px, 92vw); }
.login-title { margin: 0 0 2px; font-size: 24px; }
.field { display: block; margin: 14px 0 10px; }
.field > span { display: block; font-size: 13.5px; color: var(--muted); margin-bottom: 6px; }
input[type="password"], textarea {
  width: 100%; font: inherit; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 11px; padding: 11px 12px; resize: vertical;
}
textarea { min-height: 96px; line-height: 1.5; }
input:focus-visible, textarea:focus-visible, .btn:focus-visible, .chip:focus-visible, .seg-btn:focus-visible, .ex-card:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.login .btn { width: 100%; }

/* ----------------------------------------------------------------- accueil */

.hero { padding: 4px 2px 10px; }
.hero-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 10px; text-align: center;
}
.stat b { display: block; font-size: 24px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat span { font-size: 12px; color: var(--muted); }

.mode-row { display: flex; gap: 8px; align-items: center; margin-top: 12px; flex-wrap: wrap; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px; gap: 2px; }
.seg-btn {
  font: inherit; font-size: 14px; padding: 8px 14px; min-height: 38px;
  border: 0; border-radius: 999px; background: transparent; color: var(--muted); cursor: pointer;
}
.seg-btn[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); font-weight: 600; }
.seg-btn[disabled] { opacity: .45; cursor: not-allowed; }

.call { display: flex; align-items: center; gap: 12px; justify-content: space-between; border-color: var(--accent); background: var(--accent-soft); }
.call p { margin: 2px 0 0; }
.call .btn { flex: none; }

.group-title { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 18px 4px 8px; }
.ex-grid { display: grid; gap: 10px; grid-template-columns: 1fr; }
@media (min-width: 560px) { .ex-grid { grid-template-columns: 1fr 1fr; } }
.ex-card {
  display: flex; gap: 12px; align-items: flex-start; text-align: left;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; cursor: pointer; font: inherit; color: var(--text); box-shadow: var(--shadow);
}
.ex-card:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.ex-card .num {
  flex: none; width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-size: 13px; font-weight: 700;
}
.ex-card b { display: block; }
.ex-card .sub { font-size: 13px; color: var(--muted); display: block; }
.ex-card .tag { font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 6px; padding: 1px 5px; margin: 6px 6px 0 0; display: inline-block; }
.ex-card.disabled { opacity: .45; cursor: not-allowed; }

.lang-card { margin-top: 18px; display: grid; gap: 8px; }
.foot { text-align: center; margin-top: 18px; }

/* ---------------------------------------------------------------- exercice */

.ex-head { display: flex; align-items: center; gap: 10px; margin: 2px 2px 12px; flex-wrap: wrap; }
.ex-title { display: flex; flex-direction: column; line-height: 1.25; flex: 1 1 10ch; min-width: 0; }
.ex-title b, .ex-title span { overflow-wrap: anywhere; }
.ex-head-right { margin-left: auto; flex: none; }
.ex-head .btn { white-space: nowrap; flex: none; }

.options { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; align-items: center; }
.options label { font-size: 13px; color: var(--muted); }
.options select {
  font: inherit; font-size: 14px; padding: 8px 10px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
}
.options .chip.toggle[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }

.prompt-card { border-left: 3px solid var(--accent); }
.prompt-fr { font-size: 19px; font-weight: 560; margin: 0; }
.prompt-en { font-size: 18px; margin: 0; font-style: italic; }
.prompt-label { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 6px; }
.brief { margin: 10px 0 0; }
.brief b { font-weight: 600; }
.points { margin: 8px 0 0; padding-left: 18px; }
.points li { margin: 3px 0; }
.imposed-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.imposed {
  font-size: 13px; padding: 4px 9px; border-radius: 8px;
  background: var(--surface-2); border: 1px solid var(--line); font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.imposed.used { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 40%, var(--line)); }
.imposed.missing { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
.incoming {
  background: var(--surface-2); border-left: 3px solid var(--line); border-radius: 8px;
  padding: 10px 12px; margin: 10px 0 0; font-style: italic;
}

.chrono { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.chrono-bar { height: 4px; border-radius: 999px; background: var(--accent); flex: 1; transform-origin: left; }
.chrono-num { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 2ch; }

.answer-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.answer-tools .btn.rec { color: var(--bad); border-color: var(--bad); }

/* ---------------------------------------------------------------- réponses */

.correction { border-top: 3px solid var(--line); }
.verdict { display: flex; align-items: center; gap: 8px; font-weight: 650; margin-bottom: 8px; }
.verdict.ok { color: var(--ok); }
.verdict.almost { color: var(--warn); }
.verdict.wrong { color: var(--bad); }
.verdict.unknown { color: var(--muted); }
.block { margin-top: 12px; }
.block h4 { margin: 0 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 650; }
.err { border-left: 3px solid var(--bad); background: var(--bad-soft); border-radius: 8px; padding: 9px 11px; margin-bottom: 8px; }
.err .pair { font-size: 15px; }
.err del { text-decoration-color: var(--bad); opacity: .85; }
.err ins { text-decoration: none; font-weight: 650; }
.err .rule { font-size: 13.5px; color: var(--text); opacity: .85; margin-top: 3px; }
.natural { background: var(--ok-soft); border-left: 3px solid var(--ok); border-radius: 8px; padding: 10px 12px; font-size: 16px; }
.bonus { background: var(--warn-soft); border-left: 3px solid var(--warn); border-radius: 8px; padding: 9px 11px; font-size: 14px; }
.ref { background: var(--surface-2); border-radius: 8px; padding: 10px 12px; font-size: 15px; }
.ref + .ref { margin-top: 6px; }
.coverage { list-style: none; padding: 0; margin: 0; }
.coverage li { display: flex; gap: 8px; align-items: baseline; font-size: 14px; margin: 3px 0; }
.coverage .mark { flex: none; font-weight: 700; }
.coverage .yes { color: var(--ok); }
.coverage .no { color: var(--bad); }
.selfcheck { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
pre.model { white-space: pre-wrap; font: inherit; background: var(--surface-2); border-radius: 8px; padding: 10px 12px; margin: 0; }

.ex-footer {
  position: sticky; bottom: 0; padding: 10px 0 max(10px, env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 65%, transparent);
}
.ex-footer .btn { width: 100%; }

/* ----------------------------------------------------------- jeu de rôle */

.chat-log { display: flex; flex-direction: column; gap: 8px; max-height: 52dvh; overflow-y: auto; padding-right: 2px; }
.bubble { max-width: 86%; padding: 9px 12px; border-radius: 14px; font-size: 15px; }
.bubble.them { background: var(--surface-2); border: 1px solid var(--line); align-self: flex-start; border-bottom-left-radius: 4px; }
.bubble.me { background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line)); align-self: flex-end; border-bottom-right-radius: 4px; }
.bubble.wait { color: var(--muted); font-style: italic; }

.shadow-line { font-size: 21px; line-height: 1.45; font-weight: 560; }

/* --------------------------------------------------------------- listes */

.res-group { margin-bottom: 10px; }
.res-group h3 { font-size: 15px; margin: 0 0 6px; }
.tag-row { display: flex; gap: 6px; flex-wrap: wrap; }
.tag-row span {
  font-size: 13.5px; padding: 4px 9px; border-radius: 8px;
  background: var(--surface-2); border: 1px solid var(--line);
}
.lines { margin: 0; padding-left: 18px; }
.lines li { margin: 4px 0; }
details.acc { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); margin-bottom: 10px; box-shadow: var(--shadow); }
details.acc > summary { padding: 14px 16px; cursor: pointer; font-weight: 600; }
details.acc > div { padding: 0 16px 14px; }

.spark { display: flex; gap: 3px; align-items: flex-end; height: 56px; margin-top: 10px; }
.spark i { flex: 1; background: var(--accent-soft); border-radius: 3px 3px 0 0; min-height: 3px; display: block; }
.spark i.on { background: var(--accent); }
.err-row { border-bottom: 1px solid var(--line); padding: 9px 0; font-size: 14px; }
.err-row:last-child { border-bottom: 0; }
.err-row .w { color: var(--bad); }
.err-row .r { color: var(--ok); }
.err-row .meta { color: var(--muted); font-size: 12.5px; }

/* ----------------------------------------------------------------- toast */

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: max(18px, env(safe-area-inset-bottom)); z-index: 50;
  background: var(--text); color: var(--bg);
  padding: 10px 16px; border-radius: 999px; font-size: 14px; max-width: 90vw;
  box-shadow: var(--shadow);
}

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