/* ==========================================================================
   Calculadora Científica y Graficadora 2D - Fijate Tools
   Diseño Hardware Hiperrealista Prémium • Estilo FX-991 Matrix & Studio Grade
   ========================================================================== */

:root,
[data-theme="dark"] {
  color-scheme: dark;
  --bg-page: #060910;
  --bg-surface: #0b111e;
  --bg-card: #0f172a;
  --bg-card-hover: #172238;
  --bg-input: #070d17;
  --border-color: rgba(255, 255, 255, 0.08);
  --border-color-focus: #00e5ff;
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  
  --accent-cyan: #00e5ff;
  --accent-cyan-rgb: 0, 229, 255;
  --accent-amber: #ff9d00;
  --accent-amber-rgb: 255, 157, 0;
  --accent-emerald: #10b981;
  --accent-emerald-rgb: 16, 185, 129;
  --accent-rose: #f43f5e;
  
  /* Paleta de Teclas Físicas 3D */
  --chassis-bg: linear-gradient(180deg, #1b263b 0%, #101927 40%, #0a101a 100%);
  --chassis-border: #2d3b55;
  --chassis-shadow: 0 30px 60px -15px rgba(0, 0, 0, 0.9), 0 10px 25px -5px rgba(0, 0, 0, 0.7), inset 0 1px 1px rgba(255, 255, 255, 0.2);
  
  --screen-bezel: linear-gradient(180deg, #090e17 0%, #05080e 100%);
  --screen-glass-bg: #03070d;
  --screen-text: #e2f1ff;
  --screen-text-glow: 0 0 12px rgba(0, 229, 255, 0.35);
  
  --key-num-bg: linear-gradient(180deg, #243044 0%, #162030 100%);
  --key-num-border: #334460;
  --key-num-shadow: #090e17;
  --key-num-text: #ffffff;
  
  --key-fn-bg: linear-gradient(180deg, #162030 0%, #0d1522 100%);
  --key-fn-border: #223048;
  --key-fn-shadow: #050a12;
  --key-fn-text: #94a3b8;
  
  --key-op-bg: linear-gradient(180deg, #1f2b3e 0%, #131c2a 100%);
  --key-op-border: #2c3e5a;
  --key-op-shadow: #080d15;
  --key-op-text: #00e5ff;
  
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-heading: 'Outfit', 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

[data-theme="light"] {
  color-scheme: light;
  --bg-page: #e8edf3;
  --bg-surface: #ffffff;
  --bg-card: #f8fafc;
  --bg-card-hover: #ffffff;
  --bg-input: #f1f5f9;
  --border-color: #cbd5e1;
  --border-color-focus: #0284c7;
  
  --text-main: #0f172a;
  --text-muted: #475569;
  --text-dim: #64748b;
  
  --accent-cyan: #0284c7;
  --accent-cyan-rgb: 2, 132, 199;
  --accent-amber: #d97706;
  --accent-amber-rgb: 217, 119, 6;
  --accent-emerald: #059669;
  --accent-emerald-rgb: 5, 150, 105;
  --accent-rose: #e11d48;
  
  --chassis-bg: linear-gradient(180deg, #dbe4ee 0%, #c8d5e5 50%, #b8c7da 100%);
  --chassis-border: #a8bcd3;
  --chassis-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.25), inset 0 1px 2px rgba(255, 255, 255, 0.8);
  
  --screen-bezel: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
  --screen-glass-bg: #090e17;
  --screen-text: #e2f1ff;
  --screen-text-glow: 0 0 10px rgba(2, 132, 199, 0.3);
  
  --key-num-bg: linear-gradient(180deg, #ffffff 0%, #e2e8f0 100%);
  --key-num-border: #cbd5e1;
  --key-num-shadow: #94a3b8;
  --key-num-text: #0f172a;
  
  --key-fn-bg: linear-gradient(180deg, #f1f5f9 0%, #cbd5e1 100%);
  --key-fn-border: #94a3b8;
  --key-fn-shadow: #64748b;
  --key-fn-text: #334155;
  
  --key-op-bg: linear-gradient(180deg, #e2e8f0 0%, #cbd5e1 100%);
  --key-op-border: #94a3b8;
  --key-op-shadow: #64748b;
  --key-op-text: #0284c7;
}

/* Reset y Base */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-page);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: clip;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, .brand-title, .card-section-title {
  font-family: var(--font-heading);
  font-weight: 700;
  line-height: 1.25;
}

/* Layout Centrado */
.main-wrapper {
  width: 100% !important;
  max-width: 1320px !important;
  margin: 0 auto !important;
  padding: 24px 16px 40px;
  flex: 1;
  box-sizing: border-box;
}

.tool-with-sidebar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 24px;
  align-items: start;
  width: 100%;
}

.tool-main-content {
  min-width: 0;
  width: 100%;
}

/* Publicidad */
.tools-ad-banner-section {
  margin-bottom: 20px;
  width: 100%;
}

.ad-banner-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.ad-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  margin-bottom: 4px;
}

.ad-banner-card {
  width: 100%;
  min-height: 90px;
  background: var(--bg-card);
  border: 1px dashed var(--border-color);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tool-ad-sidebar {
  width: 300px;
  height: auto;
  align-self: stretch;
}

.ad-sticky-box {
  position: sticky;
  top: 85px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.ad-unit-card {
  width: 300px;
  min-height: 600px;
  background: var(--bg-card);
  border: 1px dashed var(--border-color);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Hero */
.tool-hero {
  margin-bottom: 24px;
}

.tool-hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 9999px;
  background: rgba(var(--accent-cyan-rgb), 0.12);
  color: var(--accent-cyan);
  border: 1px solid rgba(var(--accent-cyan-rgb), 0.25);
  font-size: 0.78rem;
  font-weight: 600;
  margin-bottom: 12px;
}

.tool-hero h2 {
  font-size: 1.75rem;
  color: var(--text-main);
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}

.tool-hero p {
  color: var(--text-muted);
  font-size: 0.98rem;
  max-width: 780px;
}

/* Pestañas */
.tool-nav-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 12px;
  margin-bottom: 20px;
  scrollbar-width: thin;
}

.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
  min-height: 42px;
  user-select: none;
}

.tab-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-main);
  border-color: rgba(var(--accent-cyan-rgb), 0.3);
}

.tab-btn.active {
  background: linear-gradient(135deg, rgba(var(--accent-cyan-rgb), 0.15), rgba(var(--accent-cyan-rgb), 0.05));
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
  box-shadow: 0 0 16px rgba(var(--accent-cyan-rgb), 0.15);
}

.tab-panel {
  display: none;
}

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

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

/* ==========================================================================
   CHASIS HARDWARE REALISTA (FX-991 MATRIX)
   ========================================================================== */
.calc-hardware-chassis {
  position: relative;
  background: var(--chassis-bg);
  border: 2px solid var(--chassis-border);
  border-radius: 24px;
  padding: 24px 22px 28px;
  box-shadow: var(--chassis-shadow);
  max-width: 620px;
  margin: 0 auto 30px;
  user-select: none;
}

/* Tornillos de acero en las 4 esquinas */
.hardware-screw {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: radial-gradient(circle, #94a3b8 20%, #475569 80%, #1e293b 100%);
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.6), 0 1px 2px rgba(0, 0, 0, 0.6);
}

.hardware-screw::after {
  content: '';
  position: absolute;
  top: 4px;
  left: 2px;
  width: 6px;
  height: 2px;
  background: #0f172a;
  transform: rotate(45deg);
}

.hardware-screw.top-left { top: 12px; left: 12px; }
.hardware-screw.top-right { top: 12px; right: 12px; }
.hardware-screw.bottom-left { bottom: 12px; left: 12px; }
.hardware-screw.bottom-right { bottom: 12px; right: 12px; }

/* Placa de Marca y Celda Solar */
.calc-hardware-brandplate {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  padding: 0 4px;
}

.brand-badge-metallic {
  display: flex;
  flex-direction: column;
}

.brand-main-name {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--text-main);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

.brand-model-code {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--accent-amber);
}

.brand-tech-desc {
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--text-dim);
}

/* Celda Solar Fotovoltaica Realista */
.solar-panel-realistic {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 2px;
  width: 120px;
  height: 28px;
  background: #060b14;
  border: 1.5px solid #2a3b52;
  border-radius: 4px;
  padding: 2px;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.8), 0 1px 2px rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

.solar-grid-cell {
  background: linear-gradient(135deg, #1a1e36 0%, #0d1326 50%, #15223d 100%);
  border-radius: 1px;
  border: 0.5px solid rgba(0, 229, 255, 0.15);
}

/* Barra de Modos de la Calculadora */
.calc-hardware-subbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.angle-mode-group,
.format-mode-group {
  display: inline-flex;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  padding: 2px;
  gap: 2px;
}

.angle-btn,
.format-btn {
  background: transparent;
  border: none;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.15s ease;
}

.angle-btn.active,
.format-btn.active {
  background: #1e293b;
  color: var(--accent-cyan);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.btn-toggle-history {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-toggle-history:hover {
  background: #1e293b;
  color: var(--text-main);
}

/* Bisel de Cristal de la Pantalla LCD */
.calc-screen-glass-bezel {
  position: relative;
  background: var(--screen-bezel);
  border: 2px solid #1a2538;
  border-radius: 12px;
  padding: 12px 16px 14px;
  box-shadow: inset 0 3px 8px rgba(0, 0, 0, 0.9), 0 2px 4px rgba(255, 255, 255, 0.05);
  margin-bottom: 16px;
  overflow: hidden;
}

.screen-glass-glare {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 45%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.08) 0%, rgba(255, 255, 255, 0.01) 80%, transparent 100%);
  pointer-events: none;
  border-top-left-radius: 10px;
  border-top-right-radius: 10px;
}

/* Barra de Estado LCD HUD */
.lcd-status-hud {
  display: flex;
  gap: 8px;
  margin-bottom: 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 4px;
}

.lcd-badge,
.lcd-badge-shift,
.lcd-badge-mem,
.lcd-badge-dim {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.15);
  padding: 1px 4px;
  border-radius: 2px;
}

.lcd-badge.active {
  color: var(--screen-text);
  background: rgba(var(--accent-cyan-rgb), 0.15);
  text-shadow: 0 0 6px var(--accent-cyan);
}

.lcd-badge-shift.active {
  color: var(--accent-amber);
  background: rgba(var(--accent-amber-rgb), 0.2);
  text-shadow: 0 0 6px var(--accent-amber);
}

.lcd-badge-mem.active {
  color: var(--accent-emerald);
  background: rgba(var(--accent-emerald-rgb), 0.2);
  text-shadow: 0 0 6px var(--accent-emerald);
}

/* Pantalla interna */
.calc-display-screen {
  display: flex;
  flex-direction: column;
}

.calc-history-prev {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  color: #7dd3fc;
  min-height: 24px;
  text-align: right;
  word-break: break-all;
  white-space: nowrap;
  overflow-x: auto;
  letter-spacing: 0.02em;
}

.calc-main-result-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin: 2px 0;
}

.calc-equal-sign {
  font-family: var(--font-mono);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--accent-cyan);
  text-shadow: var(--screen-text-glow);
}

