:root {
  --bg: #0a0c10;
  --bg2: #0f1218;
  --bg3: #141820;
  --surface: #161b26;
  --surface2: #1c2230;
  --border: #252d40;
  --border2: #313b54;
  --accent: #00e5a0;
  --accent2: #0091ff;
  --accent3: #ff4d6d;
  --accent4: #ffd93d;
  --text: #e8eaf0;
  --text2: #8890a8;
  --text3: #545c74;
  --l1: #00e5a0;
  --l2: #0091ff;
  --l3: #b794ff;
  --mono: 'Space Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --sans: 'DM Sans', system-ui, -apple-system, sans-serif;
  --display: 'Syne', var(--sans);
  --sidebar-w: 320px;
  --radius: 14px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
a { color: var(--accent2); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ============ LAYOUT ============ */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; grid-template-rows: 60px 1fr; height: 100vh; }
.app.focus { grid-template-columns: 0 1fr; }
.app.focus .sidebar { transform: translateX(-100%); }

/* ============ TOPBAR ============ */
.topbar {
  grid-column: 1 / -1;
  display: flex; align-items: center; gap: 18px;
  padding: 0 20px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  z-index: 30;
}
.brand { display: flex; align-items: center; gap: 11px; cursor: pointer; -webkit-user-select: none; user-select: none; }
.brand .logo {
  width: 32px; height: 32px; border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: grid; place-items: center; font-size: 17px;
  box-shadow: 0 0 20px rgba(0,229,160,.35);
}
.brand b { font-family: var(--display); font-weight: 800; font-size: 16px; letter-spacing: -.3px; }
.brand span { color: var(--text3); font-size: 11px; font-family: var(--mono); }

.search-wrap { position: relative; flex: 1; max-width: 460px; }
.search-wrap input {
  width: 100%; padding: 9px 14px 9px 38px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; color: var(--text); font-size: 14px; outline: none;
}
.search-wrap input:focus { border-color: var(--accent2); }
.search-wrap .ic { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--text3); }
.search-wrap kbd {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  font-family: var(--mono); font-size: 11px; color: var(--text3);
  border: 1px solid var(--border2); border-radius: 5px; padding: 1px 6px;
}

.spacer { flex: 1; }
.topbtn {
  display: flex; align-items: center; gap: 7px;
  padding: 8px 13px; border-radius: 9px; font-size: 13px; font-weight: 500;
  color: var(--text2); border: 1px solid var(--border);
}
.topbtn:hover { color: var(--text); border-color: var(--border2); background: var(--surface); }
.topbtn.active { color: var(--accent); border-color: var(--accent); }

.progress-ring { display: flex; align-items: center; gap: 9px; }
.progress-ring svg { transform: rotate(-90deg); }
.progress-ring .pct { font-family: var(--mono); font-weight: 700; font-size: 13px; }
.progress-ring .lbl { font-size: 11px; color: var(--text3); line-height: 1.2; }

/* ============ SIDEBAR ============ */
.sidebar {
  background: var(--bg2); border-right: 1px solid var(--border);
  overflow-y: auto; transition: transform .3s ease;
  padding: 14px 10px 60px;
}
.side-toggle {
  display: flex; gap: 4px; padding: 4px; margin: 0 6px 14px;
  background: var(--surface); border-radius: 10px; border: 1px solid var(--border);
}
.side-toggle button {
  flex: 1; padding: 7px; border-radius: 7px; font-size: 12.5px; font-weight: 600; color: var(--text2);
}
.side-toggle button.active { background: var(--bg3); color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,.3); }

