* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  font-family: system-ui, sans-serif;
  background: #0b1020;
  color: #e8ecf5;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
}

#viewerWrap {
  position: relative;
  flex: 1;
  min-height: 0;
}

#cesiumContainer {
  position: absolute;
  inset: 0;
}

#infoPanel {
  position: absolute;
  top: 10px;
  left: 10px;
  width: min(480px, calc(100% - 20px));
  max-height: calc(100% - 20px);
  overflow-y: auto;
  padding: 10px 12px;
  background: rgba(11, 16, 32, 0.85);
  border: 1px solid #2a3558;
  border-radius: 6px;
  font-size: 13px;
}

#infoPanel h1 {
  margin: 0;
  font-size: 16px;
  line-height: 1.2;
}

#infoPanel h2 {
  margin: 8px 0 2px;
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #ffb000;
}

#infoPanel section:first-child h2:first-child,
#infoPanel section:last-child h2:first-child {
  margin-top: 0;
}

#infoPanel h3 {
  margin: 8px 0 2px;
  font-size: 12px;
  color: #ffb000;
}

#infoPanel .groups {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 14px;
}

#infoPanel dd#pBalloonState {
  grid-column: 1 / -1;
  font-size: 12px;
  color: #cfd8f5;
}

#infoPanel .probable {
  color: #ffd27a;
  font-size: 11px;
}

#infoPanel .count {
  margin: 0 0 8px;
  color: #9fb0d8;
}

#infoPanel dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 10px;
  margin: 0;
}

#infoPanel dt {
  color: #9fb0d8;
}

#infoPanel dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
}

#pWarnings {
  margin: 0;
  padding-left: 18px;
  color: #ffd27a;
}

#infoPanel .note {
  margin: 8px 0 0;
  font-size: 11px;
  color: #7f8db3;
}

#status {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  max-width: 80%;
  padding: 14px 18px;
  background: #5a1620;
  border: 1px solid #ff6b6b;
  border-radius: 6px;
}

#controls {
  padding: 8px 12px 10px;
  background: #0f1630;
  border-top: 1px solid #2a3558;
}

#controls .row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  align-items: center;
}

#controls .group {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

button {
  white-space: nowrap;
  padding: 5px 10px;
  font: inherit;
  font-size: 13px;
  color: #e8ecf5;
  background: #1c2748;
  border: 1px solid #34457a;
  border-radius: 4px;
  cursor: pointer;
}

button:hover {
  background: #26356a;
}

button[aria-pressed="true"] {
  background: #ffb000;
  border-color: #ffb000;
  color: #111;
}

.timeline {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  font-variant-numeric: tabular-nums;
  font-size: 13px;
}

.timeline input[type="range"] {
  flex: 1;
  min-width: 0;
}

.now {
  margin-top: 2px;
  font-size: 12px;
  color: #9fb0d8;
  text-align: center;
}

#telemetry {
  background: #0b1020;
  border-top: 1px solid #2a3558;
  padding: 3px 12px 6px;
}

.telemetryHeader {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 12px;
  min-height: 26px;
}

.telemetryHeader button {
  padding: 2px 8px;
}

.telemetryHeader .hint {
  flex: 1 1 320px;
  font-size: 10px;
  line-height: 1.25;
  color: #7f8db3;
}

.pager {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #9fb0d8;
}

.pager[hidden] {
  display: none;
}

.pager button {
  min-width: 24px;
  padding: 0 6px;
  line-height: 20px;
  font-size: 14px;
}

.pager button:disabled {
  opacity: 0.35;
  cursor: default;
}

.pager .dots {
  display: inline-flex;
  gap: 4px;
  margin-left: 2px;
}

.pager .dot {
  width: 7px;
  height: 7px;
  border: 1px solid #7f8db3;
  border-radius: 50%;
  cursor: pointer;
}

.pager .dot.active {
  background: #ffb000;
  border-color: #ffb000;
}

#charts[hidden],
.chartPage[hidden] {
  display: none;
}

.chartPage {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 2px 14px;
  margin-top: 2px;
}

.chartBox h3 {
  margin: 0;
  font-size: 11px;
  line-height: 14px;
  color: #9fb0d8;
}

