:root {
  color-scheme: dark;
  --bg: #08100f;
  --bg-soft: #0c1615;
  --panel: rgba(18, 31, 29, 0.78);
  --panel-solid: #101d1b;
  --panel-bright: #152522;
  --ink: #edf5f1;
  --muted: #98aaa4;
  --faint: #657771;
  --line: rgba(190, 218, 207, 0.14);
  --line-strong: rgba(190, 218, 207, 0.27);
  --mint: #75e0b3;
  --mint-soft: rgba(117, 224, 179, 0.12);
  --blue: #89b9ff;
  --blue-soft: rgba(137, 185, 255, 0.12);
  --amber: #f4c96c;
  --amber-soft: rgba(244, 201, 108, 0.12);
  --red: #ff887a;
  --max: 1180px;
  --radius: 22px;
  --shadow: 0 28px 80px rgba(0, 0, 0, 0.28);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 82% 4%, rgba(117, 224, 179, 0.09), transparent 27rem),
    radial-gradient(circle at 5% 36%, rgba(137, 185, 255, 0.07), transparent 32rem),
    var(--bg);
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button, input { font: inherit; }
svg { display: block; }
.shell { width: min(calc(100% - 40px), var(--max)); margin: 0 auto; }
.reading-progress { position: fixed; inset: 0 auto auto 0; width: 0; height: 3px; z-index: 20; background: linear-gradient(90deg, var(--mint), var(--blue)); }

.site-nav {
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid var(--line);
  background: rgba(8, 16, 15, 0.78);
  backdrop-filter: blur(18px) saturate(130%);
  -webkit-backdrop-filter: blur(18px) saturate(130%);
}
.nav-inner { min-height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.brand { display: inline-flex; align-items: center; gap: 11px; font-weight: 720; letter-spacing: -0.02em; }
.brand-mark { width: 30px; height: 30px; display: grid; place-items: center; border: 1px solid rgba(117, 224, 179, 0.42); border-radius: 9px; color: var(--mint); background: var(--mint-soft); font-size: 14px; }
.nav-links { display: flex; align-items: center; gap: 22px; color: var(--muted); font-size: 13px; }
.nav-links a:hover, .nav-links a[aria-current="page"] { color: var(--ink); }
.nav-links .github-link { padding: 8px 12px; border: 1px solid var(--line); border-radius: 999px; }

.hero { padding: 92px 0 70px; border-bottom: 1px solid var(--line); }
.hero-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(280px, .65fr); gap: 70px; align-items: end; }
.kicker { margin: 0 0 20px; color: var(--mint); font-size: 12px; font-weight: 700; letter-spacing: .15em; text-transform: uppercase; }
.hero h1 { max-width: 850px; margin: 0; font-size: clamp(48px, 6.3vw, 84px); line-height: .98; letter-spacing: -.064em; font-weight: 730; }
.hero h1 em { color: var(--mint); font-style: normal; }
.hero-copy { margin: 30px 0 0; max-width: 690px; color: #c3d2cd; font-size: clamp(17px, 2vw, 21px); line-height: 1.65; }
.hero-aside { border-left: 1px solid var(--line-strong); padding-left: 26px; color: var(--muted); }
.hero-aside strong { display: block; margin-bottom: 8px; color: var(--ink); font-size: 14px; }
.hero-aside p { margin: 0 0 18px; font-size: 14px; }
.status-line { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--muted); font-size: 13px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--mint); box-shadow: 0 0 14px var(--mint); }

.metric-strip { display: grid; grid-template-columns: repeat(4, 1fr); margin: -1px 0 0; border: 1px solid var(--line); border-radius: 0 0 var(--radius) var(--radius); overflow: hidden; }
.metric { min-height: 138px; padding: 25px; background: rgba(12, 22, 21, .66); border-right: 1px solid var(--line); }
.metric:last-child { border-right: 0; }
.metric b { display: block; margin-bottom: 8px; font-size: 32px; line-height: 1; letter-spacing: -.04em; }
.metric span { color: var(--muted); font-size: 13px; }

