/* ==========================================================================
   HANYU YUEDU APP - COFFEE BROWN & WARM IVORY CANVAS DESIGN SYSTEM
   Phục vụ luyện thi Tiếng Trung Tổng Hợp 3 & 7 (Hán Ngữ Đọc Hiểu Bài 1 - 30)
   100 Bộ Đề Thi Chuẩn Đại học Huế (TRU4032 & TRU4072)
   ========================================================================== */

:root, [data-theme="ieltsmate"] {
  /* IELTS Mate Signature Brand (Warm Cream, Espresso Ink & Terracotta Coral) */
  --primary: #dd6552;
  --primary-hover: #c54f3c;
  --primary-light: #fdf2f0;
  --primary-glow: rgba(221, 101, 82, 0.22);
  
  --accent: #b5733a;
  --accent-light: #fbf3e8;
  --gold: #d97706;
  --gold-light: #fef3c7;
  
  --success: #2e7d32;
  --success-light: #edf7ee;
  --success-glow: rgba(46, 125, 50, 0.2);
  
  --warning: #d8a33a;
  --warning-light: #fef9ed;
  
  --danger: #dd6552;
  --danger-light: #fdf0ed;
  --info: #0284c7;
  --info-light: #f0f9ff;
  
  --bg-main: #fbf7f1; /* IELTS Mate Canvas */
  --bg-card: #ffffff; /* Warm Ivory Paper */
  --bg-card-hover: #faf4eb;
  --bg-elevated: #f4ece0; /* Soft warm surface */
  --border-color: #e8ded2; /* Soft warm border */
  --border-subtle: rgba(51, 33, 15, 0.08);
  
  --text-main: #33210f; /* Deep Warm Espresso Ink */
  --text-muted: #6f5e48; /* Warm Taupe Ink */
  --text-dim: #9f8c75; /* Faint Ink */
  
  --hanzi-font: 'Noto Serif SC', 'Songti SC', 'STKaiti', serif;
  --body-font: 'Plus Jakarta Sans', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  
  --shadow-sm: 0 1px 3px rgba(51, 33, 15, 0.06);
  --shadow-md: 0 4px 12px -2px rgba(51, 33, 15, 0.08), 0 2px 4px -2px rgba(51, 33, 15, 0.04);
  --shadow-lg: 0 12px 24px -4px rgba(51, 33, 15, 0.12);
  --shadow-glow: 0 0 20px rgba(221, 101, 82, 0.25);
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-full: 9999px;
  
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* IELTS Mate Dark (Mực Đêm Sand Dark) */
[data-theme="ieltsmate-dark"] {
  --primary: #dd6552;
  --primary-hover: #ea6f59;
  --primary-light: #3a211c;
  --primary-glow: rgba(221, 101, 82, 0.35);
  
  --accent: #deb75f;
  --accent-light: #2f2616;
  --gold: #f59e0b;
  --gold-light: #451a03;
  
  --success: #88d295;
  --success-light: #1b2a1e;
  
  --warning: #deb75f;
  --warning-light: #2f2616;
  
  --danger: #dd6552;
  --danger-light: #3a211c;
  --info: #38bdf8;
  --info-light: #082f49;
  
  --bg-main: #17120e; /* IELTS Mate Sand Dark */
  --bg-card: #211b15; /* Cream-1 Dark */
  --bg-card-hover: #29221b; /* Cream-2 Dark */
  --bg-elevated: #2c241c; /* Tan-1 */
  --border-color: #362d23;
  --border-subtle: rgba(248, 239, 226, 0.08);
  
  --text-main: #f8efe2; /* Cream Ink */
  --text-muted: #cfbfac;
  --text-dim: #9f8c75;
  
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 10px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 12px 24px rgba(0, 0, 0, 0.6);
  --shadow-glow: 0 0 20px rgba(221, 101, 82, 0.35);
}

[data-theme="light"] {
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-light: #eef2ff;
  --primary-glow: rgba(79, 70, 229, 0.25);
  
  --accent: #0ea5e9;
  --accent-light: #e0f2fe;
  --gold: #f59e0b;
  --gold-light: #fef3c7;
  
  --success: #10b981;
  --success-light: #ecfdf5;
  --success-glow: rgba(16, 185, 129, 0.25);
  
  --warning: #f59e0b;
  --warning-light: #fffbeb;
  
  --danger: #ef4444;
  --danger-light: #fef2f2;
  --info: #3b82f6;
  --info-light: #eff6ff;
  
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-hover: #f1f5f9;
  --bg-elevated: #e2e8f0;
  --border-color: #e2e8f0;
  --border-subtle: rgba(0, 0, 0, 0.06);
  
  --text-main: #0f172a;
  --text-muted: #475569;
  --text-dim: #94a3b8;
  
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 8px -1px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 12px 20px -3px rgba(0, 0, 0, 0.1);
  --shadow-glow: 0 0 20px rgba(79, 70, 229, 0.15);
}

[data-theme="dark"] {
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-light: #1e1b4b;
  --primary-glow: rgba(99, 102, 241, 0.3);
  
  --accent: #38bdf8;
  --accent-light: #082f49;
  --gold: #fbbf24;
  --gold-light: #451a03;
  
  --success: #34d399;
  --success-light: #064e3b;
  
  --warning: #fbbf24;
  --warning-light: #451a03;
  
  --danger: #f87171;
  --danger-light: #450a0a;
  --info: #60a5fa;
  --info-light: #1e293b;
  
  --bg-main: #0f172a;
  --bg-card: #1e293b;
  --bg-card-hover: #24344d;
  --bg-elevated: #334155;
  --border-color: #334155;
  --border-subtle: rgba(255, 255, 255, 0.08);
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.35);
}

/* ==========================================================================
   BASE & RESET
   ========================================================================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--body-font);
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.6;
  min-height: 100vh;
  transition: background-color 0.3s ease, color 0.3s ease;
  overflow-x: hidden;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-main);
}
::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-dim);
}

/* ==========================================================================
   COFFEE BROWN HEADER & TOP NAVIGATION
   ========================================================================== */
.app-header {
  background: linear-gradient(135deg, #2b170c 0%, #3e2213 50%, #4a2b19 100%) !important;
  border-bottom: 2px solid #5d3822 !important;
  color: #fff8f0 !important;
  box-shadow: 0 4px 20px rgba(43, 23, 12, 0.35) !important;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 0.85rem 1.5rem 0;
}

.header-top-row {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding-bottom: 0.75rem;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.brand-logo-badge {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, #d97706, #92400e) !important;
  color: #fff8f0 !important;
  border: 1px solid rgba(255, 248, 240, 0.25) !important;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--hanzi-font) !important;
  font-size: 1.5rem !important;
  font-weight: 700 !important;
  box-shadow: 0 4px 12px rgba(217, 119, 6, 0.35) !important;
  flex-shrink: 0;
}

.brand-text h1 {
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: #fff8f0 !important;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.45);
}

.brand-text p {
  font-size: 0.82rem;
  color: #e8d5c4 !important;
  margin-top: 1px;
}

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

/* Volume Switcher Pills */
.volume-switch-pills {
  background: rgba(0, 0, 0, 0.35) !important;
  border: 1px solid rgba(255, 248, 240, 0.2) !important;
  border-radius: var(--radius-full) !important;
  padding: 3px !important;
  display: flex;
  gap: 3px;
}

.vol-btn {
  background: transparent !important;
  border: none !important;
  color: #e8d5c4 !important;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 6px;
}

.vol-btn:hover {
  color: #ffffff !important;
}

.vol-btn.active {
  background: #dd6552 !important;
  color: #ffffff !important;
  box-shadow: 0 2px 8px rgba(221, 101, 82, 0.45) !important;
}

.vol-btn .vol-tag {
  font-size: 0.75rem;
  opacity: 0.9;
  font-weight: 700;
}

/* Theme Button */
.theme-btn {
  background: rgba(255, 255, 255, 0.12) !important;
  border: 1px solid rgba(255, 248, 240, 0.25) !important;
  color: #fff8f0 !important;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1rem;
  transition: var(--transition);
}

.theme-btn:hover {
  background: rgba(255, 255, 255, 0.22) !important;
  transform: scale(1.05);
}

/* Navigation Tabs Bar */
.app-nav-tabs {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  gap: 0.5rem;
  border-top: 1px solid rgba(255, 248, 240, 0.1);
  padding-top: 2px;
  overflow-x: auto;
}

.nav-tab-btn {
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  color: #e8d5c4 !important;
  padding: 0.65rem 1rem;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.nav-tab-btn:hover {
  color: #ffffff !important;
  background: rgba(255, 255, 255, 0.08) !important;
}

.nav-tab-btn.active {
  color: #ffffff !important;
  border-bottom: 3px solid #dd6552 !important;
  background: rgba(221, 101, 82, 0.16) !important;
}

.nav-tab-btn .nav-badge {
  background: rgba(255, 255, 255, 0.18) !important;
  color: #fff8f0 !important;
  font-size: 0.72rem;
  padding: 1px 7px;
  border-radius: var(--radius-full);
  font-weight: 700;
}

.nav-tab-btn.active .nav-badge {
  background: #dd6552 !important;
  color: #ffffff !important;
}

/* ==========================================================================
   COFFEE BROWN VOLUME BANNER
   ========================================================================== */
.volume-banner {
  background: linear-gradient(135deg, #f7efe6 0%, #ebe0d1 100%) !important;
  border: 1px solid #d8c7b3 !important;
  border-left: 6px solid #4a2b19 !important;
  box-shadow: var(--shadow-sm) !important;
  padding: 1.25rem 1.5rem;
  margin: 1.25rem auto 1rem;
  max-width: 1400px;
  border-radius: var(--radius-md);
}

[data-theme="ieltsmate-dark"] .volume-banner {
  background: linear-gradient(135deg, #241c15 0%, #1c1510 100%) !important;
  border: 1px solid #3d2f23 !important;
  border-left: 6px solid #d97706 !important;
}

.volume-banner-text .badge-tag {
  background: #4a2b19 !important;
  color: #fff8f0 !important;
  font-size: 0.72rem;
  font-weight: 800;
  display: inline-block;
  padding: 3px 10px;
  border-radius: var(--radius-sm);
  margin-bottom: 0.45rem;
  letter-spacing: 0.05em;
}

[data-theme="ieltsmate-dark"] .volume-banner-text .badge-tag {
  background: #d97706 !important;
  color: #17120e !important;
}

.volume-banner-text h2 {
  color: #3e2213 !important;
  font-size: 1.25rem;
  font-weight: 800;
  margin-bottom: 0.25rem;
}

[data-theme="ieltsmate-dark"] .volume-banner-text h2 {
  color: #f8efe2 !important;
}

.volume-banner-text p {
  color: #5c4033 !important;
  font-size: 0.88rem;
  line-height: 1.5;
}

[data-theme="ieltsmate-dark"] .volume-banner-text p {
  color: #cfbfac !important;
}

/* ==========================================================================
   MAIN CONTENT & TAB PANELS
   ========================================================================== */
.main-layout,
.app-main-content {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 1.5rem 3rem;
  flex: 1;
  width: 100%;
}

.tab-panel {
  display: none;
}
.tab-panel.active {
  display: block;
  animation: fadeIn 0.25s ease-in-out;
}

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

/* ==========================================================================
   TAB 1: CURRICULUM (GIÁO TRÌNH 30 BÀI ĐỌC HIỂU)
   ========================================================================== */
.curriculum-master-bar {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-left: 5px solid var(--primary);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  box-shadow: var(--shadow-sm);
}

.master-bar-title {
  display: flex;
  align-items: center;
  gap: 12px;
}
.master-bar-title .icon {
  font-size: 2rem;
}

.master-bar-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-master-export {
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 7px 14px;
  font-size: 0.82rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-master-export:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
  transform: translateY(-1px);
}

.btn-master-export.gold {
  background: var(--gold-light);
  border-color: rgba(217, 119, 6, 0.4);
  color: var(--accent);
}
.btn-master-export.gold:hover {
  background: rgba(217, 119, 6, 0.25);
  border-color: var(--gold);
}

.curriculum-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.search-input-wrapper {
  position: relative;
  flex: 1;
  min-width: 280px;
}
.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
}
.search-input-wrapper input {
  width: 100%;
  padding: 10px 14px 10px 38px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: 0.92rem;
  transition: var(--transition);
}
.search-input-wrapper input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.curriculum-filter-tags {
  display: flex;
  gap: 6px;
}
.filter-pill {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 6px 14px;
  font-size: 0.82rem;
  font-weight: 600;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: var(--transition);
}
.filter-pill:hover {
  border-color: var(--primary);
  color: var(--text-main);
}
.filter-pill.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* Lesson Grid & Cards (Matching Screenshot) */
.lesson-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 1.25rem;
}

.lesson-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  transition: var(--transition);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.lesson-card:hover {
  transform: translateY(-3px);
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  background: var(--bg-card-hover);
}

.lesson-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--primary);
  opacity: 0.8;
}

