/* ==========================================================================
   MIRIADE Wild — Design system
   Feuille de base partagée par index.html, library.html et shared.html.
   Thème clair par défaut, thème sombre via <html data-theme="dark">.
   ========================================================================== */

/* ---------- 1. Tokens ---------------------------------------------------- */
:root {
    color-scheme: light;

    --font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --font-display: 'Fraunces', 'Georgia', 'Times New Roman', serif;

    /* Surfaces & encre */
    --bg: #f6f2ea;
    --bg-2: #efe9de;
    --surface: #ffffff;
    --surface-2: #faf7f1;
    --surface-3: #f1ece2;
    --ink: #1c1a33;
    --ink-2: #4e4c66;
    --ink-3: #8a889f;
    --line: #e7e1d6;
    --line-2: #d4cdbe;

    /* Couleurs de marque */
    --primary: #4f46e5;
    --primary-2: #4338ca;
    --primary-soft: #ebe9fd;
    --primary-ink: #3730a3;
    --on-primary: #ffffff;
    --violet: #7c3aed;
    --accent: #f59e0b;
    --accent-soft: #fff3d1;
    --accent-ink: #92400e;
    --success: #15803d;
    --success-soft: #dcfce7;
    --danger: #dc2626;
    --danger-soft: #fee2e2;
    --warn: #d97706;
    --warn-soft: #fef3c7;
    --info: #2563eb;
    --info-soft: #dbeafe;

    --grad-primary: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    --grad-warm: linear-gradient(135deg, #f59e0b 0%, #f43f5e 100%);
    --grad-cover: linear-gradient(160deg, #312e81 0%, #7c3aed 55%, #db2777 100%);

    --shadow-1: 0 1px 2px rgba(28, 26, 51, .06), 0 1px 3px rgba(28, 26, 51, .05);
    --shadow-2: 0 4px 14px rgba(28, 26, 51, .08), 0 2px 4px rgba(28, 26, 51, .04);
    --shadow-3: 0 18px 44px -14px rgba(28, 26, 51, .25);
    --shadow-4: 0 34px 80px -24px rgba(28, 26, 51, .38);
    --ring: 0 0 0 4px rgba(79, 70, 229, .18);

    --r-sm: 8px;
    --r: 12px;
    --r-lg: 18px;
    --r-xl: 26px;
    --r-pill: 999px;

    --ease: cubic-bezier(.2, .8, .2, 1);
    --t-fast: .15s;
    --t: .25s;
    --t-slow: .45s;

    --header-h: 68px;
    --container: 1180px;

    /* Grain papier (SVG inline, aucun fichier externe) */
    --paper: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .55 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0f0e1b;
    --bg-2: #141327;
    --surface: #1a1930;
    --surface-2: #1f1e38;
    --surface-3: #272645;
    --ink: #ecebfb;
    --ink-2: #b9b7d3;
    --ink-3: #807e9d;
    --line: #2b2a48;
    --line-2: #3b3a62;

    --primary: #818cf8;
    --primary-2: #a5b4fc;
    --primary-soft: #26254a;
    --primary-ink: #c7d2fe;
    --on-primary: #0f0e1b;
    --accent: #fbbf24;
    --accent-soft: #3a2d10;
    --accent-ink: #fde68a;
    --success: #4ade80;
    --success-soft: #0f2e1c;
    --danger: #f87171;
    --danger-soft: #3b1414;
    --warn: #fbbf24;
    --warn-soft: #3a2a10;
    --info: #60a5fa;
    --info-soft: #172554;

    --shadow-1: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-2: 0 4px 14px rgba(0, 0, 0, .45);
    --shadow-3: 0 18px 44px -14px rgba(0, 0, 0, .7);
    --shadow-4: 0 34px 80px -24px rgba(0, 0, 0, .8);
    --ring: 0 0 0 4px rgba(129, 140, 248, .28);
}

/* ---------- 2. Reset & base --------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
    margin: 0;
    font-family: var(--font-sans);
    font-size: 15.5px;
    line-height: 1.6;
    color: var(--ink);
    background: var(--bg);
    background-image:
        radial-gradient(1200px 600px at 10% -10%, rgba(124, 58, 237, .10), transparent 60%),
        radial-gradient(900px 500px at 100% 0%, rgba(245, 158, 11, .10), transparent 55%);
    background-attachment: fixed;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color var(--t), color var(--t);
}
[data-theme="dark"] body {
    background-image:
        radial-gradient(1200px 600px at 10% -10%, rgba(124, 58, 237, .22), transparent 60%),
        radial-gradient(900px 500px at 100% 0%, rgba(245, 158, 11, .10), transparent 55%);
}
h1, h2, h3, h4, h5 { margin: 0; line-height: 1.2; font-weight: 700; color: var(--ink); }
p { margin: 0; }
a { color: var(--primary); }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
::selection { background: var(--primary-soft); color: var(--primary-ink); }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.container {
    width: 100%;
    max-width: var(--container);
    margin: 0 auto;
    padding: 0 clamp(16px, 4vw, 32px);
}
.main-content { flex: 1; padding-bottom: 64px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- 3. Header --------------------------------------------------- */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: color-mix(in srgb, var(--surface) 82%, transparent);
    backdrop-filter: saturate(160%) blur(14px);
    -webkit-backdrop-filter: saturate(160%) blur(14px);
    border-bottom: 1px solid var(--line);
    margin-bottom: clamp(24px, 4vw, 40px);
}
.header-content {
    max-width: var(--container);
    margin: 0 auto;
    padding: 0 clamp(16px, 4vw, 32px);
    height: var(--header-h);
    display: flex;
    align-items: center;
    gap: 20px;
}
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--ink);
    flex-shrink: 0;
}
.brand-mark {
    width: 38px; height: 38px;
    border-radius: 11px;
    display: grid; place-items: center;
    background: var(--grad-primary);
    color: #fff;
    font-size: 1.15rem;
    box-shadow: 0 6px 16px -6px rgba(79, 70, 229, .7);
    transition: transform var(--t) var(--ease);
}
.brand:hover .brand-mark { transform: rotate(-6deg) scale(1.05); }
.brand-name {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.25rem;
    letter-spacing: -.01em;
    line-height: 1;
}
.brand-name em { font-style: italic; font-weight: 500; color: var(--primary); }
.brand-sub { display: block; font-size: .68rem; color: var(--ink-3); letter-spacing: .06em; text-transform: uppercase; margin-top: 3px; font-family: var(--font-sans); font-weight: 600; }