.plot {
  position: relative;
  height: 170px;
}

.plot canvas {
  position: absolute;
  inset: 0;
}

.plot .cursor {
  position: absolute;
  width: 0;
  border-left: 1.5px solid rgba(255, 255, 255, 0.7);
  pointer-events: none;
  top: 0;
  height: 0;
}

#mapMode {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 10px;
  white-space: nowrap;
  padding: 2px 8px;
  font-size: 11px;
  color: #cfd8f5;
  background: rgba(11, 16, 32, 0.7);
  border: 1px solid #2a3558;
  border-radius: 10px;
  pointer-events: auto;
}

@media (max-width: 900px) {
  .chartPage {
    grid-template-columns: 1fr;
  }

  .plot {
    height: 150px;
  }

  #telemetry {
    max-height: 45vh;
    overflow-y: auto;
  }
}

@media (max-width: 600px) {
  #infoPanel .groups {
    grid-template-columns: 1fr;
  }

  #infoPanel {
    font-size: 12px;
    max-height: 45%;
  }
}

#receptionPanel {
  position: absolute;
  top: 10px;
  right: 10px;
  width: min(380px, calc(100% - 20px));
  max-height: calc(100% - 96px); /* deja libre la esquina inferior derecha para la brújula */
  overflow-y: auto;
  padding: 8px 10px;
  background: rgba(11, 16, 32, 0.88);
  border: 1px solid #2a3558;
  border-radius: 6px;
  font-size: 12px;
}

#receptionPanel .privacy {
  margin: 8px 0;
  padding: 6px 8px;
  background: #16315a;
  border-radius: 4px;
  color: #cfe3ff;
}

#receptionPanel .row {
  display: flex;
  align-items: center;
  gap: 8px;
}

#receptionPanel #logFileName {
  overflow-wrap: anywhere;
  color: #9fb0d8;
}

#receptionPanel .field {
  display: block;
  margin-top: 6px;
  color: #9fb0d8;
}

#receptionPanel input[type="text"],
#receptionPanel select {
  display: block;
  width: 100%;
  margin-top: 2px;
  padding: 4px 6px;
  font: inherit;
  color: #e8ecf5;
  background: #0b1020;
  border: 1px solid #34457a;
  border-radius: 4px;
}

#receptionPanel .check {
  display: block;
  margin-top: 8px;
}

#receptionPanel dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 8px;
  margin: 8px 0 0;
}

#receptionPanel dt {
  color: #9fb0d8;
}

#receptionPanel dd {
  margin: 0;
  overflow-wrap: anywhere;
}

#receptionPanel .error,
#importMessage.error {
  color: #ff8c8c;
}

#importMessage {
  margin-top: 6px;
  color: #cfd8f5;
}

#receptionPanel details {
  margin-top: 8px;
}

.tableWrap {
  max-height: 220px;
  overflow: auto;
}

#resultsTable {
  border-collapse: collapse;
  font-size: 11px;
}

#resultsTable th,
#resultsTable td {
  padding: 2px 5px;
  border-bottom: 1px solid #2a3558;
  text-align: left;
  vertical-align: top;
}

#resultsTable tr.status-ambiguous td {
  color: #ffd27a;
}

#resultsTable tr.status-unmatched td {
  color: #ff9a9a;
}

#receptionPanel .note {
  margin: 8px 0 0;
  font-size: 11px;
  color: #7f8db3;
}

/* ---------- Identidad visual ---------- */
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.brand .brandText {
  flex: 1 1 auto;
  min-width: 0;
}

.brand .credit {
  margin: 1px 0 0;
  font-size: 10px;
  color: #9fb0d8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand .logo {
  display: block;
  flex: none;
  object-fit: contain; /* conserva la relación de aspecto */
}

.brand .logo-rcu {
  height: 44px; /* escudo del RCU (145 × 181): proporción conservada */
  width: auto;
}

/* El logo de Pichón IV es arte lineal negro: va sobre una pastilla clara. */
.brand .logoChip {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 5px;
  background: #f4f7fb;
  border-radius: 6px;
}

.brand .logo-pichon {
  height: 28px;
  width: auto;
}

