/* ---------------------------------------------------------------
   AllBookHq - feuille de style unique
   --------------------------------------------------------------- */

:root {
    --indigo: #4f46e5;
    --indigo-dark: #4338ca;
    --ink: #0f172a;
    --body: #334155;
    --muted: #64748b;
    --line: #e2e8f0;
    --surface: #ffffff;
    --canvas: #f8fafc;
    --green: #059669;
    --amber: #b45309;
    --red: #dc2626;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 8px 24px rgba(15, 23, 42, .05);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--body);
    background: var(--canvas);
    line-height: 1.6;
}

h1, h2, h3 { color: var(--ink); line-height: 1.25; margin: 0 0 .5rem; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.35rem; margin-top: 2rem; }
h3 { font-size: 1.05rem; }
a { color: var(--indigo); text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: #eef2ff; padding: .1rem .35rem; border-radius: 4px; font-size: .85em; }

.container { width: min(1120px, 100% - 3rem); margin-inline: auto; }
.container.narrow { width: min(760px, 100% - 3rem); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.eyebrow { text-transform: uppercase; letter-spacing: .08em; font-size: .75rem; color: var(--muted); margin: 0 0 .5rem; }
.lead { font-size: 1.1rem; color: var(--body); }

/* ---- Boutons ---- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    padding: .55rem 1.1rem; border-radius: var(--radius); border: 1px solid transparent;
    font-size: .95rem; font-weight: 600; cursor: pointer; text-decoration: none;
    transition: background .15s, border-color .15s, opacity .15s;
}
.btn:hover { text-decoration: none; }
.btn:disabled { opacity: .6; cursor: progress; }
.btn-primary { background: var(--indigo); color: #fff; }
.btn-primary:hover { background: var(--indigo-dark); }
.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--muted); }
.btn-danger { background: var(--red); color: #fff; }
.btn-lg { padding: .75rem 1.5rem; font-size: 1rem; }
.btn-sm { padding: .35rem .7rem; font-size: .82rem; }
.btn-block { width: 100%; }

/* ---- Site public ---- */
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); }
.header-inner { display: flex; align-items: center; justify-content: space-between; padding: 1rem 0; }
.brand { font-weight: 800; font-size: 1.25rem; color: var(--ink); letter-spacing: -.02em; }
.brand span { color: var(--indigo); }
.brand-lg { font-size: 1.6rem; display: block; text-align: center; margin-bottom: 1.5rem; }
.site-nav { display: flex; align-items: center; gap: 1.5rem; }
/* Les boutons gardent leur propre couleur : cette regle est plus specifique
   que `.btn-primary` et repeignait leur libelle. */
.site-nav a:not(.btn) { color: var(--body); font-size: .95rem; }

