/* Grammar Page Styles */
:root {
    --primary-color: #667eea;
    --secondary-color: #764ba2;
    --accent-color: #f093fb;
    --success-color: #10b981;
    --error-color: #ef4444;
    --warning-color: #f59e0b;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --bg-light: #f8fafc;
    --border-color: #e5e7eb;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
}

.grammar-container { max-width: 1200px; margin: 3rem auto; padding: 2rem; padding-top: 1rem; min-height: 100vh; background: #f9fafb; }
.hidden { display: none !important; }

.grammar-header { text-align: center; margin: 1rem 0 2rem 0; padding: 1.5rem; background: #fff; border: 1px solid var(--border-color); border-radius: var(--radius-xl); color: var(--text-primary); box-shadow: var(--shadow-sm); }

@media (max-width: 768px) {
  .grammar-container { padding: 1rem; padding-top: 0.5rem; }
  .grammar-header { margin-top: 70px; padding: 1rem; margin-bottom: 1.5rem; }
  .grammar-title { font-size: 1.5rem; }
  .grammar-subtitle { font-size: 0.9rem; }
}

/* Enhanced grammar header */
.grammar-header {
  background: linear-gradient(135deg, #1e293b 0%, #334155 60%, #475569 100%);
  border-radius: var(--radius-xl);
  padding: 2rem 2.5rem;
  margin: 4rem auto;
  position: relative;
  overflow: hidden;
  box-shadow: 0 10px 40px rgba(30, 41, 59, 0.3);
}

.grammar-header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: 
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='60' height='60' viewBox='0 0 60 60'%3E%3Cpath d='M15 5c-2 3-1 8 2 10s7 1 9-2c-3 1-6 0-8-2s-2-5-3-6z' fill='%23fff' fill-opacity='0.03'/%3E%3Cpath d='M45 35c-2 3-1 8 2 10s7 1 9-2c-3 1-6 0-8-2s-2-5-3-6z' fill='%23fff' fill-opacity='0.02'/%3E%3C/svg%3E"),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='50' viewBox='0 0 100 50'%3E%3Cpath d='M20 35c0-8 6-14 14-14 1 0 2 0 3 .3C39 15 44 10 51 10c9 0 16 7 16 16 0 1-.1 2-.2 3 5 1 9 6 9 11' stroke='%23fff' stroke-width='1' fill='none' stroke-opacity='0.04'/%3E%3C/svg%3E");
  pointer-events: none;
}

.grammar-header-content {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  position: relative;
  z-index: 1;
}

.grammar-header-logo {
  height: 80px;
  width: auto;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.3));
  flex-shrink: 0;
}

.grammar-header-text {
  flex: 1;
}

.grammar-header-decoration {
  position: absolute;
  top: 50%;
  right: 2rem;
  transform: translateY(-50%);
  width: 120px;
  height: 120px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Ccircle cx='50' cy='50' r='45' stroke='%23fff' stroke-width='1' fill='none' stroke-opacity='0.08'/%3E%3Ccircle cx='50' cy='50' r='35' stroke='%23fff' stroke-width='1' fill='none' stroke-opacity='0.05'/%3E%3Cpath d='M50 15v70M15 50h70' stroke='%23fff' stroke-width='1' stroke-opacity='0.06'/%3E%3C/svg%3E") no-repeat center;
  opacity: 0.6;
  pointer-events: none;
}

.grammar-title { 
  font-size: 2rem; 
  font-weight: 800; 
  margin-bottom: .5rem; 
  color: #fff;
  text-shadow: 0 2px 10px rgba(0,0,0,0.3);
  letter-spacing: 0.5px;
}

.grammar-subtitle { 
  font-size: 1.05rem; 
  opacity: 1; 
  font-weight: 400; 
  color: rgba(255,255,255,0.85);
  text-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

@media (max-width: 768px) {
  .grammar-header {
    padding: 1.5rem;
  }
  
  .grammar-header-content {
    flex-direction: column;
    text-align: center;
    gap: 1rem;
  }
  
  .grammar-header-logo {
    height: 60px;
  }
  
  .grammar-header-decoration {
    display: none;
  }
  
  .grammar-title {
    font-size: 1.5rem;
  }
}

.grammar-content { display: block; margin-bottom: 1.5rem; }

.grammar-sidebar { 
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  border: 1px solid var(--border-color); 
  border-radius: var(--radius-lg); 
  padding: 1.25rem; 
  box-shadow: var(--shadow-sm); 
  height: fit-content; 
  position: sticky; 
  top: 2rem;
  transition: all 0.3s ease;
}

.grammar-sidebar:hover {
  box-shadow: 0 8px 30px rgba(0,0,0,0.08);
}

.grammar-sidebar .grammar-nav {
  padding: 1rem;
  background: #fff;
  border-radius: var(--radius-md);
  border: 1px solid rgba(0,0,0,0.04);
  margin-bottom: 1rem;
}

.grammar-sidebar .grammar-nav:last-child {
  margin-bottom: 0;
}

.grammar-sidebar .grammar-nav h3 {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--primary-color);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--primary-color);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.grammar-sidebar .grammar-nav h3::before {
  content: '';
  width: 6px;
  height: 6px;
  background: var(--primary-color);
  border-radius: 50%;
}

.grammar-main { background: #fff; border: 1px solid var(--border-color); border-radius: var(--radius-lg); padding: 1.25rem; box-shadow: var(--shadow-sm); }

/* Inputs and filters */
.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    outline: none;
    font-size: 14px;
}
.form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}
.filter-bar { display: flex; flex-wrap: wrap; gap: 8px; }
.filter-btn {
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: 999px;
    background: #fff;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 13px;
}
.filter-btn.active { background: #eef2ff; border-color: #c7d2fe; color: #3730a3; }

.grammar-nav {
    margin-bottom: 2rem;
}

.grammar-nav h3 {
    color: var(--text-primary);
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--primary-color);
}

.grammar-nav-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.grammar-nav-item {
    margin-bottom: 0.5rem;
}

.grammar-nav-link {
    display: block;
    padding: 0.75rem 1rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-md);
    transition: all 0.3s ease;
    font-weight: 500;
}

.grammar-nav-link:hover,
.grammar-nav-link.active {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    transform: translateX(5px);
    box-shadow: var(--shadow-sm);
}

.grammar-section {
    margin-bottom: 3rem;
    padding: 2rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    background: linear-gradient(145deg, #ffffff 0%, #f8fafc 100%);
}

.grammar-section h2 {
    color: var(--primary-color);
    font-size: 2rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.grammar-section h2::before {
    content: '';
    width: 4px;
    height: 2rem;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    border-radius: 2px;
}

.grammar-section h3 {
    color: var(--text-primary);
    font-size: 1.5rem;
    font-weight: 600;
    margin: 2rem 0 1rem 0;
}

.grammar-section p {
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: 1rem;
    font-size: 1rem;
}

/* Cards and list */
.grammar-list-flex { display: flex; flex-direction: column; gap: 24px; }

/* Category grouping */
.grammar-category-header {
  width: 100%;
  margin-bottom: 8px;
}
.grammar-category-header .category-title {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
  border-radius: 12px;
  font-size: 1.1rem;
  font-weight: 600;
  color: #fff;
  margin: 0;
  box-shadow: 0 2px 8px rgba(30, 41, 59, 0.15);
}
.grammar-category-header .category-icon {
  font-size: 1.3rem;
}
.grammar-category-header .category-count {
  margin-left: auto;
  font-size: 0.85rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.7);
  background: rgba(255, 255, 255, 0.1);
  padding: 4px 10px;
  border-radius: 20px;
}
.grammar-category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  width: 100%;
}
@media (max-width: 640px) {
  .grammar-category-grid {
    grid-template-columns: 1fr;
  }
  .grammar-category-header .category-title {
    font-size: 1rem;
    padding: 12px 14px;
  }
}

