/* Variables y Tema Automotriz EV */
:root {
  --bg-primary: #0a0e17;
  --bg-secondary: #131a29;
  --bg-tertiary: #1c263b;
  --bg-card: rgba(19, 26, 41, 0.85);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(0, 245, 212, 0.3);

  --accent-cyan: #00f5d4;
  --accent-blue: #00b4d8;
  --accent-electric: #4361ee;
  --accent-purple: #7209b7;
  --accent-orange: #f77f00;
  --accent-red: #e63946;
  --accent-green: #2ec4b6;

  --text-main: #f8f9fa;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;

  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --shadow-card: 0 10px 30px rgba(0, 0, 0, 0.5);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: clip;
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(0, 180, 216, 0.06) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(114, 9, 183, 0.06) 0%, transparent 40%);
}

/* Header & Barra Superior */
.top-navbar {
  background: rgba(19, 26, 41, 0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  padding: 0.8rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

.brand-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-electric));
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 1.2rem;
  color: #000;
  box-shadow: 0 0 15px rgba(0, 245, 212, 0.4);
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.brand-subtitle {
  font-size: 0.75rem;
  color: var(--accent-cyan);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-btn {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid transparent;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.nav-btn:hover {
  color: var(--text-main);
  background: var(--bg-tertiary);
  border-color: var(--border-color);
}

.nav-btn.active {
  color: var(--accent-cyan);
  background: rgba(0, 245, 212, 0.1);
  border-color: rgba(0, 245, 212, 0.3);
}

/* Contenedor Principal */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  min-width: 0;
}

/* Vistas */
.app-view {
  display: none;
  width: 100%;
  animation: fadeIn 0.3s ease forwards;
}

.app-view.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Portada / Menú Principal */
.hero-section {
  padding: 3rem 2rem 1.5rem;
  text-align: center;
  max-width: 900px;
  margin: 0 auto;
}

.hero-badge {
  display: inline-block;
  background: rgba(0, 245, 212, 0.1);
  border: 1px solid rgba(0, 245, 212, 0.3);
  color: var(--accent-cyan);
  padding: 6px 14px;
  border-radius: 50px;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 1.2rem;
}

.hero-title {
  font-size: 2.5rem;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 1rem;
  background: linear-gradient(135deg, #ffffff 40%, #00f5d4 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-desc {
  font-size: 1.1rem;
  color: var(--text-muted);
  line-height: 1.6;
}

/* Cuadrícula de Módulos */
.modules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 2rem;
  max-width: 1100px;
  margin: 2rem auto 4rem;
  padding: 0 1.5rem;
}

.module-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: var(--shadow-card);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: hidden;
  cursor: pointer;
}

.module-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: linear-gradient(90deg, var(--accent-cyan), var(--accent-blue));
  opacity: 0;
  transition: opacity 0.3s ease;
}

.module-card:hover {
  transform: translateY(-6px);
  border-color: rgba(0, 245, 212, 0.4);
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.7), 0 0 25px rgba(0, 245, 212, 0.15);
}

.module-card:hover::before {
  opacity: 1;
}

.card-img-preview {
  width: 100%;
  height: 160px;
  object-fit: cover;
  border-radius: var(--radius-md);
  margin-bottom: 1.5rem;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.card-icon-banner {
  width: 100%;
  height: 160px;
  border-radius: var(--radius-md);
  margin-bottom: 1.5rem;
  border: 1px solid rgba(0, 245, 212, 0.2);
  background: radial-gradient(circle at 30% 30%, rgba(0, 245, 212, 0.16), rgba(67, 97, 238, 0.14) 60%, #152033 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3.4rem;
  box-shadow: inset 0 0 24px rgba(0, 0, 0, 0.35);
}

.card-tag {
  font-size: 0.75rem;
  color: var(--accent-cyan);
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 1px;
  margin-bottom: 0.5rem;
}

.card-title {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 0.7rem;
  color: #fff;
}

.card-desc {
  font-size: 0.92rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 1.5rem;
  flex-grow: 1;
}

.card-btn {
  background: linear-gradient(135deg, rgba(0, 245, 212, 0.15), rgba(0, 180, 216, 0.25));
  border: 1px solid rgba(0, 245, 212, 0.4);
  color: var(--accent-cyan);
  padding: 12px 20px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s ease;
}

.module-card:hover .card-btn {
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-blue));
  color: #000;
  box-shadow: 0 0 20px rgba(0, 245, 212, 0.4);
}