.hero { background: linear-gradient(180deg, #eef2ff, var(--canvas)); padding: 4rem 0; }
.hero-inner { display: grid; grid-template-columns: 1.1fr .9fr; gap: 3rem; align-items: center; }
.hero h1 { font-size: 2.6rem; letter-spacing: -.02em; }
.hero-actions { display: flex; gap: .75rem; margin-top: 1.75rem; flex-wrap: wrap; }

.mock-book { background: var(--surface); border-radius: 14px; box-shadow: var(--shadow); padding: 1.5rem; }
.mock-cover {
    background: linear-gradient(135deg, var(--indigo), #7c3aed); color: #fff;
    border-radius: 8px; padding: 3rem 1rem; text-align: center; font-weight: 700; font-size: 1.2rem;
}
.mock-toc { list-style: none; padding: 0; margin: 1.25rem 0 0; }
.mock-toc li { padding: .5rem 0; border-bottom: 1px solid var(--line); font-size: .9rem; color: var(--muted); }

.section { padding: 3.5rem 0; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1.25rem; margin-top: 1.5rem; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.5rem; }
.step {
    display: inline-flex; width: 30px; height: 30px; border-radius: 50%;
    background: #eef2ff; color: var(--indigo); font-weight: 700;
    align-items: center; justify-content: center; margin-bottom: .75rem;
}
.feature-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1.5rem; margin-top: 2rem; }
.price-card { text-align: center; }
.price-card.featured { border-color: var(--indigo); box-shadow: var(--shadow); }
.price { font-size: 2rem; font-weight: 800; color: var(--ink); margin: .5rem 0; }
.price span { font-size: .9rem; font-weight: 500; color: var(--muted); }
.price-card ul { list-style: none; padding: 0; margin: 0 0 1.25rem; color: var(--muted); }
.price-card li { padding: .3rem 0; }

.site-footer { background: var(--surface); border-top: 1px solid var(--line); padding: 2rem 0; }
.footer-inner { display: flex; justify-content: space-between; flex-wrap: wrap; gap: .5rem; font-size: .9rem; }

/* ---- Authentification ---- */
.auth-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 2rem 1rem; }
.auth-wrapper { width: min(420px, 100%); }
.auth-card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 2rem; box-shadow: var(--shadow); }
.form-footer { text-align: center; margin-top: 1.25rem; font-size: .9rem; }

/* ---- Application ---- */
.app { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.sidebar {
    background: var(--surface); border-right: 1px solid var(--line);
    padding: 1.5rem 1.25rem; display: flex; flex-direction: column; gap: 2rem;
}
.sidebar-nav { display: flex; flex-direction: column; gap: .25rem; }
.sidebar-nav a { color: var(--body); padding: .55rem .75rem; border-radius: 8px; font-size: .95rem; }
.sidebar-nav a:hover { background: var(--canvas); text-decoration: none; }
.sidebar-footer { margin-top: auto; border-top: 1px solid var(--line); padding-top: 1rem; }
.user-name { font-weight: 600; color: var(--ink); margin: 0; }
/* Profil et deconnexion se suivent : sans cela ils se touchaient. */
.sidebar-footer .btn { margin-top: .5rem; }
.app-main { padding: 2rem 0 4rem; }
.app-main .container { width: min(1000px, 100% - 3rem); }

.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.page-head h1 { margin: 0; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1rem; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; }
.stat-value { display: block; font-size: 1.8rem; font-weight: 700; color: var(--ink); }
.stat-label { font-size: .85rem; color: var(--muted); }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.5rem; margin-bottom: 1.5rem; }
.ai-panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.ai-controls { display: flex; align-items: center; gap: .5rem; }
.inline-label { font-size: .85rem; color: var(--muted); margin: 0; }
.input-sm { width: 76px; padding: .4rem .5rem; border: 1px solid var(--line); border-radius: 8px; }
.ai-message { margin: 1rem 0 0; font-size: .9rem; min-height: 1.2rem; }
.ai-message.is-pending { color: var(--amber); }
.ai-message.is-success { color: var(--green); }
.ai-message.is-error { color: var(--red); }

/* ---- Tableaux et listes ---- */
.table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.table th, .table td { padding: .75rem 1rem; text-align: left; border-bottom: 1px solid var(--line); font-size: .92rem; }
.table th { background: var(--canvas); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.table tr:last-child td { border-bottom: none; }

.project-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1.25rem; }
.project-card {
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 1.25rem; color: inherit; display: block; transition: border-color .15s, transform .15s;
}
.project-card:hover { border-color: var(--indigo); text-decoration: none; transform: translateY(-2px); }
.project-cover {
    display: flex; align-items: center; justify-content: center;
    width: 44px; height: 56px; border-radius: 4px; color: #fff; font-weight: 700; font-size: 1.3rem; margin-bottom: .75rem;
}
.project-meta { display: flex; justify-content: space-between; align-items: center; margin-top: 1rem; }

