/* La Bétaillère V4 — peau de preview injectée sur le vrai index.
 * IMPORTANT : cette feuille ne masque ni ne remplace aucune fonctionnalité.
 * Elle ne fait que normaliser l'apparence du DOM réellement produit par index.html.
 */

html[data-lb-v4-live="1"] {
  color-scheme: dark;
  --lb4-bg: #020910;
  --lb4-bg-2: #04131d;
  --lb4-panel: rgba(5, 22, 33, .94);
  --lb4-panel-2: rgba(7, 31, 45, .94);
  --lb4-panel-soft: rgba(10, 43, 58, .72);
  --lb4-line: rgba(65, 226, 240, .22);
  --lb4-line-strong: rgba(65, 226, 240, .52);
  --lb4-cyan: #36e5ef;
  --lb4-blue: #34a5ff;
  --lb4-text: #f2fcff;
  --lb4-soft: #bed8df;
  --lb4-muted: #7f9ba4;
  --lb4-green: #38dc95;
  --lb4-yellow: #ffd45b;
  --lb4-orange: #ff9d4d;
  --lb4-red: #ff5967;
  --lb4-r1: 10px;
  --lb4-r2: 14px;
  --lb4-r3: 18px;
  --lb4-r4: 24px;
  --lb4-gap: clamp(12px, 1.7vw, 20px);
  --lb4-shadow: 0 16px 42px rgba(0,0,0,.28);
  --lb4-top: 72px;
}

html[data-lb-v4-live="1"],
html[data-lb-v4-live="1"] body {
  background: var(--lb4-bg) !important;
}

html[data-lb-v4-live="1"] body {
  color: var(--lb4-text) !important;
  background-image:
    radial-gradient(circle at 50% -140px, rgba(34, 198, 220, .16), transparent 640px),
    linear-gradient(rgba(49,231,242,.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(49,231,242,.025) 1px, transparent 1px),
    linear-gradient(180deg, #061824 0, var(--lb4-bg) 720px) !important;
  background-size: auto, 48px 48px, 48px 48px, auto !important;
  background-attachment: fixed !important;
}

html[data-lb-v4-preview="1"] body::after {
  content: "V4 LIVE PREVIEW · INDEX RÉEL";
  position: fixed;
  z-index: 2147483000;
  left: 50%;
  bottom: calc(78px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  padding: 5px 10px;
  border: 1px solid rgba(255, 212, 91, .42);
  border-radius: 999px;
  background: rgba(19, 14, 3, .88);
  color: #ffe787;
  font: 800 10px/1.2 system-ui, sans-serif;
  letter-spacing: .1em;
  pointer-events: none;
  box-shadow: 0 6px 24px rgba(0,0,0,.28);
}

html[data-lb-v4-live="1"] :where(.top-bar, .bottom-nav) {
  border-color: var(--lb4-line-strong) !important;
  background: rgba(3, 16, 25, .94) !important;
  box-shadow: 0 14px 38px rgba(0,0,0,.32), 0 0 24px rgba(54,229,239,.08) !important;
  backdrop-filter: blur(12px) saturate(125%) !important;
  -webkit-backdrop-filter: blur(12px) saturate(125%) !important;
}

html[data-lb-v4-live="1"] .top-bar::after,
html[data-lb-v4-live="1"] .bottom-nav::before {
  background: linear-gradient(90deg, transparent, var(--lb4-cyan), transparent) !important;
  opacity: .78 !important;
}

html[data-lb-v4-live="1"] .top-bar__inner,
html[data-lb-v4-live="1"] .app-page,
html[data-lb-v4-live="1"] #home {
  max-width: 1420px !important;
}

html[data-lb-v4-live="1"] :where(.lb-page-intro, .home-card, .fav-card, .search-card, .console-section, .media-section, .train-detail-card, .lb-profile-card, .lb-prefs-card, .stats-v2__card) {
  border: 1px solid var(--lb4-line) !important;
  border-radius: var(--lb4-r3) !important;
  background:
    linear-gradient(145deg, rgba(11, 53, 69, .24), rgba(3, 16, 26, .78)),
    var(--lb4-panel) !important;
  box-shadow: var(--lb4-shadow), inset 0 1px 0 rgba(255,255,255,.025) !important;
}

html[data-lb-v4-live="1"] :where(.home-card, .fav-card, .search-card, .stats-v2__card, .train-detail-card) {
  position: relative;
  overflow: clip;
}

html[data-lb-v4-live="1"] :where(.home-card, .fav-card, .search-card, .stats-v2__card, .train-detail-card)::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 2px;
  background: linear-gradient(180deg, transparent, rgba(54,229,239,.72), transparent);
  opacity: .75;
  pointer-events: none;
}

html[data-lb-v4-live="1"] .home-dashboard {
  gap: var(--lb4-gap) !important;
}

html[data-lb-v4-live="1"] :where(h1,h2,h3,h4,.console-header,.fav-title,.live-wall-title) {
  color: var(--lb4-text) !important;
  text-shadow: none !important;
}

html[data-lb-v4-live="1"] :where(.lb-page-intro__eyebrow, .section-kicker, .stats-v2__eyebrow) {
  color: var(--lb4-cyan) !important;
  letter-spacing: .11em !important;
}

html[data-lb-v4-live="1"] :where(p, small, .muted, .lb-page-intro p) {
  color: var(--lb4-soft);
}

html[data-lb-v4-live="1"] :where(button, .btn, .home-action, .mini-btn, .train-detail-btn, a.button) {
  min-height: 42px;
  border-radius: var(--lb4-r2) !important;
  border-color: var(--lb4-line-strong) !important;
  box-shadow: none !important;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease !important;
}

html[data-lb-v4-live="1"] :where(button, .btn, .home-action, .mini-btn, .train-detail-btn):hover {
  border-color: var(--lb4-cyan) !important;
  transform: translateY(-1px);
}

html[data-lb-v4-live="1"] :where(button, .btn, .home-action, .mini-btn, .train-detail-btn):active {
  transform: translateY(0) scale(.985);
}

html[data-lb-v4-live="1"] :where(button[aria-pressed="true"], button[aria-selected="true"], button.is-active, .active > button) {
  border-color: rgba(54,229,239,.72) !important;
  background: linear-gradient(135deg, rgba(10,150,184,.9), rgba(22,104,175,.9)) !important;
  color: #fff !important;
}

html[data-lb-v4-live="1"] :where(input,select,textarea) {
  min-height: 42px;
  border: 1px solid var(--lb4-line-strong) !important;
  border-radius: var(--lb4-r2) !important;
  background: rgba(1, 10, 17, .84) !important;
  color: var(--lb4-text) !important;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.02) !important;
}

