/* ============================================================
   V2 — Système de design
   Même mise en page que la V1 : bannière, grosses tuiles colorées.
   Ce qui change, c'est le rendu — ombres teintées plutôt que grises,
   fond en dégradés multiples, typographie affirmée, grain.
   ============================================================ */

:root {
  color-scheme: light;

  --sand-50:  #fdfaf7;
  --sand-100: #f7efe4;
  --sand-200: #ecdcc9;
  --sand-300: #dcc4a7;
  --sand-400: #bda88c;
  --sand-500: #a08d78;
  --sand-600: #7a6350;
  --sand-700: #564536;
  --sand-800: #362b21;
  --sand-900: #211a14;

  --clay-400: #ff9a6b;
  --clay-500: #f4703c;
  --clay-600: #dd5624;
  --clay-700: #b34018;

  --sage-500: #2fa27b;
  --sage-600: #217f60;
  --sky-500:  #2f86c4;
  --rose-500: #e04a63;
  --rose-600: #bf3550;
  --gold-500: #d3a01f;

  /* Rôles */
  --bg:          #f5ede3;
  --surface:     #fffdfa;
  --surface-alt: #f9f1e7;
  --border:      #ecdcc9;
  --border-firm: #dcc4a7;
  --text:        #362b21;
  --text-soft:   #7a6350;
  --text-faint:  #a08d78;
  --accent:      #f4703c;
  --accent-ink:  #fff;
  --accent-soft: #ffe6d8;

  /* Fond d'origine du hub, repris tel quel */
  --blob-1: #ffd6b8;
  --blob-2: #c8e6f5;

  /* Ombres : neutres pour les surfaces, teintées pour les tuiles */
  --shadow-sm: 0 1px 2px rgb(54 43 33 / .05), 0 2px 8px rgb(54 43 33 / .05);
  --shadow-md: 0 2px 6px rgb(54 43 33 / .06), 0 10px 26px rgb(54 43 33 / .09);
  --shadow-lg: 0 6px 14px rgb(54 43 33 / .08), 0 24px 56px rgb(54 43 33 / .16);
  --ring: 0 0 0 3px rgb(244 112 60 / .35);

  --r-sm: 12px;
  --r-md: 18px;
  --r-lg: 26px;
  --r-xl: 34px;
  --r-pill: 999px;

  --s1: 4px;  --s2: 8px;  --s3: 12px; --s4: 16px;
  --s5: 24px; --s6: 36px; --s7: 56px; --s8: 80px;

  --font: 'Nunito', ui-sans-serif, system-ui, -apple-system, sans-serif;
  --t-xs: .8rem;
  --t-sm: .9rem;
  --t-md: 1rem;
  --t-lg: 1.15rem;
  --t-xl: clamp(1.4rem, 1.1rem + 1.3vw, 2rem);
  --t-2xl: clamp(2rem, 1.4rem + 3vw, 3.4rem);

  --speed: .2s;
  --ease: cubic-bezier(.22, .8, .28, 1);
}

/* ─────────────────────────── BASE ─────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  min-height: 100dvh;
  font-family: var(--font);
  font-size: var(--t-md);
  line-height: 1.6;
  color: var(--text);
  background-color: var(--bg);
  /* Exactement le fond du hub d'origine */
  background-image:
    radial-gradient(circle at 20% 20%, var(--blob-1) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, var(--blob-2) 0%, transparent 50%);
  background-attachment: fixed;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3 { line-height: 1.15; font-weight: 800; letter-spacing: -.02em; }
a { color: var(--sky-500); }

:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--r-sm); }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ─────────────────────────── COQUE ─────────────────────────── */
.shell { max-width: 1120px; margin-inline: auto; padding: var(--s5) var(--s4) var(--s8); }
.shell--narrow { max-width: 720px; }

/* En-tête simple, non collante : sur un hub on veut voir le contenu */
.head { display: flex; align-items: center; gap: var(--s3); margin-bottom: var(--s6); }
.head__logo { width: 44px; height: 44px; flex: 0 0 auto; }
.head__title { font-size: var(--t-lg); font-weight: 800; margin-right: auto; }
.head__title small { display: block; font-size: var(--t-xs); font-weight: 700; color: var(--text-faint); letter-spacing: 0; }

