/* ============================================================
   RESET Y BASE
   ============================================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg:           #eef2f7;
  --panel:        #ffffff;
  --panel-border: #dde3ed;
  --accent:       #2563eb;
  --accent-hover: #1d4ed8;
  --text:         #0f172a;
  --text-muted:   #475569;
  --text-dim:     #94a3b8;

  --anat-color: #34d399;
  --al-color:  #ef4444;
  --ap-color:  #f97316;
  --dsd-color: #a855f7;

  --radius:   8px;
  --radius-sm: 4px;
}

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

/* ============================================================
   LAYOUT PRINCIPAL
   ============================================================ */
body {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

header {
  flex-shrink: 0;
  padding: 10px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--panel-border);
  display: flex;
  align-items: baseline;
  gap: 16px;
}

header h1 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
  white-space: nowrap;
}

header .subtitle {
  font-size: 12px;
  color: var(--text-muted);
}

main {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-height: 0;
}

footer {
  flex-shrink: 0;
  background: var(--panel);
  border-top: 1px solid var(--panel-border);
  padding: 6px 20px;
}

.footer-content {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  font-size: 10px;
  color: var(--text-dim);
}

.footer-content strong {
  color: var(--text-muted);
}

/* ============================================================
   VIEWPORT 3D
   ============================================================ */
#viewport-container {
  flex: 1 1 70%;
  position: relative;
  overflow: hidden;
  background: var(--bg);
  min-width: 0;
}

#three-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* ============================================================
   PANTALLA DE CARGA
   ============================================================ */
#loading-screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  z-index: 100;
  transition: opacity 0.5s ease;
}

#loading-screen.hidden {
  opacity: 0;
  pointer-events: none;
}

.loading-content {
  text-align: center;
  color: var(--text-muted);
}

.loading-icon {
  font-size: 48px;
  margin-bottom: 16px;
  animation: pulse-icon 1.5s ease-in-out infinite;
}

@keyframes pulse-icon {
  0%, 100% { opacity: 0.6; transform: scale(1); }
  50%       { opacity: 1.0; transform: scale(1.1); }
}

.loading-content p {
  margin-bottom: 12px;
  font-size: 15px;
}

.progress-bar-container {
  width: 260px;
  height: 4px;
  background: var(--panel-border);
  border-radius: 2px;
  overflow: hidden;
  margin: 0 auto 8px;
}

#progress-bar {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.3s ease;
}

.loading-detail {
  font-size: 12px;
  color: var(--text-dim);
}

/* ============================================================
   PANEL DE CONTROL
   ============================================================ */
#control-panel {
  flex: 0 0 370px;
  width: 370px;
  background: var(--panel);
  border-left: 1px solid var(--panel-border);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* Scrollbar sutil */
#control-panel::-webkit-scrollbar { width: 4px; }
#control-panel::-webkit-scrollbar-track { background: transparent; }
#control-panel::-webkit-scrollbar-thumb { background: var(--panel-border); border-radius: 2px; }

.panel-section {
  padding: 12px 14px;
  border-bottom: 1px solid var(--panel-border);
}

.section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* ============================================================
   BOTONES DE MODO
   ============================================================ */
.mode-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

.mode-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 6px;
  background: var(--bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.2s ease;
  font-family: inherit;
}

.mode-btn:hover {
  border-color: var(--accent);
  color: var(--text);
  background: rgba(37, 99, 235, 0.08);
}

.mode-btn.active {
  border-color: var(--accent);
  background: rgba(37, 99, 235, 0.15);
  color: var(--text);
}

.mode-btn[data-mode="ANAT"].active { border-color: var(--anat-color); background: rgba(52,211,153,0.12); }
.mode-btn[data-mode="AL"].active   { border-color: var(--al-color);   background: rgba(239,68,68,0.12); }
.mode-btn[data-mode="AP"].active   { border-color: var(--ap-color);   background: rgba(249,115,22,0.12); }
.mode-btn[data-mode="DSD"].active  { border-color: var(--dsd-color);  background: rgba(168,85,247,0.12); }

.mode-label {
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 4px;
}

.anat-label { font-size: 22px; }

