/* =========================================================
   Eggsperience — UI inspirée du design system EGG (cocon naturel).
   Layout : sidebar gauche fixe + main scrollable à droite.
   ========================================================= */

:root {
    --egg-bg-primary:    #F5F1EB;
    --egg-bg-surface:    #FFFFFF;
    --egg-bg-muted:      #F0EBE5;
    --egg-text-primary:  #2F2A26;
    --egg-text-secondary:#8A817C;
    --egg-text-faint:    #A39C95;
    --egg-text-disabled: #C5BDB6;
    --egg-accent:        #5A4A3E;
    --egg-accent-soft:   #8A7A6E;
    --egg-sage:          #A3B18A;
    --egg-border:        #E6DFD8;
    --egg-border-soft:   #EDE7E0;
    --egg-border-strong: #D6CEC7;
    --egg-bubble-user:   #E8DFD3;
    --egg-success:       #7FA38D;
    --egg-error:         #C97B63;
    --egg-warning:       #D6A85F;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-xl: 28px;

    --shadow-soft: 0 4px 16px rgba(47, 42, 38, 0.06);
    --shadow-card: 0 10px 30px rgba(47, 42, 38, 0.07);

    --transition-smooth: 220ms ease;

    --font-display: 'Fraunces', 'Iowan Old Style', Georgia, serif;
    --font-body:    'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

    --sidebar-w:   320px;
    --content-max: 760px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    background: var(--egg-bg-primary);
    color: var(--egg-text-primary);
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    /* Désactive le rebond élastique en bout de scroll (overscroll bounce)
       qui faisait remonter visuellement toute la page. */
    overscroll-behavior: none;
}

a { color: var(--egg-accent); text-decoration: none; }
a:hover { color: var(--egg-text-primary); }

/* ========== LAYOUT ========== */
.app {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    min-height: 100vh;
}

/* ========== SIDEBAR ========== */
.sidebar {
    background: var(--egg-bg-muted);
    border-right: 1px solid var(--egg-border);
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: sticky;
    top: 0;
    overflow: hidden;
}

.sidebar-top {
    padding: 18px 14px 14px;
    border-bottom: 1px solid var(--egg-border-strong);
    flex-shrink: 0;
}
.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px 10px;
    color: var(--egg-text-primary);
    text-decoration: none;
    line-height: 1.2;
}
.brand:hover { color: var(--egg-accent); }
.brand-logo { width: 34px; height: 34px; object-fit: contain; flex-shrink: 0; }
.brand-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.brand-name {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 19px;
    letter-spacing: -0.01em;
}
.brand-tagline {
    font-family: var(--font-body);
    font-size: 11px;
    font-weight: 500;
    color: var(--egg-text-secondary);
    text-transform: none;
    letter-spacing: 0.01em;
}

.sidebar-middle {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 16px 14px 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.sidebar-bottom {
    flex-shrink: 0;
    padding: 12px 14px;
    border-top: 1px solid var(--egg-border-strong);
    background: var(--egg-bg-muted);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* Barre de recherche en haut de la sidebar */
.nav-search {
    position: relative;
    display: flex;
    align-items: center;
    background: var(--egg-bg-surface);
    border: 1px solid var(--egg-border-strong);
    border-radius: 999px;
    padding: 0 10px;
    margin-bottom: 8px;
    transition: border-color 120ms ease, box-shadow 120ms ease;
}
.nav-search:focus-within {
    border-color: var(--egg-accent);
    box-shadow: 0 0 0 3px rgba(90, 74, 62, 0.10);
}
.nav-search svg {
    width: 14px;
    height: 14px;
    color: var(--egg-text-faint);
    flex-shrink: 0;
}
.nav-search input {
    flex: 1;
    border: 0;
    outline: 0;
    background: transparent;
    font: inherit;
    font-size: 13px;
    padding: 7px 8px;
    color: var(--egg-text-primary);
    min-width: 0;
}
.nav-search input::-webkit-search-cancel-button { display: none; }
.nav-search input::placeholder { color: var(--egg-text-faint); }
.nav-search button {
    background: transparent;
    border: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    color: var(--egg-text-faint);
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 0;
    flex-shrink: 0;
}
.nav-search button:hover { color: var(--egg-text-primary); background: var(--egg-bg-muted); }

.nav-section { display: flex; flex-direction: column; gap: 2px; }
.nav-section-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--egg-text-secondary);
    padding: 4px 10px 8px;
    font-weight: 600;
}

