/* ===== Design Tokens ===== */
:root {
  --color-bg: #f8f9fa;
  --color-surface: #ffffff;
  --color-border: #e5e7eb;
  --color-border-strong: #d1d5db;
  --color-text: #111827;
  --color-text-muted: #6b7280;
  --color-accent: #111827;
  --color-primary: #326ce5;
  --color-primary-light: #e8f0fd;
  --color-blue: #3b82f6;
  --color-purple: #7c3aed;
  --color-teal: #0d9488;
  --color-green: #22c55e;

  --cat-k8s: #326ce5;
  --cat-beginner: #16a34a;
  --cat-advanced: #dc2626;

  --font-body: "Inter", sans-serif;
  --font-display: "Sora", sans-serif;
  --font-mono: "ui-monospace", "SFMono-Regular", "Menlo", monospace;

  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-pill: 9999px;

  --shadow-sm: 0 1px 4px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.12);

  --transition: 0.18s ease;

  --content-max: 1280px;
  --sidebar-w: 260px;
}

/* ===== Reset ===== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
html {
  scroll-behavior: smooth;
  overflow-x: hidden;
}
body {
  font-family: var(--font-body);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.75;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main {
  flex: 1;
}
img,
svg {
  max-width: 100%;
  display: block;
}
a {
  color: var(--color-primary);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

/* ===== Typography ===== */
h1 {
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 5.5vw, 4rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
}
h2 {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 3.5vw, 2.4rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
h3 {
  font-size: 1.1rem;
  font-weight: 600;
  line-height: 1.4;
}
h4 {
  font-size: 0.95rem;
  font-weight: 600;
}
p {
  margin-bottom: 1rem;
}
ul,
ol {
  margin-bottom: 1rem;
  padding-left: 1.5rem;
}
li {
  margin-bottom: 0.35rem;
}
code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: #f3f4f6;
  padding: 0.15em 0.45em;
  border-radius: 4px;
  color: #374151;
}
pre {
  overflow-x: auto;
  max-width: 100%;
  background: #1e293b;
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin: 1.5rem 0;
  border: 1px solid #334155;
}
pre code {
  background: none;
  padding: 0;
  border-radius: 0;
  font-size: 0.875rem;
  line-height: 1.65;
  color: #e2e8f0;
  white-space: pre;
}

/* ===== Global Nav ===== */
.site-header {
  background: rgba(255, 255, 255, 0.6);
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid rgba(229, 231, 235, 0.6);
  box-shadow: 0 1px 20px rgba(0, 0, 0, 0.06);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
}
.nav-inner {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 1.5rem;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  min-width: 0;
  overflow: hidden;
}
.nav-logo {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--color-text);
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
}
.nav-logo span {
  color: var(--color-primary);
}
.nav-logo:hover {
  text-decoration: none;
}
.nav-links {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1;
}
.nav-links a {
  color: var(--color-text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-pill);
  transition:
    color var(--transition),
    background var(--transition);
}
.nav-links a:hover {
  color: var(--color-text);
  background: var(--color-bg);
  text-decoration: none;
}
.nav-links a.active {
  color: var(--color-primary);
  background: var(--color-primary-light);
}
.nav-chapters {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.15rem;
}
.nav-chapters li a {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--color-text-muted);
  text-decoration: none;
  padding: 0.3rem 0.6rem;
  border-radius: var(--radius-pill);
  transition:
    color var(--transition),
    background var(--transition);
  white-space: nowrap;
}
.nav-chapters li a:hover {
  color: var(--color-text);
  background: var(--color-bg);
}
.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-left: auto;
  flex-shrink: 0;
}
.nav-progress {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--color-text-muted);
  font-size: 0.8rem;
  font-weight: 500;
  text-decoration: none;
  padding: 0.35rem 0.7rem;
  border-radius: var(--radius-pill);
  transition:
    background var(--transition),
    color var(--transition);
}
.nav-progress:hover {
  background: var(--color-bg);
  color: var(--color-text);
  text-decoration: none;
}
.nav-progress-bar {
  width: 72px;
  height: 4px;
  background: var(--color-border);
  border-radius: 2px;
  overflow: hidden;
  flex-shrink: 0;
}
.nav-progress-fill {
  height: 100%;
  background: var(--color-primary);
  border-radius: 2px;
  transition: width 0.4s ease;
}
.btn-primary {
  background: var(--color-accent);
  color: #fff;
  padding: 0.5rem 1.2rem;
  border: none;
  border-radius: var(--radius-pill);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.875rem;
  text-decoration: none;
  transition:
    background var(--transition),
    box-shadow var(--transition),
    transform var(--transition);
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}
.btn-primary:hover {
  background: #1f2937;
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
  text-decoration: none;
}

