@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Lora:ital,wght@0,400;0,500;0,600;0,700;1,400;1,600&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  --bg-main: #ffffff;
  --bg-subtle: #faf9f6;
  --bg-card: #f8f8f7;
  --bg-dark: #1a1a2e;
  --text-main: #1f1f1f;
  --text-muted: #4a4a4a;
  --text-light: #6e6e6e;
  --border-color: #e5e5e5;
  --border-dark: #cccccc;
  --accent-burgundy: #9e2a2b;
  --accent-burgundy-hover: #7a1f20;
  --accent-burgundy-glow: rgba(158, 42, 43, 0.15);
  --accent-light: #fdf5f5;
  --accent-gold: #c49b2a;
  --code-bg: #1e1e24;
  --code-text: #e6edf3;
  --font-editorial: 'Lora', Georgia, serif;
  --font-ui: 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', Consolas, monospace;
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.04);
  --shadow-md: 0 6px 20px rgba(0,0,0,0.06);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.08);
  --shadow-hover: 0 12px 28px rgba(158, 42, 43, 0.1);
  --shadow-glow: 0 0 20px rgba(158, 42, 43, 0.08);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --content-max-width: 1180px;
  --transition-smooth: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 1. Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-ui);
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::selection {
  background-color: var(--accent-burgundy);
  color: white;
}

/* 2. Reading Progress Bar */
.reading-progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  background: linear-gradient(to right, var(--accent-burgundy), var(--accent-gold));
  z-index: 9999;
  width: 0%;
  transition: width 0.08s linear;
}

/* 3. Top Stripe */
.top-stripe {
  height: 4px;
  background: linear-gradient(to right, var(--accent-burgundy), var(--accent-gold), var(--accent-burgundy));
  width: 100%;
}

/* 4. Sticky Header & Navigation */
.header-wrapper {
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  background-color: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--border-color);
}

.site-header {
  max-width: var(--content-max-width);
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
}

.brand-title {
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 1.35rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: var(--text-main);
}

.brand-badge {
  background-color: var(--accent-burgundy);
  color: white;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.2rem 0.5rem;
  border-radius: 3px;
}

.nav-menu {
  display: flex;
  gap: 1.5rem;
  list-style: none;
}

.nav-link {
  font-family: var(--font-ui);
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--text-muted);
  text-decoration: none;
  position: relative;
  padding: 0.3rem 0;
  transition: color var(--transition-smooth);
}

.nav-link:hover,
.nav-link.active {
  color: var(--accent-burgundy);
}

.nav-link.active::after {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 0;
  width: 100%;
  height: 2px;
  background-color: var(--accent-burgundy);
  border-radius: 1px;
}

.mobile-menu-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  z-index: 300;
}

.mobile-menu-toggle span {
  display: block;
  width: 28px;
  height: 2px;
  background-color: var(--text-main);
  margin-bottom: 5px;
  transition: transform var(--transition-smooth), opacity var(--transition-smooth);
}

.mobile-menu-toggle span:last-child {
  margin-bottom: 0;
}

.mobile-menu-toggle.active span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.mobile-menu-toggle.active span:nth-child(2) {
  opacity: 0;
}

.mobile-menu-toggle.active span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* 5. Page Container & Layout Grid */
.page-container {
  max-width: var(--content-max-width);
  margin: 3rem auto;
  padding: 0 1.5rem;
}

.layout-grid {
  display: grid;
  grid-template-columns: 2.25fr 0.75fr;
  gap: 3.5rem;
  align-items: start;
}

/* 6. Article Header & Typography */
.article-header {
  margin-bottom: 2.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-color);
}

.article-meta {
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-burgundy);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.article-meta::after {
  content: '';
  flex-grow: 1;
  height: 1px;
  background-color: var(--border-color);
}

.reading-badge {
  font-family: var(--font-ui);
  font-weight: 500;
  font-size: 0.75rem;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 0.15rem 0.55rem;
  border-radius: 12px;
  color: var(--text-light);
  text-transform: none;
  letter-spacing: normal;
}