/* Groupe library : conteneur titre + chevron + agents (repliable) */
.nav-library-group { display: flex; flex-direction: column; margin-top: 8px; }
.nav-library-group.is-hidden { display: none; }
.nav-library-row {
    display: flex;
    align-items: center;
    gap: 2px;
    border-radius: var(--radius-sm);
}
.nav-library {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    color: var(--egg-text-primary);
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 14px;
    text-decoration: none;
    border-radius: var(--radius-sm);
    transition: background var(--transition-smooth);
    flex: 1;
    min-width: 0;
}
.nav-library:hover {
    background: rgba(90, 74, 62, 0.06);
    color: var(--egg-accent);
}
.nav-library.active {
    background: rgba(90, 74, 62, 0.10);
    color: var(--egg-accent);
}
.nav-library-icon { font-size: 16px; flex-shrink: 0; }
.nav-library-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Chevron toggle à droite de chaque library */
.nav-library-toggle {
    background: transparent;
    border: none;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    color: var(--egg-text-faint);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    flex-shrink: 0;
    transition: background 120ms ease, color 120ms ease;
}
.nav-library-toggle:hover { background: rgba(90, 74, 62, 0.10); color: var(--egg-accent); }
.nav-library-toggle svg {
    width: 14px;
    height: 14px;
    transition: transform 180ms ease;
}
.nav-library-toggle[aria-expanded="false"] svg { transform: rotate(-90deg); }

/* État replié : on cache les agents. Animation laissée à l'instant pour
   simplicité (max-height transition demande de connaître la hauteur). */
.nav-library-group[data-collapsed="true"] .nav-agents { display: none; }

.nav-agents {
    display: flex;
    flex-direction: column;
    gap: 1px;
    margin: 2px 0 4px 16px;
    border-left: 1px solid var(--egg-border-strong);
    padding-left: 8px;
}
.nav-agent {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 8px;
    color: var(--egg-text-secondary);
    font-size: 13px;
    text-decoration: none;
    border-radius: 4px;
    transition: background 120ms ease, color 120ms ease;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.nav-agent:hover {
    background: rgba(90, 74, 62, 0.06);
    color: var(--egg-text-primary);
}
.nav-agent.active {
    background: rgba(90, 74, 62, 0.10);
    color: var(--egg-accent);
    font-weight: 500;
}
/* Agent pas encore activé : italique + voile pour signaler sans crier. */
.nav-agent.is-soon {
    font-style: italic;
    opacity: 0.55;
}
.nav-agent.is-soon:hover { opacity: 0.85; }
.nav-agent.is-hidden { display: none; }
.nav-agent-icon { font-size: 14px; flex-shrink: 0; opacity: 0.85; }

.nav-fav-row {
    display: grid;
    grid-template-columns: 14px 1fr 22px;
    gap: 6px;
    align-items: center;
    padding: 5px 10px;
    border-radius: 4px;
    transition: background 120ms ease;
}
.nav-fav-row:hover { background: rgba(90, 74, 62, 0.06); }
.nav-fav-row a {
    color: var(--egg-text-primary);
    font-size: 13px;
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
}
.nav-fav-row a:hover { color: var(--egg-accent); }
.nav-fav-star {
    color: var(--egg-warning);
    font-size: 12px;
    flex-shrink: 0;
}
.nav-fav-remove {
    background: transparent;
    border: none;
    width: 22px;
    height: 22px;
    color: var(--egg-text-faint);
    cursor: pointer;
    border-radius: 3px;
    padding: 0;
    font-size: 16px;
    line-height: 1;
    opacity: 0;
    transition: opacity 120ms ease;
}
.nav-fav-row:hover .nav-fav-remove { opacity: 1; }
.nav-fav-remove:hover { background: var(--egg-bg-surface); color: var(--egg-error); }

.nav-empty {
    font-size: 12px;
    color: var(--egg-text-faint);
    padding: 4px 10px;
    font-style: italic;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    font-size: 12.5px;
    color: var(--egg-text-faint);
    text-decoration: none;
    border-radius: 4px;
    transition: color 120ms ease, background 120ms ease;
}
.sidebar-link:hover { color: var(--egg-accent); background: rgba(90, 74, 62, 0.04); }
.sidebar-link.active {
    color: var(--egg-accent);
    background: rgba(90, 74, 62, 0.10);
    font-weight: 600;
}
.sidebar-link-icon { width: 14px; height: 14px; flex-shrink: 0; opacity: 0.85; }

/* Triptyque trust (Éthique · Expertise · Données) : 3 colonnes égales, contenu centré.
   En mobile/sidebar étroite, le libellé peut wrapper sous l'icône — on passe en
   flex column pour préserver la lisibilité. */
.sidebar-trust-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 2px;
}
.sidebar-trust-row .sidebar-link {
    flex-direction: column;
    gap: 4px;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 8px 4px;
    font-size: 11.5px;
}
.sidebar-trust-row .sidebar-link-icon { width: 18px; height: 18px; }