.lesson-header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.75rem;
}

.lesson-number-tag {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent);
  background: rgba(181, 115, 58, 0.12);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  letter-spacing: 0.02em;
}

.speak-btn {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-dim);
  border-radius: var(--radius-full);
  padding: 2px 9px;
  font-size: 0.78rem;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.speak-btn:hover {
  color: var(--text-main);
  border-color: var(--text-muted);
  background: var(--bg-elevated);
}

.lesson-hanzi-title {
  font-family: var(--hanzi-font);
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.25rem;
  line-height: 1.3;
}

.lesson-pinyin-title {
  font-size: 0.9rem;
  color: var(--accent);
  font-style: italic;
  margin-bottom: 0.25rem;
}

.lesson-vi-title {
  font-size: 0.92rem;
  color: var(--text-muted);
  font-weight: 500;
}

.lesson-stats-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.85rem;
  margin-top: 1rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border-color);
  font-size: 0.82rem;
  color: var(--text-dim);
}

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

/* ==========================================================================
   TAB 2: EXAMS (100 BỘ ĐỀ THI CHUẨN ĐH HUẾ - TTTH3 & TTTH7)
   ========================================================================== */
.exam-layout-grid {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 1.5rem;
}
@media (max-width: 992px) {
  .exam-layout-grid {
    grid-template-columns: 1fr;
  }
}

.exam-sidebar {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 180px);
  position: sticky;
  top: 120px;
  box-shadow: var(--shadow-sm);
}

.sidebar-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 0.85rem;
  padding-bottom: 0.65rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.sidebar-sub-badge {
  font-size: 0.72rem;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--primary);
  font-weight: 700;
}

.exam-list-scroll {
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-right: 4px;
}

.exam-item-btn {
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.75rem 0.9rem;
  text-align: left;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.exam-item-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--primary);
}
.exam-item-btn.active {
  background: var(--primary-light) !important;
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 1px var(--primary);
}
.exam-item-title {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text-main);
}
.exam-item-score {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--primary);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  background: var(--primary-light);
}

/* Exam Main Area */
.exam-content-area {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.exam-header-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  box-shadow: var(--shadow-sm);
}

.exam-title-block h2 {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}
.exam-title-block p {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 3px;
}

.exam-timer-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.timer-box {
  background: var(--primary-light);
  border: 1px solid rgba(221, 101, 82, 0.3);
  padding: 6px 14px;
  border-radius: var(--radius-md);
  font-family: monospace;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-exam-action {
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-exam-action:hover {
  background: var(--bg-card-hover);
  border-color: var(--text-muted);
}
.btn-exam-action.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 4px 12px var(--primary-glow);
}
.btn-exam-action.primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}
.btn-exam-action.reveal-all {
  background: var(--accent-light);
  border-color: rgba(181, 115, 58, 0.35);
  color: var(--accent);
}
.btn-exam-action.reveal-all.active {
  background: var(--accent);
  color: #fff;
}

/* Exam Section & Part Containers */
.exam-part-box {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.5rem;
}

.part-header {
  border-bottom: 2px solid var(--border-color);
  padding-bottom: 0.85rem;
  margin-bottom: 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}
.part-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}
.part-score-badge {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--primary);
  background: var(--primary-light);
  padding: 3px 10px;
  border-radius: var(--radius-full);
}

/* Part 1 Bank Words */
.bank-words-container {
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
}
.bank-words-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.bank-words-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.bank-word-chip {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-family: var(--hanzi-font);
  font-size: 1.05rem;
  color: var(--text-main);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}
.bank-word-chip .key {
  font-family: var(--body-font);
  font-weight: 800;
  color: var(--primary);
  font-size: 0.85rem;
}

/* Passage Presentation Card */
.reading-passage-card {
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
}
.passage-card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 0.65rem;
  display: flex;
  align-items: center;
  gap: 6px;
}
.passage-text-content {
  font-family: var(--hanzi-font);
  font-size: 1.12rem;
  line-height: 1.85;
  color: var(--text-main);
  text-align: justify;
}

/* Question Items */
.question-item {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.15rem 1.25rem;
  margin-bottom: 1rem;
  transition: var(--transition);
}
.question-item:hover {
  border-color: rgba(221, 101, 82, 0.4);
}

.question-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}
.q-badge {
  font-size: 0.78rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text-muted);
}
.q-score {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--primary);
}

.question-text {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 0.85rem;
  line-height: 1.5;
}
.question-text .hanzi-hl {
  font-family: var(--hanzi-font);
  font-size: 1.18rem;
  font-weight: 600;
}

/* MCQ Options */
.mcq-options-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 0.85rem;
}

.mcq-option-label {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: var(--transition);
  font-size: 0.95rem;
}
.mcq-option-label:hover {
  background: var(--bg-elevated);
  border-color: var(--text-dim);
}
.mcq-option-label input[type="radio"] {
  accent-color: var(--primary);
  width: 16px;
  height: 16px;
}
.mcq-option-label.checked {
  background: var(--primary-light);
  border-color: var(--primary);
}
.mcq-option-label.correct-mark {
  background: var(--success-light) !important;
  border-color: var(--success) !important;
  color: var(--success) !important;
  font-weight: 700;
}
.mcq-option-label.incorrect-mark {
  background: var(--danger-light) !important;
  border-color: var(--danger) !important;
  color: var(--danger) !important;
  text-decoration: line-through;
}

/* Fill Blank Dropdown/Input */
.fill-blank-select {
  padding: 8px 14px;
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 1rem;
  font-family: var(--hanzi-font);
  cursor: pointer;
  outline: none;
  min-width: 140px;
}
.fill-blank-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
}

/* True / False Buttons */
.tf-buttons-group {
  display: flex;
  gap: 10px;
  margin-bottom: 0.85rem;
}
.tf-btn {
  flex: 1;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-main);
  color: var(--text-main);
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.tf-btn:hover {
  background: var(--bg-elevated);
}
.tf-btn.active-true {
  background: var(--success-light);
  border-color: var(--success);
  color: var(--success);
}
.tf-btn.active-false {
  background: var(--danger-light);
  border-color: var(--danger);
  color: var(--danger);
}

