/* kb-base.css — socle visuel commun de la refonte « Ketchup moutarde ».
   Remplace v4.css, v4-interface.css et polish-v4.css. Chargé après les
   feuilles historiques par domaine, avant les fichiers kb-<famille>.css.
   Règles : jetons de tokens.css uniquement, pas d'ombre sur les cartes,
   zones tactiles ≥ 44 px, marges latérales 20 px, une action principale
   jaune (--color-raspberry) par écran. */

:root {
  /* Alias historiques encore lus par les feuilles de domaine. */
  --v4-gutter: var(--gutter);
  --v4-rule: var(--color-border);
  --sage-soft: var(--color-primary-soft);
  --paprika: var(--color-raspberry);
  --lime: var(--color-apple);
  --radish: var(--color-raspberry-soft);
  --aubergine: var(--color-primary);
  --radius-lg: var(--radius-card);
  --plan-purple: var(--color-primary);
  --plan-purple-light: var(--color-primary-soft);
  --plan-green: var(--color-primary);
  --plan-green-dim: var(--color-primary);
  --plan-green-light: var(--color-primary-soft);
  --plan-green-chip: var(--color-apple);
  --plan-warm: var(--color-raspberry);
  --plan-warm-light: var(--color-raspberry-soft);
  --safe-top: var(--safe-area-inset-top, env(safe-area-inset-top, 0px));
  --safe-bottom: var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px));
  --safe-left: var(--safe-area-inset-left, env(safe-area-inset-left, 0px));
  --safe-right: var(--safe-area-inset-right, env(safe-area-inset-right, 0px));
}

/* ── Base ─────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: var(--font-body);
  font-size: 16px;
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
}

body {
  display: flex;
  flex-direction: column;
  position: relative;
  width: 100%;
  max-width: 720px;
  min-height: 100dvh;
  margin: 0 auto;
  font-size: 15px;
  line-height: 1.35;
}

#root { min-height: 0; height: 100dvh; }

#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  min-height: 0;
  padding: var(--safe-top) var(--safe-right) var(--safe-bottom) var(--safe-left);
  background: var(--color-bg);
}

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

h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 600; color: var(--color-text); }
h1 { font-size: 24px; line-height: 30px; letter-spacing: -.02em; }
h2 { font-size: 17px; line-height: 24px; letter-spacing: -.01em; }
h3 { font-size: 15px; line-height: 20px; }
p { text-wrap: pretty; }

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

button, input, textarea, select { font-family: var(--font-body); color: inherit; }
button, a, input, select, textarea, label { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled, .btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }

:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }

.num, [data-num], time { font-variant-numeric: tabular-nums; }

.v4-safe-overlay {
  top: var(--safe-top) !important;
  bottom: var(--safe-bottom) !important;
  left: var(--safe-left) !important;
  right: var(--safe-right) !important;
}
.v4-safe-overlay > div { max-height: 100% !important; overflow-y: auto; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ── Typographie utilitaire ───────────────────────────────── */

.kb-display { font-size: 32px; line-height: 38px; font-weight: 600; letter-spacing: -.025em; }
.kb-title { font-size: 24px; line-height: 30px; font-weight: 600; letter-spacing: -.02em; }
.kb-card-title { font-size: 20px; line-height: 26px; font-weight: 600; letter-spacing: -.015em; }
.kb-section-title { font-size: 17px; line-height: 24px; font-weight: 600; letter-spacing: -.01em; }
.kb-eyebrow { font-size: 11px; line-height: 14px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--color-primary); }
.kb-meta { font-size: 13px; line-height: 18px; color: var(--color-muted); }
.kb-subtle { color: var(--color-subtle); }
.display { font-family: var(--font-display); }
.text-ink   { color: var(--color-text); }
.text-ink-2 { color: var(--color-muted); }
.text-ink-3 { color: var(--color-subtle); }

/* ── En-tête de l'app (TopBar) ────────────────────────────── */