/* Área del Simulador Interactivo */
.simulator-layout {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 65px);
  padding: 0.8rem 1.2rem;
  gap: 0.8rem;
}

/* Barra de Control del Simulador */
.sim-header {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.7rem 1.2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 15px;
  flex-wrap: wrap;
}

.sim-info-group {
  display: flex;
  flex-direction: column;
}

.sim-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
}

.sim-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.sim-actions-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.action-btn {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
  border: 1px solid var(--border-color);
  background: var(--bg-tertiary);
  color: var(--text-main);
}

.action-btn:hover {
  background: #25334e;
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-primary {
  background: linear-gradient(135deg, #00f5d4, #00b4d8);
  color: #05101a;
  border: none;
  font-weight: 700;
  box-shadow: 0 0 15px rgba(0, 245, 212, 0.3);
}

.btn-primary:hover {
  box-shadow: 0 0 25px rgba(0, 245, 212, 0.6);
  transform: translateY(-1px);
}

.btn-danger {
  background: rgba(230, 57, 70, 0.15);
  border-color: rgba(230, 57, 70, 0.4);
  color: #ff6b6b;
}

.btn-danger:hover {
  background: rgba(230, 57, 70, 0.3);
  border-color: var(--accent-red);
}

.btn-danger.active-danger {
  background: var(--accent-red);
  color: #fff;
  border-color: var(--accent-red);
  box-shadow: 0 0 15px rgba(230, 57, 70, 0.5);
}

.btn-success {
  background: rgba(46, 196, 182, 0.15);
  border-color: rgba(46, 196, 182, 0.4);
  color: #2ec4b6;
}

/* Área central de trabajo: Lienzo + Barra lateral */
.sim-body {
  flex: 1;
  display: flex;
  gap: 0.8rem;
  min-height: 0;
  position: relative;
}

/* Lienzo SVG */
.sim-canvas-panel {
  flex: 1;
  background: #0f1624;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.6);
  display: flex;
}

.sim-wrapper {
  width: 100%;
  height: 100%;
  display: flex;
}

.sim-canvas-container {
  width: 100%;
  height: 100%;
  position: relative;
}

#sim_svg {
  width: 100%;
  height: 100%;
  user-select: none;
}

/* Panel Lateral de Herramientas y Cables */
.sim-sidebar {
  width: 290px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  padding: 1rem;
  gap: 1.2rem;
  overflow-y: auto;
}

.sidebar-section {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.sidebar-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--accent-cyan);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.cables-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cable-select-btn {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
}

.cable-select-btn:hover {
  background: #23304a;
  border-color: rgba(255, 255, 255, 0.2);
}

.cable-select-btn.active {
  border-color: var(--accent-cyan);
  background: rgba(0, 245, 212, 0.12);
  box-shadow: 0 0 10px rgba(0, 245, 212, 0.2);
}

.cable-sample-line {
  width: 28px;
  height: 6px;
  border-radius: 3px;
  flex-shrink: 0;
}

.cable-info {
  display: flex;
  flex-direction: column;
}

.cable-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: #fff;
}

.cable-desc {
  font-size: 0.7rem;
  color: var(--text-dim);
}

/* Barra de Estado y Mensajes */
.status-bar {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.7rem 1rem;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  transition: all 0.3s ease;
}

.status-bar.status-ready {
  border-left: 4px solid var(--accent-blue);
  color: var(--text-main);
}

