/* ==========================================================================
   Generador y transductor de código Morse con sonido, linterna y práctica
   Estándares canónicos de fijate.com - CSS Modular
   ========================================================================== */

/* Variables CSS para diseño temático */
:root {
  --morse-primary: #f59e0b;
  --morse-primary-hover: #d97706;
  --morse-primary-alpha: rgba(245, 158, 11, 0.15);
  --morse-accent: #10b981;
  --morse-accent-hover: #059669;
  --morse-accent-alpha: rgba(16, 185, 129, 0.15);
  --morse-beacon-glow: rgba(245, 158, 11, 0.7);
  --morse-danger: #ef4444;
  --morse-brass: #d97706;
  --morse-brass-light: #fbbf24;
  --morse-brass-shadow: #78350f;
  
  --bg-app: #0b0f19;
  --bg-card: #111827;
  --bg-card-subtle: #1f2937;
  --bg-input: #0d131f;
  --border-card: #1f2937;
  --border-focus: #f59e0b;
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --text-dim: #6b7280;
  
  --tape-bg: #fef3c7;
  --tape-text: #78350f;
  --tape-border: #fcd34d;
  
  --radius-lg: 1rem;
  --radius-md: 0.75rem;
  --radius-sm: 0.5rem;
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
}

[data-theme="light"] {
  --morse-primary: #d97706;
  --morse-primary-hover: #b45309;
  --morse-primary-alpha: rgba(217, 119, 6, 0.12);
  --morse-accent: #059669;
  --morse-accent-hover: #047857;
  --morse-accent-alpha: rgba(5, 150, 105, 0.12);
  --morse-beacon-glow: rgba(217, 119, 6, 0.5);
  --morse-danger: #dc2626;
  --morse-brass: #b45309;
  --morse-brass-light: #f59e0b;
  --morse-brass-shadow: #451a03;

  --bg-app: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-subtle: #f1f5f9;
  --bg-input: #ffffff;
  --border-card: #e2e8f0;
  --border-focus: #d97706;
  --text-main: #0f172a;
  --text-muted: #475569;
  --text-dim: #64748b;

  --tape-bg: #fffbeb;
  --tape-text: #78350f;
  --tape-border: #fde68a;
}

/* Reset y estructura global de contención */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  overflow-x: clip;
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-app);
  color: var(--text-main);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Outfit', sans-serif;
  color: var(--text-main);
  font-weight: 700;
  line-height: 1.25;
}

.mono-font {
  font-family: 'JetBrains Mono', monospace;
}

/* Layout con barra publicitaria */
.tool-layout {
  max-width: 1200px;
  margin: 1.5rem auto 3rem;
  padding: 0 1rem;
  width: 100%;
}

.tool-with-sidebar {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
  width: 100%;
}

.tool-main-content {
  flex: 1 1 0%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

/* Contenedores de tarjeta */
.card-main {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
}

@media (max-width: 640px) {
  .card-main {
    padding: 1.25rem;
    border-radius: var(--radius-md);
  }
}

/* Barra superior de pestañas */
.morse-tabs-nav {
  display: flex;
  background: var(--bg-card-subtle);
  border-radius: var(--radius-md);
  padding: 0.35rem;
  gap: 0.35rem;
  overflow-x: auto;
  scrollbar-width: thin;
  margin-bottom: 1.5rem;
}

.tab-btn {
  flex: 1;
  min-width: 130px;
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-family: 'Outfit', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.tab-btn:hover {
  color: var(--text-main);
  background: var(--morse-primary-alpha);
}

.tab-btn.active {
  background: var(--morse-primary);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.35);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
  animation: fadeIn 0.25s ease-out;
}

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

/* ==========================================================================
   Pestaña 1: Traductor y Transmisor Acústico / Óptico
   ========================================================================== */

.translation-grid {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1.5rem;
}

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

.trans-panel {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.trans-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.trans-title {
  font-size: 1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-main);
}

.trans-tools {
  display: flex;
  gap: 0.35rem;
}

.btn-trans-action {
  background: transparent;
  border: 1px solid var(--border-card);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.6rem;
  font-size: 0.8rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: all var(--transition-fast);
  min-height: 32px;
}

.btn-trans-action:hover {
  background: var(--morse-primary-alpha);
  color: var(--morse-primary);
  border-color: var(--morse-primary);
}

.trans-textarea {
  width: 100%;
  min-height: 140px;
  background: var(--bg-input);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  color: var(--text-main);
  font-size: 1rem;
  line-height: 1.5;
  resize: vertical;
  transition: border-color var(--transition-fast);
}

.trans-textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--morse-primary-alpha);
}