.top-bar {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  height: 52px;
  padding: 4px 12px;
  background: var(--color-bg);
}
.top-bar__group { display: flex; align-items: center; gap: 4px; }
.top-bar__btn {
  position: relative;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--color-muted);
  transition: background var(--trans-fast), color var(--trans-fast);
}
.top-bar__btn[aria-current="page"], .top-bar__btn[aria-expanded="true"] {
  background: var(--color-primary-soft);
  color: var(--color-primary);
}
.top-bar__pastille {
  position: absolute;
  top: 6px;
  right: 5px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border: 2px solid var(--color-bg);
  border-radius: 999px;
  background: var(--color-raspberry);
  color: var(--color-on-raspberry);
  font: 600 11px/14px var(--font-body);
  font-variant-numeric: tabular-nums;
  text-align: center;
}

/* ── Écrans ───────────────────────────────────────────────── */

.screen {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background: var(--color-bg);
}

.screen__header {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  min-height: 52px;
  margin: 0;
  padding: 4px var(--gutter) 12px;
  background: var(--color-bg);
}
.screen__header:has(> .screen__back) { padding-left: 12px; }
.screen__heading { flex: 1; min-width: 0; }
.screen__title {
  font-family: var(--font-display);
  font-size: 24px;
  line-height: 30px;
  font-weight: 600;
  letter-spacing: -.02em;
  color: var(--color-text);
  overflow-wrap: anywhere;
}
.screen__subtitle { margin-top: 2px; font-size: 13px; line-height: 18px; color: var(--color-muted); }
.screen__action { flex-shrink: 0; display: flex; align-items: center; gap: 8px; }
.screen__back {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--color-text);
}
.screen__back:active { background: var(--color-surface-2); }
.screen__back svg { width: 22px; height: 22px; }

.screen__body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 0 var(--gutter) calc(28px + var(--safe-bottom));
  background: var(--color-bg);
}

.kb-stack { display: flex; flex-direction: column; gap: 12px; }
.kb-sections { display: flex; flex-direction: column; gap: 24px; }
.kb-section { display: flex; flex-direction: column; gap: 12px; }
.kb-section__head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.kb-section__head > a, .kb-section__head > button { border: 0; background: none; color: var(--color-primary); font: 600 13px var(--font-body); min-height: 44px; }

/* ── Boutons ──────────────────────────────────────────────── */

.btn, .screen__action > button:not(.screen__back):not([class*="icon"]) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 20px;
  border: 1px solid transparent;
  border-radius: var(--radius-btn);
  font: 600 15px/20px var(--font-body);
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: background var(--trans-fast), transform var(--trans-fast), opacity var(--trans-fast);
}
.btn:active:not(:disabled) { transform: scale(.98); }
.btn svg { flex: none; }

/* Action principale : jaune moutarde, texte presque noir. */
.btn--primary, .kb-cta {
  min-height: 52px;
  background: var(--color-raspberry);
  color: var(--color-on-raspberry);
  font-size: 17px;
  letter-spacing: -.01em;
}
.btn--lg, .kb-cta { min-height: 56px; font-size: 17px; }
.btn--secondary {
  background: var(--color-surface);
  border-color: var(--color-border);
  color: var(--color-text);
}
.btn--ghost, .btn--tertiary {
  background: transparent;
  border-color: transparent;
  color: var(--color-primary);
  padding-inline: 12px;
}
/* Marque : réservée aux états mis en avant (pas l'action principale). */
.btn--accent, .btn--brand { background: var(--color-primary); color: var(--color-on-primary); }
.btn--danger { background: var(--color-danger); color: var(--color-surface); }
.btn--danger-soft { background: var(--color-danger-soft); color: var(--color-danger); }
.btn--sm { min-height: 36px; padding: 6px 14px; font-size: 13px; }
.btn--block, .btn--full { width: 100%; }
.btn--secondary.btn--sm, .btn--ghost.btn--sm { font-weight: 600; }
.btn--primary.btn--sm { min-height: 40px; font-size: 15px; }

.icon-btn, .kb-icon-btn {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: none;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--color-muted);
}
.kb-icon-btn--surface { background: var(--color-surface); border: 1px solid var(--color-border); color: var(--color-text); }