.nav { display: flex; gap: 4px; margin-left: 8px; }
.nav-link {
    text-decoration: none;
    color: var(--ink-2);
    font-weight: 500;
    padding: 8px 14px;
    border-radius: var(--r-pill);
    transition: background var(--t-fast), color var(--t-fast);
    white-space: nowrap;
}
.nav-link:hover { background: var(--surface-3); color: var(--ink); }
.nav-link.active { background: var(--primary-soft); color: var(--primary-ink); font-weight: 600; }

.header-spacer { flex: 1; }
.user-section { display: flex; align-items: center; gap: 10px; }
.auth-buttons { display: flex; gap: 8px; }
.user-info { display: flex; align-items: center; gap: 10px; }
.user-credits {
    display: inline-flex; align-items: center; gap: 6px;
    background: var(--accent-soft); color: var(--accent-ink);
    padding: 6px 12px; border-radius: var(--r-pill);
    font-size: .85rem; font-weight: 600;
    border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
}
.user-credits.pulse { animation: creditPulse .6s var(--ease); }
@keyframes creditPulse { 0% { transform: scale(1); } 40% { transform: scale(1.12); } 100% { transform: scale(1); } }
.user-menu { position: relative; }
.user-avatar {
    width: 38px; height: 38px; border-radius: 50%;
    border: 2px solid var(--surface);
    background: var(--grad-primary); color: #fff;
    font-weight: 700; font-size: .8rem;
    box-shadow: var(--shadow-2);
    display: grid; place-items: center;
    transition: transform var(--t-fast);
}
.user-avatar:hover { transform: scale(1.06); }
.user-dropdown {
    position: absolute; top: calc(100% + 10px); right: 0;
    min-width: 230px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-3);
    overflow: hidden;
    z-index: 200;
    animation: popIn .18s var(--ease);
}
@keyframes popIn { from { opacity: 0; transform: translateY(-6px) scale(.98); } to { opacity: 1; transform: none; } }
.user-dropdown .user-email {
    padding: 12px 16px; font-size: .85rem; color: var(--ink-2);
    background: var(--surface-2); border-bottom: 1px solid var(--line);
    word-break: break-all;
}
.user-dropdown .user-email strong { display: block; color: var(--ink); font-size: .9rem; }
.user-dropdown a {
    display: flex; align-items: center; gap: 10px;
    padding: 11px 16px; text-decoration: none; color: var(--ink); font-size: .9rem;
    transition: background var(--t-fast);
}
.user-dropdown a:hover { background: var(--surface-3); }
.user-dropdown a.danger { color: var(--danger); }

.icon-btn {
    width: 38px; height: 38px; border-radius: 50%;
    border: 1px solid var(--line); background: var(--surface);
    display: grid; place-items: center; font-size: 1rem; color: var(--ink-2);
    transition: background var(--t-fast), transform var(--t-fast), color var(--t-fast);
}
.icon-btn:hover { background: var(--surface-3); color: var(--ink); transform: translateY(-1px); }