.trans-textarea.morse-font {
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.12em;
  font-size: 1.15rem;
}

.trans-footer {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.btn-swap-direction {
  align-self: center;
  background: var(--morse-primary-alpha);
  border: 1px solid var(--morse-primary);
  color: var(--morse-primary);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-swap-direction:hover {
  background: var(--morse-primary);
  color: #ffffff;
  transform: rotate(180deg);
}

@media (max-width: 860px) {
  .btn-swap-direction {
    align-self: center;
    margin: -0.25rem 0;
  }
}

/* Barra de presets rápidos */
.presets-container {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.presets-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

.preset-chip {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-card);
  color: var(--text-main);
  padding: 0.35rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.825rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.preset-chip:hover {
  border-color: var(--morse-primary);
  color: var(--morse-primary);
  background: var(--morse-primary-alpha);
}

/* Panel de control de reproducción y telemetría de transmisión */
.transmission-control-panel {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.transmission-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.beacon-box {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.optical-beacon-lamp {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #1f2937;
  border: 3px solid #374151;
  position: relative;
  transition: all 0.05s ease;
  flex-shrink: 0;
}

.optical-beacon-lamp::after {
  content: '';
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  background: #374151;
  transition: all 0.05s ease;
}

.optical-beacon-lamp.active {
  background: var(--morse-primary);
  border-color: #fef08a;
  box-shadow: 0 0 25px var(--morse-beacon-glow), 0 0 50px var(--morse-beacon-glow);
}

.optical-beacon-lamp.active::after {
  background: #ffffff;
}

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

.beacon-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
}

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

/* Botonera de reproducción principal */
.playback-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.btn-play-action {
  min-height: 42px;
  padding: 0.5rem 1.25rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.95rem;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  border: none;
  transition: all var(--transition-fast);
}

.btn-primary-play {
  background: var(--morse-primary);
  color: #ffffff;
}

.btn-primary-play:hover {
  background: var(--morse-primary-hover);
  transform: translateY(-1px);
}

.btn-secondary-action {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  color: var(--text-main);
}

.btn-secondary-action:hover {
  border-color: var(--morse-primary);
  color: var(--morse-primary);
}

.btn-secondary-action.active-toggle {
  background: var(--morse-primary-alpha);
  border-color: var(--morse-primary);
  color: var(--morse-primary);
}

/* Barra de progreso y visor de Karaoke */
.progress-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.morse-progress-bar {
  width: 100%;
  height: 8px;
  background: var(--bg-card);
  border-radius: 9999px;
  overflow: hidden;
  position: relative;
}

.morse-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--morse-primary), #fbbf24);
  transition: width 0.1s linear;
}

.karaoke-display {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  min-height: 52px;
  display: flex;
  align-items: center;
  overflow-x: auto;
  white-space: nowrap;
  gap: 0.5rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.15rem;
}

.karaoke-item {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  transition: all 0.1s ease;
}

.karaoke-item .k-char {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
}

.karaoke-item .k-morse {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.karaoke-item.current {
  background: var(--morse-primary);
  color: #ffffff;
  transform: scale(1.15);
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.5);
}

.karaoke-item.current .k-char,
.karaoke-item.current .k-morse {
  color: #ffffff;
}

/* Opciones y sliders de audio / óptica */
.transmission-settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.25rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-card);
}