/* TTTH7 Part 2: Clause Reorder (连句成段) */
.clause-reorder-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 1rem;
}
.clause-item-card {
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: var(--transition);
}
.clause-item-card:hover {
  border-color: var(--accent);
  background: var(--bg-elevated);
}
.clause-item-card.selected {
  background: var(--accent-light);
  border-color: var(--accent);
}
.clause-tag {
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  font-size: 0.85rem;
  width: 26px;
  height: 26px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.clause-text {
  font-family: var(--hanzi-font);
  font-size: 1.15rem;
  color: var(--text-main);
  line-height: 1.5;
}
.reorder-result-box {
  background: var(--bg-elevated);
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-size: 0.92rem;
  margin-bottom: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.reorder-sequence {
  font-weight: 800;
  color: var(--accent);
  letter-spacing: 0.1em;
  font-size: 1.1rem;
}

/* Question Action & Single Check Bar */
.single-q-feedback {
  display: none;
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.9rem;
  margin: 0.75rem 0 0.5rem;
  font-size: 0.88rem;
  line-height: 1.5;
  animation: fadeIn 0.2s ease;
}
.single-q-feedback.correct {
  background: var(--success-light);
  border: 1px solid rgba(46, 125, 50, 0.35);
  color: var(--success);
}
.single-q-feedback.incorrect {
  background: var(--danger-light);
  border: 1px solid rgba(221, 101, 82, 0.35);
  color: var(--danger);
}

.q-actions-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 0.75rem;
  padding-top: 0.65rem;
  border-top: 1px dashed var(--border-color);
}

.btn-check-q {
  background: var(--primary-light);
  border: 1px solid var(--primary);
  color: var(--primary);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.btn-check-q:hover {
  background: var(--primary);
  color: #fff;
}

.btn-toggle-explanation {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-toggle-explanation:hover {
  border-color: var(--text-muted);
  color: var(--text-main);
  background: var(--bg-elevated);
}
.btn-toggle-explanation.active {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent);
}

/* Explanation Box Accordion */
.explanation-box {
  display: none;
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 0.9rem 1.15rem;
  margin-top: 0.75rem;
  font-size: 0.88rem;
  line-height: 1.6;
  animation: fadeIn 0.2s ease;
}
.explanation-box.show {
  display: block;
}

.exp-row-item {
  margin-bottom: 0.45rem;
}
.exp-row-item:last-child {
  margin-bottom: 0;
}

.exp-tag {
  display: inline-block;
  padding: 1px 7px;
  border-radius: var(--radius-sm);
  font-size: 0.76rem;
  font-weight: 700;
  margin-right: 6px;
}
.exp-tag.success {
  background: var(--success-light);
  color: var(--success);
  border: 1px solid rgba(46, 125, 50, 0.3);
}
.exp-tag.info {
  background: var(--info-light);
  color: var(--info);
  border: 1px solid rgba(2, 132, 199, 0.3);
}
.exp-tag.grammar {
  background: var(--accent-light);
  color: var(--accent);
  border: 1px solid rgba(181, 115, 58, 0.3);
}
.exp-val.hanzi-hl {
  font-family: var(--hanzi-font);
  font-weight: 700;
}

/* ==========================================================================
   TAB 3: READING WORKSHOP (KHO BÀI ĐỌC 226 BÀI & KỸ NĂNG)
   ========================================================================== */
.workshop-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 1.5rem;
}
@media (max-width: 992px) {
  .workshop-layout {
    grid-template-columns: 1fr;
  }
}

.workshop-sidebar {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 180px);
  position: sticky;
  top: 120px;
  box-shadow: var(--shadow-sm);
}

.workshop-list-scroll {
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-right: 4px;
}

.workshop-item-btn {
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.75rem 0.9rem;
  text-align: left;
  cursor: pointer;
  transition: var(--transition);
}
.workshop-item-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent);
}
.workshop-item-btn.active {
  background: var(--accent-light) !important;
  border-color: var(--accent) !important;
}
.workshop-item-title {
  font-family: var(--hanzi-font);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 2px;
}
.workshop-item-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.workshop-reader-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow-sm);
}

.workshop-reader-header {
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 1.25rem;
  margin-bottom: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 12px;
}
.workshop-reader-title {
  font-family: var(--hanzi-font);
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.3;
}
.workshop-reader-meta {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.workshop-reader-tools {
  display: flex;
  gap: 8px;
}

.workshop-content-body {
  font-family: var(--hanzi-font);
  font-size: 1.22rem;
  line-height: 2.1;
  color: var(--text-main);
  margin-bottom: 2rem;
}

.bilingual-paragraph-item {
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}
.bilingual-hanzi {
  font-family: var(--hanzi-font);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.8;
}
.bilingual-pinyin {
  font-size: 0.85rem;
  color: var(--accent);
  font-style: italic;
  margin: 2px 0 4px;
}
.bilingual-vi {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ==========================================================================
   MODAL DIALOG (LESSON DETAIL & EXPORT)
   ========================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1.5rem;
}
.modal-overlay.active {
  display: flex;
  animation: fadeIn 0.2s ease;
}

.lesson-modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 980px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.lesson-modal-content.fullscreen {
  max-width: 98vw;
  max-height: 98vh;
  height: 98vh;
}

.modal-header-bar {
  padding: 1.15rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-elevated);
}
.modal-title-text {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text-main);
}
.modal-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}
.btn-modal-tool {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1rem;
  transition: var(--transition);
}
.btn-modal-tool:hover {
  color: var(--text-main);
  border-color: var(--text-muted);
}

.modal-scroll-body {
  overflow-y: auto;
  padding: 1.5rem;
  flex: 1;
}

.detail-section-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--primary);
  margin: 1.5rem 0 0.85rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 8px;
}
.detail-section-title:first-child {
  margin-top: 0;
}

/* Vocab Table in Modal */
.vocab-table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-bottom: 1.25rem;
}
.vocab-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
.vocab-table th {
  background: var(--bg-elevated);
  padding: 10px 14px;
  font-weight: 700;
  color: var(--text-muted);
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}
.vocab-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-main);
}
.vocab-table tr:hover td {
  background: var(--bg-elevated);
}
.vocab-hanzi {
  font-family: var(--hanzi-font);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
}
.vocab-pinyin {
  color: var(--accent);
  font-style: italic;
  font-size: 0.88rem;
}

