:root {
  --bg: #0A0A0F;
  --surface: #141419;
  --ink: #F5F2ED;
  --text: #FFFFFF;
  --muted: #6E6E78;
  --line: #26262E;
  --red: #E63946;
  --blue: #00C2FF;
  --gold: #FFB347;
  --red-soft: #E6394633;
  --rail-w: 15rem;
  --header-h: 4rem;
  --max-width: 80rem;
  --font-head: "DIN Alternate", "Bebas Neue", Impact, "Noto Sans SC Black", sans-serif;
  --font-body: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono: "JetBrains Mono", "Roboto Mono", "SFMono-Regular", Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }

html, body, h1, h2, h3, h4, p, ul, ol, dl, dd, figure, blockquote, table, fieldset, pre { margin: 0; }

ul, ol { padding: 0; }

img { max-width: 100%; display: block; }

button, input, select, textarea { font: inherit; color: inherit; }

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

button { background: none; border: none; cursor: pointer; }

table { border-collapse: collapse; width: 100%; }

::selection { background: var(--red); color: var(--ink); }

:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; }

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  padding-left: var(--rail-w);
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 {
  font-family: var(--font-head);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: .03em;
  color: var(--ink);
}

h1 { font-size: clamp(2.4rem, 4vw, 4rem); }
h2 { font-size: clamp(1.6rem, 2.4vw, 2.4rem); }
h3 { font-size: 1.25rem; }

p { margin-bottom: 1em; }

#main-content:focus { outline: none; }
#main-content { scroll-margin-top: 2rem; }

.skip-link {
  position: fixed;
  top: 1rem;
  left: calc(var(--rail-w) + 1rem);
  z-index: 2000;
  padding: .75rem 1.25rem;
  background: var(--red);
  color: #fff;
  font-size: .875rem;
  font-weight: 700;
  letter-spacing: .05em;
  transform: translateY(-300%);
  transition: transform .2s ease;
}

.skip-link:focus-visible { transform: translateY(0); }

.site-header {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--rail-w);
  background: var(--bg);
  border-right: 1px solid var(--line);
  z-index: 100;
  display: flex;
  flex-direction: column;
  padding: 2rem 1.5rem 1.25rem;
}

.site-header::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 3.5rem;
  height: 3.5rem;
  background: var(--red);
  clip-path: polygon(100% 0, 0 0, 100% 100%);
  z-index: 0;
  pointer-events: none;
}

.site-header::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 7rem;
  height: 7rem;
  background: var(--blue);
  clip-path: polygon(0 100%, 0 0, 100% 100%);
  opacity: .12;
  z-index: 0;
  pointer-events: none;
}

.header-brand, .nav-toggle, .site-nav, .header-foot { position: relative; z-index: 1; }

.header-brand {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  max-width: 100%;
  color: var(--ink);
}

.header-brand:hover { color: var(--red); }

.brand-mark {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 2.75rem;
  height: 2.75rem;
  background: #0b0b10;
  border: 1px solid var(--line);
  font-weight: 900;
  line-height: 1.1;
  color: #fff;
  text-shadow: 0 1px 3px rgb(0 0 0 / .5);
}

.brand-mark::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--red);
  clip-path: polygon(0 0, 100% 0, 0 100%);
}

.brand-mark::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--blue);
  clip-path: polygon(100% 0, 100% 100%, 0 100%);
}

.brand-mark__line {
  position: relative;
  z-index: 1;
  font-size: .58rem;
  letter-spacing: .05em;
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: .2rem;
  min-width: 0;
}

.brand-title {
  font-family: var(--font-body);
  font-size: .78rem;
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: .04em;
  color: var(--ink);
}

.brand-tag {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  font-family: var(--font-mono);
  font-size: .58rem;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--muted);
}

.brand-tag::before {
  content: "";
  width: 1.25rem;
  height: 1px;
  background: var(--blue);
}

.nav-toggle {
  display: none;
  position: relative;
  z-index: 10;
  flex: 0 0 auto;
  width: 3rem;
  height: 3rem;
  padding: .7rem;
  border: 1px solid var(--line);
  background: var(--surface);
}

.nav-toggle:hover { border-color: var(--red); }

.nav-toggle__bar {
  display: block;
  height: 2px;
  background: var(--ink);
  margin: 4px 0;
  transition: transform .2s ease, opacity .2s ease;
}

