/* ============================================================================
   MOBILE-APP.CSS — v4 FINAL
   Toute rougeur supprimée, design cohérent doré/neutre.
   ============================================================================ */

:root {
  --ig-bg: #000000;
  --ig-surface: #0d0d0f;
  --ig-surface-2: #17171a;
  --ig-surface-3: #1e1e22;
  --ig-border: rgba(255, 255, 255, .09);
  --ig-primary: #c9a96e;
  --ig-primary-light: #e8d5a3;
  --ig-primary-variant: #8a6a3a;
  --ig-on-primary: #0d0d0f;
  --ig-text: #f5f5f5;
  --ig-text-dim: #8a8a8a;
  --ig-success: #22c55e;
  --ig-radius: 16px;
  --ig-appbar-h: 54px;
  --ig-tabbar-h: 64px;
  --ig-safe-top: env(safe-area-inset-top, 0px);
  --ig-safe-bottom: env(safe-area-inset-bottom, 0px);
  --ig-safe-left: env(safe-area-inset-left, 0px);
  --ig-safe-right: env(safe-area-inset-right, 0px);
  --ma-ripple: rgba(201, 169, 110, .32);

  /* --- échelle de z-index unique --- */
  --z-content: 1;
  --z-panel: 500;
  --z-bars: 2000;
  --z-drawer-scrim: 2400;
  --z-drawer: 2500;
  --z-moresheet-scrim: 2600;
  --z-moresheet: 2700;
  --z-volumegrid: 2800;
  --z-modal: 5000;
}

/* ============================================================
   BASE
   ============================================================ */
body.mobile-app-active {
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  background: var(--ig-bg);
  overflow-x: hidden !important;
  max-width: 100vw !important;
}
body.mobile-app-active * {
  -webkit-tap-highlight-color: transparent;
  box-sizing: border-box;
  overflow-wrap: break-word;
  word-wrap: break-word;
}

body.mobile-app-active .top-bar,
body.mobile-app-active .floating-hamburger,
body.mobile-app-active .toolbar-container,
body.mobile-app-active .progress-counter,
body.mobile-app-active .nav-markers, 
body.mobile-app-active .heatmap-header,
body.mobile-app-active .favorites-header,
body.mobile-app-active .stats-header,
body.mobile-app-active .premium-header,
body.mobile-app-active .premium-tabs,
body.mobile-app-active .favorites-sta{
  display: none !important;
}

body.mobile-app-active .heatmap-btn-fullscreen,
body.mobile-app-active .favorites-btn-fullscreen,
body.mobile-app-active .stats-btn-fullscreen,
body.mobile-app-active .mentor-btn-fullscreen,
body.mobile-app-active #premiumFullscreenBtn {
  display: none !important;
}

body.mobile-app-active .reader-layout {
  padding-top: calc(var(--ig-appbar-h) + var(--ig-safe-top));
  padding-bottom: calc(var(--ig-tabbar-h) + var(--ig-safe-bottom));
  height: 100vh;
  height: 100dvh;
  box-sizing: border-box;
  overflow-x: hidden !important;
  max-width: 100vw !important;
}

body.mobile-app-active .main-content {
  padding: 8px 10px 24px 10px !important;
  height: 100% !important;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  background: var(--ig-bg);
  position: relative;
  z-index: var(--z-content);
  overflow-x: hidden !important;
  max-width: 100vw !important;
}

body.mobile-app-active .book-content {
  border-radius: var(--ig-radius);
  padding: 16px 14px;
  background: var(--ig-surface);
  border: 1px solid var(--ig-border);
  overflow-x: hidden !important;
  height: 100% !important;
  max-width: 100% !important;
}

body.mobile-app-active .notes-sidebar {
  display: none !important;
}

/* ============================================================
   1. TOP APP BAR
   ============================================================ */
.ma-appbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: calc(var(--ig-appbar-h) + var(--ig-safe-top));
  padding-top: var(--ig-safe-top);
  padding-left: calc(14px + var(--ig-safe-left));
  padding-right: calc(10px + var(--ig-safe-right));
  background: rgba(8, 8, 9, .94);
  backdrop-filter: blur(18px) saturate(1.4);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  border-bottom: 1px solid var(--ig-border);
  display: none;
  align-items: center;
  gap: 6px;
  z-index: var(--z-bars);
}
body.mobile-app-active .ma-appbar {
  display: flex;
}

