/* Hub Kyara — PWA (Étape 5). Thème sombre repris de l'ancien site de collection. */
:root {
  --bg: #0b0b0e;
  --panel: #15151a;
  --inset: #0f0f14;
  --line: #24242e;
  --text: #f4f4f7;
  --muted: #8a8a9c;
  --mythic: #ff4d2e;
  --legendary: #f5c518;
  --ok: #4caf50;
  --warn: #f5a623;
  --ko: #f44336;
  --accent: #ff4d2e;
  --radius: 14px;
  --nav-h: 64px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, Menlo, Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(900px 420px at 90% -80px, rgba(255, 77, 46, .10), transparent 70%), var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font: 16px/1.45 var(--font);
}
a { color: inherit; }
h1 { font-size: 1.5rem; margin: 0 0 16px; }
h2 { font-size: 1.1rem; margin: 24px 0 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
p { margin: 0 0 12px; }
small { color: var(--muted); }
[hidden] { display: none !important; }

/* ---------- Structure ---------- */
.app { max-width: 1100px; margin: 0 auto; padding: 16px 16px calc(var(--nav-h) + 32px + env(safe-area-inset-bottom)); }
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top));
  background: rgba(11, 11, 14, .97); /* pas de backdrop-filter : il piégerait la nav fixe du bas */
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; font-weight: 800; letter-spacing: .02em; }
.top-actions { margin-left: auto; display: flex; gap: 8px; }
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: space-around;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--panel); border-top: 1px solid var(--line);
}
.nav a {
  position: relative; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  text-decoration: none; color: var(--muted); font-size: .72rem; min-width: 0;
}
.nav a .ico { font-size: 1.3rem; line-height: 1; }
.nav a.active { color: var(--text); }
.nav a.active .ico { transform: scale(1.1); }
.badge-count {
  position: absolute; top: 6px; left: calc(50% + 6px);
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--accent); color: #fff; font-size: .7rem; line-height: 18px; text-align: center;
}
@media (min-width: 760px) {
  .nav { position: static; height: auto; padding: 0; background: none; border: 0; justify-content: flex-start; gap: 4px; margin-left: 16px; }
  .nav a { flex: none; flex-direction: row; gap: 6px; padding: 8px 12px; border-radius: 10px; font-size: .9rem; }
  .nav a.active { background: var(--panel); }
  .nav a .ico { font-size: 1rem; }
  .badge-count { position: static; }
  .app { padding-bottom: 48px; }
}
@media (max-width: 420px) { .brand span { display: none; } }

/* ---------- Composants ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 10px 16px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--inset); color: var(--text);
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn:hover { border-color: #3a3a48; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.ghost { background: transparent; }
.btn.small { min-height: 34px; padding: 6px 10px; font-size: .85rem; border-radius: 10px; }
.btn.danger { color: var(--ko); }
.btn.ok { color: var(--ok); }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.spacer { flex: 1; }

input[type=text], input[type=search], input[type=password], select, textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--inset); color: var(--text); font: inherit;
}
textarea { resize: vertical; min-height: 80px; }
input:focus-visible, select:focus-visible, textarea:focus-visible, .btn:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; margin-bottom: 6px; color: var(--muted); font-size: .9rem; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600; background: var(--inset); border: 1px solid var(--line); white-space: nowrap; }
.chip::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.chip.ok::before { background: var(--ok); }
.chip.warn::before { background: var(--warn); }
.chip.ko::before { background: var(--ko); }
.tag { margin-left: 8px; font-size: .75rem; color: var(--muted); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; }
.err { color: var(--ko); }
.loading { color: var(--muted); padding: 24px 0; text-align: center; }
.empty { color: var(--muted); text-align: center; padding: 32px 0; }
.notice { display: block; padding: 12px 14px; margin-bottom: 8px; border-radius: 12px; background: rgba(255, 77, 46, .12); border: 1px solid rgba(255, 77, 46, .35); text-decoration: none; font-weight: 600; }
.tip { color: var(--muted); font-size: .9rem; margin-top: 24px; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 50;
  bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom));
  max-width: calc(100% - 32px); padding: 12px 16px; border-radius: 12px;
  background: #2a2a34; border: 1px solid var(--line); box-shadow: 0 8px 30px rgba(0, 0, 0, .5);
}
.toast.ko { border-color: var(--ko); }
@media (min-width: 760px) { .toast { bottom: 24px; } }

/* ---------- Connexion ---------- */
.login-wrap { max-width: 380px; margin: 8vh auto 0; text-align: center; }
.login-wrap img { width: 72px; height: 72px; }
.login-wrap h1 { margin: 12px 0 24px; }
.login { text-align: left; }
.login .btn { width: 100%; margin-top: 8px; }