.mode-btn[data-mode="ANAT"] .mode-label { color: var(--anat-color); }
.mode-btn[data-mode="AL"]   .mode-label { color: var(--al-color); }
.mode-btn[data-mode="AP"]   .mode-label { color: var(--ap-color); }
.mode-btn[data-mode="DSD"]  .mode-label { color: var(--dsd-color); }

.mode-desc {
  font-size: 10px;
  text-align: center;
  line-height: 1.2;
}

/* ============================================================
   RITMO CARDÍACO
   ============================================================ */
.rhythm-status-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  font-size: 12px;
  color: var(--text-muted);
  min-height: 16px;
}

.rhythm-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  background: #34d399;
  box-shadow: 0 0 6px #34d399;
  transition: background 0.3s, box-shadow 0.3s;
}

.rhythm-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 7px;
}

.rhythm-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 9px 4px;
  background: var(--bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 10px;
  transition: all 0.2s ease;
}

.rhythm-btn .r-ico { font-size: 16px; line-height: 1; }

.rhythm-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--text);
  background: rgba(37, 99, 235, 0.08);
}

.rhythm-btn.active {
  border-color: var(--anat-color);
  background: rgba(52, 211, 153, 0.14);
  color: var(--text);
}

.rhythm-btn.fv.active {
  border-color: var(--al-color);
  background: rgba(239, 68, 68, 0.14);
}

.rhythm-btn.shock {
  color: #b45309;
}

.rhythm-btn.shock:not(:disabled) {
  border-color: rgba(245, 158, 11, 0.5);
  background: rgba(245, 158, 11, 0.12);
  color: #b45309;
  animation: shock-ready 1.2s ease-in-out infinite;
}

.rhythm-btn.shock:not(:disabled):hover {
  background: rgba(245, 158, 11, 0.22);
  border-color: #f59e0b;
}

@keyframes shock-ready {
  0%, 100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.4); }
  50%       { box-shadow: 0 0 0 4px rgba(245, 158, 11, 0); }
}

.rhythm-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.rhythm-hint {
  margin-top: 10px;
  font-size: 10px;
  line-height: 1.5;
  color: var(--text-dim);
}

.rhythm-hint strong { color: var(--text-muted); }

.shock-counter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  padding: 6px 10px;
  background: rgba(248, 113, 113, 0.12);
  border: 1px solid rgba(248, 113, 113, 0.35);
  border-radius: 6px;
  transition: opacity 0.3s;
}

.shock-counter-hidden {
  opacity: 0;
  pointer-events: none;
}

.shock-counter-label {
  font-size: 11px;
  color: var(--text-muted);
}

.shock-counter-value {
  font-size: 20px;
  font-weight: 700;
  color: #f87171;
  min-width: 28px;
  text-align: right;
}

/* Trazado de ECG sobre el visor */
#ecg-canvas {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  width: calc(100% - 24px);
  height: 84px;
  border-radius: var(--radius);
  border: 1px solid rgba(148, 163, 184, 0.25);
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.18);
  pointer-events: none;
  z-index: 10;
}

/* ============================================================
   SLIDER DE OPACIDAD
   ============================================================ */
.opacity-control {}

.slider-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.slider-label {
  font-size: 11px;
  color: var(--text-dim);
  min-width: 28px;
  text-align: center;
}

input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: var(--panel-border);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid var(--bg);
  transition: background 0.2s;
}

input[type="range"]::-webkit-slider-thumb:hover {
  background: var(--accent-hover);
}

.opacity-value-row {
  text-align: center;
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

/* ============================================================
   INFORMACIÓN CLÍNICA
   ============================================================ */
#clinical-info {
  position: relative;
}

.info-content {
  display: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.info-content.active {
  display: block;
  opacity: 1;
}

.info-content.fade-in {
  opacity: 1;
}

.info-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  margin-bottom: 12px;
}

.info-header.anat { background: rgba(52,211,153,0.10);  border: 1px solid rgba(52,211,153,0.3); }
.info-header.al   { background: rgba(239,68,68,0.12);  border: 1px solid rgba(239,68,68,0.3); }
.info-header.ap   { background: rgba(249,115,22,0.12); border: 1px solid rgba(249,115,22,0.3); }
.info-header.dsd  { background: rgba(168,85,247,0.12); border: 1px solid rgba(168,85,247,0.3); }

.info-mode-badge {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.05em;
}

