:root {
  color-scheme: light dark;
  --bg: #f6f6f9;
  --surface: #ffffff;
  --surface-2: #f1f1f6;
  --text: #17171c;
  --text-2: #55556a;
  --border: #e2e2ea;
  --control-border: #8a8a9c; /* champs et boutons : contraste ≥ 3:1 (WCAG 1.4.11) */
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-text: #ffffff;
  --accent-soft: #ecebfd;
  --ok: #146c35;
  --ok-bg: #e3f5e9;
  --warn: #8a5100;
  --warn-bg: #fff0d6;
  --bad: #b42318;
  --bad-bg: #fde8e7;
  --info: #1d5fb8;
  --info-bg: #e5effc;
  --muted: #55556a;
  --muted-bg: #ececf2;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 20, 40, 0.06), 0 6px 20px rgba(20, 20, 40, 0.05);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f0f14;
    --surface: #18181f;
    --surface-2: #22222b;
    --text: #f1f1f5;
    --text-2: #a9a9bb;
    --border: #2e2e39;
    --control-border: #7d7d90;
    --accent: #8b84ff;
    --accent-hover: #a29cff;
    --accent-text: #0f0f14;
    --accent-soft: #25233f;
    --ok: #6bdc95;
    --ok-bg: #132f20;
    --warn: #f5b454;
    --warn-bg: #352812;
    --bad: #ff8a80;
    --bad-bg: #3a1714;
    --info: #85baff;
    --info-bg: #142640;
    --muted: #a9a9bb;
    --muted-bg: #25252e;
    --shadow: none;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
}

h1, h2, h3 { line-height: 1.2; margin: 0 0 0.5rem; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 0.75rem; }
a { color: var(--accent); }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

[hidden] { display: none !important; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* ---- Structure ---- */

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.85rem 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.brand {
  display: inline-flex; align-items: center; gap: 0.5rem;
  color: var(--text); font-weight: 700; font-size: 1.1rem; text-decoration: none;
}

.brand-mark {
  width: 18px; height: 18px; border-radius: 50%;
  border: 4px solid var(--accent);
}

.topbar-link { color: var(--text-2); text-decoration: none; font-size: 0.95rem; }
.topbar-link:hover { color: var(--text); }

.container { max-width: 1080px; margin: 0 auto; padding: 2rem 16px 4rem; }
.container.narrow { max-width: 560px; }

.page-head {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between;
  gap: 1rem; margin-bottom: 1.5rem;
}

.grid { display: grid; gap: 1.25rem; margin-bottom: 1.25rem; }
@media (min-width: 860px) {
  .grid { grid-template-columns: 1.4fr 1fr; align-items: start; }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}
.grid > .card { margin-bottom: 0; }

.eyebrow {
  margin: 0 0 0.25rem;
  font-size: 0.8rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text-2);
}

.muted { color: var(--text-2); }
.small { font-size: 0.875rem; }
.center { text-align: center; }

/* ---- Formulaires ---- */

label { display: block; font-weight: 600; font-size: 0.9rem; margin: 0.75rem 0 0.35rem; }

input[type="text"], input:not([type]), select {
  width: 100%;
  min-height: 44px;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--control-border);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
}
input[readonly] { color: var(--text-2); }

.row { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; }
.row > input { flex: 1 1 220px; width: auto; }
.row.spaced { margin-top: 0.5rem; }

.error { color: var(--bad); font-size: 0.9rem; margin: 0.5rem 0 0; min-height: 1.35em; }

/* ---- Boutons ---- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  min-height: 44px;
  padding: 0.55rem 1rem;
  border: 1px solid var(--control-border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit; font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }

.btn.danger { color: var(--bad); }
.btn.danger:hover { background: var(--bad-bg); border-color: var(--bad); }

.btn.big { min-height: 52px; padding: 0.75rem 1.4rem; font-size: 1.05rem; }
.btn.small { min-height: 36px; padding: 0.35rem 0.75rem; font-size: 0.875rem; }
.btn.block { width: 100%; }

/* ---- Liste des classes (accueil) ---- */

.class-list { list-style: none; padding: 0; margin: 0 0 1.5rem; display: grid; gap: 0.75rem; }
@media (min-width: 700px) { .class-list { grid-template-columns: 1fr 1fr; } }

.class-item {
  display: flex; flex-direction: column; gap: 0.4rem;
  padding: 1rem 1.1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
}
a.class-item:hover { border-color: var(--accent); }
.class-item-name { font-weight: 700; font-size: 1.05rem; }
.class-item-meta { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; color: var(--text-2); font-size: 0.9rem; }

/* ---- Cours et Focus ---- */

.live-line { display: flex; align-items: center; gap: 0.5rem; font-size: 1rem; }

.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--text-2); flex: none; }
.dot.live { background: var(--ok); }
.dot.off { background: var(--bad); }

@media (prefers-reduced-motion: no-preference) {
  .dot.live { animation: pulse 2s ease-in-out infinite; }
  @keyframes pulse { 50% { opacity: 0.35; } }
}

.focus-panel {
  margin: 1rem 0;
  padding: 1rem;
  border-radius: var(--radius);
  background: var(--surface-2);
}

.focus-banner {
  margin: 1rem 0;
  padding: 1.25rem;
  border-radius: var(--radius);
  background: var(--accent-soft);
  border: 1px solid var(--accent);
}
.focus-banner .focus-msg { font-size: 1.35rem; font-weight: 700; margin-bottom: 0.4rem; overflow-wrap: anywhere; }

.field-pair { display: grid; gap: 0 1rem; }
@media (min-width: 560px) { .field-pair { grid-template-columns: 2fr 1fr; } }