@media (max-width: 600px) {
  .brand {
    gap: 6px;
  }

  .brand .credit {
    display: none;
  }

  .brand .logo-rcu {
    height: 32px;
    width: auto;
  }

  .brand .logo-pichon {
    height: 20px;
  }

  .brand h1 {
    font-size: 13px;
  }
}

/* ---------- Brújula ---------- */
#compass {
  position: absolute;
  right: 12px;
  bottom: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  padding: 2px 4px 3px;
  line-height: 1;
  background: rgba(11, 16, 32, 0.55);
  border: 1px solid rgba(159, 176, 216, 0.35);
  border-radius: 12px;
  opacity: 0.85;
}

#compass:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

#compass:hover:not(:disabled),
#compass:focus-visible {
  opacity: 1;
  background: rgba(11, 16, 32, 0.8);
}

#compass:focus-visible {
  outline: 2px solid #ffb000;
}

#compass svg {
  display: block;
}

#compassDial {
  transform-origin: 0 0;
}

#compass .cp-ring {
  fill: rgba(11, 16, 32, 0.35);
  stroke: rgba(207, 216, 245, 0.7);
  stroke-width: 2;
}

#compass .cp-ticks line {
  stroke: rgba(207, 216, 245, 0.8);
  stroke-width: 2;
}

#compass .cp-north {
  fill: #ff5a4d;
}

#compass .cp-south {
  fill: #e8ecf5;
  opacity: 0.8;
}

#compass .cp-n {
  fill: #ffffff;
  font: bold 14px sans-serif;
  paint-order: stroke;
  stroke: rgba(11, 16, 32, 0.9);
  stroke-width: 3px;
}

#compass .cp-hub {
  fill: #0b1020;
  stroke: #cfd8f5;
  stroke-width: 1.5;
}

#compassPitch {
  margin-top: 1px;
  font-size: 9px;
  color: #cfd8f5;
  font-variant-numeric: tabular-nums;
}

/* ---------- Tramo final / rescate y nubosidad ---------- */
#recoveryBox {
  margin-top: 6px;
  padding: 5px 7px;
  background: rgba(193, 139, 255, 0.12);
  border-left: 3px solid #c18bff;
  border-radius: 3px;
}

#recoveryBox h3 {
  margin: 0 0 2px;
  color: #d8b8ff;
}

#recoveryBox .recoveryText {
  margin: 0;
  font-size: 11px;
  color: #e8dcff;
}

/* ---------- Panel ocultable y modo presentación ---------- */
#btnPanelToggle {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 3;
  padding: 3px 9px;
  font-size: 12px;
}

#btnPanelToggle[aria-expanded="true"] {
  background: rgba(11, 16, 32, 0.85);
}

#infoPanel {
  top: 42px;
  max-height: calc(100% - 52px);
}

#infoPanel[hidden] {
  display: none;
}

#btnPresent {
  position: absolute;
  right: 88px;
  bottom: 12px;
  padding: 4px 9px;
  font-size: 12px;
}

#btnPresent[aria-pressed="false"] {
  background: rgba(11, 16, 32, 0.7);
}

#app.presentation {
  background: #0b1020;
}

#app.presentation #infoPanel,
#app.presentation #btnPanelToggle,
#app.presentation #receptionPanel,
#app.presentation #telemetry,
#app.presentation #mapMode {
  display: none;
}

@media (max-width: 600px) {
  #infoPanel {
    max-height: 45%;
  }
}

/* ---------- Nubes 3D ---------- */
#cloudNote {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 36px;
  max-width: calc(100% - 220px);
  padding: 2px 8px;
  font-size: 11px;
  color: #cfd8f5;
  background: rgba(11, 16, 32, 0.75);
  border: 1px solid #2a3558;
  border-radius: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#cloudNote[hidden] {
  display: none;
}

#app.presentation #cloudNote {
  display: none;
}

/* ---------- Panel compacto (sin scroll en escritorio) e información ---------- */
#infoPanel {
  padding: 7px 10px 8px;
  font-size: 12.5px;
  line-height: 1.25;
  width: min(450px, calc(100% - 20px));
}

#infoPanel h2 {
  margin: 6px 0 1px;
  font-size: 10.5px;
}

