/**
 * Fijate Tools - AcufeNO: afinador de acúfenos y terapia de sonido adaptativa (Notch Therapy)
 * Estilos canónicos y adaptables (tema claro y oscuro)
 */

:root {
  --font-main: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-heading: 'Outfit', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Paleta cromática médica y terapéutica (tema oscuro por defecto) */
  --bg-app: #0b0f17;
  --bg-surface: #121824;
  --bg-surface-elevated: #1a2233;
  --bg-surface-soft: #232d42;
  --border-color: #26334d;
  --border-focus: #38bdf8;

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

  --accent-cyan: #06b6d4;
  --accent-cyan-light: #67e8f9;
  --accent-cyan-glow: rgba(6, 182, 212, 0.25);

  --accent-blue: #3b82f6;
  --accent-blue-hover: #2563eb;
  
  --accent-emerald: #10b981;
  --accent-emerald-glow: rgba(16, 185, 129, 0.25);

  --accent-rose: #f43f5e;
  --accent-amber: #f59e0b;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  --shadow-card: 0 4px 20px -2px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 25px rgba(6, 182, 212, 0.15);
}

[data-theme="light"] {
  --bg-app: #f8fafc;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #f1f5f9;
  --bg-surface-soft: #e2e8f0;
  --border-color: #cbd5e1;
  --border-focus: #0284c7;

  --text-main: #0f172a;
  --text-muted: #475569;
  --text-dim: #64748b;

  --accent-cyan: #0284c7;
  --accent-cyan-light: #0369a1;
  --accent-cyan-glow: rgba(2, 132, 199, 0.15);

  --accent-blue: #2563eb;
  --accent-blue-hover: #1d4ed8;

  --accent-emerald: #059669;
  --accent-emerald-glow: rgba(5, 150, 105, 0.15);

  --shadow-card: 0 4px 18px -2px rgba(15, 23, 42, 0.08);
  --shadow-glow: 0 0 20px rgba(2, 132, 199, 0.1);
}

/* Reset y layout de contención canónico */
*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  background-color: var(--bg-app);
  color: var(--text-main);
  font-family: var(--font-main);
  font-size: 15px;
  line-height: 1.6;
  overflow-x: clip;
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--text-main);
  margin-top: 0;
  line-height: 1.25;
}

p {
  margin-top: 0;
  margin-bottom: 1rem;
}

p:last-child {
  margin-bottom: 0;
}

.text-mono {
  font-family: var(--font-mono);
  font-feature-settings: "tnum" 1;
}

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

/* Contenedor principal de la herramienta */
.tool-layout {
  max-width: 1200px;
  margin: 1.5rem auto 3rem;
  padding: 0 1rem;
  box-sizing: border-box;
  flex: 1 0 auto;
  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;
  width: 100%;
}

/* Tarjetas base */
.card-panel {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-card);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.card-title {
  font-size: 1.25rem;
  margin-bottom: 0.35rem;
}

.card-subtitle {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 0;
}

/* 1. Banner de aviso de seguridad acústica */
.safety-notice-banner {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  background-color: rgba(6, 182, 212, 0.08);
  border: 1px solid rgba(6, 182, 212, 0.3);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  color: var(--text-main);
  font-size: 0.9rem;
}

.safety-icon {
  color: var(--accent-cyan);
  flex-shrink: 0;
  margin-top: 2px;
}

.safety-text strong {
  color: var(--accent-cyan-light);
}

[data-theme="light"] .safety-text strong {
  color: var(--accent-cyan);
}

/* 2. Barra de control maestro de audio */
.master-control-panel {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  background: linear-gradient(135deg, var(--bg-surface) 0%, var(--bg-surface-elevated) 100%);
  border-left: 4px solid var(--accent-cyan);
}

