:root {
  --bg: #f7f6f2;
  --paper: #fffdf8;
  --ink: #20201d;
  --muted: #66645e;
  --line: #ded9cf;
  --accent: #1d6f5f;
  --accent-strong: #155247;
  --good-bg: #e8f3ed;
  --good-line: #98c7b0;
  --partial-bg: #e8f1fb;
  --partial-line: #8fb7df;
  --bad-bg: #f7e9e6;
  --bad-line: #d9aaa1;
  --code: #17201e;
  --code-bg: #eeebe4;
  --shell-bg: #171b1a;
  --shell-ink: #ecf1ed;
  --shell-muted: #a8b2ad;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.55;
  width: 100%;
}

a {
  color: var(--accent-strong);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

button,
.button {
  align-items: center;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-weight: 650;
  gap: 0.4rem;
  min-height: 2.35rem;
  padding: 0.45rem 0.75rem;
  text-decoration: none;
}

button:hover,
.button:hover {
  border-color: #bdb6aa;
}

button:focus-visible,
a:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(29, 111, 95, 0.28);
  outline-offset: 2px;
}

.button--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.button--disabled {
  cursor: not-allowed;
  opacity: 0.48;
  pointer-events: none;
}

.skip-link {
  background: var(--ink);
  color: #fff;
  left: 1rem;
  padding: 0.5rem 0.75rem;
  position: fixed;
  top: -4rem;
  z-index: 20;
}

.skip-link:focus {
  top: 1rem;
}