.setting-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.setting-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.setting-val {
  font-weight: 700;
  color: var(--morse-primary);
  font-family: 'JetBrains Mono', monospace;
}

.morse-range-input {
  width: 100%;
  height: 6px;
  -webkit-appearance: none;
  background: var(--bg-card);
  border-radius: 9999px;
  outline: none;
}

.morse-range-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--morse-primary);
  cursor: pointer;
  box-shadow: 0 0 6px rgba(245, 158, 11, 0.4);
}

.morse-range-input::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--morse-primary);
  cursor: pointer;
  border: none;
}

.morse-select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 40px;
  padding: 0.5rem 2.5rem 0.5rem 0.75rem;
  border: 1px solid var(--border-card);
  border-radius: var(--radius-sm);
  background-color: var(--bg-input);
  color: var(--text-main);
  font-size: 0.9rem;
  font-family: inherit;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 16px 16px;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}

.morse-select option,
.morse-select optgroup {
  background-color: var(--bg-card);
  color: var(--text-main);
}

/* ==========================================================================
   Pestaña 2: Manipulador telegráfico interactivo (Llave Morse)
   ========================================================================== */

.telegraph-workbench {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Cinta telegráfica de teletipo (Ticker Tape) */
.ticker-tape-wrapper {
  background: var(--tape-bg);
  border: 2px solid var(--tape-border);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.08);
  position: relative;
  overflow: hidden;
}

.ticker-tape-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
  border-bottom: 1px dashed rgba(120, 53, 15, 0.25);
  padding-bottom: 0.35rem;
}

.ticker-tape-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--tape-text);
}

.ticker-tape-actions {
  display: flex;
  gap: 0.5rem;
}

