:root {
  --bg: #0f0f13; --panel: #18181f; --panel2: #20202a; --line: #2c2c38;
  --text: #ececf1; --muted: #9b9bab; --accent: #ff4f8b; --accent2: #ff7aa8;
  --ok: #3ccf8e; --bad: #ff5d5d; --warn: #ffb547; --radius: 14px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 Inter, system-ui, -apple-system, Segoe UI, sans-serif; }
a { color: var(--accent2); }
.wrap { max-width: 860px; margin: 0 auto; padding: 32px 16px 80px; }
.wrap.wide { max-width: 1280px; }
h1 { font-size: 26px; margin: 0 0 6px; letter-spacing: -.02em; }
h2 { font-size: 20px; margin: 0 0 12px; }
h3 { font-size: 16px; margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; margin-bottom: 16px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
label { display: block; font-size: 13px; color: var(--muted); margin: 14px 0 6px; }
input, textarea, select { width: 100%; background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 11px 13px; font: inherit; outline: none; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 90px; }
button { background: var(--accent); color: #fff; border: 0; border-radius: 10px; padding: 11px 18px; font: inherit; font-weight: 600; cursor: pointer; }
button:hover { background: var(--accent2); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.ghost { background: transparent; border: 1px solid var(--line); color: var(--text); }
button.ghost:hover { border-color: var(--accent); }
button.small { padding: 7px 12px; font-size: 13px; }
.err { color: var(--bad); margin-top: 10px; min-height: 1em; }

/* Étapes */
.steps { display: flex; gap: 8px; margin: 18px 0 24px; }
.step { flex: 1; padding: 10px 12px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.step b { display: block; color: var(--text); font-size: 14px; }
.step.active { border-color: var(--accent); }
.step.done { border-color: var(--ok); }
.step.done b::after { content: ' ✓'; color: var(--ok); }

/* Test de connexion */
.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 18px 0; }
.metric { background: var(--panel2); border-radius: 12px; padding: 14px; text-align: center; border: 1px solid var(--line); }
.metric .v { font-size: 24px; font-weight: 700; }
.metric .l { font-size: 12px; color: var(--muted); }
.metric.ok { border-color: var(--ok); } .metric.bad { border-color: var(--bad); }
.bar { height: 6px; background: var(--panel2); border-radius: 6px; overflow: hidden; margin-top: 12px; }
.bar > div { height: 100%; width: 0; background: var(--accent); transition: width .3s; }

/* QCM */
.q { padding: 14px 0; border-bottom: 1px solid var(--line); }
.q:last-child { border-bottom: 0; }
.q p { margin: 0 0 8px; font-weight: 600; }
.opt { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 8px; cursor: pointer; color: var(--text); margin: 0; font-size: 14px; }
.opt:hover { background: var(--panel2); }
.opt input { width: auto; }
.timer { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 10px 0; font-weight: 700; }
.timer.low { color: var(--bad); }

/* Chat */
.fans { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.fan { background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 16px; cursor: pointer; }
.fan:hover { border-color: var(--accent); }
.fan.done { opacity: .6; cursor: default; border-color: var(--ok); }
.fan .tag { font-size: 12px; color: var(--muted); }
.badge { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 99px; background: var(--line); color: var(--text); }
.badge.ok { background: rgba(60,207,142,.18); color: var(--ok); }
.badge.bad { background: rgba(255,93,93,.18); color: var(--bad); }
.badge.warn { background: rgba(255,181,71,.18); color: var(--warn); }
.persona { background: var(--panel2); border-left: 3px solid var(--accent); padding: 12px 14px; border-radius: 8px; font-size: 14px; }
.chatbox { height: 420px; overflow-y: auto; padding: 16px; background: var(--panel2); border-radius: 12px; display: flex; flex-direction: column; gap: 8px; margin: 14px 0; }
.bubble { max-width: 75%; padding: 9px 13px; border-radius: 16px; white-space: pre-wrap; word-wrap: break-word; }
.bubble.fan { align-self: flex-start; background: #2d2d3a; border-bottom-left-radius: 4px; }
.bubble.chatter { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.bubble.ppv { background: #6b3cff; }
.bubble .ppvtag { font-size: 12px; font-weight: 700; display: block; margin-bottom: 3px; opacity: .9; }
.typing { align-self: flex-start; color: var(--muted); font-size: 13px; font-style: italic; }
.ppvform { display: none; gap: 8px; margin-bottom: 8px; }
.ppvform.show { display: flex; }
.ppvform input[type=number] { width: 110px; flex: none; }

/* Admin */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--panel2); }
.score { font-weight: 700; }
.tablewrap { overflow-x: auto; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 16px; }
.drawer { position: fixed; inset: 0 0 0 auto; width: min(720px, 100%); background: var(--bg); border-left: 1px solid var(--line); overflow-y: auto; padding: 24px; transform: translateX(100%); transition: transform .25s; z-index: 20; }
.drawer.open { transform: none; }
.grades { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin: 10px 0; }
.grades div { background: var(--panel2); border-radius: 8px; padding: 8px; text-align: center; font-size: 12px; color: var(--muted); }
.grades b { display: block; font-size: 18px; color: var(--text); }

@media (max-width: 640px) {
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .steps { flex-direction: column; }
  .grades { grid-template-columns: repeat(3, 1fr); }
  .bubble { max-width: 88%; }
}

/* Boîte de réception multi-fans */
.wrap:has(.inbox) { max-width: 1180px; }
.inbox { display: grid; grid-template-columns: 280px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); height: min(68vh, 640px); border: 1px solid var(--line); border-radius: 12px; overflow: clip; }
.fanlist { border-right: 1px solid var(--line); overflow-y: auto; background: var(--panel2); min-height: 0; }
.fanitem { padding: 12px 14px; border-bottom: 1px solid var(--line); cursor: pointer; }
.fanitem:hover { background: #262632; }
.fanitem.sel { background: #2d2338; border-left: 3px solid var(--accent); padding-left: 11px; }
.fanitem.gone { opacity: .55; }
.fanitem .preview { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 3px; }
.badge.unread { background: var(--accent); color: #fff; font-weight: 700; }
.convpane { display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; }
.convhead { padding: 12px 16px; border-bottom: 1px solid var(--line); }
.convpane .chatbox { flex: 1 1 0; height: auto; min-height: 0; }
.composer { padding: 12px; border-top: 1px solid var(--line); }
.composer textarea { width: 100%; }
.sysmsg { align-self: center; font-size: 12px; color: var(--muted); background: var(--panel); padding: 4px 10px; border-radius: 99px; }
@media (max-width: 760px) {
  .inbox { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto; height: auto; }
  .fanlist { max-height: 210px; border-right: 0; border-bottom: 1px solid var(--line); }
  .convpane .chatbox { height: 340px; flex: none; }
}