.topbar {
  background: rgba(247, 246, 242, 0.94);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar__inner {
  align-items: center;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  margin: 0 auto;
  max-width: 1180px;
  padding: 0.75rem 1rem;
  width: 100%;
}

.brand {
  align-items: center;
  color: var(--ink);
  display: inline-flex;
  font-weight: 760;
  text-decoration: none;
}

.brand__logo {
  color: var(--accent);
  display: block;
  height: 2.625rem;
  width: 5.5625rem;
}

.toplinks {
  display: flex;
  gap: 1rem;
  font-size: 0.95rem;
}

.layout {
  display: grid;
  grid-template-columns: 17rem minmax(0, 1fr);
  margin: 0 auto;
  max-width: 1180px;
  width: 100%;
}

.sidebar {
  align-self: start;
  border-right: 1px solid var(--line);
  max-height: calc(100vh - 4.25rem);
  overflow: auto;
  padding: 1rem;
  position: sticky;
  top: 4.25rem;
}

.main {
  min-width: 0;
  padding: 2rem 1.25rem 4rem;
}

.main:focus {
  outline: none;
}

.home,
.lesson,
.reference {
  margin: 0 auto;
  max-width: 780px;
}

.eyebrow {
  color: var(--accent-strong);
  font-size: 0.82rem;
  font-weight: 760;
  letter-spacing: 0.04em;
  margin: 0 0 0.4rem;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  line-height: 1.15;
}

h1 {
  font-size: clamp(2rem, 5vw, 3.2rem);
  letter-spacing: 0;
  margin: 0 0 0.85rem;
}

h2 {
  font-size: 1.15rem;
  margin: 0 0 0.65rem;
}

p {
  margin: 0 0 0.9rem;
}

.tagline {
  color: var(--muted);
  font-size: 1.15rem;
  max-width: 42rem;
}

.home-actions,
.exercise-actions,
.lesson-pager {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1rem;
}

.intro-grid {
  border-bottom: 1px solid var(--line);
  border-top: 1px solid var(--line);
  display: grid;
  gap: 1.25rem;
  grid-template-columns: repeat(3, 1fr);
  margin: 2rem 0;
  padding: 1.25rem 0;
}

.intro-grid p,
.lesson-copy p,
.reference > p {
  color: var(--muted);
}

.progress {
  margin-bottom: 1rem;
}

.progress__label {
  color: var(--muted);
  font-size: 0.88rem;
  margin-bottom: 0.45rem;
}

.meter {
  appearance: none;
  accent-color: #bdb6aa;
  background: #e9e4da;
  border: 0;
  border-radius: 99px;
  display: block;
  height: 0.45rem;
  overflow: hidden;
  width: 100%;
}

.meter::-webkit-progress-bar {
  background: #e9e4da;
  border-radius: 99px;
}

.meter::-webkit-progress-value {
  background: #bdb6aa;
  border-radius: 99px;
}

.meter::-moz-progress-bar {
  background: #bdb6aa;
  border-radius: 99px;
}

.lesson-nav,
.outline {
  list-style: none;
  margin: 0;
  padding: 0;
}

.lesson-section,
.outline__section {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 760;
  letter-spacing: 0.04em;
  margin: 1rem 0 0.35rem;
  text-transform: uppercase;
}

.lesson-nav a {
  align-items: start;
  border-radius: 6px;
  color: var(--ink);
  display: grid;
  font-size: 0.9rem;
  gap: 0.5rem;
  grid-template-columns: 1.7rem 1fr;
  padding: 0.42rem;
  text-decoration: none;
}

.lesson-nav a:hover,
.lesson-nav .is-current {
  background: #ebe7dd;
}

.lesson-nav .is-done .lesson-number {
  background: var(--accent);
  color: #fff;
}

.lesson-nav .is-locked {
  color: #969189;
}

.lesson-number {
  background: #e6e1d7;
  border-radius: 99px;
  color: var(--muted);
  display: inline-grid;
  font-size: 0.78rem;
  height: 1.35rem;
  place-items: center;
  width: 1.35rem;
}

.outline {
  columns: 2;
  column-gap: 2rem;
}

.outline li {
  break-inside: avoid;
  margin: 0 0 0.45rem;
}

.outline a {
  text-decoration: none;
}

.outline span {
  color: var(--muted);
}

.examples,
.exercise,
.lesson-list-full,
.reference-grid section {
  margin-top: 1.5rem;
}

.examples {
  border-top: 1px solid var(--line);
  padding-top: 1.2rem;
}

.example {
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 1rem;
  grid-template-columns: minmax(12rem, 1fr) 1.2fr;
  padding: 0.65rem 0;
}

code,
pre,
textarea {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

code {
  background: var(--code-bg);
  border-radius: 4px;
  color: var(--code);
  font-size: 0.92em;
  padding: 0.08rem 0.28rem;
}

code,
pre {
  overflow-wrap: anywhere;
}

.example code {
  align-self: start;
  display: inline-block;
  white-space: pre-wrap;
}

.example span {
  color: var(--muted);
  white-space: pre-wrap;
}

.exercise {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1rem;
}

.exercise__header {
  align-items: start;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
}

.mode {
  border: 1px solid var(--line);
  border-radius: 99px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.18rem 0.5rem;
}

.terminal {
  background: var(--shell-bg);
  border-radius: 8px;
  color: var(--shell-ink);
  min-width: 0;
  overflow: hidden;
}

.terminal__bar {
  align-items: center;
  background: #232927;
  color: var(--shell-muted);
  display: flex;
  gap: 0.4rem;
  padding: 0.45rem 0.65rem;
}

.terminal__bar span {
  background: #5c6863;
  border-radius: 99px;
  height: 0.58rem;
  width: 0.58rem;
}

.terminal__bar strong {
  font-size: 0.78rem;
  font-weight: 650;
  margin-left: 0.25rem;
}

.command-line {
  align-items: start;
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  min-width: 0;
  padding: 0.65rem 0.8rem 0.75rem;
}

.prompt-line {
  color: var(--shell-muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.9rem;
  line-height: 1.55;
  min-width: 0;
  overflow-wrap: anywhere;
  padding: 0.5rem 0.35rem 0.5rem 0;
  white-space: nowrap;
}

textarea {
  background: transparent;
  border: 0;
  color: inherit;
  display: block;
  font-size: 0.95rem;
  line-height: 1.55;
  min-height: 8rem;
  padding: 0.5rem 0.8rem 0.8rem;
  resize: vertical;
  width: 100%;
}

.terminal textarea {
  caret-color: #fff;
  min-height: 2.45rem;
  outline: none;
  padding: 0.5rem 0 0.5rem 0.1rem;
  resize: none;
}

.terminal textarea:focus-visible {
  outline: none;
}

.editor {
  background: #fbf9f4;
  border: 1px solid var(--line);
  border-radius: 7px;
}

.editor textarea {
  color: var(--code);
}

.script-output {
  background: var(--shell-bg);
  border-radius: 7px;
  color: var(--shell-ink);
  margin-top: 0.8rem;
  padding: 0.75rem 0.8rem;
}

.script-output strong {
  color: var(--shell-muted);
  display: block;
  font-size: 0.82rem;
  margin-bottom: 0.45rem;
}

.script-output pre {
  max-height: 10rem;
}

.terminal-output {
  color: var(--shell-muted);
  height: 16.25rem;
  overflow: auto;
  padding: 0.75rem 0.8rem;
}

pre {
  margin: 0;
  overflow: auto;
  white-space: pre-wrap;
}

.file-tree,
.solution {
  border-top: 1px solid var(--line);
  color: var(--muted);
  margin-top: 0.8rem;
  padding-top: 0.75rem;
}

summary {
  cursor: pointer;
  font-weight: 650;
}

.note,
.feedback {
  border: 1px solid var(--line);
  border-radius: 6px;
  margin-top: 0.8rem;
  padding: 0.75rem;
}

.note {
  background: #f4f1ea;
}

.feedback--idle {
  background: #f8f5ee;
  color: var(--muted);
}

.feedback--ok {
  background: var(--good-bg);
  border-color: var(--good-line);
}

.feedback--partial {
  background: var(--partial-bg);
  border-color: var(--partial-line);
}

.feedback--bad {
  background: var(--bad-bg);
  border-color: var(--bad-line);
}

.feedback p:last-child {
  margin-bottom: 0;
}

.tests {
  display: grid;
  gap: 0.5rem;
  margin-top: 0.8rem;
}

.tests__help {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0.8rem 0 0.25rem;
}

.tests div {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 0.5rem;
  grid-template-columns: 5rem 1fr 1fr;
  padding: 0.45rem 0;
}

.tests span {
  color: var(--muted);
}

.lesson-pager {
  justify-content: space-between;
  margin-top: 1.25rem;
}

.reference-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

dl,
dd {
  margin: 0;
}

dl div {
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 0.8rem;
  grid-template-columns: 11rem 1fr;
  padding: 0.5rem 0;
}

dd {
  color: var(--muted);
}

.sr-only {
  clip: rect(0, 0, 0, 0);
  border: 0;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}

@media (max-width: 860px) {
  .layout {
    display: block;
    max-width: 100%;
    overflow-x: hidden;
    width: 100%;
  }

  .sidebar {
    border-bottom: 1px solid var(--line);
    border-right: 0;
    max-height: none;
    max-width: 100%;
    overflow: hidden;
    position: static;
    width: 100%;
  }

  .lesson-nav {
    display: flex;
    gap: 0.35rem;
    max-width: 100%;
    min-width: 0;
    overflow-x: auto;
    padding-bottom: 0.25rem;
    width: 100%;
  }

  .lesson-section {
    display: none;
  }

  .lesson-nav li {
    flex: 0 0 auto;
  }

  .lesson-nav a {
    grid-template-columns: 1.35rem;
    min-width: 2.3rem;
    position: relative;
  }

  .lesson-nav a span:last-child {
    clip: rect(0, 0, 0, 0);
    height: 1px;
    left: 0;
    overflow: hidden;
    position: absolute;
    top: 0;
    width: 1px;
  }

  .intro-grid,
  .reference-grid {
    grid-template-columns: 1fr;
  }

  .outline {
    columns: 1;
  }
}

@media (max-width: 560px) {
  .topbar__inner {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.55rem;
  }

  .toplinks {
    flex-wrap: wrap;
  }

  .main {
    padding: 1.4rem 0.85rem 3rem;
  }

  .exercise__header {
    flex-wrap: wrap;
  }

  .command-line {
    gap: 0.15rem;
    grid-template-columns: 1fr;
  }

  .prompt-line {
    padding: 0.5rem 0 0.15rem;
    white-space: normal;
  }

  .terminal textarea {
    padding-top: 0.15rem;
  }

  .example,
  .tests div,
  dl div {
    grid-template-columns: 1fr;
    gap: 0.35rem;
  }

  .exercise {
    padding: 0.8rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}
