:root {
  --accent: #ff5e00;
  --accent-dim: rgba(255, 94, 0, 0.15);
  --bg: #0a0a0c;
  --surface: #141418;
  --surface-2: #1c1c22;
  --border: rgba(255, 255, 255, 0.08);
  --text: #e8e8ec;
  --muted: #9a9aa8;
  --font: "Exo 2", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}

.page {
  max-width: 820px;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 2rem;
}

.lang-switch {
  display: flex;
  gap: 0.35rem;
}

.lang-switch button {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  padding: 0.3rem 0.65rem;
  cursor: pointer;
  font: inherit;
}

.lang-switch button.active {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-dim);
}

.back {
  font-size: 0.9rem;
  color: var(--muted);
  text-decoration: none;
}

.back:hover {
  color: var(--accent);
}

.hero {
  margin-bottom: 2rem;
}

.hero h1 {
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  font-weight: 600;
  letter-spacing: 0.02em;
  margin-bottom: 0.75rem;
}

.hero p {
  color: var(--muted);
  max-width: 40rem;
}

.hero p + p {
  margin-top: 0.75rem;
}

.hero__eyebrow {
  margin: 0 0 0.35rem;
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
}

.dir-list {
  list-style: none;
  margin: 1rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.5rem;
}

.dir-list__link {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--border);
  background: var(--surface);
  color: inherit;
  text-decoration: none;
}

.dir-list__link:hover,
.dir-list__link:focus-visible {
  border-color: var(--accent);
  outline: none;
}

.dir-list__title {
  font-weight: 600;
  color: var(--text);
}

.dir-list__desc {
  font-size: 0.9rem;
  color: var(--muted);
}

.stub-note {
  font-style: normal;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0 0 1.5rem;
  padding: 0.35rem;
  background: var(--surface);
  border: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 2;
}

.tabs__btn {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 0.45rem 0.85rem;
  font: inherit;
  cursor: pointer;
  text-decoration: none;
}

.tabs__btn:hover,
.tabs__btn:focus-visible {
  color: var(--text);
  outline: none;
}

.tabs__btn.is-on {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-dim);
}

.spec-title {
  font-size: 1.35rem;
  font-weight: 600;
  margin: 2rem 0 0.4rem;
}

.spec-lead {
  color: var(--muted);
  margin-bottom: 1rem;
}

.track {
  display: none;
}

.track.is-on {
  display: block;
}

.part {
  margin-bottom: 3rem;
  scroll-margin-top: 1rem;
}

.part__label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
  margin-bottom: 0.35rem;
}

.part > h2 {
  font-size: 1.35rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}

.part > .lead {
  color: var(--muted);
  margin-bottom: 1.5rem;
}

.toc {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0 0 1.5rem;
}

.toc a {
  font-size: 0.88rem;
  padding: 0.35rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
}

.toc a:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.item {
  margin-bottom: 1.75rem;
  padding-bottom: 1.75rem;
  border-bottom: 1px solid var(--border);
}

.item:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.item h3 {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.item p {
  color: var(--muted);
  margin-bottom: 0.65rem;
}

.item pre,
.item pre[class*='language-'] {
  margin-top: 0.75rem;
  padding: 0.85rem 1rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--text);
  border-radius: 0;
  text-shadow: none;
}

.item pre code,
.item pre[class*='language-'] code {
  font-family: var(--mono);
  font-size: inherit;
  background: transparent;
  padding: 0;
  text-shadow: none;
}

.item p code {
  font-family: var(--mono);
  font-size: 0.88em;
  color: var(--text);
  background: var(--surface-2);
  padding: 0.05em 0.3em;
  border-radius: 3px;
}

/* Prism tokens on dark surface */
.item .token.comment,
.item .token.prolog,
.item .token.doctype,
.item .token.cdata {
  color: #7a7a88;
}

.item .token.punctuation {
  color: #b0b0bc;
}

.item .token.property,
.item .token.tag,
.item .token.boolean,
.item .token.number,
.item .token.constant,
.item .token.symbol {
  color: #ff8f5a;
}

.item .token.selector,
.item .token.attr-name,
.item .token.string,
.item .token.char,
.item .token.builtin {
  color: #7dcea0;
}

