/* ============================================================
   ADDITIONAL STYLES — Claude Code Course
   ============================================================ */

/* Typography */
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  margin: 0;
  padding: 0;
  line-height: 1.6;
}

/* Layout */
.main-content {
  margin-left: 260px;
  min-height: 100vh;
  transition: margin-left 0.3s;
}

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 120px 0 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-primary);
  position: sticky;
  top: 0;
  z-index: 100;
  gap: 16px;
  height: 56px;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.desktop-only {
  display: flex;
}

/* Mobile header */
.mobile-header {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
}
.hamburger {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 16px;
}
.mobile-title {
  font-weight: 600;
  font-size: 14px;
}

/* Sidebar open state (mobile) */
.sidebar.open {
  transform: translateX(0) !important;
}

/* Sidebar */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 260px;
  height: 100vh;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  z-index: 200;
  display: flex;
  flex-direction: column;
}
.sidebar-logo {
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  height: 56px;
}
.logo-link {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text-primary);
  margin-bottom: 0;
  flex-shrink: 0;
}
.logo-icon {
  font-size: 24px;
  display: flex;
  align-items: center;
}
.cc-logo {
  width: 28px;
  height: 28px;
  image-rendering: pixelated;
}
.logo-text {
  font-weight: 700;
  font-size: 14px;
  line-height: 1.2;
}
.logo-text small {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 400;
}
.progress-mini {
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  flex: 1;
  min-width: 30px;
  display: none;
}
.progress-mini-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  width: 0%;
  transition: width 0.5s ease;
}
.progress-mini-text {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}
.sidebar-nav {
  padding: 8px 0 24px;
  flex: 1;
}
.nav-part {
  margin-bottom: 4px;
}
.nav-part-label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 12px 16px 4px;
  text-transform: uppercase;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 16px;
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 13px;
  border-left: 2px solid transparent;
  transition: all 0.15s;
}
.nav-link:hover {
  background: var(--bg-card);
  color: var(--text-primary);
  border-left-color: var(--border);
}
.nav-link.active {
  background: var(--bg-card);
  color: var(--accent);
  border-left-color: var(--accent);
  font-weight: 500;
}
.nav-link.done .nav-title::after {
  content: ' ✓';
  color: var(--success);
  font-size: 12px;
}
.nav-num {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 11px;
  color: var(--text-muted);
  min-width: 20px;
}
.nav-title {
  flex: 1;
  line-height: 1.3;
}

/* Breadcrumb */
.breadcrumb {
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  flex-wrap: wrap;
}
.breadcrumb a {
  color: var(--text-secondary);
  text-decoration: none;
}
.breadcrumb a:hover {
  color: var(--accent);
}
.breadcrumb span {
  color: var(--text-primary);
}
.breadcrumb a + a::before,
.breadcrumb span::before {
  content: '›';
  margin-right: 6px;
  color: var(--text-muted);
}

/* Progress bar */
.progress-overview {
  padding: 24px 32px 0;
  max-width: 860px;
  margin: 0 auto;
  width: 100%;
}
.progress-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.progress-header h2 {
  font-size: 15px;
  font-weight: 600;
  margin: 0;
  color: var(--text-secondary);
}
.progress-percentage {
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  color: var(--accent);
  font-weight: 600;
}
.progress-bar-container {
  height: 6px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 32px;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-hover));
  border-radius: 4px;
  transition: width 0.5s ease;
}

/* Search */
.search-container {
  position: relative;
  flex: 1;
  max-width: 420px;
}
.search-input {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 14px;
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
  box-sizing: border-box;
  font-family: inherit;
  transition: border-color 0.15s;
}
.search-input:focus {
  border-color: var(--accent);
}
.search-input::placeholder {
  color: var(--text-muted);
}
.search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
  z-index: 500;
  overflow: hidden;
  display: none;
}
.search-result-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  color: var(--text-primary);
  text-decoration: none;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
.search-result-item:last-child {
  border-bottom: none;
}
.search-result-item:hover {
  background: var(--bg-secondary);
}
.result-num {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text-muted);
  min-width: 22px;
}
.result-title {
  flex: 1;
}

/* Theme toggle */
.theme-toggle {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  color: var(--text-primary);
  transition: all 0.15s;
  flex-shrink: 0;
}
.theme-toggle:hover {
  border-color: var(--accent);
}

/* Hero */
.hero {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 24px 32px 48px;
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  min-width: 0;
  box-sizing: border-box;
}
.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  color: var(--accent);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 20px;
  letter-spacing: 0.03em;
}
.hero-title {
  font-size: clamp(32px, 5vw, 52px);
  font-weight: 800;
  line-height: 1.1;
  margin: 0 0 20px;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}
.hero-cc-logo {
  width: 52px;
  height: 52px;
  image-rendering: pixelated;
  vertical-align: middle;
  margin-right: 10px;
}
.hero-title .accent {
  color: var(--accent);
}
.hero-subtitle {
  font-size: 18px;
  color: var(--text-secondary);
  line-height: 1.7;
  max-width: 560px;
  margin: 0 0 32px;
}
.hero-stats {
  display: flex;
  gap: 32px;
  margin-bottom: 32px;
}
.stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.stat-num {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}
.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.btn-hero {
  font-size: 16px;
  padding: 12px 28px;
}

