:root {
  --bg: #090b0f;
  --panel: #11141a;
  --panel-2: #171b22;
  --line: #29303b;
  --text: #f5f7fa;
  --muted: #98a2b3;
  --accent: #ff3b30;
  --accent-soft: rgba(255, 59, 48, .13);
  --green: #5ee38e;
  --yellow: #ffc857;
  --shadow: 0 22px 70px rgba(0, 0, 0, .32);
}

[data-theme="light"] {
  --bg: #eef1f5;
  --panel: #ffffff;
  --panel-2: #f7f8fa;
  --line: #d9dee7;
  --text: #12151a;
  --muted: #5d6674;
  --accent-soft: rgba(220, 35, 27, .09);
  --shadow: 0 18px 50px rgba(29, 36, 48, .10);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.65;
}
button, input { font: inherit; }
button { color: inherit; }
a { color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(18px);
}
.brand { display: inline-flex; align-items: center; gap: 11px; text-decoration: none; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 2px solid var(--accent);
  border-radius: 9px;
  color: var(--accent);
  font-family: "Barlow Condensed", sans-serif;
  font-size: 1.65rem;
  font-weight: 800;
  transform: skew(-6deg);
}
.brand strong, .brand small { display: block; line-height: 1; }
.brand strong { font-family: "Barlow Condensed", sans-serif; font-size: 1.25rem; letter-spacing: .04em; }
.brand small { margin-top: 5px; color: var(--muted); font-size: .68rem; letter-spacing: .18em; }
.top-actions { display: flex; gap: 10px; }
.icon-button, .menu-button, .tool-button, .complete-button, .nav-button {
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel);
  cursor: pointer;
  transition: border-color .2s, transform .2s, background .2s;
}
.icon-button:hover, .menu-button:hover, .tool-button:hover, .nav-button:hover { border-color: var(--accent); }
.icon-button:active, .menu-button:active, .tool-button:active, .complete-button:active, .nav-button:active { transform: translateY(1px); }
.icon-button { width: 42px; height: 42px; font-size: 1.15rem; }
.menu-button { display: none; padding: 8px 14px; }

