body {
  background-color: #000;
  color: white;
  font-family: -apple-system, sans-serif;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  margin: 0;
  overflow: hidden;
  touch-action: manipulation;
}

.calculator {
  width: 350px;
  max-height: 95vh; /* Prevents the calculator from exceeding screen height */
  padding: 10px 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.header-icons {
  display: flex;
  justify-content: space-between;
  padding: 10px;
  cursor: pointer;
}

.display-container {
  text-align: right;
  padding: 30px 10px;
  min-height: 120px;
}
.equation {
  color: #888;
  font-size: 28px;
  height: 34px;
}
.main-num {
  font-size: 70px;
  font-weight: 300;
}

.buttons {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px; /* Slightly reduced gap to save vertical space */
  margin-bottom: 15px;
}

.btn {
  width: 75px;
  height: 75px;
  border-radius: 50%;
  border: none;
  font-size: 30px;
  cursor: pointer;
  transition: opacity 0.2s;
  touch-action: manipulation;
}
.btn:active {
  opacity: 0.7;
}

.gray {
  background-color: #a5a5a5;
  color: black;
}
.dark-gray {
  background-color: #333;
  color: white;
}
.orange {
  background-color: #ff9f0a;
  color: white;
}

/* History Sidebar */
.history-sidebar {
  position: fixed;
  bottom: -100%;
  left: 0;
  width: 100%;
  height: 75%;
  background: #1c1c1e;
  border-top-left-radius: 20px;
  border-top-right-radius: 20px;
  transition: bottom 0.3s ease;
  padding: 20px;
  box-sizing: border-box;
  z-index: 10;
}
.history-sidebar.active {
  bottom: 0;
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
#edit-btn {
  color: #0a84ff;
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
}
.close-btn {
  color: white;
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 15px 0;
  border-bottom: 1px solid #333;
}

/* Selection Circle */
.checkbox {
  width: 22px;
  height: 22px;
  border: 2px solid #555;
  border-radius: 50%;
  display: none;
  cursor: pointer;
  flex-shrink: 0;
}
.history-item.editing .checkbox {
  display: block;
}
.checkbox.selected {
  background-color: #ff9f0a;
  border-color: #ff9f0a;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="white"><path d="M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"/></svg>');
  background-size: 15px;
  background-repeat: no-repeat;
  background-position: center;
}

.history-footer {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 70px;
  background: #1c1c1e;
  display: none;
  justify-content: space-between;
  align-items: center;
  padding: 0 20px;
  border-top: 1px solid #333;
  box-sizing: border-box;
}
.delete-text {
  color: #ff453a;
  background: none;
  border: none;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
}
.circle-check {
  width: 25px;
  height: 25px;
  border: 2px solid #ff9f0a;
  border-radius: 50%;
}

:root {
  --x-color: #ff9f0a; /* Matches the iOS orange button color */
}

/* Developer Attribution */
.developer-container {
  margin-top: 10px; /* Reduces the 30px margin that was pushing it down */
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding-bottom: 5px;
  animation: fadeIn 1.5s ease-in-out;
}

.dev-label {
  font-size: 0.65rem;
  letter-spacing: 3px;
  color: rgba(255, 255, 255, 0.3);
  font-weight: 600;
}

.dev-link {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--x-color);
  text-decoration: none;
  letter-spacing: 1px;
  position: relative;
  transition: all 0.4s ease;
  text-shadow: 0 0 8px rgba(0, 242, 254, 0.2);
}

.dev-link::after {
  content: "";
  position: absolute;
  width: 0%;
  height: 1.5px;
  bottom: -4px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--x-color);
  transition: width 0.4s ease;
  box-shadow: 0 0 10px var(--x-color);
  border-radius: 10px;
}

.dev-link:hover {
  color: #fff;
  transform: translateY(-2px);
  text-shadow: 0 0 10px var(--x-color), 0 0 20px rgba(0, 242, 254, 0.4);
}

.dev-link:hover::after {
  width: 100%;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-height: 700px) {
  .btn {
    width: 60px;
    height: 60px;
    font-size: 24px;
  }
  .main-num {
    font-size: 50px;
  }
}