/* Parts & Module Grid */
.part-section {
  padding: 0 32px 48px;
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  min-width: 0;
  box-sizing: border-box;
}
.part-title {
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 8px;
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-primary);
}
.part-num {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  padding: 2px 8px;
  border-radius: 4px;
}
.part-desc {
  font-size: 14px;
  color: var(--text-muted);
  margin: 0 0 20px;
}
.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}
.module-card {
  display: flex;
  gap: 12px;
  padding: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  text-decoration: none;
  color: var(--text-primary);
  transition: all 0.15s;
  align-items: flex-start;
}
.module-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}
.module-card.completed {
  border-color: var(--success);
}
.module-card.completed .card-num {
  background: color-mix(in srgb, var(--success) 20%, transparent);
  color: var(--success);
}
.card-num {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  padding: 3px 7px;
  border-radius: 4px;
  min-width: 28px;
  text-align: center;
  flex-shrink: 0;
  margin-top: 2px;
}
.card-body h3 {
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 4px;
  color: var(--text-primary);
}
.card-body p {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0 0 10px;
  line-height: 1.5;
}
.card-meta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-muted);
  white-space: nowrap;
}
.badge-beginner { background: color-mix(in srgb, var(--success) 15%, transparent); border-color: color-mix(in srgb, var(--success) 30%, transparent); color: var(--success); }
.badge-intermediate { background: color-mix(in srgb, var(--warning) 15%, transparent); border-color: color-mix(in srgb, var(--warning) 30%, transparent); color: var(--warning); }
.badge-advanced { background: color-mix(in srgb, #a78bfa 15%, transparent); border-color: color-mix(in srgb, #a78bfa 30%, transparent); color: #a78bfa; }
.badge-part { background: color-mix(in srgb, var(--info) 15%, transparent); border-color: color-mix(in srgb, var(--info) 30%, transparent); color: var(--info); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-primary);
  transition: all 0.15s;
  font-family: inherit;
}
.btn:hover {
  border-color: var(--text-secondary);
}
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}
.btn-complete {
  background: var(--bg-card);
  border-color: var(--border);
  color: var(--text-secondary);
}
.btn-complete.completed {
  background: color-mix(in srgb, var(--success) 15%, transparent);
  border-color: var(--success);
  color: var(--success);
}
.btn-next,
a.btn-next {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff !important;
}
.btn-next:hover,
a.btn-next:hover {
  background: var(--accent-hover);
  color: #fff !important;
  text-decoration: none;
}
.btn-prev {
  background: var(--bg-card);
  color: var(--text-secondary);
}

/* Module body */
.module-body {
  max-width: 860px;
  margin: 0 auto;
  padding: 32px 32px 64px;
}
.module-header {
  margin-bottom: 40px;
  padding-bottom: 32px;
  border-bottom: 1px solid var(--border);
}
.module-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.module-body h1 {
  font-size: 36px;
  font-weight: 800;
  margin: 0 0 12px;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}
.subtitle {
  font-size: 18px;
  color: var(--text-secondary);
  margin: 0 0 24px;
  line-height: 1.6;
}
.objectives-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 20px;
  margin-top: 20px;
}
.objectives-box h4 {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin: 0 0 10px;
}
.objectives-box ul {
  margin: 0;
  padding-left: 20px;
}
.objectives-box li {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}
.module-body h2 {
  font-size: 24px;
  font-weight: 700;
  margin: 40px 0 16px;
  color: var(--text-primary);
}
.module-body h3 {
  font-size: 18px;
  font-weight: 600;
  margin: 32px 0 12px;
  color: var(--text-primary);
}
.module-body h4 {
  font-size: 15px;
  font-weight: 600;
  margin: 24px 0 10px;
  color: var(--text-secondary);
}
.module-body p {
  margin: 0 0 16px;
  line-height: 1.8;
  color: var(--text-secondary);
}
.module-body ul, .module-body ol {
  padding-left: 24px;
  margin: 0 0 16px;
}
.module-body li {
  margin-bottom: 6px;
  line-height: 1.7;
  color: var(--text-secondary);
}
.module-body a {
  color: var(--accent);
  text-decoration: none;
}
.module-body a:not(.resource-card):not(.academy-card):hover {
  text-decoration: underline;
}

/* Code blocks */
.code-block-wrapper {
  position: relative;
  margin: 16px 0;
}
.code-block-wrapper pre {
  margin: 0;
  padding: 20px;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow-x: auto;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 13px;
  line-height: 1.6;
}
.code-block-wrapper code {
  background: none;
  padding: 0;
  font-family: inherit;
  font-size: inherit;
}
.copy-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 4px 10px;
  font-size: 11px;
  color: var(--text-muted);
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}
.copy-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.copy-btn.copied {
  border-color: var(--success);
  color: var(--success);
}

/* Inline code */
.module-body code:not(pre code) {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 6px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.875em;
  color: var(--accent);
}

/* Callouts */
.callout {
  display: block;
  padding: 14px 18px;
  border-radius: 8px;
  border-left: 3px solid;
  margin: 20px 0;
  font-size: 14px;
  line-height: 1.7;
  background: var(--bg-card);
}
.callout strong {
  display: inline;
}
.callout code {
  display: inline;
  white-space: nowrap;
}
.callout-tip { border-color: var(--success); }
.callout-warning { border-color: var(--warning); }
.callout-info { border-color: var(--info); }

/* Tables */
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
  margin: 20px 0;
}
.module-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 20px 0;
  font-size: 14px;
}
.module-body th {
  background: var(--bg-card);
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
}
.module-body td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  vertical-align: top;
}
.module-body tr:hover td {
  background: var(--bg-card);
}

