:root {
  --bg: #0f0b18; --panel: #1a1426; --panel2: #231a33; --line: #33274a;
  --text: #ece8f5; --muted: #a79fba; --accent: #8b4fd0; --accent2: #b07cf0;
  --ok: #3ecf8e; --off: #7a7290;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); line-height: 1.5;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: inherit; text-decoration: none; }
h1 { margin: 0 0 4px; font-size: 1.6rem; }
h3 { margin: 8px 0 4px; }
.muted { color: var(--muted); }
.tiny { font-size: .8rem; }
code { background: var(--panel2); padding: 1px 6px; border-radius: 4px; font-size: .85em; }

/* ---------- Barre du haut ---------- */
.topbar { display: flex; align-items: center; gap: 12px; padding: 12px 24px;
  background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; font-size: 1.2rem; color: var(--accent2); }
.spacer { flex: 1; }
.me { display: flex; align-items: center; gap: 8px; }
.me img { width: 30px; height: 30px; border-radius: 50%; }

/* ---------- Boutons ---------- */
.btn { display: inline-block; padding: 10px 18px; border-radius: 8px; border: 0;
  cursor: pointer; font: inherit; font-weight: 600; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent2); }
.btn.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.btn.ghost:hover { color: var(--text); border-color: var(--accent); }
.btn.block { width: 100%; text-align: center; }

/* ---------- Cartes générales ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 20px; }
.center { min-height: 80vh; display: grid; place-items: center; padding: 20px; }
.login { text-align: center; max-width: 380px; width: 100%; }
.logo { width: 72px; height: 72px; margin: 0 auto 12px; border-radius: 50%; display: grid;
  place-items: center; font-size: 2rem; font-weight: 800;
  background: linear-gradient(135deg, var(--accent), #3a1a6b); }

.page { max-width: 900px; margin: 0 auto; padding: 32px 24px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; margin-top: 20px; }
.server { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
.server:hover { border-color: var(--accent); }
.server img, .ph { width: 64px; height: 64px; border-radius: 50%; }
.ph { display: grid; place-items: center; background: var(--panel2); font-weight: 700; }

/* ---------- Structure d'un serveur ---------- */
.layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); min-height: calc(100vh - 57px); }
.sidebar { background: var(--panel); border-right: 1px solid var(--line); padding: 20px 14px;
  display: flex; flex-direction: column; gap: 16px; }
