/* ==========================================================================
   Claude Style Design System (Claude Aesthetic SSoT)
   Default Mode: Warm Parchment Light Mode
   Optional Mode: Dark Mode Toggle
   ========================================================================== */

/* Light Mode Tokens (Default - Warm Parchment Aesthetic) */
:root {
  --bg-primary: #F7F4EF;        /* Warm parchment background */
  --bg-surface: #FFFFFF;        /* Warm crisp card surface */
  --bg-card: #FCFAf7;           /* Warm elevated card background */
  --bg-card-hover: #F2ECE1;     /* Interactive hover state */
  
  --border-light: #E6E0D4;      /* Soft warm border */
  --border-active: #D97757;     /* Active terracotta border */
  
  --text-main: #221F1D;         /* Deep warm charcoal text */
  --text-secondary: #6E6860;    /* Warm muted brown text */
  --text-muted: #999186;        /* 60% opacity gray for non-correct options */
  
  /* Signature Claude Color Palette */
  --accent-terracotta: #CC6B49; /* Claude Signature Terracotta Red */
  --accent-amber: #D49B35;      /* Warm Claude Amber Gold */
  --accent-sage: #5B8266;       /* Warm Claude Olive Sage Green */
  --accent-blue: #4A7C9D;       /* Warm Muted Slate Blue */
  --accent-red: #C85A54;        /* Soft Warm Red */

  --badge-bg-mc: rgba(74, 124, 157, 0.1);
  --badge-bg-tfo: rgba(91, 130, 102, 0.12);
  --badge-bg-tfx: rgba(200, 90, 84, 0.12);

  --shadow-sm: 0 2px 8px rgba(34, 31, 29, 0.05);
  --shadow-md: 0 8px 24px rgba(34, 31, 29, 0.08);
  --shadow-lg: 0 16px 40px rgba(34, 31, 29, 0.12);

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
}

/* Dark Mode Tokens (Optional Switch) */
[data-theme="dark"] {
  --bg-primary: #181614;
  --bg-surface: #221F1C;
  --bg-card: #2B2723;
  --bg-card-hover: #36312C;
  
  --border-light: #3D3731;
  --border-active: #E07A5F;
  
  --text-main: #F4F1EA;
  --text-secondary: #A39B90;
  --text-muted: #787168;
  
  --accent-terracotta: #E07A5F;
  --accent-amber: #E2AD4A;
  --accent-sage: #6E9B79;
  --accent-blue: #5C9CBD;
  --accent-red: #E57373;

  --badge-bg-mc: rgba(92, 156, 189, 0.15);
  --badge-bg-tfo: rgba(110, 155, 121, 0.18);
  --badge-bg-tfx: rgba(229, 115, 115, 0.18);

  --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 10px 28px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 20px 48px rgba(0, 0, 0, 0.6);
}

/* Global Reset & Base Typography */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Noto Sans TC', 'Outfit', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-main);
  line-height: 1.6;
  min-height: 100vh;
  padding-bottom: 50px;
  transition: background-color 0.3s ease, color 0.3s ease;
}

h1, h2, h3, .modal-title {
  font-family: 'Noto Serif TC', 'Georgia', serif;
}

.app-container {
  max-width: 1240px;
  margin: 0 auto;
  padding: 28px 20px;
}

/* Header Styling - Claude Parchment Style */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 20px;
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border-light);
}

.badge-tag {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--accent-terracotta);
  background: rgba(204, 107, 73, 0.08);
  padding: 4px 12px;
  border-radius: 20px;
  border: 1px solid rgba(204, 107, 73, 0.25);
  margin-bottom: 8px;
}

.header-brand h1 {
  font-size: 2.1rem;
  font-weight: 900;
  color: var(--text-main);
  letter-spacing: -0.5px;
}

.subtitle {
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

.official-source-link {
  font-size: 0.84rem;
  color: var(--text-secondary);
  margin-top: 6px;
}

.official-source-link a {
  color: var(--accent-terracotta);
  text-decoration: underline;
  font-weight: 600;
  transition: color 0.2s;
}

/* Official Exam Simulator Banner Styling - Claude Style */
.official-exam-banner {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 24px 28px;
  margin-bottom: 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.official-exam-banner::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--accent-terracotta);
}