/* Barre basse : action principale près du pouce. */
.kb-bottom-bar {
  position: sticky;
  bottom: 0;
  z-index: 5;
  display: flex;
  gap: 8px;
  margin: 16px calc(-1 * var(--gutter)) 0;
  padding: 12px var(--gutter) calc(12px + var(--safe-bottom));
  background: var(--color-bg);
  border-top: 1px solid var(--color-border);
}
/* La barre basse termine le défilement : pas de marge sous elle. */
.screen__body:has(.kb-bottom-bar) { padding-bottom: 0; }
.kb-bottom-bar > .btn { flex: 1; }
.kb-bottom-bar > .btn--secondary { flex: 0 1 auto; }

/* Bouton flottant */
.kb-fab {
  position: fixed;
  right: max(var(--gutter), calc((100vw - 720px) / 2 + var(--gutter)));
  bottom: calc(24px + var(--safe-bottom));
  z-index: 40;
  display: grid;
  place-items: center;
  width: 60px;
  height: 60px;
  border: 0;
  border-radius: 999px;
  background: var(--color-raspberry);
  color: var(--color-on-raspberry);
  box-shadow: var(--shadow-float);
}
.kb-fab--extended { width: auto; padding: 0 22px 0 18px; gap: 8px; display: inline-flex; align-items: center; font: 600 17px var(--font-body); }

/* ── Cartes, tuiles, listes ───────────────────────────────── */

.card, .kb-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  box-shadow: none;
  padding: 16px;
  color: var(--color-text);
}
details.card > summary { cursor: pointer; font-weight: 600; min-height: 44px; display: flex; align-items: center; list-style: none; }
details.card > summary::-webkit-details-marker { display: none; }

.kb-tile {
  background: var(--color-surface-2);
  border: 0;
  border-radius: var(--radius-tile);
  padding: 14px;
  color: var(--color-text);
  text-align: left;
}
button.kb-tile { cursor: pointer; }
.kb-tile[aria-pressed="true"], .kb-tile.is-active { background: var(--color-primary-soft); box-shadow: inset 0 0 0 1px var(--color-primary); color: var(--color-primary); }

.kb-list {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  overflow: hidden;
}
.kb-row {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 56px;
  padding: 10px 12px 10px 16px;
  border: 0;
  background: transparent;
  color: var(--color-text);
  font: inherit;
  text-align: left;
}
.kb-list > .kb-row + .kb-row, .kb-list > * + * > .kb-row, .kb-list > li + li { border-top: 1px solid var(--color-border); }
button.kb-row { cursor: pointer; }
button.kb-row:active { background: var(--color-surface-2); }
.kb-row__icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: 10px;
  background: var(--color-surface-2);
  color: var(--color-text);
}
.kb-row__icon--brand { background: var(--color-primary-soft); color: var(--color-primary); }
.kb-row__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.kb-row__title { font-size: 15px; line-height: 20px; font-weight: 600; }
.kb-row__meta { font-size: 13px; line-height: 18px; color: var(--color-muted); font-variant-numeric: tabular-nums; }
.kb-row__chev { flex: none; color: var(--color-subtle); }

/* ── Pastilles (régime, cacheroute, DLC) ──────────────────── */

.pill, .kb-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 22px;
  padding: 0 9px;
  border-radius: var(--radius-pill);
  background: var(--nq-bg);
  color: var(--nq-fg);
  font: 600 11px/16px var(--font-body);
  white-space: nowrap;
}
.pill--parve   { background: var(--parve-bg);   color: var(--parve-fg); }
.pill--laitier { background: var(--laitier-bg); color: var(--laitier-fg); }
.pill--viande  { background: var(--viande-bg);  color: var(--viande-fg); }
.pill--nq      { background: var(--nq-bg);      color: var(--nq-fg); }
.pill--brand   { background: var(--color-primary-soft); color: var(--color-primary); }
.pill--accent  { background: var(--color-raspberry-soft); color: var(--color-text); }
.pill--apple   { background: var(--color-apple-soft); color: var(--color-apple); }
.pill--danger  { background: var(--color-danger-soft); color: var(--color-danger); }
.badge--dlc-urgent  { background: var(--dlc-urgent-bg);  color: var(--dlc-urgent-fg); }
.badge--dlc-bientot { background: var(--dlc-bientot-bg); color: var(--dlc-bientot-fg); }
.badge--dlc-ambre   { background: var(--dlc-ambre-bg);   color: var(--dlc-ambre-fg); }
.badge--dlc-ok      { background: var(--dlc-ok-bg);      color: var(--dlc-ok-fg); }

