:root {
  --bg-1: #f7f6f3;
  --bg-2: #eef4ef;
  --ink: #192124;
  --muted: #5d686e;
  --card: rgba(255, 255, 255, 0.82);
  --card-strong: rgba(255, 255, 255, 0.96);
  --accent: #0b7a75;
  --accent-strong: #005f5b;
  --danger: #b6423b;
  --key-soft: #edf1f2;
  --key-number: #ffffff;
  --key-operator: #d8ebe9;
  --shadow: 0 24px 60px rgba(12, 31, 36, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 18%, rgba(11, 122, 117, 0.25), transparent 38%),
    radial-gradient(circle at 86% 20%, rgba(243, 170, 89, 0.22), transparent 30%),
    linear-gradient(140deg, var(--bg-1), var(--bg-2));
  padding: 24px;
}

.app-shell {
  max-width: 1100px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 20px;
  align-items: start;
}

.calculator-card,
.history-card {
  backdrop-filter: blur(8px);
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.75);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.calculator-card {
  padding: 20px;
}

.card-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 12px;
}

h1 {
  margin: 4px 0 0;
  font-size: clamp(1.25rem, 2vw, 1.55rem);
  line-height: 1.2;
}

.screen {
  background: var(--card-strong);
  border: 1px solid #e5eaec;
  border-radius: 18px;
  padding: 14px;
  min-height: 112px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  margin-bottom: 14px;
  overflow-wrap: anywhere;
}

.expression {
  margin: 0;
  color: var(--muted);
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.95rem;
  min-height: 24px;
}

.result {
  margin: 8px 0 0;
  font-family: "IBM Plex Mono", monospace;
  font-size: clamp(1.45rem, 3.5vw, 2rem);
  font-weight: 500;
}

.controls-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}

.key {
  border: 0;
  border-radius: 14px;
  min-height: 52px;
  padding: 8px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  transition: transform 130ms ease, filter 130ms ease, box-shadow 130ms ease;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.08);
}

.key:hover {
  transform: translateY(-1px);
  filter: brightness(1.02);
}

.key:active {
  transform: translateY(1px);
}

.soft {
  background: var(--key-soft);
}

.number {
  background: var(--key-number);
}

.operator {
  background: var(--key-operator);
}

.function {
  background: #f4f0e9;
}

.equals {
  background: linear-gradient(145deg, var(--accent), var(--accent-strong));
  color: #fff;
}

.wide {
  grid-column: span 2;
}

.pill-btn {
  border: 0;
  border-radius: 999px;
  padding: 8px 14px;
  font-family: inherit;
  font-weight: 700;
  cursor: pointer;
  background: #dbeceb;
  color: var(--accent-strong);
}

.pill-btn.danger {
  background: #f8e7e6;
  color: var(--danger);
}

.history-card {
  padding: 16px;
}

.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

h2 {
  margin: 0;
  font-size: 1.05rem;
}

.history-list {
  list-style: decimal;
  margin: 0;
  padding-left: 18px;
  max-height: 430px;
  overflow-y: auto;
}

.history-list li {
  margin: 10px 0;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.9rem;
}

.history-empty {
  color: var(--muted);
  list-style: none;
  margin-left: -18px;
}

.hint {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.35;
}

@media (max-width: 930px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .history-list {
    max-height: 200px;
  }
}

@media (max-width: 620px) {
  body {
    padding: 12px;
  }

  .calculator-card,
  .history-card {
    border-radius: 18px;
  }

  .calculator-card {
    padding: 14px;
  }

  .controls-grid {
    gap: 8px;
  }

  .key {
    min-height: 48px;
    font-size: 0.95rem;
  }
}