.ma-appbar-title {
  flex: 1;
  min-width: 0;
}
.ma-appbar-title #maAppBarMain {
  display: block;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -.2px;
  color: var(--ig-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: 'Inter', sans-serif;
}
.ma-appbar-sub {
  display: block;
  font-size: .58rem;
  font-weight: 600;
  color: var(--ig-primary);
  margin-top: 1px;
}

.ma-appbar-icons {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}
.ma-appbar-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--ig-text);
  font-size: 1.2rem;
  position: relative;
  overflow: hidden;
  transition: background .2s ease, color .2s ease, transform .15s ease;
}
.ma-appbar-btn:active {
  transform: scale(.88);
}
.ma-appbar-btn.ma-active-state {
  color: var(--ig-primary);
  background: rgba(201, 169, 110, .14);
}

/* ============================================================
   2. BOTTOM NAVIGATION — sans badges, sans rouge
   ============================================================ */
.ma-tabbar-wrap {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: var(--z-bars);
  display: none;
  pointer-events: none;
}
body.mobile-app-active .ma-tabbar-wrap {
  display: block;
}

.ma-tabbar {
  position: relative;
  pointer-events: auto;
  height: calc(var(--ig-tabbar-h) + var(--ig-safe-bottom));
  padding-bottom: var(--ig-safe-bottom);
  background: linear-gradient(180deg, rgba(10, 10, 11, .86) 0%, rgba(4, 4, 5, .98) 55%, #000 100%);
  backdrop-filter: blur(22px) saturate(1.5);
  -webkit-backdrop-filter: blur(22px) saturate(1.5);
  border-top: 1px solid rgba(255, 255, 255, .08);
  box-shadow: 0 -10px 30px rgba(0, 0, 0, .45);
  display: flex;
  align-items: stretch;
}

/* pastille lumineuse dorée */
.ma-tab-glow {
  position: absolute;
  top: 6px;
  width: 46px;
  height: 46px;
  border-radius: 16px;
  background: radial-gradient(circle at 50% 40%, rgba(201, 169, 110, .28), rgba(201, 169, 110, 0) 72%);
  transform: translateX(0);
  transition: transform .38s cubic-bezier(.34, 1.56, .64, 1), opacity .2s ease;
  pointer-events: none;
  opacity: 0;
}
.ma-tab-glow.visible {
  opacity: 1;
}

.ma-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: none;
  border: none;
  color: var(--ig-text);
  position: relative;
  overflow: visible;
  padding: 6px 0 2px 0;
  z-index: 1;
  cursor: pointer;
}
.ma-tab i {
  font-size: 1.42rem;
  opacity: .5;
  color: var(--ig-text-dim);
  transition: opacity .2s ease, color .2s ease, transform .32s cubic-bezier(.34, 1.56, .64, 1);
  transform: translateY(0) scale(1);
}
.ma-tab .ma-tab-label {
  font-size: .5rem;
  font-weight: 700;
  letter-spacing: .2px;
  color: var(--ig-text-dim);
  opacity: 0;
  transform: translateY(2px);
  transition: opacity .2s ease, transform .2s ease;
}
.ma-tab.active i {
  opacity: 1;
  color: var(--ig-primary-light);
  transform: translateY(-2px) scale(1.12);
  filter: drop-shadow(0 2px 8px rgba(201, 169, 110, .45));
  animation: ma-tab-pop .38s cubic-bezier(.34, 1.56, .64, 1);
}
.ma-tab.active .ma-tab-label {
  opacity: 1;
  transform: translateY(0);
  color: var(--ig-primary-light);
}
@keyframes ma-tab-pop {
  0% { transform: translateY(0) scale(1); }
  45% { transform: translateY(-5px) scale(1.28); }
  100% { transform: translateY(-2px) scale(1.12); }
}

/* Onglet Favoris — doré comme les autres, pas rouge */
.ma-tab[data-tab="favorites"].active i {
  color: var(--ig-primary-light);
  filter: drop-shadow(0 2px 8px rgba(201, 169, 110, .45));
}