#infoPanel h3 {
  margin: 5px 0 1px;
  font-size: 11.5px;
}

#infoPanel .groups {
  gap: 0 12px;
}

#infoPanel dl {
  gap: 1px 8px;
}

#infoPanel .count {
  margin: 0 0 4px;
  font-size: 12px;
}

#infoPanel .brand {
  margin-bottom: 4px;
  gap: 8px;
}

#infoPanel .brand .logo-rcu {
  height: 38px;
}

#infoPanel h1 {
  font-size: 15px;
}

#infoPanel #recoveryBox .recoveryText,
#infoPanel #pWarnings {
  font-size: 11.5px;
  line-height: 1.25;
}

#infoPanel #pWarnings {
  padding-left: 16px;
}

@media (max-height: 800px) {
  #btnPanelToggle {
    padding: 2px 8px;
  }

  #infoPanel {
    top: 36px;
    max-height: calc(100% - 44px);
    padding: 5px 9px 6px;
    font-size: 12px;
    line-height: 1.2;
  }

  #infoPanel h2 {
    margin-top: 4px;
  }

  #infoPanel .brand .logo-rcu {
    height: 32px;
  }

  #infoPanel .brand .credit {
    display: none;
  }
}

.infoBtn {
  flex: none;
  align-self: flex-start;
  width: 24px;
  height: 24px;
  padding: 0;
  font-size: 16px;
  line-height: 1;
  border-radius: 50%;
  color: #cfd8f5;
  background: rgba(28, 39, 72, 0.8);
}

#app.presentation #btnInfo {
  display: none;
}

.modal {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(5, 8, 18, 0.6);
}

.modal[hidden] {
  display: none;
}

.modalCard {
  display: flex;
  flex-direction: column;
  width: min(760px, 100%);
  max-height: min(86vh, 100%);
  background: #0f1630;
  border: 1px solid #34457a;
  border-radius: 8px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  font-size: 13px;
}

.modalHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px 6px;
}

.modalHeader h2 {
  margin: 0;
  font-size: 16px;
}

.modalClose {
  width: 28px;
  height: 28px;
  padding: 0;
  font-size: 15px;
  line-height: 1;
}

.modalTabs {
  display: flex;
  gap: 4px;
  padding: 0 14px 8px;
  border-bottom: 1px solid #2a3558;
}

.modalTabs button[aria-selected="true"] {
  background: #ffb000;
  border-color: #ffb000;
  color: #1a1200;
}

.modalBody {
  padding: 10px 16px 16px;
  overflow-y: auto;
  line-height: 1.4;
}

.modalCredit {
  flex: none;
  margin: 0;
  padding: 6px 16px 8px;
  border-top: 1px solid #2a3558;
  font-size: 11px;
  color: #7f8fb8;
  text-align: right;
}

.modalBody h3 {
  margin: 14px 0 4px;
  font-size: 13px;
  color: #ffb000;
}

.modalBody h3:first-child {
  margin-top: 0;
}

.modalBody p,
.modalBody ul {
  margin: 4px 0;
}

.modalBody ul {
  padding-left: 18px;
}

.modalBody .src {
  margin: 6px 0;
  padding: 6px 8px;
  background: rgba(28, 39, 72, 0.55);
  border-left: 3px solid #34457a;
  border-radius: 3px;
  font-size: 12px;
}

.modalBody .src b {
  color: #e8ecf5;
}

.modalBody .src .meta {
  color: #9fb0d8;
}

.modalBody .src code {
  color: #ffd27a;
  word-break: break-all;
}

.modalBody a {
  color: #8fb8ff;
  word-break: break-all;
}

/* ======================================================================================
   Presentación móvil (data-layout="mobile-portrait" | "mobile-landscape", ver js/layout.js).
   Todo lo de abajo cuelga de #app[data-layout^="mobile"]: en escritorio no tiene efecto.
   ====================================================================================== */
html,
body {
  overscroll-behavior: none;
}

#mobileHeader,
#sheetBar,
.mobileOnly {
  display: none;
}