.item .token.operator,
.item .token.entity,
.item .token.url {
  color: #c8c8d0;
  background: none;
}

.item .token.atrule,
.item .token.attr-value,
.item .token.keyword {
  color: #6ec4ff;
}

.item .token.function,
.item .token.class-name {
  color: #fabd6e;
}

.item .token.regex,
.item .token.important,
.item .token.variable {
  color: #ff5e00;
}

.item__example {
  margin-top: 0.85rem;
  margin-bottom: 0;
  padding: 0.65rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 2px solid var(--muted);
  color: var(--text);
  font-size: 0.92rem;
}

.item__example > p {
  margin: 0 0 0.5rem;
}

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

.item__example strong {
  color: var(--accent);
  font-weight: 600;
}

.item__list--path {
  margin: 0.35rem 0 0.25rem;
  color: var(--text);
}

.item__example + pre,
.item__example + pre[class*='language-'],
.item__example pre {
  margin-top: 0.65rem;
}

.item__example + .check {
  margin-top: 0.5rem;
}

.check {
  margin-top: 0.85rem;
  border: 1px solid var(--border);
  background: var(--surface);
}

.check + .check {
  margin-top: 0.5rem;
}

.check__summary {
  cursor: pointer;
  list-style: none;
  padding: 0.55rem 0.75rem;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--accent);
  user-select: none;
}

.check__summary::-webkit-details-marker {
  display: none;
}

.check__summary::before {
  content: "+ ";
  font-family: var(--mono);
  color: var(--muted);
}

.check[open] > .check__summary::before {
  content: "- ";
}

.check__body {
  padding: 0 0.75rem 0.75rem;
  border-top: 1px solid var(--border);
}

.check__body > p {
  margin: 0.65rem 0 0.4rem;
  color: var(--text);
  font-size: 0.92rem;
}

.check__body > p:first-child {
  margin-top: 0.65rem;
}

.item p.check__answer {
  margin-top: 0.5rem;
  margin-bottom: 0;
  padding: 0.55rem 0.65rem;
  background: var(--surface-2);
  border-left: 2px solid var(--accent);
  color: var(--muted);
  font-size: 0.88rem;
}

.item p.check__answer strong {
  color: var(--text);
  font-weight: 600;
}

.check__body pre,
.check__body pre[class*='language-'] {
  margin-top: 0.5rem;
}

.item__list {
  margin: 0.5rem 0 0.75rem;
  padding-left: 1.2rem;
  color: var(--muted);
}

.item__list li {
  margin-bottom: 0.45rem;
}

.item__list strong {
  color: var(--text);
  font-weight: 600;
}

.closing {
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
}

.closing h3 {
  font-size: 1rem;
  margin-bottom: 0.65rem;
}

.closing ul {
  padding-left: 1.2rem;
  color: var(--muted);
}

.page--guide .part {
  scroll-margin-top: 4.25rem;
}

.page--guide .item {
  margin-bottom: 1rem;
  padding: 1rem 1rem 0.9rem;
  background: var(--surface);
  border: 1px solid var(--border);
  padding-bottom: 0.9rem;
}

.page--guide .item:last-child {
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.9rem;
}

.item__why {
  color: var(--muted);
  font-size: 0.95rem;
  margin-bottom: 0.75rem;
}

.lane {
  margin-bottom: 0.65rem;
  padding: 0.55rem 0.7rem;
  background: var(--surface-2);
  border-left: 2px solid var(--border);
}

.lane:last-of-type {
  margin-bottom: 0.75rem;
}

.lane--say {
  border-left-color: var(--accent);
}

.lane--hear {
  border-left-color: var(--muted);
}

.lane h4 {
  margin: 0 0 0.35rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
}

.lane--hear h4 {
  color: var(--muted);
}

.lane .item__list {
  margin: 0;
  padding-left: 1.1rem;
  color: var(--text);
}

.lane .item__list li {
  margin-bottom: 0.3rem;
}

.lane .item__list li:last-child {
  margin-bottom: 0;
}

.fold {
  margin-top: 0.5rem;
}

.toc--sticky a.is-on {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}