/* ========== MAIN ========== */
.main {
    padding: 56px 48px 80px;
    overflow-x: hidden;
}
.main-inner {
    max-width: var(--content-max);
    margin: 0 auto;
}

/* Carte eggspert — présentation du créateur en fin de page Expertise.
   Inspirée du Meet the Creator de magif.ai : avatar rond à gauche, identité
   + badge vérifié + bio à droite. Sur mobile, le bloc s'empile. */
.eggspert-card {
    margin: 36px 0 0;
    padding: 24px;
    background: var(--egg-bg-surface);
    border: 1px solid var(--egg-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
    display: flex;
    gap: 22px;
    align-items: flex-start;
}
.eggspert-avatar {
    width: 112px;
    height: 112px;
    flex-shrink: 0;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--egg-bg-surface);
    box-shadow: 0 2px 12px rgba(47, 42, 38, 0.10);
}
.eggspert-body { flex: 1; min-width: 0; }
.eggspert-meta {
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
    color: var(--egg-text-faint);
    margin: 0 0 6px;
}
.eggspert-name {
    font-family: var(--font-display);
    font-size: 24px;
    font-weight: 600;
    color: var(--egg-text-primary);
    margin: 0 0 4px;
    line-height: 1.2;
    letter-spacing: -0.01em;
}
.eggspert-role {
    font-size: 14px;
    color: var(--egg-text-secondary);
    margin: 0 0 12px;
}
.eggspert-bio {
    font-size: 14.5px;
    line-height: 1.6;
    color: var(--egg-text-primary);
    margin: 0 0 16px;
}
.eggspert-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    margin-bottom: 16px;
}
.eggspert-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--egg-text-secondary);
    text-decoration: none;
    transition: color 120ms ease;
}
.eggspert-link svg { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.85; }
.eggspert-link:hover { color: var(--egg-accent); }
.eggspert-cta { margin-top: 4px; }
.eggspert-cta svg { width: 16px; height: 16px; }
@media (max-width: 640px) {
    .eggspert-card { flex-direction: column; align-items: center; text-align: center; padding: 20px; }
    .eggspert-body { text-align: left; width: 100%; }
    .eggspert-actions { justify-content: flex-start; }
}

/* Pages d'infos (EGG, Éthique, Données) : fond légèrement contrasté pour
   les différencier des pages d'agents. Tonalité plus chaude/papier. */
body.info-page .main { background: #FBF7F1; }
body.info-page .landing-bullets li,
body.info-page .agent-details {
    background: var(--egg-bg-surface);
    border-color: var(--egg-border);
}

h1, h2, h3 {
    font-family: var(--font-display);
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--egg-text-primary);
    margin: 0 0 14px;
}
h1 { font-size: 32px; line-height: 1.2; }
h2 { font-size: 22px; line-height: 1.25; margin-top: 28px; }
h3 { font-size: 17px; line-height: 1.3; margin-top: 22px; }

.title-icon { margin-right: 6px; }

.muted { color: var(--egg-text-secondary); }
.lead { font-size: 17px; color: var(--egg-text-secondary); margin-bottom: 28px; line-height: 1.5; }

/* Landing — section d'introduction de l'accueil */
.landing { margin-bottom: 48px; }
.landing-logo-wrap {
    margin: 0 auto 18px;
    text-align: center;
    padding: 0;
    font-size: 0;
    line-height: 0;
}
.landing-logo {
    width: 140px;
    height: auto;
    display: inline-block;
}
.landing-tagline {
    text-align: center;
    font-family: var(--font-display);
    font-style: italic;
    font-size: 22px;
    line-height: 1.35;
    color: var(--egg-accent);
    margin: 0 0 36px;
    letter-spacing: 0;
}
.landing-bullets {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 8px;
}
.landing-bullets li {
    padding: 10px 14px;
    background: var(--egg-bg-surface);
    border: 1px solid var(--egg-border);
    border-radius: var(--radius-sm);
    font-size: 15px;
    color: var(--egg-text-secondary);
    transition: border-color var(--transition-smooth);
}
.landing-bullets li:hover { border-color: var(--egg-accent-soft); }
.landing-bullets a { color: var(--egg-text-primary); }
.landing-bullets a:hover { color: var(--egg-accent); }

.landing-coda {
    margin: 32px 0 0;
    padding: 18px 22px;
    border-left: 3px solid var(--egg-accent);
    background: var(--egg-bg-muted);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-family: var(--font-display);
    font-style: italic;
    font-size: 17px;
    line-height: 1.45;
    color: var(--egg-text-primary);
}

/* Permet aux ancres de ne pas atterrir flush sous le bord supérieur. */
h2[id] { scroll-margin-top: 32px; }

