/* Chat — messages, accueil, composeur */
/* ============================================================== accueil */

.welcome {
    max-width: 780px; margin: 0 auto;
    padding: clamp(2rem, 7vh, 5rem) 1.4rem 2rem;
    text-align: center;
    animation: riseIn .5s ease both;
}
.orb {
    width: 78px; height: 78px; margin: 0 auto 1.4rem;
    border-radius: 24px;
    display: grid; place-items: center;
    box-shadow: 0 22px 50px -18px rgba(139, 92, 246, .9);
    animation: float 5s ease-in-out infinite;
    position: relative;
}
.orb::after {
    content: "";
    position: absolute; inset: -14px;
    border-radius: 32px;
    background: radial-gradient(circle, rgba(255, 77, 109, .28), transparent 70%);
    animation: glow 3.4s ease-in-out infinite;
    z-index: -1;
}
.welcome h1 {
    font-size: clamp(1.6rem, 3.6vw, 2.15rem); margin: 0 0 .6rem;
    letter-spacing: -.025em;
    position: relative;
}
.welcome h1::after {
    /* Idéogramme en fond, comme un tampon d'encre à peine visible sur la planche. */
    content: "漫画";
    position: absolute;
    left: 50%; top: 50%;
    transform: translate(-50%, -50%);
    font-size: 4.6em;
    letter-spacing: .1em;
    color: var(--grain);
    z-index: -1;
    pointer-events: none;
    white-space: nowrap;
}
.welcome p { color: var(--muted); max-width: 52ch; margin: 0 auto 2.2rem; font-size: .96rem; }