.nav-toggle[aria-expanded="true"] .nav-toggle__bar:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] .nav-toggle__bar:nth-child(2) { transform: scaleX(.2); opacity: 0; }
.nav-toggle[aria-expanded="true"] .nav-toggle__bar:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

.site-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 0;
  margin-top: 1rem;
}

.nav-list {
  list-style: none;
  padding: 0;
  margin: 0;
  border-top: 1px solid var(--line);
}

.nav-link {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .8rem .25rem;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-family: var(--font-head);
  font-size: 1rem;
  letter-spacing: .04em;
  transition: color .2s ease, background-color .2s ease, padding-left .2s ease;
}

.nav-link:hover { color: var(--ink); background: var(--red-soft); padding-left: .4rem; }

.nav-link:hover .nav-index { color: var(--blue); border-color: var(--blue); }

.nav-link[aria-current="page"] {
  color: var(--ink);
  background: var(--red-soft);
  box-shadow: inset 3px 0 0 var(--red);
}

.nav-link[aria-current="page"] .nav-index { color: var(--red); }
.nav-link[aria-current="page"]::after { background: var(--red); border-color: var(--red); }

.nav-index {
  flex: 0 0 2rem;
  margin-right: .5rem;
  padding-right: .4rem;
  border-right: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: .68rem;
  letter-spacing: .08em;
  color: var(--red);
}

.nav-label { flex: 1; }

.nav-link::after {
  content: "";
  width: .4rem;
  height: .4rem;
  flex: 0 0 auto;
  transform: rotate(45deg);
  border: 1px solid var(--line);
  background: transparent;
  transition: background-color .2s ease, border-color .2s ease;
}

.nav-link:hover::after { background: var(--blue); border-color: var(--blue); }

.nav-meta {
  position: absolute;
  right: 0;
  top: 50%;
  writing-mode: vertical-rl;
  font-family: var(--font-mono);
  font-size: .6rem;
  letter-spacing: .3em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

.header-foot {
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

.header-live {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-mono);
  font-size: .68rem;
  letter-spacing: .16em;
  color: var(--red);
}

.live-dot {
  width: .45rem;
  height: .45rem;
  margin-right: .4rem;
  background: var(--red);
  box-shadow: 0 0 0 3px var(--red-soft);
}

.header-code {
  font-family: var(--font-mono);
  font-size: .58rem;
  letter-spacing: .06em;
  color: var(--muted);
}

.header-progress {
  position: absolute;
  top: 0;
  right: 0;
  width: 2px;
  height: 100%;
  background: var(--line);
  pointer-events: none;
  z-index: 5;
}

.header-progress::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--red);
  transform: scaleY(var(--progress, 0));
  transform-origin: top;
  will-change: transform;
}

@media (max-width: 959.98px) {
  body { padding-left: 0; }

  #main-content { scroll-margin-top: calc(var(--header-h) + 1rem); }

  .skip-link { left: 1rem; }

  .site-header {
    position: sticky;
    top: 0;
    bottom: auto;
    right: 0;
    left: 0;
    width: 100%;
    min-height: var(--header-h);
    flex-direction: row;
    align-items: center;
    padding: .5rem 1rem;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .site-header::before { width: 2.5rem; height: 2.5rem; }
  .site-header::after { display: none; }

  .header-brand { flex: 1; flex-direction: row; align-items: center; }

  .brand-mark { width: 2rem; height: 2rem; }
  .brand-mark__line { font-size: .48rem; }

  .brand-tag { display: none; }

  .brand-title {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: .72rem;
  }

  .nav-toggle { display: inline-flex; }

  .site-nav {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    max-height: calc(100vh - var(--header-h));
    overflow-y: auto;
    margin-top: 0;
    padding: 1rem 1.25rem 1.5rem;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    box-shadow: 0 18px 36px rgb(0 0 0 / .45);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    pointer-events: none;
    transition: opacity .2s ease, transform .2s ease, visibility 0s linear .2s;
    z-index: 9;
  }

  .site-nav[data-open] {
    opacity: 1;
    visibility: visible;
    transform: none;
    pointer-events: auto;
    transition-delay: 0s;
  }

  .nav-meta { display: none; }
  .header-foot { display: none; }

  .header-progress {
    top: auto;
    bottom: -1px;
    left: 0;
    width: 100%;
    height: 2px;
  }

  .header-progress::before {
    transform: scaleX(var(--progress, 0));
    transform-origin: left;
  }
}

.site-main { position: relative; }

.container {
  width: 100%;
  max-width: var(--max-width);
  margin-inline: auto;
  padding-inline: clamp(1.25rem, 4vw, 3.5rem);
}

.section { padding-block: clamp(3rem, 8vw, 6rem); }
.section--tight { padding-block: 2rem; }

.grid, .grid--2, .grid--3, .grid--4 { display: grid; gap: 1.5rem; }

@media (min-width: 640px) {
  .grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 1024px) {
  .grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

.section-heading {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.section-heading h2 { margin: 0; }

.section-index {
  font-family: var(--font-mono);
  font-size: .75rem;
  letter-spacing: .1em;
  color: var(--red);
}

.section-note {
  margin-left: auto;
  font-size: .75rem;
  color: var(--muted);
}

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-bottom: 1.5rem;
  padding: 0;
  list-style: none;
  font-size: .875rem;
  color: var(--muted);
}

.breadcrumb li { display: flex; align-items: center; gap: .5rem; }
.breadcrumb li + li::before { content: "/"; color: var(--line); }
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--blue); }
.breadcrumb [aria-current="page"] { color: var(--ink); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  min-height: 2.75rem;
  padding: .7rem 1.5rem;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  font-family: var(--font-head);
  font-size: .85rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  line-height: 1;
  transition: background-color .2s ease, border-color .2s ease, color .2s ease, transform .2s ease;
}

