:root {
  --bg: #0b0b0d;
  --bg-soft: #111113;
  --panel: #17171a;
  --panel-hover: #1c1c20;
  --border: #26262b;
  --border-soft: #1e1e22;
  --text: #f2f2f4;
  --muted: #8b8b95;
  --muted-soft: #5f5f6a;
  --accent: #9147ff;
  --accent-2: #ff5fa8;
  --accent-hover: #a565ff;
  --accent-soft: rgba(145, 71, 255, 0.15);
  --danger: #ff5c5c;
  --danger-soft: rgba(255, 92, 92, 0.13);
  --success: #34d17c;
  --success-soft: rgba(52, 209, 124, 0.13);
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 28px -14px rgba(0, 0, 0, 0.6);
  --sidebar-w: 248px;
  --font: "Inter", -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

::selection {
  background: var(--accent-soft);
  color: var(--text);
}

html {
  color-scheme: dark;
}

body {
  margin: 0;
  background:
    radial-gradient(900px 520px at 14% -8%, rgba(145, 71, 255, 0.07), transparent 60%),
    radial-gradient(700px 460px at 100% 12%, rgba(255, 95, 168, 0.05), transparent 65%),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: var(--accent-hover);
}

/* Scrollbars discrets */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

*::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

*::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 999px;
}

/* ─── Layout : sidebar + contenu ───────────────────────────────── */
.shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--panel), var(--bg-soft) 85%);
  border-right: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  padding: 18px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
  font-size: 14.5px;
  letter-spacing: -0.01em;
  padding: 8px 8px 18px;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  flex-shrink: 0;
}

.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.sidebar nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* Groupe de nav dépliable (façon WizeBot) */
.nav-group {
  margin-top: 6px;
}

.nav-group:first-child {
  margin-top: 0;
}

.nav-group summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted-soft);
  padding: 8px 8px;
  cursor: pointer;
  list-style: none;
  border-radius: 6px;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.nav-group summary::-webkit-details-marker {
  display: none;
}

.nav-group summary::after {
  content: "";
  width: 6px;
  height: 6px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg);
  transition: transform 0.15s ease;
  flex-shrink: 0;
}

.nav-group[open] summary::after {
  transform: rotate(-135deg);
}

.nav-group summary:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
}

.nav-group .nav-group-items {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding-top: 2px;
}

.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  text-decoration: none;
  padding: 8px 9px;
  font-size: 13.5px;
  font-weight: 500;
  border-radius: 7px;
  position: relative;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.sidebar nav a::before {
  content: "";
  position: absolute;
  left: -12px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 0;
  border-radius: 0 3px 3px 0;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  transition: height 0.15s ease;
}

.sidebar nav a .icon {
  flex-shrink: 0;
  opacity: 0.85;
}

.sidebar nav a:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.045);
}

.sidebar nav a.active {
  color: var(--text);
  background: var(--accent-soft);
}

.sidebar nav a.active::before {
  height: 18px;
}

.sidebar nav a.active .icon {
  opacity: 1;
  color: var(--accent-hover);
}

.sidebar nav a.sidebar-nav-bottom {
  margin-top: auto;
}

.sidebar-logout {
  padding-top: 12px;
  margin-top: 8px;
  border-top: 1px solid var(--border-soft);
}