/* Bouton central */
.ma-tab-center {
  flex: 1.15;
}
.ma-tab-center .ma-center-btn {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  margin-top: 5px;
  background: linear-gradient(150deg, var(--ig-primary-light) 0%, var(--ig-primary) 45%, var(--ig-primary-variant) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 11px rgba(201, 169, 110, .42), 0 2px 6px rgba(0, 0, 0, .5), inset 0 1px 1px rgba(255, 255, 255, .4);
  transition: transform .25s cubic-bezier(.34, 1.56, .64, 1), box-shadow .25s ease;
  position: relative;
}
.ma-tab-center .ma-center-btn::after {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 22px;
  border: 1.5px solid rgba(201, 169, 110, .35);
  animation: ma-center-ring 2.6s ease-in-out infinite;
}
@keyframes ma-center-ring {
  0%, 100% { opacity: .35; transform: scale(1); }
  50% { opacity: .05; transform: scale(1.14); }
}
.ma-tab-center .ma-center-btn i {
  font-size: 1.35rem;
  color: var(--ig-on-primary);
  opacity: 1;
  filter: none;
  transform: none;
}
.ma-tab-center:active .ma-center-btn {
  transform: scale(.88) rotate(-6deg);
}
.ma-tab-center .ma-tab-label {
  margin-top: 2px;
}

/* Onglet Notes — violet, sans badge */
.ma-tab-notes .ma-notes-circle {
  width: 27px;
  height: 27px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--ig-on-primary);
  background: linear-gradient(135deg, #a78bfa, #7c3aed);
  border: 2px solid transparent;
  opacity: 0.55;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.ma-tab-notes.active .ma-notes-circle {
  opacity: 1;
  border-color: #a78bfa;
  transform: scale(1.14) translateY(-1px);
  box-shadow: 0 3px 12px rgba(167, 139, 250, 0.45);
}
.ma-tab-notes.active i {
  color: #a78bfa !important;
}
.ma-tab-notes.active .ma-tab-label {
  color: #a78bfa !important;
}

/* ============================================================
   3. RIPPLE
   ============================================================ */
.ma-ripple {
  position: relative;
  overflow: hidden;
}
.ma-ripple-circle {
  position: absolute;
  border-radius: 50%;
  background: var(--ma-ripple);
  transform: scale(0);
  animation: ma-ripple-anim .5s ease-out forwards;
  pointer-events: none;
}
@keyframes ma-ripple-anim {
  to { transform: scale(2.6); opacity: 0; }
}

/* ============================================================
   4. DRAWER
   ============================================================ */
.ma-scrim {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .62);
  z-index: var(--z-drawer-scrim);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease;
}
.ma-scrim.visible {
  opacity: 1;
  pointer-events: auto;
}

.ma-drawer {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  width: min(86vw, 340px);
  background: var(--ig-surface);
  z-index: var(--z-drawer);
  transform: translateX(-100%);
  transition: transform .3s cubic-bezier(.4, 0, .2, 1);
  border-right: 1px solid var(--ig-border);
  display: flex;
  flex-direction: column;
  padding-top: var(--ig-safe-top);
  padding-bottom: var(--ig-safe-bottom);
  box-shadow: 12px 0 40px rgba(0, 0, 0, .5);
}
.ma-drawer.open {
  transform: translateX(0);
}

.ma-drawer-header {
  padding: 22px 18px 16px 18px;
  background: linear-gradient(135deg, rgba(201, 169, 110, .16), rgba(0, 0, 0, 0));
  border-bottom: 1px solid var(--ig-border);
  flex-shrink: 0;
}
.ma-drawer-header .ma-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--ig-primary), var(--ig-primary-variant));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: var(--ig-on-primary);
  font-size: 1.25rem;
  margin-bottom: 10px;
  box-shadow: 0 4px 16px rgba(201, 169, 110, .3);
}
.ma-drawer-header .ma-name {
  font-size: .95rem;
  font-weight: 800;
  color: var(--ig-text);
}
.ma-drawer-header .ma-progress-line {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.ma-drawer-header .ma-progress-track {
  flex: 1;
  height: 4px;
  background: rgba(255, 255, 255, .08);
  border-radius: 4px;
  overflow: hidden;
}
.ma-drawer-header .ma-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--ig-primary), var(--ig-primary-light));
  border-radius: 4px;
}
.ma-drawer-header .ma-progress-text {
  font-size: .55rem;
  color: var(--ig-primary);
  font-weight: 700;
}