.master-left {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.btn-primary-audio {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  background: linear-gradient(135deg, var(--accent-cyan) 0%, #0891b2 100%);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-md);
  padding: 0.75rem 1.4rem;
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
  box-shadow: 0 4px 12px var(--accent-cyan-glow);
  transition: transform 0.15s ease, filter 0.15s ease;
}

.btn-primary-audio:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.btn-primary-audio:active {
  transform: translateY(0);
}

.btn-primary-audio.active {
  background: linear-gradient(135deg, var(--accent-emerald) 0%, #059669 100%);
  box-shadow: 0 4px 12px var(--accent-emerald-glow);
}

.status-indicator-box {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.85rem;
  background-color: var(--bg-surface-soft);
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 500;
}

.status-pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--text-dim);
  transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

.status-pulse.active-pulse {
  background-color: var(--accent-emerald);
  box-shadow: 0 0 10px var(--accent-emerald);
  animation: pulse-ring 2s infinite;
}

@keyframes pulse-ring {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.3); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

.master-right {
  flex: 1 1 240px;
  max-width: 320px;
}

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

.volume-label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  cursor: pointer;
}

.volume-val {
  margin-left: auto;
  font-weight: 600;
  color: var(--text-main);
}

/* 3. Visualizador interactivo en Canvas */
.visualizer-card {
  position: relative;
  overflow: hidden;
}

.visualizer-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.visualizer-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.badge-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 500;
}

.badge-freq {
  background-color: rgba(6, 182, 212, 0.12);
  border: 1px solid rgba(6, 182, 212, 0.3);
  color: var(--accent-cyan);
}

.badge-notch {
  background-color: rgba(244, 63, 94, 0.12);
  border: 1px solid rgba(244, 63, 94, 0.3);
  color: var(--accent-rose);
}

.canvas-wrapper {
  position: relative;
  width: 100%;
  background-color: #070a0f;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.6);
}

#audio-visualizer-canvas {
  display: block;
  width: 100%;
  height: 200px;
}

.canvas-freq-markers {
  position: absolute;
  bottom: 6px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  padding: 0 1rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.4);
  pointer-events: none;
}

.visualizer-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-color);
  font-size: 0.82rem;
}

.vis-legend {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  color: var(--text-muted);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.legend-color {
  width: 12px;
  height: 12px;
  border-radius: 3px;
}

.legend-wave {
  background: linear-gradient(180deg, var(--accent-cyan) 0%, rgba(6, 182, 212, 0.2) 100%);
}

.legend-notch {
  background: var(--accent-rose);
}

.vis-mode-switch {
  display: flex;
  gap: 0.35rem;
}

/* Chips y selectores */
.btn-chip {
  background-color: var(--bg-surface-soft);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  font-family: var(--font-heading);
  cursor: pointer;
  min-height: 36px;
  transition: all 0.15s ease;
}

.btn-chip:hover {
  background-color: var(--bg-surface-elevated);
  color: var(--text-main);
}

.btn-chip.active {
  background-color: var(--accent-cyan);
  color: #ffffff;
  border-color: var(--accent-cyan);
  font-weight: 600;
}

/* 4. Grid de los dos módulos principales (Afinador + Terapia Notch) */
.modules-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.module-header {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  margin-bottom: 1.25rem;
}

.module-step-num {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-cyan) 0%, #0891b2 100%);
  color: #ffffff;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.95rem;
  flex-shrink: 0;
  box-shadow: 0 2px 8px var(--accent-cyan-glow);
}

/* Caja de frecuencia grande del afinador */
.freq-display-box {
  background: linear-gradient(180deg, var(--bg-surface-elevated) 0%, var(--bg-surface) 100%);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  text-align: center;
  margin-bottom: 1.25rem;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.2);
}

.freq-main-number {
  font-size: 2.75rem;
  font-weight: 800;
  color: var(--accent-cyan);
  line-height: 1;
  letter-spacing: -0.02em;
}

.freq-unit {
  font-size: 1.25rem;
  color: var(--text-muted);
  margin-left: 0.25rem;
  font-weight: 500;
}

.freq-descriptor {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

/* Deslizadores personalizados de rango */
.styled-range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  border-radius: 4px;
  background: var(--bg-surface-soft);
  outline: none;
  cursor: pointer;
  margin: 0.5rem 0;
}