#app[data-layout^="mobile"] {
  --sat: env(safe-area-inset-top, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --hdr-h: calc(48px + var(--sat));
  --bar-h: 52px;
  --ctl-h: calc(122px + var(--sab));
  --sheet-h: 0px;
  position: fixed;
  inset: 0;
  height: auto;
  overflow: hidden;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

#app[data-layout="mobile-landscape"] {
  --hdr-h: calc(40px + var(--sat));
  --bar-h: 42px;
  --ctl-h: calc(49px + var(--sab));
}

/* --- Mapa: ocupa todo salvo la barra del sheet y los controles (los créditos de Cesium quedan visibles) --- */
#app[data-layout^="mobile"] #viewerWrap {
  position: absolute;
  inset: 0 0 calc(var(--ctl-h) + var(--bar-h)) 0;
  flex: none;
}

#app[data-layout^="mobile"].presentation #viewerWrap {
  bottom: var(--ctl-h);
}

#app[data-layout^="mobile"] #btnPanelToggle,
#app[data-layout^="mobile"] #btnReception {
  display: none;
}

/* --- Cabecera compacta --- */
#app[data-layout^="mobile"] #mobileHeader {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 7;
  display: flex;
  align-items: center;
  gap: 8px;
  height: var(--hdr-h);
  padding: var(--sat) calc(var(--sar) + 154px) 0 calc(var(--sal) + 8px);
  background: linear-gradient(rgba(11, 16, 32, 0.94), rgba(11, 16, 32, 0.78));
  border-bottom: 1px solid rgba(42, 53, 88, 0.8);
}

#mobileHeader .logo-rcu {
  flex: none;
  height: 30px;
  width: auto;
}

#mobileHeader .mTitle {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.1;
  white-space: nowrap;
}

#mobileHeader .mTitle strong {
  font-size: 15px;
}

#mobileHeader .mTitle span {
  font-size: 10px;
  color: #9fb0d8;
}

#mobileHeader .logoChip {
  flex: none;
  display: inline-flex;
  padding: 2px 4px;
  background: #f4f7fb;
  border-radius: 6px;
}

#mobileHeader .logo-pichon {
  height: 20px;
  width: auto;
}

#app[data-layout^="mobile"] #mobileHeader .infoBtn {
  position: absolute;
  top: calc(var(--sat) + 2px);
  right: calc(var(--sar) + 4px);
  width: 44px;
  height: 44px;
  font-size: 24px;
  border-radius: 50%;
}

#app[data-layout="mobile-landscape"] #mobileHeader .infoBtn {
  top: var(--sat);
  height: 40px;
  width: 40px;
}

#app[data-layout^="mobile"] #btnPresent {
  position: fixed;
  z-index: 8;
  top: calc(var(--sat) + 5px);
  right: calc(var(--sar) + 54px);
  bottom: auto;
  min-height: 38px;
  padding: 0 10px;
  font-size: 12px;
  border-radius: 8px;
}

#app[data-layout="mobile-landscape"] #btnPresent {
  top: calc(var(--sat) + 1px);
  right: calc(var(--sar) + 50px);
}

#app[data-layout^="mobile"].presentation #btnPresent {
  top: calc(var(--sat) + 8px);
  left: calc(var(--sal) + 8px);
  right: auto;
}

#app[data-layout^="mobile"].presentation #mobileHeader,
#app[data-layout^="mobile"].presentation #sheetBar {
  display: none;
}

/* --- Brújula: arriba a la derecha, más pequeña --- */
#app[data-layout^="mobile"] #compass {
  top: calc(var(--hdr-h) + 8px);
  right: calc(var(--sar) + 8px);
  bottom: auto;
  padding: 3px 4px 4px;
  z-index: 3;
}

#app[data-layout^="mobile"] #compass svg {
  width: 46px;
  height: 46px;
}

#app[data-layout^="mobile"] #compassPitch {
  font-size: 9px;
}

#app[data-layout^="mobile"].presentation #compass {
  top: calc(var(--sat) + 8px);
}

/* --- Chips informativos sobre el mapa --- */
#app[data-layout^="mobile"] #mapMode {
  top: calc(var(--hdr-h) + 8px);
  bottom: auto;
  left: calc(var(--sal) + 8px);
  transform: none;
  font-size: 10.5px;
}