/* Nav CTA — glassmorphism (Kubernetes blue) */
#nav-cta {
  position: relative;
  overflow: hidden;
  background: linear-gradient(
    135deg,
    rgba(50, 108, 229, 0.18) 0%,
    rgba(36, 86, 184, 0.12) 100%
  );
  color: var(--color-primary);
  border: 1px solid rgba(50, 108, 229, 0.3);
  backdrop-filter: blur(16px) saturate(200%) brightness(1.05);
  -webkit-backdrop-filter: blur(16px) saturate(200%) brightness(1.05);
  box-shadow:
    0 2px 16px rgba(50, 108, 229, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    inset 0 -1px 0 rgba(50, 108, 229, 0.1);
}
#nav-cta::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 60%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.18),
    transparent
  );
  transition: left 0.55s ease;
  pointer-events: none;
}
#nav-cta:hover::before {
  left: 160%;
}
#nav-cta:hover {
  background: linear-gradient(
    135deg,
    rgba(50, 108, 229, 0.28) 0%,
    rgba(36, 86, 184, 0.22) 100%
  );
  border-color: rgba(50, 108, 229, 0.55);
  color: var(--color-primary);
  box-shadow:
    0 4px 28px rgba(50, 108, 229, 0.28),
    0 0 0 3px rgba(50, 108, 229, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
  transform: translateY(-1px);
}
.search-btn {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  color: var(--color-text-muted);
  padding: 0.4rem 1rem;
  cursor: pointer;
  font-size: 0.85rem;
  font-family: var(--font-body);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition:
    border-color var(--transition),
    color var(--transition),
    box-shadow var(--transition);
}
.search-btn:hover {
  border-color: var(--color-primary);
  color: var(--color-text);
  box-shadow: var(--shadow-sm);
}

/* ===== Hero ===== */
.hero {
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text);
  padding: 5rem 1.5rem 4rem;
}
.hero-inner {
  max-width: var(--content-max);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 3rem;
  align-items: center;
}
.hero-left {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}
.hero-right {
  display: flex;
  align-items: center;
  justify-content: center;
}
.hero-diagram {
  width: 100%;
  max-width: 860px;
  border-radius: 1.5rem;
  overflow: hidden;
  background: var(--color-bg);
}
.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--color-primary-light);
  border: none;
  border-radius: var(--radius-pill);
  color: var(--color-primary);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.35rem 0.9rem;
  margin-bottom: 1.5rem;
  letter-spacing: 0.01em;
}
.hero h1 {
  color: var(--color-text);
  margin-bottom: 1.25rem;
}
.hero h1 em {
  font-style: normal;
  color: var(--color-primary);
}
.hero-sub {
  font-size: 1rem;
  color: var(--color-text-muted);
  max-width: 520px;
  margin-bottom: 2rem;
  line-height: 1.7;
}
.hero-ctas {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 2.5rem;
}
.btn-secondary {
  background: var(--color-surface);
  border: 1.5px solid var(--color-border-strong);
  border-radius: var(--radius-pill);
  color: var(--color-text);
  padding: 0.5rem 1.2rem;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.875rem;
  text-decoration: none;
  transition:
    border-color var(--transition),
    box-shadow var(--transition),
    transform var(--transition);
}
.btn-secondary:hover {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
  text-decoration: none;
}
.btn-large {
  padding: 0.65rem 1.5rem;
  font-size: 0.95rem;
}
.stats-bar {
  display: flex;
  gap: 2rem;
  flex-wrap: wrap;
}
.stat {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.stat-num {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--color-text);
}
.stat-label {
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

/* ===== Section Layout ===== */
.section {
  padding: 4rem 1.5rem;
}
.section-inner {
  max-width: var(--content-max);
  margin: 0 auto;
}
.section-header {
  margin-bottom: 2.5rem;
}
.section-header h2 {
  margin-bottom: 0.5rem;
}
.section-header p {
  color: var(--color-text-muted);
  font-size: 1rem;
}
.section-alt {
  background: var(--color-bg);
}

/* ===== Tag Filter Bar ===== */
.tag-filter-bar {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  flex-wrap: wrap;
}
.tag-filter-active {
  font-size: 0.85rem;
  color: var(--color-text-muted);
}
.tag-filter-active strong {
  color: var(--color-primary);
}
.tag-filter-clear {
  font-size: 0.78rem;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  background: none;
  cursor: pointer;
  color: var(--color-text-muted);
  transition:
    color var(--transition),
    border-color var(--transition);
}
.tag-filter-clear:hover {
  color: var(--color-text);
  border-color: var(--color-text-muted);
}
.guide-card.hidden {
  display: none;
}
.section.hidden {
  display: none;
}

/* ===== Category Grid ===== */
.categories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
}
.cat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 1.75rem;
  text-decoration: none;
  color: inherit;
  transition:
    transform var(--transition),
    box-shadow var(--transition),
    border-color var(--transition);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  box-shadow: var(--shadow-sm);
}
.cat-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--color-primary);
  text-decoration: none;
}
.cat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  background: var(--color-primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}
.cat-card h3 {
  font-size: 1.05rem;
}
.cat-card p {
  font-size: 0.875rem;
  color: var(--color-text-muted);
  margin: 0;
}
.cat-count {
  font-size: 0.8rem;
  font-weight: 600;
  margin-top: auto;
  color: var(--color-primary);
}