.styled-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent-cyan);
  border: 2px solid #ffffff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.styled-range::-webkit-slider-thumb:hover {
  transform: scale(1.15);
  box-shadow: 0 0 12px var(--accent-cyan);
}

.styled-range::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent-cyan);
  border: 2px solid #ffffff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  cursor: pointer;
}

.control-group {
  margin-bottom: 1.25rem;
}

.control-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.35rem;
  font-size: 0.85rem;
}

.input-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
  display: block;
  margin-bottom: 0.35rem;
}

/* Sintonización fina */
.fine-tuning-container {
  margin-bottom: 1.25rem;
}

.fine-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: block;
  margin-bottom: 0.45rem;
}

.fine-buttons-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.4rem;
}

.btn-fine {
  background-color: var(--bg-surface-soft);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.2rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  cursor: pointer;
  min-height: 40px;
  transition: all 0.15s ease;
  text-align: center;
}

.btn-fine:hover {
  background-color: var(--accent-cyan);
  color: #ffffff;
  border-color: var(--accent-cyan);
}

/* Presets clínicos */
.presets-container {
  margin-bottom: 1.25rem;
}

.presets-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.btn-preset {
  background-color: var(--bg-surface-elevated);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.65rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  cursor: pointer;
  min-height: 38px;
  transition: all 0.15s ease;
}

.btn-preset:hover {
  background-color: var(--bg-surface-soft);
  color: var(--text-main);
}

.btn-preset.active {
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
  background-color: rgba(6, 182, 212, 0.1);
  font-weight: 600;
}

/* Selector de forma de onda */
.waveform-container {
  margin-bottom: 1.25rem;
}