html[data-lb-v4-live="1"] :where(input,select,textarea):focus {
  border-color: var(--lb4-cyan) !important;
  outline: 2px solid rgba(54,229,239,.28) !important;
  outline-offset: 2px !important;
}

/* Tableau dynamique : priorité absolue à la lisibilité, pas d'effet gadget. */
html[data-lb-v4-live="1"] :where(.table-wrapper, .table-container, .dynamic-table-wrapper, .table-scroll, .lb-mobile-table-scroll) {
  border: 1px solid var(--lb4-line) !important;
  border-radius: var(--lb4-r3) !important;
  background: rgba(3, 17, 27, .92) !important;
  box-shadow: var(--lb4-shadow) !important;
  scrollbar-gutter: stable;
}

html[data-lb-v4-live="1"] table {
  border-collapse: separate !important;
  border-spacing: 0 !important;
}

html[data-lb-v4-live="1"] :where(th, thead td) {
  background: #082333 !important;
  color: var(--lb4-cyan) !important;
  border-color: rgba(54,229,239,.18) !important;
  font-weight: 800 !important;
}

html[data-lb-v4-live="1"] tbody tr {
  background: rgba(5, 23, 34, .64) !important;
  transition: background 120ms ease !important;
}

html[data-lb-v4-live="1"] tbody tr:nth-child(even) {
  background: rgba(8, 31, 43, .64) !important;
}

html[data-lb-v4-live="1"] tbody tr:hover {
  background: rgba(22, 87, 105, .28) !important;
}

html[data-lb-v4-live="1"] :where(td,th) {
  border-color: rgba(54,229,239,.13) !important;
}

/* LIVE / communauté */
html[data-lb-v4-live="1"] :where(.live-wall-card, .live-wall-card--home, .live-wall, .comments-card) {
  border-color: var(--lb4-line) !important;
  background: linear-gradient(145deg, rgba(9, 41, 55, .8), rgba(3, 17, 27, .94)) !important;
}

html[data-lb-v4-live="1"] :where(.live-comment, .live-item, .comment-row, .live-wall-item) {
  border-radius: var(--lb4-r2) !important;
  border-color: rgba(54,229,239,.15) !important;
  background: rgba(3, 18, 29, .78) !important;
}

/* LIVE voyageurs : hiérarchie claire et commune mobile / desktop.
 * On travaille dans la couche V4 existante : aucune nouvelle feuille et aucune
 * logique métier n'est ajoutée ici. */
html[data-lb-v4-live="1"] #lbLiveModal .lb-community-panel {
  width: min(980px, calc(100vw - 32px)) !important;
  max-width: 980px !important;
  max-height: min(900px, calc(100dvh - 32px)) !important;
  padding: 18px !important;
  border: 1px solid rgba(79, 225, 238, .32) !important;
  border-radius: 22px !important;
  background:
    radial-gradient(circle at 50% -12%, rgba(54,229,239,.075), transparent 36%),
    linear-gradient(155deg, rgba(5, 24, 36, .985), rgba(2, 12, 21, .995)) !important;
  box-shadow: 0 28px 80px rgba(0,0,0,.54), 0 0 0 1px rgba(54,229,239,.035) inset !important;
}

