:root {
  --rail-width: 284px;
  --header-h: 64px;
  --content-max: 1280px;
  --page-bg: #F5F0E6;
  --page-bg-alt: #1F3A2D;
  --card-bg: #FEFCF7;
  --tile-orange: #FF6B35;
  --tile-yellow: #FFC300;
  --tile-teal: #00A8A8;
  --accent: #E91E63;
  --status-new: #2196F3;
  --status-stable: #4CAF50;
  --status-dead: #F44336;
  --ink: #1A1A1A;
  --paper: #FEFCF7;
  --line: #B8B8B8;
  --font-sans: "Source Han Sans SC", "Noto Sans CJK SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --shadow: 6px 6px 0 rgba(26,26,26,0.15);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  padding-top: var(--header-h);
  background-color: var(--page-bg);
  background-image:
    linear-gradient(rgba(26,26,26,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(26,26,26,0.04) 1px, transparent 1px);
  background-size: 28px 28px;
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.7;
}

a {
  color: inherit;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

button {
  font: inherit;
}

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

h1, h2, h3, h4 {
  font-weight: 900;
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 0 0 8px;
}

code {
  font-family: var(--font-mono);
  background: var(--tile-yellow);
  border: 1px solid var(--ink);
  padding: 0 4px;
}

#main-content {
  min-height: 70vh;
  scroll-margin-top: calc(var(--header-h) + 12px);
}

.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 1100;
  background: var(--accent);
  color: var(--paper);
  padding: 8px 14px;
  font-weight: 900;
  transform: translateY(-300%);
  transition: transform 150ms ease;
}

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

.site-header {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1000;
  width: 100%;
  height: var(--header-h);
  display: flex;
  align-items: center;
  background: var(--page-bg-alt);
  color: var(--paper);
  border-bottom: 4px solid var(--tile-orange);
  padding: 0 16px;
}

.rail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  position: relative;
  z-index: 1;
}

.site-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.site-brand__mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  background: var(--tile-orange);
  color: var(--ink);
  font-weight: 900;
  font-size: 20px;
  border: 2px solid var(--ink);
  box-shadow: 3px 3px 0 var(--tile-yellow);
}

.site-brand__text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.site-brand__text strong {
  font-size: 20px;
  letter-spacing: -0.04em;
  color: var(--paper);
}

.site-brand__text small {
  font-size: 11px;
  letter-spacing: 0.08em;
  color: rgba(254,252,247,0.72);
}

.nav-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--tile-yellow);
  color: var(--ink);
  font-weight: 900;
  border: 2px solid var(--ink);
  padding: 6px 10px;
  cursor: pointer;
  box-shadow: 3px 3px 0 var(--ink);
}

.nav-toggle span:not(.nav-toggle__label) {
  display: block;
  width: 16px;
  height: 2px;
  background: var(--ink);
  margin: 2px 0;
}

.nav-toggle__label {
  font-size: 12px;
}

.nav-toggle.is-open {
  background: var(--accent);
  color: var(--paper);
}

.nav-toggle.is-open span:not(.nav-toggle__label) {
  background: var(--paper);
}

.site-nav {
  position: fixed;
  top: var(--header-h);
  left: 0;
  width: min(320px, 86vw);
  height: calc(100vh - var(--header-h));
  background: var(--page-bg-alt);
  border-right: 4px solid var(--tile-orange);
  box-shadow: 6px 0 0 rgba(26,26,26,0.18);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transform: translateX(-102%);
  transition: transform 150ms ease;
  overflow-y: auto;
}

.site-nav[data-open] {
  transform: none;
}

.site-nav__link {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 8px 12px;
  color: var(--paper);
  font-weight: 700;
  border-left: 4px solid transparent;
  border-bottom: 1px solid rgba(254,252,247,0.1);
}

.site-nav__link:hover {
  background: rgba(255,195,0,0.12);
  border-left-color: var(--tile-yellow);
}

.site-nav__link[aria-current="page"] {
  background: var(--tile-yellow);
  color: var(--ink);
  border-left-color: var(--accent);
}

.rail-index {
  display: none;
}

.rail-progress {
  position: absolute;
  top: 0;
  right: -4px;
  width: 8px;
  height: 100%;
  background: rgba(254,252,247,0.08);
}