.calc-result-input {
  flex: 1;
  background: transparent;
  border: none;
  font-family: var(--font-mono);
  font-size: 2.35rem;
  font-weight: 800;
  color: var(--screen-text);
  text-align: right;
  outline: none;
  min-width: 0;
  text-shadow: var(--screen-text-glow);
  letter-spacing: -0.02em;
}

.btn-copy-result {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-muted);
  border-radius: 6px;
  padding: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-copy-result:hover {
  background: var(--accent-cyan);
  color: #000000;
}

.calc-secondary-info {
  font-size: 0.75rem;
  color: #64748b;
  text-align: right;
  font-family: var(--font-mono);
  margin-top: 4px;
}

/* Historial desplegable */
.calc-history-drawer {
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 12px;
  max-height: 160px;
  overflow-y: auto;
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-dim);
  margin-bottom: 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  padding-bottom: 4px;
}

.btn-clear-history {
  background: transparent;
  border: none;
  color: var(--accent-rose);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
}

.history-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 5px 6px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s ease;
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

.history-item:hover {
  background: rgba(255, 255, 255, 0.08);
}

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

.history-item-val {
  color: var(--accent-cyan);
  font-weight: 700;
}

.history-empty {
  font-size: 0.75rem;
  color: var(--text-dim);
  text-align: center;
  padding: 6px 0;
}