.waveform-selector {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.radio-chip {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.85rem;
  cursor: pointer;
  font-size: 0.82rem;
  transition: border-color 0.15s ease;
  min-height: 40px;
}

.radio-chip:hover {
  border-color: var(--accent-cyan);
}

.radio-chip input[type="radio"] {
  accent-color: var(--accent-cyan);
  margin: 0;
}

/* Balance estéreo */
.pan-container {
  margin-bottom: 1.5rem;
}

.pan-controls {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.4rem;
  margin-bottom: 0.5rem;
}

/* Acciones del afinador */
.tuner-action-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.btn-action-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  background: linear-gradient(135deg, var(--accent-cyan) 0%, #0891b2 100%);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-md);
  padding: 0.75rem 1.25rem;
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
  width: 100%;
  box-shadow: 0 4px 12px var(--accent-cyan-glow);
  transition: transform 0.15s ease, filter 0.15s ease;
}

.btn-action-primary:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.btn-action-primary.playing {
  background: linear-gradient(135deg, var(--accent-rose) 0%, #be123c 100%);
  box-shadow: 0 4px 12px rgba(244, 63, 94, 0.25);
}

.btn-action-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  background-color: var(--bg-surface-elevated);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.75rem 1.25rem;
  font-family: var(--font-heading);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
  width: 100%;
  transition: all 0.15s ease;
}

.btn-action-secondary:hover {
  background-color: var(--bg-surface-soft);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
}

/* Banner de explicación de terapia Notch */
.notch-explanation-banner {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  background-color: rgba(244, 63, 94, 0.08);
  border: 1px solid rgba(244, 63, 94, 0.25);
  border-radius: var(--radius-md);
  padding: 1rem;
  margin-bottom: 1.25rem;
  font-size: 0.88rem;
}

.notch-icon {
  color: var(--accent-rose);
  flex-shrink: 0;
  margin-top: 2px;
}

.notch-desc strong {
  color: var(--accent-rose);
}

/* Selector de tipo de ruido */
.noise-type-grid {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.noise-card {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
  min-height: 48px;
}

.noise-card:hover {
  border-color: var(--accent-rose);
}

.noise-card input[type="radio"] {
  accent-color: var(--accent-rose);
  margin-top: 4px;
}

.noise-card-content {
  display: flex;
  flex-direction: column;
}

.noise-title {
  font-size: 0.9rem;
  color: var(--text-main);
}

.noise-spec {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* Select canónico con flecha SVG */
.styled-select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 42px;
  padding: 0.6rem 40px 0.6rem 0.85rem;
  background-color: var(--bg-surface-elevated);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-family: var(--font-main);
  font-size: 0.88rem;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  cursor: pointer;
  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='%2394a3b8' 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 12px center;
  appearance: none;
  -webkit-appearance: none;
}

.styled-select:focus {
  outline: none;
  border-color: var(--border-focus);
}

.styled-select option {
  background-color: var(--bg-surface);
  color: var(--text-main);
}

.btn-therapy-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  background: linear-gradient(135deg, var(--accent-rose) 0%, #be123c 100%);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-md);
  padding: 0.85rem 1.5rem;
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  min-height: 48px;
  width: 100%;
  box-shadow: 0 4px 14px rgba(244, 63, 94, 0.3);
  transition: transform 0.15s ease, filter 0.15s ease;
}

.btn-therapy-toggle:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.btn-therapy-toggle.active {
  background: linear-gradient(135deg, var(--accent-emerald) 0%, #059669 100%);
  box-shadow: 0 4px 14px var(--accent-emerald-glow);
}

/* 5. Módulo de paisajes sonoros y ambientes naturales */
.soundscapes-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}

.soundscape-item {
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.75rem;
}

.soundscape-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}

.soundscape-info {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.soundscape-icon {
  color: var(--accent-cyan);
  flex-shrink: 0;
}

.soundscape-name {
  display: block;
  font-size: 0.9rem;
  color: var(--text-main);
  line-height: 1.2;
}

.soundscape-sub {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.btn-mute-channel {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  min-height: 32px;
  min-width: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s ease;
}

.btn-mute-channel:hover {
  color: var(--text-main);
}

.btn-mute-channel.muted {
  color: var(--accent-rose);
}

.soundscape-slider-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.channel-val {
  font-size: 0.78rem;
  color: var(--text-muted);
  width: 36px;
  text-align: right;
  flex-shrink: 0;
}

/* 6. Módulo de temporizador y fade-out */
.timer-flex {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: 1.25rem;
}

.timer-left {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
}

.timer-display-box {
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.75rem 1.5rem;
  text-align: center;
  min-width: 180px;
}

.timer-countdown {
  display: block;
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent-cyan);
  line-height: 1;
}

.timer-status-sub {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.timer-presets-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.btn-timer {
  flex: 1 1 auto;
  background-color: var(--bg-surface-elevated);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.6rem 1rem;
  font-size: 0.85rem;
  font-family: var(--font-heading);
  cursor: pointer;
  min-height: 42px;
  transition: all 0.15s ease;
  text-align: center;
}

.btn-timer:hover {
  background-color: var(--bg-surface-soft);
  color: var(--text-main);
}

.btn-timer.active {
  background-color: var(--accent-cyan);
  color: #ffffff;
  border-color: var(--accent-cyan);
  font-weight: 600;
}

/* 7. Perfil y acciones rápidas */
.profile-actions-card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}

.profile-actions-left {
  flex: 1 1 300px;
}

.profile-actions-right {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.profile-actions-right button {
  min-width: 180px;
}

/* 8. Guía clínica y sección educativa */
.educational-guide-section {
  padding: 2rem;
}

.guide-main-title {
  font-size: 1.5rem;
  margin-bottom: 1.5rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-color);
}

.guide-grid-2col {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 2rem;
  margin-bottom: 2rem;
}

.guide-subtitle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.1rem;
  color: var(--accent-cyan);
  margin-bottom: 0.85rem;
}

.guide-col p {
  color: var(--text-muted);
  font-size: 0.95rem;
}

.protocol-box {
  background-color: var(--bg-surface-elevated);
  border-left: 4px solid var(--accent-emerald);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  margin-bottom: 2rem;
}

.protocol-title {
  font-size: 1.05rem;
  color: var(--text-main);
  margin-bottom: 0.75rem;
}

.protocol-steps-list {
  margin: 0;
  padding-left: 1.25rem;
  color: var(--text-muted);
}

.protocol-steps-list li {
  margin-bottom: 0.6rem;
  line-height: 1.5;
}

.protocol-steps-list strong {
  color: var(--text-main);
}

/* Acordeón interactivo FAQ */
.faq-accordion-container {
  margin-top: 1.5rem;
}

.faq-section-title {
  font-size: 1.25rem;
  margin-bottom: 1rem;
}

.faq-items {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.faq-item {
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: border-color 0.15s ease;
}

.faq-item[open] {
  border-color: var(--accent-cyan);
}

.faq-question {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-main);
  cursor: pointer;
  list-style: none;
}

.faq-question::-webkit-details-marker {
  display: none;
}

.faq-chevron {
  color: var(--text-dim);
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.faq-item[open] .faq-chevron {
  transform: rotate(180deg);
  color: var(--accent-cyan);
}

.faq-answer {
  padding: 0 1.25rem 1.25rem;
  color: var(--text-muted);
  font-size: 0.92rem;
  line-height: 1.6;
}

/* 9. Ventanas modales accesibles */
.custom-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.custom-modal[hidden] {
  display: none !important;
}

.modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(3, 7, 18, 0.75);
  backdrop-filter: blur(4px);
}

.modal-dialog {
  position: relative;
  width: 100%;
  max-width: 620px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
  z-index: 1;
  display: flex;
  flex-direction: column;
  max-height: 90vh;
  overflow: hidden;
}

.modal-dialog-sm {
  max-width: 420px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
}

.modal-title-group {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--accent-cyan);
}

