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

/* ── Design Tokens ───────────────────────────────────────────────────────── */
:root {
  --primary:       #2f8bb0;
  --primary-light: #5bb5d5;
  --primary-dark:  #1f6a8a;
  --accent:        #b0c8d2;
  --warm:          #D97706;
  --warm-dark:     #B45309;
  --bg:            #F8FAFC;
  --surface:       #FFFFFF;
  --text:          #0F172A;
  --text-secondary:#475569;
  --text-muted:    #94A3B8;
  --border:        #E2E8F0;
  --shadow-sm:     0 1px 3px rgba(0,0,0,.07), 0 4px 12px rgba(0,0,0,.04);
  --shadow-md:     0 4px 8px rgba(0,0,0,.10), 0 12px 28px rgba(0,0,0,.07);
  --radius:        12px;
  --radius-lg:     16px;
}

/* ── Reset & Base ────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { text-decoration: none; }

/* ── Scrollbar ───────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: #f1f5f9; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ── Header ──────────────────────────────────────────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, .95);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  height: 64px;
  display: flex;
  align-items: center;
}
.site-header .inner {
  max-width: 1152px;
  margin: 0 auto;
  padding: 1rem 1.5rem;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.logo {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-weight: 800;
  font-size: 1.2rem;
  color: var(--primary);
  letter-spacing: -.02em;
}
.logo-img  { height: 38px; width: auto; display: block; }
.header-brand { display: flex; flex-direction: row; align-items: center; gap: 1.5rem; }

.header-author {
  font-size: .9375rem;
  font-weight: 600;
  color: var(--primary);
  letter-spacing: .02em;
  white-space: nowrap;
}

.nav-desktop { display: flex; align-items: center; gap: 1.75rem; }
.nav-link {
  font-size: .9375rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: color .15s;
  position: relative;
  white-space: nowrap;
}
.nav-link:hover, .nav-link.active { color: var(--primary); }
.nav-link.active::after {
  content: '';
  position: absolute;
  bottom: -4px; left: 0; right: 0;
  height: 2px;
  background: var(--primary);
  border-radius: 2px;
}

/* Dropdown */
.nav-dropdown { position: relative; }
.nav-dropdown-trigger {
  display: flex; align-items: center; gap: 4px;
  font-size: .9375rem; font-weight: 500; color: var(--text-secondary);
  background: none; border: none; cursor: pointer;
  padding: 0; transition: color .15s;
}
.nav-dropdown-trigger:hover { color: var(--primary); }
.nav-dropdown-panel {
  position: absolute; top: calc(100% + 8px); left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: .5rem;
  min-width: 200px;
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity .15s, transform .15s;
  transform: translateX(-50%) translateY(-4px);
}
.nav-dropdown-panel::before {
  content: '';
  position: absolute;
  top: -16px;
  left: -8px; right: -8px;
  height: 16px;
}
.nav-dropdown:hover .nav-dropdown-panel {
  opacity: 1; visibility: visible; pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}
