  :root {
    --bg: #0e0e10; --surface: #18181b; --surface-2: #1f1f23; --surface-3: #2a2a30; --inset: rgba(0,0,0,.28);
    --border: #2a2a2e; --border-strong: #3a3a40; --text: #efeff1; --text-muted: #adadb8; --text-dim: #6b6b75;
    --accent: #9147ff; --accent-hover: #7d3ae0; --accent-soft: #bf94ff; --on-accent: #fff;
    --live: #ff4d6d; --live-soft: rgba(255,77,109,.5); --live-tint: rgba(255,77,109,.07); --ok: #3ddc97; --warn: #f5a623; --warn-soft: rgba(245,166,35,.35);
    --shadow: 0 10px 30px rgba(0,0,0,.35); --glow: rgba(145,71,255,.45); --radius: 14px; color-scheme: dark;
  }
  :root[data-theme="light"] {
    --bg: #f4f4f7; --surface: #fff; --surface-2: #f0eff5; --surface-3: #e6e4ee; --inset: rgba(0,0,0,.045);
    --border: #e2e1e8; --border-strong: #cfcdd8; --text: #17171c; --text-muted: #5c5b66; --text-dim: #9391a0;
    --accent: #7c3aed; --accent-hover: #6b2fd6; --accent-soft: #6d3be0; --live: #e6294f; --live-soft: rgba(230,41,79,.45); --live-tint: rgba(230,41,79,.06);
    --ok: #16a273; --warn: #d98c00; --warn-soft: rgba(217,140,0,.4); --shadow: 0 10px 30px rgba(20,16,40,.08); --glow: rgba(124,58,237,.3); color-scheme: light;
  }
  * { box-sizing: border-box; }
  html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 -apple-system, "SF Pro Text", "Segoe UI", system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
  body { padding: 24px clamp(14px, 4vw, 48px) 60px; max-width: 1180px; margin: 0 auto; }
  a { color: var(--accent-soft); text-decoration: none; }
  button { font: inherit; color: var(--text); background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 8px 14px; cursor: pointer; transition: background .15s, border-color .15s, transform .1s, color .15s; }
  button:hover { background: var(--surface-3); border-color: var(--border-strong); }
  button:active { transform: scale(.97); }
  button.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
  button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
  button.ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
  button.ghost:hover { color: var(--text); background: var(--surface-2); border-color: transparent; }
  button.icon { padding: 6px 9px; line-height: 1; }
  button:disabled { opacity: .5; cursor: default; }

  header { display: flex; align-items: center; justify-content: space-between; gap: 14px 24px; flex-wrap: wrap; margin-bottom: 22px; }
  .bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-left: auto; }
  .bar .sep { width: 1px; height: 22px; background: var(--border); margin: 0 4px; }
  .bar > *, .bar button, .bar .pill, .bar .coffee { height: 36px; line-height: normal; }
  .bar a { display: inline-flex; }
  .bar a > button { height: 36px; }
  .bar .pill { padding: 0 12px; }
  .bar .icon { width: 36px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
  .brand { display: flex; align-items: center; gap: 12px; }
  .brand .logo { font-size: 30px; line-height: 1; filter: drop-shadow(0 0 12px var(--glow)); }
  .brand h1 { margin: 0; font-size: 20px; font-weight: 650; letter-spacing: -.01em; }
  .brand p { margin: 0; font-size: 13px; color: var(--text-muted); }
  .pill { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); font-size: 13px; color: var(--text-muted); }
  .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-dim); flex: none; }
  .dot.ok { background: var(--ok); color: var(--ok); animation: ping 2.4s infinite; }
  .dot.warn { background: var(--warn); }
  .dot.live { background: var(--live); color: var(--live); animation: ping 1.6s infinite; }
  .dot.wait { background: var(--text-dim); animation: breathe 1.4s ease-in-out infinite; }
  .chip.pending .n { color: var(--text-muted); }
  .sec-head .count .dot { display: inline-block; vertical-align: middle; margin-right: 4px; }
  @keyframes breathe { 0%, 100% { opacity: .25; } 50% { opacity: 1; } }
  .actions { display: flex; gap: 8px; flex-wrap: wrap; }

  .hero { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 44px 18px 20px; margin-bottom: 30px; display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
  .hero .close { position: absolute; top: 8px; right: 8px; opacity: .6; }
  .hero .close:hover { opacity: 1; }
  .hero[hidden] { display: none; }
  .hero p { margin: 0; color: var(--text-muted); font-size: 14px; max-width: 640px; }
  .hero p b { color: var(--text); }
  .hero .cta { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; margin-left: auto; }
  .hero .cta small { color: var(--text-dim); font-size: 12px; }
  .hero.granted .cta { display: none; }

  section { margin-bottom: 36px; }
  .sec-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 14px; }
  .sec-head h2 { margin: 0; font-size: 13px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted); }
  .sec-head .count { font-size: 12px; color: var(--text-dim); }
  .sec-head .spacer { flex: 1; }

  .cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
  #live { min-height: 232px; }
  #history { min-height: 132px; }
  .empty { min-height: 232px; display: flex; flex-direction: column; justify-content: center; }
  .card { position: relative; overflow: hidden; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 18px 16px; box-shadow: var(--shadow); transition: opacity .25s, transform .25s; }
  .card.enter { animation: rise .45s cubic-bezier(.2,.8,.2,1) both; }
  .card.leaving { opacity: 0; transform: scale(.97); }
  .card::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: linear-gradient(var(--live), var(--accent)); }
  .card .top { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
  .avatar { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-weight: 700; font-size: 17px; color: var(--on-accent); background: var(--accent); flex: none; text-transform: uppercase; }
  .card .name { font-weight: 650; font-size: 17px; }
  .card .since { font-size: 13px; color: var(--text-muted); display: flex; align-items: center; gap: 6px; }
  .card .since b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
  .card .quote { margin: 0 0 14px; padding: 10px 12px; border-radius: 10px; background: var(--inset); border: 1px solid var(--border); font-size: 14px; overflow-wrap: anywhere; cursor: pointer; }
  .card .quote:empty { display: none; }
  .card .quote .txt { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .card .quote.open .txt { display: block; }
  .card .quote small { display: block; margin-top: 4px; color: var(--text-dim); font-size: 12px; }
  .card .foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; color: var(--text-muted); }
  .card .foot .spacer { flex: 1; }
  .empty { border: 1px dashed var(--border); border-radius: var(--radius); padding: 30px 20px; text-align: center; color: var(--text-muted); }
  .empty .rat { font-size: 34px; display: inline-block; animation: sniff 3s ease-in-out infinite; }
  .empty p { margin: 8px 0 0; font-size: 14px; }

  .list { display: flex; flex-direction: column; gap: 6px; }
  .row { display: grid; grid-template-columns: 58px 1fr; gap: 12px; align-items: center; padding: 11px 14px; border-radius: 11px; background: var(--surface); border: 1px solid var(--border); }
  .row.enter { animation: rise .35s ease both; }
  .row .t { font-variant-numeric: tabular-nums; color: var(--text-muted); font-size: 13px; }
  .row .m { min-width: 0; }
  .row .m .l1 { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
  .row .m .l1 a { font-weight: 600; color: var(--text); }
  .row .m .l1 a:hover { color: var(--accent-soft); }
  .row .m .l2 { color: var(--text-muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tag { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-muted); }
  .tag.live { color: var(--live); border-color: var(--live-soft); }
  .tag.test { color: var(--warn); border-color: var(--warn-soft); }

  .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
  .chip { display: flex; align-items: center; gap: 9px; padding: 9px 11px; border-radius: 11px; background: var(--surface); border: 1px solid var(--border); font-size: 13.5px; transition: border-color .2s, background .2s, color .2s; }
  .chip .n { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: inherit; }
  .chip .n:hover { color: var(--accent-soft); text-decoration: underline; }
  .chip .r { font-size: 11.5px; color: var(--text-dim); font-variant-numeric: tabular-nums; white-space: nowrap; }
  .chip.quiet, .chip.quiet .n { color: var(--text-dim); }
  .chip.active { border-color: var(--live-soft); background: var(--live-tint); }
  .chip.active .n { color: var(--text); font-weight: 600; }

  #toasts { position: fixed; right: 14px; top: 14px; left: 14px; display: flex; flex-direction: column; gap: 10px; z-index: 10; pointer-events: none; }
  .toast { pointer-events: auto; margin-left: auto; display: flex; gap: 12px; align-items: center; background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--live); border-radius: 12px; padding: 12px 14px; box-shadow: var(--shadow); max-width: 360px; cursor: pointer; animation: slide .35s cubic-bezier(.2,.8,.2,1) both; }
  .toast.out { animation: fade .3s ease both; }
  .toast .b { font-size: 14px; }
  .toast .b b { display: block; }
  .toast .b span { color: var(--text-muted); font-size: 13px; }

  details.how { margin-bottom: 36px; color: var(--text-muted); font-size: 14px; }
  details.how summary { cursor: pointer; color: var(--text); font-weight: 600; }
  details.how ul { padding-left: 18px; margin: 10px 0 0; }
  details.how li { margin: 4px 0; }
  footer { margin-top: 20px; color: var(--text-dim); font-size: 12.5px; display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
  footer a { color: var(--text-muted); }

  @keyframes rise { from { opacity: 0; transform: translateY(10px) scale(.985); } to { opacity: 1; transform: none; } }
  @keyframes slide { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }
  @keyframes fade { to { opacity: 0; transform: translateY(-6px); } }
  @keyframes ping { 0% { box-shadow: 0 0 0 0 currentColor; } 70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
  @keyframes sniff { 0%, 100% { transform: rotate(-4deg); } 50% { transform: rotate(4deg) translateY(-2px); } }
  @media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
  @media (max-width: 560px) { .row { grid-template-columns: 1fr; } .row .t { display: none; } .hero .cta { margin-left: 0; } }
  /* ── ajouts ── */
  .pill.good { color: var(--ok); border-color: rgba(61,220,151,.35); }
  .pill.bad { color: var(--warn); border-color: var(--warn-soft); }
  .row { grid-template-columns: 58px 1fr auto; }
  .row .x button { opacity: .55; }
  .row:hover .x button { opacity: 1; }
  .chip .x { display: none; background: none; border: 0; color: var(--text-dim); padding: 0 2px; cursor: pointer; font-size: 13px; }
  .chip:hover .x { display: inline; }
  .chip .x:hover { color: var(--live); }
  .chip.custom { border-style: dashed; border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--surface)); }
  .chip.custom .n::after { content: " ✦"; color: var(--accent-soft); font-size: 10px; }
  form.add { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
  form.add input { font: inherit; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); min-width: 240px; flex: 1; max-width: 360px; }
  form.add input:focus { outline: none; border-color: var(--accent); }
  form.add small { width: 100%; color: var(--text-dim); font-size: 12px; }
  @media (max-width: 560px) { .row { grid-template-columns: 1fr auto; } .chip .x { display: inline; } }

  /* ── header commun ── */
  a.brand { color: inherit; }
  .actions a { display: inline-flex; }
  .coffee { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 10px; color: var(--text-dim); font-size: 16px; text-decoration: none; transition: color .15s, background .15s; }
  .coffee:hover { color: var(--warn); background: var(--surface-2); }
  main { margin: 0 auto; }
  /* ── rat qui trottine ── */
  .empty .rat { display: inline-block; animation: trot 6s ease-in-out infinite; }
  @keyframes trot {
    0%   { transform: translateX(-28px) scaleX(-1) rotate(-3deg); }
    10%  { transform: translateX(-24px) scaleX(-1) rotate(4deg) translateY(-2px); }
    20%  { transform: translateX(-12px) scaleX(-1) rotate(-3deg); }
    30%  { transform: translateX(0) scaleX(-1) rotate(4deg) translateY(-2px); }
    40%  { transform: translateX(14px) scaleX(-1) rotate(-3deg); }
    48%  { transform: translateX(28px) scaleX(-1) rotate(0); }
    52%  { transform: translateX(28px) scaleX(1) rotate(0); }
    60%  { transform: translateX(24px) scaleX(1) rotate(4deg) translateY(-2px); }
    70%  { transform: translateX(12px) scaleX(1) rotate(-3deg); }
    80%  { transform: translateX(0) scaleX(1) rotate(4deg) translateY(-2px); }
    90%  { transform: translateX(-14px) scaleX(1) rotate(-3deg); }
    98%  { transform: translateX(-28px) scaleX(1) rotate(0); }
    100% { transform: translateX(-28px) scaleX(-1) rotate(-3deg); }
  }
  /* ── historique : texte complet au survol ── */
  .row .m .l2 { transition: white-space 0s; }
  .row:hover .m .l2 { white-space: normal; overflow: visible; }
  @media (max-width: 760px) { header { flex-direction: column; align-items: stretch; } .bar { margin-left: 0; } .bar .sep { display: none; } }

  /* ── disposition : contenu + panneau des chaînes à droite ── */
  .layout { display: flex; gap: 28px; align-items: flex-start; }
  .layout main { flex: 1; min-width: 0; }
  #side { width: 360px; flex: none; position: sticky; top: 16px; display: flex; flex-direction: column; max-height: calc(100vh - 32px); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
  #side .grid { grid-template-columns: 1fr; gap: 6px; overflow-y: auto; max-height: 520px; min-height: 0; padding-right: 4px; scrollbar-width: thin; }
  #side .chip { padding: 8px 12px; font-size: 14px; }
  #side .chip .x { display: inline; opacity: 0; }
  #side .chip:hover .x { opacity: 1; }
  #side form.add { margin: 0 0 14px; }
  #side form.add input { min-width: 0; max-width: none; }
  @media (max-width: 980px) {
    .layout { flex-direction: column; }
    #side { width: 100%; position: static; max-height: none; }
    #side .grid { grid-template-columns: 1fr 1fr; max-height: 360px; }
    #side .chip .x { opacity: 1; }
  }
  /* ── infobulles custom (data-tip), instantanées ── */
  [data-tip] { position: relative; }
  [data-tip] { overflow: visible; }
  [data-tip]::after { content: attr(data-tip); position: absolute; top: calc(100% + 8px); right: 0; z-index: 30; background: var(--text); color: var(--bg); font-size: 12.5px; line-height: 1.35; padding: 6px 10px; border-radius: 8px; white-space: normal; width: max-content; max-width: min(280px, 80vw); text-align: left; box-shadow: var(--shadow); opacity: 0; transform: translateY(-4px); pointer-events: none; transition: opacity .12s, transform .12s; }
  [data-tip]:hover::after, [data-tip]:focus-visible::after { opacity: 1; transform: none; transition-delay: .08s; }
  .brand [data-tip]::after, .hero [data-tip]::after { right: auto; left: 0; }