.article-title {
  font-family: var(--font-editorial);
  font-weight: 700;
  font-size: 2.5rem;
  line-height: 1.22;
  color: var(--text-main);
  margin-bottom: 0.85rem;
  letter-spacing: -0.02em;
}

.article-subtitle {
  font-family: var(--font-editorial);
  font-style: italic;
  font-size: 1.2rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.lead-paragraph {
  font-size: 1.18rem;
  line-height: 1.85;
  color: #111;
  margin-bottom: 1.75rem;
}

.lead-paragraph::first-letter {
  font-family: var(--font-editorial);
  font-weight: 700;
  font-size: 3.5rem;
  float: left;
  line-height: 0.75;
  margin-right: 0.65rem;
  margin-top: 0.15rem;
  color: var(--accent-burgundy);
}

.article-body p {
  margin-bottom: 1.5rem;
  font-size: 1.05rem;
  color: var(--text-main);
  line-height: 1.7;
}

.article-body h2 {
  font-family: var(--font-editorial);
  font-weight: 700;
  font-size: 1.65rem;
  color: var(--text-main);
  margin: 3rem 0 1.1rem 0;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-color);
  position: relative;
}

.article-body h3 {
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--accent-burgundy);
  margin: 2rem 0 0.85rem 0;
}

/* 7. Scroll Reveal Animation */
.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

/* 8. Animated Stats Counter Bar */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.5rem;
  margin: 3rem 0;
  padding: 2rem 0;
  border-top: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
}

.stat-item {
  text-align: center;
}

.stat-number {
  font-family: var(--font-ui);
  font-weight: 800;
  font-size: 2.5rem;
  color: var(--accent-burgundy);
  line-height: 1;
  margin-bottom: 0.35rem;
  display: block;
}

.stat-label {
  font-family: var(--font-ui);
  font-weight: 500;
  font-size: 0.825rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* 9. Code Blocks */
.code-block-wrapper {
  margin: 2rem 0;
  background-color: var(--code-bg);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.code-header {
  background-color: #141419;
  padding: 0.6rem 1.15rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-ui);
  font-size: 0.75rem;
  color: #8b949e;
  border-bottom: 1px solid #2d2d35;
}

.code-lang {
  font-weight: 700;
  color: var(--accent-burgundy);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.code-block {
  padding: 1.25rem;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  line-height: 1.65;
  color: var(--code-text);
  overflow-x: auto;
  white-space: pre;
}

.code-keyword { color: #ff7b72; font-weight: 600; }
.code-func { color: #d2a8ff; }
.code-string { color: #a5d6ff; }
.code-comment { color: #8b949e; font-style: italic; }
.code-num { color: #79c0ff; }

/* 10. Academic Blockquote */
.academic-blockquote {
  margin: 2.5rem 0;
  padding: 1.75rem 2rem;
  background-color: var(--bg-subtle);
  border-left: 4px solid var(--accent-burgundy);
  font-style: italic;
  font-size: 1.08rem;
  color: var(--text-muted);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  position: relative;
}

.academic-blockquote::before {
  content: open-quote;
  position: absolute;
  top: -0.15rem;
  left: 0.75rem;
  font-size: 3.5rem;
  color: var(--accent-burgundy);
  opacity: 0.15;
  font-family: var(--font-editorial);
}

.academic-blockquote cite {
  display: block;
  font-family: var(--font-ui);
  font-style: normal;
  font-size: 0.85rem;
  font-weight: 700;
  margin-top: 0.85rem;
  color: var(--text-main);
}

/* 11. Concept Box */
.concept-box {
  background-color: var(--accent-light);
  border: 1px solid rgba(158, 42, 43, 0.2);
  border-radius: var(--radius-md);
  padding: 1.75rem;
  margin: 2.5rem 0;
  position: relative;
  overflow: hidden;
}

.concept-box::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background-color: var(--accent-burgundy);
}

.concept-title {
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent-burgundy);
  margin-bottom: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.concept-list {
  padding-left: 1.25rem;
  color: var(--text-main);
}

.concept-list li {
  margin-bottom: 0.65rem;
  font-size: 0.975rem;
  line-height: 1.65;
}

/* 12. Tiers Section & Grid */
.tiers-section {
  margin-top: 4.5rem;
  padding-top: 2.5rem;
  border-top: 2px solid var(--text-main);
}

.section-label {
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent-burgundy);
  margin-bottom: 1.75rem;
}

.tiers-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
}

.tier-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.75rem;
  transition: all var(--transition-smooth);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}

.tier-card::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background-color: transparent;
  transition: background-color var(--transition-smooth);
}

.tier-card:hover {
  border-color: var(--accent-burgundy);
  transform: translateY(-4px);
  box-shadow: var(--shadow-hover);
}

.tier-card:hover::after {
  background-color: var(--accent-burgundy);
}

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

.tier-tag {
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 0.75rem;
  padding: 0.2rem 0.55rem;
  border-radius: 3px;
  background-color: #eee;
  color: var(--text-muted);
}

.tier-tag.active-track {
  background-color: var(--accent-burgundy);
  color: white;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(158, 42, 43, 0.3); }
  70% { box-shadow: 0 0 0 6px rgba(158, 42, 43, 0); }
  100% { box-shadow: 0 0 0 0 rgba(158, 42, 43, 0); }
}

.tier-title {
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text-main);
  margin-bottom: 0.35rem;
}

