:root {
  --brand: #1f5fd6;
  --brand-ink: #fff;
  --ink: #1b1d22;
  --ink-2: #5a6170;
  --ink-3: #868d9b;
  --line: #e3e6ec;
  --bg: #f5f6f9;
  --panel: #fff;
  --danger: #c0362c;
  --danger-bg: #fdecea;
  --ok: #1a7f4b;
  --ok-bg: #e7f6ee;
  --warn: #93640c;
  --warn-bg: #fdf4dc;
  --radius: 10px;
  color-scheme: light;
}

* { box-sizing: border-box; }
/* `label.field` pose un display qui l'emporterait sur l'attribut hidden. */
[hidden] { display: none !important; }
html, body, #app { margin: 0; height: 100%; }
body {
  font: 14px/1.5 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
h1 { font-size: 22px; margin: 0; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 15px; margin: 0 0 4px; font-weight: 650; }
p { margin: 0; }
a { color: var(--brand); }
code { font: 12.5px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: #f0f2f6; padding: 2px 5px; border-radius: 4px; word-break: break-all; }
.muted { color: var(--ink-2); }
.small { font-size: 12.5px; }

/* ── Mise en page ─────────────────────────────────────────── */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100%; }
.sidebar { background: var(--panel); border-right: 1px solid var(--line); padding: 16px 12px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.sidebar__brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; font-weight: 650; min-width: 0; }
.sidebar__brand img { width: 28px; height: 28px; object-fit: contain; border-radius: 6px; flex: none; }
.sidebar__brand span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item { display: block; width: 100%; text-align: left; background: none; border: 0; border-radius: 8px; padding: 8px 10px; font: inherit; color: var(--ink-2); cursor: pointer; }
.nav-item:hover { background: var(--bg); color: var(--ink); }
.nav-item[aria-current="page"] { background: color-mix(in srgb, var(--brand) 11%, white); color: var(--brand); font-weight: 600; }
.sidebar__foot { margin-top: auto; border-top: 1px solid var(--line); padding: 12px 8px 0; display: grid; gap: 8px; }
.sidebar__who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.main { padding: 28px 32px 64px; max-width: 1120px; width: 100%; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.page-head p { margin-top: 4px; color: var(--ink-2); max-width: 66ch; }
/* minmax(0, 1fr) : une colonne implicite s'étirerait à la largeur de son contenu. */
.stack { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.between { justify-content: space-between; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.card > h2 + p { color: var(--ink-2); margin-bottom: 14px; }
.stack:empty { display: none; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; align-items: start; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px 16px; align-items: start; }
.span-2 { grid-column: span 2; }

/* ── Formulaires ──────────────────────────────────────────── */
label.field { display: grid; gap: 4px; font-weight: 550; font-size: 13px; }
label.field .hint { font-weight: 400; color: var(--ink-2); font-size: 12.5px; }
input[type=text], input[type=email], input[type=password], input[type=url], input[type=number], input[type=search], select, textarea {
  width: 100%; font: inherit; color: inherit; background: #fff; border: 1px solid #cdd2dc; border-radius: 7px; padding: 7px 10px; font-weight: 400;
}
textarea { min-height: 110px; font: 12.5px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
input[aria-invalid=true] { border-color: var(--danger); }
.check { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; cursor: pointer; }
.check input { margin: 3px 0 0; width: 16px; height: 16px; accent-color: var(--brand); flex: none; }
.check b { display: block; font-weight: 550; }
.check span span { color: var(--ink-2); font-size: 12.5px; }
.color { display: flex; gap: 8px; align-items: center; }
.color input[type=color] { width: 38px; height: 34px; padding: 2px; border: 1px solid #cdd2dc; border-radius: 7px; background: #fff; cursor: pointer; flex: none; }
.btn { font: inherit; font-weight: 550; border-radius: 7px; border: 1px solid #cdd2dc; background: #fff; color: var(--ink); padding: 7px 13px; cursor: pointer; white-space: nowrap; text-decoration: none; display: inline-block; }
.btn:hover { background: var(--bg); }
.btn--primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn--primary:hover { background: color-mix(in srgb, var(--brand) 86%, black); }
.btn--danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, white); }
.btn--danger:hover { background: var(--danger-bg); }
.btn--ghost { border-color: transparent; background: none; color: var(--ink-2); }
.btn[disabled] { opacity: .55; cursor: default; }
.btn--small { padding: 4px 9px; font-size: 12.5px; }

/* ── Tuiles, tableaux, badges ─────────────────────────────── */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.tile b { display: block; font-size: 24px; font-weight: 650; font-variant-numeric: tabular-nums; }
.tile span { color: var(--ink-2); font-size: 12.5px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; font-weight: 600; color: var(--ink-2); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid #f0f2f5; vertical-align: top; }
tr:last-child td { border-bottom: 0; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 12px; font-weight: 550; background: #eef0f4; color: var(--ink-2); white-space: nowrap; }
.badge--ok { background: var(--ok-bg); color: var(--ok); }
.badge--danger { background: var(--danger-bg); color: var(--danger); }
.badge--warn { background: var(--warn-bg); color: var(--warn); }
.badge--brand { background: color-mix(in srgb, var(--brand) 12%, white); color: var(--brand); }
.notice { border-radius: 8px; padding: 10px 14px; background: #eef2fb; color: #274172; }
.notice--danger { background: var(--danger-bg); color: #8c2219; }
.notice--warn { background: var(--warn-bg); color: #6e4b06; }
.notice--ok { background: var(--ok-bg); color: #125a35; }
.notice pre { margin: 6px 0 0; white-space: pre-wrap; word-break: break-word; font-size: 12px; }
.empty { padding: 28px; text-align: center; color: var(--ink-2); }
.checklist { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.checklist li { display: flex; gap: 10px; align-items: baseline; justify-content: space-between; flex-wrap: wrap; padding: 8px 0; border-bottom: 1px solid #f0f2f5; }
.checklist li:last-child { border-bottom: 0; }

/* ── Domaines ─────────────────────────────────────────────── */
.chips { display: flex; flex-wrap: wrap; gap: 6px; border: 1px solid #cdd2dc; border-radius: 7px; padding: 6px; background: #fff; }
.chips input { border: 0; flex: 1 1 160px; min-width: 120px; padding: 3px 6px; outline: none; }
.chip { display: inline-flex; align-items: center; gap: 4px; background: #eef0f4; border-radius: 6px; padding: 2px 4px 2px 8px; }
.chip button { border: 0; background: none; cursor: pointer; color: var(--ink-2); font-size: 14px; line-height: 1; padding: 2px 4px; }

/* ── Import ───────────────────────────────────────────────── */
.drop { border: 1.5px dashed #bcc3d0; border-radius: var(--radius); padding: 28px; text-align: center; background: #fafbfc; display: block; cursor: pointer; }
.drop:hover, .drop--over { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 5%, white); }
.drop input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.progress { height: 8px; border-radius: 99px; background: #e9ecf1; overflow: hidden; }
.progress div { height: 100%; background: var(--brand); transition: width .3s; }
.radio-cards { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.radio-card { border: 1px solid #cdd2dc; border-radius: 8px; padding: 10px 12px; display: flex; gap: 8px; cursor: pointer; }
.radio-card:has(input:checked) { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 6%, white); }
.radio-card:has(input:disabled) { opacity: .55; cursor: default; }
.radio-card input { margin-top: 3px; accent-color: var(--brand); flex: none; }
.radio-card b { display: block; font-weight: 550; }
.radio-card span span { color: var(--ink-2); font-size: 12.5px; }

/* ── Marque blanche ───────────────────────────────────────── */
.brand-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; align-items: start; }
.preview { position: sticky; top: 16px; display: grid; gap: 12px; }
.mock { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--panel); }
.mock__caption { font-size: 12px; font-weight: 600; color: var(--ink-2); padding: 7px 12px; border-bottom: 1px solid var(--line); }
.mock-login { padding: 26px 22px; text-align: center; display: grid; gap: 8px; justify-items: center; }
.mock-login img { height: 56px; max-width: 200px; object-fit: contain; }
.mock-login h3 { margin: 4px 0 0; font-size: 18px; }
.mock-login p { font-size: 12.5px; opacity: .75; }
.mock-btn { display: block; width: 100%; padding: 9px; border-radius: 7px; font-weight: 600; font-size: 13px; }
.mock-chat { display: grid; grid-template-columns: 96px 1fr; min-height: 150px; font-size: 12px; }
.mock-chat aside { background: #f3f4f7; padding: 10px; display: grid; gap: 6px; align-content: start; }
.mock-room { padding: 4px 6px; border-radius: 5px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.mock-chat main { padding: 10px; display: grid; gap: 6px; align-content: end; }
.mock-bubble { justify-self: start; background: #eef0f4; border-radius: 8px; padding: 5px 9px; max-width: 90%; }
.mock-bubble--me { justify-self: end; color: #fff; }
.assets { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.asset { border: 1px solid var(--line); border-radius: 8px; padding: 10px; display: grid; gap: 8px; align-content: start; }
.asset__thumb { height: 64px; background: repeating-conic-gradient(#f1f2f5 0 25%, #fff 0 50%) 0 0 / 14px 14px; border-radius: 6px; display: flex; align-items: center; justify-content: center; overflow: hidden; color: var(--ink-3); font-size: 12px; }
.asset__thumb img { max-height: 56px; max-width: 90%; object-fit: contain; }
.asset b { font-weight: 550; font-size: 13px; }
.asset .file-btn { position: relative; overflow: hidden; }
.asset .file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* ── Dialogue, connexion, messages ────────────────────────── */
dialog { border: 0; border-radius: 12px; padding: 0; width: min(560px, calc(100vw - 32px)); box-shadow: 0 20px 60px rgba(20, 24, 35, .25); color: inherit; }
dialog::backdrop { background: rgba(20, 24, 35, .4); }
.dialog__body { padding: 20px 22px; display: grid; gap: 14px; }
.dialog__foot { padding: 12px 22px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.secret { display: flex; gap: 8px; align-items: center; background: #f4f5f8; border-radius: 8px; padding: 10px 12px; }
.secret code { flex: 1; background: none; font-size: 14px; }
.login { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.login__card { width: min(400px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 28px; display: grid; gap: 16px; }
.login__card img { height: 52px; justify-self: center; max-width: 200px; object-fit: contain; }
.login__card h1 { text-align: center; font-size: 19px; }
.login__card .btn { width: 100%; text-align: center; }
details summary { cursor: pointer; color: var(--ink-2); font-size: 13px; }
details[open] summary { margin-bottom: 10px; }
.toasts { position: fixed; bottom: 18px; right: 18px; display: grid; gap: 8px; z-index: 20; max-width: min(420px, calc(100vw - 36px)); }
.toast { background: #22262e; color: #fff; padding: 10px 14px; border-radius: 8px; box-shadow: 0 6px 24px rgba(0, 0, 0, .25); }
.toast--error { background: #8c2219; }
.toast--ok { background: #125a35; }

@media (max-width: 960px) {
  .brand-layout { grid-template-columns: minmax(0, 1fr); }
  .preview { position: static; }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; border-right: 0; border-bottom: 1px solid var(--line); padding: 10px 16px; }
  .sidebar__brand { width: 100%; padding: 0 0 6px; }
  .nav-item { width: auto; padding: 5px 8px; }
  .sidebar__foot { width: 100%; margin-top: 4px; padding: 8px 0 0; grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
  .main { padding: 18px 16px 48px; }
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: auto; }
}