/* ===== Guide Grid ===== */
.guides-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
}

/* ===== Footer ===== */
.site-footer {
  background: var(--color-surface);
  color: var(--color-text-muted);
  border-top: 1px solid var(--color-border);
  padding: 1.5rem 1.5rem;
  text-align: center;
}
.footer-inner {
  max-width: var(--content-max);
  margin: 0 auto;
}
.footer-logo {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--color-text);
  margin-bottom: 0.5rem;
}
.footer-logo span {
  color: var(--color-primary);
}
.footer-links {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin: 0.5rem 0;
  list-style: none;
}
.footer-links a {
  color: var(--color-text-muted);
  font-size: 0.875rem;
}
.footer-links a:hover {
  color: var(--color-text);
}
.footer-copy {
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

/* ===== Search Overlay ===== */
.search-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 8vh 1rem 10vh;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.search-overlay.open {
  opacity: 1;
  pointer-events: all;
}
.search-box {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  width: 100%;
  max-width: 600px;
  max-height: 78vh;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.search-input-wrap {
  display: flex;
  align-items: center;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--color-border);
  gap: 0.75rem;
  flex-shrink: 0;
}
.search-input-wrap svg {
  color: var(--color-text-muted);
  flex-shrink: 0;
}
#search-input {
  border: none;
  outline: none;
  font-size: 1.05rem;
  flex: 1;
  font-family: var(--font-body);
  padding: 0.25rem 0;
  color: var(--color-text);
  background: transparent;
}
.search-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-muted);
  font-size: 1.1rem;
  padding: 0.25rem;
  border-radius: var(--radius-sm);
}
.search-close:hover {
  background: var(--color-bg);
}
.search-results {
  overflow-y: auto;
  max-height: calc(78vh - 5rem);
  min-height: 0;
}
.search-result-item {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--color-border);
  cursor: pointer;
  transition: background var(--transition);
}
.search-result-item:hover {
  background: var(--color-bg);
}
.search-result-item h4 {
  font-size: 0.95rem;
  margin-bottom: 0.25rem;
  color: var(--color-text);
}
.search-result-item p {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin: 0 0 0.2rem;
}
.search-snippet {
  font-size: 0.78rem;
  color: var(--color-text-muted);
  line-height: 1.5;
}
.search-result-item mark {
  background: #fef08a;
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
}
.search-empty {
  padding: 2rem;
  text-align: center;
  color: var(--color-text-muted);
}