/* Bandeau du hub */
.hero { text-align: center; margin-bottom: var(--s7); }
.hero img { width: min(280px, 62vw); height: auto; display: block; margin: 0 auto; }
.hero h1 { font-size: var(--t-2xl); margin-top: var(--s4); }
.hero p  { color: var(--text-soft); margin-top: var(--s2); font-size: var(--t-sm); font-weight: 700; }

/* ───────────────────────── TUILES ─────────────────────────
   Le cœur du hub. Chaque tuile porte ses deux couleurs via
   --c1 / --c2, et son ombre est teintée de la même couleur :
   c'est ce détail qui sépare un rendu 2026 d'un rendu 2016. */
.tiles {
  display: grid; gap: var(--s4);
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}
/* display:grid l'emporterait sur l'attribut hidden : à rétablir */
.tiles[hidden] { display: none; }

.tile {
  --c1: #f4703c; --c2: #ffa96b;
  position: relative; overflow: hidden;
  display: flex; align-items: center; gap: var(--s3);
  min-height: 118px; padding: var(--s5) var(--s5);
  border-radius: var(--r-lg);
  text-decoration: none; color: #fff;
  background-image: linear-gradient(135deg, var(--c1), var(--c2));
  box-shadow: 0 2px 6px rgb(54 43 33 / .1), 0 14px 30px -10px var(--c1);
  transition: transform var(--speed) var(--ease), box-shadow var(--speed) var(--ease);
  isolation: isolate;
}
/* Voile lumineux en haut : donne du volume sans ajouter d'image */
.tile::after {
  content: ''; position: absolute; inset: 0; z-index: -1;
  background: linear-gradient(160deg, rgb(255 255 255 / .28), transparent 55%);
}
.tile:hover  { transform: translateY(-4px); box-shadow: 0 4px 10px rgb(54 43 33 / .12), 0 22px 44px -12px var(--c1); }
.tile:active { transform: translateY(-1px) scale(.99); }

.tile__icon { width: 52px; height: 52px; flex: 0 0 auto;
              filter: drop-shadow(0 2px 4px rgb(0 0 0 / .18)); }
.tile__body { min-width: 0; }
.tile__name { display: block; font-size: var(--t-lg); font-weight: 800; letter-spacing: -.01em; }
.tile__desc { display: block; font-size: var(--t-xs); font-weight: 700; opacity: .85; }

.tile__del {
  position: absolute; top: var(--s2); right: var(--s2);
  width: 28px; height: 28px; border: none; border-radius: var(--r-pill);
  background: rgb(0 0 0 / .22); color: #fff; cursor: pointer;
  font-size: var(--t-xs); font-weight: 800; opacity: 0;
  transition: opacity var(--speed) var(--ease), background var(--speed) var(--ease);
}
.tile:hover .tile__del, .tile__del:focus-visible { opacity: 1; }
.tile__del:hover { background: rgb(0 0 0 / .45); }

.tile__flag {
  position: absolute; bottom: var(--s2); right: var(--s3);
  font-size: .68rem; font-weight: 800; letter-spacing: .06em;
  background: rgb(0 0 0 / .2); padding: 1px 8px; border-radius: var(--r-pill);
}

/* Apparition décalée : discrète, mais la page semble vivante */
.tiles > * { animation: rise .5s var(--ease) backwards; }
.tiles > *:nth-child(1) { animation-delay: .02s } .tiles > *:nth-child(2) { animation-delay: .06s }
.tiles > *:nth-child(3) { animation-delay: .10s } .tiles > *:nth-child(4) { animation-delay: .14s }
.tiles > *:nth-child(5) { animation-delay: .18s } .tiles > *:nth-child(6) { animation-delay: .22s }
.tiles > *:nth-child(n+7) { animation-delay: .26s }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }

.section-label {
  font-size: var(--t-xs); font-weight: 800; letter-spacing: .1em;
  color: var(--text-faint); margin: var(--s7) 0 var(--s3);
}
.section-label:first-of-type { margin-top: 0; }

