:root {
  --bg: #f3f4f8; --panel: #ffffff; --panel2: #eef0f5; --text: #14161c; --muted: #5d6370; --border: #dde1e8;
  --accent: #3b6cf6; --accent-text: #fff; --danger: #d93a3a; --ok: #1f8f4e; --input: #ffffff; --side-active: #e6ebf7;
  --series-1: #2a78d6;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111827; --panel: #1f2937; --panel2: #2b3544; --text: #f3f4f6; --muted: #9ca3af; --border: #374151;
    --input: #374151; --side-active: #374151; --ok: #3ccf7a; --danger: #f05252; --series-1: #3987e5;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 "Segoe UI", system-ui, sans-serif; }
a { color: var(--accent); }
code { background: var(--panel2); padding: 1px 5px; border-radius: 4px; font-size: 13px; }

/* Structure */
.top { display: flex; align-items: center; gap: 12px; padding: 10px 20px; background: var(--panel); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.top .brand { font-weight: 700; text-decoration: none; color: var(--text); }
.top .guild { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top .me { margin-left: auto; display: flex; align-items: center; gap: 8px; font-size: 14px; }
.top .me img { width: 26px; height: 26px; border-radius: 50%; }
.btn.discord { background: #5865f2; color: #fff; }
.layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: calc(100vh - 53px); }
.side { background: var(--panel); border-right: 1px solid var(--border); padding: 12px 10px; }
.side a { display: flex; gap: 10px; align-items: center; padding: 8px 12px; border-radius: 8px; color: var(--text); text-decoration: none; }
.side a:hover, .side a.active { background: var(--side-active); }
.side .group { font-size: 11px; font-weight: 700; letter-spacing: .06em; color: var(--muted); margin: 16px 12px 4px; }
.side .back { color: var(--muted); margin-bottom: 6px; }
.side .group hr { border: 0; border-top: 1px solid var(--border); margin: 0; }
.badge { margin-left: auto; background: var(--danger); color: #fff; border-radius: 999px; padding: 0 7px; font-size: 12px; font-weight: 700; }
tr.unread td { background: color-mix(in srgb, var(--accent) 12%, transparent); }
main { padding: 24px; max-width: 1180px; width: 100%; }
main.narrow { max-width: 760px; margin: 0 auto; }
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .side { display: flex; overflow-x: auto; gap: 4px; padding: 8px; border-right: 0; border-bottom: 1px solid var(--border); }
  .side .group { display: none; }
  .side a { white-space: nowrap; padding: 6px 10px; }
  main { padding: 16px; }
}

h1 { font-size: 22px; margin: 0 0 4px; }
.sub { color: var(--muted); margin: 0 0 20px; }
h2 { font-size: 17px; margin: 20px 0 8px; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 18px; margin-bottom: 16px; }
.card > h2:first-child { margin-top: 0; }

/* Sections repliables */
details.section { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; margin-bottom: 16px; }
details.section[open] { border-color: var(--accent); }
details.section > summary { list-style: none; cursor: pointer; padding: 14px 18px; display: flex; justify-content: space-between; align-items: center; }
details.section > summary::-webkit-details-marker { display: none; }
details.section > summary b { display: block; font-size: 17px; }
details.section > summary span { color: var(--muted); font-size: 13px; }
details.section > summary::after { content: '▾'; color: var(--muted); font-size: 18px; transition: transform .15s; }
details.section[open] > summary::after { transform: rotate(180deg); }
details.section > .body { padding: 4px 18px 18px; border-top: 1px solid var(--border); }
details.sub-section { border-top: 1px solid var(--border); padding: 6px 0; }
details.sub-section > summary { cursor: pointer; padding: 6px 0; font-weight: 600; font-size: 14px; }

/* Formulaires */
label.lbl { display: block; font-weight: 600; margin: 12px 0 4px; }
.hint { color: var(--muted); font-size: 13px; font-weight: 400; }
input[type=text], input[type=password], input[type=number], input[type=url], input[type=time], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px; background: var(--input); color: var(--text); font: inherit;
}
textarea { min-height: 90px; resize: vertical; }
input[type=color] { width: 100%; height: 40px; padding: 3px; border: 1px solid var(--border); border-radius: 8px; background: var(--input); }
select[multiple] { min-height: 110px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 16px; }
.grid4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0 16px; }
@media (max-width: 700px) { .grid2, .grid3, .grid4 { grid-template-columns: 1fr; } }
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; }
@media (max-width: 1000px) { .split { grid-template-columns: 1fr; } }
.sticky { position: sticky; top: 70px; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.checks label { display: flex; align-items: center; gap: 6px; }

/* Interrupteurs */
.tog { display: flex; align-items: center; gap: 10px; margin: 12px 0 4px; cursor: pointer; }
.tog .t { font-weight: 600; }
.switch { appearance: none; -webkit-appearance: none; width: 44px; height: 24px; border-radius: 12px; background: var(--panel2); border: 1px solid var(--border); position: relative; cursor: pointer; flex: none; margin: 0; transition: background .15s; }
.switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.3); transition: left .15s; }
.switch:checked { background: var(--accent); border-color: var(--accent); }
.switch:checked::after { left: 22px; }

