/* PersonaVault — UI 2.0, mobile-first */

/* =================================================================
   Thèmes : couleur principale (html[data-accent]) × mode (html[data-mode])
   -----------------------------------------------------------------
   - Chaque couleur principale définit une petite palette en triplets
     « r, g, b » (--c1-* teinte principale, --c2-* teinte voisine, --c3-* milieu
     du dégradé, --c4-* fin du dégradé, halos --orb-*) : les règles écrivent
     rgb(var(--acc)), ou rgba(var(--acc), .3) pour une transparence.
     Syntaxe à virgules exprès : avec rgb(r g b / a), Chrome calcule les
     dégradés autrement (léger écart avec les anciennes valeurs rgba()).
   - Les règles n'utilisent que des rôles (--acc, --acc-soft, --ink…), que le
     mode clair redéfinit (accent clair → accent foncé, encre blanche → encre sombre).
   - var(--elev, #0e0e18) : en mode sombre la variable n'existe pas et la valeur
     d'origine s'applique telle quelle ; seul le mode clair la définit.
   Valeurs par défaut (Violet + Sombre) = rendu historique, au pixel près.
   ================================================================= */
:root {
    color-scheme: dark;

    /* palette « Violet » (par défaut) */
    --c1-100: 237, 233, 254; --c1-200: 221, 214, 254; --c1-300: 196, 181, 253; --c1-400: 167, 139, 250;
    --c1-500: 139, 92, 246;  --c1-800: 91, 33, 182;   --c1-900: 76, 29, 149;
    --c2-200: 233, 213, 255; --c2-300: 216, 180, 254; --c2-800: 107, 33, 168;
    --c3-300: 240, 171, 252; --c3-500: 217, 70, 239;
    --c4-400: 244, 114, 182; --c4-500: 236, 72, 153;
    --orb-a: 109, 40, 217; --orb-b: 190, 24, 93; --orb-c: 8, 145, 178;
    --bubble: linear-gradient(135deg, #6d4aff 0%, #b91c9c 100%);
    --on-acc: #14061f;     /* texte posé sur le dégradé (boutons) */
    /* --on-grad : icônes de la barre du bas posées sur le dégradé (blanc si non défini) */
    --tint: #1b1630;       /* fond des avatars sans photo */

    /* rôles de l'accent (mode sombre) */
    --acc: var(--c1-400);
    --acc-deep: var(--c1-500);
    --acc-soft: var(--c1-300);
    --acc-pale: var(--c1-200);
    --acc-faint: var(--c1-100);
    --acc-alt: var(--c2-200);
    --acc-alt-2: var(--c2-300);
    --acc-mid: var(--c3-500);
    --acc-glow: var(--c3-300);
    --acc-end: var(--c4-400);
    --acc-hot: var(--c4-500);
    --grad: linear-gradient(135deg, rgb(var(--c1-400)) 0%, rgb(var(--c3-500)) 52%, rgb(var(--c4-400)) 100%);

    /* surfaces et textes (mode sombre) */
    --ink: 255, 255, 255;    /* « encre » des voiles, bordures et survols */
    --bg: #07070d;
    --panel: rgba(var(--ink), .045);
    --panel-2: rgba(var(--ink), .075);
    --border: rgba(var(--ink), .10);
    --border-soft: rgba(var(--ink), .06);
    --text: #f5f3ff;
    --muted: #b4b2c8;
    --muted-2: #8e8ba6;
    --violet: rgb(var(--acc-deep));
    --pink: rgb(var(--acc-hot));
    --cyan: #22d3ee;
    --danger: #f87171;
    --gold: #fbbf24;
    --radius: 22px;
    --shadow: 0 24px 60px -28px var(--sh, rgba(0, 0, 0, .95));
    --safe-b: env(safe-area-inset-bottom, 0px);
}

/* ------------------------------------------------- couleurs principales */
html[data-accent="ocean"] {
    --c1-100: 224, 242, 254; --c1-200: 186, 230, 253; --c1-300: 125, 211, 252; --c1-400: 56, 189, 248;
    --c1-500: 14, 165, 233;  --c1-800: 7, 89, 133;    --c1-900: 12, 74, 110;
    --c2-200: 165, 243, 252; --c2-300: 103, 232, 249; --c2-800: 21, 94, 117;
    --c3-300: 147, 197, 253; --c3-500: 59, 130, 246;
    --c4-400: 34, 211, 238;  --c4-500: 6, 182, 212;
    --orb-a: 29, 78, 216; --orb-b: 14, 116, 144; --orb-c: 109, 40, 217;
    --bubble: linear-gradient(135deg, #1d4ed8 0%, #0e7490 100%);
    --on-acc: #031525;
    --on-grad: var(--on-acc);   /* dégradé clair : icônes foncées */
    --tint: #0f1a2e;
}
html[data-accent="emerald"] {
    --c1-100: 209, 250, 229; --c1-200: 167, 243, 208; --c1-300: 110, 231, 183; --c1-400: 52, 211, 153;
    --c1-500: 16, 185, 129;  --c1-800: 6, 95, 70;     --c1-900: 6, 78, 59;
    --c2-200: 187, 247, 208; --c2-300: 134, 239, 172; --c2-800: 22, 101, 52;
    --c3-300: 94, 234, 212;  --c3-500: 20, 184, 166;
    --c4-400: 163, 230, 53;  --c4-500: 132, 204, 22;
    --orb-a: 4, 120, 87; --orb-b: 15, 118, 110; --orb-c: 77, 124, 15;
    --bubble: linear-gradient(135deg, #047857 0%, #0f766e 100%);
    --on-acc: #03140d;
    --on-grad: var(--on-acc);   /* dégradé clair : icônes foncées */
    --tint: #102620;
}
html[data-accent="coral"] {
    --c1-100: 255, 237, 213; --c1-200: 254, 215, 170; --c1-300: 253, 186, 116; --c1-400: 251, 146, 60;
    --c1-500: 249, 115, 22;  --c1-800: 154, 52, 18;   --c1-900: 124, 45, 18;
    --c2-200: 253, 230, 138; --c2-300: 252, 211, 77;  --c2-800: 146, 64, 14;
    --c3-300: 253, 164, 175; --c3-500: 244, 63, 94;
    --c4-400: 251, 191, 36;  --c4-500: 245, 158, 11;
    --orb-a: 194, 65, 12; --orb-b: 190, 18, 60; --orb-c: 180, 83, 9;
    --bubble: linear-gradient(135deg, #c2410c 0%, #be123c 100%);
    --on-acc: #1f0a03;
    --on-grad: var(--on-acc);   /* dégradé clair : icônes foncées */
    --tint: #2a1610;
}
html[data-accent="rose"] {
    --c1-100: 252, 231, 243; --c1-200: 251, 207, 232; --c1-300: 249, 168, 212; --c1-400: 244, 114, 182;
    --c1-500: 236, 72, 153;  --c1-800: 157, 23, 77;   --c1-900: 131, 24, 67;
    --c2-200: 254, 205, 211; --c2-300: 253, 164, 175; --c2-800: 159, 18, 57;
    --c3-300: 240, 171, 252; --c3-500: 217, 70, 239;
    --c4-400: 251, 113, 133; --c4-500: 244, 63, 94;
    --orb-a: 190, 24, 93; --orb-b: 162, 28, 175; --orb-c: 225, 29, 72;
    --bubble: linear-gradient(135deg, #be185d 0%, #a21caf 100%);
    --on-acc: #1f0613;
    --tint: #2a1323;
}
html[data-accent="amber"] {
    --c1-100: 254, 243, 199; --c1-200: 253, 230, 138; --c1-300: 252, 211, 77;  --c1-400: 251, 191, 36;
    --c1-500: 245, 158, 11;  --c1-800: 146, 64, 14;   --c1-900: 120, 53, 15;
    --c2-200: 254, 240, 138; --c2-300: 253, 224, 71;  --c2-800: 133, 77, 14;
    --c3-300: 253, 186, 116; --c3-500: 249, 115, 22;
    --c4-400: 250, 204, 21;  --c4-500: 234, 179, 8;
    --orb-a: 180, 83, 9; --orb-b: 194, 65, 12; --orb-c: 161, 98, 7;
    --bubble: linear-gradient(135deg, #b45309 0%, #c2410c 100%);
    --on-acc: #1f1303;
    --on-grad: var(--on-acc);   /* dégradé clair : icônes foncées */
    --tint: #2a2010;
}

/* ------------------------------------------------------------ mode clair
   Les deux blocs ci-dessous sont IDENTIQUES (le second sert au mode
   « Automatique » quand le téléphone est réglé en clair) : modifier les deux. */
html[data-mode="light"] {
    color-scheme: light;
    --acc: var(--c1-500);
    --acc-soft: var(--c1-800);
    --acc-pale: var(--c1-800);
    --acc-faint: var(--c1-900);
    --acc-alt: var(--c2-800);
    --acc-alt-2: var(--c2-800);
    --acc-glow: var(--c3-500);
    --ink: 22, 19, 42;
    --bg: #f4f3f8;
    --text: #16132a;
    --text-hi: #0d0b1c;
    --text-2: #2b2742;
    --muted: #4b4862;
    --muted-2: #5d5a74;
    --danger: #b91c1c;
    --err-t: #b91c1c;
    --warn-t: #92400e;
    --ok-t: #065f46;
    --info-t: #1d4ed8;
    --cyan-t: #0e7490;
    --card: #fff;
    --elev: #fff;
    --elev-2: #f1eff7;
    --elev-err: #fff1f2;
    --bar: rgba(255, 255, 255, .88);
    --bar-grad: linear-gradient(180deg, rgba(255, 255, 255, .92), rgba(248, 247, 252, .98));
    --media: #e7e5ef;
    --scrim: rgba(22, 19, 42, .42);
    --sh: rgba(40, 30, 80, .2);
    --sh-ring: rgba(40, 30, 80, .08);
    --inset: rgba(22, 19, 42, .04);
    --hero-l1: 80%;
    --hero-l2: 78%;
    --hero-img-o: .2;
    --aurora-o: .45;
    --grain-o: .2;
    --grad-text: linear-gradient(135deg, rgb(var(--c1-500)) 0%, rgb(var(--c3-500)) 52%, rgb(var(--c4-500)) 100%);
}
@media (prefers-color-scheme: light) {
    html[data-mode="auto"] {
        color-scheme: light;
        --acc: var(--c1-500);
        --acc-soft: var(--c1-800);
        --acc-pale: var(--c1-800);
        --acc-faint: var(--c1-900);
        --acc-alt: var(--c2-800);
        --acc-alt-2: var(--c2-800);
        --acc-glow: var(--c3-500);
        --ink: 22, 19, 42;
        --bg: #f4f3f8;
        --text: #16132a;
        --text-hi: #0d0b1c;
        --text-2: #2b2742;
        --muted: #4b4862;
        --muted-2: #5d5a74;
        --danger: #b91c1c;
        --err-t: #b91c1c;
        --warn-t: #92400e;
        --ok-t: #065f46;
        --info-t: #1d4ed8;
        --cyan-t: #0e7490;
        --card: #fff;
        --elev: #fff;
        --elev-2: #f1eff7;
        --elev-err: #fff1f2;
        --bar: rgba(255, 255, 255, .88);
        --bar-grad: linear-gradient(180deg, rgba(255, 255, 255, .92), rgba(248, 247, 252, .98));
        --media: #e7e5ef;
        --scrim: rgba(22, 19, 42, .42);
        --sh: rgba(40, 30, 80, .2);
        --sh-ring: rgba(40, 30, 80, .08);
        --inset: rgba(22, 19, 42, .04);
        --hero-l1: 80%;
        --hero-l2: 78%;
        --hero-img-o: .2;
        --aurora-o: .45;
        --grain-o: .2;
        --grad-text: linear-gradient(135deg, rgb(var(--c1-500)) 0%, rgb(var(--c3-500)) 52%, rgb(var(--c4-500)) 100%);
    }
}

/* étoile du logo (dégradé SVG) : suit la couleur principale */
#g stop:first-child, #g2 stop:first-child, #eg stop:first-child { stop-color: rgb(var(--c1-400)); }
#g stop:last-child, #g2 stop:last-child, #eg stop:last-child { stop-color: rgb(var(--c4-400)); }

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    min-height: 100dvh;
    background: var(--bg);
    color: var(--text);
    font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

[hidden] { display: none !important; }

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
img { display: block; }

::selection { background: rgba(var(--acc), .35); }

/* ------------------------------------------------------------- ambiance */

.aurora {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
    opacity: var(--aurora-o, 1);
}

.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(90px);
    opacity: .5;
}

.orb-1 { width: 460px; height: 460px; top: -160px; left: -120px; background: rgb(var(--orb-a)); }
.orb-2 { width: 420px; height: 420px; bottom: -180px; right: -140px; background: rgb(var(--orb-b)); opacity: .38; }
.orb-3 { width: 320px; height: 320px; top: 40%; left: 55%; background: rgb(var(--orb-c)); opacity: .18; }

body::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background-image: radial-gradient(rgba(var(--ink), .05) 1px, transparent 1px);
    background-size: 3px 3px;
    opacity: var(--grain-o, .35);
    mix-blend-mode: overlay;
}

/* --------------------------------------------------------------- topbar */

.topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    gap: 16px;
    height: 64px;
    padding: 0 16px;
    background: var(--bar, rgba(7, 7, 13, .72));
    backdrop-filter: blur(20px) saturate(140%);
    -webkit-backdrop-filter: blur(20px) saturate(140%);
    border-bottom: 1px solid var(--border-soft);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    letter-spacing: -.02em;
    font-size: 17px;
    white-space: nowrap;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 10px;
    background: rgba(var(--acc), .14);
    border: 1px solid rgba(var(--acc), .28);
}
.brand-mark svg { width: 19px; height: 19px; }
.brand-name em { font-style: normal; background: var(--grad-text, var(--grad)); -webkit-background-clip: text; background-clip: text; color: transparent; }

.topnav {
    display: none;
    gap: 4px;
    margin-left: 12px;
}
.topnav a {
    padding: 8px 14px;
    border-radius: 999px;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--muted);
    transition: .2s;
}
.topnav a:hover { color: var(--text); background: rgba(var(--ink), .05); }
.topnav a.is-active { color: var(--text); background: rgba(var(--ink), .09); }

.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.nav-chat-link { position: relative; }
.nav-chat-dot {
    position: absolute;
    top: 3px;
    right: 3px;
    z-index: 1;
    width: 10px;
    height: 10px;
    border: 1px solid var(--bg);
    border-radius: 50%;
    background: #ef4444;
}
.tab-ico .nav-chat-dot { top: 0; right: calc(50% - 15px); }
.logout-form { margin: 0; }

.icon-btn {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 11px;
    background: transparent;
    border: 1px solid transparent;
    color: var(--muted);
    cursor: pointer;
    transition: .2s;
}
.icon-btn:hover { color: var(--text); background: rgba(var(--ink), .06); border-color: var(--border); }

/* --------------------------------------------------------------- layout */

.page {
    position: relative;
    z-index: 1;
    max-width: 1180px;
    margin: 0 auto;
    padding: 22px 16px calc(104px + var(--safe-b));
}

.eyebrow {
    margin: 0 0 4px;
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--muted-2);
}

h1, h2, h3 { letter-spacing: -.025em; margin: 0; }

.lib-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin: 6px 0 18px;
}
.lib-title h1 { font-size: clamp(21px, 5.6vw, 38px); font-weight: 700; line-height: 1.2; }
.count {
    display: inline-block;
    margin-left: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    background: rgba(var(--ink), .07);
    border: 1px solid var(--border-soft);
    border-radius: 999px;
    padding: 2px 9px;
    vertical-align: middle;
}

/* ------------------------------------------------------------- recherche */

.searchbar {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 6px 0 14px;
    height: 50px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 15px;
    transition: .2s;
}
.searchbar:focus-within {
    border-color: rgba(var(--acc), .55);
    box-shadow: 0 0 0 4px rgba(var(--acc-deep), .13);
    background: rgba(var(--ink), .06);
}
.searchbar .ico { width: 18px; height: 18px; color: var(--muted-2); flex: 0 0 auto; }
.searchbar input {
    flex: 1;
    min-width: 0;
    height: 100%;
    border: 0;
    background: transparent;
    color: var(--text);
    font: inherit;
    font-size: 16px;
    outline: none;
}
.searchbar input::placeholder { color: var(--muted-2); }
.searchbar input::-webkit-search-cancel-button { display: none; }
.search-clear {
    display: grid;
    place-items: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(var(--ink), .09);
    color: var(--muted);
    font-size: 16px;
    line-height: 1;
}


.search-go {
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 0;
    background: var(--grad);
    color: var(--on-acc);
    cursor: pointer;
    transition: transform .18s, filter .18s;
    box-shadow: 0 8px 20px -10px rgba(var(--acc), .95);
}
.search-go svg { width: 18px; height: 18px; }
.search-go:hover { filter: brightness(1.1); transform: scale(1.05); }
.search-go:active { transform: scale(.95); }

