/* ==========================================================================
   Calculadora Científica en Línea - Sistema de Diseño Profesional
   100% en Español | Encaje Completo en el Primer Marco (Sin Scroll)
   Base Font Size: 10px (62.5%) | Alto Contraste WCAG AAA | Temas Oscuro y Claro
   ========================================================================== */

/* --------------------------------------------------------------------------
   Variables de Color y Tokens de Diseño
   -------------------------------------------------------------------------- */
:root {
  /* Paleta Tema Oscuro (Por defecto) */
  --bg-primary: #070a13;
  --bg-secondary: #0d1220;
  --bg-surface: #12192c;
  --bg-surface-glass: rgba(18, 25, 44, 0.88);
  --bg-surface-hover: #1b253f;
  --bg-display: #090e1b;
  --bg-display-input: rgba(4, 7, 15, 0.65);

  --border-color: rgba(255, 255, 255, 0.11);
  --border-highlight: rgba(56, 189, 248, 0.35);
  --border-focus: #38bdf8;

  /* Tipografías y Contrastes - Modo Oscuro */
  --text-title: #ffffff;
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  /* Botones del Teclado Científico */
  --btn-num-bg: #1c273c;
  --btn-num-hover: #293853;
  --btn-num-active: #151e30;
  --btn-num-text: #ffffff;

  --btn-sci-bg: #162035;
  --btn-sci-hover: #22304d;
  --btn-sci-active: #111a2d;
  --btn-sci-text: #7dd3fc;
  --btn-sci-border: rgba(56, 189, 248, 0.22);

  --btn-toolbar-bg: #141c2e;
  --btn-toolbar-hover: #1e2a44;
  --btn-toolbar-text: #94a3b8;

  --btn-op-gradient: linear-gradient(135deg, #0284c7, #0369a1);
  --btn-op-hover: linear-gradient(135deg, #38bdf8, #0284c7);
  --btn-op-text: #ffffff;

  --btn-equals-gradient: linear-gradient(135deg, #2563eb, #1d4ed8);
  --btn-equals-hover: linear-gradient(135deg, #3b82f6, #2563eb);
  --btn-equals-shadow: 0 0.4rem 1.8rem rgba(37, 99, 235, 0.45);
  --btn-equals-text: #ffffff;

  --btn-danger-gradient: linear-gradient(135deg, #ef4444, #b91c1c);
  --btn-danger-hover: linear-gradient(135deg, #f87171, #ef4444);
  --btn-danger-text: #ffffff;

  --btn-warning-gradient: linear-gradient(135deg, #f59e0b, #d97706);
  --btn-warning-hover: linear-gradient(135deg, #fbbf24, #f59e0b);
  --btn-warning-text: #ffffff;

  --btn-parenthesis-bg: #24324a;
  --btn-parenthesis-hover: #334464;
  --btn-parenthesis-text: #f1f5f9;

  /* Acentos Neón y Resaltados */
  --accent-cyan: #38bdf8;
  --accent-emerald: #10b981;
  --accent-blue: #3b82f6;
  --accent-amber: #f59e0b;

  /* Sombras */
  --shadow-sm: 0 0.1rem 0.3rem rgba(0, 0, 0, 0.3);
  --shadow-md: 0 0.4rem 1.4rem rgba(0, 0, 0, 0.4);
  --shadow-card: 0 1.2rem 3.8rem rgba(0, 0, 0, 0.55);

  /* Radios */
  --radius-sm: 0.7rem;
  --radius-md: 1.1rem;
  --radius-lg: 1.6rem;
  --radius-full: 999.9rem;

  /* Transiciones */
  --trans-fast: 0.12s cubic-bezier(0.4, 0, 0.2, 1);
  --trans-normal: 0.24s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --------------------------------------------------------------------------
   Paleta Tema Claro (Alto Contraste y Limpieza Visual)
   -------------------------------------------------------------------------- */
[data-theme="light"] {
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-surface: #ffffff;
  --bg-surface-glass: rgba(255, 255, 255, 0.94);
  --bg-surface-hover: #f1f5f9;
  --bg-display: #f8fafc;
  --bg-display-input: #ffffff;

  --border-color: #cbd5e1;
  --border-highlight: #3b82f6;
  --border-focus: #2563eb;

  /* Textos de Máximo Contraste - Modo Claro */
  --text-title: #090d16;
  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-muted: #475569;
  --text-dim: #64748b;

  --btn-num-bg: #ffffff;
  --btn-num-hover: #e2e8f0;
  --btn-num-active: #cbd5e1;
  --btn-num-text: #0f172a;

  --btn-sci-bg: #f1f5f9;
  --btn-sci-hover: #e2e8f0;
  --btn-sci-active: #cbd5e1;
  --btn-sci-text: #0369a1;
  --btn-sci-border: #cbd5e1;

  --btn-toolbar-bg: #f8fafc;
  --btn-toolbar-hover: #e2e8f0;
  --btn-toolbar-text: #475569;

  --btn-op-gradient: linear-gradient(135deg, #0284c7, #0369a1);
  --btn-op-hover: linear-gradient(135deg, #38bdf8, #0284c7);
  --btn-op-text: #ffffff;

  --btn-equals-gradient: linear-gradient(135deg, #2563eb, #1d4ed8);
  --btn-equals-hover: linear-gradient(135deg, #3b82f6, #2563eb);
  --btn-equals-shadow: 0 0.4rem 1.6rem rgba(37, 99, 235, 0.35);
  --btn-equals-text: #ffffff;

  --btn-danger-gradient: linear-gradient(135deg, #ef4444, #dc2626);
  --btn-danger-hover: linear-gradient(135deg, #f87171, #ef4444);
  --btn-danger-text: #ffffff;

  --btn-warning-gradient: linear-gradient(135deg, #f59e0b, #d97706);
  --btn-warning-hover: linear-gradient(135deg, #fbbf24, #f59e0b);
  --btn-warning-text: #ffffff;

  --btn-parenthesis-bg: #e2e8f0;
  --btn-parenthesis-hover: #cbd5e1;
  --btn-parenthesis-text: #0f172a;

  --shadow-sm: 0 0.1rem 0.3rem rgba(0, 0, 0, 0.08);
  --shadow-md: 0 0.4rem 1.4rem rgba(0, 0, 0, 0.1);
  --shadow-card: 0 1.2rem 3.5rem rgba(15, 23, 42, 0.12);
}

/* --------------------------------------------------------------------------
   Reset Global y Sistema REM Base (10px)
   -------------------------------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 62.5%; /* Base: 10px = 1rem */
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Outfit', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 1.6rem;
  line-height: 1.5;
  color: var(--text-primary);
  background-color: var(--bg-primary);
  background-image: 
    radial-gradient(at 15% 15%, rgba(56, 189, 248, 0.08) 0, transparent 40%),
    radial-gradient(at 85% 85%, rgba(37, 99, 235, 0.08) 0, transparent 40%);
  background-attachment: fixed;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  width: 100%;
  transition: background-color var(--trans-normal), color var(--trans-normal);
}

body.drawer-open {
  overflow: hidden;
}

/* --------------------------------------------------------------------------
   Barra de Navegación Fija y Compacta
   -------------------------------------------------------------------------- */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  background: var(--bg-surface-glass);
  border-bottom: 0.1rem solid var(--border-color);
  padding: 0.8rem 0;
  height: 5.2rem;
  width: 100%;
  display: flex;
  align-items: center;
  transition: background var(--trans-normal), border-color var(--trans-normal);
}

.nav-container {
  width: 100%;
  max-width: 116rem;
  margin: 0 auto;
  padding: 0 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.2rem;
}

.brand-wrapper {
  display: inline-flex;
  align-items: center;
  gap: 1rem;
  text-decoration: none;
  color: var(--text-title);
  user-select: none;
}

.brand-icon {
  width: 3.4rem;
  height: 3.4rem;
  background: linear-gradient(135deg, #2563eb, #0284c7);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  box-shadow: 0 0.3rem 1rem rgba(37, 99, 235, 0.35);
  flex-shrink: 0;
}

.brand-icon svg {
  width: 2rem;
  height: 2rem;
}

.brand-title-group {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.navbar-brand-text {
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-title);
}

.brand-domain {
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  border: 0.1rem solid rgba(56, 189, 248, 0.35);
  font-size: 1.15rem;
  font-weight: 700;
  padding: 0.15rem 0.65rem;
  border-radius: var(--radius-full);
  letter-spacing: 0.02em;
}

[data-theme="light"] .brand-domain {
  background: #e0f2fe;
  color: #0284c7;
  border-color: #7dd3fc;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 1.4rem;
}

.nav-simple-link {
  color: var(--text-muted);
  font-size: 1.4rem;
  font-weight: 500;
  text-decoration: none;
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-sm);
  letter-spacing: -0.01em;
  transition: all var(--trans-fast);
}

.nav-simple-link:hover,
.nav-simple-link.active {
  color: var(--text-title);
  background: rgba(255, 255, 255, 0.06);
}

[data-theme="light"] .nav-simple-link:hover,
[data-theme="light"] .nav-simple-link.active {
  color: #0284c7;
  background: rgba(2, 132, 199, 0.08);
}

.nav-controls {
  display: flex;
  align-items: center;
}

.control-btn {
  background: var(--bg-surface);
  border: 0.1rem solid var(--border-color);
  color: var(--text-title);
  width: 3.6rem;
  height: 3.6rem;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--trans-fast);
}

.control-btn:hover {
  background-color: var(--bg-surface-hover);
  border-color: var(--border-highlight);
  transform: translateY(-0.1rem);
}

.control-btn svg {
  width: 1.8rem;
  height: 1.8rem;
}

/* ==========================================================================
   PRIMER MARCO DE PANTALLA (HERO VIEWPORT)
   100% visible sin necesidad de scroll vertical
   ========================================================================== */
.calc-hero-viewport {
  min-height: calc(100vh - 5.2rem);
  min-height: calc(100dvh - 5.2rem);
  max-height: calc(100vh - 5.2rem);
  max-height: calc(100dvh - 5.2rem);
  height: calc(100dvh - 5.2rem);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding: 0.8rem 1.6rem 0.6rem;
  box-sizing: border-box;
  overflow: hidden;
  position: relative;
  width: 100%;
}

.calc-hero-header {
  text-align: center;
  flex-shrink: 0;
  margin-bottom: 0.4rem;
}

.badge-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.35rem 1.2rem;
  border-radius: var(--radius-full);
  background: rgba(56, 189, 248, 0.12);
  border: 0.1rem solid rgba(56, 189, 248, 0.35);
  color: #38bdf8;
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 0.3rem;
}

[data-theme="light"] .badge-tag {
  background: #e0f2fe;
  border-color: #7dd3fc;
  color: #0369a1;
}

.badge-dot {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  background-color: #38bdf8;
  box-shadow: 0 0 0.8rem #38bdf8;
}

[data-theme="light"] .badge-dot {
  background-color: #0284c7;
  box-shadow: 0 0 0.8rem #0284c7;
}

.hero-title {
  font-size: clamp(1.8rem, 2.4vw, 2.6rem);
  font-weight: 800;
  letter-spacing: -0.025em;
  color: var(--text-title);
  line-height: 1.15;
  margin-bottom: 0;
}

/* --------------------------------------------------------------------------
   Tarjeta Principal de la Calculadora Científica
   -------------------------------------------------------------------------- */
.calc-card {
  width: 100%;
  max-width: 78rem;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  flex-shrink: 1;
  background: var(--bg-surface-glass);
  border: 0.1rem solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  transition: border-color var(--trans-normal), box-shadow var(--trans-normal);
}

/* Cabecera de la Tarjeta */
.card-header-styled {
  padding: 0.7rem 1.4rem;
  border-bottom: 0.1rem solid var(--border-color);
  background: rgba(0, 0, 0, 0.14);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-shrink: 0;
}

[data-theme="light"] .card-header-styled {
  background: rgba(0, 0, 0, 0.025);
}

.header-modes-group {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.chip-mode {
  background: rgba(255, 255, 255, 0.06);
  border: 0.1rem solid var(--border-color);
  color: var(--text-secondary);
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.2rem;
  font-weight: 700;
  padding: 0.35rem 0.9rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--trans-fast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.chip-mode:hover {
  background: var(--bg-surface-hover);
  color: var(--accent-cyan);
  border-color: var(--border-highlight);
}

.chip-mode.is-active {
  background: linear-gradient(135deg, #0284c7, #2563eb);
  color: #ffffff;
  border-color: transparent;
  box-shadow: 0 0.2rem 0.8rem rgba(2, 132, 199, 0.45);
}

.chip-mem {
  background: rgba(16, 185, 129, 0.15);
  border-color: rgba(16, 185, 129, 0.4);
  color: #34d399;
  cursor: default;
}

.screen-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.btn-screen-action {
  background: rgba(255, 255, 255, 0.06);
  border: 0.1rem solid var(--border-color);
  color: var(--text-primary);
  font-size: 1.25rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 1rem;
  border-radius: var(--radius-sm);
  transition: all var(--trans-fast);
}

.btn-screen-action:hover {
  background: var(--bg-surface-hover);
  color: var(--accent-cyan);
  border-color: var(--border-highlight);
  transform: translateY(-0.1rem);
}

.btn-history-action:hover {
  color: #a78bfa;
  border-color: rgba(167, 139, 250, 0.4);
}

/* Pantalla Digital de la Calculadora */
.calc-screen {
  padding: 0.8rem 1.4rem;
  background: var(--bg-display);
  border-bottom: 0.1rem solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  flex-shrink: 0;
}

.screen-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 1.15rem;
  color: var(--text-muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.screen-status-chips {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.screen-status-chip {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1rem;
  font-weight: 800;
  padding: 0.1rem 0.5rem;
  border-radius: 0.4rem;
  background: rgba(56, 189, 248, 0.12);
  color: #38bdf8;
  border: 0.1rem solid rgba(56, 189, 248, 0.3);
}

.screen-status-chip-2nd {
  background: rgba(167, 139, 250, 0.15);
  color: #c084fc;
  border-color: rgba(167, 139, 250, 0.35);
}

.screen-inputs {
  display: flex;
  align-items: center;
  background: var(--bg-display-input);
  border: 0.1rem solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.6rem 1.2rem;
  min-height: clamp(4.4rem, 6.2vh, 5.6rem);
  transition: border-color var(--trans-fast), box-shadow var(--trans-fast);
}

[data-theme="light"] .screen-inputs {
  background: #ffffff;
  border-color: #cbd5e1;
}

.screen-inputs:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 0.25rem rgba(56, 189, 248, 0.2);
}

.calc-input-expr {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-title);
  font-size: clamp(1.6rem, 2.2vw, 2.2rem);
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  text-align: right;
  outline: none;
  width: 60%;
  letter-spacing: 0.02em;
  min-width: 0;
}

.screen-divider {
  width: 0.1rem;
  height: 2.8rem;
  background-color: var(--border-color);
  margin: 0 0.8rem;
  flex-shrink: 0;
}

.calc-input-res {
  width: 40%;
  background: transparent;
  border: none;
  color: var(--accent-cyan);
  font-size: clamp(1.8rem, 2.6vw, 2.6rem);
  font-family: 'JetBrains Mono', monospace;
  font-weight: 800;
  text-align: right;
  outline: none;
  cursor: pointer;
  min-width: 0;
}

[data-theme="light"] .calc-input-res {
  color: #0284c7;
}

/* Barra de Memoria y Funciones Auxiliares */
.calc-toolbar-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: clamp(0.4rem, 0.8vw, 0.8rem);
  padding: 0.6rem 1.4rem 0.4rem;
  background: rgba(0, 0, 0, 0.08);
  border-bottom: 0.1rem solid var(--border-color);
  flex-shrink: 0;
}

[data-theme="light"] .calc-toolbar-row {
  background: rgba(0, 0, 0, 0.015);
}

.toolbar-btn {
  height: clamp(2.8rem, 3.8vh, 3.3rem);
  font-family: 'JetBrains Mono', monospace;
  font-size: clamp(1.15rem, 1.4vw, 1.35rem);
  font-weight: 700;
  background: var(--btn-toolbar-bg);
  color: var(--btn-toolbar-text);
  border: 0.1rem solid var(--border-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  transition: all var(--trans-fast);
}

.toolbar-btn:hover {
  background: var(--btn-toolbar-hover);
  color: var(--accent-cyan);
  border-color: var(--border-highlight);
}

.toolbar-btn:active, .toolbar-btn.is-pressed {
  transform: scale(0.95);
}

/* --------------------------------------------------------------------------
   Teclado Científico Profesional (7 Columnas x 5 Filas)
   -------------------------------------------------------------------------- */
.calc-keypad {
  padding: 0.8rem 1.4rem 1rem;
  display: flex;
  flex-direction: column;
  gap: clamp(0.4rem, 0.9vh, 0.75rem);
  flex-shrink: 1;
}

.keypad-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: clamp(0.4rem, 0.8vw, 0.8rem);
}

.calc-btn {
  height: clamp(3.8rem, 5.4vh, 5.2rem);
  font-size: clamp(1.4rem, 1.8vw, 1.95rem);
  font-weight: 700;
  border-radius: clamp(0.6rem, 1vw, 0.9rem);
  border: 0.1rem solid var(--border-color);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  -webkit-user-select: none;
  transition: transform 0.08s ease, filter 0.12s ease, box-shadow 0.12s ease;
}

.calc-btn:hover {
  transform: translateY(-0.15rem);
  filter: brightness(1.1);
}

.calc-btn:active, .calc-btn.is-pressed {
  transform: scale(0.95) translateY(0.1rem);
  filter: brightness(0.92);
}

.calc-btn svg {
  width: 1.8rem;
  height: 1.8rem;
}

/* Estilos de botones por función */
.btn-num {
  background: var(--btn-num-bg);
  color: var(--btn-num-text);
  box-shadow: var(--shadow-sm);
  font-family: 'JetBrains Mono', monospace;
  font-size: clamp(1.6rem, 2vw, 2.1rem);
}

.btn-sci {
  background: var(--btn-sci-bg);
  color: var(--btn-sci-text);
  border-color: var(--btn-sci-border);
  font-family: 'JetBrains Mono', monospace;
  font-size: clamp(1.25rem, 1.5vw, 1.6rem);
}

.btn-sci:hover {
  border-color: var(--accent-cyan);
}

.btn-parenthesis {
  background: var(--btn-parenthesis-bg);
  color: var(--btn-parenthesis-text);
  font-family: 'JetBrains Mono', monospace;
}

.btn-operator {
  background: var(--btn-op-gradient);
  color: var(--btn-op-text);
  border: none;
  font-size: clamp(1.8rem, 2.2vw, 2.4rem);
  font-weight: 800;
}

.btn-equals {
  background: var(--btn-equals-gradient);
  color: var(--btn-equals-text);
  border: none;
  font-size: clamp(2rem, 2.4vw, 2.6rem);
  font-weight: 800;
  box-shadow: var(--btn-equals-shadow);
}

.btn-clear {
  background: var(--btn-danger-gradient);
  color: var(--btn-danger-text);
  border: none;
  font-weight: 800;
}

.btn-delete {
  background: var(--btn-warning-gradient);
  color: var(--btn-warning-text);
  border: none;
}

/* Indicador Sutil hacia el Contenido Educativo */
.scroll-hint-link {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--text-muted);
  font-size: 1.25rem;
  font-weight: 600;
  text-decoration: none;
  padding: 0.3rem 1.2rem;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.04);
  border: 0.1rem solid var(--border-color);
  flex-shrink: 0;
  margin-top: 0.4rem;
  transition: all var(--trans-fast);
}

.scroll-hint-link:hover {
  color: var(--accent-cyan);
  border-color: var(--border-highlight);
  background: rgba(56, 189, 248, 0.08);
  transform: translateY(0.15rem);
}

.scroll-hint-link svg {
  animation: bounceHint 2s infinite;
}

@keyframes bounceHint {
  0%, 20%, 50%, 80%, 100% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(0.3rem);
  }
  60% {
    transform: translateY(0.15rem);
  }
}

/* ==========================================================================
   PANEL LATERAL DESLIZANTE DE HISTORIAL (DRAWER)
   ========================================================================== */
.history-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 1040;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.history-backdrop.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.history-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(44rem, 92vw);
  background: var(--bg-surface);
  border-left: 0.1rem solid var(--border-color);
  box-shadow: -0.8rem 0 3.2rem rgba(0, 0, 0, 0.5);
  z-index: 1050;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1);
}

.history-drawer.is-open {
  transform: translateX(0);
}

.drawer-header {
  padding: 1.6rem 2rem;
  border-bottom: 0.1rem solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(0, 0, 0, 0.08);
}

.drawer-title-group {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  color: var(--text-title);
}

.drawer-title-group svg {
  color: var(--accent-cyan);
}

.drawer-title {
  font-size: 1.7rem;
  font-weight: 800;
  margin: 0;
  color: var(--text-title);
}

.drawer-close-btn {
  background: transparent;
  border: 0.1rem solid var(--border-color);
  color: var(--text-muted);
  width: 3.2rem;
  height: 3.2rem;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--trans-fast);
}

.drawer-close-btn:hover {
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.4);
  background: rgba(239, 68, 68, 0.1);
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.6rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.drawer-body::-webkit-scrollbar {
  width: 0.6rem;
}

.drawer-body::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: var(--radius-full);
}

.history-item {
  background: var(--bg-display);
  border: 0.1rem solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.2rem 1.4rem;
  cursor: pointer;
  transition: all var(--trans-fast);
}

.history-item:hover {
  border-color: var(--border-highlight);
  background: var(--bg-surface-hover);
  transform: translateY(-0.15rem);
  box-shadow: var(--shadow-sm);
}

.history-item-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.4rem;
  gap: 0.8rem;
}

.history-time {
  font-size: 1.15rem;
  color: var(--text-dim);
  font-family: 'JetBrains Mono', monospace;
}

.history-calc-text {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.4rem;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  text-align: right;
}

.history-calc-result {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.7rem;
  font-weight: 800;
  color: var(--accent-cyan);
  text-align: right;
}

[data-theme="light"] .history-calc-result {
  color: #0284c7;
}

.history-empty {
  text-align: center;
  padding: 4rem 1rem;
  color: var(--text-dim);
  font-size: 1.45rem;
  font-style: italic;
}

.drawer-footer {
  padding: 1.4rem 2rem;
  border-top: 0.1rem solid var(--border-color);
  background: rgba(0, 0, 0, 0.08);
  display: flex;
  justify-content: flex-end;
}

.btn-clear-history {
  background: transparent;
  border: 0.1rem solid var(--border-color);
  color: var(--text-muted);
  font-size: 1.3rem;
  font-weight: 600;
  padding: 0.6rem 1.2rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  transition: all var(--trans-fast);
}

.btn-clear-history:hover {
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.4);
  background: rgba(239, 68, 68, 0.1);
}

/* ==========================================================================
   SECCIONES DE CONTENIDO COMPLEMENTARIO (BAJO EL PRIMER MARCO)
   ========================================================================== */
.main-wrapper {
  width: 100%;
  max-width: 116rem;
  margin: 0 auto;
  padding: 4rem 2rem 5rem;
  display: flex;
  flex-direction: column;
  gap: 3.5rem;
}

.content-card {
  padding: 2.8rem;
}

.content-header-bar {
  margin-bottom: 2.4rem;
  border-bottom: 0.1rem solid var(--border-color);
  padding-bottom: 1.6rem;
}

.content-section-title {
  font-size: clamp(2rem, 3.2vw, 2.5rem);
  font-weight: 800;
  margin-bottom: 0.6rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  color: var(--text-title);
  letter-spacing: -0.02em;
}

.content-section-title svg {
  color: var(--accent-cyan);
  width: 2.4rem;
  height: 2.4rem;
}

.content-section-subtitle {
  color: var(--text-muted);
  font-size: 1.5rem;
  margin-bottom: 0;
}

/* Cuadrícula de Funciones Científicas */
.features-grid-styled {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(30rem, 1fr));
  gap: 1.8rem;
}

.feature-box {
  padding: 2rem;
  background: var(--bg-display);
  border: 0.1rem solid var(--border-color);
  border-radius: var(--radius-md);
  transition: all var(--trans-fast);
}

.feature-box:hover {
  border-color: var(--border-highlight);
  transform: translateY(-0.2rem);
}

.feature-box-icon {
  width: 4rem;
  height: 4rem;
  border-radius: var(--radius-sm);
  background: rgba(56, 189, 248, 0.12);
  border: 0.1rem solid rgba(56, 189, 248, 0.3);
  color: var(--accent-cyan);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.2rem;
}

.feature-box-title {
  font-size: 1.7rem;
  font-weight: 700;
  margin-bottom: 0.8rem;
  color: var(--text-title);
}

.feature-box-desc {
  font-size: 1.45rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 0;
}

.feature-box-desc code {
  background: var(--bg-surface);
  border: 0.1rem solid var(--border-color);
  padding: 0.2rem 0.6rem;
  border-radius: 0.4rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.3rem;
  color: var(--accent-cyan);
}

/* Tabla de Atajos de Teclado */
.shortcuts-table-wrapper {
  overflow-x: auto;
}

.shortcuts-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 1.45rem;
  text-align: left;
}

.shortcuts-table th {
  padding: 1.2rem 1.6rem;
  background: var(--bg-display);
  color: var(--text-title);
  font-weight: 700;
  border-bottom: 0.2rem solid var(--border-color);
}

.shortcuts-table td {
  padding: 1.2rem 1.6rem;
  border-bottom: 0.1rem solid var(--border-color);
  color: var(--text-secondary);
}

.shortcuts-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.shortcuts-table kbd {
  background: var(--bg-surface-hover);
  border: 0.1rem solid var(--border-color);
  padding: 0.3rem 0.8rem;
  border-radius: 0.5rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-title);
  box-shadow: var(--shadow-sm);
  display: inline-block;
  margin: 0.1rem;
}

.shortcuts-table code {
  color: var(--accent-cyan);
  font-family: 'JetBrains Mono', monospace;
}

/* Preguntas Frecuentes (FAQ) */
.faq-section {
  padding: 2.8rem;
}

.faq-header-bar {
  margin-bottom: 2.2rem;
  border-bottom: 0.1rem solid var(--border-color);
  padding-bottom: 1.6rem;
}

.faq-title {
  font-size: clamp(2rem, 3.2vw, 2.5rem);
  font-weight: 800;
  margin-bottom: 0.4rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  color: var(--text-title);
  letter-spacing: -0.02em;
}

.faq-title svg {
  color: var(--accent-cyan);
  width: 2.4rem;
  height: 2.4rem;
}

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

.faq-accordion {
  display: flex;
  flex-direction: column;
  gap: 1.4rem;
}

.faq-item {
  background: var(--bg-display);
  border: 0.1rem solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: all var(--trans-normal);
}

.faq-item:hover {
  border-color: var(--border-highlight);
}

.faq-item.is-open {
  border-color: var(--border-highlight);
  background: rgba(18, 25, 44, 0.65);
  box-shadow: 0 0.6rem 2.4rem rgba(0, 0, 0, 0.28);
}

[data-theme="light"] .faq-item {
  background: #f8fafc;
}

[data-theme="light"] .faq-item.is-open {
  background: #ffffff;
  box-shadow: 0 0.6rem 2rem rgba(2, 132, 199, 0.1);
}

.faq-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.4rem;
  padding: 1.8rem 2.2rem;
  background: transparent;
  border: none;
  cursor: pointer;
  text-align: left;
  color: var(--text-title);
  transition: background-color var(--trans-fast);
  outline: none;
}

.faq-trigger:hover {
  background: rgba(255, 255, 255, 0.03);
}

.faq-trigger-content {
  display: flex;
  align-items: center;
  gap: 1.4rem;
  flex: 1;
}

.faq-q-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3.2rem;
  height: 3.2rem;
  background: rgba(56, 189, 248, 0.15);
  color: var(--accent-cyan);
  border: 0.1rem solid rgba(56, 189, 248, 0.35);
  border-radius: 50%;
  font-size: 1.4rem;
  font-weight: 800;
  flex-shrink: 0;
}

.faq-item.is-open .faq-q-badge {
  background: linear-gradient(135deg, #0284c7, #2563eb);
  color: #ffffff;
  border-color: transparent;
}

.faq-q-text {
  font-size: 1.65rem;
  font-weight: 700;
  line-height: 1.4;
  color: var(--text-title);
}

.faq-chevron-icon {
  width: 3.2rem;
  height: 3.2rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  flex-shrink: 0;
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.faq-item.is-open .faq-chevron-icon {
  transform: rotate(180deg);
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.2);
}

.faq-collapse {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.faq-item.is-open .faq-collapse {
  grid-template-rows: 1fr;
}

.faq-collapse-inner {
  overflow: hidden;
  opacity: 0;
  transform: translateY(-0.8rem);
  transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  padding: 0 2.2rem 0 6.8rem;
}

.faq-item.is-open .faq-collapse-inner {
  opacity: 1;
  transform: translateY(0);
  padding: 0.4rem 2.2rem 2.4rem 6.8rem;
}

.faq-collapse-inner p {
  color: var(--text-secondary);
  font-size: 1.5rem;
  line-height: 1.7;
  margin-bottom: 1rem;
}

.faq-collapse-inner p:last-child {
  margin-bottom: 0;
}

.faq-collapse-inner em {
  color: var(--accent-cyan);
  font-style: normal;
  font-weight: 600;
}

.faq-collapse-inner strong {
  color: var(--text-title);
}

.faq-list {
  list-style: none;
  padding: 0;
  margin: 1rem 0 0;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.faq-list li {
  color: var(--text-secondary);
  font-size: 1.45rem;
}

.faq-list code {
  color: var(--accent-cyan);
  font-family: 'JetBrains Mono', monospace;
  background: var(--bg-surface);
  padding: 0.2rem 0.5rem;
  border-radius: 0.4rem;
}

/* --------------------------------------------------------------------------
   Pie de Página (Footer)
   -------------------------------------------------------------------------- */
.footer-styled {
  margin-top: auto;
  padding: 3.5rem 2rem 2.5rem;
  border-top: 0.1rem solid var(--border-color);
  background: var(--bg-secondary);
  text-align: center;
}

.footer-content {
  max-width: 80rem;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.2rem;
}

.footer-brand {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  font-weight: 800;
  font-size: 1.7rem;
  color: var(--text-title);
  text-decoration: none;
}

.footer-text {
  font-size: 1.4rem;
  color: var(--text-muted);
}

.footer-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.8rem;
}

.footer-badge {
  font-size: 1.25rem;
  padding: 0.3rem 1rem;
  background: var(--bg-surface);
  border: 0.1rem solid var(--border-color);
  border-radius: var(--radius-full);
  color: var(--text-muted);
}

/* --------------------------------------------------------------------------
   Notificación Toast
   -------------------------------------------------------------------------- */
.toast-notice {
  position: fixed;
  bottom: 2.4rem;
  right: 2.4rem;
  background: #1e293b;
  color: #ffffff;
  border: 0.1rem solid #334155;
  padding: 1rem 1.8rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  display: flex;
  align-items: center;
  gap: 0.8rem;
  font-size: 1.4rem;
  font-weight: 600;
  z-index: 9999;
  transform: translateY(8rem);
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast-notice.show {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.toast-notice svg {
  color: var(--accent-emerald);
  width: 1.8rem;
  height: 1.8rem;
}

/* --------------------------------------------------------------------------
   RESPONSIVIDAD INTEGRAL
   Móvil, Tablet y Pantallas Pequeñas
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
  .nav-links {
    display: none; /* En móvil dejamos solo logo y selector de tema */
  }

  .calc-hero-viewport {
    padding: 0.6rem 1rem 0.4rem;
  }

  .content-card, .faq-section {
    padding: 2rem 1.6rem;
  }

  .faq-collapse-inner {
    padding-left: 2rem;
  }

  .faq-item.is-open .faq-collapse-inner {
    padding-left: 2rem;
  }
}

@media (max-width: 480px) {
  .calc-hero-viewport {
    padding: 0.4rem 0.6rem 0.3rem;
  }

  .calc-card {
    border-radius: 1.2rem;
  }

  .card-header-styled {
    padding: 0.5rem 0.8rem;
  }

  .chip-mode {
    font-size: 1.1rem;
    padding: 0.3rem 0.6rem;
  }

  .btn-screen-action {
    font-size: 1.15rem;
    padding: 0.35rem 0.75rem;
  }

  .calc-screen {
    padding: 0.6rem 0.8rem;
  }

  .screen-inputs {
    padding: 0.4rem 0.8rem;
    min-height: 4.4rem;
  }

  .calc-toolbar-row {
    padding: 0.4rem 0.8rem 0.3rem;
    gap: 0.35rem;
  }

  .toolbar-btn {
    height: 2.8rem;
    font-size: 1.1rem;
  }

  .calc-keypad {
    padding: 0.6rem 0.8rem 0.8rem;
    gap: 0.4rem;
  }

  .keypad-row {
    gap: 0.4rem;
  }

  .calc-btn {
    height: clamp(3.6rem, 5.2vh, 4.4rem);
    font-size: 1.4rem;
    border-radius: 0.6rem;
  }

  .btn-num {
    font-size: 1.6rem;
  }

  .btn-sci {
    font-size: 1.2rem;
  }

  .scroll-hint-link {
    font-size: 1.15rem;
    padding: 0.25rem 0.9rem;
    margin-top: 0.2rem;
  }

  .toast-notice {
    bottom: 1.4rem;
    right: 1.4rem;
    left: 1.4rem;
    justify-content: center;
  }
}

/* En pantallas con poca altura vertical (ej. laptops chicas o modo horizontal) */
@media (max-height: 580px) {
  .calc-hero-viewport {
    height: auto;
    min-height: auto;
    max-height: none;
    overflow: visible;
    padding: 0.8rem 1rem;
  }
}
