:root {
    --bg: #f4f1fa;
    --surface: #ffffff;
    --ink: #1d1a2b;
    --muted: #675f80;
    --line: #e1dcf0;
    --accent: #5b45d6;
    --accent-ink: #ffffff;
    --accent-soft: #ebe7fb;
    --error: #b3261e;
    --error-soft: #fdeceb;
    --ok: #1d7a4d;
    --ok-soft: #e4f5ec;
    --radius: 14px;
    --font: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #14112a;
        --surface: #1e1a3a;
        --ink: #ece9fb;
        --muted: #a59fc6;
        --line: #302a58;
        --accent: #9b8cff;
        --accent-ink: #14112a;
        --accent-soft: #2a2455;
        --error: #ff8f87;
        --error-soft: #3a1c28;
        --ok: #62d49a;
        --ok-soft: #173a2b;
    }
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font);
    font-size: 17px;
    line-height: 1.55;
}

a { color: var(--accent); }

/* En-tête */
.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; max-width: 960px; margin: 0 auto; padding: 16px 20px; }
.brand { font-weight: 800; font-size: 1.4rem; color: var(--accent); text-decoration: none; letter-spacing: .02em; }
.nav { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.nav a:not(.btn) { color: var(--ink); text-decoration: none; font-weight: 600; }
.nav a:not(.btn):hover { color: var(--accent); }

.page { max-width: 640px; margin: 0 auto; padding: 8px 16px 48px; display: grid; gap: 16px; }
.page:has(.hero) { max-width: 960px; }

/* Boutons */
.btn {
    display: inline-block;
    font: inherit;
    font-weight: 700;
    padding: 12px 22px;
    border: 2px solid var(--accent);
    border-radius: 999px;
    background: var(--accent);
    color: var(--accent-ink);
    text-decoration: none;
    text-align: center;
    cursor: pointer;
}
.btn-small { padding: 7px 16px; font-size: .95rem; }
.btn-ghost { background: transparent; color: var(--accent); }
button.btn { width: 100%; }
.narrate button.btn, .actions .btn { width: auto; }

/* Messages */
.flash { margin: 0; padding: 12px 16px; border-radius: 10px; }
ul.flash { padding-left: 32px; }
.flash-error { background: var(--error-soft); color: var(--error); }
.flash-success { background: var(--ok-soft); color: var(--ok); }
.errors { margin: 0 0 14px; padding: 12px 16px 12px 32px; background: var(--error-soft); color: var(--error); border-radius: 10px; }

/* Cartes et formulaires */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
.card h1 { margin: 0 0 14px; font-size: 1.5rem; line-height: 1.25; }
.card h2 { margin: 0 0 10px; font-size: 1.1rem; }

.form { display: grid; gap: 16px; }
.form label { display: grid; gap: 6px; font-weight: 600; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], select {
    width: 100%;
    font: inherit;
    padding: 11px 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--bg);
    color: var(--ink);
}
input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
input[type="range"] { width: 100%; padding: 0; accent-color: var(--accent); }
.check-line { display: flex !important; align-items: center; gap: 10px; font-weight: 400 !important; }
.check-line input { width: 1.1rem; height: 1.1rem; accent-color: var(--accent); }
.hint { color: var(--muted); font-weight: 400; font-size: .85rem; }
.muted { color: var(--muted); font-size: .9rem; }

/* Champ mot de passe avec bouton œil */
.password-field { position: relative; display: block; }
.password-field input { padding-right: 2.9rem; }
.pw-toggle {
    position: absolute; top: 50%; right: .35rem; transform: translateY(-50%);
    display: grid; place-items: center; width: 2.25rem; height: 2.25rem; padding: 0;
    border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer;
}
.pw-toggle:hover { color: var(--ink); }
.pw-toggle .eye-off { display: none; }
.pw-toggle[aria-pressed="true"] .eye-on { display: none; }
.pw-toggle[aria-pressed="true"] .eye-off { display: block; }

/* Connexion et inscription */
.auth { max-width: 24rem; width: 100%; margin: 1.5rem auto 0; display: grid; gap: 1rem; }
.auth h1 { margin: 0; text-align: center; font-size: 1.6rem; }
.auth-lead, .auth-switch { margin: 0; text-align: center; color: var(--muted); }
.auth-switch { font-size: .95rem; }

/* Accueil public */
.hero { display: grid; grid-template-columns: 1fr; gap: 32px; align-items: center; padding: 24px 0 8px; }
.hero-text h1 { margin: 0 0 14px; font-size: clamp(1.9rem, 5vw, 2.8rem); line-height: 1.15; text-wrap: balance; }
.hero-lead { margin: 0 0 22px; font-size: 1.15rem; color: var(--muted); max-width: 34rem; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; margin: 0; }

.sample {
    margin: 0;
    padding: 24px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 20px;
    transform: rotate(-1.2deg);
}
.sample p { margin: 0 0 .8em; font-size: 1.05rem; line-height: 1.7; }
.sample-title { font-weight: 800; font-size: 1.2rem !important; line-height: 1.3 !important; }
.sample mark { background: var(--accent-soft); color: var(--accent); font-weight: 800; padding: 0 .2em; border-radius: 4px; }
.sample figcaption { color: var(--muted); font-size: .85rem; margin-top: 4px; }

.steps { margin-top: 24px; }
.steps h2 { margin: 0 0 14px; font-size: 1.4rem; }
.steps-list { list-style: none; counter-reset: step; margin: 0 0 24px; padding: 0; display: grid; gap: 14px; }
.steps-list li { counter-increment: step; position: relative; padding: 16px 18px 16px 62px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.steps-list li::before {
    content: counter(step);
    position: absolute; left: 16px; top: 14px;
    display: grid; place-items: center; width: 34px; height: 34px;
    border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-weight: 800;
}

@media (min-width: 760px) {
    .hero { grid-template-columns: 1.1fr .9fr; gap: 48px; }
    .steps-list { grid-template-columns: repeat(3, 1fr); }
    .steps-list li { padding: 62px 18px 18px; }
    .steps-list li::before { left: 18px; top: 18px; }
}

/* Histoires */
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.list li { display: grid; gap: 2px; }
.list a { color: var(--accent); font-weight: 700; text-decoration: none; }

.story p { font-size: 1.15rem; line-height: 1.75; margin: 0 0 1em; }
.story .muted { margin: 0 0 20px; }
.actions { margin-top: 24px; }

.player { width: 100%; margin: 0 0 22px; }
.narrate { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin: 0 0 22px; }