/* Grammar Cards in Modal */
.grammar-card {
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-md);
  padding: 1.15rem 1.25rem;
  margin-bottom: 1rem;
}
.grammar-card-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 0.5rem;
}
.grammar-structure-box {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  margin-bottom: 0.65rem;
}
.example-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px dashed var(--border-color);
}
.example-item:last-child {
  border-bottom: none;
}
.ex-hanzi {
  font-family: var(--hanzi-font);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-main);
}
.ex-pinyin {
  font-size: 0.82rem;
  color: var(--accent);
}
.ex-vi {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Modal Score Alert */
.score-result-modal {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  padding: 2rem;
  text-align: center;
  box-shadow: var(--shadow-lg);
  animation: fadeIn 0.25s ease;
}
.score-circle {
  width: 120px;
  height: 120px;
  border-radius: var(--radius-full);
  background: var(--primary-light);
  border: 4px solid var(--primary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 1rem auto 1.5rem;
}
.score-circle .num {
  font-size: 2.2rem;
  font-weight: 900;
  color: var(--primary);
  line-height: 1;
}
.score-circle .scale {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
}

/* ==========================================================================
   VERTICAL ANSWERS & INTERACTIVE EXTENSIONS (ĐÁP ÁN DẠNG DỌC)
   ========================================================================== */

/* 1. True/False Buttons - Vertical Layout (Dạng dọc) */
.tf-buttons-row {
  display: flex !important;
  flex-direction: column !important;
  gap: 8px !important;
  margin: 0.85rem 0 !important;
  width: 100% !important;
  max-width: 460px !important;
}

.btn-tf {
  display: flex !important;
  align-items: center !important;
  justify-content: flex-start !important;
  gap: 12px !important;
  width: 100% !important;
  padding: 10px 16px !important;
  border-radius: var(--radius-sm) !important;
  border: 1px solid var(--border-color) !important;
  background: var(--bg-card) !important;
  color: var(--text-main) !important;
  font-size: 0.98rem !important;
  font-weight: 600 !important;
  cursor: pointer !important;
  transition: var(--transition) !important;
  text-align: left !important;
}

.btn-tf:hover {
  background: var(--bg-card-hover) !important;
  border-color: var(--primary) !important;
}

.btn-tf.true.selected {
  background: var(--success-light) !important;
  border-color: var(--success) !important;
  color: var(--success) !important;
  font-weight: 700 !important;
  box-shadow: 0 0 0 2px rgba(46, 125, 50, 0.2) !important;
}

.btn-tf.false.selected {
  background: var(--danger-light) !important;
  border-color: var(--danger) !important;
  color: var(--danger) !important;
  font-weight: 700 !important;
  box-shadow: 0 0 0 2px rgba(221, 101, 82, 0.2) !important;
}

/* 2. MCQ Options - Vertical Layout (Dạng dọc) */
.mcq-options-list {
  display: flex !important;
  flex-direction: column !important;
  gap: 8px !important;
  margin: 0.85rem 0 !important;
  width: 100% !important;
}

.mcq-option-btn {
  display: flex !important;
  align-items: center !important;
  justify-content: flex-start !important;
  gap: 12px !important;
  width: 100% !important;
  padding: 10px 16px !important;
  border-radius: var(--radius-sm) !important;
  border: 1px solid var(--border-color) !important;
  background: var(--bg-card) !important;
  color: var(--text-main) !important;
  font-size: 0.98rem !important;
  font-family: var(--hanzi-font) !important;
  cursor: pointer !important;
  transition: var(--transition) !important;
  text-align: left !important;
}

.mcq-option-btn:hover {
  background: var(--bg-card-hover) !important;
  border-color: var(--primary) !important;
}

.mcq-option-btn.selected {
  background: var(--primary-light) !important;
  border-color: var(--primary) !important;
  color: var(--primary) !important;
  font-weight: 700 !important;
  box-shadow: 0 0 0 2px var(--primary-glow) !important;
}

.mcq-option-btn .opt-tag {
  font-family: var(--body-font) !important;
  font-weight: 800 !important;
  font-size: 0.85rem !important;
  width: 26px !important;
  height: 26px !important;
  border-radius: var(--radius-full) !important;
  background: var(--bg-elevated) !important;
  color: var(--text-muted) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  flex-shrink: 0 !important;
}

.mcq-option-btn.selected .opt-tag {
  background: var(--primary) !important;
  color: #fff !important;
}

/* 3. Workshop MCQ vertical */
.workshop-mcq-options-vertical {
  display: flex !important;
  flex-direction: column !important;
  gap: 8px !important;
  margin: 0.85rem 0 !important;
}

.workshop-mcq-btn {
  display: flex !important;
  align-items: center !important;
  justify-content: flex-start !important;
  gap: 12px !important;
  width: 100% !important;
  padding: 10px 14px !important;
  border-radius: var(--radius-sm) !important;
  border: 1px solid var(--border-color) !important;
  background: var(--bg-card) !important;
  color: var(--text-main) !important;
  font-family: var(--hanzi-font) !important;
  font-size: 0.95rem !important;
  cursor: pointer !important;
  transition: var(--transition) !important;
  text-align: left !important;
}

.workshop-mcq-btn:hover {
  background: var(--bg-card-hover) !important;
  border-color: var(--accent) !important;
}

.workshop-mcq-btn.selected {
  background: var(--accent-light) !important;
  border-color: var(--accent) !important;
  color: var(--accent) !important;
  font-weight: 700 !important;
  box-shadow: 0 0 0 2px rgba(181, 115, 58, 0.25) !important;
}

/* 4. Clause Sequence Builder (3, 4, 5, 6 Clauses) */
.clause-list-box {
  display: flex !important;
  flex-direction: column !important;
  gap: 8px !important;
  margin-bottom: 1rem !important;
}

.clause-row-item {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 10px !important;
  padding: 10px 14px !important;
  border-radius: var(--radius-sm) !important;
  border: 1px solid var(--border-color) !important;
  background: var(--bg-main) !important;
  cursor: pointer !important;
  transition: var(--transition) !important;
}

.clause-row-item:hover {
  background: var(--bg-elevated) !important;
  border-color: var(--accent) !important;
}

.clause-row-item.chosen {
  opacity: 0.65 !important;
  background: var(--bg-elevated) !important;
  border-style: dashed !important;
}

.clause-letter-badge {
  width: 26px !important;
  height: 26px !important;
  border-radius: var(--radius-full) !important;
  background: var(--accent) !important;
  color: #fff !important;
  font-weight: 800 !important;
  font-size: 0.82rem !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  flex-shrink: 0 !important;
}

.clause-sort-controller {
  background: var(--bg-elevated) !important;
  border: 1px solid var(--border-color) !important;
  border-radius: var(--radius-md) !important;
  padding: 12px 14px !important;
  margin-bottom: 1rem !important;
}

.clause-sequence-display {
  display: flex !important;
  align-items: center !important;
  flex-wrap: wrap !important;
  gap: 8px !important;
  margin-top: 8px !important;
  min-height: 44px !important;
  padding: 6px 12px !important;
  background: var(--bg-card) !important;
  border: 1px dashed var(--border-color) !important;
  border-radius: var(--radius-sm) !important;
}

.sequence-slot-pill {
  background: var(--primary) !important;
  color: #fff !important;
  font-weight: 800 !important;
  padding: 4px 10px !important;
  border-radius: var(--radius-sm) !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 6px !important;
  font-size: 0.9rem !important;
}

.clause-pick-pool {
  display: flex !important;
  flex-wrap: wrap !important;
  gap: 8px !important;
  margin-top: 10px !important;
}

.btn-pick-clause {
  background: var(--bg-card) !important;
  border: 1px solid var(--border-color) !important;
  padding: 6px 14px !important;
  border-radius: var(--radius-sm) !important;
  font-weight: 700 !important;
  font-size: 0.9rem !important;
  cursor: pointer !important;
  transition: var(--transition) !important;
  color: var(--text-main) !important;
}

.btn-pick-clause:hover {
  background: var(--primary-light) !important;
  border-color: var(--primary) !important;
  color: var(--primary) !important;
}

.btn-pick-clause.disabled {
  opacity: 0.4 !important;
  pointer-events: none !important;
}

/* 5. Fix Workshop Sidebar Layout & Search */
.workshop-sidebar {
  display: flex !important;
  flex-direction: column !important;
  max-height: calc(100vh - 180px) !important;
  position: sticky !important;
  top: 120px !important;
}

.workshop-sidebar .search-input-wrapper {
  flex: none !important;
  width: 100% !important;
  min-width: 0 !important;
  margin-bottom: 0.75rem !important;
}

.workshop-passage-scroll,
.workshop-list-scroll {
  overflow-y: auto !important;
  flex: 1 1 0 !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 6px !important;
  padding-right: 4px !important;
  min-height: 0 !important;
}

.workshop-passage-item {
  background: var(--bg-main) !important;
  border: 1px solid var(--border-color) !important;
  border-radius: var(--radius-md) !important;
  padding: 0.75rem 0.9rem !important;
  text-align: left !important;
  cursor: pointer !important;
  transition: var(--transition) !important;
}

.workshop-passage-item:hover {
  background: var(--bg-card-hover) !important;
  border-color: var(--accent) !important;
}

.workshop-passage-item.active {
  background: var(--accent-light) !important;
  border-color: var(--accent) !important;
  border-left: 4px solid var(--accent) !important;
}

.wp-title {
  font-family: var(--hanzi-font) !important;
  font-size: 1rem !important;
  font-weight: 700 !important;
  color: var(--text-main) !important;
  margin-bottom: 2px !important;
}

.wp-sub {
  font-size: 0.78rem !important;
  color: var(--text-muted) !important;
}

/* 6. Passage Control Toolbar */
.passage-control-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 6px 12px;
  margin-bottom: 12px;
}

.passage-control-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.btn-passage-toggle {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.btn-passage-toggle:hover {
  border-color: var(--primary);
  color: var(--text-main);
}

.btn-passage-toggle.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.passage-clickable-hanzi {
  cursor: pointer;
  border-radius: 2px;
  transition: background 0.15s ease;
}

.passage-clickable-hanzi:hover {
  background: rgba(221, 101, 82, 0.22);
  color: var(--primary);
}

.passage-pinyin-line,
.passage-pinyin-block {
  font-size: 0.9rem;
  color: var(--accent);
  font-style: italic;
  margin: 3px 0 6px;
  display: none !important;
}

.passage-vi-line,
.passage-vi-block {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-bottom: 8px;
  display: none !important;
}

.show-pinyin .passage-pinyin-line,
.show-pinyin .passage-pinyin-block {
  display: block !important;
}

.show-vi .passage-vi-line,
.show-vi .passage-vi-block {
  display: block !important;
}

/* 7. Hanzi Dictionary Drawer */
.hanzi-dict-drawer {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 380px;
  max-width: 92vw;
  max-height: 80vh;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-top: 4px solid var(--primary);
  border-radius: var(--radius-lg);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.35);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(120%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.hanzi-dict-drawer.open {
  transform: translateY(0);
}

.dict-drawer-header {
  padding: 10px 14px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.dict-header-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 6px;
}

.dict-tool-btn {
  background: transparent;
  border: none;
  font-size: 1.4rem;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
}

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

.dict-search-box {
  display: flex;
  padding: 8px 12px;
  background: var(--bg-main);
  border-bottom: 1px solid var(--border-color);
  gap: 6px;
}

.dict-search-box input {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-main);
  font-size: 0.88rem;
  outline: none;
}

.btn-dict-search {
  background: var(--primary);
  border: none;
  color: #fff;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}

.dict-drawer-body {
  padding: 12px 14px;
  overflow-y: auto;
  flex: 1;
}

.dict-empty-state {
  text-align: center;
  padding: 1.5rem 0.5rem;
  color: var(--text-muted);
}

.dict-word-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-color);
}

.dict-hanzi-main {
  font-family: var(--hanzi-font);
  font-size: 2rem;
  font-weight: 800;
  color: var(--primary);
}

.btn-dict-speak {
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}

.dict-row {
  margin-bottom: 4px;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.dict-tag {
  font-size: 0.74rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: var(--radius-sm);
}

.dict-tag.pinyin {
  background: var(--accent-light);
  color: var(--accent);
}

.dict-tag.hanviet {
  background: var(--gold-light);
  color: var(--gold);
}

.dict-tag.hsk {
  background: var(--primary-light);
  color: var(--primary);
}

.dict-pinyin-val {
  font-weight: 700;
  color: var(--accent);
  font-size: 1rem;
}

.dict-hanviet-val {
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 0.05em;
}

.dict-meaning-box {
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  margin: 10px 0;
  font-size: 0.88rem;
}

.dict-meaning-text {
  margin-top: 4px;
  color: var(--text-main);
  line-height: 1.5;
}

.dict-singles-section {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border-color);
}

.dict-sec-title {
  font-weight: 700;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.dict-singles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 6px;
}

.dict-single-item {
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  cursor: pointer;
  transition: var(--transition);
}

.dict-single-item:hover {
  border-color: var(--primary);
  background: var(--bg-card-hover);
}

.s-hanzi {
  font-family: var(--hanzi-font);
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--primary);
}

