/* LevelUP — mobile-first. 4 thèmes par utilisateur (classe body.theme-*), parent = ossature plus calme. */
:root, body.theme-dark {
  --bg: #121225;
  --bg2: #1b1b34;
  --card: #22224180;
  --card-solid: #222241;
  --line: #ffffff14;
  --text: #eef0ff;
  --muted: #9a9ec4;
  --accent: #7c5cff;
  --accent2: #b16cea;
  --gold: #ffc857;
  --green: #3ddc84;
  --red: #ff5c7a;
  --radius: 18px;
  --pc: var(--accent);
  --glow1: #7c5cff26;
  --glow2: #2ec4b61f;
}
body.theme-light {
  --bg: #f2f3fa;
  --bg2: #ffffff;
  --card: #ffffffd9;
  --card-solid: #ffffff;
  --line: #14163220;
  --text: #23263c;
  --muted: #6a6f8e;
  --accent: #5b45d8;
  --accent2: #8b5cf6;
  --gold: #d99000;
  --green: #1a9e5c;
  --red: #d6335c;
  --glow1: #7c5cff1c;
  --glow2: #2ec4b618;
}
body.theme-ocean {
  --bg: #07171f;
  --bg2: #0d232e;
  --card: #102d3a99;
  --card-solid: #102d3a;
  --line: #7fdcff1a;
  --text: #e6f6ff;
  --muted: #8fb3c4;
  --accent: #19b8c9;
  --accent2: #2ec4b6;
  --gold: #ffd166;
  --green: #34e0a1;
  --red: #ff6b6b;
  --glow1: #19b8c926;
  --glow2: #2ec4b622;
}
body.theme-candy {
  --bg: #fdf1f7;
  --bg2: #ffffff;
  --card: #ffffffe0;
  --card-solid: #ffffff;
  --line: #d6337a22;
  --text: #3b2140;
  --muted: #97688f;
  --accent: #e0489a;
  --accent2: #ff7bb0;
  --gold: #e08a00;
  --green: #1fa864;
  --red: #d6335c;
  --glow1: #ff7bb02e;
  --glow2: #8b5cf620;
}
body.parent { --radius: 12px; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: Inter, system-ui, sans-serif;
  font-size: 15.5px;
  line-height: 1.45;
  color: var(--text);
  background:
    radial-gradient(1000px 500px at 85% -10%, var(--glow1), transparent 60%),
    radial-gradient(800px 400px at -10% 110%, var(--glow2), transparent 55%),
    var(--bg);
  min-height: 100dvh;
}
body.parent { background: var(--bg); }
.shell { max-width: 640px; margin: 0 auto;
  padding: calc(14px + env(safe-area-inset-top)) 14px calc(84px + env(safe-area-inset-bottom)); }
body.auth .shell { padding-top: calc(24px + env(safe-area-inset-top)); padding-bottom: 24px; }

h1, h2, h3, .logo, .hud-name, .hud-balance, .mtitle, .stat-card b {
  font-family: 'Baloo 2', Inter, system-ui, sans-serif;
}
h1 { font-size: 1.35rem; margin: 0; }
h2 { font-size: 1.05rem; margin: 0 0 4px; }
h3 { font-size: 1rem; margin: 0; }
a { color: var(--accent); text-decoration: none; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: .83rem; }
.grow { flex: 1; min-width: 0; }
.center { text-align: center; }
.empty { text-align: center; color: var(--muted); padding: 40px 12px; }
.bigicon { font-size: 3rem; text-align: center; }

/* ---------------------------------------------------------------- flash */
.flash { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 10px;
  background: color-mix(in srgb, var(--green) 14%, transparent); border: 1px solid color-mix(in srgb, var(--green) 35%, transparent); font-weight: 500; }
.flash-err { background: color-mix(in srgb, var(--red) 14%, transparent); border-color: color-mix(in srgb, var(--red) 35%, transparent); }
.flash-warn { background: color-mix(in srgb, var(--gold) 14%, transparent); border-color: color-mix(in srgb, var(--gold) 35%, transparent); }
.flash a { color: inherit; text-decoration: underline; }

/* ---------------------------------------------------------------- auth */
body.auth .shell { display: flex; align-items: center; min-height: 100dvh; }
.auth-card { width: 100%; max-width: 420px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
.logo { font-size: 2.4rem; font-weight: 800; text-align: center; letter-spacing: -1px; }
.logo span { color: var(--gold); }
.profiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; }
.profile { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 16px 8px;
  border-radius: var(--radius); background: var(--card); border: 2px solid var(--line); color: var(--text); }
.profile:active { border-color: var(--pc); }
.profile.solo { margin: 0 auto; min-width: 140px; }
.pavatar { font-size: 2rem; width: 54px; height: 54px; display: grid; place-items: center;
  background: color-mix(in srgb, var(--pc) 25%, transparent); border-radius: 50%; flex-shrink: 0; }
.pname { font-weight: 600; }
.ptag { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.back-link { color: var(--muted); }
.pin-input { text-align: center; font-size: 1.8rem; letter-spacing: .5em; }
.pinpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.pinpad button { font-size: 1.4rem; padding: 14px; border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--card); color: var(--text); font-family: 'Baloo 2', sans-serif; }
.pinpad button:active { background: var(--accent); }

/* ---------------------------------------------------------------- forms */
input, select, textarea {
  width: 100%; padding: 11px 12px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--bg2); color: var(--text); font: inherit;
}
input:focus, select:focus, textarea:focus, .btn:focus-visible, .pinpad button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
label { display: flex; flex-direction: column; gap: 4px; font-size: .88rem; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); }
label.check input { width: auto; }
input[type="color"] { padding: 2px; height: 40px; width: 70px; }
input[type="range"] { padding: 0; accent-color: var(--gold); }
.tiny { width: 62px; flex-shrink: 0; text-align: center; }
.tiny.wide { width: 90px; }
.tinydate { padding: 7px 8px; font-size: .82rem; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin: 0; }
legend { padding: 0 6px; font-weight: 600; font-size: .9rem; }
blockquote { margin: 0; padding: 8px 12px; border-left: 3px solid var(--gold); background: var(--bg2);
  border-radius: 0 10px 10px 0; font-style: italic; }
output { font-weight: 700; color: var(--gold); min-width: 64px; text-align: right; }

.stack { display: flex; flex-direction: column; gap: 10px; }
.stack.tight { gap: 6px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row3 { display: flex; gap: 8px; }
.inline-form { display: flex; gap: 8px; align-items: center; }
.validate-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.slider-wrap { flex-direction: row; align-items: center; gap: 10px; }
.time-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }

/* ---------------------------------------------------------------- boutons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px; border-radius: 14px; border: 1px solid var(--line); cursor: pointer;
  background: var(--card-solid); color: var(--text); font: 600 .92rem 'Baloo 2', sans-serif; white-space: nowrap; }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff;
  border: none; box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 40%, transparent); }
.btn.big { padding: 14px; font-size: 1.05rem; }
.btn.small { padding: 7px 12px; font-size: .82rem; border-radius: 11px; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--red); border-color: color-mix(in srgb, var(--red) 30%, transparent); }
.btn:disabled { opacity: .4; cursor: not-allowed; box-shadow: none; }
.btn:not(:disabled):active { transform: translateY(1px); }

.timechip { display: flex; flex-direction: column; padding: 10px 4px; border-radius: 14px;
  border: 1px solid var(--line); background: var(--bg2); color: var(--text); cursor: pointer; }
.timechip b { font-family: 'Baloo 2', sans-serif; font-size: 1rem; }
.timechip small { color: var(--muted); font-size: .74rem; }
.timechip:not(:disabled):active { border-color: var(--gold); }
.timechip:disabled { opacity: .38; }

/* ---------------------------------------------------------------- HUD enfant */
.hud { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; margin-bottom: 12px; backdrop-filter: blur(8px); }
.hud-id { display: flex; align-items: center; gap: 10px; }
.hud-name { font-size: 1.15rem; font-weight: 700; }
.hud-level { color: var(--pc); font-weight: 600; font-size: .85rem; }
.hud-right { margin-left: auto; text-align: right; }
.hud-balance { font-size: 1.3rem; font-weight: 800; color: var(--gold); }
.hud-balance small { font-size: .75rem; color: var(--muted); }
.hud-streak { font-size: .8rem; color: var(--muted); }
.hud-sub { display: flex; justify-content: space-between; font-size: .78rem; color: var(--muted); margin-top: 4px; }

.lvlbar { height: 10px; border-radius: 99px; background: var(--bg2); overflow: hidden; margin-top: 10px; }
.lvlbar span { display: block; height: 100%; border-radius: 99px;
  background: linear-gradient(90deg, var(--accent), var(--accent2)); transition: width .4s; }
.lvlbar.gold span { background: linear-gradient(90deg, color-mix(in srgb, var(--gold) 75%, #ff8800), var(--gold)); }
.lvlbar.slim { height: 6px; margin: 6px 0 2px; }

.pinned-card { display: flex; gap: 12px; align-items: center; padding: 12px 14px; margin-bottom: 12px;
  border-radius: var(--radius); background: color-mix(in srgb, var(--gold) 10%, transparent); border: 1px dashed color-mix(in srgb, var(--gold) 42%, transparent); color: var(--text); }
.pinned-card .ric { font-size: 1.8rem; }
.pinned-card .rtitle { font-weight: 700; font-family: 'Baloo 2', sans-serif; }
.pinned-card .lvlbar { margin-top: 6px; }

/* ---------------------------------------------------------------- missions */
.cat { margin-top: 18px; }
.cat > h2 { margin-bottom: 8px; }
.seph { margin: 18px 0 8px; }
.mission { display: flex; align-items: center; gap: 10px; padding: 11px 12px; margin-bottom: 8px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.mission.done { opacity: .55; }
.mission.off { opacity: .45; }
.mission.reward.pinned { border-color: color-mix(in srgb, var(--gold) 55%, transparent); background: color-mix(in srgb, var(--gold) 7%, transparent); }
.mic { font-size: 1.5rem; flex-shrink: 0; width: 40px; text-align: center; }
.mtitle { font-weight: 600; }
.msub { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 3px; }
.mstate { font-size: 1.2rem; }
.mstate.wait { filter: grayscale(.3); }

.xp-pill { display: inline-block; padding: 2px 9px; border-radius: 99px; font: 700 .78rem 'Baloo 2', sans-serif;
  background: color-mix(in srgb, var(--gold) 16%, transparent); color: var(--gold); }
.xp-pill.big { font-size: 1.3rem; padding: 6px 18px; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: .72rem;
  background: var(--bg2); color: var(--muted); }
.tag.gold { color: var(--gold); background: color-mix(in srgb, var(--gold) 14%, transparent); }
.tag.warn { color: var(--red); background: color-mix(in srgb, var(--red) 12%, transparent); }

/* ---------------------------------------------------------------- cartes & stats */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; margin-bottom: 12px; }
.stat-card { display: flex; flex-direction: column; align-items: center; padding: 16px 8px;
  border-radius: var(--radius); background: var(--card); border: 1px solid var(--line); color: var(--text); }
.stat-card b { font-size: 1.9rem; line-height: 1; }
.stat-card span { color: var(--muted); font-size: .8rem; margin-top: 4px; }
.stat-card.alert { border-color: color-mix(in srgb, var(--accent) 60%, transparent);
  background: color-mix(in srgb, var(--accent) 12%, transparent); }

.catbar { display: flex; height: 10px; border-radius: 99px; overflow: hidden; background: var(--bg2); }
.catseg { min-width: 6px; }
.cat-learning { background: #7c5cff; } .cat-homework { background: #3a86ff; }
.cat-sport { background: #3ddc84; } .cat-autonomy { background: #ffc857; } .cat-fun { background: #ff5c7a; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 99px;
  background: var(--card); border: 1px solid var(--line); color: var(--text); font-size: .88rem; cursor: pointer; }
.chip.on, .chip:has(input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 15%, transparent); }
.chip input { width: auto; }

/* ---------------------------------------------------------------- journal */
.lotline, .ledgerline { display: flex; gap: 10px; align-items: baseline; padding: 7px 4px;
  border-bottom: 1px solid var(--line); }
.lotline:last-child, .ledgerline:last-child { border-bottom: 0; }
.lamount { font: 700 .95rem 'Baloo 2', sans-serif; min-width: 48px; text-align: right; }
.lamount.pos { color: var(--green); }
.lamount.neg { color: var(--red); }
.daysep { margin: 14px 0 4px; font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }

/* ---------------------------------------------------------------- quiz */
.quiz-q h3 { display: flex; gap: 8px; align-items: baseline; }
.qnum { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%;
  background: var(--accent); color: #fff; font-size: .8rem; flex-shrink: 0; }
.choice { display: flex; flex-direction: row; align-items: center; gap: 10px; padding: 10px 12px;
  border-radius: 12px; border: 1px solid var(--line); background: var(--bg2); color: var(--text); cursor: pointer; }
.choice:has(input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); }
.choice input { width: auto; }

/* ---------------------------------------------------------------- topbar & tabbar */
.topbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.topbar .back { font-size: 1.3rem; color: var(--text); }
.topbar .hud-balance { margin-left: auto; }
.topbar .btn { margin-left: auto; }
.topbar .btn + .btn { margin-left: 0; }

.tabbar { position: fixed; bottom: 0; left: 0; right: 0; display: flex; justify-content: space-around;
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg2) 92%, var(--text) 4%); border-top: 1px solid var(--line);
  backdrop-filter: blur(12px); z-index: 10; }
.tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 8px;
  color: var(--muted); font-size: .68rem; font-weight: 600; border-radius: 10px; min-width: 56px; }