.exam-banner-content {
  flex: 1;
  min-width: 280px;
}

.exam-tag {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent-terracotta);
  background: rgba(204, 107, 73, 0.1);
  padding: 3px 10px;
  border-radius: 12px;
  margin-bottom: 6px;
}

.exam-banner-header h2 {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 4px;
}

.exam-desc {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
  line-height: 1.5;
}

.exam-badges-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.exam-pill {
  font-size: 0.78rem;
  padding: 4px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  color: var(--text-secondary);
}

.exam-banner-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 240px;
}

.exam-link-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
  border: none;
}

.exam-link-btn.primary {
  background: var(--accent-terracotta);
  color: #FFFFFF;
  box-shadow: 0 4px 14px rgba(204, 107, 73, 0.25);
}

.exam-link-btn.primary:hover {
  background: #B55B3B;
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(204, 107, 73, 0.35);
}

.exam-link-btn.secondary {
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-light);
}

.exam-link-btn.secondary:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-terracotta);
}

.btn-subtext {
  font-size: 0.72rem;
  font-weight: 400;
  opacity: 0.85;
  margin-top: 2px;
}

/* Header Controls & Theme Toggle */
.header-controls {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
}

.theme-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: 24px;
  color: var(--text-main);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

.theme-toggle-btn:hover {
  border-color: var(--accent-terracotta);
  transform: translateY(-1px);
}

.search-box {
  position: relative;
  width: 340px;
  max-width: 100%;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1rem;
  opacity: 0.5;
}

.search-box input {
  width: 100%;
  padding: 12px 16px 12px 42px;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: 0.9rem;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.search-box input:focus {
  outline: none;
  border-color: var(--accent-terracotta);
  background: var(--bg-card);
  box-shadow: 0 0 0 3px rgba(204, 107, 73, 0.15);
}

/* 3x3 九宮格 Matrix Grid Layout */
.mandala-matrix-section {
  margin-bottom: 36px;
}

.mandala-grid-container {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 16px;
}

.grid-cell {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 20px 18px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 126px;
  box-shadow: var(--shadow-sm);
}

.grid-cell:hover {
  transform: translateY(-3px);
  background: var(--bg-card-hover);
  border-color: rgba(204, 107, 73, 0.4);
  box-shadow: var(--shadow-md);
}

.grid-cell.active {
  border-color: var(--accent-terracotta);
  background: rgba(204, 107, 73, 0.05);
  box-shadow: 0 0 0 2px var(--accent-terracotta);
}

.grid-cell-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.cell-code {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-secondary);
  font-family: 'Outfit', monospace;
}

.cell-icon {
  font-size: 1.5rem;
}

.grid-cell-body h4 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
  margin-top: 6px;
}

.cell-desc {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-top: 2px;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.grid-cell-footer {
  margin-top: 12px;
  display: flex;
  gap: 8px;
}

.count-badge {
  font-size: 0.72rem;
  padding: 3px 9px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.04);
  color: var(--text-secondary);
  border: 1px solid var(--border-light);
}

/* Center Grid Cell (#9 Central Core) */
.grid-cell.center-core {
  background: linear-gradient(135deg, rgba(204, 107, 73, 0.08) 0%, rgba(212, 155, 53, 0.08) 100%);
  border: 2px solid var(--accent-terracotta);
  grid-column: 2;
  grid-row: 2;
  text-align: center;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
}

.center-core-content h3 {
  font-size: 1.35rem;
  font-weight: 900;
  color: var(--accent-terracotta);
}

.center-core-content p {
  font-size: 0.84rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

.core-stats-badge {
  display: inline-block;
  margin-top: 10px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-main);
  background: rgba(204, 107, 73, 0.15);
  padding: 5px 14px;
  border-radius: 14px;
}

/* Category Nav Tabs - Claude Style */
.category-tabs-nav {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 24px;
  scrollbar-width: thin;
}

.tab-btn {
  padding: 10px 18px;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.88rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.tab-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-main);
}