.ticker-btn {
  background: transparent;
  border: 1px solid var(--tape-text);
  color: var(--tape-text);
  font-size: 0.75rem;
  font-family: 'JetBrains Mono', monospace;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.ticker-btn:hover {
  background: rgba(120, 53, 15, 0.1);
}

.ticker-tape-viewport {
  min-height: 58px;
  overflow-x: auto;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.25rem 0;
  scrollbar-width: thin;
}

.tape-entry {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  animation: popIn 0.15s ease-out;
}

@keyframes popIn {
  from { transform: scale(0.7); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.tape-morse {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--tape-text);
  letter-spacing: 0.05em;
  line-height: 1;
}

.tape-letter {
  font-family: 'Outfit', sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  color: #1c1917;
  background: rgba(120, 53, 15, 0.15);
  padding: 0 4px;
  border-radius: 3px;
}

/* Área de decodificación acumulada */
.decoded-screen-box {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.decoded-screen-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
}

.decoded-text-output {
  min-height: 60px;
  background: var(--bg-input);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.15rem;
  color: var(--morse-accent);
  line-height: 1.5;
  word-break: break-word;
}

/* Instrumento Skeuomórfico: Llave Telegráfica */
.key-stage {
  background: radial-gradient(circle at center, #1e293b 0%, #0f172a 100%);
  border: 2px solid #334155;
  border-radius: var(--radius-lg);
  padding: 2.5rem 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  box-shadow: inset 0 4px 15px rgba(0, 0, 0, 0.5), 0 10px 30px rgba(0, 0, 0, 0.3);
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

[data-theme="light"] .key-stage {
  background: radial-gradient(circle at center, #e2e8f0 0%, #cbd5e1 100%);
  border-color: #94a3b8;
}

.telegraph-key-mechanism {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  width: 100%;
  max-width: 380px;
}

/* Botón y palanca basculante */
.key-arm-assembly {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  transition: transform 0.06s cubic-bezier(0.4, 0, 0.2, 1);
  transform-origin: center bottom;
}

.key-knob-handle {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #3f3f46 0%, #18181b 70%, #09090b 100%);
  border: 4px solid #52525b;
  box-shadow: 0 12px 25px rgba(0, 0, 0, 0.6), inset 0 2px 5px rgba(255, 255, 255, 0.25);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  z-index: 5;
  color: #d4d4d8;
  font-family: 'Outfit', sans-serif;
  font-size: 0.9rem;
  font-weight: 700;
  text-align: center;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  transition: all 0.05s ease;
  touch-action: none;
}

.key-knob-handle::before {
  content: '';
  position: absolute;
  inset: 12px;
  border-radius: 50%;
  border: 2px dashed rgba(255, 255, 255, 0.15);
}

.key-arm-assembly.pressed {
  transform: translateY(7px) scale(0.98);
}

.key-arm-assembly.pressed .key-knob-handle {
  border-color: var(--morse-primary);
  background: radial-gradient(circle at 35% 35%, #78350f 0%, #451a03 70%, #18181b 100%);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.8), 0 0 20px var(--morse-beacon-glow);
  color: #fef08a;
}

/* Contacto y base de latón */
.key-contact-pillar {
  width: 32px;
  height: 38px;
  background: linear-gradient(90deg, #b45309 0%, #fbbf24 50%, #92400e 100%);
  border-radius: 4px;
  margin-top: -8px;
  position: relative;
  z-index: 2;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
}

.key-base-plate {
  width: 260px;
  height: 24px;
  background: linear-gradient(180deg, #475569 0%, #1e293b 100%);
  border-radius: 6px;
  border-bottom: 4px solid #0f172a;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.5);
  margin-top: -6px;
  position: relative;
  z-index: 1;
}

/* Indicador de estado y destello en la llave */
.key-spark-indicator {
  position: absolute;
  bottom: 42px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #374151;
  transition: all 0.05s ease;
  z-index: 4;
}

.key-spark-indicator.spark {
  background: #fef08a;
  box-shadow: 0 0 20px #fde047, 0 0 35px #f59e0b;
}

/* Guía de atajo de teclado para la llave */
.key-hint-badge {
  margin-top: 1.5rem;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-card);
  padding: 0.4rem 0.8rem;
  border-radius: 9999px;
  font-size: 0.85rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.key-hint-badge kbd {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  color: var(--text-main);
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  font-weight: 700;
}

/* Tarjetas de telemetría de transmisión táctil */
.telegraph-metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
}

.metric-card {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  padding: 1rem;
  text-align: center;
}

.metric-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--morse-primary);
  line-height: 1.2;
}

.metric-title {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* ==========================================================================
   Pestaña 3: Academia telegráfica y práctica
   ========================================================================== */

.academy-container {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.academy-mode-selector {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.btn-academy-mode {
  flex: 1;
  min-height: 44px;
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-academy-mode.active {
  background: var(--morse-accent);
  color: #ffffff;
  border-color: var(--morse-accent);
}

.academy-challenge-card {
  background: var(--bg-card-subtle);
  border: 2px solid var(--border-card);
  border-radius: var(--radius-lg);
  padding: 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 1.25rem;
  transition: border-color var(--transition-fast);
}

.academy-challenge-card.success {
  border-color: var(--morse-accent);
  box-shadow: 0 0 20px var(--morse-accent-alpha);
}

.academy-challenge-card.fail {
  border-color: var(--morse-danger);
}

.challenge-prompt-label {
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 600;
}

.challenge-target-char {
  font-size: 3.5rem;
  font-family: 'Outfit', sans-serif;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1;
}

.challenge-target-morse {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.5rem;
  color: var(--morse-primary);
  letter-spacing: 0.15em;
}

.academy-input-zone {
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.academy-stats-bar {
  display: flex;
  justify-content: space-around;
  width: 100%;
  max-width: 500px;
  border-top: 1px solid var(--border-card);
  padding-top: 1rem;
}

.academy-stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.academy-stat-num {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-main);
}

.academy-stat-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ==========================================================================
   Pestaña 4: Diccionario interactivo y chuleta
   ========================================================================== */

.dictionary-container {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.dict-search-wrapper {
  position: relative;
  width: 100%;
}

.dict-search-input {
  width: 100%;
  min-height: 42px;
  padding: 0.6rem 1rem 0.6rem 2.5rem;
  background: var(--bg-input);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 0.95rem;
}

.dict-search-icon {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  pointer-events: none;
}

.dict-categories-filter {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.dict-filter-btn {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-card);
  color: var(--text-muted);
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.dict-filter-btn.active {
  background: var(--morse-primary);
  color: #ffffff;
  border-color: var(--morse-primary);
}

.morse-dict-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.85rem;
}

.dict-item-card {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: transform var(--transition-fast), border-color var(--transition-fast);
}

.dict-item-card:hover {
  border-color: var(--morse-primary);
  transform: translateY(-2px);
}

.dict-char-info {
  display: flex;
  flex-direction: column;
}

.dict-char-symbol {
  font-family: 'Outfit', sans-serif;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.1;
}

.dict-char-code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.1rem;
  color: var(--morse-primary);
  letter-spacing: 0.08em;
  font-weight: 600;
}

.dict-char-mnemonic {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.btn-dict-sound {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border-card);
  background: var(--bg-card);
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.btn-dict-sound:hover {
  background: var(--morse-primary-alpha);
  color: var(--morse-primary);
  border-color: var(--morse-primary);
}

/* ==========================================================================
   Modo baliza estroboscópica a pantalla completa (Fullscreen Beacon)
   ========================================================================== */

.fullscreen-beacon-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: #000000;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 1.5rem;
}

.fullscreen-beacon-overlay.active {
  display: flex;
}

.fullscreen-beacon-overlay.flash-on {
  background: #ffffff !important;
}

.beacon-overlay-content {
  text-align: center;
  color: #ffffff;
  padding: 1.5rem;
  border-radius: var(--radius-md);
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.beacon-overlay-text {
  font-family: 'JetBrains Mono', monospace;
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
  color: #fbbf24;
}

.btn-exit-fullscreen-beacon {
  min-height: 44px;
  padding: 0.6rem 1.5rem;
  background: var(--morse-danger);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 700;
  cursor: pointer;
  font-size: 1rem;
}

/* ==========================================================================
   Modales Canónicos HTML/CSS/JS (Cero Alerts)
   ========================================================================== */

.fijate-modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.fijate-modal-backdrop.open {
  display: flex;
}

.fijate-modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  max-width: 520px;
  width: 100%;
  padding: 1.75rem;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3), 0 10px 10px -5px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  animation: modalScale 0.2s ease-out;
}

@keyframes modalScale {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.fijate-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.fijate-modal-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
}

.btn-modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 4px;
  display: inline-flex;
}

.btn-modal-close:hover {
  color: var(--text-main);
}

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

.fijate-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* Toast de notificación rápida */
.morse-toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: var(--bg-card);
  border: 1px solid var(--morse-primary);
  color: var(--text-main);
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-md);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
  z-index: 10001;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.25s ease;
  pointer-events: none;
}

.morse-toast.show {
  transform: translateY(0);
  opacity: 1;
}

/* Utilidades responsivas */
@media (max-width: 640px) {
  .transmission-top-row {
    flex-direction: column;
    align-items: stretch;
  }
  
  .beacon-box {
    justify-content: center;
  }
  
  .playback-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }
  
  .btn-primary-play {
    grid-column: 1 / -1;
    justify-content: center;
    width: 100%;
  }

  .btn-secondary-action {
    justify-content: center;
    width: 100%;
  }

  .ticker-tape-actions {
    margin-top: 0.25rem;
  }

  .key-stage {
    padding: 2rem 1rem;
  }

  .key-knob-handle {
    width: 96px;
    height: 96px;
  }
}