.suggestions { display: grid; grid-template-columns: repeat(2, 1fr); gap: .7rem; text-align: left; }
.suggestion {
    display: flex; align-items: flex-start; gap: .7rem;
    padding: .85rem .95rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    text-align: left;
    transition: transform .16s ease, border-color .16s ease, background .16s ease;
    animation: riseIn .45s ease both;
}
.suggestion:nth-child(2) { animation-delay: .06s; }
.suggestion:nth-child(3) { animation-delay: .12s; }
.suggestion:nth-child(4) { animation-delay: .18s; }
.suggestion { position: relative; overflow: hidden; }
.suggestion::before {
    /* Traits de vitesse : ils ne se révèlent qu'au survol, sur le bord gauche. */
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 34px;
    opacity: 0;
    transition: opacity .2s ease, transform .2s ease;
    transform: translateX(-8px);
    background: repeating-linear-gradient(
        to bottom,
        var(--grain) 0 1px,
        transparent 1px 5px);
    -webkit-mask-image: linear-gradient(to right, #000, transparent);
    mask-image: linear-gradient(to right, #000, transparent);
    pointer-events: none;
}
.suggestion:hover { transform: translateY(-3px); border-color: var(--border-strong); background: var(--surface-2); }
.suggestion:hover::before { opacity: 1; transform: translateX(0); }
.suggestion .ico { font-size: 1.1rem; line-height: 1.3; }
.suggestion .txt { display: flex; flex-direction: column; gap: .1rem; min-width: 0; }
.suggestion .t { font-weight: 650; font-size: .89rem; }
.suggestion .s { font-size: .8rem; color: var(--faint); }

/* ============================================================= messages */

.msg { display: flex; gap: .9rem; animation: riseIn .4s ease both; }
.msg.user { justify-content: flex-end; }

.msg.user .bubble {
    max-width: 78%;
    background: linear-gradient(135deg, rgba(255, 77, 109, .16), rgba(139, 92, 246, .18));
    border: 1px solid var(--border-strong);
    padding: .7rem 1rem;
    /* Coin inférieur droit rentré : la pointe d'une bulle de dialogue. */
    border-radius: 18px 18px 5px 18px;
    white-space: pre-wrap;
    word-break: break-word;
}

.msg.bot .avatar {
    flex: 0 0 32px;
    width: 32px; height: 32px;
    border-radius: 10px;
    display: grid; place-items: center;
    box-shadow: 0 6px 16px -8px rgba(139, 92, 246, .9);
    position: relative;
}
.msg.bot .avatar::after {
    /* Trait d'encre sous l'avatar : le fil de la conversation. */
    content: "";
    position: absolute;
    top: calc(100% + 6px); bottom: auto;
    left: 50%; width: 1px; height: 14px;
    transform: translateX(-50%);
    background: linear-gradient(180deg, var(--border), transparent);
}
.msg.bot .content { min-width: 0; flex: 1; }

/* rendu markdown — chaque bloc est un paragraphe figé, seul le dernier s'écrit encore */
/* Un lien nu ou un titre japonais translittéré sans espace ne se coupe pas : sur un
   téléphone, une seule adresse élargissait toute la colonne de réponse. */
.markdown { overflow-wrap: break-word; }
.markdown .blk > *:first-child { margin-top: 0; }
.markdown .blk:last-child > *:last-child { margin-bottom: 0; }
.markdown p { margin: 0 0 .85rem; }
.markdown h2, .markdown h3, .markdown h4 {
    font-size: 1rem; margin: 1.3rem 0 .6rem; letter-spacing: -.01em;
    color: var(--text); font-weight: 650;
}
.markdown h2 { font-size: 1.12rem; }
.markdown h4 { font-size: .95rem; color: var(--muted); }
.markdown h2::before, .markdown h3::before {
    content: "";
    display: inline-block; width: 3px; height: .95em;
    background: linear-gradient(180deg, var(--accent), var(--accent-2));
    border-radius: 2px; margin-right: .5rem; vertical-align: -2px;
}
.markdown ul, .markdown ol {
    margin: 0 0 .9rem; padding-left: 1.25rem;
    list-style-position: outside;
}
.markdown li { margin-bottom: .42rem; line-height: 1.45; }
.markdown li::marker { color: var(--accent-2); }
.markdown strong { color: var(--ink); font-weight: 650; }
.markdown em { color: var(--muted); }
.markdown del { color: var(--faint); text-decoration: line-through; }
.markdown code {
    font-family: var(--mono); font-size: .85em;
    background: var(--surface-2); border: 1px solid var(--border);
    padding: .08rem .35rem; border-radius: 6px;
}
.markdown pre {
    margin: 0 0 .9rem;
    padding: .75rem .9rem;
    overflow-x: auto;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
}
.markdown pre code {
    background: none; border: none; padding: 0;
    font-size: .82em; color: var(--text);
}
.markdown blockquote {
    margin: 0 0 .9rem;
    padding: .15rem 0 .15rem .9rem;
    border-left: 3px solid color-mix(in srgb, var(--accent) 55%, var(--border));
    color: var(--muted);
}
.markdown blockquote p { margin: 0 0 .4rem; }
.markdown blockquote p:last-child { margin-bottom: 0; }
.markdown hr { border: none; border-top: 1px solid var(--border); margin: 1.2rem 0; }

/* liens, renvois de sources et couvertures */
.markdown a {
    color: var(--accent-2); text-decoration: none;
    border-bottom: 1px solid color-mix(in srgb, var(--accent-2) 35%, transparent);
    transition: color .15s ease, border-color .15s ease;
}
.markdown a:hover { color: var(--link-hover); border-bottom-color: var(--accent); }
.markdown sup.cite {
    display: inline-block;
    min-width: 1.05em; height: 1.05em; line-height: 1.05em;
    margin: 0 .1em; padding: 0 .2em;
    font-size: .58rem; font-weight: 700; text-align: center;
    color: var(--muted);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 999px;
    vertical-align: super;
}

/* Sources : badges discrets, alignés sur le design (plus de pavé « note de bas de page »). */
.markdown .blk.sources-blk,
.markdown .blk:has(> .source-badges) {
    margin-top: .55rem;
    padding: 0;
    border: none;
    background: none;
    font-size: inherit;
}
.source-badges {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .35rem;
}
.source-badges-label {
    font-size: .68rem;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--faint);
    margin-right: .15rem;
}
.source-badge {
    display: inline-flex;
    align-items: center;
    gap: .28rem;
    max-width: 100%;
    padding: .18rem .5rem .18rem .28rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--muted);
    text-decoration: none;
    font-size: .72rem;
    line-height: 1.2;
    transition: border-color .14s ease, color .14s ease, background .14s ease;
}
.source-badge .n {
    display: inline-grid;
    place-items: center;
    min-width: 1.15em;
    height: 1.15em;
    padding: 0 .15em;
    border-radius: 999px;
    background: color-mix(in srgb, var(--accent) 16%, transparent);
    color: var(--accent);
    font-size: .62rem;
    font-weight: 700;
}
.source-badge .t {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 160px;
}
.source-badge:hover {
    color: var(--text);
    border-color: var(--border-strong);
    background: var(--surface);
}