/* ===== Breadcrumb ===== */
.breadcrumb {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 0.75rem 1.5rem;
}
.breadcrumb-inner {
  max-width: var(--content-max);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--color-text-muted);
  flex-wrap: nowrap;
  min-width: 0;
  overflow: hidden;
}
.breadcrumb a {
  color: var(--color-text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}
.breadcrumb a:hover {
  color: var(--color-primary);
}
.breadcrumb-sep {
  color: #cbd5e1;
  flex-shrink: 0;
}
.breadcrumb-current {
  color: var(--color-text);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

/* ===== Guide Layout ===== */
.guide-layout {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 2.5rem 1.5rem;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  gap: 3rem;
  align-items: start;
}
.guide-content {
  min-width: 0;
  overflow-wrap: break-word;
  word-break: break-word;
}
.guide-content h2 {
  margin-top: 2.5rem;
  margin-bottom: 1rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--color-border);
}
.guide-content h3 {
  margin-top: 1.75rem;
  margin-bottom: 0.75rem;
}
.guide-sidebar {
  position: sticky;
  top: 84px;
}

/* ===== Guide Meta ===== */
.guide-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1rem 0 1.75rem;
}
.meta-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.3rem 0.8rem;
  border-radius: var(--radius-pill);
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-difficulty-beginner {
  background: #dcfce7;
  color: #166534;
}
.badge-difficulty-intermediate {
  background: #fef9c3;
  color: #854d0e;
}
.badge-difficulty-advanced {
  background: #fee2e2;
  color: #991b1b;
}
.badge-time {
  background: #f1f5f9;
  color: #475569;
}
.badge-category {
  color: #fff;
}
a.badge-category {
  text-decoration: none;
  cursor: pointer;
  transition: opacity var(--transition);
}
a.badge-category:hover {
  opacity: 0.82;
}
a.badge-difficulty-beginner,
a.badge-difficulty-intermediate,
a.badge-difficulty-advanced {
  text-decoration: none;
  cursor: pointer;
  transition:
    filter var(--transition),
    transform var(--transition);
}
a.badge-difficulty-beginner:hover,
a.badge-difficulty-intermediate:hover,
a.badge-difficulty-advanced:hover {
  filter: brightness(0.9);
  transform: translateY(-1px);
}
.badge-category.active {
  background: var(--color-primary);
  color: #fff;
}
.badge-k8s {
  background: var(--cat-k8s);
}

/* ===== Sidebar Widget ===== */
.sidebar-info-link {
  color: inherit;
  text-decoration: none;
  font-weight: 600;
  transition: color var(--transition);
}
.sidebar-info-link:hover {
  color: var(--color-primary);
}
.sidebar-widget {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-sm);
}
.sidebar-widget h4 {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
  margin-bottom: 1rem;
}
.toc-list {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.toc-list a {
  font-size: 0.875rem;
  color: var(--color-text-muted);
  display: block;
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-sm);
  border-left: 2px solid transparent;
  transition:
    color var(--transition),
    background var(--transition),
    border-color var(--transition);
}
.toc-list a:hover,
.toc-list a.active {
  color: var(--color-primary);
  background: var(--color-primary-light);
  border-left-color: var(--color-primary);
  text-decoration: none;
}
.sidebar-chapter {
  margin-bottom: 0.75rem;
}
.sidebar-chapter:last-child {
  margin-bottom: 0;
}
.sidebar-chapter-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-bottom: 0.25rem;
  opacity: 0.7;
}
.sidebar-guides {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.sidebar-guides a {
  font-size: 0.875rem;
  color: var(--color-text-muted);
  padding: 0.3rem 0;
  display: block;
}
.sidebar-guides a:hover {
  color: var(--color-primary);
}
.sidebar-guides a.current {
  color: var(--color-primary);
  font-weight: 600;
}

/* ===== Guide Nav (prev/next) ===== */
.guide-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 3rem;
}
.guide-nav-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  text-decoration: none;
  color: inherit;
  transition:
    box-shadow var(--transition),
    border-color var(--transition),
    transform var(--transition);
  box-shadow: var(--shadow-sm);
}
.guide-nav-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--color-primary);
  transform: translateY(-2px);
  text-decoration: none;
}
.guide-nav-card.next {
  text-align: right;
}
.guide-nav-label {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.3rem;
}
.guide-nav-card h4 {
  font-size: 0.9rem;
  color: var(--color-primary);
}