.empty {
    background: var(--egg-bg-surface);
    border: 1px solid var(--egg-border);
    border-radius: var(--radius-md);
    padding: 24px;
    color: var(--egg-text-secondary);
    text-align: center;
}

/* ========== BUTTONS ========== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 999px;
    background: var(--egg-bg-surface);
    border: 1px solid var(--egg-border-strong);
    color: var(--egg-text-primary);
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: background var(--transition-smooth), border-color var(--transition-smooth), transform 120ms ease;
}
.btn:hover {
    background: var(--egg-bg-muted);
    border-color: var(--egg-accent-soft);
}
.btn--primary {
    background: var(--egg-accent);
    border-color: var(--egg-accent);
    color: #fff;
}
.btn--primary:hover {
    background: var(--egg-accent-soft);
    border-color: var(--egg-accent-soft);
    color: #fff;
    transform: translateY(-1px);
}
.btn--ghost { background: transparent; border-color: var(--egg-border); }
.btn--ghost:hover { background: rgba(90, 74, 62, 0.04); }

/* Barre d'outils en haut de la liste d'agents d'une library (titre + recherche) */
.lib-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    margin: 28px 0 16px;
}
.lib-toolbar h2 { margin: 0; }
.lib-search {
    position: relative;
    display: flex;
    align-items: center;
    background: var(--egg-bg-surface);
    border: 1px solid var(--egg-border-strong);
    border-radius: 999px;
    padding: 0 12px;
    min-width: 240px;
    transition: border-color 120ms ease, box-shadow 120ms ease;
}
.lib-search:focus-within {
    border-color: var(--egg-accent);
    box-shadow: 0 0 0 3px rgba(90, 74, 62, 0.10);
}
.lib-search svg { width: 16px; height: 16px; color: var(--egg-text-faint); flex-shrink: 0; }
.lib-search input {
    flex: 1;
    border: 0;
    outline: 0;
    background: transparent;
    font: inherit;
    font-size: 14px;
    padding: 8px 10px;
    color: var(--egg-text-primary);
    min-width: 0;
}
.lib-search input::-webkit-search-cancel-button { display: none; }
.lib-search input::placeholder { color: var(--egg-text-faint); }

/* Card masquée par la recherche library */
.card--agent.is-hidden { display: none; }

/* ========== CARDS / GRID ========== */
.grid {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 16px;
}
.grid--libraries,
.grid--agents {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

.card {
    background: var(--egg-bg-surface);
    border: 1px solid var(--egg-border);
    border-radius: var(--radius-md);
    transition: border-color var(--transition-smooth), box-shadow var(--transition-smooth), transform 120ms ease;
}
.card:hover {
    border-color: var(--egg-accent-soft);
    box-shadow: var(--shadow-soft);
    transform: translateY(-1px);
}
.card a {
    display: block;
    padding: 18px;
    color: var(--egg-text-primary);
    text-decoration: none;
}
/* Card "Bientôt" : voile global + titre en italique. Le hover allume légèrement. */
.card.is-soon { opacity: 0.7; }
.card.is-soon:hover { opacity: 0.95; }
.card.is-soon .card__title { font-style: italic; }
.card__icon { font-size: 26px; margin-bottom: 10px; }
.card__title {
    font-family: var(--font-display);
    font-size: 17px;
    font-weight: 600;
    margin: 0 0 6px;
    color: var(--egg-text-primary);
}
.card__desc {
    font-size: 13.5px;
    color: var(--egg-text-secondary);
    margin: 0 0 10px;
    line-height: 1.5;
}
.card__meta { font-size: 12px; color: var(--egg-text-faint); margin: 0; }
.card__tags { margin: 6px 0 0; display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 999px;
    background: var(--egg-bubble-user);
    color: var(--egg-accent);
    font-size: 11.5px;
    font-weight: 500;
}

/* ========== AGENT VIEW ========== */
.agent-view { display: flex; flex-direction: column; gap: 28px; }

.agent-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 18px;
    flex-wrap: wrap;
    margin-bottom: 4px;
}
.agent-heading { min-width: 0; flex: 1; }
.agent-subtitle {
    font-family: var(--font-display);
    font-style: italic;
    font-size: 18px;
    color: var(--egg-accent);
    margin: -4px 0 12px;
    line-height: 1.35;
}
.agent-actions { display: flex; gap: 8px; flex-shrink: 0; align-items: center; }

.agent-soon {
    display: inline-flex;
    align-items: center;
    padding: 10px 18px;
    border-radius: 999px;
    background: var(--egg-bg-muted);
    border: 1px dashed var(--egg-border-strong);
    color: var(--egg-text-faint);
    font-size: 14px;
    font-weight: 500;
    font-style: italic;
}

/* Mobile : on bascule les actions sous le titre/sous-titre pour ne pas
   contracter le heading sur les petits écrans. */