html[data-lb-v4-live="1"] #lbLiveModal .lb-community-head {
  margin: 0 0 14px !important;
  padding-right: 52px !important;
}

html[data-lb-v4-live="1"] #lbLiveModal .lb-community-head h3 {
  margin: 0 !important;
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
  font-size: clamp(1rem, 2vw, 1.22rem) !important;
  letter-spacing: .015em !important;
}

html[data-lb-v4-live="1"] #lbLiveModal .lb-community-panel-sub {
  margin-top: 5px !important;
  max-width: 760px;
  color: #9bbac3 !important;
  font: 600 .86rem/1.3 "Rajdhani", system-ui, sans-serif !important;
}

html[data-lb-v4-live="1"] #lbLiveModal .lb-community-grid {
  grid-template-columns: minmax(0, 1.45fr) minmax(260px, .72fr) !important;
  gap: 12px !important;
  align-items: start !important;
}

html[data-lb-v4-live="1"] #lbLiveModal :where(.lb-live-list, .lb-live-side) {
  min-width: 0 !important;
  padding: 11px !important;
  border: 1px solid rgba(54,229,239,.14) !important;
  border-radius: 16px !important;
  background: rgba(3, 17, 27, .58) !important;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.025) !important;
}

html[data-lb-v4-live="1"] #lbLiveModal .lb-live-toolbar {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) auto !important;
  align-items: end !important;
  gap: 10px !important;
  margin: 0 0 10px !important;
}

html[data-lb-v4-live="1"] #lbLiveModal .lb-live-toolbar-main {
  min-width: 0 !important;
  display: grid !important;
  gap: 6px !important;
}

html[data-lb-v4-live="1"] #lbLiveModal .lb-live-toolbar-main > strong,
html[data-lb-v4-live="1"] #lbLiveModal #lbLiveSideTitle {
  color: #eafcff !important;
  font: 800 .83rem/1.1 "Orbitron", system-ui, sans-serif !important;
}

html[data-lb-v4-live="1"] #lbLiveModal .lb-live-direction {
  width: 100% !important;
  min-width: 0 !important;
  min-height: 40px !important;
  height: 40px !important;
  padding: 0 36px 0 12px !important;
  border-radius: 12px !important;
  border-color: rgba(54,229,239,.48) !important;
  background: rgba(1, 12, 20, .88) !important;
  color: #eefcff !important;
  font: 700 .78rem/1 "Rajdhani", system-ui, sans-serif !important;
}

html[data-lb-v4-live="1"] #lbLiveModal .lb-live-count {
  min-width: 30px !important;
  height: 30px !important;
  padding: 0 8px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  border: 1px solid rgba(54,229,239,.34) !important;
  border-radius: 999px !important;
  background: rgba(3, 25, 36, .82) !important;
  color: #aeeef4 !important;
  font: 800 .69rem/1 "Orbitron", system-ui, sans-serif !important;
}

html[data-lb-v4-live="1"] #lbLiveModal .lb-live-cards {
  display: grid !important;
  gap: 8px !important;
}

html[data-lb-v4-live="1"] #lbLiveModal .lb-live-card {
  --lb-live-accent: var(--lb4-cyan);
  position: relative !important;
  min-width: 0 !important;
  overflow: hidden !important;
  padding: 10px 11px 9px !important;
  border: 1px solid rgba(54,229,239,.19) !important;
  border-radius: 14px !important;
  background:
    linear-gradient(145deg, rgba(10, 39, 53, .44), rgba(3, 16, 26, .86)) !important;
  box-shadow: 0 7px 18px rgba(0,0,0,.20), inset 0 1px 0 rgba(255,255,255,.025) !important;
  transform: none !important;
}

html[data-lb-v4-live="1"] #lbLiveModal .lb-live-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 10px;
  bottom: 10px;
  width: 2px;
  border-radius: 0 2px 2px 0;
  background: var(--lb-live-accent);
  opacity: .78;
  box-shadow: 0 0 8px var(--lb-live-accent);
  pointer-events: none;
}

html[data-lb-v4-live="1"] #lbLiveModal .lb-live-card--ok {
  --lb-live-accent: #38dc95;
  border-color: rgba(54,229,239,.19) !important;
  background: linear-gradient(145deg, rgba(8, 38, 49, .42), rgba(3, 16, 26, .86)) !important;
}
html[data-lb-v4-live="1"] #lbLiveModal .lb-live-card--delay {
  --lb-live-accent: #ff9d4d;
  border-color: rgba(255,157,77,.29) !important;
  background: linear-gradient(145deg, rgba(42, 29, 18, .36), rgba(3, 16, 26, .88)) !important;
}
html[data-lb-v4-live="1"] #lbLiveModal .lb-live-card--partial {
  --lb-live-accent: #ffd45b;
  border-color: rgba(255,212,91,.30) !important;
  background: linear-gradient(145deg, rgba(44, 36, 16, .34), rgba(3, 16, 26, .88)) !important;
}
html[data-lb-v4-live="1"] #lbLiveModal .lb-live-card--cancel {
  --lb-live-accent: #ff5967;
  border-color: rgba(255,89,103,.31) !important;
  background: linear-gradient(145deg, rgba(43, 19, 26, .34), rgba(3, 16, 26, .88)) !important;
}