.course-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 1rem; }

/* ---- Invitation ---- */

.invite-code {
  margin: 0.75rem 0;
  padding: 0.85rem;
  border-radius: 10px;
  background: var(--surface-2);
  font-family: var(--mono);
  font-size: 1.9rem; font-weight: 700; letter-spacing: 0.06em;
  text-align: center;
  overflow-wrap: anywhere;
}

/* ---- Élèves ---- */

.students-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 0.75rem; }

.summary { display: flex; flex-wrap: wrap; gap: 0.4rem; }

.students { list-style: none; margin: 1rem 0 0; padding: 0; }

.student {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1rem;
  padding: 0.7rem 0;
  border-top: 1px solid var(--border);
}
.student-name { flex: 1 1 160px; font-weight: 600; overflow-wrap: anywhere; }
.student-status { flex: 0 0 auto; }
.student-actions { display: flex; gap: 0.25rem; margin-left: auto; }

.badge {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.85rem; font-weight: 600;
  white-space: nowrap;
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.tone-ok { color: var(--ok); background: var(--ok-bg); }
.tone-warn { color: var(--warn); background: var(--warn-bg); }
.tone-bad { color: var(--bad); background: var(--bad-bg); }
.tone-info { color: var(--info); background: var(--info-bg); }
.tone-muted { color: var(--muted); background: var(--muted-bg); }
.tone-accent { color: var(--accent); background: var(--accent-soft); }

.conn { display: inline-flex; align-items: center; gap: 0.45rem; color: var(--text-2); font-size: 0.9rem; }

/* ---- Paramètres ---- */

.settings-block { padding: 1rem 0; border-top: 1px solid var(--border); }
.settings-block:first-of-type { border-top: 0; padding-top: 0.25rem; }
.settings-block h3 { margin-bottom: 0.25rem; }

/* ---- Page d'invitation élève ---- */

.steps { padding-left: 1.25rem; margin: 1rem 0; }
.downloads { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.6rem 0; }
.downloads .size { font-weight: 400; opacity: 0.75; }
.steps li { margin-bottom: 1rem; }

details { margin-top: 1rem; padding: 0.75rem 1rem; border-radius: 10px; background: var(--surface-2); }
summary { cursor: pointer; font-weight: 600; }
details ul { margin: 0.5rem 0 0; padding-left: 1.25rem; }

/* ---- Notifications ---- */

.toasts {
  position: fixed; left: 50%; bottom: 1.25rem; transform: translateX(-50%);
  display: grid; gap: 0.5rem;
  width: min(480px, calc(100% - 32px));
  z-index: 10;
  pointer-events: none; /* ne cache pas les boutons en dessous */
}
.toast {
  padding: 0.75rem 1rem;
  border-radius: 10px;
  background: var(--text);
  color: var(--bg);
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}
.toast.error { background: #b42318; color: #fff; } /* même rouge foncé en mode sombre : contraste suffisant */

/* ---- Compte prof ---- */

.user-bar { display: flex; align-items: center; gap: 0.6rem; }
.user-name { color: var(--text-2); font-size: 0.95rem; font-weight: 600; }

.auth-card { margin-top: 1rem; }
.tabs { display: flex; gap: 0.25rem; margin: 1rem 0 0.5rem; border-bottom: 1px solid var(--border); }
.tab {
  min-height: 44px; padding: 0.5rem 0.9rem;
  border: 0; border-bottom: 3px solid transparent; background: none;
  color: var(--text-2); font: inherit; font-weight: 600; cursor: pointer;
}
.tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }

input[type="email"], input[type="password"], textarea {
  width: 100%;
  min-height: 44px;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--control-border);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
}
textarea { resize: vertical; line-height: 1.45; }
form .btn.block { margin-top: 1rem; }

.btn.google { background: var(--surface); border-color: var(--border-strong, var(--border)); margin-top: 0.75rem; }
.google-g { font-weight: 800; color: #4285f4; }
.divider { display: flex; align-items: center; gap: 0.75rem; margin: 1rem 0 0; color: var(--text-2); font-size: 0.85rem; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

.notice {
  margin: 0 0 1.25rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--warn);
  border-radius: var(--radius);
  background: var(--warn-bg);
  color: var(--text);
}

.eyebrow a { color: inherit; text-decoration: none; }
.eyebrow a:hover { text-decoration: underline; }

/* ---- Partage ---- */

.share-card.highlight { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }

/* ---- Élèves ---- */

.student-name { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 0.35rem; }
.student-email { flex-basis: 100%; font-size: 0.82rem; font-weight: 400; color: var(--text-2); }
.verified { color: var(--ok); font-weight: 700; }

/* ---- Confirmation dans la page ---- */

.dialog {
  width: min(440px, calc(100% - 32px));
  padding: 1.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}
.dialog::backdrop { background: rgba(15, 15, 25, 0.45); }
.dialog h2 { font-size: 1.2rem; margin-bottom: 0.5rem; }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0.6rem; margin-top: 1.25rem; }
.btn.danger-solid { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.danger-solid:hover { filter: brightness(0.92); }

/* ---- Après le téléchargement : la marche à suivre ---- */

.next-steps {
  margin: 0.9rem 0 0.5rem;
  padding: 1rem 1.1rem;
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent-soft);
}
.next-steps:focus { outline: none; }
.next-steps h2 { font-size: 1.05rem; margin-bottom: 0.5rem; }
.next-steps ol { margin: 0; padding-left: 1.25rem; }
.next-steps li { margin-bottom: 0.6rem; }
