:root {
  --bg: #020303;
  --panel: #070908;
  --panel-2: #0d100f;
  --ink: #f4f2df;
  --muted: #a6aa9d;
  --line: #3e4a40;
  --line-hot: #8cff9a;
  --amber: #f0c15a;
  --salmon: #ff8c7a;
  --blue: #8db9d4;
  --code: #020202;
  --shadow: rgba(0, 0, 0, 0.48);
  --mono: "Courier New", Courier, monospace;
  --sans: Verdana, Arial, Helvetica, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: dark;
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--ink);
  background:
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.025) 0 1px, transparent 1px 4px),
    repeating-linear-gradient(90deg, rgba(140, 255, 154, 0.018) 0 1px, transparent 1px 36px),
    linear-gradient(180deg, #000 0%, #020303 54%, #10100d 100%);
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.5;
}

button,
input {
  font: inherit;
}

a {
  color: var(--line-hot);
  text-decoration: none;
}

a:visited {
  color: var(--salmon);
}

a:hover {
  text-decoration: underline;
}

.course-wrap {
  width: min(1540px, calc(100% - 24px));
  margin: 0 auto;
  padding: 14px 0 22px;
}

.site-header,
.left-pane,
.right-pane {
  border: 1px solid var(--line);
  background: rgba(5, 7, 6, 0.95);
  box-shadow: 0 18px 54px var(--shadow);
}

.site-header {
  margin-bottom: 12px;
}

.signal-bar,
.pane-top,
.reader-toolbar,
.site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.signal-bar {
  min-height: 30px;
  padding: 0 10px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  background: #000;
  font-family: var(--mono);
  font-size: 12px;
}

.brand-zone {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr) 150px;
  gap: 22px;
  align-items: center;
  padding: 18px 22px;
}

.brand-art {
  display: block;
  width: 220px;
  aspect-ratio: 16 / 9;
  border: 1px solid #26352a;
  object-fit: cover;
  image-rendering: pixelated;
  background: #000;
}

.brand-copy,
.reader-title-block {
  min-width: 0;
}

.kicker,
.tiny-label {
  margin: 0 0 4px;
  color: var(--line-hot);
  font-family: var(--mono);
  font-size: 12px;
  text-transform: uppercase;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-family: var(--mono);
  font-size: clamp(26px, 3.2vw, 44px);
  line-height: 1.08;
}

.brand-copy p:last-child,
#reader-subtitle {
  max-width: 780px;
  margin: 7px 0 0;
  color: var(--muted);
}

.course-stats {
  display: grid;
  gap: 2px;
  justify-items: end;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
}

.course-stats strong {
  color: var(--amber);
  font-size: 24px;
  line-height: 1;
}

.course-shell {
  display: grid;
  grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.left-pane,
.right-pane {
  min-width: 0;
  height: calc(100vh - 192px);
  min-height: 620px;
  overflow: hidden;
}

.left-pane {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
}

.pane-top {
  min-height: 62px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: #020302;
}

.pane-top h2,
.reader-toolbar h2 {
  font-family: var(--mono);
  font-size: 20px;
  line-height: 1.18;
  overflow-wrap: anywhere;
}

#load-state {
  color: var(--amber);
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
}

.search-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
}

.search-row label {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
}

.search-row input {
  width: 100%;
  min-height: 32px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 0;
  color: var(--ink);
  background: #000;
  outline: none;
}

.search-row input:focus {
  border-color: var(--line-hot);
  box-shadow: 0 0 0 2px rgba(140, 255, 154, 0.16);
}

.course-nav {
  min-height: 0;
  overflow: auto;
  padding: 10px;
}

.arc-group {
  margin: 0 0 10px;
  border: 1px solid #26352a;
  background: rgba(0, 0, 0, 0.28);
}

.arc-group[open] {
  border-color: #50624f;
}

.arc-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 44px;
  padding: 9px 10px;
  cursor: pointer;
  color: var(--ink);
  font-family: var(--mono);
}

.arc-summary::-webkit-details-marker {
  display: none;
}

.arc-title {
  display: block;
  color: var(--line-hot);
  font-size: 12px;
  text-transform: uppercase;
}

