/* =========================================================
   109年度教師資格考試 互動評量系統 - Smooth Scroll & Fixed Sidebar
   1. 左側欄：題目導航固定不隨主頁面捲動 (Fixed Sidebar)
   2. 右側主內容區：右側有清晰滾輪，可順暢由上往下滾動
   3. 試題截圖 100% 完整呈現不裁切
   4. 四個選項 (A, B, C, D) 完整文字呈現
   5. 詳解區點選後展開，顯示極為完整詳細之內容
   ========================================================= */

:root {
  /* Color System */
  --bg-main: #f1f5f9;       /* Slate 100 */
  --bg-surface: #ffffff;
  --bg-card-header: #f8fafc;
  --bg-hover: #f8fafc;
  
  --primary: #2563eb;       /* Royal Blue */
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --primary-border: #bfdbfe;
  
  --accent: #0284c7;
  --accent-light: #f0f9ff;
  
  --success: #16a34a;       /* Emerald */
  --success-light: #f0fdf4;
  --success-border: #86efac;
  
  --danger: #dc2626;        /* Red */
  --danger-light: #fef2f2;
  --danger-border: #fca5a5;
  
  --warning: #d97706;       /* Amber */
  --warning-light: #fffbeb;
  
  --text-main: #0f172a;     /* Slate 900 */
  --text-secondary: #334155;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --border-color: #e2e8f0;
  --border-focus: #3b82f6;

  /* Typography */
  --font-sans: 'Noto Sans TC', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-serif: 'Noto Serif TC', Georgia, serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Shadows */
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.12), 0 8px 10px -6px rgba(0, 0, 0, 0.08);

  /* Radii */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --radius-full: 9999px;

  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html, body {
  width: 100%;
  height: 100%;
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* =========================================================
   App Container & Fixed Header
   ========================================================= */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100%;
  overflow: hidden;
}

.top-sticky-wrapper {
  position: sticky;
  top: 0;
  z-index: 50;
  background-color: var(--bg-surface);
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.main-header {
  border-bottom: 1px solid var(--border-color);
  padding: 10px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.portal-nav-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background-color: #f1f5f9;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 800;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.portal-nav-back:hover {
  background-color: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary-border);
  transform: translateY(-1px);
}

.logo-badge {
  background: linear-gradient(135deg, var(--primary), #3b82f6);
  color: #fff;
  font-weight: 900;
  font-size: 0.85rem;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  letter-spacing: 0.05em;
  box-shadow: 0 2px 4px rgba(37, 99, 235, 0.25);
}

.exam-titles {
  display: flex;
  flex-direction: column;
}

.exam-main-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.02em;
}