/* ---------- 4. Boutons ---------------------------------------------------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 11px 18px;
    border-radius: var(--r);
    border: 1px solid transparent;
    font-weight: 600; font-size: .95rem; line-height: 1.2;
    text-decoration: none; white-space: nowrap;
    transition: transform var(--t-fast) var(--ease), box-shadow var(--t-fast), background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
    user-select: none;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; transform: none !important; box-shadow: none !important; }
.btn-primary {
    background: var(--grad-primary); color: #fff;
    box-shadow: 0 8px 20px -8px rgba(79, 70, 229, .7);
}
.btn-primary:hover { box-shadow: 0 12px 26px -8px rgba(79, 70, 229, .8); transform: translateY(-1px); filter: brightness(1.05); }
.btn-secondary { background: var(--surface-3); color: var(--ink); border-color: var(--line); }
.btn-secondary:hover { background: var(--line); }
.btn-outline { background: var(--surface); color: var(--ink); border-color: var(--line-2); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary-ink); background: var(--primary-soft); }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-3); color: var(--ink); }
.btn-danger { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-sm { padding: 7px 12px; font-size: .85rem; border-radius: var(--r-sm); }
.btn-lg { padding: 15px 26px; font-size: 1.05rem; border-radius: var(--r-lg); }
.btn-block { width: 100%; }
.btn .spinner { width: 14px; height: 14px; border-width: 2px; margin: 0; }

/* ---------- 5. Hero ------------------------------------------------------- */
.hero {
    display: grid;
    grid-template-columns: 1.15fr .85fr;
    gap: 32px;
    align-items: center;
    margin-bottom: clamp(24px, 4vw, 40px);
}
body.has-story .hero { display: none; }
.hero-eyebrow {
    display: inline-flex; align-items: center; gap: 8px;
    font-size: .74rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
    color: var(--primary-ink); background: var(--primary-soft);
    padding: 6px 12px; border-radius: var(--r-pill);
    margin-bottom: 16px;
}
.hero h1 {
    font-family: var(--font-display);
    font-size: clamp(2rem, 4.2vw, 3.2rem);
    font-weight: 700;
    letter-spacing: -.02em;
    line-height: 1.08;
    margin-bottom: 14px;
}
.hero h1 em { font-style: italic; font-weight: 500; background: var(--grad-primary); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p { color: var(--ink-2); font-size: 1.05rem; max-width: 56ch; }
.hero-stats { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.hero-stat {
    display: inline-flex; align-items: center; gap: 8px;
    background: var(--surface); border: 1px solid var(--line);
    padding: 8px 14px; border-radius: var(--r-pill); font-size: .85rem; color: var(--ink-2);
    box-shadow: var(--shadow-1);
}
.hero-stat strong { color: var(--ink); }

.hero-art {
    position: relative;
    height: 380px;
    perspective: 1200px;
}
.hero-book {
    position: absolute; inset: 0; margin: auto;
    width: 236px; height: 296px;
    transform-style: preserve-3d;
    transform: rotateY(-22deg) rotateX(6deg);
    animation: floatBook 7s ease-in-out infinite;
}
@keyframes floatBook { 0%, 100% { transform: rotateY(-22deg) rotateX(6deg) translateY(0); } 50% { transform: rotateY(-18deg) rotateX(4deg) translateY(-10px); } }
.hero-book .cover {
    position: absolute; inset: 0;
    border-radius: 6px 16px 16px 6px;
    background: var(--grad-cover);
    box-shadow: var(--shadow-4), inset 0 0 0 1px rgba(255, 255, 255, .15);
    display: flex; flex-direction: column; justify-content: flex-end;
    padding: 22px;
    color: #fff;
    overflow: hidden;
}
.hero-book .cover::before {
    content: ''; position: absolute; inset: 0; background: var(--paper); opacity: .25; mix-blend-mode: overlay;
}
.hero-book .cover::after {
    content: ''; position: absolute; left: 14px; top: 0; bottom: 0; width: 2px;
    background: rgba(255, 255, 255, .25);
}
.hero-book .cover h3 { font-family: var(--font-display); font-size: 1.35rem; color: #fff; line-height: 1.15; position: relative; }
.hero-book .cover span { font-size: .72rem; opacity: .8; letter-spacing: .08em; text-transform: uppercase; margin-top: 8px; position: relative; }
.hero-book .cover .sun { position: absolute; top: 26px; right: 26px; width: 58px; height: 58px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fde68a, #f59e0b); box-shadow: 0 0 40px rgba(245, 158, 11, .6); }
.hero-book .pages {
    position: absolute; top: 6px; bottom: 6px; right: -10px; width: 14px;
    background: repeating-linear-gradient(to bottom, #fff 0 2px, #e8e2d6 2px 3px);
    border-radius: 0 4px 4px 0;
    transform: translateZ(-8px);
}
.hero-chip {
    position: absolute;
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--r-lg); padding: 10px 14px;
    box-shadow: var(--shadow-3);
    font-size: .8rem; display: flex; align-items: center; gap: 8px;
    animation: floatChip 6s ease-in-out infinite;
}
.hero-chip.a { left: 0; top: 3%; animation-delay: -1s; }
.hero-chip.b { right: 0; top: 46%; animation-delay: -3s; }
.hero-chip.c { left: 2%; bottom: 2%; animation-delay: -5s; }
.hero-chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); }
@keyframes floatChip { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }

/* ---------- 6. Studio (formulaire) ---------------------------------------- */
.studio {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-xl);
    box-shadow: var(--shadow-3);
    overflow: hidden;
    margin-bottom: clamp(24px, 4vw, 40px);
}
body.has-story .studio { display: none; }
.studio::before {
    content: ''; position: absolute; inset: 0 0 auto 0; height: 5px;
    background: var(--grad-primary);
}
.studio-head {
    display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
    padding: 22px clamp(18px, 3vw, 32px) 0;
}
.studio-head h2 { font-family: var(--font-display); font-size: 1.45rem; font-weight: 700; letter-spacing: -.01em; }
.studio-head p { color: var(--ink-3); font-size: .9rem; margin-top: 2px; }

.segmented {
    display: inline-flex; gap: 2px;
    background: var(--surface-3); border: 1px solid var(--line);
    padding: 4px; border-radius: var(--r-pill);
}
.seg-btn {
    border: 0; background: transparent; color: var(--ink-2);
    padding: 8px 16px; border-radius: var(--r-pill);
    font-weight: 600; font-size: .9rem;
    transition: background var(--t-fast), color var(--t-fast), box-shadow var(--t-fast);
}
.seg-btn.active { background: var(--surface); color: var(--primary-ink); box-shadow: var(--shadow-1); }
.seg-btn:hover:not(.active) { color: var(--ink); }

.form-section { display: none; padding: 20px clamp(18px, 3vw, 32px) clamp(18px, 3vw, 28px); }
.form-section.active { display: block; animation: fadeUp .35s var(--ease); }
.form-section.hiding { animation: fadeDown .3s var(--ease) forwards; }
.form-section.hidden { display: none; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fadeDown { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateY(-8px); } }

.auth-warning {
    display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
    background: var(--warn-soft); color: var(--accent-ink);
    border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent);
    border-radius: var(--r-lg); padding: 14px 16px; margin-bottom: 18px;
    animation: fadeUp .3s var(--ease);
}
.auth-warning h4 { font-size: .95rem; color: inherit; }
.auth-warning p { font-size: .88rem; flex: 1; min-width: 200px; }

