/* ==========================================================================
   Lolla — Phase 4 « IA » : LollAI coach, On joue quoi ce soir ?, Quêtes perso
   DA « Vestiaire » : aplats, bordures 1px, pas de lueur ni de dégradé.
   ========================================================================== */

/* ---------- Coach : en-tête & état ---------- */
.ai-usage { display: flex; flex-direction: column; gap: 4px; min-width: 150px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); }
.ai-usage b { font: 800 22px/1 var(--f-sans); font-variation-settings: "wdth" 115; }
.ai-usage .meter > span { background: var(--mint); }

.ai-offline { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 16px; padding: 14px 16px; border: 1px dashed var(--line-2); border-radius: var(--r-lg); background: var(--panel); }
.ai-offline .sticker { flex: none; margin-top: 2px; }
.ai-offline p + p { margin-top: 6px; }
.ai-offline code, .ai-bubble code { font: 500 12px var(--f-mono); padding: 1px 5px; border-radius: var(--r-xs); background: var(--bg); border: 1px solid var(--line); }

.ai-grid { margin-top: 0; }

/* ---------- Coach : fenêtre de chat ---------- */
.ai-chat { display: flex; flex-direction: column; }
.ai-chat-head { align-items: flex-start; }
.ai-chat-head h2 { font-size: 13.5px; }
.ai-chat-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }

.ai-match { display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; padding: 10px 18px; border-bottom: 1px solid var(--line); border-left: 4px solid var(--loss); background: var(--loss-bg); }
.ai-match.is-win { border-left-color: var(--win); background: var(--win-bg); }
.ai-match-res { font: 900 14px var(--f-sans); font-variation-settings: "wdth" 125; text-transform: uppercase; color: var(--loss); }
.ai-match.is-win .ai-match-res { color: var(--win); }
.ai-match-champs { display: flex; gap: 4px; }
.ai-match-champs img { width: 26px; height: 26px; border-radius: 50%; }
.ai-match .panel-link { margin-left: auto; }