#app[data-layout^="mobile"] #cloudNote {
  top: calc(var(--hdr-h) + 34px);
  bottom: auto;
  left: calc(var(--sal) + 8px);
  transform: none;
  max-width: calc(100% - 90px - var(--sal) - var(--sar));
}

/* --- Bottom sheet: barra (handle + pestañas) --- */
#app[data-layout^="mobile"] #sheetBar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(var(--ctl-h) + var(--sheet-h));
  z-index: 5;
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: var(--bar-h);
  padding: 0 calc(var(--sar) + 8px) 0 calc(var(--sal) + 8px);
  background: rgba(20, 29, 60, 0.92);
  border-top: 1px solid #34457a;
  border-radius: 14px 14px 0 0;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  transform: translateY(var(--drag-y, 0px));
}

#sheetHandle {
  position: absolute;
  inset: 0;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 14px 14px 0 0;
}

#sheetHandle .grip {
  position: absolute;
  top: 5px;
  left: 50%;
  width: 40px;
  height: 4px;
  margin-left: -20px;
  background: #6b7aa6;
  border-radius: 2px;
}

#sheetBar .sheetTabs {
  position: relative;
  display: flex;
  flex: 1;
  gap: 4px;
}

#sheetBar button[role="tab"],
#sheetStep {
  position: relative;
  min-height: 36px;
  padding: 0 4px;
  font-size: 13px;
  border-radius: 8px 8px 0 0;
  touch-action: manipulation;
}

#sheetBar .sheetTabs button {
  flex: 1;
  min-width: 0;
}

#sheetBar button[aria-selected="true"] {
  background: #ffb000;
  border-color: #ffb000;
  color: #1a1200;
}

#sheetStep {
  flex: none;
  width: 40px;
  font-size: 18px;
}

#app[data-layout="mobile-landscape"] #sheetBar button[role="tab"],
#app[data-layout="mobile-landscape"] #sheetStep {
  min-height: 31px;
}

/* --- Bottom sheet: contenido (datos / gráficos / recepción) --- */
#app[data-layout^="mobile"] #receptionPanel {
  display: none; /* "Mi recepción" solo existe en escritorio */
}

#app[data-layout^="mobile"] #infoPanel,
#app[data-layout^="mobile"] #telemetry {
  position: fixed;
  top: auto;
  left: 0;
  right: 0;
  bottom: var(--ctl-h);
  z-index: 4;
  display: none;
  width: auto;
  height: var(--sheet-h);
  max-height: none;
  padding: 8px calc(var(--sar) + 12px) 8px calc(var(--sal) + 12px);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: rgba(15, 22, 48, 0.92);
  border: 0;
  border-radius: 0;
  font-size: 13px;
  line-height: 1.35;
  transform: translateY(var(--drag-y, 0px));
}

#app[data-layout^="mobile"]:not([data-sheet="collapsed"])[data-sheet-tab="data"] #infoPanel {
  display: block;
}

#app[data-layout^="mobile"]:not([data-sheet="collapsed"])[data-sheet-tab="charts"] #telemetry {
  display: flex;
}

#app[data-layout^="mobile"].presentation #infoPanel,
#app[data-layout^="mobile"].presentation #telemetry {
  display: none !important;
}

#app[data-layout^="mobile"] #infoPanel .brand {
  display: none;
}

#app[data-layout^="mobile"] #infoPanel .count {
  font-size: 13px;
}

#app[data-layout^="mobile"] #infoPanel h2 {
  font-size: 11px;
}

#app[data-layout^="mobile"] #infoPanel dl {
  gap: 3px 10px;
}

/* Datos en dos columnas equilibradas (multicolumna); Globo (texto largo) ocupa todo el ancho */
#app[data-layout^="mobile"] #infoPanel .groups {
  display: block;
  column-count: 2;
  column-gap: 18px;
}

#app[data-layout^="mobile"] #infoPanel .groups section {
  display: contents;
}

#app[data-layout^="mobile"] #infoPanel dl {
  min-width: 0;
  break-inside: avoid;
}

#app[data-layout^="mobile"] #infoPanel h2 {
  break-after: avoid;
}

#app[data-layout^="mobile"] #infoPanel dd {
  overflow-wrap: anywhere;
}

