:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #07110f;
  color: #eefbf7;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 12% 10%, rgba(91, 241, 188, 0.15), transparent 32rem),
    radial-gradient(circle at 88% 88%, rgba(79, 143, 255, 0.15), transparent 30rem),
    #07110f;
}

button {
  font: inherit;
}

.shell {
  width: min(100% - 32px, 920px);
  margin: 0 auto;
  padding: 48px 0;
}

.hero {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
}

.eyebrow {
  margin: 0 0 8px;
  color: #7fffcf;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 7vw, 3.5rem);
  letter-spacing: -0.06em;
  line-height: 0.95;
}

.hint {
  max-width: 25rem;
  margin: 0;
  color: #91a7a0;
  font-size: 0.9rem;
  line-height: 1.5;
  text-align: right;
}

kbd {
  padding: 2px 6px;
  border: 1px solid #2e4941;
  border-bottom-width: 2px;
  border-radius: 5px;
  background: #10211d;
  color: #c9ddd6;
  font: 0.75rem ui-monospace, SFMono-Regular, Menlo, monospace;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 16px;
}

.calculator,
.history {
  border: 1px solid rgba(166, 219, 200, 0.14);
  border-radius: 28px;
  background: rgba(13, 29, 25, 0.86);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(18px);
}

.calculator {
  padding: 18px;
}

.screen {
  position: relative;
  min-height: 156px;
  padding: 24px 64px 18px 20px;
  overflow: hidden;
  border: 1px solid rgba(127, 255, 207, 0.14);
  border-radius: 20px;
  background:
    linear-gradient(145deg, rgba(127, 255, 207, 0.08), transparent 54%),
    #091713;
}

.expression {
  min-height: 24px;
  margin: 0;
  overflow: hidden;
  color: #6f8e84;
  font-size: 0.93rem;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.display {
  margin: 24px 0 0;
  overflow: hidden;
  font-size: clamp(2.6rem, 9vw, 4.5rem);
  font-variant-numeric: tabular-nums;
  font-weight: 650;
  letter-spacing: -0.06em;
  line-height: 1;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.memory-indicator {
  position: absolute;
  top: 20px;
  left: 20px;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: #7fffcf;
  color: #07110f;
  font-size: 0.72rem;
  font-weight: 900;
  line-height: 24px;
  text-align: center;
}

.backspace {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #78968c;
  cursor: pointer;
  font-size: 1.25rem;
}

.backspace:hover {
  background: #132721;
  color: #d9ece6;
}

.keypad {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-top: 14px;
}

.key {
  min-height: 64px;
  border: 1px solid transparent;
  border-radius: 18px;
  background: #172a25;
  color: #edf9f5;
  cursor: pointer;
  font-size: 1.15rem;
  font-weight: 680;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
  -webkit-tap-highlight-color: transparent;
}

.key:hover {
  border-color: rgba(127, 255, 207, 0.24);
  background: #1c352e;
}

.key:active {
  transform: translateY(2px) scale(0.98);
}

.key:focus-visible,
.backspace:focus-visible,
.clear-history:focus-visible {
  outline: 3px solid rgba(127, 255, 207, 0.55);
  outline-offset: 2px;
}

.key--memory {
  min-height: 46px;
  background: transparent;
  color: #7d9c92;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
}

.key--utility {
  background: #263b35;
  color: #c9ddd6;
}

.key--operator {
  background: #123b31;
  color: #7fffcf;
  font-size: 1.45rem;
}

.key--operator.is-active {
  background: #7fffcf;
  color: #07110f;
}

.key--equals {
  background: #7fffcf;
  color: #07110f;
  box-shadow: 0 10px 24px rgba(64, 230, 170, 0.16);
}

.key--equals:hover {
  background: #a0ffdc;
}

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

.history {
  min-height: 100%;
  padding: 22px;
}

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

.history h2 {
  margin: 0;
  font-size: 0.9rem;
  letter-spacing: 0.02em;
}

.clear-history {
  padding: 5px 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #67837a;
  cursor: pointer;
  font-size: 0.72rem;
}

.clear-history:hover {
  background: #172a25;
  color: #c9ddd6;
}

.history__empty {
  margin: 38px 0 0;
  color: #5f786f;
  font-size: 0.83rem;
  line-height: 1.5;
  text-align: center;
}

.history__list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.history__list li {
  display: grid;
  gap: 5px;
  padding: 12px;
  border-radius: 12px;
  background: rgba(23, 42, 37, 0.7);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.history__list span {
  overflow: hidden;
  color: #6f8e84;
  font-size: 0.75rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history__list strong {
  color: #d9ece6;
  font-size: 0.95rem;
}

@media (max-width: 720px) {
  .shell {
    padding: 28px 0;
  }

  .hero {
    display: block;
  }

  .hint {
    margin-top: 14px;
    text-align: left;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .history {
    min-height: 150px;
  }
}

@media (max-width: 430px) {
  .shell {
    width: min(100% - 16px, 920px);
  }

  .calculator {
    padding: 10px;
    border-radius: 22px;
  }

  .screen {
    min-height: 134px;
  }

  .key {
    min-height: 58px;
    border-radius: 15px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .key {
    transition: none;
  }
}