.tier-session {
  font-family: var(--font-ui);
  font-size: 0.85rem;
  color: var(--text-light);
  margin-bottom: 1rem;
}

.tier-desc {
  font-size: 0.925rem;
  color: var(--text-muted);
  line-height: 1.65;
  margin-bottom: 1.35rem;
  flex-grow: 1;
}

.tier-btn {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 0.875rem;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: all var(--transition-smooth);
  border: 1px solid var(--accent-burgundy);
  color: var(--accent-burgundy);
  background-color: transparent;
  width: 100%;
  position: relative;
  overflow: hidden;
}

.tier-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background-color: var(--accent-burgundy);
  transition: left var(--transition-smooth);
  z-index: 0;
}

.tier-btn:hover::before {
  left: 0;
}

.tier-btn:hover {
  color: white;
}

.tier-btn span {
  position: relative;
  z-index: 1;
}

/* 13. Sidebar */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 2rem;
  position: sticky;
  top: 6rem;
}

.sidebar-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.75rem;
  transition: shadow var(--transition-smooth);
}

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

.sidebar-title {
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-main);
  margin-bottom: 1.25rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--accent-burgundy);
}

.profile-widget {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.avatar-circle {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background-color: var(--accent-burgundy);
  color: white;
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 1.3rem;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-shrink: 0;
  border: 3px solid white;
  box-shadow: 0 0 0 2px var(--accent-burgundy);
  transition: transform var(--transition-smooth);
}

.avatar-circle:hover {
  transform: scale(1.08);
}

.profile-info h4 {
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text-main);
}

.profile-info p {
  font-family: var(--font-ui);
  font-size: 0.825rem;
  color: var(--text-muted);
}

.profile-bio {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 1.25rem;
}

.sidebar-links {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.sidebar-links a {
  font-family: var(--font-ui);
  font-weight: 500;
  font-size: 0.875rem;
  color: var(--accent-burgundy);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: padding-left var(--transition-smooth);
}

.sidebar-links a:hover {
  text-decoration: underline;
  padding-left: 0.25rem;
}

.notice-box {
  background-color: var(--bg-subtle);
  border: 1px dashed var(--border-dark);
  border-radius: var(--radius-sm);
  padding: 1.15rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.6;
}

/* 14. Search Wrapper */
.search-wrapper {
  margin: 1.75rem 0;
}

.search-input-box {
  width: 100%;
  padding: 0.9rem 1.25rem 0.9rem 2.75rem;
  font-family: var(--font-ui);
  font-size: 0.95rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background-color: var(--bg-card);
  color: var(--text-main);
  transition: all var(--transition-smooth);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%234a4a4a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'%3E%3C/line%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 1rem center;
}

.search-input-box:focus {
  outline: none;
  border-color: var(--accent-burgundy);
  background-color: white;
  box-shadow: 0 0 0 4px var(--accent-burgundy-glow);
}

/* 15. Tab Selector & Content */
.tab-selector-wrapper {
  margin: 1.5rem 0;
}

.tab-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.5rem;
  background-color: var(--bg-card);
  padding: 0.5rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

.tab-btn {
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 0.875rem;
  padding: 0.8rem 0.5rem;
  background-color: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-smooth);
  text-align: center;
  position: relative;
}