.exam-sub-info {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.header-center {
  display: flex;
  align-items: center;
}

.mode-toggle-group {
  display: flex;
  background-color: var(--bg-main);
  padding: 4px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
}

.mode-btn {
  border: none;
  background: transparent;
  padding: 6px 16px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
  border-radius: var(--radius-full);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all var(--transition-fast);
}

.mode-btn:hover {
  color: var(--text-main);
}

.mode-btn.active {
  background-color: var(--bg-surface);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.timer-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background-color: #fff1f2;
  border: 1px solid #fecdd3;
  padding: 5px 12px;
  border-radius: var(--radius-md);
  color: #be123c;
  font-weight: 700;
  font-family: var(--font-mono);
  font-size: 0.95rem;
}

.timer-label {
  font-size: 0.75rem;
  font-family: var(--font-sans);
  color: #9f1239;
}

.action-btn {
  border: none;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 7px 14px;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all var(--transition-fast);
}

.reset-btn {
  background-color: var(--bg-main);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
}

.reset-btn:hover {
  background-color: #e2e8f0;
  color: var(--text-main);
}

.finish-btn {
  background: linear-gradient(135deg, #16a34a, #15803d);
  color: #fff;
  box-shadow: 0 2px 4px rgba(22, 163, 74, 0.3);
}

.finish-btn:hover {
  background: linear-gradient(135deg, #15803d, #166534);
}

/* Progress Bar */
.progress-bar-container {
  border-bottom: 1px solid var(--border-color);
  position: relative;
  height: 28px;
  display: flex;
  align-items: center;
  padding: 0 24px;
}

.progress-bar-fill {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  background: linear-gradient(90deg, #93c5fd, #3b82f6);
  opacity: 0.35;
  transition: width 0.3s ease;
  z-index: 1;
}

.progress-info {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  width: 100%;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
}

/* =========================================================
   Workspace: Fixed Left Sidebar + Scrollable Right Content
   ========================================================= */
.workspace-layout {
  display: flex;
  flex: 1;
  height: calc(100vh - 95px);
  overflow: hidden;
}

/* ---------------------------------------------------------
   Left Sidebar: Fixed & Independent Scroll
   --------------------------------------------------------- */
.palette-sidebar {
  width: 270px;
  height: 100%;
  background-color: var(--bg-surface);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 16px;
  flex-shrink: 0;
}

/* Custom Scrollbar for Sidebar */
.palette-sidebar::-webkit-scrollbar {
  width: 6px;
}
.palette-sidebar::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

.palette-header {
  margin-bottom: 12px;
}

.palette-title {
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: block;
  margin-bottom: 8px;
}

.palette-filter {
  display: flex;
  gap: 4px;
  background-color: var(--bg-main);
  padding: 3px;
  border-radius: var(--radius-sm);
}

.filter-chip {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  padding: 4px 6px;
  border-radius: 4px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.filter-chip.active {
  background-color: var(--bg-surface);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.palette-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin-bottom: 16px;
}

.palette-item {
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border-color);
  background-color: #fafafa;
  color: var(--text-main);
  font-size: 0.88rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: all var(--transition-fast);
}

.palette-item:hover {
  border-color: var(--primary);
  background-color: var(--primary-light);
  transform: translateY(-1px);
}

.palette-item.current {
  border: 2px solid var(--primary);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.3);
  background-color: #eff6ff;
  color: var(--primary);
}

.palette-item.correct {
  background-color: #dcfce7;
  border-color: #86efac;
  color: #15803d;
}

.palette-item.wrong {
  background-color: #fee2e2;
  border-color: #fca5a5;
  color: #b91c1c;
}

.palette-item.answered-unrevealed {
  background-color: #e0f2fe;
  border-color: #7dd3fc;
  color: #0369a1;
}

.palette-item .star-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  font-size: 0.65rem;
  color: #f59e0b;
  line-height: 1;
}

.palette-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.72rem;
  color: var(--text-muted);
  padding: 10px 0;
  border-top: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 12px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  border: 1px solid rgba(0,0,0,0.1);
}

.legend-dot.unanswered { background-color: #fafafa; }
.legend-dot.correct { background-color: #86efac; }
.legend-dot.wrong { background-color: #fca5a5; }
.legend-dot.star { background-color: #fef08a; }

.essay-nav-card {
  margin-top: auto;
  background: linear-gradient(135deg, #f8fafc, #f1f5f9);
  border: 1px solid var(--border-color);
  padding: 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.essay-nav-card:hover {
  border-color: #3b82f6;
  background-color: var(--primary-light);
}

.essay-nav-card.current {
  border: 2px solid var(--primary);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

.essay-badge {
  display: inline-block;
  background-color: #dbeafe;
  color: #1e40af;
  font-size: 0.7rem;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
  margin-bottom: 4px;
}

.essay-nav-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-main);
}

/* ---------------------------------------------------------
   Right Main Content: Smooth Vertical Scrolling with Visible Scrollbar
   --------------------------------------------------------- */
.question-main-vertical {
  flex: 1;
  height: 100%;
  overflow-y: scroll;
  overflow-x: hidden;
  background-color: var(--bg-main);
  padding: 24px 32px 100px;
  scroll-behavior: smooth;
}

/* Obvious, Smooth Scrollbar on the Right */
.question-main-vertical::-webkit-scrollbar {
  width: 14px;
}

.question-main-vertical::-webkit-scrollbar-track {
  background: #e2e8f0;
  border-left: 1px solid #cbd5e1;
}

.question-main-vertical::-webkit-scrollbar-thumb {
  background: #94a3b8;
  border-radius: 7px;
  border: 3px solid #e2e8f0;
}

.question-main-vertical::-webkit-scrollbar-thumb:hover {
  background: #64748b;
}

.vertical-scroll-wrapper {
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Top Info Toolbar */
.q-top-bar {
  background-color: var(--bg-surface);
  padding: 14px 24px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.q-badge-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.q-num-pill {
  font-size: 1.35rem;
  font-weight: 900;
  color: var(--primary);
}

.q-type-pill {
  background-color: #f1f5f9;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
}

.q-topic-pill {
  background-color: var(--accent-light);
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid #bae6fd;
}

.q-actions {
  display: flex;
  gap: 8px;
}

.q-tool-btn {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 700;
  padding: 7px 14px;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all var(--transition-fast);
}

.q-tool-btn:hover {
  background-color: #f8fafc;
  color: var(--text-main);
  border-color: #cbd5e1;
}

.q-tool-btn.starred {
  background-color: var(--warning-light);
  border-color: #fde68a;
  color: var(--warning);
}

/* =========================================================
   Flow Cards (1.試題 -> 2.選項 -> 3.詳解)
   ========================================================= */
.flow-card {
  background-color: var(--bg-surface);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  overflow: visible;
  transition: box-shadow var(--transition-fast);
}

.flow-card:hover {
  box-shadow: var(--shadow-md);
}

.flow-card-header {
  background-color: var(--bg-card-header);
  border-bottom: 1px solid var(--border-color);
  padding: 16px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

.header-left-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.step-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background-color: var(--primary);
  color: #fff;
  font-size: 0.88rem;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
}

.header-left-title h3 {
  font-size: 1.08rem;
  font-weight: 800;
  color: var(--text-main);
}

.flow-card-body {
  padding: 24px;
}

/* ---------------------------------------------------------
   Section 1: 試題截圖 (完全呈現不截斷)
   --------------------------------------------------------- */
.flow-section-question .flow-card-body {
  background-color: #fafbfc;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.zoom-action-btn {
  background-color: #fff;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.zoom-action-btn:hover {
  background-color: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary-border);
}

.article-box, .question-box {
  background-color: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  width: 100%;
}

.article-header-tag, .question-header-tag {
  display: inline-block;
  background-color: #f1f5f9;
  color: #334155;
  font-size: 0.85rem;
  font-weight: 800;
  padding: 4px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
}

.exam-crop-img {
  width: 100%;
  max-width: 100%;
  height: auto;
  display: block;
  border-radius: 8px;
  cursor: zoom-in;
  transition: opacity 0.2s ease;
}

.exam-crop-img:hover {
  opacity: 0.97;
}

/* ---------------------------------------------------------
   Mode 3: Parallel Text Question Card Styles
   --------------------------------------------------------- */
.parallel-text-card {
  display: flex;
  flex-direction: column;
  gap: 18px;
  width: 100%;
}

.parallel-tag-banner {
  background: linear-gradient(135deg, #7c3aed, #4f46e5);
  color: #ffffff;
  font-size: 0.92rem;
  font-weight: 800;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  box-shadow: 0 2px 6px rgba(124, 58, 237, 0.25);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.parallel-article-box {
  background-color: #f8fafc;
  border: 1.5px solid #e2e8f0;
  border-left: 5px solid #6366f1;
  border-radius: var(--radius-lg);
  padding: 18px 22px;
}

.parallel-subhead {
  font-size: 0.88rem;
  font-weight: 800;
  color: #475569;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.parallel-article-content {
  font-family: var(--font-serif);
  font-size: 1.08rem;
  line-height: 1.9;
  color: #1e293b;
  white-space: pre-line;
}

.parallel-stem-box {
  background-color: #ffffff;
  border: 1.5px solid #e2e8f0;
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  box-shadow: var(--shadow-sm);
}

.parallel-stem-content {
  font-size: 1.18rem;
  font-weight: 800;
  line-height: 1.85;
  color: #0f172a;
}

.parallel-options-box {
  background-color: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-lg);
  padding: 18px 20px;
}

.parallel-options-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-top: 6px;
}

.parallel-opt-pill {
  background-color: #ffffff;
  border: 1.5px solid #cbd5e1;
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-size: 1.05rem;
  font-weight: 700;
  color: #1e293b;
  line-height: 1.5;
  transition: all var(--transition-fast);
}

.parallel-opt-pill strong {
  color: var(--primary);
  margin-right: 6px;
  font-size: 1.1rem;
}

@media (max-width: 768px) {
  .parallel-options-grid {
    grid-template-columns: 1fr;
  }
}

/* ---------------------------------------------------------
   Section 2: A、B、C、D 四個按鈕並列在同一行
   --------------------------------------------------------- */
.status-indicator {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background-color: var(--text-light);
}

.status-indicator.correct .status-dot { background-color: var(--success); }
.status-indicator.correct { color: var(--success); }
.status-indicator.wrong .status-dot { background-color: var(--danger); }
.status-indicator.wrong { color: var(--danger); }

.choice-buttons-row {
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  gap: 32px;
  padding: 18px 0;
  width: 100%;
}

.choice-bubble-btn {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 3px solid #cbd5e1;
  background-color: #ffffff;
  color: var(--text-main);
  font-size: 1.85rem;
  font-weight: 900;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.06);
  transition: all var(--transition-fast);
  outline: none;
  user-select: none;
}

.choice-bubble-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background-color: var(--primary-light);
  transform: translateY(-4px) scale(1.08);
  box-shadow: 0 8px 16px rgba(37, 99, 235, 0.25);
}

.choice-bubble-btn.selected {
  background-color: var(--primary);
  border-color: #1d4ed8;
  color: #ffffff;
  transform: translateY(-2px);
  box-shadow: 0 6px 14px rgba(37, 99, 235, 0.35);
}

.choice-bubble-btn.correct-highlight {
  background-color: var(--success) !important;
  border-color: #15803d !important;
  color: #ffffff !important;
  box-shadow: 0 6px 14px rgba(22, 163, 74, 0.35);
}

.choice-bubble-btn.wrong-highlight {
  background-color: var(--danger) !important;
  border-color: #b91c1c !important;
  color: #ffffff !important;
  box-shadow: 0 6px 14px rgba(220, 38, 38, 0.35);
}

/* Result Feedback Banner */
.result-feedback-box {
  margin-top: 20px;
  background-color: #fff;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  padding: 18px;
  animation: fadeIn 0.3s ease;
}

.feedback-banner {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  margin-bottom: 14px;
}

.feedback-banner.correct {
  background-color: var(--success-light);
  border: 1.5px solid var(--success-border);
  color: var(--success);
}

.feedback-banner.wrong {
  background-color: var(--danger-light);
  border: 1.5px solid var(--danger-border);
  color: var(--danger);
}

.feedback-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  font-weight: 900;
  color: #fff;
  flex-shrink: 0;
}

.feedback-banner.correct .feedback-icon { background-color: var(--success); }
.feedback-banner.wrong .feedback-icon { background-color: var(--danger); }

.feedback-msg h4 {
  font-size: 1.12rem;
  font-weight: 800;
}

.feedback-msg p {
  font-size: 0.92rem;
  opacity: 0.92;
}

.key-answers-row {
  display: flex;
  gap: 14px;
}

.ans-pill {
  flex: 1;
  background-color: #f8fafc;
  border: 1px solid var(--border-color);
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  text-align: center;
}

.ans-pill strong {
  font-size: 1.15rem;
  color: var(--text-main);
}

.ans-pill.correct-ans strong {
  color: var(--success);
}

/* Essay Textarea in Section 2 */
.essay-workspace {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.essay-prompt-box {
  background-color: #fffbeb;
  border: 1px solid #fef08a;
  border-radius: var(--radius-lg);
  padding: 18px;
}

.essay-prompt-box h4 {
  color: #92400e;
  font-size: 1.15rem;
  margin-bottom: 8px;
}

.essay-prompt-box p {
  font-size: 1rem;
  color: #78350f;
  line-height: 1.8;
}

.essay-editor-wrapper {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.editor-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-muted);
}

#essayInput {
  width: 100%;
  height: 300px;
  padding: 16px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border-color);
  font-family: var(--font-serif);
  font-size: 1.05rem;
  line-height: 1.8;
  resize: vertical;
  outline: none;
}

#essayInput:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

/* ---------------------------------------------------------
   Section 3: 深度詳解 (點選按鈕後才展開)
   --------------------------------------------------------- */
.flow-section-explanation {
  border-left: 5px solid var(--primary);
}

.explanation-toggle-header {
  cursor: pointer;
  user-select: none;
  transition: background-color var(--transition-fast);
}

.explanation-toggle-header:hover {
  background-color: #f1f5f9;
}

.expl-expand-trigger-btn {
  background: linear-gradient(135deg, #1e40af, #2563eb);
  color: #fff;
  border: none;
  padding: 10px 22px;
  border-radius: var(--radius-full);
  font-size: 0.95rem;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 3px 6px rgba(37, 99, 235, 0.3);
  transition: all var(--transition-fast);
}

.expl-expand-trigger-btn:hover {
  background: linear-gradient(135deg, #1d4ed8, #1e40af);
  transform: translateY(-1px);
  box-shadow: 0 5px 10px rgba(37, 99, 235, 0.4);
}

.expl-expand-trigger-btn.expanded {
  background: #475569;
  box-shadow: none;
}

.expl-expand-trigger-btn.expanded:hover {
  background: #334155;
}

.explanation-collapsible-body {
  animation: fadeInDown 0.3s ease;
  border-top: 1px solid var(--border-color);
}

.expl-detail-wrapper {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.expl-card {
  background-color: #fff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 18px;
}

.expl-card-title {
  font-size: 1rem;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.core-card {
  background-color: #f0fdf4;
  border-color: #bbf7d0;
}

.core-card .expl-card-title {
  color: #166534;
}

.core-card p {
  font-size: 1.02rem;
  color: #14532d;
  font-weight: 600;
}

.detail-card p {
  font-size: 1.02rem;
  color: var(--text-main);
  line-height: 1.85;
  white-space: pre-line;
}

.opt-analysis-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.opt-analysis-item {
  background-color: #f8fafc;
  border-left: 4px solid #cbd5e1;
  padding: 14px 18px;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  font-size: 0.98rem;
  line-height: 1.65;
}

.opt-analysis-item.correct-opt {
  background-color: #f0fdf4;
  border-left-color: #22c55e;
}

.opt-analysis-item strong {
  color: var(--text-main);
  font-size: 1.05rem;
}

.essay-structure-step {
  background-color: #f8fafc;
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 10px;
  font-size: 0.96rem;
  line-height: 1.75;
}

.key-phrase-badge {
  display: inline-block;
  background-color: #e0e7ff;
  color: #3730a3;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.88rem;
  font-weight: 700;
  margin: 5px;
}

/* =========================================================
   Bottom Navigation Toolbar
   ========================================================= */
.bottom-nav-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  padding: 16px 28px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  gap: 16px;
}

.nav-middle-info {
  font-size: 1rem;
  font-weight: 800;
  color: var(--text-secondary);
}

.nav-btn {
  padding: 12px 28px;
  font-size: 1rem;
  font-weight: 800;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border-color);
  background-color: #fff;
  color: var(--text-main);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.nav-btn:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary);
  background-color: var(--primary-light);
}

.nav-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.nav-btn.next-btn {
  background-color: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.nav-btn.next-btn:hover:not(:disabled) {
  background-color: var(--primary-hover);
  color: #fff;
}

/* =========================================================
   Modals
   ========================================================= */
.lightbox-modal, .fullpage-modal, .summary-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(4px);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.lightbox-modal.active, .fullpage-modal.active, .summary-modal.active {
  display: flex;
}

.lightbox-content {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.lightbox-content img {
  max-width: 100%;
  max-height: 80vh;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xl);
  background-color: #fff;
}

.lightbox-caption {
  color: #fff;
  font-size: 0.95rem;
  margin-top: 12px;
  font-weight: 600;
}

.lightbox-close {
  position: absolute;
  top: -40px;
  right: 0;
  background: transparent;
  border: none;
  color: #fff;
  font-size: 2rem;
  cursor: pointer;
}

/* Fullpage Modal */
.fullpage-container {
  width: 900px;
  max-width: 95vw;
  height: 90vh;
  background-color: var(--bg-surface);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-xl);
}

.fullpage-header {
  background-color: var(--bg-card-header);
  border-bottom: 1px solid var(--border-color);
  padding: 12px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.fullpage-tools {
  display: flex;
  align-items: center;
  gap: 10px;
}

.fullpage-tools button {
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background-color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.fullpage-close {
  background-color: #fee2e2 !important;
  border-color: #fecaca !important;
  color: #dc2626 !important;
}

.fullpage-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background-color: #e2e8f0;
  display: flex;
  justify-content: center;
}

.fullpage-body img {
  max-width: 100%;
  height: auto;
  box-shadow: var(--shadow-md);
  background-color: #fff;
}

/* Summary Modal */
.summary-card {
  background-color: var(--bg-surface);
  width: 540px;
  max-width: 95vw;
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-xl);
  text-align: center;
}

.summary-header h2 {
  font-size: 1.5rem;
  font-weight: 900;
  color: var(--text-main);
  margin-bottom: 4px;
}

.summary-header p {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.summary-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}

.stat-box {
  padding: 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background-color: #f8fafc;
}

.stat-box.primary {
  border-color: var(--primary-border);
  background-color: var(--primary-light);
}

.stat-box.primary .stat-num { color: var(--primary); }
.stat-box.success .stat-num { color: var(--success); }
.stat-box.danger .stat-num { color: var(--danger); }
.stat-box.info .stat-num { color: var(--accent); }

.stat-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.stat-num {
  font-size: 1.6rem;
  font-weight: 900;
  font-family: var(--font-mono);
}

.summary-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.summary-btn {
  padding: 12px;
  border-radius: var(--radius-md);
  border: none;
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.review-wrong-btn {
  background-color: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

.review-wrong-btn:hover { background-color: #fecaca; }

.restart-btn {
  background-color: var(--bg-main);
  color: var(--text-main);
  border: 1px solid var(--border-color);
}

.restart-btn:hover { background-color: #e2e8f0; }

.close-modal-btn {
  background-color: var(--primary);
  color: #fff;
}

.close-modal-btn:hover { background-color: var(--primary-hover); }

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

@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* =========================================================
   Responsive
   ========================================================= */
@media (max-width: 900px) {
  .palette-sidebar {
    width: 65px;
    padding: 8px;
  }
  .palette-title, .palette-filter, .palette-legend, .essay-nav-title {
    display: none;
  }
  .palette-grid {
    grid-template-columns: 1fr;
  }
  .question-main-vertical {
    padding: 16px 12px 80px;
  }
  .exam-sub-info {
    display: none;
  }
}

/* =========================================================
   題組閱讀文章專屬美化區域
   ========================================================= */
.article-box {
  background: #f8fafc;
  border: 1.5px solid #cbd5e1;
  border-left: 6px solid #2563eb;
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 24px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.article-header-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 0.95rem;
  font-weight: 800;
  padding: 6px 14px;
  border-radius: 8px;
  border: 1px solid #bfdbfe;
  margin-bottom: 14px;
}

.article-box img.exam-crop-img {
  width: 100%;
  height: auto;
  border-radius: 8px;
  background: #fff;
  border: 1px solid #e2e8f0;
  margin-bottom: 12px;
}

.article-box img.exam-crop-img:last-child {
  margin-bottom: 0;
}

/* =========================================================
   Cloudflare D1 Candidate Header Pill & Modal
   ========================================================= */
.candidate-header-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  padding: 6px 14px;
  border-radius: 9999px;
  font-size: 0.82rem;
  font-weight: 700;
  color: #166534;
  cursor: pointer;
  transition: all 0.15s ease;
}

.candidate-header-pill:hover {
  background: #dcfce7;
  border-color: #86efac;
}

.candidate-header-pill .pill-dot {
  width: 8px;
  height: 8px;
  background: #22c55e;
  border-radius: 50%;
  display: inline-block;
}

/* Candidate Modal */
.custom-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.custom-modal-card {
  background: #ffffff;
  border-radius: 16px;
  padding: 24px 28px;
  max-width: 440px;
  width: 100%;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.custom-modal-card h3 {
  margin: 0 0 12px;
  font-size: 1.2rem;
  font-weight: 800;
  color: #0f172a;
}

.custom-modal-card p {
  margin: 0 0 16px;
  font-size: 0.88rem;
  color: #64748b;
  line-height: 1.5;
}

.modal-form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.modal-form-group label {
  font-size: 0.85rem;
  font-weight: 700;
  color: #334155;
}

.modal-input, .modal-select {
  padding: 10px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
  outline: none;
}

.modal-input:focus, .modal-select:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.modal-btn-row {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

.modal-btn-save {
  background: #2563eb;
  color: white;
  border: none;
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
}
.modal-btn-save:hover { background: #1d4ed8; }

.modal-btn-cancel {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #cbd5e1;
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
}