/* ── Choix : chips, segmentés, interrupteurs, cases ───────── */

.kb-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.kb-chips--scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-inline: calc(-1 * var(--gutter)); padding-inline: var(--gutter); }
.kb-chips--scroll::-webkit-scrollbar { display: none; }
.kb-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex: none;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: var(--color-surface);
  color: var(--color-text);
  font: 500 15px/20px var(--font-body);
  white-space: nowrap;
  cursor: pointer;
}
.kb-chip[aria-pressed="true"], .kb-chip[aria-checked="true"], .kb-chip.is-active, .kb-chip:has(input:checked) {
  background: var(--color-primary-soft);
  border-color: var(--color-primary);
  color: var(--color-primary);
  font-weight: 600;
}
.kb-chip input { position: absolute; opacity: 0; pointer-events: none; }

.kb-seg, .appearance-control, .v4-segmented {
  display: flex;
  gap: 2px;
  min-height: 44px;
  padding: 3px;
  border: 0;
  border-radius: 999px;
  background: var(--color-surface-2);
}
.kb-seg > button, .kb-seg > label, .appearance-control__option, .v4-segmented > button {
  flex: 1 1 0;
  min-width: 0;
  min-height: 38px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--color-muted);
  font: 500 13px/1.2 var(--font-body);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.kb-seg > [aria-pressed="true"], .kb-seg > [aria-selected="true"], .kb-seg > [aria-checked="true"], .kb-seg > .is-active,
.appearance-control__option.is-active, .v4-segmented > button[aria-pressed="true"] {
  background: var(--color-surface);
  color: var(--color-text);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(26, 15, 12, .08);
}

/* Interrupteur : <input type="checkbox" role="switch" class="kb-switch"> */
:where(input[type="checkbox"].kb-switch, input[type="checkbox"][role="switch"]) {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  width: 50px;
  height: 30px;
  flex: none;
  border: 0;
  border-radius: 999px;
  background: var(--color-surface-2);
  box-shadow: inset 0 0 0 1px var(--color-border);
  cursor: pointer;
  transition: background var(--trans-fast);
}
:where(input[type="checkbox"].kb-switch, input[type="checkbox"][role="switch"])::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: var(--color-surface);
  box-shadow: 0 1px 3px rgba(26, 15, 12, .25);
  transition: transform var(--trans-fast);
}
:where(input[type="checkbox"].kb-switch, input[type="checkbox"][role="switch"]):checked { background: var(--color-primary); box-shadow: none; }
:where(input[type="checkbox"].kb-switch, input[type="checkbox"][role="switch"]):checked::after { transform: translateX(20px); }

:where(input[type="checkbox"]:not(.kb-switch):not([role="switch"])) {
  appearance: none;
  -webkit-appearance: none;
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  flex: none;
  margin: 0;
  border: 1.5px solid var(--color-subtle);
  border-radius: 7px;
  background: var(--color-surface);
  cursor: pointer;
  vertical-align: middle;
}
:where(input[type="checkbox"]:not(.kb-switch):not([role="switch"])):checked {
  border-color: var(--color-primary);
  background: var(--color-primary) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7'/%3E%3C/svg%3E") center / 15px no-repeat;
}
:where(input[type="radio"]) {
  appearance: none;
  -webkit-appearance: none;
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  flex: none;
  margin: 0;
  border: 1.5px solid var(--color-subtle);
  border-radius: 999px;
  background: var(--color-surface);
  cursor: pointer;
  vertical-align: middle;
}
:where(input[type="radio"]):checked { border: 7px solid var(--color-primary); }
:where(input[type="range"]) { accent-color: var(--color-primary); width: 100%; min-height: 44px; }
input:disabled { opacity: .5; cursor: not-allowed; }

/* ── Champs ───────────────────────────────────────────────── */

