﻿:root {
  --bg: #090d12;
  --surface: #111824;
  --surface-hover: #172031;
  --border: #263241;
  --border-hover: #3b4d64;
  --text: #eef4ff;
  --text-dim: #c8d2df;
  --text-muted: #7f8b9d;
  --accent: #5b8cff;
  --accent-dim: rgba(91, 140, 255, 0.14);
  --accent-cyan: #36c5d8;
  --accent-purple: #8b6cff;
  --accent-amber: #e8a84f;
  --success: #2fbf71;
  --warning: #e8a84f;
  --danger: #ff5f56;
  --code-bg: #1e1e1e;
  --source-bg: #101722;
  --gradient-1: linear-gradient(135deg, #5b8cff 0%, #36c5d8 100%);
  --gradient-2: linear-gradient(135deg, #5b8cff 0%, #8b6cff 56%, #ff5f56 100%);
  --radius: 8px;
  --radius-sm: 6px;
  --tech-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
  --tech-glow: 0 0 0 1px rgba(91, 140, 255, 0.08);
  /* syntax tokens (VS Code style) */
  --syn-kw: #569cd6;
  --syn-dt: #4ec9b0;
  --syn-fu: #dcdcaa;
  --syn-st: #ce9178;
  --syn-num: #b5cea8;
  --syn-ma: #c586c0;
  --syn-co: #6a9955;
}

/* UI-26 Achievement Matrix */
.records-drawer-panel {
  background: #070a0f !important;
}

.records-drawer-body {
  max-width: 1404px !important;
  padding: 16px 18px 24px !important;
}

.records-header,
.records-heatmap-card,
.records-next-card,
.records-matrix-card,
.records-rail,
.records-strip {
  border-radius: 12px !important;
  background: linear-gradient(180deg, #111824, #0d1420) !important;
  border: 1px solid #253247 !important;
  box-shadow: 0 16px 36px rgba(0,0,0,0.28) !important;
}

.records-header {
  min-height: 108px !important;
  padding: 22px 32px !important;
  gap: 28px !important;
}

.records-header-streak-ring {
  border-color: #e8a84f !important;
  box-shadow: 0 0 0 6px rgba(232,168,79,0.08);
}

.records-header-metric {
  border-left-color: rgba(37,50,71,0.72) !important;
}

.records-header-btn,
.records-filter-chip,
.records-next-btn.secondary,
.records-matrix-page {
  border-color: #33445f !important;
  background: #141d2b !important;
  color: #c8d2df !important;
}

.records-header-btn:hover {
  border-color: #e8a84f !important;
  color: #eef4ff !important;
}

.records-filter-chip.active,
.records-matrix-page.active,
.records-next-btn.primary {
  background: #5b8cff !important;
  border-color: #5b8cff !important;
  color: #ffffff !important;
}

.records-next-btn.primary:hover {
  background: #6fa0ff !important;
}

.records-heat-cell {
  background: #1a1a1a !important;
  border-color: rgba(255,255,255,0.04) !important;
}

.records-heat-cell.lv1 { background: #16345b !important; }
.records-heat-cell.lv2 { background: #315fd9 !important; }
.records-heat-cell.lv3 { background: #5b8cff !important; }

.records-matrix-table th,
.records-matrix-table td,
.records-mobile-project,
.records-rail-item {
  border-color: rgba(37,50,71,0.72) !important;
}

.records-matrix-table tr:hover td {
  background: #172033 !important;
}

.records-matrix-stage.s1 {
  background: rgba(54,197,216,0.14) !important;
  color: #36c5d8 !important;
}

.records-matrix-stage.s2 {
  background: rgba(139,108,255,0.14) !important;
  color: #8b6cff !important;
}

.records-matrix-stage.s3 {
  background: rgba(255,95,86,0.12) !important;
  color: #ff5f56 !important;
}

.records-matrix-bar-wrap,
.records-rail-goal-bar {
  background: #253247 !important;
}

.records-matrix-bar-fill,
.records-rail-goal-fill {
  background: linear-gradient(90deg, #5b8cff, #36c5d8) !important;
  box-shadow: 0 0 14px rgba(91,140,255,0.28);
}

.records-matrix-dot.none { background: #596574 !important; opacity: 0.72; }
.records-matrix-dot.learning { background: #5b8cff !important; }
.records-matrix-dot.mastered { background: #2cbb5d !important; }
.records-matrix-dot.expert { background: #8b6cff !important; }

.records-strip-chip.mastered,
.records-mobile-chip.mastered {
  background: rgba(44,187,93,0.1) !important;
  border-color: rgba(44,187,93,0.32) !important;
  color: #eef4ff !important;
}

.records-strip-chip.learning,
.records-mobile-chip.learning {
  background: rgba(91,140,255,0.1) !important;
  border-color: rgba(91,140,255,0.3) !important;
  color: #eef4ff !important;
}

.records-strip-chip.locked,
.records-mobile-chip.none {
  background: #141d2b !important;
  border-color: #253247 !important;
  color: #7f8b9d !important;
}

.records-rail-icon.done { background: rgba(44,187,93,0.14) !important; color: #2cbb5d !important; }
.records-rail-icon.learn { background: rgba(91,140,255,0.14) !important; color: #5b8cff !important; }
.records-rail-icon.submit { background: rgba(139,108,255,0.14) !important; color: #8b6cff !important; }
.records-rail-icon.project { background: rgba(232,168,79,0.14) !important; color: #e8a84f !important; }

@media (max-width: 960px) {
  .records-row2,
  .records-row-main {
    grid-template-columns: 1fr !important;
  }

  .records-header {
    flex-wrap: wrap !important;
    padding: 16px 20px !important;
  }

  .records-matrix-head {
    align-items: flex-start !important;
    flex-direction: column !important;
  }
}

@media (max-width: 560px) {
  .records-drawer-body {
    padding: 12px !important;
  }

  .records-header {
    display: grid !important;
    grid-template-columns: 1fr !important;
    justify-items: center !important;
    gap: 12px !important;
    padding: 14px 16px !important;
  }

  .records-header-metrics {
    width: 100% !important;
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 8px !important;
  }

  .records-header-metric {
    border-left: none !important;
    padding: 0 !important;
  }

  .records-header-metric-num {
    font-size: 20px !important;
    white-space: nowrap !important;
  }

  .records-header-metric-label {
    font-size: 11px !important;
  }

  .records-header-btn {
    width: 100% !important;
    min-width: 0 !important;
  }

  .records-matrix-scroll {
    display: none !important;
  }

  .records-mobile-projects {
    display: block !important;
  }

  .records-filter {
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    width: 100% !important;
    padding-bottom: 4px;
  }

  .records-strip {
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
  }
}

body.light {
  --bg: #eef5f8;
  --surface: rgba(255, 255, 255, 0.86);
  --surface-hover: rgba(245, 250, 252, 0.96);
  --border: rgba(16, 86, 111, 0.14);
  --border-hover: rgba(10, 150, 160, 0.44);
  --text: #102130;
  --text-dim: #4d6474;
  --text-muted: #7890a0;
  --accent: #007d8c;
  --accent-dim: rgba(0, 173, 181, 0.12);
  --success: #108b58;
  --warning: #bd7b00;
  --danger: #d9365f;
  --purple: #7049d8;
  --gradient-1: linear-gradient(135deg, #007d8c 0%, #14a66a 54%, #d58b00 100%);
  --gradient-2: linear-gradient(135deg, #007d8c 0%, #7049d8 58%, #d9365f 100%);
}

*, *::before, *::after {
  letter-spacing: 0;
}

html {
  background: var(--bg);
}

body {
  color: var(--text);
  background: var(--bg) !important;
  min-height: 100vh;
  overflow-x: hidden;
}

body::before {
  content: '' ;
  position: fixed ;
  inset: 0 !important;
  z-index: 0 ;
  pointer-events: none !important;
  background:
    radial-gradient(ellipse 80% 60% at 20% 10%, rgba(91,140,255,0.10), transparent 60%),
    radial-gradient(ellipse 60% 50% at 80% 90%, rgba(139,108,255,0.08), transparent 60%),
    radial-gradient(ellipse 40% 30% at 50% 50%, rgba(232,168,79,0.05), transparent 60%),
    linear-gradient(180deg, #090d12 0%, #0d1420 50%, #090d12 100%) !important;
  opacity: 1 ;
}

body::after {
  display: none;
}

body.light::before {
  background:
    linear-gradient(90deg, rgba(0,125,140,0.09) 1px, transparent 1px) 0 0 / 38px 38px,
    linear-gradient(0deg, rgba(20,166,106,0.07) 1px, transparent 1px) 0 0 / 38px 38px,
    linear-gradient(135deg, rgba(112,73,216,0.09), transparent 35%),
    linear-gradient(225deg, rgba(213,139,0,0.08), transparent 34%),
    linear-gradient(180deg, #eef5f8 0%, #f8fbfc 52%, #edf6f6 100%) !important;
}

body.light::after {
  opacity: 0.14;
}

::selection {
  background: rgba(91, 140, 255, 0.24);
  color: #ffffff;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: #0b1018 !important;
}

::-webkit-scrollbar-thumb {
  background: #3b4658 !important;
  border-radius: 8px !important;
  border: 2px solid #0b1018;
}
::-webkit-scrollbar-thumb:hover { background: var(--accent) !important; }

.navbar {
  height: 56px;
  padding: 0 24px;
  gap: 16px;
  background: rgba(9, 13, 18, 0.94);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  backdrop-filter: blur(16px);
}

body.light .navbar {
  background: rgba(246, 252, 253, 0.84) !important;
  border-bottom-color: rgba(0, 125, 140, 0.18) !important;
  box-shadow: 0 10px 28px rgba(0, 70, 90, 0.08);
}

.nav-logo {
  gap: 12px ;
  color: var(--text) !important;
  font-size: 15px ;
  font-weight: 800 ;
  text-transform: uppercase;
}

.nav-logo-icon {
  width: 36px ;
  height: 36px ;
  border-radius: 8px !important;
  color: #031015 !important;
  background: var(--gradient-1) !important;
  box-shadow: 0 0 24px rgba(44,187,93, 0.35), inset 0 0 0 1px rgba(255,255,255,0.55);
  position: relative;
  overflow: hidden;
}

.nav-logo-icon::before,
.nav-logo-icon::after {
  content: '';
  position: absolute;
  inset: 8px;
  border: 1px solid rgba(3,16,21,0.35);
  border-radius: 4px;
}

.nav-logo-icon::after {
  inset: 13px 7px;
  border-width: 0 1px;
}

.nav-links {
  gap: 8px ;
}

.nav-links a,
.nav-links .nav-func-link {
  color: var(--text-dim) !important;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 7px 10px;
  transition: color 0.2s, background 0.2s, border-color 0.2s, box-shadow 0.2s !important;
}

.nav-links a:hover,
.nav-links a.active,
.nav-links .nav-func-link:hover {
  color: var(--text) !important;
  background: rgba(44,187,93, 0.08) !important;
  border-color: rgba(44,187,93, 0.18);
  box-shadow: inset 0 -1px 0 rgba(44,187,93,0.32);
}

.nav-links a.active {
  color: var(--accent) !important;
}

.nav-search-wrap {
  max-width: 520px ;
}

.nav-search-input {
  height: 40px ;
  border-radius: 8px !important;
  background: rgba(7, 13, 24, 0.82) !important;
  border: 1px solid rgba(255,255,255, 0.2) !important;
  color: var(--text) !important;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.03);
}

body.light .nav-search-input {
  background: rgba(255,255,255,0.78) !important;
  border-color: rgba(0, 125, 140, 0.16) !important;
}

.nav-search-input:focus {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 4px var(--accent-dim), 0 0 22px rgba(44,187,93,0.16);
}

.nav-search-icon {
  color: var(--accent) !important;
}

.nav-search-dropdown,
.ac-dropdown {
  border-radius: 8px !important;
  background: rgba(7, 13, 24, 0.96) !important;
  border: 1px solid rgba(44,187,93,0.28) !important;
  box-shadow: var(--tech-shadow);
  backdrop-filter: blur(18px);
}

body.light .nav-search-dropdown,
body.light .ac-dropdown {
  background: rgba(255,255,255,0.96) !important;
  border-color: rgba(0,125,140,0.2) !important;
}

.page {
  max-width: 1280px ;
  padding-top: 34px ;
  position: relative ;
  z-index: 1 ;
}

.main-content,
#mainView {
  gap: 22px ;
}

.learn-path-bar {
  position: sticky;
  top: 64px;
  z-index: 95;
  background: rgba(6, 12, 22, 0.78) !important;
  border-bottom: 1px solid rgba(44,187,93,0.14) !important;
  backdrop-filter: blur(18px) saturate(150%);
  box-shadow: 0 8px 26px rgba(0,0,0,0.18);
}

body.light .learn-path-bar {
  background: rgba(248,252,253,0.82) !important;
  border-bottom-color: rgba(0,125,140,0.14) !important;
}

.learn-path-stage {
  border-radius: 8px !important;
  color: var(--text-dim) !important;
}

.learn-path-stage:hover,
.learn-path-stage.active {
  color: #041115 !important;
  background: var(--gradient-1) !important;
  box-shadow: 0 0 22px rgba(44,187,93,0.24);
}

.learn-path-arrow {
  color: rgba(44,187,93,0.5) !important;
}

.featured-card,
.side-card,
.project-card,
.sidebar-widget,
.periph-card,
.module-card,
.bom-card,
.record-entry,
.history-card,
.records-stat-card,
.records-proj-card,
.records-entry,
.func-card,
.detail-panel,
.overlay-check-panel,
.overlay-source-panel {
  border-radius: 8px !important;
  background: linear-gradient(145deg, var(--surface), #0c111a) !important;
  border: 1px solid var(--border) !important;
  box-shadow: 0 12px 32px rgba(0,0,0,0.35);
  backdrop-filter: blur(14px);
}

body.light .side-card,
body.light .project-card,
body.light .sidebar-widget,
body.light .periph-card,
body.light .module-card,
body.light .bom-card,
body.light .record-entry,
body.light .history-card,
body.light .records-stat-card,
body.light .records-proj-card,
body.light .records-entry,
body.light .func-card,
body.light .detail-panel,
body.light .overlay-check-panel,
body.light .overlay-source-panel {
  background: rgba(255,255,255,0.88) !important;
  border-color: rgba(0,125,140,0.15) !important;
  box-shadow: 0 14px 34px rgba(0, 70, 90, 0.08), inset 0 1px 0 rgba(255,255,255,0.9);
}

.featured-card {
  min-height: 318px;
  padding: 36px ;
  background:
    linear-gradient(90deg, rgba(9, 13, 18, 0.98) 0%, rgba(9, 13, 18, 0.85) 34%, rgba(9, 13, 18, 0.4) 66%, rgba(9, 13, 18, 0.15) 100%),
    url("assets/stm32-hero-board.png") center right / cover no-repeat !important;
  border-color: rgba(91,140,255,0.28) !important;
  box-shadow: 0 22px 70px rgba(0,0,0,0.5);
}

.featured-card::before {
  content: '' ;
  position: absolute ;
  top: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  left: auto !important;
  width: 48% ;
  height: 100% ;
  border-radius: 0 !important;
  background:
    linear-gradient(90deg, transparent 0 16%, rgba(44,187,93,0.2) 16% 17%, transparent 17% 34%, rgba(124,244,118,0.18) 34% 35%, transparent 35% 55%, rgba(255,209,102,0.17) 55% 56%, transparent 56%),
    repeating-linear-gradient(0deg, transparent 0 20px, rgba(44,187,93,0.18) 21px, transparent 22px),
    linear-gradient(135deg, rgba(44,187,93,0.12), rgba(192,132,252,0.18)) !important;
  opacity: 0.58 ;
  transform: none ;
}

.featured-card::after {
  content: 'STM32';
  position: absolute;
  right: 34px;
  bottom: 28px;
  width: 150px;
  height: 96px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: rgba(255,255,255,0.76);
  font-family: var(--font-mono);
  font-weight: 800;
  font-size: 20px;
  border: 1px solid rgba(44,187,93,0.38);
  background:
    linear-gradient(90deg, transparent 8px, rgba(44,187,93,0.36) 8px 10px, transparent 10px calc(100% - 10px), rgba(44,187,93,0.36) calc(100% - 10px) calc(100% - 8px), transparent calc(100% - 8px)),
    linear-gradient(180deg, rgba(255,255,255,0.07), rgba(255,255,255,0.02));
  box-shadow: 0 0 36px rgba(44,187,93,0.18), inset 0 0 20px rgba(44,187,93,0.08);
  opacity: 0.72;
  display: none;
}

.featured-content {
  position: relative;
  z-index: 2 ;
  max-width: 620px;
}

.featured-title {
  color: #ffffff !important;
  font-size: 34px ;
  line-height: 1.14 ;
  letter-spacing: 0;
  text-shadow: 0 0 22px rgba(44,187,93,0.18);
}

.featured-desc {
  color: #bfd3df !important;
  font-size: 14px ;
  max-width: 520px ;
}

body.light .featured-title,
body.light .featured-card-title,
body.light .featured-card .project-stage-badge,
body.light .featured-card .project-recommend {
  color: #ffffff !important;
}

body.light .featured-desc,
body.light .featured-card-desc,
body.light .featured-meta {
  color: #cfe3ee !important;
}

.hot-badge,
.project-recommend,
.project-stage-badge,
.badge,
.tech-tag,
.module-periph,
.overlay-tab,
.overlay-source-btn,
.overlay-copy-btn,
.overlay-lib-btn,
.overlay-check-btn,
.btn-start,
.theme-toggle,
.records-drawer-clear,
.records-expand-btn,
.func-code-copy,
.overlay-back,
.overlay-nav-btn,
.lib-func-item,
.lib-func-title {
  border-radius: 8px !important;
}

.hot-badge {
  color: #ff8ca3 !important;
  background: rgba(255,90,122,0.12) !important;
  border-color: rgba(255,90,122,0.28) !important;
}

.hot-badge-dot {
  background: var(--danger) !important;
  box-shadow: 0 0 14px var(--danger);
}

.project-recommend {
  background: rgba(255,209,102,0.12) !important;
  color: var(--warning) !important;
  border: 1px solid rgba(255,209,102,0.22);
}

.project-stage-badge,
.badge {
  background: rgba(44,187,93,0.1) !important;
  color: var(--accent) !important;
  border: 1px solid rgba(44,187,93,0.2);
}

.project-stage-badge.s2,
.badge-medium,
.tech-tag.purple {
  background: rgba(192,132,252,0.12) !important;
  color: var(--purple) !important;
  border-color: rgba(192,132,252,0.22) !important;
}

.project-stage-badge.s3,
.badge-hard {
  background: rgba(255,90,122,0.12) !important;
  color: var(--danger) !important;
  border-color: rgba(255,90,122,0.22) !important;
}

.badge-beginner,
.tech-tag.green {
  background: rgba(124,244,118,0.12) !important;
  color: var(--success) !important;
  border-color: rgba(124,244,118,0.22) !important;
}

.tech-tag.blue {
  background: rgba(44,187,93,0.12) !important;
  color: var(--accent) !important;
}

.tech-tag.yellow {
  background: rgba(255,209,102,0.12) !important;
  color: var(--warning) !important;
}

.btn-start,
.learn-path-stage.active {
  color: #ffffff !important;
  background: var(--accent) !important;
  border: 0 !important;
  box-shadow: 0 4px 12px rgba(91,140,255,0.3);
}
.btn-start:hover { background: #6fa0ff !important; box-shadow: 0 6px 18px rgba(91,140,255,0.4); }

.overlay-check-btn {
  color: #ffffff !important;
  background: var(--success) !important;
  border: 0 !important;
  box-shadow: 0 4px 12px rgba(47,191,113,0.3);
}
.overlay-check-btn:hover { background: #38d680 !important; box-shadow: 0 6px 18px rgba(47,191,113,0.4); }

.side-card,
.project-card,
.periph-card,
.module-card,
.sidebar-widget,
.records-entry,
.records-proj-card,
.func-card {
  position: relative;
  overflow: hidden;
}

.side-card::after,
.project-card::after,
.periph-card::after,
.module-card::after,
.sidebar-widget::after,
.func-card::after {
  content: '';
  position: absolute;
  top: 10px;
  right: 10px;
  width: 18px;
  height: 18px;
  border-top: 1px solid rgba(44,187,93,0.38);
  border-right: 1px solid rgba(44,187,93,0.38);
  opacity: 0.6;
  pointer-events: none;
}

.side-card:hover,
.project-card:hover,
.periph-card:hover,
.module-card:hover,
.sidebar-widget:hover,
.func-card:hover,
.records-entry:hover,
.records-proj-card:hover {
  border-color: var(--border-hover) !important;
  transform: translateY(-3px);
  box-shadow: var(--tech-shadow), var(--tech-glow);
}

.project-card::before,
.side-card::before,
.periph-card::before,
.module-card::before,
.func-card::before {
  background: linear-gradient(110deg, transparent 0%, rgba(44,187,93,0.08) 35%, rgba(255,255,255,0.08) 50%, rgba(255,90,122,0.06) 65%, transparent 100%) !important;
  opacity: 0;
  transform: translateX(-80%);
  transition: opacity 0.22s, transform 0.44s;
}

.project-card:hover::before,
.side-card:hover::before,
.periph-card:hover::before,
.module-card:hover::before,
.func-card:hover::before {
  opacity: 1 ;
  transform: translateX(0);
}

.project-card-icon,
.side-card-icon,
.periph-card-icon,
.history-card-icon,
.records-entry-icon {
  filter: drop-shadow(0 0 14px rgba(44,187,93,0.22));
}

.project-card-title,
.side-card-title,
.periph-card-name,
.module-name,
.widget-title,
.history-card-title,
.records-proj-name,
.records-entry-module,
.func-card-name,
.detail-project-title,
.overlay-title,
.records-drawer-title {
  color: var(--text) !important;
  font-weight: 800 ;
}

.project-card-desc,
.side-card-desc,
.periph-card-desc,
.periph-card-files,
.module-learn,
.detail-overview p,
.search-result-desc,
.records-entry-project,
.history-card-sub,
.records-stat-label,
.hw-price,
.comp-date,
.footer,
.footer a {
  color: var(--text-dim) !important;
}

.project-card-meta,
.side-card-meta,
.featured-meta,
.record-meta,
.records-entry-time,
.search-result-project {
  color: var(--text-muted) !important;
}

.sidebar-widget {
  padding: 22px ;
}

.widget-title,
.history-section-title,
.modules-title,
.bom-title,
.records-timeline-title,
.func-group-label,
.lib-func-title {
  color: var(--accent) !important;
  text-transform: uppercase;
  font-weight: 800 ;
}

.roadmap-dot {
  border-radius: 8px !important;
  background: rgba(44,187,93,0.08) !important;
}

.roadmap-dot.done {
  color: #041115 !important;
  background: var(--success) !important;
  border-color: var(--success) !important;
}

.roadmap-dot.active {
  color: #041115 !important;
  background: var(--accent) !important;
  border-color: var(--accent) !important;
  box-shadow: 0 0 18px rgba(44,187,93,0.38);
}

.roadmap-connector {
  background: linear-gradient(180deg, rgba(44,187,93,0.45), rgba(192,132,252,0.1)) !important;
}

.page-header {
  padding: 34px 0 18px ;
  margin-bottom: 26px ;
  border-bottom: 1px solid rgba(44,187,93,0.14);
  position: relative;
}

.page-header::before {
  content: '';
  position: absolute;
  left: 0;
  bottom: -1px;
  width: 220px;
  height: 1px;
  background: var(--gradient-1);
  box-shadow: 0 0 18px rgba(44,187,93,0.45);
}

.page-header h1 {
  color: var(--text) !important;
  font-size: 32px ;
  line-height: 1.16 ;
  font-weight: 900 ;
}

.page-header p {
  color: var(--text-dim) !important;
  font-size: 14px ;
}

.detail-panel,
.records-drawer-panel,
.func-overlay,
.overlay,
.func-overlay-topbar,
.overlay-topbar {
  background: rgba(5, 8, 15, 0.96) !important;
}

body.light .detail-panel,
body.light .records-drawer-panel,
body.light .func-overlay,
body.light .overlay,
body.light .func-overlay-topbar,
body.light .overlay-topbar {
  background: rgba(247, 252, 253, 0.97) !important;
}

.detail-topbar,
.overlay-topbar,
.func-overlay-topbar,
.records-drawer-header {
  border-bottom: 1px solid rgba(44,187,93,0.16) !important;
  box-shadow: 0 10px 24px rgba(0,0,0,0.18);
}

body.light .detail-topbar,
body.light .overlay-topbar,
body.light .func-overlay-topbar,
body.light .records-drawer-header {
  border-bottom-color: rgba(0,125,140,0.14) !important;
  box-shadow: 0 10px 22px rgba(0,70,90,0.06);
}

.detail-back,
.overlay-back,
.overlay-tab,
.overlay-source-btn,
.overlay-lib-btn,
.overlay-nav-btn,
.theme-toggle,
.records-drawer-close,
.records-drawer-clear,
.records-expand-btn,
.func-overlay-topbar button,
.func-code-copy {
  border-color: rgba(255,255,255,0.18) !important;
  color: var(--text-dim) !important;
  background: rgba(12,18,32,0.62) !important;
}

body.light .detail-back,
body.light .overlay-back,
body.light .overlay-tab,
body.light .overlay-source-btn,
body.light .overlay-copy-btn,
body.light .overlay-lib-btn,
body.light .overlay-nav-btn,
body.light .theme-toggle,
body.light .records-drawer-close,
body.light .records-drawer-clear,
body.light .records-expand-btn,
body.light .func-overlay-topbar button,
body.light .func-code-copy {
  background: rgba(255,255,255,0.82) !important;
  border-color: rgba(0,125,140,0.16) !important;
}

.detail-back:hover,
.overlay-back:hover,
.overlay-tab:hover,
.overlay-source-btn:hover,
.overlay-copy-btn:hover,
.overlay-lib-btn:hover,
.overlay-nav-btn:hover,
.theme-toggle:hover,
.records-drawer-close:hover,
.records-drawer-clear:hover,
.records-expand-btn:hover,
.func-overlay-topbar button:hover,
.func-code-copy:hover,
.lib-func-item:hover,
.lib-func-item.active {
  color: var(--accent) !important;
  border-color: var(--accent) !important;
  background: var(--accent-dim) !important;
}

.overlay-tab.active,
.overlay-source-btn.active {
  color: var(--accent) !important;
  border-color: var(--accent) !important;
  background: rgba(44,187,93,0.12) !important;
  box-shadow: inset 0 -2px 0 var(--accent);
}

.module-num,
.bom-qty,
.records-stat-num,
.records-proj-count {
  color: var(--accent) !important;
  border-color: rgba(44,187,93,0.24) !important;
  background: rgba(44,187,93,0.1) !important;
}

.module-card:hover .module-num {
  color: #041115 !important;
  background: var(--accent) !important;
  box-shadow: 0 0 24px rgba(44,187,93,0.34);
}

.module-code,
.overlay-editor,
.func-code-pre {
  border-radius: 8px !important;
  background: var(--code-bg) !important;
  border: 1px solid var(--border) !important;
  color: #d4d4d4 !important;
  box-shadow: none;
}
.overlay-code,
.overlay-code pre,
.overlay-source-panel,
.lib-func-sidebar {
  border-radius: 8px !important;
  background: var(--source-bg) !important;
  border: 1px solid var(--border) !important;
  color: #c8d2df !important;
  box-shadow: none;
}
.lib-gutter {
  border-radius: 8px !important;
  background: var(--code-bg) !important;
  border: 1px solid var(--border) !important;
  color: var(--text-muted) !important;
  box-shadow: none;
}

body.light .module-code,
body.light .overlay-editor,
body.light .overlay-code,
body.light .overlay-code pre,
body.light .func-code-pre,
body.light .lib-func-sidebar,
body.light .lib-gutter {
  background: rgba(246,250,252,0.94) !important;
  border-color: rgba(0,125,140,0.14) !important;
  color: #102130 !important;
}

.kw { color: var(--syn-kw) !important; }
.dt { color: var(--syn-dt) !important; }
.co { color: var(--syn-co) !important; }
.st { color: var(--syn-st) !important; }
.num { color: var(--syn-num) !important; }
.ma { color: var(--syn-ma) !important; }
.fu { color: var(--syn-fu) !important; }
.pp { color: var(--syn-ma) !important; }

.module-periph.gpio,
.module-periph.spi {
  background: rgba(124,244,118,0.12) !important;
  color: var(--success) !important;
}

.module-periph.tim,
.module-periph.adc {
  background: rgba(44,187,93,0.12) !important;
  color: var(--accent) !important;
}

.module-periph.algo {
  background: rgba(192,132,252,0.12) !important;
  color: var(--purple) !important;
}

.module-periph.i2c,
.module-periph.sys {
  background: rgba(255,209,102,0.12) !important;
  color: var(--warning) !important;
}

.module-periph.exti {
  background: rgba(255,90,122,0.12) !important;
  color: var(--danger) !important;
}

.bom-card {
  top: 88px !important;
}

.bom-total {
  border-top-color: rgba(44,187,93,0.18) !important;
}

.bom-price,
.bom-total span:last-child,
.footer a {
  color: var(--accent) !important;
}

.records-drawer-backdrop,
.overlay {
  backdrop-filter: blur(10px);
}

.records-proj-bar,
.history-progress-bar {
  background: rgba(44,187,93,0.1) !important;
}

.records-proj-bar-fill,
.history-progress-fill {
  background: var(--gradient-1) !important;
  box-shadow: 0 0 18px rgba(44,187,93,0.3);
}

.lib-body-row {
  gap: 14px ;
}

.lib-func-sidebar {
  width: 250px ;
}

.spl-search {
  width: 100%;
  max-width: 400px;
  height: 36px;
  margin-top: 12px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--code-bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  outline: none;
}
.spl-search:focus { border-color: var(--accent); }
.spl-search::placeholder { color: var(--text-muted); }

.lib-func-item {
  margin: 2px 8px;
  width: calc(100% - 16px) ;
  border-left: 2px solid transparent !important;
}

.overlay-code {
  overflow: auto;
}

.overlay-editor-wrap {
  position: relative;
  padding: 8px !important;
  gap: 6px !important;
}

.overlay-editor-wrap.split .overlay-editor-area {
  flex-basis: calc(var(--split-pct, 50%) - 3px) !important;
}

.overlay-resize-handle {
  width: 4px !important;
  border-radius: 4px;
}

.overlay-check-panel {
  width: 300px !important;
  padding: 16px !important;
}

.overlay-check-panel .check-item {
  gap: 8px !important;
  padding: 7px 0 !important;
}

.overlay-check-panel .check-title {
  margin-bottom: 12px !important;
}

.overlay-check-panel .check-hint {
  margin-left: 30px !important;
}

.overlay-copy-btn {
  position: absolute;
  top: 18px;
  right: 20px;
  z-index: 6;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-shadow: 0 8px 22px rgba(0,0,0,0.28);
}

.overlay-copy-btn[hidden],
.overlay-editor-wrap:not(.split) .overlay-copy-btn {
  display: none ;
}

.overlay-code pre,
.func-code-pre,
.module-code {
  text-shadow: 0 0 14px rgba(44,187,93,0.05);
}

.footer {
  position: relative;
  z-index: 1;
  border-top-color: rgba(44,187,93,0.14) !important;
  background: rgba(5, 8, 15, 0.52);
  backdrop-filter: blur(10px);
}

  body.light .footer {
  background: rgba(247,252,253,0.72);
}

/* ===== Project Artwork Layer ===== */
.reveal {
  opacity: 1 ;
  transform: none ;
}

:is(.featured-card, .side-card, .project-card)[data-pid],
.project-card[id^="card-"],
#featuredCard,
.detail-panel[data-pid],
body[data-project] {
  --project-image: none;
}

:is(.featured-card, .side-card, .project-card)[data-pid="xunji"],
.detail-panel[data-pid="xunji"],
body[data-project="xunji"] { --project-image: url("assets/project-bg/xunji.jpg"); }

:is(.featured-card, .side-card, .project-card)[data-pid="diangqin"],
.detail-panel[data-pid="diangqin"],
body[data-project="diangqin"] { --project-image: url("assets/project-bg/diangqin.jpg"); }

:is(.featured-card, .side-card, .project-card)[data-pid="shiboqi"],
.detail-panel[data-pid="shiboqi"],
body[data-project="shiboqi"] { --project-image: url("assets/project-bg/shiboqi.jpg"); }

:is(.featured-card, .side-card, .project-card)[data-pid="qixiang"],
.detail-panel[data-pid="qixiang"],
body[data-project="qixiang"] { --project-image: url("assets/project-bg/qixiang.jpg"); }

:is(.featured-card, .side-card, .project-card)[data-pid="pingheng"],
.detail-panel[data-pid="pingheng"],
body[data-project="pingheng"] { --project-image: url("assets/project-bg/pingheng.jpg"); }

:is(.featured-card, .side-card, .project-card)[data-pid="feikong"],
.detail-panel[data-pid="feikong"],
body[data-project="feikong"] { --project-image: url("assets/project-bg/feikong.jpg"); }

:is(.featured-card, .side-card, .project-card)[data-pid="daolibai"],
#featuredCard,
#card-daolibai,
.detail-panel[data-pid="daolibai"],
body[data-project="daolibai"] { --project-image: url("assets/project-bg/daolibai.jpg"); }

:is(.featured-card, .side-card, .project-card)[data-pid="dianyuan"],
#card-dianyuan,
.detail-panel[data-pid="dianyuan"],
body[data-project="dianyuan"] { --project-image: url("assets/project-bg/dianyuan.jpg"); }

:is(.featured-card, .side-card, .project-card)[data-pid="jiluyi"],
#card-jiluyi,
.detail-panel[data-pid="jiluyi"],
body[data-project="jiluyi"] { --project-image: url("assets/project-bg/jiluyi.jpg"); }

:is(.featured-card, .side-card, .project-card)[data-pid="menjin"],
#card-menjin,
.detail-panel[data-pid="menjin"],
body[data-project="menjin"] { --project-image: url("assets/project-bg/menjin.jpg"); }

:is(.featured-card, .side-card, .project-card)[data-pid="pinlvji"],
#card-pinlvji,
.detail-panel[data-pid="pinlvji"],
body[data-project="pinlvji"] { --project-image: url("assets/project-bg/pinlvji.jpg"); }

:is(.featured-card, .side-card, .project-card)[data-pid],
.project-card[id^="card-"],
#featuredCard {
  isolation: isolate;
  background: linear-gradient(180deg, rgba(10, 16, 28, 0.84), rgba(4, 8, 14, 0.94)) !important;
}

:is(.featured-card, .side-card, .project-card)[data-pid]::before,
.project-card[id^="card-"]::before,
#featuredCard::before {
  content: '' ;
  position: absolute ;
  inset: 0 !important;
  z-index: 0;
  width: auto ;
  height: auto ;
  border-radius: inherit !important;
  background:
    linear-gradient(180deg, rgba(5, 7, 13, 0) 0%, rgba(5, 7, 13, 0.28) 48%, rgba(5, 7, 13, 0.82) 100%),
    linear-gradient(90deg, rgba(5, 7, 13, 0.76) 0%, rgba(5, 7, 13, 0.34) 48%, rgba(5, 7, 13, 0.06) 100%),
    var(--project-image) center / cover no-repeat !important;
  filter: saturate(1.28) brightness(1.18) contrast(1.04);
  opacity: 0.94 ;
  transform: scale(1) ;
  transition: transform 0.55s cubic-bezier(.2,.8,.2,1), opacity 0.35s ease !important;
  pointer-events: none;
}

:is(.featured-card, .side-card, .project-card)[data-pid]:hover::before,
.project-card[id^="card-"]:hover::before,
#featuredCard:hover::before {
  opacity: 0.98 ;
  filter: saturate(1.36) brightness(1.26) contrast(1.06);
  transform: scale(1.06) ;
}

:is(.featured-card, .side-card, .project-card)[data-pid]::after,
.project-card[id^="card-"]::after,
#featuredCard::after {
  z-index: 3;
}

:is(.featured-card, .side-card, .project-card)[data-pid] > *,
.project-card[id^="card-"] > *,
#featuredCard > * {
  position: relative;
  z-index: 2;
}

:is(.project-card)[data-pid],
.project-card[id^="card-"] {
  min-height: 218px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 8px;
  padding: 84px 22px 22px ;
}

.side-card[data-pid] {
  min-height: 168px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 8px;
  padding: 72px 20px 20px ;
}

.featured-card[data-pid],
#featuredCard {
  min-height: 354px;
}

:is(.project-card, .side-card)[data-pid] .project-card-icon,
.project-card[id^="card-"] .project-card-icon,
.side-card[data-pid] .side-card-icon {
  position: absolute;
  top: 18px;
  left: 18px;
  z-index: 2;
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: rgba(5, 7, 13, 0.56);
  border: 1px solid rgba(44,187,93, 0.18);
  box-shadow: 0 0 24px rgba(44,187,93, 0.14);
}

body.light :is(.project-card, .side-card)[data-pid] .project-card-icon,
body.light .project-card[id^="card-"] .project-card-icon,
body.light .side-card[data-pid] .side-card-icon {
  background: rgba(255, 255, 255, 0.68);
}

:is(.project-card, .side-card)[data-pid] .project-card-title,
.project-card[id^="card-"] .project-card-title,
.side-card[data-pid] .side-card-title {
  font-size: 17px ;
  color: #f6fbff !important;
  text-shadow: 0 2px 20px rgba(0, 0, 0, 0.72), 0 0 18px rgba(44,187,93, 0.18);
}

:is(.project-card, .side-card)[data-pid] .project-card-desc,
.project-card[id^="card-"] .project-card-desc,
.side-card[data-pid] .side-card-desc {
  color: rgba(234, 248, 255, 0.9) !important;
  font-size: 12px ;
  text-shadow: 0 1px 14px rgba(0, 0, 0, 0.72);
}

body.light :is(.project-card, .side-card)[data-pid] .project-card-desc,
body.light .project-card[id^="card-"] .project-card-desc,
body.light .side-card[data-pid] .side-card-desc {
  color: rgba(238, 250, 252, 0.88) !important;
}

body[data-project] .page-header,
.detail-panel[data-pid] .detail-overview {
  position: relative;
  overflow: hidden;
  min-height: 260px;
  padding: 42px ;
  border-radius: 8px;
  border: 1px solid rgba(44,187,93, 0.22);
  background: linear-gradient(180deg, rgba(10, 16, 28, 0.82), rgba(4, 8, 14, 0.92)) !important;
  box-shadow: 0 20px 58px rgba(0,0,0,0.26), inset 0 1px 0 rgba(255,255,255,0.06);
}

body.light[data-project] .page-header,
body.light .detail-panel[data-pid] .detail-overview {
  background: rgba(255,255,255,0.9) !important;
}

body[data-project] .page-header::after,
.detail-panel[data-pid] .detail-overview::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 0;
  background:
    linear-gradient(90deg, rgba(5, 7, 13, 0.94) 0%, rgba(5, 7, 13, 0.72) 44%, rgba(5, 7, 13, 0.34) 100%),
    linear-gradient(180deg, rgba(5, 7, 13, 0.06), rgba(5, 7, 13, 0.88)),
    var(--project-image) center / cover no-repeat;
  opacity: 0.95;
  pointer-events: none;
}

body.light[data-project] .page-header::after,
body.light .detail-panel[data-pid] .detail-overview::before {
  background:
    linear-gradient(90deg, rgba(238, 245, 248, 0.96) 0%, rgba(238, 245, 248, 0.72) 42%, rgba(238, 245, 248, 0.24) 100%),
    linear-gradient(180deg, rgba(238, 245, 248, 0.08), rgba(238, 245, 248, 0.72)),
    var(--project-image) center / cover no-repeat;
}

body[data-project] .page-header > *,
.detail-panel[data-pid] .detail-overview > * {
  position: relative;
  z-index: 1;
  max-width: 720px;
}

body[data-project] .page-header h1 {
  font-size: clamp(30px, 4.5vw, 54px) ;
  color: var(--text) !important;
  text-shadow: 0 0 28px rgba(44,187,93, 0.2);
}

body[data-project] .page-header p,
.detail-panel[data-pid] .detail-overview p {
  color: var(--text-dim) !important;
  font-size: 15px ;
  line-height: 1.9 ;
}

body[data-project] .page-header .highlight,
.detail-panel[data-pid] .detail-overview .highlight {
  color: var(--accent) !important;
  text-shadow: 0 0 16px rgba(44,187,93,0.25);
}

@keyframes stm32GridDrift {
  from { transform: translate3d(0, 0, 0); }
  to { transform: translate3d(-38px, -38px, 0); }
}

@media (max-width: 980px) {
  .navbar {
    height: auto ;
    min-height: 64px;
    flex-wrap: wrap;
    padding: 10px 16px ;
  }

  .learn-path-bar {
    top: 84px;
  }

  .featured-card {
    min-height: 280px;
  }

  .featured-card::after {
    opacity: 0.28;
    right: 18px;
    bottom: 18px;
  }

  .featured-card::before {
    width: 100% ;
    opacity: 0.2 ;
  }
}

@media (max-width: 680px) {
  .page {
    padding-left: 14px ;
    padding-right: 14px ;
  }

  .nav-search-wrap {
    order: 3;
    flex-basis: 100%;
    max-width: none ;
  }

  .nav-links {
    overflow-x: auto;
    width: 100%;
    padding-bottom: 2px;
  }

  .featured-card {
    padding: 24px ;
  }

  :is(.project-card)[data-pid],
  .project-card[id^="card-"] {
    min-height: 188px;
    padding: 76px 18px 18px ;
  }

  .side-card[data-pid] {
    min-height: 156px;
    padding: 66px 18px 18px ;
  }

  .featured-card[data-pid],
  #featuredCard {
    min-height: 300px;
  }

  body[data-project] .page-header,
  .detail-panel[data-pid] .detail-overview {
    min-height: 230px;
    padding: 28px ;
  }

  .featured-title,
  .page-header h1 {
    font-size: 26px ;
  }

  .featured-footer {
    flex-direction: column;
    align-items: flex-start ;
    gap: 10px ;
  }

  .featured-card::after {
    display: none;
  }

  .lib-body-row {
    flex-direction: column;
  }

  .lib-func-sidebar {
    width: 100% ;
    max-height: 170px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

/* Mobile navigation */
.nav-menu-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: 700 18px/1 var(--font);
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}

.nav-menu-btn:hover,
.navbar.mobile-open .nav-menu-btn {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}

body.light .nav-menu-btn {
  background: #f5f5f5;
  border-color: #e5e7eb;
  color: #4b5563;
}

body.light .nav-menu-btn:hover,
body.light .navbar.mobile-open .nav-menu-btn {
  border-color: #4d6bfe;
  color: #4d6bfe;
  background: rgba(77,107,254,0.08);
}

@media (max-width: 640px) {
  .navbar {
    flex-wrap: wrap;
    height: auto;
    min-height: 56px;
    padding: 0 14px;
    gap: 8px 10px;
  }

  .nav-logo {
    height: 56px;
  }

  .nav-menu-btn {
    display: inline-flex;
    margin-left: auto;
  }

  .nav-title {
    order: 2;
    margin-left: 0;
    max-width: 34vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .nav-search-wrap {
    display: none;
    order: 3;
    flex: 0 0 100%;
    max-width: none;
    width: 100%;
    margin: 0 0 8px;
  }

  .nav-links {
    display: none;
    order: 4;
    flex: 0 0 100%;
    width: 100%;
    flex-direction: column;
    gap: 6px;
    padding: 0 0 12px;
  }

  .navbar.mobile-open .nav-search-wrap {
    display: block;
  }

  .navbar.mobile-open .nav-links {
    display: flex;
  }

  .nav-links a,
  .nav-links .nav-func-link {
    display: block;
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
  }

  .nav-search-dropdown.show {
    position: static;
    margin-top: 8px;
  }

  .overlay-topbar {
    height: auto ;
    min-height: 56px;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 8px 10px ;
  }

  .overlay-module-info {
    flex: 1 1 calc(100% - 96px);
    min-width: 0;
  }

  .overlay-module-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 14px ;
  }

  .overlay-module-tags {
    display: none ;
  }

  .overlay-source-btn,
  .overlay-wiring-btn,
  .overlay-lib-btn,
  .overlay-check-btn {
    flex: 1 1 auto;
    padding: 7px 10px ;
    text-align: center;
  }

  /* Mobile: editor full-width, check panel as bottom drawer */
  .overlay-body {
    flex-direction: column ;
  }
  .overlay-editor-wrap {
    flex: none !important;
    min-height: 50vh;
  }
  .overlay-source-panel {
    min-height: 50vh;
  }
  .overlay-check-panel {
    max-height: 40vh;
    border-top: 2px solid var(--border);
    border-left: none !important;
    width: 100% !important;
    overflow-y: auto;
  }
  .overlay-editor-area {
    flex-direction: column ;
  }
  .editor-gutter {
    display: none;
  }

  /* Mobile homepage: project cards before sidebar */
  .main-content {
    display: flex;
    flex-direction: column;
  }
  .main-content > .project-grid {
    order: -1;
  }
  .sidebar {
    margin-top: 24px;
  }
}

/* UI-26 final cascade: keep the record page dark even if old theme state remains in localStorage. */
.records-drawer-panel,
body.light .records-drawer-panel {
  background: #070a0f !important;
}

.records-drawer.open .records-drawer-panel,
body.light .records-drawer.open .records-drawer-panel {
  opacity: 1 !important;
}

.records-drawer-header,
body.light .records-drawer-header {
  background: rgba(7,10,15,0.94) !important;
  border-bottom-color: rgba(37,50,71,0.72) !important;
}

.records-header,
.records-heatmap-card,
.records-next-card,
.records-matrix-card,
.records-rail,
.records-strip,
body.light .records-header,
body.light .records-heatmap-card,
body.light .records-next-card,
body.light .records-matrix-card,
body.light .records-rail,
body.light .records-strip {
  background: linear-gradient(180deg, #111824, #0d1420) !important;
  border-color: #253247 !important;
  color: #eef4ff !important;
}

/* UI-32 cover: abstract dark launch screen */
body.cover-shell,
body.cover-shell.light {
  background: #070a0f !important;
  color: #eef4ff !important;
  color-scheme: dark;
}

body.cover-shell::before,
body.cover-shell::after {
  display: none !important;
}

body.cover-shell .cover {
  background: transparent;
}