/* ─────────────────────────── BOUTONS ─────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  padding: var(--s3) var(--s5); border: 1px solid transparent;
  border-radius: var(--r-pill); cursor: pointer;
  font-family: var(--font); font-size: var(--t-sm); font-weight: 800;
  background-image: linear-gradient(135deg, var(--clay-500), var(--clay-400));
  color: #fff;
  box-shadow: 0 10px 22px -10px var(--clay-500);
  transition: transform var(--speed) var(--ease), box-shadow var(--speed) var(--ease), filter var(--speed) var(--ease);
}
.btn:hover  { transform: translateY(-2px); box-shadow: 0 16px 30px -12px var(--clay-500); filter: brightness(1.04); }
.btn:active { transform: translateY(0) scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }

.btn--ghost {
  background-image: none; background: var(--surface); color: var(--text);
  border-color: var(--border-firm); box-shadow: none;
}
.btn--ghost:hover { border-color: var(--accent); color: var(--accent); transform: none; box-shadow: none; }

.btn--go   { background-image: linear-gradient(135deg, var(--sage-600), var(--sage-500));
             box-shadow: 0 10px 22px -10px var(--sage-500); }
.btn--warn { background-image: linear-gradient(135deg, var(--rose-600), var(--rose-500));
             box-shadow: 0 10px 22px -10px var(--rose-500); }
.btn--lg   { padding: var(--s4) var(--s6); font-size: var(--t-md); }
.btn--block{ width: 100%; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border: 1px solid var(--border);
  border-radius: var(--r-pill); background: var(--surface);
  color: var(--text-soft); cursor: pointer; font-size: var(--t-md); line-height: 1;
  transition: border-color var(--speed) var(--ease), color var(--speed) var(--ease);
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ─────────────────────────── CHAMPS ─────────────────────────── */
.field { margin-bottom: var(--s4); }
.field > label { display: block; margin-bottom: var(--s2);
                 font-size: var(--t-xs); font-weight: 800; color: var(--text-soft); }

.input, .select, .textarea {
  width: 100%; padding: var(--s4) var(--s5);
  border: 1px solid var(--border-firm); border-radius: var(--r-md);
  background: var(--surface); color: var(--text);
  font-family: var(--font); font-size: var(--t-md); font-weight: 700;
  transition: border-color var(--speed) var(--ease), box-shadow var(--speed) var(--ease);
}
.input::placeholder, .textarea::placeholder { color: var(--text-faint); font-weight: 400; }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: var(--ring);
}
.textarea { min-height: 120px; resize: vertical; line-height: 1.6; }
.input--pill, .select--pill { border-radius: var(--r-pill); }

.row { display: grid; gap: var(--s3); }
.row--2 { grid-template-columns: 1fr 1fr; }
.row--3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 560px) { .row--3 { grid-template-columns: 1fr 1fr; } }

.check { display: inline-flex; align-items: center; gap: var(--s2); cursor: pointer; font-weight: 700; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }

/* ─────────────────────────── SURFACES ─────────────────────────── */
.card, .panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow-sm);
}
.panel { padding: var(--s5); margin-bottom: var(--s5); }
.panel__head { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; margin-bottom: var(--s4); }
.panel__head h2 { font-size: var(--t-lg); margin-right: auto; }

.grid { display: grid; gap: var(--s4);
        grid-template-columns: repeat(auto-fill, minmax(var(--col, 250px), 1fr)); }

/* ─────────────────────────── ÉTIQUETTES ─────────────────────────── */
.tag { display: inline-flex; align-items: center; gap: var(--s1);
       padding: 3px var(--s3); border-radius: var(--r-pill);
       font-size: var(--t-xs); font-weight: 800;
       background: var(--accent-soft); color: var(--clay-700); }