#app[data-layout^="mobile"] #infoPanel .groups section:last-child h2:last-of-type,
#app[data-layout^="mobile"] #infoPanel .groups section:last-child dl:last-of-type {
  column-span: all;
}

/* --- Gráficos: 4 pestañas de grupo, 2 gráficos por vista (apilados; en horizontal, lado a lado) --- */
#app[data-layout^="mobile"] #telemetry {
  flex-direction: column;
  padding-top: 6px;
  padding-bottom: 6px;
  overflow: hidden;
  border-top: 0;
}

#app[data-layout^="mobile"] .telemetryHeader {
  display: contents;
}

#app[data-layout^="mobile"] #btnTelemetry,
#app[data-layout^="mobile"] #chartsPager {
  display: none;
}

#app[data-layout^="mobile"] #chartTabs {
  order: 1;
  display: flex;
  gap: 4px;
}

#chartTabs button {
  flex: 1;
  min-width: 0;
  min-height: 36px;
  padding: 0 2px;
  font-size: 12px;
  border-radius: 8px;
  touch-action: manipulation;
}

#chartTabs button[aria-selected="true"] {
  background: #ffb000;
  border-color: #ffb000;
  color: #1a1200;
}

#app[data-layout^="mobile"] #charts {
  order: 2;
  flex: 1 1 0;
  min-height: 0;
  margin-top: 6px;
}

#app[data-layout^="mobile"] #charts[hidden],
#app[data-layout^="mobile"] .chartPage[hidden] {
  display: none;
}

#app[data-layout^="mobile"] .chartPage {
  height: 100%;
  margin-top: 0;
  grid-template-columns: 1fr;
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

#app[data-layout="mobile-landscape"] .chartPage {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: minmax(0, 1fr);
  gap: 12px;
}

#app[data-layout^="mobile"] .chartBox {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#app[data-layout^="mobile"] .chartBox h3 {
  font-size: 12px;
}

#app[data-layout^="mobile"] .plot {
  flex: 1;
  height: auto;
  min-height: 0;
}

#app[data-layout^="mobile"] .telemetryHeader .hint {
  display: none;
  order: 3;
  flex: none;
  margin-top: 4px;
  font-size: 10px;
}

#app[data-layout^="mobile"][data-sheet="expanded"] .telemetryHeader .hint {
  display: block;
}

/* --- Barra de controles compacta --- */
#app[data-layout^="mobile"] #controls {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 6;
  height: var(--ctl-h);
  padding: 4px calc(var(--sar) + 8px) calc(var(--sab) + 4px) calc(var(--sal) + 8px);
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  grid-template-rows: 26px 40px 40px;
  gap: 4px;
  background: #0f1630;
  border-top: 1px solid #2a3558;
}

#app[data-layout^="mobile"] #controls .row,
#app[data-layout^="mobile"] #controls .group {
  display: contents;
}

#app[data-layout^="mobile"] #controls #speeds,
#app[data-layout^="mobile"] #controls .now,
#app[data-layout^="mobile"] #controls #tStart,
#app[data-layout^="mobile"] #controls #tEnd,
#app[data-layout^="mobile"] #controls .lbl {
  display: none;
}

#app[data-layout^="mobile"] #controls button {
  min-height: 40px;
  padding: 0 4px;
  font-size: 13px;
  border-radius: 8px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

#app[data-layout^="mobile"] #controls .timeline {
  grid-column: 1 / -1;
  grid-row: 1;
  margin: 0;
  gap: 0;
}

#app[data-layout^="mobile"] #controls #slider {
  width: 100%;
  height: 26px;
  margin: 0;
  accent-color: #ffb000;
}

#app[data-layout^="mobile"] #btnPlay {
  grid-column: 1 / 4;
  grid-row: 2;
  font-size: 15px;
  font-weight: 700;
}

#app[data-layout^="mobile"] #btnPrev {
  grid-column: 4 / 6;
  grid-row: 2;
  font-size: 16px;
}

#app[data-layout^="mobile"] #mCounter {
  grid-column: 6 / 9;
  grid-row: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}

#mCounter #mTx {
  font-size: 14px;
  font-weight: 700;
}

#mCounter #mTime {
  font-size: 11px;
  color: #9fb0d8;
}

