/* ===== Design System ===== */
:root {
  --primary: #6b5b4d;
  --primary-hover: #5a4a3d;
  --bg: #f5f1ea;
  --card-bg: #ffffff;
  --text: #2d2520;
  --text-muted: #8b7d6b;
  --border: #e5dfd5;
  --shadow: rgba(45, 37, 32, 0.08);
  --shadow-hover: rgba(45, 37, 32, 0.12);
  --success: #4a7c59;
  --error: #c85a54;
}

[data-theme="dark"] {
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --bg: #0f172a;
  --card-bg: rgba(30, 41, 59, 0.7);
  --text: #f8fafc;
  --text-muted: #94a3b8;
  --border: rgba(255, 255, 255, 0.1);
  --shadow: rgba(0, 0, 0, 0.5);
  --shadow-hover: rgba(0, 0, 0, 0.7);
  --success: #22c55e;
  --error: #ef4444;
}

/* ===== Base Styles ===== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 2rem;
  transition: background-color 0.3s ease;
}

[data-theme="dark"] body {
  background: radial-gradient(circle at top left, #1e1b4b, #0f172a);
}

/* ===== Container & Card ===== */
.container {
  width: 100%;
  max-width: 700px;
}

.card {
  background: var(--card-bg);
  border-radius: 24px;
  padding: 3rem;
  box-shadow: 0 4px 24px var(--shadow);
  border: 1px solid var(--border);
  position: relative;
  transition: all 0.3s ease;
}

[data-theme="dark"] .card {
  backdrop-filter: blur(12px);
}

@media (max-width: 600px) {
  .card {
    padding: 1.5rem;
    border-radius: 16px;
  }

  h1 {
    font-size: 1.5rem;
    margin-bottom: 2rem;
  }

  body {
    padding: 1rem;
  }
}

/* ===== Typography ===== */
h1 {
  font-size: 2rem;
  font-weight: 600;
  text-align: center;
  margin-bottom: 2.5rem;
  color: var(--text);
  letter-spacing: -0.02em;
}

label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
}

/* ===== Form Elements ===== */
.input-group {
  margin-bottom: 1.5rem;
}

select,
textarea {
  width: 100%;
  padding: 0.875rem 1rem;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
  transition: all 0.2s;
}

select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(107, 91, 77, 0.1);
}

[data-theme="dark"] select,
[data-theme="dark"] textarea {
  background: rgba(0, 0, 0, 0.2);
  border-color: var(--border);
}

.library-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

@media (max-width: 600px) {
  .library-grid {
    grid-template-columns: 1fr;
    gap: 0;
  }
}

select:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

textarea {
  min-height: 120px;
  resize: vertical;
  font-family: inherit;
}

/* ===== Letter Tile Inputs ===== */
input[type="text"] {
  width: 100%;
  padding: 1rem;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-size: 1.1rem;
  font-family: inherit;
  letter-spacing: 0.05em;
  text-align: center;
  transition: all 0.2s;
}

input[type="text"]:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(107, 91, 77, 0.1);
}

[data-theme="dark"] input[type="text"] {
  background: rgba(0, 0, 0, 0.2);
  border-color: var(--border);
  color: var(--text);
}

input[type="text"]:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ===== Buttons ===== */
button {
  width: 100%;
  padding: 0.875rem 1.5rem;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 12px;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  box-shadow: 0 2px 8px var(--shadow);
}

button:hover {
  background: var(--primary-hover);
  box-shadow: 0 4px 12px var(--shadow-hover);
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
}

.secondary-btn {
  background: transparent;
  color: var(--text);
  border: 1.5px solid var(--border);
  box-shadow: none;
  margin-top: 1rem;
}

.secondary-btn:hover {
  background: var(--bg);
  border-color: var(--primary);
}

[data-theme="dark"] .secondary-btn {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--border);
}

[data-theme="dark"] .secondary-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* ===== Quiz Mode Selection ===== */
#quiz-mode-selection {
  margin-top: 1rem;
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  padding: 0.5rem;
  background: var(--bg);
  border-radius: 12px;
  border: 1.5px solid var(--border);
}

#quiz-mode-selection label {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  border-radius: 8px;
  transition: all 0.2s;
  color: var(--text);
  font-size: 0.9rem;
  margin: 0;
}

#quiz-mode-selection label:hover {
  background: rgba(107, 91, 77, 0.08);
}

#quiz-mode-selection input[type="radio"] {
  width: auto;
  accent-color: var(--primary);
}

[data-theme="dark"] #quiz-mode-selection {
  background: rgba(255, 255, 255, 0.03);
}

[data-theme="dark"] #quiz-mode-selection label:hover {
  background: rgba(255, 255, 255, 0.05);
}

/* ===== Quiz View ===== */
.quiz-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1.5px solid var(--border);
}

.progress-bar {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  margin-bottom: 2.5rem;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--primary);
  transition: width 0.3s ease;
  border-radius: 3px;
}

/* ===== Word Display Card ===== */
.pronounce-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 2.5rem;
  padding: 2rem;
  background: var(--bg);
  border-radius: 16px;
  border: 1.5px solid var(--border);
}

[data-theme="dark"] .pronounce-box {
  background: rgba(255, 255, 255, 0.03);
}

.speak-btn {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  padding: 0;
  background: var(--primary);
  box-shadow: 0 4px 16px var(--shadow);
}

.speak-btn:hover {
  background: var(--primary-hover);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px var(--shadow-hover);
}

.speak-btn.speaking {
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.7);
  }

  70% {
    transform: scale(1.05);
    box-shadow: 0 0 0 10px rgba(99, 102, 241, 0);
  }

  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(99, 102, 241, 0);
  }
}

.speak-btn i {
  width: 32px;
  height: 32px;
  color: #ffffff;
}

/* ===== Status Badges ===== */
.status-badge {
  padding: 0.375rem 1rem;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.status-correct {
  background: var(--success);
  color: white;
}

.status-incorrect {
  background: var(--error);
  color: white;
}

/* ===== Feedback ===== */
.feedback {
  margin-top: 1.5rem;
  padding: 1.25rem;
  border-radius: 12px;
  animation: slideIn 0.3s ease-out;
  font-size: 0.95rem;
  line-height: 1.5;
}

@keyframes slideIn {
  from {
    transform: translateY(10px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* ===== Theme Toggle ===== */
.theme-toggle {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 50%;
  width: 44px;
  height: 44px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 2px 8px var(--shadow);
}

.theme-toggle:hover {
  background: var(--primary);
  color: white;
  transform: rotate(15deg) scale(1.05);
}

[data-theme="dark"] .theme-toggle {
  background: transparent;
  backdrop-filter: blur(4px);
}

/* ===== Footer ===== */
.copyright-footer {
  text-align: center;
  margin-top: 2rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  opacity: 0.7;
}

/* ===== Utilities ===== */
.hidden { display: none; }

.review-words-container {
  max-height: 350px;
  overflow-y: auto;
  background: var(--bg);
  border-radius: 1rem;
  padding: 0.5rem;
  border: 1px solid var(--border);
}

.review-word-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}

.review-word-item:last-child {
  border-bottom: none;
}

.review-word-text {
  font-weight: 600;
  color: var(--text);
}

.review-word-info {
  display: flex;
  flex-direction: column;
}

.review-word-context {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.review-word-due {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.05);
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
}


#review-list-subtitle {
  text-align: center;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

#review-list-subtitle.status-success {
  color: var(--success);
}

.view-actions {
  margin-top: 2rem;
}

.setup-notice {
  margin: 0 0 1rem 0;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
}

.setup-notice.error {
  border-color: var(--error);
  color: var(--error);
  background: rgba(200, 90, 84, 0.08);
}

.btn--outline {
  background: var(--bg);
  border: 1px solid var(--primary);
  color: var(--primary);
}

.setup-actions {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 1rem;
}

@media (max-width: 700px) {
  .setup-actions {
    grid-template-columns: 1fr;
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.card {
  animation: fadeIn 0.4s ease-out;
}

/* ===== Empty Input Shake ===== */
@keyframes inputShake {

  0%,
  100% {
    transform: translateX(0);
  }

  20% {
    transform: translateX(-6px);
  }

  40% {
    transform: translateX(6px);
  }

  60% {
    transform: translateX(-4px);
  }

  80% {
    transform: translateX(4px);
  }
}

.input-shake {
  animation: inputShake 0.35s ease;
  border-color: var(--error) !important;
  box-shadow: 0 0 0 3px rgba(200, 90, 84, 0.2) !important;
}
