/* ============================================
   SHEETS CMS — style.css
   Core Web Vitals optimized | Zero CLS
   ============================================ */

/* ---------- CSS Custom Properties ---------- */
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #eff6ff;
  --accent: #f59e0b;
  --text: #1e293b;
  --text-muted: #64748b;
  --bg: #ffffff;
  --bg-alt: #f8fafc;
  --border: #e2e8f0;
  --radius: 8px;
  --radius-lg: 16px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -1px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -2px rgba(0,0,0,.05);
  --font: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'Fira Code', 'Fira Mono', 'Cascadia Code', monospace;
  --max-w: 1200px;
  --header-h: 64px;
  --transition: 0.2s ease;
}

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

html {
  scroll-behavior: smooth;
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.7;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  /* Prevent layout shift */
  overflow-x: hidden;
}

img, video, iframe {
  max-width: 100%;
  height: auto;
  display: block;
}

a { color: var(--primary); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--primary-dark); }
a:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; border-radius: 3px; }

h1, h2, h3, h4, h5, h6 {
  line-height: 1.3;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

p { margin-bottom: 1.25rem; }
p:last-child { margin-bottom: 0; }

ul, ol { padding-left: 1.5rem; margin-bottom: 1.25rem; }
li { margin-bottom: 0.4rem; }

code {
  font-family: var(--font-mono);
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.15em 0.4em;
  font-size: 0.875em;
}

pre {
  background: #0f172a;
  color: #e2e8f0;
  border-radius: var(--radius);
  padding: 1.25rem;
  overflow-x: auto;
  margin-bottom: 1.5rem;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  line-height: 1.6;
}

pre code { background: none; border: none; padding: 0; color: inherit; }

blockquote {
  border-left: 4px solid var(--primary);
  background: var(--primary-light);
  padding: 1rem 1.5rem;
  border-radius: 0 var(--radius) var(--radius) 0;
  margin-bottom: 1.5rem;
  font-style: italic;
}

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
}

th, td {
  border: 1px solid var(--border);
  padding: 0.6rem 1rem;
  text-align: left;
}

th { background: var(--bg-alt); font-weight: 600; }
tr:nth-child(even) td { background: var(--bg-alt); }

/* ---------- Layout ---------- */
.container {
  width: 100%;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 1.25rem;
}

.layout-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 2rem;
  align-items: start;
}

.main-content { min-width: 0; }

/* ---------- Header ---------- */
#site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  height: var(--header-h);
  /* Reserve height to prevent CLS */
  min-height: var(--header-h);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-h);
  gap: 1.5rem;
}

.site-logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text);
  text-decoration: none;
  flex-shrink: 0;
  letter-spacing: -0.03em;
}

.site-logo img {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  object-fit: contain;
}

.site-logo span { color: var(--primary); }

/* ---------- Navigation ---------- */
#main-nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.nav-link {
  padding: 0.4rem 0.85rem;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: all var(--transition);
  white-space: nowrap;
}

.nav-link:hover, .nav-link.active {
  color: var(--primary);
  background: var(--primary-light);
}

/* ---------- Search ---------- */
.header-search {
  position: relative;
  flex: 1;
  max-width: 320px;
}

.header-search input {
  width: 100%;
  padding: 0.5rem 1rem 0.5rem 2.5rem;
  border: 1px solid var(--border);
  border-radius: 24px;
  font-size: 0.875rem;
  background: var(--bg-alt);
  color: var(--text);
  transition: all var(--transition);
  font-family: var(--font);
}

.header-search input:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--bg);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
}

.search-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  width: 16px;
  height: 16px;
}

/* ---------- Mobile Menu ---------- */
.menu-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.4rem;
  cursor: pointer;
  color: var(--text);
  transition: all var(--transition);
}

.menu-toggle:hover { background: var(--bg-alt); }

/* ---------- Hero / Page Header ---------- */
.page-hero {
  background: linear-gradient(135deg, #1e3a8a 0%, var(--primary) 60%, #7c3aed 100%);
  color: white;
  padding: 4rem 0 3rem;
  margin-bottom: 2.5rem;
  position: relative;
  overflow: hidden;
}

.page-hero::before {
  content: '';
  position: absolute;
  inset: 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%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.04'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  pointer-events: none;
}

.page-hero-content { position: relative; z-index: 1; }
.page-hero h1 { font-size: clamp(1.75rem, 4vw, 3rem); margin-bottom: 1rem; color: white; }
.page-hero p { font-size: 1.1rem; opacity: 0.9; max-width: 600px; }

/* ---------- Breadcrumb ---------- */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: rgba(255,255,255,0.75);
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.breadcrumb a { color: rgba(255,255,255,0.85); }
.breadcrumb a:hover { color: white; }
.breadcrumb-sep { opacity: 0.5; font-size: 0.7rem; }

/* ---------- Cards Grid ---------- */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: transform var(--transition), box-shadow var(--transition);
  display: flex;
  flex-direction: column;
}