/* ===== 404 ===== */
.error-page {
  min-height: 70vh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem;
}
.error-code {
  font-family: var(--font-display);
  font-size: 8rem;
  font-weight: 800;
  color: #d1d5db;
  line-height: 1;
}
.error-title {
  font-size: 1.5rem;
  margin-bottom: 0.75rem;
}

/* ===== Responsive ===== */
@media (max-width: 900px) {
  .guide-layout {
    grid-template-columns: 1fr;
  }
  .guide-sidebar {
    display: none;
  }
}

@media (max-width: 768px) {
  .nav-chapters {
    display: none;
  }
  .nav-progress-label {
    display: none;
  }
  .search-label {
    display: none;
  }
  .hero {
    padding: 3rem 1.5rem;
  }
  .hero-inner {
    grid-template-columns: 1fr;
    gap: 2rem;
  }
  .hero-right {
    display: flex;
    justify-content: center;
  }
  .guide-nav {
    grid-template-columns: 1fr;
  }
  .guides-grid {
    grid-template-columns: 1fr;
  }
  .search-box {
    width: 100%;
    max-width: 100%;
  }
}

@media (max-width: 600px) {
  #nav-cta {
    display: none;
  }
}

@media (max-width: 480px) {
  .section {
    padding: 2.5rem 1rem;
  }
  .hero {
    padding: 2rem 1rem 2.5rem;
  }
  .breadcrumb {
    padding: 0.5rem 1rem;
  }
  .guide-layout {
    padding: 1.5rem 1rem;
  }
  .categories-grid {
    grid-template-columns: 1fr;
  }
  .stats-bar {
    gap: 1.25rem;
    flex-wrap: wrap;
    justify-content: center;
  }
  .guide-nav-card {
    padding: 0.75rem 1rem;
  }
  .nav-inner {
    padding: 0 1rem;
    gap: 0.5rem;
  }
  .nav-progress {
    display: none;
  }
  h1 {
    font-size: clamp(1.75rem, 7vw, 2.4rem);
  }
  h2 {
    font-size: clamp(1.2rem, 5vw, 1.6rem);
  }
  .hero h1 {
    font-size: clamp(1.75rem, 8vw, 2.4rem);
  }
  .guide-content h1 {
    font-size: clamp(1.5rem, 7vw, 2rem);
  }
}

@media (max-width: 375px) {
  .nav-inner {
    padding: 0 0.75rem;
    gap: 0.35rem;
  }
  .nav-logo {
    font-size: 1.05rem;
  }
  .btn-primary {
    padding: 0.4rem 0.85rem;
    font-size: 0.8rem;
  }
  .search-btn {
    padding: 0.35rem 0.6rem;
  }
  .section {
    padding: 2rem 0.75rem;
  }
  .hero {
    padding: 1.75rem 0.75rem 2rem;
  }
  .guide-layout {
    padding: 1.25rem 0.75rem;
  }
}

/* ===== Dark Mode ===== */
:root {
  color-scheme: light;
}

[data-theme="dark"] {
  color-scheme: dark;
  --color-bg: #0f172a;
  --color-surface: #1e293b;
  --color-border: #334155;
  --color-border-strong: #475569;
  --color-text: #f1f5f9;
  --color-text-muted: #94a3b8;
  --color-accent: #6b9ef0;
  --color-primary: #6b9ef0;
  --color-primary-light: rgba(50, 108, 229, 0.15);
  --shadow-sm: 0 1px 4px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.6);
}

body {
  transition:
    background-color 0.25s ease,
    color 0.25s ease;
}

/* Theme toggle button */
.theme-toggle {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  color: var(--color-text-muted);
  width: 2.1rem;
  height: 2.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition:
    border-color var(--transition),
    color var(--transition),
    background var(--transition),
    transform var(--transition);
}
.theme-toggle:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
  transform: rotate(12deg);
}
.theme-toggle .icon-sun {
  display: none;
}
.theme-toggle .icon-moon {
  display: block;
}
[data-theme="dark"] .theme-toggle .icon-sun {
  display: block;
}
[data-theme="dark"] .theme-toggle .icon-moon {
  display: none;
}

/* Hard-coded light color overrides */
[data-theme="dark"] code {
  background: #334155;
  color: #e2e8f0;
}
[data-theme="dark"] pre code {
  background: none;
  color: #e2e8f0;
}