.info-header.anat .info-mode-badge { color: var(--anat-color); font-size: 20px; }
.info-header.al   .info-mode-badge { color: var(--al-color); }
.info-header.ap   .info-mode-badge { color: var(--ap-color); }
.info-header.dsd  .info-mode-badge { color: var(--dsd-color); }

.info-mode-title {
  font-size: 12px;
  color: var(--text);
  line-height: 1.3;
}

.info-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.info-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.info-label {
  font-size: 12px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.info-value {
  font-size: 12px;
  color: var(--text);
  text-align: right;
}

.info-value.highlight {
  font-weight: 700;
  color: #0f172a;
}

.delta {
  font-size: 10px;
  color: var(--text-dim);
}

.delta.positive {
  color: #34d399;
}

.info-divider {
  height: 1px;
  background: var(--panel-border);
  margin: 4px 0;
}

.info-coverage {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

.coverage-label {
  font-weight: 600;
  color: var(--text);
  margin-right: 4px;
}

.info-warning {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 8px 10px;
  background: rgba(239,68,68,0.08);
  border: 1px solid rgba(239,68,68,0.2);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

.warning-icon { color: #fbbf24; font-size: 14px; flex-shrink: 0; }

.info-success {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 8px 10px;
  background: rgba(52,211,153,0.08);
  border: 1px solid rgba(52,211,153,0.2);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-muted);
}

.success-icon { color: #34d399; font-size: 14px; flex-shrink: 0; }

.info-dsd-note {
  padding: 8px 10px;
  background: rgba(168,85,247,0.08);
  border: 1px solid rgba(168,85,247,0.2);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}

.or-text {
  margin-top: 4px;
  font-size: 13px;
  font-weight: 700;
  color: var(--dsd-color);
}

.al-text { color: var(--al-color); font-weight: 600; }
.ap-text { color: var(--ap-color); font-weight: 600; }

/* Caja de supervivencia */
.survival-box {
  text-align: center;
  padding: 12px;
  border-radius: var(--radius);
  margin-top: 4px;
}

.survival-box.al  { background: rgba(239,68,68,0.10);  border: 1px solid rgba(239,68,68,0.25); }
.survival-box.ap  { background: rgba(249,115,22,0.10); border: 1px solid rgba(249,115,22,0.25); }
.survival-box.dsd { background: rgba(168,85,247,0.10); border: 1px solid rgba(168,85,247,0.25); }

.survival-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}

.survival-value {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1;
  margin-bottom: 4px;
}

.survival-box.al  .survival-value { color: var(--al-color); }
.survival-box.ap  .survival-value { color: var(--ap-color); }
.survival-box.dsd .survival-value { color: var(--dsd-color); }

.survival-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.survival-ref {
  font-size: 10px;
  color: var(--text-dim);
  font-style: italic;
}

/* ============================================================
   LEYENDA
   ============================================================ */
.legend {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--text-muted);
}

.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.legend-dot.al  { background: var(--al-color); box-shadow: 0 0 6px var(--al-color); }
.legend-dot.ap  { background: var(--ap-color); box-shadow: 0 0 6px var(--ap-color); }

.legend-line {
  width: 12px;
  height: 3px;
  background: linear-gradient(to right, var(--al-color), var(--ap-color));
  border-radius: 2px;
  flex-shrink: 0;
  opacity: 0.6;
}

/* ============================================================
   BARRAS DE CORRIENTE / IMPEDANCIA
   ============================================================ */
.current-visual {
  margin-top: 4px;
}

.cv-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin-bottom: 4px;
}

.cv-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 5px;
}

.cv-row-label {
  font-size: 11px;
  color: var(--text-muted);
  width: 72px;
  flex-shrink: 0;
}

.cv-track {
  flex: 1;
  height: 7px;
  background: var(--panel-border);
  border-radius: 4px;
  overflow: hidden;
}

.cv-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.4s ease;
}

