:root {
  --bg: #0b0d12; --panel: #13151d; --panel2: #1a1d28; --line: #262a37;
  --text: #e9ebf0; --muted: #8b93a7; --accent: #9440fd; --accent2: #cc47fa;
  --green: #1db954; --user: #242a3a; --ai: #2a1d47; --danger: #ff5d6c; --rp-speech: #ff9a9a;
  --font-narr: 'Lora', Georgia, 'Times New Roman', serif;  /* police narration (differente du dialogue) */
  --nav-h: 60px; --side-w: 248px;
}
:root[data-theme="light"] {
  --bg: #f4f5f9; --panel: #ffffff; --panel2: #eef0f6; --line: #d9dde8;
  --text: #15171f; --muted: #6b7384; --user: #e7e9f2; --ai: #efe6ff; --rp-speech: #c0392b;
}
* { box-sizing: border-box; }
html, body { height: 100%; overflow-x: hidden; }
body { margin: 0; font: 15px/1.5 system-ui, -apple-system, Segoe UI, Roboto, sans-serif; background: var(--bg); color: var(--text); }
.hidden { display: none !important; }
.spacer { flex: 1; }
.only-mobile { display: none; }

/* Scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 999px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #3a4154; }

/* Overlays */
.overlay { position: fixed; inset: 0; display: grid; place-items: center; background: radial-gradient(1200px 600px at 50% -10%, #2a1150, var(--bg)); padding: 16px; z-index: 50; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 28px; width: min(420px,100%); box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.card h1 { margin: 0 0 12px; font-size: 22px; }
.card p { color: var(--muted); margin: 0 0 18px; }
.row { display: flex; gap: 12px; align-items: center; }
.brand-text { font-weight: 800; background: linear-gradient(135deg, var(--accent), var(--accent2)); -webkit-background-clip: text; background-clip: text; color: transparent; }

input, textarea, .select { width: 100%; padding: 11px 14px; margin: 6px 0; background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; color: var(--text); font: inherit; }
input:focus, textarea:focus, .select:focus { outline: none; border-color: var(--accent); }
.select { width: auto; margin: 0; cursor: pointer; }
button { cursor: pointer; border: none; border-radius: 10px; padding: 11px 16px; font-weight: 600; color: var(--text); background: var(--panel2); }
button.primary { background: linear-gradient(135deg, var(--accent), var(--accent2)); }
button.small { padding: 9px 13px; }
button:disabled { opacity: .5; cursor: default; }
.btn-ghost { background: transparent; border: 1px solid var(--line); text-decoration: none; display: inline-flex; align-items: center; color: var(--text); }
.icon-btn { background: transparent; border: 1px solid var(--line); min-width: 40px; height: 40px; padding: 0 10px; display: inline-flex; align-items: center; justify-content: center; gap: 4px; }
.tabs { display: flex; gap: 8px; margin-bottom: 10px; }
.tab { flex: 1; background: var(--panel2); opacity: .6; }
.tab.active { opacity: 1; border-bottom: 2px solid var(--accent); }
.check { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 14px; margin: 8px 0; }
.check input { width: auto; margin: 0; }
.error { color: var(--danger); min-height: 18px; font-size: 14px; }
.hint { color: var(--muted); font-size: 13px; }
code { background: var(--panel2); padding: 1px 6px; border-radius: 6px; }

/* Navbar */
.navbar { height: var(--nav-h); display: flex; align-items: center; gap: 12px; padding: 0 16px; border-bottom: 1px solid var(--line); background: var(--panel); position: sticky; top: 0; z-index: 25; }
.logo { font-size: 18px; }
.promo-pill { background: transparent; border: 1px solid var(--green); color: var(--green); border-radius: 999px; padding: 7px 14px; font-size: 13px; }
.lang { position: relative; }
.lang-menu { width: 160px; max-height: 300px; overflow-y: auto; }
.lang-menu button { width: 100%; text-align: left; background: transparent; }
.lang-menu button:hover { background: var(--panel2); }
.lang-menu button.active { color: var(--accent2); }
.profile { position: relative; display: flex; align-items: center; gap: 6px; }
.avatar-btn { width: 40px; height: 40px; padding: 0; border-radius: 50%; font-weight: 800; color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent2)); text-transform: uppercase; }
.avatar-btn:hover { filter: brightness(1.1); }
.plan-label { color: var(--muted); font-size: 13px; cursor: pointer; }
.dropdown { position: absolute; right: 0; top: 50px; width: 250px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px; box-shadow: 0 16px 40px rgba(0,0,0,.5); z-index: 30; transform-origin: top right; animation: ddIn .14s ease; }
.dd-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.dd-name { font-weight: 700; }
.dd-plan { font-size: 11px; color: var(--accent2); border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; }
.dd-credits { color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.dd-item { width: 100%; text-align: left; background: transparent; margin-top: 6px; }
.dd-item:hover { background: var(--panel2); }
.dd-item.primary-item { background: linear-gradient(135deg, var(--accent), var(--accent2)); }
.dd-item small { opacity: .7; font-weight: 400; }
.dd-toggle { display: flex; align-items: center; justify-content: space-between; padding: 10px 8px; font-size: 14px; cursor: pointer; }
.dd-toggle input { appearance: none; width: 38px; height: 22px; border-radius: 999px; background: var(--panel2); border: 1px solid var(--line); position: relative; cursor: pointer; transition: background .15s; flex-shrink: 0; }
.dd-toggle input:checked { background: linear-gradient(135deg, var(--accent), var(--accent2)); border-color: transparent; }
.dd-toggle input::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; }
.dd-toggle input:checked::after { transform: translateX(16px); }
.dd-sep { height: 1px; background: var(--line); margin: 8px 0; }

