/* =====================================================================
   Charte : fond quasi-noir légèrement bleuté, panneaux en verre dépoli,
   accent bleu vif. Le flou des panneaux n'a d'effet que parce que des
   halos colorés circulent derrière : les deux vont ensemble.
   ===================================================================== */

:root {
  --bg: #06070b;
  --text: #e8ebf2;
  --muted: #98a1b2;
  --faint: #626b7c;

  --glass: rgba(255, 255, 255, .038);
  --glass-strong: rgba(255, 255, 255, .065);
  --line: rgba(255, 255, 255, .085);
  --line-strong: rgba(255, 255, 255, .16);

  --accent: #2f6bff;
  --accent-soft: rgba(47, 107, 255, .16);
  --green: #32d583;
  --amber: #fdb022;
  --red: #f97066;

  --r-lg: 18px;
  --r-md: 12px;
  --r-sm: 9px;

  --shadow: 0 24px 60px -28px rgba(0, 0, 0, .9);
  --inset: inset 0 1px 0 0 rgba(255, 255, 255, .06);

  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Inter, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "JetBrains Mono", Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.hidden { display: none !important; }

/* Élément réservé à un droit que le compte n'a pas. Classe distincte de
   .hidden : le script bascule .hidden sur certains boutons selon l'état du
   serveur, et ne doit pas les faire réapparaître pour autant. */
.no-perm { display: none !important; }

/* ------------------------------------------------------------- Ambiance */

.ambient {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

/* Les halos ne sont pas décoratifs : sans eux le flou des panneaux n'aurait
   aucune couleur à capter et le verre paraîtrait gris. */
.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: .72;
  animation: drift 26s ease-in-out infinite alternate;
}

.blob-a {
  width: 48vw; height: 48vw;
  top: -15vw; left: -9vw;
  background: radial-gradient(circle, #2f6bff 0%, transparent 68%);
}

.blob-b {
  width: 40vw; height: 40vw;
  top: 20vh; right: -11vw;
  background: radial-gradient(circle, #7a3cff 0%, transparent 68%);
  opacity: .5;
  animation-duration: 34s;
  animation-delay: -8s;
}

.blob-c {
  width: 36vw; height: 36vw;
  bottom: -15vw; left: 24vw;
  background: radial-gradient(circle, #00c2c7 0%, transparent 68%);
  opacity: .3;
  animation-duration: 42s;
  animation-delay: -16s;
}

@keyframes drift {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to   { transform: translate3d(3vw, 4vh, 0) scale(1.12); }
}

/* ---------------------------------------------------------------- Verre */

.glass {
  position: relative;
  /* Dégradé du haut vers le bas : la lumière semble tomber sur la tranche
     supérieure de la plaque, comme sur du vrai verre. */
  background: linear-gradient(180deg, rgba(255, 255, 255, .075), rgba(255, 255, 255, .025));
  backdrop-filter: blur(32px) saturate(185%);
  -webkit-backdrop-filter: blur(32px) saturate(185%);
  border: 1px solid transparent;
  border-radius: var(--r-lg);
  box-shadow:
    inset 0 1px 0 0 rgba(255, 255, 255, .11),
    inset 0 -1px 0 0 rgba(0, 0, 0, .3),
    var(--shadow);
}

/* Bordure en dégradé : vive sur l'arête éclairée, presque nulle ailleurs.
   C'est ce liseré qui fait lire la surface comme une plaque de verre. */
.glass::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(140deg,
    rgba(255, 255, 255, .34) 0%,
    rgba(255, 255, 255, .07) 28%,
    rgba(255, 255, 255, .03) 62%,
    rgba(255, 255, 255, .16) 100%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask-composite: exclude;
  pointer-events: none;
}

/* Le navigateur qui ne sait pas flouter doit rester lisible : on opacifie. */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .glass { background: #10131b; border-color: var(--line); }
}

/* ------------------------------------------------------------- Marque */

.mark {
  width: 46px; height: 46px;
  border-radius: 14px;
  background: url('/favicon.svg') center / cover no-repeat;
  box-shadow: 0 8px 26px -8px rgba(47, 107, 255, .8);
  flex: none;
}

.mark-sm { width: 30px; height: 30px; border-radius: 9px; }

/* ------------------------------------------------------------ Connexion */

/* viewport-fit=cover étend la page sous l'encoche et la barre d'accueil :
   sans ces marges, le contenu passe dessous sur iPhone. env() vaut 0
   partout ailleurs, donc max() retombe sur la valeur normale. */
.login {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding-top: max(24px, env(safe-area-inset-top));
  padding-right: max(24px, env(safe-area-inset-right));
  padding-bottom: max(24px, env(safe-area-inset-bottom));
  padding-left: max(24px, env(safe-area-inset-left));
}

.login-card {
  width: 100%;
  max-width: 400px;
  padding: 34px 30px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-card h1 {
  margin: 14px 0 0;
  font-size: 23px;
  letter-spacing: -.02em;
}

.login-card .sub {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 14px;
}

/* ------------------------------------------------------------- Ossature */

.app {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 244px 1fr;
  gap: 18px;
  padding-top: max(18px, env(safe-area-inset-top));
  padding-right: max(18px, env(safe-area-inset-right));
  padding-bottom: max(18px, env(safe-area-inset-bottom));
  padding-left: max(18px, env(safe-area-inset-left));
  min-height: 100dvh;
  align-items: start;
}

.sidebar {
  position: sticky;
  top: 18px;
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  min-height: calc(100dvh - 36px);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 4px 6px;
}

.brand-text { font-size: 15px; letter-spacing: -.01em; color: var(--muted); }
.brand-text b { color: var(--text); font-weight: 650; }

.nav { display: flex; flex-direction: column; gap: 10px; flex: 1; }

.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-group + .nav-group { padding-top: 10px; border-top: 1px solid var(--line); }

.nav-heading {
  padding: 2px 12px 4px;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--faint);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--muted);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}

/* Survol réservé aux vrais pointeurs : sur iPhone, :hover reste collé au
   dernier élément tapé, qui paraît alors encore enfoncé. */
@media (hover: hover) {
  .nav-item:hover { background: var(--glass-strong); color: var(--text); }
}

.nav-item.is-active {
  background: var(--accent-soft);
  border-color: rgba(47, 107, 255, .34);
  color: #dce6ff;
}

.nav-ico {
  width: 22px;
  text-align: center;
  font-family: var(--mono);
  font-size: 13px;
  opacity: .85;
}

.main { display: flex; flex-direction: column; gap: 18px; min-width: 0; }

/* -------------------------------------------------------------- Barre */

.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 14px 18px;
  flex-wrap: wrap;
}

.status { display: flex; align-items: center; gap: 11px; min-width: 0; }
.status-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.status-label { font-weight: 600; letter-spacing: -.01em; }
.status-meta { font-size: 12.5px; color: var(--faint); }

.dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--faint);
  flex: none;
}