.sidebar-logout button {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.content {
  flex: 1;
  min-width: 0;
}

main {
  max-width: 760px;
  margin: 0 auto;
  padding: 40px 32px 96px;
}

.shell main {
  margin: 0;
  max-width: 1800px;
  padding: 40px 48px 96px;
}

h1 {
  font-size: 23px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0 0 6px;
}

h2 {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.005em;
  margin: 0 0 14px;
}

p.subtitle {
  color: var(--muted);
  font-size: 14px;
  margin-top: 0;
  margin-bottom: 30px;
  max-width: 62ch;
  line-height: 1.55;
}

/* ─── Tuiles de stats (aperçu) ──────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.stat-tile {
  background: linear-gradient(165deg, var(--panel), var(--bg-soft));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, 0.03);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.stat-tile:hover {
  border-color: #34343b;
  box-shadow: var(--shadow-md), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.stat-tile .icon {
  color: var(--accent-hover);
  margin-bottom: 10px;
  opacity: 0.9;
}

.stat-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: linear-gradient(160deg, var(--accent-soft), rgba(255, 95, 168, 0.09));
  border: 1px solid rgba(145, 71, 255, 0.18);
  color: var(--accent-hover);
  margin-bottom: 12px;
}

.stat-icon-ok {
  background: var(--success-soft);
  border-color: rgba(52, 209, 124, 0.25);
  color: var(--success);
}

.stat-icon-off {
  background: var(--danger-soft);
  border-color: rgba(255, 92, 92, 0.25);
  color: var(--danger);
}

.stat-tile .value {
  font-size: 25px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
  background: linear-gradient(135deg, var(--text), var(--text) 60%, var(--accent-hover));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.stat-tile .value.unknown {
  background: none;
  -webkit-text-fill-color: var(--muted-soft);
  color: var(--muted-soft);
  font-size: 19px;
}

.stat-tile .value.value-ok {
  background: none;
  -webkit-text-fill-color: var(--success);
  color: var(--success);
}

.stat-tile .value.value-off {
  background: none;
  -webkit-text-fill-color: var(--danger);
  color: var(--danger);
}

.stat-tile .label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 4px;
}

/* ─── Cartes / formulaires (réutilisés sur toutes les pages) ────── */
.card {
  background: linear-gradient(165deg, var(--panel), var(--bg-soft));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md), inset 0 1px 0 rgba(255, 255, 255, 0.03);
  padding: 22px 24px;
  margin-bottom: 16px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.card:hover {
  border-color: #303038;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 14px 32px -16px rgba(0, 0, 0, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 12px;
}

.card-head h2 {
  margin: 0;
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-soft);
}

.row:last-child {
  border-bottom: none;
  padding-bottom: 2px;
}

.row:first-child {
  padding-top: 0;
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

/* Interrupteur on/off (soumet son formulaire au clic) */
.switch {
  position: relative;
  display: inline-block;
  width: 38px;
  height: 21px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch .slider {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 999px;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.switch .slider::before {
  content: "";
  position: absolute;
  width: 15px;
  height: 15px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.15s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.switch input:checked + .slider {
  background: var(--success);
}

.switch input:checked + .slider::before {
  transform: translateX(17px);
}

.switch input:focus-visible + .slider {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Bouton icône (ex. poubelle) */
.icon-star-active {
  color: var(--accent-hover);
  fill: var(--accent-hover);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 7px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  transition: background-color 0.15s ease, color 0.15s ease;
}

.icon-btn:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

.dropzone {
  position: relative;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 22px;
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease;
}

.dropzone.dragging {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--text);
}

.dropzone.has-file {
  border-style: solid;
  border-color: var(--success);
  color: var(--text);
}

.dropzone input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
  letter-spacing: 0.01em;
}

.badge::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 999px;
  background: currentColor;
}

.badge.ok {
  background: var(--success-soft);
  color: var(--success);
}

.badge.off {
  background: var(--danger-soft);
  color: var(--danger);
}

label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
  margin-top: 16px;
}

label:first-child {
  margin-top: 0;
}

input[type="text"],
input[type="number"],
input[type="password"],
input[type="file"],
textarea,
select {
  width: 100%;
  padding: 10px 13px;
  background: #0a0a0c;
  border: 1px solid #303038;
  border-radius: 10px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.35);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

input::placeholder,
textarea::placeholder {
  color: var(--muted-soft);
}

input:hover,
textarea:hover,
select:hover {
  border-color: #3c3c45;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  background: #0d0d10;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.35), 0 0 0 3px var(--accent-soft);
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238b8b95' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}

textarea {
  resize: vertical;
  min-height: 64px;
  line-height: 1.5;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 16px;
}

.checkbox-row input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

.checkbox-row label {
  margin: 0;
  color: var(--text);
  font-weight: 500;
  cursor: pointer;
}

button,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  background: linear-gradient(165deg, var(--accent-hover), var(--accent) 65%, #7a2ff0);
  color: #fff;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: 0.005em;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.12) inset, 0 6px 16px -6px rgba(145, 71, 255, 0.65);
  transition: filter 0.15s ease, transform 0.05s ease, box-shadow 0.15s ease;
}

button:hover,
.btn:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.12) inset, 0 10px 24px -6px rgba(145, 71, 255, 0.85);
}