.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}

.card-image {
  aspect-ratio: 16/9;
  background: var(--bg-alt);
  overflow: hidden;
  /* Reserve space to prevent CLS */
}

.card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}

.card:hover .card-image img { transform: scale(1.04); }

.card-body { padding: 1.25rem; flex: 1; display: flex; flex-direction: column; }
.card-category {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--primary);
  background: var(--primary-light);
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  margin-bottom: 0.75rem;
}

.card-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  line-height: 1.4;
}

.card-title a { color: var(--text); }
.card-title a:hover { color: var(--primary); }

.card-excerpt {
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.6;
  flex: 1;
  margin-bottom: 1rem;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: auto;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.reading-time {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

/* ---------- Article Page ---------- */
.article-header {
  margin-bottom: 2rem;
}

.article-header h1 {
  font-size: clamp(1.6rem, 4vw, 2.5rem);
  margin-bottom: 1rem;
  line-height: 1.25;
}

.article-meta {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.article-meta span { display: flex; align-items: center; gap: 0.3rem; }

.article-body {
  font-size: 1.05rem;
  line-height: 1.8;
  color: #334155;
}

.article-body h2 {
  font-size: 1.5rem;
  margin: 2rem 0 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--border);
}

.article-body h3 { font-size: 1.2rem; margin: 1.5rem 0 0.75rem; }
.article-body h4 { font-size: 1.05rem; margin: 1.25rem 0 0.5rem; }

.article-body img {
  border-radius: var(--radius);
  margin: 1.5rem auto;
  box-shadow: var(--shadow-md);
}

/* ---------- Sidebar ---------- */
.sidebar {
  position: sticky;
  top: calc(var(--header-h) + 1.5rem);
}

.sidebar-widget {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}

.sidebar-widget h3 {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 1rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--border);
}

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

.related-list li {
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
  margin: 0;
}

.related-list li:last-child { border-bottom: none; }

.related-list a {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
  display: block;
  line-height: 1.4;
}

.related-list a:hover { color: var(--primary); }
.related-list .r-cat {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

/* ---------- Category Filter ---------- */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 2rem;
}

.filter-btn {
  padding: 0.4rem 1rem;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 600;
  border: 1.5px solid var(--border);
  background: var(--bg);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font);
}

.filter-btn:hover { border-color: var(--primary); color: var(--primary); }
.filter-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

/* ---------- Search Results ---------- */
.search-page-header {
  margin-bottom: 1.5rem;
}

.search-page-header h2 {
  font-size: 1.4rem;
  margin-bottom: 0.25rem;
}

.search-page-header p { color: var(--text-muted); font-size: 0.9rem; }