html[data-lb-v4-live="1"] #lbLiveModal .lb-live-card:hover,
html[data-lb-v4-live="1"] #lbLiveModal .lb-live-card:focus-within {
  border-color: color-mix(in srgb, var(--lb-live-accent) 55%, transparent) !important;
  box-shadow: 0 9px 22px rgba(0,0,0,.24), 0 0 14px color-mix(in srgb, var(--lb-live-accent) 11%, transparent) !important;
}

html[data-lb-v4-live="1"] #lbLiveModal .lb-live-card-top {
  position: relative !important;
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) auto !important;
  grid-template-rows: auto auto !important;
  column-gap: 10px !important;
  row-gap: 4px !important;
  align-items: start !important;
}

html[data-lb-v4-live="1"] #lbLiveModal .lb-live-card-top > div:first-child {
  grid-column: 1 !important;
  grid-row: 1 / span 2 !important;
  min-width: 0 !important;
  padding: 0 !important;
}

html[data-lb-v4-live="1"] #lbLiveModal .lb-live-train-row {
  display: flex !important;
  align-items: center !important;
  gap: 6px !important;
  min-width: 0 !important;
}

html[data-lb-v4-live="1"] #lbLiveModal .lb-live-train {
  min-width: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
  color: var(--lb-live-accent) !important;
  font: 800 .84rem/1.1 "Orbitron", system-ui, sans-serif !important;
  text-shadow: none !important;
}

html[data-lb-v4-live="1"] #lbLiveModal .lb-live-route,
html[data-lb-v4-live="1"] #lbLiveModal .lb-live-schedule {
  min-width: 0 !important;
  margin-top: 5px !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
  color: #d8edf1 !important;
  font: 650 .76rem/1.18 "Rajdhani", system-ui, sans-serif !important;
}

html[data-lb-v4-live="1"] #lbLiveModal .lb-live-right {
  grid-column: 2 !important;
  grid-row: 1 !important;
  min-width: 0 !important;
  display: flex !important;
  align-items: flex-end !important;
  flex-direction: column !important;
  gap: 4px !important;
}

html[data-lb-v4-live="1"] #lbLiveModal .lb-live-status-row {
  display: flex !important;
  align-items: center !important;
  justify-content: flex-end !important;
  gap: 5px !important;
  flex-wrap: nowrap !important;
}

html[data-lb-v4-live="1"] #lbLiveModal .lb-live-passenger {
  min-height: 21px !important;
  height: 21px !important;
  padding: 0 6px !important;
  border: 1px solid rgba(54,229,239,.14) !important;
  border-radius: 999px !important;
  background: rgba(255,255,255,.025) !important;
  color: #95b7bf !important;
  font: 700 .61rem/1 "Rajdhani", system-ui, sans-serif !important;
}

html[data-lb-v4-live="1"] #lbLiveModal .lb-live-status,
html[data-lb-v4-live="1"] #lbLiveModal .lb-live-user-alert {
  min-height: 21px !important;
  height: 21px !important;
  padding: 0 7px !important;
  display: inline-flex !important;
  align-items: center !important;
  border-radius: 999px !important;
  font: 800 .60rem/1 "Orbitron", system-ui, sans-serif !important;
  white-space: nowrap !important;
}

html[data-lb-v4-live="1"] #lbLiveModal .lb-live-status {
  color: var(--lb-live-accent) !important;
  border-color: color-mix(in srgb, var(--lb-live-accent) 55%, transparent) !important;
  background: color-mix(in srgb, var(--lb-live-accent) 9%, #07131d) !important;
  box-shadow: none !important;
}

html[data-lb-v4-live="1"] #lbLiveModal .lb-live-compo-top {
  position: static !important;
  grid-column: 2 !important;
  grid-row: 2 !important;
  justify-self: end !important;
  align-self: end !important;
  width: auto !important;
  max-width: 84px !important;
  margin: 0 !important;
  transform: none !important;
  opacity: .82 !important;
  filter: drop-shadow(0 0 4px rgba(54,229,239,.32)) !important;
}

html[data-lb-v4-live="1"] #lbLiveModal .lb-live-compo-top .lb-compo-icon {
  height: 14px !important;
  filter: brightness(1.12) saturate(1.06) drop-shadow(0 0 3px rgba(54,229,239,.30)) !important;
}
html[data-lb-v4-live="1"] #lbLiveModal .lb-live-compo-top .lb-compo-icon--us5 {
  height: 20px !important;
}