.dot.is-running { background: var(--green); box-shadow: 0 0 0 4px rgba(50, 213, 131, .16); }
.dot.is-busy { background: var(--amber); box-shadow: 0 0 0 4px rgba(253, 176, 34, .16); }
.dot.is-error { background: var(--red); box-shadow: 0 0 0 4px rgba(249, 112, 102, .16); }

.stats { display: flex; gap: 22px; margin-left: auto; flex-wrap: wrap; }

.stat { display: flex; flex-direction: column; gap: 1px; }
.stat-k { font-size: 10.5px; text-transform: uppercase; letter-spacing: .09em; color: var(--faint); }
.stat-v { font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }

.topbar-actions { display: flex; gap: 8px; }

/* ------------------------------------------------------------ Panneaux */

.view { display: flex; flex-direction: column; gap: 18px; }

.panel { padding: 18px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-head h2 {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--muted);
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }

.hint { margin: -4px 0 0; color: var(--faint); font-size: 13px; }

/* ------------------------------------------------------------- Console */

.panel-console { gap: 12px; }

.console {
  height: min(56vh, 560px);
  overflow-y: auto;
  padding: 14px 16px;
  border-radius: var(--r-md);
  background: rgba(0, 0, 0, .34);
  border: 1px solid rgba(255, 255, 255, .05);
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  scrollbar-width: thin;
}