.tab-btn:hover {
  color: var(--accent-burgundy);
  background-color: rgba(158, 42, 43, 0.06);
}

.tab-btn.active {
  background-color: var(--accent-burgundy);
  color: white;
  box-shadow: var(--shadow-sm);
  transform: scale(1.02);
}

.tab-content-container {
  background-color: white;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 2.5rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 3.5rem;
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
  animation: fadeSlideIn 0.35s ease;
}

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

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

.subject-code {
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--accent-burgundy);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.subject-title {
  font-family: var(--font-editorial);
  font-weight: 700;
  font-size: 1.85rem;
  color: var(--text-main);
  margin-top: 0.25rem;
}

.resource-group {
  margin-bottom: 2.25rem;
}

.resource-group-title {
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text-main);
  margin-bottom: 1.15rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.resource-group-title::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  background-color: var(--accent-burgundy);
  border-radius: 50%;
}

/* 16. Download Cards */
.download-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 1.15rem;
}

.download-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 1.3rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  transition: all var(--transition-smooth);
  position: relative;
  overflow: hidden;
}

.download-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 100%;
  background-color: var(--accent-light);
  transition: width var(--transition-smooth);
  z-index: 0;
}

.download-card:hover::before {
  width: 100%;
}

.download-card:hover {
  border-color: var(--accent-burgundy);
  box-shadow: var(--shadow-sm);
}

.download-card > * {
  position: relative;
  z-index: 1;
}

.download-info {
  display: flex;
  flex-direction: column;
}

.download-title {
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 0.925rem;
  color: var(--text-main);
  margin-bottom: 0.3rem;
}

.download-meta {
  font-family: var(--font-ui);
  font-size: 0.775rem;
  color: var(--text-light);
}

.dl-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 0.8rem;
  padding: 0.6rem 1rem;
  background-color: var(--accent-burgundy);
  color: white;
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: all var(--transition-smooth);
  white-space: nowrap;
  flex-shrink: 0;
}

.dl-btn:hover {
  background-color: var(--accent-burgundy-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

/* 17. Master Textbook Area */
.master-textbook-area {
  margin-top: 5rem;
  padding-top: 3rem;
  border-top: 2px solid var(--border-color);
}

.master-textbook-header {
  margin-bottom: 3rem;
}

.master-textbook-header h2 {
  font-family: var(--font-editorial);
  font-weight: 700;
  font-size: 2.15rem;
  color: var(--text-main);
  margin-bottom: 0.5rem;
}

.master-textbook-header p {
  font-family: var(--font-editorial);
  font-style: italic;
  font-size: 1.15rem;
  color: var(--text-muted);
}

.subject-textbook-article {
  margin-bottom: 4rem;
  padding-bottom: 3rem;
  border-bottom: 1px dashed var(--border-dark);
}

.subject-textbook-article:last-child {
  border-bottom: none;
}

/* 18. Back-to-Top Button */
.back-to-top {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background-color: var(--accent-burgundy);
  color: white;
  border: none;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 1.25rem;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-smooth);
  z-index: 90;
}

.back-to-top.visible {
  opacity: 1;
  visibility: visible;
}

.back-to-top:hover {
  background-color: var(--accent-burgundy-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

/* 19. Footer */
.site-footer {
  border-top: 1px solid var(--border-color);
  background-color: var(--bg-card);
  padding: 4rem 1.5rem 2rem;
  margin-top: 6rem;
  font-family: var(--font-ui);
  font-size: 0.875rem;
  color: var(--text-muted);
}

.footer-inner {
  max-width: var(--content-max-width);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 2.5rem;
  margin-bottom: 3rem;
}

.footer-col h4 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 1.15rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.footer-col p {
  line-height: 1.65;
  margin-bottom: 0.85rem;
  font-size: 0.875rem;
}

.footer-links {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.footer-links a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--transition-smooth);
}

.footer-links a:hover {
  color: var(--accent-burgundy);
}

.footer-bottom {
  max-width: var(--content-max-width);
  margin: 0 auto;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: var(--text-light);
}

/* 21. Back Navigation */
.back-nav {
  margin-bottom: 1.75rem;
}

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--accent-burgundy);
  text-decoration: none;
  padding: 0.45rem 0.9rem;
  border-radius: var(--radius-sm);
  background-color: var(--accent-light);
  transition: all var(--transition-smooth);
}