html[data-lb-v4-live="1"] #lbLiveModal .lb-live-sncf-cause,
html[data-lb-v4-live="1"] #lbLiveModal .lb-live-sncf-cause--full {
  box-sizing: border-box !important;
  display: inline-flex !important;
  align-items: center !important;
  align-self: flex-start !important;
  width: fit-content !important;
  max-width: calc(100% - 2px) !important;
  margin: 7px 0 0 !important;
  padding: 5px 8px !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
  border: 0 !important;
  border-left: 2px solid var(--lb-live-accent) !important;
  border-radius: 7px !important;
  background: color-mix(in srgb, var(--lb-live-accent) 7%, rgba(3,15,24,.78)) !important;
  color: color-mix(in srgb, var(--lb-live-accent) 74%, white) !important;
  font: 700 .67rem/1.15 "Rajdhani", system-ui, sans-serif !important;
}

html[data-lb-v4-live="1"] #lbLiveModal .lb-live-meta {
  margin: 7px 0 0 !important;
  padding: 0 !important;
  display: flex !important;
  flex-wrap: wrap !important;
  gap: 5px !important;
  border: 0 !important;
}

html[data-lb-v4-live="1"] #lbLiveModal .lb-live-chip {
  min-height: 20px !important;
  height: 20px !important;
  padding: 0 7px !important;
  border-radius: 999px !important;
  background: rgba(255,255,255,.025) !important;
  font: 700 .60rem/1 "Rajdhani", system-ui, sans-serif !important;
}

html[data-lb-v4-live="1"] #lbLiveModal .lb-live-card-actions {
  display: grid !important;
  grid-template-columns: minmax(96px, .42fr) minmax(170px, 1fr) !important;
  gap: 8px !important;
  align-items: center !important;
  margin: 8px 0 0 !important;
}

html[data-lb-v4-live="1"] #lbLiveModal .lb-live-card-actions button,
html[data-lb-v4-live="1"] #lbLiveModal .lb-live-card-actions .lb-live-presence-btn {
  width: 100% !important;
  min-width: 0 !important;
  min-height: 34px !important;
  height: 34px !important;
  margin: 0 !important;
  padding: 0 11px !important;
  border-radius: 10px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
  font: 800 .69rem/1 "Rajdhani", system-ui, sans-serif !important;
  letter-spacing: .015em !important;
  box-shadow: none !important;
  transform: none !important;
}

html[data-lb-v4-live="1"] #lbLiveModal .lb-live-card-actions [data-lb-signal-train] {
  justify-self: start !important;
  color: #dcecf0 !important;
  border: 1px solid rgba(255,190,71,.25) !important;
  background: rgba(255,190,71,.035) !important;
}

html[data-lb-v4-live="1"] #lbLiveModal .lb-live-card-actions [data-lb-signal-train]:hover,
html[data-lb-v4-live="1"] #lbLiveModal .lb-live-card-actions [data-lb-signal-train]:focus-visible {
  color: #ffe09a !important;
  border-color: rgba(255,190,71,.50) !important;
  background: rgba(255,190,71,.075) !important;
}

html[data-lb-v4-live="1"] #lbLiveModal .lb-live-card-actions .lb-live-presence-btn {
  color: #f4feff !important;
  border: 1px solid rgba(54,229,239,.48) !important;
  background: linear-gradient(180deg, rgba(9, 116, 143, .92), rgba(4, 67, 94, .96)) !important;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08), 0 0 12px rgba(54,229,239,.08) !important;
}

html[data-lb-v4-live="1"] #lbLiveModal .lb-live-card-actions .lb-live-presence-btn:hover,
html[data-lb-v4-live="1"] #lbLiveModal .lb-live-card-actions .lb-live-presence-btn:focus-visible {
  border-color: rgba(54,229,239,.78) !important;
  background: linear-gradient(180deg, rgba(10, 135, 163, .96), rgba(4, 78, 107, .98)) !important;
}

html[data-lb-v4-live="1"] #lbLiveModal .lb-live-card-actions .lb-live-presence-btn.is-active,
html[data-lb-v4-live="1"] #lbLiveModal .lb-live-card-actions .lb-live-presence-btn[aria-pressed="true"] {
  color: #ffffff !important;
  border-color: rgba(102,236,255,.86) !important;
  background: linear-gradient(180deg, rgba(0,168,200,.98), rgba(0,92,148,.99)) !important;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.14), 0 0 14px rgba(54,229,239,.18) !important;
}

html[data-lb-v4-live="1"] #lbLiveModal .lb-live-feed {
  border-radius: 12px !important;
}

