/* Thème chaleureux : crème, rouge houx, vert sapin, or. */
:root {
  --bg: #fbf6ef; --card: #ffffff; --text: #2d2421; --muted: #7b6b63; --border: #ecdfd2;
  --accent: #b0322a; --accent-hover: #942720; --accent-text: #ffffff; --accent-soft: #fbe9e5;
  --pine: #1f4a3b; --pine-soft: #e6f1ec; --gold: #c18a1e; --gold-soft: #fbf0d9;
  --side-bg: #1d3b31; --side-text: #e9e1d6; --side-muted: #a3b7ad; --side-active: #2c5446;
  --ok: #217a52; --ko: #b42f25; --warn: #96650a; --info: #3b5bab;
  --info-bg: #eaf0fb; --ok-bg: #e5f4ec; --ko-bg: #fcebe8; --warn-bg: #fdf3da;
  --shadow: 0 1px 2px rgb(60 40 20 / 6%), 0 4px 14px rgb(60 40 20 / 6%);
  --radius: 14px;
  color-scheme: light dark;
}
/* Sombre : selon le système, sauf choix explicite (bouton du menu, static/theme.js). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #16130f; --card: #211c18; --text: #efe7de; --muted: #a8998d; --border: #352d27;
    --accent: #e0645a; --accent-hover: #ea7d74; --accent-text: #1a0f0d; --accent-soft: #3a1f1c;
    --pine: #7cc4a5; --pine-soft: #1b2e27; --gold: #e2b350; --gold-soft: #33280f;
    --side-bg: #0f201a; --side-text: #e6ddd2; --side-muted: #8aa298; --side-active: #1d3a30;
    --ok: #5bc791; --ko: #f0786d; --warn: #e3b341; --info: #8ea9ef;
    --info-bg: #1d2640; --ok-bg: #15302a; --ko-bg: #3a1f1c; --warn-bg: #352b13;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 4px 14px rgb(0 0 0 / 25%);
  }
}
:root[data-theme="dark"] {
  --bg: #16130f; --card: #211c18; --text: #efe7de; --muted: #a8998d; --border: #352d27;
  --accent: #e0645a; --accent-hover: #ea7d74; --accent-text: #1a0f0d; --accent-soft: #3a1f1c;
  --pine: #7cc4a5; --pine-soft: #1b2e27; --gold: #e2b350; --gold-soft: #33280f;
  --side-bg: #0f201a; --side-text: #e6ddd2; --side-muted: #8aa298; --side-active: #1d3a30;
  --ok: #5bc791; --ko: #f0786d; --warn: #e3b341; --info: #8ea9ef;
  --info-bg: #1d2640; --ok-bg: #15302a; --ko-bg: #3a1f1c; --warn-bg: #352b13;
  --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 4px 14px rgb(0 0 0 / 25%);
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }
code { font: 0.85em ui-monospace, SFMono-Regular, Menlo, monospace; background: color-mix(in srgb, var(--border) 50%, transparent); padding: 0.05em 0.3em; border-radius: 4px; }
code.wrap { white-space: pre-wrap; word-break: break-word; }
h1 { font-size: 1.6rem; line-height: 1.25; margin: 0 0 0.35rem; letter-spacing: -0.01em; }
h2 { font-size: 1.1rem; margin: 0 0 0.75rem; }
h3 { font-size: 1rem; margin: 0 0 0.5rem; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ---- Icônes (sprite Lucide, static/icons.svg) ---- */
.icon { width: 1.15em; height: 1.15em; flex: none; vertical-align: -0.2em; }
h1 > .icon { color: var(--accent); }
.hero h1 > .icon { color: var(--gold); }
h2 > .icon { color: var(--gold); }
.spin { animation: spin 1.2s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation: none; } }