.guild-id { display: flex; align-items: center; gap: 10px; padding: 0 6px; }
.guild-id img, .guild-id .ph { width: 40px; height: 40px; }
.sidebar nav { display: flex; flex-direction: column; gap: 4px; }
.sidebar nav a, .sidebar nav .soon { padding: 10px 12px; border-radius: 8px; color: var(--muted); }
.sidebar nav a:hover { background: var(--panel2); color: var(--text); }
.sidebar nav a.on { background: var(--accent); color: #fff; }
.sidebar nav .soon { opacity: .5; }
.sidebar nav em { font-size: .7rem; margin-left: 4px; }
.back { margin-top: auto; color: var(--muted); font-size: .9rem; padding: 0 6px; }
.content { padding: 32px 40px; min-width: 0; }

/* ---------- Vue d'ensemble ---------- */
a.module { display: block; }
.module .icon { font-size: 1.8rem; }
.module.link:hover { border-color: var(--accent); }
.module .go { float: right; color: var(--accent2); font-size: .85rem; font-weight: 600; }
.badge { display: inline-block; padding: 3px 10px; border-radius: 99px; font-size: .78rem; font-weight: 600; }
.badge.on { background: rgba(62,207,142,.15); color: var(--ok); }
.badge.off { background: rgba(122,114,144,.2); color: var(--off); }
.badge.soon { background: rgba(176,124,240,.15); color: var(--accent2); }

/* ---------- Alertes ---------- */
.alert { padding: 12px 16px; border-radius: 8px; margin: 0 0 20px; font-weight: 500; }
.alert.success { background: rgba(62,207,142,.12); color: var(--ok); border: 1px solid rgba(62,207,142,.3); }
.alert.error { background: rgba(240,80,100,.12); color: #ff7a8a; border: 1px solid rgba(240,80,100,.3); }
.alert.warning { background: rgba(240,180,60,.12); color: #f0b43c; border: 1px solid rgba(240,180,60,.3); }

/* ---------- Pages de configuration ---------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 24px; }
.page-head p { margin: 0; }

.cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(380px, 520px); gap: 24px; }
.settings { display: flex; flex-direction: column; gap: 20px; min-width: 0; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 22px; }
.panel > header { margin-bottom: 16px; }
.panel h2 { margin: 0; font-size: 1.05rem; }
.panel > header p { margin: 2px 0 0; color: var(--muted); font-size: .85rem; }

.fields { display: flex; flex-direction: column; gap: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-head { display: flex; justify-content: space-between; align-items: baseline; }
.lbl { font-weight: 600; font-size: .88rem; }
.val { color: var(--accent2); font-weight: 600; }
.hint { color: var(--muted); font-size: .8rem; font-weight: 400; }

.settings input[type="text"], .settings select, .settings textarea {
  width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 10px 12px; font: inherit; font-weight: 400; }
.settings input[type="text"]:focus, .settings select:focus, .settings textarea:focus {
  outline: 2px solid var(--accent); border-color: transparent; }
.settings textarea { resize: vertical; }
.settings input[type="range"] { width: 100%; accent-color: var(--accent); }

/* Interrupteur */
.toggle { display: flex; align-items: center; gap: 12px; cursor: pointer; font-weight: 600; position: relative; }
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle .slider { position: relative; flex: none; width: 44px; height: 24px; border-radius: 99px;
  background: var(--off); transition: background .2s; }
.toggle .slider::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px;
  border-radius: 50%; background: #fff; transition: transform .2s; }
.toggle input:checked + .slider { background: var(--accent); }
.toggle input:checked + .slider::after { transform: translateX(20px); }
.toggle input:focus-visible + .slider { outline: 2px solid var(--accent2); outline-offset: 2px; }

/* Pastilles de couleur */
.colors { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.swatch { display: flex; align-items: center; gap: 10px; background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px; padding: 6px 12px 6px 6px; }
.swatch input[type="color"] { width: 34px; height: 34px; padding: 0; border: 0; background: none;
  cursor: pointer; border-radius: 8px; }
.swatch input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.swatch input[type="color"]::-webkit-color-swatch { border: 0; border-radius: 8px; }
.swatch input[type="color"]::-moz-color-swatch { border: 0; border-radius: 8px; }
.hex { background: none; padding: 0; color: var(--muted); font-size: .8rem;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }

.actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* Barre d'enregistrement collée en bas de l'écran */
.savebar { position: sticky; bottom: 16px; z-index: 5; display: flex; align-items: center; gap: 10px;
  flex-wrap: wrap; padding: 14px 18px; border-radius: 14px; border: 1px solid var(--line);
  background: rgba(26, 20, 38, .92); backdrop-filter: blur(8px); }
.savebar .hint { margin-left: auto; }

/* Aperçu */
.preview-col .panel { position: sticky; top: 20px; }
.discord-msg { background: #2b2d31; border-radius: 8px; padding: 14px; margin-bottom: 16px; }
.discord-msg .who { font-weight: 600; margin-bottom: 4px; }
.discord-msg .tag { background: #5865f2; font-size: .65rem; padding: 1px 5px; border-radius: 4px; margin-left: 4px; }
#preview-text { white-space: pre-wrap; word-break: break-word; margin-bottom: 10px; }
.card-preview { width: 100%; display: block; border-radius: 6px; aspect-ratio: 1024 / 450; background: var(--panel2); }
#card-status, #bg-status { margin: 8px 0 0; }

/* ---------- Écrans plus petits ---------- */
@media (max-width: 1150px) {
  .cols { grid-template-columns: 1fr; }
  .preview-col { order: -1; }
  .preview-col .panel { position: static; }
}
@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
  .content { padding: 20px; }
  .grid-2 { grid-template-columns: 1fr; }
  .savebar .hint { margin-left: 0; }
}

.crumb { display: inline-block; margin-bottom: 12px; color: var(--muted); font-size: .9rem; }
.crumb:hover { color: var(--text); }
.panels-grid { margin-top: 0; }
.inline { display: inline; margin: 0; }

/* Choix du style */
.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.choice { position: relative; display: flex; flex-direction: column; gap: 4px; padding: 14px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 12px; cursor: pointer; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice:hover { border-color: var(--accent); }
.choice:has(input:checked) { border-color: var(--accent2); background: rgba(139, 79, 208, .14); }
.choice:has(input:focus-visible) { outline: 2px solid var(--accent2); }
.c-icon { font-size: 1.5rem; }

/* Liste des rôles */
.items { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.item { background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 12px;
  display: flex; flex-direction: column; gap: 8px; }
.item-top { display: flex; align-items: center; gap: 6px; }
.item-top strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-form { display: grid; grid-template-columns: 90px 1fr 1.3fr auto; gap: 8px; align-items: center; }
.icon-btn { width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--line);
  background: transparent; color: var(--muted); cursor: pointer; font: inherit; }
.icon-btn:hover { color: var(--text); border-color: var(--accent); }
.icon-btn.danger:hover { color: #ff7a8a; border-color: rgba(240, 80, 100, .6); }
.warn-text { color: #f0b43c; margin: 0; }
.btn.danger { background: rgba(240, 80, 100, .15); color: #ff7a8a; border: 1px solid rgba(240, 80, 100, .35); }
.btn.danger:hover { background: rgba(240, 80, 100, .25); }

/* Aperçu du panneau */
.embed { background: #232428; border-left: 4px solid var(--accent); border-radius: 4px;
  padding: 10px 14px; margin: 6px 0 10px; }
.embed-title { font-weight: 700; margin-bottom: 4px; word-break: break-word; }
.embed-desc, .embed-list { white-space: pre-wrap; word-break: break-word; font-size: .92rem; }
.embed-list { margin-top: 8px; }
.pv-select { display: flex; justify-content: space-between; align-items: center; background: #1e1f22;
  border: 1px solid #3f4147; border-radius: 6px; padding: 10px 12px; color: #b5bac1; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: #4e5058; border-radius: 6px; padding: 6px 12px; font-size: .85rem; }
.chip.react { background: #2f3136; border: 1px solid #5865f2; padding: 4px 8px; }

@media (max-width: 760px) { .item-form { grid-template-columns: 1fr; } }

.picker-tools { display: flex; gap: 8px; flex-wrap: wrap; }
.picker-tools input { flex: 1; min-width: 180px; }
.picker { max-height: 280px; overflow-y: auto; display: grid; gap: 6px;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 10px; }
.pick { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 8px; cursor: pointer; }
.pick:hover { background: var(--panel2); }
.pick input { width: 16px; height: 16px; accent-color: var(--accent); flex: none; }
.pick span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }