:root {
  --bg: #ffffff;
  --text: #333;
  --button-bg: #3498db;
  --button-hover: #2980b9;
  --equals-bg: #2ecc71;
  --equals-hover: #27ae60;
  --display-bg: #f0f0f0;
}

body.dark {
  --bg: #1f1f1f;
  --text: #f0f0f0;
  --button-bg: #444;
  --button-hover: #666;
  --equals-bg: #27ae60;
  --equals-hover: #2ecc71;
  --display-bg: #333;
}

body {
  font-family: 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  margin: 0;
  transition: background 0.3s, color 0.3s;
}

.calculator {
  background: var(--bg);
  padding: 20px;
  border-radius: 20px;
  max-width: 360px;
  width: 100%;
  box-shadow: 0 10px 25px rgba(0,0,0,0.15);
  transition: background 0.3s, color 0.3s;
}

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#toggleMode {
  font-size: 1.4rem;
  background: none;
  border: none;
  cursor: pointer;
}

#display {
  width: 100%;
  font-size: 2rem;
  padding: 10px;
  margin: 15px 0;
  border: none;
  border-radius: 10px;
  text-align: right;
  background: var(--display-bg);
  color: var(--text);
}

.clear-button-wrapper {
  display: flex;
  justify-content: center;
  margin: 10px 0 15px;
}

.clear-btn {
  background: linear-gradient(135deg, #f85032, #e73827);
  color: white;
  font-size: 1rem;
  padding: 10px 25px;
  border: none;
  border-radius: 30px;
  cursor: pointer;
  transition: all 0.25s ease;
  box-shadow: 0 5px 10px rgba(0, 0, 0, 0.15);
}

.clear-btn:hover {
  transform: scale(1.05);
  background: linear-gradient(135deg, #e73827, #d52c1c);
}

body.dark .clear-btn {
  background: linear-gradient(135deg, #aa3939, #d46a6a);
}

body.dark .clear-btn:hover {
  background: linear-gradient(135deg, #d46a6a, #aa3939);
}

.buttons {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

button {
  padding: 18px;
  font-size: 1.2rem;
  border: none;
  border-radius: 12px;
  background: var(--button-bg);
  color: white;
  cursor: pointer;
  transition: 0.2s;
}

button:hover {
  background: var(--button-hover);
}

.equals {
  grid-column: span 2;
  background: var(--equals-bg);
}

.equals:hover {
  background: var(--equals-hover);
}

.history {
  margin-top: 20px;
}

.history h3 {
  margin-bottom: 10px;
  font-size: 1rem;
}

#historyList {
  list-style: none;
  padding: 0;
  max-height: 150px;
  overflow-y: auto;
}

#historyList li {
  padding: 6px 10px;
  border-bottom: 1px solid rgba(0,0,0,0.05);
  font-size: 0.95rem;
}