.status-bar.status-success {
  border-left: 4px solid var(--accent-green);
  background: rgba(46, 196, 182, 0.15);
  color: #2ec4b6;
  font-weight: 600;
}

.status-bar.status-error {
  border-left: 4px solid var(--accent-red);
  background: rgba(230, 57, 70, 0.15);
  color: #ff6b6b;
  font-weight: 600;
}

.status-bar.status-warning {
  border-left: 4px solid var(--accent-orange);
  background: rgba(247, 127, 0, 0.15);
  color: #ffa94d;
}

.status-bar.status-info {
  border-left: 4px solid var(--accent-cyan);
  background: rgba(0, 245, 212, 0.12);
  color: var(--accent-cyan);
  font-weight: 600;
}

/* Elementos SVG interactivos */
.device-rect {
  fill: #152033;
  stroke: rgba(255, 255, 255, 0.18);
  stroke-width: 1.5;
  transition: all 0.2s ease;
}

.device-group {
  cursor: pointer;
}

.device-group:hover .device-rect {
  stroke: var(--accent-cyan);
  filter: drop-shadow(0 0 10px rgba(0, 245, 212, 0.4));
}

.device-title {
  fill: #f1f5f9;
  font-size: 13px;
  font-weight: 600;
  pointer-events: none;
}

/* Terminales (Pins) */
.pin-group {
  cursor: pointer;
}

.pin-circle {
  fill: #3a86ff;
  stroke: #ffffff;
  stroke-width: 2.5;
  transition: all 0.2s ease;
}

.pin-group:hover .pin-circle {
  fill: var(--accent-cyan);
  r: 10;
  stroke-width: 3;
  filter: drop-shadow(0 0 8px rgba(0, 245, 212, 0.8));
}

.pin-circle.pin-active {
  fill: #ffbe0b !important;
  stroke: #ffffff;
  r: 11;
  stroke-width: 3.5;
  animation: pulsePin 1s infinite alternate;
}