.tag--sage { background: #d9f2e7; color: var(--sage-600); }
.tag--sky  { background: #d9ecf9; color: var(--sky-500); }
.tag--rose { background: #fde0e5; color: var(--rose-600); }
.chips { display: flex; flex-wrap: wrap; gap: var(--s2); }
.chip {
  padding: var(--s2) var(--s4); border-radius: var(--r-pill); cursor: pointer;
  border: 1px solid var(--border-firm); background: var(--surface); color: var(--text-soft);
  font-family: var(--font); font-size: var(--t-sm); font-weight: 800;
  transition: all var(--speed) var(--ease);
}
.chip:hover { border-color: var(--accent); color: var(--text); }
.chip[aria-pressed="true"] {
  background-image: linear-gradient(135deg, var(--clay-500), var(--clay-400));
  border-color: transparent; color: #fff;
  box-shadow: 0 8px 18px -8px var(--clay-500);
}

/* ─────────────────────────── ÉTATS ─────────────────────────── */
.empty { text-align: center; padding: var(--s7) var(--s4); color: var(--text-faint); }
.empty__icon { font-size: 3rem; line-height: 1; }
.empty h3 { margin-top: var(--s3); font-size: var(--t-lg); color: var(--text-soft); }
.empty p  { margin-top: var(--s2); font-size: var(--t-sm); }

.meter { height: 10px; border-radius: var(--r-pill); background: var(--border); overflow: hidden; }
.meter > i { display: block; height: 100%; border-radius: var(--r-pill);
             background-image: linear-gradient(90deg, var(--sage-500), var(--sage-600));
             transition: width .4s var(--ease); }

/* ─────────────────────── POPUP (façon V1) ───────────────────────
   Une simple surcouche masquée/affichée par une classe. Le <dialog>
   natif posait problème, on reprend le principe éprouvé de la V1. */
.popup {
  position: fixed; inset: 0; z-index: 600;
  background: rgb(90 62 43 / .35);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  opacity: 0; pointer-events: none;
  transition: opacity .3s ease;
}
.popup.open { opacity: 1; pointer-events: auto; }

.popup__card {
  background: var(--surface); border-radius: 28px;
  padding: 36px 28px 28px;
  width: 100%; max-width: 420px;
  max-height: 88vh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
  position: relative;
}
.popup__card h2 { font-size: var(--t-lg); margin-bottom: var(--s5); }

/* Panneaux riches (création de bouton…) : au large sur PC, inchangés sur
   mobile où c'est la largeur d'écran qui commande de toute façon. */
.popup__card--wide { max-width: 780px; }
@media (min-width: 700px) {
  .popup__card--wide { padding: 40px 36px 32px; }
  .popup__card--wide .akita-opt { width: 58px; height: 58px; }
}

.popup__close {
  position: absolute; top: 16px; right: 18px;
  width: 32px; height: 32px; border: none; border-radius: var(--r-pill);
  background: var(--surface-alt); color: var(--text-faint);
  font-size: 1rem; font-weight: 800; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--speed) var(--ease), color var(--speed) var(--ease);
}
.popup__close:hover { background: var(--accent-soft); color: var(--accent); }

.popup__actions { display: flex; gap: var(--s3); margin-top: var(--s5); }
.popup__actions .btn { flex: 1; }
.popup__err { min-height: 1.4em; margin-top: var(--s3);
              color: var(--rose-500); font-weight: 800; font-size: var(--t-sm); }

/* ── Onglets internes du panel d'administration ── */
.ptabs {
  display: flex; gap: var(--s1); padding: var(--s1);
  background: var(--surface-alt); border: 1px solid var(--border);
  border-radius: var(--r-pill); margin-bottom: var(--s5);
}
.ptab {
  flex: 1; min-width: 0; padding: var(--s2) var(--s3);
  border: none; border-radius: var(--r-pill);
  background: transparent; color: var(--text-soft); cursor: pointer;
  font-family: var(--font); font-size: var(--t-sm); font-weight: 800;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: background var(--speed) var(--ease), color var(--speed) var(--ease);
}
@media (max-width: 460px) {
  .ptab { padding: var(--s2) var(--s1); font-size: var(--t-xs); }
}
.ptab:hover { color: var(--text); }
.ptab[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); }
.ptab-panel[hidden] { display: none; }

/* ── Composition de l'Akita : un accessoire par famille ──
   Choix visuel : on voit l'accessoire au lieu de lire son nom. */
.akita-picker {
  display: grid; gap: var(--s3);
  padding: var(--s3); border: 1px solid var(--border-firm);
  border-radius: var(--r-md); background: var(--surface-alt);
}
/* min-width:0 : sans ça l'enfant de grille prend la largeur de son
   contenu et la bande déborde au lieu de défiler. */
.akita-fam { min-width: 0; }
.akita-fam__label {
  display: block; font-size: var(--t-xs); font-weight: 800;
  color: var(--text-faint); letter-spacing: .06em; margin-bottom: var(--s1);
}
/* Bande défilante : évite une grille interminable pour 36 accessoires */
.akita-strip {
  display: flex; gap: var(--s2); overflow-x: auto; padding-bottom: var(--s1);
  scrollbar-width: thin; scroll-snap-type: x proximity;
}
.akita-opt {
  flex: 0 0 auto; width: 52px; height: 52px; padding: 3px;
  border: 2px solid transparent; border-radius: var(--r-md);
  background: var(--surface); cursor: pointer; scroll-snap-align: start;
  transition: border-color var(--speed) var(--ease), transform var(--speed) var(--ease);
}
.akita-opt:hover { transform: translateY(-2px); border-color: var(--border-firm); }
.akita-opt img  { width: 100%; height: 100%; display: block; }
.akita-opt[aria-pressed="true"] {
  border-color: var(--accent);
  box-shadow: 0 6px 14px -6px var(--accent);
}
.akita-opt--none {
  display: flex; align-items: center; justify-content: center;
  color: var(--text-faint); font-size: 1.1rem; font-weight: 800;
}

.btn--tiny { padding: 4px 12px; font-size: var(--t-xs); box-shadow: none; }

/* ── Listes du panel d'administration ── */
.admin-list {
  border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--surface-alt); overflow: hidden;
}
.admin-row {
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s2) var(--s3); border-bottom: 1px solid var(--border);
}
.admin-row:last-child { border-bottom: none; }
.admin-row__dot { width: 16px; height: 16px; border-radius: var(--r-pill); flex: 0 0 auto; }
.admin-row__move { display: flex; flex-direction: column; gap: 1px; flex: 0 0 auto; }
.admin-row__move .icon-btn { width: 24px; height: 18px; font-size: .7rem; border-radius: var(--r-sm); }
.admin-row__move .icon-btn:disabled { opacity: .3; cursor: default; }
.admin-row .icon-btn:disabled:hover { border-color: var(--border); color: var(--text-faint); background: var(--surface); }
.admin-row__name { flex: 1; min-width: 0; font-size: var(--t-sm); font-weight: 700;
                   overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-row img { border-radius: var(--r-sm); background: var(--surface); flex: 0 0 auto; }

/* ── Bascule ancien / nouvel affichage ── */
.switch-view {
  position: fixed; top: 14px; right: 14px; z-index: 200;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 15px; border-radius: var(--r-pill);
  background: var(--surface); border: 1px solid var(--border-firm);
  color: var(--text-soft); text-decoration: none;
  font-family: var(--font); font-weight: 800; font-size: var(--t-xs);
  box-shadow: var(--shadow-sm);
  transition: border-color var(--speed) var(--ease), color var(--speed) var(--ease),
              transform var(--speed) var(--ease);
}
.switch-view:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-1px); }