.search-highlight { background: #fef08a; border-radius: 2px; padding: 0 2px; }

/* ---------- Share Buttons ---------- */
.share-section {
  margin: 2.5rem 0;
  padding: 1.5rem;
  background: var(--bg-alt);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}

.share-section h3 {
  font-size: 0.9rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.share-btns {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.share-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1.1rem;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  color: white;
  transition: transform var(--transition), opacity var(--transition);
}

.share-btn:hover { transform: translateY(-2px); opacity: 0.9; color: white; }
.share-btn.twitter { background: #000000; }
.share-btn.facebook { background: #1877f2; }
.share-btn.linkedin { background: #0a66c2; }
.share-btn.whatsapp { background: #25d366; }
.share-btn.copy-link { background: var(--text); }
.share-btn.print-btn { background: #64748b; }

/* ---------- Ad Zones ---------- */
.ad-zone {
  background: var(--bg-alt);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  position: relative;
  overflow: hidden;
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ad-zone-label {
  position: absolute;
  top: 4px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.65rem;
  background: var(--border);
  color: var(--text-muted);
  padding: 1px 8px;
  border-radius: 0 0 4px 4px;
}

.ad-header { margin-bottom: 1.5rem; min-height: 90px; }
.ad-sidebar { margin-bottom: 1.5rem; min-height: 250px; }
.ad-footer { margin-top: 2rem; min-height: 90px; }

/* ---------- Adblock Notice ---------- */
.adblock-notice {
  display: none;
  background: linear-gradient(135deg, #fff7ed, #fef3c7);
  border: 1px solid #f59e0b;
  border-radius: var(--radius);
  padding: 0.75rem 1.25rem;
  font-size: 0.875rem;
  color: #92400e;
  margin-bottom: 1rem;
  align-items: center;
  gap: 0.5rem;
}

.adblock-notice.visible { display: flex; }

/* ---------- Cookie / Page Views ---------- */
.stats-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

.stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0.2rem 0.6rem;
}

/* ---------- Footer ---------- */
#site-footer {
  background: #0f172a;
  color: #94a3b8;
  margin-top: auto;
}

.footer-main {
  padding: 3rem 0 2rem;
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 2rem;
}

.footer-brand .site-logo { color: white; margin-bottom: 1rem; }
.footer-brand p { font-size: 0.875rem; line-height: 1.7; }

.footer-col h4 {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #e2e8f0;
  margin-bottom: 1rem;
}

.footer-col ul { list-style: none; padding: 0; margin: 0; }
.footer-col li { margin-bottom: 0.5rem; }
.footer-col a { color: #94a3b8; font-size: 0.875rem; }
.footer-col a:hover { color: white; }

.footer-bottom {
  border-top: 1px solid #1e293b;
  padding: 1.25rem 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
  gap: 1rem;
  flex-wrap: wrap;
}

/* ---------- Loading States ---------- */
.skeleton {
  background: linear-gradient(90deg, var(--bg-alt) 25%, #e9ecef 50%, var(--bg-alt) 75%);
  background-size: 400% 100%;
  animation: shimmer 1.5s ease infinite;
  border-radius: var(--radius);
}

@keyframes shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

.skeleton-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.sk-img { height: 180px; }
.sk-body { padding: 1.25rem; }
.sk-line { height: 14px; margin-bottom: 10px; }
.sk-line.wide { width: 90%; }
.sk-line.mid { width: 65%; }
.sk-line.short { width: 40%; }

/* ---------- 404 / Error ---------- */
.error-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 50vh;
  text-align: center;
  padding: 2rem;
}

.error-page .error-code {
  font-size: 6rem;
  font-weight: 900;
  color: var(--border);
  line-height: 1;
  margin-bottom: 1rem;
}

.error-page h2 { margin-bottom: 0.5rem; }
.error-page p { color: var(--text-muted); margin-bottom: 1.5rem; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.6rem 1.5rem;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.9rem;
  font-family: var(--font);
  cursor: pointer;
  transition: all var(--transition);
  border: none;
  text-decoration: none;
}

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

.btn-primary:hover {
  background: var(--primary-dark);
  color: white;
  transform: translateY(-1px);
}

/* ---------- FAQ Accordion ---------- */
.faq-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.75rem;
  overflow: hidden;
}

.faq-question {
  width: 100%;
  background: var(--bg);
  border: none;
  padding: 1rem 1.25rem;
  text-align: left;
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  transition: background var(--transition);
}

.faq-question:hover { background: var(--bg-alt); }
.faq-question.open { background: var(--primary-light); color: var(--primary); }

.faq-icon {
  flex-shrink: 0;
  transition: transform var(--transition);
  font-size: 1.25rem;
  font-weight: 300;
}

.faq-question.open .faq-icon { transform: rotate(45deg); }

.faq-answer {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s ease, padding 0.35s ease;
  padding: 0 1.25rem;
  color: var(--text-muted);
  line-height: 1.7;
}

.faq-answer.open {
  max-height: 600px;
  padding: 1rem 1.25rem 1.25rem;
}

/* ---------- Toast / Notifications ---------- */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  background: #0f172a;
  color: white;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  animation: slideIn 0.3s ease;
  max-width: 300px;
}

.toast.success { border-left: 4px solid #10b981; }
.toast.error { border-left: 4px solid #ef4444; }
.toast.info { border-left: 4px solid var(--primary); }

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

/* ---------- Progress Bar ---------- */
#reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  background: var(--primary);
  z-index: 9999;
  transition: width 0.1s linear;
  width: 0;
}

/* ---------- Back to Top ---------- */
#back-to-top {
  position: fixed;
  bottom: 1.5rem;
  left: 1.5rem;
  width: 44px;
  height: 44px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition), transform var(--transition);
  box-shadow: var(--shadow-md);
  font-size: 1.1rem;
}

#back-to-top.visible { opacity: 1; pointer-events: auto; }
#back-to-top:hover { transform: translateY(-3px); background: var(--primary-dark); }

/* ---------- Table of Contents ---------- */
.toc-widget {
  background: var(--primary-light);
  border: 1px solid #bfdbfe;
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 2rem;
}

.toc-widget h4 {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--primary);
  margin-bottom: 0.75rem;
}

.toc-list { list-style: none; padding: 0; margin: 0; }
.toc-list li { margin-bottom: 0.3rem; }
.toc-list a {
  font-size: 0.875rem;
  color: var(--text);
}

.toc-list a:hover { color: var(--primary); }
.toc-list .toc-h3 { padding-left: 1rem; font-size: 0.825rem; }

/* ---------- Offline Banner ---------- */
#offline-banner {
  display: none;
  background: #f59e0b;
  color: white;
  text-align: center;
  padding: 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  position: sticky;
  top: var(--header-h);
  z-index: 99;
}

#offline-banner.show { display: block; }

/* ---------- PRINT STYLES ---------- */
@media print {
  #site-header, #site-footer, .sidebar, .share-section,
  .ad-zone, #back-to-top, #reading-progress, .filter-bar,
  .menu-toggle, #offline-banner { display: none !important; }

  body { font-size: 11pt; line-height: 1.5; color: #000; background: white; }
  .layout-grid { grid-template-columns: 1fr; }
  .container { max-width: 100%; padding: 0; }
  .page-hero { background: white; color: black; padding: 1rem 0; }
  .page-hero h1 { color: black; }
  .breadcrumb { color: #666; }
  .breadcrumb a { color: #333; }
  a { color: #000; text-decoration: underline; }
  a[href]::after { content: " (" attr(href) ")"; font-size: 0.75em; }
  h1, h2, h3 { page-break-after: avoid; }
  p, li { page-break-inside: avoid; }
  .card { border: 1px solid #ccc; break-inside: avoid; }
  .cards-grid { grid-template-columns: 1fr 1fr; }
}

/* ---------- Responsive — Tablet ---------- */
@media (max-width: 1024px) {
  .layout-grid { grid-template-columns: 1fr 280px; gap: 1.5rem; }
  .footer-main { grid-template-columns: 1fr 1fr; }
}

/* ---------- Responsive — Mobile ---------- */
@media (max-width: 768px) {
  :root { --header-h: 56px; }

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

  .sidebar {
    position: static;
    order: -1;
  }

  #main-nav {
    display: none;
    position: absolute;
    top: var(--header-h);
    left: 0;
    right: 0;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 1.25rem;
    flex-direction: column;
    align-items: stretch;
    gap: 0.25rem;
    box-shadow: var(--shadow-md);
  }

  #main-nav.open { display: flex; }

  .nav-link { padding: 0.6rem 0.85rem; }

  .menu-toggle { display: flex; }

  .header-search { max-width: 160px; }

  .page-hero { padding: 2.5rem 0 2rem; }

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

  .footer-main { grid-template-columns: 1fr 1fr; gap: 1.5rem; }

  .share-btns { gap: 0.5rem; }
  .share-btn { padding: 0.4rem 0.8rem; font-size: 0.8rem; }

  .footer-bottom { flex-direction: column; text-align: center; }
}

@media (max-width: 480px) {
  .header-search { display: none; }
  .footer-main { grid-template-columns: 1fr; }
  .footer-brand { margin-bottom: 0; }
  .card-meta { flex-wrap: wrap; gap: 0.5rem; }
}

/* ---------- Dark Mode ---------- */
@media (prefers-color-scheme: dark) {
  :root {
    --text: #e2e8f0;
    --text-muted: #94a3b8;
    --bg: #0f172a;
    --bg-alt: #1e293b;
    --border: #334155;
    --primary-light: #1e3a5f;
  }

  .card, .sidebar-widget, .faq-question { background: #1e293b; }
  .header-search input { background: #1e293b; color: var(--text); }
  code { background: #1e293b; }
  .toc-widget { background: #1e3a5f; border-color: #2563eb; }
  .article-body { color: #cbd5e1; }
  th { background: #1e293b; }
  .filter-btn { background: #1e293b; color: var(--text-muted); }
  .share-section { background: #1e293b; }
  blockquote { background: #1e3a5f; }
}

/* ---------- Utility Classes ---------- */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.hidden { display: none !important; }
.flex { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: 0.5rem; }
.font-bold { font-weight: 700; }
.section-title {
  font-size: 1.5rem;
  font-weight: 800;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.section-title::after {
  content: '';
  flex: 1;
  height: 2px;
  background: var(--border);
  margin-left: 1rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.5rem;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.badge-blue { background: #dbeafe; color: #1d4ed8; }
.badge-green { background: #dcfce7; color: #15803d; }
.badge-gray { background: var(--bg-alt); color: var(--text-muted); }