/* BOUTON CONNEXION / DÉCONNEXION DANS DRAWER — neutre/doré */
.ma-drawer-auth-btn {
  margin-top: 10px;
  width: 100%;
  padding: 10px 16px;
  border-radius: 14px;
  border: 1px solid var(--ig-border);
  background: var(--ig-surface-2);
  color: var(--ig-text);
  font-size: .7rem;
  font-weight: 700;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: all .2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.ma-drawer-auth-btn:hover {
  background: var(--ig-surface-3);
}
.ma-drawer-auth-btn.guest {
  background: rgba(201, 169, 110, .12);
  border-color: rgba(201, 169, 110, .2);
  color: var(--ig-primary-light);
}
.ma-drawer-auth-btn.guest:hover {
  background: rgba(201, 169, 110, .18);
}
.ma-drawer-auth-btn.logout {
  color: var(--ig-text-dim);
}
.ma-drawer-auth-btn.logout:hover {
  background: rgba(255, 255, 255, .04);
}

.ma-drawer-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
  -webkit-overflow-scrolling: touch;
}
.ma-drawer-search {
  margin: 10px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--ig-surface-2);
  border-radius: 12px;
  padding: 9px 14px;
  border: 1px solid var(--ig-border);
}
.ma-drawer-search input {
  flex: 1;
  background: none;
  border: none;
  color: var(--ig-text);
  font-size: .75rem;
  outline: none;
  font-family: 'Inter', sans-serif;
}
.ma-drawer-search i {
  color: var(--ig-text-dim);
  font-size: .75rem;
}
.ma-drawer-section-title {
  padding: 10px 18px 4px 18px;
  font-size: .55rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--ig-text-dim);
  font-weight: 800;
}
.ma-drawer .notes-list {
  padding: 0 8px;
}
.ma-drawer .note-item {
  margin-bottom: 8px;
}

.ma-drawer-footer {
  padding: 10px 14px;
  border-top: 1px solid var(--ig-border);
  flex-shrink: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.ma-drawer-footer button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  background: var(--ig-surface-2);
  border: 1px solid var(--ig-border);
  border-radius: 12px;
  padding: 10px 4px;
  color: var(--ig-text);
  font-size: .5rem;
  font-weight: 700;
  transition: transform .15s ease;
  cursor: pointer;
}
.ma-drawer-footer button:active {
  transform: scale(.93);
}
.ma-drawer-footer button i {
  font-size: 1rem;
  color: var(--ig-primary);
}

/* ============================================================
   5. MODALES — sans rouge
   ============================================================ */
body.mobile-app-active .modal-overlay,
body.mobile-app-active .confirm-modal-overlay,
body.mobile-app-active .edit-modal-overlay,
body.mobile-app-active .task-modal-overlay,
body.mobile-app-active .comments-modal-overlay,
body.mobile-app-active .link-picker-overlay {
  z-index: var(--z-modal) !important;
  align-items: flex-end !important;
  background: rgba(0, 0, 0, .68) !important;
  backdrop-filter: blur(8px) !important;
  -webkit-backdrop-filter: blur(8px) !important;
  padding: 0 !important;
}

body.mobile-app-active .modal-container,
body.mobile-app-active .confirm-modal-box,
body.mobile-app-active .edit-modal,
body.mobile-app-active .task-modal,
body.mobile-app-active .comments-modal {
  width: 100% !important;
  max-width: 100% !important;
  border-radius: 22px 22px 0 0 !important;
  margin: 0 !important;
  max-height: calc(92vh - var(--ig-safe-bottom)) !important;
  padding-bottom: calc(22px + var(--ig-safe-bottom)) !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch;
  position: relative !important;
  top: auto !important;
  transform: none !important;
  box-shadow: 0 -20px 60px rgba(0, 0, 0, .6) !important;
  animation: ma-sheet-in .32s cubic-bezier(.32, .72, 0, 1) !important;
}
@keyframes ma-sheet-in {
  from { transform: translateY(100%); opacity: .4; }
  to { transform: translateY(0); opacity: 1; }
}