.text-section { display: grid; gap: 18px; }
.selectors-section { margin-top: 22px; padding-top: 22px; border-top: 1px dashed var(--line-2); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px; align-items: start; }
.form-group { display: flex; flex-direction: column; gap: 8px; position: relative; }
.form-group label {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: .78rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2);
}
.form-group label .hint {
    display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%;
    background: var(--surface-3); color: var(--ink-3); font-size: .68rem; font-weight: 700; cursor: help;
    text-transform: none; letter-spacing: 0;
}
.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="number"],
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 13px 15px;
    border: 1.5px solid var(--line-2);
    border-radius: var(--r);
    background: var(--surface-2);
    color: var(--ink);
    transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
}
.form-group input:hover, .form-group textarea:hover, .form-group select:hover { border-color: var(--ink-3); }
.form-group input:focus, .form-group textarea:focus, .form-group select:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); background: var(--surface); }
.form-group textarea { min-height: 110px; resize: vertical; line-height: 1.55; }
textarea.auto-resize { overflow: hidden; resize: none; }
.form-group ::placeholder { color: var(--ink-3); }
.form-group select {
    appearance: none; -webkit-appearance: none;
    padding-right: 42px; cursor: pointer;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%238a889f' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.8' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 14px center; background-repeat: no-repeat; background-size: 18px;
}
.form-group select option:disabled { color: var(--ink-3); }
.form-group input.invalid, .form-group textarea.invalid { border-color: var(--danger); }
.field-error { display: none; color: var(--danger); font-size: .82rem; padding: 6px 10px; background: var(--danger-soft); border-radius: var(--r-sm); }
.field-error:not(:empty) { display: block; }
.shake { animation: shakeX .35s ease-in-out; }
@keyframes shakeX { 0%, 100% { transform: none; } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

/* Saisie du thème avec micro / caméra */
.input-with-mic { display: flex; gap: 10px; align-items: stretch; }
.input-with-mic textarea { flex: 1; min-height: 120px; }
.input-buttons { display: flex; flex-direction: column; gap: 8px; }
.mic-btn, .camera-btn {
    width: 48px; height: 48px; border-radius: var(--r);
    border: 1px solid var(--line-2); background: var(--surface);
    display: grid; place-items: center; color: var(--ink-2);
    position: relative; overflow: hidden;
    transition: background var(--t-fast), color var(--t-fast), transform var(--t-fast), border-color var(--t-fast);
}
.mic-btn:hover, .camera-btn:hover { background: var(--primary-soft); color: var(--primary-ink); border-color: var(--primary); transform: translateY(-1px); }
.mic-icon, .camera-icon { width: 20px; height: 20px; }
.mic-btn.recording { background: var(--danger); border-color: var(--danger); color: #fff; animation: micPulse 1.4s infinite; }
@keyframes micPulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, .45); } 50% { box-shadow: 0 0 0 10px rgba(220, 38, 38, 0); } }
.mic-btn.processing, .camera-btn.processing { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); cursor: wait; }
.camera-btn.processing::after {
    content: ''; position: absolute; inset: 0; margin: auto; width: 18px; height: 18px;
    border: 2px solid transparent; border-top-color: currentColor; border-radius: 50%; animation: spin 1s linear infinite;
}
.theme-tools { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.theme-suggestions { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
    border: 1px solid var(--line-2); background: var(--surface); color: var(--ink-2);
    border-radius: var(--r-pill); padding: 5px 11px; font-size: .8rem; font-weight: 500;
    transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast), transform var(--t-fast);
}
.chip:hover { background: var(--primary-soft); border-color: var(--primary); color: var(--primary-ink); transform: translateY(-1px); }
.form-group select.stt-lang-select {
    width: auto; max-width: 150px; padding: 5px 30px 5px 10px; font-size: .78rem;
    background-color: transparent; border-color: transparent; color: var(--ink-3);
    background-size: 14px; background-position: right 10px center;
}
.form-group select.stt-lang-select:hover, .form-group select.stt-lang-select:focus { border-color: var(--line-2); color: var(--ink); box-shadow: none; }

.style-hint {
    display: none; font-size: .8rem; color: var(--primary-ink); background: var(--primary-soft);
    border-left: 3px solid var(--primary); border-radius: 0 var(--r-sm) var(--r-sm) 0; padding: 7px 10px;
    animation: fadeUp .2s var(--ease);
}
.custom-art-style-input-container { display: none; }
.custom-art-style-input-container textarea { width: 100%; min-height: 70px; }
.credit-preview { font-size: .82rem; min-height: 1.2em; }
.credit-preview .ok { color: var(--success); }
.credit-preview .warn { color: var(--warn); }
.credit-preview .ko { color: var(--danger); }

.form-actions {
    display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
    margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line);
}
.form-actions .btn-primary { flex: 1; min-width: 220px; }
.form-actions .kbd-hint { font-size: .78rem; color: var(--ink-3); margin-left: auto; }
kbd { font-family: var(--font-sans); font-size: .72rem; background: var(--surface-3); border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 5px; padding: 1px 6px; color: var(--ink-2); }

/* ---------- 7. Chargement / génération ------------------------------------ */
.loading {
    display: none;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-xl);
    box-shadow: var(--shadow-3); padding: clamp(24px, 4vw, 40px);
    margin-bottom: clamp(24px, 4vw, 40px); text-align: center;
    position: relative; overflow: hidden;
}
.loading.active { display: block; animation: fadeUp .35s var(--ease); }
.loading::before { content: ''; position: absolute; inset: 0 0 auto 0; height: 5px; background: var(--grad-warm); }
.loading-book {
    width: 84px; height: 60px; margin: 6px auto 18px; position: relative; perspective: 600px;
}
.loading-book span {
    position: absolute; left: 50%; top: 0; width: 40px; height: 56px;
    background: var(--surface-2); border: 1.5px solid var(--line-2); border-radius: 3px 8px 8px 3px;
    transform-origin: left center; transform: rotateY(0deg);
    box-shadow: var(--shadow-1);
}
.loading-book span:nth-child(1) { animation: flip 1.8s ease-in-out infinite; }
.loading-book span:nth-child(2) { animation: flip 1.8s ease-in-out .3s infinite; }
.loading-book span:nth-child(3) { animation: flip 1.8s ease-in-out .6s infinite; }
.loading-book::before { content: ''; position: absolute; left: 50%; top: 0; width: 40px; height: 56px; background: var(--primary-soft); border: 1.5px solid var(--line-2); border-radius: 8px 3px 3px 8px; transform: translateX(-100%); }
@keyframes flip { 0% { transform: rotateY(0); } 50%, 100% { transform: rotateY(-180deg); } }
.generation-steps { display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.gen-step {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 14px; border-radius: var(--r-pill);
    background: var(--surface-3); color: var(--ink-3); font-size: .85rem; font-weight: 600;
    border: 1px solid transparent;
    transition: all var(--t);
}
.gen-step .step-icon { font-size: 1rem; }
.gen-step.active { background: var(--primary-soft); color: var(--primary-ink); border-color: var(--primary); animation: stepPulse 1.4s ease-in-out infinite; }
.gen-step.done { background: var(--success-soft); color: var(--success); }
.gen-step.done .step-icon::after { content: ' ✓'; }
.step-arrow { color: var(--line-2); }
@keyframes stepPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.04); } }
#loading-text { color: var(--ink-2); font-size: .95rem; margin-bottom: 14px; min-height: 1.5em; }
.progress-bar { height: 10px; background: var(--surface-3); border-radius: var(--r-pill); overflow: hidden; margin: 0 auto 14px; max-width: 560px; position: relative; }
.progress-fill {
    height: 100%; width: 0; border-radius: var(--r-pill);
    background: var(--grad-primary);
    transition: width .45s var(--ease);
    position: relative; overflow: hidden;
}
.progress-fill::after {
    content: ''; position: absolute; inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .45), transparent);
    animation: shimmer 1.6s linear infinite;
}
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
.loading-meta { display: flex; justify-content: center; gap: 18px; font-size: .82rem; color: var(--ink-3); flex-wrap: wrap; }
.loading-actions { margin-top: 18px; }