.markdown img.cover {
    max-width: 168px; width: 100%;
    border-radius: 10px;
    border: 1px solid var(--border);
    /* Cadre de planche : un léger décalage d'ombre, comme une case posée sur la page. */
    box-shadow: 5px 5px 0 -1px var(--shadow), 0 0 0 1px var(--grain);
    margin: .2rem .6rem .4rem 0;
    animation: riseIn .45s ease both;
}
.markdown img.md-icon {
    display: inline-block;
    height: 1.2em;
    width: auto;
    max-width: 2.4em;
    margin: 0 .2em;
    vertical-align: -0.22em;
    border: 0;
    border-radius: 4px;
    box-shadow: none;
    background: transparent;
}

/* ============================================================== médias */

.media-set { display: flex; flex-direction: column; gap: .9rem; margin: .9rem 0 .2rem; }

.media {
    animation: riseIn .4s ease both;
    border-top: 1px solid var(--border-soft);
    padding-top: .7rem;
}
.media > header {
    display: flex; align-items: center; gap: .45rem;
    margin-bottom: .5rem;
}
.media .src-badge {
    display: inline-flex;
    align-items: center;
    max-width: 100%;
    padding: .18rem .55rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    font-size: .68rem;
    font-weight: 600;
    color: var(--muted);
    letter-spacing: .01em;
}
.media .src-badge a {
    color: inherit;
    text-decoration: none;
    border: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 280px;
}
.media .src-badge a:hover { color: var(--link-hover); }
.media .what { color: var(--muted); font-weight: 600; }
.media .from { color: var(--faint); font-size: .7rem; letter-spacing: .02em; text-transform: none; }
.media .from::before { content: "via "; }
.media .from a { color: var(--faint); text-decoration: none; border-bottom: 1px dotted var(--border); }
.media .from a:hover { color: var(--link-hover); }

/* Rail défilant : la molette horizontale, les flèches, ou le doigt sur mobile. */
.rail { position: relative; }
.rail .track {
    display: flex; gap: .55rem;
    overflow-x: auto; overflow-y: hidden;
    scroll-snap-type: x proximity;
    padding: 2px 2px 8px;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}
.rail .track::-webkit-scrollbar { height: 6px; }
.rail .track::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
.rail .track > * { scroll-snap-align: start; flex: 0 0 auto; }

.rail .slide {
    position: absolute; top: calc(50% - 30px); z-index: 3;
    width: 30px; height: 44px;
    display: none; align-items: center; justify-content: center;
    font-size: 1.3rem; line-height: 1;
    color: var(--text);
    background: linear-gradient(180deg, rgba(12, 12, 18, .92), rgba(12, 12, 18, .78));
    border: 1px solid var(--border); border-radius: 10px;
    backdrop-filter: blur(6px);
    transition: opacity .15s ease, background .15s ease;
}
.rail.scrollable .slide { display: flex; }
.rail .slide:hover { background: var(--surface-2); }
.rail .slide:disabled { opacity: 0; pointer-events: none; }
.rail .slide.left { left: -6px; }
.rail .slide.right { right: -6px; }