/* Exercise section */
.exercise-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  margin: 40px 0;
}
.exercise-section h3 {
  margin: 0 0 12px;
  font-size: 18px;
}
.exercise-section ol {
  margin: 12px 0;
}

/* Resources */
.resources-section {
  margin: 40px 0;
}
.resources-section h3 {
  margin: 0 0 16px;
}
.resources-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}
.resource-card {
  display: block;
  padding: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  text-decoration: none;
  color: var(--text-primary);
  transition: all 0.15s;
}
.resource-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}
.resource-type {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin-bottom: 6px;
}
.resource-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text-primary);
}
.resource-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* Bottom nav */
.module-nav-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 32px 0;
  margin-top: 40px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 12px;
}
.nav-prev-next {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

/* Footer */
.site-footer {
  text-align: center;
  padding: 48px 32px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 13px;
  max-width: 860px;
  margin: 0 auto;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}
.site-footer a {
  color: var(--accent);
  text-decoration: none;
}
.site-footer .version-tag {
  display: inline-block;
  margin-top: 8px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 8px;
  color: var(--text-muted);
}
/* Agilize logo — dark/light switching */
.agilize-logo { height: 18px; width: auto; vertical-align: middle; }
.agilize-logo-light { display: none; }
html.light .agilize-logo-dark { display: none; }
html.light .agilize-logo-light { display: inline; }
.footer-by {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-bottom: 8px;
  font-size: 12px;
  color: var(--text-muted);
  text-decoration: none;
}
.footer-by .agilize-logo { height: 16px; }
.sidebar-by {
  display: flex;
  align-items: center;
}
.sidebar-by .agilize-logo { height: 18px; opacity: 0.5; transition: opacity 0.2s; }
.sidebar-by:hover .agilize-logo { opacity: 1; }
.hero-credits {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 20px;
  font-size: 13px;
  color: var(--text-muted);
}
.hero-credits-logo { height: 14px; width: auto; }
.anthropic-logo-light { display: none; }
html.light .anthropic-logo-dark { display: none; }
html.light .anthropic-logo-light { display: inline; }
.hero-credits-sep { opacity: 0.4; }
.hero-credits-by { display: inline-flex; align-items: center; }
.hero-credits-by .agilize-logo { height: 18px; }
.sidebar-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px 14px;
  border-top: 1px solid var(--border);
  margin-top: auto;
}
.sidebar-bottom .version-tag {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 7px;
}

/* Academy sidebar link highlight */
.nav-link-academy {
  margin: 8px 12px 0;
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-radius: 6px;
}
.nav-link-academy .nav-title {
  color: var(--accent);
  font-weight: 600;
}
.nav-link-academy .nav-num {
  color: var(--accent);
}
.nav-link-academy:hover {
  background: color-mix(in srgb, var(--accent) 20%, transparent);
}