.s-py {
  font-size: 0.78rem;
  color: var(--accent);
}

.s-sv {
  font-size: 0.75rem;
  color: var(--gold);
  font-weight: 700;
}

.s-vi {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.dict-related-tags {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.dict-related-pill {
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  text-align: left;
  cursor: pointer;
  transition: var(--transition);
  color: var(--text-main);
}

.dict-related-pill:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

/* ==========================================================================
   WORKSHOP VOLUME FILTER PILLS & SIDEBAR FIX
   ========================================================================== */
.workshop-volume-filter-pills {
  display: flex;
  gap: 6px;
  margin-bottom: 0.85rem;
  width: 100%;
}

.wv-filter-btn {
  flex: 1;
  padding: 6px 4px;
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
  white-space: nowrap;
}

.wv-filter-btn:hover {
  border-color: var(--primary);
  color: var(--text-main);
}

.wv-filter-btn.active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

/* ==========================================================================
   HANDBOOK PREVIEW & PRINT MODAL
   ========================================================================== */
.handbook-preview-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  width: 95%;
  max-width: 1100px;
  height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-color);
  overflow: hidden;
  animation: modalPop 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.preview-header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-surface);
  flex-shrink: 0;
  gap: 12px;
}

.preview-brand-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.preview-icon {
  font-size: 1.8rem;
}

.preview-title-text {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-main);
  margin: 0;
}

.preview-sub-text {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin: 0;
}

.preview-action-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-preview-tool {
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid var(--border-color);
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-preview-tool.print-pdf {
  background: linear-gradient(135deg, #059669, #047857);
  color: #ffffff;
  border-color: #047857;
}

.btn-preview-tool.print-pdf:hover {
  background: linear-gradient(135deg, #047857, #065f46);
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(5, 150, 105, 0.3);
}

.btn-preview-tool.word {
  background: #1d4ed8;
  color: #ffffff;
  border-color: #1e40af;
}

.btn-preview-tool.word:hover {
  background: #1e40af;
}

.btn-preview-tool.excel {
  background: #15803d;
  color: #ffffff;
  border-color: #166534;
}

.btn-preview-tool.excel:hover {
  background: #166534;
}

.btn-preview-tool.close {
  background: var(--bg-main);
  color: var(--text-muted);
  font-size: 1.25rem;
  padding: 4px 10px;
}

.btn-preview-tool.close:hover {
  color: var(--danger);
}

.preview-scroll-body {
  flex: 1;
  overflow-y: auto;
  padding: 2.5rem;
  background: var(--bg-main);
}

/* Document Sheet in Preview (Simulating A4 paper) */
.preview-document-sheet {
  background: #ffffff;
  color: #1f2937;
  max-width: 900px;
  margin: 0 auto;
  padding: 3rem 3.5rem;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
  border-radius: 4px;
  font-family: 'Times New Roman', 'SimSun', serif;
  line-height: 1.6;
}

.doc-cover-header {
  text-align: center;
  border-bottom: 2.5px solid #064e3b;
  padding-bottom: 1.5rem;
  margin-bottom: 2rem;
}

.doc-org-title {
  font-size: 0.95rem;
  font-weight: 700;
  text-transform: uppercase;
  color: #374151;
  letter-spacing: 0.5px;
}

.doc-main-title {
  font-size: 1.85rem;
  font-weight: 800;
  color: #064e3b;
  margin: 0.5rem 0;
}

.doc-sub-title {
  font-size: 1.05rem;
  color: #047857;
  font-style: italic;
}

.doc-stat-pills {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 1rem;
  flex-wrap: wrap;
}

.doc-stat-pill {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #065f46;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
}

.doc-toc-box {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 2.5rem;
}

.doc-toc-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: #111827;
  margin-bottom: 0.75rem;
  border-bottom: 1px dashed #d1d5db;
  padding-bottom: 0.5rem;
}

.doc-toc-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px 16px;
  font-size: 0.9rem;
}

.doc-toc-link {
  color: #0369a1;
  text-decoration: none;
  display: flex;
  justify-content: space-between;
}

.doc-toc-link:hover {
  text-decoration: underline;
}

.preview-lesson-block {
  margin-bottom: 3rem;
  padding-top: 1rem;
  border-top: 1px solid #e5e7eb;
}

.preview-lesson-head {
  margin-bottom: 1.25rem;
}

.preview-lesson-title {
  font-size: 1.4rem;
  font-weight: 800;
  color: #064e3b;
  font-family: 'Times New Roman', 'SimSun', serif;
}

.preview-lesson-sub {
  font-size: 0.95rem;
  color: #4b5563;
  font-style: italic;
}

.preview-section-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #047857;
  margin: 1.25rem 0 0.5rem 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Document Vocabulary Table */
.doc-vocab-table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.75rem 0 1.5rem 0;
  font-size: 0.88rem;
}

.doc-vocab-table th,
.doc-vocab-table td {
  border: 1px solid #cbd5e1;
  padding: 6px 8px;
  text-align: left;
}

.doc-vocab-table th {
  background: #f1f5f9;
  color: #0f172a;
  font-weight: 700;
}

.doc-vocab-table td.ch {
  font-family: var(--hanzi-font);
  font-size: 1.15rem;
  font-weight: 700;
  color: #0f172a;
}

.doc-vocab-table td.py {
  color: #b45309;
  font-weight: 600;
}

.doc-vocab-table td.hv {
  color: #047857;
  font-weight: 600;
}

/* Document Grammar & Passages */
.doc-grammar-item {
  background: #f8fafc;
  border-left: 3px solid #047857;
  padding: 8px 12px;
  margin-bottom: 8px;
  border-radius: 0 4px 4px 0;
}

.doc-passage-item {
  background: #fdfdfd;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 12px;
  margin-bottom: 12px;
}

.doc-passage-ch {
  font-family: var(--hanzi-font);
  font-size: 1.15rem;
  font-weight: 600;
  color: #0f172a;
  margin-bottom: 4px;
  line-height: 1.6;
}

.doc-passage-py {
  font-size: 0.85rem;
  color: #b45309;
  margin-bottom: 2px;
}

.doc-passage-vi {
  font-size: 0.88rem;
  color: #475569;
  font-style: italic;
}

/* ==========================================================================
   PRINT STYLESHEET (A4 PDF EXPORT)
   ========================================================================== */
@media print {
  @page {
    size: A4 portrait;
    margin: 15mm 12mm 15mm 12mm;
  }

  body * {
    visibility: hidden !important;
  }

  #preview-handbook-modal,
  #preview-handbook-modal *,
  #user-notebook-modal,
  #user-notebook-modal * {
    visibility: visible !important;
  }

  #preview-handbook-modal,
  #user-notebook-modal {
    position: absolute !important;
    left: 0 !important;
    top: 0 !important;
    width: 100% !important;
    height: auto !important;
    background: transparent !important;
    padding: 0 !important;
    margin: 0 !important;
    display: block !important;
    overflow: visible !important;
  }

  .handbook-preview-card {
    border: none !important;
    box-shadow: none !important;
    max-width: 100% !important;
    width: 100% !important;
    height: auto !important;
    background: transparent !important;
    overflow: visible !important;
  }

  .preview-header-bar,
  .no-print {
    display: none !important;
  }

  .preview-scroll-body {
    padding: 0 !important;
    background: transparent !important;
    overflow: visible !important;
  }

  .preview-document-sheet {
    box-shadow: none !important;
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
    max-width: 100% !important;
    width: 100% !important;
  }

  .preview-lesson-block {
    page-break-after: always;
    break-after: page;
  }

  .doc-vocab-table,
  .doc-passage-item,
  .doc-grammar-item {
    page-break-inside: avoid;
    break-inside: avoid;
  }
}

/* ==========================================================================
   CLICKABLE HANZI SPANS & HIGHLIGHTS
   ========================================================================== */
.hz-char {
  cursor: pointer;
  border-radius: 2px;
  transition: all 0.12s ease;
  display: inline;
  padding: 0 1px;
}

.hz-char:hover {
  background: rgba(221, 101, 82, 0.28) !important;
  color: var(--primary) !important;
  border-radius: 3px;
  box-shadow: 0 0 0 1px var(--primary);
}

.hz-char.hz-selected {
  background: #fef08a !important;
  color: #854d0e !important;
  font-weight: 700;
  border-radius: 3px;
}