@keyframes pulsePin {
  from { filter: drop-shadow(0 0 5px #ffbe0b); }
  to { filter: drop-shadow(0 0 16px #ffbe0b); }
}

.pin-label {
  fill: #e2e8f0;
  font-size: 11px;
  font-weight: 700;
  paint-order: stroke;
  stroke: #0a0e17;
  stroke-width: 3px;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

/* Cables */
.cable-group {
  cursor: default;
}

.cable-group.delete-target {
  cursor: pointer;
}

.cable-group.delete-target:hover path:first-child {
  stroke: var(--accent-red) !important;
  stroke-dasharray: 6 4;
}

.cable-animated {
  stroke-dasharray: 10 5;
  animation: flowCable 1s linear infinite;
}

@keyframes flowCable {
  from { stroke-dashoffset: 30; }
  to { stroke-dashoffset: 0; }
}

/* Modales y Ficha Técnica */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 580px;
  padding: 2rem;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
  position: relative;
  transform: translateY(20px);
  transition: transform 0.25s ease;
}

.modal-overlay.active .modal-card {
  transform: translateY(0);
}

.modal-close-btn {
  position: absolute;
  top: 1.2rem;
  right: 1.2rem;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  transition: color 0.2s ease;
}

.modal-close-btn:hover {
  color: #fff;
}

.modal-header {
  display: flex;
  align-items: center;
  gap: 15px;
  margin-bottom: 1.5rem;
}

.modal-img {
  width: 90px;
  height: 70px;
  object-fit: contain;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  padding: 6px;
}

.modal-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: #fff;
}

.modal-body {
  font-size: 0.95rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 1.5rem;
}

.modal-terminals-list {
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  padding: 1rem;
  margin-top: 1rem;
}

.modal-terminals-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent-cyan);
  text-transform: uppercase;
  margin-bottom: 0.6rem;
}

.terminal-item {
  display: flex;
  justify-content: space-between;
  padding: 5px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 0.85rem;
}

.terminal-item:last-child {
  border-bottom: none;
}

/* Reporte de Resultados */
.report-list {
  max-height: 150px;
  overflow-y: auto;
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.report-item {
  font-size: 0.78rem;
  padding: 4px 8px;
  border-radius: 4px;
}

.report-item.err {
  background: rgba(230, 57, 70, 0.1);
  color: #ff858d;
}

/* Visor de Anotaciones Técnicas de Aprendizaje */
.notes-layout {
  width: 100%;
  max-width: 1320px;
  margin: 0 auto;
  padding: 1.5rem 1.5rem 3rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.notes-header {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.4rem 1.8rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1.2rem;
  flex-wrap: wrap;
  box-shadow: var(--shadow-card);
}

.notes-main-title {
  font-size: 1.65rem;
  font-weight: 800;
  color: #fff;
  line-height: 1.25;
}

.notes-main-subtitle {
  font-size: 0.92rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
}

.notes-header-actions,
.notes-footer-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.notes-footer-actions {
  justify-content: center;
  padding-top: 0.5rem;
}

.notes-body {
  display: flex;
  align-items: flex-start;
  gap: 1.5rem;
}

.notes-toc-sidebar {
  width: 300px;
  flex-shrink: 0;
  position: sticky;
  top: 82px;
  max-height: calc(100vh - 102px);
  overflow-y: auto;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  box-shadow: var(--shadow-card);
}

.notes-toc-header {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--accent-cyan);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding-bottom: 0.7rem;
  margin-bottom: 0.7rem;
  border-bottom: 1px solid var(--border-color);
}

.notes-toc-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.notes-toc-item {
  line-height: 1.35;
}

.notes-toc-level-1 {
  font-weight: 700;
}

.notes-toc-level-2 {
  margin-top: 0.35rem;
  font-weight: 600;
}

.notes-toc-level-3 {
  padding-left: 0.75rem;
}

.notes-toc-level-4 {
  padding-left: 1.4rem;
  font-size: 0.86em;
}

.notes-toc-link {
  display: block;
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.82rem;
  border-left: 2px solid transparent;
  transition: all 0.15s ease;
}

.notes-toc-link:hover {
  color: var(--text-main);
  background: var(--bg-tertiary);
}

.notes-toc-link.active {
  color: var(--accent-cyan);
  background: rgba(0, 245, 212, 0.1);
  border-left-color: var(--accent-cyan);
}

.notes-toc-empty {
  font-size: 0.82rem;
  color: var(--text-dim);
}

.notes-content-panel {
  flex: 1;
  min-width: 0;
  overflow-wrap: break-word;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2rem 2.2rem;
  box-shadow: var(--shadow-card);
  color: #e2e8f0;
  line-height: 1.68;
  font-size: 0.96rem;
}

#notes_content h1,
#notes_content h2,
#notes_content h3,
#notes_content h4,
#notes_content h5,
#notes_content h6 {
  scroll-margin-top: 84px;
  color: #fff;
  font-weight: 700;
  line-height: 1.3;
}

#notes_content h1 {
  font-size: 1.85rem;
  margin-bottom: 1rem;
  padding-bottom: 0.7rem;
  border-bottom: 1px solid rgba(0, 245, 212, 0.25);
  color: var(--accent-cyan);
}

#notes_content h2 {
  font-size: 1.42rem;
  margin: 2rem 0 0.85rem;
  padding-bottom: 0.45rem;
  border-bottom: 1px solid var(--border-color);
  color: #f8fafc;
}

#notes_content h3 {
  font-size: 1.15rem;
  margin: 1.5rem 0 0.6rem;
  color: var(--accent-cyan);
}

#notes_content h4 {
  font-size: 1rem;
  margin: 1.2rem 0 0.5rem;
  color: #93c5fd;
}

#notes_content p {
  margin-bottom: 0.9rem;
  color: #cbd5e1;
}

#notes_content ul,
#notes_content ol {
  margin: 0.5rem 0 1rem 1.4rem;
  color: #cbd5e1;
}

#notes_content li {
  margin-bottom: 0.35rem;
}