/* Deep Study sidebar link */
.nav-link-deepstudy {
  margin: 12px 12px 0;
  background: color-mix(in srgb, #C9A87C 8%, transparent);
  border: 1px solid color-mix(in srgb, #C9A87C 22%, var(--border));
  border-radius: 6px;
}
.nav-link-deepstudy .nav-title {
  color: #C9A87C;
  font-weight: 600;
}
.nav-link-deepstudy .nav-num {
  color: #C9A87C;
}
.nav-link-deepstudy:hover {
  background: color-mix(in srgb, #C9A87C 18%, transparent);
}
.nav-part-courses {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
/* YouTube custom icon */
.icon-yt { width: 1em; height: 1em; vertical-align: -0.125em; }
.nav-part-courses .nav-num i.uil-robot { color: #a78bfa; }

/* Deep Study banner */
/* Recommended Courses */
.recommended-courses {
  max-width: 860px;
  margin: 0 auto;
  padding: 48px 32px 0;
  width: 100%;
  box-sizing: border-box;
}
.recommended-courses .section-title {
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.recommended-courses .section-title i { font-size: 22px; }
.recommended-courses .section-title .icon-yt { width: 22px; height: 22px; }
.recommended-courses .section-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  margin: 0 0 20px;
}
.recommended-courses .section-subtitle a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}
.recommended-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.recommended-card {
  display: flex;
  gap: 14px;
  padding: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  text-decoration: none;
  color: var(--text-primary);
  transition: border-color 0.2s, transform 0.2s;
}
.recommended-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}
.recommended-card-icon {
  font-size: 24px;
  flex-shrink: 0;
  line-height: 1;
}
.recommended-card-icon .icon-yt { width: 24px; height: 24px; }
.recommended-card-icon .uil-robot { color: #a78bfa; }
.recommended-card-body h3 {
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 6px;
  line-height: 1.3;
}
.recommended-card-body p {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0 0 10px;
  line-height: 1.5;
}
.recommended-card-meta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.recommended-card-meta .badge { font-size: 10px; padding: 2px 6px; }
@media (max-width: 768px) {
  .recommended-grid { grid-template-columns: 1fr; }
}

.deep-study-banner {
  max-width: 860px;
  margin: 0 auto;
  padding: 48px 32px;
  width: 100%;
  box-sizing: border-box;
}
.deep-study-card {
  display: block;
  padding: 32px 36px;
  border-radius: 12px;
  background: linear-gradient(135deg, color-mix(in srgb, #C9A87C 8%, var(--bg-card)), var(--bg-card));
  border: 1px solid color-mix(in srgb, #C9A87C 30%, var(--border));
  text-decoration: none;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
}
.deep-study-card:hover {
  border-color: color-mix(in srgb, #C9A87C 55%, var(--border));
  box-shadow: 0 4px 24px color-mix(in srgb, #C9A87C 10%, transparent);
  transform: translateY(-2px);
}
.deep-study-label {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1.5px;
  color: #C9A87C;
  margin-bottom: 16px;
  font-family: 'JetBrains Mono', monospace;
}
.deep-study-title {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 12px;
  line-height: 1.3;
}
.deep-study-title span {
  color: #C9A87C;
}
.deep-study-desc {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.6;
  margin: 0 0 20px;
  max-width: 640px;
}
.deep-study-cta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: #C9A87C;
  transition: gap 0.15s;
}
.deep-study-card:hover .deep-study-cta {
  gap: 10px;
}

/* Hero cross-reference link — animated gradient border */
.hero-xref-wrap {
  display: inline-block;
  border-radius: 7px;
  padding: 1px;
  margin-bottom: 48px;
  background: conic-gradient(from 0deg, #C9A87C, #d4a574, #b07eda, #7eb8da, #7ec9a0, #C9A87C);
}
.hero-xref {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.6rem 1.1rem 0.6rem 0.6rem;
  background: var(--bg-primary);
  border: none;
  border-radius: 6px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.85rem;
  transition: background 0.25s, color 0.25s;
}
.hero-xref-wrap:hover .hero-xref {
  color: var(--text-primary);
  background: color-mix(in srgb, var(--bg-primary) 92%, transparent);
}
.hero-xref-badge {
  background: rgba(232, 147, 122, 0.15);
  color: #C9A87C;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.3em 0.6em;
  border-radius: 4px;
  flex-shrink: 0;
}
.hero-xref-text {
  font-weight: 500;
  color: var(--text-secondary);
}
.hero-xref-ext {
  color: #C9A87C;
  opacity: 0.6;
  flex-shrink: 0;
  transition: opacity 0.2s;
}
.hero-xref:hover .hero-xref-ext {
  opacity: 1;
}
html.light .hero-xref-badge {
  background: rgba(180, 110, 20, 0.12);
  color: #9B5E0E;
}
html.light .hero-xref-ext {
  color: #9B5E0E;
}

/* ============================================================
   RESPONSIVE — Mobile First
   ============================================================ */

/* Sidebar overlay backdrop */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 199;
  backdrop-filter: blur(2px);
}
.sidebar-backdrop.active {
  display: block;
}

/* ============================================================
   Custom Components — permission-modes, tools-grid,
   decision-tree, skill-catalog, use-cases-grid, hierarchy-diagram
   ============================================================ */

/* --- Permission Modes --- */
.permission-modes {
  display: flex;
  flex-direction: row;
  gap: 16px;
  flex-wrap: wrap;
}

.permission-mode {
  flex: 1 1 0;
  min-width: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
}

.permission-mode.recommended {
  border-left: 3px solid var(--accent);
}

.permission-mode.warning-mode {
  border-left: 3px solid var(--warning);
}

.mode-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.mode-name {
  margin: 0;
  font-size: 16px;
  color: var(--text-primary);
}

.mode-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  white-space: nowrap;
}

.recommended-badge {
  background: rgba(var(--accent-rgb, 99, 102, 241), 0.15);
  color: var(--accent);
}

.danger-badge {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}

.mode-description {
  margin: 0;
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* --- Tools Grid --- */
.tools-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.tool-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px;
}

.tool-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.tool-icon {
  font-size: 20px;
  flex-shrink: 0;
  color: var(--accent);
  filter: drop-shadow(0 0 6px rgba(247, 129, 102, 0.55));
}

html.light .tool-icon,
html.light .hierarchy-icon {
  filter: none;
}

.tool-name {
  margin: 0;
  font-size: 15px;
  color: var(--text-primary);
}

.tool-description {
  margin: 0;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* --- Decision Tree --- */
.decision-tree {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.decision-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  flex-wrap: wrap;
}

.decision-condition {
  flex: 1 1 0;
  min-width: 0;
  font-size: 14px;
  color: var(--text-secondary);
}

.decision-arrow {
  color: var(--text-muted);
  font-size: 16px;
  flex-shrink: 0;
}

.tool-badge {
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  background: rgba(var(--accent-rgb, 99, 102, 241), 0.15);
  color: var(--accent);
  white-space: nowrap;
  flex-shrink: 0;
}

.tool-badge.preferred {
  background: rgba(var(--accent-rgb, 99, 102, 241), 0.25);
}

/* --- Skill Catalog --- */
.skill-catalog {
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.skill-row {
  display: flex;
  align-items: baseline;
  gap: 16px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.skill-row:last-child {
  border-bottom: none;
}

.skill-trigger {
  font-family: 'Fira Code', 'JetBrains Mono', monospace;
  font-size: 13px;
  color: var(--accent);
  flex-shrink: 0;
  min-width: 100px;
}

.skill-desc {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
  flex: 1;
}

.skill-badge {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  border: 1px dashed var(--border);
  border-radius: 4px;
  padding: 2px 7px;
  flex-shrink: 0;
  white-space: nowrap;
}

/* --- Use Cases Grid --- */
.use-cases-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.use-case-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
}

.use-case-icon {
  font-size: 24px;
  margin-bottom: 10px;
}

.use-case-title {
  margin: 0 0 8px;
  font-size: 15px;
  color: var(--text-primary);
}

.use-case-desc {
  margin: 0;
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* --- Hierarchy Diagram --- */
.hierarchy-diagram {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
}

.hierarchy-level {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px;
}

.hierarchy-level-1 {
  border-left: 3px solid var(--accent);
}

.hierarchy-level-2 {
  border-left: 3px solid var(--text-secondary);
}

.hierarchy-level-3 {
  border-left: 3px solid var(--text-muted);
}

.hierarchy-icon {
  font-size: 22px;
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  filter: drop-shadow(0 0 6px rgba(247, 129, 102, 0.55));
}

.hierarchy-content {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.hierarchy-content strong {
  color: var(--text-primary);
}

.hierarchy-content p {
  margin: 4px 0 0;
}

.hierarchy-arrow {
  text-align: center;
  padding: 6px 0;
  font-size: 13px;
  color: var(--text-muted);
}

/* Tablet (up to 1024px) */
@media (max-width: 1024px) {
  .main-content {
    margin-left: 220px;
  }
  .sidebar {
    width: 220px;
  }
  .module-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Tools grid: 3 cols → 2 cols at tablet */
  .tools-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  html.terminal .terminal-bar {
    padding-left: calc(220px + 1rem);
  }
}

/* Prevent horizontal overflow — clip at html level only, body stays natural */
html {
  max-width: 100%;
}
/* All content must wrap within its container */
.module-body,
.module-body p,
.module-body li,
.module-body td,
.module-body th,
.callout {
  overflow-wrap: break-word;
  word-wrap: break-word;
}
/* Inline code: never break mid-word, keep readable */
.module-body code:not(pre code) {
  white-space: nowrap;
}
/* Table wrapper: tables scroll inside their wrapper, not the page */
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}

/* Mobile (up to 768px) */
@media (max-width: 768px) {
  /* Sidebar: slide-in drawer */
  .sidebar {
    width: 280px;
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 300;
  }
  .sidebar.open {
    transform: translateX(0);
  }

  /* Main content: full width */
  .main-content {
    margin-left: 0;
  }

  /* Mobile header: always visible */
  .mobile-header {
    display: flex;
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 10px 16px;
  }

  /* Topbar: compact on mobile */
  .topbar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 10px 16px;
  }
  .topbar .breadcrumb {
    font-size: 12px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    flex: none;
  }
  .topbar-right {
    width: 100%;
  }
  .search-container {
    max-width: 100%;
    width: 100%;
  }
  .desktop-only {
    display: none !important;
  }

  /* Hero */
  .hero {
    padding: 28px 16px 28px;
  }
  .hero-title {
    font-size: 28px;
    margin-bottom: 14px;
  }
  .hero-subtitle {
    font-size: 15px;
    margin-bottom: 24px;
  }
  .hero-stats {
    gap: 16px;
    flex-wrap: wrap;
  }
  .stat-num {
    font-size: 22px;
  }
  .btn-hero {
    width: 100%;
    justify-content: center;
    font-size: 15px;
    padding: 12px 20px;
  }

  /* Progress overview */
  .progress-overview {
    padding: 16px 16px 0;
  }

  /* Parts & Module Grid */
  .part-section {
    padding: 0 16px 28px;
  }
  .part-title {
    font-size: 17px;
    flex-wrap: wrap;
    gap: 8px;
  }
  .module-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .module-card {
    padding: 14px;
  }

  /* Module body */
  .module-body {
    padding: 20px 16px 48px;
    width: 100%;
    box-sizing: border-box;
    min-width: 0;
  }
  .module-header {
    margin-bottom: 28px;
    padding-top: 8px;
    padding-bottom: 24px;
  }
  .module-body h1 {
    font-size: 24px;
  }
  .subtitle {
    font-size: 15px;
  }
  .module-body h2 {
    font-size: 20px;
    margin: 28px 0 12px;
  }
  .module-body h3 {
    font-size: 17px;
    margin: 24px 0 10px;
  }

  /* Code blocks: horizontal scroll, no negative margin */
  .code-block-wrapper {
    margin: 12px 0;
    border-radius: 8px;
    max-width: 100%;
    overflow: hidden;
  }
  .code-block-wrapper pre {
    border-radius: 8px;
    padding: 16px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
  }
  .code-block-wrapper pre code {
    white-space: pre;
    word-break: normal;
    overflow-wrap: normal;
  }
  .copy-btn {
    top: 6px;
    right: 6px;
    padding: 3px 8px;
    font-size: 10px;
  }

  /* Tables: scroll inside .table-wrapper */
  .table-wrapper {
    margin: 12px 0;
  }
  .module-body table {
    min-width: 500px;
  }
  .module-body th,
  .module-body td {
    padding: 8px 10px;
    font-size: 13px;
  }

  /* Callouts */
  .callout {
    font-size: 13px;
    padding: 12px 14px;
  }

  /* Exercise */
  .exercise-section {
    padding: 18px 16px;
    margin: 28px 0;
    border-radius: 0;
    border-left: none;
    border-right: none;
  }

  /* Resources grid */
  .resources-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  /* Bottom nav */
  .module-nav-bottom {
    flex-direction: column;
    align-items: stretch;
    padding: 24px 0;
    gap: 10px;
  }
  .nav-prev-next {
    flex-direction: column;
    gap: 8px;
  }
  .btn-complete,
  .btn-next,
  .btn-prev {
    width: 100%;
    justify-content: center;
  }

  /* Search results */
  .search-results {
    position: fixed;
    top: auto;
    left: 16px;
    right: 16px;
    max-height: 60vh;
    overflow-y: auto;
  }

  /* Objectives box */
  .objectives-box {
    padding: 14px 16px;
    overflow-x: hidden;
  }
  .objectives-box ul li,
  .module-body li {
    word-wrap: break-word;
    overflow-wrap: break-word;
  }

  /* Deep Study banner */
  .deep-study-banner {
    padding: 32px 16px;
  }
  .deep-study-card {
    padding: 24px 20px;
  }
  .deep-study-title {
    font-size: 1.3rem;
  }

  /* Hero cross-reference */
  .hero-xref {
    font-size: 0.75rem;
    padding: 0.5rem 0.8rem 0.5rem 0.5rem;
    gap: 0.5rem;
  }
  .hero-xref-badge {
    font-size: 0.55rem;
  }
  .hero-xref-wrap {
    margin-bottom: 32px;
  }

  /* Site footer */
  .site-footer {
    padding: 32px 16px;
    font-size: 12px;
  }

  /* Module meta badges */
  .module-meta {
    flex-wrap: wrap;
    gap: 6px;
  }

  /* --- Mobile: Permission Modes --- */
  .permission-modes {
    flex-direction: column;
  }

  .permission-mode {
    flex: 1 1 auto;
  }

  /* --- Mobile: Tools Grid --- */
  .tools-grid {
    grid-template-columns: 1fr;
  }

  /* --- Mobile: Decision Tree --- */
  .decision-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .decision-condition {
    flex: none;
  }

  /* --- Mobile: Skill Catalog --- */
  .skill-row {
    flex-direction: column;
    gap: 4px;
  }

  .skill-trigger {
    min-width: auto;
  }

  /* --- Mobile: Use Cases Grid --- */
  .use-cases-grid {
    grid-template-columns: 1fr;
  }

  /* --- Mobile: Hierarchy Diagram --- */
  .hierarchy-level {
    flex-direction: column;
    gap: 10px;
  }
}

/* Small mobile (up to 480px) */
@media (max-width: 480px) {
  .hero-title {
    font-size: 24px;
  }
  .hero-badge {
    font-size: 11px;
  }
  .module-body h1 {
    font-size: 22px;
  }
  .module-meta {
    gap: 4px;
  }
  .badge {
    font-size: 10px;
    padding: 2px 6px;
  }
}

/* ---------------------------------------------------------------
   Anthropic Academy — Cards
--------------------------------------------------------------- */
.academy-group-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 48px;
  margin-bottom: 20px;
  padding-top: 32px;
  border-top: 1px solid var(--border);
}
.content-section:first-of-type .academy-group-header {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}
.academy-group-header h2 {
  font-size: 1.125rem;
  font-weight: 600;
  margin: 0;
}
.academy-group-header > i {
  font-size: 1.25rem;
  color: var(--accent);
}
.academy-group-count {
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2px 10px;
  margin-left: auto;
}

.academy-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.academy-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  text-decoration: none;
  color: var(--text-primary);
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}
.academy-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(0,0,0,0.25);
}
.academy-card-wide {
  grid-column: 1 / -1;
}
.academy-card-wide .academy-card-highlights {
  display: flex;
  flex-wrap: wrap;
}

.academy-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.academy-card-category {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 2px 8px;
  border-radius: 4px;
}
.academy-cat-code    { background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent); }
.academy-cat-api     { background: color-mix(in srgb, var(--info) 15%, transparent);   color: var(--info); }
.academy-cat-mcp     { background: color-mix(in srgb, var(--success) 15%, transparent); color: var(--success); }
.academy-cat-cloud   { background: color-mix(in srgb, #a78bfa 15%, transparent); color: #a78bfa; }
.academy-cat-foundation { background: color-mix(in srgb, var(--warning) 15%, transparent); color: var(--warning); }
.academy-cat-fluency { background: color-mix(in srgb, #f472b6 15%, transparent); color: #f472b6; }

.academy-card-cert {
  font-size: 0.6875rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}
.academy-card-title {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.35;
  margin: 0;
  color: var(--text-primary);
}
.academy-card-desc {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  line-height: 1.55;
  flex: 1;
}
.academy-card-highlights {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.academy-highlight {
  font-size: 0.6875rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 8px;
  color: var(--text-secondary);
  white-space: nowrap;
}
.academy-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.academy-card-meta {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.academy-card-meta span {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 5px;
}
.academy-card-cta {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
  flex-shrink: 0;
}

@media (max-width: 600px) {
  .academy-grid { grid-template-columns: 1fr; }
  .academy-card-wide { grid-column: 1; }
}

/* ============================================================
   TERMINAL THEME — CRT Effects, Animations & Decorations
   ============================================================ */

/* --- Terminal Bar --- */
.terminal-bar {
  height: 0;
  overflow: visible;
  position: relative;
}
html.terminal .terminal-bar {
  height: 56px;
  overflow: visible;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 0 24px 0 calc(260px + 24px);
  font-size: 0.7rem;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
  position: sticky;
  top: 0;
  z-index: 150;
}
/* In terminal mode, hide the regular topbar — search lives in terminal bar */
html.terminal .topbar {
  display: none;
}
.terminal-bar .terminal-dots,
.terminal-bar .terminal-title { display: none; }
html.terminal .terminal-bar .terminal-dots,
html.terminal .terminal-bar .terminal-title { display: flex; }
.terminal-dots { display: flex; gap: 0.35rem; }
.terminal-dots span { width: 10px; height: 10px; border-radius: 50%; }
.terminal-dots span:nth-child(1) { background: #da7e7e; }
.terminal-dots span:nth-child(2) { background: #dac87e; }
.terminal-dots span:nth-child(3) { background: #7ec9a0; }
.terminal-title { flex: 0 0 auto; text-align: center; letter-spacing: 0.04em; }

/* Terminal bar search — hidden by default, shown in terminal mode */
.terminal-bar-search { display: none; }
html.terminal .terminal-bar-search {
  display: block;
  flex: 1;
  max-width: 420px;
  margin: 0 auto;
}
html.terminal .terminal-bar-search .search-input {
  height: 30px;
  font-size: 12px;
  padding: 0 12px;
  background: var(--bg-card);
  border-radius: 0;
}

/* --- Theme Switcher (3-theme) --- */
.theme-switcher {
  position: fixed;
  top: 10px;
  right: 24px;
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.theme-switcher .theme-toggle {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
  font-size: 16px;
  flex-shrink: 0;
  padding: 0;
}
.theme-switcher .theme-toggle:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border-color: var(--accent);
}
.theme-switcher .theme-toggle .icon-sun { display: block; }
.theme-switcher .theme-toggle .icon-moon { display: none; }
html.light .theme-switcher .theme-toggle .icon-sun { display: none; }
html.light .theme-switcher .theme-toggle .icon-moon { display: block; }
html.terminal .theme-switcher .theme-toggle .icon-sun { display: block; }
html.terminal .theme-switcher .theme-toggle .icon-moon { display: none; }
.theme-switcher .theme-toggle svg { width: 18px; height: 18px; }

.theme-btn-terminal {
  height: 36px;
  width: 58px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-muted);
  cursor: pointer;
  padding: 0 0.55rem;
  font-size: 0.68rem;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.theme-btn-terminal:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border-color: var(--accent);
}
html.terminal .theme-btn-terminal {
  color: var(--accent);
  border-color: rgba(232, 147, 122, 0.4);
  background: rgba(232, 147, 122, 0.08);
}
.cli-typing { display: inline-flex; align-items: center; }
.cli-text { color: var(--accent); }
.cli-cursor {
  animation: blink-cursor 1s step-end infinite;
  color: var(--accent);
}
.theme-btn-terminal > span:first-child {
  color: var(--accent);
}
@keyframes blink-cursor {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* In terminal mode, dock the switcher inside the terminal bar */
html.terminal .theme-switcher {
  position: static;
  transform: none;
  margin-left: auto;
}
html.terminal .theme-switcher .theme-toggle,
html.terminal .theme-btn-terminal {
  height: 26px;
  border-color: var(--border);
  background: transparent;
}
html.terminal .theme-switcher .theme-toggle { width: 26px; }
html.terminal .theme-switcher .theme-toggle svg { width: 14px; height: 14px; }
html.terminal .theme-btn-terminal { font-size: 0.62rem; padding: 0 0.4rem; width: 50px; }

/* --- CRT Scanlines --- */
html.terminal body::after {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent, transparent 2px,
    rgba(0,0,0,0.18) 2px, rgba(0,0,0,0.18) 4px
  );
  pointer-events: none;
  z-index: 9999;
}

/* --- CRT Vignette --- */
html.terminal body::before {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: radial-gradient(ellipse at center, transparent 50%, rgba(0,0,0,0.45) 100%);
  pointer-events: none;
  z-index: 9998;
}

/* --- CRT Rolling Interference Band --- */
.crt-interference { display: none; }
html.terminal .crt-interference {
  display: block;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 80px;
  pointer-events: none;
  z-index: 9997;
  background: linear-gradient(
    180deg,
    transparent 0%,
    rgba(232,147,122,0.03) 30%,
    rgba(126,184,218,0.04) 50%,
    rgba(232,147,122,0.03) 70%,
    transparent 100%
  );
  animation: roll-band 4s linear infinite;
}
@keyframes roll-band {
  0%   { top: -80px; }
  100% { top: 100vh; }
}

/* --- CRT Horizontal Tear --- */
.crt-tear { display: none; }
html.terminal .crt-tear {
  display: block;
  position: fixed;
  left: 0; right: 0;
  height: 2px;
  pointer-events: none;
  z-index: 9997;
  background: rgba(232,147,122,0.12);
  animation: tear-flash 5s step-end infinite;
}
@keyframes tear-flash {
  0%, 100%  { top: 30%; opacity: 0; }
  15%       { top: 30%; opacity: 0; }
  15.5%     { top: 30%; opacity: 1; transform: scaleX(1); }
  16%       { top: 30%; opacity: 0; }
  45%       { top: 65%; opacity: 0; }
  45.5%     { top: 65%; opacity: 1; transform: scaleX(0.7); }
  46%       { top: 65%; opacity: 0; }
  75%       { top: 15%; opacity: 0; }
  75.3%     { top: 15%; opacity: 1; transform: scaleX(0.85); }
  76%       { top: 15%; opacity: 0; }
}

/* --- Screen Flicker --- */
html.terminal body { animation: screen-flicker 5s ease-in-out infinite; }
@keyframes screen-flicker {
  0%, 100% { opacity: 1; }
  70%      { opacity: 1; }
  70.5%    { opacity: 0.92; }
  71%      { opacity: 1; }
  85%      { opacity: 1; }
  85.3%    { opacity: 0.95; }
  85.6%    { opacity: 1; }
}

/* --- Glitch Burst (sporadic) --- */
@keyframes glitch-burst {
  0%, 88%, 100% { transform: none; text-shadow: 0 0 20px rgba(232,147,122,0.15); }
  89%  { transform: translate(-3px, 0); text-shadow: -3px 0 rgba(126,184,218,0.6), 3px 0 rgba(232,147,122,0.6); }
  90%  { transform: translate(3px, 1px) skewX(-2deg); text-shadow: 3px 0 rgba(126,201,160,0.5), -3px 0 rgba(176,126,218,0.5); }
  91%  { transform: translate(-1px, -1px); text-shadow: -2px 0 rgba(232,147,122,0.7), 2px 0 rgba(126,184,218,0.4); }
  92%  { transform: translate(2px, 0) skewX(1deg); text-shadow: 1px 0 rgba(218,200,126,0.5), -1px 0 rgba(232,147,122,0.5); }
  93%  { transform: none; text-shadow: 0 0 20px rgba(232,147,122,0.15); }
}

/* --- Sweep Line (card decoration) --- */
@keyframes sweep-line {
  0%, 100% { top: -2px; opacity: 0; }
  5%       { opacity: 1; }
  30%      { top: 100%; opacity: 0.6; }
  35%, 100% { opacity: 0; }
}

/* --- Terminal Font Override --- */
html.terminal body {
  font-family: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
}

/* --- Terminal Heading Glow & Glitch --- */
html.terminal .hero-title,
html.terminal .part-title,
html.terminal .section-title {
  text-shadow: 0 0 20px rgba(232, 147, 122, 0.15);
  animation: glitch-burst 7s ease-in-out infinite;
}
html.terminal .hero-title .accent {
  text-shadow: 0 0 30px rgba(232, 147, 122, 0.3);
}

/* Staggered glitch on part titles */
html.terminal .part-section:nth-child(odd) .part-title { animation-delay: -3s; }
html.terminal .part-section:nth-child(3n) .part-title { animation-duration: 11s; animation-delay: -5s; }
html.terminal .part-section:nth-child(4n) .part-title { animation-duration: 7s; animation-delay: -1s; }

/* --- Terminal Stat Glow --- */
html.terminal .stat-num {
  text-shadow: 0 0 12px rgba(232, 147, 122, 0.3);
  animation: glitch-burst 6s ease-in-out infinite;
}
html.terminal .stat:nth-child(2) .stat-num { animation-delay: -1.5s; }
html.terminal .stat:nth-child(3) .stat-num { animation-delay: -3s; }

/* --- Terminal Part Number Prefix --- */
html.terminal .part-num::before { content: '$ '; color: var(--accent); }

/* --- Terminal Card Decorations --- */
html.terminal .module-card {
  position: relative;
}
html.terminal .module-card::before {
  content: '\250C\2500';
  position: absolute;
  top: 0.4rem;
  left: 0.6rem;
  color: var(--border);
  font-size: 0.7rem;
  font-family: 'JetBrains Mono', monospace;
}
html.terminal .module-card::after {
  content: '';
  position: absolute;
  left: 0; right: 0;
  height: 1px;
  background: rgba(232,147,122,0.1);
  animation: sweep-line 12s linear infinite;
  pointer-events: none;
}
html.terminal .module-card:nth-child(odd)::after { animation-delay: -4s; }
html.terminal .module-card:nth-child(3n)::after { animation-delay: -8s; animation-duration: 15s; }

/* --- Terminal Nav Prefix --- */
html.terminal .nav-part-label::before {
  content: '# ';
  color: var(--accent);
}

/* --- Terminal Footer EOF --- */
html.terminal .site-footer::before {
  content: '// EOF';
  display: block;
  color: rgba(232,147,122,0.4);
  margin-bottom: 1rem;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  font-family: 'JetBrains Mono', monospace;
}

/* --- Terminal Hero Badge Prefix --- */
html.terminal .hero-badge::before {
  content: '> ';
  color: var(--accent);
  font-family: 'JetBrains Mono', monospace;
}

/* --- Terminal Progress Bar --- */
html.terminal .progress-fill {
  background: linear-gradient(90deg, var(--accent), #b07eda);
}

/* --- Terminal Sidebar --- */
html.terminal .sidebar {
  border-right-color: var(--border);
}
html.terminal .nav-link:hover {
  border-left-color: var(--accent);
}

/* --- Hide default topbar theme toggle when switcher is present --- */
.theme-switcher ~ .topbar .theme-toggle,
.has-theme-switcher .topbar .desktop-only[data-testid="theme-toggle"] {
  display: none;
}

/* --- Mobile: keep switcher visible --- */
@media (max-width: 768px) {
  .theme-switcher {
    top: 0.5rem;
    right: 0.5rem;
  }
  .theme-switcher .theme-toggle { width: 32px; height: 32px; }
  .theme-btn-terminal { height: 32px; width: 50px; font-size: 0.6rem; }

  /* Hide mobile header theme toggle when switcher exists */
  .mobile-header .theme-toggle { display: none !important; }

  /* Terminal bar: no sidebar offset on mobile */
  html.terminal .terminal-bar {
    padding: 0 0.75rem;
    font-size: 0.65rem;
    height: 48px;
  }
}