/* Dictionary Drawer Save to Notebook Button */
.btn-save-notebook {
  background: var(--bg-card);
  border: 1px solid var(--gold);
  color: var(--gold);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.btn-save-notebook:hover {
  background: var(--gold);
  color: #ffffff;
}

.btn-save-notebook.saved {
  background: var(--gold);
  color: #ffffff;
}

/* Toast Message */
.dict-toast-msg {
  position: fixed;
  bottom: 25px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: #064e3b;
  color: #ffffff;
  padding: 10px 22px;
  border-radius: 30px;
  font-weight: 700;
  font-size: 0.92rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  z-index: 100000;
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
}

.dict-toast-msg.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Handbook Preview Pinyin & Vietnamese Toggles */
.hide-handbook-pinyin .doc-passage-py,
.hide-handbook-pinyin td.py,
.hide-handbook-pinyin th:nth-child(3) {
  display: none !important;
}

.hide-handbook-vi .doc-passage-vi {
  display: none !important;
}

@media print {
  .hide-handbook-pinyin .doc-passage-py,
  .hide-handbook-pinyin td.py,
  .hide-handbook-pinyin th:nth-child(3) {
    display: none !important;
  }

  .hide-handbook-vi .doc-passage-vi {
    display: none !important;
  }
}


/* ==========================================================================
   PERSONAL SAVED VOCABULARY NOTEBOOK STYLES
   ========================================================================== */
.btn-user-notebook-header {
  background: linear-gradient(135deg, #d97706, #b45309);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 2px 8px rgba(180, 83, 9, 0.25);
  transition: var(--transition);
}

.btn-user-notebook-header:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(180, 83, 9, 0.35);
  filter: brightness(1.08);
}

.hide-handbook-pinyin .doc-passage-py,
.hide-handbook-pinyin .doc-grammar-py,
.hide-handbook-pinyin td.py,
.hide-handbook-pinyin th.col-py {
  display: none !important;
}

.hide-handbook-vi .doc-passage-vi,
.hide-handbook-vi .doc-grammar-vi,
.hide-handbook-vi .doc-vocab-exvi,
.hide-handbook-vi td.mn,
.hide-handbook-vi th.col-mn {
  display: none !important;
}


/* ==========================================================================
   ======
   TAB 3: CHUYÊN ĐỀ VIẾT VĂN & BÀI MẪU (WRITING WORKSHOP)
   ========================================================================== */
.writing-layout-grid {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 1.5rem;
}

@media (max-width: 960px) {
  .writing-layout-grid {
    grid-template-columns: 1fr;
  }
}

.writing-topic-list {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
}

.topic-item-btn {
  width: 100%;
  text-align: left;
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  padding: 0.85rem 1rem;
  border-radius: var(--radius-md);
  margin-bottom: 0.65rem;
  cursor: pointer;
  transition: var(--transition);
}

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

.topic-item-btn.active {
  background: linear-gradient(135deg, rgba(79, 70, 229, 0.2), rgba(14, 165, 233, 0.2));
  border-color: var(--primary);
}

.topic-item-btn .t-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-main);
  margin-bottom: 0.25rem;
}

.topic-item-btn .t-req {
  font-size: 0.78rem;
  color: var(--accent);
}

/* Writing Pad Details */
.writing-detail-view {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
}

.topic-header-banner {
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 1.25rem;
  margin-bottom: 1.5rem;
}

.topic-header-banner h2 {
  font-size: 1.45rem;
  font-weight: 800;
  margin-bottom: 0.4rem;
}

.req-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(14, 165, 233, 0.15);
  color: #38bdf8;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 600;
}

/* Outline Cards */
.outline-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}
@media (max-width: 768px) {
  .outline-grid {
    grid-template-columns: 1fr;
  }
}

.outline-card {
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
}

.outline-card h4 {
  font-size: 0.9rem;
  color: var(--accent);
  margin-bottom: 0.5rem;
}

.outline-card p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Vocab & Structure Tags */
.chips-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 1.5rem;
}

.vocab-badge-chip {
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
}
.vocab-badge-chip b {
  font-family: var(--hanzi-font);
  color: var(--text-main);
  font-size: 0.95rem;
}
.vocab-badge-chip span {
  color: var(--text-dim);
  font-size: 0.8rem;
  margin-left: 4px;
}

/* Interactive Textarea & Live Hanzi Counter */
.writing-pad-box {
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}

.writing-pad-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.writing-pad-header h4 {
  font-size: 0.95rem;
  font-weight: 700;
}

.counter-gauge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  font-weight: 700;
}

.counter-pill {
  padding: 4px 12px;
  border-radius: var(--radius-full);
  background: var(--bg-elevated);
  color: var(--text-muted);
  transition: var(--transition);
}
.counter-pill.under {
  background: rgba(245, 158, 11, 0.15);
  color: var(--warning);
}
.counter-pill.target {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
}
.counter-pill.over {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
}

.chinese-textarea {
  width: 100%;
  min-height: 140px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 1rem;
  color: var(--text-main);
  font-family: var(--hanzi-font);
  font-size: 1.15rem;
  line-height: 1.8;
  resize: vertical;
  outline: none;
}
.chinese-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

/* Multi-Style Sample Essay Section (IELTS Mate Card Style) */
.style-switcher-bar {
  margin-bottom: 1.25rem;
}

.style-tabs-group {
  display: inline-flex;
  background: var(--bg-elevated);
  padding: 4px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
  gap: 4px;
  flex-wrap: wrap;
}

.style-tab-btn {
  background: transparent;
  border: none;
  padding: 8px 18px;
  border-radius: var(--radius-full);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  user-select: none;
}
.style-tab-btn:hover {
  color: var(--text-main);
}
.style-tab-btn.active {
  background: var(--bg-card);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.sample-essay-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  margin-bottom: 1.5rem;
}
.sample-essay-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
}

.sample-essay-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.sample-meta-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.style-tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid var(--primary-glow);
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  font-weight: 700;
}

.style-desc-text {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-style: italic;
}

.sample-hanzi-content {
  font-family: var(--hanzi-font);
  font-size: 1.25rem;
  line-height: 2;
  color: var(--text-main);
  margin-bottom: 1rem;
  letter-spacing: 0.03em;
  background: var(--bg-main);
  padding: 1.25rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.sample-pinyin-content {
  font-size: 0.95rem;
  line-height: 1.8;
  color: var(--accent);
  margin-bottom: 0.85rem;
  font-style: italic;
  padding: 0.5rem 0.75rem;
  background: var(--accent-light);
  border-radius: var(--radius-sm);
}

.sample-vi-content {
  font-size: 0.95rem;
  line-height: 1.8;
  color: var(--text-main);
  border-top: 1px dashed var(--border-color);
  padding-top: 1rem;
}

/* Side-by-side comparison grid */
.sample-comparison-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 1.5rem;
}

/* Utilities */
.text-center { text-align: center; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }

/* ==========================================================================
   ENHANCED LESSON MODAL FULLSCREEN & EXPORT TOOLBAR
   ========================================================================== */

.modal-overlay.is-fullscreen {
  padding: 0 !important;
}

.lesson-modal-content.fullscreen {
  width: 100vw !important;
  max-width: 100vw !important;
  height: 100vh !important;
  max-height: 100vh !important;
  border-radius: 0 !important;
  border: none !important;
  margin: 0 !important;
}

.modal-header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.btn-modal-action {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.35rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition);
}

.btn-modal-action:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  transform: translateY(-1px);
}

.btn-modal-action.primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* Master Curriculum Toolbar */
.curriculum-master-bar {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  box-shadow: var(--shadow-sm);
}

.master-bar-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.master-bar-title .icon {
  font-size: 1.75rem;
  background: rgba(221, 101, 82, 0.12);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.master-bar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.btn-master-export {
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.5rem 0.9rem;
  font-size: 0.86rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition);
}

.btn-master-export:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.btn-master-export.gold {
  background: linear-gradient(135deg, #a8791f, #c5932e);
  color: #fff;
  border-color: #a8791f;
}

.btn-master-export.gold:hover {
  background: linear-gradient(135deg, #8a6216, #a8791f);
}

/* Lesson Texts & Dialogues */
.lesson-text-block {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

.lesson-text-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 0.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.lesson-text-sub {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px dashed var(--border-color);
}

.dialogue-turn {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.dialogue-turn:hover {
  background: var(--bg-elevated);
}

.turn-speaker {
  font-weight: 700;
  color: var(--primary);
  min-width: 50px;
  background: rgba(221, 101, 82, 0.1);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  text-align: center;
  font-size: 0.82rem;
  flex-shrink: 0;
}

.turn-content {
  flex: 1;
}

.turn-hanzi {
  font-family: var(--hanzi-font);
  font-size: 1.2rem;
  color: var(--text-main);
  line-height: 1.5;
}

.turn-pinyin {
  font-size: 0.88rem;
  color: var(--accent);
  font-style: italic;
  margin: 2px 0;
}

.turn-vi {
  font-size: 0.88rem;
  color: var(--text-muted);
}

/* =====================================================================
/* ==========================================================================
   4-COURSE SWITCHER PILLS (TTTH 3 - 4 - 7 - 8)
   ========================================================================== */
.course-switch-pills {
  display: flex;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 248, 240, 0.18);
  border-radius: var(--radius-full);
  padding: 4px;
  gap: 4px;
  flex-wrap: wrap;
}

.course-pill-btn {
  background: transparent;
  border: none;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  color: #e8d5c4;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: var(--transition);
  user-select: none;
}

.course-pill-btn:hover {
  color: #fff8f0;
  background: rgba(255, 255, 255, 0.08);
}

.course-pill-btn.active {
  background: linear-gradient(135deg, #d97706, #b45309);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(217, 119, 6, 0.4);
}

.course-pill-btn .course-badge {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  opacity: 0.85;
}

.course-pill-btn .course-label {
  font-size: 0.82rem;
  font-weight: 700;
}


/* ==========================================================================
   WRITING & OCR VISION WORKSHOP STYLES (FROM TH4&8)
   ========================================================================== */
   TAB 3: CHUYÊN ĐỀ VIẾT VĂN & BÀI MẪU (WRITING WORKSHOP)
   ========================================================================== */
.writing-layout-grid {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 1.5rem;
}

@media (max-width: 960px) {
  .writing-layout-grid {
    grid-template-columns: 1fr;
  }
}

.writing-topic-list {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
}

.topic-item-btn {
  width: 100%;
  text-align: left;
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  padding: 0.85rem 1rem;
  border-radius: var(--radius-md);
  margin-bottom: 0.65rem;
  cursor: pointer;
  transition: var(--transition);
}

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

.topic-item-btn.active {
  background: linear-gradient(135deg, rgba(79, 70, 229, 0.2), rgba(14, 165, 233, 0.2));
  border-color: var(--primary);
}

.topic-item-btn .t-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-main);
  margin-bottom: 0.25rem;
}

.topic-item-btn .t-req {
  font-size: 0.78rem;
  color: var(--accent);
}

/* Writing Pad Details */
.writing-detail-view {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
}

.topic-header-banner {
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 1.25rem;
  margin-bottom: 1.5rem;
}

.topic-header-banner h2 {
  font-size: 1.45rem;
  font-weight: 800;
  margin-bottom: 0.4rem;
}

.req-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(14, 165, 233, 0.15);
  color: #38bdf8;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 600;
}

/* Outline Cards */
.outline-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}
@media (max-width: 768px) {
  .outline-grid {
    grid-template-columns: 1fr;
  }
}