/* ---------- 8. Espace histoire ------------------------------------------- */
.story-display { display: none; scroll-margin-top: calc(var(--header-h) + 16px); }
.story-display.active { display: block; animation: fadeUp .35s var(--ease); }
.story-controls {
    position: sticky; top: calc(var(--header-h) + 8px); z-index: 50;
    display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--line); border-radius: var(--r-lg);
    padding: 10px 12px; margin-bottom: 22px;
    box-shadow: var(--shadow-2);
    visibility: hidden;
}
.story-display.ready .story-controls { visibility: visible; }
.toolbar-group { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.story-controls .btn { padding: 8px 12px; font-size: .88rem; }
.badge {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 5px 10px; border-radius: var(--r-pill);
    background: var(--surface-3); color: var(--ink-2); font-size: .78rem; font-weight: 600;
    max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.book-container { display: flex; flex-direction: column; gap: 26px; }
.book-title { text-align: center; padding: 8px 0 6px; }
.book-title h1 { font-family: var(--font-display); font-size: clamp(1.7rem, 3.4vw, 2.6rem); letter-spacing: -.02em; }
.book-title p { color: var(--ink-3); margin-top: 6px; font-size: .9rem; }

/* Double page */
.book-page {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-xl);
    box-shadow: var(--shadow-2);
    overflow: hidden;
    transition: box-shadow var(--t) var(--ease), transform var(--t) var(--ease);
    animation: fadeUp .4s var(--ease);
}
.book-page::after {
    content: ''; position: absolute; inset: 0; pointer-events: none;
    background: var(--paper); opacity: .18; mix-blend-mode: multiply;
}
[data-theme="dark"] .book-page::after { mix-blend-mode: screen; opacity: .06; }
.book-page:hover { box-shadow: var(--shadow-3); transform: translateY(-2px); }
.page-image {
    position: relative; min-height: 320px; background: var(--surface-3);
    display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.page-image img { width: 100%; height: 100%; object-fit: cover; transition: transform .6s var(--ease); }
.page-image:hover img { transform: scale(1.03); }
.page-image.loading { background: linear-gradient(100deg, var(--surface-3) 30%, var(--surface-2) 50%, var(--surface-3) 70%); background-size: 200% 100%; animation: skeleton 1.4s linear infinite; }
@keyframes skeleton { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.loading-placeholder, .image-placeholder, .error-placeholder {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
    color: var(--ink-3); font-size: .9rem; padding: 24px; text-align: center;
}
.error-placeholder { color: var(--danger); }
.btn-retry-image { margin-top: 6px; }
.image-loader {
    position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
    background: color-mix(in srgb, var(--surface) 80%, transparent); backdrop-filter: blur(3px); z-index: 5; color: var(--ink-2); font-size: .9rem;
}
.image-controls {
    position: absolute; left: 12px; right: 12px; bottom: 12px; z-index: 6;
    display: flex; gap: 6px; flex-wrap: wrap; justify-content: center;
    opacity: 0; transform: translateY(6px);
    transition: opacity var(--t), transform var(--t);
}
.page-image:hover .image-controls, .page-image:focus-within .image-controls { opacity: 1; transform: none; }
.image-controls button {
    border: 0; border-radius: var(--r-pill); padding: 7px 12px; font-size: .78rem; font-weight: 600;
    background: rgba(255, 255, 255, .92); color: #1c1a33;
    backdrop-filter: blur(8px); box-shadow: var(--shadow-2);
    transition: transform var(--t-fast), background var(--t-fast);
}
.image-controls button:hover { transform: translateY(-1px); background: #fff; }
.image-controls .btn-edit-image { background: var(--primary); color: #fff; }
.image-controls .btn-regenerate-image:hover { background: var(--accent-soft); }
.version-indicator {
    position: absolute; top: 12px; right: 12px; z-index: 6;
    background: rgba(28, 26, 51, .75); color: #fff; font-size: .7rem; font-weight: 700;
    padding: 3px 8px; border-radius: var(--r-pill); backdrop-filter: blur(6px);
}
.book-page .page-text {
    position: relative; padding: clamp(22px, 3vw, 36px) clamp(22px, 3vw, 40px);
    display: flex; flex-direction: column; justify-content: center; gap: 12px;
}
.book-page .page-text::before {
    content: attr(data-page-label);
    font-size: .72rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3);
}
.page-title-container, .page-text-container { position: relative; display: flex; align-items: flex-start; gap: 10px; }
.page-title-container { align-items: center; }
.page-title { font-family: var(--font-display); font-size: clamp(1.3rem, 2.2vw, 1.75rem); font-weight: 700; letter-spacing: -.01em; }
.page-title-container .page-title, .page-text-container .page-content { flex: 1; }
.page-content {
    font-family: var(--font-display); font-size: 1.08rem; line-height: 1.75; color: var(--ink-2);
    text-align: left; margin: 0;
}
.page-content::first-letter { font-size: 2.6em; float: left; line-height: .85; padding: 4px 8px 0 0; color: var(--primary); font-weight: 700; }
.page-error { color: var(--danger); font-size: .85rem; background: var(--danger-soft); padding: 8px 10px; border-radius: var(--r-sm); }
.btn-edit-title, .btn-edit-text {
    flex-shrink: 0; width: 30px; height: 30px; border-radius: 50%;
    border: 1px solid var(--line-2); background: var(--surface); color: var(--ink-2); font-size: .8rem;
    opacity: 0; transition: opacity var(--t-fast), background var(--t-fast), transform var(--t-fast);
}
.book-page:hover .btn-edit-title, .book-page:hover .btn-edit-text, .btn-edit-title:focus, .btn-edit-text:focus { opacity: .8; }
.btn-edit-title:hover, .btn-edit-text:hover { opacity: 1 !important; background: var(--primary-soft); color: var(--primary-ink); border-color: var(--primary); transform: scale(1.06); }
.page-title-input, .page-text-textarea {
    width: 100%; padding: 10px 12px; border: 1.5px solid var(--primary); border-radius: var(--r);
    background: var(--surface-2); color: var(--ink); box-shadow: var(--ring);
    font-family: var(--font-display); line-height: 1.6;
}
.page-title-input { font-size: 1.25rem; font-weight: 700; }
.page-text-textarea { min-height: 160px; resize: vertical; font-size: 1rem; }
.edit-buttons { display: flex; gap: 8px; margin-top: 8px; width: 100%; }
.btn-save-title, .btn-save-text { background: var(--success); color: #fff; border: 0; border-radius: var(--r-sm); padding: 7px 12px; font-weight: 600; font-size: .85rem; }
.btn-cancel-title, .btn-cancel-text { background: var(--surface-3); color: var(--ink); border: 1px solid var(--line-2); border-radius: var(--r-sm); padding: 7px 12px; font-weight: 600; font-size: .85rem; }
.edit-hint { font-size: .75rem; color: var(--ink-3); align-self: center; margin-left: auto; }

@media (hover: none) {
    .image-controls { opacity: 1; transform: none; }
    .btn-edit-title, .btn-edit-text { opacity: .8; }
}

/* ---------- 9. Modales ---------------------------------------------------- */
.modal, .modal-overlay {
    position: fixed; inset: 0; z-index: 2000;
    display: none; align-items: center; justify-content: center; padding: 16px;
    background: rgba(15, 14, 27, .55);
    backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
    animation: fadeIn .2s ease;
}
.modal.show, .modal[style*="display: flex"], .modal-overlay { display: flex; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-content {
    width: 100%; max-width: 520px; max-height: 90vh; min-width: 0;
    background: var(--surface); color: var(--ink);
    border: 1px solid var(--line); border-radius: var(--r-xl);
    box-shadow: var(--shadow-4);
    display: flex; flex-direction: column; overflow: hidden;
    animation: popIn .25s var(--ease);
}
.modal-content.wide { max-width: 720px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.modal-header h3 { font-family: var(--font-display); font-size: 1.25rem; }
.modal-close {
    width: 34px; height: 34px; border-radius: 50%; border: 0; background: var(--surface-3); color: var(--ink-2); font-size: 1.2rem; line-height: 1;
    display: grid; place-items: center; transition: background var(--t-fast), color var(--t-fast);
}
.modal-close:hover { background: var(--line); color: var(--ink); }
.modal-body { padding: 22px; overflow-y: auto; min-width: 0; overflow-wrap: anywhere; }
.modal-footer { padding: 14px 22px 20px; display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; border-top: 1px solid var(--line); }
.modal-footer:empty { display: none; }

.tabs { display: flex; gap: 4px; background: var(--surface-3); padding: 4px; border-radius: var(--r-pill); margin-bottom: 20px; }
.tab-btn { flex: 1; border: 0; background: transparent; padding: 9px 12px; border-radius: var(--r-pill); font-weight: 600; font-size: .88rem; color: var(--ink-2); transition: all var(--t-fast); }
.tab-btn.active { background: var(--surface); color: var(--primary-ink); box-shadow: var(--shadow-1); }
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadeUp .25s var(--ease); }

.info-icon { font-size: 2.4rem; text-align: center; margin-bottom: 6px; }
.registration-request-info h4 { font-family: var(--font-display); font-size: 1.35rem; text-align: center; margin-bottom: 8px; }
.registration-request-info .intro-text { text-align: center; color: var(--ink-2); margin-bottom: 18px; }
.info-card { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 16px; margin-bottom: 14px; }
.info-card h5 { font-size: .85rem; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 10px; }
.email-item { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: .9rem; margin-bottom: 6px; }
.email-item strong { min-width: 90px; color: var(--ink-2); font-weight: 600; }
.email-link { color: var(--primary-ink); background: var(--primary-soft); padding: 3px 9px; border-radius: var(--r-sm); text-decoration: none; font-weight: 600; word-break: break-all; }
.tab-btn { white-space: normal; }
.required-info { margin: 0; padding-left: 0; list-style: none; display: grid; gap: 6px; }
.required-info li { padding: 8px 12px; background: var(--surface); border-left: 3px solid var(--primary); border-radius: var(--r-sm); font-size: .9rem; }
.process-steps { margin: 0; padding-left: 20px; display: grid; gap: 6px; font-size: .9rem; color: var(--ink-2); }
.email-button { margin: 4px 0 16px; }
.features-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.feature-item { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; padding: 12px 8px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); font-size: .8rem; color: var(--ink-2); }
.feature-icon { font-size: 1.5rem; }
.auth-form-simple { display: grid; gap: 14px; }
.auth-form-simple p { color: var(--ink-2); font-size: .92rem; }
.auth-message { display: none; padding: 10px 14px; border-radius: var(--r); font-size: .88rem; text-align: center; }
.auth-message.success, .auth-message.error, .auth-message.warning, .auth-message.info { display: block; }
.auth-message.success { background: var(--success-soft); color: var(--success); }
.auth-message.error { background: var(--danger-soft); color: var(--danger); }
.auth-message.warning { background: var(--warn-soft); color: var(--accent-ink); }
.auth-message.info { background: var(--info-soft); color: var(--info); }
.verification-pending { text-align: center; padding: 10px 0; }
.verification-pending .big { font-size: 3rem; margin-bottom: 8px; }
.verification-pending h4 { font-family: var(--font-display); font-size: 1.3rem; margin-bottom: 8px; }
.verification-pending p { color: var(--ink-2); margin-bottom: 8px; }
.tip { background: var(--info-soft); color: var(--info); border-radius: var(--r); padding: 10px 14px; font-size: .88rem; margin-top: 14px; }

.credit-info { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 16px 0; }
.credit-stat { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; text-align: center; }
.credit-stat .label { display: block; font-size: .75rem; color: var(--ink-3); text-transform: uppercase; letter-spacing: .05em; }
.credit-stat .value { font-size: 1.6rem; font-weight: 700; color: var(--primary); }
.modal-body ul { padding-left: 20px; color: var(--ink-2); }

/* Profil */
.profile-card { display: flex; align-items: center; gap: 14px; padding: 14px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-lg); margin-bottom: 14px; }
.profile-avatar { width: 54px; height: 54px; border-radius: 50%; background: var(--grad-primary); color: #fff; font-weight: 700; font-size: 1.2rem; display: grid; place-items: center; flex-shrink: 0; }
.profile-card small { color: var(--ink-3); display: block; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat-tile { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; text-align: center; }
.stat-tile b { display: block; font-size: 1.5rem; color: var(--ink); font-weight: 700; }
.stat-tile span { font-size: .75rem; color: var(--ink-3); }
.profile-name-row { display: flex; gap: 8px; }
.profile-name-row input { flex: 1; padding: 10px 12px; border: 1.5px solid var(--line-2); border-radius: var(--r); background: var(--surface-2); }
.profile-name-row input:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }

/* Modale d'édition d'image (injectée par book-renderer.js) */
#edit-image-modal .modal-content { max-width: 640px; }
.image-preview { text-align: center; margin-bottom: 16px; padding: 10px; background: var(--surface-2); border-radius: var(--r-lg); border: 1px solid var(--line); }
.image-preview img { margin: 0 auto; max-height: 280px; object-fit: contain; border-radius: var(--r); }
.edit-form label { display: block; font-weight: 600; margin-bottom: 8px; font-size: .9rem; }
.edit-form textarea { width: 100%; min-height: 96px; padding: 12px; border: 1.5px solid var(--line-2); border-radius: var(--r); background: var(--surface-2); resize: vertical; }
.edit-form textarea:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
.edit-examples { margin-top: 12px; padding: 12px 14px; background: var(--surface-2); border-left: 3px solid var(--primary); border-radius: 0 var(--r) var(--r) 0; font-size: .85rem; color: var(--ink-2); }
.edit-examples p { font-weight: 600; margin-bottom: 6px; }
.edit-examples ul { margin: 0; padding-left: 18px; display: grid; gap: 3px; }
.edit-examples li { cursor: pointer; }
.edit-examples li:hover { color: var(--primary-ink); }
#edit-image-modal .btn-cancel, #edit-image-modal .btn-edit { padding: 10px 16px; border-radius: var(--r); font-weight: 600; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); }
#edit-image-modal .btn-edit { background: var(--grad-primary); color: #fff; border-color: transparent; }
#edit-image-modal .btn-edit:disabled { opacity: .6; cursor: not-allowed; }
.loading-overlay {
    position: absolute; inset: 0; z-index: 3;
    background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center; gap: 12px; color: var(--primary-ink); font-weight: 600;
}

/* Partage */
.share-link-row { display: flex; gap: 8px; margin: 12px 0; }
.share-link-row input { flex: 1; padding: 10px 12px; border: 1.5px solid var(--line-2); border-radius: var(--r); background: var(--surface-2); font-size: .88rem; color: var(--ink); }
.share-qr { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 14px; background: #fff; border-radius: var(--r-lg); border: 1px solid var(--line); margin-top: 10px; }
.share-qr small { color: #6b6a85; font-size: .78rem; }
.share-qr img, .share-qr canvas { border-radius: 6px; }
.share-hint { font-size: .85rem; color: var(--ink-2); }

/* ---------- 10. Toasts & bannières --------------------------------------- */
.toast-stack { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 4000; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: min(92vw, 480px); }
.toast-message, .notification {
    pointer-events: auto;
    display: flex; align-items: center; gap: 10px;
    background: var(--surface); color: var(--ink);
    border: 1px solid var(--line); border-left: 4px solid var(--primary);
    border-radius: var(--r-lg); padding: 11px 14px;
    box-shadow: var(--shadow-3);
    font-size: .9rem; line-height: 1.4;
    max-width: 100%;
    opacity: 0; transform: translateY(-14px);
    transition: opacity var(--t) var(--ease), transform var(--t) var(--ease);
}
.toast-message.show, .notification.show { opacity: 1; transform: none; }
.toast-message.hide, .notification.hide { opacity: 0; transform: translateY(-14px); }
.toast-message.success, .notification.success { border-left-color: var(--success); }
.toast-message.error, .notification.error { border-left-color: var(--danger); }
.toast-message.warning, .notification.warning { border-left-color: var(--warn); }
.toast-message.info, .notification.info { border-left-color: var(--info); }
.toast-icon { font-size: 1.05rem; flex-shrink: 0; }
.toast-text { flex: 1; }
.toast-action { border: 1px solid var(--line-2); background: var(--surface-2); color: var(--ink); border-radius: var(--r-sm); padding: 5px 10px; font-size: .8rem; font-weight: 600; white-space: nowrap; }
.toast-action:hover { background: var(--primary-soft); color: var(--primary-ink); border-color: var(--primary); }
.toast-close { border: 0; background: transparent; color: var(--ink-3); font-size: 1.1rem; line-height: 1; padding: 2px 4px; }
.toast-close:hover { color: var(--ink); }

.low-credit-banner {
    position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%);
    z-index: 900; display: none; align-items: center; gap: 14px;
    background: var(--surface); border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent);
    border-radius: var(--r-pill); padding: 10px 14px 10px 16px;
    box-shadow: var(--shadow-3); font-size: .88rem; color: var(--ink);
    max-width: min(92vw, 640px);
}
.low-credit-banner.show { display: flex; animation: fadeUp .3s var(--ease); }
.low-credit-banner .toast-close { font-size: 1.2rem; }

/* ---------- 11. Mode présentation ---------------------------------------- */
.present {
    position: fixed; inset: 0; z-index: 5000; display: none;
    background: #0b0a16; color: #fff;
    flex-direction: column;
}
.present.show { display: flex; animation: fadeIn .25s ease; }
.present-bg { position: absolute; inset: 0; background-size: cover; background-position: center; filter: blur(40px) saturate(1.3); opacity: .35; transform: scale(1.15); transition: background-image .4s; }
.present-top { position: relative; z-index: 2; display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; gap: 12px; }
.present-title { font-family: var(--font-display); font-size: 1.05rem; opacity: .85; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.present-actions { display: flex; gap: 8px; }
.present-btn { border: 1px solid rgba(255, 255, 255, .2); background: rgba(255, 255, 255, .1); color: #fff; border-radius: var(--r-pill); padding: 8px 14px; font-weight: 600; font-size: .85rem; backdrop-filter: blur(8px); transition: background var(--t-fast); }
.present-btn:hover { background: rgba(255, 255, 255, .22); }
.present-btn.active { background: var(--accent); color: #1c1a33; border-color: transparent; }
.present-stage {
    position: relative; z-index: 2; flex: 1; min-height: 0;
    display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr); gap: clamp(16px, 3vw, 40px);
    align-items: center; padding: 0 clamp(16px, 4vw, 56px);
}
.present-image { display: flex; align-items: center; justify-content: center; min-height: 0; height: 100%; }
.present-image img { max-height: calc(100vh - 170px); max-width: 100%; object-fit: contain; border-radius: 18px; box-shadow: 0 40px 90px -30px rgba(0, 0, 0, .9); animation: fadeUp .35s var(--ease); }
.present-text { min-height: 0; overflow: auto; max-height: calc(100vh - 170px); padding-right: 6px; animation: fadeUp .4s var(--ease); }
.present-text h2 { font-family: var(--font-display); color: #fff; font-size: clamp(1.5rem, 3vw, 2.4rem); letter-spacing: -.01em; margin-bottom: 16px; }
.present-text p { font-family: var(--font-display); font-size: clamp(1.15rem, 2vw, 1.55rem); line-height: 1.65; color: rgba(255, 255, 255, .9); }
.present-text p .w { transition: background var(--t-fast); border-radius: 4px; }
.present-text p .w.on { background: rgba(245, 158, 11, .55); }
.present-bottom { position: relative; z-index: 2; display: flex; align-items: center; justify-content: center; gap: 16px; padding: 14px 20px 20px; }
.present-nav { width: 46px; height: 46px; border-radius: 50%; border: 1px solid rgba(255, 255, 255, .25); background: rgba(255, 255, 255, .1); color: #fff; font-size: 1.3rem; display: grid; place-items: center; transition: background var(--t-fast), transform var(--t-fast); }
.present-nav:hover:not(:disabled) { background: rgba(255, 255, 255, .25); transform: scale(1.06); }
.present-nav:disabled { opacity: .3; cursor: not-allowed; }
.present-dots { display: flex; gap: 6px; }
.present-dot { width: 8px; height: 8px; border-radius: 50%; background: rgba(255, 255, 255, .3); border: 0; padding: 0; transition: all var(--t-fast); }
.present-dot.active { background: var(--accent); width: 22px; border-radius: 4px; }
.present-counter { font-size: .85rem; opacity: .7; min-width: 60px; text-align: center; }
@media (max-width: 860px) {
    .present-stage { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) auto; gap: 12px; align-items: stretch; }
    .present-image img { max-height: 48vh; }
    .present-text { max-height: 34vh; }
    .present-text h2 { font-size: 1.3rem; margin-bottom: 8px; }
    .present-text p { font-size: 1.05rem; }
}

/* ---------- 12. Pied de page & divers ------------------------------------ */
.site-footer-v2 {
    background: var(--surface); border-top: 1px solid var(--line);
    padding: 26px 16px; margin-top: auto;
}
.site-footer-v2-content { max-width: var(--container); margin: 0 auto; display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.site-footer-v2-title h2 { font-size: .85rem; font-weight: 600; color: var(--ink-2); letter-spacing: .04em; text-transform: uppercase; }
.site-footer-v2-link { display: flex; gap: 28px; align-items: center; justify-content: center; text-decoration: none; opacity: .9; transition: opacity var(--t-fast); }
.site-footer-v2-link:hover { opacity: 1; }
.site-footer-v2-link img { height: 54px; width: auto; object-fit: contain; border-radius: 6px; }
[data-theme="dark"] .site-footer-v2-link img { background: #fff; padding: 4px; }
.footer-note { font-size: .78rem; color: var(--ink-3); }
.footer-note a { color: var(--ink-2); }

.scroll-top-btn {
    position: fixed; right: 22px; bottom: 22px; z-index: 800;
    width: 46px; height: 46px; border-radius: 50%; border: 1px solid var(--line);
    background: var(--surface); color: var(--ink); box-shadow: var(--shadow-3); font-size: 1.2rem;
    opacity: 0; pointer-events: none; transform: translateY(10px);
    transition: opacity var(--t), transform var(--t);
}
.scroll-top-btn.visible { opacity: 1; pointer-events: auto; transform: none; }
.scroll-top-btn:hover { background: var(--primary-soft); color: var(--primary-ink); }

.spinner {
    width: 40px; height: 40px; margin: 0 auto;
    border: 3px solid var(--line); border-top-color: var(--primary); border-radius: 50%;
    animation: spin .8s linear infinite;
}
.spinner-small { width: 20px; height: 20px; border: 2px solid var(--line); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state {
    text-align: center; padding: clamp(32px, 6vw, 64px) 20px;
    background: var(--surface); border: 1.5px dashed var(--line-2); border-radius: var(--r-xl);
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 10px; }
.empty-state h3 { font-family: var(--font-display); font-size: 1.4rem; margin-bottom: 6px; }
.empty-state p { color: var(--ink-2); margin-bottom: 16px; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 6px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--ink-3); }

/* ---------- 13. Responsive ---------------------------------------------- */
@media (max-width: 960px) {
    .hero { grid-template-columns: 1fr; }
    .hero-art { display: none; }
}
@media (max-width: 760px) {
    :root { --header-h: 60px; }
    .brand-sub { display: none; }
    .nav-link { padding: 7px 10px; font-size: .9rem; }
    .user-credits span.label { display: none; }
    .book-page { grid-template-columns: 1fr; }
    .page-image { min-height: 240px; }
    .page-image img { max-height: 420px; }
    .story-controls { top: calc(var(--header-h) + 4px); }
    .story-controls .btn .label { display: none; }
    .form-actions .kbd-hint { display: none; }
    .input-with-mic { flex-direction: column; }
    .input-buttons { flex-direction: row; justify-content: flex-end; }
    .modal-content { max-height: 94vh; border-radius: var(--r-lg); }
}
@media (max-width: 520px) {
    .nav { display: none; }
    .header-content { gap: 10px; }
    .header .btn .label { display: none; }
    .header .btn-sm { padding: 7px 10px; }
    .brand-name { font-size: 1.1rem; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}

@media print {
    .header, .studio, .story-controls, .site-footer-v2, .scroll-top-btn, .toast-stack, .low-credit-banner, .image-controls, .btn-edit-title, .btn-edit-text, .hero { display: none !important; }
    body { background: #fff; }
    .book-page { break-inside: avoid; box-shadow: none; border: 1px solid #ddd; }
}
