:root {
  --bg: #0b0d12;
  --bg-2: #12151d;
  --bg-3: #191d27;
  --line: #262b38;
  --text: #e9ecf3;
  --muted: #8a92a6;
  --accent: #ff3b5c;
  --accent-2: #ff7a3b;
  --ok: #34d399;
  --warn: #fbbf24;
  --err: #f87171;
  --info: #60a5fa;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  font-family: "Segoe UI", system-ui, -apple-system, Inter, Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); min-height: 100%; }
body { font-size: 15px; line-height: 1.45; }
a { color: inherit; text-decoration: none; }
.hidden { display: none !important; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--err); min-height: 1.2em; margin: 6px 0 0; font-size: 13px; }
code, .mono { font-family: Consolas, "Cascadia Mono", Menlo, monospace; font-size: 13px; }
p code { word-break: break-all; }

/* ---------- Marque ---------- */
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; letter-spacing: .3px; font-size: 16px; }
.brand b { color: var(--accent); font-weight: 800; }
.brand.big { font-size: 26px; margin-bottom: 4px; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px rgba(255, 59, 92, .18); display: inline-block; }

/* ---------- Connexion ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(1200px 600px at 20% -10%, rgba(255, 59, 92, .18), transparent 60%), radial-gradient(900px 500px at 100% 100%, rgba(255, 122, 59, .12), transparent 60%), var(--bg); }
.login-card { width: min(380px, 100%); background: var(--bg-2); border: 1px solid var(--line); border-radius: 20px; padding: 32px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 12px; }

/* ---------- Structure ---------- */
.app { display: grid; grid-template-columns: 1fr 320px; grid-template-rows: 60px auto 1fr; min-height: 100vh; }
.topbar { grid-column: 1 / -1; display: flex; align-items: center; gap: 28px; padding: 0 24px; border-bottom: 1px solid var(--line); background: rgba(11, 13, 18, .85); backdrop-filter: blur(10px); position: sticky; top: 0; z-index: 10; }
.topbar nav { display: flex; gap: 4px; }
.topbar nav a { padding: 8px 14px; border-radius: 10px; color: var(--muted); font-weight: 500; }
.topbar nav a:hover { color: var(--text); background: var(--bg-3); }
.topbar nav a.active { color: var(--text); background: var(--bg-3); }
.status { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.pill { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; background: var(--bg-3); border: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.pill .led { width: 8px; height: 8px; border-radius: 50%; background: var(--err); box-shadow: 0 0 8px var(--err); }
.pill.on { color: var(--text); }
.pill.on .led { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
main { padding: 28px 32px 60px; min-width: 0; }
.ticker { border-left: 1px solid var(--line); background: var(--bg-2); padding: 18px; position: sticky; top: 60px; align-self: start; max-height: calc(100vh - 60px); overflow: auto; }
.ticker-head { display: flex; justify-content: space-between; align-items: center; font-weight: 600; margin-bottom: 12px; }
.ticker ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.ticker li { background: var(--bg-3); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 13px; animation: pop .25s ease; }
.ticker li .t { color: var(--muted); font-size: 12px; display: flex; justify-content: space-between; gap: 8px; }
@keyframes pop { from { transform: translateY(-6px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (max-width: 1000px) {
  .app { grid-template-columns: 1fr; }
  .ticker { display: none; }
  main { padding: 20px 16px 60px; }
  .topbar { gap: 12px; padding: 0 14px; }
}

/* ---------- Composants ---------- */
h1 { font-size: 26px; margin: 0 0 6px; letter-spacing: -.3px; }
h2 { font-size: 18px; margin: 0 0 10px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.btn { border: 1px solid var(--line); background: var(--bg-3); color: var(--text); padding: 9px 16px; border-radius: 10px; font-size: 14px; font-weight: 600; cursor: pointer; transition: .15s; display: inline-flex; align-items: center; gap: 8px; }
.btn:hover { border-color: #3a4152; background: #202634; }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border-color: transparent; color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--err); }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.link { background: none; border: 0; color: var(--accent); cursor: pointer; font-size: 13px; padding: 0; }
input, textarea, select { width: 100%; background: var(--bg); border: 1px solid var(--line); color: var(--text); padding: 10px 12px; border-radius: 10px; font: inherit; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255, 59, 92, .15); }
textarea { min-height: 80px; resize: vertical; }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field { margin-bottom: 14px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.switch { position: relative; width: 42px; height: 24px; background: var(--line); border-radius: 999px; cursor: pointer; transition: .2s; flex: none; border: 0; padding: 0; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: .2s; }
.switch.on { background: var(--ok); }
.switch.on::after { left: 21px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--bg-3); border: 1px solid var(--line); color: var(--muted); }
.chip.live { background: rgba(255, 59, 92, .15); border-color: rgba(255, 59, 92, .4); color: var(--accent); }
.chip.ok { color: var(--ok); } .chip.warn { color: var(--warn); } .chip.err { color: var(--err); } .chip.info { color: var(--info); }
.card { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-2 > * { min-width: 0; }
.copy { min-width: 0; }
@media (max-width: 800px) { .grid-2, .row { grid-template-columns: 1fr; } }
.empty { text-align: center; color: var(--muted); padding: 40px 20px; border: 1px dashed var(--line); border-radius: var(--radius); }
.kv { display: grid; grid-template-columns: 180px 1fr; gap: 8px 16px; align-items: center; font-size: 14px; }
.copy { display: flex; gap: 8px; align-items: center; }
.copy code { flex: 1; background: var(--bg); border: 1px solid var(--line); padding: 8px 10px; border-radius: 8px; overflow: auto; white-space: nowrap; }

/* ---------- Bibliothèque ---------- */
.games { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 20px; }
.game-card { position: relative; border-radius: var(--radius); overflow: hidden; background: var(--bg-2); border: 1px solid var(--line); cursor: pointer; transition: transform .15s, border-color .15s, box-shadow .15s; display: flex; flex-direction: column; }
.game-card:hover { transform: translateY(-3px); border-color: #3a4152; box-shadow: var(--shadow); }
.game-card .cover { aspect-ratio: 460 / 215; background: var(--bg-3); position: relative; overflow: hidden; }
.game-card .cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.game-card .cover .fallback { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 800; font-size: 22px; text-align: center; padding: 20px; color: #fff; }
.game-card .body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 6px; }
.game-card .name { font-weight: 700; font-size: 16px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.game-card .meta { color: var(--muted); font-size: 13px; }
.game-card.off { opacity: .55; }
.game-card.add { border-style: dashed; align-items: center; justify-content: center; min-height: 200px; color: var(--muted); font-weight: 600; background: transparent; }
.game-card.add:hover { color: var(--text); }

/* ---------- Page jeu ---------- */
.hero { position: relative; border-radius: 20px; overflow: hidden; min-height: 220px; border: 1px solid var(--line); margin-bottom: 24px; background: var(--bg-2); }
.hero img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; filter: blur(18px) brightness(.45) saturate(1.2); transform: scale(1.1); }
.hero .inner { position: relative; display: flex; gap: 24px; padding: 24px; align-items: flex-end; flex-wrap: wrap; }
.hero .poster { width: 260px; aspect-ratio: 460 / 215; border-radius: 12px; overflow: hidden; border: 1px solid rgba(255, 255, 255, .15); background: var(--bg-3); box-shadow: var(--shadow); flex: none; }
.hero .poster .cover { height: 100%; }
.hero .poster img { position: static; filter: none; transform: none; width: 100%; height: 100%; object-fit: cover; display: block; }
.hero .info { flex: 1; min-width: 240px; }
.hero .info p { color: #c7cbd6; margin: 6px 0 14px; max-width: 640px; }
.hero .tools { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.actions { display: flex; flex-direction: column; gap: 10px; }
.action { display: grid; grid-template-columns: auto 1fr auto; gap: 16px; align-items: center; background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.action.off { opacity: .55; }
.action .num { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-weight: 800; background: var(--bg-3); color: var(--muted); font-size: 13px; }
.action .title { font-weight: 700; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.action .desc { color: var(--muted); font-size: 13px; margin-top: 2px; }
.action .triggers { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.action .tools { display: flex; gap: 8px; align-items: center; }
@media (max-width: 700px) { .action { grid-template-columns: 1fr; } .action .num { display: none; } }
.trigger-row { display: grid; grid-template-columns: 130px 1fr 90px 90px auto; gap: 8px; align-items: center; margin-bottom: 8px; }
@media (max-width: 700px) { .trigger-row { grid-template-columns: 1fr 1fr; } }

/* ---------- Journal ---------- */
.log { display: flex; flex-direction: column; gap: 6px; }
.log-row { display: grid; grid-template-columns: 90px 110px 1fr auto; gap: 12px; align-items: center; padding: 10px 14px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; font-size: 14px; }
.log-row .time { color: var(--muted); font-size: 13px; }
.log-row .who { color: var(--muted); font-size: 13px; }
@media (max-width: 800px) { .log-row { grid-template-columns: 1fr auto; } .log-row .who { display: none; } }
.status-chip { min-width: 90px; justify-content: center; }

/* ---------- Modale ---------- */
.modal { position: fixed; inset: 0; background: rgba(0, 0, 0, .6); display: grid; place-items: center; z-index: 50; padding: 20px; backdrop-filter: blur(4px); }
.modal-card { width: min(640px, 100%); max-height: 90vh; overflow: auto; background: var(--bg-2); border: 1px solid var(--line); border-radius: 18px; padding: 24px; box-shadow: var(--shadow); }
.modal-card h2 { margin-bottom: 16px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.modal-foot .spacer { flex: 1; }

/* ---------- Toasts ---------- */
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: var(--bg-3); border: 1px solid var(--line); padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow); font-size: 14px; animation: pop .2s ease; }
.toast.ok { border-color: rgba(52, 211, 153, .5); } .toast.err { border-color: rgba(248, 113, 113, .5); }

/* ---------- Paramètres ---------- */
.steps { counter-reset: s; display: flex; flex-direction: column; gap: 12px; margin: 0; padding: 0; list-style: none; }
.steps li { counter-increment: s; display: grid; grid-template-columns: 30px 1fr; gap: 12px; align-items: start; }
.steps li::before { content: counter(s); width: 26px; height: 26px; border-radius: 8px; background: var(--bg-3); display: grid; place-items: center; font-weight: 800; font-size: 13px; color: var(--accent); }
pre { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 12px; overflow: auto; font-size: 13px; margin: 8px 0 0; }

/* ---------- Paramètres d'action & URL ---------- */
.action .url { margin-top: 8px; min-width: 0; }
.action .url code { display: block; background: var(--bg); border: 1px solid var(--line); padding: 6px 10px; border-radius: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); cursor: copy; font-size: 12px; }
.action .url code:hover { color: var(--text); border-color: #3a4152; }
.param-row { display: grid; grid-template-columns: 200px 1fr auto; gap: 8px; align-items: center; margin-bottom: 8px; }
@media (max-width: 700px) { .param-row { grid-template-columns: 1fr 1fr auto; } }
.url-preview { flex: 1; background: var(--bg); border: 1px solid var(--line); padding: 8px 10px; border-radius: 8px; word-break: break-all; font-size: 12px; color: var(--text); }
details.raw { margin-top: 4px; }
details.raw summary { cursor: pointer; color: var(--accent); font-size: 12px; }
details.raw pre { margin-top: 6px; max-height: 220px; font-size: 12px; }
.copy code.url-preview { white-space: normal; overflow: visible; }

/* ---------- Webhooks : rubriques, paramètres en ligne ---------- */
.group-head { margin: 14px 0 2px; font-size: 12px; font-weight: 800; letter-spacing: 1.2px; text-transform: uppercase; color: var(--muted); display: flex; align-items: center; gap: 10px; }
.group-head::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.actions > .group-head:first-child { margin-top: 0; }
.action .fields { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; align-items: center; }
.feditor { display: inline-flex; align-items: center; gap: 8px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 4px 6px 4px 12px; margin: 0; font-size: 13px; color: var(--text); }
.feditor .flabel { color: var(--muted); font-weight: 600; white-space: nowrap; }
.feditor input, .feditor select { width: auto; padding: 5px 8px; border-radius: 7px; font-size: 14px; font-weight: 700; background: var(--bg-3); }
.feditor.number input { width: 96px; text-align: right; }
.feditor.text input { width: 150px; font-weight: 500; }
.feditor.select select { max-width: 220px; }
.feditor .funit { color: var(--muted); font-weight: 600; }
.switch.small { width: 36px; height: 20px; }
.switch.small::after { width: 14px; height: 14px; }
.switch.small.on::after { left: 19px; }
.action .url { position: relative; }
.saved { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); background: var(--bg); padding: 0 8px; font-size: 12px; color: var(--ok); font-weight: 700; opacity: 0; transition: opacity .3s; white-space: nowrap; pointer-events: none; }
.saved.show { opacity: 1; }
details.adv { margin-top: 14px; }
details.adv summary { cursor: pointer; color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.kv a.btn { display: inline-flex; }

/* ---------- Bandeau d'état (jeu, plugin, agent) ---------- */
.statusband { grid-column: 1 / -1; display: flex; gap: 12px; align-items: stretch; flex-wrap: wrap;
  padding: 14px 32px; border-bottom: 1px solid var(--line); background: linear-gradient(180deg, var(--bg-2), var(--bg)); }
.statusband:empty { display: none; }
.stat { display: flex; align-items: center; gap: 11px; padding: 11px 16px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--bg-3); min-width: 0; }
.stat .big-led { width: 14px; height: 14px; border-radius: 50%; background: var(--muted); flex: none; }
.stat .txt { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stat .lbl { font-size: 11px; letter-spacing: 1.1px; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.stat .val { font-size: 15px; font-weight: 800; white-space: nowrap; }
.stat .sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 430px; }
.stat.ok { border-color: rgba(52,211,153,.5); background: rgba(52,211,153,.10); }
.stat.ok .big-led { background: var(--ok); box-shadow: 0 0 12px var(--ok); animation: pulse 2s infinite; }
.stat.ok .val { color: var(--ok); }
.stat.warn { border-color: rgba(251,191,36,.55); background: rgba(251,191,36,.10); }
.stat.warn .big-led { background: var(--warn); box-shadow: 0 0 12px var(--warn); }
.stat.warn .val { color: var(--warn); }
.stat.err { border-color: rgba(248,113,113,.5); background: rgba(248,113,113,.08); }
.stat.err .big-led { background: var(--err); }
.stat.err .val { color: var(--err); }
.stat.off .val { color: var(--muted); }
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .45 } }
.statusband .spacer { flex: 1; min-width: 0; }
.modeswitch { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg-3); }
.modeswitch .lbl { font-size: 11px; letter-spacing: 1.1px; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.segmented { display: inline-flex; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 3px; }
.segmented button { border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 13px; font-weight: 700;
  padding: 6px 14px; border-radius: 8px; cursor: pointer; white-space: nowrap; }
.segmented button.on { background: var(--accent); color: #fff; }
.segmented button:not(.on):hover { color: var(--text); background: var(--bg-3); }
.install-log { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-top: 12px;
  font-family: Consolas, monospace; font-size: 12px; max-height: 260px; overflow: auto; white-space: pre-wrap; }
@media (max-width: 900px) { .statusband { padding: 12px 16px; } .stat .val { white-space: normal; } }

/* ---------- Nouveautés / journal des versions ---------- */
.notes { max-height: 55vh; overflow: auto; }
.note { border-left: 3px solid var(--accent); padding: 2px 0 2px 14px; margin-bottom: 18px; }
.note-head { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; margin-bottom: 6px; }
.note-ver { font-weight: 800; font-size: 15px; }
.note-title { color: var(--accent); font-weight: 600; font-size: 14px; }
.note-date { color: var(--muted); font-size: 12px; margin-left: auto; }
.note-list { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.note-list li { font-size: 14px; line-height: 1.5; }