.tabbar a.on { color: var(--text); background: color-mix(in srgb, var(--accent) 18%, transparent); }
.tabbar .ic { font-size: 1.25rem; }

@media (min-width: 640px) {
  body { font-size: 16px; }
  .time-row { grid-template-columns: repeat(4, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------------------------------------------------------------- sélecteur de thème */
.theme-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.theme-tile { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 6px;
  border-radius: 14px; border: 2px solid var(--line); background: var(--bg2); cursor: pointer;
  color: var(--text); font-size: .8rem; font-weight: 600; text-align: center; }
.theme-tile input { position: absolute; opacity: 0; width: 0; }
.theme-tile:has(input:checked) { border-color: var(--accent); }
.th-preview { display: flex; gap: 3px; width: 100%; height: 26px; border-radius: 8px; padding: 4px;
  justify-content: center; align-items: center; }
.th-preview i { width: 12px; height: 12px; border-radius: 50%; }
.th-dark  .th-preview { background: #121225; } .th-dark  .th-preview i:nth-child(1){background:#7c5cff}
.th-dark  .th-preview i:nth-child(2){background:#ffc857} .th-dark .th-preview i:nth-child(3){background:#3ddc84}
.th-light .th-preview { background: #f2f3fa; border: 1px solid #ddd; } .th-light .th-preview i:nth-child(1){background:#5b45d8}
.th-light .th-preview i:nth-child(2){background:#d99000} .th-light .th-preview i:nth-child(3){background:#1a9e5c}
.th-ocean .th-preview { background: #07171f; } .th-ocean .th-preview i:nth-child(1){background:#19b8c9}
.th-ocean .th-preview i:nth-child(2){background:#ffd166} .th-ocean .th-preview i:nth-child(3){background:#34e0a1}
.th-candy .th-preview { background: #fdf1f7; border: 1px solid #f3cfe0; } .th-candy .th-preview i:nth-child(1){background:#e0489a}
.th-candy .th-preview i:nth-child(2){background:#e08a00} .th-candy .th-preview i:nth-child(3){background:#8b5cf6}
.pavatar.big { width: 84px; height: 84px; font-size: 3rem; margin: 0 auto; }

/* ---------------------------------------------------------------- correctifs formats mobile */
/* iOS zoome sur tout champ < 16px : on force 16px sur mobile */
@media (max-width: 640px) {
  input, select, textarea { font-size: 16px; }
  .grid2 { grid-template-columns: 1fr; }            /* formulaires : 1 colonne sur téléphone */
  .grid2:has(.stat-card) { grid-template-columns: 1fr 1fr; }  /* sauf les compteurs du tableau parent */
  .time-row { grid-template-columns: repeat(2, 1fr); }        /* chips de minutes sur 2 colonnes */
  .mission { flex-wrap: wrap; }                     /* récompenses : boutons passent dessous sans déborder */
  .mission > .stack.tight { flex-direction: row; width: 100%; justify-content: flex-end; }
  .validate-row .slider-wrap { width: 100%; }
  .topbar h1 { font-size: 1.15rem; }
  .row3 { flex-wrap: wrap; }
  .row3 input:not(.tiny) { min-width: 140px; }
}
/* la barre d'onglets ne rétrécit jamais les 5 onglets parent au point de couper le texte */
.tabbar a { min-width: 0; flex: 1; max-width: 96px; }
.tabbar { gap: 2px; }

/* ---------------------------------------------------------------- avatars image */
.pavatar { overflow: hidden; }
.pavatar img, .ic-avatar img, .chip-av img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; display: block; }
.ic-avatar { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; overflow: hidden; font-size: 1.05rem; }
.chip-av { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; overflow: hidden; vertical-align: -5px; }
.avatar-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.avatar-tile { position: relative; border-radius: 50%; border: 3px solid transparent; cursor: pointer; aspect-ratio: 1; }
.avatar-tile img { width: 100%; height: 100%; border-radius: 50%; display: block; }
.avatar-tile input { position: absolute; opacity: 0; width: 0; height: 0; }
.avatar-tile:has(input:checked) { border-color: var(--gold); box-shadow: 0 0 0 2px color-mix(in srgb, var(--gold) 40%, transparent); }
@media (max-width: 400px) { .avatar-grid { grid-template-columns: repeat(4, 1fr); } }

/* ---------------------------------------------------------------- école */
.lesson h3 { margin: 14px 0 6px; color: var(--accent); }
.lesson p { margin: 0 0 8px; }
.lesson ul { margin: 0 0 10px; padding-left: 22px; }
.lesson li { margin-bottom: 4px; }
.drill-q { display: flex; flex-direction: row; align-items: center; gap: 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 8px 12px; }
.drill-op { font: 700 1.25rem 'Baloo 2', sans-serif; min-width: 118px; text-align: right; white-space: nowrap; }
.drill-q input { max-width: 130px; text-align: center; font-size: 1.1rem; font-weight: 600; }
.quiz-fix { border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.quiz-fix:last-child { border-bottom: 0; }

/* ---------------------------------------------------------------- contrat enfant */
.contract-link { display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 10px 14px; margin-bottom: 12px; border-radius: var(--radius);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent); color: var(--text); font-weight: 600; }
.contract-link span { color: var(--accent); font-size: .85rem; white-space: nowrap; }
.flash .why { color: inherit; text-decoration: underline; font-weight: 600; }
ul.rules { margin: 0; padding-left: 20px; }
ul.rules li { margin-bottom: 6px; }
.card.alert-soft { border-color: color-mix(in srgb, var(--gold) 45%, transparent);
  background: color-mix(in srgb, var(--gold) 8%, transparent); }

/* ---------------------------------------------------------------- tirelire */
.card.piggy { border-color: color-mix(in srgb, var(--gold) 45%, transparent);
  background: color-mix(in srgb, var(--gold) 8%, transparent); }
.deposit-row, .card.piggy .time-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(64px, 1fr)); gap: 8px; }
.withdraw-details { margin-top: 4px; }
.withdraw-details summary { cursor: pointer; list-style: none; }
.withdraw-details summary::-webkit-details-marker { display: none; }
.withdraw-details summary::before { content: '▸ '; }
.withdraw-details[open] summary::before { content: '▾ '; }

/* =====================================================================
   UNIVERS ENFANT — refonte "fun" (scopé body.child / body.kids)
   Le parent (body.parent) n'est pas affecté : il garde son ossature calme.
   ===================================================================== */

/* Formes plus rondes et ludiques */
body.child { --radius: 22px; }
body.child .card,
body.child .mission,
body.child .qcard { border-radius: var(--radius); }

/* --- Tuiles d'icônes des missions : carré arrondi en dégradé --- */
body.child .mic {
  width: 52px; height: 52px; font-size: 1.7rem;
  display: grid; place-items: center; border-radius: 16px;
  background: linear-gradient(140deg,
    color-mix(in srgb, var(--pc, var(--accent)) 30%, var(--card-solid)),
    color-mix(in srgb, var(--accent2) 24%, var(--card-solid)));
  box-shadow: 0 4px 12px color-mix(in srgb, var(--accent) 22%, transparent),
              inset 0 1px 0 #ffffff30;
  transition: transform .18s cubic-bezier(.34,1.56,.64,1);
}
body.child .mission { gap: 12px; padding: 12px 13px; border-width: 1.5px;
  transition: transform .16s ease, border-color .16s ease; }
body.child .mission:active { transform: scale(.985); }
body.child .mission:not(.done):active .mic { transform: rotate(-6deg) scale(1.06); }
body.child .cat > h2 {
  font-size: 1.15rem; letter-spacing: -.01em; display: flex; align-items: center; gap: 8px;
  padding-left: 2px;
}

/* --- HUD plus joyeux --- */
body.child .hud {
  border-radius: 26px; border-width: 1.5px;
  background:
    radial-gradient(120% 140% at 100% 0%, color-mix(in srgb, var(--accent2) 22%, transparent), transparent 60%),
    var(--card);
}
body.child .pavatar {
  border: 3px solid color-mix(in srgb, var(--pc, var(--accent)) 55%, transparent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--pc, var(--accent)) 16%, transparent);
}
body.child .hud-balance {
  background: linear-gradient(120deg, var(--gold), color-mix(in srgb, var(--gold) 60%, #ff8a00));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
body.child .lvlbar { height: 12px; }

/* --- Boutons enfant plus "pop" --- */
body.child .btn { border-radius: 16px; }
body.child .btn.primary { box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 45%, transparent); }
body.child .btn.big { border-radius: 18px; }

/* =====================================================================
   Carte "Question du jour" sur l'accueil
   ===================================================================== */
.daily-quiz {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px; margin-bottom: 12px;
  border-radius: 22px; color: #fff; position: relative; overflow: hidden;
  background: linear-gradient(120deg, var(--accent), var(--accent2));
  box-shadow: 0 8px 22px color-mix(in srgb, var(--accent) 38%, transparent);
}
.daily-quiz::after { /* reflet animé */
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(75deg, transparent 40%, #ffffff33 50%, transparent 60%);
  transform: translateX(-120%); animation: dq-shine 4.5s ease-in-out infinite;
}
.daily-quiz.done { background: linear-gradient(120deg,
  color-mix(in srgb, var(--green) 85%, #0a7), color-mix(in srgb, var(--green) 60%, var(--accent2))); }
.daily-quiz .dq-ic { font-size: 2rem; filter: drop-shadow(0 2px 3px #0003);
  animation: dq-bounce 2.4s ease-in-out infinite; }
.daily-quiz .dq-title { font: 800 1.12rem 'Baloo 2', sans-serif; }
.daily-quiz .dq-sub { font-size: .82rem; opacity: .95; }
.daily-quiz .dq-go { font: 700 .82rem 'Baloo 2', sans-serif; background: #ffffff2e;
  padding: 8px 12px; border-radius: 99px; white-space: nowrap; }
@keyframes dq-shine { 0%,60% { transform: translateX(-120%); } 100% { transform: translateX(120%); } }
@keyframes dq-bounce { 0%,100% { transform: translateY(0) rotate(-4deg); } 50% { transform: translateY(-4px) rotate(4deg); } }

/* =====================================================================
   Page Question du jour — carte de question + révélation
   ===================================================================== */
.qbanner { padding: 11px 15px; border-radius: 16px; margin-bottom: 12px; font-weight: 600;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 28%, transparent); }
.qbanner.soft { background: color-mix(in srgb, var(--gold) 12%, transparent);
  border-color: color-mix(in srgb, var(--gold) 30%, transparent); }

.qcard { background: var(--card); border: 1.5px solid var(--line); border-radius: 24px;
  padding: 18px; margin-bottom: 12px; }
.qcard .qcat { display: inline-flex; align-items: center; gap: 6px; font: 700 .78rem 'Baloo 2', sans-serif;
  color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent);
  padding: 4px 12px; border-radius: 99px; margin-bottom: 10px; }
.qcard .qcat-ic { font-size: 1rem; }
.qcard .qtext { font-size: 1.28rem; line-height: 1.3; margin: 4px 0 14px; }
.qchoices { display: flex; flex-direction: column; gap: 10px; }

.qopt { display: flex; align-items: center; gap: 12px; padding: 14px 15px; border-radius: 16px;
  border: 2px solid var(--line); background: var(--bg2); font-size: 1.02rem; cursor: pointer;
  transition: transform .14s ease, border-color .14s ease, background .14s ease; }
.qopt.pick:active { transform: scale(.98); }
.qopt.pick:has(input:checked) { border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, transparent); }
.qopt input { display: none; }
.qbullet { display: grid; place-items: center; width: 30px; height: 30px; flex-shrink: 0;
  border-radius: 10px; font: 800 .9rem 'Baloo 2', sans-serif; color: #fff;
  background: linear-gradient(140deg, var(--accent), var(--accent2)); }

/* révélation */
.qopt.ok { border-color: color-mix(in srgb, var(--green) 70%, transparent);
  background: color-mix(in srgb, var(--green) 16%, transparent); font-weight: 600; }
.qopt.ko { border-color: color-mix(in srgb, var(--red) 60%, transparent);
  background: color-mix(in srgb, var(--red) 13%, transparent); }
.qmark { width: 26px; text-align: center; font-size: 1.1rem; flex-shrink: 0; }
.qverdict { font: 800 1.05rem 'Baloo 2', sans-serif; margin-bottom: 8px; }
.reveal.good .qverdict { color: var(--green); }
.reveal.bad .qverdict { color: var(--gold); }
.reveal { animation: qpop .28s cubic-bezier(.34,1.56,.64,1); }
@keyframes qpop { from { transform: scale(.96); opacity: .4; } to { transform: scale(1); opacity: 1; } }

.qexp { display: flex; gap: 10px; margin-top: 14px; padding: 12px 14px; border-radius: 14px;
  background: color-mix(in srgb, var(--gold) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--gold) 28%, transparent); }
.qexp-ic { font-size: 1.2rem; flex-shrink: 0; }
.qxp { text-align: center; margin-top: 14px; }
.qxp .xp-pill.big { animation: qpop .4s .1s both cubic-bezier(.34,1.56,.64,1); }
.qactions { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }

/* petit feu d'artifice discret sur bonne réponse */
.reveal.good::before {
  content: "🎉"; position: absolute; font-size: 1.4rem; opacity: 0;
  animation: confetti 1.1s ease-out .05s 2;
}
.reveal { position: relative; }
@keyframes confetti { 0% { opacity: 0; transform: translateY(0) scale(.6); }
  20% { opacity: 1; } 100% { opacity: 0; transform: translateY(-40px) scale(1.2) rotate(25deg); } }

/* =====================================================================
   Sélecteur d'icônes (récompenses) — grille fermée type avatars
   ===================================================================== */
.icon-picker { display: flex; flex-direction: column; gap: 12px; }
.ip-group { display: flex; flex-direction: column; gap: 6px; }
.ip-label { font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.ip-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); gap: 8px; }
.ip-tile { position: relative; display: grid; place-items: center; aspect-ratio: 1;
  border-radius: 14px; border: 2px solid var(--line); background: var(--bg2); cursor: pointer;
  font-size: 1.5rem; transition: transform .12s ease, border-color .12s ease; }
.ip-tile:active { transform: scale(.93); }
.ip-tile input { position: absolute; opacity: 0; width: 0; height: 0; }
.ip-tile:has(input:checked) { border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 35%, transparent); }

/* =====================================================================
   Cartes de navigation (Réglages parent -> Contenus)
   ===================================================================== */
.nav-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.nav-card { display: flex; flex-direction: column; gap: 2px; padding: 14px; border-radius: 14px;
  background: var(--bg2); border: 1px solid var(--line); color: var(--text); }
.nav-card:active { border-color: var(--accent); }
.nav-card .nc-ic { font-size: 1.5rem; }
.nav-card .nc-t { font-weight: 700; font-family: 'Baloo 2', sans-serif; }
.nav-card .nc-s { font-size: .78rem; color: var(--muted); }

/* Ajout d'une question (parent) : ligne réponse = radio + champ */
.qrow { flex-direction: row; align-items: center; gap: 10px; }
.qrow .qradio { width: auto; flex-shrink: 0; }
@media (max-width: 400px) { .nav-cards { grid-template-columns: 1fr; } }

/* ================================================================ */
/* ============ v0.13 — UNIVERS ENFANT FUN + CULTURE ============== */
/* ================================================================ */

/* ---------- univers enfant : formes plus rondes, plus joueuses --- */
body.child { --radius: 22px; }
body.child .btn { border-radius: 18px; }
body.child .btn.primary { box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 45%, transparent); }
body.child .btn:not(:disabled):active { transform: translateY(1px) scale(.985); }

/* icônes de mission : pastilles carrées arrondies en dégradé, légère rotation alternée */
body.child .mission { border-width: 2px; }
body.child .mission .mic {
  width: 46px; height: 46px; display: grid; place-items: center;
  border-radius: 16px; font-size: 1.45rem;
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--accent) 30%, transparent),
    color-mix(in srgb, var(--accent2) 26%, transparent));
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
  transform: rotate(-3deg);
}
body.child .mission:nth-child(even) .mic {
  transform: rotate(3deg);
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--gold) 30%, transparent),
    color-mix(in srgb, var(--accent2) 22%, transparent));
  border-color: color-mix(in srgb, var(--gold) 30%, transparent);
}
body.child .mission:active .mic { animation: wobble .45s ease; }
@keyframes wobble {
  0% { transform: rotate(-3deg) scale(1); }
  30% { transform: rotate(5deg) scale(1.12); }
  60% { transform: rotate(-4deg) scale(1.05); }
  100% { transform: rotate(-3deg) scale(1); }
}
body.child .mission.done .mic { filter: grayscale(.35); }

/* HUD : halo doux + barre de niveau rayée animée */
body.child .hud {
  border-width: 2px;
  border-color: color-mix(in srgb, var(--pc) 35%, transparent);
  box-shadow: 0 8px 30px color-mix(in srgb, var(--pc) 16%, transparent);
}
body.child .lvlbar span {
  background:
    repeating-linear-gradient(45deg, #ffffff2e 0 8px, transparent 8px 16px),
    linear-gradient(90deg, var(--accent), var(--accent2));
  background-size: 200% 100%, 100% 100%;
  animation: stripes 2.2s linear infinite;
}
@keyframes stripes { to { background-position: 32px 0, 0 0; } }

/* titres de section enfant : petit soulignement joueur */
body.child .cat > h2 {
  display: inline-block; position: relative; padding-bottom: 3px;
}
body.child .cat > h2::after {
  content: ''; position: absolute; left: 0; right: 18%; bottom: 0; height: 5px;
  border-radius: 99px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--gold) 70%, transparent), transparent);
}