.cv-fill.al   { background: var(--al-color); }
.cv-fill.ap   { background: var(--ap-color); }
.cv-fill.good { background: #34d399; }

.cv-value {
  font-size: 11px;
  font-weight: 600;
  width: 38px;
  text-align: right;
  flex-shrink: 0;
  color: var(--text);
}

/* ============================================================
   BLOQUES CUBRE / NO CUBRE
   ============================================================ */
.coverage-detail {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.cov-block {
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  line-height: 1.5;
  color: var(--text-muted);
}

.cov-block p { margin: 0; }

.cov-block.cubre    { background: rgba(52,211,153,0.08); border: 1px solid rgba(52,211,153,0.28); }
.cov-block.no-cubre { background: rgba(239,68,68,0.06);  border: 1px solid rgba(239,68,68,0.22); }
.cov-block.dsd-cubre { background: rgba(168,85,247,0.08); border: 1px solid rgba(168,85,247,0.25); }

.cov-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 5px;
  font-size: 11px;
  color: var(--text);
}

.cov-icon        { font-size: 13px; font-weight: 700; }
.cov-icon.cubre  { color: #10b981; }
.cov-icon.no-cubre { color: var(--al-color); }

/* ============================================================
   PANEL ANAT
   ============================================================ */
.info-anat-note {
  padding: 8px 10px;
  background: rgba(52,211,153,0.07);
  border: 1px solid rgba(52,211,153,0.2);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}

.info-anat-note p { margin-bottom: 6px; }

.anat-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.anat-list li::before {
  content: '—  ';
  color: var(--anat-color);
  font-size: 10px;
}

.anat-list li {
  font-size: 11px;
  color: var(--text-dim);
}

.anat-hint {
  font-size: 11px;
  color: var(--text-dim);
  font-style: italic;
  line-height: 1.4;
  text-align: center;
}

/* ============================================================
   PESTAÑAS DE NAVEGACIÓN
   ============================================================ */
.app-tabs {
  flex-shrink: 0;
  display: flex;
  align-items: flex-end;
  gap: 2px;
  padding: 0 20px;
  background: var(--panel);
  border-bottom: 2px solid var(--panel-border);
}

.app-tab {
  padding: 8px 18px 7px;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  background: transparent;
  font-family: inherit;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
  line-height: 1;
}

.app-tab:hover:not(.active) {
  color: var(--text);
}

.app-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

/* ============================================================
   PANEL DE REVISIÓN NARRATIVA
   ============================================================ */
#review-panel {
  flex: 1;
  overflow-y: auto;
  padding: 28px 20px 40px;
  background: var(--bg);
  min-height: 0;
}

#review-panel::-webkit-scrollbar { width: 6px; }
#review-panel::-webkit-scrollbar-track { background: transparent; }
#review-panel::-webkit-scrollbar-thumb { background: var(--panel-border); border-radius: 3px; }

.review-container {
  max-width: 820px;
  margin: 0 auto;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 40px 52px;
}

.review-meta {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 24px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--panel-border);
}

.review-title {
  font-size: 19px;
  font-weight: 700;
  line-height: 1.4;
  color: var(--text);
}

.review-badge {
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  background: rgba(37, 99, 235, 0.08);
  border: 1px solid rgba(37, 99, 235, 0.2);
  border-radius: var(--radius);
  padding: 4px 10px;
  margin-top: 3px;
}

.review-author-block {
  margin-bottom: 24px;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.75;
}

.review-author-block strong {
  display: block;
  color: var(--text);
  font-size: 14px;
  margin-bottom: 2px;
}

.review-abstract {
  background: rgba(37, 99, 235, 0.04);
  border: 1px solid rgba(37, 99, 235, 0.15);
  border-radius: var(--radius);
  padding: 18px 22px;
  margin-bottom: 30px;
}

.review-abstract-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin-bottom: 8px;
}

.review-abstract p {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.75;
  margin: 0;
}

.review-section {
  margin-bottom: 26px;
}

.review-section h2 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 10px;
  padding-bottom: 7px;
  border-bottom: 1px solid var(--panel-border);
}

.review-section h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin: 14px 0 6px;
}

.review-section p {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.8;
  margin-bottom: 10px;
}

.review-section p:last-child { margin-bottom: 0; }

.review-callout {
  padding: 13px 17px;
  border-radius: var(--radius);
  margin: 14px 0;
}

.review-callout.purple {
  background: rgba(168, 85, 247, 0.06);
  border: 1px solid rgba(168, 85, 247, 0.2);
}

.review-callout.green {
  background: rgba(52, 211, 153, 0.06);
  border: 1px solid rgba(52, 211, 153, 0.2);
}