:where(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="color"]),
textarea, select), .form-input, .form-select {
  width: 100%;
  max-width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-field);
  background-color: var(--color-surface);
  color: var(--color-text);
  font: 400 16px/22px var(--font-body);
  outline: none;
  transition: border-color var(--trans-fast), box-shadow var(--trans-fast);
}
:where(textarea) { padding: 12px 14px; min-height: 96px; resize: vertical; }
:where(select) {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236B5C53' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 18px;
}
:where(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]), textarea, select):focus-visible, .form-input:focus, .form-select:focus {
  outline: none;
  border-color: var(--color-focus);
  box-shadow: inset 0 0 0 1px var(--color-focus);
}
input::placeholder, textarea::placeholder { color: var(--color-subtle); }
input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; }
input[type="file"] { font: 13px var(--font-body); max-width: 100%; }

.kb-search { position: relative; }
.kb-search > svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--color-subtle); pointer-events: none; }
.kb-search > input { padding-left: 44px; border-radius: 999px; background-color: var(--color-surface-2); border-color: transparent; }

.form-row { display: flex; gap: 12px; }
.form-field { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 0; }
.form-label, .kb-label { font-size: 13px; line-height: 18px; font-weight: 500; color: var(--color-muted); text-transform: none; letter-spacing: 0; }
.form-error, .kb-error {
  padding: 12px 14px;
  border: 0;
  border-radius: var(--radius-field);
  background: var(--color-danger-soft);
  color: var(--color-danger);
  font-size: 14px;
  line-height: 20px;
}
.form-toggle { display: flex; align-items: center; gap: 12px; min-height: 44px; font-size: 15px; font-weight: 500; color: var(--color-text); cursor: pointer; }
@media (max-width: 360px) { .form-row:has(input[type="date"]) { flex-direction: column; } }

/* ── Feuilles (modales depuis le bas) ─────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-top: calc(24px + var(--safe-top));
  background: var(--color-scrim);
  animation: kb-fade 200ms ease;
}
.modal {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 720px;
  max-height: calc(100dvh - 24px - var(--safe-top));
  overflow: hidden;
  border: 0;
  border-radius: var(--radius-sheet) var(--radius-sheet) 0 0;
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: var(--shadow-float);
  animation: kb-sheet-in 280ms var(--ease-sheet);
}
.modal::before {
  content: "";
  position: absolute;
  top: 8px;
  left: 50%;
  width: 36px;
  height: 4px;
  margin-left: -18px;
  border-radius: 999px;
  background: var(--color-border);
  z-index: 2;
}
.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
  margin: 0;
  padding: 24px var(--gutter) 8px;
  border: 0;
  touch-action: none;
}
.modal__title { margin: 0; font: 600 20px/26px var(--font-display); letter-spacing: -.015em; color: var(--color-text); }
.modal__close {
  display: inline-grid;
  place-items: center;
  min-width: 44px;
  min-height: 44px;
  margin-right: -10px;
  padding: 0 10px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--color-primary);
  font: 600 15px var(--font-body);
  white-space: nowrap;
}
.modal__body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 8px var(--gutter) 20px;
}
.modal__actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  padding: 12px var(--gutter) calc(12px + var(--safe-bottom));
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
}
.modal__actions .btn { flex: 1; }
.modal__body > .modal__actions { position: sticky; bottom: -20px; z-index: 1; margin: 8px calc(-1 * var(--gutter)) -20px; }
.modal.is-dragging { transition: none; }
@keyframes kb-sheet-in { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes kb-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
@media (min-width: 760px) {
  .modal-overlay { align-items: center; padding: 24px; }
  .modal { max-width: 560px; border-radius: var(--radius-sheet); max-height: calc(100dvh - 48px); }
}

/* ── Progression d'étapes ─────────────────────────────────── */

.kb-steps { display: flex; gap: 4px; }
.kb-steps > span { flex: 1; height: 4px; border-radius: 999px; background: var(--color-surface-2); }
.kb-steps > span.is-done, .kb-steps > span.is-current { background: var(--color-primary); }

/* ── États : vide, chargement, erreur, hors ligne ─────────── */