body.mobile-app-active .modal-container::before,
body.mobile-app-active .confirm-modal-box::before,
body.mobile-app-active .edit-modal::before,
body.mobile-app-active .task-modal::before,
body.mobile-app-active .comments-modal::before {
  content: '';
  display: block;
  width: 38px;
  height: 4px;
  border-radius: 4px;
  background: rgba(255, 255, 255, .28);
  margin: 0 auto 10px auto;
}

/* ============================================================
   6. PAGES PLEIN ÉCRAN
   ============================================================ */
body.mobile-app-active #lawMapFullscreen,
body.mobile-app-active #favoritesFullscreen,
body.mobile-app-active #statsFullscreen,
body.mobile-app-active #notebookFullscreen,
body.mobile-app-active #mentorFullscreen {
  position: fixed !important;
  inset: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  height: 100% !important;
  margin: 0 !important;
  z-index: var(--z-panel) !important;
  background: var(--ig-bg) !important;
  padding: 0 calc(10px + var(--ig-safe-right)) 5px calc(10px + var(--ig-safe-left)) !important;
  transform: translateX(100%);
  transition: transform .32s cubic-bezier(.4, 0, .2, 1);
  overflow-y: auto !important;
  overflow-x: hidden !important;
  -webkit-overflow-scrolling: touch;
  box-sizing: border-box !important;
}
body.mobile-app-active #lawMapFullscreen.ma-open,
body.mobile-app-active #favoritesFullscreen.ma-open,
body.mobile-app-active #statsFullscreen.ma-open,
body.mobile-app-active #notebookFullscreen.ma-open,
body.mobile-app-active #mentorFullscreen.ma-open {
  transform: translateX(0) !important;
}

body.mobile-app-active .heatmap-matrix,
body.mobile-app-active .favorites-grid,
body.mobile-app-active .stats-charts,
body.mobile-app-active #statsFullscreen .chart-wrapper {
  max-height: none !important;
  overflow: visible !important;
  height: auto !important;
}
body.mobile-app-active .favorites-grid {
  display: grid !important;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)) !important;
}
body.mobile-app-active .heatmap-matrix table {
  width: 100% !important;
}
body.mobile-app-active .heatmap-matrix td {
  min-width: 36px !important;
  min-height: 36px !important;
}
body.mobile-app-active .heatmap-matrix .cell-inner {
  min-height: 34px !important;
  min-width: 34px !important;
  font-size: 0.7rem !important;
}

body.mobile-app-active .mentor-body {
  flex-direction: column;
  height: auto !important;
}
body.mobile-app-active .mentor-conversations-panel {
  max-width: 100%;
  flex: none;
  max-height: 150px;
}
body.mobile-app-active .notes-panel,
body.mobile-app-active .agenda-panel {
  flex-direction: column;
  height: auto !important;
}
body.mobile-app-active .notes-list-panel,
body.mobile-app-active .agenda-calendar-panel {
  max-height: 230px;
}
body.mobile-app-active .premium-tabs {
  overflow-x: auto;
  flex-wrap: nowrap;
  -webkit-overflow-scrolling: touch;
}
body.mobile-app-active .notes-editor-body {
  overflow: visible !important;
}

/* ============================================================
   7. MENU secondaire — sans rouge
   ============================================================ */
