:root {
  color-scheme: light;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --panel-edge: #d8dee6;
  --text: #17202a;
  --muted: #657080;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.14), transparent 32%),
    linear-gradient(315deg, rgba(190, 18, 60, 0.1), transparent 34%),
    var(--bg);
  color: var(--text);
}

button {
  font: inherit;
}

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

.calculator {
  width: min(100%, 360px);
  border: 3px solid #bcc5cf;
  border-top-color: #f8fafc;
  border-right-color: #939eaa;
  border-bottom-color: #747f8b;
  border-left-color: #e3e8ed;
  border-radius: 20px;
  background: var(--panel);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.95),
    0 2px 0 #c4ccd5,
    0 5px 0 #a5afba,
    0 8px 0 #7d8894,
    0 15px 18px rgba(23, 32, 42, 0.2),
    0 28px 65px rgba(23, 32, 42, 0.15);
  overflow: hidden;
}

.display {
  min-height: 132px;
  display: grid;
  align-content: end;
  gap: 8px;
  padding: 24px;
  background: #18212d;
  color: #ffffff;
  text-align: right;
}

.expression {
  max-width: 100%;
  min-width: 0;
  min-height: 22px;
  color: #b6c2d0;
  font-size: 0.95rem;
  overflow-x: auto;
  overflow-y: hidden;
  overflow-wrap: normal;
  white-space: normal;
  word-break: normal;
}

.result {
  display: block;
  max-width: 100%;
  min-width: 0;
  width: 100%;
  color: #ffffff;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.35;
  overflow-x: auto;
  overflow-y: hidden;
  overflow-wrap: normal;
  white-space: normal;
  word-break: normal;
}

.keys {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
  padding: 11px;
  background: linear-gradient(145deg, #dce2e9, #cbd3dd);
  box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.9);
}

.key {
  --face-top: #fbfcfd;
  --face-bottom: #dce3ea;
  --key-edge: #aeb8c4;
  --key-outline: #c3ccd5;
  --key-shine: rgba(255, 255, 255, 0.9);
  position: relative;
  isolation: isolate;
  min-height: 72px;
  border: 0;
  border-radius: 0;
  padding: 0;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-size: 1.25rem;
  font-weight: 700;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.key-surface {
  position: absolute;
  inset: 0;
  z-index: -1;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.key-label {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding-bottom: 7px;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.75);
  transition: transform 70ms ease;
  pointer-events: none;
}

.key-label sup {
  margin-left: 1px;
  font-size: 0.62em;
  transform: translateY(-0.45em);
}

.key:hover .key-label {
  transform: translateY(-1px);
}

.key.is-pressed .key-label,
.key:active .key-label {
  transform: translateY(5px);
}

.key-blank {
  cursor: default;
  pointer-events: none;
}

.key:focus-visible {
  outline: 3px solid #f59e0b;
  outline-offset: 1px;
  border-radius: 11px;
}

.key-muted {
  --face-top: #edf1f5;
  --face-bottom: #cbd3dc;
  --key-edge: #9ba7b4;
  color: var(--muted);
  font-size: 1rem;
}

.key-operator {
  --face-top: #15978d;
  --face-bottom: #0c7069;
  --key-edge: #07534e;
  --key-outline: #09645e;
  --key-shine: rgba(190, 255, 246, 0.5);
  color: #ffffff;
}

.key-operator .key-label,
.key-equals .key-label {
  text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.28);
}

.key-equals {
  --face-top: #df2452;
  --face-bottom: #ad1037;
  --key-edge: #7d0b29;
  --key-outline: #9a0d30;
  --key-shine: rgba(255, 205, 218, 0.5);
  color: #ffffff;
}

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

.key-blank {
  --face-top: #d3dae2;
  --face-bottom: #c2cbd5;
  --key-edge: #b7c0ca;
  opacity: 0.72;
}

@media (max-width: 420px) {
  .app {
    padding: 12px;
  }

  .display {
    min-height: 120px;
    padding: 20px;
  }

  .key {
    min-height: 64px;
  }

  .keys {
    gap: 5px;
    padding: 8px;
  }
}