/* Rueda Direccional D-Pad Replay */
.calc-hardware-middle-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  padding: 0 4px;
}

.mem-cluster {
  display: flex;
  gap: 5px;
}

.btn-key-mem {
  background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
  border: 1px solid #334155;
  border-radius: 4px;
  padding: 4px 8px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  box-shadow: 0 2px 0 #070b12, inset 0 1px 0 rgba(255, 255, 255, 0.15);
  transition: all 0.1s ease;
}

.btn-key-mem:active {
  transform: translateY(2px);
  box-shadow: 0 0 0 #070b12;
}

.dpad-replay-dial {
  position: relative;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: radial-gradient(circle, #2a384f 0%, #151f30 70%, #0d1522 100%);
  border: 1.5px solid #3b4d6b;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.6), inset 0 1px 1px rgba(255, 255, 255, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
}

.dpad-label {
  position: absolute;
  top: 3px;
  font-size: 0.48rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  color: #94a3b8;
}

.dpad-arrow {
  position: absolute;
  font-size: 0.55rem;
  color: #64748b;
}

.dpad-arrow.up { top: 12px; }
.dpad-arrow.down { bottom: 6px; }
.dpad-arrow.left { left: 8px; }
.dpad-arrow.right { right: 8px; }

.dpad-core {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: radial-gradient(circle, #3d4f6c 0%, #1a2538 100%);
  border: 1px solid #4a6184;
}

/* ==========================================================================
   TECLADO FÍSICO 3D CON SERIGRAFÍA SECUNDARIA (SHIFT LEGENDS)
   ========================================================================== */
.calc-keypad-realistic-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px 8px;
}

.key-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

.key-legend-sub {
  font-family: var(--font-mono);
  font-size: 0.64rem;
  font-weight: 700;
  color: #64748b;
  margin-bottom: 3px;
  height: 12px;
  line-height: 12px;
  text-align: center;
  white-space: nowrap;
  letter-spacing: -0.02em;
}

.key-legend-sub.shift-color {
  color: var(--accent-amber);
}

.key-legend-sub.alert-color {
  color: var(--accent-rose);
}

.key-legend-sub.ans-color {
  color: var(--accent-cyan);
}

/* Teclas 3D Ergonómicas con Recorrido Físico */
.key-3d {
  width: 100%;
  min-height: 44px;
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  outline: none;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.08s ease, box-shadow 0.08s ease, background 0.08s ease;
  user-select: none;
}

.key-3d:active {
  transform: translateY(3px) !important;
}

/* Teclas Numéricas */
.btn-num {
  background: var(--key-num-bg);
  border: 1px solid var(--key-num-border);
  color: var(--key-num-text);
  box-shadow: 0 4px 0 var(--key-num-shadow), 0 5px 8px rgba(0, 0, 0, 0.4), inset 0 1px 1px rgba(255, 255, 255, 0.2);
  font-size: 1.25rem;
}

.btn-num:hover {
  background: linear-gradient(180deg, #2e3c54 0%, #1c283c 100%);
}

.btn-num:active {
  box-shadow: 0 1px 0 var(--key-num-shadow), inset 0 2px 4px rgba(0, 0, 0, 0.6);
}

/* Teclas de Funciones Científicas */
.btn-fn, .btn-paren {
  background: var(--key-fn-bg);
  border: 1px solid var(--key-fn-border);
  color: var(--key-fn-text);
  box-shadow: 0 3px 0 var(--key-fn-shadow), 0 4px 6px rgba(0, 0, 0, 0.35), inset 0 1px 1px rgba(255, 255, 255, 0.15);
  font-size: 0.92rem;
}

.btn-fn:hover, .btn-paren:hover {
  background: linear-gradient(180deg, #1e2b40 0%, #121c2c 100%);
  color: var(--text-main);
}

.btn-fn:active, .btn-paren:active {
  box-shadow: 0 1px 0 var(--key-fn-shadow), inset 0 2px 4px rgba(0, 0, 0, 0.5);
}

/* Tecla SHIFT / 2ND */
.btn-shift {
  background: linear-gradient(180deg, #d97706 0%, #92400e 100%);
  border: 1px solid #f59e0b;
  color: #ffffff;
  box-shadow: 0 3px 0 #5f2b05, 0 4px 8px rgba(217, 119, 6, 0.4), inset 0 1px 1px rgba(255, 255, 255, 0.4);
  font-weight: 800;
}

.btn-shift.active-2nd {
  background: linear-gradient(180deg, #fbbf24 0%, #d97706 100%);
  box-shadow: 0 1px 0 #5f2b05, 0 0 12px rgba(245, 158, 11, 0.6), inset 0 1px 2px rgba(255, 255, 255, 0.8);
  transform: translateY(2px);
}

/* Teclas de Acción: AC y DEL */
.btn-action-ac {
  background: linear-gradient(180deg, #e11d48 0%, #9f1239 100%);
  border: 1px solid #f43f5e;
  color: #ffffff;
  box-shadow: 0 4px 0 #4c0519, 0 5px 8px rgba(225, 29, 72, 0.4), inset 0 1px 1px rgba(255, 255, 255, 0.3);
  font-weight: 800;
}

.btn-action-ac:active {
  box-shadow: 0 1px 0 #4c0519, inset 0 2px 4px rgba(0, 0, 0, 0.6);
}

.btn-action-del {
  background: linear-gradient(180deg, #ea580c 0%, #9a3412 100%);
  border: 1px solid #f97316;
  color: #ffffff;
  box-shadow: 0 4px 0 #541c0a, 0 5px 8px rgba(234, 88, 12, 0.4), inset 0 1px 1px rgba(255, 255, 255, 0.3);
  font-weight: 800;
}

.btn-action-del:active {
  box-shadow: 0 1px 0 #541c0a, inset 0 2px 4px rgba(0, 0, 0, 0.6);
}

/* Teclas de Operadores Aritméticos (+, -, *, /) */
.btn-op {
  background: var(--key-op-bg);
  border: 1px solid var(--key-op-border);
  color: var(--key-op-text);
  box-shadow: 0 4px 0 var(--key-op-shadow), 0 5px 8px rgba(0, 0, 0, 0.4), inset 0 1px 1px rgba(255, 255, 255, 0.2);
  font-size: 1.15rem;
}

.btn-op:hover {
  background: linear-gradient(180deg, #273852 0%, #19263a 100%);
}

.btn-op:active {
  box-shadow: 0 1px 0 var(--key-op-shadow), inset 0 2px 4px rgba(0, 0, 0, 0.6);
}

/* Tecla IGUAL (= / EXE) */
.btn-equals {
  background: linear-gradient(180deg, #00e5ff 0%, #0099cc 100%);
  border: 1px solid #67e8f9;
  color: #04121e;
  box-shadow: 0 4px 0 #005577, 0 6px 12px rgba(0, 229, 255, 0.4), inset 0 1px 2px rgba(255, 255, 255, 0.6);
  font-size: 1.4rem;
  font-weight: 900;
}

.btn-equals:hover {
  background: linear-gradient(180deg, #38bdf8 0%, #00b4d8 100%);
  box-shadow: 0 4px 0 #005577, 0 8px 16px rgba(0, 229, 255, 0.6);
}

.btn-equals:active {
  box-shadow: 0 1px 0 #005577, inset 0 2px 4px rgba(0, 0, 0, 0.6);
}

/* ==========================================================================
   Módulo 2: Graficador 2D Osciloscopio
   ========================================================================== */
.calc-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 24px;
  box-shadow: var(--shadow-card);
  margin-bottom: 24px;
}

.section-title-wrap {
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 14px;
}

.card-section-title {
  font-size: 1.25rem;
  color: var(--text-main);
  margin-bottom: 4px;
}

.section-subtext {
  font-size: 0.86rem;
  color: var(--text-muted);
}

.grapher-inputs-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.graph-fn-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.fn-color-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 8px currentColor;
}

.fn-label {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
  white-space: nowrap;
}

.graph-fn-row .input-field-wrap {
  flex: 1;
}

.input-field-wrap {
  display: flex;
  align-items: stretch;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  min-height: 40px;
}

.input-field-wrap:focus-within {
  border-color: var(--border-color-focus);
  box-shadow: 0 0 0 2px rgba(var(--accent-cyan-rgb), 0.2);
}

.form-input {
  flex: 1 1 0%;
  width: 0;
  min-width: 0;
  background: transparent;
  border: none;
  padding: 8px 12px;
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 500;
  outline: none;
}

.unit-suffix {
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  background: rgba(255, 255, 255, 0.04);
  border-left: 1px solid var(--border-color);
  color: var(--text-dim);
  font-size: 0.82rem;
  font-weight: 600;
  user-select: none;
}

.graph-controls-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.graph-presets-pills {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.preset-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-dim);
}

.graph-preset-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 0.78rem;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.graph-preset-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-main);
  border-color: var(--accent-cyan);
}

.graph-zoom-btns {
  display: flex;
  gap: 6px;
}

.btn-graph-action {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-graph-action:hover {
  background: var(--bg-card-hover);
  color: var(--text-main);
}

.graph-canvas-container {
  position: relative;
  width: 100%;
  background: #03070e;
  border: 2px solid #1e293b;
  border-radius: 12px;
  overflow: hidden;
  cursor: crosshair;
  box-shadow: inset 0 4px 12px rgba(0, 0, 0, 0.9);
}

#graph_canvas {
  width: 100%;
  height: 480px;
  display: block;
}

.graph-tooltip {
  position: absolute;
  background: rgba(11, 17, 30, 0.94);
  border: 1px solid var(--accent-cyan);
  border-radius: 6px;
  padding: 4px 8px;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: #ffffff;
  pointer-events: none;
  z-index: 10;
  backdrop-filter: blur(4px);
  white-space: nowrap;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
}

/* ==========================================================================
   Módulo 3: Constantes Físicas
   ========================================================================== */
.constants-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.const-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
  transition: all 0.2s ease;
}

.const-card:hover {
  border-color: rgba(var(--accent-cyan-rgb), 0.4);
  background: var(--bg-card-hover);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.const-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.const-sym {
  font-family: var(--font-mono);
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--accent-cyan);
}

.const-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-main);
}

.const-val-row {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-muted);
  word-break: break-all;
}

.const-unit {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.const-actions {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}

.btn-const-action {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-const-action:hover {
  background: var(--accent-cyan);
  color: #000000;
  border-color: var(--accent-cyan);
}

/* ==========================================================================
   Módulo 4: Modo Programador
   ========================================================================== */
.programmer-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.prog-input {
  text-transform: uppercase;
}

.bit-inspector-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 16px;
}

.bit-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-dim);
  margin-bottom: 12px;
}