.rail-progress span {
  display: block;
  width: 100%;
  height: 0;
  background: var(--tile-yellow);
  box-shadow: 0 0 8px var(--tile-yellow);
}

.page-wrap {
  width: min(100%, var(--content-max));
  margin: 0 auto;
  padding: 20px 16px 48px;
}

.page-section {
  padding: 28px 16px;
}

.page-section--light {
  background: var(--tile-yellow);
  border: 2px solid var(--ink);
  box-shadow: var(--shadow);
}

.page-section--dark {
  background: var(--page-bg-alt);
  color: var(--paper);
  border: 2px solid var(--ink);
  box-shadow: var(--shadow);
}

.section-head {
  margin-bottom: 16px;
}

.eyebrow {
  display: block;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 4px;
}

.section-title {
  font-size: clamp(24px, 4vw, 48px);
}

.section-desc {
  max-width: 52em;
  color: rgba(26,26,26,0.78);
}

.section-head--dark .section-title {
  color: var(--paper);
}

.section-head--dark .section-desc {
  color: rgba(254,252,247,0.78);
}

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 16px;
}

.breadcrumb__item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.breadcrumb__item + .breadcrumb__item::before {
  content: "/";
  color: var(--line);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 16px;
  background: var(--tile-yellow);
  color: var(--ink);
  font-weight: 900;
  border: 2px solid var(--ink);
  box-shadow: 4px 4px 0 var(--ink);
  cursor: pointer;
}

.btn:hover {
  background: var(--ink);
  color: var(--tile-yellow);
  text-decoration: none;
}

.btn--primary {
  background: var(--accent);
  color: var(--paper);
}

.btn--teal {
  background: var(--tile-teal);
}

.card-grid {
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

.card {
  position: relative;
  background: var(--card-bg);
  border: 2px solid var(--ink);
  box-shadow: var(--shadow);
  padding: 16px;
}

.card--orange {
  background: var(--tile-orange);
}

.card--yellow {
  background: var(--tile-yellow);
}

.card--teal {
  background: var(--tile-teal);
}

.card__title {
  font-size: 18px;
  margin: 0 0 4px;
}

.card__meta {
  font-family: var(--font-mono);
  font-size: 12px;
  opacity: 0.8;
  margin-bottom: 8px;
}

.card__link::after {
  content: "";
  position: absolute;
  inset: 0;
}

.tile-matrix {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}

.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 110px;
  padding: 12px;
  background: var(--tile-teal);
  border: 2px solid var(--ink);
  box-shadow: var(--shadow);
  color: var(--ink);
}

.tile--orange {
  background: var(--tile-orange);
}

.tile--yellow {
  background: var(--tile-yellow);
}

.tile--teal {
  background: var(--tile-teal);
}

.tile--dark {
  background: var(--page-bg-alt);
  color: var(--paper);
}

.tile__name {
  font-weight: 900;
  font-size: 16px;
}

.tile__count {
  align-self: flex-start;
  font-family: var(--font-mono);
  font-size: 12px;
  background: rgba(26,26,26,0.12);
  padding: 2px 6px;
  border: 1px solid rgba(26,26,26,0.3);
}

.entry-list {
  display: grid;
  background: var(--card-bg);
  border: 2px solid var(--ink);
  box-shadow: var(--shadow);
}

.entry-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  align-items: baseline;
}

.entry-row:last-child {
  border-bottom: 0;
}

.entry-row__name {
  font-weight: 900;
}

.entry-row__section,
.entry-row__batch {
  font-family: var(--font-mono);
  font-size: 12px;
}

.entry-row__state {
  justify-self: start;
}

.entry-row:hover {
  background: var(--tile-yellow);
}

.table-scroll {
  overflow-x: auto;
  background: var(--card-bg);
  border: 2px solid var(--ink);
  box-shadow: var(--shadow);
}

.index-table {
  width: 100%;
  min-width: 560px;
  border-collapse: collapse;
  font-size: 14px;
}

.index-table th,
.index-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.index-table th {
  background: var(--page-bg-alt);
  color: var(--paper);
  font-family: var(--font-mono);
  font-weight: 700;
}