.nav-dropdown-item {
  display: block; padding: .5rem .875rem;
  border-radius: 8px; font-size: .875rem; font-weight: 500;
  color: var(--text-secondary); transition: all .12s;
}
.nav-dropdown-item:hover { background: #e8f4f8; color: var(--primary); }

.btn-nav {
  padding: .5rem 1.125rem;
  background: var(--warm);
  color: #fff;
  border-radius: 8px;
  font-size: .875rem;
  font-weight: 600;
  transition: background .15s, transform .1s;
  white-space: nowrap;
}
.btn-nav:hover { background: var(--warm-dark); }

/* Mobile menu button */
.btn-hamburger {
  display: none;
  padding: .5rem; border: none; background: none; cursor: pointer;
  color: var(--text-secondary); border-radius: 8px;
}
.btn-hamburger:hover { background: var(--bg); }

/* Mobile menu */
.mobile-menu {
  display: none;
  position: fixed;
  top: 64px; left: 0; right: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 8px 24px rgba(0,0,0,.10);
  z-index: 99;
  padding: 1rem;
  max-height: calc(100vh - 64px);
  overflow-y: auto;
}
.mobile-menu.open { display: block; }
.mobile-nav-link {
  display: block; padding: .625rem 1rem;
  border-radius: 8px; font-weight: 500; color: var(--text-secondary);
  transition: all .12s;
}
.mobile-nav-link:hover { background: #e8f4f8; color: var(--primary); }
.mobile-nav-label {
  padding: .25rem 1rem;
  font-size: .6875rem; font-weight: 700; letter-spacing: .08em;
  color: var(--text-muted); text-transform: uppercase; margin-top: .5rem;
}

/* ── Hero ─────────────────────────────────────────────────────────────────── */
.hero {
  position: relative;
  background-color: #1a3d52;
  background-image: url('../images/hero-bg.jpg');
  background-size: cover;
  background-position: center 40%;
  overflow: hidden;
  padding: 6rem 1.5rem;
  text-align: center;
  color: #fff;
}
.hero-pattern {
  position: absolute; inset: 0;
  background:
    linear-gradient(to bottom,
      rgba(12, 32, 46, 0.72) 0%,
      rgba(15, 38, 55, 0.78) 60%,
      rgba(10, 28, 42, 0.88) 100%);
}
.math-float {
  position: absolute;
  font-size: 3.5rem; font-weight: 800;
  color: rgba(255,255,255,.22);
  user-select: none; pointer-events: none;
  animation: float 6s ease-in-out infinite;
  text-shadow: 0 0 32px rgba(255,255,255,.15);
  line-height: 1;
}
@keyframes float {
  0%   { transform: translateY(0)     rotate(0deg);  }
  30%  { transform: translateY(-22px) rotate(3deg);  }
  60%  { transform: translateY(-10px) rotate(-2deg); }
  100% { transform: translateY(0)     rotate(0deg);  }
}
.hero-badge {
  display: inline-flex; align-items: center; gap: .375rem;
  background: rgba(255,255,255,.15); border: 1px solid rgba(255,255,255,.25);
  border-radius: 999px; padding: .375rem .875rem;
  font-size: .8125rem; font-weight: 600; letter-spacing: .04em;
  color: rgba(255,255,255,.9); margin-bottom: 1.5rem;
}
.hero-title {
  font-size: clamp(2rem, 5vw, 3.25rem);
  font-weight: 800; letter-spacing: -.03em;
  line-height: 1.15; margin-bottom: 1.25rem;
}
.hero-subtitle {
  font-size: clamp(1rem, 2vw, 1.2rem);
  color: rgba(255,255,255,.80); max-width: 560px;
  margin: 0 auto 2.25rem; line-height: 1.65;
}
.hero-ctas { display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; }
.btn-hero-primary {
  padding: .875rem 1.75rem;
  background: var(--warm); color: #fff;
  border-radius: 10px; font-weight: 700; font-size: 1rem;
  transition: background .15s, transform .15s, box-shadow .15s;
  box-shadow: 0 4px 16px rgba(217,119,6,.35);
}
.btn-hero-primary:hover { background: var(--warm-dark); transform: translateY(-2px); box-shadow: 0 6px 20px rgba(217,119,6,.45); }
.btn-hero-secondary {
  padding: .875rem 1.75rem;
  background: rgba(255,255,255,.15); color: #fff;
  border: 2px solid rgba(255,255,255,.4);
  border-radius: 10px; font-weight: 700; font-size: 1rem;
  transition: background .15s;
}
.btn-hero-secondary:hover { background: rgba(255,255,255,.25); }
.hero-stats {
  display: flex; gap: 2.5rem; justify-content: center; flex-wrap: wrap;
  margin-top: 3rem; padding-top: 2rem;
  border-top: 1px solid rgba(255,255,255,.2);
}
.hero-stat-num  { font-size: 1.75rem; font-weight: 800; }
.hero-stat-label{ font-size: .8125rem; color: rgba(255,255,255,.65); margin-top: .125rem; }

/* Class hero */
.class-hero {
  padding: 3.5rem 1.5rem;
  color: #fff; position: relative; overflow: hidden;
}
.class-hero-pattern {
  position: absolute; inset: 0;
  background: radial-gradient(circle at 80% 50%, rgba(255,255,255,.1) 0%, transparent 60%);
}

/* ── Cards ────────────────────────────────────────────────────────────────── */
.article-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  overflow: hidden;
  display: flex; flex-direction: column;
  transition: transform .2s ease, box-shadow .2s ease;
}
.article-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
}
.card-body { padding: 1.5rem; flex: 1; display: flex; flex-direction: column; }
.card-meta { display: flex; align-items: center; gap: .5rem; margin-bottom: .75rem; flex-wrap: wrap; }
.card-title {
  font-size: 1rem; font-weight: 700;
  color: var(--text); line-height: 1.4;
  margin-bottom: .5rem; transition: color .15s;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.article-card:hover .card-title { color: var(--primary); }
.card-excerpt {
  font-size: .875rem; color: var(--text-secondary);
  line-height: 1.65; margin-bottom: 1rem; flex: 1;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-footer {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: auto;
}
.card-category { font-size: .75rem; color: var(--text-muted); font-weight: 500; }
.card-link {
  font-size: .875rem; font-weight: 600; color: var(--warm);
  transition: color .15s;
}
.card-link:hover { color: var(--warm-dark); text-decoration: underline; }

/* Class card */
.class-card {
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  overflow: hidden;
  transition: transform .18s, box-shadow .18s, border-color .18s;
  display: flex; flex-direction: column;
  background: var(--surface); color: var(--text);
  text-decoration: none;
}
.class-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary-light);
}
.class-card--featured {
  border-color: var(--primary);
  border-width: 1.5px;
}
.class-card-bar { height: 5px; flex-shrink: 0; }
.class-card-body { padding: 1.25rem 1.25rem .75rem; flex: 1; }
.class-card-icon-wrap {
  width: 38px; height: 38px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: .875rem; flex-shrink: 0;
}
.class-card-header { display: flex; align-items: center; gap: .5rem; margin-bottom: .5rem; flex-wrap: wrap; }
.class-card-name { font-size: 1.0625rem; font-weight: 700; }
.class-card-badge {
  font-size: .6875rem; font-weight: 600;
  background: #e4f2f8; color: var(--primary-dark);
  padding: .15rem .5rem; border-radius: 999px; letter-spacing: .03em;
}
.class-card-desc { font-size: .875rem; color: var(--text-secondary); line-height: 1.6; }
.class-card-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: .875rem 1.25rem;
  border-top: 1px solid var(--border);
}
.class-card-count { font-size: .8125rem; color: var(--text-muted); }
.class-card-arrow {
  font-size: .8125rem; font-weight: 600;
  display: flex; align-items: center; gap: .25rem;
}

