/* Neurone — style « appli Apple iOS 26 » (repris de Carrés : fond groupé, cartes inset grouped,
   séparateurs décalés, dégradé de teinte par onglet, barre d'onglets flottante, feuilles). */
:root {
  --bg: #f2f2f7; --card: #fff; --card2: #f2f2f7; --fg: #000; --muted: rgba(118,118,128,.12); --muted-fg: #6c6c70;
  --sep: rgba(60,60,67,.22); --blue: #0071e3; --blue-fill: #0071e3; --blue-text: #005bb8; --green: #34c759; --green-text: #1f7a37;
  --red: #ff3b30; --red-text: #d70015; --orange: #ff9500; --purple: #af52de; --indigo: #5856d6; --pink: #ff2d55; --teal: #30b0c7;
  --spring: cubic-bezier(.32,1.4,.6,1);
  --wash-a: rgba(88,86,214,.28); --wash-b: rgba(0,122,255,.22);
  color-scheme: light;
}
html[data-tab="words"] { --wash-a: rgba(52,199,89,.28); --wash-b: rgba(48,176,199,.26); }
html[data-tab="talk"] { --wash-a: rgba(175,82,222,.24); --wash-b: rgba(255,45,85,.2); }
html[data-tab="settings"] { --wash-a: rgba(142,142,147,.24); --wash-b: rgba(0,122,255,.16); }
html[data-dark] {
  color-scheme: dark;
  --bg: #000; --card: #1c1c1e; --card2: #2c2c2e; --fg: #fff; --muted: rgba(118,118,128,.24); --muted-fg: #98989f;
  --sep: rgba(84,84,88,.6); --blue: #0a84ff; --blue-text: #409cff; --green-text: #30d158; --red-text: #ff6961; --orange: #ff9f0a;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { min-height: 100%; background: var(--bg); }
html, body { margin: 0; color: var(--fg); font: 17px/1.4 "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-feature-settings: "cv11", "ss01"; letter-spacing: -.2px; -webkit-font-smoothing: antialiased; }
html, body, button, a, input, textarea, label { touch-action: manipulation; }
body { padding: calc(env(safe-area-inset-top) + 16px) 16px calc(env(safe-area-inset-bottom) + 110px); max-width: 560px; margin: 0 auto;
  min-height: 100vh; min-height: 100dvh; }
body::before { content: ""; position: fixed; left: 0; right: 0; top: 0; height: 46vh; z-index: -1; pointer-events: none;
  background: radial-gradient(70% 90% at 0% 0%, var(--wash-a), transparent 70%), radial-gradient(70% 90% at 100% 10%, var(--wash-b), transparent 70%);
  -webkit-mask-image: linear-gradient(#000 40%, transparent); mask-image: linear-gradient(#000 40%, transparent); transition: background .6s; }
html::after { content: ""; position: fixed; left: 0; right: 0; top: 0; height: env(safe-area-inset-top); z-index: 7; pointer-events: none;
  background: linear-gradient(rgba(255,255,255,.35), rgba(255,255,255,0)); }
html[data-dark]::after { background: linear-gradient(rgba(0,0,0,.35), rgba(0,0,0,0)); }
svg.lucide { width: 20px; height: 20px; stroke-width: 2; flex-shrink: 0; }
.hidden { display: none !important; }
button { font: inherit; color: inherit; letter-spacing: inherit; }

/* Titres */
header.page { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 8px 4px 18px; }
.eyebrow { font-size: 13px; font-weight: 600; color: var(--muted-fg); text-transform: uppercase; letter-spacing: .2px; }
h1 { font-size: 34px; line-height: 1.1; margin: 2px 0 0; letter-spacing: -.8px; font-weight: 700; }
.section-title { font-size: 20px; font-weight: 700; letter-spacing: -.3px; margin: 26px 4px 10px; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.section-title small { font-size: 15px; font-weight: 500; color: var(--muted-fg); letter-spacing: -.1px; }
.compact-bar { display: flex; align-items: flex-end; justify-content: center; position: fixed; left: 0; right: 0; top: 0; z-index: 5;
  height: calc(env(safe-area-inset-top) + 44px); padding-bottom: 11px; font-weight: 600; font-size: 17px;
  background: rgba(242,242,247,.9); -webkit-backdrop-filter: blur(6px) saturate(140%); backdrop-filter: blur(6px) saturate(140%);
  border-bottom: .5px solid rgba(60,60,67,.18); opacity: 0; transform: translateY(-6px); pointer-events: none; transition: opacity .2s, transform .2s; }
html[data-dark] .compact-bar { background: rgba(18,18,18,.9); border-bottom-color: rgba(84,84,88,.5); }
.compact-bar.show { opacity: 1; transform: none; }

/* Cartes et listes */
.card { background: var(--card); border-radius: 22px; padding: 16px; margin-bottom: 12px; }
section:not(.hidden) .card { animation: rise .45s var(--spring) both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
.muted { color: var(--muted-fg); }
.small { font-size: 15px; }
.row { display: flex; align-items: center; gap: 12px; }
.grow { flex: 1; min-width: 0; }
.list { padding: 4px 0 4px 16px; }
.list-row { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 8px 16px 8px 0; position: relative; width: 100%;
  background: none; border: 0; text-align: left; cursor: pointer; }
.list-row + .list-row::before { content: ""; position: absolute; top: 0; right: 0; left: 44px; height: .5px; background: var(--sep); }
.list.plain .list-row + .list-row::before { left: 0; }
.list-row .t { font-weight: 500; }
.list-row .s { font-size: 15px; color: var(--muted-fg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-row > .chev { color: #c4c4c7; width: 18px; }
html[data-dark] .list-row > .chev { color: #5a5a5e; }
.ico { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; color: #fff; flex-shrink: 0; }
.ico svg.lucide { width: 18px; height: 18px; }

/* Boutons capsule */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border: 0; border-radius: 999px;
  font-size: 17px; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; transition: transform .3s var(--spring), opacity .15s; }
.btn:active { transform: scale(.95); opacity: .8; }
.btn:disabled { opacity: .4; pointer-events: none; }
.btn-primary { background: var(--blue-fill); color: #fff; }
.btn-secondary { background: var(--muted); color: var(--blue-text); }
.btn-ghost { background: transparent; color: var(--blue-text); }
.btn-danger { background: var(--muted); color: var(--red-text); }
.btn-block { width: 100%; height: 52px; }
.btn-icon { width: 44px; height: 44px; padding: 0; }
.btn-round { width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%; display: grid; place-items: center; cursor: pointer; background: var(--card); color: var(--blue-text); }
.btn-row { display: flex; gap: 10px; }
.btn-row > .btn { flex: 1; }

/* Champs */
input, textarea { width: 100%; font: inherit; color: var(--fg); background: var(--muted); border: 0; border-radius: 12px; min-height: 44px; padding: 10px 14px; font-size: 17px; outline: none; }
html[data-dark] input, html[data-dark] textarea { background: var(--card2); }
input:focus, textarea:focus { box-shadow: 0 0 0 2px var(--blue); }
label.field { display: block; font-size: 13px; color: var(--muted-fg); text-transform: uppercase; letter-spacing: .2px; font-weight: 500; margin: 14px 4px 6px; }
label.field:first-child { margin-top: 0; }
.search { position: relative; margin-bottom: 12px; }
.search svg.lucide { position: absolute; left: 12px; top: 12px; color: var(--muted-fg); width: 20px; }
.search input { padding-left: 40px; background: var(--muted); }
html[data-dark] .search input { background: var(--card); }

/* Contrôle segmenté */
.seg { display: flex; background: var(--muted); border-radius: 12px; padding: 2px; }
.seg button { flex: 1; height: 44px; border: 0; background: none; border-radius: 10px; font-size: 15px; font-weight: 500; cursor: pointer; padding: 0 4px; }
.seg button.on { background: var(--card); font-weight: 600; box-shadow: 0 3px 8px rgba(0,0,0,.12), 0 3px 1px rgba(0,0,0,.04); }
html[data-dark] .seg button.on { background: #636366; }

/* Interrupteur iOS */
.switch { appearance: none; -webkit-appearance: none; width: 51px; min-width: 51px; height: 31px; min-height: 31px; padding: 0; border-radius: 999px; background: rgba(120,120,128,.24);
  position: relative; cursor: pointer; transition: background .25s; margin: 0; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff;
  box-shadow: 0 3px 8px rgba(0,0,0,.15), 0 3px 1px rgba(0,0,0,.06); transition: transform .3s var(--spring); }
.switch:checked { background: var(--green); }
.switch:checked::after { transform: translateX(20px); }
.switch:focus { box-shadow: none; }

/* Pastilles (chips) */
.chips { display: flex; gap: 8px; overflow-x: auto; margin: 0 -16px 12px; padding: 0 16px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips.wrap { flex-wrap: wrap; overflow: visible; margin: 0 0 12px; padding: 0; }
.chip { position: relative; flex-shrink: 0; height: 36px; padding: 0 14px; border: 0; border-radius: 999px; background: var(--card); font-size: 15px; font-weight: 500; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.chip.on { background: var(--blue-fill); color: #fff; }
.chip::after { content: ""; position: absolute; left: 0; right: 0; top: -4px; bottom: -4px; } /* zone tactile de 44 px */
.chip svg.lucide { width: 16px; height: 16px; }

/* Barre d'onglets flottante iOS 26 */
nav { position: fixed; z-index: 10; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 10px); transform: translateX(-50%);
  width: min(92vw, 360px); display: flex; padding: 5px; gap: 2px; border-radius: 999px;
  background: rgba(250,250,252,.62); -webkit-backdrop-filter: blur(24px) saturate(200%); backdrop-filter: blur(24px) saturate(200%);
  box-shadow: inset 0 .5px 0 rgba(255,255,255,.9), 0 0 0 .5px rgba(0,0,0,.06), 0 10px 30px -8px rgba(0,0,0,.2);
  transition: transform .5s var(--spring), opacity .3s; }
nav.away, body.typing nav { transform: translate(-50%, 140%); opacity: 0; pointer-events: none; }
nav button { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 2px; border: 0; background: none; cursor: pointer;
  border-radius: 999px; padding: 7px 0; color: #1c1c1e; font-size: 10.5px; letter-spacing: -.2px; white-space: nowrap; font-weight: 600; letter-spacing: 0; position: relative; transition: background .3s, color .2s; }
nav button svg.lucide { width: 22px; height: 22px; }
nav button.active { color: var(--blue-text); background: rgba(118,118,128,.14); }
nav .badge { position: absolute; top: 4px; left: calc(50% + 7px); width: 9px; height: 9px; border-radius: 50%; background: var(--red); }
html[data-dark] nav { background: rgba(30,30,32,.72); box-shadow: inset 0 .5px 0 rgba(255,255,255,.12), 0 0 0 .5px rgba(255,255,255,.08), 0 10px 30px -8px rgba(0,0,0,.6); }
html[data-dark] nav button { color: #e5e5ea; }
html[data-dark] nav button.active { color: var(--blue-text); background: rgba(118,118,128,.3); }

/* Feuille (sheet) */
.dim { position: fixed; inset: 0; background: rgba(0,0,0,.25); z-index: 20; opacity: 0; pointer-events: none; transition: opacity .3s; }
.dim.show { opacity: 1; pointer-events: auto; }
.sheet { position: fixed; left: 8px; right: 8px; bottom: 8px; margin: 0 auto; max-width: 544px; z-index: 21; max-height: 88vh; overflow: auto;
  border-radius: 32px; padding: 0 18px calc(env(safe-area-inset-bottom) + 18px); background: var(--card);
  box-shadow: 0 -10px 40px rgba(0,0,0,.12); animation: sheetUp .45s var(--spring); }
html[data-dark] .sheet { background: #1c1c1e; }
@keyframes sheetUp { from { transform: translateY(100%); } }
.sheet-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin: 0 -18px 8px; padding: 18px 8px 6px; background: inherit; background: var(--card); }
html[data-dark] .sheet-head { background: #1c1c1e; }
.sheet-head::before { content: ""; position: absolute; top: 6px; left: 50%; width: 36px; height: 5px; margin-left: -18px; border-radius: 3px; background: rgba(60,60,67,.3); }
.sheet-head b { font-size: 17px; flex: 1; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sheet-head .btn, .sheet-head > span { padding: 0 10px; width: 84px; flex-shrink: 0; }
.sheet .group { background: var(--card2); border-radius: 16px; padding: 12px 14px; margin-bottom: 12px; }
html[data-dark] .sheet input, html[data-dark] .sheet textarea { background: var(--card2); }
.big-word { font-size: 34px; font-weight: 700; letter-spacing: -.8px; line-height: 1.1; overflow-wrap: anywhere; }

/* Toast */
.toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 84px); z-index: 40; display: flex; align-items: center; gap: 8px;
  max-width: calc(100vw - 32px); padding: 12px 18px; border-radius: 999px; background: rgba(28,28,30,.92); color: #fff; font-size: 15px; font-weight: 600;
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); opacity: 0; pointer-events: none;
  transform: translate(-50%, 16px) scale(.92); transition: opacity .25s, transform .5s var(--spring); }
.toast.show { opacity: 1; transform: translate(-50%, 0) scale(1); pointer-events: auto; }
.toast .undo { background: none; border: 0; color: #64d2ff; font-weight: 700; padding: 0 0 0 6px; min-height: 32px; cursor: pointer; }
html[data-dark] .toast { background: rgba(58,58,60,.95); }
body.sheet-open .toast, body.lesson-open .toast { top: calc(env(safe-area-inset-top) + 10px); bottom: auto; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
.chip-muted { background: var(--muted); }
