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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans TC', sans-serif;
  background: #F1F5F9;
  color: #1E293B;
  line-height: 1.6;
}

/* ── Header ── */
.header {
  background: #1D4ED8;
  color: white;
  padding: 14px 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.header h1 { font-size: 1.2rem; font-weight: 700; }
.stats { font-size: 0.85rem; opacity: 0.85; }

/* ── Layout ── */
.main-layout {
  max-width: 1400px;
  margin: 24px auto;
  padding: 0 16px;
  display: flex;
  gap: 20px;
  align-items: flex-start;
}

/* ── Sidebar ── */
.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: white;
  border-radius: 12px;
  padding: 18px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.07);
  position: sticky;
  top: 72px;
}
.filter-group { margin-bottom: 14px; }
.filter-group label {
  display: block;
  font-size: 0.73rem;
  font-weight: 700;
  color: #64748B;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 5px;
}
.filter-group select,
.filter-group input {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid #E2E8F0;
  border-radius: 8px;
  font-size: 0.88rem;
  color: #1E293B;
  background: #F8FAFC;
  outline: none;
}
.filter-group select:focus,
.filter-group input:focus {
  border-color: #3B82F6;
  background: white;
}
.btn-secondary {
  width: 100%;
  padding: 8px;
  background: #F1F5F9;
  border: 1px solid #E2E8F0;
  border-radius: 8px;
  font-size: 0.84rem;
  cursor: pointer;
  color: #475569;
  transition: background 0.15s;
}
.btn-secondary:hover { background: #E2E8F0; }
.btn-random {
  width: 100%;
  padding: 8px;
  background: #1D4ED8;
  border: none;
  border-radius: 8px;
  font-size: 0.84rem;
  cursor: pointer;
  color: white;
  margin-top: 6px;
  transition: background 0.15s;
}
.btn-random:hover { background: #1E40AF; }
.btn-exam {
  width: 100%;
  padding: 8px;
  background: #7C3AED;
  border: none;
  border-radius: 8px;
  font-size: 0.84rem;
  cursor: pointer;
  color: white;
  margin-top: 6px;
  transition: background 0.15s;
}
.btn-exam:hover { background: #6D28D9; }
.random-row {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}
.random-row input {
  width: 54px;
  padding: 7px 8px;
  border: 1px solid #E2E8F0;
  border-radius: 8px;
  font-size: 0.88rem;
  color: #1E293B;
  background: #F8FAFC;
  text-align: center;
  outline: none;
}
.random-row input:focus { border-color: #3B82F6; background: white; }
.random-row .btn-random { flex: 1; margin-top: 0; }
body.dark .random-row input { background: #0F172A; border-color: #334155; color: #E2E8F0; }
body.dark .random-row input:focus { background: #1E293B; }
.btn-theme {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
  transition: background 0.15s;
}
.btn-theme:hover { background: rgba(255,255,255,0.15); }
.font-ctrl { display: flex; gap: 4px; }
.progress-stats {
  margin-top: 10px;
  font-size: 0.82rem;
  color: #475569;
  text-align: center;
  font-weight: 600;
}
.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot-correct { background: #22C55E; }
.dot-wrong   { background: #EF4444; }
.bm-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  color: #CBD5E1;
  padding: 0 2px;
  line-height: 1;
  flex-shrink: 0;
}
.bm-btn:hover { color: #F59E0B; }
.bm-btn.bm-active { color: #F59E0B; }
body.dark .bm-btn { color: #475569; }
body.dark .bm-btn:hover { color: #F59E0B; }
body.dark .bm-btn.bm-active { color: #F59E0B; }
body.dark .progress-stats { color: #64748B; }
.filter-stats {
  margin-top: 14px;
  font-size: 0.82rem;
  color: #94A3B8;
  text-align: center;
  padding-top: 12px;
  border-top: 1px solid #F1F5F9;
}

/* ── Content ── */
.content { flex: 1; min-width: 0; }

/* ── Question Card ── */
.question-card {
  background: white;
  border-radius: 10px;
  margin-bottom: 10px;
  border: 1px solid #E2E8F0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  overflow: hidden;
  transition: box-shadow 0.2s;
}
.question-card:hover { box-shadow: 0 3px 10px rgba(0,0,0,0.09); }
.question-card.expanded { border-color: #93C5FD; }

.question-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  cursor: pointer;
  user-select: none;
  background: #F8FAFC;
}
.question-header:hover { background: #EFF6FF; }

.question-meta {
  font-size: 0.75rem;
  color: #64748B;
  background: #E2E8F0;
  padding: 2px 8px;
  border-radius: 20px;
  white-space: nowrap;
}
.question-num {
  font-weight: 700;
  color: #1D4ED8;
  font-size: 0.9rem;
  white-space: nowrap;
}
.badge-mod {
  background: #FEF3C7;
  color: #92400E;
  font-size: 0.7rem;
  padding: 2px 7px;
  border-radius: 20px;
  font-weight: 700;
  white-space: nowrap;
}
.toggle-icon {
  margin-left: auto;
  color: #CBD5E1;
  font-size: 0.65rem;
  flex-shrink: 0;
}

.question-preview {
  padding: 6px 16px 11px;
  font-size: 0.85rem;
  color: #64748B;
  background: #F8FAFC;
  border-top: 1px solid #F1F5F9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.question-body {
  padding: 18px;
  border-top: 1px solid #E2E8F0;
}
.question-text {
  font-size: 0.93rem;
  line-height: 1.9;
  margin-bottom: 16px;
  white-space: pre-wrap;
}

/* ── Options ── */
.options { display: flex; flex-direction: column; gap: 7px; margin-bottom: 16px; }
.option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 14px;
  border-radius: 8px;
  background: #F8FAFC;
  border: 1px solid #E2E8F0;
  transition: background 0.15s, border-color 0.15s;
  cursor: pointer;
}
.option:hover {
  background: #EFF6FF;
  border-color: #93C5FD;
}
.option.correct {
  background: #DCFCE7;
  border-color: #86EFAC;
}
.option.wrong {
  background: #FEE2E2;
  border-color: #FCA5A5;
}
.option.selected {
  background: #EDE9FE;
  border-color: #A78BFA;
}
.option-label {
  font-weight: 700;
  color: #1D4ED8;
  min-width: 18px;
  font-size: 0.88rem;
  flex-shrink: 0;
}
.option-text { font-size: 0.88rem; color: #334155; line-height: 1.6; }

/* ── Answer ── */
.answer-reveal {
  font-size: 0.9rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  border-radius: 8px;
  margin-top: 4px;
}
.answer-correct {
  background: #DCFCE7;
  color: #15803D;
}
.answer-wrong {
  background: #FEE2E2;
  color: #B91C1C;
}
.badge-mod-small {
  background: #FEF3C7;
  color: #92400E;
  font-size: 0.68rem;
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 700;
}

/* ── Images ── */
.question-images {
  margin: 0 0 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.question-img {
  max-width: 100%;
  max-height: 320px;
  border-radius: 8px;
  border: 1px solid #E2E8F0;
  cursor: zoom-in;
  transition: transform 0.2s;
}
.question-img.zoomed {
  max-height: none;
  max-width: 100%;
  cursor: zoom-out;
  z-index: 10;
  position: relative;
}

/* ── Loading / Empty ── */
.loading, .empty {
  text-align: center;
  padding: 60px 20px;
  color: #94A3B8;
  font-size: 0.9rem;
}

/* ── Dark Mode ── */
body.dark {
  background: #0F172A;
  color: #E2E8F0;
}
body.dark .sidebar {
  background: #1E293B;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}
body.dark .filter-group label { color: #94A3B8; }
body.dark .filter-group select,
body.dark .filter-group input {
  background: #0F172A;
  border-color: #334155;
  color: #E2E8F0;
}
body.dark .filter-group select:focus,
body.dark .filter-group input:focus { background: #1E293B; border-color: #3B82F6; }
body.dark .btn-secondary { background: #1E293B; border-color: #334155; color: #94A3B8; }
body.dark .btn-secondary:hover { background: #334155; }
body.dark .filter-stats { color: #475569; border-color: #1E293B; }

body.dark .question-card { background: #1E293B; border-color: #334155; }
body.dark .question-card.expanded { border-color: #3B82F6; }
body.dark .question-header { background: #1E293B; }
body.dark .question-header:hover { background: #263348; }
body.dark .question-meta { background: #334155; color: #94A3B8; }
body.dark .question-num { color: #60A5FA; }
body.dark .question-preview { background: #1E293B; color: #64748B; border-color: #334155; }
body.dark .question-body { border-color: #334155; }
body.dark .question-text { color: #CBD5E1; }

body.dark .option { background: #0F172A; border-color: #334155; }
body.dark .option:hover { background: #1E3A5F; border-color: #3B82F6; }
body.dark .option.correct { background: #14532D; border-color: #16A34A; }
body.dark .option.wrong { background: #450A0A; border-color: #DC2626; }
body.dark .option.selected { background: #2E1065; border-color: #7C3AED; }
body.dark .option-label { color: #60A5FA; }
body.dark .option-text { color: #CBD5E1; }

body.dark .answer-correct { background: #14532D; color: #4ADE80; }
body.dark .answer-wrong { background: #450A0A; color: #F87171; }
body.dark .question-img { border-color: #334155; }
body.dark .loading, body.dark .empty { color: #475569; }
body.dark .footer { color: #475569; }

/* ── Back to Top ── */
#back-to-top {
  display: none;
  position: fixed;
  bottom: 28px;
  right: 24px;
  width: 40px;
  height: 40px;
  background: #1D4ED8;
  color: white;
  border: none;
  border-radius: 50%;
  font-size: 1.1rem;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  z-index: 200;
  transition: background 0.15s;
}
#back-to-top:hover { background: #1E40AF; }

/* ── Quiz History ── */
.quiz-history { margin-top: 14px; font-size: 0.8rem; }
.history-title { font-weight: 700; color: #64748B; font-size: 0.73rem; text-transform: uppercase; letter-spacing: 0.6px; margin-bottom: 6px; }
.history-row { display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px solid #F1F5F9; }
.history-date { color: #94A3B8; }
.history-info { font-weight: 600; color: #475569; }
body.dark .history-row { border-color: #1E293B; }
body.dark .history-info { color: #94A3B8; }

/* ── Note Box ── */
.note-box { margin-top: 10px; }
.note-label { font-size: 0.78rem; font-weight: 600; color: #64748B; margin-bottom: 5px; }
.note-textarea {
  width: 100%;
  min-height: 72px;
  padding: 8px 12px;
  border: 1px solid #E2E8F0;
  border-radius: 8px;
  font-size: 0.85rem;
  color: #334155;
  background: #F8FAFC;
  resize: vertical;
  outline: none;
  font-family: inherit;
  line-height: 1.6;
}
.note-textarea:focus { border-color: #3B82F6; background: white; }
body.dark .note-label { color: #64748B; }
body.dark .note-textarea { background: #0F172A; border-color: #334155; color: #CBD5E1; }
body.dark .note-textarea:focus { background: #1E293B; }

/* ── 官方解析 ── */
.official-note-box {
  margin-top: 10px;
  padding: 10px 14px;
  background: #F0FDF4;
  border-left: 4px solid #22C55E;
  border-radius: 0 8px 8px 0;
}
.official-note-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: #15803D;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.official-note-text {
  font-size: 0.88rem;
  color: #1E293B;
  line-height: 1.7;
}
.official-note-textarea {
  width: 100%;
  min-height: 80px;
  padding: 8px 12px;
  border: 1px solid #86EFAC;
  border-radius: 6px;
  font-size: 0.85rem;
  color: #166534;
  background: #DCFCE7;
  resize: vertical;
  outline: none;
  font-family: inherit;
  line-height: 1.6;
  box-sizing: border-box;
}
.official-note-textarea:focus { border-color: #22C55E; background: white; }
.admin-badge {
  background: #F59E0B;
  color: white;
  font-size: 0.68rem;
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 600;
}
.admin-banner {
  background: #F59E0B;
  color: white;
  text-align: center;
  padding: 8px 16px;
  font-size: 0.9rem;
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 1100;
}
.admin-export-btn {
  position: fixed;
  bottom: 80px;
  right: 20px;
  background: #22C55E;
  color: white;
  border: none;
  padding: 12px 18px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
  z-index: 1000;
}
.admin-export-btn:hover { background: #16A34A; }
body.dark .official-note-box { background: #052E16; border-color: #22C55E; }
body.dark .official-note-label { color: #4ADE80; }
body.dark .official-note-text { color: #D1FAE5; }
body.dark .official-note-textarea { background: #052E16; border-color: #22C55E; color: #D1FAE5; }

/* ── Changelog ── */
.changelog-panel {
  background: white;
  border: 1px solid #E2E8F0;
  border-left: 4px solid #1D4ED8;
  border-radius: 0 10px 10px 0;
  padding: 12px 16px;
  margin-bottom: 12px;
  font-size: 0.85rem;
}
.changelog-header {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.changelog-badge {
  background: #1D4ED8;
  color: white;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  white-space: nowrap;
}
.changelog-date {
  font-size: 0.75rem;
  color: #94A3B8;
  white-space: nowrap;
}
.changelog-title { color: #1E293B; }
.changelog-toggle {
  margin-left: auto;
  background: none;
  border: none;
  color: #3B82F6;
  font-size: 0.8rem;
  cursor: pointer;
  padding: 0;
  white-space: nowrap;
}
.changelog-toggle:hover { text-decoration: underline; }
.changelog-items {
  margin: 6px 0 0 16px;
  color: #475569;
  line-height: 1.7;
}
.changelog-entry { margin-top: 12px; padding-top: 12px; border-top: 1px solid #F1F5F9; }
.changelog-entry-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
body.dark .changelog-panel { background: #1E293B; border-color: #334155; border-left-color: #3B82F6; }
body.dark .changelog-title { color: #E2E8F0; }
body.dark .changelog-items { color: #94A3B8; }
body.dark .changelog-entry { border-color: #334155; }

/* ── Quiz Bar ── */
#quiz-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #1D4ED8;
  color: white;
  padding: 10px 16px;
  border-radius: 10px;
  margin-bottom: 12px;
}
.quiz-progress-text { font-size: 0.88rem; font-weight: 600; white-space: nowrap; }
.quiz-progress-track {
  flex: 1;
  height: 6px;
  background: rgba(255,255,255,0.25);
  border-radius: 3px;
  overflow: hidden;
}
.quiz-progress-fill {
  height: 100%;
  background: white;
  border-radius: 3px;
  width: 0%;
  transition: width 0.4s;
}
.quiz-exit-btn {
  background: rgba(255,255,255,0.2);
  border: 1px solid rgba(255,255,255,0.4);
  color: white;
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 0.82rem;
  cursor: pointer;
  white-space: nowrap;
}
.quiz-exit-btn:hover { background: rgba(255,255,255,0.35); }
.quiz-submit-btn {
  background: #F59E0B;
  border: none;
  color: white;
  padding: 5px 14px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.quiz-submit-btn:hover { background: #D97706; }

/* ── Quiz Summary ── */
.summary-card {
  background: white;
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 16px;
  border: 1px solid #E2E8F0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.07);
  text-align: center;
}
.summary-title { font-size: 1.1rem; font-weight: 700; color: #1E293B; margin-bottom: 20px; }
.summary-stats { display: flex; justify-content: center; gap: 16px; }
.summary-stat {
  flex: 1;
  max-width: 110px;
  padding: 16px 8px;
  border-radius: 10px;
}
.summary-stat-correct { background: #DCFCE7; }
.summary-stat-wrong   { background: #FEE2E2; }
.summary-stat-rate    { background: #EFF6FF; }
.summary-num { font-size: 1.6rem; font-weight: 700; }
.summary-stat-correct .summary-num { color: #15803D; }
.summary-stat-wrong   .summary-num { color: #B91C1C; }
.summary-stat-rate    .summary-num { color: #1D4ED8; }
.summary-label { font-size: 0.8rem; color: #64748B; margin-top: 4px; }
body.dark .summary-card { background: #1E293B; border-color: #334155; }
body.dark .summary-title { color: #E2E8F0; }

/* ── Footer ── */
.footer {
  text-align: center;
  padding: 24px;
  font-size: 0.82rem;
  color: #94A3B8;
}

/* ── Responsive ── */
@media (max-width: 700px) {
  .main-layout { flex-direction: column; padding: 0 8px; margin: 12px auto; }
  .sidebar { width: 100%; position: static; padding: 12px; }
  .header h1 { font-size: 1rem; }
  .header-inner { padding: 0; }

  .question-card { margin-bottom: 8px; }
  .question-header { padding: 10px 12px; flex-wrap: wrap; }
  .question-meta { font-size: 0.7rem; }
  .question-num { font-size: 0.85rem; }
  .question-preview { font-size: 0.8rem; padding: 5px 12px 9px; }

  .question-body { padding: 12px; }
  .question-text { font-size: 0.88rem; line-height: 1.8; }
  .option { padding: 10px 12px; }
  .option-text { font-size: 0.85rem; }

  .question-img { max-width: 100%; max-height: none; }
}