#notes_content li > ul,
#notes_content li > ol {
  margin-top: 0.35rem;
  margin-bottom: 0.45rem;
}

#notes_content hr {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: 1.8rem 0;
}

#notes_content blockquote {
  margin: 1rem 0;
  padding: 0.75rem 1rem;
  border-left: 4px solid var(--accent-blue);
  background: rgba(0, 180, 216, 0.08);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-main);
}

#notes_content a {
  color: var(--accent-cyan);
  text-decoration: underline;
}

#notes_content :not(pre) > code {
  background: rgba(28, 38, 59, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #67e8f9;
  padding: 0.12rem 0.38rem;
  border-radius: 4px;
  font-family: Consolas, "Cascadia Code", "Courier New", monospace;
  font-size: 0.87em;
  overflow-wrap: anywhere;
}

#notes_content pre {
  background: #080c14;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem 1.15rem;
  margin: 1rem 0 1.2rem;
  overflow-x: auto;
}

#notes_content pre code {
  color: #e2e8f0;
  font-family: Consolas, "Cascadia Code", "Courier New", monospace;
  font-size: 0.86rem;
  line-height: 1.5;
}

.notes-table-wrap {
  width: 100%;
  overflow-x: auto;
  margin: 0.9rem 0 1.3rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: rgba(10, 14, 23, 0.55);
}

.notes-table-wrap table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.87rem;
}

.notes-table-wrap th,
.notes-table-wrap td {
  padding: 0.58rem 0.75rem;
  border-bottom: 1px solid var(--border-color);
  border-right: 1px solid rgba(255, 255, 255, 0.04);
  vertical-align: top;
  text-align: left;
}

.notes-table-wrap th:last-child,
.notes-table-wrap td:last-child {
  border-right: none;
}

.notes-table-wrap thead th {
  background: var(--bg-tertiary);
  color: var(--accent-cyan);
  font-weight: 700;
  white-space: nowrap;
}

.notes-table-wrap tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.02);
}

.notes-table-wrap tbody tr:hover {
  background: rgba(0, 245, 212, 0.05);
}

.notes-fallback {
  padding: 1.2rem;
  border-radius: var(--radius-md);
  background: rgba(247, 127, 0, 0.14);
  border: 1px solid rgba(247, 127, 0, 0.4);
  color: #ffd199;
}

/* Responsive */
@media (max-width: 1024px) {
  .simulator-layout {
    height: auto;
    min-height: calc(100vh - 65px);
  }
  .sim-body {
    flex-direction: column;
  }
  .sim-sidebar {
    width: 100%;
  }
  .sim-canvas-panel {
    min-height: 550px;
  }
  .notes-body {
    flex-direction: column;
    align-items: stretch;
  }
  .notes-toc-sidebar {
    width: 100%;
    position: static;
    max-height: 280px;
  }
  .notes-content-panel {
    width: 100%;
    max-width: 100%;
    padding: 1.4rem 1.25rem;
  }
}

@media (max-width: 900px) {
  .top-navbar {
    flex-wrap: wrap;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
  }
  .nav-links {
    flex-wrap: wrap;
    gap: 6px;
  }
}

/* Selector de Idioma (ES / 廣東話) */
.lang-switcher {
  display: inline-flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  padding: 2px;
  margin-left: 0.4rem;
  gap: 2px;
}

.lang-btn {
  background: transparent;
  border: none;
  color: var(--text-muted, #94a3b8);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.35rem 0.65rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.lang-btn:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
}

.lang-btn.active {
  background: var(--accent-cyan, #00f5d4);
  color: #0a0e17;
}

.notes-lang-notice {
  background: rgba(0, 245, 212, 0.1);
  border: 1px solid rgba(0, 245, 212, 0.35);
  color: #e2e8f0;
  border-radius: 10px;
  padding: 0.85rem 1.1rem;
  margin-bottom: 1.2rem;
  font-size: 0.9rem;
  line-height: 1.5;
}