.index-table tr:nth-child(even) td {
  background: rgba(0,168,168,0.08);
}

.index-table tr:hover td {
  background: var(--tile-yellow);
}

.tag-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag-block {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--tile-yellow);
  color: var(--ink);
  border: 2px solid var(--ink);
  padding: 4px 10px;
  font-size: 13px;
  font-weight: 900;
}

.tag-block--teal {
  background: var(--tile-teal);
}

.tag-block--orange {
  background: var(--tile-orange);
}

.tag-block--hot {
  background: var(--accent);
  color: var(--paper);
}

.tag-block span {
  font-family: var(--font-mono);
  font-size: 11px;
}

.tag-block:hover {
  background: var(--ink);
  color: var(--tile-yellow);
}

.badge-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 2px solid var(--ink);
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 900;
  font-family: var(--font-mono);
  white-space: nowrap;
  color: var(--ink);
}

.badge-status::before {
  content: "";
  width: 8px;
  height: 8px;
  background: currentColor;
  border-radius: 50%;
}

.badge-status--new {
  background: var(--status-new);
}

.badge-status--stable {
  background: var(--status-stable);
}

.badge-status--dead {
  background: var(--status-dead);
}

.order-index {
  font-family: var(--font-mono);
  font-weight: 900;
  font-size: 14px;
  color: var(--accent);
}

.order-index--dark {
  color: var(--tile-yellow);
}

.metric-bar {
  display: grid;
  gap: 4px;
}

.metric-bar__head {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 700;
}

.metric-bar__track {
  height: 10px;
  border: 2px solid var(--ink);
  background: rgba(26,26,26,0.08);
}

.metric-bar__fill {
  height: 100%;
  width: 50%;
  background: var(--tile-orange);
}

.metric-bar__fill--accent {
  background: var(--accent);
}

.metric-bar__fill--teal {
  background: var(--tile-teal);
}

.index-strip {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 8px 4px;
}

.index-strip__item {
  flex: 0 0 auto;
  min-width: 44px;
  text-align: center;
  padding: 6px 8px;
  background: var(--card-bg);
  border: 2px solid var(--ink);
  font-family: var(--font-mono);
  font-weight: 900;
  color: var(--ink);
}

.index-strip__item:hover {
  background: var(--tile-yellow);
}

.index-strip__item--active {
  background: var(--accent);
  color: var(--ink);
  border-color: var(--ink);
}

.rail-scroll {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding-bottom: 8px;
}

.rail-scroll__item {
  flex: 0 0 240px;
  scroll-snap-align: start;
  background: var(--card-bg);
  border: 2px solid var(--ink);
  padding: 12px;
}

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

.compare-table th,
.compare-table td {
  border: 1px solid var(--line);
  padding: 8px 10px;
  vertical-align: top;
}

.compare-table th {
  background: var(--tile-teal);
  color: var(--ink);
  font-weight: 900;
}

.compare-table tr:nth-child(even) td {
  background: rgba(255,195,0,0.15);
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 2px solid var(--ink);
  background: var(--card-bg);
  color: var(--ink);
  font-weight: 900;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 13px;
}

.filter-chip[aria-pressed="true"] {
  background: var(--accent);
  color: var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
}

.figure-frame {
  display: grid;
  place-items: center;
  min-height: 120px;
  padding: 12px;
  background: var(--tile-teal);
  color: var(--ink);
  border: 2px solid var(--ink);
  box-shadow: var(--shadow);
  font-family: var(--font-mono);
  font-size: 12px;
  text-align: center;
}

.figure-frame--yellow {
  background: var(--tile-yellow);
}

.figure-frame--orange {
  background: var(--tile-orange);
}

.figure-frame--dark {
  background: var(--page-bg-alt);
  color: var(--paper);
}

.site-footer {
  background: var(--tile-orange);
  color: var(--ink);
  border-top: 4px solid var(--ink);
  padding: 32px 16px 20px;
}

.site-footer .site-brand__text strong {
  color: var(--ink);
}

.site-footer .site-brand__text small {
  color: rgba(26,26,26,0.72);
}

.site-footer .site-brand__mark {
  box-shadow: 3px 3px 0 var(--ink);
}

.site-footer__brand {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 24px;
}

