:root {
  --bg-color: #ffffff;
  --text-color: #222;
  --primary: #4caf50;
  --secondary: #f1f1f1;
  --button-color: #e0e0e0;
  --button-text: #000;
}

body.dark {
  --bg-color: #121212;
  --text-color: #ffffff;
  --primary: #81c784;
  --secondary: #1e1e1e;
  --button-color: #333;
  --button-text: #fff;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Segoe UI', sans-serif;
}

body {
  background-color: var(--bg-color);
  color: var(--text-color);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.container {
  max-width: 400px;
  width: 100%;
  padding: 20px;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

h1 {
  font-size: 1.8em;
  color: var(--primary);
}

#toggleTheme {
  background: none;
  border: none;
  font-size: 1.2em;
  cursor: pointer;
  color: var(--text-color);
}

.calculator {
  background: var(--secondary);
  border-radius: 10px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.calculator input {
  width: 100%;
  padding: 12px;
  font-size: 1em;
  margin-bottom: 10px;
  border: 1px solid #ccc;
  border-radius: 6px;
  background: var(--bg-color);
  color: var(--text-color);
}

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

button {
  padding: 15px;
  font-size: 1em;
  border: none;
  border-radius: 6px;
  background-color: var(--button-color);
  color: var(--button-text);
  cursor: pointer;
  transition: background-color 0.2s ease;
}

button:hover {
  background-color: var(--primary);
  color: #fff;
}

button.clear {
  grid-column: span 4;
  background-color: #f44336;
  color: white;
}

.history {
  margin-top: 30px;
}

.history input {
  width: 100%;
  margin-bottom: 10px;
  padding: 10px;
  border-radius: 6px;
  border: 1px solid #ccc;
  background: var(--bg-color);
  color: var(--text-color);
}

#historyList {
  list-style: none;
  max-height: 200px;
  overflow-y: auto;
  padding: 10px;
  background: var(--secondary);
  border-radius: 8px;
}

#historyList li {
  padding: 8px;
  border-bottom: 1px solid #ccc;
}
