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

body {
  font-family: "Inter", sans-serif;
  color: hsl(0, 0%, 20%);
  background: hsl(0, 0%, 94%);
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100vh;
  justify-content: center;
}

#calculator {
  background-color: hsl(0, 0%, 20%);
  max-width: 400px;
  margin: 0 auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  border-radius: 20px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
}

#display {
  width: 100%;
  padding: 20px;
  font-size: 2.5rem;
  text-align: right;
  border: none;
  color: #f9f9f9;
  background-color: hsl(0, 0%, 35%);
  border-radius: 10px;
}

#keys {
  display: grid;
  grid-template-columns: repeat(4, 1fr); /* 4 equal columns */
  grid-auto-rows: 4rem; /* or any consistent height */
  gap: 1rem; /* spacing between buttons */
}

#clear,
#back {
  grid-column: span 2;
  background-color: hsl(40, 40%, 40%);
}

button {
  width: 100%;
  background-color: hsl(0, 0%, 35%);
  color: white;
  border-radius: 10px;
  font-size: 1.5rem;
  border: none;
  cursor: pointer;
}

button:hover {
  background-color: hsl(0, 0%, 40%);
}

button:active {
  background-color: hsl(0, 0%, 50%);
}

.operator {
  background-color: hsl(240, 100%, 70%);
}

.operator:hover {
  background-color: hsl(240, 100%, 75%);
}

.operator:active {
  background-color: hsl(240, 100%, 80%);
}

#clear:hover,
#back:hover {
  background-color: hsl(40, 40%, 50%);
}

#clear:active,
#back:active {
  background-color: hsl(40, 40%, 60%);
}

.footer {
  margin-top: 3em;
}

.footer a {
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}

.footer a:hover {
  text-decoration: underline;
  color: hsl(40, 40%, 50%);
}

body.dark-mode {
  background: hsl(0, 0%, 10%);
  color: hsl(0, 0%, 90%);
}

body.dark-mode #calculator {
  background-color: hsl(0, 0%, 20%);
}

body.dark-mode #display {
  background-color: hsl(0, 0%, 25%);
  color: hsl(0, 0%, 95%);
}

body.dark-mode button {
  background-color: hsl(0, 0%, 30%);
}

body.dark-mode button:active {
  background-color: hsl(0, 0%, 45%);
}

body.dark-mode .operator {
  background-color: hsl(240, 100%, 65%);
}

body.dark-mode #clear,
body.dark-mode #back {
  background-color: hsl(40, 40%, 35%);
}

body.dark-mode #calculator {
  box-shadow: 0 8px 20px rgba(255, 255, 255, 0.05);
}

* {
  transition: background-color 0.3s ease, color 0.3s ease;
}

#theme-toggle {
  position: relative;
  width: 60px;
  height: 30px;
  background-color: hsl(0, 0%, 35%);
  border-radius: 30px;
  border: none;
  cursor: pointer;
  transition: background-color 0.3s ease;
}

#theme-toggle::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  background-color: white;
  border-radius: 50%;
  transition: transform 0.3s ease;
}

body.dark-mode #theme-toggle {
  background-color: hsl(240, 100%, 65%);
}

body.dark-mode #theme-toggle::before {
  transform: translateX(30px);
}

.theme-wrapper {
  margin-bottom: 2rem;
  display: flex;
  justify-content: center;
}