.chapter-list { list-style: none; counter-reset: chapter; padding: 0; margin: 0; }
.chapter-item {
    counter-increment: chapter; display: flex; justify-content: space-between; align-items: center; gap: 1rem;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 1rem 1.25rem; margin-bottom: .6rem;
}
.chapter-item::before { content: counter(chapter); color: var(--muted); font-weight: 700; min-width: 1.5rem; }
.chapter-main { flex: 1; }
.chapter-title { font-weight: 600; color: var(--ink); }
.chapter-side { display: flex; align-items: center; gap: .6rem; }

.badge { display: inline-block; padding: .18rem .55rem; border-radius: 999px; font-size: .75rem; font-weight: 600; background: #f1f5f9; color: var(--muted); }
.badge-ready, .badge-written, .badge-published { background: #d1fae5; color: #065f46; }
.badge-generating, .badge-writing { background: #fef3c7; color: #92400e; }
.badge-draft, .badge-empty { background: #e2e8f0; color: #475569; }
.badge-alert, .badge-failed { background: #fee2e2; color: #991b1b; }

.empty-state { background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); padding: 3rem 1.5rem; text-align: center; }

/* ---- Formulaires ---- */
.form label { display: block; font-size: .88rem; font-weight: 600; color: var(--ink); margin: 1rem 0 .35rem; }
.form input[type="text"], .form input[type="email"], .form input[type="password"],
.form input[type="number"], .form input[type="search"], .form textarea, .form select {
    width: 100%; padding: .6rem .75rem; border: 1px solid var(--line); border-radius: 8px;
    font: inherit; color: var(--ink); background: #fff;
}
.form input:focus, .form textarea:focus, .form select:focus { outline: 2px solid #c7d2fe; border-color: var(--indigo); }
.form textarea { resize: vertical; }
.form-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.75rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-actions { display: flex; justify-content: flex-end; gap: .75rem; margin-top: 1.5rem; }
.field-error { color: var(--red); font-size: .82rem; margin: .3rem 0 0; }
.search-bar { display: flex; gap: .5rem; margin-bottom: 1.5rem; }
.search-bar input { flex: 1; padding: .55rem .75rem; border: 1px solid var(--line); border-radius: 8px; font: inherit; }

.editor-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-top: 1rem; }
.editor { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .88rem; line-height: 1.6; }
.preview-block { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.5rem; margin-top: 1.5rem; }
.preview-block summary { cursor: pointer; font-weight: 600; color: var(--ink); }
.chapter-preview { margin-top: 1rem; }
.chapter-preview h3 { margin-top: 1.5rem; }

.danger-zone {
    display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap;
    background: #fef2f2; border: 1px solid #fecaca; border-radius: var(--radius); padding: 1.25rem 1.5rem; margin-top: 2rem;
}
.danger-zone h3 { margin: 0; color: #991b1b; }

/* ---- Alertes ---- */
.alert { border-radius: var(--radius); padding: .85rem 1.1rem; margin-bottom: 1.25rem; font-size: .92rem; border: 1px solid; }
.alert-success { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.alert-error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.alert-warning { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.alert-info { background: #f8fafc; border-color: var(--line); color: var(--muted); }
.error-list { margin: 0; padding-left: 1.1rem; }

.error-code { font-size: 4rem; margin-bottom: 0; }
.debug-box { background: #0f172a; color: #e2e8f0; padding: 1.25rem; border-radius: var(--radius); overflow-x: auto; text-align: left; font-size: .8rem; }

/* ---- Responsive ---- */
@media (max-width: 900px) {
    .hero-inner { grid-template-columns: 1fr; }
    .app { grid-template-columns: 1fr; }
    .sidebar { flex-direction: row; align-items: center; flex-wrap: wrap; gap: 1rem; border-right: none; border-bottom: 1px solid var(--line); }
    .sidebar-nav { flex-direction: row; flex-wrap: wrap; }
    .sidebar-footer { margin: 0; border: none; padding: 0; }
    .form-row { grid-template-columns: 1fr; }
}

/* ---------------------------------------------------------------
   Back-office
   --------------------------------------------------------------- */

.tag-admin {
    font-size: .65rem; text-transform: uppercase; letter-spacing: .08em;
    background: var(--indigo); color: #fff; padding: .1rem .4rem; border-radius: 4px; vertical-align: middle;
}
.nav-heading {
    font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted);
    margin: 1.1rem 0 .3rem; padding-left: .75rem;
}
.nav-heading:first-child { margin-top: 0; }
.sidebar-nav a.is-active { background: #eef2ff; color: var(--indigo); font-weight: 600; }

.admin .app-main .container { width: min(1160px, 100% - 3rem); }
.admin-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; align-items: start; }
.admin-columns > section h2:first-child, .admin-columns > form h2:first-child { margin-top: 0; }

.status-list { list-style: none; padding: 0; margin: 0 0 1.25rem; }
.status-list li {
    display: flex; justify-content: space-between; align-items: center;
    padding: .55rem 0; border-bottom: 1px solid var(--line); font-size: .92rem;
}
.status-list li:last-child { border-bottom: none; }

/* Journal : une entree par bloc, la plus recente en tete. Le liseré de
   gauche porte le niveau -- il se repere en parcourant la colonne, sans
   avoir a lire chaque badge. */
.log-list { list-style: none; padding: 0; margin: 0 0 1.5rem; display: grid; gap: .5rem; }
.log-entry {
    background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--line);
    border-radius: var(--radius); padding: .7rem .9rem;
}
.log-entry.log-error { border-left-color: #dc2626; }
.log-entry.log-warning { border-left-color: #d97706; }
.log-entry.log-info { border-left-color: #059669; }
.log-head { display: flex; align-items: center; gap: .6rem; margin-bottom: .35rem; }
.log-message { margin: 0; font-size: .92rem; overflow-wrap: anywhere; }
.log-detail {
    margin: .5rem 0 0; padding: .6rem .8rem; background: var(--canvas); border-radius: var(--radius);
    font-size: .8rem; line-height: 1.5; overflow-x: auto; white-space: pre;
}

.plain-list { list-style: none; padding: 0; margin: 0; }
.plain-list li { display: flex; justify-content: space-between; gap: 1rem; padding: .45rem 0; border-bottom: 1px solid var(--line); font-size: .9rem; }
.plain-list li:last-child { border-bottom: none; }

.tabs { display: flex; gap: .25rem; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin-bottom: 1.5rem; }
.tab {
    padding: .6rem 1rem; border-radius: 8px 8px 0 0; color: var(--body);
    font-size: .92rem; font-weight: 500; border: 1px solid transparent; border-bottom: none;
}
.tab:hover { background: var(--canvas); text-decoration: none; }
.tab.is-active { background: var(--surface); border-color: var(--line); color: var(--ink); font-weight: 600; margin-bottom: -1px; }

.switch-row { display: flex; align-items: center; gap: .6rem; margin: 1rem 0 .35rem; font-weight: 500; cursor: pointer; }
.switch-row input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--indigo); }
.input-color { width: 72px; height: 40px; padding: .2rem; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.field-key { margin: .25rem 0 0; opacity: .65; }

.row-actions { text-align: right; white-space: nowrap; }
.page-content h3 { margin-top: 1.75rem; }
.page-content ul, .page-content ol { padding-left: 1.25rem; }

@media (max-width: 900px) {
    .admin-columns { grid-template-columns: 1fr; }
}

.secret-field { display: flex; gap: .5rem; align-items: center; }
.secret-field input, .secret-field select { flex: 1; }
.secret-field .btn { white-space: nowrap; }

.ai-controls-inline { margin-top: 1rem; flex-wrap: wrap; }
.ai-controls-inline .muted { flex: 1 1 12rem; }

/* Barre de progression de la redaction en serie */
.progress {
    height: 6px; background: var(--line); border-radius: 999px;
    overflow: hidden; margin-top: 1rem;
}
.progress-bar {
    height: 100%; width: 0; background: var(--indigo);
    border-radius: 999px; transition: width .3s ease;
}
.chapter-item.is-writing { border-color: var(--indigo); background: #fbfbff; }
.chapter-item.is-failed { border-color: #fecaca; background: #fffafa; }
/* Redige, mais la reponse s'est perdue : ni vert ni rouge. */
.chapter-item.is-recovered { border-color: #fde68a; background: #fffdf5; }

/* Hierarchie chapitres / sous-chapitres */
.chapter-list { counter-reset: none; }
.chapter-item::before { content: none; }
.chapter-number {
    min-width: 2.4rem; color: var(--muted); font-weight: 700;
    font-variant-numeric: tabular-nums; font-size: .95rem;
}
.chapter-item.is-child {
    margin-left: 2rem; background: var(--canvas);
    border-left: 3px solid var(--line);
}
.chapter-item.is-child .chapter-title { font-weight: 500; font-size: .95rem; }
.chapter-item.is-child .chapter-number { color: #94a3b8; font-size: .85rem; }
.add-chapter { margin-top: 1.5rem; }
.add-chapter h3 { margin-top: 0; }

.inline-form { display: inline; }
.btn-delete-chapter { color: var(--red); }
.btn-delete-chapter:hover { border-color: var(--red); background: #fef2f2; }

/* Ecran de mise en page */
.design-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1.5rem; align-items: start; }
.design-layout h2:first-child { margin-top: 0; }
.design-preview {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 1.25rem; position: sticky; top: 1rem;
}
.preview-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.preview-head h2 { margin: 0; }
/* L'apercu affiche une page entiere : l'iframe garde une largeur logique
   fixe et c'est la mise a l'echelle qui la fait tenir dans le panneau. */
.preview-viewport {
    height: 70vh; min-height: 420px; overflow: auto; margin: .75rem 0;
    border: 1px solid var(--line); border-radius: 8px; background: #e2e8f0;
}
#design-preview-frame {
    width: var(--preview-width, 900px);
    height: var(--preview-height, 1200px);
    border: 0; background: #f1f5f9; display: block;
    transform: scale(var(--preview-scale, 1));
    transform-origin: top left;
}
.preview-head { flex-wrap: wrap; }
.preview-head .inline-label { margin-left: auto; }
@media (max-width: 1000px) {
    .design-layout { grid-template-columns: 1fr; }
    .design-preview { position: static; }
}
.head-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* Galerie de modeles de mise en page */
.template-head { display: flex; align-items: center; gap: .75rem; }
.template-head h2 { margin: 0; }
.template-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: .75rem; margin: 1rem 0 1.5rem;
}
.template-card {
    display: flex; flex-direction: column; gap: .4rem; text-align: left;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    padding: .75rem; cursor: pointer; font: inherit; color: inherit;
    transition: border-color .15s, box-shadow .15s;
}
.template-card:hover { border-color: var(--indigo); }
.template-card.is-active { border-color: var(--indigo); box-shadow: 0 0 0 2px #c7d2fe; }
.template-name { font-weight: 600; font-size: .9rem; color: var(--ink); }
.template-desc { font-size: .78rem; color: var(--muted); line-height: 1.4; }

.template-thumb {
    display: block; background: #fff; border: 1px solid var(--line); border-radius: 6px;
    padding: .5rem; height: 82px; overflow: hidden;
}
.template-thumb .thumb-band { display: block; height: 4px; width: 38%; background: var(--tpl-accent); border-radius: 2px; }
.template-thumb .thumb-title { display: block; font-size: 1.1rem; font-weight: 700; color: var(--tpl-accent); margin: .25rem 0 .3rem; line-height: 1; }
.template-thumb .thumb-line { display: block; height: 3px; background: #e2e8f0; border-radius: 2px; margin-bottom: 4px; }
.template-thumb .thumb-line.short { width: 62%; }
.tpl-font-serif .thumb-title { font-family: Georgia, "Times New Roman", serif; }
.tpl-font-mixed .thumb-title { font-family: -apple-system, "Segoe UI", Roboto, sans-serif; }
.tpl-font-sans .thumb-title { font-family: -apple-system, "Segoe UI", Roboto, sans-serif; }
.tpl-font-ronde .thumb-title { font-family: "Avenir Next", Avenir, Futura, "Century Gothic", sans-serif; }

/* Bibliotheque d'images */
.upload-form { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; }
.upload-form input[type="file"] { flex: 1 1 16rem; font-size: .9rem; }

.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .9rem; }
.media-item { margin: 0; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.media-item img { display: block; width: 100%; height: 110px; object-fit: cover; background: var(--canvas); }
.media-item figcaption {
    padding: .5rem; display: flex; flex-direction: column; gap: .35rem;
    align-items: flex-start; font-size: .78rem;
}

.media-picker { display: flex; gap: .5rem; flex-wrap: wrap; margin: .5rem 0; }
.media-option {
    width: 74px; height: 74px; padding: 0; overflow: hidden; cursor: pointer;
    border: 1px solid var(--line); border-radius: 8px; background: var(--surface);
}
.media-option.is-active { border-color: var(--indigo); box-shadow: 0 0 0 2px #c7d2fe; }
.media-option img { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-none { font-size: .72rem; color: var(--muted); padding: .3rem; display: block; line-height: 1.3; }

/* ---- Formulaire de mise en page ---- */
.form-tabs { margin: 1.25rem 0 1rem; }
.form-tabs .tab { background: none; cursor: pointer; font: inherit; }
.tab-panel { animation: panel-in .15s ease; }
.tab-panel > label:first-child { margin-top: 0; }
@keyframes panel-in { from { opacity: 0; transform: translateY(-2px); } to { opacity: 1; transform: none; } }

/* Boutons radio presentes comme un selecteur segmente */
.segmented { display: flex; flex-wrap: wrap; gap: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.segment { flex: 1 1 auto; margin: 0; position: relative; }
.segment input { position: absolute; opacity: 0; pointer-events: none; }
.segment span {
    display: block; padding: .5rem .75rem; text-align: center; cursor: pointer;
    font-size: .9rem; font-weight: 500; color: var(--body);
    border-left: 1px solid var(--line); transition: background .12s, color .12s;
    white-space: nowrap;
}
.segment:first-child span { border-left: 0; }
.segment span:hover { background: var(--canvas); }
.segment input:checked + span { background: var(--indigo); color: #fff; font-weight: 600; }
.segment input:focus-visible + span { outline: 2px solid #c7d2fe; outline-offset: -2px; }

.field-hint { margin: .35rem 0 0; }
.color-row { display: flex; align-items: center; gap: .75rem; }

/* Barre d'enregistrement, toujours accessible */
.save-bar {
    position: sticky; bottom: 0; margin: 1.5rem -1.75rem -1.75rem;
    padding: .85rem 1.75rem; background: var(--surface); border-top: 1px solid var(--line);
    display: flex; align-items: center; gap: .75rem; flex-wrap: wrap;
    border-radius: 0 0 var(--radius) var(--radius);
}
.save-state { flex: 1; font-size: .88rem; color: var(--muted); }
.save-bar.is-dirty { background: #fffbeb; border-top-color: #fde68a; }
.save-bar.is-dirty .save-state { color: #92400e; font-weight: 600; }

/* Libelle de champ accompagne d'une action (proposition IA) */
.label-row { display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.label-row label { margin-bottom: .35rem; }
.form .label-row + textarea { margin-top: 0; }

/* La vignette d'un modele reprend l'habillage de sa couverture, pour qu'on
   choisisse sur l'aspect et non sur le seul nom. */
.template-thumb { position: relative; overflow: hidden; }
.template-thumb > * { position: relative; z-index: 1; }
.tpl-cover-plein { background: var(--tpl-accent); }
.tpl-cover-plein .thumb-title { color: #fff; }
.tpl-cover-plein .thumb-band { background: rgba(255, 255, 255, .75); }
.tpl-cover-plein .thumb-line { background: rgba(255, 255, 255, .45); }
.tpl-cover-bloc::before {
    content: ''; position: absolute; inset: 0 0 55% 0; background: var(--tpl-accent);
}
.tpl-cover-bloc .thumb-band { background: rgba(255, 255, 255, .8); }
.tpl-cover-bloc .thumb-title { color: #fff; }
.tpl-cover-angle::before {
    content: ''; position: absolute; inset: 0; background: var(--tpl-accent);
    clip-path: polygon(0 68%, 100% 42%, 100% 100%, 0 100%);
}
.tpl-cover-cadre { border: 3px solid var(--tpl-accent); }
.tpl-cover-formes { background: var(--tpl-accent); }
.tpl-cover-formes .thumb-title { color: #fff; }
.tpl-cover-formes .thumb-band { background: linear-gradient(90deg, #1d4ed8, #38bdf8); width: 52%; }
.tpl-cover-formes .thumb-line { background: rgba(255, 255, 255, .4); }
.tpl-cover-formes::before {
    content: ''; position: absolute; width: 46px; height: 46px; right: -14px; top: -14px;
    border: 7px solid transparent; border-radius: 50%;
    border-top-color: #f5b642; border-left-color: #c026d3; border-bottom-color: #a21caf;
}
.tpl-cover-vagues, .tpl-cover-grille { background: var(--tpl-accent); }
.tpl-cover-vagues .thumb-title, .tpl-cover-grille .thumb-title { color: #fff; }
.tpl-cover-vagues .thumb-line, .tpl-cover-grille .thumb-line { background: rgba(255, 255, 255, .4); }
.tpl-cover-vagues .thumb-band { background: linear-gradient(90deg, #0e7490, #22d3ee); width: 52%; }
.tpl-cover-vagues::before {
    content: ''; position: absolute; width: 54px; height: 54px; right: -16px; top: -16px;
    border-radius: 50%; background: linear-gradient(140deg, #22d3ee, #0e7490);
}
.tpl-cover-grille .thumb-band { background: linear-gradient(90deg, #f97316, #fbbf24); width: 52%; }
.tpl-cover-grille::before {
    content: ''; position: absolute; inset: 0; opacity: .5;
    background-image: radial-gradient(rgba(255, 255, 255, .55) 1.5px, rgba(0, 0, 0, 0) 1.5px);
    background-size: 12px 12px;
}
.tpl-cover-grille::after {
    content: ''; position: absolute; width: 40px; height: 40px; right: -10px; top: -8px;
    background: linear-gradient(135deg, #fb7185, #f97316); transform: rotate(22deg);
}
.tpl-cover-photo { background: linear-gradient(160deg, #475569, #0f172a); }
.tpl-cover-photo .thumb-title { color: #fff; }
.tpl-cover-photo .thumb-band { background: var(--tpl-accent); width: 52%; }
.tpl-cover-photo .thumb-line { background: rgba(255, 255, 255, .45); }
.tpl-cover-degrade { background: linear-gradient(165deg, var(--tpl-accent), #fff 88%); }
.tpl-cover-degrade .thumb-title { color: #0f172a; }
.tpl-cover-medaillon { position: relative; }
.tpl-cover-medaillon::before {
    content: ''; position: absolute; inset: 0; background: var(--tpl-accent); opacity: .09;
}
.tpl-cover-medaillon .thumb-band { margin: 0 auto; width: 34%; height: 1px; }
.tpl-cover-medaillon .thumb-title { text-align: center; }