@media (max-width: 640px) {
    .agent-header { flex-direction: column; align-items: stretch; }
    .agent-actions { margin-top: 4px; }
}

/* Sections typées de la fiche agent : Situation / Formules / Chemin / À l'issue / Posture / Limites */
.agent-section { margin: 0; }
.agent-section h2 {
    font-size: 13px;
    font-family: var(--font-body);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--egg-accent);
    margin: 0 0 10px;
}
.agent-section p { margin: 0 0 10px; line-height: 1.65; }
.agent-section p:last-child { margin-bottom: 0; }

.agent-formules {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.agent-formules li {
    padding: 10px 14px;
    background: var(--egg-bg-surface);
    border-left: 3px solid var(--egg-accent-soft);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-style: italic;
    color: var(--egg-text-primary);
    line-height: 1.5;
}

.agent-section--limits {
    padding: 18px 22px;
    background: var(--egg-bg-muted);
    border-radius: var(--radius-md);
    border: 1px solid var(--egg-border);
}
.agent-section--limits ul { margin: 0; padding-left: 22px; }
.agent-section--limits li { margin-bottom: 8px; line-height: 1.55; }
.agent-section--limits li:last-child { margin-bottom: 0; }

/* Card library agents : sous-titre italique sous le nom */
.card__subtitle {
    font-family: var(--font-display);
    font-style: italic;
    font-size: 14px;
    color: var(--egg-accent);
    margin: 0 0 10px;
    line-height: 1.4;
}

.fav-toggle {
    background: transparent;
    border: 1px solid var(--egg-border-strong);
    width: 38px;
    height: 38px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    color: var(--egg-text-faint);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: color 120ms ease, border-color 120ms ease, background 120ms ease;
}
.fav-toggle:hover {
    color: var(--egg-warning);
    border-color: var(--egg-warning);
    background: var(--egg-bg-surface);
}
.fav-toggle.is-fav {
    color: var(--egg-warning);
    border-color: var(--egg-warning);
    background: var(--egg-bg-surface);
}

.agent-details {
    background: var(--egg-bg-surface);
    border: 1px solid var(--egg-border);
    border-radius: var(--radius-md);
    padding: 18px 22px;
    display: grid;
    gap: 14px;
}

.agent-detail dt {
    font-size: 11.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--egg-accent);
    margin-bottom: 4px;
}
.agent-detail dd {
    margin: 0;
    color: var(--egg-text-primary);
    font-size: 14px;
    line-height: 1.55;
}

/* Mode "agent lancé" : on cache tout sauf l'iframe.
   L'iframe est positionnée en fixed pour couvrir toute la zone main
   (à droite de la sidebar en desktop, plein écran en mobile). */
body.agent-running .agent-header,
body.agent-running .agent-details { display: none; }

/* Burger mobile masqué quand l'agent tourne : l'iframe a son propre menu,
   et la croix de l'iframe sert à revenir à la description (où le burger
   réapparaît). */
body.agent-running .mobile-burger { display: none !important; }

/* Lock du scroll : la page ne doit pas pouvoir défiler quand l'agent
   tourne. On verrouille html ET body à la taille de la viewport, en
   utilisant 100dvh (dynamic viewport height) qui s'adapte à la barre
   d'URL mobile pour qu'on voie réellement le bas de l'iframe (zone de
   saisie de la plupart des agents). */
html.agent-running-html,
body.agent-running {
    overflow: hidden;
    height: 100dvh;
    overscroll-behavior: none;
}

.agent-frame-wrap {
    position: fixed;
    top: 0;
    left: var(--sidebar-w);
    right: 0;
    height: 100dvh;
    z-index: 50;
    border: 0;
    border-radius: 0;
    overflow: hidden;
    background: var(--egg-bg-surface);
}
.agent-frame-wrap iframe { width: 100%; height: 100%; border: 0; display: block; }
.agent-frame-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--egg-bg-muted);
    color: var(--egg-text-secondary);
    font-size: 14px;
    text-align: center;
    padding: 24px;
}
.agent-frame-wrap.blocked .agent-frame-overlay { background: var(--egg-bg-surface); }
.frame-blocked p { margin: 0 0 12px; max-width: 420px; }

/* Bouton fermer flottant en haut-droite de l'iframe */
.agent-frame-close {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 60;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid var(--egg-border);
    color: var(--egg-text-primary);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    box-shadow: 0 2px 10px rgba(47, 42, 38, 0.12);
    transition: background 120ms ease, color 120ms ease, transform 120ms ease;
}
.agent-frame-close:hover {
    background: #fff;
    color: var(--egg-error);
    transform: scale(1.05);
}

/* Mobile : iframe couvre tout l'écran (sidebar est cachée derrière de toute façon) */
@media (max-width: 880px) {
    .agent-frame-wrap { left: 0; }
}

