/* ============ 1. Reset ============ */
*,
*::before,
*::after { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.85;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, p, figure, blockquote, ol, ul, dl, dd {
  margin: 0;
}

ol, ul { padding: 0; }

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

a { color: var(--brick); }

button { font: inherit; }

:where(a, button, summary, [tabindex]):focus-visible {
  outline: 3px solid var(--brick);
  outline-offset: 3px;
  border-radius: 1px;
}

/* ============ 2. Tokens ============ */
:root {
  --paper: #F7F4EC;
  --ink: #141414;
  --ink-soft: #3A3A3A;
  --mist: #B7CFDF;
  --deep: #2F4F63;
  --brick: #A63D2F;
  --sand: #D8B36A;
  --sea: #7FA99B;
  --haze: #D9D4C8;
  --brick-soft: #E8C9C0;

  --rail-w: 232px;
  --edge: clamp(18px, 4vw, 48px);
  --gap: clamp(16px, 2.4vw, 28px);

  --font-display: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-body: "Source Han Sans SC", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
}

/* ============ 3. Typography ============ */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 900;
  letter-spacing: -0.02em;
  line-height: 1.14;
}

h1 { font-size: clamp(36px, 5.2vw, 68px); }
h2 { font-size: clamp(26px, 3.4vw, 40px); }
h3 { font-size: clamp(20px, 2.2vw, 25px); }

strong { font-weight: 800; }

::selection {
  background: var(--brick);
  color: var(--paper);
}

/* ============ 4. Layout utilities ============ */
.u-wrap {
  width: 100%;
  max-width: 1180px;
  margin-inline: auto;
  padding-inline: var(--edge);
}

.prose {
  font-size: clamp(16px, 1.05vw, 17.5px);
  line-height: 1.85;
  max-width: 68ch;
  color: var(--ink);
}

.prose p { margin-bottom: 1.2em; }
.prose p:last-child { margin-bottom: 0; }
.prose h2 { margin: 2.1em 0 0.7em; }
.prose h3 { margin: 1.7em 0 0.6em; }
.prose ul, .prose ol { margin: 0 0 1.2em; padding-left: 1.3em; }
.prose li { margin-bottom: 0.4em; }
.prose a { text-decoration: underline; text-underline-offset: 3px; }
.prose hr { border: 0; border-top: 1px solid var(--haze); margin: 2.4em 0; }
.prose code {
  font-family: var(--font-mono);
  font-size: 0.92em;
  background: var(--haze);
  padding: 0.1em 0.4em;
  border-radius: 2px;
}

.split { display: grid; gap: clamp(20px, 3vw, 40px); }

.grid { display: grid; gap: var(--gap); }

.grid--2 { grid-template-columns: minmax(0, 1fr); }

.grid--stagger { grid-template-columns: minmax(0, 1fr); }

@media (min-width: 880px) {
  .split {
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
    align-items: start;
  }
  .grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid--stagger { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid--stagger > *:nth-child(even) { margin-top: clamp(20px, 4vw, 56px); }
}

/* ============ 5. Editorial components ============ */
.eyebrow {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.2em;
  color: var(--deep);
  margin: 0 0 10px;
}

.sec-num {
  display: block;
  font-family: var(--font-mono);
  font-size: clamp(34px, 6vw, 64px);
  font-weight: 500;
  line-height: 0.9;
  letter-spacing: -0.04em;
  color: var(--sand);
}

.annot {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  line-height: 1.7;
  color: var(--deep);
}

.annot--vertical {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  letter-spacing: 0.22em;
}

.frame {
  position: relative;
  border: 1px solid var(--ink);
  background: var(--paper);
  padding: clamp(20px, 3vw, 40px);
}

.frame::before,
.frame::after {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  border: 1px solid var(--brick);
  pointer-events: none;
}

.frame::before {
  top: -1px;
  left: -1px;
  border-right: 0;
  border-bottom: 0;
}

.frame::after {
  right: -1px;
  bottom: -1px;
  border-top: 0;
  border-left: 0;
}

.panel {
  background: var(--paper);
  border: 1px solid var(--ink);
  border-radius: 2px;
  padding: clamp(18px, 3vw, 28px);
  box-shadow: -6px 6px 0 var(--haze);
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}

.panel--mist {
  background: var(--mist);
  border-color: var(--deep);
  box-shadow: -6px 6px 0 rgba(47, 79, 99, 0.22);
}

a.panel:hover,
.panel:hover {
  transform: translateY(-2px);
  box-shadow: -8px 8px 0 var(--haze);
  border-color: var(--deep);
}

.lede {
  margin: 0 0 clamp(20px, 3vw, 32px);
  padding: 16px 18px;
  border-left: 3px solid var(--sand);
  background: rgba(216, 179, 106, 0.14);
  font-size: clamp(15px, 1.05vw, 16.5px);
  line-height: 1.8;
  color: var(--ink-soft);
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.12em;
  line-height: 1.4;
  padding: 0.4em 0.75em;
  background: var(--brick);
  color: var(--paper);
  text-decoration: none;
  border-radius: 0;
  clip-path: polygon(7px 0, 100% 0, 100% calc(100% - 7px), calc(100% - 7px) 100%, 0 100%, 0 7px);
  transition: background-color 0.16s ease, color 0.16s ease;
}

.tag--sea { background: var(--sea); color: var(--ink); }
.tag--sand { background: var(--sand); color: var(--ink); }

.tag--old {
  background: transparent;
  color: var(--ink-soft);
  border: 1px dashed var(--ink-soft);
  clip-path: none;
}

.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5em;
  margin: 0 0 20px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
}