.outline-card {
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
}

.outline-card h4 {
  font-size: 0.9rem;
  color: var(--accent);
  margin-bottom: 0.5rem;
}

.outline-card p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Vocab & Structure Tags */
.chips-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 1.5rem;
}

.vocab-badge-chip {
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
}
.vocab-badge-chip b {
  font-family: var(--hanzi-font);
  color: var(--text-main);
  font-size: 0.95rem;
}
.vocab-badge-chip span {
  color: var(--text-dim);
  font-size: 0.8rem;
  margin-left: 4px;
}

/* Interactive Textarea & Live Hanzi Counter */
.writing-pad-box {
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}

.writing-pad-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.writing-pad-header h4 {
  font-size: 0.95rem;
  font-weight: 700;
}

.counter-gauge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  font-weight: 700;
}

.counter-pill {
  padding: 4px 12px;
  border-radius: var(--radius-full);
  background: var(--bg-elevated);
  color: var(--text-muted);
  transition: var(--transition);
}
.counter-pill.under {
  background: rgba(245, 158, 11, 0.15);
  color: var(--warning);
}
.counter-pill.target {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
}
.counter-pill.over {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
}

.chinese-textarea {
  width: 100%;
  min-height: 140px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 1rem;
  color: var(--text-main);
  font-family: var(--hanzi-font);
  font-size: 1.15rem;
  line-height: 1.8;
  resize: vertical;
  outline: none;
}
.chinese-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

/* Multi-Style Sample Essay Section (IELTS Mate Card Style) */
.style-switcher-bar {
  margin-bottom: 1.25rem;
}

.style-tabs-group {
  display: inline-flex;
  background: var(--bg-elevated);
  padding: 4px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
  gap: 4px;
  flex-wrap: wrap;
}

.style-tab-btn {
  background: transparent;
  border: none;
  padding: 8px 18px;
  border-radius: var(--radius-full);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  user-select: none;
}
.style-tab-btn:hover {
  color: var(--text-main);
}
.style-tab-btn.active {
  background: var(--bg-card);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.sample-essay-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  margin-bottom: 1.5rem;
}
.sample-essay-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
}

.sample-essay-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.sample-meta-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.style-tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid var(--primary-glow);
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  font-weight: 700;
}

.style-desc-text {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-style: italic;
}

.sample-hanzi-content {
  font-family: var(--hanzi-font);
  font-size: 1.25rem;
  line-height: 2;
  color: var(--text-main);
  margin-bottom: 1rem;
  letter-spacing: 0.03em;
  background: var(--bg-main);
  padding: 1.25rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.sample-pinyin-content {
  font-size: 0.95rem;
  line-height: 1.8;
  color: var(--accent);
  margin-bottom: 0.85rem;
  font-style: italic;
  padding: 0.5rem 0.75rem;
  background: var(--accent-light);
  border-radius: var(--radius-sm);
}

.sample-vi-content {
  font-size: 0.95rem;
  line-height: 1.8;
  color: var(--text-main);
  border-top: 1px dashed var(--border-color);
  padding-top: 1rem;
}

/* Side-by-side comparison grid */
.sample-comparison-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 1.5rem;
}

/* Utilities */
.text-center { text-align: center; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }

/* ==========================================================================
   ENHANCED LESSON MODAL FULLSCREEN & EXPORT TOOLBAR
   ========================================================================== */

.modal-overlay.is-fullscreen {
  padding: 0 !important;
}

.lesson-modal-content.fullscreen {
  width: 100vw !important;
  max-width: 100vw !important;
  height: 100vh !important;
  max-height: 100vh !important;
  border-radius: 0 !important;
  border: none !important;
  margin: 0 !important;
}

.modal-header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.btn-modal-action {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.35rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition);
}

.btn-modal-action:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  transform: translateY(-1px);
}

.btn-modal-action.primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* Master Curriculum Toolbar */
.curriculum-master-bar {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  box-shadow: var(--shadow-sm);
}

.master-bar-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.master-bar-title .icon {
  font-size: 1.75rem;
  background: rgba(221, 101, 82, 0.12);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.master-bar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.btn-master-export {
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.5rem 0.9rem;
  font-size: 0.86rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition);
}

