:root {
  --bg: #e6ebf1;
  --texto: #2f3a4a;
  --texto-suave: #7b8a9e;
  --sombra-clara: #ffffff;
  --sombra-oscura: #b8c3d1;
  --acento: #5b7cfa;
  --acento-texto: #ffffff;
  --radio: 18px;
}

[data-tema="oscuro"] {
  --bg: #2b2f3a;
  --texto: #e8ecf3;
  --texto-suave: #9aa5b6;
  --sombra-clara: #363c4a;
  --sombra-oscura: #1f232c;
  --acento: #5b7cfa;
  --acento-texto: #ffffff;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  transition: background 0.3s ease;
}

.app {
  padding: 24px;
}

.calculadora {
  width: min(92vw, 380px);
  padding: 22px;
  border-radius: 28px;
  background: var(--bg);
  box-shadow: 12px 12px 24px var(--sombra-oscura), -12px -12px 24px var(--sombra-clara);
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.chip {
  border: none;
  padding: 8px 16px;
  border-radius: 12px;
  background: var(--bg);
  color: var(--texto-suave);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 5px 5px 10px var(--sombra-oscura), -5px -5px 10px var(--sombra-clara);
  transition: 0.2s ease;
}

.chip.activo {
  color: var(--acento);
}

.icon-btn {
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 12px;
  background: var(--bg);
  box-shadow: 5px 5px 10px var(--sombra-oscura), -5px -5px 10px var(--sombra-clara);
  cursor: pointer;
  font-size: 16px;
}

.pantalla {
  border-radius: var(--radio);
  padding: 18px 16px;
  margin-bottom: 16px;
  min-height: 96px;
  background: var(--bg);
  box-shadow: inset 6px 6px 12px var(--sombra-oscura), inset -6px -6px 12px var(--sombra-clara);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  overflow: hidden;
}

.historial {
  min-height: 18px;
  text-align: right;
  color: var(--texto-suave);
  font-size: 13px;
  overflow-x: auto;
  white-space: nowrap;
}

.display {
  text-align: right;
  color: var(--texto);
  font-size: clamp(24px, 8vw, 34px);
  font-weight: 600;
  overflow-x: auto;
  white-space: nowrap;
}

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

.teclado.cientifico {
  grid-template-columns: repeat(5, 1fr);
  margin-bottom: 12px;
}

.oculto {
  display: none !important;
}

.tecla {
  border: none;
  border-radius: 14px;
  padding: 16px 0;
  background: var(--bg);
  color: var(--texto);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 6px 6px 12px var(--sombra-oscura), -6px -6px 12px var(--sombra-clara);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}

.teclado.cientifico .tecla {
  padding: 10px 0;
  font-size: 13px;
}

.tecla:active {
  box-shadow: inset 4px 4px 8px var(--sombra-oscura), inset -4px -4px 8px var(--sombra-clara);
  transform: scale(0.97);
}

.tecla.op, .tecla.igual {
  color: var(--acento);
}

.tecla.accion {
  color: #e0645d;
}

.tecla.func {
  color: var(--texto-suave);
}

.tecla.igual {
  background: var(--acento);
  color: var(--acento-texto);
  box-shadow: 6px 6px 12px var(--sombra-oscura), -6px -6px 12px var(--sombra-clara);
}

.tecla.cero {
  grid-column: span 2;
}