.breadcrumbs a {
  color: var(--deep);
  text-decoration: none;
  transition: color 0.16s ease;
}

.breadcrumbs a:hover { color: var(--brick); }

.breadcrumbs [aria-current="page"] { color: var(--ink); }

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

.dir-list li { border-bottom: 1px solid var(--haze); }

.dir-list a {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 2px;
  font-size: 15px;
  color: var(--ink);
  text-decoration: none;
  transition: color 0.16s ease;
}

.dir-list a:hover { color: var(--brick); }

.dir-list span {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
}

.media-frame {
  position: relative;
  display: block;
  overflow: hidden;
  aspect-ratio: 16 / 10;
  background: var(--mist);
  border: 1px solid var(--deep);
  border-radius: 2px;
}

.media-frame--wide { aspect-ratio: 21 / 9; }
.media-frame--tall { aspect-ratio: 4 / 5; }

.media-frame > img,
.media-frame > picture,
.media-frame > picture > img {
  width: 100%;
  height: 100%;
  display: block;
}

.media-frame > img,
.media-frame > picture > img { object-fit: cover; }

.faq { border-top: 1px solid var(--ink); }

.faq__item { border-bottom: 1px solid var(--haze); }

.faq__item summary {
  position: relative;
  list-style: none;
  cursor: pointer;
  padding: 14px 12px 14px 30px;
  font-family: var(--font-display);
  font-size: clamp(15px, 1.2vw, 17px);
  font-weight: 800;
  letter-spacing: -0.01em;
  transition: color 0.16s ease, background-color 0.16s ease;
}

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

.faq__item summary::before {
  content: "+";
  position: absolute;
  left: 6px;
  top: 13px;
  font-family: var(--font-mono);
  color: var(--brick);
}

.faq__item[open] summary::before { content: "–"; }
.faq__item summary:hover { color: var(--brick); }

.faq__item[open] {
  border-left: 3px solid var(--brick);
  padding-left: 6px;
  background: rgba(232, 201, 192, 0.22);
}

/* ============ 6. Buttons ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4em;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 14px;
  letter-spacing: 0.02em;
  line-height: 1.4;
  padding: 0.62em 1.1em;
  border: 1px solid var(--ink);
  border-radius: 2px;
  background: transparent;
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.16s ease, color 0.16s ease, border-color 0.16s ease, transform 0.16s ease;
}

.btn:hover { transform: translateY(-1px); }

.btn--brick {
  background: var(--brick);
  border-color: var(--brick);
  color: var(--paper);
}

.btn--brick:hover {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}

.btn--ghost { background: transparent; }

.btn--ghost:hover {
  background: var(--mist);
  border-color: var(--deep);
  color: var(--deep);
}

.btn--sm { font-size: 12.5px; padding: 0.5em 0.85em; }
.btn--xs { font-size: 11.5px; padding: 0.45em 0.68em; letter-spacing: 0.04em; }

/* ============ 7. Header / rail / drawer ============ */
.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 200;
  transform: translateY(-180%);
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.08em;
  padding: 0.7em 1.1em;
  text-decoration: none;
  border-radius: 2px;
  transition: transform 0.16s ease;
}

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

.scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  z-index: 150;
  pointer-events: none;
  background: transparent;
}

.scroll-progress__bar {
  display: block;
  width: 0;
  height: 100%;
  background: var(--brick);
}

.site-header {
  position: relative;
  z-index: 70;
}

