:root {
  color-scheme: light;
  --bg: #f4f7f5;
  --panel: #ffffff;
  --panel-shadow: 0 26px 70px rgba(32, 42, 38, 0.18);
  --text: #18221f;
  --muted: #6f7b76;
  --key: #edf1ef;
  --key-hover: #e1e8e5;
  --operator: #245f73;
  --operator-hover: #1d5264;
  --utility: #dbe7de;
  --utility-hover: #cfddd3;
  --equals: #d0643c;
  --equals-hover: #bb5734;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  position: relative;
  padding-bottom: 52px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 18% 18%, rgba(208, 100, 60, 0.16), transparent 28%),
    radial-gradient(circle at 78% 12%, rgba(36, 95, 115, 0.14), transparent 26%),
    linear-gradient(135deg, #f7faf8 0%, var(--bg) 48%, #eaf0ec 100%);
}

button {
  font: inherit;
}

.page-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.calculator {
  width: min(100%, 390px);
  padding: 22px;
  border: 1px solid rgba(24, 34, 31, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.84);
  box-shadow: var(--panel-shadow);
  backdrop-filter: blur(18px);
}

.display {
  min-height: 132px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 10px;
  padding: 22px;
  margin-bottom: 18px;
  border-radius: 8px;
  background: #18221f;
  color: #ffffff;
  overflow: hidden;
}

.expression,
.result {
  width: 100%;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.expression {
  min-height: 24px;
  color: rgba(255, 255, 255, 0.64);
  font-size: 18px;
}

.result {
  min-height: 48px;
  font-size: 42px;
  font-weight: 750;
  line-height: 1.15;
}

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

.key {
  min-width: 0;
  height: 64px;
  border: 0;
  border-radius: 8px;
  background: var(--key);
  color: var(--text);
  font-size: 23px;
  font-weight: 700;
  cursor: pointer;
  transition:
    transform 120ms ease,
    background 120ms ease,
    box-shadow 120ms ease;
}

.key:hover {
  background: var(--key-hover);
  box-shadow: inset 0 0 0 1px rgba(24, 34, 31, 0.06);
}

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

.key:focus-visible {
  outline: 3px solid rgba(36, 95, 115, 0.28);
  outline-offset: 2px;
}

.operator {
  background: var(--operator);
  color: #ffffff;
}

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

.utility {
  background: var(--utility);
}

.utility:hover {
  background: var(--utility-hover);
}

.equals {
  background: var(--equals);
  color: #ffffff;
}

.equals:hover {
  background: var(--equals-hover);
}

.zero {
  grid-column: span 2;
}

.site-footer {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  justify-content: center;
  padding: 14px 16px;
  font-size: 14px;
}

.site-footer a {
  color: var(--muted);
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--text);
  text-decoration: underline;
}

@media (max-width: 420px) {
  .page-shell {
    padding: 14px;
  }

  .calculator {
    padding: 14px;
  }

  .display {
    min-height: 118px;
    padding: 18px;
  }

  .key {
    height: 58px;
    font-size: 21px;
  }

  .result {
    font-size: 36px;
  }
}