.bit-grid-container {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.byte-block {
  display: flex;
  gap: 3px;
}

.bit-cell {
  flex: 1;
  aspect-ratio: 1;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-dim);
  cursor: pointer;
  user-select: none;
  transition: all 0.15s ease;
}

.bit-cell.on {
  background: rgba(var(--accent-cyan-rgb), 0.25);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
  box-shadow: 0 0 6px rgba(var(--accent-cyan-rgb), 0.4);
}

/* ==========================================
   Sección Educativa (SEO)
   ========================================== */
.percent-edu-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 24px;
}

.edu-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 20px;
}

.edu-card h4 {
  font-size: 1rem;
  color: var(--text-main);
  margin-bottom: 10px;
}

.edu-card p {
  font-size: 0.86rem;
  color: var(--text-muted);
  line-height: 1.55;
  margin-bottom: 8px;
}

.edu-card p:last-child {
  margin-bottom: 0;
}

.edu-card code {
  font-family: var(--font-mono);
  background: rgba(255, 255, 255, 0.06);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--accent-cyan);
  font-size: 0.82rem;
}

/* ==========================================
   Adaptabilidad Móvil (Responsive)
   ========================================== */
@media (max-width: 1024px) {
  .tool-with-sidebar {
    grid-template-columns: 1fr;
  }
  .tool-ad-sidebar {
    width: 100%;
    margin-top: 20px;
  }
  .ad-unit-card {
    width: 100%;
    min-height: 250px;
    height: auto;
  }
}

@media (max-width: 768px) {
  .main-wrapper {
    padding: 16px 12px 32px;
  }

  .calc-hardware-chassis {
    padding: 18px 12px 22px;
    border-radius: 18px;
  }

  .calc-keypad-realistic-grid {
    gap: 8px 4px;
  }

  .key-3d {
    min-height: 42px;
    font-size: 0.95rem;
  }

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

  .key-legend-sub {
    font-size: 0.58rem;
    height: 10px;
    line-height: 10px;
  }

  .grapher-inputs-grid,
  .constants-grid,
  .programmer-form-grid,
  .percent-edu-grid {
    grid-template-columns: 1fr;
  }

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

  .calc-result-input {
    font-size: 1.8rem;
  }
}