.review-callout p {
  font-size: 13px;
  color: var(--text);
  line-height: 1.65;
  margin: 0 !important;
}

/* Tabla de resultados DOSE VF */
.review-results-table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 12px;
}

.review-results-table th {
  text-align: left;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 6px 12px;
  border-bottom: 2px solid var(--panel-border);
}

.review-results-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--panel-border);
  color: var(--text);
  vertical-align: middle;
  font-size: 13px;
}

.review-results-table tr:last-child td { border-bottom: none; }
.review-results-table tr:hover td { background: var(--bg); }

.td-al  { color: var(--al-color);  font-weight: 700; }
.td-ap  { color: var(--ap-color);  font-weight: 700; }
.td-dsd { color: var(--dsd-color); font-weight: 700; }
.td-num { font-weight: 700; font-size: 15px; }
.td-rr  { font-size: 11px; color: var(--text-dim); }

/* Lista de referencias */
.ref-list {
  list-style: none;
  padding: 0;
  margin: 0;
  counter-reset: ref-counter;
}

.ref-list li {
  counter-increment: ref-counter;
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 12px;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.65;
  padding: 11px 0;
  border-bottom: 1px solid var(--panel-border);
}

.ref-list li:last-child { border-bottom: none; }

.ref-num {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--bg);
  border: 1px solid var(--panel-border);
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  flex-shrink: 0;
  margin-top: 1px;
}

.ref-doi {
  display: inline-block;
  margin-top: 3px;
  font-size: 11px;
  color: var(--accent);
  font-family: ui-monospace, 'SF Mono', monospace;
  word-break: break-all;
}

.ref-doi:hover { text-decoration: underline; }

/* ============================================================
   RESPONSIVE — MÓVIL (< 768 px)
   ============================================================ */
@media (max-width: 767px) {

  /* Body: permitir scroll vertical en lugar de overflow hidden */
  html, body {
    height: auto;
    overflow: auto;
  }

  body {
    min-height: 100dvh;
    height: auto;
  }

  /* Header: subtítulo pasa a segunda línea */
  header {
    flex-wrap: wrap;
    gap: 4px;
    padding: 8px 14px;
  }

  header .subtitle {
    flex-basis: 100%;
    font-size: 11px;
    line-height: 1.3;
  }

  /* Pestañas: área táctil más grande */
  .app-tab {
    padding: 10px 16px 9px;
    font-size: 14px;
  }

  /* Main: de horizontal a vertical, scroll por el body */
  main {
    flex-direction: column;
    overflow: visible;
    height: auto;
    min-height: 0;
  }

  /* Viewport 3D: altura fija en la parte superior */
  #viewport-container {
    flex: none;
    height: 55vh;
    min-height: 260px;
    width: 100%;
  }

  /* Panel de control: ancho completo, altura natural */
  #control-panel {
    flex: none;
    width: 100%;
    height: auto;
    border-left: none;
    border-top: 1px solid var(--panel-border);
    overflow-y: visible;
  }

  /* Botones de modo: padding mayor para toque con dedo */
  .mode-btn {
    padding: 12px 6px;
  }

  .mode-label {
    font-size: 20px;
  }

  .mode-desc {
    font-size: 11px;
  }

  /* Slider: thumb más grande para arrastrar con dedo */
  input[type="range"]::-webkit-slider-thumb {
    width: 22px;
    height: 22px;
  }

  /* Panel de revisión narrativa: body hace el scroll */
  #review-panel {
    flex: none;
    overflow-y: visible;
    padding: 16px 12px 32px;
  }

  .review-container {
    padding: 24px 20px;
    border-radius: 8px;
  }

  /* Cabecera: título y badge apilados */
  .review-meta {
    flex-direction: column;
    gap: 10px;
  }

  .review-title {
    font-size: 16px;
  }

  /* Tabla DOSE VF: texto más compacto */
  .review-results-table {
    font-size: 11px;
  }

  .review-results-table th,
  .review-results-table td {
    padding: 6px 8px;
  }

  .td-num {
    font-size: 13px;
  }

  /* Footer: apilado verticalmente */
  footer {
    padding: 8px 14px;
  }

  .footer-content {
    flex-direction: column;
    gap: 4px;
  }
}
