:root {
  --bg: #06070d;
  --bg2: rgba(23, 22, 38, 0.66);
  --bg3: rgba(255, 255, 255, 0.055);
  --border: rgba(255, 255, 255, 0.09);
  --text: #f3f4fb;
  --text-muted: #9a9db3;
  --accent: #6d8dff;
  --accent2: #ffb454;
  --accent3: #ff6f9c;
  --accent4: #c084fc;
  --accent5: #6ea8fe;
  --grad: linear-gradient(100deg, #5b7fff 0%, #b26bff 55%, #ff5ec7 100%);
  --grad-soft: linear-gradient(100deg, rgba(91,127,255,.16) 0%, rgba(178,107,255,.16) 55%, rgba(255,94,199,.16) 100%);
  --cert-basic: #6d8dff;
  --cert-micro: #ffb454;
  --cert-robo: #c084fc;
  --cert-proto: #ff6f9c;
  --chain-bg: rgba(255, 255, 255, 0.05);
  --chain-arrow: #6d7290;
  --learned: #2dd4bf;
  --font: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-display: 'Space Grotesk', 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
  --mono: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

/* ── Ambient background glow ── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(46rem 32rem at 88% -8%, rgba(178, 107, 255, .28), transparent 60%),
    radial-gradient(40rem 30rem at -8% 12%, rgba(91, 127, 255, .24), transparent 60%),
    radial-gradient(46rem 34rem at 70% 92%, rgba(255, 94, 199, .16), transparent 60%),
    var(--bg);
  pointer-events: none;
}

/* ── Layout ── */
.app {
  display: grid;
  grid-template-rows: 60px 1fr;
  grid-template-columns: 260px 1fr;
  grid-template-areas:
    "header header"
    "sidebar main";
  min-height: 100vh;
}

/* ── Header ── */
header {
  grid-area: header;
  background: rgba(13, 13, 22, 0.6);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 22px;
  position: sticky;
  top: 0;
  z-index: 100;
}
header::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 1px;
  background: var(--grad);
  opacity: .55;
}

.logo {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.2px;
  white-space: nowrap;
  text-decoration: none;
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.logo span { -webkit-text-fill-color: var(--text-muted); color: var(--text-muted); font-weight: 400; }

.search-wrap {
  flex: 1;
  max-width: 420px;
  position: relative;
}
.search-wrap input {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 14px 8px 36px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color .2s, box-shadow .2s, background .2s;
}
.search-wrap input:focus {
  border-color: rgba(178, 107, 255, .55);
  background: rgba(255, 255, 255, .08);
  box-shadow: 0 0 0 3px rgba(109, 141, 255, .15), 0 0 24px rgba(178, 107, 255, .15);
}
.search-wrap input::placeholder { color: var(--text-muted); }
.search-icon {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 14px;
  pointer-events: none;
}

.header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.progress-pill {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 5px 14px;
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}
.progress-pill strong {
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.menu-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
}

/* ── Sidebar ── */
sidebar, .sidebar {
  grid-area: sidebar;
  background: rgba(13, 13, 22, 0.45);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  height: calc(100vh - 60px);
  position: sticky;
  top: 60px;
  padding-bottom: 40px;
}

.sidebar-section {
  border-bottom: 1px solid var(--border);
}

.sidebar-section-header {
  padding: 14px 16px 10px;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
  transition: color .15s;
}
.sidebar-section-header:hover { color: var(--text); }
.sidebar-chevron { font-size: 10px; transition: transform .2s; }
.sidebar-section.open .sidebar-chevron { transform: rotate(90deg); }

.sidebar-items { display: none; padding-bottom: 4px; }
.sidebar-section.open .sidebar-items { display: block; }

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px 8px 24px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all .15s;
  text-decoration: none;
  border-left: 2px solid transparent;
}
.sidebar-item:hover {
  background: var(--bg3);
  color: var(--text);
}
.sidebar-item.active {
  color: var(--text);
  background: var(--grad-soft);
  border-left-color: transparent;
  position: relative;
}
.sidebar-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 2px;
  background: var(--grad);
}

.cert-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 3px;
  margin-left: auto;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* ── Main Content ── */
main {
  grid-area: main;
  overflow-y: auto;
  padding: 0;
}

/* ── Hero / Dashboard ── */
.hero {
  padding: 52px 40px 40px;
  max-width: 860px;
}

.hero h1 {
  font-family: var(--font-display);
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.3px;
  line-height: 1.25;
  margin-bottom: 14px;
}
.hero h1 span {
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero-sub {
  font-size: 16px;
  color: var(--text-muted);
  margin-bottom: 36px;
  max-width: 600px;
}

.path-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 48px;
}

.path-card {
  background: var(--bg2);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  cursor: pointer;
  transition: all .25s;
  position: relative;
  overflow: hidden;
}
.path-card:hover {
  border-color: rgba(178, 107, 255, .5);
  transform: translateY(-3px);
  box-shadow: 0 12px 32px rgba(91, 127, 255, .12), 0 4px 16px rgba(255, 94, 199, .1);
}
.path-card.locked { opacity: .55; cursor: default; }
.path-card.locked:hover { transform: none; border-color: var(--border); box-shadow: none; }

