/* Oreille d’or — feuille de style. Ivoire chaud, bleu canard profond, or. Pas de style inline (CSP stricte). */
:root {
  --bg: #fbf6ec; --card: #fffdf8; --ink: #1d2733; --muted: #5d6673; --line: #e7dcc7;
  --teal: #12555b; --teal-2: #1b7279; --teal-soft: #e3f0ef; --gold: #c8922a; --gold-2: #e8b44c; --gold-soft: #fbefd3;
  --ok: #217a4b; --ok-soft: #e1f3e8; --ko: #b6402f; --ko-soft: #fbe5e0;
  --r: 18px; --r-s: 12px; --shadow: 0 1px 2px rgba(40, 30, 10, .06), 0 6px 22px rgba(40, 30, 10, .07);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
html.hc { --muted: #2f3640; --line: #a99c83; --ink: #000; --teal: #0b3d42; }
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; touch-action: manipulation; }
button, a, input, select, summary, label { touch-action: manipulation; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 var(--font); min-height: 100vh; padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
body.in-session, body.in-prof { padding-bottom: 24px; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: 1.6rem; letter-spacing: -.01em; } h2 { font-size: 1.2rem; } h3, .h3 { font-size: 1.02rem; }
p { margin: 0 0 .7em; }
a { color: var(--teal); }
[hidden] { display: none !important; }
.sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.sr:focus { position: fixed !important; top: 8px; left: 8px; width: auto; height: auto; clip: auto; background: #fff; padding: 8px 12px; z-index: 99; border-radius: 8px; }
.wrap { max-width: 760px; margin: 0 auto; padding: 0 16px; }
.wrap.wide { max-width: 1180px; }
.small { font-size: .88rem; } .muted { color: var(--muted); } .strong { font-weight: 650; } .center { text-align: center; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 10px 0; }
.row.center { justify-content: center; }
.ic { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ic.big { width: 30px; height: 30px; }
.with-ic { display: flex; align-items: center; gap: 10px; }
.eyebrow { text-transform: uppercase; letter-spacing: .08em; font-size: .75rem; font-weight: 700; color: var(--gold); margin-bottom: .3em; }
.lead { font-size: 1.05rem; color: var(--muted); }

/* En-tête et onglets */
.top { position: sticky; top: 0; z-index: 20; background: rgba(251, 246, 236, .92); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); padding-top: env(safe-area-inset-top); }
.top .wrap { display: flex; align-items: center; gap: 10px; min-height: 58px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-weight: 800; font-size: 1.15rem; margin-right: auto; min-width: 0; }
.brand svg { width: 34px; height: 34px; flex: none; }
.brand em { font-style: normal; color: var(--gold); }
.brand > span { white-space: nowrap; }
@media (max-width: 520px) { .brand small { display: none; } .who { max-width: 38vw; } }
.brand small { display: block; font-weight: 500; font-size: .72rem; color: var(--muted); letter-spacing: .01em; }
.icon-btn { display: inline-grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; border: 1px solid transparent; background: transparent; color: var(--ink); cursor: pointer; text-decoration: none; flex: none; }
.icon-btn:hover { background: var(--teal-soft); }
.who { display: flex; align-items: center; gap: 6px; text-decoration: none; color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: 99px; padding: 4px 12px 4px 4px; max-width: 42vw; font-size: .9rem; font-weight: 600; }
.who-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: rgba(255, 253, 248, .96); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.tabs .wrap { display: flex; justify-content: space-around; }
.tab { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 14px; min-width: 88px; font-size: .78rem; font-weight: 600; color: var(--muted); text-decoration: none; }
.tab[aria-current="page"] { color: var(--teal); }
.tab[aria-current="page"]::before { content: ""; position: absolute; top: 0; left: 30%; right: 30%; height: 3px; border-radius: 0 0 3px 3px; background: var(--gold); }
.badge { position: absolute; top: 3px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--ko); color: #fff; font-size: .7rem; line-height: 18px; text-align: center; }
body.in-session .tabs, body.in-prof .tabs { display: none; }

/* Cartes et boutons */
main { padding: 18px 0 8px; outline: none; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; margin: 0 0 16px; box-shadow: var(--shadow); }
.card.note { background: var(--gold-soft); border-color: #efd9a6; box-shadow: none; }
.hero { background: linear-gradient(135deg, #fffaf0, #f7ead0); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 18px; border-radius: 99px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font: 600 .95rem var(--font); text-decoration: none; cursor: pointer; position: relative; transition: transform .08s, box-shadow .15s, background .15s; }
.btn:hover { border-color: var(--teal-2); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: linear-gradient(180deg, var(--teal-2), var(--teal)); color: #fff; border-color: var(--teal); box-shadow: 0 3px 0 #0b3a3e; }
.btn.primary:active { transform: translateY(2px); box-shadow: 0 1px 0 #0b3a3e; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--ko); border-color: #ebc3bb; }
.modal .btn.danger { background: var(--ko); color: #fff; border-color: var(--ko); }
.btn.small { min-height: 38px; padding: 6px 14px; font-size: .88rem; }
.btn.big { min-height: 54px; padding: 12px 26px; font-size: 1.05rem; }
.btn:disabled { opacity: .45; cursor: default; }
.btn:focus-visible, .icon-btn:focus-visible, .choice:focus-visible, .pk:focus-visible, .tchip:focus-visible, .lv-btn:focus-visible, .ex-card:focus-visible, .who-card:focus-visible { outline: 3px solid var(--gold-2); outline-offset: 2px; }
.pill { display: inline-block; padding: 3px 12px; border-radius: 99px; font-size: .82rem; font-weight: 650; background: var(--teal-soft); color: var(--teal); }
.pill.ok { background: var(--ok-soft); color: var(--ok); } .pill.gold { background: var(--gold-soft); color: #8a5c08; font-size: .95rem; padding: 6px 16px; }

/* Accueil */
.ex-grid { list-style: none; margin: 0 0 16px; padding: 0; display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 620px) { .ex-grid { grid-template-columns: 1fr 1fr; } }
.ex-card { display: flex; flex-direction: column; gap: 8px; height: 100%; padding: 16px 18px; border-radius: var(--r); background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow); color: var(--ink); text-decoration: none; transition: transform .12s, border-color .12s; }
.ex-card:hover { transform: translateY(-2px); border-color: var(--gold-2); }
.ex-head { display: flex; align-items: center; gap: 10px; font-size: 1.05rem; }
.ex-ic { width: 38px; height: 38px; padding: 8px; border-radius: 12px; background: var(--teal-soft); color: var(--teal); }
.ex-abs .ex-ic { background: var(--gold-soft); color: #9a6708; }
.ex-foot { display: flex; align-items: center; gap: 12px; margin-top: auto; }
.meter { flex: 1; height: 8px; border-radius: 4px; background: #efe6d4; overflow: hidden; }
.meter i { display: block; height: 100%; width: var(--p, 0%); background: linear-gradient(90deg, var(--gold), var(--gold-2)); border-radius: 4px; }

/* Niveaux */
.ptop { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.ptop h1 { margin: 0; font-size: 1.4rem; }
.levels { list-style: none; margin: 10px 0; padding: 0; display: grid; gap: 8px; }
.levels > li { display: flex; align-items: center; gap: 10px; }
.levels > li:not(:has(.lv-btn)) { padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-s); }
.levels > li.ok:not(:has(.lv-btn)) { background: var(--ok-soft); border-color: #bfe0cb; color: var(--ok); }
.lv-btn { flex: 1; display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--r-s); border: 1px solid var(--line); background: var(--card); color: var(--ink); font: inherit; text-align: left; cursor: pointer; min-height: 48px; }
.lv-btn[aria-pressed="true"] { border: 2px solid var(--teal); background: var(--teal-soft); }
.lv-btn:disabled { cursor: default; color: var(--muted); background: #f6f1e7; }
.lv-n { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--gold-soft); color: #8a5c08; font-weight: 750; font-size: .85rem; flex: none; }
.lv-t { flex: 1; font-weight: 600; }
.chips-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 12px; }
.tchip { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 6px 14px; border-radius: 99px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font: 600 .9rem var(--font); cursor: pointer; }
.tchip .ic { width: 18px; height: 18px; color: var(--teal); }
.tchip.new { border-color: var(--gold); background: var(--gold-soft); }
.tchip[aria-pressed="true"] { background: var(--teal); color: #fff; border-color: var(--teal); }
.tchip[aria-pressed="false"] { opacity: .7; text-decoration: line-through; }

/* Statistiques */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin: 0 0 16px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-s); padding: 12px 14px; }
.stat b { display: block; font-size: 1.35rem; color: var(--teal); }
.stat span { font-size: .84rem; color: var(--muted); }
.act { display: flex; align-items: flex-end; gap: 3px; height: 80px; padding-top: 6px; }
.act .bar { flex: 1; height: var(--h, 0%); min-height: 3px; border-radius: 3px 3px 0 0; background: var(--gold); }
.act .bar.zero { background: #ece3d1; }
.plist { margin: 6px 0 10px; padding-left: 1.2em; } .plist li { margin: 3px 0; }
.hist { list-style: none; margin: 0; padding: 0; }
.hist li { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 8px 0; border-bottom: 1px solid var(--line); }
.hist li:last-child { border-bottom: 0; }

/* Série */
.stop { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.stitle { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.stitle .lvl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sbar { height: 6px; border-radius: 3px; background: #ece3d1; overflow: hidden; margin-bottom: 14px; }
.sbar i { display: block; height: 100%; width: var(--p, 0%); background: linear-gradient(90deg, var(--teal-2), var(--gold)); transition: width .3s; }
.qcard { text-align: center; transition: border-color .2s, background .2s; }
.qcard.is-ok { border-color: #9fd2b3; } .qcard.is-ko { border-color: #e8b2a7; }
.qt { font-size: 1.45rem; margin-bottom: .2em; }
.qs { min-height: 1.5em; }
.listen { min-width: 190px; }
.padbox { margin: 18px 0 6px; }
.fb:empty { display: none; }
.fb { margin-top: 14px; padding: 14px; border-radius: var(--r-s); background: #f8f2e6; }
.is-ok .fb { background: var(--ok-soft); } .is-ko .fb { background: var(--ko-soft); }
.verdict { font-size: 1.2rem; font-weight: 800; margin-bottom: .3em; }
.is-ok .verdict { color: var(--ok); } .is-ko .verdict { color: var(--ko); }

/* Clavier de piano (une octave) */
.piano { position: relative; max-width: 560px; margin: 0 auto; user-select: none; -webkit-user-select: none; }
.pw { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.pb { position: absolute; inset: 0 0 auto 0; height: 58%; pointer-events: none; }
.pk { position: relative; border-radius: 0 0 10px 10px; cursor: pointer; font: 700 .9rem var(--font); display: flex; align-items: flex-end; justify-content: center; padding: 0 0 10px; transition: background .12s, transform .06s; -webkit-tap-highlight-color: transparent; }
.pk.wht { height: 170px; background: linear-gradient(180deg, #fff, #f7f2e8); border: 1px solid #d8ccb4; color: var(--ink); box-shadow: inset 0 -5px 0 #e9dfcb; }
.pk.blk { position: absolute; top: 0; height: 100%; width: 11%; left: calc(var(--x) * (100% / 7) - 5.5%); background: linear-gradient(180deg, #2a3240, #121821); color: #f3e7cf; border: 1px solid #0c1015; font-size: .72rem; pointer-events: auto; z-index: 2; box-shadow: inset 0 -4px 0 #000; padding-bottom: 8px; }
.pk:active:not(:disabled) { transform: translateY(2px); }
.pk.wht:hover:not(:disabled) { background: #fff8e6; }
.pk:disabled { cursor: default; }
.pk.wht:disabled { background: #ece6da; color: #a49a88; box-shadow: none; }
.pk.blk:disabled { background: #6b6f76; color: #b7b0a2; }
.piano.done .pk { opacity: .55; }
.pk.right { background: var(--ok) !important; color: #fff !important; opacity: 1 !important; border-color: var(--ok); }
.pk.wrong { background: var(--ko) !important; color: #fff !important; opacity: 1 !important; border-color: var(--ko); }
@media (max-width: 420px) { .pk.wht { height: 150px; font-size: .78rem; } .pk.blk { width: 12%; left: calc(var(--x) * (100% / 7) - 6%); font-size: .6rem; } }

/* Boutons de réponse */
.choices { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); max-width: 640px; margin: 0 auto; }
.choices.deg { grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); }
.choices.fin { grid-template-columns: repeat(3, 1fr); max-width: 480px; }
.choice { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 64px; padding: 8px 10px; border-radius: var(--r-s); border: 1px solid var(--line); background: #fff; color: var(--ink); font: inherit; cursor: pointer; box-shadow: 0 2px 0 #e6dbc6; }
.choice b { font-size: 1.15rem; } .choice span { font-size: .78rem; color: var(--muted); }
.choice kbd { position: absolute; top: 4px; right: 7px; font: 600 .66rem var(--font); color: #b2a68f; }
.choices.fin .choice { min-height: 96px; } .choices.fin .ic { color: var(--teal); }
.choice:hover:not(:disabled) { border-color: var(--teal-2); background: #fbfffe; }
.choice:active:not(:disabled) { transform: translateY(2px); box-shadow: none; }
.choice:disabled { cursor: default; opacity: .55; }
.choice.right { background: var(--ok); border-color: var(--ok); opacity: 1; } .choice.right b, .choice.right span, .choice.right .ic { color: #fff; }
.choice.wrong { background: var(--ko); border-color: var(--ko); opacity: 1; } .choice.wrong b, .choice.wrong span, .choice.wrong .ic { color: #fff; }
@media (hover: none) { .choice kbd { display: none; } }
.bilan h1 { font-size: 2.6rem; color: var(--teal); margin: .1em 0; }

/* Apprenants */
.who-grid { list-style: none; padding: 0; margin: 16px 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.who-card { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 16px 10px; border-radius: var(--r); border: 1px solid var(--line); background: #fff; font: inherit; color: var(--ink); cursor: pointer; text-align: center; }
.who-card.cur { border: 2px solid var(--teal); }
.who-n { font-weight: 700; word-break: break-word; }
.avatar { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; color: #fff; font-weight: 800; flex: none; background: var(--teal); }
.avatar.xs { width: 30px; height: 30px; font-size: .85rem; } .avatar.lg { width: 56px; height: 56px; font-size: 1.4rem; }
.avatar.c0 { background: #12555b; } .avatar.c1 { background: #c8922a; } .avatar.c2 { background: #7b4b94; } .avatar.c3 { background: #b6402f; } .avatar.c4 { background: #2f6db0; } .avatar.c5 { background: #4f7d2c; }

/* Réglages */
.set { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.set:last-child { border-bottom: 0; }
.set.col { flex-direction: column; align-items: stretch; gap: 6px; }
.set label { font-weight: 600; }
.help { display: block; font-weight: 400; font-size: .85rem; color: var(--muted); }
.field { width: 100%; min-height: 44px; padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--r-s); background: #fff; font: 16px var(--font); color: var(--ink); }
.pin-in { font-size: 1.6rem; letter-spacing: .5em; text-align: center; }
input[type="range"] { flex: 1; min-width: 160px; accent-color: var(--teal); }
.switch { appearance: none; -webkit-appearance: none; width: 50px; height: 30px; border-radius: 15px; background: #d9cfbd; position: relative; cursor: pointer; flex: none; transition: background .15s; margin: 0; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .15s; }
.switch:checked { background: var(--teal); } .switch:checked::after { transform: translateX(20px); }
.switch:focus-visible { outline: 3px solid var(--gold-2); outline-offset: 2px; }
.warn-text { color: var(--ko); font-size: .9rem; min-height: 1.3em; margin: 6px 0 0; }
.steps { padding-left: 1.3em; } .steps li { margin: 6px 0; } .steps .ic { width: 18px; height: 18px; vertical-align: -3px; }

/* Modales, notifications, bandeau de mise à jour */
.modal { border: 0; border-radius: var(--r); padding: 0; width: min(460px, calc(100vw - 32px)); max-height: calc(100vh - 40px); background: var(--card); color: var(--ink); box-shadow: 0 20px 60px rgba(20, 20, 10, .3); }
.modal::backdrop { background: rgba(25, 30, 35, .45); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 16px 16px 0 20px; }
.modal-head h2 { margin: 0; font-size: 1.15rem; }
.modal-body { padding: 10px 20px; }
.modal-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; padding: 6px 20px 18px; }
#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(90px + env(safe-area-inset-bottom)); z-index: 60; background: #1f2a33; color: #fff; padding: 10px 18px; border-radius: 99px; font-size: .92rem; max-width: calc(100vw - 32px); box-shadow: var(--shadow); text-align: center; }
.upd-banner { position: fixed; left: 12px; right: 12px; bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 50; max-width: 620px; margin: 0 auto; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px 14px; border-radius: var(--r-s); background: #fff; border: 1px solid var(--gold); box-shadow: var(--shadow); }
.upd-banner span { flex: 1; min-width: 180px; font-weight: 600; }
.upd-banner.top { top: calc(66px + env(safe-area-inset-top)); bottom: auto; }

/* Espace professeur */
.prof-top { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.prof-top h1 { flex: 1; margin: 0; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -4px; }
.ptable { width: 100%; border-collapse: collapse; font-size: .9rem; }
.ptable th, .ptable td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.ptable thead th { font-size: .78rem; color: var(--muted); font-weight: 650; }
.plink { display: inline-flex; align-items: center; gap: 8px; font-weight: 650; text-decoration: none; }
.warn-card { border-color: #e8b2a7; background: var(--ko-soft); }

html.nomotion *, html.nomotion *::before, html.nomotion *::after { transition: none !important; animation: none !important; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media print {
  .top, .tabs, .no-print, #toast, .upd-banner { display: none !important; }
  body { background: #fff; padding: 0; } .card, .stat { box-shadow: none; break-inside: avoid; } .wrap.wide { max-width: none; }
  .ptable th, .ptable td { white-space: normal; }
}