/* Boutons */
button, .btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; border: 0; border-radius: 8px; background: var(--accent); color: var(--accent-text); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
button.ghost, .btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
button.danger, .btn.danger { background: var(--danger); color: #fff; }
button.ok, .btn.ok { background: var(--ok); color: #fff; }
button.small { padding: 5px 10px; font-size: 13px; }
.actions { display: flex; gap: 8px; align-items: center; margin-top: 16px; flex-wrap: wrap; }
.savebar { position: sticky; bottom: 0; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 12px 18px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; box-shadow: 0 -4px 16px rgba(0,0,0,.15); }

/* Listes dynamiques */
.item { background: var(--panel2); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; margin-top: 10px; }
.item-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.item-head b { font-size: 15px; }
.item-tools { display: flex; gap: 4px; }
.item-tools button { padding: 4px 9px; }
.rule { display: grid; grid-template-columns: auto minmax(0, 1fr) 140px auto; gap: 8px; align-items: center; background: var(--panel2); border: 1px solid var(--border); border-radius: 8px; padding: 8px; margin-top: 6px; }
@media (max-width: 600px) { .rule { grid-template-columns: 1fr 1fr; } }

/* Sélecteurs à puces */
.picker { display: grid; gap: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips:empty { display: none; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--panel2); border: 1px solid var(--border); border-radius: 6px; padding: 3px 4px 3px 9px; font-size: 14px; }
.chip .dot { width: 10px; height: 10px; border-radius: 50%; background: #99aab5; }
.chip img { width: 18px; height: 18px; border-radius: 50%; }
.chip button { background: transparent; color: var(--muted); border: 0; padding: 0 6px; font-size: 16px; line-height: 1; }
.chip button:hover { color: var(--danger); }
.member-search { position: relative; }
.suggest { position: absolute; z-index: 10; left: 0; right: 0; top: calc(100% + 4px); background: var(--panel); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.25); overflow: hidden; }
.suggest:empty { display: none; }
.suggest .hint { padding: 10px 12px; }
.suggest-item { display: flex; width: 100%; gap: 8px; align-items: center; background: transparent; color: var(--text); border-radius: 0; font-weight: 400; padding: 8px 12px; }
.suggest-item:hover { background: var(--panel2); }
.suggest-item img { width: 22px; height: 22px; border-radius: 50%; }

/* Statistiques */
.segmented { display: inline-flex; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 3px; margin-bottom: 16px; }
.segmented a { padding: 6px 14px; border-radius: 6px; color: var(--muted); text-decoration: none; font-size: 14px; }
.segmented a.active { background: var(--accent); color: var(--accent-text); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; display: grid; gap: 2px; }
.tile span { color: var(--muted); font-size: 13px; }
.tile b { font-size: 26px; line-height: 1.2; }
.tile small { color: var(--muted); font-size: 12px; }
.chart { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px; height: 200px; }
.y-axis { display: flex; flex-direction: column; justify-content: space-between; font-size: 11px; color: var(--muted); text-align: right; padding-bottom: 18px; }
.plot { position: relative; display: grid; grid-template-rows: minmax(0, 1fr) 18px; }
.plot .grid { position: absolute; inset: 0 0 18px 0; display: flex; flex-direction: column; justify-content: space-between; pointer-events: none; }
.plot .grid i { border-top: 1px solid var(--border); opacity: .6; }
.bars { display: flex; align-items: flex-end; gap: 2px; position: relative; }
.bar-slot { flex: 1; height: 100%; display: flex; align-items: flex-end; cursor: default; outline: none; }
.bar-slot .bar { width: 100%; background: var(--series-1); border-radius: 4px 4px 0 0; }
.bar-slot:hover .bar, .bar-slot:focus .bar { filter: brightness(1.15); }
.bar-slot:hover, .bar-slot:focus { background: color-mix(in srgb, var(--text) 6%, transparent); border-radius: 4px; }
.x-labels { display: flex; gap: 2px; font-size: 11px; color: var(--muted); }
.x-labels span { flex: 1; white-space: nowrap; overflow: visible; }
.tooltip { position: fixed; z-index: 50; pointer-events: none; background: var(--panel); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; font-size: 13px; box-shadow: 0 6px 18px rgba(0,0,0,.25); white-space: nowrap; }
td.who { display: flex; align-items: center; gap: 8px; }
td.who img { width: 22px; height: 22px; border-radius: 50%; }

/* Tableaux, cartes, messages */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-size: 13px; font-weight: 600; }
.table-wrap { overflow-x: auto; }
.notice { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.notice.error { background: color-mix(in srgb, var(--danger) 15%, transparent); color: var(--danger); }
.guilds, .cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.guilds a { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--text); }
.guilds img, .guilds .ph { width: 48px; height: 48px; border-radius: 50%; background: var(--accent); flex: none; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; background: var(--panel2); color: var(--muted); }
.pill.on { background: color-mix(in srgb, var(--ok) 20%, transparent); color: var(--ok); }
.pill.off { background: color-mix(in srgb, var(--danger) 20%, transparent); color: var(--danger); }
.muted { color: var(--muted); }
.inline-form { display: inline; }
.vars { display: flex; flex-wrap: wrap; gap: 6px; }
.vars code { cursor: help; }
.integration-head { height: 110px; border-radius: 10px; margin: -4px 0 14px; display: flex; align-items: center; justify-content: center; gap: 14px; background: linear-gradient(135deg, #2d3748, #4a5568); color: #fff; font-size: 30px; font-weight: 700; }

/* Aperçu Discord (toujours en thème sombre, comme Discord) */
.dc { background: #313338; color: #dbdee1; border-radius: 10px; padding: 14px; font-size: 14px; }
.dc-content { margin-bottom: 6px; }
.dc-mention { background: rgba(88,101,242,.3); color: #c9cdfb; border-radius: 3px; padding: 0 2px; }
.dc-embed { background: #2b2d31; border-left: 4px solid #5865f2; border-radius: 4px; padding: 10px 14px 12px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0 12px; max-width: 520px; }
.dc-embed .left > * { margin-top: 6px; }
.dc-embed .left > *:first-child { margin-top: 0; }
.dc-author { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: #f2f3f5; }
.dc-author img, .dc-footer img { width: 20px; height: 20px; border-radius: 50%; }
.dc-title { font-weight: 700; color: #f2f3f5; }
.dc-title.link { color: #00a8fc; }
.dc-desc { white-space: pre-wrap; overflow-wrap: anywhere; }
.dc-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.dc-field { grid-column: 1 / -1; }
.dc-field.inline { grid-column: auto; }
.dc-field b { display: block; color: #f2f3f5; font-size: 13px; }
.dc-field div { white-space: pre-wrap; overflow-wrap: anywhere; }
.dc-thumb { width: 80px; height: 80px; object-fit: cover; border-radius: 4px; }
.dc-image { max-width: 100%; border-radius: 4px; grid-column: 1 / -1; margin-top: 10px; }
.dc-footer { display: flex; align-items: center; gap: 6px; font-size: 12px; color: #b5bac1; }
.dc-buttons { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.dc-btn { padding: 6px 14px; border-radius: 4px; color: #fff; font-weight: 600; font-size: 14px; }
.dc-btn.primary { background: #5865f2; } .dc-btn.success { background: #248046; } .dc-btn.danger { background: #da373c; } .dc-btn.secondary { background: #4e5058; }
.dc-btn.disabled { opacity: .5; }