.ma-more-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--ig-surface);
  border-radius: 22px 22px 0 0;
  z-index: var(--z-moresheet);
  transform: translateY(100%);
  transition: transform .3s cubic-bezier(.32, .72, 0, 1);
  padding: 0 0 calc(16px + var(--ig-safe-bottom)) 0;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, .55);
  max-height: 75vh;
  overflow-y: auto;
  border-top: 1px solid var(--ig-border);
}
.ma-more-sheet.open {
  transform: translateY(0);
}
.ma-more-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 10px 14px 10px 14px;
}
.ma-more-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 15px 6px;
  border-radius: 16px;
  background: var(--ig-surface-2);
  border: 1px solid var(--ig-border);
  color: var(--ig-text);
  font-size: .6rem;
  font-weight: 600;
  text-align: center;
  position: relative;
  overflow: hidden;
  transition: transform .15s ease;
  cursor: pointer;
}
.ma-more-item:active {
  transform: scale(.94);
}
.ma-more-item i {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(201, 169, 110, .14);
  color: var(--ig-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}
.ma-more-item.danger i {
  background: rgba(255, 255, 255, .06);
  color: var(--ig-text-dim);
}

/* ============================================================
   8. GRILLE DES VOLUMES
   ============================================================ */
.ma-volumegrid {
  position: fixed;
  inset: 0;
  z-index: var(--z-volumegrid);
  background: var(--ig-bg);
  transform: translateY(100%);
  transition: transform .34s cubic-bezier(.32, .72, 0, 1);
  display: flex;
  flex-direction: column;
  padding-top: var(--ig-safe-top);
  padding-bottom: var(--ig-safe-bottom);
}
.ma-volumegrid.open {
  transform: translateY(0);
}

.ma-vg-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--ig-border);
  flex-shrink: 0;
  background: linear-gradient(180deg, rgba(201, 169, 110, .08), transparent);
}
.ma-vg-header .ma-vg-back {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ig-surface-2);
  border: 1px solid var(--ig-border);
  color: var(--ig-text);
  font-size: 1.05rem;
  flex-shrink: 0;
  cursor: pointer;
}
.ma-vg-header .ma-vg-title {
  flex: 1;
}
.ma-vg-header .ma-vg-title strong {
  display: block;
  font-size: 1rem;
  font-weight: 800;
  color: var(--ig-text);
  background: linear-gradient(135deg, var(--ig-primary-light), var(--ig-primary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.ma-vg-header .ma-vg-title span {
  display: block;
  font-size: .58rem;
  color: var(--ig-text-dim);
  margin-top: 2px;
  font-weight: 600;
}

.ma-vg-progress {
  margin: 10px 14px 0 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.ma-vg-progress-track {
  flex: 1;
  height: 6px;
  border-radius: 6px;
  background: var(--ig-surface-3);
  overflow: hidden;
}
.ma-vg-progress-fill {
  height: 100%;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--ig-primary), var(--ig-primary-light));
  transition: width .5s ease;
}
.ma-vg-progress-text {
  font-size: .6rem;
  font-weight: 800;
  color: var(--ig-primary);
  white-space: nowrap;
}

.ma-vg-filters {
  display: flex;
  gap: 8px;
  padding: 12px 14px 10px 14px;
  flex-shrink: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.ma-vg-filters::-webkit-scrollbar {
  display: none;
}
.ma-vg-chip {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 15px;
  border-radius: 22px;
  border: 1px solid var(--ig-border);
  background: var(--ig-surface-2);
  color: var(--ig-text-dim);
  font-size: .65rem;
  font-weight: 700;
  transition: all .2s ease;
  cursor: pointer;
}
.ma-vg-chip.active {
  background: linear-gradient(135deg, var(--ig-primary), var(--ig-primary-variant));
  color: var(--ig-on-primary);
  border-color: transparent;
  box-shadow: 0 3px 12px rgba(201, 169, 110, .3);
}

.ma-vg-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 4px 10px 24px 10px;
}
.ma-vg-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
}

.ma-vg-cell {
  position: relative;
  aspect-ratio: 1/1;
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: transform .18s cubic-bezier(.34, 1.56, .64, 1);
  cursor: pointer;
}
.ma-vg-cell:active {
  transform: scale(.93);
}

.ma-vg-cell.unlocked {
  background: linear-gradient(155deg, var(--ig-primary-light) 0%, var(--ig-primary) 48%, #6b4e22 100%);
  box-shadow: 0 6px 18px rgba(201, 169, 110, .32), inset 0 1px 1px rgba(255, 255, 255, .35);
}
.ma-vg-cell.unlocked::after {
  content: '';
  position: absolute;
  top: -40%;
  left: -20%;
  width: 70%;
  height: 70%;
  background: radial-gradient(circle, rgba(255, 255, 255, .35), transparent 70%);
  transform: rotate(-20deg);
  pointer-events: none;
}
.ma-vg-cell.unlocked .ma-vg-num {
  color: #241705;
  text-shadow: 0 1px 0 rgba(255, 255, 255, .25);
}
.ma-vg-cell.unlocked .ma-vg-check {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--ig-success);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .3);
  border: 2px solid rgba(255, 255, 255, .5);
}
.ma-vg-cell.unlocked .ma-vg-check i {
  font-size: .5rem;
  color: #fff;
}