/* ========== ADMIN ========== */
.admin-header {
    background: var(--egg-text-primary);
    color: #fff;
    padding: 14px 28px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.admin-header a { color: #fff; }
.admin-header a:hover { color: var(--egg-bg-muted); }
.admin-nav { display: flex; gap: 18px; font-size: 14px; }

.admin-wrap { max-width: 960px; margin: 0 auto; padding: 40px 28px; }

/* Formulaires admin — cible à la fois form.form (legacy) et .admin-form. */
form.form,
.admin-form { display: flex; flex-direction: column; gap: 18px; }
form.form label,
.admin-form > label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
    color: var(--egg-text-secondary);
    font-weight: 600;
}
form.form input[type=text],
form.form input[type=url],
form.form input[type=password],
form.form input[type=email],
form.form input[type=number],
form.form textarea,
form.form select,
.admin-form input[type=text],
.admin-form input[type=url],
.admin-form input[type=password],
.admin-form input[type=email],
.admin-form input[type=number],
.admin-form textarea,
.admin-form select {
    border: 1px solid var(--egg-border-strong);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    font: inherit;
    font-weight: 400;
    color: var(--egg-text-primary);
    background: var(--egg-bg-surface);
    width: 100%;
}
form.form textarea,
.admin-form textarea { min-height: 90px; resize: vertical; line-height: 1.5; }
form.form input:focus,
form.form textarea:focus,
form.form select:focus,
.admin-form input:focus,
.admin-form textarea:focus,
.admin-form select:focus {
    outline: none;
    border-color: var(--egg-accent);
    box-shadow: 0 0 0 3px rgba(90, 74, 62, 0.12);
}
form.form .form-actions,
.admin-form .form-actions {
    display: flex;
    gap: 10px;
    margin-top: 8px;
    padding-top: 18px;
    border-top: 1px solid var(--egg-border);
}
.admin-form .req { color: var(--egg-error); margin-left: 2px; }
.admin-form label small,
.admin-form label .hint {
    font-weight: 400;
    color: var(--egg-text-faint);
    font-size: 12px;
    margin-top: 4px;
}

/* Groupement de champs en sections (titre + bloc) */
.form-section {
    background: var(--egg-bg-surface);
    border: 1px solid var(--egg-border);
    border-radius: var(--radius-md);
    padding: 22px 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.form-section-head {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin: -4px 0 6px;
}
.form-section-head h2 {
    font-size: 14px;
    font-family: var(--font-body);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--egg-accent);
    margin: 0;
}
.form-section-head p {
    font-size: 12.5px;
    color: var(--egg-text-faint);
    margin: 0;
}

/* Rangée de champs côte à côte (icône + position, etc.) */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
@media (max-width: 540px) { .form-row { grid-template-columns: 1fr; } }

/* Aperçu d'icône (emoji ou img) à côté d'un champ */
.icon-input-wrap {
    display: grid;
    grid-template-columns: 56px 1fr;
    gap: 12px;
    align-items: center;
}
.icon-preview {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-sm);
    background: var(--egg-bg-muted);
    border: 1px solid var(--egg-border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    overflow: hidden;
    color: var(--egg-text-faint);
}
.icon-preview img { width: 100%; height: 100%; object-fit: cover; }
.icon-preview.empty::after {
    content: '?';
    font-family: var(--font-display);
    font-weight: 600;
}

/* Détails — fieldset avec lignes label/valeur supprimables */
.details-fieldset {
    border: 1px solid var(--egg-border);
    border-radius: var(--radius-md);
    padding: 18px 22px;
    background: var(--egg-bg-surface);
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin: 0;
}
.details-fieldset legend {
    font-size: 14px;
    font-family: var(--font-body);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--egg-accent);
    padding: 0 6px;
}
.details-fieldset > p {
    font-size: 12.5px;
    color: var(--egg-text-faint);
    margin: -4px 0 4px;
}
.detail-row {
    display: grid;
    grid-template-columns: 200px 1fr 32px;
    gap: 10px;
    align-items: start;
}
@media (max-width: 640px) { .detail-row { grid-template-columns: 1fr 32px; } }
.detail-row > input[type=text] { font-weight: 500; }
.detail-row button.link-danger {
    align-self: start;
    width: 32px;
    height: 32px;
    margin-top: 4px;
    border-radius: 50%;
    background: transparent;
    border: 1px solid var(--egg-border);
    color: var(--egg-text-faint);
    font-size: 18px;
    line-height: 1;
    text-decoration: none;
    transition: color 120ms ease, border-color 120ms ease, background 120ms ease;
}
.detail-row button.link-danger:hover {
    color: var(--egg-error);
    border-color: var(--egg-error);
    background: rgba(201, 123, 99, 0.08);
}