button:active,
.btn:active {
  transform: translateY(1px);
  filter: brightness(0.98);
}

button:focus-visible,
.btn:focus-visible {
  outline: 2px solid var(--accent-hover);
  outline-offset: 2px;
}

button.secondary,
.btn.secondary {
  background: var(--panel-hover);
  border: 1px solid var(--border);
  color: var(--text);
  box-shadow: none;
}

button.secondary:hover,
.btn.secondary:hover {
  border-color: #3a3a42;
  filter: none;
  background: #202024;
  transform: translateY(-1px);
  box-shadow: 0 6px 16px -8px rgba(0, 0, 0, 0.5);
}

button.danger {
  background: transparent;
  border: none;
  color: var(--danger);
  padding: 5px 12px;
  font-size: 13px;
  box-shadow: none;
}

button.danger:hover {
  background: var(--danger-soft);
  filter: none;
}

button:disabled,
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  filter: none;
}

form.inline {
  display: inline;
}

.actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 20px;
}

.mono {
  font-family: "SF Mono", "Cascadia Code", Consolas, monospace;
  font-size: 12.5px;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 12.5px;
}

.flash {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 22px;
  font-size: 13.5px;
  line-height: 1.55;
}

.flash.error {
  background: var(--danger-soft);
  color: #ff9d9d;
  border: 1px solid rgba(255, 92, 92, 0.25);
}

.flash.success {
  background: var(--success-soft);
  color: #7bdea3;
  border: 1px solid rgba(52, 209, 124, 0.25);
}

.empty {
  color: var(--muted-soft);
  font-style: italic;
  padding: 10px 0;
  font-size: 13.5px;
}

.cmd-search {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 11px;
  background: #0a0a0c;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--muted-soft);
  flex-shrink: 0;
}

.cmd-search input {
  border: none;
  background: none;
  padding: 0;
  margin: 0;
  width: 140px;
  font-size: 13px;
  color: var(--text);
}

.cmd-search input:focus {
  outline: none;
  box-shadow: none;
}

.cmd-row:last-child > .row {
  border-bottom: none;
}

.cmd-edit-form {
  padding: 14px 0 18px;
  border-bottom: 1px solid var(--border-soft);
}

.cmd-row:last-child .cmd-edit-form {
  border-bottom: none;
}

/* Récompenses -> réaction personnalisée (message libre sur une récompense existante) */
.custom-reward-row {
  align-items: flex-start;
  gap: 12px;
}

.custom-reward-form {
  flex: 1;
  min-width: 0;
}

.custom-reward-form textarea {
  margin-top: 0;
}

.custom-reward-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 8px;
}

.custom-reward-row .row-actions {
  padding-top: 4px;
}

details.create-reward {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px dashed var(--border);
}

details.create-reward summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-hover);
  list-style: none;
}

details.create-reward summary::-webkit-details-marker {
  display: none;
}

details.create-reward[open] summary {
  margin-bottom: 4px;
}

.login-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
  padding: 24px;
  background:
    radial-gradient(720px 420px at 50% 8%, var(--accent-soft), transparent 68%),
    radial-gradient(480px 300px at 82% 78%, rgba(255, 95, 168, 0.09), transparent 70%),
    var(--bg);
}

.login-screen .brand-mark {
  width: 84px;
  height: 84px;
  margin-bottom: 6px;
  filter: drop-shadow(0 10px 24px rgba(145, 71, 255, 0.4));
}

.login-kicker {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
  margin-bottom: 6px;
}

.login-screen h1 {
  font-size: 30px;
  max-width: 16ch;
  line-height: 1.15;
}

.login-screen .subtitle {
  margin-bottom: 8px;
  max-width: 42ch;
}

.login-screen .btn {
  margin-top: 14px;
  padding: 12px 26px;
  font-size: 14.5px;
}