@media (max-width: 860px) {
  html[data-lb-v4-live="1"] #lbLiveModal {
    padding: max(5px, env(safe-area-inset-top)) 5px max(5px, env(safe-area-inset-bottom)) !important;
  }

  html[data-lb-v4-live="1"] #lbLiveModal .lb-community-panel {
    width: calc(100vw - 10px) !important;
    max-width: none !important;
    max-height: calc(100dvh - 10px) !important;
    padding: 12px !important;
    border-radius: 18px !important;
  }

  html[data-lb-v4-live="1"] #lbLiveModal .lb-community-head {
    margin-bottom: 11px !important;
    padding-right: 43px !important;
  }

  html[data-lb-v4-live="1"] #lbLiveModal .lb-community-panel-sub {
    font-size: .79rem !important;
  }

  html[data-lb-v4-live="1"] #lbLiveModal .lb-community-grid {
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 8px !important;
  }

  html[data-lb-v4-live="1"] #lbLiveModal .lb-live-side {
    display: none !important;
  }

  html[data-lb-v4-live="1"] #lbLiveModal .lb-live-list {
    padding: 9px !important;
    border-radius: 14px !important;
  }

  html[data-lb-v4-live="1"] #lbLiveModal .lb-live-toolbar {
    grid-template-columns: minmax(0, 1fr) auto !important;
    gap: 8px !important;
    margin-bottom: 8px !important;
  }

  html[data-lb-v4-live="1"] #lbLiveModal .lb-live-direction {
    min-height: 38px !important;
    height: 38px !important;
    font-size: .74rem !important;
  }

  html[data-lb-v4-live="1"] #lbLiveModal .lb-live-cards {
    gap: 7px !important;
  }

  html[data-lb-v4-live="1"] #lbLiveModal .lb-live-card {
    padding: 9px 10px 8px !important;
    border-radius: 13px !important;
  }

  html[data-lb-v4-live="1"] #lbLiveModal .lb-live-train {
    font-size: .79rem !important;
  }

  html[data-lb-v4-live="1"] #lbLiveModal .lb-live-route,
  html[data-lb-v4-live="1"] #lbLiveModal .lb-live-schedule {
    font-size: .72rem !important;
  }

  html[data-lb-v4-live="1"] #lbLiveModal .lb-live-passenger,
  html[data-lb-v4-live="1"] #lbLiveModal .lb-live-status,
  html[data-lb-v4-live="1"] #lbLiveModal .lb-live-user-alert {
    min-height: 20px !important;
    height: 20px !important;
  }

  html[data-lb-v4-live="1"] #lbLiveModal .lb-live-compo-top {
    max-width: 72px !important;
  }

  html[data-lb-v4-live="1"] #lbLiveModal .lb-live-compo-top .lb-compo-icon {
    height: 13px !important;
  }

  html[data-lb-v4-live="1"] #lbLiveModal .lb-live-compo-top .lb-compo-icon--us5 {
    height: 18px !important;
  }

  html[data-lb-v4-live="1"] #lbLiveModal .lb-live-sncf-cause,
  html[data-lb-v4-live="1"] #lbLiveModal .lb-live-sncf-cause--full {
    margin-top: 6px !important;
    padding: 4px 7px !important;
    font-size: .64rem !important;
  }

  html[data-lb-v4-live="1"] #lbLiveModal .lb-live-card-actions {
    grid-template-columns: minmax(88px, .58fr) minmax(0, 1.42fr) !important;
    gap: 7px !important;
    margin-top: 7px !important;
  }

  html[data-lb-v4-live="1"] #lbLiveModal .lb-live-card-actions button,
  html[data-lb-v4-live="1"] #lbLiveModal .lb-live-card-actions .lb-live-presence-btn {
    min-height: 32px !important;
    height: 32px !important;
    padding: 0 8px !important;
    border-radius: 9px !important;
    font-size: .66rem !important;
  }
}

@media (max-width: 380px) {
  html[data-lb-v4-live="1"] #lbLiveModal .lb-community-panel {
    padding: 10px !important;
  }

  html[data-lb-v4-live="1"] #lbLiveModal .lb-live-list {
    padding: 7px !important;
  }

  html[data-lb-v4-live="1"] #lbLiveModal .lb-live-card-actions {
    grid-template-columns: 84px minmax(0, 1fr) !important;
    gap: 6px !important;
  }

  html[data-lb-v4-live="1"] #lbLiveModal .lb-live-card-actions button,
  html[data-lb-v4-live="1"] #lbLiveModal .lb-live-card-actions .lb-live-presence-btn {
    padding-inline: 6px !important;
    font-size: .63rem !important;
  }
}

/* Favoris */
html[data-lb-v4-live="1"] :where(.fav-card, .favorite-card, .favorite-train-card) {
  min-height: 0 !important;
}

html[data-lb-v4-live="1"] :where(.fav-card .train-number, .favorite-train-card .train-number, .train-detail-number) {
  color: var(--lb4-text) !important;
}

/* Info trafic */
html[data-lb-v4-live="1"] :where(.traffic-pill, .traffic-status, .status-badge, .delay-badge) {
  border-radius: 999px !important;
}