.level-group { margin-bottom: 16px; }
.level-head {
  display: flex; align-items: center; gap: 9px; padding: 8px 10px 6px;
}
.level-badge {
  width: 22px; height: 22px; border-radius: 7px; display: grid; place-items: center;
  font-family: var(--mono); font-weight: 700; font-size: 12px; color: #061; flex-shrink: 0;
}
.level-1 .level-badge { background: var(--l1); }
.level-2 .level-badge { background: var(--l2); color: #fff; }
.level-3 .level-badge { background: var(--l3); color: #201; }
.level-head .lh-title { font-family: var(--display); font-weight: 700; font-size: 13.5px; }
.level-head .lh-sub { font-size: 10.5px; color: var(--text3); font-family: var(--mono); }
.level-bar { height: 3px; background: var(--surface); border-radius: 3px; margin: 0 10px 8px; overflow: hidden; }
.level-bar i { display: block; height: 100%; border-radius: 3px; transition: width .5s ease; }
.level-1 .level-bar i { background: var(--l1); }
.level-2 .level-bar i { background: var(--l2); }
.level-3 .level-bar i { background: var(--l3); }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 9px; font-size: 13.5px; color: var(--text2);
  cursor: pointer; position: relative; -webkit-user-select: none; user-select: none;
}
.nav-item:hover { background: var(--surface); color: var(--text); }
.nav-item.active { background: var(--surface2); color: var(--text); }
.nav-item.active::before {
  content: ''; position: absolute; left: 0; top: 7px; bottom: 7px; width: 3px;
  background: var(--accent); border-radius: 3px;
}
.nav-item .ni-ic { font-size: 15px; width: 20px; text-align: center; flex-shrink: 0; }
.nav-item .ni-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item .ni-focus { font-size: 11px; color: var(--text3); }
.dot {
  width: 15px; height: 15px; border-radius: 50%; border: 2px solid var(--border2);
  flex-shrink: 0; display: grid; place-items: center; transition: all .2s;
}
.dot.done { background: var(--accent); border-color: var(--accent); }
.dot.done::after { content: '✓'; font-size: 9px; color: #042; font-weight: 800; }

/* ============ MAIN ============ */
.main { overflow-y: auto; position: relative; scroll-behavior: smooth; }
.view { max-width: 920px; margin: 0 auto; padding: 34px 40px 120px; }

/* hidden helper */
.hidden { display: none !important; }

/* ---- HOME ---- */
.hero { margin-bottom: 30px; }
.hero .eyebrow { font-family: var(--mono); font-size: 12px; color: var(--accent); letter-spacing: 2px; text-transform: uppercase; }
.hero h1 { font-family: var(--display); font-weight: 800; font-size: 44px; line-height: 1.05; letter-spacing: -1.5px; margin: 10px 0 14px; }
.hero h1 em { font-style: normal; background: linear-gradient(120deg, var(--accent), var(--accent2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p { color: var(--text2); font-size: 16px; max-width: 640px; }

.stats-row { display: flex; gap: 12px; margin: 26px 0 36px; flex-wrap: wrap; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 20px; flex: 1; min-width: 120px;
}
.stat b { font-family: var(--display); font-size: 28px; font-weight: 800; display: block; }
.stat span { font-size: 12px; color: var(--text3); font-family: var(--mono); }

.section-title { font-family: var(--display); font-weight: 700; font-size: 22px; margin: 30px 0 16px; letter-spacing: -.5px; display: flex; align-items: center; gap: 10px; }
.section-title small { font-size: 13px; color: var(--text3); font-weight: 400; font-family: var(--mono); }

.level-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px; margin-bottom: 16px; position: relative; overflow: hidden;
}
.level-card::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; }
.level-card.l1::before { background: var(--l1); }
.level-card.l2::before { background: var(--l2); }
.level-card.l3::before { background: var(--l3); }
.level-card .lc-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 6px; }
.level-card h3 { font-family: var(--display); font-size: 21px; font-weight: 800; }
.level-card .lc-tag { font-family: var(--mono); font-size: 11px; padding: 3px 9px; border-radius: 20px; white-space: nowrap; }
.level-card.l1 .lc-tag { background: rgba(0,229,160,.13); color: var(--l1); }
.level-card.l2 .lc-tag { background: rgba(0,145,255,.13); color: var(--l2); }
.level-card.l3 .lc-tag { background: rgba(183,148,255,.13); color: var(--l3); }
.level-card .lc-goal { color: var(--text2); font-size: 14px; }
.level-card .lc-window { font-family: var(--mono); font-size: 11px; color: var(--text3); margin-top: 2px; }
.level-card .lc-prog { height: 6px; background: var(--bg3); border-radius: 6px; margin: 14px 0; overflow: hidden; }
.level-card .lc-prog i { display: block; height: 100%; transition: width .6s; }
.level-card.l1 .lc-prog i { background: var(--l1); }
.level-card.l2 .lc-prog i { background: var(--l2); }
.level-card.l3 .lc-prog i { background: var(--l3); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: flex; align-items: center; gap: 7px; padding: 7px 12px;
  background: var(--bg3); border: 1px solid var(--border); border-radius: 9px;
  font-size: 13px; cursor: pointer; transition: all .15s;
}
.chip:hover { border-color: var(--border2); transform: translateY(-2px); background: var(--surface2); }
.chip.done { opacity: .55; }
.chip .cdot { width: 8px; height: 8px; border-radius: 50%; background: var(--border2); }
.chip.done .cdot { background: var(--accent); }

.cta {
  display: inline-flex; align-items: center; gap: 10px; margin-top: 8px;
  padding: 13px 22px; border-radius: 11px; font-weight: 700; font-size: 15px;
  background: linear-gradient(120deg, var(--accent), var(--accent2)); color: #04110c;
  box-shadow: 0 6px 24px rgba(0,229,160,.28); transition: transform .15s;
}
.cta:hover { transform: translateY(-2px); }

/* ---- MODULE VIEW ---- */
.crumb { font-family: var(--mono); font-size: 12px; color: var(--text3); margin-bottom: 14px; display: flex; gap: 7px; flex-wrap: wrap; align-items: center; }
.crumb a { color: var(--text2); cursor: pointer; }
.crumb a:hover { color: var(--accent); text-decoration: none; }

.mod-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 8px; }
.mod-head .mh-ic { font-size: 38px; line-height: 1; }
.mod-head h1 { font-family: var(--display); font-weight: 800; font-size: 32px; letter-spacing: -1px; line-height: 1.1; }
.meta-row { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; color: var(--text3); font-size: 12.5px; font-family: var(--mono); margin: 12px 0 22px; }
.meta-row .complete-btn {
  display: flex; align-items: center; gap: 8px; padding: 8px 15px; border-radius: 9px;
  border: 1px solid var(--accent); color: var(--accent); font-weight: 600; font-size: 13px; font-family: var(--sans);
}
.meta-row .complete-btn:hover { background: rgba(0,229,160,.1); }
.meta-row .complete-btn.done { background: var(--accent); color: #042; }

.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px 26px; margin-bottom: 20px;
}
.panel-title { font-family: var(--display); font-weight: 700; font-size: 16px; margin-bottom: 14px; display: flex; align-items: center; gap: 9px; color: var(--text); }
.panel-title .pt-count { font-family: var(--mono); font-size: 12px; color: var(--text3); font-weight: 400; }

.res-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 11px; }
.res-card {
  display: flex; align-items: center; gap: 12px; padding: 13px 15px;
  background: var(--bg3); border: 1px solid var(--border); border-radius: 11px;
  cursor: pointer; transition: all .15s; text-decoration: none; color: var(--text);
}
.res-card:hover { border-color: var(--accent2); transform: translateY(-2px); text-decoration: none; }
.res-card .rc-ic { font-size: 22px; width: 26px; text-align: center; }
.res-card .rc-body { overflow: hidden; min-width: 0; }
.res-card .rc-name { display: block; font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.res-card .rc-type { display: block; font-family: var(--mono); font-size: 10.5px; color: var(--text3); text-transform: uppercase; letter-spacing: 1px; margin-top: 2px; }
.res-card.course { border-color: rgba(255,217,61,.3); }
.res-card.course .rc-type { color: var(--accent4); }

.sub-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.sub-card {
  background: var(--bg3); border: 1px solid var(--border); border-radius: 12px; padding: 16px;
  cursor: pointer; transition: all .15s; position: relative;
}
.sub-card:hover { border-color: var(--accent); transform: translateY(-3px); }
.sub-card .sc-ic { font-size: 22px; margin-bottom: 8px; }
.sub-card h4 { font-family: var(--display); font-size: 15px; font-weight: 700; margin-bottom: 4px; }
.sub-card .sc-meta { font-family: var(--mono); font-size: 11px; color: var(--text3); display: flex; gap: 10px; }
.sub-card .sc-dot { position: absolute; top: 14px; right: 14px; width: 9px; height: 9px; border-radius: 50%; background: var(--border2); }
.sub-card.done .sc-dot { background: var(--accent); }

.empty-note {
  padding: 16px 18px; border: 1px dashed var(--border2); border-radius: 11px;
  color: var(--text3); font-size: 13.5px; background: var(--bg3);
}
.empty-note b { color: var(--text2); }

/* sibling "other options" */
.siblings { display: flex; flex-wrap: wrap; gap: 8px; }
.sib {
  display: flex; align-items: center; gap: 8px; padding: 8px 13px; border-radius: 9px;
  background: var(--bg3); border: 1px solid var(--border); font-size: 13px; cursor: pointer; transition: all .15s;
}
.sib:hover { border-color: var(--accent); color: var(--accent); }
.sib.current { border-color: var(--accent2); color: var(--accent2); }

.prevnext { display: flex; justify-content: space-between; gap: 14px; margin-top: 26px; }
.pn {
  flex: 1; padding: 15px 18px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; cursor: pointer; transition: all .15s;
}
.pn:hover { border-color: var(--accent); }
.pn.disabled { opacity: .3; pointer-events: none; }
.pn .pn-lbl { font-family: var(--mono); font-size: 11px; color: var(--text3); }
.pn .pn-name { font-weight: 600; font-size: 14px; margin-top: 3px; }
.pn.next { text-align: right; }

/* ============ MARKDOWN ============ */
.md { font-size: 15px; color: #d4d8e4; }
.md > *:first-child { margin-top: 0; }
.md h1, .md h2, .md h3, .md h4 { font-family: var(--display); font-weight: 700; color: var(--text); line-height: 1.25; }
.md h1 { font-size: 27px; margin: 30px 0 14px; letter-spacing: -.5px; }
.md h2 { font-size: 21px; margin: 28px 0 12px; padding-top: 14px; border-top: 1px solid var(--border); }
.md h3 { font-size: 17px; margin: 22px 0 9px; color: var(--accent); }
.md h4 { font-size: 15px; margin: 16px 0 7px; color: var(--text2); }
.md p { margin: 11px 0; }
.md ul, .md ol { margin: 11px 0 11px 24px; }
.md li { margin: 5px 0; }
.md li::marker { color: var(--accent); }
.md a { color: var(--accent2); }
.md strong { color: #fff; }
.md hr { border: none; border-top: 1px solid var(--border); margin: 24px 0; }
.md blockquote { border-left: 3px solid var(--accent); padding: 4px 16px; margin: 14px 0; background: var(--bg3); border-radius: 0 8px 8px 0; color: var(--text2); }
.md code { font-family: var(--mono); font-size: 13px; background: var(--bg3); padding: 2px 7px; border-radius: 5px; color: var(--accent4); border: 1px solid var(--border); }
.md pre { background: #0b0e14; border: 1px solid var(--border); border-radius: 11px; padding: 16px 18px; overflow-x: auto; margin: 14px 0; }
.md pre code { background: none; border: none; padding: 0; color: #c8d0e0; font-size: 13px; line-height: 1.6; }
.md table { width: 100%; border-collapse: collapse; margin: 16px 0; font-size: 13.5px; display: block; overflow-x: auto; }
.md th, .md td { border: 1px solid var(--border); padding: 9px 13px; text-align: left; }
.md th { background: var(--bg3); font-family: var(--display); font-weight: 700; color: var(--text); }
.md tr:nth-child(even) td { background: rgba(255,255,255,.015); }
.md img { max-width: 100%; border-radius: 10px; }

/* ============ TOAST / CELEBRATE ============ */
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%) translateY(120px);
  background: var(--surface2); border: 1px solid var(--accent); color: var(--text);
  padding: 13px 22px; border-radius: 12px; font-weight: 600; font-size: 14px;
  box-shadow: 0 10px 40px rgba(0,0,0,.5); z-index: 100; transition: transform .35s cubic-bezier(.2,1.3,.5,1);
  display: flex; align-items: center; gap: 10px;
}
.toast.show { transform: translateX(-50%) translateY(0); }

/* empty-search */
.no-results { color: var(--text3); padding: 14px; font-size: 13px; text-align: center; }

@media (max-width: 780px) {
  .app { grid-template-columns: 0 1fr; }
  .sidebar { position: fixed; top: 60px; bottom: 0; width: 86%; max-width: 340px; z-index: 40; transform: translateX(-100%); }
  .app.show-nav .sidebar { transform: translateX(0); }
  .view { padding: 22px 18px 100px; }
  .hero h1 { font-size: 32px; }
  .search-wrap { max-width: none; }
}