.site-footer__note {
  max-width: 30em;
  margin: 4px 0 0;
  font-weight: 500;
  font-size: 14px;
}

.site-footer__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 20px;
  border-top: 2px solid rgba(26,26,26,0.2);
  padding-top: 24px;
  margin-bottom: 20px;
}

.footer-col__title {
  font-size: 14px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 8px;
  border-bottom: 2px solid var(--ink);
  padding-bottom: 4px;
}

.footer-col__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}

.footer-col__link {
  font-weight: 700;
  border-bottom: 2px solid transparent;
}

.footer-col__link:hover {
  border-bottom-color: var(--ink);
  text-decoration: none;
}

.site-footer__contact {
  display: grid;
  gap: 8px;
  border-top: 2px solid rgba(26,26,26,0.2);
  padding-top: 20px;
  margin-bottom: 16px;
}

.site-footer__contact-item {
  font-family: var(--font-mono);
  font-size: 13px;
  display: block;
}

.site-footer__contact-link {
  justify-self: start;
  background: var(--ink);
  color: var(--tile-yellow);
  padding: 6px 12px;
  font-weight: 900;
  border: 2px solid var(--ink);
}

.site-footer__contact-link:hover {
  background: var(--accent);
  color: var(--paper);
  text-decoration: none;
}

.site-footer__legal {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 13px;
  font-weight: 700;
  border-top: 2px solid rgba(26,26,26,0.2);
  padding-top: 16px;
}

.site-footer__legal a {
  text-decoration: underline;
  text-underline-offset: 3px;
}

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

@media (max-width: 959.98px) {
  .rail-progress {
    display: none;
  }
}

@media (min-width: 960px) {
  body {
    padding-top: 0;
    padding-left: var(--rail-width);
  }

  #main-content {
    scroll-margin-top: 12px;
  }

  .site-header {
    right: auto;
    width: var(--rail-width);
    height: 100vh;
    bottom: 0;
    flex-direction: column;
    align-items: stretch;
    padding: 0;
    border-bottom: 0;
    border-right: 4px solid var(--tile-orange);
    box-shadow: 4px 0 0 var(--tile-yellow);
  }

  .site-header::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background-image:
      linear-gradient(rgba(254,252,247,0.06) 1px, transparent 1px),
      linear-gradient(90deg, rgba(254,252,247,0.06) 1px, transparent 1px);
    background-size: 28px 28px;
  }

  .rail-head {
    position: relative;
    z-index: 1;
    padding: 28px 20px 18px;
    flex-direction: column;
    align-items: flex-start;
    gap: 18px;
  }

  .site-brand {
    flex-direction: column;
    align-items: flex-start;
  }

  .site-brand__mark {
    width: 48px;
    height: 48px;
    font-size: 24px;
  }

  .nav-toggle {
    display: none;
  }

  .site-nav {
    position: static;
    flex: 1;
    width: auto;
    height: auto;
    background: transparent;
    border: 0;
    box-shadow: none;
    padding: 0 12px 20px;
    transform: none;
    overflow: visible;
  }

  .site-nav__link {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    padding: 0 12px;
    border-left: 4px solid transparent;
    border-bottom: 0;
  }

  .site-nav__link::before {
    content: "·";
    font-family: var(--font-mono);
    color: var(--tile-yellow);
    font-size: 20px;
  }

  .site-nav__link:hover {
    background: rgba(255,195,0,0.12);
    border-left-color: var(--tile-yellow);
  }

  .site-nav__link[aria-current="page"] {
    background: var(--tile-yellow);
    color: var(--ink);
    border-left-color: var(--accent);
  }

  .rail-index {
    position: relative;
    z-index: 1;
    display: grid;
    gap: 6px;
    padding: 18px 20px 22px;
    border-top: 1px solid rgba(254,252,247,0.15);
    font-family: var(--font-mono);
    font-size: 12px;
    color: rgba(254,252,247,0.7);
  }

  .rail-index__cell::before {
    content: "▚ ";
    color: var(--tile-orange);
  }

  .rail-progress {
    display: block;
  }

  .page-wrap {
    padding: 32px 28px 64px;
  }

  .page-section {
    padding: 36px 28px;
  }
}

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

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