@media (max-width: 760px) {
  .shell {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    height: auto;
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
  }
  .sidebar nav {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .nav-group summary {
    display: none;
  }
  .nav-group .nav-group-items {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .sidebar nav a.sidebar-nav-bottom {
    margin-top: 0;
  }
  .sidebar-logout {
    border-top: none;
    padding-top: 0;
    margin-top: 0;
    margin-left: auto;
  }
  .sidebar-logout button {
    width: auto;
  }
  .shell main {
    padding: 24px 20px 64px;
  }
}

/* Utilitaires d'espacement (évite le style="" inline au cas par cas) */
.mt-sm {
  margin-top: 12px;
}

.mt-md {
  margin-top: 16px;
}

.mb-md {
  margin-bottom: 16px;
}

.desc-tight {
  margin-top: -8px;
  margin-bottom: 16px;
}

.audio-compact {
  height: 32px;
}

/* Éditeur de message repliable (accordéon) — pour ne pas empiler des
   textareas ouvertes en permanence sur les pages qui en ont beaucoup. */
.msg-editor {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  overflow: hidden;
  background: var(--bg-soft);
}

.msg-editor:last-child {
  margin-bottom: 0;
}

.msg-editor summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  cursor: pointer;
  list-style: none;
  font-size: 13px;
  font-weight: 600;
  transition: background-color 0.15s ease;
}

.msg-editor summary:hover {
  background: rgba(255, 255, 255, 0.03);
}

.msg-editor summary::-webkit-details-marker {
  display: none;
}

.msg-editor summary .hint {
  font-weight: 400;
  color: var(--muted-soft);
  font-size: 11.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  text-align: right;
  min-width: 0;
}

.msg-editor summary::after {
  content: "";
  width: 6px;
  height: 6px;
  border-right: 1.5px solid var(--muted-soft);
  border-bottom: 1.5px solid var(--muted-soft);
  transform: rotate(45deg);
  transition: transform 0.15s ease;
  flex-shrink: 0;
}

.msg-editor[open] summary::after {
  transform: rotate(-135deg);
}

.msg-editor .msg-editor-body {
  padding: 14px;
  border-top: 1px solid var(--border-soft);
  background: var(--panel);
}

.msg-editor .msg-editor-body label:first-child {
  margin-top: 0;
}

/* Liste des messages : glisser-déposer par poignée + interrupteur en dehors
   de la case cliquable, puis l'accordéon (titre + édition). */
.msg-list {
  min-height: 10px;
}

.msg-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 8px;
}

.msg-row:last-of-type {
  margin-bottom: 0;
}

.msg-row.dragging {
  opacity: 0.4;
}

.drag-handle {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 22px;
  height: 38px;
  margin-top: 4px;
  color: var(--muted-soft);
  cursor: grab;
  border-radius: 6px;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.drag-handle:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

.msg-row.dragging .drag-handle {
  cursor: grabbing;
}

.msg-row > .switch {
  flex-shrink: 0;
  margin-top: 8px;
}

.msg-row .msg-editor {
  flex: 1;
  min-width: 0;
  margin-bottom: 0;
}

/* Chip d'icône devant un titre de carte — casse l'effet "mur de texte". */
.card-head {
  align-items: center;
}

.card-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: linear-gradient(160deg, var(--accent-soft), rgba(255, 95, 168, 0.09));
  border: 1px solid rgba(145, 71, 255, 0.18);
  color: var(--accent-hover);
  flex-shrink: 0;
}

.card-title {
  display: flex;
  align-items: center;
  gap: 11px;
}

.card-title h2 {
  margin: 0;
}

/* Comptes Twitch : les deux cartes côte à côte plutôt qu'empilées */
.accounts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: start;
}

/* Section repliable de premier niveau (page Fonctionnalités) — regroupe
   plusieurs cartes sous un même "menu déroulant" au lieu de tout empiler. */
.section-accordion {
  margin-bottom: 16px;
}

