:root {
  --bg: radial-gradient(1200px 800px at 20% 10%, #2a2a72 0%, #000 70%);
  --panel: rgba(255, 255, 255, 0.08);
  --panel-border: rgba(255, 255, 255, 0.12);
  --text: #f5f7fb;
  --text-dim: #c9cede;
  --accent: #00d4ff;
  --accent-2: #7c4dff;
  --op: #263853;
  --fn: #334155;
  --eq: #22c55e;
  --shadow: 0 10px 25px rgba(0, 0, 0, 0.35);
}

[data-theme="light"] {
  --bg: radial-gradient(1200px 800px at 20% 10%, #e8f1ff 0%, #e6e6ff 70%);
  --panel: rgba(255, 255, 255, 0.7);
  --panel-border: rgba(0, 0, 0, 0.08);
  --text: #0f172a;
  --text-dim: #334155;
  --accent: #2563eb;
  --accent-2: #7c3aed;
  --op: #e2e8f0;
  --fn: #e5e7eb;
  --eq: #16a34a;
}

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

.App {
  height: 100dvh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.container_calculadora {
  width: min(680px, 96vw);
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 24px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--panel-border);
}
.brand {
  font-weight: 800;
  letter-spacing: 0.4px;
}
.actions {
  display: flex;
  gap: 10px;
  align-items: center;
}
.theme-switch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}
.theme-switch input {
  display: none;
}
.theme-switch span {
  font-size: 18px;
  opacity: 0.9;
}

.pantalla {
  padding: 18px;
  display: grid;
  gap: 6px;
  min-height: 120px;
}
.display-expresion {
  text-align: right;
  font-size: 16px;
  color: var(--text-dim);
  min-height: 22px;
  word-wrap: anywhere;
}
.display-resultado {
  text-align: right;
  font-size: clamp(28px, 6vw, 44px);
  font-weight: 800;
  word-wrap: anywhere;
}

.layout {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 8px;
  padding: 12px;
}

.historial {
  max-height: 420px;
  overflow: auto;
  border-right: 1px solid var(--panel-border);
  padding: 10px 12px 10px 16px;
}
.historial[hidden] {
  display: none;
}
.historial-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--text-dim);
  font-weight: 700;
  margin-bottom: 8px;
}
#historyList {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 8px;
}
#historyList li {
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
}
#historyList li:hover {
  outline: 2px solid rgba(124, 77, 255, 0.35);
}
#historyList .expr {
  color: var(--text-dim);
  font-size: 12px;
}
#historyList .res {
  font-weight: 800;
}

.buttons_calc {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  padding: 10px;
}

.btn {
  appearance: none;
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  border-radius: 14px;
  padding: 14px 10px;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.06s ease, background 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.2);
}
.btn:active {
  transform: translateY(2px);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.25);
}
.btn.small {
  padding: 8px 12px;
  font-size: 14px;
  font-weight: 700;
}
.btn.tiny {
  padding: 6px 10px;
  font-size: 12px;
}

.btn.op {
  background: linear-gradient(
    180deg,
    rgba(37, 99, 235, 0.2),
    rgba(37, 99, 235, 0.1)
  );
  border-color: rgba(37, 99, 235, 0.35);
}
.btn.fn {
  background: linear-gradient(
    180deg,
    rgba(148, 163, 184, 0.25),
    rgba(148, 163, 184, 0.12)
  );
  border-color: rgba(148, 163, 184, 0.35);
}
.btn.eq {
  background: linear-gradient(
    180deg,
    rgba(34, 197, 94, 0.3),
    rgba(34, 197, 94, 0.18)
  );
  border-color: rgba(34, 197, 94, 0.45);
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .historial {
    order: 2;
    border-right: none;
    border-top: 1px solid var(--panel-border);
  }
}

@media (max-width: 420px) {
  .btn {
    font-size: 16px;
    padding: 12px 10px;
  }
}