.app-shell { display: grid; grid-template-columns: 320px minmax(0, 1fr); min-height: calc(100vh - 72px); }
.sidebar {
  position: sticky;
  top: 72px;
  height: calc(100vh - 72px);
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: var(--panel);
}
.sidebar-head { padding: 26px 22px 18px; }
.eyebrow { margin: 0 0 9px; color: var(--accent); font-size: .75rem; font-weight: 800; letter-spacing: .16em; }
.progress-label { display: flex; justify-content: space-between; gap: 14px; font-size: .88rem; }
.progress-label span { color: var(--muted); }
.progress-track { height: 5px; margin-top: 12px; overflow: hidden; border-radius: 99px; background: var(--line); }
.progress-track span { display: block; width: 0; height: 100%; background: var(--accent); transition: width .3s ease; }
.search-box { display: flex; align-items: center; gap: 8px; margin: 0 16px 14px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 9px; color: var(--muted); background: var(--bg); }
.search-box input { width: 100%; border: 0; outline: 0; color: var(--text); background: transparent; font-size: .9rem; }
.lesson-list { padding: 0 10px 16px; }
.lesson-link {
  width: 100%;
  display: grid;
  grid-template-columns: 36px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.lesson-link:hover { background: var(--panel-2); }
.lesson-link.active { border-color: color-mix(in srgb, var(--accent) 44%, var(--line)); background: var(--accent-soft); }
.lesson-number { display: grid; place-items: center; width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 8px; color: var(--muted); font-family: "Barlow Condensed", sans-serif; font-weight: 700; }
.lesson-link.active .lesson-number { border-color: var(--accent); color: var(--accent); }
.lesson-name strong { display: block; font-size: .9rem; line-height: 1.3; }
.lesson-name small { color: var(--muted); font-size: .75rem; }
.check { color: var(--green); font-weight: 800; }
.sidebar-note { margin: 8px 18px 28px; padding: 15px; border-left: 3px solid var(--yellow); background: var(--panel-2); font-size: .82rem; }
.sidebar-note p { margin: 4px 0 0; color: var(--muted); line-height: 1.55; }

.lesson-stage { min-width: 0; padding: 0 5vw 70px; }
.status-strip { display: flex; justify-content: space-between; gap: 18px; padding: 16px 0; border-bottom: 1px solid var(--line); color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .1em; }
.status-strip span:first-child { color: var(--green); }
.status-strip i { display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: var(--green); box-shadow: 0 0 12px var(--green); }
.lesson-wrap { width: min(900px, 100%); margin: 0 auto; }
.lesson-hero { padding: 58px 0 30px; }
.lesson-kicker { margin: 0 0 10px; color: var(--accent); font-weight: 800; letter-spacing: .15em; font-size: .78rem; }
h1, h2, h3 { font-family: "Barlow Condensed", sans-serif; line-height: 1.05; }
h1 { max-width: 760px; margin: 0; font-size: clamp(3rem, 7vw, 6rem); letter-spacing: -.035em; text-transform: uppercase; }
.lesson-summary { max-width: 720px; margin: 20px 0 0; color: var(--muted); font-size: clamp(1.05rem, 2vw, 1.24rem); }
.lesson-tools { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 24px; }
.tool-button { padding: 9px 14px; }
.lesson-grid { display: grid; grid-template-columns: minmax(0, 1fr) 250px; gap: 28px; align-items: start; }
.content-card, .objectives-card, .quiz-card, .loading-card { border: 1px solid var(--line); border-radius: 14px; background: var(--panel); box-shadow: var(--shadow); }
.content-card { padding: clamp(22px, 4vw, 42px); }
.content-card h2 { margin: 38px 0 12px; font-size: 2rem; }
.content-card h2:first-child { margin-top: 0; }
.content-card h3 { margin: 26px 0 8px; font-size: 1.4rem; }
.content-card p { margin: 0 0 17px; }
.content-card ul { padding-left: 22px; }
.content-card li { margin: 7px 0; }
.content-card code { padding: 2px 6px; border-radius: 5px; color: var(--green); background: var(--bg); font-size: .9em; }
.diagram { margin: 22px 0; padding: 20px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .87rem; line-height: 1.9; overflow-x: auto; }
.callout { margin: 22px 0; padding: 18px 20px; border-left: 4px solid var(--accent); background: var(--accent-soft); }
.callout strong { display: block; margin-bottom: 4px; }
.objectives-card { position: sticky; top: 96px; padding: 20px; }
.objectives-card h2 { margin: 0 0 12px; font-size: 1.35rem; }
.objectives-card ul { margin: 0; padding-left: 18px; color: var(--muted); font-size: .9rem; }
.objectives-card li { margin: 10px 0; }
.quiz-card { margin-top: 28px; padding: clamp(22px, 4vw, 36px); }
.quiz-card h2 { margin: 0; font-size: 2rem; }
.quiz-question { margin: 24px 0; }
.quiz-question > p { font-weight: 700; }
.answer-list { display: grid; gap: 9px; }
.answer-option { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 9px; cursor: pointer; }
.answer-option:hover { border-color: var(--accent); }
.answer-option input { margin-top: 5px; accent-color: var(--accent); }
.quiz-result { min-height: 26px; margin-top: 12px; font-weight: 700; }
.complete-button { padding: 11px 17px; border-color: var(--accent); background: var(--accent); color: white; font-weight: 800; }
.complete-button.done { border-color: var(--green); background: transparent; color: var(--green); }
.lesson-footer { display: flex; justify-content: space-between; gap: 14px; margin-top: 28px; }
.nav-button { min-width: 120px; padding: 11px 15px; }
.nav-button:disabled { opacity: .35; cursor: not-allowed; }
.loading-card { margin: 60px auto; padding: 40px; max-width: 700px; color: var(--muted); text-align: center; }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 50; transform: translateY(20px); opacity: 0; padding: 11px 15px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel); box-shadow: var(--shadow); pointer-events: none; transition: .25s ease; }
.toast.show { transform: translateY(0); opacity: 1; }

@media (max-width: 900px) {
  .menu-button { display: inline-block; }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 25; inset: 72px auto 0 0; width: min(340px, 88vw); height: calc(100vh - 72px); transform: translateX(-105%); box-shadow: var(--shadow); transition: transform .25s ease; }
  .sidebar.open { transform: translateX(0); }
  .lesson-stage { padding: 0 22px 64px; }
  .lesson-grid { grid-template-columns: 1fr; }
  .objectives-card { position: static; order: -1; }
}

@media (max-width: 560px) {
  .topbar { height: 64px; padding: 0 14px; }
  .brand-mark { width: 35px; height: 35px; }
  .brand strong { font-size: 1.05rem; }
  .brand small { font-size: .58rem; }
  .icon-button { width: 38px; height: 38px; }
  .menu-button { padding: 7px 10px; }
  .sidebar { top: 64px; height: calc(100vh - 64px); }
  .lesson-stage { padding-inline: 16px; }
  .status-strip { display: block; }
  .status-strip span { display: block; }
  .status-strip span + span { margin-top: 5px; }
  .lesson-hero { padding-top: 38px; }
  h1 { font-size: 3.2rem; }
  .lesson-footer { flex-direction: column; }
  .nav-button { width: 100%; }
}

@media print {
  .topbar, .sidebar, .status-strip, .lesson-tools, .quiz-card, .lesson-footer { display: none !important; }
  .app-shell { display: block; }
  .lesson-stage { padding: 0; }
  .lesson-grid { display: block; }
  .content-card, .objectives-card { border: 0; box-shadow: none; }
  .objectives-card { margin-bottom: 20px; }
}
