:root {
  --primary: #1e3a8a;
  --primary-light: #3b82f6;
  --primary-dark: #172554;
  --accent: #b45309;
  --accent-light: #f59e0b;
  --bg: #f8fafc;
  --card-bg: #ffffff;
  --text: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --tag-bg: #f1f5f9;
  --success: #059669;
  --success-bg: #ecfdf5;
  --danger: #dc2626;
  --radius: 12px;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --font-serif: "Songti SC", "Noto Serif CJK TC", "Source Han Serif TC", "PMingLiU", "Georgia", serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
header.site-header {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #1e3a8a 100%);
  color: #ffffff;
  padding: 2.2rem 1.5rem 1.6rem;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

header.site-header::after {
  content: "";
  position: absolute;
  top: -50%;
  right: -10%;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(59, 130, 246, 0.15) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}

.header-container {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

.brand-wrapper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.brand-title-group h1 {
  font-family: var(--font-serif);
  font-size: 2.1rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.brand-badge {
  font-size: 0.8rem;
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.4);
  padding: 0.2rem 0.6rem;
  border-radius: 9999px;
  font-family: var(--font-sans);
  font-weight: 600;
}

.brand-subtitle {
  color: #94a3b8;
  font-size: 0.95rem;
  margin-top: 0.3rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.mode-toggle-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #ffffff;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.88rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.2s ease;
}

.mode-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.3);
}

.mode-toggle-btn.active {
  background: #d97706;
  border-color: #f59e0b;
}

/* Stats metrics strip */
.stats-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.8rem;
  margin-top: 0.5rem;
}

.stat-item {
  background: rgba(255, 255, 255, 0.07);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 0.75rem 1rem;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
}

.stat-val {
  font-size: 1.5rem;
  font-weight: 700;
  color: #f8fafc;
  line-height: 1.2;
}

.stat-lbl {
  font-size: 0.78rem;
  color: #94a3b8;
  margin-top: 0.2rem;
}

/* Navigation tabs */
nav.main-nav {
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 40;
  box-shadow: var(--shadow-sm);
}

.nav-container {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  overflow-x: auto;
  scrollbar-width: none;
}

.nav-container::-webkit-scrollbar {
  display: none;
}

.nav-tab {
  padding: 1rem 1.4rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-muted);
  border: none;
  background: transparent;
  cursor: pointer;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border-bottom: 3px solid transparent;
  transition: all 0.2s ease;
}

.nav-tab:hover {
  color: var(--primary);
  background: #f8fafc;
}

.nav-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: #ffffff;
}

.nav-tab .tab-badge {
  background: var(--tag-bg);
  color: var(--text-muted);
  font-size: 0.75rem;
  padding: 0.15rem 0.5rem;
  border-radius: 9999px;
}

.nav-tab.active .tab-badge {
  background: #dbeafe;
  color: var(--primary);
}

/* Main Container */
main.main-content {
  max-width: 1280px;
  width: 100%;
  margin: 1.5rem auto;
  padding: 0 1rem;
  flex: 1;
}

.tab-pane {
  display: none;
  animation: fadeIn 0.25s ease;
}

.tab-pane.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Filter controls bar */
.filter-bar {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.8rem;
}

.filter-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  min-width: 70px;
}

.filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.pill-btn {
  background: var(--tag-bg);
  border: 1px solid transparent;
  color: var(--text);
  font-size: 0.82rem;
  padding: 0.3rem 0.75rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.pill-btn:hover {
  background: #e2e8f0;
}

.pill-btn.active {
  background: var(--primary);
  color: #ffffff;
  font-weight: 600;
}

.search-input-wrap {
  flex: 1;
  min-width: 260px;
  position: relative;
}

.search-input {
  width: 100%;
  padding: 0.65rem 1rem 0.65rem 2.4rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.92rem;
  background-color: #f8fafc;
  outline: none;
  transition: border-color 0.2s;
}

.search-input:focus {
  border-color: var(--primary-light);
  background-color: #ffffff;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.search-icon {
  position: absolute;
  left: 0.8rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

/* Question list */
.questions-grid {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.question-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.question-card:hover {
  box-shadow: var(--shadow);
  border-color: #cbd5e1;
}

.q-header {
  padding: 1rem 1.4rem;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.8rem;
}

.q-badge-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.badge {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: 6px;
}

.badge-year {
  background: #e0f2fe;
  color: #0369a1;
}

.badge-qnum {
  background: #fef3c7;
  color: #92400e;
}

.badge-cat {
  background: #ede9fe;
  color: #6d28d9;
}

.badge-format {
  background: #f1f5f9;
  color: #475569;
}

.badge-poet {
  background: #dcfce7;
  color: #15803d;
  font-family: var(--font-serif);
}

.q-source-link {
  font-size: 0.82rem;
  color: var(--primary-light);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.q-source-link:hover {
  text-decoration: underline;
}

.q-body {
  padding: 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

/* Reading passage */
.reading-box {
  background: #fffbeb;
  border-left: 4px solid #f59e0b;
  border-radius: 0 8px 8px 0;
  padding: 1rem 1.2rem;
  font-family: var(--font-serif);
  font-size: 1.02rem;
  color: #334155;
  line-height: 1.8;
  white-space: pre-line;
}

.reading-title {
  font-weight: 700;
  color: #92400e;
  margin-bottom: 0.4rem;
  font-size: 0.9rem;
  font-family: var(--font-sans);
}

.q-stem {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.6;
}

.options-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.option-item {
  display: flex;
  align-items: flex-start;
  gap: 0.8rem;
  padding: 0.65rem 0.9rem;
  border-radius: 8px;
  background: #f8fafc;
  border: 1px solid var(--border);
  font-size: 0.95rem;
  transition: all 0.15s ease;
}

.option-item.is-correct {
  background: var(--success-bg);
  border-color: #6ee7b7;
  font-weight: 600;
}

.opt-key {
  font-weight: 700;
  min-width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  background: #e2e8f0;
  color: var(--text);
  font-size: 0.82rem;
}

.option-item.is-correct .opt-key {
  background: var(--success);
  color: #ffffff;
}

.opt-text {
  flex: 1;
}

/* Answer and Analysis section */
.q-footer {
  border-top: 1px dashed var(--border);
  padding-top: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.ans-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.8rem;
}

.ans-reveal-wrap {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.official-ans-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--success-bg);
  border: 1px solid #a7f3d0;
  color: var(--success);
  font-weight: 700;
  font-size: 0.95rem;
  padding: 0.35rem 0.85rem;
  border-radius: 8px;
}

.ans-hidden {
  filter: blur(5px);
  user-select: none;
  cursor: pointer;
  transition: filter 0.2s;
}

.ans-hidden:hover {
  filter: blur(2px);
}

.reveal-btn {
  background: #f1f5f9;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.82rem;
  padding: 0.3rem 0.7rem;
  border-radius: 6px;
  cursor: pointer;
}

.tags-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.tag-item {
  font-size: 0.78rem;
  background: #f1f5f9;
  color: #475569;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
}

/* Skills & Traps accordion */
.analysis-box {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  overflow: hidden;
}

.analysis-toggle {
  width: 100%;
  padding: 0.75rem 1rem;
  background: #f1f5f9;
  border: none;
  text-align: left;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
}

.analysis-toggle:hover {
  background: #e2e8f0;
}

.analysis-content {
  padding: 1rem 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  font-size: 0.92rem;
  line-height: 1.7;
}

.analysis-section {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.analysis-section-title {
  font-weight: 700;
  font-size: 0.88rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.sec-focus .analysis-section-title { color: #0284c7; }
.sec-rationale .analysis-section-title { color: #059669; }
.sec-distractors .analysis-section-title { color: #d97706; }
.sec-strategy .analysis-section-title { color: #7c3aed; }

/* Knowledge Graph tab styles */
.taxonomy-container {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.dim-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.4rem;
  box-shadow: var(--shadow-sm);
}

.dim-title {
  font-size: 1.3rem;
  font-family: var(--font-serif);
  font-weight: 700;
  color: var(--primary);
  border-bottom: 2px solid #e2e8f0;
  padding-bottom: 0.6rem;
  margin-bottom: 0.6rem;
}

.dim-desc {
  font-size: 0.92rem;
  color: var(--text-muted);
  margin-bottom: 1.2rem;
}

.subcat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
}

.subcat-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.subcat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.subcat-name {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text);
}

.subcat-count {
  background: var(--primary);
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 9999px;
}

.subcat-skills {
  font-size: 0.88rem;
  color: #475569;
  line-height: 1.5;
}

.subcat-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.4rem;
}

.q-link-chip {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  cursor: pointer;
  text-decoration: none;
}

.q-link-chip:hover {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

/* Poets Gallery */
.poets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.2rem;
}

.poet-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.poet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.poet-name {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--primary-dark);
}

.poet-era-badge {
  font-size: 0.78rem;
  background: #fef3c7;
  color: #92400e;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-weight: 600;
}

.poet-style {
  font-size: 0.88rem;
  color: var(--accent);
  font-weight: 600;
}

.poet-desc {
  font-size: 0.88rem;
  color: #475569;
  line-height: 1.6;
}

.poet-poems-list {
  font-family: var(--font-serif);
  font-size: 0.86rem;
  color: #334155;
  background: #f8fafc;
  padding: 0.6rem 0.8rem;
  border-radius: 6px;
  line-height: 1.5;
}

/* Cross-Strait & Types Tab */
.comparison-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.4rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.5rem;
}

.section-head {
  font-family: var(--font-serif);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.table-responsive {
  overflow-x: auto;
  margin: 1rem 0;
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  text-align: left;
}

table.data-table th, table.data-table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
}

table.data-table th {
  background: #f1f5f9;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}

table.data-table tr:hover td {
  background: #f8fafc;
}

/* Simulated Exams Tab */
.sim-exam-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.8rem;
}

.sim-exam-title {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 0.4rem;
}

.sim-exam-meta {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

/* Archives Table */
.archives-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  margin-bottom: 1rem;
}

.archive-search {
  flex: 1;
  min-width: 250px;
}

.dl-btn {
  background: var(--primary);
  color: #ffffff;
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  transition: background 0.15s ease;
}

.dl-btn:hover {
  background: var(--primary-light);
}

.hash-copy {
  font-family: monospace;
  font-size: 0.78rem;
  color: #64748b;
  cursor: pointer;
  background: #f1f5f9;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
}

.hash-copy:hover {
  background: #e2e8f0;
  color: var(--text);
}

/* Footer */
footer.site-footer {
  background: #0f172a;
  color: #94a3b8;
  padding: 2.5rem 1.5rem;
  margin-top: 3rem;
  border-top: 1px solid #334155;
  font-size: 0.88rem;
}

.footer-container {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

.footer-top {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 1.2rem;
}

.footer-brand {
  font-family: var(--font-serif);
  font-size: 1.2rem;
  color: #ffffff;
  font-weight: 700;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 1.2rem;
}

.footer-links a {
  color: #94a3b8;
  text-decoration: none;
  transition: color 0.15s ease;
}

.footer-links a:hover {
  color: #ffffff;
}

.footer-bottom {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.6rem;
  font-size: 0.82rem;
}

/* Responsive */
@media (max-width: 768px) {
  header.site-header { padding: 1.5rem 1rem 1.2rem; }
  .brand-title-group h1 { font-size: 1.6rem; }
  .nav-tab { padding: 0.8rem 1rem; font-size: 0.88rem; }
  .filter-bar { padding: 1rem; }
  .q-body { padding: 1rem; }
  .reading-box { font-size: 0.95rem; }
}