html[data-lb-v4-live="1"] :where(.status-ok, .is-ok, .on-time) {
  color: var(--lb4-green) !important;
}
html[data-lb-v4-live="1"] :where(.status-warning, .is-warning, .delay, .late) {
  color: var(--lb4-orange) !important;
}
html[data-lb-v4-live="1"] :where(.status-danger, .is-danger, .cancelled, .suppressed) {
  color: var(--lb4-red) !important;
}

/* Fiches trains */
html[data-lb-v4-live="1"] :where(.train-detail-modal, .train-detail-sheet, .train-detail-card) {
  --lb-card-accent: var(--lb4-cyan);
}

html[data-lb-v4-live="1"] :where(.train-detail-header, .train-detail-hero) {
  border-bottom: 1px solid var(--lb4-line) !important;
  background: linear-gradient(110deg, rgba(14, 80, 97, .26), rgba(3, 18, 29, .86)) !important;
}

html[data-lb-v4-live="1"] :where(.train-detail-stop, .trip-stop, .route-stop) {
  border-color: rgba(54,229,239,.15) !important;
}

/* Stats */
html[data-lb-v4-live="1"] :where(.stats-v2, .stats-v2__shell, .stats-shell) {
  --stats-accent: var(--lb4-cyan);
}

html[data-lb-v4-live="1"] :where(.stats-v2__metric, .stats-v2__kpi, .stats-kpi) {
  border: 1px solid var(--lb4-line) !important;
  border-radius: var(--lb4-r2) !important;
  background: rgba(4, 23, 34, .76) !important;
}

html[data-lb-v4-live="1"] canvas {
  border-radius: var(--lb4-r2);
}

/* Modales : même surface et mêmes rayons, sans modifier leur logique JS. */
html[data-lb-v4-live="1"] :where(dialog, [role="dialog"], .modal, .selection-modal, .lb-auth-modal, .prefs-modal) {
  border-color: var(--lb4-line-strong) !important;
}

html[data-lb-v4-live="1"] :where(dialog, .modal-content, .modal__content, .selection-modal__panel, .lb-auth-modal__panel, .prefs-modal__panel) {
  border-radius: var(--lb4-r4) !important;
  background: linear-gradient(155deg, rgba(8, 37, 50, .96), rgba(2, 13, 22, .985)) !important;
  box-shadow: 0 30px 90px rgba(0,0,0,.52), 0 0 0 1px rgba(54,229,239,.12) !important;
}

html[data-lb-v4-live="1"] :where(.modal-header, .modal__header, .selection-modal__header) {
  border-bottom-color: var(--lb4-line) !important;
  background: rgba(5, 27, 39, .96) !important;
}

/* Scrollbars */
html[data-lb-v4-live="1"] * {
  scrollbar-width: thin;
  scrollbar-color: rgba(54,229,239,.42) rgba(2,12,20,.55);
}

html[data-lb-v4-live="1"] *::-webkit-scrollbar { width: 9px; height: 9px; }
html[data-lb-v4-live="1"] *::-webkit-scrollbar-track { background: rgba(2,12,20,.55); }
html[data-lb-v4-live="1"] *::-webkit-scrollbar-thumb {
  border: 2px solid rgba(2,12,20,.55);
  border-radius: 999px;
  background: rgba(54,229,239,.42);
}

