/* AlgeQuiz – site prof. Polices système uniquement, aucune ressource externe. */
:root {
  --blue: #1E3D4A;
  --blue-ink: #101E24;
  --blue-soft: #E8F0F3;
  --blue-text: #1E3D4A;
  --ink: #0D161A;
  --muted: #566770;
  --muted-2: #4B5563;
  --line: #E5E7EB;
  --line-2: #D1D5DB;
  --bg: #F5EFE6;
  --side: #1E3D4A;
  --ok-bg: #F0FDF4; --ok-line: #BBF7D0; --ok-ink: #166534;
  --warn-bg: #FFF7ED; --warn-ink: #9A3412;
  --bad: #B91C1C; --bad-bg: #FEF2F2;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 15px; line-height: 1.45; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--blue-ink); }
a:hover { color: #101E24; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }
[hidden] { display: none !important; }
h1 { margin: 0; font-size: 28px; font-weight: 700; letter-spacing: -0.01em; }
h2 { margin: 0; font-size: 18px; font-weight: 700; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Structure ---------- */
.layout { min-height: 100vh; display: flex; }
.side { width: 240px; flex-shrink: 0; background: var(--side); color: #E2E8F0; padding: 24px 16px; display: flex; flex-direction: column; gap: 6px; position: sticky; top: 0; height: 100vh; }
.side .brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 20px; }
.side .brand img { width: 34px; height: 34px; }
.side .brand strong { font-size: 20px; color: #FFFFFF; }
.side .brand small { font-size: 11px; background: #2D5869; color: #CBD5E1; padding: 2px 6px; border-radius: 6px; }
.nav { min-height: 44px; display: flex; align-items: center; padding: 0 12px; border-radius: 8px; color: #CBD5E1; text-decoration: none; font-size: 15px; }
.nav:hover { color: #FFFFFF; background: #2D5869; }
.nav.active { background: #2D5869; color: #FFFFFF; font-weight: 600; }
.side .who { margin-top: auto; padding: 16px 8px 0; border-top: 1px solid #2D5869; font-size: 13px; color: #BAD4DF; display: flex; flex-direction: column; gap: 6px; }
.side .who button { background: none; border: 0; color: #CBD5E1; padding: 0; text-align: left; text-decoration: underline; }
.main { flex: 1; min-width: 0; padding: 32px; display: flex; flex-direction: column; gap: 24px; max-width: 1400px; }

@media (max-width: 860px) {
  .layout { flex-direction: column; }
  .side { width: auto; height: auto; position: static; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 12px; }
  .side .brand { padding: 0 8px 0 0; }
  .side .who { margin: 0 0 0 auto; border: 0; padding: 0; flex-direction: row; gap: 12px; }
  .main { padding: 20px 16px; }
}

/* ---------- Éléments ---------- */
.btn { min-height: 44px; padding: 0 18px; border-radius: 10px; border: 1px solid var(--line-2); background: #FFFFFF; font-weight: 500; display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none; color: var(--ink); white-space: nowrap; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #FFFFFF; font-weight: 600; }
.btn.outline { border-color: var(--blue); color: var(--blue-ink); font-weight: 600; }
.btn.danger { color: var(--bad); border-color: #FCA5A5; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 14px; border-radius: 8px; }
.btn.link { border: 0; background: none; color: var(--blue-ink); padding: 0 4px; min-height: 36px; }
.btn:disabled { opacity: .6; cursor: default; }
.input, select.input, textarea.input { width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--line-2); border-radius: 10px; background: #FFFFFF; }
textarea.input { min-height: 80px; resize: vertical; }
.input.mono { font-family: var(--mono); }
.input.narrow { width: 90px; text-align: center; }
label.field { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 14px; }
label.field > small { font-weight: 400; color: var(--muted); }
label.check { display: flex; align-items: center; gap: 8px; font-weight: 400; min-height: 28px; }
.panel { background: #FFFFFF; border: 1px solid var(--line); border-radius: 14px; padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.panel > .title { font-weight: 600; }
.muted { color: var(--muted); font-size: 14px; }
.error { color: var(--bad); background: var(--bad-bg); border: 1px solid #FECACA; border-radius: 10px; padding: 10px 12px; margin: 0; font-size: 14px; }
.notice { color: var(--ok-ink); background: var(--ok-bg); border: 1px solid var(--ok-line); border-radius: 10px; padding: 10px 12px; margin: 0; font-size: 14px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.nowrap { flex-wrap: nowrap; white-space: nowrap; }
.panel .btn.link { justify-content: flex-start; padding: 0; }
.grow { flex: 1 1 auto; min-width: 0; }
.badge { font-size: 12px; font-weight: 600; padding: 4px 8px; border-radius: 6px; background: #F1F5F9; color: #334155; white-space: nowrap; }
.badge.teachers { background: var(--blue-soft); color: var(--blue-text); }
.badge.public { background: var(--warn-bg); color: var(--warn-ink); }
.badge.open { background: var(--ok-bg); color: var(--ok-ink); }
.chip { font-size: 12px; padding: 3px 8px; border-radius: 6px; background: var(--blue-soft); color: var(--blue-text); }
.chip.level { background: var(--ink); color: #FFFFFF; font-weight: 600; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.code { font-family: var(--mono); letter-spacing: 2px; }
.empty { color: var(--muted); text-align: center; padding: 32px 16px; margin: 0; }
.loading { padding: 48px; text-align: center; color: var(--muted); }

/* ---------- Pages de connexion ---------- */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth form, .auth .box { width: 100%; max-width: 420px; background: #FFFFFF; border: 1px solid var(--line); border-radius: 16px; padding: 28px; display: flex; flex-direction: column; gap: 14px; }
.auth .brand { display: flex; align-items: center; gap: 10px; justify-content: center; margin-bottom: 4px; }
.auth .brand img { width: 40px; height: 40px; }
.auth .brand strong { font-size: 22px; }
.auth h1 { font-size: 22px; text-align: center; }
.auth .links { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; font-size: 14px; }

/* ---------- Liste des quiz ---------- */
.tabs { display: flex; gap: 6px; background: #E5E7EB; padding: 4px; border-radius: 10px; }
.tab { min-height: 40px; padding: 0 16px; border: 0; border-radius: 8px; background: transparent; color: var(--muted-2); }
.tab[aria-selected="true"] { background: #FFFFFF; color: var(--ink); font-weight: 600; }
.cols { display: flex; gap: 24px; align-items: flex-start; flex-wrap: wrap; }
.filters { flex: 1 1 230px; max-width: 280px; font-size: 14px; gap: 18px; }
.filters .head { font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.filters .grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px 6px; }
.filters .dom { display: flex; justify-content: space-between; width: 100%; border: 0; background: none; padding: 6px 0; font-weight: 600; text-align: left; }
.filters .sub { padding-left: 18px; }
.results { flex: 999 1 480px; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.quiz-card { background: #FFFFFF; border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.quiz-card .info { flex: 1 1 300px; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.quiz-card .t { font-weight: 600; font-size: 16px; }
.pager { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; padding-top: 8px; }
.pager button[aria-current="page"] { background: var(--blue); border-color: var(--blue); color: #FFFFFF; font-weight: 600; }
@media (max-width: 700px) { .filters { max-width: none; } }

/* ---------- Éditeur ---------- */
.editor { display: flex; gap: 24px; align-items: flex-start; flex-wrap: wrap; }
.editor .left { flex: 3 1 460px; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.editor .right { flex: 2 1 300px; display: flex; flex-direction: column; gap: 16px; position: sticky; top: 16px; }
.qcard { background: #FFFFFF; border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.qcard .qhead { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.qcard .num { font-weight: 700; color: var(--muted); min-width: 28px; }
.qcard .tools { margin-left: auto; display: flex; gap: 4px; }
.qcard .tools button { min-width: 36px; min-height: 36px; border: 1px solid var(--line); border-radius: 8px; background: #FFFFFF; }
.qcard .opts { display: flex; flex-direction: column; gap: 8px; }
.qcard .opt { display: flex; gap: 8px; align-items: center; }
.qcard .qerr { margin: 0; }
.add-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 12px; border: 2px dashed #CBD5E1; border-radius: 12px; }
.total { font-size: 26px; font-weight: 700; }
.vis-opt { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: #FFFFFF; width: 100%; }
.vis-opt[aria-checked="true"] { border: 2px solid var(--blue); background: var(--blue-soft); }
.vis-opt small { color: var(--muted); font-size: 13px; }
.toggle-chip { font-size: 13px; padding: 6px 10px; border-radius: 6px; border: 1px solid var(--line-2); background: #FFFFFF; min-height: 34px; }
.toggle-chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #FFFFFF; font-weight: 600; }
.theme-chip { font-size: 13px; padding: 6px 10px; border-radius: 6px; background: var(--blue-soft); color: var(--blue-text); border: 0; min-height: 34px; }
.code-box { background: var(--ok-bg); border: 1px solid var(--ok-line); border-radius: 10px; padding: 12px; display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.code-box .code { font-size: 22px; color: #14532D; }
.sheet-edit { overflow-x: auto; }
.sheet-edit table { border-collapse: collapse; }
.sheet-edit th { background: #F1F5F9; color: var(--muted); font-weight: 500; padding: 4px 8px; font-size: 13px; }
.sheet-edit td { padding: 2px; }
.sheet-edit input { width: 90px; min-height: 36px; padding: 4px 6px; border: 1px solid var(--line-2); border-radius: 6px; font-family: var(--mono); font-size: 14px; }

/* ---------- Résultats ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; }
.stat { background: #FFFFFF; border: 1px solid var(--line); border-radius: 14px; padding: 18px; }
.stat .v { font-size: 28px; font-weight: 700; }
.table-wrap { overflow-x: auto; background: #FFFFFF; border: 1px solid var(--line); border-radius: 14px; }
table.data { width: 100%; border-collapse: collapse; min-width: 560px; }
table.data th { text-align: left; color: var(--muted); font-size: 13px; font-weight: 600; padding: 12px 16px; }
table.data td { padding: 12px 16px; border-top: 1px solid #F1F5F9; }
table.data tr.clickable { cursor: pointer; }
table.data tr.clickable:hover td { background: #F9FAFB; }
.rate { display: flex; align-items: center; gap: 10px; }
.rate .bar { flex: 1; height: 8px; background: #E5E7EB; border-radius: 4px; overflow: hidden; min-width: 80px; }
.rate .bar > div { height: 100%; border-radius: 4px; background: var(--blue); }
.rate .bar > div.low { background: #E8853D; }
.answer-ok { color: var(--ok-ink); font-weight: 600; }
.answer-ko { color: var(--bad); font-weight: 600; }

dialog { border: 0; border-radius: 16px; padding: 0; max-width: 640px; width: calc(100% - 32px); box-shadow: 0 20px 50px rgba(15, 23, 42, .25); }
dialog::backdrop { background: rgba(15, 23, 42, .45); }
dialog .box { padding: 24px; display: flex; flex-direction: column; gap: 14px; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #FFFFFF; padding: 10px 16px; border-radius: 10px; font-size: 14px; z-index: 10; }