.toc a:focus-visible {
  border-color: var(--accent);
  color: var(--accent);
  outline: none;
}

@media (max-width: 1099px) {
  .toc--sticky {
    position: sticky;
    top: 0;
    z-index: 3;
    flex-wrap: nowrap;
    overflow-x: auto;
    margin: 0 -1.25rem 1.25rem;
    padding: 0.55rem 1.25rem;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    -webkit-overflow-scrolling: touch;
  }

  .toc--sticky a {
    flex: 0 0 auto;
  }
}

@media (min-width: 1100px) {
  .page--guide {
    max-width: 1080px;
  }

  .guide {
    display: grid;
    grid-template-columns: 13.5rem minmax(0, 1fr);
    gap: 1.75rem;
    align-items: start;
  }

  .toc--sticky {
    position: sticky;
    top: 0.75rem;
    flex-direction: column;
    flex-wrap: nowrap;
    gap: 0.35rem;
    margin: 0;
    max-height: calc(100vh - 1.5rem);
    overflow: auto;
  }

  .toc--sticky a {
    display: block;
  }

  .page--guide .part {
    scroll-margin-top: 1rem;
  }
}

/* Essay landing (philosophy page) */
.page--essay .hero {
  margin-bottom: 2.25rem;
}

.progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  z-index: 10;
  pointer-events: none;
}

.progress i {
  display: block;
  height: 100%;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: 0 50%;
}

.cheat {
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 1.3rem 1.4rem 1.45rem;
  margin: 0 0 3rem;
}

.cheat__title {
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
  margin: 0 0 0.7rem;
}

.cheat__loop {
  font-weight: 500;
  margin: 0 0 1.05rem;
}

.cheat__list {
  list-style: none;
  counter-reset: cheat;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.32rem 1.75rem;
}

.cheat__list li {
  position: relative;
  padding-left: 1.9rem;
  font-size: 0.92rem;
  color: var(--muted);
}

.cheat__list li::before {
  counter-increment: cheat;
  content: counter(cheat, decimal-leading-zero);
  position: absolute;
  left: 0;
  top: 0.18em;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--accent);
}

.toc__caption {
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin: 0.9rem 0 0.3rem;
}

.toc__group:first-child .toc__caption {
  margin-top: 0;
}

@media (max-width: 1099px) {
  .toc__caption {
    display: none;
  }

  .toc__group {
    display: contents;
  }

  .cheat__list {
    grid-template-columns: 1fr;
  }
}

.page--essay .part + .part {
  border-top: 1px solid var(--border);
  padding-top: 2.25rem;
}

.page--essay .part__label {
  font-family: var(--mono);
}

.page--essay .part > h2 {
  font-size: 1.55rem;
  margin-bottom: 1.6rem;
}

.page--essay .part section {
  margin-bottom: 2.25rem;
  scroll-margin-top: 4.25rem;
}

.page--essay .part section:last-child {
  margin-bottom: 0;
}

.page--essay .part h3 {
  font-size: 1.12rem;
  font-weight: 600;
  margin: 0 0 0.8rem;
}

.page--essay .part p {
  margin: 0 0 0.85rem;
}

.page--essay .part p:last-child {
  margin-bottom: 0;
}

.page--essay .part ul,
.page--essay .part ol {
  margin: 0.35rem 0 0.85rem;
  padding-left: 1.2rem;
}

.page--essay .part li {
  margin-bottom: 0.35rem;
}

.page--essay .part li:last-child {
  margin-bottom: 0;
}

.page--essay .part .key {
  border-left: 2px solid var(--accent);
  padding: 0.12rem 0 0.12rem 0.9rem;
  margin: 1.05rem 0;
  font-weight: 500;
}

.page--essay p code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: var(--surface-2);
  padding: 0.05em 0.3em;
}

@media print {
  :root {
    --bg: #fff;
    --surface: #fff;
    --surface-2: #f4f4f4;
    --border: #ddd;
    --text: #111;
    --muted: #555;
  }

  .progress,
  .topbar,
  .toc {
    display: none;
  }

  .guide {
    display: block;
  }

  .cheat {
    background: none;
  }
}