.section-accordion summary {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: linear-gradient(165deg, var(--panel), var(--bg-soft));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  list-style: none;
  font-size: 15px;
  font-weight: 700;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.section-accordion summary::-webkit-details-marker {
  display: none;
}

.section-accordion summary:hover {
  border-color: #303038;
  background: linear-gradient(165deg, var(--panel-hover), var(--bg-soft));
}

.section-accordion summary::after {
  content: "";
  margin-left: auto;
  width: 8px;
  height: 8px;
  border-right: 1.5px solid var(--muted-soft);
  border-bottom: 1.5px solid var(--muted-soft);
  transform: rotate(45deg);
  transition: transform 0.15s ease;
  flex-shrink: 0;
}

.section-accordion[open] summary::after {
  transform: rotate(-135deg);
}

.section-accordion[open] > summary {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  border-bottom-color: var(--border-soft);
}

.section-accordion .section-body {
  padding: 22px;
  border: 1px solid var(--border);
  border-top: none;
  border-bottom-left-radius: var(--radius);
  border-bottom-right-radius: var(--radius);
  background: var(--bg-soft);
}

.section-accordion .section-body > .card:last-child,
.section-accordion .section-body > form:last-child {
  margin-bottom: 0;
}

/* Grille générique pour des cartes comparables côte à côte (ex. Rewards) au
   lieu d'un empilement vertical systématique — casse l'effet "liste de
   formulaires" sur les pages larges. */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
  gap: 16px;
  align-items: start;
}

.card-grid > .card {
  margin-bottom: 0;
}

/* Petit sous-titre de groupe (ex. "Réactions personnalisées" au sein de la
   section Rewards) — pas une carte en soi, juste un séparateur visuel avant
   une grille de cartes. */
.section-subheading {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

.account-card {
  margin-bottom: 0;
}

.account-status {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}

@media (max-width: 640px) {
  .accounts-grid {
    grid-template-columns: 1fr;
  }
}

/* Grille pour poser deux champs courts côte à côte au lieu de les empiler */
.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.field-grid > div > label:first-child,
.field-grid > label:first-child {
  margin-top: 0;
}

@media (max-width: 520px) {
  .field-grid {
    grid-template-columns: 1fr;
  }
}

/* Interrupteur "Activé" en tête de carte (remplace la case à cocher) */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}

.toggle-row .toggle-label {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
}

.checkbox-grid .checkbox-row {
  margin-top: 0;
}

/* Panneau d'insertion sous un textarea (placeholders + emojis + emotes) */
.msg-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  background: var(--panel-hover);
  border: 1px solid var(--border);
  color: var(--muted);
  font-family: "SF Mono", Consolas, monospace;
  font-size: 11.5px;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: 999px;
  box-shadow: none;
}

.chip:hover {
  color: var(--text);
  border-color: var(--accent);
  filter: none;
  background: var(--accent-soft);
}

.emoji-picker {
  position: relative;
}

.emoji-picker summary {
  list-style: none;
  cursor: pointer;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  background: var(--panel-hover);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 999px;
}

.emoji-picker summary:hover {
  color: var(--text);
  border-color: var(--accent);
}

.emoji-picker summary::-webkit-details-marker {
  display: none;
}

.emoji-picker .emoji-grid {
  position: absolute;
  z-index: 5;
  top: calc(100% + 6px);
  left: 0;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
  width: 240px;
  max-height: 180px;
  overflow-y: auto;
  padding: 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
}

.emoji-btn,
.emote-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 6px;
  padding: 4px;
  font-size: 16px;
  line-height: 1;
  box-shadow: none;
  cursor: pointer;
}

.emoji-btn:hover,
.emote-btn:hover {
  background: var(--accent-soft);
  filter: none;
}

.emote-btn img {
  width: 24px;
  height: 24px;
  object-fit: contain;
}

/* Page Informations : vitrine des emotes de la chaîne (lecture seule) */
.emote-showcase {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 10px;
}

.emote-showcase-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 8px;
  background: var(--panel-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-align: center;
}