.modal-title {
  font-size: 1.15rem;
  margin: 0;
  color: var(--text-main);
}

.btn-close-modal {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  min-width: 40px;
  transition: color 0.15s ease, background-color 0.15s ease;
}

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

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1.25rem 1.5rem;
  border-top: 1px solid var(--border-color);
  background-color: var(--bg-surface-elevated);
}

/* Ficha del informe de acúfeno */
.report-card {
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.5rem;
}

.report-badge-bar {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  font-family: var(--font-mono);
  color: var(--text-dim);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px dashed var(--border-color);
}

.report-main-kpis {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
  text-align: center;
}

.report-kpi {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.75rem 0.5rem;
}

.report-kpi-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.report-kpi-value {
  display: block;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--accent-cyan);
}

.report-section-title {
  font-size: 0.95rem;
  color: var(--text-main);
  margin-bottom: 0.5rem;
}

.report-list {
  margin: 0 0 1.25rem 0;
  padding-left: 1.2rem;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.report-list li {
  margin-bottom: 0.4rem;
}

.report-list strong {
  color: var(--text-main);
}

.report-disclaimer {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 0.78rem;
  color: var(--text-dim);
  background-color: rgba(0, 0, 0, 0.2);
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-sm);
}

.report-disclaimer svg {
  flex-shrink: 0;
  margin-top: 1px;
}

/* 10. Responsive adaptativo móvil y tablet */
@media (max-width: 992px) {
  .modules-grid {
    grid-template-columns: 1fr;
  }

  .soundscapes-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .guide-grid-2col {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .fine-buttons-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 640px) {
  .tool-layout {
    margin: 1rem auto 2rem;
    padding: 0 0.75rem;
  }

  .card-panel {
    padding: 1.15rem;
  }

  .master-control-panel {
    flex-direction: column;
    align-items: stretch;
  }

  .master-left {
    flex-direction: column;
    align-items: stretch;
  }

  .btn-primary-audio {
    width: 100%;
  }

  .master-right {
    max-width: 100%;
  }

  .soundscapes-grid {
    grid-template-columns: 1fr;
  }

  .timer-flex {
    flex-direction: column;
    align-items: stretch;
  }

  .timer-presets-row {
    flex-direction: column;
  }

  .report-main-kpis {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }

  .profile-actions-right {
    width: 100%;
  }

  .profile-actions-right button {
    width: 100%;
  }

  .modal-footer {
    flex-direction: column;
  }

  .modal-footer button {
    width: 100%;
  }

  .freq-main-number {
    font-size: 2.2rem;
  }
}