/* Tags : input chips visuel (parsing côté serveur via virgules) */
.tag-input-wrap {
    border: 1px solid var(--egg-border-strong);
    border-radius: var(--radius-sm);
    background: var(--egg-bg-surface);
    padding: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    min-height: 44px;
    cursor: text;
    transition: border-color 120ms ease, box-shadow 120ms ease;
}
.tag-input-wrap.focus,
.tag-input-wrap:focus-within {
    border-color: var(--egg-accent);
    box-shadow: 0 0 0 3px rgba(90, 74, 62, 0.12);
}
.tag-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 4px 4px 10px;
    background: var(--egg-bubble-user);
    color: var(--egg-accent);
    border-radius: 999px;
    font-size: 12.5px;
    font-weight: 600;
}
.tag-chip button {
    background: transparent;
    border: none;
    color: inherit;
    cursor: pointer;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    font-size: 14px;
    line-height: 1;
    padding: 0;
    opacity: 0.7;
}
.tag-chip button:hover { opacity: 1; }
.tag-input-wrap input.tag-input {
    border: 0;
    outline: 0;
    flex: 1;
    min-width: 120px;
    padding: 4px 8px;
    font: inherit;
    background: transparent;
    box-shadow: none !important;
}

/* Checkboxes Visible sur (tenants) sur library-edit */
.tenant-checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}
.tenant-check {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border: 1px solid var(--egg-border-strong);
    border-radius: 999px;
    cursor: pointer;
    font-size: 13.5px;
    font-weight: 500;
    background: var(--egg-bg-surface);
    transition: border-color 120ms ease, background 120ms ease;
}
.tenant-check:hover { border-color: var(--egg-accent-soft); }
.tenant-check input[type=checkbox] {
    appearance: none;
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border: 1px solid var(--egg-border-strong);
    border-radius: 4px;
    background: var(--egg-bg-surface);
    cursor: pointer;
    position: relative;
    flex-shrink: 0;
    margin: 0;
}
.tenant-check input[type=checkbox]:checked {
    background: var(--egg-accent);
    border-color: var(--egg-accent);
}
.tenant-check input[type=checkbox]:checked::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 5px;
    width: 4px;
    height: 8px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}
.tenant-check:has(input:checked) {
    border-color: var(--egg-accent);
    background: rgba(90, 74, 62, 0.06);
}

/* Aperçu logo dans tenant-edit (logo à gauche, formulaires upload + path à droite) */
.logo-preview-row {
    display: flex;
    gap: 24px;
    align-items: flex-start;
}
.logo-preview {
    width: 112px;
    height: 112px;
    border-radius: var(--radius-md);
    background: var(--egg-bg-muted);
    border: 1px solid var(--egg-border);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}
.logo-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.logo-preview .muted { font-size: 12px; padding: 6px; text-align: center; }
@media (max-width: 540px) {
    .logo-preview-row { flex-direction: column; align-items: stretch; }
    .logo-preview { width: 96px; height: 96px; }
}

.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 14px;
}
.alert--error { background: rgba(201, 123, 99, 0.15); color: #8a3d2c; border: 1px solid rgba(201, 123, 99, 0.35); }
.alert--ok    { background: rgba(127, 163, 141, 0.18); color: #355b48; border: 1px solid rgba(127, 163, 141, 0.40); }

table.admin-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--egg-bg-surface);
    border: 1px solid var(--egg-border);
    border-radius: var(--radius-md);
    overflow: hidden;
    font-size: 14px;
}
table.admin-table th,
table.admin-table td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--egg-border);
}
table.admin-table th {
    background: var(--egg-bg-muted);
    font-weight: 600;
    color: var(--egg-text-primary);
    font-size: 12.5px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
table.admin-table tr:last-child td { border-bottom: none; }
table.admin-table td a { color: var(--egg-accent); }

/* ========== ADMIN EXTRAS ========== */
.admin-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
}
.admin-toolbar h1 { margin: 0; }
.admin-toolbar h2 { margin: 0; font-size: 18px; }
.admin-toolbar a:not(.btn) {
    color: var(--egg-text-secondary);
    font-size: 13px;
}

.admin-section {
    margin-top: 36px;
    padding-top: 24px;
    border-top: 1px solid var(--egg-border);
}