@media (max-width: 760px) {
  html[data-lb-v4-preview="1"] body::after {
    bottom: calc(72px + env(safe-area-inset-bottom, 0px));
    font-size: 8px;
  }

  html[data-lb-v4-live="1"] :where(.home-card, .fav-card, .search-card, .stats-v2__card, .train-detail-card) {
    border-radius: var(--lb4-r2) !important;
  }

  html[data-lb-v4-live="1"] :where(button, input, select, textarea) {
    min-height: 44px !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  html[data-lb-v4-live="1"] *,
  html[data-lb-v4-live="1"] *::before,
  html[data-lb-v4-live="1"] *::after {
    scroll-behavior: auto !important;
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}


/* LB HOME FAVORITES STABLE COMPO V1
 * Empêche le badge ARRIVÉ / À VENIR de changer brutalement de largeur pendant
 * l'arrivée de Compotrains.json. La composition remplace un espace déjà réservé.
 */
html[data-lb-v4-live="1"] #homeFavSlot .home-fav-head {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) auto !important;
  align-items: center !important;
  column-gap: 8px !important;
}
html[data-lb-v4-live="1"] #homeFavSlot .home-fav-trainline {
  min-width: 0 !important;
}
html[data-lb-v4-live="1"] #homeFavSlot .home-fav-badge {
  width: auto !important;
  min-width: 0 !important;
  max-width: none !important;
  min-height: 25px !important;
  margin: 0 0 0 auto !important;
  padding: 3px 6px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: flex-end !important;
  gap: 5px !important;
  white-space: nowrap !important;
}
html[data-lb-v4-live="1"] #homeFavSlot .home-fav-badge .fav-type-wrap,
html[data-lb-v4-live="1"] #homeFavSlot .home-fav-badge .fav-type-compo,
html[data-lb-v4-live="1"] #homeFavSlot .home-fav-badge .lb-compo-inline {
  display: inline-flex !important;
  align-items: center !important;
  flex: 0 0 auto !important;
}
html[data-lb-v4-live="1"] #homeFavSlot .home-fav-compo-loading {
  width: 48px;
  height: 17px;
  flex: 0 0 48px;
  display: inline-flex;
  align-items: center;
  overflow: hidden;
  border-radius: 6px;
  background: rgba(54,229,239,.055);
}
html[data-lb-v4-live="1"] #homeFavSlot .home-fav-compo-loading i {
  width: 100%;
  height: 100%;
  display: block;
  background: linear-gradient(90deg, transparent, rgba(128,245,250,.18), transparent);
  transform: translateX(-100%);
  animation: lbHomeFavCompoLoading 1.15s ease-in-out infinite;
}
@keyframes lbHomeFavCompoLoading {
  to { transform: translateX(100%); }
}
@media (prefers-reduced-motion: reduce) {
  html[data-lb-v4-live="1"] #homeFavSlot .home-fav-compo-loading i {
    animation: none !important;
    transform: none !important;
  }
}
@media (max-width: 720px), (hover: none) and (pointer: coarse) and (max-width: 900px) {
  html[data-lb-v4-live="1"] #homeFavSlot .home-fav-head {
    column-gap: 4px !important;
  }
  html[data-lb-v4-live="1"] #homeFavSlot .home-fav-badge {
    max-width: none !important;
    min-width: 0 !important;
    padding: 2px 4px !important;
    gap: 3px !important;
  }
  html[data-lb-v4-live="1"] #homeFavSlot .home-fav-compo-loading {
    width: 30px;
    height: 13px;
    flex-basis: 30px;
  }
}


/* LB TABLE TRAIN COMPOSITION COLOR PRIORITY V1
 * Le thème V4 impose un cyan !important à tous les <th>. Les anciennes classes
 * de composition continuaient toutefois à fournir leur text-shadow : le texte cyan
 * se superposait donc au halo violet/jaune/vert et donnait l'impression d'une
 * couche estompée au-dessus du numéro.
 *
 * On corrige uniquement le numéro de train. La logique JS de composition et la
 * détection .reduced-seats restent strictement inchangées.
 */
html[data-lb-v4-live="1"] #trainInfo th.train-header.us-train:not(.reduced-seats) .train-num,
html[data-lb-v4-live="1"] #trainInfo th.train-header.us-train:not(.reduced-seats) .train-num a.train-link {
  color: #bf00ff !important;
  text-shadow: 0 0 5px #bf00ff, 0 0 10px #8000ff !important;
}
html[data-lb-v4-live="1"] #trainInfo th.train-header.us5-train:not(.reduced-seats) .train-num,
html[data-lb-v4-live="1"] #trainInfo th.train-header.us5-train:not(.reduced-seats) .train-num a.train-link {
  color: #ffd24a !important;
  text-shadow: 0 0 5px #ffd24a, 0 0 12px rgba(255,210,74,.65) !important;
}
html[data-lb-v4-live="1"] #trainInfo th.train-header.um-train:not(.reduced-seats) .train-num,
html[data-lb-v4-live="1"] #trainInfo th.train-header.um-train:not(.reduced-seats) .train-num a.train-link {
  color: #00f0ff !important;
  text-shadow: 0 0 5px rgba(0,240,255,.75), 0 0 10px rgba(0,200,255,.45) !important;
}
html[data-lb-v4-live="1"] #trainInfo th.train-header.um3-train:not(.reduced-seats) .train-num,
html[data-lb-v4-live="1"] #trainInfo th.train-header.um3-train:not(.reduced-seats) .train-num a.train-link {
  color: #00ffa6 !important;
  text-shadow: 0 0 5px #00ffa6, 0 0 10px rgba(0,255,166,.5) !important;
}
html[data-lb-v4-live="1"] #trainInfo th.train-header.no-compo-text:not(.reduced-seats) .train-num,
html[data-lb-v4-live="1"] #trainInfo th.train-header.no-compo-text:not(.reduced-seats) .train-num a.train-link {
  color: #ffffff !important;
  text-shadow: none !important;
}

/* Une modification visuelle de capacité ne prend priorité QUE lorsque le code
 * a réellement posé la classe .reduced-seats après détection de l'alerte.
 * Aucun sélecteur générique ne simule cet état.
 */
html[data-lb-v4-live="1"] #trainInfo th.train-header.reduced-seats .train-num,
html[data-lb-v4-live="1"] #trainInfo th.train-header.reduced-seats .train-num a.train-link {
  color: #bf00ff !important;
  text-shadow: 0 0 5px #bf00ff, 0 0 10px #8000ff !important;
}