#app[data-layout^="mobile"] #btnNext {
  grid-column: 9 / 11;
  grid-row: 2;
  font-size: 16px;
}

#app[data-layout^="mobile"] #btnSpeedM {
  display: block;
  grid-column: 11 / 13;
  grid-row: 2;
  font-weight: 700;
}

#app[data-layout^="mobile"] #btnOverview {
  grid-column: 1 / 4;
  grid-row: 3;
}

#app[data-layout^="mobile"] #btnFollow {
  grid-column: 4 / 7;
  grid-row: 3;
}

#app[data-layout^="mobile"] #btnImmersive {
  grid-column: 7 / 10;
  grid-row: 3;
}

#app[data-layout^="mobile"] #btnClouds3d {
  grid-column: 10 / 13;
  grid-row: 3;
}

/* Horizontal: una sola fila de controles */
#app[data-layout="mobile-landscape"] #controls {
  grid-template-columns: auto auto auto auto minmax(80px, 1fr) auto auto auto auto auto;
  grid-template-rows: 40px;
  align-items: center;
}

#app[data-layout="mobile-landscape"] #btnPlay { grid-column: 1; grid-row: 1; min-width: 60px; }
#app[data-layout="mobile-landscape"] #btnPrev { grid-column: 2; grid-row: 1; min-width: 44px; }
#app[data-layout="mobile-landscape"] #mCounter { grid-column: 3; grid-row: 1; min-width: 64px; }
#app[data-layout="mobile-landscape"] #btnNext { grid-column: 4; grid-row: 1; min-width: 44px; }
#app[data-layout="mobile-landscape"] #controls .timeline { grid-column: 5; grid-row: 1; }
#app[data-layout="mobile-landscape"] #btnSpeedM { grid-column: 6; grid-row: 1; min-width: 48px; }
#app[data-layout="mobile-landscape"] #btnOverview { grid-column: 7; grid-row: 1; padding: 0 10px; }
#app[data-layout="mobile-landscape"] #btnFollow { grid-column: 8; grid-row: 1; padding: 0 10px; }
#app[data-layout="mobile-landscape"] #btnImmersive { grid-column: 9; grid-row: 1; padding: 0 10px; }
#app[data-layout="mobile-landscape"] #btnClouds3d { grid-column: 10; grid-row: 1; padding: 0 10px; }

/* --- Ventana de información en móvil --- */
#app[data-layout^="mobile"] .modal {
  padding: calc(var(--sat) + 8px) calc(var(--sar) + 8px) calc(var(--sab) + 8px) calc(var(--sal) + 8px);
}

#app[data-layout^="mobile"] .modalCard {
  max-height: 100%;
}

#app[data-layout^="mobile"] .modalClose {
  width: 44px;
  height: 44px;
  font-size: 18px;
}

#app[data-layout^="mobile"] .modalTabs button {
  min-height: 40px;
  padding: 0 8px;
  font-size: 12px;
}

#app[data-layout^="mobile"] .modalBody {
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

#app[data-layout="mobile-landscape"] #chartTabs button {
  min-height: 30px;
}

#app[data-layout="mobile-landscape"] #telemetry {
  padding-top: 4px;
  padding-bottom: 4px;
}

#app[data-layout="mobile-landscape"] #charts {
  margin-top: 4px;
}

/* Vertical: etiqueta sobre valor (las columnas son estrechas); el texto largo de Globo ocupa todo el ancho */
#app[data-layout="mobile-portrait"] #infoPanel dl {
  grid-template-columns: 1fr;
  gap: 0;
}

#app[data-layout="mobile-portrait"] #infoPanel dt {
  margin-top: 4px;
  font-size: 11.5px;
  line-height: 1.2;
}

#app[data-layout="mobile-portrait"] #infoPanel dd#pBalloonState {
  grid-column: auto;
}

#app[data-layout="mobile-portrait"] #infoPanel .groups section:last-child dl:last-of-type {
  grid-template-columns: auto 1fr;
  gap: 2px 10px;
}

#app[data-layout="mobile-portrait"] #infoPanel .groups section:last-child dl:last-of-type dd#pBalloonState {
  grid-column: 1 / -1;
}