/* ---- Structure ---- */
/* Grand écran : le menu reste fixe, seul `main` défile. */
.shell { display: grid; grid-template-columns: clamp(230px, 15vw, 280px) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); height: 100vh; height: 100dvh; overflow: hidden; }
/* `popover` sert au tiroir mobile : sur grand écran, on neutralise ses styles par défaut. */
.sidebar { background: var(--side-bg); color: var(--side-text); padding: 1.25rem 0.9rem; display: flex; flex-direction: column; gap: 1.25rem; position: static; inset: auto; height: auto; min-height: 0; width: auto; margin: 0; border: 0; overflow-y: auto; }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.topbar, .menu-close { display: none; }
.brand { display: flex; align-items: center; gap: 0.6rem; color: var(--side-text); text-decoration: none; font-weight: 700; font-size: 1.1rem; padding: 0 0.5rem; }
.brand:hover { color: #fff; }
.brand-mark { display: inline-flex; color: var(--gold); font-size: 1.6rem; line-height: 1; }
.brand small { display: block; font-weight: 400; font-size: 0.78rem; color: var(--side-muted); }
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-title { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--side-muted); padding: 0 0.6rem 0.35rem; margin: 0; }
.nav-group a { display: flex; align-items: center; gap: 0.6rem; padding: 0.45rem 0.6rem; border-radius: 9px; color: var(--side-text); text-decoration: none; }
.nav-group a:hover { background: var(--side-active); color: #fff; }
.nav-group a[aria-current="page"] { background: var(--side-active); color: #fff; box-shadow: inset 3px 0 0 var(--gold); }
.nav-icon { opacity: 0.85; }
.nav-group a[aria-current="page"] .nav-icon { opacity: 1; color: var(--gold); }
.nav-group.backstage a { font-size: 0.92rem; color: var(--side-muted); }
.nav-group.backstage a[aria-current="page"], .nav-group.backstage a:hover { color: var(--side-text); }
.me { margin-top: auto; display: flex; align-items: center; gap: 0.6rem; padding: 0.6rem; border-top: 1px solid var(--side-active); }
.me img, .me .initial { width: 34px; height: 34px; border-radius: 50%; flex: none; }
.me .initial { display: inline-flex; align-items: center; justify-content: center; background: var(--gold); color: #2d2421; font-weight: 700; }
.me div { min-width: 0; flex: 1; }
.me strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me form { margin: 0; }
.me button.link { color: var(--side-muted); font-size: 0.85rem; white-space: nowrap; }
.me button.link:hover { color: #fff; }
.theme-toggle { flex: none; padding: 0.4rem; border: 1px solid var(--side-active); background: none; color: var(--side-muted); }
.theme-toggle:hover { border-color: var(--side-muted); color: #fff; }
.theme-toggle .when-dark { display: none; }
:root[data-theme="dark"] .theme-toggle .when-dark { display: inline; }
:root[data-theme="dark"] .theme-toggle .when-light { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .when-dark { display: inline; }
  :root:not([data-theme="light"]) .theme-toggle .when-light { display: none; }
}

main { padding: 1.75rem clamp(1rem, 2.5vw, 2.75rem) 3rem; width: 100%; min-width: 0; }
.shell > main { overflow-y: auto; overscroll-behavior: contain; }
.page-head { margin-bottom: 1.25rem; }
.page-head .lead { color: var(--muted); margin: 0; max-width: 72ch; }
.back { display: inline-block; margin-bottom: 0.5rem; font-size: 0.9rem; text-decoration: none; }

@media (max-width: 900px) {
  /* Mobile : retour au défilement de page, sous la barre du haut collée. */
  .shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto; height: auto; overflow: visible; }
  .shell > main { overflow: visible; }
  .topbar { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; position: sticky; top: 0; z-index: 20; padding: 0.55rem 0.75rem 0.55rem 1rem; background: var(--side-bg); color: var(--side-text); box-shadow: var(--shadow); }
  .topbar .brand { padding: 0; font-size: 1rem; }
  .topbar .brand-mark { font-size: 1.35rem; }
  .menu-toggle, .menu-close { display: inline-flex; padding: 0.45rem; font-size: 1.3rem; background: none; border-color: transparent; color: var(--side-text); }
  .menu-toggle:hover, .menu-close:hover { border-color: var(--side-active); color: #fff; }
  /* Tiroir : fermé, `popover` le masque ; ouvert, il glisse depuis la gauche. */
  .sidebar:not(:popover-open) { display: none; }
  .sidebar:popover-open { position: fixed; inset: 0 auto 0 0; width: min(300px, 86vw); height: 100dvh; box-shadow: 0 0 40px rgb(0 0 0 / 35%); animation: drawer-in 0.18s ease-out; }
  .sidebar::backdrop { background: rgb(15 10 8 / 45%); }
  main { padding: 1.1rem 1rem 2.5rem; }
  .card { padding: 1rem; }
  h1 { font-size: 1.35rem; }
  .hero { padding: 1.25rem; }
  .hero h1 { font-size: 1.4rem; }
  /* Sous 16px, iOS zoome sur le champ actif. */
  input, select, textarea { font-size: 16px; }
}
@keyframes drawer-in { from { transform: translateX(-100%); } }
@media (prefers-reduced-motion: reduce) { .sidebar:popover-open { animation: none; } }
@media (max-width: 600px) {
  .hero::after { display: none; }
  .timeline li { flex-wrap: wrap; gap: 0.1rem 0.75rem; }
  .timeline .when { min-width: 0; width: 100%; }
  .actions > button, .actions > .button { flex: 1 1 auto; justify-content: center; }
  .grid.stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; }
  .tile { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
  .big { font-size: 1.6rem; }
}

/* ---- Cartes et grilles ---- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem 1.25rem; margin-bottom: 1rem; box-shadow: var(--shadow); overflow-x: auto; }
.card > :last-child { margin-bottom: 0; }

/* ---- Tableau de bord des modules ---- */
.module-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 17rem), 1fr)); gap: 1rem; }
.module-card { position: relative; display: flex; flex-direction: column; gap: 0.6rem; padding: 1rem 1.1rem; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); transition: border-color 0.12s ease, transform 0.12s ease; }
.module-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.module-card.broken { opacity: 0.75; }
.module-card-head { display: flex; align-items: center; gap: 0.75rem; }
.module-icon { flex: none; display: grid; place-items: center; width: 2.75rem; height: 2.75rem; border-radius: 12px; background: var(--pine-soft); color: var(--pine); }
.module-icon .icon { width: 1.5rem; height: 1.5rem; }
.module-card-title { min-width: 0; display: grid; gap: 0.2rem; justify-items: start; }
.module-card-title h2 { margin: 0; font-size: 1.05rem; }
.module-card-title a { color: var(--text); text-decoration: none; }
/* Toute la carte est cliquable ; les boutons restent au-dessus. */
.module-card a.stretched::after { content: ""; position: absolute; inset: 0; border-radius: var(--radius); }
.module-desc { margin: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.module-error { margin: 0; color: var(--ko); display: flex; align-items: center; gap: 0.3rem; }
.module-card-actions { position: relative; z-index: 1; margin-top: auto; display: flex; flex-wrap: wrap; gap: 0.4rem; }
.module-card-actions button { padding: 0.3rem 0.7rem; font-size: 0.85rem; }
@media (prefers-reduced-motion: reduce) { .module-card { transition: none; } .module-card:hover { transform: none; } }
.card-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 0.5rem; margin-bottom: 0.75rem; }
.card-head h2 { margin: 0; }
.grid { display: grid; gap: 1rem; margin-bottom: 1rem; }
.grid .card { margin-bottom: 0; }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(min(190px, 100%), 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(min(380px, 100%), 1fr)); }
.grid.fields { grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); gap: 0 1rem; margin: 0; }
.stat p { margin: 0.2rem 0; }
.big { font-size: 2rem; font-weight: 750; line-height: 1.1; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.ok { color: var(--ok); }
.ko { color: var(--ko); }
.row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.5rem; align-items: baseline; }
ul.plain, ul.meta { margin: 0; padding-left: 1.1rem; }
ul.plain li, ul.meta li { margin: 0.25rem 0; }
.empty { text-align: center; color: var(--muted); padding: 1.25rem 0.5rem; }
.empty-icon { display: block; margin: 0 auto 0.4rem; font-size: 1.8rem; opacity: 0.6; }