.back-btn:hover {
  background-color: #f0dada;
  transform: translateX(-3px);
}

/* 20. Responsive Breakpoints */
/* ========================================
   RESPONSIVE DESIGN — TABLET (max-width: 960px)
   ======================================== */
@media (max-width: 960px) {
  .layout-grid {
    grid-template-columns: 1fr;
    gap: 2.5rem;
  }

  .sidebar {
    position: static;
  }

  .tiers-grid {
    grid-template-columns: 1fr;
  }

  .tab-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .footer-inner {
    grid-template-columns: 1fr 1fr;
  }

  .stats-bar {
    grid-template-columns: repeat(2, 1fr);
    gap: 1.25rem;
  }

  .page-container {
    margin: 2rem auto;
    padding: 0 1.25rem;
  }

  .article-title {
    font-size: 2.2rem;
  }

  .article-body h2 {
    font-size: 1.45rem;
    margin: 2.5rem 0 1rem 0;
  }

  .code-block-wrapper {
    margin: 1.5rem -0.5rem;
    border-radius: var(--radius-sm);
  }

  .code-block {
    font-size: 0.8rem;
    padding: 1rem;
  }
}

/* ========================================
   RESPONSIVE DESIGN — MOBILE (max-width: 768px)
   ======================================== */
@media (max-width: 768px) {
  /* --- Header & Navigation --- */
  .site-header {
    flex-direction: row;
    justify-content: space-between;
    padding: 0.75rem 1rem;
  }

  .brand-title {
    font-size: 1.15rem;
  }

  .brand-badge {
    font-size: 0.55rem;
    padding: 0.15rem 0.4rem;
  }

  .nav-menu {
    position: fixed;
    top: 0;
    right: -100%;
    width: 280px;
    height: 100vh;
    height: 100dvh;
    background-color: white;
    flex-direction: column;
    padding: 5rem 2rem 2rem;
    gap: 1.5rem;
    box-shadow: -8px 0 30px rgba(0,0,0,0.1);
    transition: right var(--transition-smooth);
    z-index: 200;
    overflow-y: auto;
  }

  .nav-menu.open {
    right: 0;
  }

  .nav-link {
    font-size: 1rem;
    padding: 0.5rem 0;
  }

  .mobile-menu-toggle {
    display: flex;
    flex-direction: column;
    gap: 5px;
    cursor: pointer;
    z-index: 300;
    background: none;
    border: none;
    padding: 0.5rem;
  }

  .mobile-menu-toggle span {
    width: 24px;
    height: 2px;
    background-color: var(--text-main);
    transition: all var(--transition-smooth);
    display: block;
  }

  .nav-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0,0,0,0.4);
    z-index: 150;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-smooth);
  }

  .nav-overlay.open {
    opacity: 1;
    visibility: visible;
  }

  /* --- Page Container & Spacing --- */
  .page-container {
    margin: 1.5rem auto;
    padding: 0 1rem;
  }

  /* --- Article Typography --- */
  .article-header {
    margin-bottom: 1.75rem;
    padding-bottom: 1rem;
  }

  .article-meta {
    font-size: 0.7rem;
    gap: 0.5rem;
    flex-wrap: wrap;
  }

  .article-title {
    font-size: 1.75rem;
    line-height: 1.25;
    letter-spacing: -0.01em;
  }

  .article-subtitle {
    font-size: 1rem;
    line-height: 1.45;
  }

  .lead-paragraph {
    font-size: 1.05rem;
    line-height: 1.75;
  }

  .lead-paragraph::first-letter {
    font-size: 2.8rem;
    margin-right: 0.45rem;
  }

  .article-body p {
    font-size: 0.975rem;
    line-height: 1.7;
    text-align: left;
  }

  .article-body h2 {
    font-size: 1.35rem;
    margin: 2rem 0 0.85rem 0;
  }

  .article-body h3 {
    font-size: 1.1rem;
    margin: 1.5rem 0 0.75rem 0;
  }

  /* --- Stats Bar --- */
  .stats-bar {
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin: 2rem 0;
    padding: 1.5rem 0;
  }

  .stat-number {
    font-size: 2rem;
  }

  .stat-label {
    font-size: 0.75rem;
  }

  /* --- Code Blocks --- */
  .code-block-wrapper {
    margin: 1.5rem -1rem;
    border-radius: 0;
  }

  .code-header {
    padding: 0.5rem 1rem;
    font-size: 0.7rem;
  }

  .code-block {
    padding: 1rem;
    font-size: 0.78rem;
    line-height: 1.55;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* --- Concept Box --- */
  .concept-box {
    padding: 1.25rem 1rem 1.25rem 1.25rem;
    margin: 1.75rem 0;
  }

  .concept-title {
    font-size: 0.85rem;
  }

  .concept-list li {
    font-size: 0.925rem;
    margin-bottom: 0.55rem;
    line-height: 1.6;
  }

  /* --- Academic Blockquote --- */
  .academic-blockquote {
    padding: 1.25rem 1.25rem 1.25rem 1.5rem;
    font-size: 1rem;
    margin: 2rem 0;
  }

  .academic-blockquote::before {
    font-size: 2.5rem;
    left: 0.5rem;
    top: -0.1rem;
  }

  .academic-blockquote cite {
    font-size: 0.8rem;
  }

  /* --- Search Input --- */
  .search-wrapper {
    margin: 1.25rem 0;
  }

  .search-input-box {
    padding: 0.75rem 1rem 0.75rem 2.5rem;
    font-size: 0.9rem;
  }

  /* --- Tab Selector --- */
  .tab-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.35rem;
    padding: 0.35rem;
  }

  .tab-btn {
    font-size: 0.78rem;
    padding: 0.65rem 0.3rem;
  }

  .tab-content-container {
    padding: 1.5rem 1rem;
  }

  .subject-header {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
  }

  .subject-code {
    font-size: 0.7rem;
  }

  .subject-title {
    font-size: 1.45rem;
  }

  .resource-group-title {
    font-size: 0.95rem;
  }

  /* --- Download Cards --- */
  .download-cards-grid {
    grid-template-columns: 1fr;
    gap: 0.85rem;
  }

  .download-card {
    flex-direction: column;
    align-items: stretch;
    padding: 1rem;
    gap: 0.75rem;
  }

  .download-title {
    font-size: 0.875rem;
  }

  .download-meta {
    font-size: 0.725rem;
  }

  .dl-btn {
    justify-content: center;
    width: 100%;
    padding: 0.7rem 1rem;
    font-size: 0.8rem;
  }

  /* --- Tier Cards --- */
  .tiers-section {
    margin-top: 3rem;
    padding-top: 1.75rem;
  }

  .section-label {
    font-size: 0.8rem;
    margin-bottom: 1.25rem;
  }

  .tier-card {
    padding: 1.25rem;
  }

  .tier-title {
    font-size: 1.05rem;
  }

  .tier-session {
    font-size: 0.8rem;
  }

  .tier-desc {
    font-size: 0.875rem;
  }

  .tier-btn {
    font-size: 0.825rem;
    padding: 0.65rem 1rem;
  }

  /* --- Sidebar --- */
  .sidebar {
    gap: 1.5rem;
  }

  .sidebar-card {
    padding: 1.35rem;
  }

  .sidebar-title {
    font-size: 0.8rem;
    margin-bottom: 1rem;
  }

  .profile-widget {
    gap: 0.85rem;
    margin-bottom: 1rem;
  }

  .avatar-circle {
    width: 50px;
    height: 50px;
    font-size: 1.1rem;
  }

  .profile-info h4 {
    font-size: 0.95rem;
  }

  .profile-info p {
    font-size: 0.775rem;
  }

  .profile-bio {
    font-size: 0.85rem;
  }

  .sidebar-links a {
    font-size: 0.825rem;
  }

  .notice-box {
    font-size: 0.825rem;
    padding: 1rem;
  }

  /* --- Back Navigation --- */
  .back-nav {
    margin-bottom: 1.25rem;
  }

  .back-btn {
    font-size: 0.825rem;
    padding: 0.4rem 0.75rem;
  }

  /* --- Master Textbook Area --- */
  .master-textbook-area {
    margin-top: 3rem;
    padding-top: 2rem;
  }

  .master-textbook-header h2 {
    font-size: 1.65rem;
  }

  .master-textbook-header p {
    font-size: 1rem;
  }

  .subject-textbook-article h3 {
    font-size: 1.1rem;
  }

  .subject-textbook-article p {
    font-size: 0.95rem;
  }

  /* --- Footer --- */
  .site-footer {
    padding: 2.5rem 1rem 1.5rem;
    margin-top: 4rem;
  }

  .footer-inner {
    grid-template-columns: 1fr;
    gap: 1.75rem;
    margin-bottom: 2rem;
  }

  .footer-col h4 {
    font-size: 0.85rem;
    margin-bottom: 0.85rem;
  }

  .footer-col p {
    font-size: 0.825rem;
  }

  .footer-links a {
    font-size: 0.825rem;
  }

  .footer-bottom {
    flex-direction: column;
    gap: 0.5rem;
    text-align: center;
    font-size: 0.75rem;
  }

  /* --- Back to Top --- */
  .back-to-top {
    bottom: 1.5rem;
    right: 1.5rem;
    width: 42px;
    height: 42px;
    font-size: 1.1rem;
  }
}

