:root {
  color-scheme: light;
  --base-font-size: 16px;
  --bg: #f4f6f9;
  --card: #ffffff;
  --line: #e1e6f0;
  --primary: #1f6feb;
  --text: #1f2937;
  --muted: #64748b;
  --content-bg: #f8fbff;
  --content-line: #e2ebf8;
}

* {
  box-sizing: border-box;
}

.hidden {
  display: none !important;
}

body {
  margin: 0;
  font-family: "Segoe UI", "Noto Sans TC", Arial, sans-serif;
  font-size: var(--base-font-size);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

body.dark-mode {
  color-scheme: dark;
  --bg: #0d1117;
  --card: #161b22;
  --line: #30363d;
  --primary: #58a6ff;
  --text: #c9d1d9;
  --muted: #8b949e;
  --content-bg: #0d1117;
  --content-line: #30363d;
}

/* === Navbar Styling === */
.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: 12px 24px;
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.nav-logo {
  height: 36px;
  width: 36px;
  object-fit: contain;
  border-radius: 8px;
}

.nav-title {
  font-size: 1.3em;
  font-weight: 700;
  letter-spacing: 0.5px;
  background: linear-gradient(135deg, #1f6feb, #60a5fa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.nav-tabs {
  display: flex;
  gap: 8px;
  flex: 1;
  justify-content: center;
}

.nav-home-btn {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s;
  font-size: 0.9em;
}

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

/* === Home Panel Styling === */
.home-panel {
  display: flex;
  flex-direction: column;
  gap: 30px;
  margin-top: 10px;
}

.hero-section {
  text-align: center;
  padding: 40px 20px;
  background: linear-gradient(135deg, rgba(31, 111, 235, 0.08) 0%, rgba(96, 165, 250, 0.05) 100%);
  border: 1px solid var(--line);
  border-radius: 16px;
}

.hero-section h1 {
  margin: 0 0 10px;
  font-size: 2.2em;
  font-weight: 800;
}

.hero-section p {
  margin: 0;
  color: var(--muted);
  font-size: 1.1em;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
}

.lesson-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 24px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.02);
  transition: transform 0.2s, box-shadow 0.2s;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100%;
}

.lesson-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.06);
  border-color: var(--primary);
}

.card-icon {
  font-size: 2em;
  margin-bottom: 12px;
}

.lesson-card h3 {
  margin: 0 0 8px;
  font-size: 1.25em;
  font-weight: 700;
}

.lesson-card p {
  margin: 0 0 20px;
  font-size: 0.9em;
  color: var(--muted);
  flex-grow: 1;
}

.card-actions {
  display: flex;
  gap: 10px;
}

.card-actions button {
  flex: 1;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.85em;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-card-learn {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
}

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

.btn-card-quiz {
  border: none;
  background: var(--primary);
  color: var(--bg);
}

.btn-card-quiz:hover {
  opacity: 0.9;
}

.quick-quiz-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.08) 0%, rgba(34, 197, 94, 0.04) 100%);
  border: 1px solid rgba(34, 197, 94, 0.2);
  border-radius: 14px;
  padding: 24px;
  margin-top: 10px;
}

.quick-quiz-info h3 {
  margin: 0 0 4px;
  color: #22c55e;
  font-size: 1.3em;
  font-weight: 700;
}

.quick-quiz-info p {
  margin: 0;
  color: var(--muted);
  font-size: 0.95em;
}

.quick-quiz-card button {
  padding: 12px 24px;
  font-size: 1em;
  background: #22c55e;
  color: white;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(34, 197, 94, 0.2);
  transition: all 0.2s;
}

.quick-quiz-card button:hover {
  background: #16a34a;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(34, 197, 94, 0.3);
}

/* Adjust layout since header is removed */
main {
  max-width: 1200px;
  margin: 20px auto;
  padding: 0 16px 30px;
}

.detail-status {
  display: inline-block;
  margin-right: 8px;
  font-weight: 600;
}

.detail-status.correct {
  color: #22c55e;
}

.detail-status.incorrect {
  color: #ef4444;
}

.result-buttons {
  display: flex;
  gap: 12px;
  margin-top: 20px;
}

.result-buttons button {
  flex: 1;
}

.toolbar button {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  border-radius: 10px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 1em;
}

.font-size-label {
  display: inline-flex;
  align-items: center;
  padding: 0 6px;
  color: var(--muted);
  font-weight: 600;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.tab-btn {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
  font-size: 0.95em;
}

.tab-btn.active {
  border-color: var(--primary);
  color: var(--primary);
  font-weight: 600;
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px;
}

.section-title {
  margin-top: 0;
}

.links a {
  color: var(--primary);
  margin-right: 10px;
}

.word-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 8px 16px;
}

.word-item {
  border-bottom: 1px dashed var(--line);
  padding-bottom: 5px;
}

.collapsible-section {
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
}

.collapsible-section summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 8px;
}

.collapsible-section[open] summary {
  border-bottom: 1px dashed var(--line);
  padding-bottom: 6px;
}

.content-box {
  background: var(--content-bg);
  border: 1px solid var(--content-line);
  border-radius: 10px;
  padding: 12px;
  white-space: pre-line;
}

.translation-popup {
  position: absolute;
  z-index: 9999;
  width: min(380px, calc(100vw - 20px));
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.translation-popup.hidden {
  display: none;
}

.translation-popup-title {
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--primary);
}