.ai-thread { display: flex; flex-direction: column; gap: 12px; padding: 18px; max-height: min(62vh, 640px); min-height: 220px; overflow-y: auto; scrollbar-width: thin; background: var(--bg-2); }
.ai-msg { display: flex; align-items: flex-end; gap: 8px; max-width: 88%; animation: fade .2s var(--ease); }
.ai-msg.is-user { align-self: flex-end; flex-direction: row-reverse; }
.ai-msg[hidden] { display: none; }
.ai-avatar {
    flex: none; display: grid; place-items: center; width: 28px; height: 28px; border-radius: var(--r-sm);
    background: var(--brand); color: #fff; font: 800 10.5px var(--f-mono); letter-spacing: .02em;
}
.ai-bubble {
    position: relative; min-width: 0; padding: 10px 13px; border-radius: var(--r-lg);
    background: var(--panel-2); border: 1px solid var(--line); color: var(--text); line-height: 1.55; overflow-wrap: anywhere;
}
.is-coach .ai-bubble { border-bottom-left-radius: var(--r-xs); }
.is-user .ai-bubble { background: var(--brand); border-color: var(--brand); color: #fff; border-bottom-right-radius: var(--r-xs); }
.ai-bubble p + p, .ai-bubble p + ul, .ai-bubble p + ol, .ai-bubble ul + p, .ai-bubble ol + p { margin-top: 8px; }
.ai-bubble ul, .ai-bubble ol { margin: 6px 0 0; padding-left: 20px; }
.ai-bubble li + li { margin-top: 3px; }
.ai-bubble strong { font-weight: 750; color: #fff; }
.is-coach .ai-bubble strong { color: var(--mint); }
.ai-bubble .md-h { font-weight: 800; text-transform: none; font-size: 12.5px; letter-spacing: 0; }
.ai-src {
    display: inline-block; margin-top: 8px; padding: 1px 6px; border-radius: var(--r-xs);
    font: 600 10px/1.6 var(--f-body); text-transform: none; letter-spacing: 0; color: var(--muted); background: var(--bg); border: 1px solid var(--line);
}
.ai-typing .ai-bubble { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 8px; }
.ai-dots { display: inline-flex; gap: 3px; }
.ai-dots i { width: 6px; height: 6px; background: var(--muted); border-radius: 1px; animation: ai-blink 1s infinite steps(1); }
.ai-dots i:nth-child(2) { animation-delay: .2s; }
.ai-dots i:nth-child(3) { animation-delay: .4s; }
@keyframes ai-blink { 0%, 100% { opacity: .25; } 50% { opacity: 1; } }

.ai-compose { display: flex; align-items: flex-end; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--line); background: var(--panel); }
.ai-compose[hidden] { display: none; }
.ai-compose textarea { flex: 1; min-height: 42px; max-height: 180px; resize: none; }
.ai-compose .btn { height: 42px; }
.ai-compose .btn[disabled] { opacity: .5; pointer-events: none; }
.ai-foot { padding: 0 14px 12px; background: var(--panel); }
.ai-full { padding: 14px 18px; border-top: 1px solid var(--line); color: var(--text-2); }

/* ---------- Coach : nouvelle conversation ---------- */
.ai-modes, .ai-personas { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.ai-mode, .ai-persona { position: relative; display: flex; cursor: pointer; }
.ai-mode input, .ai-persona input { position: absolute; opacity: 0; pointer-events: none; }
.ai-mode span, .ai-persona span {
    flex: 1; display: flex; flex-direction: column; gap: 3px; padding: 11px 12px;
    border: 1px solid var(--line-2); border-radius: var(--r); background: var(--bg-2); transition: border-color .12s, background .12s;
}
.ai-mode b, .ai-persona b { font-weight: 750; font-size: 13.5px; }
.ai-mode small, .ai-persona small { color: var(--muted); font-size: 12px; line-height: 1.35; }
.ai-mode:hover span, .ai-persona:hover span { border-color: #454a56; }
.ai-mode input:checked + span { border-color: var(--brand-2); background: var(--win-bg); }
.ai-persona input:checked + span { border-color: var(--mint); background: rgba(79, 240, 200, .07); }
.ai-mode input:focus-visible + span, .ai-persona input:focus-visible + span { outline: 2px solid var(--mint); outline-offset: 2px; }
[data-ai-match-field][hidden] { display: none; }

.ai-convs .list-row { padding: 9px 8px; margin: 0 -8px; border-radius: var(--r-sm); border-bottom-color: transparent; }
.ai-convs .list-row:hover { background: var(--panel-2); }
.ai-convs .list-row.is-active { background: var(--panel-3); }
.ai-conv-ico { display: grid; place-items: center; width: 30px; height: 30px; flex: none; border-radius: var(--r-sm); background: var(--bg-2); border: 1px solid var(--line); color: var(--text-2); }
.ai-convs b { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ai-how { margin: 0; padding-left: 18px; color: var(--text-2); font-size: 13px; display: flex; flex-direction: column; gap: 6px; }

/* ==========================================================================
   On joue quoi ce soir ?
   ========================================================================== */
.tn-grid { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 16px; align-items: start; }
.tn-mood-list { display: flex; flex-direction: column; gap: 6px; }
.tn-mood-list form { display: flex; }
.tn-mood {
    flex: 1; display: flex; flex-direction: column; align-items: flex-start; gap: 1px; text-align: left; cursor: pointer;
    padding: 10px 12px 10px 14px; border: 1px solid var(--line-2); border-left-width: 4px; border-radius: var(--r);
    background: var(--bg-2); transition: background .12s, border-color .12s;
}
.tn-mood b { font-weight: 800; font-size: 14px; }
.tn-mood small { color: var(--muted); font-size: 12px; }
.tn-mood:hover { background: var(--panel-2); }
.tn-mood[disabled] { opacity: .6; }
.tn-mood-tryhard { border-left-color: var(--loss); }
.tn-mood-detente { border-left-color: var(--mint); }
.tn-mood-decouverte { border-left-color: var(--brand-2); }
.tn-mood-confort { border-left-color: var(--gold); }
.tn-mood-nimporte { border-left-color: var(--pink); }
.tn-mood.is-active { background: var(--text); border-color: var(--text); color: var(--bg); }
.tn-mood.is-active small { color: #444a55; }
.tn-mood-tryhard.is-active { border-left-color: var(--loss); }
.tn-mood-detente.is-active { border-left-color: var(--mint); }
.tn-mood-decouverte.is-active { border-left-color: var(--brand-2); }
.tn-mood-confort.is-active { border-left-color: var(--gold); }
.tn-mood-nimporte.is-active { border-left-color: var(--pink); }
.tn-out { margin-top: 8px; }

.tn-badge-tryhard { background: rgba(255, 84, 101, .14); color: #ff8b97; }
.tn-badge-detente { background: rgba(79, 240, 200, .12); color: var(--mint); }
.tn-badge-decouverte { background: rgba(77, 124, 255, .16); color: #9bb5ff; }
.tn-badge-confort { background: rgba(242, 193, 78, .14); color: var(--gold); }
.tn-badge-nimporte { background: rgba(255, 122, 184, .14); color: var(--pink); }

.tn-roster { display: flex; flex-direction: column; margin-top: 16px; border-top: 1px solid var(--line); }
.tn-who { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); opacity: .55; }
.tn-who.is-in { opacity: 1; }
.tn-who b { font-weight: 700; }
.tn-roll { margin-top: 16px; }
.tn-roll-hint { margin-top: 8px; text-align: center; }

.tn-picks { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.tn-pick { display: flex; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: var(--r); background: var(--bg-2); }
.tn-pick.is-me { border-color: var(--mint); }
.tn-slot { position: relative; flex: none; width: 72px; height: 72px; border-radius: var(--r); overflow: hidden; border: 2px solid var(--line-2); background: var(--panel-3); }
.tn-face { width: 100%; height: 100%; object-fit: cover; transform: scale(1.08); }
.tn-pick.is-spinning .tn-slot { border-color: var(--yellow); }
.tn-pick.is-spinning .tn-face { filter: grayscale(.6); }
.tn-pick.is-landed .tn-slot { border-color: var(--mint); animation: tn-land .35s var(--ease); }
.tn-pick.is-spinning .tn-pick-champ, .tn-pick.is-spinning .tn-pick-why { visibility: hidden; }
@keyframes tn-land { 0% { transform: scale(1.12) rotate(-3deg); } 60% { transform: scale(.97) rotate(1deg); } 100% { transform: none; } }
.tn-pick-body { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.tn-pick-who { display: flex; align-items: center; gap: 5px; font: 500 11px var(--f-body); text-transform: none; letter-spacing: 0; color: var(--muted); }
.tn-pick-champ { font-size: 19px; line-height: 1; }
.tn-pick-why { font-size: 12.5px; color: var(--text-2); }
.tn-pick-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: auto; padding-top: 4px; }

.tn-comp { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 18px; padding: 14px 0 4px; border-top: 1px solid var(--line); }
.tn-comp p { color: var(--text-2); }
.tn-duo { margin-top: 12px; font-size: 13px; color: var(--text-2); }
.tn-plan { margin-top: 14px; padding: 14px 16px; border-radius: var(--r); background: var(--bg-2); border: 1px solid var(--line); }
.tn-plan .label { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.tn-plan ol { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.tn-plan li::marker { font: 700 12px var(--f-mono); color: var(--mint); }
.tn-late { margin-top: 10px; }
.is-waiting { opacity: 0; }
.tn-comp.is-in .sticker { animation: tn-stick .4s var(--ease); }
.tn-plan.is-in, .tn-duo.is-in { animation: fade .3s var(--ease); }
@keyframes tn-stick { 0% { opacity: 0; transform: scale(1.6) rotate(-12deg); } 70% { opacity: 1; transform: scale(.95) rotate(-1deg); } 100% { transform: rotate(-2.5deg); } }

/* ==========================================================================
   Quêtes perso
   ========================================================================== */
.qst-score { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.qst-score b { font: 900 34px/1 var(--f-sans); font-variation-settings: "wdth" 125; }
.qst-score small { color: var(--gold); }

.qst-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.qst-card { display: flex; flex-direction: column; gap: 10px; padding: 16px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--panel); }
.qst-card.is-done { border-color: rgba(79, 240, 200, .45); }
.qst-head { display: flex; align-items: center; gap: 8px; }
.qst-head .sticker { margin-left: auto; }
.qst-ico { display: grid; place-items: center; width: 34px; height: 34px; flex: none; border-radius: var(--r-sm); background: var(--brand); color: #fff; }
.qst-ico.is-small { width: 26px; height: 26px; background: var(--mint); color: var(--mint-ink); }
.is-done .qst-ico { background: var(--mint); color: var(--mint-ink); }
.qst-title { font-size: 17px; font-weight: 800; line-height: 1.2; font-variation-settings: "wdth" 110; }
.qst-hint { font-size: 13px; color: var(--text-2); flex: 1; }
.qst-progress { display: flex; flex-direction: column; gap: 6px; }
.qst-progress .meter { height: 8px; border-radius: 2px; }
.qst-progress .meter > span { background: var(--brand-2); }
.is-done .qst-progress .meter > span { background: var(--mint); }
.qst-progress p { color: var(--muted); font-size: 11.5px; }
.qst-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; padding-top: 10px; border-top: 1px solid var(--line); }
.qst-note { margin-top: 10px; }
.qst-bottom { margin-top: 16px; }
.qst-dots { display: inline-flex; gap: 4px; margin-top: 4px; }
.qst-dots i { width: 22px; height: 6px; border-radius: 1px; background: var(--panel-3); }
.qst-dots i.is-done { background: var(--mint); }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
    .tn-grid { grid-template-columns: 300px minmax(0, 1fr); }
}
@media (max-width: 1023px) {
    .tn-grid { grid-template-columns: 1fr; }
    .qst-list { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 760px) {
    .ai-modes, .ai-personas { grid-template-columns: 1fr; }
    .ai-msg { max-width: 94%; }
    .ai-thread { padding: 14px 12px; max-height: 60vh; }
    .ai-compose .btn span { display: none; }
    .ai-usage { flex-direction: row; align-items: center; flex-wrap: wrap; width: 100%; }
    .ai-usage .meter { flex-basis: 100%; }
    .ai-match .panel-link { margin-left: 0; }
    .qst-list { grid-template-columns: 1fr; }
    .qst-score { align-items: flex-start; }
    .tn-picks { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
    .tn-pick.is-landed .tn-slot, .tn-comp.is-in .sticker, .ai-msg { animation: none; }
    .is-waiting { opacity: 1; }
}