.ma-vg-cell.current-vol {
  outline: 2.5px solid #fff;
  outline-offset: -2.5px;
}
.ma-vg-cell.current-vol::before {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 19px;
  border: 2px solid var(--ig-primary-light);
  animation: ma-vg-current-pulse 1.8s ease-in-out infinite;
}
@keyframes ma-vg-current-pulse {
  0%, 100% { opacity: .9; }
  50% { opacity: .2; }
}

.ma-vg-cell.locked {
  background: linear-gradient(155deg, #232326, #101012);
  border: 1px solid rgba(255, 255, 255, .06);
}
.ma-vg-cell.locked .ma-vg-num {
  color: rgba(255, 255, 255, .32);
}
.ma-vg-cell.locked .ma-vg-lockwrap {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .07);
  display: flex;
  align-items: center;
  justify-content: center;
}
.ma-vg-cell.locked .ma-vg-lockwrap i {
  font-size: .85rem;
  color: rgba(255, 255, 255, .45);
}

.ma-vg-cell.next-unlock {
  background: linear-gradient(155deg, #2a2214, #161208);
  border: 1.5px dashed var(--ig-primary);
  animation: ma-vg-next-glow 2.2s ease-in-out infinite;
}
@keyframes ma-vg-next-glow {
  0%, 100% { box-shadow: 0 0 0 rgba(201, 169, 110, 0); }
  50% { box-shadow: 0 0 16px rgba(201, 169, 110, .3); }
}
.ma-vg-cell.next-unlock .ma-vg-num {
  color: var(--ig-primary-light);
}
.ma-vg-cell.next-unlock .ma-vg-lockwrap {
  background: rgba(201, 169, 110, .18);
}
.ma-vg-cell.next-unlock .ma-vg-lockwrap i {
  color: var(--ig-primary-light);
  font-size: .85rem;
}
.ma-vg-cell.next-unlock .ma-vg-unlock-label {
  position: absolute;
  bottom: 6px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: .42rem;
  font-weight: 800;
  letter-spacing: .4px;
  color: var(--ig-primary-light);
  text-transform: uppercase;
}

.ma-vg-num {
  font-size: 1.5rem;
  font-weight: 900;
  line-height: 1;
}
.ma-vg-vol-label {
  font-size: .44rem;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
  opacity: .75;
}

.ma-volumegrid-empty {
  grid-column: 1/-1;
  text-align: center;
  padding: 60px 20px;
  color: var(--ig-text-dim);
}
.ma-volumegrid-empty i {
  font-size: 2rem;
  opacity: .3;
  display: block;
  margin-bottom: 10px;
}

.ma-vg-legend {
  display: flex;
  justify-content: center;
  gap: 16px;
  padding: 12px 10px 4px 10px;
  flex-shrink: 0;
}
.ma-vg-legend span {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: .5rem;
  color: var(--ig-text-dim);
  font-weight: 600;
}
.ma-vg-legend .dot {
  width: 9px;
  height: 9px;
  border-radius: 3px;
}
.ma-vg-legend .dot.unlocked {
  background: linear-gradient(135deg, var(--ig-primary-light), var(--ig-primary));
}
.ma-vg-legend .dot.locked {
  background: #2a2a2d;
  border: 1px solid rgba(255, 255, 255, .15);
}
.ma-vg-legend .dot.next {
  background: transparent;
  border: 1.5px dashed var(--ig-primary);
}

/* ============================================================
   9. RESPONSIVE
   ============================================================ */
@media (max-width: 700px) {
  .ma-vg-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
  }
  .ma-vg-num {
    font-size: 1.2rem;
  }
  body.mobile-app-active .heatmap-matrix td {
    min-width: 28px !important;
    min-height: 28px !important;
  }
  body.mobile-app-active .heatmap-matrix .cell-inner {
    min-height: 26px !important;
    min-width: 26px !important;
    font-size: 0.55rem !important;
  }
}

