:root {
  --brand-blue: #0b5fff;
  --brand-blue-2: #0a4fe0;
  --bg: linear-gradient(160deg, var(--brand-blue), var(--brand-blue-2));
  --key: #9aa0a6; /* gris mucho más claro */
  --key-hover: #b0b6bb;
  --key-active: #8a9096;
  --op: #8b949e;
  --eq: #7f8892;
  --text: #ffffff;
  --shadow: rgba(0,0,0,0.2);
}

* { box-sizing: border-box; }
html, body {
  height: 100%;
  margin: 0;
  background: transparent;
  color: var(--text);
  font-family: "Noto Sans", system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}

.app-header {
  text-align: center;
  padding: 24px 16px 8px;
}
.app-header h1 {
  margin: 0;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.calculator {
  max-width: 380px;
  width: min(92vw, 380px);
  margin: 8px auto 40px;
  padding: 12px 12px 16px;
  background: var(--bg);
  border: 2px solid rgba(255, 255, 255, 0.18);
  border-radius: 16px;
  box-shadow: 0 12px 30px var(--shadow);
}

.display-wrap {
  position: relative;
  background: rgba(255,255,255,0.07);
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 6px 18px var(--shadow) inset;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-height: 72px;
}

.memory-indicator {
  position: absolute;
  left: 12px;
  top: 10px;
  opacity: 0;
  font-weight: 600;
  transition: opacity 160ms ease;
}

.display {
  width: 100%;
  text-align: right;
  font-size: 2.2rem;
  line-height: 1.2;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.keys {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.key {
  background: var(--key);
  color: var(--text);
  border: none;
  border-radius: 10px;
  padding: 16px;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 120ms ease, transform 40ms ease, opacity 120ms ease;
  box-shadow: 0 2px 0 rgba(0,0,0,0.15);
  user-select: none;
}
.key:hover { background: var(--key-hover); }
.key:active { background: var(--key-active); transform: scale(0.99); }
.key:focus-visible {
  outline: 2px solid rgba(255,255,255,0.6);
  outline-offset: 2px;
}

.key-op { background: var(--op); }
.key-eq { background: var(--eq); }
.key-fn { background: #8f97a0; }
.key-mem { background: #8f97a0; }

.key-wide {
  grid-column: span 2;
}

.memory-on .memory-indicator { opacity: 1; }

.calc-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 4px 4px 10px;
}
.calc-title { margin: 0; font-weight: 700; font-size: 1rem; }
.btn-close {
  background: transparent;
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.35);
  border-radius: 8px;
  width: 34px; height: 34px;
  font-size: 1.1rem; line-height: 1;
  cursor: pointer; transition: opacity 140ms ease, background 120ms ease;
}
.btn-close:hover { background: rgba(255,255,255,0.08); }
.btn-close:active { opacity: 0.7; }

/* Responsive */
@media (max-width: 420px) {
  .display { font-size: 1.8rem; }
  .keys { gap: 8px; }
}