/* ══════════════════════════════════════════════════════════════════════════════
   responsive.css — chargé EN DERNIER. Modes d'affichage (body.mode-tv|desktop|mobile),
   breakpoints unifiés, rôles (body.role-owner|public), effets (body.fx-off).

   Breakpoints (miroir de js/core/breakpoints.js — modifier aux deux endroits) :
     XS < 600 · SM < 1024 · MD < 1600 · LG >= 1600 · + mode TV (scène 800×600).
   Les media queries ne pouvant pas lire de variables, les seuils sont recopiés :
     XS : max-width: 599px        SM : 600–1023px
     MD : 1024–1599px             LG : min-width: 1600px
   Les classes body.bp-xs|sm|md|lg posées par JS permettent aussi de cibler un
   breakpoint indépendamment du mode (ex. mode forcé).
   ══════════════════════════════════════════════════════════════════════════════ */

:root {
  --bp-sm: 600px;
  --bp-md: 1024px;
  --bp-lg: 1600px;
  --tv-w: 800px;
  --tv-h: 600px;
  --tv-band-h: 40px;
  --tv-ticker-h: 44px;
  --band-h: 44px;
  --tabbar-h: 56px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ── Utilitaires globaux ─────────────────────────────────────────────────────*/
[hidden] { display: none !important; }

.skip-link {
  position: absolute;
  left: 8px;
  top: -64px;
  z-index: 100000;
  padding: 10px 14px;
  background: #000;
  color: var(--green);
  border: 2px solid var(--green);
  font-family: var(--font-hud);
  font-size: var(--type-body);
}
.skip-link:focus { top: 8px; }

/* Rôle : tout ce qui est « owner » reste masqué tant que le rôle n'est pas confirmé. */
body:not(.role-owner) [data-owner-only] { display: none !important; }
body.role-pending .dashboard-grid,
body.role-pending .ticker-zone { visibility: hidden; }

/* Vue publique : lecture seule, aucun outil, aucune actualité interne. */
body.role-public .dash-tabs,
body.role-public .ticker-zone,
body.role-public .header-zoom-rail,
body.role-public .status-effects-strip__suggest,
body.role-public .status-effects-strip__action { display: none !important; }
body.role-public .stat-bar__btns,
body.role-public .stat-btn { display: none !important; }

/* ── Effets : body.fx-off + prefers-reduced-motion ───────────────────────────*/
body.fx-off {
  --green-glow: none;
  --blue-glow: none;
  --rose-glow: none;
  --red-glow: none;
  --amber-glow: none;
  animation: none;
}
body.fx-off .scanlines,
body.fx-off .crt-vfx-noise,
body.fx-off .crt-glass,
body.fx-off #matrix-bg { display: none !important; }
body.fx-off *,
body.fx-off *::before,
body.fx-off *::after { text-shadow: none !important; }
body.fx-off .crt-stage { filter: none !important; }
body.fx-off .logo.glitch,
body.fx-off .logo.glitch::before,
body.fx-off .logo.glitch::after { animation: none !important; }
body.fx-off .panel--quests .panel-body::before { animation: none; opacity: 0; }

@media (prefers-reduced-motion: reduce) {
  body.crt { animation: none; }
  .loading-placeholder,
  .conn-offline .conn-dot,
  .stat-bar--critical .stat-bar__fill,
  .stat-bar--critical .stat-bar__icon,
  .stat-bar--low .stat-bar__icon,
  .stat-bar--ok .stat-bar__icon,
  .panel--quests .panel-body::before,
  .levelup-text { animation: none !important; }
}

/* ── Identité (Z1) ───────────────────────────────────────────────────────────*/
.identity-band {
  position: relative;
  z-index: 4;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  max-height: 48px;
  padding: 0 14px;
  white-space: nowrap;
  border-bottom: 1px solid color-mix(in srgb, var(--green) 25%, transparent);
  background: linear-gradient(180deg, rgba(8, 24, 16, 0.95) 0%, rgba(2, 8, 5, 0.98) 100%);
}

/* Le bloc XP existant se met sur UNE ligne : LV · titre · barre · xp · quêtes */
.identity-band .world-xp-bar {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0;
  border: 0;
  background: none;
  box-shadow: none;
  font-size: var(--type-small);
}
.identity-band .world-xp-bar__main,
.identity-band .world-xp-bar__head { display: contents; }
.identity-band .world-xp-bar__level { order: 0; flex: none; }
.identity-band .world-xp-bar__title {
  order: 1;
  flex: 0 1 auto;
  min-width: 0;
  max-width: 34%;
  font-size: 1em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.identity-band .world-xp-bar__track { order: 2; flex: 1 1 60px; min-width: 40px; height: 10px; }
.identity-band .world-xp-bar__nums { order: 3; flex: none; font-size: 1em; white-space: nowrap; }
.identity-band .world-xp-bar__quests { order: 4; flex: none; font-size: 1em; white-space: nowrap; }

.identity-band__slots {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
/* éléments repositionnés par js/core/mode.js (horloge, connexion) */
.identity-band__slots > .clock { order: 1; font-size: var(--type-small); text-shadow: none; letter-spacing: 0.04em; }
.identity-band__slots > .conn-status { order: 2; }
.identity-band__slots > .role-badge { order: 3; }
.identity-band__slots > .mode-badge { order: 4; }
.identity-band__slots > .overflow-btn { order: 5; }
.identity-band__slots .clock__date,
.identity-band__slots .clock__sep,
.identity-band__slots .clock__cell--t5,
.identity-band__slots .clock__cell--t15 { display: none !important; }
.identity-band__slots .clock.clock--triple { width: auto; max-width: none; display: block; }
.identity-band__slots .clock__grid { display: block; }

.role-badge,
.mode-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  font-family: var(--font-hud);
  font-size: var(--type-caption);
  font-weight: 600;
  letter-spacing: 0.1em;
  border: 1px solid currentColor;
  border-radius: 3px;
  line-height: 1.3;
}
.role-badge:empty { display: none; }
.role-badge--owner { color: var(--green); }
.role-badge--public { color: var(--amber); }
.mode-badge { color: var(--blue); }
body:not(.mode-tv) .mode-badge { display: none; }

.overflow-btn {
  display: none;
  min-width: 44px;
  min-height: 40px;
  padding: 0 10px;
  font-size: 22px;
  line-height: 1;
  color: var(--green);
  background: transparent;
  border: 1px solid color-mix(in srgb, var(--green) 35%, #000);
  border-radius: 3px;
  cursor: pointer;
}

/* Connexion : trois états */
.conn-status { font-size: var(--type-body); }
.conn-reconnecting .conn-dot { background: var(--amber); animation: blink 0.8s step-end infinite; }
.conn-reconnecting .conn-label { color: var(--amber); }
.conn-status .conn-label { white-space: nowrap; }

/* Auth (header) */
.auth-session { font-family: var(--font-hud); font-size: var(--type-caption); color: var(--green-muted); white-space: nowrap; }
.auth-btn { cursor: pointer; }
.auth-btn--login { color: var(--amber); border: 1px solid color-mix(in srgb, var(--amber) 50%, #000); padding: 2px 8px; border-radius: 3px; }
body.role-owner .auth-btn--login { display: none !important; }

.header-tool {
  font-family: var(--font-hud);
  font-size: var(--type-caption);
  padding: 2px 8px;
  color: var(--green-muted);
  background: transparent;
  border: 1px solid color-mix(in srgb, var(--green) 25%, #000);
  border-radius: 3px;
  cursor: pointer;
  white-space: nowrap;
}
.header-tool[aria-pressed="true"] { color: var(--green); }

/* dB-mètre : masqué par défaut, ouvert via le bouton « dB » (debug owner) */
body:not(.show-db-meter) .db-meter { display: none !important; }

/* Modale passphrase */
.auth-modal { position: fixed; inset: 0; z-index: 100001; display: flex; align-items: center; justify-content: center; padding: 16px; }
.auth-modal[hidden] { display: none; }
.auth-modal__backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.82); }
.auth-modal__box {
  position: relative;
  width: min(420px, 100%);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #020805;
  border: 2px solid var(--green);
  box-shadow: 0 0 40px rgba(57, 255, 20, 0.2);
  font-family: var(--font-hud);
}
.auth-modal__title { font-family: var(--font-pixel); font-size: var(--type-pixel-md); color: var(--green); font-weight: normal; line-height: 1.4; }
.auth-modal__desc { color: var(--dim); font-size: var(--type-small); }
.auth-modal__label { font-size: var(--type-small); color: var(--green-muted); }
.auth-modal__input { width: 100%; min-height: 44px; font-size: 16px; }
.auth-modal__error { min-height: 1.4em; color: var(--red); font-size: var(--type-small); }
.auth-modal__actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.auth-modal__btn {
  min-height: 44px;
  padding: 0 16px;
  cursor: pointer;
  font-size: var(--type-body);
  background: transparent;
  border: 1px solid color-mix(in srgb, var(--green) 40%, #000);
  border-radius: 3px;
}
.auth-modal__btn--primary { color: var(--bg); background: var(--green); font-weight: 600; }
.auth-modal__btn:disabled { opacity: 0.6; cursor: wait; }
body.modal-open { overflow: hidden; }

/* Menu « ⋯ » (mobile) — hors .crt-stage : position:fixed sûre */
.overflow-menu {
  position: fixed;
  z-index: 300;
  top: calc(var(--band-h) + 6px);
  right: 8px;
  width: min(360px, calc(100vw - 16px));
  max-height: calc(100dvh - var(--band-h) - var(--tabbar-h) - var(--safe-bottom) - 24px);
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #020805;
  border: 2px solid color-mix(in srgb, var(--green) 50%, #000);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.85);
}
.overflow-menu[hidden] { display: none; }
body:not(.mode-mobile) .overflow-menu { display: none !important; }
.overflow-menu__body { display: flex; flex-direction: column; gap: 10px; }
.overflow-menu__body .header-menu { flex-direction: column; align-items: stretch; gap: 6px; }
.overflow-menu__body .header-menu > * { min-height: 44px; justify-content: flex-start; display: inline-flex; align-items: center; padding: 0 10px; border: 1px solid color-mix(in srgb, var(--green) 20%, #000); border-radius: 3px; }
.overflow-menu__body .header-weather { max-width: 100%; white-space: normal; min-height: 44px; }
.overflow-menu__body .db-meter { max-width: 100%; }
.overflow-menu__tools { display: flex; gap: 8px; flex-wrap: wrap; }
.overflow-menu__tool {
  flex: 1 1 120px;
  min-height: 44px;
  cursor: pointer;
  font-family: var(--font-hud);
  font-size: var(--type-small);
  color: var(--green);
  background: transparent;
  border: 1px solid color-mix(in srgb, var(--green) 35%, #000);
  border-radius: 3px;
}

/* Mission principale (Z4) */
.mission-main:empty { display: none; }
.mission-main { width: 100%; }
.mission-main .hero-quest-wrap { margin: 0; }

/* Jauges TV (masquées hors TV) */
.tv-gauges { display: none; }

/* Statuts actifs : compacts (une ligne par statut) */
.status-effects-strip { padding: 6px 10px; gap: 8px; }
.status-effects-strip__chip { flex-wrap: nowrap; align-items: center; gap: 4px 8px; padding: 4px 10px; }
.status-effects-strip__suggest { width: auto; flex-basis: auto; display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }

/* Horloge : mode réduit (classes posées par ui/clock.js) */
.clock--offsets-off .clock__sep,
.clock--offsets-off .clock__cell--t5,
.clock--offsets-off .clock__cell--t15 { display: none; }
.clock--date-off .clock__date { display: none; }
.clock--offsets-off .clock__grid { grid-template-columns: auto; }

/* ══════════════════════════════════════════════════════════════════════════════
   DESKTOP + MOBILE : pas de fenêtre de scroll interne, scroll de page naturel
   ══════════════════════════════════════════════════════════════════════════════ */
html:not(.mode-tv),
body:not(.mode-tv) {
  height: auto;
  min-height: 100dvh;
  max-height: none;
  overflow: visible;
}
body.crt:not(.mode-tv) .crt-wrap,
body.crt:not(.mode-tv) .crt-stage {
  height: auto;
  max-height: none;
  overflow: visible;
}
body.crt:not(.mode-tv) .dashboard-grid {
  overflow: visible;
  scrollbar-gutter: auto;
  flex: 0 0 auto;
}
body.crt:not(.mode-tv) .panel { min-height: auto; }
body.crt:not(.mode-tv) .panel--collapsed { min-height: 0; }
body.crt:not(.mode-tv) .panel-body,
body.crt:not(.mode-tv) .panel--personal .panel-body,
body.crt:not(.mode-tv) .panel--quests .panel-body,
body.crt:not(.mode-tv) .panel--wizard .panel-body,
body.crt:not(.mode-tv) .panel--actions .panel-body {
  flex: 0 1 auto;
  min-height: auto;
  overflow: visible;
}
body.crt:not(.mode-tv) .panel--personal { display: flex; flex-direction: column; }
body.crt:not(.mode-tv) #personal-stats,
body.crt:not(.mode-tv) .stat-rows,
body.crt:not(.mode-tv) .personal-sheet-scroll,
body.crt:not(.mode-tv) .quest-journal-root,
body.crt:not(.mode-tv) .quest-journal,
body.crt:not(.mode-tv) .quest-journal__list,
body.crt:not(.mode-tv) .actions-panel__body,
body.crt:not(.mode-tv) .matrix-hub-side {
  flex: 0 1 auto;
  height: auto;
  min-height: auto;
  max-height: none;
  overflow: visible;
}
body.crt:not(.mode-tv) .personal-sheet-scroll { padding-right: 0; scrollbar-gutter: auto; }
body.crt:not(.mode-tv) #personal-stats .personal-alerts { position: static; }
body.crt:not(.mode-tv) .matrix-hub-root { height: auto; }
body.crt:not(.mode-tv) #wizard-canvas {
  flex: 0 0 auto;
  width: min(100%, 300px);
  height: auto;
  max-height: none;
}
body.crt:not(.mode-tv) .panel--wizard .panel-body { align-items: center; }
body.crt:not(.mode-tv) #neurowatts-frame { height: min(62dvh, 720px); }
body.crt:not(.mode-tv) .panel--neurowatts { min-height: 0; }

/* ══════════════════════════════════════════════════════════════════════════════
   DESKTOP (SM / MD / LG)
   ══════════════════════════════════════════════════════════════════════════════ */
body.mode-desktop .dash-tabs { display: none; }
body.mode-desktop .crt-wrap { padding: clamp(6px, 0.8vw, 12px); }

/* Header ≤ 120 px */
body.mode-desktop .dashboard-header {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px 16px;
  min-height: 0;
  max-height: 120px;
  padding: 6px 16px 6px 46px;
}
body.mode-desktop .header-left { flex: 1 1 0; max-width: none; min-width: 0; gap: 2px; }
body.mode-desktop .header-brand { flex-wrap: nowrap; gap: 10px; align-items: baseline; }
body.mode-desktop .header-brand .version {
  font-size: var(--type-small);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
body.mode-desktop .header-menu { gap: 2px 14px; padding-top: 0; }
body.mode-desktop .header-center { flex: 0 0 auto; width: auto; max-width: 52%; }
body.mode-desktop .dashboard-header .header-center .clock.clock--triple { width: auto; }
body.mode-desktop .header-right {
  flex: 1 1 0;
  min-width: 0;
  flex-wrap: nowrap;
  gap: 8px 12px;
  position: relative;
}
body.mode-desktop .header-weather {
  flex: 1 1 auto;
  min-width: 0;
  max-width: none;
  min-height: 30px;
  font-size: var(--type-small);
  padding: 2px 8px;
}
body.mode-desktop .conn-status { font-size: var(--type-body); flex: none; }
body.mode-desktop .header-right .db-meter {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 20;
  width: min(460px, 90vw);
  max-width: none;
  padding: 8px 10px;
  background: #020805;
  border: 1px solid color-mix(in srgb, var(--green) 40%, #000);
}
body.mode-desktop .header-zoom-rail { display: flex; }

/* Horloge : une seule ligne dans le header */
body.mode-desktop .clock { font-size: clamp(1.25rem, 1rem + 0.7vw, 1.9rem); }
body.mode-desktop .clock.clock--triple { gap: 2px; line-height: 1.1; }

/* Bandeau identité desktop */
body.mode-desktop .identity-band { min-height: 40px; max-height: 48px; }
body.mode-desktop .identity-band .world-xp-bar__title { max-width: 26%; }

/* Grille : SM = 2 colonnes · MD = 3 colonnes (layout serveur) · LG = 4 colonnes */
body.mode-desktop .dashboard-grid { gap: 10px 12px; align-items: start; }
body.mode-desktop .dashboard-grid > .panel { align-self: stretch; }

body.mode-desktop.bp-xs .dashboard-grid { grid-template-columns: minmax(0, 1fr); }
body.mode-desktop.bp-xs .dashboard-grid .panel:not(.panel--layout-hidden) { display: flex !important; grid-column: auto; grid-row: auto; }

@media (min-width: 600px) and (max-width: 1023px) {
  body.mode-desktop .dashboard-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: none; grid-auto-rows: auto; }
  body.mode-desktop .panel--personal { grid-column: 1; grid-row: auto; order: 1; }
  body.mode-desktop .panel--wizard { grid-column: 2; grid-row: auto; order: 2; }
  body.mode-desktop .panel--quests { grid-column: 1 / -1; grid-row: auto; order: 3; }
  body.mode-desktop .panel--actions { grid-column: 1; grid-row: auto; order: 4; }
  body.mode-desktop .panel--hub { grid-column: 2; grid-row: auto; order: 5; }
  body.mode-desktop .panel--neurowatts { grid-column: 1 / -1; grid-row: auto; order: 6; }
  body.mode-desktop .quest-journal { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  body.mode-desktop .matrix-hub-root { grid-template-columns: minmax(0, 1fr); min-height: 0; }
  body.mode-desktop .dashboard-header { flex-wrap: wrap; }
  body.mode-desktop .header-left { flex: 1 1 280px; }
  body.mode-desktop .header-center { max-width: 100%; }
  body.mode-desktop .header-right { flex: 1 1 100%; justify-content: flex-end; }
  body.mode-desktop .header-brand .version { display: none; }
}

@media (min-width: 1600px) {
  body.mode-desktop .dashboard-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); grid-template-rows: none; grid-auto-rows: auto; }
  body.mode-desktop .panel--personal { grid-column: 1 / span 2; grid-row: 1 / span 3; }
  body.mode-desktop .panel--wizard { grid-column: 3; grid-row: 1; }
  body.mode-desktop .panel--quests { grid-column: 4; grid-row: 1 / span 2; }
  body.mode-desktop .panel--actions { grid-column: 3; grid-row: 2; }
  body.mode-desktop .panel--hub { grid-column: 3 / span 2; grid-row: 3; }
  body.mode-desktop .panel--neurowatts { grid-column: 1 / -1; grid-row: 4; }
  body.mode-desktop .quest-journal { grid-template-columns: minmax(0, 1fr); }
}

/* Vue publique desktop : une colonne centrée (avatar + statuts + mission) */
body.mode-desktop.role-public .dashboard-grid {
  grid-template-columns: minmax(0, 560px);
  grid-template-rows: none;
  justify-content: center;
}
body.mode-desktop.role-public .panel--wizard { grid-column: 1; grid-row: 1; }
body.mode-desktop.role-public .status-effects-strip { justify-content: center; }

/* ══════════════════════════════════════════════════════════════════════════════
   MOBILE (XS ou ?mode=mobile) — header ≤ 56 px, onglets en bas, un panneau à la fois
   ══════════════════════════════════════════════════════════════════════════════ */
body.mode-mobile {
  padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom));
  --type-h1: 1.375rem;
  --type-h2: 1.25rem;
  --type-h3: 1.1875rem;
  --type-h4: 1.125rem;
  --type-body: 1.125rem;
  --type-small: 1.0625rem;
  --type-caption: 1rem;
  --type-pixel-sm: 14px;
  --type-pixel-md: 15px;
}
body.mode-mobile .crt-wrap { padding: 0; max-width: 640px; margin-inline: auto; }
body.mode-mobile .crt-stage { border: 0; border-radius: 0; zoom: 1; box-shadow: none; filter: none; }
body.mode-mobile .crt-glass { display: none; }
body.mode-mobile #matrix-bg,
body.mode-mobile .crt-vfx-noise,
body.mode-mobile .scanlines { display: none; }

/* En-tête : le bandeau identité devient l'unique header (40 px) ; l'ancien header est vidé */
body.mode-mobile .lcd-statusbar { display: none; }
body.mode-mobile .dashboard-header { display: none; }
body.mode-mobile .identity-band {
  --band-h: 40px;
  position: sticky;
  top: 0;
  z-index: 60;
  min-height: 40px;
  max-height: 48px;
  padding: 0 8px;
  gap: 8px;
}
body.mode-mobile .identity-band .world-xp-bar { gap: 8px; }
body.mode-mobile .identity-band .world-xp-bar__nums,
body.mode-mobile .identity-band .world-xp-bar__quests,
body.mode-mobile .identity-band .wq-lbl { display: none; }
body.mode-mobile .identity-band .world-xp-bar__title { max-width: 38%; }
body.mode-mobile .identity-band .world-xp-bar__track { flex: 1 1 36px; min-width: 36px; }
body.mode-mobile .identity-band__slots { gap: 6px; }
body.mode-mobile .identity-band__slots > .clock { font-size: var(--type-small); }
body.mode-mobile .identity-band__slots .clock__cell--t0 { font-size: 1em; }
body.mode-mobile .role-badge { padding: 1px 5px; }
body.mode-mobile .overflow-btn { display: inline-flex; align-items: center; justify-content: center; }

/* Connexion en pastille (le libellé reste lisible par les lecteurs d'écran) */
body.mode-mobile .identity-band__slots > .conn-status { gap: 0; min-width: 20px; justify-content: center; }
body.mode-mobile .identity-band__slots > .conn-status .conn-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
body.mode-mobile .identity-band__slots > .conn-status .conn-dot { width: 14px; height: 14px; }

/* Onglets : barre fixe en bas */
body.mode-mobile .dash-tabs {
  display: flex;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 200;
  height: calc(var(--tabbar-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: linear-gradient(180deg, #0c1a10 0%, #020403 100%);
  border-top: 2px solid color-mix(in srgb, var(--green) 28%, #000);
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.85), inset 0 1px 0 rgba(57, 255, 20, 0.12);
}
body.mode-mobile .dash-tab {
  flex: 1 1 0;
  min-width: 44px;
  min-height: var(--tabbar-h);
  gap: 2px;
  padding: 4px 2px;
  font-family: var(--font-hud);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  touch-action: manipulation;
}
body.mode-mobile .dash-tab__label { font-size: 11px; line-height: 1.1; }
body.mode-mobile .dash-tab__icon { font-size: 20px; }
body.mode-mobile .dash-tab:focus-visible { outline: 2px solid var(--green); outline-offset: -3px; }
body.mode-mobile .dash-tab[aria-pressed="true"],
body.mode-mobile .dash-tab--active { color: var(--green); }

/* Un panneau à la fois, scroll de page naturel */
body.mode-mobile .dashboard-grid {
  display: block;
  padding: 8px 8px 12px;
  overflow: visible;
}
body.mode-mobile .dashboard-grid .panel { display: none !important; margin: 0; }
body.mode-mobile .dashboard-grid .panel.panel--tab-active:not(.panel--layout-hidden) {
  display: flex !important;
  min-height: 0;
  grid-column: auto;
  grid-row: auto;
}
body.mode-mobile .panel--collapsed .panel-body { display: flex; }
body.mode-mobile .panel-fold { display: none; }
body.mode-mobile .panel-title { cursor: default; margin: -1px -2px 6px; }
body.mode-mobile .panel-title__inner {
  font-size: var(--type-pixel-md);
  padding: 8px 10px;
  text-align: left;
}
body.mode-mobile .panel--wizard .panel-title__inner { text-align: left; }
body.mode-mobile .panel--wizard { padding: 6px; }

/* Statuts : uniquement sur FICHE, chips qui passent à la ligne (pas de scroll horizontal) */
body.mode-mobile:not([data-tab="panel-wizard"]) .status-effects-strip { display: none !important; }
body.mode-mobile .status-effects-strip {
  flex-wrap: wrap;
  overflow: visible;
  max-height: none;
  padding: 6px 8px;
  gap: 6px;
}
body.mode-mobile .status-effects-strip__chip { flex-wrap: wrap; max-width: 100%; }
body.mode-mobile .status-effects-strip__suggest { display: inline-flex; }
body.mode-mobile .status-effects-strip__action[data-chip-action] { display: none; }

/* Tickers : haut masqué, bas sur une ligne */
body.mode-mobile .ticker-bar--top { display: none; }
body.mode-mobile .ticker-bar--bottom { display: flex; min-height: 28px; max-height: 32px; }
body.mode-mobile .ticker-bar--bottom .ticker-content { font-size: var(--type-small); }

/* Fiche : avatar plus compact, mission visible */
body.mode-mobile #wizard-canvas { width: min(70%, 240px); }
body.mode-mobile .mission-main { margin-top: 8px; }

/* Cibles tactiles ≥ 44 px */
body.mode-mobile .action-btn,
body.mode-mobile .quest-chip__btn,
body.mode-mobile .quest-chip__title-finish,
body.mode-mobile .quest-chip__add-sub,
body.mode-mobile .hero-quest__btn,
body.mode-mobile .status-effects-strip__action,
body.mode-mobile .stat-btn,
body.mode-mobile .layout-editor__btn,
body.mode-mobile .overflow-menu__tool,
body.mode-mobile .header-layout-btn,
body.mode-mobile .matrix-hub-action { min-height: 44px; min-width: 44px; }
body.mode-mobile .quest-chip__subtask { min-height: 44px; align-items: center; }
body.mode-mobile .quest-chip__subtask input[type="checkbox"] { width: 22px; height: 22px; }
body.mode-mobile .stat-bar__track[role="slider"] { position: relative; touch-action: pan-y; }
body.mode-mobile .stat-bar__track[role="slider"]::before { content: ''; position: absolute; inset: -14px 0; }

/* Personal : pas de colonne de largeur minimale qui force le débordement */
body.mode-mobile #personal-stats .stat-bar--rpg {
  grid-template-columns: 32px minmax(0, 1fr) auto;
  grid-template-areas: "icon label value" "track track track";
  row-gap: 6px;
}
body.mode-mobile #personal-stats .stat-bar__track { grid-area: track; width: 100%; }
body.mode-mobile #personal-stats .stat-group { white-space: normal; }
body.mode-mobile #personal-stats .stat-group__grid { grid-template-columns: minmax(0, 1fr); }
body.mode-mobile .quest-journal { grid-template-columns: minmax(0, 1fr); }
body.mode-mobile .matrix-hub-root { grid-template-columns: minmax(0, 1fr); min-height: 0; font-size: var(--type-small); }
body.mode-mobile .matrix-hub-main { min-height: 280px; }
body.mode-mobile .matrix-hub-ascii { max-height: 160px; }
body.mode-mobile .actions-panel__buttons { gap: 8px; }

/* Éditeur de mise en page : inutile sur mobile */
body.mode-mobile #dashboard-layout-open { display: none; }

/* ══════════════════════════════════════════════════════════════════════════════
   TV — scène 800×600 px logiques, mise à l'échelle par transform: scale() (letterbox),
   aucun scroll. Budget : bandeau 40 + ticker 44 + corps 516.
   ══════════════════════════════════════════════════════════════════════════════ */
html.mode-tv,
body.mode-tv {
  height: 100%;
  min-height: 0;
  overflow: hidden;
  background: #000;
}
body.mode-tv {
  --type-h1: 24px;
  --type-h2: 22px;
  --type-h3: 20px;
  --type-h4: 19px;
  --type-body: 19px;
  --type-small: 18px;
  --type-caption: 18px;
  --type-pixel-sm: 18px;
  --type-pixel-md: 18px;
  --type-display: 22px;
  --dash-type-s: 18px;
  --dash-type-m: 19px;
  --dash-type-l: 20px;
  animation: none;
  font-size: 19px;
}
body.mode-tv .crt-wrap {
  position: fixed;
  inset: 0;
  display: block;
  padding: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  background: #000;
}
body.mode-tv .crt-stage {
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--tv-w);
  height: var(--tv-h);
  margin: 0;
  zoom: 1;
  transform: translate(-50%, -50%) scale(var(--tv-scale, 1));
  transform-origin: 50% 50%;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  filter: none;
  overflow: hidden;
  display: grid;
  grid-template-columns: 262px 276px 262px;
  grid-template-rows: var(--tv-band-h) minmax(0, 1fr) var(--tv-ticker-h);
  column-gap: 0;
}
body.mode-tv .lcd-statusbar,
body.mode-tv .dashboard-header,
body.mode-tv .crt-glass,
body.mode-tv .dash-tabs,
body.mode-tv .overflow-menu,
body.mode-tv .overflow-btn { display: none !important; }
body.mode-tv .dashboard-grid > .panel:not(.panel--wizard) { display: none !important; }
body.mode-tv .dashboard-grid { display: contents; }

body.mode-tv .identity-band {
  grid-column: 1 / -1;
  grid-row: 1;
  height: var(--tv-band-h);
  min-height: var(--tv-band-h);
  max-height: var(--tv-band-h);
  padding: 0 10px;
  gap: 10px;
  font-size: var(--type-small);
}
body.mode-tv .identity-band .world-xp-bar { gap: 8px; }
body.mode-tv .identity-band .world-xp-bar__title { max-width: 22%; }
body.mode-tv .identity-band .world-xp-bar__track { flex: 1 1 40px; min-width: 40px; height: 12px; }
body.mode-tv .identity-band .wq-lbl { display: none; }
body.mode-tv .identity-band__slots { gap: 8px; }
body.mode-tv .identity-band__slots > .clock { font-size: 18px; }
body.mode-tv .role-badge,
body.mode-tv .mode-badge { font-size: 18px; padding: 0 6px; }
body.mode-tv .conn-status { font-size: 18px; gap: 6px; }

body.mode-tv .tv-gauges {
  grid-column: 1;
  grid-row: 2;
  display: grid;
  grid-template-rows: repeat(6, minmax(0, 1fr));
  gap: 6px;
  padding: 8px 6px 8px 10px;
  min-height: 0;
  position: relative;
  z-index: 3;
}
.tv-gauges__empty { color: var(--dim); font-size: 18px; }
.tv-gauge { display: flex; flex-direction: column; justify-content: center; gap: 4px; min-height: 0; }
.tv-gauge__head { display: flex; justify-content: space-between; align-items: baseline; font-family: var(--font-hud); font-size: 18px; font-weight: 600; line-height: 1.1; }
.tv-gauge__label { letter-spacing: 0.04em; }
.tv-gauge__value { font-variant-numeric: tabular-nums; }
.tv-gauge__track { height: 14px; border: 1px solid color-mix(in srgb, var(--green) 30%, #000); background: rgba(0, 0, 0, 0.55); border-radius: 2px; overflow: hidden; }
.tv-gauge__fill { height: 100%; background: var(--green); transition: width 0.4s ease; }
.tv-gauge--ok .tv-gauge__head { color: var(--green); }
.tv-gauge--low .tv-gauge__head { color: var(--amber); }
.tv-gauge--low .tv-gauge__fill { background: var(--amber); }
.tv-gauge--critical .tv-gauge__head { color: var(--red); }
.tv-gauge--critical .tv-gauge__fill { background: var(--red); }

/* Avatar central (~35 % de la largeur) */
body.mode-tv .panel--wizard {
  grid-column: 2;
  grid-row: 2;
  position: static;
  display: flex;
  min-height: 0;
  padding: 0;
  border: 0;
  background: none;
  box-shadow: none;
  overflow: visible;
}
body.mode-tv .panel--wizard::before,
body.mode-tv .panel--wizard::after,
body.mode-tv .panel--wizard .panel-title,
body.mode-tv .panel--wizard .debug-zone { display: none !important; }
body.mode-tv .panel--wizard .panel-body {
  position: static;
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
  overflow: visible;
  justify-content: center;
  align-items: center;
}
body.mode-tv #wizard-canvas {
  width: 100%;
  height: auto;
  max-height: 500px;
  object-fit: contain;
  flex: 0 1 auto;
}

/* Statuts actifs (colonne droite haute) + mission principale (colonne droite basse) */
body.mode-tv .status-effects-strip {
  grid-column: 3;
  grid-row: 2;
  align-self: start;
  display: none;
  flex-direction: column;
  align-items: stretch;
  flex-wrap: nowrap;
  gap: 6px;
  max-height: 290px;
  overflow: hidden;
  margin: 8px 8px 0 4px;
  padding: 0;
  border: 0;
  background: none;
  position: relative;
  z-index: 3;
}
body.mode-tv .status-effects-strip.status-effects-strip--has { display: flex; }
body.mode-tv .status-effects-strip__chip { padding: 4px 8px; font-size: 18px; flex-wrap: nowrap; gap: 6px; }
body.mode-tv .status-effects-strip__suggest,
body.mode-tv .status-effects-strip__action { display: none !important; }
body.mode-tv .status-effects-strip__label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1 1 auto; }
body.mode-tv .status-effects-strip__time { flex: none; }

body.mode-tv #mission-main {
  position: absolute;
  right: 8px;
  bottom: calc(var(--tv-ticker-h) + 8px);
  width: 250px;
  max-height: 190px;
  overflow: hidden;
  z-index: 3;
  font-size: 18px;
}
body.mode-tv #mission-main button,
body.mode-tv #mission-main .hero-quest__actions { display: none !important; }
body.mode-tv #mission-main .hero-quest__title { font-size: 20px; line-height: 1.2; }
body.mode-tv #mission-main .hero-quest__label,
body.mode-tv #mission-main .hero-quest__xp,
body.mode-tv #mission-main .hero-quest__progress,
body.mode-tv #mission-main .hero-quest__meta { font-size: 18px; }

/* Ticker unique, 44 px */
body.mode-tv .ticker-zone {
  grid-column: 1 / -1;
  grid-row: 3;
  height: var(--tv-ticker-h);
  overflow: hidden;
}
body.mode-tv .ticker-bar--bottom { display: none; }
body.mode-tv .ticker-bar--top { height: 100%; min-height: 0; }
body.mode-tv .ticker-content { font-size: 20px; }
body.mode-tv .ticker-prefix { font-size: 20px; }
body.mode-tv .levelup-overlay { z-index: 1000; }
body.mode-tv * { scrollbar-width: none; }
body.mode-tv *::-webkit-scrollbar { display: none; }

/* Hors TV : jamais de jauges TV */
body:not(.mode-tv) .tv-gauges { display: none; }

/* Toggle No Strobe monté dans l'en-tête (main.js) — masqué en mobile (présent dans le menu « ⋯ »). */
.header-nostrobe { display: inline-flex; }
body.mode-mobile .header-nostrobe { display: none; }

/* Hub : les enfants de grille ne doivent pas imposer leur largeur min-content (débordement tablette). */
.matrix-hub-root > *, .matrix-hub-side, .matrix-hub-inspector { min-width: 0; max-width: 100%; }
.matrix-hub-inspector { overflow-x: auto; }
.matrix-hub-inspector__table-wrap { overflow-x: auto; }
.matrix-hub-inspector__table { width: 100%; table-layout: fixed; }
.matrix-hub-inspector__table th, .matrix-hub-inspector__table td { overflow-wrap: anywhere; }
.header-nostrobe button { white-space: nowrap; }
