:root {
  --ink: #151b17;
  --muted: #68716b;
  --paper: #f3f1e9;
  --panel: #fbfaf5;
  --line: #d8d7cd;
  --green: #3f6f52;
  --green-dark: #244331;
  --green-soft: #dce8de;
  --amber: #d49545;
  --red: #a94d45;
  --sidebar: #111713;
  --sidebar-muted: #93a096;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --sans: "Inter", system-ui, sans-serif;
  --serif: "Newsreader", Georgia, serif;
  --shadow: 0 20px 45px rgba(28, 36, 30, .1);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  min-height: 100vh;
}
button, input, textarea { font: inherit; }
button { color: inherit; }
a { color: var(--green); }
kbd, code { font-family: var(--mono); }
kbd {
  padding: 2px 6px;
  border: 1px solid #b8bdb8;
  border-bottom-width: 2px;
  border-radius: 4px;
  background: #fff;
  color: var(--ink);
  font-size: .78em;
}
.noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .025;
  z-index: 20;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.5'/%3E%3C/svg%3E");
}

.topbar {
  height: 62px;
  background: #0c110e;
  color: #eff5ef;
  display: grid;
  grid-template-columns: 280px 1fr auto;
  align-items: center;
  padding: 0 22px;
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 15;
  border-bottom: 1px solid #28342c;
}
.brand {
  color: inherit;
  text-decoration: none;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 11px;
  letter-spacing: -.02em;
}
.brand-mark {
  font: 600 15px var(--mono);
  background: #bad4bd;
  color: #142319;
  padding: 7px 6px;
  border-radius: 4px;
}
.topbar-center { display: flex; align-items: center; justify-content: center; gap: 22px; }
.mode-pill {
  font: 600 11px var(--mono);
  letter-spacing: .08em;
  border: 1px solid #405246;
  border-radius: 99px;
  padding: 5px 9px;
  color: #b8c6ba;
}
.mode-pill i {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #72c182;
  margin-right: 6px;
  box-shadow: 0 0 8px #72c182;
}
.command-hint { color: #7f8d82; font-size: 12px; }
.command-hint kbd { background: #252e28; border-color: #465249; color: #ccd7ce; }
.topbar-actions { display: flex; gap: 4px; }
.text-button, .icon-button {
  border: 0;
  background: transparent;
  color: #aab6ac;
  padding: 9px 10px;
  cursor: pointer;
}
.text-button:hover, .icon-button:hover { color: #fff; }
.mobile-only { display: none; }

.app-shell { display: grid; grid-template-columns: 278px 1fr; min-height: 100vh; padding-top: 62px; }
.sidebar {
  position: fixed;
  top: 62px; bottom: 0; left: 0;
  width: 278px;
  background: var(--sidebar);
  color: #edf2ed;
  overflow-y: auto;
  z-index: 12;
  border-right: 1px solid #263029;
}
.sidebar-progress { padding: 24px 22px 20px; border-bottom: 1px solid #29342c; }
.eyebrow {
  color: var(--green);
  font: 600 11px var(--mono);
  letter-spacing: .12em;
}
.sidebar .eyebrow { color: #809588; }
.progress-row { display: flex; justify-content: space-between; align-items: baseline; margin: 11px 0 10px; }
.progress-row strong { font: 600 26px var(--mono); }
.progress-row span { color: var(--sidebar-muted); font-size: 11px; }
.progress-track { height: 3px; background: #344139; overflow: hidden; }
.progress-track span { display: block; height: 100%; background: #8fc39a; width: 0; transition: width .4s; }
#moduleNav { padding: 14px 0; }
.nav-module { border-bottom: 1px solid #202a23; }
.nav-module-header {
  width: 100%;
  border: 0;
  background: transparent;
  color: #e4ebe5;
  text-align: left;
  padding: 14px 20px;
  cursor: pointer;
  display: grid;
  grid-template-columns: 26px 1fr auto;
  gap: 8px;
  align-items: center;
}
.nav-module-header:hover, .nav-module-header.active { background: #1a231d; }
.nav-module-header .num { color: #6f8275; font: 500 10px var(--mono); }
.nav-module-header strong { font-size: 12px; font-weight: 600; line-height: 1.3; }
.nav-module-header .chev { color: #65736a; font-size: 10px; }
.nav-lessons { display: none; padding: 0 0 8px; }
.nav-module.open .nav-lessons { display: block; }
.nav-lesson {
  width: 100%;
  border: 0;
  border-left: 2px solid transparent;
  background: transparent;
  color: #89978d;
  text-align: left;
  padding: 8px 18px 8px 54px;
  font-size: 11px;
  cursor: pointer;
  position: relative;
}
.nav-lesson::before {
  content: "";
  position: absolute;
  left: 35px; top: 12px;
  width: 5px; height: 5px;
  border: 1px solid #647169;
  border-radius: 50%;
}
.nav-lesson.done::before { background: #7eb58a; border-color: #7eb58a; }
.nav-lesson:hover, .nav-lesson.active { color: #fff; border-left-color: #81ae89; background: #18221b; }
.sidebar-footer { padding: 14px 0 28px; border-top: 1px solid #29342c; }
.sidebar-link { width: 100%; text-align: left; border: 0; background: none; color: #89978d; padding: 10px 22px; cursor: pointer; font-size: 12px; }
.sidebar-link:hover { color: white; }

main { grid-column: 2; min-width: 0; }
.page { max-width: 1180px; margin: 0 auto; padding: 54px 52px 80px; }
.hero {
  min-height: 420px;
  display: grid;
  grid-template-columns: 1.05fr .95fr;
  gap: 64px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding-bottom: 54px;
}
.hero h1 {
  font: 600 clamp(47px, 5.2vw, 76px)/.94 var(--serif);
  letter-spacing: -.045em;
  margin: 16px 0 22px;
}
.hero h1 em { color: var(--green); font-style: italic; }
.hero p { color: #5e675f; font-size: 16px; line-height: 1.75; max-width: 620px; }
.hero-actions { display: flex; gap: 10px; margin-top: 29px; flex-wrap: wrap; }
.primary-button, .secondary-button {
  border-radius: 3px;
  padding: 13px 18px;
  cursor: pointer;
  font-weight: 600;
  border: 1px solid var(--ink);
}
.primary-button { background: var(--ink); color: #fff; }
.primary-button:hover { background: var(--green-dark); }
.primary-button span { margin-left: 18px; }
.secondary-button { background: transparent; }
.secondary-button:hover { background: #fff; }
.hero-terminal { background: #111713; color: #cbd5cd; border: 1px solid #313b34; box-shadow: var(--shadow); transform: rotate(.8deg); }
.terminal-bar { height: 38px; border-bottom: 1px solid #303b33; display: flex; align-items: center; gap: 6px; padding: 0 12px; }
.terminal-bar span { width: 8px; height: 8px; border-radius: 50%; background: #455148; }
.terminal-bar b { margin-left: auto; margin-right: auto; color: #7e9083; font: 500 9px var(--mono); }
.terminal-body { padding: 20px 13px 24px; font: 13px/2.4 var(--mono); overflow: hidden; }
.terminal-body > div { display: flex; }
.terminal-body .line-no { color: #4f5f54; display: inline-block; width: 28px; user-select: none; }
.terminal-body b { color: #8ecb99; }
.terminal-body i { color: #65756a; font-style: normal; }
.terminal-body mark { background: #304a38; color: #bce2c2; padding: 2px 4px; }
.terminal-result { background: #171f19; }
.block-cursor { display: inline-block; width: 8px; height: 16px; background: #96c69e; vertical-align: middle; animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--line); margin: 34px 0 62px; background: var(--panel); }
.metric { padding: 19px 21px; border-right: 1px solid var(--line); }
.metric:last-child { border: 0; }
.metric strong { display: block; font: 600 25px var(--mono); margin-bottom: 5px; }
.metric span { color: var(--muted); font-size: 11px; }
.metric small { color: var(--green); font: 500 10px var(--mono); float: right; margin-top: 8px; }
.dashboard-section { margin-top: 62px; }
.section-heading { display: flex; justify-content: space-between; align-items: end; margin-bottom: 22px; gap: 20px; }
.section-heading h2 { font: 600 34px/1.1 var(--serif); margin: 8px 0 0; letter-spacing: -.02em; }
.section-note { color: var(--muted); font: 11px var(--mono); }
.layer-stack { border-top: 1px solid var(--line); }
.layer-card {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  align-items: center;
  padding: 19px 4px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: padding .2s, background .2s;
}
.layer-card:hover { padding-left: 14px; padding-right: 14px; background: var(--panel); }
.layer-card > span { color: #929991; font: 11px var(--mono); }
.layer-card strong { font: 600 21px var(--serif); display: block; }
.layer-card small { color: var(--muted); }
.layer-card > b { color: var(--green); font: 500 11px var(--mono); }
.current-module-card {
  background: var(--green-dark);
  color: #eff5ef;
  display: grid;
  grid-template-columns: 1fr 220px;
  padding: 30px;
  box-shadow: var(--shadow);
}
.current-module-card h3 { font: 600 29px var(--serif); margin: 8px 0; }
.current-module-card p { color: #bdcbbf; line-height: 1.6; max-width: 650px; }
.module-mini-progress { display: grid; place-items: center; border-left: 1px solid #496052; }
.module-mini-progress strong { font: 600 42px var(--mono); }
.module-mini-progress span { color: #aebdaf; font-size: 11px; }

.lesson-page { max-width: 1040px; }
.lesson-header { border-bottom: 1px solid var(--line); padding-bottom: 31px; margin-bottom: 38px; }
.lesson-breadcrumb { color: var(--green); font: 600 11px var(--mono); letter-spacing: .08em; }
.lesson-title-row { display: flex; justify-content: space-between; gap: 20px; align-items: start; }
.lesson-header h1 { font: 600 clamp(40px, 5vw, 62px)/1 var(--serif); letter-spacing: -.035em; margin: 15px 0 13px; }
.lesson-header p { color: var(--muted); font-size: 16px; line-height: 1.65; max-width: 760px; }
.bookmark-button { background: transparent; border: 1px solid var(--line); padding: 10px 12px; cursor: pointer; font-size: 18px; }
.bookmark-button.active { color: var(--amber); background: #fff7e7; }
.lesson-meta { display: flex; gap: 20px; margin-top: 20px; color: #717a73; font: 11px var(--mono); }
.lesson-layout { display: grid; grid-template-columns: minmax(0, 1fr) 230px; gap: 54px; }
.lesson-content { font-size: 16px; line-height: 1.78; }
.lesson-content h2 { font: 600 31px var(--serif); margin: 45px 0 13px; letter-spacing: -.02em; }
.lesson-content h3 { font-size: 17px; margin: 28px 0 8px; }
.lesson-content p { margin: 0 0 18px; }
.lesson-content ul, .lesson-content ol { padding-left: 22px; }
.lesson-content li { margin: 8px 0; }
.lesson-content pre {
  background: #121814;
  color: #d3ddd5;
  padding: 19px 21px;
  overflow-x: auto;
  border-left: 3px solid #79a982;
  font: 13px/1.65 var(--mono);
}
.lesson-content :not(pre) > code {
  background: #e3e5dc;
  border: 1px solid #d2d5cc;
  padding: 1px 5px;
  font-size: .86em;
}
.callout {
  border: 1px solid #cfd8cf;
  border-left: 4px solid var(--green);
  background: #edf3ed;
  padding: 17px 18px;
  margin: 25px 0;
}
.callout.warning { background: #f7efe3; border-color: #e2cba8; border-left-color: var(--amber); }
.callout strong { display: block; font: 600 11px var(--mono); letter-spacing: .08em; margin-bottom: 5px; }
.formula {
  display: flex;
  justify-content: center;
  gap: 13px;
  align-items: center;
  padding: 23px;
  border: 1px solid var(--line);
  background: var(--panel);
  margin: 24px 0;
  font: 600 17px var(--mono);
}
.formula b { color: var(--green); border: 1px solid #b8c8ba; padding: 7px 10px; background: white; }
.lesson-aside { position: sticky; top: 90px; align-self: start; }
.aside-card { border: 1px solid var(--line); background: var(--panel); padding: 17px; margin-bottom: 14px; }
.aside-card h4 { margin: 0 0 10px; font: 600 11px var(--mono); letter-spacing: .08em; color: var(--green); }
.aside-card p, .aside-card li { font-size: 12px; line-height: 1.55; color: var(--muted); }
.aside-card ul { padding-left: 17px; margin-bottom: 0; }
.lesson-bottom { margin-top: 48px; padding-top: 27px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; gap: 14px; }

.practice-card {
  margin: 34px 0;
  border: 1px solid #a9b7aa;
  background: #f9fbf6;
}
.practice-head { display: flex; justify-content: space-between; background: #dce8dd; padding: 12px 16px; border-bottom: 1px solid #b9c6ba; }
.practice-head strong { font: 600 11px var(--mono); letter-spacing: .08em; }
.practice-head span { font: 10px var(--mono); color: #647267; }
.practice-body { padding: 18px; }
.practice-body h3 { margin-top: 0; }
.practice-task { background: white; border: 1px solid var(--line); padding: 15px; font-family: var(--mono); font-size: 13px; white-space: pre-wrap; }
.reveal { display: none; background: #edf3ed; border: 1px solid #c7d4c9; margin-top: 12px; padding: 13px; font-size: 13px; }
.reveal.open { display: block; }

.quiz-page, .module-page, .simple-page { max-width: 1000px; }
.module-hero { padding: 37px; color: #edf4ee; background: var(--green-dark); margin-bottom: 32px; }
.module-hero .eyebrow { color: #9ec2a3; }
.module-hero h1 { font: 600 48px/1 var(--serif); margin: 13px 0; }
.module-hero p { color: #c1cdc3; line-height: 1.65; max-width: 730px; }
.lesson-list { border-top: 1px solid var(--line); }
.lesson-list-item {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  gap: 16px;
  align-items: center;
  padding: 22px 8px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.lesson-list-item:hover { background: var(--panel); }
.lesson-list-item .status-dot { width: 22px; height: 22px; border: 1px solid #a9b0aa; display: grid; place-items: center; border-radius: 50%; font-size: 11px; }
.lesson-list-item.done .status-dot { background: var(--green); color: #fff; border-color: var(--green); }
.lesson-list-item h3 { margin: 0 0 5px; font: 600 22px var(--serif); }
.lesson-list-item p { margin: 0; color: var(--muted); font-size: 13px; }
.lesson-list-item .duration { font: 11px var(--mono); color: var(--muted); }
.field-test { background: #e5e0d2; border: 1px solid #d1c9b7; margin-top: 27px; padding: 24px; display: flex; justify-content: space-between; gap: 22px; align-items: center; }
.field-test h3 { margin: 0 0 6px; font: 600 24px var(--serif); }
.field-test p { color: #69665d; margin: 0; font-size: 13px; }

.quiz-header h1, .simple-page > h1 { font: 600 48px/1 var(--serif); margin: 12px 0; }
.quiz-question { border-top: 1px solid var(--line); padding: 28px 0; }
.quiz-question h3 { font-size: 16px; line-height: 1.5; margin-top: 0; }
.quiz-options { display: grid; gap: 9px; }
.quiz-option { display: flex; gap: 10px; align-items: start; border: 1px solid var(--line); background: var(--panel); padding: 13px 15px; cursor: pointer; }
.quiz-option:hover { border-color: #9bad9d; }
.quiz-option input { margin-top: 3px; accent-color: var(--green); }
.quiz-option.correct { background: #e3efe4; border-color: #83aa89; }
.quiz-option.incorrect { background: #f5e3e0; border-color: #c9928d; }
.quiz-explanation { display: none; margin-top: 10px; padding: 12px; font-size: 13px; color: var(--muted); }
.quiz-explanation.show { display: block; }
.quiz-result { background: var(--green-dark); color: white; padding: 28px; margin-top: 24px; }
.quiz-result strong { font: 600 42px var(--mono); }
.quiz-result p { color: #c2cec4; }

.cheat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; margin-top: 30px; }
.cheat-section { border: 1px solid var(--line); background: var(--panel); padding: 18px; }
.cheat-section h2 { font: 600 24px var(--serif); margin: 0 0 12px; }
.command-row { display: grid; grid-template-columns: 90px 1fr; gap: 12px; padding: 8px 0; border-top: 1px solid #e2e1d9; font-size: 12px; }
.command-row code { color: var(--green); font-weight: 600; }

.modal-backdrop { position: fixed; inset: 0; background: rgba(4, 8, 5, .72); z-index: 50; display: grid; place-items: start center; padding-top: 10vh; }
.modal-backdrop.hidden { display: none; }
.modal { width: min(640px, calc(100vw - 28px)); max-height: 78vh; overflow: auto; background: var(--panel); box-shadow: 0 30px 80px #0008; padding: 25px; }
.modal h2 { font: 600 30px var(--serif); margin: 0 0 16px; }
.modal-close { float: right; border: 0; background: transparent; cursor: pointer; font-size: 20px; }
.search-input, .notes-input {
  width: 100%; border: 1px solid #bfc5bf; background: white; padding: 12px; outline: none;
}
.search-input:focus, .notes-input:focus { border-color: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.search-results { margin-top: 15px; }
.search-result { border-top: 1px solid var(--line); padding: 13px 5px; cursor: pointer; }
.search-result:hover { background: var(--green-soft); }
.search-result strong { display: block; }
.search-result small { color: var(--muted); }
.data-actions { display: flex; gap: 9px; flex-wrap: wrap; margin: 18px 0; }
.danger-button { border: 1px solid var(--red); color: var(--red); background: white; padding: 10px 13px; cursor: pointer; }
.toast-region { position: fixed; right: 20px; bottom: 20px; z-index: 60; display: grid; gap: 8px; }
.toast { background: #111713; color: white; padding: 12px 16px; box-shadow: var(--shadow); font-size: 12px; animation: toast-in .2s ease; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }
.empty-state { border: 1px dashed #b9beb9; padding: 38px; text-align: center; color: var(--muted); }

@media (max-width: 980px) {
  .topbar { grid-template-columns: auto 1fr auto; }
  .mobile-only { display: block; }
  .brand { margin-left: 8px; }
  .topbar-center { display: none; }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { transform: translateX(-100%); transition: transform .25s; box-shadow: 20px 0 50px #0005; }
  .sidebar.open { transform: translateX(0); }
  main { grid-column: 1; }
  .page { padding: 42px 28px 70px; }
  .hero { grid-template-columns: 1fr; gap: 32px; }
  .lesson-layout { grid-template-columns: 1fr; }
  .lesson-aside { position: static; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
}

@media (max-width: 650px) {
  .topbar { height: 56px; padding: 0 10px; }
  .topbar-actions span { display: none; }
  .app-shell { padding-top: 56px; }
  .sidebar { top: 56px; }
  .page { padding: 32px 18px 60px; }
  .hero { padding-bottom: 38px; min-height: auto; }
  .hero h1 { font-size: 48px; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .metric:nth-child(2) { border-right: 0; }
  .metric:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .layer-card { grid-template-columns: 32px 1fr; }
  .layer-card > b { display: none; }
  .current-module-card { grid-template-columns: 1fr; }
  .module-mini-progress { border: 0; border-top: 1px solid #496052; padding-top: 20px; margin-top: 20px; }
  .section-heading { align-items: start; flex-direction: column; }
  .lesson-title-row { display: block; }
  .bookmark-button { float: right; }
  .lesson-aside { grid-template-columns: 1fr; }
  .lesson-bottom { flex-direction: column; }
  .lesson-bottom button { width: 100%; }
  .cheat-grid { grid-template-columns: 1fr; }
  .field-test { align-items: start; flex-direction: column; }
}
