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

:root {
  --bg: #0a0a0a;
  --fg: #f0f0f0;
  --accent: #7c6af7;
  --key: #1c1c1e;
  --fn: #2c2c2e;
  --op-bg: var(--accent);
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
  overflow: hidden;
  touch-action: manipulation;
}

body {
  display: flex;
  flex-direction: column;
  height: 100svh;
}

#display {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: flex-end;
  padding: 1.5rem 1.25rem 1rem;
  gap: 0.25rem;
  min-height: 0;
}

#expr {
  font-size: 1.1rem;
  color: #555;
  min-height: 1.4em;
  word-break: break-all;
  text-align: right;
}

#result {
  font-size: clamp(3rem, 16vw, 5.5rem);
  font-weight: 200;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  word-break: break-all;
  text-align: right;
}

#keys {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  padding: 10px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
}

button {
  background: var(--key);
  color: var(--fg);
  border: none;
  border-radius: 50%;
  aspect-ratio: 1;
  font-size: clamp(1.2rem, 6vw, 1.8rem);
  font-weight: 400;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: opacity 0.1s;
  width: 100%;
}

button:active { opacity: 0.6; }
button.fn     { background: var(--fn); color: var(--fg); }
button.op     { background: var(--op-bg); color: #fff; }
button.op.active { background: #fff; color: var(--accent); }

button.wide {
  grid-column: span 2;
  border-radius: 999px;
  aspect-ratio: unset;
  padding-left: 28%;
  text-align: left;
}