.link-danger {
    background: none;
    border: none;
    color: var(--egg-error);
    cursor: pointer;
    font: inherit;
    padding: 0;
    text-decoration: underline;
}
.link-danger:hover { color: #8a3d2c; }
form.inline { display: inline; }
td.actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
td.actions a { white-space: nowrap; }
td code {
    background: var(--egg-bg-muted);
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 12px;
    color: var(--egg-text-secondary);
}
td.url-cell a {
    display: inline-block;
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: middle;
}
table.admin-table tbody tr:hover { background: var(--egg-bg-muted); }
table.admin-table .icon-cell {
    font-size: 20px;
    width: 36px;
    text-align: center;
    color: var(--egg-text-secondary);
}

/* ========== LOGIN ========== */
body.admin--login { background: var(--egg-bg-primary); }
.login-wrap {
    max-width: 360px;
    margin: 80px auto;
    padding: 32px;
    background: var(--egg-bg-surface);
    border: 1px solid var(--egg-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
}
.login-wrap h1 { font-size: 22px; margin: 0 0 18px; }
.login-wrap form { display: flex; flex-direction: column; gap: 16px; }
.login-wrap label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
    color: var(--egg-text-secondary);
    font-weight: 500;
}
.login-wrap input[type=password] {
    border: 1px solid var(--egg-border-strong);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    font: inherit;
    color: var(--egg-text-primary);
    background: var(--egg-bg-surface);
}
.login-wrap input[type=password]:focus {
    outline: none;
    border-color: var(--egg-accent);
    box-shadow: 0 0 0 3px rgba(90, 74, 62, 0.12);
}
.login-wrap p.muted { margin-top: 20px; font-size: 13px; text-align: center; }
.flash {
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    margin-bottom: 14px;
    font-size: 13.5px;
}
.flash--error { background: rgba(201, 123, 99, 0.15); color: #8a3d2c; border: 1px solid rgba(201, 123, 99, 0.35); }
.flash--ok    { background: rgba(127, 163, 141, 0.18); color: #355b48; border: 1px solid rgba(127, 163, 141, 0.40); }

/* ========== MOBILE BURGER + TAP SHIELD ========== */
/* Bouton burger : visible uniquement en mobile (≤880px).
   Attaché au <body>, hors du .main, pour que le transform du main ne le
   fasse pas bouger avec la translation. */
.mobile-burger {
    display: none;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 200;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--egg-bg-surface);
    border: 1px solid var(--egg-border-soft);
    color: var(--egg-text-primary);
    box-shadow: 0 2px 10px rgba(47, 42, 38, 0.10);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 120ms ease, color 120ms ease;
}
.mobile-burger:hover { background: var(--egg-bg-muted); color: var(--egg-accent); }
.mobile-burger svg { width: 22px; height: 22px; }

/* Tap shield : overlay sur le main quand la sidebar est ouverte, capte
   les clics pour fermer + flou léger derrière. Caché par défaut. */
.main-tap-shield {
    position: absolute;
    inset: 0;
    z-index: 100;
    display: none;
    cursor: pointer;
    background: rgba(245, 241, 235, 0.18);
    -webkit-backdrop-filter: blur(2px) saturate(0.92);
    backdrop-filter: blur(2px) saturate(0.92);
    transition: opacity 220ms ease;
}

/* ========== RESPONSIVE — PATTERN DRAWER (inspiré egg-app v2) ========== */
@media (max-width: 880px) {
    .app {
        grid-template-columns: 1fr;
        overflow: visible;
        position: relative;
    }

    /* Sidebar : fixed, full height, en dessous du main */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: calc(100vw - 28px);
        max-width: 360px;
        height: 100dvh;
        z-index: 1;
        border-right: 1px solid var(--egg-border);
    }

    /* Main : au-dessus de la sidebar, glisse à droite quand ouvert */
    .main {
        position: relative;
        z-index: 2;
        min-height: 100dvh;
        background: var(--egg-bg-primary);
        padding: 60px 22px 60px;
        transition: transform 280ms cubic-bezier(0.4, 0, 0.2, 1),
                    border-radius 280ms ease,
                    box-shadow 280ms ease;
        will-change: transform;
    }

    body.sidebar-open .main {
        transform: translateX(min(calc(100vw - 28px), 360px));
        border-top-left-radius: 20px;
        border-bottom-left-radius: 20px;
        box-shadow: -10px 0 30px rgba(47, 42, 38, 0.16);
        overflow: hidden;
    }

    body.sidebar-open .main-tap-shield { display: block; }

    /* Affiche le burger en mobile */
    .mobile-burger { display: flex; }

    /* Décale le contenu pour éviter qu'il passe sous le burger */
    .main-inner { padding-top: 8px; }

    /* Décale le brand de la sidebar pour laisser la place au burger
       (qui reste fixed top:12px left:12px, soit ~52px occupés). */
    .brand { padding-left: 56px; }
}

/* Admin : layout simple, juste un padding mobile */
@media (max-width: 720px) {
    .admin-wrap { padding: 24px 18px; }
    .admin-header { padding: 12px 18px; }
    .admin-toolbar { flex-direction: column; align-items: flex-start; }
}