.emote-showcase-item img {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

.emote-showcase-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

/* Page Informations : classement des commandes par utilisation */
.command-stats {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.command-stat-row {
  display: grid;
  grid-template-columns: 100px 1fr 36px;
  align-items: center;
  gap: 12px;
}

.command-stat-trigger {
  color: var(--text);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.command-stat-bar-track {
  height: 8px;
  background: var(--panel-hover);
  border-radius: 999px;
  overflow: hidden;
}

.command-stat-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 999px;
  transition: width 0.4s cubic-bezier(0.2, 0.7, 0.3, 1);
}

.command-stat-count {
  text-align: right;
  font-weight: 600;
}

/* Page Communauté : mini graphiques de tendance (followers/unfollows par
   mois, abonnés par palier) — même look que les barres de command-stats. */
.mini-chart {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-soft);
}

.mini-chart-row {
  display: grid;
  grid-template-columns: 76px 1fr 28px;
  align-items: center;
  gap: 12px;
}

.mini-chart-label {
  font-size: 12px;
  color: var(--muted);
  text-transform: capitalize;
  white-space: nowrap;
}

.mini-chart-bar-track {
  height: 8px;
  background: var(--panel-hover);
  border-radius: 999px;
  overflow: hidden;
}

.mini-chart-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 999px;
  transition: width 0.4s cubic-bezier(0.2, 0.7, 0.3, 1);
}

.mini-chart-count {
  text-align: right;
  font-weight: 600;
  font-size: 12px;
}

/* Page Informations : grille des clips récents */
.clip-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.clip-card {
  display: flex;
  flex-direction: column;
  background: var(--panel-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.clip-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.clip-card img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  display: block;
}

.clip-card-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
}

/* Champ "bulles" réutilisable (ex. alias de commande) */
.tags-input {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.tags-input:focus-within {
  border-color: var(--accent);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.35), 0 0 0 3px var(--accent-soft);
}

.tags-input .tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 6px 3px 10px;
  background: var(--accent-soft);
  color: var(--accent-hover);
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  font-family: "SF Mono", "Cascadia Code", Consolas, monospace;
}

.tags-input .tag-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: none;
  background: none;
  color: inherit;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  opacity: 0.7;
}

.tags-input .tag-remove:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.12);
}

.tags-input input[type="text"] {
  flex: 1;
  min-width: 90px;
  border: none;
  background: none;
  padding: 4px 2px;
  margin: 0;
}

.tags-input input[type="text"]:focus {
  outline: none;
  box-shadow: none;
}

.clip-card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ─── Animations / micro-interactions ─────────────────────────────── */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes flashIn {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes switchPop {
  0% {
    transform: scale(1);
  }
  40% {
    transform: scale(1.12);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes countUpFade {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Le contenu de chaque page apparaît en fondu-décalé, légèrement échelonné
   pour les premiers éléments (cartes, stats) — casse l'effet "page statique". */
.shell main > * {
  animation: fadeInUp 0.4s cubic-bezier(0.2, 0.7, 0.3, 1) both;
}

.shell main > *:nth-child(1) { animation-delay: 0s; }
.shell main > *:nth-child(2) { animation-delay: 0.04s; }
.shell main > *:nth-child(3) { animation-delay: 0.08s; }
.shell main > *:nth-child(4) { animation-delay: 0.12s; }
.shell main > *:nth-child(5) { animation-delay: 0.16s; }
.shell main > *:nth-child(6) { animation-delay: 0.2s; }
.shell main > *:nth-child(n + 7) { animation-delay: 0.22s; }

.flash {
  animation: flashIn 0.3s cubic-bezier(0.2, 0.7, 0.3, 1) both;
}

/* Petit "pop" sur le rond du switch quand il passe à l'état activé. */
.switch input:checked + .slider::before {
  animation: switchPop 0.25s ease;
}

/* Léger zoom de l'icône d'une carte quand on survole toute la carte —
   petit signe de vie sans que ce soit gadget. */
.card {
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.card:hover .card-icon {
  transform: scale(1.08);
}

.card-icon,
.stat-icon {
  transition: transform 0.2s ease;
}

.stat-tile:hover .stat-icon {
  transform: scale(1.08);
}

.value[data-counting] {
  animation: countUpFade 0.4s ease;
}

/* Respecte la préférence système "mouvement réduit" : on coupe toutes les
   animations décoratives plutôt que de les rendre instantanées en JS. */
@media (prefers-reduced-motion: reduce) {
  .shell main > *,
  .flash,
  .switch input:checked + .slider::before,
  .value[data-counting] {
    animation: none !important;
  }
  .card:hover .card-icon,
  .stat-tile:hover .stat-icon {
    transform: none;
  }
  * {
    transition-duration: 0.001ms !important;
  }
}