.translation-popup-origin {
  color: var(--muted);
  margin-bottom: 6px;
  border-bottom: 1px dashed var(--line);
  padding-bottom: 6px;
  white-space: pre-wrap;
}

.translation-popup-result {
  white-space: pre-wrap;
}

/* === 考題練習樣式 === */
.quiz-panel {
  display: block;
}

.quiz-panel.hidden {
  display: none;
}

.quiz-start,
.quiz-config,
.quiz-container,
.quiz-result {
  display: block;
}

.quiz-start.hidden,
.quiz-config.hidden,
.quiz-container.hidden,
.quiz-result.hidden {
  display: none;
}

.quiz-start h2,
.quiz-config h2,
.quiz-result h2 {
  margin-top: 0;
  color: var(--primary);
}

.quiz-course-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin: 20px 0;
}

.quiz-course-btn {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  border-radius: 10px;
  padding: 16px;
  cursor: pointer;
  text-align: left;
  font-size: 0.95em;
  transition: all 0.2s;
}

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

.quiz-course-title {
  font-weight: 600;
  margin: 0 0 4px;
}

.quiz-course-info {
  font-size: 0.85em;
  color: var(--muted);
  margin: 0;
}

.quiz-config-options {
  background: var(--content-bg);
  border: 1px solid var(--content-line);
  border-radius: 10px;
  padding: 16px;
  margin: 20px 0;
}

.quiz-config-options label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}

.quiz-config-options select {
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--card);
  color: var(--text);
  font-size: 1em;
  cursor: pointer;
}

.quiz-progress {
  margin-bottom: 20px;
}

.quiz-progress span {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  color: var(--text);
}

.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--content-bg);
  border: 1px solid var(--content-line);
  border-radius: 4px;
  overflow: hidden;
}

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

.question-area {
  background: var(--content-bg);
  border: 1px solid var(--content-line);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 20px;
}

.question-area h3 {
  margin-top: 0;
  color: var(--primary);
  font-size: 1.1em;
}

.options-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.option-btn {
  border: 2px solid var(--line);
  background: var(--card);
  color: var(--text);
  border-radius: 8px;
  padding: 12px 14px;
  text-align: left;
  cursor: pointer;
  font-size: 0.95em;
  transition: all 0.2s;
}

.option-btn:hover:not(:disabled) {
  border-color: var(--primary);
  background: var(--content-bg);
}

.option-btn.selected {
  border-color: var(--primary);
  background: var(--primary);
  color: var(--bg);
  font-weight: 600;
}

.option-btn.correct {
  border-color: #22c55e;
  background: #22c55e;
  color: white;
}

.option-btn.incorrect {
  border-color: #ef4444;
  background: #ef4444;
  color: white;
}

.option-btn:disabled {
  cursor: not-allowed;
  opacity: 0.7;
}

.quiz-buttons {
  display: flex;
  gap: 12px;
  margin-top: 20px;
}

.btn-primary {
  flex: 1;
  padding: 12px;
  border: none;
  background: var(--primary);
  color: var(--bg);
  border-radius: 8px;
  cursor: pointer;
  font-size: 1em;
  font-weight: 600;
  transition: opacity 0.2s;
}

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

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-secondary {
  flex: 1;
  padding: 12px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  border-radius: 8px;
  cursor: pointer;
  font-size: 1em;
  font-weight: 600;
  transition: all 0.2s;
}

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

.btn-next {
  flex: 1;
  padding: 12px;
  border: none;
  background: var(--primary);
  color: var(--bg);
  border-radius: 8px;
  cursor: pointer;
  font-size: 1em;
  font-weight: 600;
  transition: opacity 0.2s;
}

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

.btn-next.hidden {
  display: none;
}

.back-btn {
  margin-top: 16px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95em;
  transition: all 0.2s;
}

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

.result-score {
  text-align: center;
  margin: 30px 0;
}

.score-circle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 150px;
  height: 150px;
  border-radius: 50%;
  background: var(--content-bg);
  border: 3px solid var(--primary);
  font-size: 2.5em;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 16px;
}

.result-score p {
  font-size: 1.1em;
  color: var(--muted);
}

.result-details {
  background: var(--content-bg);
  border: 1px solid var(--content-line);
  border-radius: 10px;
  padding: 16px;
  margin: 20px 0;
  max-height: 300px;
  overflow-y: auto;
}

.detail-item {
  padding: 8px 0;
  border-bottom: 1px dashed var(--line);
  font-size: 0.9em;
}

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

.detail-status {
  display: inline-block;
  margin-right: 8px;
  font-weight: 600;
}

.detail-status.correct {
  color: #22c55e;
}

.detail-status.incorrect {
  color: #ef4444;
}

.result-buttons {
  display: flex;
  gap: 12px;
  margin-top: 20px;
}

.result-buttons button {
  flex: 1;
}

/* Exam Paper Styles */
.exam-paper-area {
  margin-top: 20px;
  text-align: left;
}
.exam-section {
  margin-bottom: 30px;
}
.exam-question {
  margin-bottom: 15px;
}
.exam-question label {
  display: block;
  margin-bottom: 5px;
  font-weight: bold;
}
.exam-input, .exam-textarea {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  border-radius: 4px;
  font-size: 1rem;
  font-family: inherit;
}
.exam-textarea {
  resize: vertical;
}
.exam-input:focus, .exam-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(31, 111, 235, 0.2);
}
.correct-ans {
  color: #ef4444;
  margin-top: 5px;
  font-size: 0.9em;
}