.path-card-icon {
  font-size: 28px;
  margin-bottom: 12px;
  display: block;
}
.path-card h3 {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 4px;
}
.path-card p {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.path-card-progress {
  height: 4px;
  background: var(--bg3);
  border-radius: 2px;
  overflow: hidden;
}
.path-card-bar {
  height: 100%;
  background: var(--grad);
  border-radius: 2px;
  transition: width .4s ease;
}

.path-card-count {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
}

.lock-icon {
  position: absolute;
  top: 14px;
  right: 14px;
  font-size: 16px;
  opacity: .4;
}

/* ── Concept List View ── */
.section-view {
  padding: 32px 40px;
  max-width: 860px;
}

.section-view-header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 8px;
}
.section-view-icon { font-size: 32px; }
.section-view h2 {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  line-height: 1.3;
}
.section-view-meta {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 28px;
  padding-left: 48px;
}

.section-progress-bar {
  height: 5px;
  background: var(--bg3);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 6px;
}
.section-progress-fill {
  height: 100%;
  background: var(--grad);
  border-radius: 3px;
  transition: width .4s;
}
.section-progress-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 28px;
}

/* ── Concept Card ── */
.concept-card {
  background: var(--bg2);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: 14px;
  margin-bottom: 16px;
  overflow: hidden;
  transition: border-color .2s, box-shadow .2s;
}
.concept-card:hover { border-color: rgba(109, 141, 255, .4); }
.concept-card.learned { border-color: rgba(45, 212, 191, .4); }

.concept-card-top {
  padding: 18px 20px 16px;
  cursor: pointer;
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.concept-check {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--border);
  flex-shrink: 0;
  margin-top: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  cursor: pointer;
  transition: all .2s;
  color: transparent;
}
.concept-card.learned .concept-check {
  background: var(--learned);
  border-color: var(--learned);
  color: #06070d;
}

.concept-card-header {
  flex: 1;
}

.concept-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.concept-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  line-height: 1.3;
}
.tag {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.tag-basic { background: rgba(109, 141, 255, .18); color: #9db4ff; }
.tag-micro { background: rgba(255, 180, 84, .18); color: #ffc478; }
.tag-robo  { background: rgba(192, 132, 252, .18); color: #d5a8ff; }
.tag-proto { background: rgba(255, 111, 156, .18); color: #ff9ab7; }

/* ── Chain ── */
.chain {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 12px;
}

.chain-node {
  background: var(--chain-bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  transition: all .15s;
}
.chain-node:hover {
  background: var(--grad-soft);
  border-color: rgba(178, 107, 255, .5);
  color: var(--text);
}

.chain-arrow {
  color: var(--chain-arrow);
  font-size: 14px;
  flex-shrink: 0;
}

.concept-blurb {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.55;
}

.concept-card-body {
  display: none;
  padding: 0 20px 20px;
  border-top: 1px solid var(--border);
  padding-top: 18px;
}
.concept-card.expanded .concept-card-body { display: block; }

.concept-card-expand-icon {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 3px;
  flex-shrink: 0;
  transition: transform .2s;
}
.concept-card.expanded .concept-card-expand-icon { transform: rotate(180deg); }

/* ── Body sections ── */
.detail-section {
  margin-bottom: 18px;
}
.detail-section:last-child { margin-bottom: 0; }

.detail-label {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.9px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.detail-text {
  font-size: 14px;
  color: var(--text);
  line-height: 1.6;
}

.detail-text strong { color: var(--accent5); }

.memory-tip {
  background: rgba(192, 132, 252, .08);
  border: 1px solid rgba(192, 132, 252, .25);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 13px;
  color: var(--text);
  line-height: 1.55;
}
.memory-tip-icon { margin-right: 6px; }

.exam-tip {
  background: rgba(45, 212, 191, .08);
  border: 1px solid rgba(45, 212, 191, .25);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 13px;
  color: var(--text);
  line-height: 1.55;
}

.key-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.fact-pill {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 12px;
  font-family: var(--mono);
  color: var(--accent2);
}

.learn-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 16px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all .2s;
  font-family: var(--font);
}
.learn-btn:hover {
  border-color: rgba(178, 107, 255, .5);
  color: var(--text);
  background: var(--grad-soft);
}
.concept-card.learned .learn-btn {
  border-color: rgba(45, 212, 191, .5);
  color: var(--learned);
  background: rgba(45, 212, 191, .08);
}

/* ── Search results ── */
.search-view {
  padding: 32px 40px;
  max-width: 860px;
}
.search-view h2 {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 700;
  margin-bottom: 20px;
}
.search-empty {
  color: var(--text-muted);
  font-size: 14px;
  text-align: center;
  padding: 60px 0;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(178, 107, 255, .4); }

/* ── Responsive ── */
@media (max-width: 720px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-areas:
      "header"
      "main";
  }
  .sidebar {
    display: none;
    position: fixed;
    top: 60px;
    left: 0;
    width: 260px;
    height: calc(100vh - 60px);
    z-index: 90;
    box-shadow: 4px 0 30px rgba(0,0,0,.6);
  }
  .sidebar.open { display: block; }
  .menu-btn { display: block; }
  .hero, .section-view, .search-view {
    padding: 24px 20px;
  }
  .path-cards { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 440px) {
  .path-cards { grid-template-columns: 1fr; }
}

/* ── Animations ── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.concept-card { animation: fadeIn .2s ease both; }
.concept-card:nth-child(2) { animation-delay: .04s; }
.concept-card:nth-child(3) { animation-delay: .08s; }
.concept-card:nth-child(4) { animation-delay: .12s; }
.concept-card:nth-child(5) { animation-delay: .16s; }
.concept-card:nth-child(6) { animation-delay: .20s; }