/* Layout */
.layout { display: flex; height: calc(100vh - var(--nav-h)); }
.sidebar { width: var(--side-w); flex-shrink: 0; border-right: 1px solid var(--line); background: var(--panel); padding: 14px; overflow-y: auto; display: flex; flex-direction: column; }
.user-card { display: flex; align-items: center; gap: 10px; padding: 10px; margin-bottom: 12px; background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; }
.uc-av { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; color: #fff; text-transform: uppercase; background: linear-gradient(135deg, var(--accent), var(--accent2)); flex-shrink: 0; }
.uc-name { font-weight: 700; font-size: 14px; }
.uc-plan { font-size: 12px; color: var(--muted); }
.side-item { width: 100%; text-align: left; background: transparent; margin-bottom: 4px; display: flex; align-items: center; gap: 4px; }
.side-item:hover { background: var(--panel2); }
.side-item.active { background: linear-gradient(135deg, rgba(148,64,253,.25), rgba(204,71,250,.12)); border: 1px solid var(--line); color: var(--accent2); }
.side-upgrade { color: var(--green); }
.mini-badge { font-size: 10px; background: var(--green); color: #fff; border-radius: 999px; padding: 1px 6px; margin-left: auto; }
.side-title { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; margin: 14px 6px 8px; }
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; }
.side-foot { display: flex; gap: 8px; margin-top: auto; padding-top: 14px; }
.side-link { flex: 1; text-align: center; font-size: 13px; color: var(--muted); text-decoration: none; border: 1px solid var(--line); border-radius: 10px; padding: 8px; }
.side-link:hover { border-color: var(--accent); color: var(--text); }
.tag { background: var(--panel2); border: 1px solid var(--line); border-radius: 999px; padding: 5px 11px; font-size: 13px; cursor: pointer; white-space: nowrap; }
.tag:hover { border-color: var(--accent); }
.tag.active { background: linear-gradient(135deg, var(--accent), var(--accent2)); border-color: transparent; }

/* Sidebar : groupes repliables + menu Plus */
.side-group { display: flex; flex-direction: column; }
.side-collapse { justify-content: flex-start; }
.side-collapse .chev { margin-left: auto; transition: transform .15s; }
.side-collapse.open .chev { transform: rotate(180deg); }
.side-sub { display: flex; flex-direction: column; overflow: hidden; }
.side-item.sub { padding-left: 28px; font-size: 14px; color: var(--muted); }
.side-item.sub:hover { color: var(--text); }
.side-more { position: relative; margin-top: 6px; }
.more-menu { position: absolute; bottom: 44px; left: 0; right: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 8px; box-shadow: 0 -10px 30px rgba(0,0,0,.4); animation: ddIn .14s ease; }
.more-menu .side-item { margin-bottom: 2px; }

/* Pieces de monnaie */
#coins-view { animation: viewIn .2s ease; }
.coins-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; max-width: 820px; }
.coinpack { position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 22px; display: flex; flex-direction: column; }
.coinpack.featured { border-color: var(--accent); box-shadow: 0 10px 40px rgba(148,64,253,.2); }
.coinpack-amt { font-size: 28px; font-weight: 800; }
.coinpack p { color: var(--muted); font-size: 14px; flex: 1; }
.coinpack-badge { position: absolute; top: 12px; right: 12px; font-size: 11px; font-weight: 700; color: #fff; background: #e0a60b; border-radius: 999px; padding: 2px 8px; }
.coinpack-badge.save { background: linear-gradient(135deg, var(--accent), var(--accent2)); }

.content { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 20px; min-width: 0; }
/* En discussion, seule la liste des messages defile (le fond flou agrandi ne cree pas de barre) */
.content.chat-mode { overflow: hidden; }

/* Discover top */
.discover-top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: center; margin-bottom: 14px; }
.search-wrap { flex: 1; min-width: 220px; max-width: 460px; }
.search-wrap input { margin: 0; border-radius: 999px; }
.feed-tabs { display: flex; background: var(--panel2); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.pill { background: transparent; border-radius: 999px; padding: 8px 18px; font-size: 14px; }
.pill.active { background: linear-gradient(135deg, var(--accent), var(--accent2)); }
.adult-btn { border: 1px solid var(--line); background: var(--panel2); border-radius: 999px; font-size: 13px; }
.adult-btn.active { border-color: var(--accent); color: var(--accent2); }
.filters { display: flex; gap: 10px; justify-content: center; margin-bottom: 16px; flex-wrap: wrap; }
.tagrow { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 12px; margin-bottom: 8px; }

/* Gallery cards (image-style) */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.char { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; cursor: pointer; transition: transform .1s, border-color .1s; }
.char:hover { transform: translateY(-3px); border-color: var(--accent); }
.char .cover { position: relative; aspect-ratio: 3/4; display: grid; place-items: center; font-size: 60px; background: linear-gradient(145deg, #241a3a, #2e2450); overflow: hidden; }
.cover-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.av-mini { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; vertical-align: middle; }
.chat-row .av .av-mini { width: 40px; height: 40px; }
.char .creator { position: absolute; top: 8px; left: 8px; font-size: 11px; background: rgba(0,0,0,.55); border-radius: 999px; padding: 2px 8px; color: #fff; }
.char .nsfwtag { position: absolute; top: 8px; right: 8px; font-size: 10px; background: var(--accent); border-radius: 999px; padding: 2px 7px; color: #fff; }
.char .body { padding: 12px; }
.char .nm { font-weight: 700; }
.char .tg { color: var(--muted); font-size: 13px; min-height: 36px; margin-top: 2px; }
.char .foot { display: flex; gap: 12px; margin-top: 8px; font-size: 12px; color: var(--muted); }

/* Page personnage */
#char-view { animation: viewIn .2s ease; max-width: 1180px; margin: 0 auto; }
.cp-top { margin-bottom: 12px; }
.cp-grid { display: grid; grid-template-columns: minmax(260px, 380px) 1fr; gap: 28px; align-items: start; }
.cp-left { display: flex; flex-direction: column; gap: 14px; position: sticky; top: 0; }
.cp-cover { position: relative; aspect-ratio: 4/5; border-radius: 20px; overflow: hidden; background: linear-gradient(145deg, #241a3a, #2e2450); display: grid; place-items: center; border: 1px solid var(--line); box-shadow: 0 18px 50px rgba(0,0,0,.35); }
.cp-cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cp-cover::after { content: ''; position: absolute; inset: auto 0 0 0; height: 30%; background: linear-gradient(transparent, rgba(0,0,0,.45)); pointer-events: none; }
.cp-cover-emoji { font-size: 110px; }
.cp-badge { position: absolute; top: 12px; right: 12px; z-index: 1; font-size: 12px; font-weight: 700; color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent2)); border-radius: 999px; padding: 3px 10px; }
.cp-reacts { display: grid; grid-template-columns: 1fr 1fr 1.2fr; gap: 10px; }
.cp-react { display: flex; align-items: center; justify-content: center; gap: 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 11px 8px; font-size: 14px; }
.cp-react .ic { font-size: 17px; color: var(--muted); transition: color .15s, transform .15s; }
.cp-react:hover { border-color: var(--accent); }
.cp-react.on { border-color: var(--accent); background: linear-gradient(135deg, rgba(148,64,253,.22), rgba(204,71,250,.12)); }
.cp-react.on .ic { color: var(--accent2); }
.cp-react.pop .ic { animation: pop .3s ease; }
.cp-creator { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 14px; }
.cp-creator-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.cp-mini-list { display: flex; flex-direction: column; gap: 8px; }
.cp-mini { position: relative; display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 8px; font-weight: 400; }
.cp-mini:hover { border-color: var(--accent); }
.cp-mini-av { width: 46px; height: 58px; border-radius: 9px; overflow: hidden; flex-shrink: 0; display: grid; place-items: center; font-size: 26px; background: linear-gradient(145deg, #241a3a, #2e2450); }
.cp-mini-av img { width: 100%; height: 100%; object-fit: cover; }
.cp-mini-txt { display: flex; flex-direction: column; min-width: 0; }
.cp-mini-txt b { font-size: 14px; }
.cp-mini-txt small { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cp-mini .nsfwtag { position: absolute; top: 6px; right: 6px; font-size: 10px; background: var(--accent); border-radius: 999px; padding: 1px 6px; color: #fff; }
.cp-main { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.cp-name { font-size: clamp(28px, 4vw, 42px); line-height: 1.1; margin: 4px 0 0; letter-spacing: -.01em; }
.cp-tagline { color: var(--muted); margin: -6px 0 0; font-size: 16px; }
.cp-stats { display: flex; gap: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.cp-stats > div { flex: 1; padding: 14px 18px; display: flex; flex-direction: column; border-right: 1px solid var(--line); }
.cp-stats > div:last-child { border-right: none; }
.cp-stats b { font-size: 22px; }
.cp-stats span { color: var(--muted); font-size: 13px; }
.cp-cta { display: flex; gap: 10px; flex-wrap: wrap; }
.cp-start { flex: 1; min-width: 220px; padding: 15px 20px; font-size: 16px; border-radius: 14px; box-shadow: 0 10px 30px rgba(148,64,253,.3); }
.cp-card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 16px 18px; }
.cp-card h3 { margin: 0 0 10px; font-size: 16px; }
.cp-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.cp-tag { font-size: 12px; border: 1px solid var(--line); background: var(--panel2); border-radius: 999px; padding: 3px 10px; color: var(--muted); }
.cp-tag.hot { color: #fff; border-color: transparent; background: linear-gradient(135deg, var(--accent), var(--accent2)); }
.cp-desc { margin: 0; line-height: 1.6; white-space: pre-wrap; }
.cp-greeting { background: var(--ai); border-radius: 14px; border-bottom-left-radius: 4px; padding: 12px 14px; line-height: 1.55; }
.cp-similar { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
#chat-name { cursor: pointer; }
#chat-name:hover { color: var(--accent2); }

/* Chats list */
.chats-list { display: flex; flex-direction: column; gap: 10px; max-width: 640px; }
.chat-row { display: flex; align-items: center; gap: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; cursor: pointer; }
.chat-row:hover { border-color: var(--accent); }
.chat-row .av { font-size: 28px; }

/* Toolbar */
.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.toolbar h2 { margin: 0; font-size: 20px; }

/* Form */
.form-card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 20px; max-width: 560px; }
.form-card label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 10px; }

/* Subscribe */
#subscribe-view { animation: viewIn .2s ease; }
.sub-hero { text-align: center; padding: 10px 0 24px; }
.sub-hero h1 { font-size: 30px; margin: 10px 0 8px; }
.sub-hero p { color: var(--muted); max-width: 520px; margin: 0 auto; }
.promo-tag { display: inline-block; background: linear-gradient(135deg, #1db954, #19a34a); color: #fff; font-weight: 700; font-size: 13px; border-radius: 999px; padding: 4px 12px; }
.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; max-width: 860px; margin: 0 auto; }
.plan { position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 24px; display: flex; flex-direction: column; }
.plan.featured { border-color: var(--accent); box-shadow: 0 10px 40px rgba(148,64,253,.2); transform: scale(1.03); }
.plan-badge { position: absolute; top: -10px; left: 50%; transform: translateX(-50%); background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; font-size: 11px; font-weight: 700; padding: 3px 12px; border-radius: 999px; white-space: nowrap; }
.plan-badge.save { background: linear-gradient(135deg, #1db954, #19a34a); }
.plan-name { font-weight: 700; color: var(--muted); }
.plan-price { font-size: 32px; font-weight: 800; margin: 6px 0 16px; }
.plan-price span { font-size: 14px; font-weight: 500; color: var(--muted); }
.plan-feats { list-style: none; padding: 0; margin: 0 0 20px; flex: 1; display: flex; flex-direction: column; gap: 10px; font-size: 14px; }
.plan-feats .off { color: var(--muted); opacity: .6; }
.plan-cta { width: 100%; }
.sub-note { text-align: center; color: var(--muted); font-size: 12px; margin-top: 20px; }

/* Pages info */
#info-view { animation: viewIn .2s ease; }
.info-body { max-width: 620px; }
.info-card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px; margin-bottom: 12px; }
.info-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); }
.info-row:last-child { border-bottom: none; }
.info-row span:first-child { color: var(--muted); }
.info-empty { text-align: center; color: var(--muted); padding: 40px 20px; }
.info-empty .big { font-size: 42px; display: block; margin-bottom: 10px; }
.info-profile-head { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.info-profile-head .big-av { width: 60px; height: 60px; border-radius: 50%; display: grid; place-items: center; font-size: 26px; font-weight: 800; color: #fff; text-transform: uppercase; background: linear-gradient(135deg, var(--accent), var(--accent2)); }

/* Chat */
.chat { display: flex; height: 100%; gap: 16px; position: relative; }
.chat-main { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; z-index: 1; max-width: 920px; margin: 0 auto; }
.chat-head { display: flex; align-items: center; gap: 10px; padding-bottom: 12px; font-weight: 600; }
.messages { flex: 1; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 78%; padding: 10px 14px 6px; border-radius: 14px; white-space: pre-wrap; word-wrap: break-word; position: relative; }
.msg.typing { padding: 14px 16px; }
.msg.pinned { box-shadow: inset 3px 0 0 var(--accent2); }
.msg-actions { display: flex; gap: 2px; justify-content: flex-end; margin-top: 4px; opacity: 0; transition: opacity .15s; }
.msg:hover .msg-actions, .msg.is-last .msg-actions, .msg.pinned .msg-actions { opacity: 1; }
.act { background: transparent; padding: 2px 7px; font-size: 13px; border-radius: 8px; color: var(--muted); filter: grayscale(1); opacity: .75; }
.act:hover { background: rgba(255,255,255,.08); filter: none; opacity: 1; }
.act.on { filter: none; opacity: 1; background: rgba(204,71,250,.18); }
.act-regen { display: none; }
.msg.is-last .act-regen { display: inline-block; }

/* Fond du chat (avatar flou ou image) */
.chat-bg { position: absolute; inset: -20px; z-index: 0; background-size: cover; background-position: center; pointer-events: none; opacity: 0; transition: opacity .3s; }
.chat.bg-avatar .chat-bg { opacity: 1; filter: blur(22px) brightness(.4) saturate(1.2); transform: scale(1.1); }
.chat.bg-image .chat-bg { opacity: 1; filter: brightness(.45); }
.chat.bg-avatar .msg, .chat.bg-image .msg { backdrop-filter: blur(6px); }
.chat.bg-avatar .msg.assistant, .chat.bg-image .msg.assistant { background: rgba(42,29,71,.82); }
.chat.bg-avatar .msg.user, .chat.bg-image .msg.user { background: rgba(36,42,58,.85); }
.chat.bg-avatar .chat-head, .chat.bg-image .chat-head { color: #fff; }

/* Panneau lateral du chat */
.chat-panel { width: 310px; flex-shrink: 0; position: relative; z-index: 2; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 14px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.chat.panel-closed .chat-panel { display: none; }
.cpn-head { display: flex; align-items: center; justify-content: space-between; }
.cpn-title-sm { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.cpn-close { min-width: 32px; height: 32px; }
.cpn-char { display: flex; gap: 12px; align-items: center; padding: 6px 0 10px; }
.cpn-av { width: 64px; height: 80px; border-radius: 12px; overflow: hidden; flex-shrink: 0; display: grid; place-items: center; font-size: 34px; background: linear-gradient(145deg, #241a3a, #2e2450); }
.cpn-av img { width: 100%; height: 100%; object-fit: cover; }
.cpn-char-txt { display: flex; flex-direction: column; min-width: 0; }
.cpn-char-txt b { font-size: 17px; }
.cpn-char-txt small { color: var(--muted); font-size: 12px; }
.cpn-group { background: var(--panel2); border: 1px solid var(--line); border-radius: 14px; padding: 6px; display: flex; flex-direction: column; }
.cpn-item { width: 100%; text-align: left; background: transparent; display: flex; align-items: center; gap: 6px; font-weight: 500; }
.cpn-item:hover { background: rgba(148,64,253,.12); }
.cpn-item .chev { margin-left: auto; color: var(--muted); font-size: 18px; line-height: 1; }
.cpn-badge { font-size: 11px; background: var(--accent); color: #fff; border-radius: 999px; padding: 0 7px; }
.cpn-badge:empty { display: none; }
.cpn-title { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 10px 4px 2px; }
.cpn-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 8px; font-size: 14px; }
.cpn-row .select { max-width: 170px; font-size: 13px; padding: 6px 8px; }
.cpn-group .dd-toggle { padding: 8px; }
.chat-panel .brain { width: auto; padding: 10px; overflow: visible; }
.bg-choices { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 4px; }
.bg-choice { padding: 9px 4px; font-size: 13px; background: var(--panel); border: 1px solid var(--line); }
.bg-choice.active { border-color: var(--accent); color: var(--accent2); }
#bg-url-row { padding: 0 4px 4px; }

/* Modales parametres / resume */
.modal-dim { background: rgba(5,6,10,.7); backdrop-filter: blur(4px); }
.st-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 10px 0; }
.st-field { background: var(--panel2); border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
.st-wide { grid-column: 1 / -1; }
.st-label { display: flex; justify-content: space-between; align-items: center; font-weight: 600; font-size: 14px; }
.st-label small { color: var(--muted); font-weight: 400; }
.st-label b { font-size: 12px; color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent2)); border-radius: 8px; padding: 2px 8px; }
.st-field input[type=range] { width: 100%; padding: 0; margin: 12px 0 4px; accent-color: var(--accent2); background: transparent; border: none; }
.st-ends { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.pin-row { display: flex; gap: 10px; align-items: flex-start; background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 10px; margin-top: 8px; }
.pin-who { font-size: 12px; color: var(--accent2); font-weight: 700; flex-shrink: 0; width: 56px; }
.pin-txt { flex: 1; font-size: 14px; max-height: 120px; overflow-y: auto; }
.pin-row .btn-ghost.small { padding: 5px 9px; font-size: 12px; flex-shrink: 0; }
/* Resume : zone + compteur + boutons dans un meme bloc */
.sm-box { background: var(--panel2); border: 1px solid var(--line); border-radius: 14px; padding: 4px 4px 10px; margin-top: 6px; }
.sm-box:focus-within { border-color: var(--accent); }
#sm-text { resize: none; border: none; background: transparent; margin: 0; min-height: 170px; line-height: 1.6; }
#sm-text:focus { border: none; }
.sm-foot { display: flex; align-items: center; gap: 8px; padding: 4px 10px 0; }
.sm-foot .btn-ghost.small { padding: 7px 14px; }
#sm-counter.warn { color: var(--danger); }

/* Pas de barre de defilement visible dans les fenetres (le defilement reste actif) */
.no-scrollbar, .card-wide, .cm-body, .bm-text, .pin-txt, .bm-result { scrollbar-width: none; -ms-overflow-style: none; }
.no-scrollbar::-webkit-scrollbar, .card-wide::-webkit-scrollbar, .cm-body::-webkit-scrollbar,
.bm-text::-webkit-scrollbar, .pin-txt::-webkit-scrollbar, .bm-result::-webkit-scrollbar { display: none; }

/* Memoire : editeur bloc-notes */
.brain-write-btn { width: 100%; margin-bottom: 8px; }
.brain-card { width: min(760px, 100%); max-height: 90vh; }
.brain-card .modal-head h2 small { font-size: 13px; font-weight: 400; }
.bm-help { display: flex; flex-direction: column; gap: 3px; font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.bm-help code { font-size: 12px; }
.bm-cats code { margin-right: 2px; }
.bm-text { flex: 1; min-height: 340px; resize: vertical; font-family: var(--font-narr); font-size: 16px; line-height: 1.7; padding: 14px 16px;
  background: repeating-linear-gradient(transparent, transparent calc(1.7em - 1px), rgba(148,64,253,.12) calc(1.7em - 1px), rgba(148,64,253,.12) 1.7em);
  background-attachment: local; background-position: 0 14px; background-color: var(--panel2); }
.bm-result { background: rgba(255,93,108,.08); border: 1px solid var(--danger); border-radius: 10px; padding: 10px 12px; font-size: 13px; margin-top: 6px; max-height: 140px; overflow-y: auto; }
.bm-rej { margin-top: 4px; color: var(--danger); }
.bm-rej small { color: var(--muted); }
.bm-foot { margin-top: 10px; }
.msg.user { align-self: flex-end; background: var(--user); border-bottom-right-radius: 4px; }
.msg.assistant { align-self: flex-start; background: var(--ai); border-bottom-left-radius: 4px; }
.dots { display: inline-flex; gap: 5px; align-items: center; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); display: inline-block; animation: blink 1.2s infinite ease-in-out; }
.dots i:nth-child(2) { animation-delay: .18s; }
.dots i:nth-child(3) { animation-delay: .36s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
/* Narration et pensees : police serif distincte du dialogue (sans-serif) */
.rp-action { font-family: var(--font-narr); font-weight: 600; letter-spacing: .2px; }
.rp-thought { font-family: var(--font-narr); font-style: italic; opacity: .85; }
.paywall { background: linear-gradient(135deg, rgba(148,64,253,.3), rgba(204,71,250,.2)); border: 1px solid var(--accent); border-radius: 12px; padding: 12px; display: flex; align-items: center; justify-content: center; gap: 12px; margin: 8px 0; }
.composer { display: flex; gap: 10px; padding-top: 12px; align-items: flex-end; }
.composer textarea { margin: 0; resize: none; min-height: 44px; max-height: 160px; line-height: 1.4; overflow-y: auto; }
.composer button { height: 44px; flex-shrink: 0; }

/* Brain (dans le panneau du chat) */
.brain-hint { color: var(--muted); font-size: 12px; margin: 0 0 6px; }
.cat { margin-top: 12px; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--accent2); }
.entry { display: flex; gap: 6px; align-items: center; background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; margin-top: 6px; }
.entry span.txt { flex: 1; font-size: 14px; }
.entry button { padding: 4px 8px; background: transparent; border: 1px solid var(--line); font-size: 12px; }
.brain-add { display: flex; gap: 6px; margin-top: 12px; }
.brain-add input { margin: 0; }

/* Bouton info + fiche personnage */
.info-btn { width: 24px; height: 24px; min-width: 24px; border-radius: 50%; border: 1px solid var(--line); background: transparent; color: var(--muted); font-family: Georgia, serif; font-style: italic; font-weight: 700; padding: 0; display: inline-grid; place-items: center; line-height: 1; }
.info-btn:hover { border-color: var(--accent); color: var(--accent2); }
.card-wide { width: min(640px, 100%); max-height: 82vh; display: flex; flex-direction: column; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.modal-head h2 { margin: 0; font-size: 20px; }
.cm-body { overflow-y: auto; }
.cm-avatar { width: 110px; height: 150px; border-radius: 12px; object-fit: cover; display: block; margin-bottom: 10px; }
.cm-tag { display: inline-block; font-size: 12px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 2px 8px; margin: 2px 4px 2px 0; }
.cm-label { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--accent2); margin-top: 14px; }
.cm-prompt { white-space: pre-wrap; word-wrap: break-word; background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 12px; font-size: 13px; line-height: 1.55; margin-top: 6px; }

/* Toast */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--panel2); border: 1px solid var(--accent); border-radius: 12px; padding: 12px 18px; z-index: 60; box-shadow: 0 10px 30px rgba(0,0,0,.4); animation: toastIn .2s ease; }

/* Animations */
@keyframes ddIn { from { opacity: 0; transform: scale(.96) translateY(-4px); } to { opacity: 1; transform: scale(1) translateY(0); } }
@keyframes viewIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes msgIn { from { opacity: 0; transform: translateY(6px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes cardIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pop { 0% { transform: scale(1); } 50% { transform: scale(1.06); } 100% { transform: scale(1); } }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }
#gallery-view, #create-view, #chat-view, #chats-view { animation: viewIn .2s ease; }
.msg { animation: msgIn .18s ease; }
.char { animation: cardIn .22s ease backwards; }
.gallery .char:nth-child(1){animation-delay:.02s}.gallery .char:nth-child(2){animation-delay:.05s}.gallery .char:nth-child(3){animation-delay:.08s}.gallery .char:nth-child(4){animation-delay:.11s}.gallery .char:nth-child(5){animation-delay:.14s}.gallery .char:nth-child(6){animation-delay:.17s}
button, .tag, .char, .side-item, .pill { transition: transform .08s ease, background .15s ease, border-color .15s ease, filter .15s ease; }
button:active { transform: scale(.96); }
.primary:hover { filter: brightness(1.08); }
.icon-btn:hover, .btn-ghost:hover { background: var(--panel2); }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* Responsive */
@media (max-width: 820px) {
  .only-mobile { display: inline-flex; }
  .sidebar { position: fixed; top: var(--nav-h); bottom: 0; left: 0; z-index: 20; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: translateX(0); }
  .plan-label { display: none; }
  .chat-panel { position: fixed; right: 0; top: var(--nav-h); bottom: 0; width: min(330px, 92vw); z-index: 30; border-radius: 16px 0 0 16px; box-shadow: -20px 0 50px rgba(0,0,0,.5); }
  .msg { max-width: 88%; }
  .msg-actions { opacity: 1; }
  .st-grid { grid-template-columns: 1fr; }
  .cp-grid { grid-template-columns: 1fr; gap: 18px; }
  .cp-left { display: contents; } /* mobile : image, reactions, infos, puis createur */
  .cp-cover { order: 1; } .cp-reacts { order: 2; } .cp-main { order: 3; } .cp-creator { order: 4; }
  .cp-cover { max-height: 62vh; }
  .cp-stats > div { padding: 12px; }
  .cp-stats b { font-size: 18px; }
}

/* =====================================================================
   CHAT IMMERSIF : plein ecran, boutons flottants, panneau colle au bord
   ===================================================================== */
body.immersive .navbar { display: none; }
body.immersive .layout { height: 100vh; }
body.immersive .content.chat-mode { padding: 0; }
body.immersive .chat { gap: 0; }
body.immersive .chat-bg { inset: 0; }
/* le menu de gauche devient un tiroir plein hauteur (ouvert par ») */
body.immersive .sidebar { position: fixed; top: 0; bottom: 0; left: 0; z-index: 45; width: 270px; transform: translateX(-100%); transition: transform .22s ease; box-shadow: 20px 0 50px rgba(0,0,0,.5); }
body.immersive .sidebar.open { transform: translateX(0); }

/* colonne de discussion centree */
.chat-main { padding: 14px 18px 14px; }
body.immersive .chat-main { max-width: 820px; width: 100%; }

/* boutons flottants */
.float-left { position: absolute; top: 14px; left: 16px; z-index: 6; display: flex; gap: 8px; }
.float-btn { width: 40px; height: 40px; padding: 0; display: grid; place-items: center; border-radius: 12px; font-size: 18px; color: #fff;
  background: rgba(20,22,30,.55); border: 1px solid rgba(255,255,255,.08); backdrop-filter: blur(8px); }
.float-btn:hover { background: rgba(148,64,253,.45); }
.float-logo { background: linear-gradient(135deg, var(--accent), var(--accent2)); border: none; }
.float-right { position: absolute; top: 14px; right: 16px; z-index: 6; font-size: 20px; }
.chat:not(.panel-closed) .float-right { display: none; }
@media (max-width: 1350px) { body.immersive .chat-main { padding-top: 64px; } }

/* panneau : plein hauteur, colle a droite, fond plein (pas une carte) */
.chat-panel { border-radius: 0; border: none; border-left: 1px solid var(--line); background: var(--panel); width: 360px; padding: 12px 16px 20px; height: 100%; }
.cpn-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.cpn-head .cpn-close { width: 36px; min-width: 36px; height: 36px; border: none; font-size: 22px; }
span.cpn-close { display: inline-block; }
.pn-page { display: flex; flex-direction: column; gap: 6px; }

/* tiroir "mes discussions" */
.drawer { position: fixed; top: 0; bottom: 0; left: 0; z-index: 45; width: 290px; background: var(--panel); border-right: 1px solid var(--line); padding: 14px; transform: translateX(-100%); transition: transform .22s ease; display: flex; flex-direction: column; box-shadow: 20px 0 50px rgba(0,0,0,.5); }
.drawer.open { transform: translateX(0); }
.cd-list { display: flex; flex-direction: column; gap: 6px; overflow-y: auto; margin-top: 8px; }
.cd-item { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; background: transparent; padding: 8px; font-weight: 500; }
.cd-item:hover, .cd-item.active { background: rgba(148,64,253,.15); }
.cd-av { width: 40px; height: 40px; border-radius: 50%; overflow: hidden; display: grid; place-items: center; font-size: 22px; background: var(--panel2); flex-shrink: 0; }
.cd-av img { width: 100%; height: 100%; object-fit: cover; }
.scrim { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.45); }

/* plus de barre de defilement visible dans la discussion et le panneau */
.messages, .chat-panel, .cd-list { scrollbar-width: none; }
.messages::-webkit-scrollbar, .chat-panel::-webkit-scrollbar, .cd-list::-webkit-scrollbar { display: none; }

/* ---- Page "Resume & epingles" ---- */
.sum-head b { font-size: 16px; }
.sum-title { font-weight: 700; font-size: 15px; margin: 12px 2px 4px; }
.sum-sub { font-size: 13px; color: var(--muted); }
.sum-sub-out { margin: 8px 4px 0; }
.tip { color: var(--muted); font-weight: 400; cursor: help; font-size: 13px; }
.sum-freq { padding: 12px; gap: 10px; }
.freq-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 8px; }
.freq { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; cursor: pointer; line-height: 1.3; }
.freq input { width: 16px; height: 16px; margin: 1px 0 0; accent-color: var(--accent2); flex-shrink: 0; }
.freq small { color: var(--muted); }
.pin-cap { padding: 12px; gap: 8px; }
.pin-cap .hint b { color: var(--text); }
.pin-bar { height: 6px; border-radius: 999px; background: var(--panel); overflow: hidden; }
.pin-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent2)); transition: width .3s; }
.pin-bar i.full { background: var(--danger); }
.pin-list { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
.pin-day { align-self: flex-start; font-size: 12px; font-weight: 700; background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 2px 8px; margin-top: 6px; }
.pin-card { margin-left: 14px; border-left: 2px solid var(--line); padding-left: 10px; }
.pin-top { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; font-size: 13px; }
.pin-av { width: 24px; height: 24px; border-radius: 50%; overflow: hidden; display: grid; place-items: center; font-size: 13px; background: var(--panel2); flex-shrink: 0; }
.pin-av img { width: 100%; height: 100%; object-fit: cover; }
.pin-av.me { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; font-weight: 800; text-transform: uppercase; }
.pin-body { background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; font-size: 14px; line-height: 1.55; }
.pin-ta { margin: 0; resize: vertical; min-height: 120px; }

@media (max-width: 820px) {
  body.immersive .chat-main { padding: 64px 10px 10px; }
  .chat-panel { width: min(360px, 92vw); border-radius: 0; }
}

@media (max-width: 820px) { body.immersive .chat-panel { top: 0; } }

/* Chargement : cercle tournant */
.boot { position: fixed; inset: 0; z-index: 100; background: var(--bg); display: grid; place-items: center; transition: opacity .2s ease; }
.boot.done { opacity: 0; pointer-events: none; }
.spinner { width: 40px; height: 40px; border-radius: 50%; border: 3px solid rgba(255,255,255,.12); border-top-color: var(--accent2); animation: spin .75s linear infinite; }
:root[data-theme="light"] .spinner { border-color: rgba(0,0,0,.1); border-top-color: var(--accent); }
.msgs-loading { flex: 1; display: grid; place-items: center; min-height: 200px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Choix du style de narration */
.st-narr { margin-bottom: 4px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.seg label { cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.seg small { color: var(--muted); font-family: var(--font-narr); font-style: italic; }
.seg input:checked + span { border-color: var(--accent); background: linear-gradient(135deg, rgba(148,64,253,.22), rgba(204,71,250,.1)); }

/* Resume : lecture mise en forme + crayon d'edition */
.sum-row { display: flex; align-items: center; justify-content: space-between; margin: 10px 4px 2px; }
.sm-edit { width: 32px; height: 32px; padding: 0; display: grid; place-items: center; border-radius: 9px; background: transparent; color: var(--muted); }
.sm-edit:hover { background: var(--panel2); color: var(--accent2); }
.sm-view-box { padding: 12px 14px; }
.sm-view { max-height: 360px; overflow-y: auto; font-size: 14px; line-height: 1.55; }
.sm-view p { margin: 0 0 4px; }
.sm-view strong { color: var(--text); font-weight: 700; }
.sm-view ul { margin: 2px 0 10px; padding-left: 20px; }
.sm-view li { margin: 3px 0; }
.sm-view li::marker { color: var(--accent2); }
.sm-resum { width: 100%; margin-top: 10px; padding: 9px; font-size: 13px; border-radius: 10px; color: #fff; background: linear-gradient(135deg, rgba(148,64,253,.55), rgba(204,71,250,.4)); display: flex; align-items: center; justify-content: center; gap: 8px; }
.sm-resum:hover { filter: brightness(1.12); }
.spinner-sm { width: 14px; height: 14px; border-width: 2px; display: inline-block; }

/* Messages hors RP (HRP / OOC) */
.msg.ooc { background: transparent !important; border: 1px dashed var(--line); color: var(--muted); font-size: 14px; font-family: system-ui, sans-serif; }
.msg.assistant.ooc { border-color: rgba(204,71,250,.45); }
.hrp-badge { display: inline-block; font-size: 10px; font-weight: 800; letter-spacing: .06em; color: #fff; background: var(--accent); border-radius: 6px; padding: 1px 6px; margin-right: 8px; vertical-align: 1px; font-family: system-ui, sans-serif; }
.hrp-badge.soft { background: transparent; color: var(--accent2); border: 1px solid var(--accent); font-weight: 600; letter-spacing: 0; }
.hrp-note { color: var(--muted); font-style: italic; font-size: .92em; }

/* En-tete des reponses : avatar + nom + modele */
.msg-head { display: flex; align-items: center; gap: 8px; margin: -2px 0 6px; font-family: system-ui, sans-serif; font-size: 13px; }
.mh-av { width: 26px; height: 26px; border-radius: 50%; overflow: hidden; display: grid; place-items: center; background: var(--panel2); flex-shrink: 0; font-size: 14px; }
.mh-av img { width: 100%; height: 100%; object-fit: cover; }
.msg-head b { font-weight: 700; }
.mh-model { background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.08); color: var(--muted); font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 7px; }
.mh-model:hover { color: #fff; border-color: var(--accent); }
.cpn-model-label { margin-left: auto; font-size: 12px; color: var(--accent2); font-weight: 600; }
.cpn-model-label + .chev { margin-left: 6px; }

/* Fenetre "Changer de modele" */
.mm-card { width: min(980px, 100%); max-height: 88vh; display: flex; flex-direction: column; gap: 12px; padding: 22px; }
.mm-head { display: flex; align-items: center; gap: 12px; }
.mm-head h2 { margin: 0; font-size: 20px; display: flex; align-items: center; gap: 10px; }
.mm-nf { font-size: 11px; font-weight: 700; color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent2)); border-radius: 999px; padding: 2px 9px; }
.mm-search { max-width: 300px; margin: 0; border-radius: 10px; }
.mm-tabs { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--panel2); border-radius: 999px; padding: 4px; gap: 4px; }
.mm-tab { background: transparent; border-radius: 999px; font-size: 14px; color: var(--muted); display: flex; align-items: center; justify-content: center; gap: 6px; }
.mm-tab.active { background: linear-gradient(135deg, rgba(148,64,253,.35), rgba(204,71,250,.2)); color: #fff; }
.tier-badge { font-size: 10px; font-weight: 800; border-radius: 6px; padding: 1px 6px; color: #111; }
.tier-badge.free { background: #3ddc84; } .tier-badge.pro { background: #f4c542; } .tier-badge.ultra { background: linear-gradient(135deg, #b18cff, #ff7ad9); color: #fff; }
.mm-body { display: grid; grid-template-columns: 290px 1fr; gap: 14px; min-height: 0; flex: 1; }
.mm-list { display: flex; flex-direction: column; gap: 8px; overflow-y: auto; max-height: 52vh; }
.mm-item { text-align: left; background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 4px; font-weight: 400; }
.mm-item b { font-size: 15px; }
.mm-item small { color: var(--muted); font-size: 12px; }
.mm-item.active { border-color: var(--accent); background: linear-gradient(135deg, rgba(148,64,253,.2), rgba(204,71,250,.08)); }
.mm-badge { align-self: flex-start; font-size: 11px; font-weight: 700; color: #fff; background: rgba(204,71,250,.35); border: 1px solid var(--accent); border-radius: 6px; padding: 0 7px; }
.mm-detail { overflow-y: auto; max-height: 52vh; }
.mm-card-detail { background: var(--panel2); border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.mm-dhead { display: flex; align-items: center; gap: 10px; }
.mm-dhead h3 { margin: 0; font-size: 19px; }
.mm-creator { color: #f4c542; font-size: 13px; margin-top: 2px; }
.mm-stats { display: flex; gap: 16px; font-size: 13px; color: var(--muted); margin: 10px 0 6px; flex-wrap: wrap; }
.mm-desc { color: var(--muted); font-size: 13px; line-height: 1.5; margin: 0 0 12px; }
.mm-variants { display: flex; flex-direction: column; gap: 8px; }
.mm-variant { display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto; align-items: center; text-align: left; gap: 2px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; font-weight: 400; }
.mm-variant small { grid-column: 1; color: var(--muted); font-size: 12px; }
.mm-variant .spd { grid-row: 1 / span 2; grid-column: 2; }
.mm-variant.selected { border-color: var(--accent2); box-shadow: 0 0 0 1px var(--accent2) inset; background: linear-gradient(135deg, rgba(148,64,253,.22), rgba(204,71,250,.1)); }
.mm-variant.locked { opacity: .55; cursor: not-allowed; }
.mm-foot { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.mm-selected { background: var(--panel2); border-radius: 10px; padding: 9px 14px; font-size: 14px; }
.mm-selected span { color: var(--accent2); font-weight: 700; }
.mm-note { max-width: 300px; font-size: 12px; }
/* vitesse : 3 barres */
.spd { display: inline-flex; align-items: flex-end; gap: 2px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.spd i { width: 3px; background: currentColor; border-radius: 1px; opacity: .35; }
.spd i:nth-child(1) { height: 5px; } .spd i:nth-child(2) { height: 8px; } .spd i:nth-child(3) { height: 11px; margin-right: 4px; }
.spd.fast { color: #3ddc84; } .spd.fast i { opacity: 1; }
.spd.mid { color: #f4c542; } .spd.mid i:nth-child(-n+2) { opacity: 1; }
.spd.slow { color: var(--danger); } .spd.slow i:nth-child(1) { opacity: 1; }
.spd.none { color: var(--muted); }
@media (max-width: 820px) {
  .mm-body { grid-template-columns: 1fr; } .mm-list { max-height: 28vh; } .mm-search { max-width: 160px; }
}

/* Menu contextuel des messages */
.ctx-menu { position: fixed; z-index: 70; min-width: 170px; background: #17181c; border: 1px solid rgba(255,255,255,.12); border-radius: 12px; padding: 6px; box-shadow: 0 14px 40px rgba(0,0,0,.55); animation: ddIn .12s ease; }
.ctx-menu button { width: 100%; display: flex; align-items: center; gap: 10px; background: transparent; color: #eee; font-size: 14px; font-weight: 600; padding: 9px 10px; border-radius: 8px; text-align: left; }
.ctx-menu button + button { border-top: 1px solid rgba(255,255,255,.07); border-radius: 0 0 8px 8px; }
.ctx-menu button:hover { background: rgba(148,64,253,.22); }
.ctx-menu svg { flex-shrink: 0; opacity: .85; }
.msg.ctx-open { box-shadow: 0 0 0 2px var(--accent2); }
/* Edition d'un message dans sa bulle */
.msg-edit textarea { width: 100%; min-height: 120px; margin: 0; resize: vertical; font: inherit; line-height: 1.5; background: rgba(0,0,0,.25); }
.msg-edit .sm-foot { padding: 8px 0 0; }

/* Fond du chat sur 2 couches (remplace les regles precedentes) */
.chat-bg { filter: none !important; transform: none !important; overflow: hidden; }
.chat-bg .bg-blur, .chat-bg .bg-sharp { position: absolute; inset: 0; background-size: cover; background-position: center; background-repeat: no-repeat; }
.chat-bg .bg-sharp { display: none; }
/* Avatar flou : seulement la couche floutee */
.chat.bg-avatar .bg-blur { filter: blur(22px) brightness(.4) saturate(1.2); transform: scale(1.1); }
/* Image nette (paysage) : plein ecran, assombrie */
.chat.bg-image .bg-blur { display: none; }
.chat.bg-image .bg-sharp { display: block; filter: brightness(.45); }
/* Image nette en PORTRAIT : entiere et nette au centre, la meme floutee sur les cotes */
.chat.bg-image.bg-portrait .bg-blur { display: block; filter: blur(24px) brightness(.35) saturate(1.15); transform: scale(1.12); }
.chat.bg-image.bg-portrait .bg-sharp { background-size: contain; filter: brightness(.6); box-shadow: 0 0 80px rgba(0,0,0,.6); }

.sm-view p.sm-char { margin: 0 0 10px; }
.sm-view p.sm-char strong { color: var(--accent2); }

/* Narration : chaque action / pensee / replique sur sa ligne, paragraphes espaces */
.rp-seg { display: block; }
.rp-seg + .rp-seg { margin-top: .35em; }
.rp-para + .rp-para { margin-top: .8em; }

/* Coeur qui suit la ligne en cours d'ecriture */
.pen-heart { display: inline-block; margin-left: .3em; color: var(--accent, #b06bff); font-style: normal; font-weight: 400;
  animation: pen-beat .9s ease-in-out infinite; transform-origin: center; }
.pen-heart.solo { margin: 0; font-size: 1.1em; }
@keyframes pen-beat { 0%, 100% { transform: scale(1); opacity: .75; } 40% { transform: scale(1.3); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .pen-heart { animation: none; } }