/* ── Bouton flottant d'administration (position de la V1) ── */
.fab {
  position: fixed; right: 28px; bottom: 28px; z-index: 100;
  width: 52px; height: 52px; border: none; border-radius: var(--r-pill);
  background-image: linear-gradient(135deg, var(--clay-500), var(--clay-400));
  color: #fff; font-size: 1.8rem; font-weight: 800; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 18px rgb(0 0 0 / .2);
  transition: transform var(--speed) var(--ease), box-shadow var(--speed) var(--ease);
}
.fab:hover { transform: scale(1.1); box-shadow: 0 8px 24px rgb(0 0 0 / .25); }

/* ─────────────────────────── DIALOGUE ─────────────────────────── */
dialog {
  width: min(620px, calc(100vw - 2rem));
  padding: var(--s6); border: 1px solid var(--border);
  border-radius: var(--r-xl); background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-lg);
}
dialog::backdrop { background: rgb(33 26 20 / .55); backdrop-filter: blur(8px); }
dialog h2 { font-size: var(--t-xl); margin-bottom: var(--s5); }
dialog[open] { animation: pop .24s var(--ease); }
@keyframes pop { from { opacity: 0; transform: translateY(12px) scale(.97); } }

.dialog__actions { display: flex; gap: var(--s3); margin-top: var(--s5); }
.dialog__actions .btn { flex: 1; }

/* ─────────────────────────── MESSAGE FLOTTANT ─────────────────────────── */
.toast {
  position: fixed; inset-inline: 0; bottom: var(--s5); z-index: 90;
  margin-inline: auto; width: fit-content; max-width: calc(100vw - 2rem);
  padding: var(--s3) var(--s5); border-radius: var(--r-pill);
  background: var(--sand-800); color: var(--sand-50);
  font-size: var(--t-sm); font-weight: 800; text-align: center;
  box-shadow: var(--shadow-lg); pointer-events: none;
  opacity: 0; transform: translateY(20px);
  transition: opacity var(--speed) var(--ease), transform var(--speed) var(--ease);
}
.toast[data-show] { opacity: 1; transform: none; }

/* ─────────────────────────── UTILITAIRES ─────────────────────────── */
.stack   { display: flex; flex-direction: column; gap: var(--s3); }
.cluster { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }
.spacer  { margin-inline-start: auto; }
.muted   { color: var(--text-faint); }
.center  { text-align: center; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0;
           overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