/* ---- Accueil ---- */
.hero { position: relative; overflow: hidden; background: linear-gradient(135deg, var(--pine) 0%, #2d6150 60%, #3e7a62 100%); color: #fbf6ef; border-radius: calc(var(--radius) + 4px); padding: 1.6rem 1.75rem; margin-bottom: 1.25rem; box-shadow: var(--shadow); }
.hero h1 { color: #fff; font-size: 1.75rem; }
.hero p { margin: 0.25rem 0 0; color: #dfeae4; max-width: 60ch; }
.hero::after { content: "❄ ✦ ❄ ✦ ❄"; position: absolute; right: 1.25rem; top: 0.9rem; letter-spacing: 0.4em; color: rgb(255 255 255 / 22%); font-size: 1.1rem; pointer-events: none; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .hero { background: linear-gradient(135deg, #12342a 0%, #1b4637 60%, #245441 100%); } }
:root[data-theme="dark"] .hero { background: linear-gradient(135deg, #12342a 0%, #1b4637 60%, #245441 100%); }
.pill { display: inline-flex; align-items: center; gap: 0.45rem; margin-top: 0.9rem; padding: 0.3rem 0.8rem; border-radius: 999px; font-size: 0.9rem; font-weight: 600; background: rgb(255 255 255 / 14%); color: #fff; }
.pill .dot { width: 0.6rem; height: 0.6rem; border-radius: 50%; background: #6fdc9f; box-shadow: 0 0 0 3px rgb(111 220 159 / 30%); }
.pill.off .dot { background: #ff8f80; box-shadow: 0 0 0 3px rgb(255 143 128 / 30%); }

.tile { display: flex; gap: 0.9rem; align-items: center; }
.tile-icon { flex: none; width: 2.75rem; height: 2.75rem; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; font-size: 1.35rem; background: var(--accent-soft); color: var(--accent); }
.tile.pine .tile-icon { background: var(--pine-soft); color: var(--pine); }
.tile.gold .tile-icon { background: var(--gold-soft); color: var(--gold); }
.tile p { margin: 0; }
.tile .label { color: var(--muted); font-size: 0.88rem; }

.shortcuts { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(230px, 100%), 1fr)); gap: 0.75rem; margin-bottom: 1.25rem; }
.shortcut { display: flex; gap: 0.75rem; align-items: flex-start; padding: 0.9rem 1rem; border-radius: var(--radius); border: 1px solid var(--border); background: var(--card); color: var(--text); text-decoration: none; box-shadow: var(--shadow); transition: transform 0.12s ease, border-color 0.12s ease; }
.shortcut:hover { color: var(--text); border-color: var(--gold); transform: translateY(-2px); }
.shortcut .lead-icon { font-size: 1.5rem; margin-top: 0.1rem; color: var(--accent); }
.shortcut strong { display: block; }
.shortcut span.muted { font-size: 0.86rem; }
@media (prefers-reduced-motion: reduce) { .shortcut { transition: none; } .shortcut:hover { transform: none; } }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; gap: 0.75rem; padding: 0.55rem 0; border-bottom: 1px dashed var(--border); }
.timeline li:last-child { border-bottom: none; }
.timeline .when { flex: none; min-width: 7.5rem; color: var(--muted); font-size: 0.88rem; }
.timeline .what { min-width: 0; }
.timeline .what small { display: block; color: var(--muted); }

.notice { display: flex; gap: 0.75rem; align-items: flex-start; }
.notice .lead-icon { font-size: 1.3rem; margin-top: 0.1rem; }
.notice p { margin: 0; }

/* ---- Tableaux ---- */
table { width: 100%; border-collapse: collapse; font-size: 0.93rem; }
th, td { text-align: left; padding: 0.55rem 0.6rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.04em; white-space: nowrap; }
tbody tr:hover { background: color-mix(in srgb, var(--gold-soft) 45%, transparent); }
tbody tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; white-space: nowrap; }

/* ---- Boutons et formulaires ---- */
button, .button { font: inherit; font-weight: 550; padding: 0.45rem 0.95rem; border-radius: 9px; border: 1px solid var(--border); background: var(--card); color: var(--text); cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 0.4rem; }
button:hover, .button:hover { border-color: var(--accent); color: var(--text); }
button.primary, .button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
button.primary:hover, .button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-text); }
button.danger { color: var(--ko); }
button.danger:hover { border-color: var(--ko); }
button.link { border: none; background: none; color: var(--accent); padding: 0; font-weight: 400; }
button.htmx-request { opacity: 0.6; cursor: progress; }
.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.9rem 0; }

input, select, textarea { font: inherit; padding: 0.45rem 0.6rem; border: 1px solid var(--border); border-radius: 9px; background: var(--bg); color: var(--text); max-width: 100%; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-soft); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); width: 1.05rem; height: 1.05rem; }
textarea { width: 100%; }
textarea.code { font-family: ui-monospace, monospace; font-size: 0.9rem; }
form.config label { display: flex; flex-direction: column; gap: 0.3rem; margin: 0.85rem 0; }
form.config label > span { font-weight: 550; }
form.config label .hint, .hint { font-weight: 400; color: var(--muted); font-size: 0.85rem; }
form.config label.check { flex-direction: row; align-items: flex-start; gap: 0.5rem; font-weight: 400; }
form.config label.check input { flex: none; margin: 0.2em 0 0; }
.grid.fields label { display: flex; flex-direction: column; gap: 0.3rem; margin: 0.85rem 0; }
form.adjust, form.search, form.filters { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin-top: 0.75rem; }
form.search { margin: 0 0 1rem; }
form.search input { flex: 1; min-width: min(240px, 100%); padding: 0.65rem 0.9rem; font-size: 1rem; }
form.filters { align-items: flex-end; }
form.filters label { display: flex; flex-direction: column; gap: 0.2rem; font-size: 0.85rem; color: var(--muted); }
form.inline { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; margin: 0; }
form.inline input[type="text"] { flex: 0 1 22rem; min-width: 0; }
fieldset { border: 1px solid var(--border); border-radius: 10px; padding: 0.5rem 1rem; margin: 0.85rem 0; }
legend { font-weight: 600; padding: 0 0.3rem; }

details > summary { cursor: pointer; font-weight: 600; list-style: none; display: flex; align-items: center; gap: 0.5rem; }
details > summary::-webkit-details-marker { display: none; }
details > summary .icon { color: var(--gold); }
details > summary::before { content: "▸"; color: var(--gold); transition: transform 0.15s; }
details[open] > summary::before { transform: rotate(90deg); }
details[open] > summary { margin-bottom: 0.5rem; }
details.create > summary { color: var(--accent); }
details.tech { margin-top: 0.75rem; padding-top: 0.6rem; border-top: 1px dashed var(--border); }
details.tech > summary { font-weight: 500; font-size: 0.88rem; color: var(--muted); }

/* ---- Modales (static/modals.js) ---- */
dialog.modal { width: min(36rem, calc(100vw - 32px)); max-height: calc(100dvh - 2rem); padding: 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); color: var(--text); box-shadow: 0 12px 40px rgb(0 0 0 / 28%); }
dialog.modal::backdrop { background: rgb(20 14 10 / 45%); }
.modal-body { padding: 1.1rem 1.25rem; }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; margin-bottom: 0.25rem; }
.modal-head h2 { margin: 0; }
.modal-close { border: 0; background: none; padding: 0.3rem; color: var(--muted); }
.modal-close:hover { color: var(--text); }
.modal-result:empty { display: none; }
.modal-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 0.5rem; margin-top: 1rem; }