/* ---------- Comptes ---------- */
.accounts { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); }
.account { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.account-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; font-size: .9rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.account .btn { align-self: flex-start; }
.switch-row { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 12px; background: var(--inset); border: 1px solid var(--line); cursor: pointer; }
.switch-row > span:first-child { flex: 1; display: flex; flex-direction: column; }
.switch { position: relative; width: 52px; height: 30px; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.slider { position: absolute; inset: 0; border-radius: 15px; background: #3a3a48; transition: background .2s; pointer-events: none; }
.slider::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .2s; }
.switch input:checked + .slider { background: var(--ok); }
.switch input:checked + .slider::after { transform: translateX(22px); }
.switch input:focus-visible + .slider { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Modale d'appairage ---------- */
dialog {
  width: min(560px, calc(100% - 32px)); max-height: calc(100% - 32px); padding: 0;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); color: var(--text);
}
dialog::backdrop { background: rgba(0, 0, 0, .65); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); }
.modal-head h2 { margin: 0; color: var(--text); text-transform: none; letter-spacing: 0; font-size: 1.1rem; }
.modal-body { padding: 16px; }
.steps { padding-left: 20px; margin: 0 0 16px; }
.steps li { margin-bottom: 10px; }
.bookmarklet {
  display: inline-block; padding: 12px 16px; border-radius: 12px; border: 2px dashed var(--legendary);
  color: var(--legendary); font-weight: 700; text-decoration: none; cursor: grab; user-select: none;
}
.tabs { display: flex; gap: 4px; margin-bottom: 16px; background: var(--inset); padding: 4px; border-radius: 12px; }
.tabs button { flex: 1; min-height: 40px; border: 0; border-radius: 9px; background: none; color: var(--muted); font: inherit; font-weight: 600; cursor: pointer; }
.tabs button[aria-selected=true] { background: var(--panel); color: var(--text); }
.live { margin-top: 16px; padding: 12px; border-radius: 12px; background: var(--inset); display: flex; flex-direction: column; gap: 6px; }
code.copy { display: block; word-break: break-all; font: .75rem var(--mono); color: var(--muted); max-height: 90px; overflow: auto; padding: 8px; border-radius: 8px; background: var(--bg); user-select: all; }

/* ---------- Collection ---------- */
.page-head { display: flex; flex-direction: column; gap: 2px; margin-bottom: 14px; }
.page-head.row { flex-direction: row; align-items: center; }
.page-head h1 { margin: 0; }

.avatar {
  --hue: 10;
  display: inline-grid; place-items: center; flex: none;
  width: 26px; height: 26px; border-radius: 50%;
  background: hsl(var(--hue) 70% 45%); color: #fff;
  font: 800 .8rem var(--font); text-shadow: 0 1px 2px rgba(0, 0, 0, .35);
}
.players { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 6px; margin-bottom: 14px; scrollbar-width: thin; }
.players a {
  flex: none; display: flex; align-items: center; gap: 8px; padding: 6px 14px 6px 6px; border-radius: 999px;
  background: var(--panel); border: 1px solid var(--line); text-decoration: none; font-weight: 600;
  transition: border-color .15s, background .15s;
}
.players a:hover { border-color: #3a3a48; }
.players a.active { border-color: var(--accent); background: rgba(255, 77, 46, .14); }
.players small { color: var(--muted); font-weight: 600; }

.stats { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: 16px; }
.stat {
  display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: var(--radius);
  background: var(--panel); border: 1px solid var(--line);
}
.stat strong { display: block; font-size: 1.05rem; }
.stat.clickable { cursor: pointer; transition: border-color .15s, transform .15s; }
.stat.clickable:hover { border-color: #3a3a48; transform: translateY(-1px); }
.ring {
  --p: 0; --c: var(--accent);
  flex: none; width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(var(--c) calc(var(--p) * 1%), var(--inset) 0);
  position: relative;
}
.ring::before { content: ""; position: absolute; inset: 5px; border-radius: 50%; background: var(--panel); }
.ring span { position: relative; font: 700 .72rem var(--mono); }
.ring.r-all { --c: linear-gradient(var(--legendary), var(--mythic)); background: conic-gradient(var(--legendary), var(--mythic) calc(var(--p) * 1%), var(--inset) 0); }
.ring.r-mythique { --c: var(--mythic); }
.ring.r-legendaire { --c: var(--legendary); }
.ring.num { background: var(--inset); }
.ring.num span { font-size: 1.05rem; }
.ring.r-dbl span { color: #7cc4ff; }
.ring.r-want span { color: var(--legendary); }

.filterbar {
  display: grid; gap: 8px; margin: 0 0 16px; padding: 10px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
}
.filter-row { display: grid; gap: 8px; grid-template-columns: 1fr 1fr; }
.filter-row input { grid-column: 1 / -1; }
.filter-row select { min-height: 40px; padding: 6px 10px; }
.filter-segs { display: grid; gap: 8px; grid-template-columns: 1fr; }
.filter-foot { display: flex; align-items: center; gap: 8px; min-height: 34px; }
@media (min-width: 760px) {
  /* sur ordinateur seulement : barre de filtres qui reste visible en défilant */
  .filterbar { position: sticky; top: 61px; z-index: 5; background: rgba(21, 21, 26, .97); }
  .filter-row { grid-template-columns: 2fr 1fr 1fr; }
  .filter-row input { grid-column: auto; }
  .filter-segs { grid-template-columns: 1fr 1.4fr; }
}
.seg { display: flex; gap: 4px; background: var(--inset); padding: 4px; border-radius: 12px; overflow-x: auto; }
.seg button { flex: 1; min-height: 34px; border: 0; border-radius: 9px; background: none; color: var(--muted); font: inherit; font-size: .88rem; font-weight: 600; cursor: pointer; white-space: nowrap; padding: 0 10px; }
.seg button.active { background: var(--panel); color: var(--text); box-shadow: 0 1px 0 rgba(255, 255, 255, .04), 0 2px 8px rgba(0, 0, 0, .3); }

/* Cartes */
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
@media (min-width: 760px) { .grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; } }
.grid-empty { grid-column: 1 / -1; }
.card {
  --rc: var(--line);
  position: relative; display: flex; flex-direction: column; overflow: hidden; cursor: pointer;
  border-radius: var(--radius); background: var(--panel);
  border: 1px solid var(--rc);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s;
}
.card.r-mythique { --rc: rgba(255, 77, 46, .55); }
.card.r-legendaire { --rc: rgba(245, 197, 24, .5); }
.card:hover, .card:focus-visible { transform: translateY(-3px); box-shadow: 0 10px 26px rgba(0, 0, 0, .45), 0 0 0 1px var(--rc); outline: none; }
.card.r-mythique:hover, .card.r-mythique:focus-visible { box-shadow: 0 10px 28px rgba(255, 77, 46, .28), 0 0 0 1px var(--rc); }
.card.r-legendaire:hover, .card.r-legendaire:focus-visible { box-shadow: 0 10px 28px rgba(245, 197, 24, .22), 0 0 0 1px var(--rc); }
.card.wanted { box-shadow: 0 0 0 2px var(--legendary); }
.card-img { position: relative; aspect-ratio: 16 / 15; background: radial-gradient(circle at 50% 30%, #1d1d24, var(--inset)); display: grid; place-items: center; overflow: hidden; }
.card-img img { width: 100%; height: 100%; object-fit: cover; transition: transform .3s ease; }
.card:hover .card-img img { transform: scale(1.04); }
/* reflet holographique sur les mythiques possédées */
.card.r-mythique:not(.missing) .card-img::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .3s;
  background: linear-gradient(115deg, transparent 30%, rgba(255, 140, 90, .25) 45%, rgba(255, 255, 255, .25) 50%, rgba(255, 200, 80, .2) 55%, transparent 70%);
  background-size: 250% 100%; animation: holo 2.6s linear infinite;
}
.card.r-mythique:not(.missing):hover .card-img::after { opacity: 1; }
@keyframes holo { from { background-position: 120% 0; } to { background-position: -120% 0; } }
@media (prefers-reduced-motion: reduce) { .card, .card-img img { transition: none; } .card-img::after { animation: none !important; } }
.noimg { font-size: 2rem; opacity: .4; }
.card .badge {
  position: absolute; top: 8px; right: 8px; width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center; font: 700 .78rem var(--mono);
  background: rgba(11, 11, 14, .85); border: 2px solid var(--muted);
}
.r-mythique .badge { border-color: var(--mythic); color: var(--mythic); }
.r-legendaire .badge { border-color: var(--legendary); color: var(--legendary); }
.qty-pill {
  position: absolute; top: 8px; left: 8px; padding: 2px 8px; border-radius: 999px;
  background: rgba(11, 11, 14, .85); font: 700 .8rem var(--mono); border: 1px solid var(--line);
}
.qty-pill.dbl { background: #1d4f7a; border-color: #4aa3e8; color: #fff; }
.lock {
  position: absolute; inset: 0; display: grid; place-items: center;
  font: 800 2.4rem var(--font); color: rgba(255, 255, 255, .35); background: rgba(11, 11, 14, .35);
}
.ribbon {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 4px 8px; text-align: center;
  font-size: .72rem; font-weight: 800; letter-spacing: .02em; text-transform: uppercase;
}
.ribbon.dbl { background: linear-gradient(transparent, rgba(29, 79, 122, .95)); color: #cfe8ff; padding-top: 14px; }
.ribbon.want { background: linear-gradient(transparent, rgba(160, 120, 0, .95)); color: #fff6cc; padding-top: 14px; }
.card.missing .card-img img { filter: grayscale(1) brightness(.45); }
.card.missing .card-body { opacity: .55; }
.card-body { padding: 9px 11px 11px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.card-name { font-size: .92rem; line-height: 1.25; overflow-wrap: anywhere; }
.card-body small { font-size: .75rem; }
.more { display: flex; justify-content: center; margin-top: 16px; }

/* Fiche d'une carte */
.card-detail { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 520px) { .card-detail { grid-template-columns: 200px 1fr; } }
.card-detail-img { position: relative; border-radius: var(--radius); overflow: hidden; aspect-ratio: 16 / 15; background: var(--inset); display: grid; place-items: center; border: 2px solid var(--line); }
.card-detail.r-mythique .card-detail-img { border-color: var(--mythic); box-shadow: 0 0 24px rgba(255, 77, 46, .25); }
.card-detail.r-legendaire .card-detail-img { border-color: var(--legendary); box-shadow: 0 0 24px rgba(245, 197, 24, .2); }
.card-detail-img img { width: 100%; height: 100%; object-fit: cover; }
.card-detail-img .badge { position: absolute; top: 8px; right: 8px; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font: 700 .8rem var(--mono); background: rgba(11, 11, 14, .85); border: 2px solid var(--muted); }
.card-detail.r-mythique .badge { border-color: var(--mythic); color: var(--mythic); }
.card-detail.r-legendaire .badge { border-color: var(--legendary); color: var(--legendary); }
.card-detail h3 { margin: 12px 0 8px; font-size: .85rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.owners { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.owners li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; background: var(--inset); }
.owners li.none { opacity: .5; }
.owners .who { flex: 1; font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.owners .btn { white-space: nowrap; }
.owners b { font-family: var(--mono); }
.tag-dbl, .tag-want {
  font-size: .68rem; font-weight: 800; text-transform: uppercase; letter-spacing: .02em;
  padding: 1px 6px; border-radius: 6px; white-space: nowrap;
}
.tag-dbl { background: #1d4f7a; color: #cfe8ff; }
.tag-want { background: rgba(245, 197, 24, .18); color: var(--legendary); }

/* ---------- Messages ---------- */
.convs { display: flex; flex-direction: column; gap: 8px; }
.conv { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 12px 14px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); text-decoration: none; }
.conv p { grid-column: 1 / -1; margin: 0; color: var(--muted); font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv time { color: var(--muted); font-size: .8rem; }
.conv.unread { border-color: rgba(255, 77, 46, .5); }
.conv .count { background: var(--accent); color: #fff; border-radius: 9px; padding: 0 7px; font-size: .75rem; margin-left: 8px; }
.thread-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.thread-head h1 { margin: 0; }
.thread { display: flex; flex-direction: column; gap: 8px; padding-bottom: 12px; }
.bubble { max-width: 82%; padding: 8px 12px; border-radius: 14px 14px 14px 4px; background: var(--panel); border: 1px solid var(--line); align-self: flex-start; }
.bubble.mine { align-self: flex-end; border-radius: 14px 14px 4px 14px; background: rgba(255, 77, 46, .16); border-color: rgba(255, 77, 46, .35); }
.bubble p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble time { display: block; font-size: .72rem; color: var(--muted); margin-top: 2px; }
.bubble a { font-size: .8rem; }
.composer { position: sticky; bottom: calc(var(--nav-h) + 8px + env(safe-area-inset-bottom)); display: flex; gap: 8px; align-items: flex-end; padding: 8px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line); }
.composer textarea { min-height: 44px; max-height: 160px; }
@media (min-width: 760px) { .composer { bottom: 8px; } }

/* ---------- Échanges ---------- */
.trades { display: flex; flex-direction: column; gap: 12px; }
.trade { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.trade-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.trade-sides { display: grid; gap: 10px; grid-template-columns: 1fr; }
@media (min-width: 600px) { .trade-sides { grid-template-columns: 1fr 1fr; } }
.trade-sides h3 { margin: 0 0 6px; font-size: .85rem; color: var(--muted); font-weight: 600; }
.minis { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.mini { display: flex; align-items: center; gap: 8px; padding: 6px; border-radius: 10px; background: var(--inset); }
.mini img, .mini .noimg { width: 36px; height: 36px; border-radius: 6px; object-fit: cover; flex: none; font-size: 1.1rem; display: grid; place-items: center; }
.mini span { flex: 1; min-width: 0; overflow-wrap: anywhere; font-size: .9rem; }
.mini b { font-family: var(--mono); }
.mini.r-mythique { box-shadow: inset 3px 0 0 var(--mythic); }
.mini.r-legendaire { box-shadow: inset 3px 0 0 var(--legendary); }
.quote { margin: 0; padding: 8px 12px; border-left: 3px solid var(--line); color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere; }
.picker { display: flex; flex-direction: column; gap: 8px; }
.results { display: flex; flex-direction: column; gap: 6px; max-height: 280px; overflow-y: auto; }
.results button.mini { border: 1px solid var(--line); color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.stepper { display: flex; align-items: center; gap: 4px; }
.stepper button { width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--text); font: inherit; cursor: pointer; }
.stepper b { min-width: 28px; text-align: center; }

/* Idées d'échange */
.ideas { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .ideas { grid-template-columns: 1fr 1fr; } }
.idea { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.idea.match { border-color: rgba(245, 197, 24, .45); background: linear-gradient(160deg, rgba(245, 197, 24, .07), var(--panel) 45%); }
.idea-head { display: flex; align-items: center; gap: 10px; }
.idea-head strong { font-size: 1.05rem; }
.match-tag { font-size: .75rem; font-weight: 800; color: var(--legendary); white-space: nowrap; }
.idea h3 { margin: 6px 0 0; font-size: .9rem; font-weight: 600; color: var(--muted); }
.idea h3 .big { color: var(--text); font: 800 1.1rem var(--mono); margin-right: 2px; }
.strip { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 8px; scroll-snap-type: x proximity; scrollbar-width: thin; }
.strip-empty { margin: 0; color: var(--muted); font-size: .85rem; padding: 6px 0; }
.strip-more { flex: none; align-self: center; padding: 6px 10px; border-radius: 999px; background: var(--inset); color: var(--muted); font-weight: 700; }
.thumb {
  flex: none; width: 92px; position: relative; padding: 0; border-radius: 10px; overflow: hidden; cursor: pointer;
  border: 1px solid var(--line); background: var(--inset); color: var(--text); font: inherit; scroll-snap-align: start;
  display: flex; flex-direction: column; transition: transform .15s;
}
.thumb:hover { transform: translateY(-2px); }
.thumb.r-mythique { border-color: rgba(255, 77, 46, .6); }
.thumb.r-legendaire { border-color: rgba(245, 197, 24, .55); }
.thumb img, .thumb .noimg { width: 100%; aspect-ratio: 16 / 15; object-fit: cover; display: grid; place-items: center; }
.thumb-q { position: absolute; top: 4px; left: 4px; padding: 1px 6px; border-radius: 999px; background: #1d4f7a; color: #fff; font: 700 .66rem var(--mono); }
.thumb-name { padding: 4px 6px 6px; font-size: .72rem; line-height: 1.2; text-align: left; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

/* Constructeur d'échange */
.trade-builder { display: grid; gap: 12px; grid-template-columns: 1fr; margin-top: 8px; }
@media (min-width: 900px) { .trade-builder { grid-template-columns: 1fr 1fr; } }
.trade-builder .side { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; min-width: 0; }
.trade-builder .side h2 { margin-top: 0; color: var(--text); text-transform: none; letter-spacing: 0; }
.trade-builder .give { box-shadow: inset 3px 0 0 #4aa3e8; }
.trade-builder .get { box-shadow: inset 3px 0 0 var(--legendary); }
.results-title { display: block; margin: 4px 0 2px; color: var(--muted); font-weight: 700; }
.mini-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; }
.mini > span:not(.stepper) { display: flex; flex-direction: column; }
.mini-empty { padding: 6px; }

/* ---------- Drops (canaux type Discord) ---------- */
.drops { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 760px) { .drops { grid-template-columns: 220px 1fr; align-items: start; } }
.channels {
  display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin;
}
.channels-title { display: none; }
@media (min-width: 760px) {
  .channels {
    position: sticky; top: 72px; flex-direction: column; overflow: visible; padding: 10px;
    background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  }
  .channels-title { display: block; padding: 4px 8px 6px; font-size: .72rem; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
}
.channel {
  flex: none; display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 10px;
  text-decoration: none; color: var(--muted); font-weight: 600; background: var(--panel); border: 1px solid var(--line);
}
@media (min-width: 760px) { .channel { background: none; border-color: transparent; } }
.channel:hover { color: var(--text); background: var(--inset); }
.channel.active { color: var(--text); background: rgba(255, 77, 46, .15); border-color: rgba(255, 77, 46, .35); }
.channel.unread { color: var(--text); }
.channel .avatar { width: 22px; height: 22px; font-size: .7rem; }
.ch-ico { width: 22px; text-align: center; }
.ch-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch-count { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--accent); color: #fff; font-size: .72rem; line-height: 20px; text-align: center; }

.drops-main { min-width: 0; }
.drops-head { display: flex; flex-direction: column; gap: 2px; margin-bottom: 8px; }
.drops-head h1 { margin: 0; }
.feed { display: flex; flex-direction: column; gap: 4px; padding-bottom: 12px; }
.day-sep { display: flex; align-items: center; gap: 10px; margin: 14px 0 6px; color: var(--muted); font-size: .78rem; font-weight: 700; text-transform: capitalize; }
.day-sep::before, .day-sep::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.post {
  position: relative; display: flex; gap: 12px; padding: 10px 12px; border-radius: 12px;
  border-left: 3px solid transparent; transition: background .15s;
}
.post:hover { background: var(--panel); }
.post .avatar { width: 38px; height: 38px; font-size: .95rem; margin-top: 2px; }
.avatar.bot { background: #2a2a34; }
.post-body { flex: 1; min-width: 0; }
.post-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px 8px; }
.post-head time { color: var(--muted); font-size: .75rem; }
.post-text { margin: 2px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.post-tag { font-size: .66rem; font-weight: 800; letter-spacing: .04em; padding: 1px 6px; border-radius: 6px; }
.post-tag.annonce { background: rgba(255, 77, 46, .2); color: var(--mythic); }
.post-tag.r-mythique { background: rgba(255, 77, 46, .2); color: var(--mythic); }
.post-tag.r-legendaire { background: rgba(245, 197, 24, .18); color: var(--legendary); }
.post.t-drop.r-mythique { border-left-color: var(--mythic); background: linear-gradient(90deg, rgba(255, 77, 46, .08), transparent 60%); }
.post.t-drop.r-legendaire { border-left-color: var(--legendary); background: linear-gradient(90deg, rgba(245, 197, 24, .07), transparent 60%); }
.post.t-alerte { border-left-color: var(--warn); }
.post.t-alerte .post-text { color: #ffd38a; }
.post.t-info .post-text { color: var(--muted); }
.post.t-annonce { border-left-color: var(--accent); background: var(--panel); }
.post-img {
  display: block; margin-top: 8px; padding: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
  background: var(--inset); cursor: zoom-in; max-width: min(420px, 100%);
}
.post-img img { display: block; width: 100%; height: auto; max-height: 320px; object-fit: contain; }
.post.r-mythique .post-img { border-color: rgba(255, 77, 46, .5); }
.post.r-legendaire .post-img { border-color: rgba(245, 197, 24, .45); }
.post-del {
  position: absolute; top: 8px; right: 8px; width: 28px; height: 28px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--inset); color: var(--muted); cursor: pointer; opacity: 0; transition: opacity .15s;
}
.post:hover .post-del, .post-del:focus-visible { opacity: 1; }
@media (pointer: coarse) { .post-del { opacity: .6; } }
.lightbox-img { display: block; width: 100%; height: auto; border-radius: 10px; }

/* ---------- Admin ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; background: var(--panel); position: sticky; top: 0; }
td.wrap { white-space: normal; min-width: 180px; color: var(--ko); }
tr.group td { background: var(--inset); font-weight: 700; }
.mini .mini-tags span, .mini .stepper { flex: none; }
.post:has(.post-del) { padding-right: 44px; }

/* ---------------------------------------------------------------------------
   Admin
   --------------------------------------------------------------------------- */
.admin-tabs { margin-bottom: 16px; }
.admin-body .tip { margin: 8px 0 12px; }
.admin-body h2 { font-size: 1.05rem; margin: 0 0 10px; }
.admin-actions { margin: -4px 0 4px; }
.admin-section { margin-top: 24px; }
.sub { display: block; color: var(--muted); font-size: .78rem; font-weight: 400; }
.sub.ko { color: var(--ko); }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: .85rem; word-break: break-all; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.row.nowrap { flex-wrap: nowrap; gap: 4px; }
td.wrap.plain { color: var(--text); }
.stat .chip { font-size: .85rem; }
.cmd-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.cmd-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); }
.cmd-list .sub { display: inline; }

.members { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); }
.member { display: flex; flex-direction: column; gap: 10px; }
.member.off { opacity: .65; }
.member-head { display: flex; align-items: center; gap: 10px; }
.member-actions { gap: 6px; }

.admin-forms { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); }
.admin-form h2 { margin-top: 0; }
.admin-form select, .admin-form input { width: 100%; }

.cred { display: grid; gap: 8px; grid-template-columns: 1fr 1fr; margin: 12px 0; }
.cred > div { padding: 10px; border-radius: 10px; background: var(--inset); border: 1px solid var(--line); }
.cred small { display: block; color: var(--muted); font-size: .78rem; }
.cred strong { font-size: 1.05rem; user-select: all; word-break: break-all; }
@media (max-width: 420px) { .cred { grid-template-columns: 1fr; } }

.bars { display: flex; align-items: flex-end; gap: 4px; height: 150px; margin: 14px 0 4px; padding: 10px 8px 0; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line); overflow-x: auto; }
.bar { flex: 1 0 22px; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 2px; }
.bar-fill { --h: 0%; display: block; width: 100%; max-width: 28px; height: calc(var(--h) * .75); min-height: 2px; border-radius: 6px 6px 0 0; background: var(--accent); }
.bar-n { font-size: .68rem; color: var(--muted); }
.bar small { font-size: .62rem; color: var(--muted); padding-bottom: 4px; white-space: nowrap; }
.stats-table th[scope=row] { position: sticky; left: 0; background: var(--panel); }
.stats-table td.zero { color: var(--warn); }
.stats-table td.has-err { color: var(--ko); font-weight: 700; }
.admin-tabs { flex-wrap: wrap; }
.admin-tabs button { flex: 1 0 auto; }
.accs { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 360px), 1fr)); margin-top: 12px; }
.acc-group { grid-column: 1 / -1; margin: 10px 0 0; font-size: .95rem; color: var(--muted); }
.acc { display: flex; flex-direction: column; gap: 8px; padding: 12px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line); }
.acc.current { border-color: rgba(76, 175, 80, .55); }
.acc.paused { opacity: .75; }
.acc-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.acc-facts { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: .85rem; color: var(--muted); }
.acc-facts b { color: var(--text); font-weight: 600; }
.acc-facts .ko, .acc-err { color: var(--ko); }
.acc-err { margin: 0; font-size: .8rem; word-break: break-word; }
.acc-actions { gap: 6px; }

/* ---------------------------------------------------------------------------
   Accueil : tableau de bord, alertes de comptes, mon compte, bandeau de mise à jour
   --------------------------------------------------------------------------- */
.home-stats { margin-top: 12px; }
.home-drops { margin-bottom: 18px; }
.home-drops h2 { margin: 0; font-size: 1.05rem; }
.home-drops .row { margin-bottom: 8px; }
.notice.warn-notice { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; justify-content: space-between; background: rgba(245, 166, 35, .12); border-color: rgba(245, 166, 35, .45); }
.facts dd.warn { color: var(--warn); font-weight: 600; }
.facts dd.ko { color: var(--ko); font-weight: 600; }
.facts dd .sub { margin-top: 2px; }
.home-me { margin-top: 24px; display: flex; flex-direction: column; gap: 10px; }
.home-me h2 { margin: 0; font-size: 1.05rem; }
.update-banner {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + 12px + env(safe-area-inset-bottom, 0px));
  z-index: 50; display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 16px; max-width: calc(100% - 32px);
  border-radius: 14px; background: var(--panel); border: 1px solid var(--accent); box-shadow: 0 8px 30px rgba(0, 0, 0, .5); font-weight: 600;
}
@media (min-width: 760px) { .update-banner { bottom: 20px; } }
.home-stats .stat strong { font-size: .95rem; overflow-wrap: anywhere; }
.home-push { margin-top: 24px; display: flex; flex-direction: column; gap: 10px; }
.home-push h2 { margin: 0; font-size: 1.05rem; }
.push-prefs { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.check-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; background: var(--inset); border: 1px solid var(--line); cursor: pointer; }
.check-row input { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }

/* ---------------------------------------------------------------------------
   Collection : groupe, souhaits, progression
   --------------------------------------------------------------------------- */
.players .group-link { border-style: dashed; }
.group-ava { display: grid; place-items: center; background: var(--inset); font-size: 1rem; }
.ribbon.wish { background: linear-gradient(transparent, rgba(107, 79, 216, .95)); color: #efeaff; padding-top: 14px; }
.coll-progress { margin: 0 0 16px; display: flex; flex-direction: column; gap: 8px; }
.coll-progress:empty { display: none; }
.coll-progress h2 { margin: 0; font-size: 1.05rem; }
.spark-wrap { padding: 8px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line); }
.spark { display: block; width: 100%; height: 120px; }
.spark-line { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.spark-area { fill: rgba(255, 77, 46, .12); stroke: none; }
.spark-dot { fill: var(--accent); }
.owners-mini { display: block; color: var(--muted); font-size: .7rem; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-detail-info .sub { margin: 4px 0; }

/* ---------------------------------------------------------------------------
   Drops : réactions, épinglé, filtres, annonce enrichie, classement
   --------------------------------------------------------------------------- */
.reacts { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-top: 6px; position: relative; }
.react {
  display: inline-flex; align-items: center; gap: 4px; min-height: 28px; padding: 2px 8px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--inset); color: var(--text); font: inherit; font-size: .85rem; cursor: pointer;
}
.react b { font-size: .75rem; color: var(--muted); }
.react.mine { border-color: rgba(255, 77, 46, .6); background: rgba(255, 77, 46, .12); }
.react.mine b { color: var(--text); }
.react.add { color: var(--muted); opacity: .7; }
.post:hover .react.add, .react.add:focus-visible { opacity: 1; }
.react-picker { display: flex; gap: 2px; padding: 4px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); box-shadow: 0 6px 20px rgba(0, 0, 0, .45); }
.react-picker[hidden] { display: none; }
.react-pick { width: 36px; height: 36px; border: 0; border-radius: 8px; background: none; font-size: 1.15rem; cursor: pointer; }
.react-pick:hover { background: var(--inset); }
.post-tag.pin { background: rgba(124, 196, 255, .15); color: #7cc4ff; }
.post-pin {
  position: absolute; top: 8px; right: 42px; width: 28px; height: 28px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--inset); cursor: pointer; opacity: 0; transition: opacity .15s;
}
.post:hover .post-pin, .post-pin:focus-visible { opacity: 1; }
@media (pointer: coarse) { .post-pin { opacity: .6; } }
.post:has(.post-pin) { padding-right: 76px; }
.pinned { margin: 0 0 12px; padding: 6px; border-radius: var(--radius); border: 1px solid rgba(124, 196, 255, .35); background: rgba(124, 196, 255, .05); }
.pinned > .sub { padding: 2px 8px; }
.drop-filters { margin: 0 0 10px; }
.drop-filters select { width: auto; }
.composer.composer-annonce { flex-direction: column; align-items: stretch; }
.composer-row { display: flex; gap: 8px; align-items: flex-end; }
.composer-row textarea { flex: 1; }
.composer-tools { gap: 6px; }
.composer-tools input[type=datetime-local] { width: auto; min-height: 34px; }
.scheduled:empty { display: none; }
.scheduled { display: flex; flex-direction: column; gap: 4px; }
.sched { display: flex; align-items: center; gap: 8px; justify-content: space-between; font-size: .82rem; padding: 4px 8px; border-radius: 8px; background: var(--inset); }
.rank { margin-top: 12px; }
.rank tr.me td { background: rgba(255, 77, 46, .08); }
.r-mythique-t { color: var(--mythic); font-weight: 700; }
.r-legendaire-t { color: var(--legendary); font-weight: 700; }
.drops-main > .scheduled { margin: 8px 0; }

/* Échanges : bilan, vérification, expiration, contre-proposition */
.trade-stats { display: flex; flex-direction: column; gap: 8px; margin: 0 0 12px; padding: 12px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line); }
.trade-stats .chip { gap: 6px; }
.trade-stats .chip::before { display: none; }
.trade-stats .avatar { width: 20px; height: 20px; font-size: .7rem; }
.ok-text { color: var(--ok); }
.warn-text { color: var(--warn); }
.notice.info-notice { background: rgba(124, 196, 255, .08); border-color: rgba(124, 196, 255, .35); font-weight: 500; }

/* Messages : groupe, réponse, carte jointe, actions, « vu », « écrit… » */
.conv.group { border-color: rgba(124, 196, 255, .35); }
.bubble { cursor: pointer; }
.bubble.deleted { opacity: .6; cursor: default; }
.bubble-who { display: block; font-size: .78rem; color: #7cc4ff; margin-bottom: 2px; }
.bubble-quote { margin: 0 0 6px; padding: 4px 8px; border-left: 3px solid var(--muted); border-radius: 4px; background: rgba(255, 255, 255, .04); font-size: .8rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.bubble-quote b { color: var(--text); }
.bubble-card { display: flex; align-items: center; gap: 8px; margin-top: 6px; padding: 4px; width: 100%; max-width: 260px; border-radius: 10px; border: 1px solid var(--line); background: var(--inset); color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.bubble-card.r-mythique { border-color: rgba(255, 77, 46, .55); }
.bubble-card.r-legendaire { border-color: rgba(245, 197, 24, .5); }
.bubble-card img, .bubble-card .noimg { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; flex: none; display: grid; place-items: center; }
.bubble-card span { display: flex; flex-direction: column; min-width: 0; }
.bubble-card small { color: var(--muted); font-size: .72rem; }
.bubble-actions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.bubble-actions[hidden] { display: none; }
.thread-status { min-height: 1.2em; margin: 0 0 6px; text-align: right; font-size: .78rem; color: var(--muted); display: flex; gap: 10px; justify-content: flex-end; }
.thread-status .typing { margin-right: auto; color: #7cc4ff; font-style: italic; }
.composer.composer-msg { flex-direction: column; align-items: stretch; }
.composer-msg .composer-row .btn.ghost { min-width: 44px; padding: 0 10px; }
.composer-extras { display: flex; flex-wrap: wrap; gap: 6px; }
.composer-extras:empty { display: none; }
.composer-extras .chip::before { display: none; }
.chip-x { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 0 0 0 4px; font: inherit; }
.result { display: flex; align-items: center; gap: 10px; padding: 6px; border-radius: 10px; border: 1px solid var(--line); background: var(--inset); color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.result img, .result .noimg { width: 40px; height: 40px; object-fit: cover; border-radius: 6px; flex: none; display: grid; place-items: center; }
.result.r-mythique { border-color: rgba(255, 77, 46, .45); }
.result.r-legendaire { border-color: rgba(245, 197, 24, .4); }
.result small { color: var(--muted); }

/* Admin : serveur, services, journal du bot ; page de maintenance */
.ring.r-ok { --c: var(--ok); }
.svc-list { display: grid; gap: 6px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); }
.svc { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 12px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); }
.log-filters { margin-bottom: 8px; }
.log-filters select, .log-filters input { width: auto; flex: 1 1 160px; }
.botlog { max-height: 420px; overflow: auto; padding: 8px; border-radius: var(--radius); background: #07070a; border: 1px solid var(--line); font: .74rem/1.45 var(--mono); }
.log-line { display: grid; grid-template-columns: auto auto 1fr; gap: 8px; padding: 1px 0; border-bottom: 1px solid rgba(255, 255, 255, .03); }
.log-line time { color: var(--muted); white-space: nowrap; }
.log-line b { font-weight: 700; }
.log-line span { overflow-wrap: anywhere; }
.log-line.lv-warning b, .log-line.lv-warning span { color: var(--warn); }
.log-line.lv-error b, .log-line.lv-error span, .log-line.lv-critical span { color: var(--ko); }
.panel.maintenance { text-align: center; max-width: 520px; margin: 40px auto; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.maint-ico { font-size: 3rem; }

/* ---------------------------------------------------------------------------
   Confort : thème clair, taille du texte
   --------------------------------------------------------------------------- */
:root[data-theme=light] {
  --bg: #f6f6f8;
  --panel: #ffffff;
  --inset: #eeeef2;
  --line: #dcdce4;
  --text: #16161c;
  --muted: #5d5d70;
  --legendary: #b88a00;
  color-scheme: light;
}
:root[data-theme=light] body { background: radial-gradient(900px 420px at 90% -80px, rgba(255, 77, 46, .08), transparent 70%), var(--bg); }
:root[data-theme=light] .topbar, :root[data-theme=light] .nav { background: rgba(255, 255, 255, .92); }
:root[data-theme=light] .botlog { background: #fbfbfd; }
:root[data-theme=light] .update-banner, :root[data-theme=light] .react-picker { box-shadow: 0 8px 30px rgba(0, 0, 0, .15); }
:root[data-size=grand] { font-size: 112.5%; }
:root[data-size=grand] body { font-size: 18px; }
:root[data-size=tres-grand] { font-size: 125%; }
:root[data-size=tres-grand] body { font-size: 20px; }
.prefs { display: grid; gap: 0 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); }
.prefs .field { margin-bottom: 0; }

/* Recherche globale */
.search-results { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; max-height: 60vh; overflow-y: auto; }
.search-results .result .avatar { width: 32px; height: 32px; }
.search-results .result small { color: var(--muted); }

/* Profil et badges */
.profile-head { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; }
.profile-id { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.profile-id .avatar { width: 56px; height: 56px; font-size: 1.4rem; }
.profile-id h1 { margin: 0; }
.bio { margin: 6px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.fav-card { display: flex; align-items: center; gap: 12px; padding: 8px; border-radius: 12px; border: 1px solid var(--line); background: var(--inset); color: var(--text); font: inherit; text-align: left; cursor: pointer; max-width: 360px; }
.fav-card.r-mythique { border-color: rgba(255, 77, 46, .55); }
.fav-card.r-legendaire { border-color: rgba(245, 197, 24, .5); }
.fav-card img, .fav-card .noimg { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; flex: none; display: grid; place-items: center; }
.fav-card span { display: flex; flex-direction: column; }
.fav-card small { color: var(--muted); font-size: .75rem; }
.badges { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); margin-bottom: 16px; }
.badge-item { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px 8px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line); text-align: center; opacity: .55; filter: grayscale(1); }
.badge-item.got { opacity: 1; filter: none; border-color: rgba(245, 197, 24, .45); }
.badge-emoji { font-size: 1.8rem; }
.badge-item small { color: var(--muted); font-size: .72rem; }
.badge-bar { display: block; width: 100%; height: 4px; border-radius: 4px; background: var(--inset); overflow: hidden; margin-top: 4px; }
.badge-bar i { --p: 0%; display: block; height: 100%; width: var(--p); background: var(--accent); }

/* Guide */
.guide-item { margin-bottom: 8px; padding: 0; }
.guide-item summary { padding: 14px 16px; cursor: pointer; font-weight: 600; }
.guide-item p { margin: 0; padding: 0 16px 14px; color: var(--muted); }

/* Hors ligne */
.offline-banner {
  position: fixed; left: 50%; transform: translateX(-50%); top: 8px; z-index: 60; padding: 8px 14px; border-radius: 999px;
  background: var(--panel); border: 1px solid var(--warn); color: var(--text); font-size: .85rem; font-weight: 600; box-shadow: 0 6px 20px rgba(0, 0, 0, .35);
}
.svc-list.health { margin-bottom: 8px; }
.svc span .sub { display: block; }

/* ===========================================================================
   Messages (refonte) : liste + conversation à défilement propre
   =========================================================================== */
.app:has(.view-chat) { padding-bottom: 0; }
body:has(.view-chat) { overflow: hidden; }
.chat-layout { display: grid; grid-template-columns: 1fr; gap: 16px; }
.chat-layout.has-thread .chat-list-box { display: none; }
.chat-layout:not(.has-thread) .chat-empty { display: none; }
@media (min-width: 900px) {
  .chat-layout { grid-template-columns: 320px 1fr; align-items: start; }
  .chat-layout.has-thread .chat-list-box { display: block; }
  .chat-layout:not(.has-thread) .chat-empty { display: flex; }
  .chat-list-box { position: sticky; top: 76px; max-height: calc(100vh - 100px); overflow-y: auto; }
  .chat-back { display: none !important; }
}

/* Liste des conversations */
.chat-convs { display: flex; flex-direction: column; gap: 10px; }
.chat-convs-head { display: flex; align-items: center; gap: 8px; }
.chat-convs-head h1 { margin: 0; }
.chat-convs-head select { width: auto; max-width: 55%; }
.conv-list { display: flex; flex-direction: column; gap: 4px; }
.conv-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 14px;
  color: var(--text); text-decoration: none; border: 1px solid transparent; transition: background .15s;
}
.conv-item:hover { background: var(--panel); }
.conv-item.active { background: var(--panel); border-color: var(--line); }
.conv-item .avatar { width: 46px; height: 46px; flex: none; font-size: 1.1rem; }
.conv-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.conv-top, .conv-bottom { display: flex; align-items: center; gap: 8px; }
.conv-top strong { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-top time { font-size: .75rem; color: var(--muted); flex: none; }
.conv-preview { flex: 1; min-width: 0; color: var(--muted); font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-item.unread .conv-preview { color: var(--text); font-weight: 600; }
.conv-item.unread .conv-top time { color: var(--accent); font-weight: 700; }
.conv-badge { flex: none; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--accent); color: #fff; font-size: .72rem; display: grid; place-items: center; }
.conv-fresh { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.conv-chip { gap: 6px; text-decoration: none; color: var(--text); }
.conv-chip::before { display: none; }
.conv-chip .avatar { width: 20px; height: 20px; font-size: .65rem; }
.chat-empty { min-height: 50vh; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); }
.chat-empty-ico { font-size: 3rem; }

/* Conversation */
.chat {
  --chat-h: 70vh;
  height: var(--chat-h); display: flex; flex-direction: column; overflow: hidden;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
}
.chat-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--panel); }
.chat-head .avatar { width: 38px; height: 38px; flex: none; }
.chat-back { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; color: var(--text); text-decoration: none; font-size: 1.2rem; }
.chat-back:hover { background: var(--inset); }
.chat-title { display: flex; flex-direction: column; min-width: 0; }
.chat-title strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-sub { color: var(--muted); font-size: .76rem; min-height: 1em; }
.chat-sub .typing { color: #7cc4ff; }
.dots { display: inline-flex; gap: 2px; margin-left: 4px; vertical-align: middle; }
.dots b { width: 4px; height: 4px; border-radius: 50%; background: currentColor; animation: dot 1.2s infinite ease-in-out; }
.dots b:nth-child(2) { animation-delay: .15s; }
.dots b:nth-child(3) { animation-delay: .3s; }
@keyframes dot { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-2px); } }
@media (prefers-reduced-motion: reduce) { .dots b { animation: none; } }
.chat-body { position: relative; flex: 1; min-height: 0; display: flex; }
.chat-scroll { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 8px 12px 12px; background: var(--bg); }
.chat-older-wrap { display: flex; justify-content: center; }
.chat-older-wrap .btn[hidden] { display: none; }
.chat-first { margin: 24px 0; }
.chat-msgs { display: flex; flex-direction: column; }
.chat-msgs .day-sep { margin: 14px 0 6px; }
.msg-row { display: flex; align-items: flex-end; gap: 6px; margin-top: 2px; }
.msg-row.gfirst { margin-top: 10px; }
.msg-row.mine { justify-content: flex-end; }
.msg-row .avatar, .avatar-spacer { width: 28px; height: 28px; flex: none; font-size: .7rem; }
.msg-col { display: flex; flex-direction: column; max-width: min(78%, 560px); }
.msg-row.mine .msg-col { align-items: flex-end; }
.msg-who { font-size: .74rem; color: #7cc4ff; margin: 0 0 2px 10px; font-weight: 600; }
.msg-time { font-size: .7rem; color: var(--muted); margin: 3px 8px 0; }
.msg-tick { color: var(--muted); }
.chat .bubble {
  max-width: 100%; align-self: auto; padding: 8px 12px; border-radius: 18px; border: 0; cursor: pointer;
  background: var(--inset); color: var(--text); box-shadow: 0 1px 0 rgba(0, 0, 0, .15);
}
.chat .bubble.mine { background: linear-gradient(135deg, #ff5a3c, #e8432a); color: #fff; }
.chat .bubble.theirs.first { border-bottom-left-radius: 6px; }
.chat .bubble.theirs.middle { border-top-left-radius: 6px; border-bottom-left-radius: 6px; }
.chat .bubble.theirs.last { border-top-left-radius: 6px; }
.chat .bubble.mine.first { border-bottom-right-radius: 6px; }
.chat .bubble.mine.middle { border-top-right-radius: 6px; border-bottom-right-radius: 6px; }
.chat .bubble.mine.last { border-top-right-radius: 6px; }
.chat .bubble p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.4; }
.chat .bubble.deleted { background: transparent; border: 1px dashed var(--line); color: var(--muted); box-shadow: none; cursor: default; }
.chat .bubble-quote { display: block; width: 100%; text-align: left; font: inherit; font-size: .8rem; cursor: pointer; border: 0; border-left: 3px solid #7cc4ff; }
.chat .bubble.mine .bubble-quote { background: rgba(0, 0, 0, .18); border-left-color: rgba(255, 255, 255, .7); color: rgba(255, 255, 255, .85); }
.chat .bubble.mine .bubble-quote b { color: #fff; }
.chat .bubble.mine .bubble-card { background: rgba(0, 0, 0, .2); border-color: rgba(255, 255, 255, .35); color: #fff; }
.chat .bubble.mine .bubble-card small { color: rgba(255, 255, 255, .8); }
.bubble-link { display: inline-block; margin-top: 4px; font-size: .8rem; color: inherit; opacity: .9; }
.chat .bubble.flash { animation: flash 1.4s ease-out; }
@keyframes flash { 0%, 40% { box-shadow: 0 0 0 3px #7cc4ff; } 100% { box-shadow: 0 1px 0 rgba(0, 0, 0, .15); } }
.msg-actions { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0 2px; }
.msg-actions button { min-height: 32px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); color: var(--text); font: inherit; font-size: .8rem; cursor: pointer; }
.msg-actions button.danger { color: var(--ko); }
.chat-new-pill {
  position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); z-index: 2;
  padding: 6px 14px; border-radius: 999px; border: 0; background: var(--accent); color: #fff; font: inherit; font-size: .82rem; font-weight: 700;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .35); cursor: pointer;
}
.chat-new-pill[hidden] { display: none; }

/* Barre de saisie */
.chat-input { display: flex; flex-direction: column; gap: 6px; padding: 8px 10px; border-top: 1px solid var(--line); background: var(--panel); }
.chat-input-row { display: flex; align-items: flex-end; gap: 8px; }
.chat-input textarea {
  flex: 1; min-height: 42px; max-height: 140px; resize: none; padding: 10px 14px; border-radius: 21px; line-height: 1.35;
  background: var(--inset); border: 1px solid var(--line);
}
.chat-attach, .chat-send { flex: none; width: 42px; height: 42px; border-radius: 50%; border: 0; display: grid; place-items: center; cursor: pointer; font-size: 1.1rem; }
.chat-attach { background: var(--inset); color: var(--text); }
.chat-send { background: var(--accent); color: #fff; }
.chat-send:disabled { opacity: .5; cursor: default; }
.extra-chip::before { display: none; }
.extra-chip { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