.arc-subtitle {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.arc-count {
  color: var(--amber);
  font-size: 12px;
}

.doc-list {
  display: grid;
  gap: 1px;
  padding: 0 6px 8px;
}

.doc-button,
.reader-actions button,
.copy-code {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 0;
  color: var(--ink);
  background: #020302;
  cursor: pointer;
  font-family: var(--mono);
}

.doc-button {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 8px;
  width: 100%;
  padding: 8px;
  text-align: left;
}

.doc-button:hover,
.reader-actions button:hover,
.copy-code:hover {
  border-color: var(--line-hot);
}

.doc-button[aria-current="true"] {
  border-color: var(--line-hot);
  background: rgba(140, 255, 154, 0.1);
}

.doc-number {
  color: var(--amber);
  font-size: 12px;
}

.doc-title {
  display: block;
  font-size: 13px;
  line-height: 1.28;
  overflow-wrap: anywhere;
}

.doc-subtitle,
.doc-meta {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 11px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.doc-meta {
  color: var(--blue);
  font-family: var(--mono);
}

.loading-note,
.empty-note {
  margin: 8px;
  color: var(--muted);
  font-family: var(--mono);
}

.right-pane {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
}

.reader-toolbar {
  min-height: 78px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: #020302;
}

.reader-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
}

.reader-actions button {
  min-width: 66px;
  padding: 6px 10px;
}

.reader-actions button[disabled] {
  cursor: not-allowed;
  opacity: 0.45;
}

.reader-actions button[aria-pressed="true"] {
  color: #061006;
  border-color: var(--line-hot);
  background: var(--line-hot);
}

.lesson-map {
  display: flex;
  gap: 6px;
  min-height: 42px;
  max-height: 86px;
  overflow: auto;
  padding: 7px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
}

.lesson-chip {
  flex: 0 0 auto;
  max-width: 280px;
  min-height: 28px;
  padding: 5px 9px;
  border: 1px solid #2f3b32;
  color: var(--muted);
  background: #000;
  font-family: var(--mono);
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

.lesson-chip:hover {
  border-color: var(--line-hot);
  color: var(--ink);
}

.reader {
  min-height: 0;
  overflow: auto;
  padding: 24px min(5vw, 56px) 70px;
  color: #f7f5e7;
}

.reader > * {
  max-width: 920px;
}

.reader h1,
.reader h2,
.reader h3,
.reader h4 {
  font-family: var(--mono);
  line-height: 1.18;
  overflow-wrap: anywhere;
}

.reader h1 {
  margin: 0 0 16px;
  color: var(--line-hot);
  font-size: 31px;
}

.reader h2 {
  margin: 30px 0 10px;
  color: var(--amber);
  font-size: 23px;
}

.reader h3 {
  margin: 24px 0 8px;
  color: var(--blue);
  font-size: 18px;
}

.reader h4 {
  margin: 20px 0 8px;
  color: var(--salmon);
  font-size: 15px;
}

.reader p,
.reader li {
  font-size: 15px;
  line-height: 1.72;
  overflow-wrap: anywhere;
}

.reader p {
  margin: 0 0 14px;
}

.reader blockquote {
  margin: 18px 0;
  padding: 12px 16px;
  border-left: 3px solid var(--line-hot);
  color: #dce8d7;
  background: rgba(140, 255, 154, 0.07);
}

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

.reader hr {
  height: 1px;
  margin: 28px 0;
  border: 0;
  background: var(--line);
}

.reader ul,
.reader ol {
  margin: 0 0 16px 22px;
  padding: 0;
}

.reader table {
  display: block;
  width: 100%;
  margin: 18px 0 22px;
  border-collapse: collapse;
  overflow-x: auto;
  font-size: 13px;
}

.reader th,
.reader td {
  padding: 8px 10px;
  border: 1px solid #334239;
  text-align: left;
  vertical-align: top;
}

.reader th {
  color: var(--line-hot);
  background: #020302;
  font-family: var(--mono);
}

.reader td {
  background: rgba(255, 255, 255, 0.025);
}

.reader code {
  padding: 1px 4px;
  color: #eaffdf;
  background: #000;
  font-family: var(--mono);
  font-size: 0.94em;
}

.code-shell {
  position: relative;
  max-width: 100%;
  margin: 18px 0 22px;
}

.reader pre {
  max-width: 100%;
  margin: 0;
  padding: 16px;
  border: 1px solid #2f3b32;
  color: #dfffd9;
  background: var(--code);
  overflow: auto;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.55;
  white-space: pre;
}

.reader pre code {
  padding: 0;
  background: transparent;
}

.copy-code {
  position: absolute;
  top: 7px;
  right: 7px;
  min-height: 26px;
  padding: 4px 8px;
  color: var(--muted);
  background: rgba(0, 0, 0, 0.78);
  font-size: 11px;
}

.raw-text {
  white-space: pre-wrap;
}

.site-footer {
  min-height: 42px;
  margin-top: 12px;
  padding: 0 10px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: #000;
  font-family: var(--mono);
  font-size: 12px;
}

@media (max-width: 980px) {
  .brand-zone {
    grid-template-columns: 150px minmax(0, 1fr);
  }

  .brand-art {
    width: 150px;
  }

  .course-stats {
    grid-column: 1 / -1;
    grid-template-columns: repeat(4, auto);
    justify-content: start;
    justify-items: start;
  }

  .course-shell {
    grid-template-columns: 1fr;
  }

  .left-pane,
  .right-pane {
    height: auto;
    min-height: 0;
  }

  .course-nav {
    max-height: 48vh;
  }

  .right-pane {
    min-height: 72vh;
  }
}

@media (max-width: 640px) {
  .course-wrap {
    width: calc(100% - 14px);
    padding-top: 7px;
  }

  .brand-zone {
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .brand-art {
    width: 100%;
    max-height: 155px;
  }

  .signal-bar,
  .reader-toolbar,
  .site-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .reader-actions {
    width: 100%;
    justify-content: stretch;
  }

  .reader-actions button {
    flex: 1 1 0;
    min-width: 0;
  }

  .reader {
    padding: 18px 14px 54px;
  }

  .reader h1 {
    font-size: 25px;
  }

  .reader h2 {
    font-size: 20px;
  }
}