/* galerie d'images */
.media.images .shot {
    position: relative;
    height: 178px; width: calc(178px * var(--ratio, .74));
    max-width: 320px; min-width: 92px;
    padding: 0; overflow: hidden;
    background: var(--surface-2);
    border: 1px solid var(--border); border-radius: 12px;
    cursor: zoom-in;
    transition: transform .18s ease, border-color .18s ease;
}
.media.images .shot:hover { transform: translateY(-2px); border-color: var(--accent); }
.media.images .shot img { width: 100%; height: 100%; object-fit: cover; display: block; }
.media.images .shot .cap {
    position: absolute; inset: auto 0 0 0;
    padding: .55rem .5rem .35rem;
    font-size: .68rem; line-height: 1.25; text-align: left; color: #f4f4fa;
    background: linear-gradient(180deg, transparent, rgba(6, 6, 10, .88));
    opacity: 0; transition: opacity .18s ease;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.media.images .shot:hover .cap { opacity: 1; }

/* vignettes vidéo */
.media.videos .clip { width: 276px; }
.media.videos .play {
    position: relative; display: block; width: 100%; aspect-ratio: 16 / 9;
    padding: 0; overflow: hidden;
    border: 1px solid var(--border); border-radius: 12px;
    background: var(--surface-2); cursor: pointer;
    transition: border-color .18s ease;
}
.media.videos .play:hover { border-color: var(--accent); }
.media.videos .play img { width: 100%; height: 100%; object-fit: cover; display: block; }
.media.videos .badge {
    position: absolute; inset: 0; margin: auto;
    width: 46px; height: 46px;
    display: grid; place-items: center;
    font-size: .95rem; color: #fff;
    background: rgba(10, 10, 14, .62); border: 1px solid rgba(255, 255, 255, .3);
    border-radius: 50%;
    transition: transform .18s ease, background .18s ease;
}
.media.videos .play:hover .badge { transform: scale(1.08); background: var(--accent); border-color: transparent; }
.media.videos iframe {
    width: 100%; aspect-ratio: 16 / 9; display: block;
    border: 1px solid var(--border); border-radius: 12px; background: #000;
}
.media.videos .name {
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
    margin-top: .4rem;
    font-size: .78rem; line-height: 1.3; color: var(--muted); text-decoration: none;
}
.media.videos .name:hover { color: var(--text); }
/* La chaîne, sous le titre : elle dit si l'extrait vient de l'éditeur ou d'un remontage. */
.media.videos .by {
    display: block; margin-top: .15rem;
    font-size: .72rem; color: var(--faint);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.media.videos .runtime {
    position: absolute; right: .4rem; bottom: .4rem;
    padding: .05rem .3rem;
    font-size: .68rem; font-variant-numeric: tabular-nums; color: #fff;
    background: rgba(10, 10, 14, .78); border-radius: 4px;
}

/* extraits musicaux */
.tracklist { display: flex; flex-direction: column; gap: .4rem; }
.track-row {
    display: grid; grid-template-columns: 44px minmax(0, 1fr) minmax(150px, 232px);
    align-items: center; gap: .7rem;
    padding: .4rem .55rem;
    background: var(--surface-2);
    border: 1px solid var(--border-soft); border-radius: 12px;
    transition: border-color .18s ease;
}
.track-row:hover { border-color: var(--border); }
.track-row .sleeve { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; background: var(--surface); }
.track-row .meta { min-width: 0; display: flex; flex-direction: column; gap: .1rem; }
.track-row .name {
    font-size: .84rem; color: var(--text); text-decoration: none;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.track-row .name:hover { color: var(--link-hover); }
.track-row .by { font-size: .74rem; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.track-row audio { width: 100%; height: 34px; }

/* image en grand */
.viewer {
    position: fixed; inset: 0; z-index: 60;
    display: none; align-items: center; justify-content: center;
    gap: .4rem; padding: clamp(.8rem, 4vw, 3rem);
    background: rgba(6, 6, 10, .86); backdrop-filter: blur(10px);
}
.viewer.open { display: flex; animation: fadeIn .16s ease both; }
.viewer figure { margin: 0; display: flex; flex-direction: column; align-items: center; gap: .6rem; min-width: 0; }
.viewer img {
    max-width: min(90vw, 1100px); max-height: 82vh;
    object-fit: contain;
    border-radius: 12px; border: 1px solid var(--border);
    box-shadow: 0 24px 60px var(--shadow);
}
.viewer figcaption { font-size: .8rem; color: var(--muted); text-align: center; max-width: 60ch; }
.viewer .close { position: absolute; top: 1rem; right: 1.1rem; }
.viewer .close, .viewer .nav {
    width: 40px; height: 40px; flex: 0 0 auto;
    display: grid; place-items: center;
    font-size: 1.4rem; color: var(--text);
    background: rgba(20, 20, 28, .8); border: 1px solid var(--border); border-radius: 10px;
    transition: background .15s ease, transform .15s ease;
}
.viewer .close:hover, .viewer .nav:hover { background: var(--surface-2); transform: scale(1.05); }

/* curseur de frappe */
.caret {
    display: inline-block;
    width: 7px; height: 1.05em;
    background: var(--accent);
    border-radius: 1px;
    margin-left: 2px;
    vertical-align: -2px;
    animation: blink 1s steps(2, start) infinite;
}

/* Indicateur de réflexion. Les points viennent **après** la phrase, et s'écrivent l'un après
   l'autre : c'est ce que fait quelqu'un qui tape, et c'est ce qu'on lit sans y penser. Des
   points qui rebondissent devant le texte disaient « chargement en cours », ce qui n'est pas
   la même promesse. */
.thinking { display: flex; align-items: baseline; gap: .1rem; color: var(--faint); font-size: .88rem; }
.thinking .ellipsis { display: inline-flex; letter-spacing: .08em; }
.thinking .ellipsis i {
    font-style: normal;
    opacity: 0;
    animation: inkDot 1.5s infinite ease-in-out;
}
.thinking .ellipsis i:nth-child(2) { animation-delay: .22s; }
.thinking .ellipsis i:nth-child(3) { animation-delay: .44s; }
.thinking .label {
    /* La lueur qui balaie le texte prend la couleur de l'encre du thème : un blanc en dur
       disparaissait sur fond clair, et la phrase s'effaçait par le milieu à chaque passage. */
    background: linear-gradient(90deg, var(--faint), var(--text), var(--faint));
    background-size: 220% 100%;
    -webkit-background-clip: text; background-clip: text; color: transparent;
    animation: shimmer 2s linear infinite;
    /* Le libellé change quand le serveur annonce une consultation de sources. */
    transition: opacity .16s ease;
}

/* actions sous les réponses */
.actions { display: flex; gap: .3rem; margin-top: .7rem; opacity: 0; transition: opacity .18s ease; }
.msg.bot:hover .actions, .actions.visible { opacity: 1; }
.action {
    display: inline-flex; align-items: center; gap: .3rem;
    font-size: .76rem; color: var(--faint);
    background: transparent; border: 1px solid transparent;
    padding: .25rem .5rem; border-radius: 8px;
    transition: background .15s ease, color .15s ease;
}
.action:hover { background: var(--surface-2); color: var(--text); }

/* =========================================================== composeur

   Le composeur, le bouton d'envoi et la pastille « aller en bas » sont partis dans
   shell.css : la Question du jour les affiche aussi, sans charger cette feuille — ils
   apparaissaient donc là-bas sans aucun style (champ blanc, bouton gris du navigateur).
   Ne restent ici que les pièces jointes, propres au chat. */

.attach-btn {
    flex: 0 0 36px;
    width: 36px; height: 36px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--muted);
    display: grid; place-items: center;
    transition: color .14s ease, border-color .14s ease, transform .14s ease;
}
.attach-btn:hover {
    color: var(--accent);
    border-color: var(--border-strong);
    transform: scale(1.05);
}

.attach-preview {
    max-width: 780px;
    margin: 0 auto .55rem;
    display: flex;
    flex-wrap: wrap;
    gap: .45rem;
}
.attach-chip {
    display: flex;
    align-items: center;
    gap: .45rem;
    max-width: 100%;
    padding: .35rem .45rem .35rem .4rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    font-size: .78rem;
    color: var(--text);
}
.attach-chip .thumb {
    width: 28px; height: 28px;
    border-radius: 8px;
    object-fit: cover;
    background: var(--surface-2);
    flex: 0 0 auto;
}
.attach-chip .meta {
    min-width: 0;
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}
.attach-chip .meta strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 160px;
    font-weight: 600;
}
.attach-chip .meta span { color: var(--faint); font-size: .7rem; }
.attach-chip .drop {
    border: none; background: transparent;
    color: var(--faint); cursor: pointer;
    width: 22px; height: 22px;
    border-radius: 50%;
    font-size: .9rem;
}
.attach-chip .drop:hover { color: var(--accent); background: var(--surface-2); }

.msg-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: .45rem;
    margin-top: .55rem;
}
.msg-file {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .4rem .55rem;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    text-decoration: none;
    color: var(--text);
    font-size: .82rem;
    max-width: 100%;
}
.msg-file:hover { border-color: var(--border-strong); color: var(--link-hover, var(--accent)); }
.msg-file img, .msg-file video {
    width: 42px; height: 42px;
    border-radius: 8px;
    object-fit: cover;
    background: var(--surface);
}
.msg-file .dl {
    margin-left: .15rem;
    opacity: .7;
    font-size: .75rem;
}

.media .shot, .media .clip { position: relative; }
.media-dl {
    position: absolute;
    top: .35rem; right: .35rem;
    z-index: 2;
    width: 28px; height: 28px;
    border-radius: 50%;
    border: none;
    background: rgba(0,0,0,.55);
    color: #fff;
    font-size: .75rem;
    display: grid; place-items: center;
    cursor: pointer;
}
.media-dl:hover { background: rgba(0,0,0,.75); }
.viewer .dl-full {
    position: absolute;
    bottom: 1.2rem; right: 1.2rem;
    z-index: 3;
    padding: .45rem .75rem;
    border-radius: 999px;
    border: none;
    background: rgba(0,0,0,.65);
    color: #fff;
    font: inherit;
    font-size: .82rem;
    cursor: pointer;
}


.seo-crawl {
    max-width: 780px;
    margin: 0 auto;
    padding: .75rem 1.4rem 1.5rem;
    font-size: .78rem;
    line-height: 1.45;
    color: var(--faint);
    text-align: center;
}
.seo-crawl h2 {
    margin: 0 0 .35rem;
    font-size: .82rem;
    font-weight: 650;
    color: var(--muted);
}
.seo-crawl p { margin: 0; }
.seo-crawl a { color: var(--accent-3); }
.chat:not(.is-empty) .seo-crawl { display: none; }

/* ========================================================== responsive

   Ces règles vivaient dans shell.css, chargé *avant* cette feuille : la mise en page de
   bureau écrite ici les écrasait toutes, et le téléphone recevait en réalité l'interface du
   bureau. Elles sont donc revenues à côté de ce qu'elles corrigent. */

/* Au doigt, rien ne se « survole » : les actions sous une réponse et les légendes d'images
   doivent rester lisibles en permanence. */
@media (hover: none) {
    .actions, .msg.user .action.edit { opacity: 1; }
    .media.images .shot .cap { opacity: 1; }
    /* Le doigt fait défiler mieux que deux flèches de 30 pixels. */
    .rail.scrollable .slide { display: none; }
    .rail .track { scroll-snap-type: x proximity; }
    /* Bascule Chat / Théorie : 30 px de haut, c'est un bouton qu'on rate une fois sur trois. */
    .mode-opt { min-height: 40px; }
    .attach-btn, .msg-file, .media-dl { min-height: 40px; }
    .media-dl { width: 40px; }
}

@media (max-width: 820px) {
    .msg.user .bubble { max-width: 88%; }
    .msg { gap: .65rem; }
    /* Le bouton de reprise reste au même endroit qu'au bureau, en plus discret. */
    .msg.user .action.edit { font-size: .72rem; padding: .25rem .4rem; }

    /* L'accueil garde sa grille 2 × 2 : c'est elle qui fait reconnaître la page. Elle tient
       si les cartes passent en colonne et si les descriptions s'arrêtent à deux lignes. */
    .welcome { padding: 1.25rem 1rem 1.5rem; }
    .chat.is-empty .thread { padding: .25rem 1rem 1rem; gap: .95rem; }
    .orb { width: 62px; height: 62px; margin-bottom: .9rem; }
    .welcome h1 { font-size: clamp(1.4rem, 7.2vw, 1.9rem); }
    .chat.is-empty .welcome h1 { font-size: clamp(1.4rem, 7.2vw, 1.9rem); }
    .welcome p { font-size: .88rem; margin-bottom: 1.4rem; }
    .suggestions { gap: .55rem; }
    .suggestion { flex-direction: column; gap: .35rem; padding: .7rem .75rem; }
    .suggestion .s {
        display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .media.images .shot { height: 140px; }
    .media.videos .clip { width: 232px; }
    .track-row { grid-template-columns: 40px minmax(0, 1fr); row-gap: .4rem; }
    .track-row audio { grid-column: 1 / -1; }
    .seo-crawl { padding: .75rem 1rem 1.25rem; }
}

/* La barre du haut porte trois choses — le menu, le sélecteur de mode, la version du
   modèle — et le sélecteur est centré au *milieu de la page*, pas entre ses voisins. Sous
   700 px les trois se chevauchaient : le titre passait sous le sélecteur, illisible. Le
   sélecteur reprend donc sa place dans le flux, et le titre — que le fil de discussion
   rappelle déjà — laisse la place. */
@media (max-width: 700px) {
    .topbar { grid-template-areas: "menu mode right"; }
    .topbar-title { display: none; }
    .mode-switch {
        position: static;
        transform: none;
        grid-area: mode;
        justify-self: center;
    }
}

@media (max-width: 420px) {
    .mode-opt { font-size: .74rem; padding: .34rem .7rem; }
    .msg.user .bubble { max-width: 92%; }
}

/* Écran court (téléphone compact, ou clavier ouvert) : au bureau les quatre suggestions
   tiennent sous le titre sans défiler, et c'est ce qui fait la page d'accueil. Sur 667 px de
   haut, il faut prendre la hauteur au décor — la vignette et le tampon d'encre — pas aux
   cartes. */
@media (max-width: 820px) and (max-height: 740px) {
    .welcome { padding-top: .75rem; }
    .chat.is-empty .thread { gap: .8rem; }
    .suggestions-quiet { transform: scale(.98); }
    .orb { width: 50px; height: 50px; margin-bottom: .6rem; }
    .welcome h1,
    .chat.is-empty .welcome h1 { font-size: clamp(1.25rem, 6.4vw, 1.6rem); }
    .welcome h1::after { display: none; }
    .welcome p { font-size: .82rem; margin-bottom: 1rem; }
}

/* Les très petits écrans n'ont plus la place pour deux colonnes de suggestions sans couper
   les mots. Le seuil est bas exprès — un iPhone SE (375 px) garde la grille 2 × 2. */
@media (max-width: 340px) {
    .suggestions { grid-template-columns: 1fr; }
    .suggestion { flex-direction: row; }
    .welcome { padding-left: .75rem; padding-right: .75rem; }
}

/* Téléphone couché : le composeur et le fil se partagent moins de 400 px de haut. */
@media (max-width: 940px) and (orientation: landscape) and (max-height: 500px) {
    .chat.is-empty .thread { gap: .6rem; }
    .orb { width: 42px; height: 42px; margin-bottom: .4rem; }
    .welcome h1,
    .chat.is-empty .welcome h1 { font-size: 1.25rem; }
    .welcome h1::after { display: none; }
    .suggestions-quiet { display: none; }
}