/* pastille XP qui "respire" quand on vient de gagner */
.bigicon.pop, body.child .xp-pill.big { animation: pop .5s cubic-bezier(.2,1.6,.4,1); }
@keyframes pop { from { transform: scale(.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ---------- carte "Question du jour" sur l'accueil enfant -------- */
.daily-quiz {
  display: flex; align-items: center; gap: 12px; padding: 13px 14px; margin-bottom: 12px;
  border-radius: var(--radius); color: var(--text);
  background:
    radial-gradient(120px 60px at 90% 0%, color-mix(in srgb, var(--gold) 22%, transparent), transparent 70%),
    color-mix(in srgb, var(--accent) 13%, transparent);
  border: 2px dashed color-mix(in srgb, var(--accent) 45%, transparent);
}
.daily-quiz .dq-ic {
  width: 46px; height: 46px; display: grid; place-items: center; font-size: 1.5rem;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-radius: 50% 40% 55% 45% / 50% 55% 45% 50%;   /* forme "blob" fun */
  flex-shrink: 0;
}
.daily-quiz .dq-title { font: 700 1.02rem 'Baloo 2', sans-serif; }
.daily-quiz .dq-sub { font-size: .8rem; color: var(--muted); }
.daily-quiz .dq-go {
  font: 700 .85rem 'Baloo 2', sans-serif; color: var(--accent); white-space: nowrap;
  padding: 7px 11px; border-radius: 12px;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
}
.daily-quiz.done { border-style: solid; border-color: color-mix(in srgb, var(--green) 40%, transparent);
  background: color-mix(in srgb, var(--green) 9%, transparent); }
.daily-quiz.done .dq-ic { background: linear-gradient(135deg, var(--green), color-mix(in srgb, var(--green) 55%, var(--accent))); }
.daily-quiz.done .dq-go { color: var(--green); background: color-mix(in srgb, var(--green) 13%, transparent); }

/* ---------- page Question du jour (body.kids) -------------------- */
.qbanner {
  padding: 11px 14px; border-radius: var(--radius); margin-bottom: 12px; font-weight: 600;
  background: color-mix(in srgb, var(--gold) 15%, transparent);
  border: 1px solid color-mix(in srgb, var(--gold) 38%, transparent);
}
.qbanner.soft { background: color-mix(in srgb, var(--accent) 11%, transparent);
  border-color: color-mix(in srgb, var(--accent) 30%, transparent); }

.qcard {
  display: flex; flex-direction: column; gap: 12px;
  background: var(--card); border: 2px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 12px; backdrop-filter: blur(8px);
}
.qcard.ask { border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.qcard.reveal.good { border-color: color-mix(in srgb, var(--green) 55%, transparent);
  box-shadow: 0 10px 34px color-mix(in srgb, var(--green) 18%, transparent); }
.qcard.reveal.bad { border-color: color-mix(in srgb, var(--gold) 50%, transparent); }

.qcat { display: inline-flex; align-items: center; gap: 7px; align-self: flex-start;
  font: 700 .8rem 'Baloo 2', sans-serif; text-transform: uppercase; letter-spacing: .05em;
  color: var(--accent); padding: 5px 11px; border-radius: 99px;
  background: color-mix(in srgb, var(--accent) 13%, transparent); }
.qcat-ic { font-size: 1rem; }
.qtext { font-size: 1.18rem; line-height: 1.35; margin: 0; }
.qverdict { font: 700 1.05rem 'Baloo 2', sans-serif; }
.qcard.reveal.good .qverdict { color: var(--green); }
.qcard.reveal.bad .qverdict { color: var(--gold); }

.qchoices { display: flex; flex-direction: column; gap: 9px; }
.qopt { display: flex; align-items: center; gap: 11px; padding: 12px 13px;
  border-radius: 16px; border: 2px solid var(--line); background: var(--bg2); color: var(--text); }
.qopt.pick { cursor: pointer; }
.qopt.pick:active { transform: scale(.99); }
.qopt.pick input { position: absolute; opacity: 0; width: 0; height: 0; }
.qopt.pick:has(input:checked) { border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 15%, transparent); }
.qbullet { display: grid; place-items: center; width: 28px; height: 28px; flex-shrink: 0;
  border-radius: 10px; font: 700 .85rem 'Baloo 2', sans-serif;
  background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }
.qopt.pick:has(input:checked) .qbullet { background: var(--accent); color: #fff; }
.qopt.ok { border-color: var(--green); background: color-mix(in srgb, var(--green) 13%, transparent); font-weight: 600; }
.qopt.ko { border-color: color-mix(in srgb, var(--red) 55%, transparent);
  background: color-mix(in srgb, var(--red) 10%, transparent); }
.qmark { width: 24px; flex-shrink: 0; text-align: center; }

.qexp { display: flex; gap: 10px; padding: 12px 13px; border-radius: 16px; line-height: 1.45;
  background: color-mix(in srgb, var(--gold) 10%, transparent);
  border: 1px dashed color-mix(in srgb, var(--gold) 42%, transparent); }
.qexp-ic { flex-shrink: 0; font-size: 1.15rem; }
.qxp { text-align: center; }
.qactions { display: flex; flex-direction: column; gap: 9px; }
.qactions form { display: contents; }

/* ---------- sélecteur d'icônes (récompenses) --------------------- */
.icon-picker { display: flex; flex-direction: column; gap: 10px; }
.ip-group { display: flex; flex-direction: column; gap: 5px; }
.ip-label { font-size: .76rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.ip-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); gap: 7px; }
.ip-tile { position: relative; display: grid; place-items: center; aspect-ratio: 1;
  font-size: 1.35rem; border-radius: 13px; border: 2px solid var(--line);
  background: var(--bg2); cursor: pointer; }
.ip-tile input { position: absolute; opacity: 0; width: 0; height: 0; }
.ip-tile:has(input:checked) { border-color: var(--gold);
  background: color-mix(in srgb, var(--gold) 14%, transparent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--gold) 35%, transparent); }
.ip-tile:active { transform: scale(.94); }

/* ---------- cartes de navigation (réglages parent) --------------- */
.nav-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.nav-card { display: flex; flex-direction: column; gap: 3px; padding: 12px;
  border-radius: 14px; border: 1px solid var(--line); background: var(--bg2); color: var(--text); }
.nav-card:active { border-color: var(--accent); }
.nav-card .nc-ic { font-size: 1.4rem; }
.nav-card .nc-t { font-weight: 700; font-size: .92rem; }
.nav-card .nc-s { font-size: .74rem; color: var(--muted); line-height: 1.3; }
@media (max-width: 400px) { .nav-cards { grid-template-columns: 1fr; } }

/* ---------- formulaire d'ajout de question (parent) -------------- */
.qrow { display: flex; flex-direction: row; align-items: center; gap: 10px; }
.qrow .qradio { width: 20px; height: 20px; flex-shrink: 0; accent-color: var(--green); }

/* ---------- divers ------------------------------------------------ */
body.child .empty { font-size: 1rem; }

/* sous-titres de catégorie dans la boutique enfant */
.shop-cat { margin: 14px 0 7px; font-size: .92rem; color: var(--muted);
  font-family: 'Baloo 2', sans-serif; }
.shop-cat:first-of-type { margin-top: 4px; }

/* ===== v0.14 : série culture + En savoir plus ===== */
.cstreak {
  margin-left: auto; font-weight: 800; font-size: .95rem;
  background: color-mix(in srgb, var(--warn, #f59e0b) 18%, var(--card));
  border: 1px solid color-mix(in srgb, var(--warn, #f59e0b) 45%, transparent);
  border-radius: 999px; padding: .25rem .7rem; white-space: nowrap;
}
.dq-flame {
  font-size: .8em; font-weight: 800; vertical-align: middle;
  background: color-mix(in srgb, var(--warn, #f59e0b) 20%, var(--card));
  border-radius: 999px; padding: .1rem .5rem; margin-left: .3rem;
}
.qstreak-note { margin-top: .5rem; font-size: .9rem; font-weight: 600; }
.qstreak-note.muted { font-weight: 500; }

.qmore {
  margin-top: .8rem; border: 1px dashed var(--border);
  border-radius: var(--r-md, 12px); background: color-mix(in srgb, var(--accent) 6%, var(--card));
}
.qmore summary {
  cursor: pointer; padding: .7rem .9rem; font-weight: 700; list-style: none;
  user-select: none;
}
.qmore summary::-webkit-details-marker { display: none; }
.qmore summary::after { content: " ▾"; opacity: .6; }
.qmore[open] summary::after { content: " ▴"; }
.qmore-body {
  padding: 0 .9rem .9rem; line-height: 1.55; font-size: .95rem;
}
body.child.kids .qmore summary { font-size: 1rem; }

/* ---- Icônes SVG des catégories culture (v0.15) ---- */
.cat-svg { display: inline-flex; align-items: center; justify-content: center;
  color: var(--catc, currentColor); flex-shrink: 0; }
.cat-svg svg { width: 1.15em; height: 1.15em; display: block; }
.qcat .qcat-ic .cat-svg svg { width: 1.05rem; height: 1.05rem; }
.mic .cat-svg { width: 34px; height: 34px; border-radius: 10px;
  background: color-mix(in srgb, var(--catc) 14%, transparent); }
.mic .cat-svg svg { width: 19px; height: 19px; }
.chip .cat-svg svg { width: .95em; height: .95em; vertical-align: -0.12em; }
.chip .cat-svg { display: inline-flex; vertical-align: middle; margin-right: 2px; }
.seph .cat-svg svg { width: 1em; height: 1em; }
.seph .cat-svg { vertical-align: -0.12em; }

/* ---- Icônes SVG des menus (v0.16) ---- */
.app-ic { width: 1.25em; height: 1.25em; display: block; }
.tabbar .ic { display: flex; align-items: center; justify-content: center; height: 24px; }
.tabbar .ic .app-ic { width: 22px; height: 22px; }
.tabbar a.on .app-ic { stroke-width: 2.3; }
.nav-card .nc-ic { display: flex; align-items: center; }
.nav-card .nc-ic .app-ic { width: 26px; height: 26px; color: var(--accent, currentColor); }

/* ---- Dashboard parent (v0.17 UX refresh) ---- */
.dashboard-kpi { margin-bottom: 8px; }
.stat-card.soft { background: var(--bg2); border-color: var(--bd); opacity: .95; }
.section-title { font-size: 1rem; color: var(--muted); margin: 18px 4px 4px; letter-spacing: .04em; text-transform: uppercase; font-weight: 700; }
.child-card { border-left: 4px solid var(--pc, var(--accent)); }
.child-card .grow { flex: 1; min-width: 0; }
.badge-level { display: inline-block; margin-left: 8px; padding: 2px 8px; border-radius: 99px;
  background: color-mix(in srgb, var(--pc, var(--accent)) 20%, transparent);
  color: var(--pc, var(--accent)); font-size: .75rem; font-weight: 700; vertical-align: middle; }
.level-bar { height: 8px; background: var(--bg2); border-radius: 99px; overflow: hidden; }
.level-bar-fill { height: 100%; background: linear-gradient(90deg, var(--pc, var(--accent)), color-mix(in srgb, var(--pc, var(--accent)) 60%, #fff));
  transition: width .6s ease; }
.child-metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; text-align: center; }
.child-metrics .metric { display: flex; flex-direction: column; padding: 8px 4px; background: var(--bg2); border-radius: 12px; }
.child-metrics .metric b { font-size: 1.1rem; line-height: 1.1; }
.child-metrics .metric i { font-style: normal; font-size: .7rem; color: var(--muted); margin-top: 2px; }
.child-metrics .metric.hot { background: color-mix(in srgb, #ff8a5b 15%, var(--bg2)); }
.child-metrics .metric.ok { background: color-mix(in srgb, #4ade80 15%, var(--bg2)); }
.tirelire { padding: 10px 12px; background: color-mix(in srgb, var(--accent) 10%, var(--bg2)); border-radius: 12px; }
.tirelire.full { background: color-mix(in srgb, #4ade80 20%, var(--bg2)); }
.mini-bar { height: 6px; background: rgba(255,255,255,.15); border-radius: 99px; margin-top: 6px; overflow: hidden; }
.mini-bar-fill { height: 100%; background: var(--accent); transition: width .6s ease; }
.child-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---- Chat familial (v0.18, layout WhatsApp v0.18.11) ----
   Sur la page chat_thread : le shell prend toute la hauteur, la fenêtre de messages
   scroll à l'intérieur, la composer est FIXÉE juste au-dessus de la tabbar. */
body.chat-page .shell { padding-bottom: 0; padding-top: 0; height: 100dvh;
  display: flex; flex-direction: column; overflow: hidden; }
body.chat-page .topbar { padding: calc(10px + env(safe-area-inset-top)) 4px 8px; margin: 0; flex-shrink: 0; }

.chat-thread-row { border-left: 4px solid var(--pc, var(--accent)); text-decoration: none; color: inherit; }
.chat-preview { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.chat-unread { display: inline-block; min-width: 20px; height: 20px; line-height: 20px; padding: 0 6px;
  background: #ff5b5b; color: #fff; border-radius: 99px; font-size: .75rem; font-weight: 700; text-align: center; margin-left: 6px; }

/* Fenêtre de messages : prend l'espace restant, scroll INTERNE.
   Le padding-bottom laisse la place pour la composer sticky. */
.chat-window { flex: 1 1 auto; display: flex; flex-direction: column; gap: 6px;
  padding: 12px; overflow-y: auto; -webkit-overflow-scrolling: touch;
  background: var(--bg2); border-radius: 12px 12px 0 0; min-height: 0; }
.chat-msg { display: flex; flex-direction: column; max-width: 80%; }
.chat-msg.mine { align-self: flex-end; align-items: flex-end; }
.chat-msg.his { align-self: flex-start; align-items: flex-start; }
.chat-bubble { padding: 8px 12px; border-radius: 14px; word-break: break-word; line-height: 1.35; }
.chat-msg.mine .chat-bubble { background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.chat-msg.his  .chat-bubble { background: var(--bg); color: var(--text); border-bottom-left-radius: 4px; border: 1px solid var(--bd); }
.chat-bubble.deleted { opacity: .55; font-style: italic; background: var(--bg2) !important; color: var(--muted) !important; border: 1px dashed var(--bd) !important; }
.chat-meta { margin-top: 2px; font-size: .7rem; }

/* Composer FIXÉE juste au-dessus de la tabbar (qui fait ~80px + safe-area). */
.chat-composer { flex-shrink: 0; background: var(--bg);
  padding: 8px 12px calc(84px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--bd); box-shadow: 0 -6px 14px rgba(0,0,0,.15);
  display: flex; flex-direction: column; gap: 6px; }
.chat-composer-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: end; }
.chat-composer textarea[name=body] {
  width: 100%;
  /* 1 ligne au départ, max ~4 lignes = ~4 × line-height 1.35 × 1rem + padding = ~110px */
  min-height: 42px; max-height: 110px;
  padding: 10px 12px; font-family: inherit; font-size: 1rem; line-height: 1.35;
  border-radius: 18px; border: 1px solid var(--bd); background: var(--bg2); color: var(--text);
  resize: none; overflow-y: auto; -webkit-appearance: none; appearance: none;
  box-sizing: border-box; margin: 0; display: block;
}
.chat-composer textarea[name=body]::placeholder { color: var(--muted); opacity: .8; }
.chat-composer textarea[name=body]:focus { outline: 2px solid color-mix(in srgb, var(--accent) 40%, transparent); border-color: var(--accent); }
.chat-send { width: 44px; height: 44px; padding: 0; border-radius: 50%; font-size: 1.2rem; line-height: 1;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.chat-emoji-bar { display: flex; flex-wrap: nowrap; gap: 4px; padding: 0; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.emoji-btn { padding: 4px 8px; border: 1px solid var(--bd); background: var(--bg2); border-radius: 10px;
  font-size: 1.15rem; cursor: pointer; line-height: 1; flex-shrink: 0; }
.emoji-btn:hover { background: var(--bg); }
/* ---- SOS ---- */
.sos-card { border: 2px solid color-mix(in srgb, #ff5b5b 60%, transparent); background: color-mix(in srgb, #ff5b5b 8%, var(--bg2)); }
.sos-buttons { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.sos-btn { padding: 16px 6px; font-size: 1.6rem; line-height: 1.2; background: var(--bg); border: 1px solid var(--bd); cursor: pointer; }
.sos-btn b { display: block; font-size: .8rem; margin-top: 4px; }
.sos-btn:hover { background: color-mix(in srgb, #ff5b5b 12%, var(--bg)); border-color: #ff5b5b; }
/* ---- Modération ---- */
.mod-msg { padding: 10px 12px; border-radius: 10px; background: var(--bg2); border-left: 3px solid var(--accent); margin-bottom: 6px; }
.mod-msg.deleted { opacity: .55; border-left-color: var(--muted); }
.mod-msg-body { margin: 6px 0; }

/* ---- Chat : actions par bulle + édition inline (v0.18.5) ---- */
.chat-bubble-wrap { position: relative; display: inline-block; max-width: 100%; }
.chat-msg.mine .chat-bubble-wrap { align-self: flex-end; }
.chat-bubble[data-toggle-meta] { cursor: pointer; }

/* Croix (supprimer) coin haut-droit, crayon (modifier) coin haut-gauche —
   symétriques, même style rond mini. Toujours semi-visibles pour découvrabilité. */
.chat-del-x, .chat-edit-x { position: absolute; top: -8px; margin: 0; padding: 0;
  z-index: 2; line-height: 1; text-decoration: none; }
.chat-del-x  { right: -8px; }
.chat-edit-x { left: -8px; }
.chat-del-x button, .chat-edit-x {
  width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--bd);
  background: var(--bg2); color: var(--muted); font-size: 14px; cursor: pointer;
  padding: 0; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 1px 4px rgba(0,0,0,.25); text-decoration: none;
  opacity: .5; transition: opacity .15s, transform .15s, color .15s, border-color .15s;
}
.chat-msg:hover .chat-del-x button, .chat-msg:hover .chat-edit-x { opacity: 1; }
.chat-del-x button:hover  { color: #ff5b5b;      border-color: #ff5b5b;      transform: scale(1.15); }
.chat-edit-x:hover        { color: var(--accent); border-color: var(--accent); transform: scale(1.15); }
@media (hover: none) {
  .chat-msg.mine .chat-del-x button,
  .chat-msg.mine .chat-edit-x { opacity: .85; }
}

.chat-edited { font-size: .7rem; opacity: .7; font-style: italic; }
.chat-meta[hidden] { display: none; }

.chat-edit-form { display: flex; flex-direction: column; gap: 6px; width: 100%; max-width: 100%; }
.chat-edit-form textarea { width: 100%; min-height: 60px; padding: 8px 12px; border-radius: 14px;
  border: 1px solid var(--accent); background: var(--bg2); color: var(--text); font: inherit;
  font-size: 1rem; line-height: 1.35; resize: vertical; box-sizing: border-box; }
.chat-edit-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* ---- Bravo sans XP (v0.19) ---- */
.praise-card { border-left: 4px solid #f472b6; background: color-mix(in srgb, #f472b6 8%, var(--bg2)); }
.praise-line { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--bd); }
.praise-line:last-child { border-bottom: 0; }
.praise-heart { font-size: 1.4rem; line-height: 1.2; }
.praise-details { margin-top: 8px; }
.praise-details summary { list-style: none; cursor: pointer; }
.praise-details summary::-webkit-details-marker { display: none; }
.praise-details textarea { width: 100%; padding: 8px 12px; border-radius: 12px;
  border: 1px solid var(--bd); background: var(--bg2); color: var(--text); font: inherit; font-size: .95rem;
  resize: vertical; box-sizing: border-box; }

/* ---- Expériences (v0.19) ---- */
.exp-section { border-left: 4px solid #f472b6; padding-left: 10px; background: color-mix(in srgb, #f472b6 5%, transparent);
  border-radius: 12px; margin-bottom: 12px; }
.mission.reward.exp { border: 1px solid color-mix(in srgb, #f472b6 40%, transparent); }
.check-inline { display: flex; align-items: flex-start; gap: 8px; padding: 10px; background: var(--bg2);
  border-radius: 12px; margin: 8px 0; cursor: pointer; }
.check-inline input { flex-shrink: 0; margin-top: 3px; }

/* ---- Chat photos (v0.19) ---- */
.chat-bubble.has-photo { padding: 4px; }
.chat-photo { display: block; max-width: 100%; max-height: 320px; border-radius: 10px;
  object-fit: cover;
  /* Activer l'appui long iOS (menu Enregistrer / Copier / Partager)
     et empêcher le drag desktop involontaire. */
  -webkit-touch-callout: default;
  -webkit-user-select: none; user-select: none;
  pointer-events: auto; }
.chat-photo-link { display: block; line-height: 0; }
.chat-attach { display: inline-flex; width: 44px; height: 44px; border-radius: 50%;
  background: var(--bg2); border: 1px solid var(--bd); color: var(--text);
  font-size: 1.2rem; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; }
.chat-attach:hover { background: var(--bg); border-color: var(--accent); }
.chat-attach.uploading { opacity: .5; pointer-events: none; }
.chat-composer-row { grid-template-columns: auto 1fr auto; }

/* ---- Photo : preview avant envoi + bouton download (v0.19.2) ---- */
.chat-photo-wrap { position: relative; display: inline-block; }
.chat-photo-dl { position: absolute; top: 6px; right: 6px; width: 32px; height: 32px;
  border-radius: 50%; background: rgba(0,0,0,.55); color: #fff; font-size: 1rem;
  display: flex; align-items: center; justify-content: center; text-decoration: none;
  transition: background .15s, transform .15s; z-index: 2; }
.chat-photo-dl:hover { background: rgba(0,0,0,.8); transform: scale(1.1); }

/* Preview avant envoi (overlay full-width en bas, au-dessus de la composer) */
.chat-photo-preview { position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  background: rgba(0,0,0,.85); backdrop-filter: blur(10px);
  padding: 12px 12px calc(12px + env(safe-area-inset-bottom));
  border-top: 2px solid var(--accent); animation: slide-up .2s ease-out; }
@keyframes slide-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
.chat-photo-preview-inner { max-width: 640px; margin: 0 auto; position: relative;
  display: flex; flex-direction: column; gap: 10px; align-items: center; }
.chat-photo-preview .chat-photo-cancel { position: absolute; top: -6px; right: -6px;
  width: 30px; height: 30px; border-radius: 50%; background: #fff; color: #333;
  border: 0; font-size: 20px; line-height: 1; cursor: pointer; z-index: 3;
  box-shadow: 0 2px 8px rgba(0,0,0,.4); }
#chat-photo-preview-img { max-width: 100%; max-height: 40vh; border-radius: 12px; object-fit: contain; }
#chat-photo-caption { width: 100%; padding: 10px 14px; border-radius: 20px;
  border: 1px solid var(--bd); background: var(--bg2); color: var(--text);
  font-family: inherit; font-size: 1rem; box-sizing: border-box; }
.chat-photo-preview-actions { display: flex; gap: 8px; width: 100%; justify-content: flex-end; }
.chat-photo-preview-actions .btn { padding: 10px 18px; }
