* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: linear-gradient(135deg, #0f172a, #1e293b);
  color: #e2e8f0;
}

.app {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  align-items: flex-start;
}

.calculator {
  background: #1e293b;
  border-radius: 20px;
  padding: 20px;
  width: 320px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
}

.display {
  background: #0f172a;
  border-radius: 12px;
  padding: 24px 18px;
  margin-bottom: 16px;
  font-size: 2.4rem;
  font-weight: 600;
  text-align: right;
  overflow-x: auto;
  white-space: nowrap;
  min-height: 84px;
}

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

.key {
  border: none;
  border-radius: 12px;
  padding: 18px 0;
  font-size: 1.3rem;
  font-weight: 600;
  color: #e2e8f0;
  background: #334155;
  cursor: pointer;
  transition: filter 0.12s ease, transform 0.05s ease;
}

.key:hover {
  filter: brightness(1.15);
}

.key:active {
  transform: scale(0.96);
}

.key--fn {
  background: #475569;
  color: #cbd5e1;
}

.key--op {
  background: #f59e0b;
  color: #1e293b;
}

.key--equals {
  background: #22c55e;
  color: #052e16;
}

.history {
  background: #1e293b;
  border-radius: 20px;
  padding: 20px;
  width: 280px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
}

.history__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.history__header h2 {
  font-size: 1.1rem;
}

.history__clear {
  border: none;
  background: transparent;
  color: #94a3b8;
  font-size: 0.85rem;
  cursor: pointer;
}

.history__clear:hover {
  color: #f87171;
}

.history__list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 360px;
  overflow-y: auto;
}

.history__list li {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #0f172a;
  cursor: pointer;
}

.history__list li:hover {
  background: #334155;
}

.history__list .expr {
  font-size: 0.85rem;
  color: #94a3b8;
}

.history__list .res {
  font-size: 1.05rem;
  font-weight: 600;
}

.history__list:empty::after {
  content: "Noch keine Berechnungen.";
  color: #64748b;
  font-size: 0.85rem;
}