/* ── Badge / Chip ─────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: .2rem .625rem; border-radius: 999px;
  font-size: .6875rem; font-weight: 700; letter-spacing: .04em;
  white-space: nowrap;
}
.badge-blue   { background: #d4edf5; color: #1f6a8a; }
.badge-indigo { background: #cde6ef; color: #1a5a76; }
.badge-green  { background: #DCFCE7; color: #166534; }
.read-time { font-size: .75rem; color: var(--text-muted); }

/* ── Filter chips ─────────────────────────────────────────────────────────── */
.filter-chips { display: flex; gap: .5rem; flex-wrap: wrap; }
.chip {
  padding: .375rem .875rem;
  border-radius: 999px; font-size: .875rem; font-weight: 500;
  cursor: pointer; border: 2px solid var(--border);
  background: var(--surface); color: var(--text-secondary);
  transition: all .15s; white-space: nowrap;
  font-family: inherit;
}
.chip:hover { border-color: var(--primary-light); color: var(--primary); background: #e8f4f8; }
.chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ── Search ───────────────────────────────────────────────────────────────── */
.search-wrap { position: relative; }
.search-icon {
  position: absolute; left: .875rem; top: 50%;
  transform: translateY(-50%); color: var(--text-muted); pointer-events: none;
}
.search-input {
  width: 100%; padding: .75rem 1rem .75rem 2.75rem;
  border-radius: 999px; border: 2px solid var(--border);
  font-size: .9375rem; font-family: inherit;
  background: var(--surface); color: var(--text);
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.search-input:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}
.search-input::placeholder { color: var(--text-muted); }

/* ── Breadcrumbs ──────────────────────────────────────────────────────────── */
.breadcrumb { display: flex; align-items: center; gap: .375rem; flex-wrap: wrap; }
.breadcrumb-item { font-size: .8125rem; color: var(--text-muted); }
.breadcrumb-item a { color: var(--text-muted); transition: color .12s; }
.breadcrumb-item a:hover { color: var(--primary); }
.breadcrumb-item.current { color: var(--primary); font-weight: 600; }
.breadcrumb-sep { color: #CBD5E1; font-size: .75rem; }

/* ── Grids ────────────────────────────────────────────────────────────────── */
.articles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
}
.classes-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
}
.topics-grid {
  display: flex; gap: .625rem; flex-wrap: wrap;
}
.topic-pill {
  padding: .375rem .875rem;
  background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.3);
  border-radius: 999px; font-size: .875rem; font-weight: 500; color: #fff;
}