/* ========================================
   RESPONSIVE DESIGN — SMALL PHONES (max-width: 480px)
   ======================================== */
@media (max-width: 480px) {
  .page-container {
    padding: 0 0.75rem;
    margin: 1rem auto;
  }

  .article-title {
    font-size: 1.5rem;
    line-height: 1.28;
  }

  .article-subtitle {
    font-size: 0.9rem;
  }

  .article-meta {
    font-size: 0.65rem;
  }

  .lead-paragraph {
    font-size: 0.975rem;
  }

  .lead-paragraph::first-letter {
    font-size: 2.4rem;
    margin-right: 0.35rem;
  }

  .article-body p {
    font-size: 0.925rem;
  }

  .article-body h2 {
    font-size: 1.2rem;
  }

  .article-body h3 {
    font-size: 1rem;
  }

  .stats-bar {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    padding: 1.25rem 0;
    margin: 1.5rem 0;
  }

  .stat-number {
    font-size: 1.65rem;
  }

  .stat-label {
    font-size: 0.675rem;
  }

  .code-block {
    font-size: 0.72rem;
    padding: 0.85rem;
  }

  .concept-box {
    padding: 1rem 0.85rem 1rem 1.1rem;
  }

  .concept-list li {
    font-size: 0.875rem;
  }

  .tab-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.25rem;
  }

  .tab-btn {
    font-size: 0.72rem;
    padding: 0.55rem 0.25rem;
  }

  .tab-content-container {
    padding: 1.15rem 0.85rem;
  }

  .subject-title {
    font-size: 1.25rem;
  }

  .tier-card {
    padding: 1rem;
  }

  .tier-title {
    font-size: 0.975rem;
  }

  .tier-desc {
    font-size: 0.825rem;
  }

  .tier-btn {
    font-size: 0.78rem;
    padding: 0.6rem 0.85rem;
  }

  .sidebar-card {
    padding: 1.15rem;
  }

  .avatar-circle {
    width: 44px;
    height: 44px;
    font-size: 1rem;
  }

  .academic-blockquote {
    padding: 1rem 1rem 1rem 1.25rem;
    font-size: 0.925rem;
  }

  .footer-col h4 {
    font-size: 0.8rem;
  }

  .back-to-top {
    bottom: 1rem;
    right: 1rem;
    width: 38px;
    height: 38px;
    font-size: 1rem;
  }

  .nav-menu {
    width: 240px;
    padding: 4.5rem 1.5rem 2rem;
  }
}