.section { padding: 96px 0; }
.section + .section { border-top: 1px solid var(--line); }
.section-head { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 40px; margin-bottom: 38px; }
.section-index { margin: 4px 0 0; color: var(--faint); font: 600 11px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .12em; text-transform: uppercase; }
.section-head h2 { margin: 0; max-width: 780px; font-size: clamp(30px, 4vw, 51px); line-height: 1.08; letter-spacing: -.045em; }
.section-head p:last-child { max-width: 700px; margin: 17px 0 0; color: var(--muted); }

.process-grid { display: grid; grid-template-columns: repeat(5, 1fr); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.process-step { min-height: 205px; padding: 22px; background: var(--panel); border-right: 1px solid var(--line); }
.process-step:last-child { border-right: 0; }
.process-step b { display: inline-grid; width: 31px; height: 31px; place-items: center; margin-bottom: 42px; color: var(--mint); border: 1px solid rgba(117, 224, 179, .36); border-radius: 9px; font: 600 12px ui-monospace, SFMono-Regular, Menlo, monospace; }
.process-step h3 { margin: 0 0 8px; font-size: 16px; }
.process-step p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.55; }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 24px; }
.search { position: relative; width: min(100%, 420px); }
.search input { width: 100%; min-height: 48px; padding: 0 46px 0 16px; color: var(--ink); background: rgba(12, 22, 21, .8); border: 1px solid var(--line); border-radius: 13px; outline: none; }
.search input:focus { border-color: rgba(117, 224, 179, .55); box-shadow: 0 0 0 4px rgba(117, 224, 179, .08); }
.search svg { position: absolute; right: 15px; top: 15px; color: var(--faint); }
.filter-count { color: var(--faint); font: 500 12px ui-monospace, SFMono-Regular, Menlo, monospace; }
.case-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.case-card { position: relative; min-height: 410px; padding: 28px; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius); background: linear-gradient(145deg, rgba(22, 38, 35, .94), rgba(11, 21, 20, .9)); box-shadow: var(--shadow); overflow: hidden; transition: transform .25s, border-color .25s; }
.case-card::after { content: ""; position: absolute; inset: auto -20% -45% 15%; height: 60%; background: radial-gradient(circle, var(--card-glow, rgba(117, 224, 179, .13)), transparent 68%); pointer-events: none; }
.case-card:hover { transform: translateY(-5px); border-color: var(--line-strong); }
.case-card[data-kind="gpu"] { --card-glow: rgba(137, 185, 255, .18); }
.case-top { display: flex; justify-content: space-between; gap: 18px; }
.case-number { color: var(--faint); font: 600 12px ui-monospace, SFMono-Regular, Menlo, monospace; }
.badge { display: inline-flex; align-items: center; gap: 7px; padding: 6px 10px; border: 1px solid rgba(117, 224, 179, .27); border-radius: 999px; color: var(--mint); background: var(--mint-soft); font-size: 11px; font-weight: 650; }
.badge.amber { color: var(--amber); background: var(--amber-soft); border-color: rgba(244, 201, 108, .28); }
.case-card h3 { max-width: 520px; margin: 58px 0 14px; font-size: clamp(27px, 3vw, 39px); line-height: 1.08; letter-spacing: -.04em; }
.case-card > p { max-width: 560px; margin: 0; color: var(--muted); }
.case-meta { position: relative; z-index: 1; display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; padding-top: 32px; }
.case-meta span { padding: 6px 9px; color: #adbfba; background: rgba(255, 255, 255, .035); border: 1px solid var(--line); border-radius: 7px; font-size: 11px; }
.case-link { position: relative; z-index: 1; display: flex; align-items: center; justify-content: space-between; margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--line); color: var(--ink); font-size: 14px; font-weight: 650; }
.case-link span:last-child { color: var(--mint); font-size: 20px; }
.empty-search { display: none; padding: 40px; color: var(--muted); text-align: center; border: 1px dashed var(--line-strong); border-radius: var(--radius); }