/* ── Sections ─────────────────────────────────────────────────────────────── */
.section { padding: 4rem 1.5rem; }
.section-sm { padding: 2.5rem 1.5rem; }
.container { max-width: 1152px; margin: 0 auto; }
.container-article { max-width: 780px; margin: 0 auto; }
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 2rem; gap: 1rem;
}
.section-title { font-size: 1.5rem; font-weight: 800; letter-spacing: -.02em; color: var(--text); }
.section-link { font-size: .875rem; font-weight: 600; color: var(--warm); white-space: nowrap; }
.section-link:hover { color: var(--warm-dark); text-decoration: underline; }

/* ── Article content ──────────────────────────────────────────────────────── */
.content-block {
  background: var(--surface); border-radius: var(--radius);
  border: 1px solid var(--border); padding: 1.75rem;
  margin-bottom: 1.5rem;
}
.content-block-header {
  display: flex; align-items: center; gap: .75rem;
  margin-bottom: 1.25rem; padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}
.content-block-icon {
  width: 36px; height: 36px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: .9375rem; font-weight: 700; flex-shrink: 0;
}
.content-block-icon.statement { background: #F1F5F9; color: #475569; }
.content-block-icon.solution  { background: #d4edf5; color: var(--primary); }
.content-block-label { font-weight: 700; font-size: 1rem; }
.content-prose {
  font-size: 1.0625rem; line-height: 1.85; color: var(--text);
}
.content-prose p { margin-bottom: .875rem; }
.content-prose p:last-child { margin-bottom: 0; }
.content-prose strong { font-weight: 700; color: var(--primary-dark); }

/* Math overflow */
.MJX-TEX { overflow-x: auto; }
mjx-container { overflow-x: auto; max-width: 100%; }

/* ── FAQ ──────────────────────────────────────────────────────────────────── */
.faq-item { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; margin-bottom: .75rem; }
.faq-trigger {
  width: 100%; padding: 1rem 1.25rem;
  display: flex; justify-content: space-between; align-items: center;
  background: var(--surface); border: none; cursor: pointer;
  font-family: inherit; font-size: .9375rem; font-weight: 600;
  color: var(--text); text-align: left; transition: background .12s;
}
.faq-trigger:hover { background: #F8FAFC; }
.faq-icon { flex-shrink: 0; color: var(--primary); font-size: 1.25rem; line-height: 1; transition: transform .2s; }
.faq-trigger.open .faq-icon { transform: rotate(45deg); }
.faq-body {
  max-height: 0; overflow: hidden;
  transition: max-height .3s ease, padding .3s ease;
  background: #F8FAFC; font-size: .9375rem; color: var(--text-secondary); line-height: 1.7;
}
.faq-body.open { max-height: 300px; padding: .875rem 1.25rem 1rem; }

/* ── Features section ─────────────────────────────────────────────────────── */
.features-section {
  background: var(--bg);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.features-header { text-align: center; margin-bottom: 3rem; }
.features-sub { color: var(--text-secondary); margin-top: .375rem; font-size: .9375rem; }
.features-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.feature-card {
  padding: 2rem;
  background: var(--bg);
}
.feature-icon-wrap {
  width: 40px; height: 40px; border-radius: 10px;
  background: #e4f2f8;
  display: flex; align-items: center; justify-content: center;
  color: var(--primary); margin-bottom: 1rem; flex-shrink: 0;
}
.feature-title { font-size: 1rem; font-weight: 700; margin-bottom: .375rem; color: var(--text); }
.feature-desc  { font-size: .875rem; color: var(--text-secondary); line-height: 1.7; }

@media (max-width: 768px) {
  .features-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
  .features-grid { grid-template-columns: 1fr; }
}

/* ── CTA banner ───────────────────────────────────────────────────────────── */
.cta-banner {
  background: linear-gradient(135deg, #1f6a8a, #2f8bb0);
  border-radius: var(--radius-lg); padding: 3rem 2rem; text-align: center; color: #fff;
}
.cta-banner h2 { font-size: 1.75rem; font-weight: 800; margin-bottom: .75rem; letter-spacing: -.02em; }
.cta-banner p  { color: rgba(255,255,255,.80); margin-bottom: 1.75rem; font-size: 1rem; }
.btn-cta-white {
  display: inline-block; padding: .875rem 2rem;
  background: #fff; color: var(--primary);
  border-radius: 10px; font-weight: 700; font-size: 1rem;
  transition: transform .15s, box-shadow .15s;
}
.btn-cta-white:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,.2); }

/* ── Empty / loading states ───────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 4rem 2rem; color: var(--text-muted); }
.empty-state-icon { font-size: 3rem; margin-bottom: 1rem; }
.empty-state-msg { font-size: 1rem; }

/* ── Footer ───────────────────────────────────────────────────────────────── */
.site-footer { background: #0d3d52; color: #94A3B8; }
.footer-inner { max-width: 1152px; margin: 0 auto; padding: 3.5rem 1.5rem 2rem; }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 3rem; margin-bottom: 2.5rem; }
.footer-brand-name { color: #fff; font-weight: 800; font-size: 1.1rem; margin-bottom: .625rem; display: flex; align-items: center; gap: .375rem; }
.footer-brand-desc { font-size: .875rem; color: #64748B; line-height: 1.65; max-width: 280px; }
.footer-col-title  { color: #fff; font-weight: 700; font-size: .9375rem; margin-bottom: 1rem; }
.footer-link { display: block; font-size: .875rem; color: #64748B; margin-bottom: .5rem; transition: color .12s; }
.footer-link:hover { color: #94A3B8; }
.footer-social {
  display: flex; gap: .625rem; flex-wrap: wrap; margin-top: 1.25rem;
}
.footer-social-link {
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 8px;
  background: rgba(255,255,255,.08); color: #94A3B8;
  transition: background .15s, color .15s;
}
.footer-social-link:hover { background: rgba(255,255,255,.18); color: #fff; }

.footer-bottom {
  border-top: 1px solid #1a5068; padding-top: 1.5rem;
  display: flex; align-items: center; justify-content: center;
  gap: 1.5rem; flex-wrap: wrap;
  font-size: .8125rem; color: #94a3b8;
}

/* ── Header search ────────────────────────────────────────────────────────── */
.header-search-wrap { position: relative; display: flex; align-items: center; }
.header-search-btn {
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 8px; border: none;
  background: none; cursor: pointer; color: var(--text-secondary);
  transition: background .15s, color .15s;
}
.header-search-btn:hover { background: var(--bg); color: var(--primary); }
.header-search-panel {
  position: absolute; top: calc(100% + 10px); right: 0;
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow-md);
  width: 300px; padding: .5rem;
  opacity: 0; visibility: hidden; pointer-events: none;
  transform: translateY(-6px);
  transition: opacity .18s, transform .18s, visibility .18s;
  z-index: 200;
}
.header-search-panel.open {
  opacity: 1; visibility: visible; pointer-events: auto; transform: translateY(0);
}
.header-search-panel form {
  display: flex; align-items: center; gap: .375rem;
}
.header-search-input {
  flex: 1; padding: .625rem .875rem;
  border: 1.5px solid var(--border); border-radius: 8px;
  font-size: .9375rem; font-family: inherit; outline: none;
  background: var(--bg); color: var(--text);
  transition: border-color .15s;
}
.header-search-input:focus { border-color: var(--primary); }
.header-search-submit {
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 8px; border: none;
  background: var(--warm); color: #fff; cursor: pointer; flex-shrink: 0;
  transition: background .15s;
}
.header-search-submit:hover { background: var(--warm-dark); }

@media (max-width: 480px) {
  .header-search-panel { width: calc(100vw - 2rem); right: -1rem; }
}

/* ── Comments ──────────────────────────────────────────────────────────────── */
.comments-section {
  margin-top: 3rem; padding-top: 2.5rem;
  border-top: 1px solid var(--border);
}
.comments-count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 24px; height: 24px; border-radius: 999px;
  background: var(--warm); color: #fff;
  font-size: .75rem; font-weight: 700;
  padding: 0 .4rem; margin-left: .5rem; vertical-align: middle;
}
.comments-list { margin-bottom: 2rem; display: flex; flex-direction: column; gap: 1.25rem; }
.comments-empty { color: var(--text-muted); font-size: .9375rem; }

.comment-item {
  display: flex; gap: 1rem; align-items: flex-start;
}
.comment-item--new { animation: commentIn .35s ease; }
@keyframes commentIn { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:none; } }

.comment-avatar {
  width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, var(--primary-light), var(--primary));
  color: #fff; font-size: .875rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.comment-body { flex: 1; min-width: 0; }
.comment-meta { display: flex; align-items: center; gap: .75rem; margin-bottom: .375rem; flex-wrap: wrap; }
.comment-name { font-weight: 700; font-size: .9375rem; color: var(--text); }
.comment-date { font-size: .8125rem; color: var(--text-muted); }
.comment-text { font-size: .9375rem; color: var(--text-secondary); line-height: 1.7; word-break: break-word; }

/* Comment form */
.comment-form-wrap {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.75rem; margin-top: .5rem;
}
.comment-form-title { font-size: 1.0625rem; font-weight: 700; margin-bottom: 1.25rem; }
.comment-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-group { display: flex; flex-direction: column; gap: .375rem; }
.form-label { font-size: .875rem; font-weight: 600; color: var(--text); }
.req { color: var(--warm); }
.form-hint { font-weight: 400; color: var(--text-muted); font-size: .8125rem; }
.form-input {
  padding: .625rem .875rem; border-radius: 8px;
  border: 1.5px solid var(--border); font-size: .9375rem;
  font-family: inherit; background: var(--surface); color: var(--text);
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.form-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(47,139,176,.12); }
.form-textarea {
  padding: .625rem .875rem; border-radius: 8px;
  border: 1.5px solid var(--border); font-size: .9375rem;
  font-family: inherit; background: var(--surface); color: var(--text);
  outline: none; resize: vertical; min-height: 110px;
  transition: border-color .15s, box-shadow .15s; width: 100%;
}
.form-textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(47,139,176,.12); }
.char-count { font-size: .75rem; color: var(--text-muted); text-align: right; margin-top: .25rem; }

.captcha-wrap {
  display: flex; align-items: center; gap: .625rem; flex-wrap: wrap;
  margin-top: 1rem; padding: .875rem 1rem;
  background: #fff; border: 1.5px solid var(--border); border-radius: 8px;
}
.captcha-label { font-size: .875rem; font-weight: 600; color: var(--text-muted); }
.captcha-eq { font-size: .9375rem; }
.captcha-input {
  width: 64px; padding: .5rem .625rem; border-radius: 6px;
  border: 1.5px solid var(--border); font-size: 1rem; font-family: inherit;
  text-align: center; outline: none; transition: border-color .15s;
}
.captcha-input:focus { border-color: var(--primary); }

.form-msg { margin-top: .875rem; font-size: .9rem; font-weight: 500; min-height: 1.25rem; border-radius: 6px; padding: .5rem .875rem; display: none; }
.form-msg--error   { display: block; background: #FEF2F2; color: #991B1B; border: 1px solid #FCA5A5; }
.form-msg--success { display: block; background: #ECFDF5; color: #065F46; border: 1px solid #6EE7B7; }

.btn-comment-submit {
  display: inline-flex; align-items: center; gap: .5rem;
  margin-top: 1.25rem; padding: .75rem 1.5rem;
  background: var(--warm); color: #fff; border: none;
  border-radius: 9px; font-size: .9375rem; font-weight: 700;
  font-family: inherit; cursor: pointer;
  transition: background .15s, transform .1s;
  box-shadow: 0 3px 10px rgba(217,119,6,.25);
}
.btn-comment-submit:hover { background: var(--warm-dark); transform: translateY(-1px); }

@media (max-width: 640px) {
  .comment-form-grid { grid-template-columns: 1fr; }
  .captcha-wrap { flex-direction: column; align-items: flex-start; }
}

/* ── Archive page filter bar ──────────────────────────────────────────────── */
.archive-toolbar {
  display: flex; gap: 1rem; flex-wrap: wrap;
  align-items: center; margin-bottom: 2.5rem;
}
.archive-search { flex: 1; min-width: 220px; }

/* ── Article header ───────────────────────────────────────────────────────── */
.article-header { margin-bottom: 2rem; }
.article-title { font-size: clamp(1.5rem, 3.5vw, 2.25rem); font-weight: 800; letter-spacing: -.02em; line-height: 1.2; margin-bottom: 1rem; }
.article-meta { display: flex; align-items: center; gap: .875rem; flex-wrap: wrap; }

/* ── Related posts ────────────────────────────────────────────────────────── */
.related-section { margin-top: 3.5rem; padding-top: 2.5rem; border-top: 1px solid var(--border); }

/* ── Utilities ────────────────────────────────────────────────────────────── */
.divider { border: none; border-top: 1px solid var(--border); margin: 2rem 0; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: .875rem; }
.mt-2 { margin-top: .5rem; }

/* ── Responsive ───────────────────────────────────────────────────────────── */

/* Tablet landscape & small desktop (≤900px) */
@media (max-width: 900px) {
  .nav-desktop, .btn-nav { display: none; }
  .btn-hamburger { display: flex; }
  .header-author { display: none; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
}

/* Tablet portrait (≤768px) */
@media (max-width: 768px) {
  .classes-grid  { grid-template-columns: repeat(2, 1fr); }
  .articles-grid { grid-template-columns: repeat(2, 1fr); }
  .container-article { padding: 0 1.25rem; }
}

/* Mobile (≤640px) */
@media (max-width: 640px) {
  .articles-grid { grid-template-columns: 1fr; }

  /* Toolbar: stack vertically on mobile */
  .archive-toolbar { flex-direction: column; }
  .archive-search { width: 100%; min-width: 0; }
  .filter-chips { flex-wrap: wrap; }

  /* Toolbar not sticky on mobile — too tall */
  .archive-filter-bar { position: static !important; }

  /* Article content: prevent math/code overflow */
  .content-prose { overflow-x: auto; word-break: break-word; }
  .content-block { overflow-x: hidden; }

  /* Author name below logo on mobile */
  .header-brand { flex-direction: column; align-items: flex-start; gap: 1px; }
  .header-author { display: block; font-size: .75rem; }

  .hero { padding: 3.5rem 1.25rem; }
  .hero-stats { gap: 1.5rem; }
  .hero-stat-num { font-size: 1.375rem; }
  .footer-grid { grid-template-columns: 1fr; gap: 2rem; }
  .section { padding: 3rem 1.25rem; }
  .section-sm { padding: 2rem 1.25rem; }
  .section-header { flex-direction: column; align-items: flex-start; gap: .5rem; }
}

/* Small mobile (≤420px) */
@media (max-width: 420px) {
  .classes-grid { grid-template-columns: 1fr; }
  .hero-ctas { flex-direction: column; align-items: stretch; }
  .btn-hero-primary, .btn-hero-secondary { text-align: center; }
  .hero-stats { flex-direction: column; gap: 1rem; align-items: center; }
  .comment-form-grid { grid-template-columns: 1fr; }
}

/* ── Pagination ───────────────────────────────────────────────────────────── */
.pagination { display: flex; justify-content: center; align-items: center; gap: .375rem; flex-wrap: wrap; }
.pg-btn {
  min-width: 2.25rem; height: 2.25rem; padding: 0 .625rem;
  border: 1.5px solid var(--border); border-radius: 8px;
  background: #fff; color: var(--text); font-size: .875rem; font-weight: 500;
  cursor: pointer; font-family: inherit; transition: all .15s;
}
.pg-btn:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.pg-btn.pg-active { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 700; }
.pg-btn:disabled { opacity: .35; cursor: default; }
.pg-arrow { font-size: 1rem; }

/* ── Ad banner ────────────────────────────────────────────────────────────── */
.ad-banner-wrap {
  background: var(--bg);
  border-top: 1px solid var(--border);
  padding: 1.25rem 1.5rem;
  text-align: center;
}
.ad-banner {
  display: inline-block; position: relative;
  text-decoration: none; border-radius: 8px; overflow: hidden;
}
.ad-label {
  position: absolute; top: 4px; left: 6px;
  font-size: .625rem; font-weight: 600; letter-spacing: .06em;
  color: var(--text-muted); text-transform: uppercase; z-index: 1;
}
.ad-banner img {
  display: block; max-width: 100%; height: auto; border-radius: 8px;
}

/* ── Terms page ───────────────────────────────────────────────────────────── */
.terms-body { padding: 0.5rem 0 3rem; }
.terms-intro {
  font-size: 1rem; color: var(--text-secondary); line-height: 1.8;
  padding: 1.25rem 1.5rem; background: var(--bg);
  border-left: 4px solid var(--primary-light); border-radius: 0 8px 8px 0;
  margin-bottom: 2.5rem;
}
.terms-heading {
  font-size: 1.125rem; font-weight: 700; color: var(--text);
  margin: 2.25rem 0 .75rem; padding-bottom: .5rem;
  border-bottom: 1px solid var(--border);
}
.terms-body p { font-size: .9375rem; color: var(--text-secondary); line-height: 1.8; margin-bottom: 1rem; }
.terms-list {
  list-style: none; padding: 0; margin: 0 0 1rem 0;
  display: flex; flex-direction: column; gap: .5rem;
}
.terms-list li {
  font-size: .9375rem; color: var(--text-secondary); line-height: 1.7;
  padding-left: 1.25rem; position: relative;
}
.terms-list li::before {
  content: ''; position: absolute; left: 0; top: .65em;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--primary-light);
}
.terms-license-badge {
  display: inline-flex; align-items: center; gap: .5rem; flex-wrap: wrap;
  margin-top: 2.5rem; padding: .875rem 1.25rem;
  background: #e4f2f8; border-radius: 10px;
  font-size: .875rem; color: var(--primary-dark);
}
.terms-license-badge a { color: var(--primary); font-weight: 600; }

/* ── Print ────────────────────────────────────────────────────────────────── */
@media print {
  .site-header, .site-footer, .related-section, .mobile-menu { display: none !important; }
  .content-block { box-shadow: none; border: 1px solid #ccc; }
  .article-title { font-size: 1.5rem; }
}