.tab-btn.active {
  background: var(--accent-terracotta);
  color: #FFFFFF;
  font-weight: 700;
  border-color: var(--accent-terracotta);
  box-shadow: 0 4px 12px rgba(204, 107, 73, 0.25);
}

/* Category Header Banner */
.category-header-banner {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 22px 26px;
  margin-bottom: 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  box-shadow: var(--shadow-sm);
}

.banner-title-group h2 {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text-main);
}

.banner-title-group p {
  font-size: 0.92rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.banner-stats {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.stat-pill {
  background: var(--bg-card);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  color: var(--text-secondary);
  border: 1px solid var(--border-light);
}

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

/* Content Toolbar & Filter Chips */
.content-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 24px;
}

.filter-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-chip {
  padding: 7px 16px;
  border-radius: 20px;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
  font-size: 0.84rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.filter-chip:hover {
  background: var(--bg-card-hover);
  color: var(--text-main);
}

.filter-chip.active {
  background: var(--text-main);
  color: var(--bg-primary);
  border-color: var(--text-main);
  font-weight: 700;
}

.toolbar-info {
  font-size: 0.86rem;
  color: var(--text-secondary);
}

/* Question Cards & Specifications */
.questions-list {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.section-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0 10px 0;
}

.section-divider h3 {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--accent-terracotta);
  white-space: nowrap;
}

.section-divider .line {
  height: 1px;
  background: var(--border-light);
  width: 100%;
}

.question-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 24px;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.question-card:hover {
  border-color: rgba(204, 107, 73, 0.3);
  box-shadow: var(--shadow-md);
}

.q-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 16px;
}

.q-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 6px;
  white-space: nowrap;
}

.q-badge.mc {
  background: var(--badge-bg-mc);
  color: var(--accent-blue);
  border: 1px solid rgba(74, 124, 157, 0.25);
}

.q-badge.tf-o {
  background: var(--badge-bg-tfo);
  color: var(--accent-sage);
  border: 1px solid rgba(91, 130, 102, 0.3);
}

.q-badge.tf-x {
  background: var(--badge-bg-tfx);
  color: var(--accent-red);
  border: 1px solid rgba(200, 90, 84, 0.3);
}

.q-title {
  font-size: 1.08rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.5;
  flex: 1;
}

/* Multiple Choice Options Styling per User Rule:
   - Correct Option: Standard contrast & font size
   - Non-Correct Options: 60% Muted Gray (Opacity 0.6 / color var(--text-muted))
*/
.mc-options-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 16px 0;
}

.mc-option-item {
  padding: 13px 18px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: all 0.2s ease;
}

/* CORRECT OPTION: Full contrast & Claude Olive Sage Green Tint */
.mc-option-item.correct {
  background: rgba(91, 130, 102, 0.08);
  border-color: rgba(91, 130, 102, 0.35);
  color: var(--text-main);
  font-weight: 700;
}

.mc-option-item.correct .option-num {
  background: var(--accent-sage);
  color: #FFFFFF;
  font-weight: 900;
  padding: 2px 8px;
  border-radius: 4px;
}

/* NON-CORRECT OPTION: 60% Muted Gray */
.mc-option-item.incorrect {
  opacity: 0.6;
  color: var(--text-muted);
  background: rgba(0, 0, 0, 0.01);
}

.mc-option-item.incorrect .option-num {
  color: var(--text-muted);
  font-weight: 500;
}

/* MORE Button Overlay Trigger */
.q-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--border-light);
}

.more-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(204, 107, 73, 0.1);
  color: var(--accent-terracotta);
  border: 1px solid rgba(204, 107, 73, 0.3);
  padding: 7px 16px;
  border-radius: 20px;
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.more-btn:hover {
  background: var(--accent-terracotta);
  color: #FFFFFF;
  box-shadow: 0 4px 12px rgba(204, 107, 73, 0.3);
}

/* True/False Explanation Box */
.tf-explanation-box {
  margin-top: 16px;
  padding: 16px 18px;
  background: rgba(91, 130, 102, 0.05);
  border-left: 4px solid var(--accent-sage);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.92rem;
  color: var(--text-main);
  line-height: 1.65;
}