/* ---- Alertes et badges ---- */
.alert { padding: 0.7rem 0.9rem; border-radius: 10px; margin: 0.5rem 0 1rem; border: 1px solid transparent; }
.alert-info { background: var(--info-bg); }
.alert-success { background: var(--ok-bg); color: var(--ok); }
.alert-error { background: var(--ko-bg); color: var(--ko); }
.alert-warning { background: var(--warn-bg); color: var(--warn); }
.alert small { display: block; opacity: 0.8; margin-top: 0.15rem; }

/* ---- Toasts : résultats des actions (#action-result, static/toasts.js) ---- */
#action-result {
  position: fixed; top: 1rem; right: 1rem; z-index: 1000;
  width: min(26rem, calc(100vw - 2rem));
  display: grid; gap: 0.5rem; pointer-events: none;
}
#action-result > .alert {
  pointer-events: auto; position: relative; margin: 0; padding-right: 2.25rem;
  border-color: var(--border); box-shadow: var(--shadow);
  animation: toast-in 0.2s ease-out;
  transition: opacity 0.2s, transform 0.2s;
}
#action-result > .alert.toast-leaving { opacity: 0; transform: translateX(1rem); }
.toast-close {
  position: absolute; top: 0.3rem; right: 0.35rem;
  padding: 0 0.4rem; border: 0; background: none; color: inherit;
  font-size: 1.2rem; line-height: 1.4; opacity: 0.7; cursor: pointer;
}
.toast-close:hover, .toast-close:focus-visible { opacity: 1; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-0.5rem); } }
@media (max-width: 600px) { #action-result { top: 0.75rem; right: 16px; width: calc(100vw - 32px); } }
@media (prefers-reduced-motion: reduce) {
  #action-result > .alert { animation: none; transition: none; }
}

.badge { display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.1rem 0.6rem; border-radius: 999px; font-size: 0.8rem; font-weight: 600; white-space: nowrap; background: color-mix(in srgb, var(--border) 60%, transparent); color: var(--muted); vertical-align: middle; }
.badge::before { content: ""; width: 0.45rem; height: 0.45rem; border-radius: 50%; background: currentColor; }
.badge.tone-ok { background: var(--ok-bg); color: var(--ok); }
.badge.tone-ko { background: var(--ko-bg); color: var(--ko); }
.badge.tone-warn { background: var(--warn-bg); color: var(--warn); }
.badge.tone-info { background: var(--info-bg); color: var(--info); }

/* ---- Connexion ---- */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem; background: radial-gradient(circle at 20% 10%, var(--gold-soft), transparent 45%), radial-gradient(circle at 80% 90%, var(--pine-soft), transparent 50%), var(--bg); }
.login { max-width: 420px; width: 100%; text-align: center; padding: 2.25rem 2rem; }
.login .brand-mark { font-size: 3rem; display: block; margin-bottom: 0.5rem; }
.login p { color: var(--muted); }

