﻿:root {
  --bg-1: #041729;
  --bg-2: #072f4f;
  --panel: rgba(8, 22, 44, 0.8);
  --ink: #eaf7ff;
  --muted: #94b9d2;
  --num: #133c66;
  --op: #0fa7a0;
  --sci: #2e73bb;
  --func: #6556b3;
  --danger: #d64c67;
  --accent: #f4b400;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", "Trebuchet MS", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 20% 20%, #0f4f85 0%, transparent 40%),
    radial-gradient(circle at 80% 10%, #0c7e74 0%, transparent 36%),
    linear-gradient(145deg, var(--bg-1), var(--bg-2));
  min-height: 100vh;
  overflow-x: hidden;
}

.app-shell {
  position: relative;
}

.app-shell::before,
.app-shell::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  filter: blur(26px);
  opacity: 0.65;
  z-index: 0;
  animation: drift 10s ease-in-out infinite alternate;
}

.app-shell::before {
  width: 220px;
  height: 220px;
  background: #1bc8d4;
  top: 12%;
  left: 8%;
}

.app-shell::after {
  width: 250px;
  height: 250px;
  background: #f4b400;
  bottom: 10%;
  right: 8%;
  animation-delay: 1.2s;
}

.calc {
  position: relative;
  z-index: 1;
  max-width: 680px;
  border-radius: 22px;
  background: linear-gradient(160deg, rgba(16, 44, 81, 0.95), var(--panel));
  backdrop-filter: blur(12px);
}

.title {
  font-weight: 700;
  letter-spacing: 0.03em;
}

.subtitle {
  color: var(--muted);
  letter-spacing: 0.03em;
}

.mode-btn {
  border-radius: 999px;
  border-color: #8bc6ec;
  color: #d8efff;
}

.mode-btn:hover {
  background: #8bc6ec;
  color: #05223a;
}

.display-wrap {
  background: rgba(0, 0, 0, 0.34);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 16px;
  padding: 10px 12px;
}

.history {
  color: var(--muted);
  min-height: 22px;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.display {
  background: transparent;
  border: 0;
  box-shadow: none;
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  font-weight: 700;
  color: #f8fdff;
  padding: 0;
}

.display:focus {
  box-shadow: none;
}

.keys-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.52rem;
}

.key {
  border: 0;
  color: #eff8ff;
  border-radius: 12px;
  min-height: 48px;
  font-weight: 700;
  font-size: clamp(0.86rem, 1.8vw, 1rem);
  transition: transform 0.1s ease, box-shadow 0.2s ease, filter 0.2s ease;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28), 0 8px 16px rgba(0, 0, 0, 0.25);
}

.key:hover {
  filter: brightness(1.12);
  transform: translateY(-1px);
}

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

.key-num {
  background: linear-gradient(170deg, #1b4f81, var(--num));
}

.key-op {
  background: linear-gradient(170deg, #24bcb4, var(--op));
}

.key-sci {
  background: linear-gradient(170deg, #4b88ca, var(--sci));
}

.key-func {
  background: linear-gradient(170deg, #7d6dd3, var(--func));
}

.key-danger {
  background: linear-gradient(170deg, #f07488, var(--danger));
}

.key-equals {
  background: linear-gradient(170deg, #ffd25f, var(--accent));
  color: #3a2a00;
  grid-column: span 2;
}

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

@keyframes drift {
  from {
    transform: translateY(-8px) translateX(-8px) scale(1);
  }
  to {
    transform: translateY(12px) translateX(10px) scale(1.08);
  }
}

@media (max-width: 575px) {
  .calc {
    border-radius: 16px;
  }

  .keys-grid {
    gap: 0.42rem;
  }

  .key {
    min-height: 44px;
    border-radius: 10px;
    font-size: 0.84rem;
  }

  .history {
    font-size: 0.78rem;
  }
}

@media (min-width: 992px) {
  .calc {
    max-width: 760px;
  }

  .key {
    min-height: 56px;
    font-size: 1rem;
  }
}

