:root {
  color-scheme: dark;
  --bg: #0f1419;
  --card: #1c2430;
  --display: #121820;
  --text: #f4f7fb;
  --muted: #8b98a8;
  --key: #2a3442;
  --key-hover: #364356;
  --fn: #3d4a5c;
  --op: #e8a23a;
  --op-hover: #f0b45a;
  --eq: #3d9a6a;
  --eq-hover: #4eb07c;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  place-items: center;
  font-family: "Segoe UI", system-ui, sans-serif;
  background:
    radial-gradient(circle at top, #1c2a3a 0%, transparent 45%),
    var(--bg);
  color: var(--text);
}

.app {
  width: min(360px, calc(100vw - 32px));
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.home {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  border-radius: 12px;
  color: var(--text);
  background: var(--key);
}

.home:hover {
  background: var(--key-hover);
}

.home svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.calculator {
  background: var(--card);
  border-radius: 24px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.display {
  background: var(--display);
  border-radius: 16px;
  min-height: 108px;
  padding: 16px 18px;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: flex-end;
  gap: 6px;
}

.expression {
  margin: 0;
  min-height: 1.2em;
  color: var(--muted);
  font-size: 0.95rem;
  word-break: break-all;
}

.value {
  font-size: 2.6rem;
  font-weight: 500;
  line-height: 1.1;
  word-break: break-all;
}

.keys {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.key {
  appearance: none;
  border: 0;
  border-radius: 14px;
  min-height: 64px;
  font: inherit;
  font-size: 1.35rem;
  color: var(--text);
  background: var(--key);
  cursor: pointer;
}

.key:hover {
  background: var(--key-hover);
}

.key:active {
  transform: translateY(1px);
}

.key:focus-visible {
  outline: 2px solid #8ec5ff;
  outline-offset: 2px;
}

.key-fn {
  background: var(--fn);
  color: #d7e0ea;
}

.key-op,
.key-eq {
  font-weight: 600;
}

.key-op {
  background: var(--op);
  color: #1a1408;
}

.key-op:hover,
.key-op.is-active {
  background: var(--op-hover);
}

.key-eq {
  background: var(--eq);
  color: #04140c;
}

.key-eq:hover {
  background: var(--eq-hover);
}

.key-zero {
  grid-column: span 2;
}