/* Level group headers */
.level-group { width: 100%; margin-bottom: 0.5rem; }
.level-group-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  border-radius: 12px;
  margin-bottom: 16px;
  border: 1px solid #e2e8f0;
}
.level-group-header .level-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  font-weight: 800;
  font-size: 14px;
  color: #fff;
}
.level-group-header .level-icon.hsk1 { background: linear-gradient(135deg, #22c55e, #16a34a); }
.level-group-header .level-icon.hsk2 { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.level-group-header .level-icon.hsk3 { background: linear-gradient(135deg, #8b5cf6, #7c3aed); }
.level-group-header .level-icon.hsk4 { background: linear-gradient(135deg, #f59e0b, #d97706); }
.level-group-header .level-icon.hsk5 { background: linear-gradient(135deg, #ef4444, #dc2626); }
.level-group-header .level-icon.hsk6 { background: linear-gradient(135deg, #ec4899, #db2777); }
.level-group-header .level-title { font-size: 1.1rem; font-weight: 700; color: var(--text-primary); }
.level-group-header .level-count { font-size: 0.85rem; color: var(--text-secondary); margin-left: auto; }

.grammar-card { 
  flex: 1 1 calc(100% - 16px); 
  max-width: 100%; 
  border: 1px solid var(--border-color); 
  border-radius: 16px; 
  padding: 16px 18px; 
  background: #fff; 
  box-shadow: 0 2px 8px rgba(0,0,0,0.04); 
  cursor: pointer; 
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}
.grammar-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--primary-color);
  opacity: 0;
  transition: opacity 0.25s ease;
}
.grammar-card:hover { 
  transform: translateY(-4px) scale(1.01); 
  box-shadow: 0 12px 32px rgba(0,0,0,0.1); 
  border-color: var(--primary-color);
}
.grammar-card:hover::before {
  opacity: 1;
}
.grammar-card:active {
  transform: translateY(-2px) scale(1.005);
}
.grammar-card, .grammar-card:link, .grammar-card:visited { text-decoration: none; color: inherit; }
.grammar-card .card-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.gp-title { font-size: 17px; font-weight: 700; color: var(--text-primary); margin: 0; letter-spacing: 0.1px; line-height: 1.4; }
.grammar-card .arrow { 
  color: #9ca3af; 
  font-size: 20px; 
  line-height: 1; 
  transition: transform 0.25s ease, color 0.25s ease;
}
.grammar-card:hover .arrow {
  transform: translateX(4px);
  color: var(--primary-color);
}
.gp-meta { margin-top: 10px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.chip.small { 
  font-size: 11px; 
  padding: 4px 10px; 
  background: linear-gradient(135deg, #f0f4ff 0%, #e0e7ff 100%);
  border: 1px solid #c7d2fe; 
  border-radius: 999px; 
  color: #4338ca; 
  font-weight: 600;
  transition: all 0.2s ease;
}
.grammar-card:hover .chip.small {
  background: linear-gradient(135deg, #e0e7ff 0%, #c7d2fe 100%);
}
.badge-new { 
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px; 
  padding: 4px 10px; 
  border-radius: 999px; 
  background: linear-gradient(135deg, #dcfce7 0%, #bbf7d0 100%);
  color: #166534; 
  font-weight: 700;
  animation: badge-pulse 2s ease-in-out infinite;
}
.badge-new::before {
  content: '✨';
  font-size: 10px;
}
@keyframes badge-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}
.badge-premium {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 999px;
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  color: #92400e;
  font-weight: 700;
  border: 1px solid #fcd34d;
}

@media (min-width: 560px) { .grammar-card { flex-basis: calc(50% - 16px); } }
@media (min-width: 920px) { .grammar-card { flex-basis: calc(33.333% - 16px); } }
@media (min-width: 1280px) { .grammar-card { flex-basis: calc(25% - 16px); } }
.pattern-text .pt-op { display: inline-block; padding: 0 .35ch; font-weight: 800; color: #4f46e5; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.pattern-text .pt-paren { color: #6b7280; font-weight: 700; }
.pattern-text .pt-focus { display: inline-block; padding: 2px 8px; border-radius: 8px; background: linear-gradient(135deg, #fde68a, #fef3c7); color: #92400e; font-weight: 900; border: 1px solid #fcd34d; }
.pattern-text .pt-term { display: inline-block; padding: 1px 6px; border-radius: 6px; background: #eef2ff; color: #3730a3; border: 1px solid #c7d2fe; font-weight: 800; }
.pattern-text .pt-particle { display: inline-block; padding: 0 6px; border-radius: 6px; background: #f3f4f6; color: #374151; border: 1px solid #e5e7eb; font-weight: 700; }
.pattern-text .pt-text { font-weight: 700; color: var(--text-primary); }


/* Detail */
.grammar-detail { max-width: 760px; margin: 0 auto; }
.gp-level { color: var(--text-secondary); margin-bottom: 8px; }
.gp-examples blockquote { background: var(--bg-light); border-left: 4px solid var(--primary-color); margin: 10px 0; padding: 10px 12px; border-radius: 8px; }
.gp-structure pre { background: #111827; color: #e5e7eb; padding: 12px; border-radius: 8px; overflow: auto; }
.gp-images img { max-width: 100%; height: auto; border-radius: 8px; border: 1px solid var(--border-color); margin-right: 8px; margin-top: 8px; }
.loader { text-align: center; color: var(--text-secondary); margin-top: 12px; }

/* Locked banner for partial content */
.locked-banner {
    background: #fff7ed;
    border: 1px solid #fdba74;
    color: #9a3412;
    padding: 10px 12px;
    border-radius: 10px;
    margin: 10px 0 14px 0;
    font-weight: 600;
}

/* Key modal removed in new flow */
/* .modal { display: none; } */

.grammar-example {
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    margin: 1.5rem 0;
    position: relative;
    overflow: hidden;
}

.grammar-example::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, var(--primary-color), var(--accent-color));
}

.grammar-example-title {
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.grammar-sentence {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.chinese-text {
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--text-primary);
    font-family: 'ZCOOL XiaoWei', serif;
}

.pinyin-text {
    font-size: 1rem;
    color: var(--text-secondary);
    font-style: italic;
}

.english-text {
    font-size: 1rem;
    color: var(--success-color);
    font-weight: 500;
}

.grammar-pattern {
    background: linear-gradient(135deg, #ddd6fe 0%, #e0e7ff 100%);
    border: 2px solid var(--primary-color);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    margin: 1.5rem 0;
    text-align: center;
}

.pattern-formula {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-color);
    font-family: 'Inter', monospace;
    margin-bottom: 0.5rem;
}

.pattern-description {
    color: var(--text-secondary);
    font-style: italic;
}

.grammar-table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
    background: white;
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.grammar-table th,
.grammar-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.grammar-table th {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    font-weight: 600;
}

.grammar-table tr:hover {
    background: var(--bg-light);
}

.grammar-quiz {
    background: linear-gradient(135deg, #fff7ed 0%, #ffedd5 100%);
    border: 2px solid var(--warning-color);
    border-radius: var(--radius-lg);
    padding: 2rem;
    margin: 2rem 0;
}

.quiz-title {
    color: var(--warning-color);
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.quiz-title::before {
    content: '🧩';
    font-size: 1.25rem;
}

.quiz-question {
    background: white;
    padding: 1.5rem;
    border-radius: var(--radius-md);
    margin: 1rem 0;
    border: 1px solid var(--border-color);
}

.quiz-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-top: 1rem;
}

.quiz-option {
    padding: 1rem;
    background: var(--bg-light);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    font-weight: 500;
}

.quiz-option:hover {
    border-color: var(--primary-color);
    background: white;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.quiz-option.correct {
    border-color: var(--success-color);
    background: #dcfce7;
    color: var(--success-color);
}

.quiz-option.incorrect {
    border-color: var(--error-color);
    background: #fef2f2;
    color: var(--error-color);
}

.grammar-note {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border-left: 4px solid var(--primary-color);
    padding: 1.5rem;
    margin: 1.5rem 0;
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.note-title {
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.note-title::before {
    content: '💡';
}

.grammar-warning {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border-left: 4px solid var(--warning-color);
    padding: 1.5rem;
    margin: 1.5rem 0;
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.warning-title {
    font-weight: 600;
    color: var(--warning-color);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.warning-title::before {
    content: '⚠️';
}

.progress-bar {
    background: var(--border-color);
    height: 8px;
    border-radius: 4px;
    overflow: hidden;
    margin: 2rem 0;
}

.progress-fill {
    background: linear-gradient(90deg, var(--primary-color), var(--accent-color));
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
}

.grammar-navigation {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 3rem;
    padding: 2rem;
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

.nav-btn {
    padding: 1rem 2rem;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    border: none;
    border-radius: var(--radius-lg);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.nav-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.nav-btn.secondary {
    background: white;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
}

.nav-btn.secondary:hover {
    background: var(--primary-color);
    color: white;
}

/* Ensure toolbar buttons become visible when toggled by JS */
#btnBack.show,
#btnPrint.show {
    display: inline-flex !important;
}

/* Hide top toolbar; we use inline actions within detail header instead */
.tool-bar { display: none !important; }

/* Responsive Design */
@media (max-width: 1024px) {
    /* grid removed; content stacks by default */
    
    .grammar-sidebar {
        position: static;
        order: 2;
    }
    
    .grammar-main {
        order: 1;
    }
}

@media (max-width: 768px) {
    .grammar-container {
        padding: 1rem;
    }
    
    .grammar-title {
        font-size: 2rem;
    }
    
    .grammar-subtitle {
        font-size: 1rem;
    }
    
    .grammar-header,
    .grammar-main,
    .grammar-sidebar {
        padding: 1rem;
    }
    
    .quiz-options {
        grid-template-columns: 1fr;
    }
    
    .grammar-navigation {
        flex-direction: column;
        gap: 1rem;
    }
    
    .grammar-table {
        font-size: 0.875rem;
    }
    
    .grammar-table th,
    .grammar-table td {
        padding: 0.75rem 0.5rem;
    }
}

@media (max-width: 480px) {
    .grammar-title {
        font-size: 1.75rem;
    }
    
    .chinese-text {
        font-size: 1.2rem;
    }
    
    .pattern-formula {
        font-size: 1rem;
    }
    
    .nav-btn {
        padding: 0.75rem 1.5rem;
        font-size: 0.875rem;
    }
}

/* Animation Classes */
.fade-in {
    animation: fadeIn 0.6s ease-out;
}

.slide-up {
    animation: slideUp 0.6s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

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

/* Patterns section */
.patterns-wrap { margin-top: 1.5rem; padding-top: 1rem; border-top: 2px dashed var(--border-color); }
.patterns-title { font-size: 1.25rem; font-weight: 700; color: var(--text-primary); margin-bottom: .5rem; }

/* Patterns Toolbar with Auto-collapse toggle */
.patterns-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 1rem;
  padding: 0 0.25rem;
}

.auto-collapse-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  user-select: none;
}

.auto-collapse-toggle input {
  display: none;
}

.toggle-slider {
  width: 36px;
  height: 20px;
  background: #d1d5db;
  border-radius: 999px;
  position: relative;
  transition: background 0.2s ease;
}

.toggle-slider::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.auto-collapse-toggle input:checked + .toggle-slider {
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
}

.auto-collapse-toggle input:checked + .toggle-slider::after {
  transform: translateX(16px);
}

.toggle-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.patterns-list { display: flex; flex-direction: column; gap: 1rem; }

.pattern-section { position: relative; border: 1px solid #c7d2fe; border-radius: 14px; background: #fff; overflow: hidden; box-shadow: var(--shadow-sm); transition: box-shadow .2s ease, border-color .2s ease, transform .2s ease; }
.pattern-section::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: linear-gradient(180deg, #6366f1, #22d3ee); opacity: 1; border-radius: 14px 0 0 14px; transition: width .2s ease; }
.pattern-section.active { box-shadow: 0 8px 30px rgba(99, 102, 241, 0.25); border-color: #6366f1; transform: scale(1.01); }
.pattern-section.active::before { width: 6px; }
.pattern-header { width: 100%; background: linear-gradient(135deg, #eef2ff 0%, #e0e7ff 100%); border: 0; padding: 1.05rem 1.2rem; display: flex; align-items: center; justify-content: space-between; cursor: pointer; transition: background .2s ease, transform .15s ease, box-shadow .2s ease; border-bottom: 1px solid #c7d2fe; color: #1e1b4b; }
.pattern-header:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(99,102,241,.18); background: linear-gradient(135deg, #e0e7ff 0%, #c7d2fe 100%); }
.pattern-header:focus-visible { outline: 3px solid rgba(102,126,234,.35); outline-offset: 2px; }
.pattern-section.active .pattern-header { 
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%); 
  border-bottom-color: #4f46e5;
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}
.pattern-section.active .pattern-header .pattern-index { 
  background: #fff; 
  color: #4f46e5; 
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.pattern-section.active .pattern-header .pattern-text { color: #fff; }
.pattern-section.active .pattern-header .pt-text { color: #fff; }
.pattern-section.active .pattern-header .pt-term { color: #fde047; text-shadow: 0 1px 2px rgba(0,0,0,0.3); }
.pattern-section.active .pattern-header .pt-particle { color: #e9d5ff; text-shadow: 0 1px 2px rgba(0,0,0,0.2); }
.pattern-section.active .pattern-header .pt-op { color: #fecaca; text-shadow: 0 1px 2px rgba(0,0,0,0.2); }
.pattern-section.active .pattern-header .pt-focus { color: #bbf7d0; text-shadow: 0 1px 2px rgba(0,0,0,0.2); }
.pattern-section.active .pattern-header .chevron { border-color: #fff; }
.pattern-title { display: flex; align-items: flex-start; gap: .85rem; text-align: left; }
.pattern-title-main { display: flex; flex-direction: column; gap: 4px; }
.pattern-index { width: 38px; height: 38px; border-radius: 12px; background: linear-gradient(135deg, #6366f1, #4f46e5); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 900; font-size: 0.98rem; box-shadow: 0 4px 12px rgba(99,102,241,.35); }

/* Pattern Badge - Base style */
.pattern-badge { font-size: 12px; padding: 4px 10px; border-radius: 999px; font-weight: 700; letter-spacing: .25px; text-transform: none; display: inline-flex; width: fit-content; transition: all 0.2s ease; }

/* Badge color variants */
.pattern-badge.badge-overview { background: linear-gradient(135deg, #dbeafe, #bfdbfe); color: #1e40af; border: 1px solid #93c5fd; }
.pattern-badge.badge-usage { background: linear-gradient(135deg, #d1fae5, #a7f3d0); color: #065f46; border: 1px solid #6ee7b7; }
.pattern-badge.badge-structure { background: linear-gradient(135deg, #ede9fe, #ddd6fe); color: #5b21b6; border: 1px solid #c4b5fd; }
.pattern-badge.badge-summary { background: linear-gradient(135deg, #ffedd5, #fed7aa); color: #9a3412; border: 1px solid #fdba74; }
.pattern-badge.badge-comparison { background: linear-gradient(135deg, #ccfbf1, #99f6e4); color: #115e59; border: 1px solid #5eead4; }
.pattern-badge.badge-criteria { background: linear-gradient(135deg, #fee2e2, #fecaca); color: #991b1b; border: 1px solid #fca5a5; }
.pattern-badge.badge-theory { background: linear-gradient(135deg, #e0e7ff, #c7d2fe); color: #3730a3; border: 1px solid #a5b4fc; }
.pattern-badge.badge-classification { background: linear-gradient(135deg, #fce7f3, #fbcfe8); color: #9d174d; border: 1px solid #f9a8d4; }
.pattern-badge.badge-syntax { background: linear-gradient(135deg, #cffafe, #a5f3fc); color: #0e7490; border: 1px solid #67e8f9; }
.pattern-badge.badge-history { background: linear-gradient(135deg, #fef3c7, #fde68a); color: #92400e; border: 1px solid #fcd34d; }
.pattern-badge.badge-language { background: linear-gradient(135deg, #d1fae5, #6ee7b7); color: #047857; border: 1px solid #34d399; }
.pattern-badge.badge-connection { background: linear-gradient(135deg, #f3e8ff, #e9d5ff); color: #7c3aed; border: 1px solid #c4b5fd; }
.pattern-badge.badge-default { background: linear-gradient(135deg, #f3f4f6, #e5e7eb); color: #374151; border: 1px solid #d1d5db; }

/* Active state badge - make it lighter on dark header */
.pattern-section.active .pattern-header .pattern-badge { 
  background: rgba(255,255,255,0.25);
  border-color: rgba(255,255,255,0.4);
  color: #fff;
}

.pattern-text { font-weight: 800; color: #1e1b4b; letter-spacing: .25px; font-size: 1.08rem; line-height: 1.55; word-break: break-word; }
.chevron { width: 12px; height: 12px; border-right: 2px solid #6366f1; border-bottom: 2px solid #6366f1; transform: rotate(-45deg); transition: transform .2s ease, border-color .2s ease; margin-left: 1rem; }
.pattern-header[aria-expanded="true"] .chevron { transform: rotate(45deg); border-color: #4f46e5; }

.pattern-body { max-height: 0; opacity: 0; overflow: hidden; transition: max-height .4s ease-out, opacity .3s ease, padding .28s ease, background .28s ease; padding: 0 1rem; background: #fff; }
.pattern-body.open { max-height: none; opacity: 1; padding: .95rem 1.05rem 1.1rem 1.05rem; background: linear-gradient(180deg, #fafbff 0%, #f8fafc 100%); border-top: 1px dashed #c7d2fe; overflow: visible; }
.pattern-body.open .pattern-meaning, .pattern-body.open .pattern-usage, .pattern-body.open .pattern-notes { color: #1e1b4b; font-weight: 400; }
.pattern-body.open h4 { color: #1e1b4b; font-weight: 600; }
.pattern-body.open .examples-list .example-item { background: #f8fafc; border-color: #e5e7eb; }
.pattern-body.open .examples-list .ex-zh { color: #1e1b4b; font-weight: 600; }
.pattern-body.open .examples-list .ex-vi { color: #4b5563; }
.examples-list .example-item { background: var(--bg-light); border: 1px solid var(--border-color); border-radius: var(--radius-sm); padding: .6rem .8rem; transition: all .2s ease; }
.pattern-notes p { color: #4b5563; }
.pattern-meaning { color: var(--text-primary); font-weight: 600; margin: .25rem 0 .5rem 0; }
.pattern-usage { color: var(--text-secondary); margin-bottom: .5rem; line-height: 1.7; }

/* Usage Explanation Sub-sections */
.pattern-usage .usage-section-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--primary-color);
  margin: 1rem 0 0.5rem 0;
  padding-bottom: 0.25rem;
  border-bottom: 2px solid var(--primary-color);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.pattern-usage .usage-section-title:first-child {
  margin-top: 0;
}

.pattern-usage .usage-subsection {
  display: flex;
  gap: 0.5rem;
  margin: 0.75rem 0;
  padding: 0.6rem 0.75rem;
  background: linear-gradient(135deg, #f8fafc, #f1f5f9);
  border-left: 3px solid var(--primary-color);
  border-radius: 0 8px 8px 0;
}

.pattern-usage .subsection-num {
  font-weight: 700;
  color: var(--primary-color);
  min-width: 2rem;
  flex-shrink: 0;
}

.pattern-usage .subsection-text {
  color: var(--text-primary);
  flex: 1;
}

.pattern-usage .usage-example {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin: 0.5rem 0 0.5rem 1rem;
  padding: 0.5rem 0.75rem;
  background: #fffbeb;
  border: 1px solid #fcd34d;
  border-radius: 8px;
}

.pattern-usage .usage-example-label {
  font-weight: 600;
  color: #92400e;
  margin: 0.5rem 0 0.25rem 1rem;
}

.pattern-usage .example-label {
  font-weight: 600;
  color: #92400e;
  flex-shrink: 0;
}

.pattern-usage .example-content {
  color: #78350f;
}

.pattern-usage .usage-example-inline {
  margin: 0.4rem 0 0.4rem 1.5rem;
  padding: 0.4rem 0.6rem;
  background: #f0fdf4;
  border: 1px solid #86efac;
  border-radius: 6px;
  font-size: 0.95rem;
}

.pattern-usage .usage-bullet {
  display: flex;
  gap: 0.5rem;
  margin: 0.4rem 0 0.4rem 0.5rem;
  padding: 0.3rem 0;
}

.pattern-usage .bullet-dot {
  color: var(--primary-color);
  font-weight: bold;
  flex-shrink: 0;
}

.pattern-usage .bullet-text {
  color: var(--text-primary);
}

.pattern-usage .usage-text {
  margin: 0.4rem 0;
  color: var(--text-secondary);
}

/* Example text formatting */
.pattern-usage .ex-chinese,
.pattern-usage .han-char {
  font-weight: 600;
  color: #1e40af;
}

.pattern-usage .ex-arrow {
  color: #9ca3af;
  margin: 0 0.25rem;
}

.pattern-usage .ex-vietnamese {
  color: #059669;
  font-style: italic;
}

/* Pinyin styling - beautiful gradient text */
.pattern-usage .pinyin,
.slide-line .pinyin {
  font-style: italic;
  font-weight: 500;
  color: #7c3aed;
  background: linear-gradient(135deg, #7c3aed 0%, #a78bfa 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-family: 'Segoe UI', system-ui, sans-serif;
}

.pattern-usage .pinyin-label,
.slide-line .pinyin-label {
  font-size: 0.85em;
  color: #6b7280;
  font-weight: 500;
}

/* Terminology in 【】brackets */
.pattern-usage .terminology,
.slide-line .terminology {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  color: #92400e;
  padding: 0.15rem 0.4rem;
  border-radius: 6px;
  font-weight: 600;
  border: 1px solid #f59e0b;
  display: inline;
  white-space: nowrap;
}

/* Terminology header - block level for section titles like 【Xu hướng kép】 */
.pattern-usage .terminology-header {
  display: block;
  margin: 1rem 0 0.5rem 0;
  padding-top: 0.75rem;
  border-top: 1px dashed #e5e7eb;
}

.pattern-usage .terminology-header:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.pattern-usage .terminology-header .terminology {
  font-size: 1rem;
  padding: 0.25rem 0.6rem;
}

/* Linguistic abbreviations like N, V, Adj */
.pattern-usage .ling-abbrev,
.slide-line .ling-abbrev {
  display: inline-block;
  background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
  color: #1e40af;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  font-weight: 700;
  font-size: 0.85em;
  font-family: 'Monaco', 'Consolas', monospace;
  border: 1px solid #60a5fa;
  margin: 0 0.1rem;
}

/* Han characters in usage text */
.pattern-usage .han-char {
  font-weight: 600;
  color: #1e40af;
}

.pattern-examples h4 { margin: .5rem 0; color: var(--text-primary); }
.examples-list { list-style: none; padding-left: 0; margin: 0; display: grid; gap: .5rem; }
.examples-list .example-item { background: var(--bg-light); border: 1px solid var(--border-color); border-radius: var(--radius-sm); padding: .5rem .75rem; transition: all .2s ease; }
.pattern-body.open .examples-list .example-item { animation: fadeIn .25s ease both; }
.examples-list .example-item.collapsed { display: none; }
.examples-list .ex-zh { font-weight: 600; color: var(--text-primary); }
.examples-list .ex-vi { color: var(--text-secondary); font-style: italic; }
.btn-more { margin-top: .5rem; background: #fff; border: 1px solid var(--border-color); padding: .4rem .75rem; border-radius: 8px; cursor: pointer; color: var(--text-secondary); }
.btn-more:hover { background: #f8fafc; }

/* Special simplified detail style */
.special-detail { border: 1px solid var(--border-color); border-radius: var(--radius-lg); padding: 1rem; background: #fff; box-shadow: var(--shadow-sm); }

/* ====================================
   UNIFIED HERO HEADER with Toolbar
   ==================================== */
.detail-hero-unified {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.5rem;
  border: none;
  border-radius: 16px;
  background: linear-gradient(135deg, #1e3a5f 0%, #2d5a87 40%, #3d7ab5 70%, #5a9bd4 100%);
  margin-bottom: 1rem;
  box-shadow: 0 8px 30px -10px rgba(30, 58, 95, 0.4), inset 0 1px 0 rgba(255,255,255,0.1);
  flex-wrap: wrap;
  position: relative;
  overflow: hidden;
}

.detail-hero-unified::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 250px;
  height: 100%;
  background: radial-gradient(ellipse at top right, rgba(255,255,255,0.12) 0%, transparent 70%);
  pointer-events: none;
}

.hero-main {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  position: relative;
  z-index: 1;
  flex: 1;
  min-width: 200px;
}

.detail-hero-unified .detail-title {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: 0.3px;
  margin: 0;
  color: #fff;
  text-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

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

.detail-tag {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 999px;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  backdrop-filter: blur(8px);
}

.hero-toolbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  position: relative;
  z-index: 1;
}

.hero-btn {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.9rem;
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 10px;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  backdrop-filter: blur(8px);
}

.hero-btn:hover {
  background: rgba(255,255,255,0.25);
  transform: translateY(-1px);
}

.hero-btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.hero-btn.reset-btn {
  padding: 0.5rem;
  background: rgba(239,68,68,0.2);
  border-color: rgba(248,113,113,0.4);
}

.hero-btn.reset-btn:hover {
  background: rgba(239,68,68,0.35);
}

.hero-btn.hidden {
  display: none;
}

/* Hero View Toggle */
.hero-view-toggle {
  display: flex;
  background: rgba(0,0,0,0.2);
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
}

.hero-view-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 30px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: rgba(255,255,255,0.6);
  cursor: pointer;
  transition: all 0.2s ease;
}

.hero-view-btn:hover {
  color: rgba(255,255,255,0.9);
  background: rgba(255,255,255,0.1);
}

.hero-view-btn.active {
  background: rgba(255,255,255,0.2);
  color: #fff;
  box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

.hero-view-btn svg {
  width: 16px;
  height: 16px;
}

/* Old detail-hero kept for backward compatibility */
.detail-hero { 
  display: flex; 
  align-items: center; 
  justify-content: space-between; 
  gap: 1rem; 
  padding: 1.5rem 2rem; 
  border: none; 
  border-radius: 20px; 
  background: linear-gradient(135deg, #1e3a5f 0%, #2d5a87 40%, #3d7ab5 70%, #5a9bd4 100%); 
  margin-bottom: 1.25rem; 
  box-shadow: 0 10px 40px -10px rgba(30, 58, 95, 0.4), inset 0 1px 0 rgba(255,255,255,0.1); 
  flex-wrap: wrap;
  position: relative;
  overflow: hidden;
}
.detail-hero::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 300px;
  height: 100%;
  background: radial-gradient(ellipse at top right, rgba(255,255,255,0.15) 0%, transparent 70%);
  pointer-events: none;
}
.detail-title { font-size: 1.75rem; font-weight: 800; letter-spacing: 0.3px; margin: 0; color: #fff; text-shadow: 0 2px 10px rgba(0,0,0,0.2); position: relative; z-index: 1; }
.chip { border: 1px solid rgba(255,255,255,0.3); background: rgba(255,255,255,0.15); backdrop-filter: blur(10px); color: #fff; padding: 8px 16px; border-radius: 999px; font-weight: 600; font-size: .85rem; white-space: nowrap; position: relative; z-index: 1; }
.detail-actions { display: inline-flex; gap: 10px; margin-left: auto; position: relative; z-index: 1; }
.detail-actions .nav-btn { white-space: nowrap; background: rgba(255,255,255,0.2); border: 1px solid rgba(255,255,255,0.3); color: #fff; backdrop-filter: blur(10px); }
.detail-actions .nav-btn:hover { background: rgba(255,255,255,0.3); }
.detail-actions .nav-btn.secondary { background: rgba(255,255,255,0.1); }

/* Responsive Unified Hero */
@media (max-width: 640px) {
  .detail-hero-unified {
    flex-direction: column;
    align-items: stretch;
    padding: 1rem;
    gap: 0.75rem;
  }
  
  .hero-main {
    align-items: center;
    text-align: center;
  }
  
  .detail-hero-unified .detail-title {
    font-size: 1.25rem;
    word-break: break-word;
  }
  
  .detail-tags {
    justify-content: center;
  }
  
  .hero-toolbar {
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.4rem;
  }
  
  .hero-btn .btn-text {
    display: none;
  }
  
  .hero-btn {
    padding: 0.5rem;
  }
}

@media (max-width: 640px) {
    .detail-hero { flex-direction: column; align-items: flex-start; padding: 1.25rem; gap: 0.75rem; }
    .detail-actions { width: 100%; justify-content: flex-start; margin-left: 0; flex-wrap: wrap; gap: 8px; }
    .detail-actions .nav-btn { flex: 1; min-width: 0; text-align: center; padding: 0.6rem 0.8rem; font-size: 0.85rem; }
    .detail-title { font-size: 1.35rem; word-break: break-word; }
    .chip { font-size: 0.75rem; padding: 6px 12px; word-break: break-word; white-space: normal; max-width: 100%; }
}

/* ====================================
   COLLAPSIBLE DETAIL SUMMARY
   ==================================== */
.detail-summary { 
  font-size: 1.07rem; 
  line-height: 1.8; 
  color: var(--text-primary); 
  padding: 0.5rem 1rem; 
  font-weight: 550; 
  position: relative;
}
.detail-summary p { margin: 0 0 0.5rem 0; }
.detail-summary p:last-child { margin-bottom: 0; }

.detail-summary.collapsible {
  padding-bottom: 2.5rem;
}

.detail-summary.collapsible .summary-content {
  max-height: 100px;
  overflow: hidden;
  transition: max-height 0.4s ease;
}

.detail-summary.collapsible.expanded .summary-content {
  max-height: 2000px;
}

.detail-summary.collapsible .summary-fade {
  position: absolute;
  bottom: 2.5rem;
  left: 0;
  right: 0;
  height: 50px;
  background: linear-gradient(to bottom, transparent, #fff);
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.detail-summary.collapsible.expanded .summary-fade {
  opacity: 0;
}

.summary-toggle {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 1rem;
  background: linear-gradient(135deg, #f8fafc, #f1f5f9);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  color: var(--primary-color);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}

.summary-toggle:hover {
  background: linear-gradient(135deg, #e2e8f0, #e2e8f0);
  transform: translateX(-50%) translateY(-1px);
  box-shadow: 0 3px 8px rgba(0,0,0,0.12);
}

.summary-toggle svg {
  transition: transform 0.3s ease;
}

.detail-summary.expanded .summary-toggle svg {
  transform: rotate(180deg);
}

.detail-meta { color: var(--text-secondary); font-size: .9rem; padding: .5rem 1rem; }

/* ====================================
   TOOLBAR TOOLTIP GUIDE
   ==================================== */
.toolbar-tooltip {
  position: fixed;
  z-index: 10001;
  background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
  color: #f8fafc;
  padding: 0.6rem 1rem;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  max-width: 280px;
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.toolbar-tooltip.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}

.toolbar-tooltip::before {
  content: '';
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  border-width: 0 6px 6px 6px;
  border-style: solid;
  border-color: transparent transparent #1e293b transparent;
}

.toolbar-tooltip.above::before {
  top: auto;
  bottom: -6px;
  border-width: 6px 6px 0 6px;
  border-color: #334155 transparent transparent transparent;
}

.toolbar-tooltip .tooltip-text {
  flex: 1;
  line-height: 1.4;
}

.toolbar-tooltip .tooltip-dismiss {
  cursor: pointer;
  opacity: 0.7;
  font-size: 0.9rem;
  padding: 2px 4px;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.toolbar-tooltip .tooltip-dismiss:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.15);
}

/* Has-tooltip indicator for first time users */
.has-tooltip {
  position: relative;
}

.has-tooltip::after {
  content: '';
  position: absolute;
  top: -2px;
  right: -2px;
  width: 8px;
  height: 8px;
  background: #f59e0b;
  border-radius: 50%;
  animation: tooltipPulse 2s infinite;
}

@keyframes tooltipPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.2); opacity: 0.7; }
}

/* Hide indicator when user has seen the guide */
body.toolbar-guide-seen .has-tooltip::after {
  display: none;
}

/* Unlock CTA and Modal */
.unlock-cta { display: flex; justify-content: center; margin: .5rem 0 1rem 0; }
.btn-unlock { border: 1px solid #f59e0b; background: linear-gradient(135deg, #fff7ed 0%, #fffbeb 100%); color: #92400e; padding: .5rem .9rem; border-radius: 10px; cursor: pointer; font-weight: 700; box-shadow: var(--shadow-sm); }
.btn-unlock:hover { filter: brightness(0.98); transform: translateY(-1px); transition: all .2s ease; }

.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: none; align-items: center; justify-content: center; z-index: 10000; }
.modal-card { width: min(92vw, 420px); background: #fff; border-radius: 14px; box-shadow: var(--shadow-lg); padding: 1rem; border: 1px solid var(--border-color); animation: fadeIn .2s ease both; }
.modal-card h3 { margin: 0 0 .5rem 0; font-size: 1.25rem; color: var(--text-primary); }
.modal-card input { width: 100%; padding: .6rem .8rem; border: 1px solid var(--border-color); border-radius: 10px; margin: .5rem 0 .75rem 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: .5rem; }
.btn-outline { background: #fff; border: 1px solid var(--border-color); border-radius: 10px; padding: .45rem .8rem; cursor: pointer; }
.btn-primary { background: linear-gradient(135deg, var(--primary-color), var(--secondary-color)); color: #fff; border: none; border-radius: 10px; padding: .45rem .8rem; cursor: pointer; }
.modal-error { color: var(--error-color); margin-top: .5rem; }
/* Modal help */
.modal-help { margin-top: .5rem; }
.modal-help-text { color: var(--text-secondary); font-size: .9rem; }
.modal-help-text a { color: #2563eb; text-decoration: none; font-weight: 600; }
.modal-help-text a:hover { text-decoration: underline; }

/* Print Styles */
@media print {
    .grammar-sidebar,
    .grammar-navigation,
    .quiz-options,
    .mini-quiz-wrap {
        display: none;
    }
    
    .grammar-content {
        grid-template-columns: 1fr;
    }
    
    .grammar-container {
        padding: 0;
    }
    
    .grammar-section {
        break-inside: avoid;
        page-break-inside: avoid;
    }
}

/* ============== QUIZ START BUTTON ============== */
.quiz-start-section {
  margin-top: 2rem;
  padding: 0;
}

.quiz-start-card {
  background: linear-gradient(145deg, #f0f9ff 0%, #e0f2fe 50%, #bae6fd 100%);
  border: 2px solid #7dd3fc;
  border-radius: var(--radius-xl);
  padding: 2rem;
  text-align: center;
  box-shadow: 0 10px 40px -10px rgba(14, 165, 233, 0.3);
  transition: all 0.3s ease;
}

.quiz-start-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 15px 50px -10px rgba(14, 165, 233, 0.4);
}

.quiz-start-icon {
  color: #0284c7;
  margin-bottom: 1rem;
  display: inline-block;
}

.quiz-start-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: #0c4a6e;
  margin: 0 0 0.5rem 0;
}

.quiz-start-desc {
  color: #0369a1;
  font-size: 0.95rem;
  margin: 0 0 1.25rem 0;
}

.btn-start-quiz {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.85rem 2rem;
  background: linear-gradient(135deg, #0ea5e9, #0284c7);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 15px rgba(14, 165, 233, 0.4);
}

.btn-start-quiz:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 25px rgba(14, 165, 233, 0.5);
  background: linear-gradient(135deg, #38bdf8, #0ea5e9);
}

.btn-start-quiz svg {
  flex-shrink: 0;
}

/* Quiz mode - hide other content */
.quiz-mode-hidden {
  display: none !important;
}

body.quiz-active {
  overflow: hidden;
}

/* Quiz Fullscreen Mode */
.mini-quiz-wrap.quiz-fullscreen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100vw;
  height: 100vh;
  max-height: 100vh;
  overflow-y: auto;
  z-index: 9999;
  margin: 0;
  border-radius: 0;
  animation: quizFadeIn 0.3s ease;
  display: flex;
  flex-direction: column;
}

@keyframes quizFadeIn {
  0% { opacity: 0; }
  100% { opacity: 1; }
}

.mini-quiz-wrap.quiz-fullscreen .quiz-header {
  padding-top: 3rem;
  padding-bottom: 1.5rem;
}

.mini-quiz-wrap.quiz-fullscreen .quiz-card {
  max-width: 800px;
  margin: 0 auto;
  width: 95%;
  padding: 2rem;
  flex: 1;
}

.mini-quiz-wrap.quiz-fullscreen .quiz-question-wrap {
  max-width: 100%;
}

.mini-quiz-wrap.quiz-fullscreen .question-text {
  font-size: 1.25rem;
  line-height: 1.7;
  margin-bottom: 1.5rem;
}

.mini-quiz-wrap.quiz-fullscreen .quiz-options {
  gap: 0.75rem;
}

.mini-quiz-wrap.quiz-fullscreen .quiz-option {
  padding: 1rem 1.25rem;
  font-size: 1rem;
}

.mini-quiz-wrap.quiz-fullscreen .option-letter {
  width: 32px;
  height: 32px;
  font-size: 0.9rem;
}

.mini-quiz-wrap.quiz-fullscreen .btn-check,
.mini-quiz-wrap.quiz-fullscreen .btn-next {
  padding: 0.85rem 2rem;
  font-size: 1rem;
}

.mini-quiz-wrap.quiz-fullscreen .quiz-explanation {
  padding: 1.25rem;
  margin-top: 1.25rem;
}

.mini-quiz-wrap.quiz-fullscreen .exp-text {
  font-size: 1rem;
  line-height: 1.65;
}

.mini-quiz-wrap.quiz-fullscreen .quiz-result {
  max-width: 550px;
  margin: 0 auto;
  padding: 2rem;
}

/* Quiz Exit Button */
.quiz-exit-btn {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  width: 36px;
  height: 36px;
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: all 0.2s ease;
  backdrop-filter: blur(4px);
}

.quiz-exit-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.1);
}

/* ============== MINI QUIZ STYLES ============== */
.mini-quiz-wrap {
  margin-top: 2.5rem;
  padding: 0;
  background: linear-gradient(145deg, #1e293b 0%, #334155 50%, #475569 100%);
  border-radius: var(--radius-xl);
  box-shadow: 0 20px 60px -15px rgba(30, 41, 59, 0.5);
  position: relative;
  overflow: hidden;
}

.mini-quiz-wrap::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(255,255,255,0.05) 0%, transparent 60%);
  animation: shimmer 8s linear infinite;
}

@keyframes shimmer {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.quiz-header {
  text-align: center;
  padding: 1.25rem 1rem 1rem;
  position: relative;
  z-index: 1;
}

.quiz-logo {
  height: 72px;
  width: auto;
  margin-bottom: 0.5rem;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.3));
}

.quiz-icon {
  color: rgba(255,255,255,0.9);
  margin-bottom: 0.35rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.quiz-icon svg {
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

.quiz-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: #fff;
  margin: 0 0 0.15rem 0;
  text-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

.quiz-subtitle {
  color: rgba(255,255,255,0.85);
  font-size: 0.85rem;
  margin: 0;
}

/* Progress bar */
.quiz-progress {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 1.25rem 0.75rem;
  position: relative;
  z-index: 1;
}

.quiz-progress-bar {
  flex: 1;
  height: 6px;
  background: rgba(255,255,255,0.3);
  border-radius: 999px;
  overflow: hidden;
  backdrop-filter: blur(4px);
}

.quiz-progress-fill {
  height: 100%;
  background: #fff;
  border-radius: 999px;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 0 10px rgba(255,255,255,0.5);
}

.quiz-progress-text {
  font-size: 0.8rem;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  text-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

/* Quiz Card - Inner white card */
.quiz-card {
  background: #fff;
  border-radius: var(--radius-lg) var(--radius-lg) var(--radius-xl) var(--radius-xl);
  padding: 1.25rem;
  margin: 0;
  position: relative;
  z-index: 1;
}

.quiz-card.slide-out {
  opacity: 0;
  transform: translateX(-15px);
}

.quiz-card.slide-in {
  animation: slideIn 0.25s ease forwards;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(15px); }
  to { opacity: 1; transform: translateX(0); }
}

.question-number {
  display: inline-block;
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  margin-bottom: 0.6rem;
  letter-spacing: 0.5px;
}

.question-text {
  font-size: 1rem;
  line-height: 1.65;
  color: var(--text-primary);
  margin-bottom: 1rem;
  font-weight: 500;
}

/* Quiz Options - Compact 2x2 grid on larger screens */
.quiz-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.quiz-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.75rem;
  background: #f8fafc;
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: left;
  font-size: 0.9rem;
}

.quiz-option:hover:not(.disabled) {
  border-color: var(--primary-color);
  background: rgba(102, 126, 234, 0.06);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
}

.quiz-option.selected {
  border-color: var(--primary-color);
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.1), rgba(118, 75, 162, 0.1));
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}

.quiz-option.correct {
  border-color: var(--success-color);
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(5, 150, 105, 0.1));
  animation: correctPop 0.3s ease;
}

@keyframes correctPop {
  0% { transform: scale(1); }
  50% { transform: scale(1.02); }
  100% { transform: scale(1); }
}

.quiz-option.correct .option-icon::after {
  content: '✓';
  color: var(--success-color);
  font-weight: bold;
  font-size: 1rem;
}

.quiz-option.wrong {
  border-color: var(--error-color);
  background: rgba(239, 68, 68, 0.08);
  animation: shake 0.4s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-3px); }
  40%, 80% { transform: translateX(3px); }
}

.quiz-option.wrong .option-icon::after {
  content: '✗';
  color: var(--error-color);
  font-weight: bold;
  font-size: 1rem;
}

.quiz-option.disabled {
  cursor: default;
  pointer-events: none;
}

.option-letter {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background: #e5e7eb;
  border-radius: 50%;
  font-weight: 700;
  font-size: 0.75rem;
  color: var(--text-secondary);
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.quiz-option.selected .option-letter {
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  color: #fff;
}

.quiz-option.correct .option-letter {
  background: var(--success-color);
  color: #fff;
}

.quiz-option.wrong .option-letter {
  background: var(--error-color);
  color: #fff;
}

.option-text {
  flex: 1;
  color: var(--text-primary);
  line-height: 1.3;
}

.option-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Quiz Actions */
.quiz-actions {
  display: flex;
  justify-content: center;
}

.btn-check {
  padding: 0.6rem 1.75rem;
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.btn-check:hover:not(.disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.btn-check.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-check.hidden {
  display: none;
}

/* Quiz Explanation - Compact inline */
.quiz-explanation {
  margin-top: 0.75rem;
  padding: 0.85rem;
  background: linear-gradient(135deg, #fef9c3 0%, #fef08a 100%);
  border: 1px solid #fcd34d;
  border-radius: var(--radius-md);
  display: none;
  position: relative;
  overflow: hidden;
}

.quiz-explanation::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #f59e0b, #fbbf24, #f59e0b);
}

.quiz-explanation.show {
  display: block;
  animation: fadeInUp 0.3s ease;
}

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

.explanation-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.explanation-icon {
  display: inline-flex;
  align-items: center;
  color: #92400e;
}

.explanation-title {
  font-weight: 700;
  color: #92400e;
  font-size: 0.85rem;
}

.explanation-content {
  color: #78350f;
  line-height: 1.5;
  font-size: 0.9rem;
}

.exp-result {
  font-weight: 700;
  font-size: 0.9rem;
  margin-bottom: 0.35rem;
  padding: 0.3rem 0.6rem;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.exp-result.correct {
  background: rgba(16, 185, 129, 0.2);
  color: #065f46;
}

.exp-result.correct svg {
  color: #10b981;
}

.exp-result.wrong {
  background: rgba(239, 68, 68, 0.2);
  color: #991b1b;
}

.exp-result.wrong svg {
  color: #ef4444;
}

.exp-text {
  margin-top: 0.5rem;
  font-size: 0.9rem;
  line-height: 1.55;
}

.btn-next {
  margin-top: 0.75rem;
  padding: 0.55rem 1.25rem;
  background: linear-gradient(135deg, var(--success-color), #059669);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  width: 100%;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.btn-next:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(16, 185, 129, 0.4);
}

/* Highlight Styles */
.quiz-highlight-pending {
  /* No highlight until answer checked */
  background: transparent;
}

.quiz-highlight {
  position: relative;
  background: linear-gradient(120deg, #fef08a 0%, #fde047 100%);
  padding: 0.05rem 0.25rem;
  border-radius: 3px;
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(253, 224, 71, 0.5);
}

.quiz-highlight.animated {
  animation: highlightPulse 0.5s ease;
}

@keyframes highlightPulse {
  0% { background: transparent; box-shadow: none; }
  50% { background: #fde047; box-shadow: 0 0 15px rgba(253, 224, 71, 0.8); }
  100% { background: linear-gradient(120deg, #fef08a 0%, #fde047 100%); }
}

.highlight-tooltip {
  position: absolute;
  bottom: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%) scale(0.9);
  background: linear-gradient(135deg, #1f2937, #374151);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 500;
  padding: 0.3rem 0.5rem;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
  z-index: 10;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.highlight-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 4px solid transparent;
  border-top-color: #374151;
}

.quiz-highlight:hover .highlight-tooltip {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) scale(1);
}

/* Quiz Result - Compact celebration */
.quiz-result {
  text-align: center;
  padding: 1.5rem 1rem;
  position: relative;
  background: #fff;
  border-radius: var(--radius-lg) var(--radius-lg) var(--radius-xl) var(--radius-xl);
}

.quiz-result.show {
  animation: resultShow 0.4s ease;
}

@keyframes resultShow {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.result-confetti {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: 
    radial-gradient(circle, var(--primary-color) 1.5px, transparent 1.5px),
    radial-gradient(circle, var(--secondary-color) 1.5px, transparent 1.5px),
    radial-gradient(circle, var(--accent-color) 1.5px, transparent 1.5px),
    radial-gradient(circle, var(--success-color) 1.5px, transparent 1.5px);
  background-size: 40px 40px, 35px 35px, 50px 50px, 38px 38px;
  background-position: 0 0, 15px 15px, 8px 25px, 30px 10px;
  opacity: 0.25;
  animation: confettiFloat 4s linear infinite;
}

@keyframes confettiFloat {
  from { background-position: 0 0, 15px 15px, 8px 25px, 30px 10px; }
  to { background-position: 40px 40px, 55px 55px, 48px 65px, 70px 50px; }
}

/* ============== GRAMMAR MIND MAP ============== */
/* View toggle header - always visible */
.grammar-view-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  padding: 1rem 1.25rem;
  background: linear-gradient(135deg, #fff 0%, #f8fafc 100%);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

.grammar-mindmap {
  margin-top: 0;
  padding: 1.5rem;
  background: 
    /* Bamboo leaves pattern */
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='60' height='60' viewBox='0 0 60 60'%3E%3Cpath d='M15 5c-2 3-1 8 2 10s7 1 9-2c-3 1-6 0-8-2s-2-5-3-6z' fill='%2322c55e' fill-opacity='0.06'/%3E%3Cpath d='M45 25c-2 3-1 8 2 10s7 1 9-2c-3 1-6 0-8-2s-2-5-3-6z' fill='%2322c55e' fill-opacity='0.05'/%3E%3Cpath d='M5 45c-2 3-1 8 2 10s7 1 9-2c-3 1-6 0-8-2s-2-5-3-6z' fill='%2322c55e' fill-opacity='0.04'/%3E%3C/svg%3E"),
    /* Cloud pattern (祥云) */
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='50' viewBox='0 0 100 50'%3E%3Cpath d='M20 35c0-8 6-14 14-14 1 0 2 0 3 .3C39 15 44 10 51 10c9 0 16 7 16 16 0 1-.1 2-.2 3 5 1 9 6 9 11' stroke='%23667eea' stroke-width='1' fill='none' stroke-opacity='0.08'/%3E%3C/svg%3E"),
    /* Great Wall silhouette */
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='40' viewBox='0 0 200 40'%3E%3Cpath d='M0 38h10v-8h5v8h10v-12h5v12h10v-6h5v6h10v-10h5v10h10v-8h5v8h10v-14h5v14h10v-6h5v6h10v-10h5v10h10v-8h5v8h10v-12h5v12h10v-6h5v6h15' stroke='%239ca3af' stroke-width='1' fill='none' stroke-opacity='0.06'/%3E%3C/svg%3E"),
    linear-gradient(180deg, #fafbfc 0%, #f8fafc 100%);
  background-position: top left, top right, bottom center, center;
  background-repeat: repeat, repeat, repeat-x, no-repeat;
  background-size: 60px 60px, 100px 50px, 200px 40px, 100% 100%;
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-color);
  overflow: hidden;
  position: relative;
}

.grammar-mindmap::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 150px;
  height: 150px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Ccircle cx='50' cy='50' r='45' stroke='%23ef4444' stroke-width='2' fill='none' stroke-opacity='0.08'/%3E%3Cpath d='M50 15v70M15 50h70M25 25l50 50M75 25l-50 50' stroke='%23ef4444' stroke-width='1' stroke-opacity='0.06'/%3E%3C/svg%3E") no-repeat center;
  opacity: 0.5;
  pointer-events: none;
}

.grammar-mindmap::after {
  content: '';
  position: absolute;
  bottom: 10px;
  left: 10px;
  width: 80px;
  height: 100px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 60'%3E%3Cpath d='M20 5v50M15 10c5 3 5 8 0 12M25 15c-5 3-5 8 0 12M15 30c5 3 5 8 0 12M25 35c-5 3-5 8 0 12' stroke='%2322c55e' stroke-width='2' fill='none' stroke-opacity='0.1' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat center;
  opacity: 0.6;
  pointer-events: none;
}

.mindmap-tree {
  position: relative;
  z-index: 1;
}

.mindmap-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.mindmap-title::before {
  content: '';
  display: inline-block;
  width: 24px;
  height: 24px;
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  border-radius: 6px;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='white'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M4 5a1 1 0 011-1h14a1 1 0 011 1v2a1 1 0 01-1 1H5a1 1 0 01-1-1V5zM4 13a1 1 0 011-1h6a1 1 0 011 1v6a1 1 0 01-1 1H5a1 1 0 01-1-1v-6zM16 13a1 1 0 011-1h2a1 1 0 011 1v6a1 1 0 01-1 1h-2a1 1 0 01-1-1v-6z'/%3E%3C/svg%3E") center/contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='white'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M4 5a1 1 0 011-1h14a1 1 0 011 1v2a1 1 0 01-1 1H5a1 1 0 01-1-1V5zM4 13a1 1 0 011-1h6a1 1 0 011 1v6a1 1 0 01-1 1H5a1 1 0 01-1-1v-6zM16 13a1 1 0 011-1h2a1 1 0 011 1v6a1 1 0 01-1 1h-2a1 1 0 01-1-1v-6z'/%3E%3C/svg%3E") center/contain no-repeat;
}

.mindmap-toggle {
  display: flex;
  gap: 0.5rem;
}

.mindmap-toggle-btn {
  padding: 0.5rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: 999px;
  background: #fff;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.mindmap-toggle-btn:hover {
  border-color: var(--primary-color);
  color: var(--primary-color);
}

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

/* Mindmap Category Grouping */
.mindmap-category {
  margin-bottom: 2rem;
  background: #fff;
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  border: 1px solid #e2e8f0;
}
.mindmap-category:last-child {
  margin-bottom: 0;
}
.mindmap-category-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
  border-radius: 10px;
  margin-bottom: 1.25rem;
  color: #fff;
  font-weight: 600;
  font-size: 1.05rem;
}
.mindmap-category-header .category-icon {
  font-size: 1.2rem;
}
.mindmap-category-content {
  padding-left: 0.5rem;
}

.mindmap-level {
  display: flex;
  align-items: flex-start;
  margin-bottom: 1.5rem;
  position: relative;
}

.mindmap-level:last-child {
  margin-bottom: 0;
}

.mindmap-level-label {
  flex-shrink: 0;
  width: 80px;
  padding: 0.75rem;
  text-align: center;
  border-radius: 12px;
  font-weight: 800;
  font-size: 0.9rem;
  color: #fff;
  position: relative;
  z-index: 2;
}

.mindmap-level-label.hsk1 { background: linear-gradient(135deg, #22c55e, #16a34a); }
.mindmap-level-label.hsk2 { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.mindmap-level-label.hsk3 { background: linear-gradient(135deg, #8b5cf6, #7c3aed); }
.mindmap-level-label.hsk4 { background: linear-gradient(135deg, #f59e0b, #d97706); }
.mindmap-level-label.hsk5 { background: linear-gradient(135deg, #ef4444, #dc2626); }
.mindmap-level-label.hsk6 { background: linear-gradient(135deg, #ec4899, #db2777); }

.mindmap-connector {
  position: absolute;
  left: 40px;
  top: 100%;
  width: 2px;
  height: calc(100% + 1.5rem);
  background: linear-gradient(to bottom, #e2e8f0, transparent);
}

.mindmap-level:last-child .mindmap-connector {
  display: none;
}

.mindmap-items {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-left: 1.5rem;
  position: relative;
}

.mindmap-items::before {
  content: '';
  position: absolute;
  left: -1rem;
  top: 50%;
  width: 1rem;
  height: 2px;
  background: #e2e8f0;
}

.mindmap-item {
  padding: 0.6rem 1rem;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  text-decoration: none;
}

.mindmap-item:hover {
  background: #f0f4ff;
  border-color: var(--primary-color);
  color: var(--primary-color);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
}

.mindmap-item.new::after {
  content: 'Mới';
  position: absolute;
  top: -6px;
  right: -6px;
  padding: 2px 6px;
  background: #22c55e;
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  border-radius: 999px;
}

.mindmap-empty {
  text-align: center;
  padding: 2rem;
  color: var(--text-secondary);
  font-size: 0.95rem;
}

/* Mindmap responsive */
@media (max-width: 768px) {
  .mindmap-level {
    flex-direction: column;
  }
  
  .mindmap-level-label {
    width: auto;
    margin-bottom: 0.75rem;
  }
  
  .mindmap-items {
    margin-left: 0;
  }
  
  .mindmap-items::before {
    display: none;
  }
  
  .mindmap-connector {
    display: none;
  }
}

.result-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.5rem;
  animation: resultPop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes resultPop {
  0% { transform: scale(0); opacity: 0; }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); opacity: 1; }
}

.result-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 0.15rem 0;
}

.result-message {
  color: var(--text-secondary);
  margin: 0 0 1rem 0;
  font-size: 0.9rem;
}

.result-score {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 0.2rem;
  margin-bottom: 0.15rem;
}

.score-correct {
  font-size: 2.75rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--success-color), #059669);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.score-divider {
  font-size: 1.5rem;
  color: var(--text-secondary);
}

.score-total {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.result-label {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin: 0 0 1rem 0;
}

.btn-restart {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1.5rem;
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.btn-restart svg {
  flex-shrink: 0;
}

.btn-restart:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

/* Responsive - Stack options on mobile */
@media (max-width: 640px) {
  .mini-quiz-wrap {
    margin-top: 1.5rem;
    border-radius: var(--radius-lg);
  }
  
  .quiz-header {
    padding: 1rem 0.75rem 0.75rem;
  }
  
  .quiz-title {
    font-size: 1.1rem;
  }
  
  .quiz-subtitle {
    font-size: 0.8rem;
  }
  
  .quiz-progress {
    padding: 0 1rem 0.6rem;
  }
  
  .quiz-card {
    padding: 1rem;
    border-radius: var(--radius-md) var(--radius-md) var(--radius-lg) var(--radius-lg);
  }
  
  .question-text {
    font-size: 0.95rem;
    margin-bottom: 0.85rem;
  }
  
  .quiz-options {
    grid-template-columns: 1fr;
    gap: 0.4rem;
  }
  
  .quiz-option {
    padding: 0.55rem 0.65rem;
    font-size: 0.85rem;
  }
  
  .option-letter {
    width: 22px;
    height: 22px;
    font-size: 0.7rem;
  }
  
  .quiz-explanation {
    padding: 0.75rem;
  }
  
  .exp-text {
    font-size: 0.85rem;
  }
  
  .btn-next {
    font-size: 0.8rem;
    padding: 0.5rem 1rem;
  }
  
  .result-title {
    font-size: 1.15rem;
  }
  
  .score-correct {
    font-size: 2.25rem;
  }
  
  .score-total, .score-divider {
    font-size: 1.25rem;
  }
  
  .result-score {
    margin-bottom: 0.1rem;
  }
  
  .result-label {
    font-size: 0.8rem;
    margin-bottom: 0.85rem;
  }
}

/* Quiz Card styles moved above */

/* ============== PATTERN SLIDESHOW MODULE ============== */
/* View Toggle Buttons */
.patterns-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.patterns-view-toggle {
  display: flex;
  gap: 0.5rem;
  background: #f1f5f9;
  padding: 4px;
  border-radius: 10px;
}

.view-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.view-btn:hover {
  color: var(--primary-color);
}

.view-btn.active {
  background: #fff;
  color: var(--primary-color);
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.view-btn svg {
  flex-shrink: 0;
}

/* Slideshow Container */
.patterns-slideshow {
  min-height: 400px;
}

.patterns-slideshow.hidden {
  display: none;
}

.slideshow-container {
  position: relative;
  width: 100%;
  min-height: 450px;
  border-radius: var(--radius-xl);
  overflow: hidden;
  background: linear-gradient(145deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  display: flex;
  flex-direction: column;
}

.slideshow-container.fullscreen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100vw;
  height: 100vh;
  min-height: 100vh;
  z-index: 99999;
  border-radius: 0;
}

/* Slides wrapper takes remaining space */
.slides-wrapper {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  min-height: 0;
}

body.slideshow-fullscreen-active {
  overflow: hidden;
}

/* Chinese-themed Background */
.slideshow-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.bamboo-left {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 120px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 60 400'%3E%3Cpath d='M30 0v400' stroke='%2322c55e' stroke-width='8' stroke-opacity='0.15'/%3E%3Cpath d='M30 50c-15 5-15 15 0 20M30 120c-15 5-15 15 0 20M30 190c-15 5-15 15 0 20M30 260c-15 5-15 15 0 20M30 330c-15 5-15 15 0 20' stroke='%2322c55e' stroke-width='3' fill='none' stroke-opacity='0.12'/%3E%3Cpath d='M10 30c-8 10-5 25 5 30M10 100c-8 10-5 25 5 30M10 170c-8 10-5 25 5 30' fill='%2322c55e' fill-opacity='0.08'/%3E%3C/svg%3E") repeat-y left center;
  opacity: 0.8;
}

.bamboo-right {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 120px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 60 400'%3E%3Cpath d='M30 0v400' stroke='%2322c55e' stroke-width='8' stroke-opacity='0.15'/%3E%3Cpath d='M30 80c15 5 15 15 0 20M30 150c15 5 15 15 0 20M30 220c15 5 15 15 0 20M30 290c15 5 15 15 0 20M30 360c15 5 15 15 0 20' stroke='%2322c55e' stroke-width='3' fill='none' stroke-opacity='0.12'/%3E%3Cpath d='M50 60c8 10 5 25-5 30M50 130c8 10 5 25-5 30M50 200c8 10 5 25-5 30' fill='%2322c55e' fill-opacity='0.08'/%3E%3C/svg%3E") repeat-y right center;
  opacity: 0.8;
}

.cloud-pattern {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 150px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='100' viewBox='0 0 200 100'%3E%3Cpath d='M30 70c0-15 12-27 27-27 2 0 4 0 5 .5C66 30 78 20 93 20c18 0 32 14 32 32 0 2 0 4-.5 6 10 2 18 11 18 22' stroke='%23fff' stroke-width='1.5' fill='none' stroke-opacity='0.06'/%3E%3Cpath d='M140 80c0-10 8-18 18-18 1 0 2 0 3 .3 3-8 10-14 19-14 12 0 21 9 21 21 0 1 0 2-.2 4 7 1 12 7 12 15' stroke='%23fff' stroke-width='1' fill='none' stroke-opacity='0.04'/%3E%3C/svg%3E") repeat-x top center;
  animation: cloudFloat 60s linear infinite;
}

@keyframes cloudFloat {
  from { background-position: 0 0; }
  to { background-position: 400px 0; }
}

.chinese-border {
  position: absolute;
  inset: 15px;
  border: 2px solid rgba(255,215,0,0.15);
  border-radius: 8px;
  pointer-events: none;
}

.chinese-border::before {
  content: '';
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
  width: 60px;
  height: 16px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 60 16'%3E%3Cpath d='M0 8h15c5 0 5-6 10-6s5 6 10 6h15' stroke='%23ffd700' stroke-width='2' fill='none' stroke-opacity='0.3'/%3E%3C/svg%3E") no-repeat center;
}

/* Slides */
.slides-wrapper {
  position: relative;
  min-height: 350px;
  padding: 2rem;
}

.slideshow-container.fullscreen .slides-wrapper {
  min-height: calc(100vh - 120px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.slide {
  position: absolute;
  inset: 2rem;
  opacity: 0;
  visibility: hidden;
  transform: scale(0.95);
  transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.slide.active {
  opacity: 1;
  visibility: visible;
  transform: scale(1);
}

.slideshow-container.fullscreen .slide {
  inset: 3rem;
}

/* Slide Transitions */
.slide.enter-fade { animation: fadeIn 0.5s ease forwards; }
.slide.exit-fade { animation: fadeOut 0.3s ease forwards; }

.slide.enter-slide-left { animation: slideInLeft 0.5s ease forwards; }
.slide.exit-slide-left { animation: slideOutLeft 0.3s ease forwards; }

.slide.enter-slide-right { animation: slideInRight 0.5s ease forwards; }
.slide.exit-slide-right { animation: slideOutRight 0.3s ease forwards; }

.slide.enter-slide-up { animation: slideInUp 0.5s ease forwards; }
.slide.exit-slide-up { animation: slideOutUp 0.3s ease forwards; }

.slide.enter-zoom { animation: zoomIn 0.5s ease forwards; }
.slide.exit-zoom { animation: zoomOut 0.3s ease forwards; }

.slide.enter-flip { animation: flipIn 0.6s ease forwards; }
.slide.exit-flip { animation: flipOut 0.3s ease forwards; }

.slide.enter-rotate { animation: rotateIn 0.5s ease forwards; }
.slide.exit-rotate { animation: rotateOut 0.3s ease forwards; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }

@keyframes slideInLeft { from { transform: translateX(-100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes slideOutLeft { from { transform: translateX(0); opacity: 1; } to { transform: translateX(100%); opacity: 0; } }

@keyframes slideInRight { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes slideOutRight { from { transform: translateX(0); opacity: 1; } to { transform: translateX(-100%); opacity: 0; } }

@keyframes slideInUp { from { transform: translateY(50%); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes slideOutUp { from { transform: translateY(0); opacity: 1; } to { transform: translateY(-50%); opacity: 0; } }

@keyframes zoomIn { from { transform: scale(0.5); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes zoomOut { from { transform: scale(1); opacity: 1; } to { transform: scale(1.2); opacity: 0; } }

@keyframes flipIn { from { transform: perspective(800px) rotateY(-90deg); opacity: 0; } to { transform: perspective(800px) rotateY(0); opacity: 1; } }
@keyframes flipOut { from { transform: perspective(800px) rotateY(0); opacity: 1; } to { transform: perspective(800px) rotateY(90deg); opacity: 0; } }

@keyframes rotateIn { from { transform: rotate(-10deg) scale(0.9); opacity: 0; } to { transform: rotate(0) scale(1); opacity: 1; } }
@keyframes rotateOut { from { transform: rotate(0) scale(1); opacity: 1; } to { transform: rotate(10deg) scale(0.9); opacity: 0; } }

/* ====================================
   TITLE SLIDE STYLES
   ==================================== */
.slide-title .title-content {
  background: linear-gradient(135deg, #1e3a5f 0%, #2d5a87 50%, #1e3a5f 100%);
  color: #fff;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 320px;
  position: relative;
  overflow: hidden;
}

.slide-title .title-content::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M30 5L35 25H55L39 37L44 57L30 45L16 57L21 37L5 25H25L30 5Z' fill='%23ffffff' fill-opacity='0.03'/%3E%3C/svg%3E");
  pointer-events: none;
}

.title-decoration {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.chinese-ornament {
  position: absolute;
  width: 60px;
  height: 60px;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='30' cy='30' r='25' stroke='%23fbbf24' stroke-width='2' fill='none' opacity='0.4'/%3E%3Ccircle cx='30' cy='30' r='15' stroke='%23fbbf24' stroke-width='1' fill='none' opacity='0.3'/%3E%3C/svg%3E") center/contain no-repeat;
  opacity: 0.6;
}

.chinese-ornament.top-left { top: 10px; left: 10px; }
.chinese-ornament.top-right { top: 10px; right: 10px; transform: rotate(90deg); }
.chinese-ornament.bottom-left { bottom: 10px; left: 10px; transform: rotate(-90deg); }
.chinese-ornament.bottom-right { bottom: 10px; right: 10px; transform: rotate(180deg); }

.title-badge {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
  animation: titleBadgeIn 0.6s ease-out;
}

.title-badge .slide-badge {
  background: rgba(255,255,255,0.2);
  border: 1px solid rgba(255,255,255,0.3);
  color: #fff;
}

.pattern-number {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #fff;
  padding: 6px 16px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
}

.title-pattern {
  font-size: 2rem;
  font-weight: 800;
  margin: 0 0 1rem 0;
  text-shadow: 0 2px 10px rgba(0,0,0,0.3);
  animation: titlePatternIn 0.8s ease-out;
  line-height: 1.4;
}

.slideshow-container.fullscreen .title-pattern {
  font-size: 3rem;
}

.title-meaning {
  font-size: 1.2rem;
  color: rgba(255,255,255,0.85);
  margin: 0;
  max-width: 500px;
  animation: titleMeaningIn 1s ease-out;
}

.slideshow-container.fullscreen .title-meaning {
  font-size: 1.5rem;
}

.title-hint {
  position: absolute;
  bottom: 20px;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: rgba(255,255,255,0.6);
  font-size: 0.9rem;
  animation: titleHintPulse 2s ease-in-out infinite;
}

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

@keyframes titlePatternIn {
  from { opacity: 0; transform: scale(0.8); }
  to { opacity: 1; transform: scale(1); }
}

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

@keyframes titleHintPulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

/* ====================================
   FEEDBACK SLIDE STYLES
   ==================================== */
.slide-feedback .feedback-content {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 50%, #fef3c7 100%);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 350px;
  position: relative;
}

.slide-feedback .feedback-content::before {
  display: none;
}

.feedback-header {
  margin-bottom: 1.5rem;
}

.feedback-icon {
  font-size: 3rem;
  animation: feedbackBounce 1s ease infinite;
}

@keyframes feedbackBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.feedback-title {
  font-size: 1.6rem;
  font-weight: 800;
  color: #92400e;
  margin: 0.5rem 0;
}

.feedback-subtitle {
  color: #a16207;
  font-size: 1rem;
  margin: 0;
}

.feedback-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
  max-width: 400px;
}

.feedback-rating {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.rating-label {
  font-weight: 600;
  color: #78350f;
}

.rating-stars {
  display: flex;
  gap: 0.5rem;
}

.star-btn {
  background: none;
  border: none;
  font-size: 2rem;
  cursor: pointer;
  opacity: 0.4;
  transition: all 0.2s ease;
  filter: grayscale(100%);
}

.star-btn:hover,
.star-btn.active {
  opacity: 1;
  filter: grayscale(0%);
  transform: scale(1.2);
}

.feedback-comment textarea {
  width: 100%;
  padding: 0.75rem;
  border: 2px solid #d97706;
  border-radius: 10px;
  font-size: 0.95rem;
  resize: none;
  background: rgba(255,255,255,0.8);
}

.feedback-comment textarea:focus {
  outline: none;
  border-color: #92400e;
  background: #fff;
}

.feedback-submit {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(217, 119, 6, 0.3);
}

.feedback-submit:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(217, 119, 6, 0.4);
}

.feedback-submit:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.feedback-thanks {
  font-size: 1.2rem;
  font-weight: 700;
  color: #15803d;
  animation: thanksFadeIn 0.5s ease;
  margin: 0 0 1rem 0;
}

@keyframes thanksFadeIn {
  from { opacity: 0; transform: scale(0.8); }
  to { opacity: 1; transform: scale(1); }
}

/* Feedback Completion Actions */
.feedback-completion {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  animation: thanksFadeIn 0.5s ease;
}

.completion-actions {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: center;
}

.completion-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  border: none;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s ease;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.completion-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(0,0,0,0.2);
}

.completion-btn.quiz-btn {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
}

.completion-btn.quiz-btn:hover {
  background: linear-gradient(135deg, #059669, #047857);
}

.completion-btn.back-btn {
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: #fff;
}

.completion-btn.back-btn:hover {
  background: linear-gradient(135deg, #4f46e5, #4338ca);
}

.loading-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Slide Content */
.slide-content {
  background: rgba(255,255,255,0.95);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  min-height: 280px;
  max-height: calc(100vh - 200px);
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
  position: relative;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.slideshow-container.fullscreen .slide-content {
  min-height: 50vh;
  max-height: 80vh;
  padding: 2.5rem;
}

.slide-content::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, #ef4444, #f59e0b, #22c55e, #3b82f6, #8b5cf6);
}

.slide-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid #f1f5f9;
  flex-wrap: wrap;
}

.slide-badge {
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.slide-pattern-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-primary);
}

.slideshow-container.fullscreen .slide-pattern-title {
  font-size: 1.8rem;
}

.slide-body {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  flex: 1;
}

.slide-line {
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text-primary);
  padding: 0.4rem 0;
  border-bottom: 1px solid rgba(0,0,0,0.05);
  animation: lineAppear 0.5s ease forwards;
  opacity: 0;
}

.slideshow-container.fullscreen .slide-line {
  font-size: 1.25rem;
}

.slide-line:nth-child(1) { animation-delay: 0.1s; }
.slide-line:nth-child(2) { animation-delay: 0.2s; }
.slide-line:nth-child(3) { animation-delay: 0.3s; }
.slide-line:nth-child(4) { animation-delay: 0.4s; }
.slide-line:nth-child(5) { animation-delay: 0.5s; }
.slide-line:nth-child(6) { animation-delay: 0.6s; }

@keyframes lineAppear {
  from { opacity: 0; transform: translateX(-20px); }
  to { opacity: 1; transform: translateX(0); }
}

.slide-line.meaning {
  font-weight: 600;
  color: #1e40af;
}

.slide-line .line-label {
  color: var(--primary-color);
  font-weight: 700;
}

.slide-line.section-title {
  font-weight: 700;
  color: var(--text-primary);
  border-bottom: none;
  margin-top: 0.5rem;
}

.slide-line.example {
  padding-left: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: baseline;
}

.slide-line .ex-num {
  color: var(--primary-color);
  font-weight: 700;
  min-width: 24px;
}

.slide-line .ex-zh {
  font-weight: 600;
  color: #1f2937;
}

.slide-line .ex-vi {
  color: #059669;
  font-style: italic;
}

.slide-line.usage-formatted {
  background: var(--bg-secondary);
  padding: 1rem 1.25rem;
  border-radius: 10px;
  border-left: 4px solid var(--primary);
  font-size: 0.95rem;
  line-height: 1.7;
  max-height: 60vh;
  overflow-y: auto;
}

.slide-line.usage-formatted .usage-section-title {
  font-size: 1.05rem;
  margin-top: 1rem;
  margin-bottom: 0.5rem;
}

.slide-line.usage-formatted .usage-section-title:first-child {
  margin-top: 0;
}

.slide-line.usage-formatted .usage-bullet {
  padding-left: 1.25rem;
  margin: 0.35rem 0;
}

.slide-line.usage-formatted .usage-example {
  padding-left: 1.5rem;
  margin: 0.5rem 0;
}

.slide-line.notes {
  background: #fefce8;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  border-left: 4px solid #f59e0b;
  color: #78350f;
}

.slide-continuation {
  text-align: center;
  color: var(--text-secondary);
  font-style: italic;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 2px dashed #e5e7eb;
}

.slide-decoration {
  position: absolute;
  bottom: 10px;
  right: 10px;
  width: 80px;
  height: 80px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 80 80'%3E%3Ccircle cx='40' cy='40' r='35' stroke='%23ef4444' stroke-width='1' fill='none' stroke-opacity='0.1'/%3E%3Cpath d='M40 10v60M10 40h60' stroke='%23ef4444' stroke-width='0.5' stroke-opacity='0.08'/%3E%3C/svg%3E") no-repeat center;
  opacity: 0.5;
  pointer-events: none;
}

/* Slideshow Controls */
.slideshow-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 1rem;
}

.slide-nav {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.3);
  background: rgba(255,255,255,0.1);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.slide-nav:hover {
  background: rgba(255,255,255,0.2);
  border-color: rgba(255,255,255,0.5);
  transform: scale(1.1);
}

.slide-nav:active {
  transform: scale(0.95);
}

.slide-progress {
  display: flex;
  align-items: center;
  gap: 4px;
  color: #fff;
  font-size: 1.1rem;
  font-weight: 600;
  min-width: 80px;
  justify-content: center;
}

.slide-current {
  color: #fbbf24;
  font-size: 1.3rem;
}

.slide-fullscreen {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.3);
  background: rgba(255,255,255,0.1);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  margin-left: 1rem;
}

.slide-fullscreen:hover {
  background: rgba(255,255,255,0.2);
}

/* ====================================
   SLIDESHOW TOOLBOX - Enhanced Controls
   ==================================== */
.slideshow-toolbox {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: linear-gradient(to top, rgba(255,255,255,0.95), rgba(255,255,255,0.8));
  margin-top: 0;
  position: relative;
  z-index: 10;
  border-top: 1px solid rgba(0,0,0,0.08);
  flex-shrink: 0;
}

.toolbox-btn {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border: 1px solid rgba(139,69,19,0.3);
  border-radius: 8px;
  background: rgba(139,69,19,0.1);
  color: #8b4513;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.25s ease;
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}

.toolbox-btn:hover {
  background: rgba(139,69,19,0.2);
  border-color: rgba(139,69,19,0.5);
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(0,0,0,0.12);
}

.toolbox-btn:active {
  transform: translateY(0);
}

.toolbox-btn svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.toolbox-btn.prev svg,
.toolbox-btn.next svg {
  fill: currentColor;
}

.toolbox-btn-label {
  display: inline-block;
}

/* Progress Section */
.toolbox-progress {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  min-width: 100px;
  padding: 0 0.75rem;
}

.progress-info {
  display: flex;
  align-items: baseline;
  gap: 0.2rem;
  font-family: 'Noto Serif SC', serif;
}

.progress-current {
  font-size: 1.25rem;
  font-weight: 700;
  color: #b45309;
}

.progress-sep {
  font-size: 1rem;
  color: #9ca3af;
  margin: 0 0.1rem;
}

.progress-total {
  font-size: 1rem;
  font-weight: 500;
  color: #6b7280;
}

.progress-bar {
  width: 100%;
  height: 3px;
  background: rgba(139,69,19,0.15);
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #b45309, #d97706);
  border-radius: 2px;
  transition: width 0.4s ease;
}

/* Toolbox Divider */
.toolbox-divider {
  width: 1px;
  height: 24px;
  background: rgba(139,69,19,0.2);
  margin: 0 0.25rem;
}

/* Fullscreen Buttons in Toolbox */
.toolbox-btn.fullscreen,
.toolbox-btn.exit-fullscreen {
  background: rgba(30,58,95,0.1);
  border-color: rgba(30,58,95,0.3);
  color: #1e3a5f;
}

.toolbox-btn.fullscreen:hover,
.toolbox-btn.exit-fullscreen:hover {
  background: rgba(30,58,95,0.2);
  border-color: rgba(30,58,95,0.5);
}

.toolbox-btn.hidden {
  display: none;
}

/* ====================================
   SLIDE PATTERN BOX - Framed Pattern Title
   ==================================== */
.slide-pattern-box {
  background: linear-gradient(135deg, rgba(139,69,19,0.4), rgba(101,67,33,0.3));
  border: 2px solid rgba(255,215,0,0.5);
  border-radius: 12px;
  padding: 1rem 1.5rem;
  margin-bottom: 1rem;
  position: relative;
  box-shadow: 
    0 4px 16px rgba(0,0,0,0.2),
    inset 0 1px 0 rgba(255,255,255,0.1);
}

.slide-pattern-box::before {
  content: '句型';
  position: absolute;
  top: -10px;
  left: 1rem;
  background: linear-gradient(135deg, #8b4513, #654321);
  color: #fbbf24;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.15rem 0.6rem;
  border-radius: 4px;
  border: 1px solid rgba(255,215,0,0.5);
  font-family: 'Noto Serif SC', serif;
  letter-spacing: 1px;
}

.slide-pattern-box::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 30px;
  height: 30px;
  background: linear-gradient(135deg, transparent 50%, rgba(255,215,0,0.2) 50%);
  border-radius: 0 10px 0 0;
}

.slide-pattern-box .slide-pattern-title {
  font-size: 1.35rem;
  color: #fff;
  text-shadow: 0 2px 4px rgba(0,0,0,0.3);
  line-height: 1.6;
  text-align: center;
}

/* Pattern Components Styling */
.slide-pattern-box .pt-text {
  color: #fff;
  font-weight: 500;
}

.slide-pattern-box .pt-op {
  color: #fbbf24;
  font-weight: 600;
  margin: 0 0.25rem;
}

.slide-pattern-box .pt-term {
  color: #60a5fa;
  font-weight: 600;
  background: rgba(96,165,250,0.15);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  border: 1px solid rgba(96,165,250,0.3);
}

.slide-pattern-box .pt-paren {
  color: rgba(255,255,255,0.7);
  font-weight: 400;
}

.slide-pattern-box .pt-term-opt {
  color: #a78bfa;
  font-weight: 500;
  background: rgba(167,139,250,0.15);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  border: 1px dashed rgba(167,139,250,0.4);
}

.slide-pattern-box .pt-op-or {
  color: #f97316;
  font-weight: 600;
  margin: 0 0.2rem;
}

/* Slide Indicators */
.slide-indicators {
  display: flex;
  justify-content: center;
  gap: 6px;
  padding-bottom: 1rem;
  flex-wrap: wrap;
  max-width: 80%;
  margin: 0 auto;
}

.indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255,255,255,0.3);
  cursor: pointer;
  transition: all 0.2s ease;
}

.indicator:hover {
  background: rgba(255,255,255,0.5);
  transform: scale(1.2);
}

.indicator.active {
  background: #fbbf24;
  width: 24px;
  border-radius: 4px;
}

/* Responsive Slideshow */
@media (max-width: 768px) {
  .patterns-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  
  .patterns-view-toggle {
    justify-content: center;
  }
  
  .slideshow-container {
    min-height: 400px;
  }
  
  .slides-wrapper {
    padding: 1rem;
  }
  
  .slide {
    inset: 1rem;
  }
  
  .slide-content {
    padding: 1.25rem;
    min-height: 280px;
  }
  
  .slide-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }
  
  .slide-pattern-title {
    font-size: 1.1rem;
  }
  
  .slide-line {
    font-size: 0.95rem;
  }
  
  .bamboo-left,
  .bamboo-right {
    width: 60px;
    opacity: 0.5;
  }
  
  .slideshow-controls {
    padding: 0.75rem;
    gap: 0.5rem;
  }
  
  .slide-nav {
    width: 40px;
    height: 40px;
  }
  
  .slide-indicators {
    max-width: 90%;
  }
  
  /* Toolbox Responsive */
  .slideshow-toolbox {
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.5rem;
  }
  
  .toolbox-btn {
    padding: 0.4rem 0.6rem;
    font-size: 0.8rem;
  }
  
  .toolbox-btn .btn-label {
    display: none;
  }
  
  .toolbox-progress {
    min-width: 70px;
    padding: 0 0.5rem;
  }
  
  .progress-current {
    font-size: 1.1rem;
  }
  
  .progress-sep,
  .progress-total {
    font-size: 0.9rem;
  }
  
  .toolbox-divider {
    display: none;
  }
  
  /* Pattern Box Responsive */
  .slide-pattern-box {
    padding: 0.6rem 0.8rem;
    margin-bottom: 0.6rem;
    border-radius: 8px;
  }
  
  .slide-pattern-box::before {
    font-size: 0.65rem;
    padding: 0.1rem 0.4rem;
    top: -8px;
    left: 0.6rem;
  }
  
  .slide-pattern-box .slide-pattern-title {
    font-size: 0.95rem;
    line-height: 1.4;
  }
  
  .slide-pattern-box .pt-term {
    padding: 0.05rem 0.25rem;
    font-size: 0.9rem;
  }
  
  .slide-pattern-box .pt-term-opt {
    padding: 0.05rem 0.25rem;
    font-size: 0.9rem;
  }
}
/* ========================================
   SOURCE PREVIEW - PDF Page Gallery
   ======================================== */

.source-preview {
  background: linear-gradient(135deg, #fefce8 0%, #fef3c7 100%);
  border: 1px solid #fde047;
  border-radius: 12px;
  margin-bottom: 1.5rem;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(234, 179, 8, 0.15);
}

.source-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  background: linear-gradient(to right, rgba(253, 224, 71, 0.3), transparent);
}

.source-icon {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  border-radius: 10px;
  color: white;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(245, 158, 11, 0.3);
}

.source-info {
  flex: 1;
  min-width: 0;
}

.source-title {
  font-size: 1rem;
  font-weight: 700;
  color: #92400e;
  margin: 0 0 0.25rem 0;
}

.source-book {
  font-size: 0.95rem;
  font-weight: 600;
  color: #b45309;
  margin: 0;
  line-height: 1.4;
}

.source-pages {
  font-size: 0.85rem;
  color: #a16207;
  margin: 0.25rem 0 0 0;
  font-style: italic;
}

.source-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: #f59e0b;
  border: none;
  border-radius: 8px;
  color: white;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.source-toggle:hover {
  background: #d97706;
  transform: translateY(-1px);
}

.source-toggle[aria-expanded="true"] svg {
  transform: rotate(180deg);
}

.source-toggle svg {
  transition: transform 0.3s ease;
}

/* Source Gallery */
.source-gallery {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s ease, padding 0.3s ease;
}

.source-gallery:not(.collapsed) {
  max-height: 500px;
  padding: 1rem 1.25rem 1.25rem;
  border-top: 1px solid rgba(253, 224, 71, 0.5);
}

.source-thumbs {
  display: flex;
  gap: 0.75rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  scroll-snap-type: x mandatory;
  scrollbar-width: thin;
  scrollbar-color: #fbbf24 #fef3c7;
}

.source-thumbs::-webkit-scrollbar {
  height: 6px;
}

.source-thumbs::-webkit-scrollbar-track {
  background: #fef3c7;
  border-radius: 3px;
}

.source-thumbs::-webkit-scrollbar-thumb {
  background: #fbbf24;
  border-radius: 3px;
}

.source-thumb {
  flex: 0 0 auto;
  width: 140px;
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s ease;
  scroll-snap-align: start;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  border: 2px solid transparent;
}

.source-thumb:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
  border-color: #f59e0b;
}

.source-thumb img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  display: block;
  background: #fff;
}

.thumb-page {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 0.4rem 0.5rem;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.7), transparent);
  color: white;
  font-size: 0.75rem;
  font-weight: 600;
  text-align: center;
}

/* Source Lightbox */
.source-lightbox {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.source-lightbox.hidden {
  display: none;
}

.lightbox-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
}

.lightbox-container {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 95vw;
  max-height: 95vh;
  z-index: 1;
}

.lightbox-close {
  position: absolute;
  top: -40px;
  right: 0;
  width: 36px;
  height: 36px;
  border: none;
  background: rgba(255, 255, 255, 0.2);
  color: white;
  font-size: 24px;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-close:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.1);
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 50px;
  height: 50px;
  border: none;
  background: rgba(255, 255, 255, 0.2);
  color: white;
  font-size: 28px;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-prev {
  left: -60px;
}

.lightbox-next {
  right: -60px;
}

.lightbox-nav:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: translateY(-50%) scale(1.1);
}

.lightbox-content {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
}

.lightbox-content img {
  max-width: 100%;
  max-height: 85vh;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.lightbox-counter {
  position: absolute;
  bottom: -30px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.9rem;
  font-weight: 500;
}

/* Mobile responsive for source preview */
@media (max-width: 640px) {
  .source-header {
    flex-wrap: wrap;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
  }
  
  .source-icon {
    width: 38px;
    height: 38px;
  }
  
  .source-icon svg {
    width: 18px;
    height: 18px;
  }
  
  .source-title {
    font-size: 0.9rem;
  }
  
  .source-book {
    font-size: 0.85rem;
  }
  
  .source-pages {
    font-size: 0.8rem;
  }
  
  .source-toggle {
    width: 100%;
    justify-content: center;
    padding: 0.6rem 1rem;
  }
  
  .source-gallery:not(.collapsed) {
    padding: 0.875rem 1rem 1rem;
  }
  
  .source-thumb {
    width: 110px;
  }
  
  .source-thumb img {
    height: 150px;
  }
  
  .lightbox-nav {
    width: 40px;
    height: 40px;
    font-size: 24px;
  }
  
  .lightbox-prev {
    left: 10px;
  }
  
  .lightbox-next {
    right: 10px;
  }
  
  .lightbox-close {
    top: 10px;
    right: 10px;
  }
}

/* ==================== DARK THEME SUPPORT ==================== */
[data-theme="dark"] {
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --bg-light: #0f172a;
  --border-color: #334155;
}

/* Main container & app */
[data-theme="dark"] .grammar-container,
[data-theme="dark"] #grammar-app {
  background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
}

/* Header */
[data-theme="dark"] .grammar-header {
  background: linear-gradient(135deg, #1e1b4b 0%, #312e81 60%, #3730a3 100%);
  border-color: #4338ca;
}

/* Sidebar */
[data-theme="dark"] .grammar-sidebar {
  background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
  border-color: #334155;
}

[data-theme="dark"] .grammar-sidebar .grammar-nav {
  background: #1e293b;
  border-color: #334155;
}

[data-theme="dark"] .grammar-sidebar .grammar-nav h3 {
  color: #a5b4fc;
}

/* Main content */
[data-theme="dark"] .grammar-main {
  background: #1e293b;
  border-color: #334155;
}

/* Grammar detail */
[data-theme="dark"] .grammar-detail {
  background: #1e293b;
  color: #f1f5f9;
}

[data-theme="dark"] .grammar-detail h2,
[data-theme="dark"] .grammar-detail h3,
[data-theme="dark"] .grammar-detail h4 {
  color: #f1f5f9;
}

[data-theme="dark"] .grammar-detail p {
  color: #cbd5e1;
}

/* Pattern sections */
[data-theme="dark"] .pattern-section {
  background: #1e293b;
  border-color: #334155;
}

[data-theme="dark"] .pattern-header {
  background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
  border-color: #475569;
}

[data-theme="dark"] .pattern-header:hover {
  background: linear-gradient(135deg, #334155 0%, #475569 100%);
}

[data-theme="dark"] .pattern-text {
  color: #f1f5f9;
}

[data-theme="dark"] .chevron {
  border-color: #818cf8;
}

/* Pattern body open state */
[data-theme="dark"] .pattern-body {
  background: #0f172a;
}

[data-theme="dark"] .pattern-body.open {
  background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
  border-top-color: #4338ca;
}

[data-theme="dark"] .pattern-body.open .pattern-meaning,
[data-theme="dark"] .pattern-body.open .pattern-usage,
[data-theme="dark"] .pattern-body.open .pattern-notes {
  color: #e2e8f0;
}

[data-theme="dark"] .pattern-body.open h4 {
  color: #f1f5f9;
}

[data-theme="dark"] .pattern-body.open .examples-list .example-item {
  background: #0f172a;
  border-color: #334155;
}

[data-theme="dark"] .pattern-body.open .examples-list .ex-zh {
  color: #f1f5f9;
}

[data-theme="dark"] .pattern-body.open .examples-list .ex-vi {
  color: #94a3b8;
}

[data-theme="dark"] .pattern-meaning {
  color: #e2e8f0;
}

[data-theme="dark"] .pattern-usage {
  color: #94a3b8;
}

[data-theme="dark"] .pattern-notes p {
  color: #94a3b8;
}

/* Usage subsections */
[data-theme="dark"] .pattern-usage .usage-subsection {
  background: linear-gradient(135deg, #1e293b, #0f172a);
  border-left-color: #6366f1;
}

[data-theme="dark"] .pattern-usage .subsection-num {
  color: #818cf8;
}

/* Forms and inputs */
[data-theme="dark"] .form-control {
  background: #0f172a;
  border-color: #334155;
  color: #f1f5f9;
}

[data-theme="dark"] .form-control:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

[data-theme="dark"] .filter-btn {
  background: #1e293b;
  border-color: #334155;
  color: #94a3b8;
}

[data-theme="dark"] .filter-btn:hover,
[data-theme="dark"] .filter-btn.active {
  background: #6366f1;
  border-color: #6366f1;
  color: #fff;
}

/* Cards */
[data-theme="dark"] .grammar-card,
[data-theme="dark"] .topic-card {
  background: #1e293b;
  border-color: #334155;
}

[data-theme="dark"] .grammar-card:hover,
[data-theme="dark"] .topic-card:hover {
  border-color: #6366f1;
  box-shadow: 0 10px 25px rgba(99, 102, 241, 0.2);
}

[data-theme="dark"] .card-title {
  color: #f1f5f9;
}

[data-theme="dark"] .card-description {
  color: #94a3b8;
}

/* Examples */
[data-theme="dark"] .example-item {
  background: #0f172a;
  border-color: #334155;
}

[data-theme="dark"] .ex-zh {
  color: #f1f5f9;
}

[data-theme="dark"] .ex-py {
  color: #a5b4fc;
}

[data-theme="dark"] .ex-vi {
  color: #94a3b8;
}

/* Search & level selector */
[data-theme="dark"] .search-input,
[data-theme="dark"] .level-selector {
  background: #0f172a;
  border-color: #334155;
  color: #f1f5f9;
}

/* Source preview */
[data-theme="dark"] .source-preview {
  background: #1e293b;
  border-color: #334155;
}

[data-theme="dark"] .source-header {
  background: linear-gradient(135deg, #312e81 0%, #3730a3 100%);
}

[data-theme="dark"] .source-gallery {
  background: #0f172a;
}

[data-theme="dark"] .source-thumb {
  background: #1e293b;
  border-color: #334155;
}

/* Buttons */
[data-theme="dark"] .btn-primary {
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
}

[data-theme="dark"] .btn-secondary {
  background: #334155;
  color: #f1f5f9;
  border-color: #475569;
}

[data-theme="dark"] .btn-secondary:hover {
  background: #475569;
}

/* Navigation */
[data-theme="dark"] .grammar-nav-link {
  color: #94a3b8;
}

[data-theme="dark"] .grammar-nav-link:hover,
[data-theme="dark"] .grammar-nav-link.active {
  color: #818cf8;
  background: rgba(99, 102, 241, 0.1);
}

/* Toast */
[data-theme="dark"] .toast {
  background: #1e293b;
  border-color: #334155;
  color: #f1f5f9;
}

/* Loading */
[data-theme="dark"] .loading-overlay {
  background: rgba(15, 23, 42, 0.9);
}

/* Scrollbar */
[data-theme="dark"] ::-webkit-scrollbar-track {
  background: #0f172a;
}

[data-theme="dark"] ::-webkit-scrollbar-thumb {
  background: #334155;
}

[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
  background: #475569;
}

/* ==================== SLIDESHOW DARK THEME ==================== */
/* Slide content */
[data-theme="dark"] .slide-content {
  background: rgba(30, 41, 59, 0.98);
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}

[data-theme="dark"] .slide-header {
  border-bottom-color: #334155;
}

/* Slide badge */
[data-theme="dark"] .slide-badge {
  background: #334155;
  color: #e2e8f0;
}

[data-theme="dark"] .slide-badge.badge-default {
  background: linear-gradient(135deg, #4338ca 0%, #6366f1 100%);
  color: #fff;
}

/* Pattern box */
[data-theme="dark"] .slide-pattern-box {
  background: #0f172a;
  border-color: #334155;
}

[data-theme="dark"] .slide-pattern-title {
  color: #f1f5f9;
}

[data-theme="dark"] .pt-text {
  color: #f1f5f9;
}

[data-theme="dark"] .pt-op {
  color: #94a3b8;
}

[data-theme="dark"] .pt-paren {
  color: #64748b;
}

[data-theme="dark"] .pt-particle {
  color: #fbbf24;
}

[data-theme="dark"] .pt-term {
  color: #a5b4fc;
}

/* Slide body & lines */
[data-theme="dark"] .slide-body {
  color: #e2e8f0;
}

[data-theme="dark"] .slide-line {
  color: #e2e8f0;
  border-bottom-color: rgba(255,255,255,0.05);
}

[data-theme="dark"] .slide-line.meaning {
  color: #93c5fd;
}

[data-theme="dark"] .slide-line .line-label {
  color: #818cf8;
}

[data-theme="dark"] .slide-line.section-title {
  color: #f1f5f9;
}

[data-theme="dark"] .slide-line .ex-num {
  color: #818cf8;
}

[data-theme="dark"] .slide-line .ex-zh {
  color: #f1f5f9;
}

[data-theme="dark"] .slide-line .ex-vi {
  color: #4ade80;
}

[data-theme="dark"] .slide-line.usage-formatted {
  background: #0f172a;
  border-left-color: #6366f1;
  color: #cbd5e1;
}

[data-theme="dark"] .slide-line.notes {
  background: rgba(245, 158, 11, 0.1);
  border-left-color: #f59e0b;
  color: #fcd34d;
}

/* Slide continuation */
[data-theme="dark"] .slide-continuation {
  color: #64748b;
  border-top-color: #334155;
}

/* Slideshow controls */
[data-theme="dark"] .slide-nav {
  border-color: rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.05);
}

[data-theme="dark"] .slide-nav:hover {
  background: rgba(255,255,255,0.15);
  border-color: rgba(255,255,255,0.4);
}

/* Slideshow container */
[data-theme="dark"] .slideshow-container {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
}

[data-theme="dark"] .slideshow-header {
  background: rgba(15, 23, 42, 0.9);
  border-bottom-color: #334155;
}

[data-theme="dark"] .slideshow-title {
  color: #f1f5f9;
}

[data-theme="dark"] .slide-indicator {
  color: #94a3b8;
}

[data-theme="dark"] .slideshow-close {
  color: #94a3b8;
}

[data-theme="dark"] .slideshow-close:hover {
  color: #f1f5f9;
  background: rgba(255,255,255,0.1);
}
/* ═══════════════════════════════════════════════════════════════════════════
   MEMORY TIPS - Mẹo ghi nhớ (Collapsible Slide/Carousel)
   ═══════════════════════════════════════════════════════════════════════════ */

.memory-tips-section {
  margin: 1.5rem 0;
  padding: 0;
}

/* Toggle Button - Always Visible */
.memory-tips-toggle-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border: 2px solid #f59e0b;
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-family: inherit;
}

.memory-tips-toggle-btn:hover {
  background: linear-gradient(135deg, #fde68a 0%, #fcd34d 100%);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

.memory-tips-toggle-btn .toggle-icon {
  font-size: 1.5rem;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

.memory-tips-toggle-btn .toggle-text {
  flex: 1;
  text-align: left;
  font-size: 1.1rem;
  font-weight: 700;
  color: #92400e;
}

.memory-tips-toggle-btn .toggle-text small {
  font-weight: 500;
  opacity: 0.8;
}

.memory-tips-toggle-btn .toggle-chevron {
  color: #92400e;
  transition: transform 0.3s ease;
}

.memory-tips-section:not(.collapsed) .toggle-chevron {
  transform: rotate(180deg);
}

/* Content - Hidden when collapsed */
.memory-tips-content {
  overflow: hidden;
  transition: max-height 0.4s ease, opacity 0.3s ease, margin 0.3s ease;
  opacity: 1;
  margin-top: 1rem;
}

.memory-tips-section.collapsed .memory-tips-content {
  max-height: 0;
  opacity: 0;
  margin-top: 0;
}

/* Grid Layout for Tips - Single card per page (slide mode) */
.tips-grid {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* Individual Tip Card - Full width slide */
.tip-card {
  background: #fff;
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  border-top: 4px solid var(--tip-color, #667eea);
  transition: all 0.3s ease;
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
}

.tip-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

/* Card Header */
.tip-card-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px dashed var(--border-color);
}

.tip-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  background: linear-gradient(135deg, var(--tip-color, #667eea), color-mix(in srgb, var(--tip-color, #667eea) 80%, #000));
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.tip-title-wrap {
  flex: 1;
}

.tip-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 2px 0;
}

.tip-title-cn {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
}

/* Card Body */
.tip-card-body {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

/* Content Sections */
.tip-section {
  padding: 0.75rem 1rem;
  background: #f8fafc;
  border-radius: 12px;
  border-left: 4px solid var(--tip-color, #667eea);
}

.tip-section-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--tip-color, #667eea);
  margin-bottom: 0.5rem;
}

.tip-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.tip-list li {
  position: relative;
  padding: 0.3rem 0 0.3rem 1.25rem;
  font-size: 0.9rem;
  color: var(--text-primary);
  line-height: 1.5;
}

.tip-list li::before {
  content: '✦';
  position: absolute;
  left: 0;
  color: var(--tip-color, #667eea);
  font-size: 0.6rem;
  top: 0.5rem;
}

/* Example Bubbles */
.tip-examples {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.tip-example {
  padding: 0.5rem 0.75rem;
  background: #fff;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

/* Page Navigation for Tips */
.tips-page-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
}

.tips-page-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  border: 2px solid var(--primary-color);
  background: #fff;
  color: var(--primary-color);
  font-weight: 600;
  font-size: 0.9rem;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
}

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

.tips-page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.tips-page-info {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.tips-page-info .tips-page-current {
  color: var(--primary-color);
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .tips-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  
  .tip-card {
    padding: 1rem;
  }
  
  .tip-icon {
    width: 42px;
    height: 42px;
    font-size: 1.25rem;
  }
  
  .tip-title {
    font-size: 1.05rem;
  }
  
  .tips-page-nav {
    gap: 0.5rem;
  }
  
  .tips-page-btn {
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
  }
}
    height: 32px;
  }
}

/* Dark Mode */
[data-theme="dark"] .tip-slide {
  background: #1e293b;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .tip-slide-header {
  border-bottom-color: #334155;
}

[data-theme="dark"] .tip-title {
  color: #f1f5f9;
}

[data-theme="dark"] .tip-card {
  background: #1e293b;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .tip-card-header {
  border-color: #475569;
}

[data-theme="dark"] .tip-title {
  color: #f1f5f9;
}

[data-theme="dark"] .tip-section {
  background: #0f172a;
}

[data-theme="dark"] .tip-list li {
  color: #e2e8f0;
}

[data-theme="dark"] .tip-example {
  background: #334155;
  border-color: #475569;
  color: #f1f5f9;
}

[data-theme="dark"] .tips-page-btn {
  background: #334155;
  border-color: var(--primary-color);
  color: #94a3b8;
}

[data-theme="dark"] .tips-page-btn:hover:not(:disabled) {
  background: var(--primary-color);
  color: #fff;
}

[data-theme="dark"] .tips-page-info {
  color: #94a3b8;
}

[data-theme="dark"] .memory-tips-toggle-btn {
  background: linear-gradient(135deg, #78350f 0%, #92400e 100%);
  border-color: #b45309;
}

[data-theme="dark"] .memory-tips-toggle-btn .toggle-text {
  color: #fef3c7;
}

[data-theme="dark"] .memory-tips-toggle-btn .toggle-chevron {
  color: #fde68a;
}

[data-theme="dark"] .memory-tips-toggle-btn:hover {
  background: linear-gradient(135deg, #92400e 0%, #b45309 100%);
}

/* ═══════════════════════════════════════════════════════════════════════════
   SUB-PATTERNS - Pattern con
   ═══════════════════════════════════════════════════════════════════════════ */

.sub-patterns-wrap {
  margin-top: 1rem;
  padding: 1rem;
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border-radius: 12px;
  border: 1px dashed #f59e0b;
}

.sub-patterns-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: #92400e;
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sub-patterns-title::before {
  content: '📌';
}

.sub-pattern-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.sub-pattern-item {
  background: #fff;
  border-radius: 10px;
  padding: 0.75rem 1rem;
  border-left: 3px solid #f59e0b;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.sub-pattern-name {
  font-size: 0.85rem;
  font-weight: 700;
  color: #92400e;
  margin-bottom: 0.25rem;
}

.sub-pattern-formula {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  font-family: 'Noto Sans SC', 'PingFang SC', sans-serif;
  margin-bottom: 0.5rem;
  padding: 0.4rem 0.6rem;
  background: #fef3c7;
  border-radius: 6px;
  display: inline-block;
}

.sub-pattern-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 0.5rem;
}

.sub-pattern-desc-line {
  display: block;
  padding: 0.15rem 0;
}

.sub-pattern-examples {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.sub-pattern-ex {
  padding: 0.3rem 0.6rem;
  background: #ecfdf5;
  color: #065f46;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 500;
}

/* Dark Mode Sub-patterns */
[data-theme="dark"] .sub-patterns-wrap {
  background: linear-gradient(135deg, #422006 0%, #713f12 100%);
  border-color: #a16207;
}

[data-theme="dark"] .sub-patterns-title {
  color: #fef3c7;
}

[data-theme="dark"] .sub-pattern-item {
  background: #1e293b;
  border-left-color: #f59e0b;
}

[data-theme="dark"] .sub-pattern-name {
  color: #fde68a;
}

[data-theme="dark"] .sub-pattern-formula {
  background: #422006;
  color: #fef3c7;
}

[data-theme="dark"] .sub-pattern-desc {
  color: #94a3b8;
}

[data-theme="dark"] .sub-pattern-ex {
  background: #064e3b;
  color: #6ee7b7;
}