.btn:hover { transform: translate(-2px, -2px); border-color: var(--red); color: var(--red); }

.btn--red { background: var(--red); border-color: var(--red); color: #fff; }
.btn--red:hover { background: var(--blue); border-color: var(--blue); color: var(--bg); transform: translate(0, -2px); }

.btn--blue { background: var(--blue); border-color: var(--blue); color: var(--bg); }
.btn--blue:hover { background: var(--red); border-color: var(--red); color: #fff; transform: translate(0, -2px); }

.btn--ghost { background: transparent; }
.btn--ghost:hover { background: transparent; border-color: var(--blue); color: var(--blue); }

.study-board {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(14rem, 20rem);
  gap: clamp(2rem, 5vw, 4rem);
  align-items: start;
}

.board-aside {
  position: sticky;
  top: 1.5rem;
  font-size: .875rem;
  color: var(--muted);
}

.board-main { min-width: 0; }

@media (max-width: 800px) {
  .study-board { grid-template-columns: 1fr; }
  .board-aside { position: static; }
}

.evidence {
  position: relative;
  padding: 1rem 1.25rem 1rem 1.5rem;
  background: var(--surface);
  border-left: 3px solid var(--red);
}

.evidence--blue { border-left-color: var(--blue); }

.evidence__label {
  display: block;
  margin-bottom: .35rem;
  font-family: var(--font-mono);
  font-size: .7rem;
  letter-spacing: .15em;
  text-transform: uppercase;
  color: var(--blue);
}

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

.term-list {
  display: grid;
  grid-template-columns: minmax(7rem, 10rem) 1fr;
  gap: .5rem 1rem;
}

.term-list dt { font-weight: 700; color: var(--ink); }
.term-list dd { margin: 0; color: var(--muted); }

.media-frame {
  position: relative;
  display: block;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  aspect-ratio: 16 / 9;
}

.media-frame--4x3 { aspect-ratio: 4 / 3; }
.media-frame--1x1 { aspect-ratio: 1 / 1; }
.media-frame--wide { aspect-ratio: 21 / 9; }

.media-frame img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.media-frame::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 0;
  width: 25%;
  height: 25%;
  background: var(--red);
  clip-path: polygon(100% 0, 100% 100%, 0 100%);
  opacity: 0;
  transition: opacity .2s ease;
}

.media-frame:hover::after { opacity: .6; }

.stat { display: block; }

.stat__number {
  display: block;
  font-family: var(--font-mono);
  font-size: clamp(2.4rem, 5vw, 4.5rem);
  line-height: .9;
  letter-spacing: .02em;
  color: var(--ink);
}

.stat--red .stat__number { color: var(--red); }
.stat--blue .stat__number { color: var(--blue); }

.stat__label {
  display: block;
  margin-top: .5rem;
  font-family: var(--font-mono);
  font-size: .7rem;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--muted);
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .15rem .65rem;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-size: .75rem;
  letter-spacing: .05em;
}