.suggest {
    position: absolute;
    z-index: 60;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    padding: 6px;
    border-radius: 16px;
    border: 1px solid rgba(var(--ink), .14);
    background: var(--elev, #14141f);
    box-shadow: 0 26px 55px -22px var(--sh, #000);
    max-height: 286px;
    overflow: auto;
    animation: fade .14s both;
}
.suggest button {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    padding: 9px 11px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: 13.5px;
    text-align: left;
    cursor: pointer;
    transition: background .15s, color .15s;
}
.suggest button .hash { color: rgb(var(--acc-soft)); }
.suggest button em { margin-left: auto; font-style: normal; font-size: 11px; color: var(--muted-2); }
.suggest button:hover, .suggest button.is-active { background: rgba(var(--ink), .07); color: var(--text); }
.suggest .sug-free { color: var(--muted); }
.suggest .sug-free strong { color: var(--text-hi, #fff); font-weight: 600; }
.suggest .sug-empty { padding: 11px 12px; font-size: 12.5px; color: var(--muted-2); }

.filters-active {
    display: flex;
    align-items: center;
    gap: 7px;
    flex-wrap: wrap;
    margin-top: 10px;
}
.filter-pill {
    font-size: 11.5px;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(var(--acc), .14);
    border: 1px solid rgba(var(--acc), .28);
    color: rgb(var(--acc-pale));
    max-width: 46vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.btn-clear {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    border-radius: 11px;
    border: 1px solid rgba(248, 113, 113, .42);
    background: rgba(239, 68, 68, .13);
    color: var(--err-t, #fca5a5);
    font-size: 12.5px;
    font-weight: 600;
    transition: .18s;
}
.btn-clear .ico { width: 14px; height: 14px; }
.btn-clear:hover { background: rgba(239, 68, 68, .24); border-color: rgba(248, 113, 113, .7); color: var(--err-t, #fecaca); }

/* ----------------------------------------------------------------- chips */

.tagrow {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 14px 26px 4px 0;
    scrollbar-width: none;
    -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 26px), transparent);
    mask-image: linear-gradient(90deg, #000 calc(100% - 26px), transparent);
}
.tagrow::-webkit-scrollbar { display: none; }

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex: 0 0 auto;
    padding: 7px 13px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: rgba(var(--ink), .035);
    color: var(--muted);
    font-size: 12.5px;
    font-weight: 500;
    transition: .2s;
    white-space: nowrap;
}
.chip em { font-style: normal; font-size: 11px; color: var(--muted-2); }
.chip:hover { color: var(--text); border-color: rgba(var(--ink), .2); }
.chip.is-on {
    color: var(--text-hi, #fff);
    background: rgba(var(--acc-deep), .22);
    border-color: rgba(var(--acc), .55);
}
.chip.is-on em { color: rgba(var(--ink), .7); }
/* ------------------------------------------------------------------ grid */

.grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px 14px;
    margin-top: 20px;
}

.persona-card {
    display: flex;
    flex-direction: column;
    gap: 9px;
    min-width: 0;
    animation: rise .45s both;
}
.persona-card:nth-child(2) { animation-delay: .03s; }
.persona-card:nth-child(3) { animation-delay: .06s; }
.persona-card:nth-child(4) { animation-delay: .09s; }
.persona-card:nth-child(5) { animation-delay: .12s; }
.persona-card:nth-child(6) { animation-delay: .15s; }
.persona-card.is-archived { opacity: .55; }

.persona-media {
    position: relative;
    aspect-ratio: 4 / 5;
    overflow: hidden;
    border-radius: 18px;
    border: 1px solid var(--border-soft);
    background: var(--media, #12121c);
    transition: border-color .25s, transform .25s cubic-bezier(.2, .8, .3, 1), box-shadow .25s;
}
.persona-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .7s cubic-bezier(.2, .8, .3, 1);
}
.persona-card:hover .persona-media {
    transform: translateY(-3px);
    border-color: rgba(var(--ink), .2);
    box-shadow: 0 22px 40px -26px var(--sh, #000);
}
.persona-card:hover .persona-media img { transform: scale(1.04); }
.persona-card:active .persona-media { transform: scale(.99); }

.avatar-fallback {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    background:
        radial-gradient(120% 100% at 25% 15%, hsl(var(--hue) 85% 62% / .95), transparent 55%),
        radial-gradient(100% 100% at 85% 90%, hsl(calc(var(--hue) + 55) 80% 45% / .9), transparent 60%),
        linear-gradient(160deg, var(--tint), #0a0a14);
}
.avatar-fallback span {
    font-size: clamp(26px, 10vw, 40px);
    font-weight: 700;
    letter-spacing: -.03em;
    color: rgba(255, 255, 255, .55);
    text-shadow: 0 2px 20px rgba(0, 0, 0, .45);
}

.persona-heart {
    position: absolute;
    top: 8px;
    right: 8px;
    display: grid;
    place-items: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(10, 10, 18, .55);
    backdrop-filter: blur(6px);
    color: #fb7185;
}
.persona-heart svg { width: 13px; height: 13px; }

.persona-caption {
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding: 0 2px;
    min-width: 0;
}
.persona-caption strong {
    font-size: 14.5px;
    font-weight: 600;
    letter-spacing: -.01em;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: color .2s;
}
.persona-card:hover .persona-caption strong { color: var(--text-hi, #fff); }
.persona-caption span {
    font-size: 12.5px;
    color: var(--muted-2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.add-tile .persona-media {
    display: grid;
    place-items: center;
    border: 1px dashed rgba(var(--ink), .18);
    background: rgba(var(--ink), .02);
    color: var(--muted-2);
}
.add-tile .persona-media .ico { width: 26px; height: 26px; }
.add-tile .persona-caption strong { color: var(--muted); font-weight: 500; }
.add-tile:hover .persona-media { border-color: rgba(var(--acc), .55); background: rgba(var(--acc-deep), .07); color: var(--text); }
.add-tile:hover .persona-caption strong { color: var(--text); }


/* --------------------------------------------------------------- souvenirs */
.mem-intro { margin: 0 0 14px; }
.mem-add { margin-top: 14px; gap: 12px; }
.mem-add-foot { display: flex; align-items: flex-end; gap: 10px; }
.mem-add-foot .field { flex: 1; }
.mem-add-foot .btn { flex: 0 0 auto; }

.mem-list { display: flex; flex-direction: column; gap: 9px; margin-top: 16px; }
.mem-item {
    border: 1px solid var(--border-soft);
    border-radius: 16px;
    background: var(--card, rgba(var(--ink), .028));
    padding: 11px 13px;
    display: flex;
    flex-direction: column;
    gap: 7px;
}
.mem-item-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.mem-item-head form { margin: 0 0 0 auto; }
.mem-scope { font-size: 10.5px; color: var(--muted-2); margin-left: auto; padding-right: 4px; }
.mem-content { margin: 0; font-size: 13.5px; line-height: 1.5; color: var(--text); }

.cat, .conf {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .05em;
    text-transform: uppercase;
    padding: 3px 8px;
    border-radius: 999px;
    border: 1px solid transparent;
}
.cat-preference { background: rgba(var(--acc-deep), .16); border-color: rgba(var(--acc-deep), .3); color: rgb(var(--acc-soft)); }
.cat-fait { background: rgba(34, 211, 238, .13); border-color: rgba(34, 211, 238, .28); color: var(--cyan-t, #67e8f9); }
.cat-projet { background: rgba(52, 211, 153, .13); border-color: rgba(52, 211, 153, .28); color: var(--ok-t, #6ee7b7); }
.cat-contrainte { background: rgba(248, 113, 113, .13); border-color: rgba(248, 113, 113, .28); color: var(--err-t, #fca5a5); }
.cat-decision { background: rgba(251, 191, 36, .13); border-color: rgba(251, 191, 36, .28); color: var(--warn-t, #fcd34d); }

.conf { font-weight: 600; letter-spacing: .02em; text-transform: none; background: rgba(var(--ink), .06); border-color: var(--border); color: var(--muted); }
.conf-hypothese { color: var(--warn-t, #fcd34d); border-color: rgba(251, 191, 36, .28); background: rgba(251, 191, 36, .08); }
.conf-temporaire { color: var(--muted-2); }

.mem-edit summary {
    cursor: pointer;
    font-size: 11.5px;
    color: var(--muted-2);
    list-style: none;
}
.mem-edit summary::-webkit-details-marker { display: none; }
.mem-edit summary:hover { color: var(--text); }
.mem-edit[open] summary { margin-bottom: 10px; color: var(--muted); }
.mem-edit form { display: flex; flex-direction: column; gap: 9px; }

.mem-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12.5px;
    font-weight: 600;
    color: rgb(var(--acc-soft));
    padding: 7px 0;
}
.mem-link .ico { width: 14px; height: 14px; }
.mem-link:hover { color: rgb(var(--acc-alt)); }


/* panneau latéral / tiroir de la conversation */
.sheet-backdrop {
    position: fixed;
    inset: 0;
    z-index: 94;
    background: var(--scrim, rgba(4, 4, 9, .5));
    backdrop-filter: blur(2px);
    animation: fade .16s both;
}

.chat-sheet {
    position: fixed;
    z-index: 96;
    left: 10px;
    right: 10px;
    bottom: calc(96px + env(safe-area-inset-bottom, 0px));
    max-height: 66dvh;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 14px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: var(--elev, #0e0e18);
    box-shadow: 0 30px 70px -30px var(--sh, #000);
    opacity: 0;
    transform: translateY(10px) scale(.985);
    pointer-events: none;
    transition: opacity .18s ease, transform .22s cubic-bezier(.2, .8, .3, 1);
    scrollbar-width: none;
}
.chat-sheet::-webkit-scrollbar { width: 0; }
.chat-sheet.is-open { opacity: 1; transform: none; pointer-events: auto; }

.sheet-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
}
.sheet-head h2 { font-size: 15px; font-weight: 650; }
.sheet-body { display: flex; flex-direction: column; gap: 12px; }

.sheet-card {
    padding: 12px;
    border: 1px solid var(--border-soft);
    border-radius: 16px;
    background: rgba(var(--ink), .035);
}
.sheet-settings-group { display: grid; gap: 14px; }
.sheet-settings-group > :where(form, section) { min-width: 0; }
.sheet-settings-group > :where(.sheet-directive, .sheet-settings-form, .chat-danger) {
    border-top: 1px solid var(--border-soft);
    padding-top: 12px;
}
.scene-time { display: grid; gap: 10px; }
.scene-time .mem-head { gap: 8px; }
.scene-mode {
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(var(--ink), .06);
    color: var(--muted-2);
    font-size: 11px;
    font-weight: 650;
}
.scene-mode[data-forced="1"] {
    background: rgba(var(--acc), .14);
    color: var(--text);
}
.scene-moment { margin: 0; font-size: 18px; font-weight: 650; font-variant-numeric: tabular-nums; }
.scene-fields { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 8px; }
.scene-fields .input { width: 100%; min-width: 0; min-height: 40px; }
.scene-time .form-actions { justify-content: flex-start; }

.sheet-ctx {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px;
    border-radius: 16px;
    background: rgba(var(--ink), .035);
    border: 1px solid var(--border-soft);
}
.sheet-ctx-text { display: flex; flex-direction: column; gap: 2px; font-size: 11.5px; color: var(--muted-2); }
.sheet-ctx-text strong { font-size: 14.5px; color: var(--text); font-weight: 650; }

.sheet-form { display: flex; flex-direction: column; gap: 10px; }
.sheet-settings-form, .klipy-options { display: grid; gap: 10px; }
.sheet-settings-form > .form-actions { margin-top: 2px; }
.sheet-advanced { border-top: 1px dashed var(--border); padding-top: 10px; }
.sheet-advanced summary {
    cursor: pointer;
    font-size: 11.5px;
    color: var(--muted-2);
    list-style: none;
    margin-bottom: 8px;
}
.sheet-advanced summary::-webkit-details-marker { display: none; }
.sheet-advanced summary:hover { color: var(--text); }

@media (min-width: 900px) {
    .chat-sheet {
        left: auto;
        right: 20px;
        bottom: 20px;
        width: 380px;
        max-height: 78dvh;
        border-radius: 22px;
    }

    /* le chat se décale pour ne pas être recouvert par le panneau */
    .chat-main { transition: padding-right .22s ease; }
    body.sheet-open .chat-main { padding-right: 400px; }
}

.lms-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 11px;
    border-radius: 12px;
    background: rgba(var(--ink), .03);
    border: 1px solid var(--border-soft);
    font-size: 11.5px;
    color: var(--muted-2);
}
.lms-status .lms-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex: 0 0 auto;
    background: #7c7f8c;
    box-shadow: 0 0 0 3px rgba(var(--ink), .04);
}
.lms-status[data-state="ok"] { color: var(--ok-t, #9ff0c8); border-color: rgba(52, 211, 153, .28); background: rgba(52, 211, 153, .07); }
.lms-status[data-state="ok"] .lms-dot { background: #34d399; box-shadow: 0 0 0 3px rgba(52, 211, 153, .16); }
.lms-status[data-state="idle"] { color: var(--warn-t, #f4d49a); border-color: rgba(251, 191, 36, .26); background: rgba(251, 191, 36, .06); }
.lms-status[data-state="idle"] .lms-dot { background: #fbbf24; box-shadow: 0 0 0 3px rgba(251, 191, 36, .14); }
.lms-status[data-state="ko"] { color: var(--err-t, #f6b1b1); border-color: rgba(248, 113, 113, .28); background: rgba(248, 113, 113, .07); }
.lms-status[data-state="ko"] .lms-dot { background: #f87171; box-shadow: 0 0 0 3px rgba(248, 113, 113, .16); }
.lms-status[data-state="load"] .lms-dot { background: rgb(var(--acc)); animation: pulse-dot 1.1s infinite; }
.lms-status .lms-text { flex: 1 1 auto; line-height: 1.35; }
.lms-status .lms-text b { color: inherit; font-weight: 650; }
.lms-status .lms-refresh {
    flex: 0 0 auto;
    background: none;
    border: 0;
    color: inherit;
    opacity: .6;
    font-size: 14px;
    line-height: 1;
    padding: 2px 4px;
    cursor: pointer;
}
.lms-status .lms-refresh:hover { opacity: 1; }

.chat-model { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.chat-model [data-model-name] { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.model-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex: 0 0 auto;
    background: #6b6e7a;
    transition: background .2s ease, box-shadow .2s ease;
}
.model-dot[data-state="ok"] { background: #34d399; box-shadow: 0 0 0 2px rgba(52, 211, 153, .18); }
.model-dot[data-state="ko"] { background: #f87171; box-shadow: 0 0 0 2px rgba(248, 113, 113, .18); }
.model-dot[data-state="load"] { background: #60a5fa; box-shadow: 0 0 0 2px rgba(96, 165, 250, .2); animation: pulse-dot 1.1s infinite; }

.msg { flex-wrap: wrap; }

.msg-tool {
    width: 31px;
    height: 31px;
    display: grid;
    place-items: center;
    padding: 0;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: rgba(var(--ink), .05);
    color: var(--muted-2);
    cursor: pointer;
    transition: color .15s ease, border-color .15s ease, background .15s ease, transform .1s ease;
}
.msg-tool svg { width: 15px; height: 15px; display: block; }
.msg-tool:hover { color: var(--text); border-color: rgba(var(--ink), .22); background: rgba(var(--ink), .09); }
.msg-tool:active { transform: scale(.94); }
.msg-tool-edit:hover { color: rgb(var(--acc-soft)); border-color: rgba(var(--acc), .45); }
.msg-tool-del:hover { color: var(--danger); border-color: rgba(248, 113, 113, .4); background: rgba(248, 113, 113, .12); }
.msg-tool-save { color: var(--ok-t, #9ff0c8); border-color: rgba(52, 211, 153, .35); }
.msg-tool-save:hover { background: rgba(52, 211, 153, .14); color: var(--ok-t, #d1fae5); }

.msg-edit {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 7px;
}
.msg-edit textarea { width: 100%; font-size: 13px; line-height: 1.5; resize: vertical; }
.msg-edit-actions { display: flex; gap: 6px; justify-content: flex-end; }

.chat-send.is-stop { background: rgba(var(--ink), .16); color: var(--text-hi, #fff); }
.chat-send.is-stop:hover { background: rgba(var(--ink), .24); }
.chat-queue {
    flex: 0 0 auto;
    margin: 0;
    padding: 3px 14px;
    color: var(--muted);
    font-size: 12px;
    text-align: end;
}

.unread-dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    margin-right: 6px;
    background: rgb(var(--acc-end));
    box-shadow: 0 0 0 3px rgba(var(--acc-end), .18);
    vertical-align: middle;
}

.bubble-img {
    display: block;
    max-width: 220px;
    max-height: 280px;
    border-radius: 14px;
    margin-bottom: 6px;
    object-fit: cover;
    cursor: zoom-in;
}
.msg-user .bubble-img { margin-left: auto; }
.bubble.chat-klipy { margin: 0; width: min(236px, 100%); padding: 7px; }
.chat-klipy :is(img, video) { display: block; width: 100%; height: auto; border-radius: 14px; }
.chat-klipy figcaption { margin-top: 3px; font-size: 10px; color: var(--muted-2); }

/* le champ et son trombone forment une seule pastille */
.chat-field {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: flex-end;
    gap: 2px;
    padding: 0 4px 0 8px;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: rgba(var(--ink), .05);
    transition: border-color .2s;
}
.chat-field:focus-within { border-color: rgba(var(--acc), .55); }
.chat-field .chat-input {
    border: 0;
    background: transparent;
    padding-left: 2px;
    padding-right: 8px;
}
/* le halo de focus appartient à la pastille, pas au champ interne */
.chat-field .chat-input:focus { box-shadow: none; }

.chat-attach {
    flex: 0 0 auto;
    width: 26px;
    height: 26px;
    margin-bottom: 9px;
    display: grid;
    place-items: center;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--muted-2);
    cursor: pointer;
    transition: color .15s, transform .15s;
}
.chat-attach svg { width: 18px; height: 18px; }
.chat-attach:hover { color: var(--text); }
.chat-attach:active { transform: scale(.92); }

.attach-preview {
    position: relative;
    align-self: flex-start;
    margin: 0 14px 8px;
    width: 76px;
    height: 76px;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border);
}
.attach-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.attach-preview button {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 0;
    background: rgba(0, 0, 0, .65);
    color: #fff;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
}

.chat-older {
    display: flex;
    justify-content: center;
    padding: 4px 0 12px;
}
.chat-older .btn { font-size: 11.5px; padding: 7px 14px; }
.chat-source-excerpt { align-self: stretch; }
.chat-source-excerpt p { margin: 10px 0 0; overflow-wrap: anywhere; }

.directive-text {
    margin: 0 0 6px;
    font-size: 12.5px;
    line-height: 1.6;
    color: var(--text);
}

.persona-summary {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 12px;
    border-radius: 14px;
    background: var(--card, rgba(var(--ink), .03));
    border: 1px solid var(--border-soft);
}
.perso-line {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 10px;
    margin: 0;
    font-size: 11.5px;
    color: var(--muted-2);
}
.perso-line b { color: var(--text); font-weight: 650; }
.perso-directive { font-style: italic; }

.field-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
.mini-link {
    background: none;
    border: 0;
    padding: 0;
    font-size: 11px;
    font-weight: 600;
    color: rgb(var(--acc-soft));
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
}
.mini-link:disabled { opacity: .55; text-decoration: none; }

.persona-ai {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-top: 16px;
    border-top: 1px solid var(--border-soft);
}
.persona-ai-head h3 { font-size: 13.5px; font-weight: 650; }
.persona-ai-head .hint { margin: 2px 0 0; }

.prompt-block {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 14px 0;
    border-top: 1px solid var(--border-soft);
}
.prompt-block:first-of-type { border-top: 0; padding-top: 0; }
.prompt-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.prompt-head h3 { font-size: 13px; font-weight: 650; display: flex; align-items: center; gap: 8px; }
.pill {
    padding: 2px 8px;
    border-radius: 99px;
    font-size: 9.5px;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    background: rgba(var(--acc), .18);
    color: rgb(var(--acc-pale));
}
.prompt-area { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11.5px; line-height: 1.55; min-height: 120px; }
.prompt-head .mini { cursor: pointer; }

.range-field :is(span, label) b {
    display: inline-block;
    min-width: 34px;
    padding: 1px 7px;
    border-radius: 99px;
    background: rgba(var(--acc), .18);
    color: rgb(var(--acc-faint));
    font-size: 11px;
    font-weight: 650;
    text-align: center;
}
.inline-choice {
    border: 0;
    padding: 0;
    background: transparent;
    color: rgb(var(--acc-soft));
    font: inherit;
    font-weight: 650;
    text-transform: lowercase;
    text-decoration: underline;
    text-underline-offset: .18em;
    cursor: pointer;
}
.inline-choice:hover { color: var(--text); }
.range {
    width: 100%;
    height: 26px;
    appearance: none;
    background: transparent;
    cursor: pointer;
}
.range::-webkit-slider-runnable-track {
    height: 4px;
    border-radius: 99px;
    background: rgba(var(--ink), .14);
}
.range::-webkit-slider-thumb {
    appearance: none;
    width: 18px;
    height: 18px;
    margin-top: -7px;
    border-radius: 50%;
    background: rgb(var(--acc));
    border: 2px solid var(--elev, #0d0d17);
    box-shadow: 0 2px 8px rgba(0, 0, 0, .4);
}
.range::-moz-range-track { height: 4px; border-radius: 99px; background: rgba(var(--ink), .14); }
.range::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: rgb(var(--acc));
    border: 2px solid var(--elev, #0d0d17);
}

.backup-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 16px;
    margin-bottom: 14px;
    border-radius: 16px;
    background: var(--card, rgba(var(--ink), .03));
    border: 1px solid var(--border-soft);
}
.backup-card h3 { font-size: 13.5px; font-weight: 650; }
.backup-card input[type="file"] { font-size: 11.5px; padding: 8px; }
.backup-card .form-actions { margin-top: 4px; }

.settings-block {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-top: 14px;
    border-top: 1px solid var(--border-soft);
}
.settings-block h3 { font-size: 13px; font-weight: 650; }
.row-tight { gap: 8px; align-items: flex-end; }
.row-tight .field { flex: 1 1 0; }

.fact-box {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-top: 14px;
    border-top: 1px solid var(--border-soft);
}
.fact-hint { margin: -4px 0 0; font-size: 11px; color: var(--muted-2); line-height: 1.4; }

.fact-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 190px;
    overflow-y: auto;
    scrollbar-width: thin;
}
.fact-list li {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 11px;
    background: rgba(var(--ink), .04);
    border: 1px solid var(--border-soft);
    font-size: 11.5px;
    line-height: 1.45;
}
.fact-txt { flex: 1 1 auto; }
.fact-del {
    flex: 0 0 auto;
    background: none;
    border: 0;
    color: var(--muted-2);
    font-size: 15px;
    line-height: 1;
    padding: 0 2px;
    cursor: pointer;
}
.fact-del:hover { color: var(--danger); }
.fact-empty { justify-content: center; color: var(--muted-2); font-style: italic; }

.fact-add { display: flex; gap: 6px; }
.fact-add .input { flex: 1 1 auto; font-size: 12px; padding: 8px 10px; }

.recall-box {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-top: 14px;
    border-top: 1px solid var(--border-soft);
}
.recall-list { max-height: 260px; }
.recall-item { flex-direction: column; align-items: stretch; gap: 8px; }
.recall-body { display: flex; flex-direction: column; gap: 3px; }
.recall-meta { font-size: 9.5px; letter-spacing: .03em; text-transform: uppercase; color: var(--muted-2); }
.recall-txt { margin: 0; font-size: 11.5px; line-height: 1.45; color: var(--text); }
.recall-item .msg-tool { align-self: flex-start; }

.msg-memory {
    align-self: flex-start;
    display: flex;
    align-items: flex-start;
    gap: 7px;
    max-width: 86%;
    margin: 2px 0 2px 34px;
    padding: 7px 11px;
    border-radius: 11px;
    background: rgba(52, 211, 153, .06);
    border: 1px dashed rgba(52, 211, 153, .3);
    font-size: 10.5px;
    line-height: 1.45;
    color: var(--ok-t, #a7f3d0);
    animation: fade .2s both;
}
.msg-memory svg { width: 13px; height: 13px; flex: 0 0 auto; margin-top: 1px; opacity: .8; }
.msg-memory span { min-width: 0; overflow-wrap: anywhere; }

/* le persona est allé chercher une information (internet, Wikipédia, météo) */
.msg-web {
    align-self: flex-start;
    display: flex;
    align-items: flex-start;
    gap: 7px;
    max-width: 86%;
    margin: 2px 0 2px 34px;
    padding: 7px 11px;
    border-radius: 11px;
    background: rgba(96, 165, 250, .08);
    border: 1px solid rgba(96, 165, 250, .4);
    font-size: 10.5px;
    line-height: 1.45;
    color: var(--info-t, #93c5fd);
    animation: fade .2s both;
    overflow-wrap: anywhere;
}
.msg-web svg { width: 13px; height: 13px; flex: 0 0 auto; margin-top: 1px; }

.msg-loading {
    align-self: center;
    margin: 2px 0 10px;
    padding: 4px 12px;
    border-radius: 99px;
    background: rgba(var(--ink), .05);
    border: 1px solid var(--border-soft);
    font-size: 11px;
    color: var(--muted-2);
    letter-spacing: .01em;
}

.lms-actions .btn { width: 100%; }

.lms-progress {
    padding: 12px 10px 10px;
    border-radius: 14px;
    background: rgba(var(--ink), .025);
    border: 1px solid var(--border-soft);
}

.lms-steps {
    list-style: none;
    display: flex;
    align-items: flex-start;
    margin: 0;
    padding: 0;
}
.lms-steps li {
    position: relative;
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    font-size: 10px;
    line-height: 1.2;
    color: var(--muted-2);
    text-align: center;
}
.lms-steps li::before {
    content: "";
    position: absolute;
    top: 9px;
    right: calc(50% + 13px);
    width: calc(100% - 26px);
    height: 2px;
    border-radius: 2px;
    background: rgba(var(--ink), .09);
    transition: background .25s ease;
}
.lms-steps li:first-child::before { display: none; }

.lms-steps .n {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: 10px;
    font-weight: 650;
    background: rgba(var(--ink), .06);
    border: 1px solid var(--border);
    color: var(--muted-2);
    transition: background .2s ease, border-color .2s ease, color .2s ease;
}
.lms-steps li[data-state="done"] { color: var(--ok-t, #9ff0c8); }
.lms-steps li[data-state="done"] .n { background: #34d399; border-color: #34d399; color: #06251a; }
.lms-steps li[data-state="done"]::before { background: rgba(52, 211, 153, .5); }
.lms-steps li[data-state="active"] { color: var(--info-t, #cfe0ff); }
.lms-steps li[data-state="active"] .n {
    background: rgba(96, 165, 250, .18);
    border-color: #60a5fa;
    color: var(--info-t, #dbeafe);
    animation: pulse-dot 1.1s infinite;
}
.lms-steps li[data-state="fail"] { color: var(--err-t, #f6b1b1); }
.lms-steps li[data-state="fail"] .n { background: rgba(248, 113, 113, .18); border-color: #f87171; color: var(--err-t, #fecaca); }

.lms-timer {
    margin: 8px 0 0;
    text-align: center;
    font-size: 10.5px;
    color: var(--muted-2);
    font-variant-numeric: tabular-nums;
}

#fb-modal .modal-card { max-width: 420px; }
#fb-modal .fb-msg { font-size: 12.5px; color: var(--text); margin: 0 0 6px; }
#fb-modal .fb-hint { font-size: 11.5px; color: var(--muted-2); margin: 0 0 14px; line-height: 1.5; }

@keyframes pulse-dot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: .45; transform: scale(.82); }
}

/* --------------------------------------------------------------------- chat */

.page-chat {
    padding: 0;
    max-width: none;
    height: calc(100dvh - 64px);
    overflow: hidden;
}

.chat-shell {
    display: flex;
    height: 100%;
    max-width: 1320px;
    margin: 0 auto;
    width: 100%;
}

.chat-side {
    display: none;
    width: 268px;
    flex: 0 0 auto;
    border-right: 1px solid var(--border-soft);
    padding: 12px 10px;
    overflow-y: auto;
}
.chat-side-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 8px 10px;
    font-size: 11px;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--muted-2);
    font-weight: 600;
}
.chat-side-row {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 9px;
    border-radius: 12px;
    font-size: 13px;
    color: var(--muted);
    transition: .18s;
}
.chat-side-row:hover { background: rgba(var(--ink), .05); color: var(--text); }
.chat-side-row.is-on { background: rgba(var(--acc-deep), .16); color: var(--text-hi, #fff); }
.chat-side-mono {
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    border-radius: 8px;
    background: rgba(var(--acc), .18);
    color: rgb(var(--acc-pale));
    font-size: 10.5px;
    font-weight: 700;
    flex: 0 0 auto;
}
.chat-side-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-side-mono img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }
.chat-side-name strong { display: block; overflow: hidden; text-overflow: ellipsis; color: var(--text-hi, #fff); }
.chat-side-name strong ~ [data-side-title] { display: block; overflow: hidden; text-overflow: ellipsis; color: var(--muted); font-size: 11px; }

.chat-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.chat-head {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border-soft);
    background: var(--bar, rgba(9, 9, 16, .6));
    backdrop-filter: blur(12px);
    flex: 0 0 auto;
}
.chat-more { position: relative; flex: 0 0 auto; }
.chat-more summary {
    list-style: none;
    cursor: pointer;
    border-radius: 50%;
}
.chat-more summary:is(:hover, :focus-visible), .chat-more[open] summary {
    background: rgba(var(--ink), .12);
    color: var(--text);
}
.chat-more summary::-webkit-details-marker { display: none; }
.chat-more-panel {
    position: absolute;
    inset-inline-end: 0;
    top: calc(100% + 8px);
    width: min(238px, calc(100vw - 24px));
    padding: 5px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--elev, #151420);
    box-shadow: var(--shadow);
}
.chat-menu-action {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px;
    border: 0;
    border-radius: 10px;
    background: none;
    color: var(--text);
    font: inherit;
    font-size: 14px;
    text-align: start;
    cursor: pointer;
}
.chat-menu-action:is(:hover, :focus-visible) { background: var(--panel-2); }
.chat-menu-action svg { width: 20px; height: 20px; flex: 0 0 auto; color: var(--muted); }

.chat-find {
    position: absolute;
    inset: 0;
    z-index: 10;
    display: flex;
    flex-direction: column;
    background: var(--bg);
}
.chat-find-head,
.chat-find-footer {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-soft);
    background: var(--elev, #100f19);
}
.chat-find-field {
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0;
    padding-inline: 12px 4px;
    border: 1px solid var(--border);
    border-radius: 22px;
    background: var(--panel);
}
.chat-find-field:focus-within { border-color: rgba(var(--acc), .7); }
.chat-find-field input {
    width: 100%;
    min-width: 0;
    min-height: 42px;
    border: 0;
    outline: 0;
    background: none;
    color: var(--text);
    font: inherit;
    font-size: 16px;
}
.chat-find-field .icon-btn { border-color: transparent; }
.chat-find-list { flex: 1; min-height: 0; overflow: auto; }
.chat-find-list ul { list-style: none; margin: 0 auto; padding: 0 12px; max-width: 780px; }
.chat-find-result {
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr);
    align-items: start;
    gap: 11px;
    width: 100%;
    padding: 12px 3px;
    border: 0;
    border-bottom: 1px solid var(--border-soft);
    background: none;
    color: var(--text);
    font: inherit;
    text-align: start;
    cursor: pointer;
}
.chat-find-result:is(:hover, :focus-visible, [aria-current="true"]) { background: var(--panel); }
.chat-find-result .chat-avatar { display: grid; place-items: center; font-size: 15px; font-weight: 700; }
.chat-find-result-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.chat-find-result-head strong { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 14px; }
.chat-find-result time { flex: 0 0 auto; color: var(--muted-2); font-size: 11.5px; }
.chat-find-excerpt {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    overflow-wrap: anywhere;
    color: var(--muted);
    font-size: 13.5px;
    line-height: 1.45;
}
.chat-find-message { margin: 18px 14px; color: var(--muted); text-align: center; }
.chat-find-list > .btn { display: block; margin: 12px auto; }
.chat-find-reading { display: flex; position: relative; flex: 1; min-height: 0; }
.chat-find-reading .chat-scroll { padding-bottom: 108px; }
.chat-find-steps { position: absolute; bottom: 10px; inset-inline-end: 12px; display: grid; gap: 6px; }
.chat-find-steps .icon-btn { background: var(--elev, #181723); }
.chat-find mark { background: rgba(var(--acc), .28); color: inherit; border-radius: 3px; }
.chat-find .msg-user mark { background: rgba(255, 255, 255, .3); }
.chat-find .is-find-current :is(.bubble, .bubble-img) { outline: 1px solid rgb(var(--acc-soft)); outline-offset: 2px; }
.chat-find-footer { border-top: 1px solid var(--border-soft); border-bottom: 0; padding-bottom: calc(8px + var(--safe-b)); }
.chat-find-footer span { color: var(--muted); font-size: 12.5px; }
.chat-find-mode {
    margin-inline-start: auto;
    min-height: 40px;
    padding: 5px 8px;
    border: 0;
    border-radius: 10px;
    background: rgba(var(--acc), .12);
    color: rgb(var(--acc-faint));
    font: inherit;
    font-size: 12.5px;
    font-weight: 650;
    cursor: pointer;
}
.chat-find-date { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 12px; }
.chat-find-date label { color: var(--muted); font-size: 13px; }
.chat-find-date input { width: auto; max-width: 100%; }
.chat-id { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
a.chat-id { color: inherit; text-decoration: none; border-radius: 12px; transition: opacity .15s; }
a.chat-id:active { opacity: .72; }
.chat-head .ctx-ring-btn { width: 34px; height: 34px; flex: 0 0 auto; }
.chat-avatar {
    width: 36px;
    height: 36px;
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    flex: 0 0 auto;
    border: 1px solid var(--border-soft);
}
.chat-avatar img { width: 100%; height: 100%; object-fit: cover; }
.chat-avatar .avatar-fallback span { font-size: 13px; transform: none; }
.chat-avatar-lg { width: 84px; height: 84px; border-radius: 24px; }
.chat-avatar-lg .avatar-fallback span { font-size: 30px; }

.chat-id-text { min-width: 0; display: flex; flex-direction: column; }
.chat-id-text strong { font-size: 14.5px; font-weight: 600; }
.chat-id-text span { font-size: 11px; color: var(--muted-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------------------------------------------- préférences d'affichage */
.tabs {
    display: flex;
    gap: 6px;
    margin: 0 0 16px;
    padding: 5px;
    border-radius: 14px;
    background: rgba(var(--ink), .04);
    border: 1px solid var(--border-soft);
    overflow-x: auto;
    flex-wrap: nowrap;
    scroll-behavior: smooth;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
    mask-image: linear-gradient(to right, #000 0, #000 calc(100% - 26px), transparent 100%);
}
.tabs::-webkit-scrollbar { display: none; }
.tabs.is-end { mask-image: none; }

.tab {
    flex: 0 0 auto;
    white-space: nowrap;
    padding: 9px 13px;
    border-radius: 10px;
    border: 0;
    background: none;
    color: var(--muted-2);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    scroll-snap-align: center;
    transition: background .18s ease, color .18s ease;
}
.tab.is-on { background: rgba(var(--acc), .18); color: rgb(var(--acc-faint)); }
.tab-panel { animation: fade .18s both; }

.ui-preview {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px;
    border-radius: 16px;
    border: 1px dashed var(--border);
    background: var(--inset, rgba(0, 0, 0, .28));
}
.ui-preview[data-density="compact"] { gap: 4px; }
.pv-msg { display: flex; gap: 8px; align-items: flex-start; max-width: var(--pv-width, 86%); }
.pv-bot { align-self: flex-start; }
.pv-user { align-self: flex-end; }
.pv-av {
    width: 24px;
    height: 24px;
    border-radius: 8px;
    background: rgba(var(--ink), .12);
    display: grid;
    place-items: center;
    font-size: 10px;
    flex: 0 0 auto;
}
.ui-preview[data-avatars="0"] .pv-av { display: none; }
.pv-bubble {
    padding: 9px 13px;
    border-radius: 16px;
    background: rgba(var(--ink), .07);
    border: 1px solid var(--border-soft);
    font-size: var(--pv-font, 14.5px);
    line-height: 1.5;
}
.pv-user .pv-bubble {
    background: var(--bubble);
    border-color: transparent;
    color: #ffffff;
}
.ui-preview[data-bubble="plat"] .pv-bubble { border-radius: 8px; background: rgba(var(--ink), .05); border-color: transparent; }
.ui-preview[data-bubble="carte"] .pv-bubble { border-radius: 14px; background: rgba(var(--ink), .09); box-shadow: 0 10px 26px -20px var(--sh, #000); }

/* les mêmes variantes sur les vraies conversations */
html .bubble { font-size: var(--chat-font, 14.5px); }
html[data-width="large"] .msg { max-width: 96%; }
html[data-density="compact"] .chat-scroll { gap: 4px; }
html[data-avatars="0"] .msg-avatar { display: none; }
html[data-bubble="plat"] .msg-bot .bubble { border-radius: 8px; background: rgba(var(--ink), .05); border-color: transparent; }
html[data-bubble="carte"] .msg-bot .bubble { border-radius: 14px; background: rgba(var(--ink), .09); box-shadow: 0 10px 26px -22px var(--sh, #000); }

.chat-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 18px 14px 10px;
    display: flex;
    flex-direction: column;
    gap: 9px;
    scroll-behavior: smooth;
}

.msg { display: flex; gap: 8px; align-items: flex-start; max-width: 86%; }
.chat-room .page-chat { height: 100dvh; }
.chat-room .topbar { display: none; }
.msg-bot { align-self: flex-start; }
.msg-user { align-self: flex-end; flex-direction: row-reverse; }

.msg-avatar {
    width: 26px;
    height: 26px;
    border-radius: 9px;
    overflow: hidden;
    position: relative;
    flex: 0 0 auto;
    margin-top: 3px;
}
.msg-avatar img { width: 100%; height: 100%; object-fit: cover; }
.msg-avatar .avatar-fallback span { font-size: 10px; transform: none; }

.bubble {
    padding: 10px 14px;
    border-radius: 18px;
    font-size: 14.5px;
    line-height: 1.5;
    background: rgba(var(--ink), .06);
    border: 1px solid var(--border-soft);
    color: var(--text);
    word-break: break-word;
    overflow-wrap: anywhere;
}
.bubbles {
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: flex-start;
    min-width: 0;
}
.msg-user > .bubbles { align-items: flex-end; }
.msg-user > .bubbles:has(> .chat-quote) {
    align-items: stretch;
    gap: 2px;
    padding: 6px;
    border-radius: 18px 18px 6px 18px;
    background: var(--bubble);
    color: #fff;
}
.msg-user > .bubbles:has(> .chat-quote) .bubble { padding: 4px 8px 6px; background: none; }
.chat-quote {
    display: grid;
    min-width: 0;
    max-width: 100%;
    gap: 2px;
    padding: 6px 10px;
    border: 0;
    border-inline-start: 3px solid rgb(var(--acc-soft));
    border-radius: 8px;
    background: rgba(var(--acc), .09);
    color: inherit;
    font: inherit;
    font-size: 12.5px;
    line-height: 1.4;
    text-align: start;
}
.msg-user .chat-quote { background: rgba(0, 0, 0, .18); }
button.chat-quote { cursor: pointer; }
button.chat-quote:hover { border-inline-start-color: rgb(var(--acc)); }
.chat-quote strong, .chat-quote span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-quote span { opacity: .86; }
.chat-quote-draft {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 6px;
    padding: 4px 12px 0;
    flex: 0 0 auto;
}
.chat-quote-draft[hidden] { display: none; }
.is-quote-target .bubble { outline: 2px solid rgb(var(--acc-soft)); outline-offset: 2px; }
.msg-bubble {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    min-width: 0;
    max-width: 100%;
    gap: 4px;
}
.msg-bubble > .bubble { max-width: 100%; }

.msg-bot .bubble { border-bottom-left-radius: 6px; }
.msg-bot .bubble a { text-decoration: underline; }
.msg-user .bubble {
    /* texte blanc sur un dégradé plus profond : lisible sur mobile */
    background: var(--bubble);
    border: 0;
    color: #ffffff;
    font-weight: 500;
    border-bottom-right-radius: 6px;
    text-shadow: 0 1px 1px rgba(0, 0, 0, .18);
}

.msg-godmode .godmode-tag {
    color: var(--warn-t, #fcd34d);
    font-size: 10px;
    font-weight: 750;
    letter-spacing: .06em;
    text-transform: uppercase;
}
.msg-user.msg-godmode .bubble {
    background: var(--panel-2);
    border: 1px solid var(--border-soft);
    border-inline-end: 3px solid var(--warn-t, #fcd34d);
    color: var(--text);
    font-style: italic;
    font-weight: 400;
    text-shadow: none;
    white-space: pre-wrap;
}

.msg-notice {
    align-self: center;
    max-width: 92%;
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 12px;
    line-height: 1.5;
    text-align: center;
    color: var(--warn-t, #fcd34d);
    background: rgba(251, 191, 36, .08);
    border: 1px dashed rgba(251, 191, 36, .32);
}

.typing .bubble {
    display: flex;
    gap: 6px;
    align-items: center;
    padding: 15px 17px 13px;
}
.typing .bubble i {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(var(--ink), .82);
    animation: dot-hop 1.16s cubic-bezier(.34, .72, .38, 1) infinite;
    will-change: transform;
}
.typing .bubble i:nth-child(2) { animation-delay: .13s; }
.typing .bubble i:nth-child(3) { animation-delay: .26s; }

/* trois sauts décalés, puis ~500 ms de pause, en boucle */
@keyframes dot-hop {
    0%   { transform: translateY(0);     opacity: .45; }
    16%  { transform: translateY(-8px);  opacity: 1; }
    33%  { transform: translateY(0);     opacity: .6; }
    100% { transform: translateY(0);     opacity: .45; }
}

.chat-composer {
    flex: 0 0 auto;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--border-soft);
    background: var(--bar, rgba(9, 9, 16, .82));
    backdrop-filter: blur(14px);
}
.chat-input {
    flex: 1;
    min-height: 44px;
    max-height: 132px;
    padding: 11px 14px;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: rgba(var(--ink), .05);
    color: var(--text);
    font: inherit;
    font-size: 16px;
    line-height: 1.4;
    resize: none;
    outline: none;
    transition: .2s;
    /* pas de barre de défilement visible (Chrome Android en affiche une) */
    overflow-x: hidden;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.chat-input::-webkit-scrollbar { width: 0; height: 0; display: none; }
.chat-input:focus { border-color: rgba(var(--acc), .6); box-shadow: 0 0 0 4px rgba(var(--acc-deep), .12); }
.chat-input::placeholder { color: var(--muted-2); }

.chat-send {
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 0;
    background: var(--grad);
    color: var(--on-acc);
    cursor: pointer;
    transition: .18s;
    box-shadow: 0 10px 22px -10px rgba(var(--acc), .9);
}
.chat-send svg { width: 20px; height: 20px; }
.chat-send:hover { filter: brightness(1.08); }
.chat-more summary,
.chat-send:disabled {
    background: rgba(var(--ink), .07);
    color: var(--muted-2);
    border: 1px solid var(--border-soft);
}
.chat-send:disabled {
    box-shadow: none;
    cursor: default;
}

.chat-foot {
    flex: 0 0 auto;
    margin: 0;
    padding: 6px 14px calc(8px + env(safe-area-inset-bottom, 0px));
    font-size: 10.5px;
    color: var(--muted-2);
    text-align: center;
    border-top: 1px solid transparent;
    background: var(--bar, rgba(9, 9, 16, .5));
}
.chat-foot.is-ko { color: var(--err-t, #fca5a5); }

.chat-intro {
    margin: auto;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 30px 20px;
    color: var(--muted);
}
.chat-intro h2 { font-size: 19px; color: var(--text); }
.chat-intro p { margin: 0; font-size: 13px; }

.chat-status {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 16px;
    font-size: 12px;
    color: var(--muted-2);
}
.chat-status strong { color: var(--muted); font-weight: 600; }
.chat-status.is-ko { color: var(--err-t, #fca5a5); }

/* liste des conversations */
.conv-list { display: flex; flex-direction: column; gap: 8px; }
.conv-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 12px 9px 9px;
    border-radius: 16px;
    border: 1px solid var(--border-soft);
    background: var(--card, rgba(var(--ink), .028));
    transition: .18s;
}
.conv-card:hover { background: rgba(var(--ink), .06); border-color: rgba(var(--ink), .16); }
.conv-avatar { width: 46px; height: 46px; border-radius: 13px; overflow: hidden; position: relative; flex: 0 0 auto; }
.conv-avatar img { width: 100%; height: 100%; object-fit: cover; }
.conv-avatar .avatar-fallback span { font-size: 16px; transform: none; }
.conv-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.conv-body strong { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-body span { font-size: 12.5px; color: var(--muted-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; font-size: 10.5px; color: var(--muted-2); flex: 0 0 auto; }
.conv-meta em { font-style: normal; }

/* popin de sélection */
.modal {
    position: fixed;
    inset: 0;
    z-index: 95;
    display: grid;
    place-items: center;
    padding: 16px;
    background: var(--scrim, rgba(4, 4, 9, .72));
    backdrop-filter: blur(8px);
    animation: fade .16s both;
}
.modal-card {
    width: 100%;
    max-width: 520px;
    max-height: 88dvh;
    overflow-y: auto;
    padding: 16px;
    border-radius: 22px;
    border: 1px solid var(--border);
    background: var(--elev, #0e0e18);
    box-shadow: 0 40px 80px -30px var(--sh, #000);
    display: flex;
    flex-direction: column;
    gap: 12px;
    animation: rise .2s both;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.modal-head h2 { font-size: 16px; font-weight: 650; }

.rename-row { display: flex; gap: 8px; }
.rename-row .input { flex: 1; }
.card-form-flat { padding: 0; border: 0; background: transparent; box-shadow: none; }
.chat-danger { margin-top: 6px; }



@media (min-width: 900px) {
    .chat-side { display: block; }
    .chat-scroll { padding: 22px 26px 12px; }
    .msg { max-width: min(72%, 640px); }
    .chat-scroll { scroll-padding-bottom: 20px; }
}



/* anneau de contexte */
.ctx-ring-btn {
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
    border-radius: 50%;
    transition: transform .18s;
}
.ctx-ring-btn:hover { transform: scale(1.06); }
.ctx-ring-btn svg, .mem-gauge svg { display: block; }
.ring text { paint-order: stroke; }

.mem-gauge { display: flex; align-items: center; gap: 16px; }
.mem-legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 5px; font-size: 11.5px; color: var(--muted-2); }
.mem-legend li { display: flex; align-items: center; gap: 7px; }
.mem-legend strong { color: var(--muted); font-weight: 600; }
.mem-legend i { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; }
.dot-mem { background: #38bdf8; }
.dot-thr { background: var(--text-hi, #fff); border-radius: 1px !important; width: 3px !important; height: 10px !important; }

/* mémoire de conversation */
.mem-box {
    border-top: 1px solid var(--border-soft);
    padding-top: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.mem-head { display: flex; align-items: center; justify-content: space-between; }
.mem-head h3 { font-size: 13px; font-weight: 650; }
.mem-pct { font-size: 11px; color: var(--muted-2); }
.mem-pct.is-hot { color: var(--err-t, #fca5a5); }
.mem-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px; }
.mem-stats div {
    background: var(--card, rgba(var(--ink), .04));
    border: 1px solid var(--border-soft);
    border-radius: 12px;
    padding: 8px 4px;
    text-align: center;
}
.mem-stats strong { display: block; font-size: 14.5px; font-weight: 650; }
.mem-stats span { font-size: 9.5px; color: var(--muted-2); }
.mem-bar { height: 5px; border-radius: 99px; background: rgba(var(--ink), .07); overflow: hidden; }
.mem-bar i { display: block; height: 100%; border-radius: 99px; background: var(--grad); transition: width .3s; }
.mem-form { display: flex; flex-direction: column; gap: 10px; }

/* ------------------------------------------------------- bascule vue liste */

.view-toggle {
    display: inline-flex;
    gap: 2px;
    padding: 3px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: rgba(var(--ink), .03);
    flex: 0 0 auto;
}
.view-toggle button {
    display: grid;
    place-items: center;
    width: 34px;
    height: 30px;
    padding: 0;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--muted-2);
    cursor: pointer;
    transition: .18s;
}
.view-toggle button svg { width: 16px; height: 16px; }
.view-toggle button:hover { color: var(--text); background: rgba(var(--ink), .07); }
.view-toggle button.is-on {
    color: var(--text-hi, #fff);
    background: rgba(var(--acc-deep), .24);
    box-shadow: inset 0 0 0 1px rgba(var(--acc), .38);
}

html[data-view="list"] .grid {
    display: flex;
    flex-direction: column;
    gap: 9px;
    margin-top: 16px;
}
html[data-view="list"] .persona-card {
    flex-direction: row;
    align-items: center;
    gap: 12px;
    padding: 8px 12px 8px 8px;
    border-radius: 16px;
    border: 1px solid var(--border-soft);
    background: var(--card, rgba(var(--ink), .028));
    transition: background .18s, border-color .18s;
}
html[data-view="list"] .persona-card:hover {
    background: rgba(var(--ink), .06);
    border-color: rgba(var(--ink), .16);
}
html[data-view="list"] .persona-media {
    width: 56px;
    height: 56px;
    aspect-ratio: auto;
    border-radius: 12px;
    flex: 0 0 auto;
    transform: none !important;
    box-shadow: none !important;
}
html[data-view="list"] .persona-caption {
    flex: 1;
    min-width: 0;
    gap: 1px;
    padding: 0;
}
html[data-view="list"] .persona-caption strong { font-size: 14.5px; }
html[data-view="list"] .avatar-fallback span { font-size: 18px; }
html[data-view="list"] .persona-heart { top: -3px; right: -3px; width: 18px; height: 18px; }
html[data-view="list"] .persona-heart svg { width: 9px; height: 9px; }
html[data-view="list"] .persona-card.is-archived { opacity: .6; }
html[data-view="list"] .add-tile { padding: 8px 12px 8px 8px; background: rgba(var(--ink), .015); }
html[data-view="list"] .add-tile .persona-media {
    width: 56px;
    height: 56px;
    border: 1px dashed rgba(var(--ink), .18);
}
html[data-view="list"] .add-tile .ico { width: 20px; height: 20px; }

.persona-extra { display: none; }
html[data-view="list"] .persona-extra {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-left: auto;
    flex: 0 0 auto;
    padding-left: 12px;
}
html[data-view="list"] .persona-extra span {
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 999px;
    background: rgba(var(--acc), .12);
    border: 1px solid rgba(var(--acc), .22);
    color: rgb(var(--acc-soft));
    white-space: nowrap;
}
@media (max-width: 719px) {
    html[data-view="list"] .persona-extra { display: none; }
}

@media (min-width: 900px) {
    html[data-view="list"] .persona-media { width: 64px; height: 64px; }
    html[data-view="list"] .persona-card { padding: 9px 16px 9px 9px; }
}

/* ---------------------------------------------------------------- boutons */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 17px;
    border-radius: 13px;
    border: 1px solid transparent;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: -.01em;
    cursor: pointer;
    transition: .2s;
    white-space: nowrap;
    background: transparent;
}
.btn .ico { width: 16px; height: 16px; flex: 0 0 auto; }
.btn-sm { padding: 8px 13px; font-size: 13px; border-radius: 11px; }
.btn-block { width: 100%; }

.btn-primary {
    background: var(--grad);
    color: var(--on-acc);
    box-shadow: 0 12px 28px -14px rgba(var(--acc), .9);
}
.btn-primary:hover { filter: brightness(1.08); box-shadow: 0 16px 34px -14px rgba(var(--acc), 1); }
.btn-primary:active { transform: translateY(1px); }

.btn-ghost {
    background: var(--panel);
    border-color: var(--border);
    color: var(--text);
}
.btn-ghost:hover { background: var(--panel-2); border-color: rgba(var(--ink), .22); }

.btn-danger-ghost { background: transparent; border-color: rgba(248, 113, 113, .28); color: var(--danger); }
.btn-danger-ghost:hover { background: rgba(248, 113, 113, .12); border-color: rgba(248, 113, 113, .5); }

.btn-danger { background: #b91c1c; color: #fff; }
.btn-danger:hover { background: #dc2626; }

/* ------------------------------------------------------------------ retour */

.back {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 12px;
    color: var(--muted);
    font-size: 13.5px;
    font-weight: 500;
    transition: .2s;
}
.back:hover { color: var(--text); }
.back .ico { width: 18px; height: 18px; }

/* ------------------------------------------------------------------- hero */

.hero {
    position: relative;
    border-radius: 24px;
    overflow: hidden;
    border: 1px solid var(--border);
    background:
        radial-gradient(120% 110% at 0% 0%, hsl(var(--hue) 65% var(--hero-l1, 34%) / .55), transparent 62%),
        radial-gradient(90% 90% at 100% 100%, hsl(calc(var(--hue) + 70) 60% var(--hero-l2, 30%) / .28), transparent 60%),
        var(--card, rgba(var(--ink), .035));
    box-shadow: var(--shadow);
}

.hero-bg {
    position: absolute;
    inset: -30px;
    background-size: cover;
    background-position: center;
    filter: blur(46px) saturate(1.4);
    opacity: var(--hero-img-o, .42);
    transform: scale(1.12);
    z-index: 0;
}

.hero-portrait {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 240px;
    overflow: hidden;
}
.hero-portrait img { width: 100%; height: 100%; object-fit: cover; }
.hero-portrait .avatar-fallback span { font-size: 84px; }

.hero-body {
    position: relative;
    z-index: 1;
    padding: 20px 20px 22px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.hero-badges { display: flex; flex-wrap: wrap; gap: 6px; }
.badge {
    font-size: 11px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(var(--ink), .1);
    border: 1px solid rgba(var(--ink), .12);
    color: rgba(var(--ink), .82);
}
.badge-tag {
    background: rgba(var(--acc), .16);
    border-color: rgba(var(--acc), .3);
    color: rgb(var(--acc-pale));
    transition: background .18s, border-color .18s, color .18s;
}
a.badge-tag:hover { background: rgba(var(--acc), .32); border-color: rgba(var(--acc-soft), .65); color: var(--text-hi, #fff); }
.badge-gold { background: rgba(251, 191, 36, .16); border-color: rgba(251, 191, 36, .32); color: var(--warn-t, #fde68a); }

.hero h1 { font-size: clamp(28px, 7vw, 44px); font-weight: 700; line-height: 1.1; }
.hero-tagline { margin: 0; font-size: 15px; color: rgba(var(--ink), .86); font-weight: 500; }
.hero-desc { margin: 2px 0 0; font-size: 14px; color: rgba(var(--ink), .74); max-width: 62ch; }

.hero-facts {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    font-size: 12px;
    color: rgba(var(--ink), .62);
    margin-top: 2px;
}
.hero-facts span + span::before { content: "·"; margin-right: 14px; color: rgba(var(--ink), .18); }

/* actions de la fiche : rangée de boutons ronds avec libellé (piste A) */
.hero-actions {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    gap: 8px;
    margin-top: 12px;
    max-width: 420px;
}
.round-act { display: flex; flex-direction: column; align-items: center; gap: 7px; margin: 0; min-width: 0; }
.round-btn {
    width: 56px;
    height: 56px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    border: 1px solid rgba(var(--ink), .13);
    background: rgba(var(--ink), .06);
    color: var(--text);
    cursor: pointer;
    text-decoration: none;
    transition: background .18s, transform .18s, border-color .18s;
}
.round-btn svg { width: 23px; height: 23px; }
.round-btn:hover { background: rgba(var(--ink), .11); border-color: rgba(var(--ink), .2); }
.round-btn:active { transform: scale(.92); }
.round-btn.is-main {
    border: 0;
    background: var(--grad);
    color: var(--on-grad, #fff);
    box-shadow: 0 10px 24px -10px rgba(var(--acc), .75);
}
.round-btn.is-main:hover { filter: brightness(1.06); }
.round-btn[disabled] { opacity: .6; cursor: progress; }
.round-label {
    max-width: 100%;
    font-size: 12px;
    font-weight: 600;
    color: rgba(var(--ink), .82);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* mobile : nom, accroche et tags posés en bas du portrait (voile sombre pour la lisibilité) */
@media (max-width: 899px) {
    .hero-portrait { height: 320px; }
    .hero-portrait::after {
        content: "";
        position: absolute;
        left: 0;
        right: 0;
        bottom: 0;
        height: 150px;
        background: linear-gradient(to top, rgba(8, 8, 14, .9), rgba(8, 8, 14, 0));
        pointer-events: none;
    }
    .hero-head {
        position: relative;
        z-index: 2;
        margin-top: -128px;
        min-height: 108px;
        display: flex;
        flex-direction: column;
        justify-content: flex-end;
        gap: 6px;
        color: #fff;
    }
    .hero-head h1 { color: #fff; }
    .hero-head .hero-tagline { color: rgba(255, 255, 255, .86); }
    .hero-head .badge { background: rgba(255, 255, 255, .16); color: #fff; border-color: rgba(255, 255, 255, .22); }
    .hero-body { padding-top: 0; }
    .hero-head + * { margin-top: 10px; }
}
.hero-head { display: flex; flex-direction: column; gap: 10px; }

/* fenêtre d'export */
.export-list { display: grid; gap: 8px; }
.export-option {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 14px;
    border-radius: 16px;
    border: 1px solid var(--border-soft);
    background: rgba(var(--ink), .03);
    color: var(--text);
    text-decoration: none;
    transition: .18s;
}
.export-option:hover, .export-option:focus-visible { background: rgba(var(--ink), .07); border-color: rgba(var(--acc), .45); }
.export-option:active { transform: scale(.99); }
.export-ico {
    width: 46px;
    height: 46px;
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    border-radius: 13px;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .04em;
    color: #fff;
}
.export-zip .export-ico { background: linear-gradient(135deg, #8b5cf6, #d946ef); }
.export-json .export-ico { background: linear-gradient(135deg, #0ea5e9, #6366f1); }
.export-png .export-ico { background: linear-gradient(135deg, #f43f5e, #f59e0b); }
.export-text { flex: 1; min-width: 0; display: grid; gap: 3px; }
.export-text strong { font-size: 14.5px; font-weight: 650; }
.export-text small { font-size: 12.5px; line-height: 1.45; color: var(--muted); }
.export-badge {
    margin-left: 4px;
    padding: 1px 7px;
    border-radius: 999px;
    font-size: 10.5px;
    font-style: normal;
    font-weight: 700;
    vertical-align: 1px;
    color: rgb(var(--acc-soft));
    background: rgba(var(--acc), .16);
}
.export-go {
    width: 34px;
    height: 34px;
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: rgba(var(--ink), .06);
    color: var(--muted);
    transition: .18s;
}
.export-go .ico { width: 17px; height: 17px; }
.export-option:hover .export-go { background: rgba(var(--acc), .18); color: rgb(var(--acc-soft)); }
.export-note { margin: 12px 2px 0; font-size: 12.5px; }

/* ------------------------------------------------------------------ panneaux */

.detail-cols { display: grid; gap: 14px; margin-top: 14px; align-items: start; }
/* un panneau pleine largeur respire toujours (il était collé au portrait sur mobile) */
.panel-wide { margin-top: 14px; }
/* toutes les cartes sous les colonnes (consigne de jeu, prompts…), pas seulement la première */
.detail-cols ~ .panel { margin-top: 14px; }

.panel {
    border-radius: 20px;
    border: 1px solid var(--border-soft);
    background: var(--card, rgba(var(--ink), .028));
    padding: 16px;
}
.panel h2 { font-size: 15px; font-weight: 650; display: flex; align-items: center; gap: 4px; }
.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}
.upload-form { margin: 0; }

.hint { margin: 0; font-size: 13px; color: var(--muted-2); line-height: 1.6; }

.paste-hint { margin-bottom: 12px; font-size: 11.5px; }
.paste-hint kbd {
    display: inline-block;
    padding: 1px 5px;
    margin: 0 1px;
    border-radius: 5px;
    border: 1px solid var(--border);
    background: rgba(var(--ink), .06);
    font-family: inherit;
    font-size: 10.5px;
    color: var(--muted);
}
.shot-add.is-drop { border-color: rgba(var(--acc), .85); background: rgba(var(--acc-deep), .14); }

.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(124px, 1fr));
    gap: 10px;
}
.shot {
    position: relative;
    margin: 0;
    aspect-ratio: 1;
    border-radius: 14px;
    overflow: hidden;
    border: 1px solid var(--border-soft);
    background: var(--media, #111119);
}
.shot img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; transition: transform .5s; }
.shot:hover img { transform: scale(1.05); }

.shot-add {
    border: 1px dashed rgba(var(--ink), .18);
    background: rgba(var(--ink), .02);
    display: grid;
    place-items: center;
    transition: .2s;
}
.shot-add:hover { border-color: rgba(var(--acc), .55); background: rgba(var(--acc-deep), .08); }
.shot-add label {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    width: 100%;
    height: 100%;
    cursor: pointer;
    color: var(--muted);
    font-size: 11.5px;
    font-weight: 600;
}
.shot-add .ico { width: 20px; height: 20px; }
.shot-add:hover label { color: var(--text); }

.shot-badge {
    position: absolute;
    top: 7px;
    left: 7px;
    width: 24px;
    height: 24px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: rgba(0, 0, 0, .55);
    color: #fbbf24;
    backdrop-filter: blur(6px);
    pointer-events: none;
}
.shot-badge svg { width: 14px; height: 14px; }

.metas { margin: 0; display: grid; gap: 10px; }
.metas > div { display: grid; gap: 1px; }
.metas dt {
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--muted-2);
}
.metas dd { margin: 0; font-size: 13.5px; color: var(--text); }
.side-date { margin: 14px 0 0; font-size: 11.5px; color: var(--muted-2); }

/* ----------------------------------------------------------------- prompts */

.prompt-list { display: grid; gap: 10px; }
.panel-head:has([data-prompt-new]), .panel-head > .prompt-tools { flex-wrap: wrap; }
.prompt-audit-panel + .prompt-audit-panel { margin-top: 16px; }
.prompt-audit-metrics {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin: 0;
}
.prompt-audit-metrics dd { margin: 4px 0 0; font-size: 1.4rem; font-variant-numeric: tabular-nums; }
.prompt-audit-omission { padding: 8px 12px; }
.prompt-audit-omission summary, summary.prompt-audit-omission { cursor: pointer; }

.prompt {
    border: 1px solid var(--border-soft);
    border-radius: 16px;
    background: var(--card, rgba(var(--ink), .025));
    padding: 13px 14px;
    display: flex;
    flex-direction: column;
    gap: 9px;
}
.prompt-head {
    display: flex;
    align-items: center;
    gap: 9px;
    flex-wrap: wrap;
}
.prompt-head strong { font-size: 13.5px; font-weight: 600; }
.prompt-tools { margin-left: auto; display: flex; align-items: center; gap: 5px; }
.prompt-tools form { margin: 0; }
.prompt-token-count {
    color: var(--muted);
    font-size: 11px;
    font-variant-numeric: tabular-nums;
    text-align: end;
}

.mini {
    padding: 6px 10px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: rgba(var(--ink), .05);
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: .2s;
}
.mini:hover { color: var(--text); background: rgba(var(--ink), .1); }
.mini-danger { color: var(--danger); font-size: 14px; line-height: 1; padding: 3px 8px; }
.mini-danger:hover { background: rgba(248, 113, 113, .16); color: var(--err-t, #fca5a5); }

.kind {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    padding: 3px 8px;
    border-radius: 999px;
    border: 1px solid transparent;
}
.kind-image { background: rgba(var(--acc-deep), .16); border-color: rgba(var(--acc-deep), .3); color: rgb(var(--acc-soft)); }
.kind-negative { background: rgba(248, 113, 113, .14); border-color: rgba(248, 113, 113, .28); color: var(--err-t, #fca5a5); }
.kind-video { background: rgba(34, 211, 238, .13); border-color: rgba(34, 211, 238, .28); color: var(--cyan-t, #67e8f9); }
.kind-system { background: rgba(251, 191, 36, .13); border-color: rgba(251, 191, 36, .28); color: var(--warn-t, #fcd34d); }
.kind-planning { background: rgba(52, 211, 153, .13); border-color: rgba(52, 211, 153, .28); color: var(--ok-t, #6ee7b7); }
.kind-other { background: rgba(var(--ink), .07); border-color: var(--border); color: var(--muted); }

.prompt-body {
    margin: 0;
    padding: 11px 12px;
    border-radius: 11px;
    background: var(--inset, rgba(0, 0, 0, .32));
    border: 1px solid var(--border-soft);
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
    font-size: 12.5px;
    line-height: 1.65;
    color: var(--text-2, #d9d6ea);
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 280px;
    overflow: auto;
}

.prompt-edit, .prompt-new {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 4px;
    padding-top: 12px;
    border-top: 1px dashed var(--border);
}
/* le formulaire « nouveau prompt » suit la liste : même respiration qu'entre deux cartes */
.prompt-new { margin-top: 14px; }

/* ------------------------------------------------------------------ champs */

.field { display: flex; flex-direction: column; gap: 5px; }
.field > span { font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: .01em; }
.field > small { font-size: 11px; color: var(--muted-2); }

.input {
    width: 100%;
    padding: 11px 13px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: rgba(var(--ink), .04);
    color: var(--text);
    font: inherit;
    font-size: 16px;
    outline: none;
    transition: .2s;
}
select.input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 55%, calc(100% - 13px) 55%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 34px; }
.input:focus {
    border-color: rgba(var(--acc), .6);
    box-shadow: 0 0 0 4px rgba(var(--acc-deep), .13);
    background: rgba(var(--ink), .06);
}
.input::placeholder { color: var(--muted-2); }
textarea.input {
    resize: vertical;
    line-height: 1.6;
    font-size: 15px;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(var(--ink), .18) transparent;
}
textarea.input::-webkit-scrollbar { width: 8px; }
textarea.input::-webkit-scrollbar-thumb {
    background: rgba(var(--ink), .16);
    border-radius: 99px;
}
textarea.input::-webkit-scrollbar-track { background: transparent; }

.row2 { display: grid; gap: 12px; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }

/* ------------------------------------------------------------- page formulaire */

.form-wrap { max-width: 720px; margin: 0 auto; }
.form-head { margin-bottom: 16px; }
.form-head h1 { font-size: clamp(24px, 6vw, 32px); font-weight: 700; }

.card-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 18px;
    border-radius: 22px;
    border: 1px solid var(--border);
    background: var(--card, rgba(var(--ink), .035));
    box-shadow: var(--shadow);
}

.avatar-picker { display: flex; align-items: center; gap: 16px; }
.avatar-preview {
    position: relative;
    flex: 0 0 auto;
    width: 88px;
    height: 88px;
    border-radius: 20px;
    overflow: hidden;
    border: 1px solid var(--border);
    background: var(--media, #12121c);
}
.avatar-preview img { width: 100%; height: 100%; object-fit: cover; }
.avatar-picker p { margin: 6px 0 0; font-size: 11.5px; color: var(--muted-2); }
.avatar-picker .btn input { cursor: pointer; }

/* -------------------------------------------------------------------- login */

.login-wrap { min-height: calc(100dvh - 160px); display: grid; place-items: center; padding: 10px; }
.login-card {
    width: 100%;
    max-width: 372px;
    padding: 26px 22px;
    border-radius: 26px;
    border: 1px solid var(--border);
    background: var(--card, rgba(var(--ink), .045));
    backdrop-filter: blur(16px);
    box-shadow: var(--shadow);
    animation: rise .5s both;
}
.login-brand { text-align: center; margin-bottom: 22px; }
.brand-mark-lg { width: 52px; height: 52px; border-radius: 16px; margin: 0 auto 12px; }
.brand-mark-lg svg { width: 30px; height: 30px; }
.login-brand h1 { font-size: 24px; font-weight: 700; }
.login-brand h1 em { font-style: normal; background: var(--grad-text, var(--grad)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.login-brand p { margin: 6px 0 0; font-size: 12.5px; color: var(--muted); }
.login-form { display: flex; flex-direction: column; gap: 14px; }

/* ------------------------------------------------------------------ flashes */

.flash {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 14px;
    margin-bottom: 12px;
    border-radius: 13px;
    font-size: 13.5px;
    border: 1px solid var(--border);
    background: rgba(var(--ink), .05);
    animation: rise .3s both;
}
.flash-ok { border-color: rgba(52, 211, 153, .32); background: rgba(16, 185, 129, .12); color: var(--ok-t, #a7f3d0); }
.flash-error { border-color: rgba(248, 113, 113, .32); background: rgba(239, 68, 68, .12); color: var(--err-t, #fecaca); }
.flash-close { margin-left: auto; background: none; border: 0; color: inherit; opacity: .6; font-size: 17px; cursor: pointer; padding: 0 2px; }

/* -------------------------------------------------------------------- empty */

.empty { text-align: center; padding: 56px 20px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.empty-orb {
    width: 68px;
    height: 68px;
    display: grid;
    place-items: center;
    border-radius: 22px;
    background: rgba(var(--acc), .12);
    border: 1px solid rgba(var(--acc), .25);
    margin-bottom: 4px;
}
.empty-orb svg { width: 34px; height: 34px; }
.empty h2 { font-size: 19px; font-weight: 650; }
.empty p { margin: 0 0 10px; font-size: 13.5px; color: var(--muted); max-width: 34ch; }

.nf { text-align: center; padding: 80px 20px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.nf h1 { font-size: 64px; background: var(--grad-text, var(--grad)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.nf p { margin: 0; color: var(--muted); }

/* ------------------------------------------------------------------ lightbox */

.lightbox {
    position: fixed;
    inset: 0;
    z-index: 90;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(4, 4, 9, .93);
    backdrop-filter: blur(14px);
    animation: fade .2s both;
}
.lightbox { padding: 0; display: block; }
/* une photo par « page », défilement aimanté : le doigt fait défiler, comme une galerie de téléphone */
.lb-track {
    position: absolute;
    inset: 0;
    display: flex;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    overscroll-behavior: contain;
    scrollbar-width: none;
}
.lb-track::-webkit-scrollbar { display: none; }
.lb-slide {
    flex: 0 0 100%;
    height: 100%;
    display: grid;
    place-items: center;
    padding: 64px 14px calc(44px + env(safe-area-inset-bottom));
    scroll-snap-align: center;
    scroll-snap-stop: always;
}
.lb-slide img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 14px;
    box-shadow: 0 30px 80px -20px #000;
    -webkit-user-drag: none;
    user-select: none;
}
.lb-top {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: calc(12px + env(safe-area-inset-top)) 14px 12px;
    pointer-events: none;
}
.lb-top > * { pointer-events: auto; }
.lb-count {
    min-width: 1px;
    padding: 6px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .12);
    color: #fff;
    font-size: 13.5px;
    font-weight: 650;
    font-variant-numeric: tabular-nums;
    backdrop-filter: blur(8px);
}
.lb-count:empty { visibility: hidden; }
.lb-actions { display: flex; gap: 10px; }
.lb-btn, .lb-nav {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, .22);
    background: rgba(255, 255, 255, .12);
    color: #fff;
    cursor: pointer;
    backdrop-filter: blur(8px);
    transition: background .18s, transform .18s;
}
.lb-btn svg, .lb-nav svg { width: 20px; height: 20px; }
.lb-btn:hover, .lb-nav:hover:not(:disabled) { background: rgba(255, 255, 255, .22); }
.lb-btn:active, .lb-nav:active:not(:disabled) { transform: scale(.92); }
/* ancienne croix : remplacée par .lb-btn */
.lightbox .lightbox-close { position: static; font-size: inherit; }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); }
.lb-nav:active:not(:disabled) { transform: translateY(-50%) scale(.92); }
.lb-prev { left: 16px; }
.lb-next { right: 16px; }
.lb-nav:disabled { opacity: 0; pointer-events: none; }
.lightbox.is-single .lb-nav { display: none; }
/* au doigt, on glisse : pas de flèches qui cachent la photo */
@media (hover: none) and (pointer: coarse) { .lb-nav { display: none; } }
.lb-dots {
    position: absolute;
    left: 0;
    right: 0;
    bottom: calc(16px + env(safe-area-inset-bottom));
    display: flex;
    justify-content: center;
    gap: 6px;
    pointer-events: none;
}
.lb-dots i {
    width: 6px;
    height: 6px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .35);
    transition: width .2s, background .2s;
}
.lb-dots i.is-on { width: 18px; background: #fff; }

/* --------------------------------------------------------------------- tabbar */

.tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    align-items: center;
    height: calc(62px + var(--safe-b));
    padding-bottom: var(--safe-b);
    background: var(--bar, rgba(9, 9, 16, .86));
    backdrop-filter: blur(22px) saturate(150%);
    -webkit-backdrop-filter: blur(22px) saturate(150%);
    border-top: 1px solid var(--border-soft);
}
.tabbar a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    height: 100%;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .01em;
    color: var(--muted);
    transition: .2s;
}
.tabbar a.is-active { color: var(--text); }
.tabbar a .ico { width: 20px; height: 20px; }

.tab-add .ico { width: 21px !important; height: 21px !important; color: rgb(var(--acc-soft)); }
.tab-add { color: rgb(var(--acc-soft)); }
.tab-add span { color: rgb(var(--acc-soft)); }

.tabbar a.is-active .ico { color: rgb(var(--acc-soft)); }
.tabbar a.is-active { position: relative; }
.tabbar a.is-active::before {
    content: "";
    position: absolute;
    top: 6px;
    width: 18px;
    height: 2px;
    border-radius: 2px;
    background: var(--grad);
}

/* ------------------------------------------------------------------- toasts */

.toast {
    position: fixed;
    left: 50%;
    bottom: calc(84px + var(--safe-b));
    z-index: 130; /* au-dessus des panneaux et fenêtres */
    width: min(420px, calc(100vw - 32px));
    box-sizing: border-box;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 16px 12px 12px;
    border-radius: 16px;
    background: var(--elev, #14141f);
    background-image: linear-gradient(rgba(var(--ink), .03), rgba(var(--ink), .03));
    backdrop-filter: blur(18px) saturate(1.2);
    -webkit-backdrop-filter: blur(18px) saturate(1.2);
    border: 1px solid var(--border);
    color: var(--text);
    text-align: left;
    opacity: 0;
    transform: translate(-50%, 14px);
    transition: opacity .22s ease, transform .28s cubic-bezier(.2, .85, .25, 1);
    pointer-events: none;
    box-shadow: 0 22px 50px -18px var(--sh, #000);
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }
.toast-ico {
    flex: 0 0 28px;
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    color: #fff;
    background: var(--grad);
}
.toast-ico svg { width: 16px; height: 16px; }
.toast-body { flex: 1; min-width: 0; display: grid; gap: 3px; padding-top: 4px; }
.toast-title { font-size: 13.5px; font-weight: 650; line-height: 1.35; }
.toast-text { font-size: 12.5px; line-height: 1.45; color: var(--muted); overflow-wrap: anywhere; }
.toast-text[hidden] { display: none; }
.toast-text.is-code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; color: var(--text); opacity: .85; }
.toast.is-error .toast-ico { background: #ef4444; }

/* ------------------------------------------------------- sélecteur custom */

.sel { position: relative; }

.sel-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 11px 13px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: rgba(var(--ink), .04);
    color: var(--text);
    font: inherit;
    font-size: 15px;
    text-align: left;
    cursor: pointer;
    transition: .2s;
}
.sel-btn:hover { background: rgba(var(--ink), .06); border-color: rgba(var(--ink), .18); }
.sel-btn[aria-expanded="true"] {
    border-color: rgba(var(--acc), .6);
    box-shadow: 0 0 0 4px rgba(var(--acc-deep), .13);
    background: rgba(var(--ink), .06);
}
.sel-value { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sel-caret { width: 16px; height: 16px; flex: 0 0 auto; color: var(--muted); transition: transform .2s; }
.sel-btn[aria-expanded="true"] .sel-caret { transform: rotate(180deg); color: rgb(var(--acc-soft)); }

.sel-menu {
    position: absolute;
    z-index: 70;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    margin: 0;
    padding: 6px;
    list-style: none;
    border-radius: 14px;
    border: 1px solid rgba(var(--ink), .14);
    background: var(--elev, #14141f);
    box-shadow: 0 26px 55px -22px var(--sh, #000);
    max-height: 250px;
    overflow: auto;
    animation: fade .14s both;
}
.sel-menu li {
    padding: 9px 11px;
    border-radius: 9px;
    font-size: 14px;
    color: var(--muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background .15s, color .15s;
}
.sel-menu li:hover, .sel-menu li.is-focus { background: rgba(var(--ink), .07); color: var(--text); }
.sel-menu li[aria-selected="true"] { color: var(--text-hi, #fff); background: rgba(var(--acc-deep), .2); }
.sel-menu li[aria-selected="true"]::after { content: "✓"; margin-left: auto; color: rgb(var(--acc-soft)); font-size: 12px; }

.sel-native { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

/* --------------------------------------------------------- réglages / IA */

.form-sub { margin: 6px 0 0; font-size: 13px; color: var(--muted); }
.settings-sub { margin-top: 28px; }

.check { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); cursor: pointer; }
/* interrupteur (bascule) : la case native reste en dessous, accessible au clavier
   et aux lecteurs d'écran ; seule son apparence change */
.check input {
    appearance: none;
    -webkit-appearance: none;
    width: 42px;
    height: 24px;
    flex: 0 0 auto;
    margin: 0;
    border-radius: 999px;
    border: 1px solid rgba(var(--ink), .18);
    background: rgba(var(--ink), .12);
    cursor: pointer;
    position: relative;
    transition: background .2s ease, border-color .2s ease, box-shadow .2s ease;
}
.check input::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .45);
    transition: transform .22s cubic-bezier(.3, .7, .3, 1);
}
.check input:checked { background: var(--grad); border-color: transparent; box-shadow: 0 0 0 3px rgba(var(--acc), .14); }
.check input:checked::after { transform: translateX(18px); }
.check input:focus-visible { outline: 2px solid rgba(var(--acc), .9); outline-offset: 2px; }
.check:hover input { border-color: rgba(var(--acc), .6); }
.check input:disabled { opacity: .45; cursor: not-allowed; }
@media (prefers-reduced-motion: reduce) { .check input, .check input::after { transition: none; } }

.llm-status {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid var(--border-soft);
    background: rgba(var(--ink), .02);
    font-size: 12.5px;
    color: var(--muted);
    transition: .2s;
}
.dot { width: 7px; height: 7px; border-radius: 50%; flex: 0 0 auto; background: #6b7280; box-shadow: 0 0 0 3px rgba(107, 114, 128, .16); }
.dot-ok { background: #34d399; box-shadow: 0 0 0 3px rgba(52, 211, 153, .18); }
.dot-ko { background: #f87171; box-shadow: 0 0 0 3px rgba(248, 113, 113, .18); }
.llm-status.is-ok { color: var(--ok-t, #a7f3d0); border-color: rgba(52, 211, 153, .3); background: rgba(16, 185, 129, .09); }
.llm-status.is-ko { color: var(--err-t, #fecaca); border-color: rgba(248, 113, 113, .3); background: rgba(239, 68, 68, .09); }

.panel-help { margin-top: 14px; }
.panel-help h2 { margin-bottom: 9px; }
.panel-help .hint + .hint { margin-top: 8px; }


.btn-ai {
    background: linear-gradient(135deg, rgba(var(--acc), .2), rgba(var(--acc-end), .16));
    border-color: rgba(var(--acc), .38);
    color: rgb(var(--acc-alt));
}
.btn-ai:hover {
    background: linear-gradient(135deg, rgba(var(--acc), .3), rgba(var(--acc-end), .24));
    border-color: rgba(var(--acc), .6);
}
.btn.is-busy { cursor: progress; opacity: .85; }
.btn.is-busy::after {
    content: "";
    width: 13px;
    height: 13px;
    border-radius: 50%;
    border: 2px solid rgba(var(--ink), .32);
    border-top-color: var(--text-hi, #fff);
    animation: spin .7s linear infinite;
}

.toast.is-error { border-color: rgba(248, 113, 113, .45); }

.icon-btn.is-active { color: var(--text); background: rgba(var(--ink), .08); }

@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------------ responsive */

@media (min-width: 560px) {
    .row2 { grid-template-columns: 1fr 1fr; }
    .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px 16px; }
    .gallery { grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); }
    .page { padding-left: 24px; padding-right: 24px; }
}

@media (min-width: 900px) {
    .topbar { padding: 0 max(32px, calc(50vw - 558px)); }
    .topnav { display: flex; }
    .topbar-actions .topbar-chat { display: none; }
    .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 24px 20px; }
    .page { padding: 30px 32px 60px; }

    .hero { display: flex; align-items: flex-end; gap: 24px; padding: 20px; }
    .hero-portrait { width: 250px; height: 315px; border-radius: 18px; flex: 0 0 auto; box-shadow: 0 22px 50px -24px var(--sh, #000); }
    .hero-body { padding: 6px 6px 10px; flex: 1; min-width: 0; }
    .hero h1 { font-size: 44px; }

    .detail-cols { grid-template-columns: minmax(0, 1fr) 280px; gap: 16px; }
    .panel { padding: 20px; }
    .panel-side { position: sticky; top: 84px; }
    .panel-wide { grid-column: 1 / -1; margin-top: 14px; }
    .gallery { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 11px; }

    .tabbar { display: none; }
    .page { padding-bottom: 60px; }
    .form-wrap .card-form { padding: 24px; }
}

@media (max-width: 899px) {
    .hide-mobile { display: none; }
    /* le "+" de la barre du bas suffit sur mobile */
    .topbar-actions > .btn-primary { display: none; }
}

@media (max-width: 559px) {
}

@media (max-width: 519px) {
    .hide-sm { display: none; }
    .avatar-preview { width: 76px; height: 76px; border-radius: 17px; }
}

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

    /* l'indicateur de saisie doit rester vivant : simple fondu, sans mouvement */
    .typing .bubble i { animation: dot-fade 1.5s ease-in-out infinite !important; }
    .typing .bubble i:nth-child(2) { animation-delay: .22s !important; }
    .typing .bubble i:nth-child(3) { animation-delay: .44s !important; }
    .as-final-dots i { animation: dot-fade 1.5s ease-in-out infinite !important; }
    .as-final-dots i:nth-child(2) { animation-delay: .22s !important; }
    .as-final-dots i:nth-child(3) { animation-delay: .44s !important; }
}

/* *action* et **texte** dans les bulles : astérisques cachés, gardés dans le texte */
.md-mark { display: none; }
em.md-emph { font-style: italic; opacity: .82; }
strong.md-emph { font-weight: 700; }

@keyframes dot-fade {
    0%, 100% { opacity: .3; }
    40% { opacity: 1; }
}

@keyframes rise {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: none; }
}

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* =================================================================
   Mobile & écrans tactiles — correctifs (v64)
   ================================================================= */

/* contrôles natifs (autofill, barres de défilement, sélecteurs) en sombre */
:root { color-scheme: dark; }
html { -webkit-tap-highlight-color: transparent; }

/* chat : la hauteur suit le clavier (iOS ne redimensionne pas 100dvh) */
.chat-room .page-chat { height: var(--app-h, 100dvh); }
html.kb-open .chat-room .chat-composer { padding-bottom: 10px; }

/* chat : l'avatar reste à côté des longues bulles (le retour à la ligne
   de .msg ne sert qu'à la barre d'outils) */
.msg-bot > .bubble,
.msg-bot > .bubbles { max-width: calc(100% - 34px); }
html[data-avatars="0"] .msg-bot > .bubbles { max-width: 100%; }

/* icônes de la barre du haut : taille fixe (sinon le SVG remplit le bouton) */
.icon-btn > .ico, .icon-btn > svg:not([width]) { width: 20px; height: 20px; }

/* focus clavier visible partout (pas seulement sur les champs) */
:where(a, button, [role="button"], summary, label.btn):focus-visible {
    outline: 2px solid rgb(var(--acc-soft));
    outline-offset: 2px;
}

/* l'astuce Ctrl+V n'a de sens qu'avec un clavier et une souris */
@media (hover: none), (pointer: coarse) {
    .only-pointer { display: none; }
}

/* actions de galerie : visibles sans survol sur tous les écrans tactiles */
@media (hover: none) {
}

/* déconnexion : dans les réglages sur mobile, plus à côté de l'engrenage */
.settings-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.settings-logout { display: flex; margin: 0; }
.settings-logout-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: rgba(var(--ink), .05);
    color: var(--muted);
}
.settings-logout-btn:hover, .settings-logout-btn:focus-visible { color: #f87171; border-color: rgba(248, 113, 113, .45); background: rgba(248, 113, 113, .1); }
@media (min-width: 900px) {
    .settings-logout { display: none; }
}
@media (max-width: 899px) {
    .topbar .logout-form { display: none; }
}

@media (pointer: coarse) {
    /* iOS zoome sur tout champ < 16 px au moment du focus */
    input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]),
    textarea,
    select,
    textarea.input,
    .prompt-area,
    .fact-add .input { font-size: 16px; }

    /* zones de toucher : 44 px visés, 40 px au minimum */
    .icon-btn { width: 44px; height: 44px; }
    .view-toggle button { width: 40px; height: 36px; }
    .mini { min-height: 36px; padding: 8px 12px; }
    .mini-danger { min-width: 40px; min-height: 40px; font-size: 18px; padding: 0; display: inline-grid; place-items: center; }
    .fact-del { min-width: 36px; min-height: 36px; margin: -8px -8px -8px 0; font-size: 18px; }
    .lms-status .lms-refresh { min-width: 40px; min-height: 40px; margin: -10px -8px; font-size: 16px; }
    .back { padding: 10px 6px 10px 0; margin-top: -10px; margin-bottom: 2px; }
    .mini-link { padding: 8px 0; }
}

/* lisibilité : textes courants à 11,5 px minimum sur téléphone
   (les pastilles en capitales et les initiales d'avatar gardent leur taille) */
@media (max-width: 899px) {
    .msg-memory, .msg-web, .lms-steps li, .chat-side-mono, .metas dt, .mini-link,
    .msg-loading, .lms-timer, .badge { font-size: 11.5px; }
    .conv-meta, .chat-foot, .chat-id-text span, .mem-scope { font-size: 12px; }
}

/* effets d'ambiance allégés sur mobile : les halos flous fixes et le grain
   en surimpression coûtent cher au défilement sur Android d'entrée de gamme */
@media (max-width: 899px), (pointer: coarse) {
    .aurora .orb { display: none; }
    .aurora {
        background:
            radial-gradient(70% 45% at 0% 0%, rgba(var(--orb-a), .42), transparent 70%),
            radial-gradient(70% 40% at 100% 100%, rgba(var(--orb-b), .28), transparent 70%),
            radial-gradient(50% 30% at 70% 45%, rgba(var(--orb-c), .10), transparent 70%);
    }
    body::after { display: none; }
    .chat-composer, .topbar { backdrop-filter: none; -webkit-backdrop-filter: none; }
    .chat-composer { background: var(--bar, rgba(9, 9, 16, .96)); }
    .topbar { background: var(--elev, #0a0a12); }
}

/* =================================================================
   Réglages — lisibilité mobile (v65)
   ================================================================= */

/* onglets : libellé court sur téléphone, barre collée sous l'en-tête */
.tab-short { display: none; }
.settings-page .tabs {
    position: sticky;
    top: 64px;
    z-index: 30;
    background: var(--bar, rgba(14, 14, 24, .96));
}

/* onglet Discussion : une carte par sujet */
.settings-stack { display: flex; flex-direction: column; gap: 14px; }
.settings-card {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 18px;
    border-radius: 22px;
    border: 1px solid var(--border);
    background: var(--card, rgba(var(--ink), .035));
    box-shadow: var(--shadow);
}
.settings-card-title { font-size: 14px; font-weight: 650; }

/* sections repliables (bulles, relances) */
.settings-fold { gap: 0; }
.settings-fold > summary {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 28px;
    list-style: none;
    cursor: pointer;
}
.settings-fold > summary::-webkit-details-marker { display: none; }
.settings-fold > summary::after {
    content: "";
    width: 8px;
    height: 8px;
    margin: 0 4px 4px auto;
    border-right: 2px solid var(--muted);
    border-bottom: 2px solid var(--muted);
    transform: rotate(45deg);
    transition: transform .2s;
    flex: 0 0 auto;
}
.settings-fold[open] > summary::after { transform: rotate(-135deg); margin-bottom: -4px; }
.fold-title { font-size: 14px; font-weight: 650; }
.fold-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.fold-sum { font-size: 12.5px; color: var(--muted-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fold-body { display: flex; flex-direction: column; gap: 12px; margin-top: 14px; }

/* plage horaire : « de [8] h à [23] h » */
.hours-range { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; }
.hours-range .input { width: 72px; text-align: center; padding-left: 8px; padding-right: 8px; }

/* Réglages : « Enregistrer » n'apparaît qu'après une modification (barre fixe en bas) ;
   les autres actions de la barre (« Tester la connexion ») restent visibles, à leur place. */
.dirty-note { display: none; margin-right: auto; align-self: center; font-size: 12.5px; color: var(--warn-t, #fcd34d); }
form.is-dirty .dirty-note { display: inline; }
.settings-page form[data-dirty-guard]:not(.is-dirty) .save-bar [type="submit"] { display: none; }
.settings-page form[data-dirty-guard]:not(.is-dirty) .save-bar:not(:has(button:not([type="submit"]))) { display: none; }
form.is-dirty .save-bar {
    position: sticky;
    bottom: 12px;
    z-index: 20;
    padding: 10px;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: var(--bar, rgba(14, 14, 24, .97));
    box-shadow: 0 16px 40px -18px var(--sh, #000);
}
form.is-dirty .save-bar { border-color: rgba(251, 191, 36, .28); }

/* maintenance LM Studio, séparée du formulaire */
.settings-maint { margin-top: 14px; }

/* sauvegarde : sélecteur de fichier dans le thème */
.file-pick {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 52px;
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px dashed var(--border);
    background: rgba(var(--ink), .03);
    color: var(--muted);
    font-size: 14px;
    cursor: pointer;
    transition: border-color .2s, background .2s;
}
.file-pick:hover, .file-pick:focus-within { border-color: rgba(var(--acc), .55); background: rgba(var(--acc), .06); }
.file-pick.has-file { border-style: solid; color: var(--text); }
.file-pick .ico { width: 18px; height: 18px; flex: 0 0 auto; }
.file-pick-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-pick input[type="file"] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* zones de prompts : hauteur pilotée par le contenu (JS) */
.prompt-area[data-autosize] { overflow-y: hidden; resize: none; }

@media (max-width: 899px) {
    /* en-tête compact : la barre du bas remplace le lien retour */
    .settings-back, .settings-head .form-sub { display: none; }
    .settings-head { margin-bottom: 12px; }
}

@media (max-width: 559px) {
    .tab-long { display: none; }
    .tab-short { display: inline; }
    .settings-page .tab { flex: 1 1 auto; padding: 9px 6px; text-align: center; }
    .settings-card { padding: 16px; }
}

/* =================================================================
   Fenêtres modales communes et bulles d'information (v66)
   ================================================================= */

html.modal-open, html.modal-open body { overflow: hidden; }
.pv-dialog { z-index: 120; }
.pv-dialog .modal-card { max-width: 460px; gap: 14px; padding: 18px; }
.pv-dialog-body { display: flex; flex-direction: column; gap: 10px; font-size: 14.5px; line-height: 1.6; color: var(--muted); }
.pv-dialog-body p { margin: 0; }
.pv-dialog-body strong { color: var(--text); font-weight: 650; }
.pv-dialog-body code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12.5px;
    padding: 1px 6px;
    border-radius: 6px;
    background: rgba(var(--ink), .07);
    color: rgb(var(--acc-pale));
    word-break: break-all;
}
.pv-dialog-actions { margin-top: 4px; }
.pv-dialog.is-danger .modal-card { border-color: rgba(248, 113, 113, .32); }

/* sur téléphone : la fenêtre monte du bas, boutons pleine largeur */
@media (max-width: 559px) {
    .pv-dialog { place-items: end stretch; padding: 0; }
    .pv-dialog .modal-card {
        max-width: none;
        border-radius: 22px 22px 0 0;
        padding: 18px 16px calc(16px + var(--safe-b));
        max-height: 85dvh;
    }
    .pv-dialog-actions { flex-direction: column-reverse; }
    .pv-dialog-actions .btn { width: 100%; justify-content: center; min-height: 46px; }
}

/* bouton « i » : petit visuellement, grande zone de toucher */
.info-btn {
    position: relative;
    display: inline-grid;
    place-items: center;
    width: 19px;
    height: 19px;
    margin-left: 4px;
    padding: 0;
    border-radius: 50%;
    border: 1px solid rgba(var(--acc-soft), .45);
    background: rgba(var(--acc), .12);
    color: rgb(var(--acc-soft));
    font: italic 700 11.5px/1 Georgia, "Times New Roman", serif;
    vertical-align: middle;
    cursor: pointer;
    transition: background .2s, border-color .2s;
}
.info-btn::after { content: ""; position: absolute; inset: -8px; }
.info-btn:hover { background: rgba(var(--acc), .26); border-color: rgb(var(--acc-soft)); }
.form-head h2 .info-btn, .settings-card-title .info-btn { width: 20px; height: 20px; }
small.warn { color: var(--warn-t, #fcd34d); }

/* =================================================================
   Chat : bulle « aller en bas » (v67)
   ================================================================= */
.chat-main { position: relative; }
.chat-jump {
    position: absolute;
    left: 50%;
    bottom: 90px;
    z-index: 30;
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 50%;
    border: 1px solid rgba(var(--ink), .14);
    background: var(--elev, rgba(24, 24, 38, .96));
    color: var(--text);
    box-shadow: 0 10px 28px -10px var(--sh, rgba(0, 0, 0, .9)), 0 0 0 1px var(--sh-ring, rgba(0, 0, 0, .3));
    cursor: pointer;
    transform: translateX(-50%);
    animation: jump-in .18s ease-out both;
    -webkit-tap-highlight-color: transparent;
}
.chat-jump svg { width: 18px; height: 18px; }
.chat-jump:hover { background: var(--elev-2, rgba(36, 36, 56, .98)); }
.chat-jump::after { content: ""; position: absolute; inset: -6px; border-radius: 50%; } /* zone de toucher 52 px */
/* du nouveau est arrivé pendant qu'on lisait plus haut */
.chat-jump.has-new::before {
    content: "";
    position: absolute;
    top: 1px;
    right: 1px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgb(var(--acc));
    box-shadow: 0 0 0 2px var(--elev, #0e0e18);
}
@keyframes jump-in {
    from { opacity: 0; transform: translate(-50%, 6px) scale(.9); }
    to { opacity: 1; transform: translate(-50%, 0) scale(1); }
}

/* =================================================================
   Barre de navigation du bas — nouveau design (v68)
   Trois propositions, sélectionnées par html[data-tabbar] : float | pill | classic
   ================================================================= */

/* espace réservé sous le contenu, réutilisé par la barre d'enregistrement et les toasts */
:root { --tabbar-space: calc(62px + var(--safe-b)); }
html[data-tabbar="float"], html[data-tabbar="pill"] { --tabbar-space: calc(84px + var(--safe-b)); }
html[data-tabbar="classic"] { --tabbar-space: calc(66px + var(--safe-b)); }

.toast { bottom: calc(var(--tabbar-space) + 18px); }
@media (max-width: 899px) {
    form.is-dirty .save-bar { bottom: calc(var(--tabbar-space) + 10px); }
    /* réserve sous le contenu pour la barre du bas — pas dans une conversation, qui n'en a pas */
    .page:not(.page-chat) { padding-bottom: calc(var(--tabbar-space) + 40px); }
}

.tabbar .tab-ico { position: relative; display: grid; place-items: center; transition: transform .25s cubic-bezier(.2, .8, .2, 1), background .25s, box-shadow .25s; }
.tabbar .tab-label { line-height: 1; transition: color .2s, opacity .2s; }
.tabbar a { -webkit-tap-highlight-color: transparent; }
.tabbar a:active .tab-ico { transform: scale(.9); }

/* ------------------------------------------------ A · capsule flottante */
html[data-tabbar="float"] .tabbar {
    left: 12px;
    right: 12px;
    bottom: calc(10px + var(--safe-b));
    height: 64px;
    padding: 0 6px;
    border-radius: 24px;
    border: 1px solid rgba(var(--ink), .09);
    background: var(--bar, rgba(16, 16, 28, .95));
    backdrop-filter: blur(24px) saturate(160%);
    -webkit-backdrop-filter: blur(24px) saturate(160%);
    box-shadow: 0 18px 40px -16px var(--sh, rgba(0, 0, 0, .95)), inset 0 1px 0 rgba(var(--ink), .05);
}
html[data-tabbar="float"] .tabbar a { gap: 4px; color: var(--muted-2); }
html[data-tabbar="float"] .tabbar a.is-active::before { display: none; }
html[data-tabbar="float"] .tabbar .tab-ico { width: 46px; height: 28px; border-radius: 999px; }
html[data-tabbar="float"] .tabbar a.is-active .tab-ico {
    background: linear-gradient(135deg, rgba(var(--acc), .28), rgba(var(--acc-hot), .22));
    box-shadow: 0 0 0 1px rgba(var(--acc-soft), .25), 0 6px 18px -6px rgba(var(--acc), .7);
}
html[data-tabbar="float"] .tabbar a.is-active .ico { color: var(--text); }
html[data-tabbar="float"] .tabbar a.is-active .tab-label { color: rgb(var(--acc-faint)); }
/* « + » : bouton rond en dégradé qui dépasse de la capsule */
html[data-tabbar="float"] .tabbar .tab-add .tab-ico {
    width: 52px;
    height: 52px;
    margin-top: -26px;
    border-radius: 50%;
    background: var(--grad);
    box-shadow: 0 10px 24px -6px rgba(var(--acc-mid), .75), 0 0 0 5px var(--elev, rgba(16, 16, 28, .9));
}
html[data-tabbar="float"] .tabbar .tab-add .ico { width: 24px !important; height: 24px !important; color: var(--on-grad, #fff); }
html[data-tabbar="float"] .tabbar .tab-add .tab-label { color: rgb(var(--acc-alt-2)); }

/* ------------------------------------------- B · pilule qui se déplie */
html[data-tabbar="pill"] .tabbar {
    left: 12px;
    right: 12px;
    bottom: calc(10px + var(--safe-b));
    height: 62px;
    padding: 0 8px;
    display: flex;
    justify-content: space-between;
    border-radius: 999px;
    border: 1px solid rgba(var(--ink), .09);
    background: var(--bar, rgba(16, 16, 28, .95));
    backdrop-filter: blur(24px) saturate(160%);
    -webkit-backdrop-filter: blur(24px) saturate(160%);
    box-shadow: 0 18px 40px -16px var(--sh, rgba(0, 0, 0, .95));
}
html[data-tabbar="pill"] .tabbar a {
    flex: 0 0 auto;
    flex-direction: row;
    gap: 7px;
    height: 44px;
    min-width: 44px;
    padding: 0 12px;
    border-radius: 999px;
    color: var(--muted-2);
    transition: background .3s, color .2s, padding .3s;
}
html[data-tabbar="pill"] .tabbar a.is-active::before { display: none; }
/* libellé visible seulement sur l'onglet actif (les autres le gardent pour les lecteurs d'écran) */
html[data-tabbar="pill"] .tabbar a:not(.is-active) .tab-label {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}
html[data-tabbar="pill"] .tabbar a.is-active {
    padding: 0 16px 0 13px;
    background: var(--grad);
    color: var(--on-grad, #fff);
    box-shadow: 0 8px 22px -8px rgba(var(--acc-mid), .8);
}
html[data-tabbar="pill"] .tabbar a.is-active .ico { color: var(--on-grad, #fff); }
html[data-tabbar="pill"] .tabbar a.is-active .tab-label { font-size: 12.5px; font-weight: 700; color: var(--on-grad, #fff); }
html[data-tabbar="pill"] .tabbar .tab-add { width: 44px; padding: 0; border: 1px solid rgba(var(--acc-soft), .35); background: rgba(var(--acc), .14); }
html[data-tabbar="pill"] .tabbar .tab-add .ico { color: rgb(var(--acc-alt)) !important; }

/* --------------------------------------------- C · barre classique soignée */
html[data-tabbar="classic"] .tabbar {
    height: calc(66px + var(--safe-b));
    background: var(--bar-grad, linear-gradient(180deg, rgba(14, 14, 24, .9), rgba(8, 8, 15, .97)));
    border-top: 1px solid rgba(var(--ink), .07);
    box-shadow: 0 -12px 30px -18px var(--sh, rgba(0, 0, 0, .9));
}
html[data-tabbar="classic"] .tabbar a { gap: 5px; color: var(--muted-2); }
html[data-tabbar="classic"] .tabbar a.is-active::before { display: none; }
html[data-tabbar="classic"] .tabbar a.is-active .tab-label { color: var(--text); }
html[data-tabbar="classic"] .tabbar a.is-active .ico { color: rgb(var(--acc-alt)); filter: drop-shadow(0 0 8px rgba(var(--acc-soft), .65)); }
/* point lumineux sous l'onglet actif */
html[data-tabbar="classic"] .tabbar a.is-active .tab-ico::after {
    content: "";
    position: absolute;
    top: -9px;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: rgb(var(--acc-glow));
    box-shadow: 0 0 8px 2px rgba(var(--acc-glow), .7);
}
html[data-tabbar="classic"] .tabbar .tab-add .tab-ico {
    width: 54px;
    height: 54px;
    margin-top: -30px;
    border-radius: 18px;
    background: var(--grad);
    transform: rotate(0);
    box-shadow: 0 12px 26px -8px rgba(var(--acc-mid), .8), 0 0 0 6px var(--elev, rgba(10, 10, 18, 1));
}
html[data-tabbar="classic"] .tabbar .tab-add .ico { width: 24px !important; height: 24px !important; color: var(--on-grad, #fff); }
html[data-tabbar="classic"] .tabbar .tab-add .tab-label { color: rgb(var(--acc-alt-2)); }

@media (prefers-reduced-motion: reduce) {
    .tabbar .tab-ico, html[data-tabbar="pill"] .tabbar a { transition: none; }
}

/* Date affichée au toucher, sous les bulles du personnage. */
.msg-time { font-size: 11.5px; color: var(--muted-2); white-space: nowrap; font-variant-numeric: tabular-nums; }

.msg-user:not(.is-selecting-text) [data-message-menu] {
    -webkit-touch-callout: none;
    user-select: none;
}
.message-menu {
    position: fixed;
    z-index: 55;
    width: min(280px, calc(100vw - 16px));
    padding: 8px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 22px;
    background: var(--elev, #171423);
    box-shadow: 0 10px 30px rgba(0, 0, 0, .34);
}
.message-menu .msg-time {
    display: block;
    padding: 8px 14px;
    font-size: 13px;
    white-space: normal;
}
.message-menu .action-row {
    min-height: 44px;
    border: 0;
    background: transparent;
}
.message-menu .action-row:hover,
.message-menu .action-row:focus-visible { background: rgba(var(--ink), .07); }

.bubble[data-react] { cursor: pointer; }
.bubble[data-react][aria-expanded="true"] { border-color: rgba(var(--acc-mid), .55); }
.msg-reaction-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 8px;
    min-height: 28px;
    border-radius: 99px;
    border: 1px solid rgba(var(--acc-mid), .34);
    background: rgba(var(--acc-mid), .15);
    color: var(--text);
    font-size: 16px;
    line-height: 1;
}
button.msg-reaction-chip { cursor: pointer; }
button.msg-reaction-chip:hover { background: rgba(var(--acc-mid), .26); }

@media (prefers-reduced-motion: no-preference) {
    [data-reaction-animation] {
        position: relative;
        animation: reaction-pop 320ms ease-out both;
    }
    [data-reaction-animation="like"] { animation-name: reaction-bounce; }
    [data-reaction-animation="heart"] { animation-name: reaction-heartbeat; }
    [data-reaction-animation="celebrate"]::after {
        content: "";
        position: absolute;
        inset: 0;
        pointer-events: none;
        background:
            radial-gradient(circle, #ffd477 55%, transparent 70%) 50% 0 / 4px 4px,
            radial-gradient(circle, #ff82af 55%, transparent 70%) 100% 30% / 3px 3px,
            radial-gradient(circle, #73dbff 55%, transparent 70%) 86% 95% / 4px 4px,
            radial-gradient(circle, #ffd477 55%, transparent 70%) 15% 92% / 3px 3px,
            radial-gradient(circle, #c1a0ff 55%, transparent 70%) 0 35% / 4px 4px;
        background-repeat: no-repeat;
        animation: reaction-sparkles 320ms ease-out both;
    }
}

@keyframes reaction-pop {
    0% { transform: scale(.85); }
    40% { transform: scale(1.5); }
    100% { transform: scale(1); }
}
@keyframes reaction-bounce {
    0% { transform: scale(.85); }
    35% { transform: translateY(-7px) rotate(-12deg) scale(1.5); }
    68% { transform: translateY(1px) rotate(5deg) scale(1.08); }
    100% { transform: none; }
}
@keyframes reaction-heartbeat {
    0% { transform: scale(.9); }
    32% { transform: scale(1.65); }
    55% { transform: scale(1.05); }
    74% { transform: scale(1.28); }
    100% { transform: scale(1); }
}
@keyframes reaction-sparkles {
    0% { transform: scale(.65); opacity: 0; }
    35% { opacity: 1; }
    100% { transform: scale(2.4); opacity: 0; }
}

.reaction-avatar { display: grid; place-items: center; position: relative; width: 17px; height: 17px; border-radius: 50%; overflow: hidden; }
.reaction-avatar img { width: 100%; height: 100%; object-fit: cover; }
.reaction-avatar .avatar-fallback span { font-size: 7px; transform: none; }
.reaction-popover {
    position: fixed;
    z-index: 25;
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
    gap: 6px;
    width: min(348px, calc(100vw - 16px));
    pointer-events: none;
}
.reaction-picker {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 3px;
    padding: 6px;
    border: 1px solid var(--border);
    border-radius: 28px;
    background: var(--elev, #171423);
    box-shadow: 0 8px 28px rgba(0, 0, 0, .23);
    overflow-y: auto;
    pointer-events: auto;
}
.reaction-picker.is-expanded { border-radius: 21px; }
.reaction-picker > button {
    display: grid;
    place-items: center;
    width: 100%;
    height: 42px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--text);
    cursor: pointer;
    font-size: clamp(20px, 6.1vw, 26px);
    line-height: 1;
}
.reaction-picker > button:hover,
.reaction-picker > button[aria-pressed="true"] { background: rgba(var(--acc-mid), .20); }
.reaction-picker > .msg-tool-more-reactions { background: rgba(var(--ink), .07); }
.reaction-actions {
    display: flex;
    gap: 6px;
    padding-inline: 6px;
}
.reaction-actions .msg-tool {
    background: var(--elev, #171423);
    box-shadow: 0 4px 12px rgba(0, 0, 0, .23);
    pointer-events: auto;
}
@media (pointer: coarse) { .reaction-actions .msg-tool { width: 44px; height: 44px; } }

/* curseur à deux poignées : deux curseurs natifs superposés sur une même piste */
.dual-range {
    --lo: 0;
    --hi: 1;
    --thumb: 18px;
    position: relative;
    height: 26px;
}
.dual-range::before,
.dual-range-fill {
    content: "";
    position: absolute;
    top: 50%;
    height: 4px;
    margin-top: -2px;
    border-radius: 99px;
}
.dual-range::before { left: 0; right: 0; background: rgba(var(--ink), .14); }
/* le centre d'une poignée va de thumb/2 à 100 % - thumb/2 */
.dual-range-fill {
    left: calc(var(--thumb) / 2 + (100% - var(--thumb)) * var(--lo));
    width: calc((100% - var(--thumb)) * (var(--hi) - var(--lo)));
    background: var(--grad);
}
.dual-range .range {
    position: absolute;
    inset: 0;
    z-index: 2;
    margin: 0;
    pointer-events: none; /* seules les poignées captent le doigt */
}
.dual-range .range::-webkit-slider-runnable-track { background: transparent; }
.dual-range .range::-moz-range-track { background: transparent; }
.dual-range { cursor: pointer; touch-action: pan-y; } /* glisser à l'horizontale, défiler à la verticale */
.dual-range .range:focus-visible::-webkit-slider-thumb { outline: 2px solid rgba(var(--acc), .9); outline-offset: 2px; }

/* bouton fermer (×) : pastille ronde avec contour, bien visible */
.icon-btn.btn-close {
    width: 36px;
    height: 36px;
    flex: none;
    border-radius: 50%;
    border-color: rgba(var(--ink), .18);
    background: rgba(var(--ink), .06);
    color: var(--text);
    font-size: 22px;
    line-height: 1;
}
.icon-btn.btn-close:hover {
    border-color: rgba(var(--acc), .6);
    background: rgba(var(--ink), .1);
}
.icon-btn.btn-close:active { transform: scale(.94); }
@media (pointer: coarse) {
    /* écran tactile : un peu plus grand pour le doigt */
    .icon-btn.btn-close { width: 40px; height: 40px; }
}

/* avertissement discret sous un réglage qui n'aura pas d'effet */
.inline-warn {
    margin: 2px 0 6px;
    padding: 9px 12px;
    border-radius: 12px;
    border: 1px solid rgba(251, 191, 36, .35);
    background: rgba(251, 191, 36, .1);
    color: var(--text);
    font-size: 13px;
    line-height: 1.5;
}
.inline-warn a { color: rgb(var(--acc)); font-weight: 600; white-space: nowrap; }

/* ‹ 2 / 3 › sous la dernière réponse régénérée */
.msg-versions {
    flex: 0 0 100%;
    display: flex;
    align-items: center;
    gap: 2px;
    margin: 4px 0 0 42px;
    font-size: 12px;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}
html[data-avatars="0"] .msg-versions { margin-left: 0; }
.msg-versions span { min-width: 38px; text-align: center; }
.msg-versions button {
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
}
.msg-versions button svg { width: 16px; height: 16px; }
.msg-versions button:hover:not(:disabled) { background: rgba(var(--ink), .08); color: var(--text); }
.msg-versions button:disabled { opacity: .35; cursor: default; }
@media (pointer: coarse) { .msg-versions button { width: 36px; height: 36px; } }

/* état de la tâche planifiée des relances (Réglages) */
.cron-box {
    display: grid;
    gap: 8px;
    margin: 4px 0 10px;
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: rgba(var(--ink), .03);
}
.cron-box.is-warn { border-color: rgba(251, 191, 36, .35); background: rgba(251, 191, 36, .08); }
.cron-state { display: flex; align-items: baseline; gap: 9px; margin: 0; font-size: 13.5px; line-height: 1.5; }
.cron-state .dot { transform: translateY(-1px); }
.cron-how summary { cursor: pointer; font-size: 13px; font-weight: 600; color: rgb(var(--acc)); }
.cron-how[open] summary { margin-bottom: 8px; }
.cron-how .hint { margin: 0 0 8px; }
.cron-how code { font-size: 12px; }
.cron-line { display: flex; gap: 8px; align-items: flex-start; margin-bottom: 8px; }
.cron-line code {
    flex: 1;
    min-width: 0;
    padding: 8px 10px;
    border-radius: 10px;
    background: rgba(var(--ink), .07);
    overflow-wrap: anywhere;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* idées de premier message (conversation vide) */
.chat-starters { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 14px; width: min(100%, 420px); }
.chat-starters .chip { cursor: pointer; font: inherit; font-size: 13px; max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
.chat-starters-more { border: 0; background: transparent; cursor: pointer; min-height: 36px; }
.chat-opening-questions { justify-content: flex-start; margin: 12px 0 0; }
.chat-starters[hidden], .chat-starters-more[hidden] { display: none; }
.empty .btn { margin-top: 2px; }
.empty-fav .empty-orb, .empty-arch .empty-orb, .empty-found .empty-orb { color: rgb(var(--acc)); }
.empty-orb svg { color: rgb(var(--acc)); }

/* liste des discussions : épinglées, heure relative, non lu */
.conv-group {
    margin: 18px 4px 8px;
    font-size: 11.5px;
    font-weight: 650;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--muted-2);
}
.conv-group:first-of-type { margin-top: 6px; }
.conv-item { display: flex; align-items: center; gap: 4px; }
.conv-item .conv-card { flex: 1; min-width: 0; }
.conv-line { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.conv-line strong { flex: 1; min-width: 0; color: var(--text-hi, #fff); }
.conv-line strong span { color: inherit; font-size: inherit; }
.contact-item {
    border: 1px solid var(--border-soft);
    border-radius: 16px;
    background: var(--card, rgba(var(--ink), .028));
}
.contact-item.is-unread { border-color: rgba(var(--acc), .35); }
/* bouton « nouvelle conversation », à droite de la ligne « ▶ n discussions » (ancré en haut :
   il reste sur cette ligne quand la liste des discussions est dépliée) */
.contact-foot { position: relative; }
.contact-new { position: absolute; right: 10px; top: -2px; margin: 0; z-index: 1; }
.contact-new-btn {
    display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%;
    border: 1px solid rgba(var(--acc), .35); background: rgba(var(--acc), .12); color: rgb(var(--acc)); cursor: pointer;
}
.contact-new-btn:is(:hover, :focus-visible) { background: rgba(var(--acc), .22); }
.contact-new-btn svg { width: 20px; height: 20px; }
.contact-history summary { padding-right: 56px; }
.contact-open { border: 0; background: transparent; }
.contact-open .conv-avatar { border-radius: 50%; }
.contact-open .conv-line strong { font-size: 15px; font-weight: 700; }
.contact-history { margin: 0 12px; border-top: 1px solid var(--border-soft); }
.contact-history summary { padding: 10px 4px; color: var(--muted); font-size: 12px; cursor: pointer; }
.contact-history summary:hover { color: var(--text); }
.contact-threads { margin: 0 0 10px; }
.conv-line time { flex: 0 0 auto; font-size: 11.5px; color: var(--muted-2); font-variant-numeric: tabular-nums; }
.conv-body .conv-preview {
    flex: 1;
    min-width: 0;
    font-size: 13px;
    color: var(--muted-2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.conv-you { font-weight: 600; color: var(--muted); margin-right: 3px; }
.conv-body .conv-badge {
    flex: 0 0 auto;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 10.5px;
    font-weight: 700;
    color: #fff;
    background: var(--grad);
}
.conv-item.is-unread .conv-line strong { font-weight: 750; }
.conv-item.is-unread .conv-line time { color: rgb(var(--acc)); font-weight: 650; }
.conv-item.is-unread .conv-preview { color: var(--text); }
.conv-item.is-unread .conv-card { border-color: rgba(var(--acc), .35); }

/* création d'un persona : import en pied de carte (tuile → fenêtre) */
.form-import { display: grid; gap: 14px; margin-top: 22px; }
.form-import-or {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--muted-2);
}
.form-import-or::before, .form-import-or::after { content: ""; flex: 1; height: 1px; background: var(--border-soft); }
.import-tile {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    padding: 14px 16px;
    border-radius: 16px;
    border: 1px dashed rgba(var(--acc), .4);
    background: rgba(var(--acc), .06);
    color: var(--text);
    font: inherit;
    text-align: left;
    cursor: pointer;
    transition: .18s;
}
.import-tile:hover, .import-tile:focus-visible {
    border-style: solid;
    border-color: rgba(var(--acc), .6);
    background: rgba(var(--acc), .11);
}
.import-tile:active { transform: scale(.99); }
.import-tile-ico {
    width: 42px;
    height: 42px;
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    border-radius: 13px;
    background: var(--grad);
    color: var(--on-grad, #fff);
    box-shadow: 0 6px 16px -6px rgba(var(--acc), .6);
}
.import-tile-ico svg { width: 21px; height: 21px; }
.import-tile-text { flex: 1; min-width: 0; display: grid; gap: 2px; }
.import-tile-text strong { font-size: 14.5px; font-weight: 650; }
.import-tile-text small { font-size: 12.5px; color: var(--muted); line-height: 1.4; }
.import-tile-go { width: 18px; height: 18px; flex: 0 0 auto; color: var(--muted-2); transition: transform .18s; }
.import-tile:hover .import-tile-go { transform: translateX(3px); color: rgb(var(--acc)); }
.import-modal-body { display: grid; gap: 14px; justify-items: start; }
.import-modal-body .hint { margin: 0; }

/* liste des discussions : compteur, punaise indicative, menu d'actions */
/* appui long = menu : ni sélection de texte ni bulle « copier » du système, ni sur la carte
   ni sur le menu qui apparaît sous le doigt encore posé */
.conv-list, .conv-group, .conv-hint, .action-sheet {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}
.conv-pinned-ico { width: 13px; height: 13px; margin-right: 5px; vertical-align: -1px; color: rgb(var(--acc)); }
.conv-body .conv-count { flex: 0 0 auto; font-style: normal; font-size: 11px; color: var(--muted-2); font-variant-numeric: tabular-nums; }
.conv-more {
    width: 34px;
    height: 34px;
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--muted-2);
    cursor: pointer;
}
.conv-more svg { width: 18px; height: 18px; }
.conv-more:hover, .conv-more:focus-visible { background: rgba(var(--ink), .07); color: var(--text); }
/* sur écran tactile, l'appui long suffit : pas de bouton « ⋯ » qui mange la place */
@media (hover: none) and (pointer: coarse) { .conv-more { display: none; } }
@media (hover: hover) { .conv-item:not(:hover) .conv-more:not(:focus-visible) { opacity: 0; } }
.conv-hint { margin: 14px 4px 0; text-align: center; font-size: 12px; }
@media (hover: hover) and (pointer: fine) { .conv-hint { display: none; } }

/* menu d'actions : feuille en bas sur mobile, fenêtre au centre ailleurs */
.action-sheet .modal-head .eyebrow { margin: 0 0 2px; }
.action-sheet .modal-head h2 { font-size: 16px; overflow-wrap: anywhere; }
.action-list { display: grid; gap: 6px; }
.action-row {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 13px 14px;
    border-radius: 14px;
    border: 1px solid var(--border-soft);
    background: rgba(var(--ink), .03);
    color: var(--text);
    font: inherit;
    font-size: 15px;
    text-align: left;
    cursor: pointer;
}
.action-row svg { width: 20px; height: 20px; flex: 0 0 auto; }
.action-row:hover, .action-row:focus-visible { background: rgba(var(--ink), .07); }
.action-row[aria-busy="true"] { cursor: wait; color: var(--muted); }
.action-row.is-danger { color: #f87171; }
html[data-mode="light"] .action-row.is-danger { color: #dc2626; }
@media (max-width: 640px) {
    .action-sheet { align-items: end; padding: 0; }
    .action-sheet .modal-card {
        width: 100%;
        max-width: none;
        border-radius: 22px 22px 0 0;
        padding-bottom: calc(18px + env(safe-area-inset-bottom));
        animation: sheet-up .22s ease-out both;
    }
}
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }

/* visionneuse : portrait (étoile) et suppression de la photo affichée */
.lb-btn.is-on { color: #fbbf24; border-color: rgba(251, 191, 36, .5); cursor: default; }
.lb-btn.is-on svg path { fill: currentColor; }
.lb-btn.lb-danger:hover { background: rgba(248, 113, 113, .3); border-color: rgba(248, 113, 113, .6); }
.lb-btn[hidden] { display: none; }
@media (max-width: 380px) { .lb-actions { gap: 7px; } .lb-btn { width: 40px; height: 40px; } }

/* sous-menu « retirer la fiche » : deux lignes, titre + explication */
.action-row-2 { align-items: flex-start; }
.action-row-2 svg { margin-top: 2px; }
.action-row-2 span { display: grid; gap: 2px; }
.action-row-2 strong { font-size: 15px; font-weight: 650; }
.action-row-2 small { font-size: 12.5px; line-height: 1.45; color: var(--muted); font-weight: 400; }
.action-list form { margin: 0; }

/* favori : bouton rond en haut à droite du portrait */
.hero-fav-form { position: absolute; top: 12px; right: 12px; z-index: 2; margin: 0; }
.hero-fav {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, .28);
    background: rgba(10, 10, 16, .45);
    color: #fff;
    cursor: pointer;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: 0 6px 18px -6px rgba(0, 0, 0, .6);
    transition: transform .18s, background .18s, color .18s;
}
.hero-fav svg { width: 21px; height: 21px; }
.hero-fav:hover { background: rgba(10, 10, 16, .62); }
.hero-fav:active { transform: scale(.9); }
.hero-fav.is-on { color: #f472b6; border-color: rgba(244, 114, 182, .55); }

/* souvenirs : formulaire d'ajout replié derrière un bouton (la liste reste en vue) */
.mem-add-fold { margin: 0 0 14px; }
.mem-add-fold > summary { list-style: none; display: inline-flex; width: auto; cursor: pointer; }
.mem-add-fold > summary::-webkit-details-marker { display: none; }
.mem-add-fold[open] > summary { margin-bottom: 10px; }
.mem-add-fold[open] > summary .ico { transform: rotate(45deg); }
.mem-add-fold > summary .ico { transition: transform .2s; }
.mem-add-fold .mem-add { margin-top: 0; }

/* séparateur de jour dans une discussion */
.msg-day { display: flex; justify-content: center; margin: 10px 0 2px; pointer-events: none; }
.msg-day span {
    padding: 4px 12px;
    border-radius: 999px;
    background: rgba(var(--ink), .07);
    border: 1px solid var(--border-soft);
    color: var(--muted);
    font-size: 11.5px;
    font-weight: 600;
}

/* « Nouvelle discussion » : bouton rond sur mobile, le titre et son compteur tiennent sur une ligne */
@media (max-width: 480px) {
    .btn-new { width: 46px; height: 46px; padding: 0; border-radius: 50%; justify-content: center; flex: 0 0 auto; }
    .btn-new .btn-label { display: none; }
    .btn-new .ico { width: 20px; height: 20px; }
}

/* texte réservé aux lecteurs d'écran */
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* boutons icône ronds (copier, éditer, supprimer) */
.icon-tool {
    width: 38px;
    height: 38px;
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    border-radius: 50%;
    border: 1px solid transparent;
    background: rgba(var(--ink), .06);
    color: rgba(var(--ink), .82);
    cursor: pointer;
    transition: background .18s, color .18s, transform .18s;
}
.icon-tool svg { width: 18px; height: 18px; }
.icon-tool:hover { background: rgba(var(--ink), .12); color: var(--text); }
.icon-tool:active { transform: scale(.92); }
.icon-tool.is-done { color: #34d399; background: rgba(52, 211, 153, .16); }
.icon-tool.is-danger { color: #f87171; background: transparent; }
.icon-tool.is-danger:hover { background: rgba(248, 113, 113, .14); }
html[data-mode="light"] .icon-tool.is-danger { color: #dc2626; }
@media (pointer: coarse) { .icon-tool { width: 42px; height: 42px; } }
.prompt-body[data-prompt-edit] { cursor: pointer; }

/* ======================================================================
   Éditeur de prompt v3 (mobile d'abord) : le texte prend l'écran, l'IA est en bas,
   les propositions s'affichent dans le texte, une seule feuille du bas pour le reste.
   ====================================================================== */
.prompt-editor .pe-card {
    position: relative;
    width: min(720px, 100%);
    max-width: none;
    height: min(88dvh, 860px);
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 0;
    overflow: hidden;
}
.pe-head { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.pe-hbtn {
    flex: 0 0 auto; width: 40px; height: 40px; border-radius: 50%; border: 0; cursor: pointer;
    display: grid; place-items: center; background: rgba(var(--ink), .07); color: var(--text);
}
.pe-hbtn svg { width: 18px; height: 18px; }
.pe-title {
    flex: 1; min-width: 0; height: 40px; padding: 0 4px; border: 0; background: transparent;
    color: var(--text); font: inherit; font-size: 17px; font-weight: 700;
}
.pe-title:focus { outline: none; }
.pe-title::placeholder { color: var(--muted-2); }
.pe-kindsel {
    flex: 0 0 auto; height: 32px; padding: 0 26px 0 12px; border-radius: 999px; border: 0; cursor: pointer;
    font: inherit; font-size: 12.5px; font-weight: 700; appearance: none; -webkit-appearance: none;
    background: rgba(var(--acc-deep), .2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='m7 10 5 5 5-5' fill='none' stroke='%23a8a8bc' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 8px center / 14px;
    color: rgb(var(--acc-soft));
}
.pe-kindsel[data-kind="negative"] { background-color: rgba(248, 113, 113, .16); color: var(--err-t, #fca5a5); }
.pe-kindsel[data-kind="video"] { background-color: rgba(34, 211, 238, .14); color: var(--cyan-t, #67e8f9); }
.pe-kindsel[data-kind="system"] { background-color: rgba(251, 191, 36, .15); color: var(--warn-t, #fcd34d); }
.pe-kindsel[data-kind="other"] { background-color: rgba(var(--ink), .08); color: var(--text); }
.pe-kindsel option { color: initial; background: initial; }

/* le texte, en grand */
.pe-content {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 10px;
    min-height: 0;
    overflow: auto;
    overscroll-behavior: contain;
}
.pe-content > :not(.pe-body) { flex-shrink: 0; }
.pe-body, .pe-diffview {
    flex: 1; min-height: 120px; padding: 10px 6px; border: 0; border-radius: 0;
    background: transparent; color: var(--text); resize: none; overflow: auto;
    font: 15px/1.75 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    white-space: pre-wrap; word-break: break-word;
}
.pe-diffview { flex-basis: auto; overflow: visible; }
.pe-body:focus { outline: none; }
.pe-body::placeholder { color: var(--muted-2); }
.pe-body[hidden], .pe-diffview[hidden] { display: none; }
.pe-body.is-flash { animation: pe-flash 1.2s ease-out; border-radius: 12px; }
@keyframes pe-flash { 0% { background: rgba(232, 121, 249, .16); } 100% { background: transparent; } }
.prompt-editor.is-ai-busy .pe-body { opacity: .55; }
.pe-diffview .is-add { color: #a7f3d0; background: rgba(52, 211, 153, .2); border-radius: 4px; }
.pe-diffview .is-del { color: #fecaca; background: rgba(248, 113, 113, .18); text-decoration: line-through; text-decoration-color: rgba(248, 113, 113, .75); border-radius: 4px; }
.pe-diffview .is-kept { color: var(--muted-2); }
html[data-mode="light"] .pe-diffview .is-add { color: #065f46; }
html[data-mode="light"] .pe-diffview .is-del { color: #991b1b; }

/* bandeau d'une proposition */
.pe-banner {
    display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; padding: 10px 14px; border-radius: 16px;
    background: rgba(232, 121, 249, .1); border: 1px solid rgba(232, 121, 249, .38); font-size: 14px;
}
.pe-banner[hidden] { display: none; }
.pe-banner strong { flex: 1; min-width: 0; }
.pe-banner-ico { color: #e879f9; }
.pe-banner-stats { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--muted); }
.pe-banner small { flex-basis: 100%; color: var(--muted); font-size: 12.5px; }
.pe-banner small.is-safe { color: #6ee7b7; }
html[data-mode="light"] .pe-banner small.is-safe { color: #047857; }

/* l'IA, toujours en bas */
.pe-ai { display: flex; flex-direction: column; gap: 8px; flex-shrink: 0; }
.prompt-editor.is-proposing .pe-ai { display: none; }
.pe-chips {
    display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px;
}
.pe-chips::-webkit-scrollbar { display: none; }
.pe-chip {
    flex: 0 0 auto; height: 34px; padding: 0 13px; border-radius: 999px; cursor: pointer; white-space: nowrap;
    border: 1px solid rgba(var(--ink), .14); background: transparent; color: var(--text);
    font: inherit; font-size: 13px; font-weight: 600;
}
.pe-chip.is-ai { border: 0; color: #fff; background: linear-gradient(135deg, #a78bfa, #e879f9 60%, #f472b6); }
.pe-chip.is-ai::before { content: "✦ "; }
.pe-chip.is-add::before { content: "+ "; color: #34d399; }
.pe-chip.is-sugg { border-color: rgba(232, 121, 249, .45); background: rgba(232, 121, 249, .08); }
.pe-chip.is-sugg::before { content: "✦ "; color: #e879f9; }
.pe-chip.is-undo { border-color: rgba(232, 121, 249, .5); color: #f0abfc; }
html[data-mode="light"] .pe-chip.is-undo { color: #a21caf; }
.pe-chip:disabled { opacity: .45; cursor: progress; }
.pe-compose {
    display: flex; align-items: center; gap: 8px; padding: 5px 5px 5px 14px; border-radius: 999px;
    background: rgba(var(--ink), .06); border: 1px solid rgba(232, 121, 249, .4);
}
.pe-compose:focus-within { border-color: rgba(232, 121, 249, .75); box-shadow: 0 0 0 4px rgba(232, 121, 249, .12); }
.pe-compose-ico { color: #e879f9; display: grid; }
.pe-compose-ico svg { width: 18px; height: 18px; }
.pe-ask { flex: 1; min-width: 0; height: 40px; border: 0; background: transparent; color: var(--text); font: inherit; font-size: 15px; }
.pe-ask:focus { outline: none; }
.pe-ask[hidden], .pe-busy[hidden], .pe-send[hidden], .pe-stop[hidden] { display: none; }
.pe-busy {
    flex: 1; min-width: 0; height: 40px; display: flex; align-items: center; font-size: 14px; font-weight: 600;
    background: linear-gradient(90deg, var(--muted) 0%, #f0abfc 50%, var(--muted) 100%);
    background-size: 220% 100%; -webkit-background-clip: text; background-clip: text; color: transparent;
    animation: pe-shine 1.6s linear infinite; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
@keyframes pe-shine { from { background-position: 120% 0; } to { background-position: -120% 0; } }
@media (prefers-reduced-motion: reduce) { .pe-busy { animation: none; color: var(--muted); } }
.pe-send, .pe-stop {
    flex: 0 0 auto; width: 42px; height: 42px; border-radius: 50%; border: 0; cursor: pointer; color: #fff;
    display: grid; place-items: center; background: linear-gradient(135deg, #a78bfa, #e879f9 60%, #f472b6);
}
.pe-stop { background: rgba(var(--ink), .16); color: var(--text); }
.pe-send svg, .pe-stop svg { width: 18px; height: 18px; }

/* boutons du bas */
.pe-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; flex-shrink: 0; }
.pe-actions[hidden] { display: none; }
.pe-actions.pe-decide { grid-template-columns: 1fr 1fr 1.3fr; }
.pe-actions .btn { height: 52px; justify-content: center; font-size: 15px; border-radius: 16px; }

/* feuille du bas (bilan, variantes, historique, options) : dans l'éditeur, une seule zone qui défile */
.pe-sheet-back { position: absolute; inset: 0; z-index: 4; background: rgba(4, 4, 9, .55); }
.pe-sheet-back[hidden], .pe-sheet[hidden] { display: none; }
.pe-sheet {
    position: absolute; left: 0; right: 0; bottom: 0; z-index: 5; max-height: 86%;
    display: flex; flex-direction: column; border-radius: 24px 24px 0 0;
    background: var(--elev, #0e0e18); border-top: 1px solid rgba(var(--ink), .12);
    box-shadow: 0 -20px 40px -20px rgba(0, 0, 0, .7);
    transform: translateY(100%); transition: transform .22s ease-out;
    padding-bottom: env(safe-area-inset-bottom);
}
.pe-sheet.is-on { transform: none; }
.pe-sheet-grab { flex: 0 0 auto; height: 26px; cursor: grab; touch-action: none; position: relative; }
.pe-sheet-grab::after { content: ""; position: absolute; left: 50%; top: 10px; width: 40px; height: 5px; margin-left: -20px; border-radius: 9px; background: rgba(var(--ink), .22); }
.pe-sheet-body { overflow: auto; padding: 0 18px 18px; display: flex; flex-direction: column; gap: 10px; }
.pe-sheet-lead { margin: 0; color: var(--muted); font-size: 13.5px; }
.pe-sheet-foot { display: flex; gap: 10px; padding-top: 6px; }
.pe-sheet-foot .btn { flex: 1; height: 48px; justify-content: center; border-radius: 14px; }

/* bilan */
.pe-score { display: flex; align-items: center; gap: 14px; }
.pe-ring {
    --c: #fbbf24; flex: 0 0 auto; width: 62px; height: 62px; border-radius: 50%; display: grid; place-items: center;
    background: conic-gradient(var(--c) calc(var(--p) * 1%), rgba(var(--ink), .1) 0);
}
.pe-ring.is-bon { --c: #34d399; }
.pe-ring.is-faible { --c: #f87171; }
.pe-ring strong { width: 50px; height: 50px; border-radius: 50%; display: grid; place-items: center; background: var(--elev, #0e0e18); font-size: 18px; font-weight: 800; }
.pe-score-txt p { margin: 4px 0 0; font-size: 13.5px; line-height: 1.45; color: var(--muted); }
.pe-level { font-size: 14px; }
.pe-level.is-bon { color: #34d399; } .pe-level.is-moyen { color: #fbbf24; } .pe-level.is-faible { color: #f87171; }
html[data-mode="light"] .pe-level.is-bon { color: #047857; }
html[data-mode="light"] .pe-level.is-moyen { color: #b45309; }
html[data-mode="light"] .pe-level.is-faible { color: #b91c1c; }
.pe-crits { list-style: none; margin: 0; padding: 0; }
.pe-crits li { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 6px 0; border-top: 1px solid rgba(var(--ink), .07); }
.pe-dot { flex: 0 0 auto; width: 10px; height: 10px; border-radius: 50%; background: #f87171; }
.pe-crits li.is-partial .pe-dot { background: #fbbf24; }
.pe-crits li.is-ok .pe-dot { background: #34d399; }
.pe-crit-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; font-size: 14.5px; }
.pe-crit-txt small { color: var(--muted); font-size: 12.5px; line-height: 1.4; }
.pe-crit-add {
    flex: 0 0 auto; height: 36px; padding: 0 14px; border-radius: 999px; cursor: pointer; font: inherit; font-size: 13px; font-weight: 700;
    border: 1px solid rgba(232, 121, 249, .5); background: rgba(232, 121, 249, .08); color: #f0abfc;
}
html[data-mode="light"] .pe-crit-add { color: #a21caf; }
.pe-conflicts { padding: 10px 12px; border-radius: 12px; background: rgba(251, 191, 36, .1); border: 1px solid rgba(251, 191, 36, .3); font-size: 13.5px; }
.pe-conflicts strong { color: #fbbf24; }
html[data-mode="light"] .pe-conflicts strong { color: #b45309; }
.pe-conflicts ul { margin: 4px 0 0; padding-left: 18px; }

/* variantes */
.pe-variant {
    position: relative; display: flex; flex-direction: column; gap: 4px; text-align: left; cursor: pointer; font: inherit; color: var(--text);
    padding: 14px 14px 14px 50px; border-radius: 16px; border: 1px solid rgba(var(--ink), .12); background: rgba(var(--ink), .04);
}
.pe-variant:active { transform: scale(.99); }
.pe-v-n { position: absolute; left: 14px; top: 14px; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
    font-size: 12px; font-weight: 800; color: #fff; background: linear-gradient(135deg, #a78bfa, #e879f9); }
.pe-variant small { color: var(--muted); font: 12.5px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* options (⋯) */
.pe-menu-item {
    display: flex; align-items: center; gap: 14px; min-height: 54px; padding: 0 6px; border: 0; border-radius: 12px;
    background: transparent; color: var(--text); font: inherit; font-size: 15.5px; font-weight: 600; text-align: left; cursor: pointer;
}
.pe-menu-item:active { background: rgba(var(--ink), .06); }
.pe-menu-item.is-done { color: #34d399; }
.pe-menu-ico { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: rgba(var(--ink), .07); font-size: 16px; }
.pe-menu-item.is-danger { color: #f87171; }
.pe-menu-note { margin: 4px 6px 0; font-size: 12.5px; color: var(--muted-2); }

/* historique */
.pe-hist-list { display: flex; flex-direction: column; gap: 8px; }
.pe-hist { border-radius: 14px; background: rgba(var(--ink), .045); }
.pe-hist > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px; min-height: 50px; padding: 0 14px; font-size: 14px; }
.pe-hist > summary::-webkit-details-marker { display: none; }
.pe-hist-when { flex: 1; }
.pe-hist-add { color: #34d399; font-weight: 700; font-variant-numeric: tabular-nums; }
.pe-hist-del { color: #f87171; font-weight: 700; font-variant-numeric: tabular-nums; }
html[data-mode="light"] .pe-hist-add { color: #059669; }
html[data-mode="light"] .pe-hist-del { color: #dc2626; }
.pe-diff { margin: 0 10px; padding: 8px 0; border-radius: 10px; background: rgba(var(--ink), .04); font: 12px/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.pe-diff-line { padding: 0 10px; white-space: pre-wrap; word-break: break-word; }
.pe-diff-line.is-add { background: rgba(52, 211, 153, .14); color: #6ee7b7; }
.pe-diff-line.is-del { background: rgba(248, 113, 113, .14); color: #fca5a5; text-decoration: line-through; }
.pe-diff-line.is-same { color: var(--muted); }
html[data-mode="light"] .pe-diff-line.is-add { color: #047857; }
html[data-mode="light"] .pe-diff-line.is-del { color: #b91c1c; }
.pe-diff-skip { padding: 2px 10px; color: var(--muted-2); font-style: italic; }
.pe-hist-tools { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; padding: 10px; }
.icon-tool.is-ai-soft { color: #e879f9; }
html[data-mode="light"] .icon-tool.is-ai-soft { color: #a21caf; }

@media (max-width: 640px) {
    .prompt-editor { align-items: end; padding: 0; }
    .prompt-editor .pe-card {
        width: 100%;
        height: calc(100dvh - 24px);
        max-height: calc(100dvh - 24px);
        border-radius: 24px 24px 0 0;
        padding-bottom: calc(14px + env(safe-area-inset-bottom));
        animation: sheet-up .22s ease-out both;
    }
}
.hero-portrait img[data-full] { cursor: zoom-in; }

/* ---- panneau de la conversation : feuille qui monte du bas sur mobile, à tirer pour fermer ---- */
.sheet-grab, .chat-sheet-backdrop { display: none; }
.model-test {
    display: inline-grid;
    place-items: center;
    flex: 0 0 18px;
    width: 18px;
    height: 18px;
    min-width: 18px;
    aspect-ratio: 1;
    align-self: center;
    box-sizing: border-box;
    margin-left: 6px;
    padding: 0;
    border-radius: 50%;
    color: #000;
    background: #fbbf24;
    line-height: 0;
}
.model-test[hidden] { display: none; }
.model-test svg { width: 12px; height: 12px; display: block; }
.model-test svg path { stroke-width: 2.4; }
.conv-model { display: grid; gap: 8px; margin: 0; }
.conv-model-label { font-size: 13px; font-weight: 650; }
.conv-model-row { display: flex; gap: 8px; align-items: center; }
.conv-model-select { flex: 1; min-width: 0; height: 46px; }
.conv-model.is-override .conv-model-select { border-color: rgba(251, 191, 36, .6); }
.conv-model .hint { margin: 0; }
@media (max-width: 899px) {
    .chat-sheet {
        left: 0;
        right: 0;
        top: auto;
        bottom: 0 !important;
        width: auto;
        max-height: calc(100dvh - max(32px, env(safe-area-inset-top, 0px) + 16px));
        display: flex;
        flex-direction: column;
        overflow: hidden;
        padding: 0 0 env(safe-area-inset-bottom, 0px);
        border-radius: 24px 24px 0 0;
        border-bottom: 0;
        opacity: 1;
        transform: translateY(105%);
        transition: transform .34s cubic-bezier(.2, .85, .25, 1);
        box-shadow: 0 -20px 60px -20px var(--sh, #000);
    }
    .chat-sheet.is-open { transform: translateY(var(--drag, 0px)); }
    .chat-sheet.is-dragging { transition: none; }
    .sheet-grab {
        display: flex;
        justify-content: center;
        padding: 10px 0 4px;
        flex: 0 0 auto;
        touch-action: none;
        cursor: grab;
    }
    .sheet-grab span { width: 42px; height: 5px; border-radius: 999px; background: rgba(var(--ink), .28); }
    .chat-sheet .sheet-head {
        flex: 0 0 auto;
        margin: 0;
        padding: 4px 16px 12px;
        border-bottom: 1px solid var(--border-soft);
        touch-action: none;
    }
    .chat-sheet .sheet-body {
        flex: 1 1 auto;
        min-height: 0;
        overflow-y: auto;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
        padding: 16px 16px 24px;
    }
    .chat-sheet-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 95;
        background: rgba(4, 4, 9, .58);
        opacity: 0;
        pointer-events: none;
        transition: opacity .3s ease;
    }
    body.sheet-open .chat-sheet-backdrop { opacity: var(--backdrop-o, 1); pointer-events: auto; }
    body.sheet-dragging .chat-sheet-backdrop { transition: none; }
}
/* la règle générale « .chat-id-text span » (ellipse, overflow caché) ne doit ni rogner
   la pastille d'état ni déformer l'icône du modèle de test */
.chat-id-text .chat-model { overflow: visible; padding-left: 3px; }
.chat-id-text .model-test { overflow: visible; font-size: 0; flex: 0 0 18px; width: 18px; height: 18px; }

/* échec du chargement d'un modèle (panneau de la conversation) */
.lms-error {
    display: grid;
    gap: 8px;
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid rgba(248, 113, 113, .4);
    background: rgba(248, 113, 113, .1);
}
.lms-error[hidden] { display: none; }
.lms-error-hint { margin: 0; font-size: 13.5px; line-height: 1.5; color: var(--text); }
.lms-error-more summary { cursor: pointer; font-size: 12px; color: var(--muted); }
.lms-error-more p {
    margin: 6px 0 0;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 11.5px;
    line-height: 1.5;
    color: var(--muted);
    overflow-wrap: anywhere;
}
.lms-error .btn { justify-self: start; }

/* ---------------------------------------------- journal des échanges (Réglages › Journal) */
.settings-logs-link {
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr) 18px;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    margin-bottom: 14px;
    border: 1px solid var(--border-soft);
    border-radius: 16px;
    background: var(--card, rgba(var(--ink), .03));
    color: var(--text);
}
.settings-logs-link:is(:hover, :focus-visible) {
    border-color: rgba(var(--acc), .4);
}
.settings-logs-ico {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: rgba(var(--acc), .14); color: rgb(var(--acc));
}
.settings-logs-ico svg { width: 20px; height: 20px; }
.settings-logs-text { display: grid; gap: 3px; overflow-wrap: anywhere; }
.settings-logs-text strong { font-size: 14px; font-weight: 650; line-height: 1.3; }
.settings-logs-text small { color: var(--muted); font-size: 12px; line-height: 1.4; }
.settings-logs-go { width: 18px; height: 18px; color: var(--muted); }
.settings-logs-link:is(:hover, :focus-visible) .settings-logs-go { color: rgb(var(--acc)); }

.logs-intro { margin: 0 0 14px; }

/* ---------------------------------------- discussions entre personas */
.duo-intro { margin: 0 0 14px; }
.duo-setup { display: grid; gap: 14px; }
.duo-setup h2, .duo-sessions h2 { margin: 0; font-size: 16px; }
.duo-slots { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.duo-slot {
    display: flex; align-items: center; gap: 10px; min-width: 0; min-height: 60px;
    padding: 10px 12px; border: 1px dashed var(--border); border-radius: 16px;
    background: transparent; color: var(--text); font: inherit; text-align: left;
}
.duo-slot.is-filled { border-style: solid; border-color: rgba(var(--acc), .45); background: rgba(var(--acc), .08); cursor: pointer; }
.duo-slot:disabled { cursor: default; }
.duo-slot-text { display: grid; gap: 2px; min-width: 0; }
.duo-slot-text small { color: var(--muted); font-size: 11.5px; }
.duo-slot-text strong { font-size: 14px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.duo-avatar {
    --hue: 265;
    position: relative; flex: 0 0 auto; width: 40px; height: 40px; overflow: hidden;
    border-radius: 50%; background: var(--tint); display: grid; place-items: center;
}
.duo-avatar img { width: 100%; height: 100%; object-fit: cover; }
.duo-avatar .avatar-fallback span { font-size: 15px; }
.duo-avatar-empty { color: var(--muted); font-size: 14px; font-weight: 650; }
.duo-list {
    display: grid; gap: 6px; max-height: 320px; overflow-y: auto; margin: 0; padding: 2px;
    list-style: none; overscroll-behavior: contain;
}
.duo-pick {
    display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 8px 12px;
    border: 1px solid var(--border-soft); border-radius: 14px; background: var(--panel);
    color: var(--text); font: inherit; text-align: left; cursor: pointer;
}
.duo-pick:is(:hover, :focus-visible) { border-color: rgba(var(--acc), .4); }
.duo-pick[aria-pressed="true"] { border-color: rgb(var(--acc)); background: rgba(var(--acc), .1); }
.duo-pick-text { display: grid; gap: 2px; flex: 1 1 auto; min-width: 0; }
.duo-pick-text strong { font-size: 14px; font-weight: 600; }
.duo-pick-text small { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.duo-pick-badge {
    display: grid; place-items: center; flex: 0 0 auto; width: 26px; height: 26px; border-radius: 50%;
    background: rgb(var(--acc)); color: var(--on-acc); font-size: 13px; font-weight: 700;
}
.duo-turns { max-width: 200px; }

/* liste des discussions */
.duo-sessions { display: grid; gap: 10px; margin-bottom: 18px; }
.duo-session-list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.duo-session-link {
    display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 10px 12px;
    border: 1px solid var(--border-soft); border-radius: 16px; background: var(--panel); color: var(--text);
}
.duo-session-link:is(:hover, :focus-visible) { border-color: rgba(var(--acc), .4); }
.duo-pair { display: flex; flex: 0 0 auto; }
.duo-pair .duo-avatar { width: 34px; height: 34px; border: 2px solid var(--bg); }
.duo-pair .duo-avatar + .duo-avatar { margin-left: -10px; }
.duo-session-text { display: grid; gap: 2px; flex: 1 1 auto; min-width: 0; }
.duo-session-text strong { font-size: 14px; font-weight: 600; }
.duo-session-text small { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.duo-badge { flex: 0 0 auto; padding: 4px 9px; border-radius: 999px; font-size: 11.5px; background: rgba(var(--ink), .07); color: var(--muted); white-space: nowrap; }
.duo-badge.is-running { background: rgba(52, 211, 153, .14); color: #6ee7b7; }
.duo-badge.is-paused { background: rgba(251, 191, 36, .12); color: #fcd34d; }

/* discussion en direct : barre fixe en haut */
.duo-live { display: grid; gap: 12px; }
.duo-bar {
    position: sticky; top: 64px; z-index: 30; display: grid; gap: 10px;
    margin: 0 -4px; padding: 12px; border: 1px solid var(--border-soft); border-radius: 18px;
    background: rgba(var(--elev-rgb, 12, 12, 20), .92); background: color-mix(in srgb, var(--bg) 90%, transparent);
    backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); box-shadow: var(--shadow);
}
.duo-bar-people { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.duo-who { display: flex; align-items: center; gap: 9px; min-width: 0; }
.duo-who-1 { flex-direction: row-reverse; text-align: right; }
.duo-who-avatar { width: 40px; height: 40px; box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px rgba(var(--ink), .2); transition: box-shadow .3s; }
.duo-who-avatar.has-mood { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--mood, rgba(var(--ink), .2)); }
/* pastille de couleur d'humeur (palette inspirée des Sims) */
.duo-dot {
    display: inline-block; flex: 0 0 auto; width: 9px; height: 9px; border-radius: 50%;
    background: var(--mood, #d4d4d8); box-shadow: 0 0 6px var(--mood, transparent); vertical-align: middle;
}
.duo-who-text { display: grid; gap: 3px; min-width: 0; }
.duo-who-text strong { font-size: 13.5px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.duo-mood {
    display: inline-flex; align-items: center; gap: 6px; justify-self: start; max-width: 100%;
    padding: 2px 9px 2px 7px; border-radius: 999px; font-size: 11.5px; overflow: hidden; white-space: nowrap;
    border: 1px solid color-mix(in srgb, var(--mood, #d4d4d8) 45%, transparent);
    background: color-mix(in srgb, var(--mood, #d4d4d8) 16%, transparent); color: var(--text);
}
.duo-who-1 .duo-mood { justify-self: end; }
.duo-bar-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.duo-status { margin: 0; flex: 1 1 160px; color: var(--muted); font-size: 12.5px; line-height: 1.4; }
.duo-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.duo-actions .btn { min-height: 38px; }
.duo-actions .duo-stop { color: #fda4af; }
.duo-bar-tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.duo-tab {
    display: inline-flex; align-items: center; min-height: 34px; padding: 0 12px; border-radius: 999px;
    border: 1px solid var(--border-soft); background: transparent; color: var(--text); font: inherit; font-size: 12.5px; cursor: pointer;
}
.duo-tab[aria-expanded="true"] { border-color: rgb(var(--acc)); background: rgba(var(--acc), .12); }
.duo-panel {
    display: grid; gap: 12px; overflow-y: auto; overscroll-behavior: contain;
    /* la barre fixe + le panneau doivent rester au-dessus de la barre de navigation du bas */
    max-height: max(180px, calc(100dvh - 420px));
}
.duo-feel { display: grid; gap: 6px; }
.duo-feel-title { margin: 0; font-size: 13px; font-weight: 600; }
.duo-feel-reason { margin: 0; color: var(--muted); font-size: 12px; font-style: italic; }
.duo-gauge { display: grid; grid-template-columns: 64px minmax(0, 1fr) 38px; align-items: center; gap: 8px; font-size: 12px; }
.duo-gauge-label { color: var(--muted); }
.duo-gauge-value { text-align: right; font-variant-numeric: tabular-nums; }
.duo-gauge-track { position: relative; height: 8px; border-radius: 8px; background: rgba(var(--ink), .08); }
/* barres à la Sims : le milieu vaut 0, la barre se remplit vers la droite en positif
   et vers la gauche en négatif ; couleur prise dans la palette des humeurs (--fill) */
.duo-gauge-track { height: 10px; }
.duo-gauge-track::after {
    content: ""; position: absolute; left: 50%; top: -2px; bottom: -2px; width: 2px; margin-left: -1px;
    background: rgba(var(--ink), .35); pointer-events: none; /* le trait du milieu ne doit pas capter le doigt */
}
.duo-gauge-fill {
    position: absolute; top: 0; bottom: 0; left: 50%; width: 0; background: var(--fill, rgba(var(--ink), .3));
    box-shadow: 0 0 8px color-mix(in srgb, var(--fill, transparent) 55%, transparent);
    border-radius: 0 8px 8px 0; transition: width .5s, left .5s, background-color .5s;
}
.duo-gauge.is-negative .duo-gauge-fill { border-radius: 8px 0 0 8px; }
.duo-mj-row { display: flex; flex-wrap: wrap; gap: 8px; }
.duo-scene { margin: 0; font-size: 12.5px; line-height: 1.4; color: rgb(var(--acc-pale)); }
.duo-directions { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.duo-directions:empty { display: none; }
.duo-directions li {
    display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 10px; border-radius: 12px;
    border: 1px dashed rgba(var(--acc), .4); background: rgba(var(--acc), .08); font-size: 12.5px;
}
.duo-directions li span { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.duo-mj-row .input[name="text"] { flex: 1 1 200px; min-width: 0; }
.duo-mj-target { flex: 0 1 150px; min-width: 0; }

/* fil */
.duo-topic { margin: 0; color: var(--muted); font-size: 12.5px; }
.duo-thread { display: grid; gap: 12px; margin: 0; padding: 0 0 24px; list-style: none; }
.duo-line { display: flex; align-items: flex-end; gap: 10px; max-width: 640px; }
.duo-line-1 { flex-direction: row-reverse; margin-left: auto; }
.duo-line .duo-avatar { width: 32px; height: 32px; }
.duo-line-body { display: grid; gap: 4px; min-width: 0; }
.duo-line-1 .duo-line-body { justify-items: end; }
.duo-line-body strong { font-size: 12px; font-weight: 600; color: rgb(var(--acc-soft)); }
.duo-line-1 .duo-line-body strong { color: var(--cyan); }
.duo-line-body p {
    margin: 0; padding: 10px 13px; border-radius: 18px 18px 18px 6px; background: var(--panel-2);
    font-size: 14px; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere;
}
.duo-line-1 .duo-line-body p { border-radius: 18px 18px 6px 18px; }
.duo-typing .bubble { background: var(--panel-2); border-radius: 18px; }
.duo-note {
    justify-self: center; max-width: 92%; padding: 6px 12px; border-radius: 12px; font-size: 12.5px; line-height: 1.45;
    text-align: center; color: var(--muted); background: rgba(var(--ink), .05);
}
.duo-note-direction { color: rgb(var(--acc-pale)); background: rgba(var(--acc), .1); border: 1px dashed rgba(var(--acc), .4); }
.duo-note-event { color: #fcd34d; background: rgba(251, 191, 36, .08); border: 1px dashed rgba(251, 191, 36, .32); }
.duo-note-scene { color: #a5f3fc; background: rgba(34, 211, 238, .08); border: 1px dashed rgba(34, 211, 238, .35); }
.duo-note-mood { display: inline-flex; align-items: center; gap: 7px; border: 1px solid color-mix(in srgb, var(--mood, #d4d4d8) 35%, transparent); }
.duo-note-adjust { color: rgb(var(--acc-pale)); background: rgba(var(--acc), .08); border: 1px solid rgba(var(--acc), .35); }

/* réglage des humeurs : pastilles de la palette (choix) */
.duo-emotions { display: flex; flex-wrap: wrap; gap: 8px; }
.duo-emotion {
    width: 28px; height: 28px; padding: 0; border-radius: 50%; border: 2px solid transparent; cursor: pointer;
    background: var(--mood); box-shadow: inset 0 0 0 2px var(--bg);
}
.duo-emotion[aria-checked="true"] { border-color: var(--mood); box-shadow: inset 0 0 0 3px var(--bg), 0 0 10px var(--mood); }
.duo-emotion:focus-visible { outline: 2px solid rgb(var(--acc)); outline-offset: 2px; }
.duo-feel-mood { font-weight: 600; }

/* curseurs : un point à glisser posé sur la barre (l'input range, transparent, porte le point) */
.duo-slider {
    position: absolute; left: 0; right: 0; top: 50%; width: 100%; height: 28px; margin: 0; transform: translateY(-50%);
    background: transparent; -webkit-appearance: none; appearance: none; cursor: pointer; touch-action: pan-y; z-index: 2;
}
.duo-slider:focus { outline: none; }
.duo-slider::-webkit-slider-runnable-track { height: 28px; background: transparent; }
.duo-slider::-moz-range-track { height: 28px; background: transparent; }
.duo-slider::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none; width: 20px; height: 20px; margin-top: 4px; border-radius: 50%;
    background: #fff; border: 3px solid var(--thumb, var(--fill, rgb(var(--acc)))); box-shadow: 0 2px 8px rgba(0, 0, 0, .45);
}
.duo-slider::-moz-range-thumb {
    width: 14px; height: 14px; border-radius: 50%; background: #fff;
    border: 3px solid var(--thumb, rgb(var(--acc))); box-shadow: 0 2px 8px rgba(0, 0, 0, .45);
}
.duo-slider:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 3px rgba(var(--acc), .5); }
:is(.duo-gauge-intensity, .duo-gauge-anger) .duo-gauge-track::after { display: none; }
:is(.duo-gauge-intensity, .duo-gauge-anger) .duo-gauge-fill { left: 0; border-radius: 8px; }

/* conversation : humeur du persona (en-tête) et ressentis envers l'utilisateur (panneau) */
.chat-mood {
    display: inline-flex; align-items: center; gap: 5px; margin-left: 6px; padding: 1px 8px 1px 6px; border-radius: 999px;
    vertical-align: middle; font-size: 11px; font-weight: 500; white-space: nowrap;
    border: 1px solid color-mix(in srgb, var(--mood, #d4d4d8) 45%, transparent);
    background: color-mix(in srgb, var(--mood, #d4d4d8) 16%, transparent); color: var(--text);
}
.chat-mood .duo-dot { width: 7px; height: 7px; }
.chat-avatar.has-mood { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--mood); transition: box-shadow .3s; }
.feel-box { display: grid; gap: 10px; }
.feel-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.feel-actions .hint { font-size: 12px; }
.duo-gauge.is-off { opacity: .45; }
.duo-gauge.is-off .duo-slider { cursor: not-allowed; }
html[data-mode="light"] .duo-badge.is-running { color: #065f46; }
html[data-mode="light"] .duo-badge.is-paused, html[data-mode="light"] .duo-note-event { color: #92400e; }
html[data-mode="light"] .duo-note-scene { color: #155e75; }
html[data-mode="light"] .duo-actions .duo-stop { color: #be123c; }
@media (prefers-color-scheme: light) {
    html[data-mode="auto"] .duo-badge.is-running { color: #065f46; }
    html[data-mode="auto"] .duo-badge.is-paused, html[data-mode="auto"] .duo-note-event { color: #92400e; }
    html[data-mode="auto"] .duo-note-scene { color: #155e75; }
    html[data-mode="auto"] .duo-actions .duo-stop { color: #be123c; }
}
@media (max-width: 420px) {
    .duo-slots { grid-template-columns: minmax(0, 1fr); }
    .duo-bar { top: 64px; padding: 10px; }
    .duo-gauge { grid-template-columns: 56px minmax(0, 1fr) 34px; }
}
.logs { display: flex; flex-direction: column; gap: 10px; padding-bottom: 40px; }
.log {
    border-radius: 16px;
    border: 1px solid rgba(var(--ink), .09);
    background: rgba(var(--ink), .035);
    overflow: hidden;
}
.log-head {
    list-style: none; cursor: pointer;
    display: grid; grid-template-columns: auto auto 1fr; align-items: center;
    gap: 4px 10px; padding: 12px 14px;
}
.log-head::-webkit-details-marker { display: none; }
.log-dot { width: 9px; height: 9px; border-radius: 50%; background: #34d399; }
.log-error .log-dot { background: #f87171; }
.log-aborted .log-dot { background: #fbbf24; }
.log-purpose {
    font-size: 11.5px; font-weight: 700; letter-spacing: .02em;
    padding: 3px 9px; border-radius: 999px;
    background: rgba(var(--acc), .14); color: rgb(var(--acc));
}
.log-model { font-size: 13px; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log-facts { grid-column: 2 / -1; font-size: 12px; color: var(--muted); }
.log-status { color: #f87171; }
.log-aborted .log-status { color: #fbbf24; }
.log-body { padding: 0 14px 14px; display: flex; flex-direction: column; gap: 12px; }
.log-meta { margin: 0; font-size: 12px; color: var(--muted); line-height: 1.6; word-break: break-word; }
.log-meta code { font-size: 11.5px; }
.log-part h3 { margin: 0 0 8px; font-size: 13px; font-weight: 700; display: flex; align-items: center; gap: 6px; }
.log-out h3 span:first-child { color: #60a5fa; }
.log-in h3 span:first-child { color: #34d399; }
.log-part pre, .log-msg pre {
    margin: 0; padding: 10px 12px; border-radius: 12px;
    background: rgba(var(--ink), .05);
    font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 12px; line-height: 1.6;
    white-space: pre-wrap; word-break: break-word;
    max-height: 420px; overflow: auto;
}
.log-msg { border-left: 3px solid rgba(var(--ink), .18); padding-left: 10px; margin-bottom: 8px; }
.log-msg.role-system { border-left-color: #fbbf24; }
.log-msg.role-user { border-left-color: #60a5fa; }
.log-msg.role-assistant { border-left-color: #c084fc; }
.log-msg > summary {
    list-style: none; cursor: pointer; display: flex; align-items: baseline; gap: 8px;
    padding: 2px 0 6px; font-size: 12px; min-width: 0;
}
.log-msg > summary::-webkit-details-marker { display: none; }
.log-role { font-weight: 700; }
.log-len { color: var(--muted); flex: 0 0 auto; }
.log-peek { color: var(--muted); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log-msg[open] .log-peek { display: none; }
.log-in .log-reply { border-left: 3px solid #34d399; }
.log-error { color: #fca5a5; background: rgba(248, 113, 113, .1) !important; }
html[data-mode="light"] .log-error { color: #b91c1c; }
.log-tools { display: flex; justify-content: flex-end; }
.prompt-editor .pe-body, .prompt-editor .pe-body:focus { background: transparent; box-shadow: none; border: 0; }

/* ======================================================================
   Assistant de création de persona (/p/assist, /p/{slug}/assist)
   ====================================================================== */
.page-assist { max-width: 760px; }
.as { display: flex; flex-direction: column; gap: 10px; height: calc(100dvh - 150px); min-height: 480px; }
/* mobile (tant que la barre du bas existerait) : plein écran, sans en-tête ni barre du bas
   (la barre du bas n'est pas rendue ; la règle reste au cas où, plus forte que html[data-tabbar] .tabbar) */
@media (max-width: 899px) {
    body.assist-room .topbar, html body.assist-room .tabbar { display: none !important; }
    .page.page-assist { padding: 0; max-width: none; }
    .as { height: var(--app-h, 100dvh); min-height: 0; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); }
}
.as-head { display: flex; align-items: center; gap: 8px; }
.as-hbtn {
    flex: 0 0 auto; width: 40px; height: 40px; border-radius: 50%; border: 0; cursor: pointer; display: grid; place-items: center;
    background: rgba(var(--ink), .07); color: var(--text);
}
.as-hbtn svg { width: 19px; height: 19px; }
.as-title { flex: 1; min-width: 0; margin: 0; font-size: 17px; font-weight: 750; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.as-create {
    flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 14px 0 11px; border: 0; border-radius: 999px; cursor: pointer;
    color: #fff; font: inherit; font-size: 14px; font-weight: 700; background: linear-gradient(135deg, #a78bfa, #e879f9 60%, #f472b6);
}
.as-create svg { width: 18px; height: 18px; }
.as-create:disabled, .as-hbtn:disabled { opacity: .5; }
.as-empty { padding: 30px 10px; text-align: center; display: grid; gap: 14px; justify-items: center; color: var(--muted); }

/* fiche en cours */
.as-fiche { border-radius: 18px; background: rgba(var(--ink), .05); border: 1px solid rgba(var(--ink), .08); }
.as-fiche > summary {
    list-style: none; cursor: pointer; display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; padding: 12px 14px;
}
.as-fiche > summary::-webkit-details-marker { display: none; }
.as-fiche-name { font-size: 14px; font-weight: 700; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.as-fiche-pct { font-size: 13px; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.as-fiche-pct::after { content: " ▾"; font-size: 11px; }
.as-fiche[open] .as-fiche-pct::after { content: " ▴"; }
.as-bar { grid-column: 1 / -1; height: 6px; border-radius: 9px; background: rgba(var(--ink), .09); overflow: hidden; }
.as-bar i { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, #a78bfa, #f472b6); transition: width .5s ease; }
/* étapes : toujours visibles, la prochaine en surbrillance */
.as-steps {
    grid-column: 1 / -1; list-style: none; margin: 2px -14px 0; padding: 0 14px; display: flex; gap: 6px;
    overflow-x: auto; scrollbar-width: none; scroll-behavior: smooth;
}
.as-steps::-webkit-scrollbar { display: none; }
.as-steps li {
    flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px 0 4px; border-radius: 999px;
    font-size: 12.5px; color: var(--muted-2); white-space: nowrap; background: rgba(var(--ink), .04);
}
.as-step-dot {
    width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 700;
    background: rgba(var(--ink), .08); color: var(--muted);
}
.as-steps li.is-done { color: var(--text); }
.as-steps li.is-done .as-step-dot { background: rgba(52, 211, 153, .18); color: #34d399; }
.as-steps li.is-now { color: var(--text); font-weight: 650; background: rgba(232, 121, 249, .12); box-shadow: inset 0 0 0 1px rgba(232, 121, 249, .45); }
.as-steps li.is-now .as-step-dot { background: linear-gradient(135deg, #a78bfa, #f472b6); color: #fff; }
.as-steps li.is-auto .as-step-dot { color: #e879f9; }

/* aperçu de la fiche (dépliée) */
.as-preview { max-height: 46dvh; overflow-y: auto; overscroll-behavior: contain; padding: 4px 14px 2px; border-top: 1px solid rgba(var(--ink), .07); }
.as-preview-title { margin: 8px 0 6px; font-size: 11.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted-2); }
.as-preview-list { margin: 0; display: grid; gap: 2px; }
.as-preview-list dt { margin-top: 8px; font-size: 12px; font-weight: 700; color: var(--muted); }
.as-preview-list dd { margin: 0; font-size: 13.5px; line-height: 1.45; white-space: pre-wrap; word-break: break-word; }
.as-preview-list dd.as-preview-empty { color: var(--muted); font-style: italic; }
.as-src { color: rgb(var(--acc-soft, var(--acc))); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.as-msg.is-assistant.is-source { background: transparent; border: 1px solid rgba(52, 211, 153, .35); color: var(--muted); font-size: 13.5px; }
.as-fiche-note { margin: 10px 0 12px; font-size: 12px; color: var(--muted-2); }

/* conversation : la seule zone qui défile */
.as-thread { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 4px 2px 8px; overscroll-behavior: contain; }
.as-msg { max-width: 86%; padding: 11px 14px; border-radius: 18px; font-size: 15px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.as-msg.is-assistant { align-self: flex-start; background: rgba(var(--ink), .07); border-bottom-left-radius: 6px; }
.as-msg.is-assistant.is-note { background: transparent; border: 1px dashed rgba(232, 121, 249, .45); color: var(--muted); font-size: 14px; }
.as-msg.is-user { align-self: flex-end; color: #fff; background: linear-gradient(135deg, #7c3aed, #c026d3); border-bottom-right-radius: 6px; }
.as-msg.is-user.is-suggest { background: rgba(232, 121, 249, .16); color: #f0abfc; font-weight: 600; }
html[data-mode="light"] .as-msg.is-user.is-suggest { color: #a21caf; }
/* indicateur « l'IA réfléchit » : les mêmes trois points que dans une discussion (.typing .bubble) */
.as-msg.as-typing { padding: 0; }
.as-typing .bubble { background: transparent; border: 0; }

/* réponses rapides + saisie */
.as-bottom { display: flex; flex-direction: column; gap: 8px; }
.as-chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: 0 -12px; padding: 0 12px; }
.as-chips::-webkit-scrollbar { display: none; }
.as-chip {
    flex: 0 0 auto; height: 38px; padding: 0 14px; border-radius: 999px; cursor: pointer; white-space: nowrap;
    border: 1px solid rgba(var(--ink), .16); background: transparent; color: var(--text); font: inherit; font-size: 13.5px; font-weight: 600;
}
.as-chip.is-suggest { border-color: rgba(232, 121, 249, .5); background: rgba(232, 121, 249, .12); color: #f0abfc; font-weight: 700; }
.as-chip.is-suggest::before { content: "✦ "; }
html[data-mode="light"] .as-chip.is-suggest { color: #a21caf; }
.as-chip.is-now { border-style: dashed; }
.as-chip:disabled { opacity: .45; }
.as-compose {
    display: flex; align-items: flex-end; gap: 8px; padding: 5px 5px 5px 16px; border-radius: 26px;
    background: rgba(var(--ink), .06); border: 1px solid rgba(232, 121, 249, .4);
}
.as-compose:focus-within { border-color: rgba(232, 121, 249, .75); box-shadow: 0 0 0 4px rgba(232, 121, 249, .12); }
.as-input { flex: 1; min-width: 0; min-height: 42px; max-height: 140px; padding: 10px 0; border: 0; resize: none; background: transparent; color: var(--text); font: inherit; font-size: 15.5px; line-height: 1.4; }
.as-input:focus { outline: none; }
.as-send {
    flex: 0 0 auto; width: 42px; height: 42px; border-radius: 50%; border: 0; cursor: pointer; color: #fff; display: grid; place-items: center;
    background: linear-gradient(135deg, #a78bfa, #e879f9 60%, #f472b6);
}
.as-send svg { width: 18px; height: 18px; }
.as-send:disabled { opacity: .5; }

/* rédaction finale */
.as-final { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 24px; background: rgba(4, 4, 9, .7); backdrop-filter: blur(6px); }
.as-final[hidden] { display: none; }
.as-final-card { max-width: 340px; text-align: center; display: grid; gap: 10px; justify-items: center; padding: 26px 22px; border-radius: 24px; background: var(--elev, #0e0e18); border: 1px solid rgba(232, 121, 249, .35); }
.as-final-card p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.5; }
.as-final-ico { width: 56px; height: 56px; border-radius: 18px; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, #a78bfa, #e879f9 60%, #f472b6); animation: as-pulse 1.6s ease-in-out infinite; }
.as-final-ico svg { width: 28px; height: 28px; }
@keyframes as-pulse { 50% { transform: scale(1.08); box-shadow: 0 0 0 10px rgba(232, 121, 249, .12); } }
.as-final-dots { display: flex; gap: 6px; padding: 4px 0 2px; }
.as-final-dots i { width: 8px; height: 8px; border-radius: 50%; background: rgba(var(--ink), .82); animation: dot-hop 1.16s cubic-bezier(.34, .72, .38, 1) infinite; }
.as-final-dots i:nth-child(2) { animation-delay: .13s; }
.as-final-dots i:nth-child(3) { animation-delay: .26s; }
@media (prefers-reduced-motion: reduce) { .as-final-ico { animation: none; } }

.as-review {
    width: min(680px, calc(100% - 24px));
    max-height: calc(var(--app-h, 100dvh) - 24px);
    padding: 0;
    overflow: hidden;
    border: 1px solid rgba(var(--ink), .16);
    border-radius: 18px;
    background: var(--elev, #0e0e18);
    color: var(--text);
}
.as-review::backdrop { background: rgba(4, 4, 9, .7); }
.kb-open .as-review { inset-block: 12px auto; margin-block: 0; }
.as-review-form { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; max-height: calc(var(--app-h, 100dvh) - 26px); }
.as-review-form header, .as-review-form footer { padding: 12px 16px; background: var(--elev, #0e0e18); }
.as-review-form h2 { margin: 0; font-size: 18px; }
.as-review-form h2:focus { outline: none; }
.as-review-form header p { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.as-review-scroll { min-height: 0; overflow: auto; overscroll-behavior: contain; border-block: 1px solid rgba(var(--ink), .12); }
.as-review-fields {
    display: grid;
    gap: 12px;
    min-width: 0;
    margin: 0;
    padding: 14px 18px;
    border: 0;
}
.as-review-field { display: grid; gap: 5px; font-size: 13px; font-weight: 600; }
.as-review-field .input { width: 100%; font-weight: 400; }
.as-review-actions { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; }
.as-review-actions .btn { min-height: 44px; }
@media (max-width: 600px) {
    .as-review-actions .btn-ghost { flex: 1 1 10rem; }
    .as-review-field textarea.input { field-sizing: content; min-height: 5.5em; resize: none; }
}
.as-review-error { color: var(--danger); margin: 0 0 10px; font-size: 13px; }

/* entrée « Créer avec l'IA » sur la page de création : une ligne discrète, au second plan */
.assist-link {
    display: flex; align-items: center; gap: 10px; margin: -4px 0 16px; padding: 10px 12px; border-radius: 12px;
    text-decoration: none; color: var(--text); border: 1px solid var(--border-soft, rgba(255, 255, 255, .08)); background: transparent;
    transition: border-color .18s, background .18s;
}
.assist-link:hover, .assist-link:focus-visible { border-color: rgba(var(--acc), .45); background: rgba(var(--acc), .05); }
.assist-link-ico { width: 18px; height: 18px; flex: 0 0 auto; color: rgb(var(--acc-soft, var(--acc))); }
.assist-link-text { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 8px; }
.assist-link-text strong { flex: 0 0 auto; font-size: 14px; font-weight: 650; }
.assist-link-text small { min-width: 0; font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.assist-link-go { width: 16px; height: 16px; flex: 0 0 auto; color: var(--muted-2); }

/* éditeur de prompt : aperçu d'un planning (jour, heure → activité) */
.pe-plan { margin: 8px 0 0; padding: 10px 12px; border: 1px solid var(--border-soft); border-radius: 14px; background: rgba(var(--ink), .03); }
.pe-plan[hidden] { display: none; }
.pe-plan-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.pe-plan-label { font-size: 12.5px; color: var(--muted); }
.pe-plan-day { width: auto; min-width: 0; flex: 1 1 110px; }
.pe-plan-time { width: auto; flex: 0 1 110px; }
.pe-plan-out { margin: 8px 0 0; font-size: 14px; line-height: 1.45; }
.pe-plan-out small { color: var(--muted); }
.pe-plan-next { display: block; font-size: 12.5px; color: var(--muted); }
.pe-plan-errors { margin: 6px 0 0; padding: 0; list-style: none; font-size: 12.5px; color: var(--warn-t, #fcd34d); }
.pe-plan-errors li + li { margin-top: 2px; }
.pe-plan-help { margin: 8px 0 0; }