@media (max-width: 480px) {
  .ma-vg-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }
  .ma-vg-num {
    font-size: 1rem;
  }
  .ma-vg-cell .ma-vg-vol-label {
    font-size: .35rem;
  }
  .ma-vg-cell .ma-vg-check {
    width: 16px;
    height: 16px;
  }
  .ma-vg-cell .ma-vg-check i {
    font-size: .4rem;
  }
  body.mobile-app-active .heatmap-matrix td {
    min-width: 22px !important;
    min-height: 22px !important;
  }
  body.mobile-app-active .heatmap-matrix .cell-inner {
    min-height: 20px !important;
    min-width: 20px !important;
    font-size: 0.45rem !important;
  }
  body.mobile-app-active .favorites-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)) !important;
  }
}

/* ============================================================
   10. Toast
   ============================================================ */
body.mobile-app-active .toast {
  bottom: calc(var(--ig-tabbar-h) + var(--ig-safe-bottom) + 14px) !important;
  width: calc(100% - 32px);
  max-width: 360px;
  text-align: center;
  border-radius: 14px !important;
  z-index: calc(var(--z-modal) + 100) !important;
}

/* ============================================================
   11. Correction scroll horizontal
   ============================================================ */
body.mobile-app-active .main-content,
body.mobile-app-active .book-content,
body.mobile-app-active .reader-layout,
body.mobile-app-active .ma-drawer,
body.mobile-app-active .ma-volumegrid,
body.mobile-app-active .ma-more-sheet {
  overflow-x: hidden !important;
  max-width: 100vw !important;
}

body.mobile-app-active img,
body.mobile-app-active table,
body.mobile-app-active pre,
body.mobile-app-active .heatmap-matrix table {
  max-width: 100% !important;
  height: auto !important;
}

/* ============================================================
   12. POPUP DE COMPTE — pas de rouge
   ============================================================ */
.ma-auth-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--ig-surface);
  border-radius: 26px 26px 0 0;
  z-index: var(--z-moresheet);
  transform: translateY(100%);
  transition: transform .34s cubic-bezier(.32, .72, 0, 1);
  padding: 6px 22px calc(24px + var(--ig-safe-bottom)) 22px;
  box-shadow: 0 -14px 50px rgba(0, 0, 0, .6);
  border-top: 1px solid var(--ig-border);
  text-align: center;
  overflow: hidden;
}
.ma-auth-sheet.open {
  transform: translateY(0);
}

.ma-auth-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  margin: 14px auto 14px auto;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(155deg, var(--ig-primary-light), var(--ig-primary) 60%, var(--ig-primary-variant));
  box-shadow: 0 10px 28px rgba(201, 169, 110, .4), inset 0 2px 2px rgba(255, 255, 255, .4);
  position: relative;
  z-index: 1;
}
.ma-auth-avatar i {
  font-size: 1.7rem;
  color: var(--ig-on-primary);
}
.ma-auth-avatar.logout {
  background: var(--ig-surface-2);
  box-shadow: 0 10px 28px rgba(0, 0, 0, .3);
}
.ma-auth-avatar.logout i {
  color: var(--ig-text-dim);
}

.ma-auth-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--ig-text);
  position: relative;
  z-index: 1;
}
.ma-auth-sub {
  font-size: .72rem;
  color: var(--ig-text-dim);
  line-height: 1.5;
  margin: 8px 0 20px 0;
  position: relative;
  z-index: 1;
}

.ma-auth-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px 20px;
  border-radius: 16px;
  border: none;
  font-size: .82rem;
  font-weight: 800;
  font-family: 'Inter', sans-serif;
  margin-bottom: 10px;
  transition: transform .15s ease;
  cursor: pointer;
}
.ma-auth-btn:active {
  transform: scale(.97);
}
.ma-auth-btn.primary {
  background: linear-gradient(135deg, var(--ig-primary-light), var(--ig-primary));
  color: var(--ig-on-primary);
  box-shadow: 0 8px 22px rgba(201, 169, 110, .35);
}
.ma-auth-btn.secondary {
  background: var(--ig-surface-2);
  color: var(--ig-text);
  border: 1px solid var(--ig-border);
}
.ma-auth-btn.danger {
  background: rgba(255, 255, 255, .04);
  color: var(--ig-text-dim);
  border: 1px solid var(--ig-border);
}
.ma-auth-btn.danger:hover {
  background: rgba(255, 255, 255, .08);
}
.ma-auth-skip {
  display: block;
  margin-top: 6px;
  font-size: .65rem;
  color: var(--ig-text-dim);
  font-weight: 600;
  padding: 8px;
  cursor: pointer;
}