.empty-screen, .kb-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 0;
  margin: 12px 0;
  padding: 32px 20px;
  border: 0;
  border-radius: var(--radius-card);
  background: transparent;
  color: var(--color-muted);
  text-align: center;
}
.empty-screen__icon, .kb-empty__icon {
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  margin-bottom: 4px;
  border-radius: 999px;
  background: var(--color-surface-2);
  color: var(--color-primary);
  font-size: 32px;
  line-height: 1;
}
.empty-screen__title, .kb-empty__title { font: 600 20px/26px var(--font-display); letter-spacing: -.015em; color: var(--color-text); }
.empty-screen__desc, .kb-empty__desc { max-width: 36ch; font-size: 15px; line-height: 21px; color: var(--color-muted); }

.kb-skel { display: block; border-radius: var(--radius-tile); background: var(--color-surface-2); animation: kb-pulse 1.4s ease-in-out infinite; }
@keyframes kb-pulse { 50% { opacity: .55; } }

.spinner {
  display: inline-block;
  width: 26px;
  height: 26px;
  border: 3px solid var(--color-surface-2);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--color-scrim);
}
.loading-overlay__panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  max-width: 320px;
  padding: 28px 32px;
  border: 0;
  border-radius: var(--radius-card);
  background: var(--color-surface);
  box-shadow: var(--shadow-float);
  text-align: center;
}
.loading-overlay__message { font-size: 15px; font-weight: 600; color: var(--color-text); }
.loading-inline { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 32px 0; color: var(--color-muted); }
.loading-inline__message { font-size: 13px; }
.boot-loading { flex: 1; display: grid; place-items: center; min-height: 55dvh; background: var(--color-bg); }
.boot-loading .loading-inline { border-radius: var(--radius-card); background: var(--color-surface); padding: 24px 32px; }

.auth-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  padding: 12px 16px;
  border: 0;
  border-radius: var(--radius-tile);
  background: var(--color-surface-2);
  color: var(--color-muted);
  font-size: 13px;
}
.auth-banner--ok   { background: var(--parve-bg); color: var(--parve-fg); }
.auth-banner--warn { background: var(--dlc-bientot-bg); color: var(--dlc-bientot-fg); }

.kb-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 12px 14px 12px 16px;
  border: 0;
  border-radius: var(--radius-tile);
  background: var(--dlc-bientot-bg);
  color: var(--dlc-bientot-fg);
  font: 600 15px/20px var(--font-body);
  text-align: left;
  width: 100%;
}
.kb-banner--danger { background: var(--color-danger-soft); color: var(--color-danger); }
.kb-banner--brand { background: var(--color-primary-soft); color: var(--color-primary); }
.kb-banner--offline { background: var(--color-text); color: var(--color-bg); border-radius: 0; }

/* ── Toasts ───────────────────────────────────────────────── */