.tag--red { color: var(--red); border-color: var(--red); background: var(--red-soft); }
.tag--blue { color: var(--blue); border-color: var(--blue); background: rgb(0 194 255 / .08); }
.tag--gold { color: var(--gold); border-color: var(--gold); background: rgb(255 179 71 / .08); }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); background: var(--surface); }

th, td {
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

th {
  font-family: var(--font-mono);
  font-size: .7rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--bg);
}

tr:hover td { background: var(--red-soft); }

details {
  border: 1px solid var(--line);
  background: var(--surface);
  margin-bottom: .75rem;
}

summary {
  padding: 1rem 1.25rem;
  cursor: pointer;
  font-weight: 700;
  color: var(--ink);
  list-style: none;
}

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

summary::before {
  content: "+";
  display: inline-block;
  width: 1.5rem;
  font-family: var(--font-mono);
  color: var(--red);
}

details[open] summary::before { content: "−"; color: var(--blue); }

details > div { padding: 0 1.25rem 1rem 2.75rem; color: var(--muted); }

.site-footer {
  background: var(--surface);
  color: var(--muted);
}

.footer-shell {
  max-width: var(--max-width);
  margin-inline: auto;
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1.2fr);
  gap: clamp(2rem, 5vw, 4rem);
  padding: clamp(2.5rem, 6vw, 5rem) clamp(1.25rem, 4vw, 3.5rem) 2rem;
}

.footer-brand__name {
  font-family: var(--font-head);
  font-size: clamp(1.75rem, 3vw, 2.5rem);
  line-height: 1;
  letter-spacing: .08em;
  color: var(--ink);
}

.footer-brand__title {
  margin: .25rem 0 .75rem;
  color: var(--muted);
  font-size: .8rem;
  letter-spacing: .08em;
}

.footer-trust {
  max-width: 36rem;
  margin-bottom: 1.25rem;
  padding-left: 1rem;
  border-left: 3px solid var(--blue);
  font-size: .85rem;
  color: var(--muted);
}

.footer-legal {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-top: 1.25rem;
  padding: 0;
  list-style: none;
}

.footer-legal a {
  display: inline-flex;
  align-items: center;
  padding: .3rem .75rem;
  border: 1px solid var(--line);
  font-size: .8rem;
  color: var(--muted);
  transition: color .2s ease, border-color .2s ease, background-color .2s ease;
}

.footer-legal a:hover { color: var(--blue); border-color: var(--blue); background: rgb(0 194 255 / .06); }

.footer-heading {
  position: relative;
  margin: 0 0 1rem;
  padding-left: .75rem;
  font-family: var(--font-head);
  font-size: .8rem;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--ink);
}

.footer-heading::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: .35rem;
  height: .35rem;
  transform: translateY(-50%);
  background: var(--red);
}

.footer-nav ul { list-style: none; padding: 0; margin: 0; }
.footer-nav li { margin-bottom: .35rem; }

.footer-nav a {
  display: inline-block;
  padding: .2rem 0;
  color: var(--muted);
  transition: color .2s ease, transform .2s ease;
}

.footer-nav a:hover { color: var(--blue); transform: translateX(3px); }
.footer-nav a[aria-current="page"] { color: var(--ink); }

.site-footer a { color: var(--muted); }
.site-footer a:hover { color: var(--blue); }

.footer-contact p { margin-bottom: .5rem; font-size: .85rem; color: var(--muted); }
.footer-contact__note { font-size: .75rem; }

.footer-icp {
  margin-top: .75rem;
  padding-top: .75rem;
  border-top: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: .7rem;
  letter-spacing: .05em;
}

.footer-bottom {
  margin-top: 1.5rem;
  border-top: 1px solid var(--line);
}

.footer-bottom p {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1rem clamp(1.25rem, 4vw, 3.5rem);
  font-family: var(--font-mono);
  font-size: .75rem;
  letter-spacing: .04em;
  color: var(--muted);
}

@media (max-width: 900px) {
  .footer-shell { grid-template-columns: 1fr; padding: 2.5rem 1.25rem 1.5rem; }
  .footer-bottom p { padding: .75rem 1.25rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    transition-duration: .001s !important;
    animation-duration: .001s !important;
    animation-iteration-count: 1 !important;
  }
}