[data-theme="dark"] .site-header {
  background: rgba(15, 23, 42, 0.78);
  border-bottom-color: rgba(51, 65, 85, 0.7);
}

[data-theme="dark"] #nav-cta {
  background: linear-gradient(
    135deg,
    rgba(107, 158, 240, 0.18) 0%,
    rgba(50, 108, 229, 0.12) 100%
  );
  border-color: rgba(107, 158, 240, 0.3);
  color: #93c5fd;
}
[data-theme="dark"] #nav-cta:hover {
  background: linear-gradient(
    135deg,
    rgba(107, 158, 240, 0.28) 0%,
    rgba(50, 108, 229, 0.22) 100%
  );
  border-color: rgba(107, 158, 240, 0.55);
  color: #bfdbfe;
}

[data-theme="dark"] .btn-primary:hover {
  background: #2456b8;
}

[data-theme="dark"] .badge-difficulty-beginner {
  background: rgba(34, 197, 94, 0.15);
  color: #4ade80;
}
[data-theme="dark"] .badge-difficulty-intermediate {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
}
[data-theme="dark"] .badge-difficulty-advanced {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
}
[data-theme="dark"] .badge-time {
  background: #334155;
  color: #94a3b8;
}

[data-theme="dark"] .search-result-item mark {
  background: rgba(253, 224, 71, 0.25);
  color: #fde047;
}

[data-theme="dark"] .error-code {
  color: #334155;
}
[data-theme="dark"] .breadcrumb-sep {
  color: #475569;
}

/* ===== Reading progress bar ===== */
#reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  background: var(--color-primary);
  transition: width 0.1s linear;
  z-index: 300;
  border-radius: 0 var(--radius-pill) var(--radius-pill) 0;
}

/* ===== Applause ===== */
@keyframes toast-glow {
  0%,
  100% {
    box-shadow:
      0 8px 40px rgba(50, 108, 229, 0.35),
      0 0 0 1px rgba(255, 255, 255, 0.15),
      inset 0 1px 0 rgba(255, 255, 255, 0.35);
  }
  50% {
    box-shadow:
      0 8px 56px rgba(36, 86, 184, 0.55),
      0 0 0 2px rgba(50, 108, 229, 0.35),
      inset 0 1px 0 rgba(255, 255, 255, 0.4);
  }
}
@keyframes toast-in {
  0% {
    opacity: 0;
    transform: translateX(-50%) translateY(24px) scale(0.88);
  }
  60% {
    transform: translateX(-50%) translateY(-4px) scale(1.03);
  }
  100% {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
  }
}
.applause-toast {
  position: fixed;
  bottom: 5rem;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  color: #fff;
  padding: 0.75rem 1.9rem;
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(50, 108, 229, 0.4);
  background: linear-gradient(
    135deg,
    rgba(50, 108, 229, 0.72) 0%,
    rgba(36, 86, 184, 0.68) 55%,
    rgba(50, 108, 229, 0.6) 100%
  );
  backdrop-filter: blur(24px) saturate(220%) brightness(1.1);
  -webkit-backdrop-filter: blur(24px) saturate(220%) brightness(1.1);
  box-shadow:
    0 8px 40px rgba(50, 108, 229, 0.35),
    0 0 0 1px rgba(255, 255, 255, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.35);
  z-index: 400;
  opacity: 0;
  transition:
    opacity 0.25s,
    transform 0.25s;
}
.applause-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  animation:
    toast-in 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) both,
    toast-glow 2.2s ease-in-out 0.45s infinite;
}
.applause-toast.hide {
  opacity: 0;
  transform: translateX(-50%) translateY(8px) scale(0.95);
}
.applause-particle {
  position: fixed;
  bottom: 4rem;
  font-size: 1.5rem;
  z-index: 400;
  pointer-events: none;
  animation: particle-float var(--duration, 2s) ease-out forwards;
}
@keyframes particle-float {
  0% {
    transform: translateY(0) translateX(0) scale(1);
    opacity: 1;
  }
  30% {
    opacity: 1;
  }
  100% {
    transform: translateY(-200px) translateX(var(--drift, 0px)) scale(0.6);
    opacity: 0;
  }
}