.btn-master-export:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.btn-master-export.gold {
  background: linear-gradient(135deg, #a8791f, #c5932e);
  color: #fff;
  border-color: #a8791f;
}

.btn-master-export.gold:hover {
  background: linear-gradient(135deg, #8a6216, #a8791f);
}

/* Lesson Texts & Dialogues */
.lesson-text-block {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

.lesson-text-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 0.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.lesson-text-sub {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px dashed var(--border-color);
}

.dialogue-turn {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.dialogue-turn:hover {
  background: var(--bg-elevated);
}

.turn-speaker {
  font-weight: 700;
  color: var(--primary);
  min-width: 50px;
  background: rgba(221, 101, 82, 0.1);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  text-align: center;
  font-size: 0.82rem;
  flex-shrink: 0;
}

.turn-content {
  flex: 1;
}

.turn-hanzi {
  font-family: var(--hanzi-font);
  font-size: 1.2rem;
  color: var(--text-main);
  line-height: 1.5;
}

.turn-pinyin {
  font-size: 0.88rem;
  color: var(--accent);
  font-style: italic;
  margin: 2px 0;
}

.turn-vi {
  font-size: 0.88rem;
  color: var(--text-muted);
}

/* ==========================================================================
   COFFEE BROWN HEADER & BANNER (NÂU CAFE CAO CẤP)
   ========================================================================== */

.app-header {
  background: linear-gradient(135deg, #2b170c 0%, #3e2213 50%, #4a2b19 100%) !important;
  border-bottom: 2px solid #5d3822 !important;
  color: #fff8f0 !important;
  box-shadow: 0 4px 20px rgba(43, 23, 12, 0.35) !important;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 0.85rem 1.5rem;
}

[data-theme="light"] .app-header,
[data-theme="ieltsmate"] .app-header,
[data-theme="ieltsmate-dark"] .app-header,
[data-theme="dark"] .app-header {
  background: linear-gradient(135deg, #2b170c 0%, #3e2213 50%, #4a2b19 100%) !important;
  border-bottom: 2px solid #5d3822 !important;
}

.brand-logo,
.brand-logo-badge {
  background: linear-gradient(135deg, #d97706, #92400e) !important;
  color: #fff8f0 !important;
  border: 1px solid rgba(255, 248, 240, 0.25) !important;
  box-shadow: 0 4px 12px rgba(217, 119, 6, 0.35) !important;
  font-family: var(--hanzi-font) !important;
  font-size: 1.5rem !important;
  font-weight: 700 !important;
}

.brand-text h1,
.brand-info h1 {
  color: #fff8f0 !important;
  background: none !important;
  -webkit-background-clip: initial !important;
  -webkit-text-fill-color: initial !important;
  font-weight: 800 !important;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.45) !important;
}

.brand-text p,
.brand-info p {
  color: #e8d5c4 !important;
}

/* Volume switcher in header */
.volume-switch-pills {
  background: rgba(0, 0, 0, 0.35) !important;
  border: 1px solid rgba(255, 248, 240, 0.2) !important;
  border-radius: var(--radius-full) !important;
  padding: 3px !important;
}

.vol-btn {
  color: #e8d5c4 !important;
  background: transparent !important;
  border: none !important;
}

.vol-btn:hover {
  color: #ffffff !important;
}

.vol-btn.active {
  background: #dd6552 !important;
  color: #ffffff !important;
  box-shadow: 0 2px 8px rgba(221, 101, 82, 0.45) !important;
}

/* Tab buttons in header */
.nav-tab-btn {
  color: #e8d5c4 !important;
}

.nav-tab-btn:hover {
  color: #ffffff !important;
  background: rgba(255, 255, 255, 0.08) !important;
}

.nav-tab-btn.active {
  color: #ffffff !important;
  border-bottom: 3px solid #dd6552 !important;
  background: rgba(221, 101, 82, 0.16) !important;
}

.nav-tab-btn .nav-badge {
  background: rgba(255, 255, 255, 0.18) !important;
  color: #fff8f0 !important;
}

.nav-tab-btn.active .nav-badge {
  background: #dd6552 !important;
  color: #ffffff !important;
}

/* Theme button in header */
.theme-btn {
  background: rgba(255, 255, 255, 0.12) !important;
  border: 1px solid rgba(255, 248, 240, 0.25) !important;
  color: #fff8f0 !important;
}
.theme-btn:hover {
  background: rgba(255, 255, 255, 0.22) !important;
}

/* Coffee Brown Volume Banner */
.volume-banner {
  background: linear-gradient(135deg, #f7efe6 0%, #ebe0d1 100%) !important;
  border: 1px solid #d8c7b3 !important;
  border-left: 6px solid #4a2b19 !important;
  box-shadow: var(--shadow-sm) !important;
}

.volume-banner-text h2 {
  color: #3e2213 !important;
  font-weight: 800 !important;
}

.volume-banner-text p {
  color: #5c4033 !important;
}

.volume-banner .badge-tag {
  background: #4a2b19 !important;
  color: #fff8f0 !important;
}

/* ==========================================================================
   OCR PREVIEW & SCANNER LASER STYLES
   ========================================================================== */
.ocr-preview-panel {
  background: var(--bg-card);
  border: 2px dashed #d97706;
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin-top: 1rem;
  animation: modalScale 0.25s ease;
}

.ocr-preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-color);
}

.ocr-preview-body {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 1.25rem;
  align-items: flex-start;
}
@media (max-width: 768px) {
  .ocr-preview-body {
    grid-template-columns: 1fr;
  }
}

.ocr-img-wrap {
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border-color);
  max-height: 260px;
  background: #111;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ocr-img-wrap img {
  max-width: 100%;
  max-height: 260px;
  object-fit: contain;
}

.scanner-laser-line {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, #ef4444, #f59e0b, #ef4444, transparent);
  box-shadow: 0 0 12px #ef4444;
  animation: laserScan 2s infinite ease-in-out;
}

@keyframes laserScan {
  0% { top: 0%; }
  50% { top: 95%; }
  100% { top: 0%; }
}

.ocr-result-wrap {
  display: flex;
  flex-direction: column;
}

.ocr-text-result {
  min-height: 140px;
  max-height: 200px;
  overflow-y: auto;
  padding: 0.85rem;
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-family: var(--hanzi-font);
  font-size: 1.2rem;
  line-height: 1.8;
  color: var(--text-main);
  outline: none;
}
.ocr-text-result:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
}


/* Enhanced Exam Sidebar & Smooth Scrolling */
.exam-sidebar {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 120px) !important;
  position: sticky;
  top: 80px;
  box-shadow: var(--shadow-sm);
  z-index: 10;
}

.exam-list-scroll {
  overflow-y: auto !important;
  max-height: calc(100vh - 200px) !important;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 6px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

.exam-list-scroll::-webkit-scrollbar {
  width: 6px;
}
.exam-list-scroll::-webkit-scrollbar-track {
  background: var(--bg-elevated);
  border-radius: 4px;
}
.exam-list-scroll::-webkit-scrollbar-thumb {
  background: var(--primary);
  border-radius: 4px;
}

.exam-item-btn, .exam-item-card {
  background: var(--bg-main) !important;
  border: 1px solid var(--border-color) !important;
  border-radius: var(--radius-md) !important;
  padding: 0.75rem 0.95rem !important;
  text-align: left !important;
  cursor: pointer !important;
  transition: all 0.2s ease !important;
  display: flex !important;
  justify-content: space-between !important;
  align-items: center !important;
  gap: 8px !important;
  user-select: none;
}

.exam-item-btn:hover, .exam-item-card:hover {
  background: var(--bg-card-hover) !important;
  border-color: var(--primary) !important;
  transform: translateY(-1px);
}

.exam-item-btn.active, .exam-item-card.active {
  background: var(--primary-light) !important;
  border-color: var(--primary) !important;
  border-left: 4px solid var(--primary) !important;
  box-shadow: 0 2px 8px rgba(180, 83, 9, 0.15) !important;
}

/* Exam Card Detailed Typography & Scrollbar Polish */
.exam-item-header {
  display: flex !important;
  justify-content: space-between !important;
  align-items: center !important;
  margin-bottom: 4px !important;
}

.exam-num {
  font-weight: 700 !important;
  color: var(--primary) !important;
  font-size: 0.88rem !important;
}

.exam-title-text {
  font-size: 0.88rem !important;
  font-weight: 600 !important;
  color: var(--text-main) !important;
  line-height: 1.35 !important;
  margin-bottom: 3px !important;
}

.exam-meta-text {
  font-size: 0.78rem !important;
  color: var(--text-dim) !important;
}

.exam-list-scroll {
  scrollbar-width: thin !important;
  scrollbar-color: var(--primary) var(--bg-elevated) !important;
}

.exam-list-scroll::-webkit-scrollbar {
  width: 8px !important;
}

.exam-list-scroll::-webkit-scrollbar-track {
  background: var(--bg-elevated) !important;
  border-radius: 4px !important;
}

.exam-list-scroll::-webkit-scrollbar-thumb {
  background: var(--primary) !important;
  border-radius: 4px !important;
}



/* ==========================================================================
   TTTH 4 & 8 INTERACTIVE QUESTION COMPONENTS (PINYIN, REORDER, ERROR FIX, TRANSLATION)
   ========================================================================== */
.pinyin-input-box {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.q-hanzi-prompt {
  font-family: var(--hanzi-font);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-main);
  min-width: 120px;
}

.pinyin-input-field {
  flex: 1;
  min-width: 220px;
  padding: 0.65rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 1rem;
  outline: none;
}
.pinyin-input-field:focus {
  border-color: var(--primary);
}

/* Sentence Reorder Interactive Area */
.reorder-pool-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0.75rem 0;
  min-height: 48px;
  padding: 8px;
  background: var(--bg-card);
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-md);
}

.reorder-result-box {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 52px;
  padding: 10px;
  background: rgba(79, 70, 229, 0.08);
  border: 2px solid rgba(79, 70, 229, 0.3);
  border-radius: var(--radius-md);
  margin-bottom: 0.75rem;
  align-items: center;
}

.word-chip {
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  font-family: var(--hanzi-font);
  font-size: 1.15rem;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  cursor: pointer;
  user-select: none;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
}

.word-chip:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  transform: translateY(-2px);
}

.word-chip.selected {
  background: linear-gradient(135deg, #4f46e5, #0ea5e9);
  color: #fff;
  box-shadow: 0 2px 8px var(--primary-glow);
}

.reorder-actions-bar {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.btn-small-tool {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 4px 10px;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}
.btn-small-tool:hover {
  background: var(--bg-elevated);
  color: var(--text-main);
}

.btn-check-q {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  border: none;
  padding: 5px 14px;
  font-size: 0.82rem;
  font-weight: 600;
  border-radius: var(--radius-full);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 2px 6px rgba(16, 185, 129, 0.25);
  transition: var(--transition);
  user-select: none;
}
.btn-check-q:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
  background: linear-gradient(135deg, #059669, #047857);
}

.single-q-feedback {
  margin: 0.65rem 0 0.35rem 0;
  padding: 0.65rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  line-height: 1.5;
  display: none;
  animation: expSlide 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.single-q-feedback.correct {
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.35);
  color: #10b981;
}
.single-q-feedback.incorrect {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #f87171;
}

/* Question Action Bar & Instant Explanation Reveal */
.q-actions-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-top: 0.65rem;
  flex-wrap: wrap;
}

.btn-toggle-explanation {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 5px 14px;
  font-size: 0.82rem;
  font-weight: 600;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  user-select: none;
}
.btn-toggle-explanation:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
  transform: translateY(-1px);
}
.btn-toggle-explanation.active {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

.explanation-box {
  margin-top: 0.85rem;
  padding: 1rem 1.15rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--primary);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  font-size: 0.9rem;
  line-height: 1.6;
  display: none;
  animation: expSlide 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: var(--shadow-sm);
}
@keyframes expSlide {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
.explanation-box.show {
  display: block;
}

.exp-row-item {
  margin-bottom: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.exp-row-item:last-child {
  margin-bottom: 0;
}

.exp-tag {
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.exp-tag.success { color: var(--success); }
.exp-tag.danger { color: var(--danger); }
.exp-tag.info { color: var(--accent); }
.exp-tag.grammar { color: var(--primary); }
.exp-tag.alt { color: var(--warning); }

.exp-val.hanzi-hl {
  font-family: var(--hanzi-font);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.6;
}
.exp-val.pinyin-hl {
  font-weight: 700;
  color: var(--primary);
  font-size: 1rem;
}

.explanation-box.wrong-alert {
  background: rgba(221, 101, 82, 0.08);
  border-left-color: var(--danger);
}

/* Exam Header Tools */
.exam-tools-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.btn-tool-secondary {
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-tool-secondary:hover, .btn-tool-secondary.active {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
}

/* Pinyin Tone Helper Toolbar */
.pinyin-toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 0.5rem;
  padding: 6px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}
.pinyin-toolbar span {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-right: 4px;
}
.pinyin-char-btn {
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  font-size: 0.85rem;
  padding: 2px 6px;
  border-radius: 4px;
  cursor: pointer;
  transition: var(--transition);
}
.pinyin-char-btn:hover {
  background: var(--primary);
  color: #fff;
}

/* Score Summary Modal */
.score-summary-modal {
  text-align: center;
  padding: 2rem;
}

.score-badge-circle {
  width: 110px;
  height: 110px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, #4f46e5, #10b981);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.5rem;
  box-shadow: 0 10px 25px var(--primary-glow);
}

.score-number {
  font-size: 2.4rem;
  font-weight: 800;
  line-height: 1;
}
.score-scale {
  font-size: 0.85rem;
  opacity: 0.85;
}

.score-verdict {
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.score-breakdown-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  margin: 1.5rem 0;
  text-align: left;
}

.score-part-card {
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  padding: 0.85rem;
  border-radius: var(--radius-md);
}

.score-part-card .part-name {
  font-size: 0.75rem;
  color: var(--text-dim);
}
.score-part-card .part-pts {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--accent);
}

/* ==========================================================================
   TAB 3: CHUYÊN ĐỀ VIẾT VĂN & BÀI MẪU (WRITING WORKSHOP)
   ========================================================================== */