.ln { color: #b9c2d2; }
.ln-system { color: #7fa8ff; }
.ln-command { color: #ffd479; }
.ln-error { color: #ff9b94; }
.ln-warn { color: var(--amber); }

.console-input {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 6px 14px;
  border-radius: var(--r-md);
  background: rgba(0, 0, 0, .3);
  border: 1px solid var(--line);
}

.console-input:focus-within { border-color: rgba(47, 107, 255, .55); }

.prompt { font-family: var(--mono); color: var(--accent); }

/* ------------------------------------------------------ Champs, boutons */

.input {
  width: 100%;
  padding: 10px 13px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, .28);
  color: var(--text);
  font: inherit;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

.input::placeholder { color: var(--faint); }

.input:focus {
  border-color: rgba(47, 107, 255, .6);
  box-shadow: 0 0 0 3px rgba(47, 107, 255, .14);
}

.input-bare {
  flex: 1;
  min-width: 0;
  border: none;
  background: none;
  padding: 8px 0;
  font-family: var(--mono);
  font-size: 13px;
}

/* iOS Safari agrandit la page dès qu'on touche un champ dont la police fait
   moins de 16 px, et conserve ce zoom pour le site : les visites suivantes
   s'ouvrent déjà zoomées. On agit sur la taille du texte plutôt que sur
   user-scalable, qui interdirait aussi le zoom volontaire. */
@media (pointer: coarse) {
  .input,
  .input-bare,
  select,
  textarea {
    font-size: 16px;
  }
}

.input-bare:focus { box-shadow: none; }

.label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--faint);
  margin-top: 6px;
}

.btn {
  padding: 9px 16px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--glass-strong);
  color: var(--text);
  font: inherit;
  font-weight: 550;
  white-space: nowrap;
  cursor: pointer;
  /* Certains boutons sont des liens de téléchargement. */
  text-decoration: none;
  display: inline-block;
  text-align: center;
  transition: transform .12s, background .15s, border-color .15s, opacity .15s;
}

@media (hover: hover) {
  .btn:hover { background: rgba(255, 255, 255, .1); border-color: var(--line-strong); }
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(180deg, #3b76ff, #2159e6);
  border-color: rgba(120, 160, 255, .45);
  box-shadow: 0 10px 26px -12px rgba(47, 107, 255, .9), var(--inset);
  color: #fff;
}

@media (hover: hover) {
  .btn-primary:hover { background: linear-gradient(180deg, #4d83ff, #2a62f0); }
}

.btn-danger {
  background: linear-gradient(180deg, #e8574d, #c9372d);
  border-color: rgba(255, 140, 130, .4);
  color: #fff;
}

.btn-ghost { background: transparent; }
.btn-wide { width: 100%; justify-content: center; }
.btn-sm { padding: 6px 12px; font-size: 13px; }

.row { display: flex; gap: 10px; }
.row .input { flex: 1; }

.check {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
}

.check input { accent-color: var(--accent); }

/* --------------------------------------------------------------- Listes */

.pill {
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--glass-strong);
  border: 1px solid var(--line);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  line-height: 1.5;
  border: 1px solid var(--line);
  color: var(--muted);
  white-space: nowrap;
}

.tag-op { color: #ffd479; border-color: rgba(255, 212, 121, .32); }
.tag-on { color: var(--green); border-color: rgba(50, 213, 131, .32); }
.tag-warn { color: var(--amber); border-color: rgba(253, 176, 34, .32); }

.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 7px; }

.list li {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 13px;
  border-radius: var(--r-md);
  background: rgba(255, 255, 255, .022);
  border: 1px solid rgba(255, 255, 255, .05);
  min-width: 0;
}

/* Les noms de fichiers de mods sont longs et sans espaces : sans cela ils
   débordent du panneau au lieu de passer à la ligne. */
.list-compact li {
  padding: 7px 11px;
  font-size: 13px;
  font-family: var(--mono);
  overflow-wrap: anywhere;
}

.avatar {
  width: 34px;
  height: 34px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 9px;
  overflow: hidden;
  background: hsl(var(--avatar-hue, 220) 42% 34%);
  color: #fff;
  font-size: 14px;
  font-weight: 650;
  line-height: 1;
}

/* Initiale et tête occupent la même cellule : la seconde recouvre la
   première en fondu une fois chargée, sans décaler la ligne. */
.avatar > * { grid-area: 1 / 1; }

.avatar img {
  display: block;
  width: 100%;
  height: 100%;
  opacity: 0;
  transition: opacity .18s ease;
  /* Une tête Minecraft fait 8×8 pixels : l'interpolation la rendrait floue. */
  image-rendering: pixelated;
}

.avatar.is-loaded img { opacity: 1; }
.avatar.is-loaded .avatar-initiale { opacity: 0; }

.li-main { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.li-title { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li-sub { font-size: 12.5px; color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* align-items: center est indispensable ici : sans lui les pastilles, plus
   basses que les boutons, s'étirent sur toute la hauteur de la ligne et leur
   texte se retrouve collé en haut. */
.li-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: none;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* Le sélecteur de version prend la place d'une paire de boutons : il doit
   rester dans la ligne plutôt que la faire déborder. */
.input-role { flex: 0 0 auto; width: auto; }
.input-secret { font-family: var(--mono); letter-spacing: .04em; }
.row-wrap { flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 8px; max-width: 420px; }
.stack .btn { align-self: flex-start; margin-top: 8px; }

.linked { display: flex; align-items: center; gap: 12px; }
.linked:empty { display: none; }

.whoami {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
}

.roles { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--faint); }
.roles b { color: var(--muted); font-weight: 600; }

.input-version {
  padding: 6px 10px;
  font-size: 13px;
  max-width: 190px;
}

.empty { color: var(--faint); font-size: 13.5px; padding: 6px 2px; }

.results { display: flex; flex-direction: column; gap: 7px; max-height: 420px; overflow-y: auto; }

.result {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 13px;
  border-radius: var(--r-md);
  border: 1px solid rgba(255, 255, 255, .05);
  background: rgba(255, 255, 255, .022);
}

.result img { width: 34px; height: 34px; border-radius: 9px; flex: none; background: rgba(0,0,0,.3); }

/* -------------------------------------------------------------- Alertes */

.alert {
  margin: 0;
  padding: 11px 14px;
  border-radius: var(--r-md);
  font-size: 13.5px;
  border: 1px solid;
}

.alert-error { background: rgba(249, 112, 102, .1); border-color: rgba(249, 112, 102, .32); color: #ffbdb7; }
.alert-ok { background: rgba(50, 213, 131, .08); border-color: rgba(50, 213, 131, .3); color: #a6f4c5; }
.alert-warn { background: rgba(253, 176, 34, .08); border-color: rgba(253, 176, 34, .3); color: #fedf89; }

/* ----------------------------------------------------------------- Chat */

.nav-badge {
  margin-left: auto;
  min-width: 20px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 650;
  text-align: center;
}

.chat {
  height: min(56vh, 560px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px;
  border-radius: var(--r-md);
  background: rgba(0, 0, 0, .34);
  border: 1px solid rgba(255, 255, 255, .05);
  scrollbar-width: thin;
}

.msg { display: flex; gap: 10px; align-items: flex-start; }
.msg .avatar { width: 30px; height: 30px; border-radius: 8px; font-size: 13px; }
.msg-body { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.msg-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.msg-name { font-weight: 650; font-size: 13.5px; }
.msg-time { color: var(--faint); font-size: 11.5px; }
.msg-text { font-size: 14px; line-height: 1.45; overflow-wrap: anywhere; }
.msg-web .msg-name { color: #8fb3ff; }
.msg-say .msg-text { color: #ffd479; }

/* Connexions, progrès, morts : une ligne discrète, pas une bulle. */
.msg-event {
  align-self: center;
  max-width: 100%;
  color: var(--faint);
  font-size: 12.5px;
  text-align: center;
  overflow-wrap: anywhere;
}
.msg-event b { color: var(--muted); font-weight: 600; }

.input-chat { font-family: inherit; font-size: 14px; }

/* ----------------------------------------------------------- Historique */

.kv { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.25; min-width: 64px; }
.kv + .kv { margin-left: 12px; }
.kv b { font-size: 15px; font-weight: 650; font-variant-numeric: tabular-nums; }
.kv span { font-size: 11.5px; color: var(--faint); }

.days { display: flex; flex-direction: column; gap: 16px; }
.day h3 {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--faint);
}

.session { display: flex; align-items: center; gap: 10px; padding: 6px 2px; }
.session .avatar { width: 26px; height: 26px; border-radius: 7px; font-size: 12px; }
.session-name { font-weight: 600; font-size: 14px; }
.session-time { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.session-dur { margin-left: auto; font-size: 13px; font-variant-numeric: tabular-nums; display: flex; gap: 8px; align-items: center; }

/* -------------------------------------------------------- Notifications */

.toggles { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px; }
.toggles .check {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  font-size: 13.5px;
  cursor: pointer;
}

/* ------------------------------------------------------------ Rejoindre */

.facts { display: flex; flex-wrap: wrap; gap: 8px; }
.facts:empty { display: none; }

.steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 13.5px; }
.steps b { color: var(--text); font-weight: 600; }
.steps a { color: var(--text); }

.toast-zone {
  position: fixed;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 9px;
  max-width: min(380px, calc(100vw - 36px));
}

.toast {
  padding: 12px 15px;
  border-radius: var(--r-md);
  background: rgba(18, 21, 29, .86);
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  font-size: 13.5px;
  animation: toast-in .22s ease-out;
}

.toast-ok { border-color: rgba(50, 213, 131, .38); }
.toast-err { border-color: rgba(249, 112, 102, .4); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

/* --------------------------------------------------------- Petits écrans */

/* La barre de titre et le tiroir n'existent que sur petit écran ; sur grand
   écran la barre latérale est toujours là et les remplace. */
.mobile-bar { display: none; }
.drawer-backdrop { display: none; }
[hidden] { display: none !important; }

@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
    gap: 12px;
    padding-top: max(12px, env(safe-area-inset-top));
    padding-right: max(12px, env(safe-area-inset-right));
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    padding-left: max(12px, env(safe-area-inset-left));
  }

  .mobile-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 13px;
    position: sticky;
    /* Collée sous l'encoche, pas dessous. */
    top: calc(12px + env(safe-area-inset-top));
    z-index: 30;
  }

  .burger {
    width: 38px;
    height: 38px;
    flex: none;
    display: grid;
    place-content: center;
    gap: 5px;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    background: var(--glass-strong);
    cursor: pointer;
  }

  .burger span {
    display: block;
    width: 17px;
    height: 2px;
    border-radius: 2px;
    background: var(--text);
    transition: transform .22s ease, opacity .16s ease;
  }

  /* Les trois barres se replient en croix quand le tiroir est ouvert. */
  .burger[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
  .burger[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
  .burger[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

  .mobile-bar .brand-text { font-size: 16px; }

  /* La barre latérale devient un tiroir hors écran. */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(278px, 80vw);
    min-height: 0;
    z-index: 60;
    border-radius: 0 var(--r-lg) var(--r-lg) 0;
    transform: translateX(-102%);
    transition: transform .26s cubic-bezier(.4, 0, .2, 1);
    /* Plus opaque que les autres panneaux : il passe par-dessus du contenu
       et doit rester lisible, pas seulement joli. */
    background: linear-gradient(180deg, rgba(22, 26, 36, .93), rgba(11, 14, 20, .95));
    padding-top: max(18px, env(safe-area-inset-top));
    padding-bottom: max(18px, env(safe-area-inset-bottom));
    padding-left: max(14px, env(safe-area-inset-left));
  }

  /* Avec les sections, le menu dépasse la hauteur d'un petit téléphone.
     Seule la liste des onglets défile : le logo, le compte et la
     déconnexion restent en place, et le liseré du tiroir (dessiné sur
     le tiroir lui-même) ne part pas avec le contenu. */
  .sidebar .nav {
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
  }

  .sidebar.is-open { transform: none; }

  .drawer-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 50;
    background: rgba(3, 5, 9, .6);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    animation: fade-in .2s ease-out;
  }

  body.drawer-open { overflow: hidden; }

  .nav-item { padding: 12px; }

  /* Titre puis actions sur deux lignes : les boutons de version ne tiennent
     pas à côté du nom du mod sur un écran de téléphone. Alignées à gauche,
     car un alignement à droite rend le retour à la ligne irrégulier. */
  .list li { flex-wrap: wrap; }
  .li-actions { width: 100%; justify-content: flex-start; align-items: center; }
  .kv { align-items: flex-start; }
  .input-version { max-width: none; flex: 1; }

  .grid-2 { grid-template-columns: 1fr; }
  .stats { width: 100%; margin-left: 0; gap: 16px; }
  .topbar-actions { width: 100%; }
  .topbar-actions .btn { flex: 1; }
  .console,
  .chat { height: 46vh; }
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* --------------------------------------------------------------- Carte */

.panel-map { padding: 8px; }

.map-stage {
  position: relative;
  height: min(74vh, 780px);
  border-radius: var(--r-md);
  overflow: hidden;
  background: #0b0d12;
}

/* Les gestes (glisser, pincer) sont gérés par la carte : le navigateur ne
   doit ni défiler ni zoomer la page à leur place. */
.map-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: grab;
}

.map-canvas:active { cursor: grabbing; }

.map-hud {
  position: absolute;
  left: 10px;
  right: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.map-hud > * { pointer-events: auto; }
.map-hud-top { top: 10px; }
.map-hud-bottom { bottom: 10px; }
.map-spacer { flex: 1; pointer-events: none; }

.map-select,
.map-btn,
.map-coords {
  background: rgba(11, 13, 18, .78);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

.map-select { width: auto; max-width: 44vw; padding: 8px 11px; }
.map-select:disabled { opacity: .55; }
.map-btn { padding: 8px 12px; }
.map-btn[aria-pressed="true"] { border-color: var(--accent); color: #fff; }
.map-zoom,
.map-icon { width: 40px; padding: 8px 0; font-size: 18px; line-height: 1; }
.map-hud-top { flex-wrap: nowrap; }
.map-hud-top .map-select { min-width: 0; flex: 0 1 auto; }

.map-coords {
  padding: 7px 11px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.map-status {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
  max-width: min(86%, 380px);
  padding: 12px 16px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: rgba(11, 13, 18, .86);
  color: var(--muted);
  text-align: center;
  font-size: 13.5px;
  pointer-events: none;
}

/* Plein écran : la carte recouvre tout, comme une mini-carte posée à côté
   du clavier. Le Fullscreen API n'existe pas pour ça sur iPhone : on passe
   par une couche fixe, décalée des bords arrondis et de l'encoche. */
.view.map-full {
  position: fixed;
  inset: 0;
  z-index: 60;
  gap: 0;
}

.view.map-full .panel-map { height: 100%; padding: 0; border-radius: 0; }
.view.map-full .panel-map::before { display: none; }
.view.map-full .map-stage { height: 100dvh; border-radius: 0; }
.view.map-full .map-hud { left: max(10px, env(safe-area-inset-left)); right: max(10px, env(safe-area-inset-right)); }
.view.map-full .map-hud-top { top: max(10px, env(safe-area-inset-top)); }
.view.map-full .map-hud-bottom { bottom: max(10px, env(safe-area-inset-bottom)); }

body.map-full-open { overflow: hidden; }

@media (max-width: 900px) {
  .map-stage { height: calc(100dvh - 118px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); }
  #map-world { display: none; }
  #map-world:enabled { display: block; }
}

/* Panneau d'un point de repère : création (appui long, clic droit) ou
   détails (toucher un point). Il glisse depuis le bas de la carte. */
.map-sheet {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 60px;
  z-index: 5;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 460px;
  margin: 0 auto;
  background: rgba(16, 19, 27, .92);
}

.view.map-full .map-sheet { bottom: max(60px, calc(50px + env(safe-area-inset-bottom))); }

.map-sheet-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.map-sheet-coords { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.map-sheet-add { display: flex; flex-direction: column; gap: 10px; }
.map-sheet-add .row { display: flex; gap: 8px; }
.map-wp-initials { width: 74px; flex: none; text-align: center; text-transform: uppercase; }
.map-sheet-info { margin: 0; color: var(--muted); font-size: 13.5px; }
.map-sheet-actions { display: flex; gap: 8px; justify-content: flex-end; }

.map-swatches { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }

.map-swatch {
  aspect-ratio: 1;
  border-radius: 7px;
  border: 2px solid rgba(0, 0, 0, .5);
  cursor: pointer;
  padding: 0;
}

.map-swatch[aria-checked="true"] { outline: 2px solid #fff; outline-offset: 2px; }