.principle-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.principle { padding: 30px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.principle small { color: var(--mint); font: 600 11px ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .09em; }
.principle h3 { margin: 16px 0 10px; font-size: 23px; letter-spacing: -.025em; }
.principle p { margin: 0; color: var(--muted); }

.page-hero { padding: 74px 0 56px; border-bottom: 1px solid var(--line); }
.back-link { display: inline-flex; align-items: center; gap: 8px; margin-bottom: 44px; color: var(--muted); font-size: 13px; }
.back-link:hover { color: var(--ink); }
.page-hero-grid { display: grid; grid-template-columns: minmax(0, 1.28fr) minmax(280px, .72fr); gap: 70px; align-items: end; }
.page-hero h1 { margin: 12px 0 18px; max-width: 820px; font-size: clamp(42px, 6vw, 74px); line-height: 1.02; letter-spacing: -.055em; }
.page-hero .lede { max-width: 720px; margin: 0; color: #c3d2cd; font-size: 18px; }
.case-facts { display: grid; gap: 0; border: 1px solid var(--line); border-radius: 17px; background: var(--panel); overflow: hidden; }
.fact { display: flex; justify-content: space-between; gap: 22px; padding: 15px 17px; border-bottom: 1px solid var(--line); font-size: 13px; }
.fact:last-child { border-bottom: 0; }
.fact span:first-child { color: var(--faint); }
.fact span:last-child { color: #d6e1dd; text-align: right; }

.article-layout { display: grid; grid-template-columns: 210px minmax(0, 760px); gap: 70px; justify-content: center; padding: 72px 0 110px; }
.toc { position: sticky; top: 98px; align-self: start; }
.toc p { margin: 0 0 14px; color: var(--faint); font: 600 10px ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .13em; text-transform: uppercase; }
.toc a { display: block; padding: 7px 0 7px 14px; color: var(--faint); border-left: 1px solid var(--line); font-size: 12px; }
.toc a:hover, .toc a.active { color: var(--ink); border-left-color: var(--mint); }
.article { min-width: 0; }
.article section { padding: 0 0 72px; scroll-margin-top: 96px; }
.article section + section { padding-top: 6px; }
.article h2 { margin: 0 0 22px; font-size: clamp(28px, 4vw, 42px); line-height: 1.12; letter-spacing: -.04em; }
.article h3 { margin: 32px 0 12px; font-size: 21px; letter-spacing: -.02em; }
.article p { color: #b5c5c0; }
.article p strong { color: var(--ink); }
.article ul, .article ol { padding-left: 22px; color: #b5c5c0; }
.article li { margin: 9px 0; }
.plain-card { padding: 26px 28px; border: 1px solid rgba(117, 224, 179, .27); border-radius: 18px; background: linear-gradient(135deg, rgba(117, 224, 179, .1), rgba(117, 224, 179, .035)); }
.plain-card .label { margin: 0 0 8px; color: var(--mint); font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.plain-card p:last-child { margin-bottom: 0; color: #d5e3de; font-size: 17px; }
.callout { margin: 24px 0; padding: 20px 22px; border-left: 3px solid var(--amber); border-radius: 0 13px 13px 0; background: var(--amber-soft); }
.callout p { margin: 0; color: #e3d7b9; }
.callout.blue { border-left-color: var(--blue); background: var(--blue-soft); }
.callout.blue p { color: #cedcf1; }

.glossary { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.term { padding: 18px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); }
.term b { display: block; margin-bottom: 6px; color: var(--ink); }
.term p { margin: 0; color: var(--muted); font-size: 13px; }

.flow { margin: 26px 0; padding: 24px; border: 1px solid var(--line); border-radius: 18px; background: rgba(7, 14, 13, .62); overflow-x: auto; }
.flow-title { margin: 0 0 20px; color: var(--faint); font: 600 10px ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .12em; text-transform: uppercase; }
.flow-row { min-width: 650px; display: grid; grid-template-columns: repeat(5, 1fr); align-items: stretch; gap: 24px; }
.flow-node { position: relative; min-height: 116px; display: flex; flex-direction: column; justify-content: center; padding: 14px; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--panel-solid); }
.flow-node:not(:last-child)::after { content: "→"; position: absolute; right: -19px; top: calc(50% - 12px); color: var(--faint); }
.flow-node b { font-size: 13px; line-height: 1.35; }
.flow-node span { margin-top: 6px; color: var(--faint); font: 500 10px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace; }
.flow-node.problem { border-color: rgba(255, 136, 122, .42); background: rgba(255, 136, 122, .08); }
.flow-node.fixed { border-color: rgba(117, 224, 179, .42); background: rgba(117, 224, 179, .08); }

.responsibility-table { width: 100%; margin: 25px 0; border-collapse: separate; border-spacing: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 15px; font-size: 13px; }
.responsibility-table th, .responsibility-table td { padding: 14px 15px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
.responsibility-table th { color: var(--muted); background: rgba(255,255,255,.035); font-size: 11px; letter-spacing: .05em; text-transform: uppercase; }
.responsibility-table td { color: #b8c7c2; }
.responsibility-table td:first-child { color: var(--ink); font-weight: 620; }
.responsibility-table tr:last-child td { border-bottom: 0; }

.code-block { margin: 22px 0; padding: 20px; overflow-x: auto; color: #cde8dd; background: #07110f; border: 1px solid var(--line); border-radius: 14px; font: 500 12px/1.7 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre; }
code { color: #bdebd8; font: .9em ui-monospace, SFMono-Regular, Menlo, monospace; }

.memory-figure { display: grid; gap: 20px; margin: 28px 0; padding: 26px; border: 1px solid var(--line); border-radius: 18px; background: rgba(7, 14, 13, .62); }
.memory-row { display: grid; grid-template-columns: 92px 1fr 62px; gap: 15px; align-items: center; }
.memory-row > b { font-size: 12px; }
.memory-bar { position: relative; height: 46px; display: flex; border-radius: 9px; background: rgba(255,255,255,.035); overflow: hidden; }
.memory-bar::after { content: "64 KiB"; position: absolute; top: 0; bottom: 0; left: 80%; padding: 3px 0 0 5px; border-left: 2px dashed rgba(244, 201, 108, .72); color: var(--amber); font: 600 9px ui-monospace, SFMono-Regular, Menlo, monospace; }
.seg { display: grid; place-items: center; color: #07110f; font: 700 10px ui-monospace, SFMono-Regular, Menlo, monospace; }
.seg.q { width: 20%; background: var(--mint); }
.seg.k { width: 40%; background: var(--blue); }
.seg.v { width: 40%; background: #b4a3ff; }
.memory-row.after .seg.k, .memory-row.after .seg.v { width: 20%; }
.memory-row.after .memory-bar { padding-right: 40%; }
.memory-row > span { color: var(--muted); font: 600 11px ui-monospace, SFMono-Regular, Menlo, monospace; text-align: right; }
.memory-legend { display: flex; flex-wrap: wrap; gap: 16px; color: var(--faint); font-size: 11px; }
.memory-legend i { width: 9px; height: 9px; display: inline-block; margin-right: 6px; border-radius: 2px; }

.evidence-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; margin: 25px 0; }
.evidence { padding: 20px; border: 1px solid var(--line); border-radius: 15px; background: var(--panel); }
.evidence .evidence-state { color: var(--mint); font: 650 10px ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .08em; text-transform: uppercase; }
.evidence h3 { margin: 10px 0 6px; font-size: 17px; }
.evidence p { margin: 0; color: var(--muted); font-size: 13px; }

.link-panel { display: grid; gap: 1px; margin-top: 26px; border: 1px solid var(--line); border-radius: 15px; background: var(--line); overflow: hidden; }
.link-panel a { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 15px 17px; background: var(--panel-solid); font-size: 13px; }
.link-panel a:hover { background: var(--panel-bright); }
.link-panel span:first-child { color: var(--muted); }
.link-panel span:last-child { color: var(--mint); text-align: right; word-break: break-all; }

.status-timeline { position: relative; margin: 30px 0 0; padding-left: 25px; }
.status-timeline::before { content: ""; position: absolute; left: 6px; top: 6px; bottom: 6px; width: 1px; background: var(--line-strong); }
.status-item { position: relative; padding: 0 0 26px; }
.status-item:last-child { padding-bottom: 0; }
.status-item::before { content: ""; position: absolute; left: -24px; top: 7px; width: 10px; height: 10px; border: 2px solid var(--bg); border-radius: 50%; background: var(--mint); box-shadow: 0 0 0 1px rgba(117,224,179,.35); }
.status-item.pending::before { background: var(--amber); box-shadow: 0 0 0 1px rgba(244,201,108,.35); }
.status-item b { display: block; font-size: 14px; }
.status-item p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

.article-footer { padding: 34px 0 80px; border-top: 1px solid var(--line); }
.next-card { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 28px; border: 1px solid var(--line); border-radius: 18px; background: var(--panel); }
.next-card small { color: var(--faint); }
.next-card b { display: block; margin-top: 5px; font-size: 19px; }
.next-card span:last-child { color: var(--mint); font-size: 24px; }

.site-footer { border-top: 1px solid var(--line); }
.footer-inner { min-height: 110px; display: flex; align-items: center; justify-content: space-between; gap: 24px; color: var(--faint); font-size: 12px; }
.footer-inner a:hover { color: var(--mint); }

@media (max-width: 900px) {
  .hero-grid, .page-hero-grid { grid-template-columns: 1fr; gap: 40px; }
  .hero-aside { max-width: 600px; }
  .metric-strip { grid-template-columns: repeat(2, 1fr); }
  .metric:nth-child(2) { border-right: 0; }
  .metric:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .section-head { grid-template-columns: 1fr; gap: 12px; }
  .process-grid { grid-template-columns: 1fr 1fr; }
  .process-step { min-height: 170px; border-bottom: 1px solid var(--line); }
  .process-step:nth-child(2n) { border-right: 0; }
  .process-step:last-child { grid-column: 1 / -1; border-bottom: 0; }
  .case-grid { grid-template-columns: 1fr; }
  .article-layout { grid-template-columns: 1fr; gap: 30px; }
  .toc { position: static; display: flex; gap: 4px; overflow-x: auto; padding-bottom: 10px; }
  .toc p { display: none; }
  .toc a { flex: 0 0 auto; padding: 7px 10px; border: 1px solid var(--line); border-radius: 999px; }
  .toc a:hover, .toc a.active { border-color: rgba(117,224,179,.45); }
}

@media (max-width: 640px) {
  body { font-size: 15px; }
  .shell { width: min(calc(100% - 28px), var(--max)); }
  .nav-inner { min-height: 60px; }
  .nav-links a:not(.github-link) { display: none; }
  .hero { padding: 66px 0 48px; }
  .hero h1 { font-size: clamp(43px, 14vw, 66px); }
  .hero-copy { font-size: 16px; }
  .metric { min-height: 118px; padding: 19px; }
  .metric b { font-size: 27px; }
  .section { padding: 72px 0; }
  .process-grid { grid-template-columns: 1fr; }
  .process-step, .process-step:last-child { grid-column: auto; border-right: 0; }
  .process-step b { margin-bottom: 22px; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .case-card { min-height: 380px; padding: 23px; }
  .case-card h3 { margin-top: 46px; }
  .principle-grid, .glossary, .evidence-grid { grid-template-columns: 1fr; }
  .page-hero { padding: 44px 0 42px; }
  .back-link { margin-bottom: 28px; }
  .page-hero h1 { font-size: 40px; }
  .article-layout { padding: 38px 0 80px; }
  .plain-card, .flow, .memory-figure { padding: 19px; }
  .responsibility-table { display: block; overflow-x: auto; white-space: nowrap; }
  .memory-row { grid-template-columns: 70px 1fr; }
  .memory-row > span { grid-column: 2; text-align: left; }
  .footer-inner { align-items: flex-start; flex-direction: column; justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; }
}