.kb-toasts {
  position: fixed;
  left: 50%;
  bottom: calc(96px + var(--safe-bottom));
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: calc(100% - 2 * var(--gutter));
  max-width: 440px;
  transform: translateX(-50%);
  pointer-events: none;
}
.kb-toast {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--color-text);
  color: var(--color-bg);
  font: 500 15px/20px var(--font-body);
  box-shadow: var(--shadow-float);
  animation: kb-toast-in 200ms var(--ease-sheet);
  pointer-events: auto;
}
.kb-toast__icon { flex: none; display: grid; place-items: center; }
.kb-toast--error .kb-toast__icon { color: var(--color-danger); }
:root[data-theme="dark"] .kb-toast--error .kb-toast__icon { color: #9E1C14; }
.kb-toast--success .kb-toast__icon { color: var(--color-raspberry); }
.kb-toast__action { margin-left: auto; border: 0; background: none; color: inherit; font: 600 15px var(--font-body); text-decoration: underline; min-height: 44px; }
@keyframes kb-toast-in { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ── Pile de cartes (swipe) et lignes à glisser ───────────── */

.kb-swipe { position: relative; touch-action: pan-y; user-select: none; }
.kb-swipe__stack { position: relative; }
.kb-swipe__stack::before, .kb-swipe__stack::after {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: -8px;
  height: 40px;
  border-radius: var(--radius-card);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  z-index: 0;
}
.kb-swipe__stack::after { left: 16px; right: 16px; bottom: -16px; background: var(--color-surface-2); z-index: -1; }
.kb-swipe__card {
  position: relative;
  z-index: 1;
  border-radius: var(--radius-card);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-float);
  overflow: hidden;
  will-change: transform;
}
.kb-swipe__card.is-leaving { transition: transform 200ms ease-out, opacity 200ms ease-out; }
.kb-swipe__card.is-entering { animation: kb-swipe-in 200ms ease-out; }
.kb-swipe__actions { display: flex; gap: 8px; margin-top: 28px; }
.kb-swipe__actions > .btn { flex: 1; }
@keyframes kb-swipe-in { from { transform: scale(.96); } to { transform: none; } }

.kb-swipe-row { position: relative; overflow: hidden; }
.kb-swipe-row__actions { position: absolute; inset: 0 0 0 auto; display: flex; }
.kb-swipe-row__actions > button { width: 84px; border: 0; font: 600 13px var(--font-body); display: grid; place-items: center; align-content: center; gap: 4px; }
.kb-swipe-row__content { position: relative; z-index: 1; background: var(--color-surface); transition: transform 180ms ease-out; touch-action: pan-y; }
.kb-swipe-row.is-dragging .kb-swipe-row__content { transition: none; }

/* ── Divers ───────────────────────────────────────────────── */

.v4-pictogram { display: inline-block; vertical-align: -.22em; flex-shrink: 0; max-width: 1.5em; color: currentColor; }
.checklist-item { padding-block: 10px; }
.checklist-item__check { width: 30px; height: 30px; border: 1px solid var(--color-border); }
[role="alert"]:not(.kb-toast):not(.form-error):not(.kb-error):not(.kb-banner) { line-height: 1.5; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
.kb-swipe-row__action--brand { background: var(--color-primary); color: var(--color-on-primary); }
.kb-swipe-row__action--danger { background: var(--color-danger); color: var(--color-surface); }
.kb-swipe-row__action--neutral { background: var(--color-surface-2); color: var(--color-text); }
.kb-swipe-row__toggle:focus-visible { position: static; width: auto; height: auto; margin: 0; clip: auto; }

/* Bandeau hors ligne (persistant sous l'en-tête). */
.kb-offline {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  margin: 0 12px 8px;
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--color-text);
  color: var(--color-bg);
  font-size: 13px;
  line-height: 18px;
}
.kb-offline strong { font-weight: 600; }

/* Écran d'erreur plein écran (chargement impossible). */
.kb-error-screen { justify-content: space-between; padding: 0 var(--gutter) calc(16px + var(--safe-bottom)); }
.kb-error-screen__body { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; text-align: center; }
.kb-error-screen__body p { max-width: 34ch; color: var(--color-muted); font-size: 15px; line-height: 21px; }
.kb-error-screen__icon { display: grid; place-items: center; width: 88px; height: 88px; border-radius: 999px; background: var(--color-danger-soft); color: var(--color-danger); }
.kb-error-screen__actions { display: flex; flex-direction: column; gap: 8px; }

/* Autocomplétion (ville) */
.kb-autocomplete { position: relative; }
.kb-autocomplete > input.is-valid { padding-right: 40px; }
.kb-autocomplete__ok { position: absolute; right: 12px; top: 24px; transform: translateY(-50%); color: var(--color-apple); display: grid; }
.kb-autocomplete__list {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 20;
  max-height: 240px; overflow-y: auto;
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-tile);
  box-shadow: var(--shadow-float);
}
.kb-autocomplete__wait { padding: 12px 16px; font-size: 13px; color: var(--color-muted); }
.kb-autocomplete__item { min-height: 48px; display: flex; align-items: center; padding: 10px 16px; font-size: 15px; color: var(--color-text); cursor: pointer; border-top: 1px solid var(--color-border); }
.kb-autocomplete__item:first-child { border-top: 0; }
.kb-autocomplete__item:hover { background: var(--color-surface-2); }
.kb-autocomplete__hint { margin-top: 6px; font-size: 13px; color: var(--color-danger); }