/* --- desktop rail --- */
.rail {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--rail-w);
  display: flex;
  flex-direction: column;
  padding: 26px 22px 22px;
  background: var(--paper);
  border-right: 1px solid var(--ink);
  z-index: 90;
  overflow-y: auto;
}

.rail::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 8px;
  background-image: repeating-linear-gradient(to bottom, var(--haze) 0 1px, transparent 1px 12px);
  opacity: 0.7;
  pointer-events: none;
}

.rail__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--haze);
}

.brandmark {
  display: block;
  text-decoration: none;
  color: var(--ink);
}

.brandmark__name {
  display: block;
  font-family: var(--font-display);
  font-size: 27px;
  font-weight: 900;
  letter-spacing: -0.02em;
  line-height: 1.1;
  transition: color 0.16s ease;
}

.brandmark:hover .brandmark__name { color: var(--brick); }

.brandmark__meta {
  display: block;
  margin-top: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  color: var(--deep);
}

.rail__close {
  display: none;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 18px;
  line-height: 1;
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--ink);
  border-radius: 2px;
  cursor: pointer;
  transition: background-color 0.16s ease, color 0.16s ease, border-color 0.16s ease;
}

.rail__close:hover {
  background: var(--brick);
  border-color: var(--brick);
  color: var(--paper);
}

.rail__nav {
  flex: 1 1 auto;
  min-height: 0;
  padding: 18px 0 20px;
}

.rail__caption {
  margin: 0 0 10px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.2em;
  color: var(--ink-soft);
}

.rail-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.rail-list__item { border-top: 1px solid var(--haze); }
.rail-list__item:last-child { border-bottom: 1px solid var(--haze); }

.rail-link {
  position: relative;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 12px 10px;
  font-family: var(--font-display);
  font-size: 16.5px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--ink);
  text-decoration: none;
  border-radius: 2px;
  transition: background-color 0.16s ease, color 0.16s ease;
}

.rail-link::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: -22px;
  width: 3px;
  background: transparent;
  transition: background-color 0.16s ease;
}

.rail-link__num {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  transition: color 0.16s ease;
}

.rail-link__label {
  overflow-wrap: anywhere;
  transition: letter-spacing 0.16s ease;
}

.rail-link:hover { color: var(--brick); }
.rail-link:hover .rail-link__num { color: var(--brick); }

.rail-link[aria-current="page"],
.rail-link[aria-current="page"]:hover {
  background: var(--brick);
  color: var(--paper);
}

.rail-link[aria-current="page"] .rail-link__num { color: var(--brick-soft); }

.rail-link[aria-current="page"]::before { background: var(--sand); }

.rail__foot {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--haze);
}

.rail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.rail-note {
  margin: 12px 0 0;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  overflow-wrap: anywhere;
}

/* --- mobile bar --- */
.mobile-bar { display: none; }

.mobile-bar__brand {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 900;
  letter-spacing: -0.01em;
  color: var(--ink);
  text-decoration: none;
}

.mobile-bar__dot { color: var(--brick); }

.mobile-bar__actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0.5em 0.7em;
  background: var(--ink);
  color: var(--paper);
  border: 1px solid var(--ink);
  border-radius: 2px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: background-color 0.16s ease, border-color 0.16s ease;
}

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

.nav-toggle__bars {
  position: relative;
  display: block;
  width: 16px;
  height: 2px;
  background: currentColor;
}

.nav-toggle__bars::before,
.nav-toggle__bars::after {
  content: "";
  position: absolute;
  left: 0;
  width: 16px;
  height: 2px;
  background: currentColor;
  transition: transform 0.16s ease, top 0.16s ease;
}

.nav-toggle__bars::before { top: -5px; }
.nav-toggle__bars::after { top: 5px; }

.site-header[data-open="true"] .nav-toggle__bars { background: transparent; }
.site-header[data-open="true"] .nav-toggle__bars::before { top: 0; transform: rotate(45deg); }
.site-header[data-open="true"] .nav-toggle__bars::after { top: 0; transform: rotate(-45deg); }

.nav-scrim { display: none; }

/* --- desktop offset --- */
@media (min-width: 1024px) {
  body { padding-left: var(--rail-w); }
  .scroll-progress { left: var(--rail-w); }
}

