:root {
  --bg-color: #121212;
  --calc-bg: #1f1f1f;
  --text-color: #fff;
  --button-bg: #333;
  --button-hover: #444;
  --display-bg: #2c2c2c;
}

body.light {
  --bg-color: #f0f0f0;
  --calc-bg: #ffffff;
  --text-color: #000;
  --button-bg: #e0e0e0;
  --button-hover: #cccccc;
  --display-bg: #ffffff;
}

body {
  background: var(--bg-color);
  color: var(--text-color);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  font-family: 'Segoe UI', sans-serif;
  transition: background 0.3s ease;
  padding: 20px;
}

.theme-toggle {
  position: absolute;
  top: 20px;
  right: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.theme-toggle input {
  width: 40px;
  height: 20px;
  appearance: none;
  background: var(--button-bg);
  border-radius: 20px;
  position: relative;
  outline: none;
  cursor: pointer;
  transition: background 0.3s;
}

.theme-toggle input:checked {
  background: #00c853;
}

.theme-toggle input::before {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  top: 1px;
  left: 1px;
  transition: transform 0.3s;
}

.theme-toggle input:checked::before {
  transform: translateX(20px);
}

.calculator {
  background: var(--calc-bg);
  padding: 20px;
  border-radius: 20px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
  width: 300px;
  margin-top: 60px;
}

#display {
  width: 100%;
  height: 60px;
  font-size: 28px;
  text-align: right;
  margin-bottom: 15px;
  padding: 10px 0px;
  border-radius: 12px;
  border: none;
  background: var(--display-bg);
  color: var(--text-color);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.4);
}

.buttons {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

button.btn {
  font-size: 20px;
  font-weight: bold;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  padding: 18px;
  transition: all 0.2s ease-in-out;
}

/* Digit buttons */
button.digit {
  background-color: #2d2d2d;
  color: #ffffff;
}
body.light button.digit {
  background-color: #ffffff;
  color: #000000;
}
button.digit:hover {
  background-color: #3a3a3a;
}
body.light button.digit:hover {
  background-color: #e0e0e0;
}

/* Operator buttons */
button.operator {
  background-color: #ff5722;
  color: #fff;
}
body.light button.operator {
  background-color: #ff9800;
}
button.operator:hover {
  background-color: #e64a19;
}
body.light button.operator:hover {
  background-color: #ff5722;
}

/* History */
.history-container {
  width: 300px;
  margin-top: 20px;
  background-color: var(--calc-bg);
  border-radius: 12px;
  padding: 15px;
  color: var(--text-color);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.history-container h3 {
  margin-top: 0;
  font-size: 18px;
  border-bottom: 1px solid var(--button-bg);
  padding-bottom: 5px;
}

#historyList {
  list-style: none;
  padding-left: 0;
  max-height: 200px;
  overflow-y: auto;
}

#historyList li {
  padding: 6px 0;
  border-bottom: 1px solid var(--button-hover);
  font-size: 16px;
}

.history-wrapper {
  position: absolute;
  top: 20px;
  left: 20px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.history-dropdown {
  margin-top: 8px;
  background-color: var(--calc-bg);
  border-radius: 10px;
  padding: 10px 15px;
  color: var(--text-color);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);
  width: 250px;
  z-index: 100;
}

.history-dropdown h3 {
  margin: 0 0 10px;
  font-size: 16px;
  border-bottom: 1px solid var(--button-bg);
  padding-bottom: 4px;
}

#historyList {
  list-style: none;
  padding: 0;
  margin: 0;
  max-height: 180px;
  overflow-y: auto;
}

#historyList li {
  padding: 5px 0;
  font-size: 14px;
  border-bottom: 1px solid var(--button-hover);
}