/* ---- Personnages ---- */
.persona-head { display: flex; align-items: center; gap: 0.9rem; }
.persona-head h2 { margin: 0; }
.persona-head img, .avatar-placeholder { border-radius: 50%; width: 60px; height: 60px; object-fit: cover; border: 3px solid var(--gold-soft); }
.avatar-placeholder { display: inline-flex; align-items: center; justify-content: center; background: var(--gold-soft); color: var(--gold); font-size: 1.6rem; }
.persona-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(380px, 100%), 1fr)); gap: 1rem; }
.persona-grid .card { margin-bottom: 0; }

pre.wrap { white-space: pre-wrap; word-break: break-word; background: var(--bg); padding: 0.85rem; border-radius: 10px; border: 1px solid var(--border); font: inherit; }

main.login-page { max-width: none; padding: 0; }
.timeline li > .num, .timeline li > strong:last-child { margin-left: auto; white-space: nowrap; }
.filters.card { margin-bottom: 1rem; }

/* ---- Onglets, tableaux clé/valeur, listes d'actions ---- */
.tabs { display: flex; flex-wrap: wrap; gap: 0.25rem; margin-bottom: 1rem; border-bottom: 1px solid var(--border); }
.tabs a { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.5rem 0.9rem; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 550; }
.tabs a:hover { color: var(--text); }
.tabs a[aria-current="page"] { color: var(--text); border-bottom-color: var(--accent); }
table.kv th { width: 34%; text-align: left; font-weight: 550; color: var(--muted); vertical-align: top; text-transform: none; letter-spacing: normal; font-size: 0.93rem; }
.action-list { list-style: none; padding: 0; }
.action-list li { margin: 0; padding: 0.75rem 0; border-top: 1px solid var(--border); }
.action-list li:first-child { border-top: 0; padding-top: 0.25rem; }
.action-row { display: grid; grid-template-columns: 13rem minmax(0, 1fr); gap: 0.5rem 1rem; align-items: start; margin: 0; }
.action-row > button { width: 100%; justify-content: flex-start; text-align: left; }
.action-body { display: grid; gap: 0.5rem; min-width: 0; }
.action-body > p { margin: 0; padding-top: 0.35rem; }
.action-fields { display: grid; grid-template-columns: minmax(0, 18rem) 9rem; gap: 0.5rem 0.75rem; }
.action-fields label { display: grid; gap: 0.2rem; margin: 0; font-size: 0.85rem; }
.action-fields label > span { color: var(--muted); }
.action-fields label.check { grid-column: 1 / -1; display: flex; align-items: center; gap: 0.5rem; }
.action-fields select, .action-fields input { width: 100%; }
@media (max-width: 600px) {
  .action-row, .action-fields { grid-template-columns: minmax(0, 1fr); }
}
.row-actions { white-space: nowrap; }
.row-actions button, .row-actions .button { padding: 0.25rem 0.6rem; font-size: 0.85rem; }
td.row-actions { text-align: right; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---- Éditeur de messages Discord (static/discord-editor.js) ---- */
.dc-editor { margin: 0.85rem 0; container-type: inline-size; }
.dc-label { display: block; font-weight: 550; margin-bottom: 0.3rem; }
form.config .dc-editor label { margin: 0.4rem 0; }
.dc-panes { display: grid; gap: 0.75rem; grid-template-columns: minmax(0, 1fr); }
@container (min-width: 820px) { .dc-panes { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.dc-write { position: relative; min-width: 0; display: flex; flex-direction: column; }
.dc-toolbar { display: flex; flex-wrap: wrap; gap: 0.25rem 0.5rem; padding: 0.3rem; border: 1px solid var(--border); border-bottom: none; border-radius: 9px 9px 0 0; background: var(--card); }
.dc-group { display: inline-flex; gap: 2px; }
.dc-group + .dc-group { padding-left: 0.5rem; border-left: 1px solid var(--border); }
.dc-toolbar button { padding: 0.35rem; border-color: transparent; background: none; color: var(--muted); border-radius: 7px; }
.dc-toolbar button:hover { color: var(--text); background: var(--gold-soft); border-color: transparent; }
.dc-write textarea { display: block; flex: 1; border-radius: 0 0 9px 9px; resize: vertical; min-height: 6rem; }
.dc-meta { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.5rem; margin: 0.3rem 0 0; }
.dc-count { font-size: 0.82rem; color: var(--muted); font-variant-numeric: tabular-nums; margin-left: auto; }
.dc-count.dc-near { color: var(--warn); font-weight: 600; }
.dc-pop { position: absolute; z-index: 5; top: 2.6rem; left: 0.3rem; width: min(360px, calc(100% - 0.6rem)); padding: 0.75rem 0.9rem; background: var(--card); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); }
.dc-pop label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.9rem; }
.dc-pop label.check { flex-direction: row; align-items: center; gap: 0.45rem; }
.dc-pop .hint { margin: 0.3rem 0; }
.dc-pop.dc-invalid input:invalid, .dc-pop.dc-invalid input:placeholder-shown { border-color: var(--ko); }
.dc-pop-actions { display: flex; gap: 0.5rem; margin-top: 0.5rem; }

/* Aperçu aux couleurs de Discord (thème sombre), quel que soit le thème du panel. */
.dc-preview { min-width: 0; border-radius: 10px; background: #313338; color: #dbdee1; padding: 0.6rem 0.9rem 0.9rem; font: 15px/1.375 "gg sans", "Noto Sans", system-ui, sans-serif; }
.dc-preview-title { margin: 0 0 0.5rem; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: #949ba4; display: flex; align-items: center; gap: 0.35rem; }
.dc-message { display: flex; gap: 0.9rem; }
.dc-avatar { flex: none; width: 40px; height: 40px; border-radius: 50%; background: #5865f2; color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 1.2rem; }
.dc-main { min-width: 0; flex: 1; }
.dc-author { margin: 0 0 0.1rem; display: flex; align-items: center; gap: 0.35rem; flex-wrap: wrap; }
.dc-author strong { color: #f2f3f5; font-weight: 600; }
.dc-tag { background: #5865f2; color: #fff; font-size: 0.62rem; font-weight: 700; padding: 0.05rem 0.3rem; border-radius: 3px; }
.dc-time { color: #949ba4; font-size: 0.75rem; }
.dc-body { overflow-wrap: anywhere; }
.dc-body p { margin: 0; }
.dc-body p.dc-blank { height: 1.375em; }
.dc-body .dc-empty { color: #949ba4; font-style: italic; }
.dc-body .dc-h1 { font-size: 1.5rem; font-weight: 700; line-height: 1.25; margin: 0.5rem 0 0.25rem; color: #f2f3f5; }
.dc-body .dc-h2 { font-size: 1.25rem; font-weight: 700; line-height: 1.25; margin: 0.5rem 0 0.25rem; color: #f2f3f5; }
.dc-body .dc-h3 { font-size: 1rem; font-weight: 700; margin: 0.5rem 0 0.25rem; color: #f2f3f5; }
.dc-body > .dc-h1:first-child, .dc-body > .dc-h2:first-child, .dc-body > .dc-h3:first-child, .dc-embed > :first-child { margin-top: 0; }
.dc-body .dc-subtext { font-size: 0.8rem; color: #949ba4; }
.dc-body strong { color: inherit; }
.dc-body a { color: #00a8fc; text-decoration: none; }
.dc-body a:hover { text-decoration: underline; color: #00a8fc; }
.dc-body code { background: #2b2d31; color: #dbdee1; border: 1px solid #1e1f22; padding: 0.1em 0.25em; border-radius: 4px; font-size: 0.85em; }
.dc-body pre.dc-codeblock { margin: 0.25rem 0; padding: 0.5rem; background: #2b2d31; border: 1px solid #1e1f22; border-radius: 4px; white-space: pre-wrap; }
.dc-body pre.dc-codeblock code { background: none; border: none; padding: 0; }
.dc-body blockquote { margin: 0.1rem 0; padding: 0 0 0 0.75rem; border-left: 4px solid #4e5058; }
.dc-body ul, .dc-body ol { margin: 0.1rem 0; padding-left: 1.4rem; }
.dc-body li.dc-depth-1 { margin-left: 1.25rem; } .dc-body li.dc-depth-2 { margin-left: 2.5rem; } .dc-body li.dc-depth-3 { margin-left: 3.75rem; }
.dc-body .dc-mention { background: rgb(88 101 242 / 30%); color: #c9cdfb; padding: 0 0.15em; border-radius: 3px; font-weight: 500; }
.dc-body .dc-timestamp { background: rgb(255 255 255 / 8%); padding: 0 0.2em; border-radius: 3px; }
.dc-body .dc-emoji { width: 1.375em; height: 1.375em; vertical-align: -0.3em; object-fit: contain; }
.dc-body .dc-spoiler { background: #1e1f22; color: transparent; border-radius: 3px; cursor: pointer; padding: 0 0.1em; }
.dc-body .dc-spoiler * { color: transparent; background: none; border-color: transparent; }
.dc-body .dc-spoiler.dc-revealed { background: rgb(255 255 255 / 10%); color: inherit; cursor: auto; }
.dc-body .dc-spoiler.dc-revealed * { color: revert; }
.dc-body .dc-image { display: block; max-width: min(100%, 400px); max-height: 300px; margin-top: 0.4rem; border-radius: 8px; }
.dc-body .dc-image-placeholder { margin-top: 0.4rem; padding: 0.75rem; max-width: 400px; border: 1px dashed #4e5058; border-radius: 8px; color: #b5bac1; font-size: 0.85rem; overflow-wrap: anywhere; }
.dc-body .dc-image-placeholder small { color: #949ba4; }
.dc-body .dc-embed { margin-top: 0.15rem; max-width: 520px; padding: 0.5rem 1rem 0.75rem 0.75rem; background: #2b2d31; border-left: 4px solid #1f8b4c; border-radius: 4px; font-size: 0.875rem; }
.dc-body .dc-warning { margin-top: 0.4rem; font-size: 0.8rem; color: #f0b232; }
form.config .dc-editor label.dc-label, .dc-editor .dc-label { display: block; margin: 0 0 0.3rem; }
@media (pointer: coarse) { .dc-toolbar button { padding: 0.5rem; } }
/* Éditeur étroit : barre d'outils sur une seule ligne, qui défile. */
@container (max-width: 560px) {
  .dc-toolbar { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; mask-image: linear-gradient(to right, #000 85%, transparent); }
  .dc-group { flex: none; }
}

/* Page d'un module : textes par jour */
.day-grid { list-style: none; padding: 0; margin: 0 0 0.5rem; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 0.35rem; max-width: 26rem; }
.day-grid .day { display: flex; align-items: center; justify-content: center; aspect-ratio: 1; border-radius: 8px; border: 1px solid var(--border); text-decoration: none; color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.day-grid .day:hover { border-color: var(--accent); }
.day-grid .day.written { background: var(--pine-soft); border-color: var(--pine); color: var(--pine); }
.day-grid .day.off { opacity: 0.45; }
.day-grid .day[aria-current] { outline: 2px solid var(--accent); outline-offset: 1px; }
.legend { display: inline-flex; align-items: center; gap: 0.3rem; margin-right: 0.6rem; }
.legend::before { content: ""; width: 0.8rem; height: 0.8rem; border-radius: 3px; border: 1px solid var(--border); }
.legend.written::before { background: var(--pine-soft); border-color: var(--pine); }
.legend.off::before { opacity: 0.45; }
.text-form.variant { padding-bottom: 1rem; margin-bottom: 1rem; border-bottom: 1px solid var(--border); }
.variables li, .coverage li { margin: 0.35rem 0; }