/* --- drawer / tablet / phone --- */
@media (max-width: 1023px) {
  .site-header {
    position: sticky;
    top: 0;
    z-index: 80;
    background: var(--paper);
  }

  .mobile-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 14px;
    background: var(--paper);
    border-bottom: 1px solid var(--ink);
  }

  .rail {
    inset: 0 0 0 auto;
    width: min(340px, 86vw);
    border-right: 0;
    border-left: 1px solid var(--ink);
    padding: 20px 20px 24px;
    transform: translateX(102%);
    transition: transform 0.22s ease;
    z-index: 95;
  }

  .rail::after { display: none; }
  .rail__close { display: inline-flex; }

  .site-header[data-open="true"] .rail { transform: translateX(0); }

  .nav-scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 85;
    background: rgba(20, 20, 20, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease;
  }

  .site-header[data-open="true"] .nav-scrim {
    opacity: 1;
    pointer-events: auto;
  }

  body.nav-open { overflow: hidden; }
}

@media (max-width: 420px) {
  .mobile-bar__brand { font-size: 15px; }
  .btn--xs { font-size: 10.5px; padding: 0.42em 0.55em; }
  .nav-toggle__text { display: none; }
  .nav-toggle { padding: 0.55em; }
}

/* ============ 8. Footer ============ */
.site-footer {
  position: relative;
  z-index: 10;
  margin-top: clamp(48px, 8vw, 96px);
  background: var(--ink);
  color: var(--paper);
  border-top: 3px solid var(--brick);
}

.footer__ruler {
  height: 14px;
  background-image: repeating-linear-gradient(90deg, rgba(247, 244, 236, 0.3) 0 1px, transparent 1px 20px);
}

.footer__inner {
  width: 100%;
  max-width: 1180px;
  margin-inline: auto;
  padding: clamp(32px, 5vw, 64px) var(--edge) clamp(24px, 3vw, 42px);
  display: grid;
  grid-template-columns: minmax(200px, 0.9fr) minmax(0, 2.4fr);
  gap: clamp(26px, 4vw, 64px);
}

.footer__brand-name {
  font-family: var(--font-display);
  font-size: clamp(28px, 3vw, 38px);
  font-weight: 900;
  letter-spacing: -0.02em;
  line-height: 1.1;
  color: var(--paper);
}

.footer__brand-note {
  margin: 12px 0 0;
  max-width: 28ch;
  font-size: 14px;
  line-height: 1.8;
  color: rgba(247, 244, 236, 0.72);
}

.footer__reg {
  margin: 16px 0 0;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--sand);
}

.footer-cols {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(16px, 2.4vw, 32px);
}

.foot-col__title {
  margin: 0 0 12px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.18em;
  line-height: 1.5;
  color: var(--mist);
}

.foot-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 2px;
}

.foot-link {
  display: inline-block;
  padding: 5px 0;
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--paper);
  text-decoration: none;
  background-image: linear-gradient(var(--brick-soft), var(--brick-soft));
  background-repeat: no-repeat;
  background-position: 0 100%;
  background-size: 0% 1px;
  transition: background-size 0.18s ease, color 0.18s ease;
}

.foot-link:hover {
  color: var(--brick-soft);
  background-size: 100% 1px;
}

.foot-items {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
  font-size: 13px;
  line-height: 1.75;
  color: rgba(247, 244, 236, 0.72);
}

.footer__base {
  width: 100%;
  max-width: 1180px;
  margin-inline: auto;
  padding: 18px var(--edge) 28px;
  border-top: 1px solid rgba(247, 244, 236, 0.18);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.footer__legal {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  line-height: 1.7;
  color: rgba(247, 244, 236, 0.62);
}

.to-top {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0.55em 0.9em;
  background: transparent;
  color: var(--paper);
  border: 1px solid rgba(247, 244, 236, 0.4);
  border-radius: 2px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}

.to-top:hover {
  background: var(--brick);
  border-color: var(--brick);
  color: var(--paper);
}

@media (max-width: 899px) {
  .footer__inner { grid-template-columns: minmax(0, 1fr); }
  .footer-cols { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 479px) {
  .footer-cols { grid-template-columns: minmax(0, 1fr); }
  .footer__base { flex-direction: column; align-items: flex-start; }
}

/* ============ 9. Motion preferences ============ */
@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;
    scroll-behavior: auto !important;
  }

  .panel:hover,
  a.panel:hover,
  .btn:hover {
    transform: none;
  }
}

/* ============ 10. Print ============ */
@media print {
  .rail,
  .mobile-bar,
  .nav-scrim,
  .scroll-progress,
  .skip-link,
  .to-top,
  .site-footer { display: none !important; }

  body { padding-left: 0; background: #fff; color: #000; }
  .panel, .frame { box-shadow: none; border-color: #000; }
}