.tf-explanation-box.incorrect-type {
  background: rgba(200, 90, 84, 0.05);
  border-left-color: var(--accent-red);
}

/* Modal Overlay styling */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(34, 31, 29, 0.65);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  max-width: 620px;
  width: 100%;
  padding: 32px;
  position: relative;
  box-shadow: var(--shadow-lg);
  transform: scale(0.95);
  transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.modal-overlay.open .modal-card {
  transform: scale(1);
}

.modal-close {
  position: absolute;
  right: 22px;
  top: 20px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.7rem;
  cursor: pointer;
  transition: color 0.2s;
}

.modal-close:hover {
  color: var(--text-main);
}

.modal-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent-terracotta);
  background: rgba(204, 107, 73, 0.12);
  padding: 4px 12px;
  border-radius: 12px;
  margin-bottom: 12px;
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 18px;
}

.modal-body {
  font-size: 0.96rem;
  color: var(--text-main);
  line-height: 1.75;
  background: var(--bg-primary);
  padding: 20px;
  border-radius: var(--radius-sm);
  border-left: 4px solid var(--accent-terracotta);
}

/* Footer Styling */
.app-footer {
  margin-top: 64px;
  text-align: center;
  font-size: 0.84rem;
  color: var(--text-secondary);
  border-top: 1px solid var(--border-light);
  padding-top: 28px;
}

/* Responsive Breakpoints & Mobile UX Optimizations */
@media (max-width: 900px) {
  .mandala-grid-container {
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
  }

  .grid-cell {
    padding: 16px 14px;
    min-height: 110px;
  }

  .grid-cell-body h4 {
    font-size: 0.95rem;
  }
}

@media (max-width: 640px) {
  .app-container {
    padding: 16px 12px;
  }

  /* Compact 2-column Mandala Grid on Mobile to maintain Matrix feel */
  .mandala-grid-container {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .grid-cell {
    padding: 14px 12px;
    min-height: 104px;
  }

  .grid-cell.center-core {
    grid-column: span 2;
    grid-row: auto;
    padding: 16px;
  }

  .center-core-content h3 {
    font-size: 1.15rem;
  }

  /* Mobile App Header Stack */
  .app-header {
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
    margin-bottom: 20px;
    padding-bottom: 16px;
  }
  
  .header-brand h1 {
    font-size: 1.6rem;
  }

  .header-controls {
    width: 100%;
    align-items: stretch;
    flex-direction: column-reverse;
  }

  .theme-toggle-btn {
    justify-content: center;
    width: 100%;
    min-height: 44px; /* Touch target standard */
  }

  .search-box {
    width: 100%;
  }

  .search-box input {
    min-height: 44px;
    font-size: 0.95rem;
  }

  /* Official Exam Banner Mobile Layout */
  .official-exam-banner {
    padding: 18px 16px;
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
  }

  .exam-banner-actions {
    width: 100%;
    min-width: 0;
  }

  .exam-link-btn {
    min-height: 46px;
    width: 100%;
  }

  /* Touch-friendly Category Nav Tabs */
  .category-tabs-nav {
    -webkit-overflow-scrolling: touch;
    gap: 6px;
    padding-bottom: 10px;
  }

  .tab-btn {
    min-height: 44px;
    padding: 10px 14px;
    font-size: 0.85rem;
  }

  /* Touch-friendly Filter Chips */
  .filter-group {
    width: 100%;
  }

  .filter-chip {
    min-height: 42px;
    padding: 8px 14px;
    font-size: 0.82rem;
    display: flex;
    align-items: center;
  }

  /* Question Cards Mobile Spacing */
  .question-card {
    padding: 18px 14px;
    border-radius: var(--radius-sm);
  }

  .q-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .q-title {
    font-size: 1rem;
  }

  .mc-option-item {
    padding: 12px 14px;
    font-size: 0.9rem;
  }

  .more-btn {
    min-height: 42px;
    width: 100%;
    justify-content: center;
  }

  /* Mobile Modals */
  .modal-card {
    padding: 20px 16px;
    max-height: 88vh;
    border-radius: var(--radius-md);
  }

  .modal-title {
    font-size: 1.1rem;
    padding-right: 28px;
  }
}
