:root {
  --color1: #667eea;
  --color2: #764ba2;
}

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

body {
  font-family: Arial, sans-serif;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--color1), var(--color2));
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
  transition: all 0.3s;
}

body.dark {
  background: linear-gradient(135deg, #1a1a2e, #16213e);
}

.container {
  background: white;
  border-radius: 20px;
  padding: 40px;
  width: 100%;
  max-width: 600px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  transition: all 0.3s;
}

body.dark .container {
  background: #1e1e2e;
  color: white;
}

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
  flex-wrap: wrap;
  gap: 10px;
}

h1 {
  color: var(--color1);
  font-size: 28px;
}

body.dark h1 {
  color: #a78bfa;
}

p {
  color: #888;
  margin-bottom: 20px;
}

body.dark p {
  color: #aaa;
}

.input-field {
  width: 100%;
  padding: 15px;
  font-size: 16px;
  border-radius: 12px;
  border: 2px solid var(--color1);
  outline: none;
  margin-top: 15px;
  transition: all 0.3s;
}

body.dark .input-field {
  background: #2a2a3e;
  color: white;
  border-color: #a78bfa;
}

.dark-btn {
  background: #f0f0f0;
  border: none;
  padding: 8px 15px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 14px;
  width: auto;
}

body.dark .dark-btn {
  background: #333;
  color: white;
}

.logout-btn {
  background: #ff4d4d;
  color: white;
  border: none;
  padding: 8px 15px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 14px;
  width: auto;
}

.mode-btns {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.mode-btn {
  flex: 1;
  background: #f0f0f0;
  color: #333;
  border: 2px solid #ddd;
  padding: 10px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 13px;
  width: auto;
}

.mode-btn.active {
  background: linear-gradient(135deg, var(--color1), var(--color2));
  color: white;
  border: none;
}

body.dark .mode-btn {
  background: #333;
  color: white;
  border-color: #555;
}

.subjects {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.subject-btn {
  background: #f0f0f0;
  color: #333;
  border: 2px solid #ddd;
  padding: 8px 15px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 14px;
  width: auto;
}

.subject-btn.active {
  background: linear-gradient(135deg, var(--color1), var(--color2));
  color: white;
  border: none;
}

body.dark .subject-btn {
  background: #333;
  color: white;
  border-color: #555;
}

textarea {
  width: 100%;
  padding: 15px;
  font-size: 16px;
  border-radius: 12px;
  border: 2px solid var(--color1);
  resize: none;
  outline: none;
  transition: all 0.3s;
}

body.dark textarea {
  background: #2a2a3e;
  color: white;
  border-color: #a78bfa;
}

.main-btn {
  width: 100%;
  background: linear-gradient(135deg, var(--color1), var(--color2));
  color: white;
  padding: 15px;
  font-size: 18px;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  margin-top: 15px;
}

.main-btn:hover {
  opacity: 0.9;
}

#answer {
  margin-top: 20px;
  background: #f8f8ff;
  padding: 20px;
  border-radius: 12px;
  border: 2px solid var(--color1);
  font-size: 16px;
  line-height: 1.8;
  min-height: 60px;
  color: #333;
  transition: all 0.3s;
}

body.dark #answer {
  background: #2a2a3e;
  color: white;
  border-color: #a78bfa;
}

#quiz-question {
  background: #f8f8ff;
  padding: 20px;
  border-radius: 12px;
  border: 2px solid var(--color1);
  font-size: 16px;
  line-height: 1.8;
  color: #333;
  margin-bottom: 15px;
  margin-top: 15px;
}

body.dark #quiz-question {
  background: #2a2a3e;
  color: white;
  border-color: #a78bfa;
}

#quiz-result {
  margin-top: 15px;
  padding: 15px;
  border-radius: 12px;
  font-size: 16px;
  line-height: 1.8;
}

.stat-card {
  background: #f8f8ff;
  border: 2px solid var(--color1);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 15px;
  text-align: center;
}

body.dark .stat-card {
  background: #2a2a3e;
  border-color: #a78bfa;
}

.stat-number {
  font-size: 40px;
  font-weight: bold;
  color: var(--color1);
}

body.dark .stat-number {
  color: #a78bfa;
}

.stat-label {
  font-size: 16px;
  color: #888;
  margin-top: 5px;
}

.theme-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 15px;
}

.theme-card {
  padding: 25px;
  border-radius: 15px;
  color: white;
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  text-align: center;
  transition: transform 0.2s;
}

.theme-card:hover {
  transform: scale(1.05);
}

#history-section {
  margin-top: 30px;
}

.history-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}

h2 {
  color: var(--color1);
  font-size: 20px;
}

body.dark h2 {
  color: #a78bfa;
}

.clear-btn {
  background: #ff4d4d;
  color: white;
  border: none;
  padding: 8px 15px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 14px;
  width: auto;
}

.history-item {
  background: #f8f8ff;
  border: 2px solid var(--color1);
  border-radius: 12px;
  padding: 15px;
  margin-bottom: 15px;
}

body.dark .history-item {
  background: #2a2a3e;
  border-color: #a78bfa;
  color: white;
}

.history-question {
  font-weight: bold;
  color: var(--color1);
  margin-bottom: 8px;
}

body.dark .history-question {
  color: #a78bfa;
}

.history-subject {
  font-size: 12px;
  color: #888;
  margin-bottom: 8px;
}

@media (max-width: 480px) {
  .container {
    padding: 20px;
  }
  h1 {
    font-size: 22px;
  }
  .subject-btn {
    padding: 6px 10px;
    font-size: 12px;
  }
  .main-btn {
    font-size: 16px;
  }
}