/* ═══════════════════════════════════════════════════════════════════
   高性价比人生指南 — Swiss International / minimal grid
   Ink on paper. One accent. Hairlines as structure. No shadows.
   ═══════════════════════════════════════════════════════════════════ */

@layer reset, tokens, base, layout, components, motion;

/* ── reset ─────────────────────────────────────────────────────────── */
@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  * { margin: 0; }
  html { -webkit-text-size-adjust: 100%; }
  body { min-height: 100svh; line-height: 1.5; -webkit-font-smoothing: antialiased; }
  img, svg, video { display: block; max-width: 100%; }
  button, input, select, textarea { font: inherit; color: inherit; }
  button { background: none; border: 0; cursor: pointer; }
  a { color: inherit; text-decoration: none; }
  ul, ol { list-style: none; padding: 0; }
  table { border-collapse: collapse; width: 100%; }
  :focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 1px; }
}

/* ── tokens ────────────────────────────────────────────────────────── */
@layer tokens {
  :root {
    --ink:        #0B0B0C;
    --ink-2:      #3A3A3D;
    --muted:      #63636A;
    --paper:      #F7F6F2;
    --paper-2:    #EFEEE8;
    --paper-3:    #E6E4DC;
    --accent:     #E4320B;
    --accent-deep: #BE2A06;
    --accent-ink: #FFFFFF;
    --link:       #1B3FD8;
    --line:       rgba(11, 11, 12, .16);
    --line-2:     rgba(11, 11, 12, .085);
    --line-3:     rgba(11, 11, 12, .05);
    --mark:       #FFE24A;

    --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
            "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", "Source Han Sans SC",
            sans-serif;
    --mono: "SF Mono", "JetBrains Mono", ui-monospace, "Cascadia Mono", Menlo, Consolas,
            "Noto Sans Mono CJK SC", monospace;

    --gut: clamp(18px, 4.2vw, 56px);
    --maxw: 1560px;
    --r: 2px;

    --step--1: clamp(.78rem, .76rem + .1vw, .84rem);
    --step-0:  clamp(.94rem, .91rem + .16vw, 1rem);
    --step-1:  clamp(1.06rem, 1rem + .3vw, 1.2rem);
    --step-2:  clamp(1.28rem, 1.15rem + .65vw, 1.7rem);
    --step-3:  clamp(1.7rem, 1.4rem + 1.5vw, 2.6rem);
    --step-4:  clamp(2.3rem, 1.6rem + 3.4vw, 4.4rem);
    --step-5:  clamp(3.2rem, 1.4rem + 8vw, 9rem);

    --ease: cubic-bezier(.22, .61, .36, 1);
    --ease-out: cubic-bezier(.16, 1, .3, 1);
    --dur: .34s;
  }

  html[data-theme="dark"] {
    --ink:        #F4F3EE;
    --ink-2:      #C9C8C1;
    --muted:      #8E8D87;
    --paper:      #0A0A0B;
    --paper-2:    #131316;
    --paper-3:    #1C1C20;
    --accent:     #FF5A2B;
    --accent-deep: #FF6A3D;
    --accent-ink: #0A0A0B;
    --link:       #7C9BFF;
    --line:       rgba(244, 243, 238, .2);
    --line-2:     rgba(244, 243, 238, .11);
    --line-3:     rgba(244, 243, 238, .06);
    --mark:       #6B5B00;
  }

  @media (prefers-color-scheme: dark) {
    html:not([data-theme="light"]) {
      --ink: #F4F3EE; --ink-2: #C9C8C1; --muted: #8E8D87;
      --paper: #0A0A0B; --paper-2: #131316; --paper-3: #1C1C20;
      --accent: #FF5A2B; --accent-deep: #FF6A3D; --accent-ink: #0A0A0B; --link: #7C9BFF;
      --line: rgba(244,243,238,.2); --line-2: rgba(244,243,238,.11); --line-3: rgba(244,243,238,.06);
      --mark: #6B5B00;
    }
  }
}

/* ── base ──────────────────────────────────────────────────────────── */
@layer base {
  html { scroll-behavior: smooth; scroll-padding-top: 88px; }
  body {
    font-family: var(--sans);
    font-size: var(--step-0);
    color: var(--ink);
    background: var(--paper);
    font-feature-settings: "tnum" 0, "kern" 1;
    overflow-wrap: break-word;
    transition: background-color .5s var(--ease), color .5s var(--ease);
    overflow-x: hidden;
  }
  h1, h2, h3, h4 { font-weight: 600; line-height: 1.08; letter-spacing: -.018em; text-wrap: balance; }
  p { text-wrap: pretty; }
  strong { font-weight: 600; }
  .u-mono { font-family: var(--mono); font-variant-ligatures: none; }
  .sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
  }
  .u-label {
    font-family: var(--mono); font-size: var(--step--1); letter-spacing: .1em;
    text-transform: uppercase; color: var(--muted); font-weight: 500;
  }
  .num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
  .skip {
    position: fixed; top: 8px; left: 8px; z-index: 200; padding: 10px 16px;
    background: var(--ink); color: var(--paper); transform: translateY(-160%);
    transition: transform .2s var(--ease); font-size: var(--step--1);
  }
  .skip:focus { transform: none; }
  .noscript { padding: 40px var(--gut); font-size: var(--step-1); }
  ::selection { background: var(--mark); color: #0B0B0C; }
}

/* ── layout ────────────────────────────────────────────────────────── */
@layer layout {
  .wrap { width: 100%; max-width: var(--maxw); margin-inline: auto; padding-inline: var(--gut); }
  .rule { height: 1px; background: var(--line); border: 0; }

  .progress { position: fixed; inset: 0 0 auto; height: 2px; z-index: 90; pointer-events: none; }
  .progress i {
    display: block; height: 100%; width: 0; background: var(--accent);
    transform-origin: 0 50%; transition: width .1s linear;
  }

  .topbar {
    position: sticky; top: 0; z-index: 80;
    background: color-mix(in srgb, var(--paper) 86%, transparent);
    backdrop-filter: saturate(1.6) blur(14px);
    border-bottom: 1px solid var(--line-2);
  }
  .topbar__in {
    max-width: var(--maxw); margin-inline: auto; padding: 0 var(--gut);
    height: 60px; display: flex; align-items: center; gap: clamp(14px, 3vw, 40px);
  }
  .brand { display: flex; align-items: center; gap: 10px; font-weight: 600; letter-spacing: -.01em; white-space: nowrap; }
  .brand__mark { display: grid; gap: 2.5px; width: 18px; }
  .brand__mark i { display: block; height: 2.5px; background: var(--ink); }
  .brand__mark i:nth-child(1) { background: var(--accent); width: 100%; }
  .brand__mark i:nth-child(2) { width: 66%; }
  .brand__mark i:nth-child(3) { width: 84%; }
  .brand:hover .brand__mark i:nth-child(2) { width: 100%; }
  .brand__mark i { transition: width .4s var(--ease-out); }

  .nav { display: flex; gap: clamp(10px, 1.6vw, 26px); margin-inline-end: auto; }
  .nav a {
    position: relative; padding: 4px 0; font-size: var(--step--1); color: var(--muted);
    transition: color .22s var(--ease); white-space: nowrap;
  }
  .nav a::after {
    content: ""; position: absolute; left: 0; right: 0; bottom: -2px; height: 1.5px;
    background: var(--accent); transform: scaleX(0); transform-origin: 0 50%;
    transition: transform .3s var(--ease-out);
  }
  .nav a:hover { color: var(--ink); }
  .nav a[aria-current="page"] { color: var(--ink); }
  .nav a[aria-current="page"]::after { transform: scaleX(1); }

  .topbar__end { display: flex; gap: 6px; align-items: center; }
  .iconbtn {
    width: 34px; height: 34px; display: grid; place-items: center; position: relative;
    border: 1px solid var(--line); border-radius: var(--r); color: var(--ink-2);
    transition: border-color .2s, color .2s, background-color .2s;
  }
  .iconbtn:hover { border-color: var(--ink); color: var(--ink); background: var(--paper-2); }
  .iconbtn b {
    position: absolute; top: -6px; right: -6px; min-width: 17px; height: 17px; padding: 0 4px;
    display: grid; place-items: center; border-radius: 9px; background: var(--accent-deep);
    color: var(--accent-ink); font: 600 10px/1 var(--mono);
  }
  .iconbtn b[data-empty="1"] { display: none; }

  .foot { border-top: 1px solid var(--line); margin-top: clamp(60px, 9vw, 130px); }
  .foot__grid {
    max-width: var(--maxw); margin-inline: auto; padding: clamp(38px, 5vw, 66px) var(--gut);
    display: grid; gap: clamp(24px, 3vw, 50px);
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  }
  .foot__col--wide { grid-column: span 1; }
  .foot__title { font-size: var(--step-2); font-weight: 600; letter-spacing: -.02em; margin-bottom: 8px; }
  .foot__note { color: var(--muted); font-size: var(--step--1); max-width: 42ch; }
  .foot__label {
    font-family: var(--mono); font-size: var(--step--1); letter-spacing: .1em;
    text-transform: uppercase; color: var(--muted); margin-bottom: 8px;
  }
  .foot__col p { font-size: var(--step--1); color: var(--muted); }
  .foot__col a { color: var(--link); text-decoration: underline; text-underline-offset: 3px; }
  .foot__bar {
    max-width: var(--maxw); margin-inline: auto; padding: 14px var(--gut) 22px;
    display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap;
    border-top: 1px solid var(--line-2);
    font-family: var(--mono); font-size: 11.5px; letter-spacing: .04em; color: var(--muted);
  }

  section { padding-block: clamp(46px, 7vw, 104px); }
  .sec-head { display: flex; align-items: baseline; gap: 18px; margin-bottom: clamp(22px, 3vw, 40px); }
  .sec-head h2 { font-size: var(--step-3); }
  .sec-head .u-label { flex: none; }
  .sec-head::after { content: ""; flex: 1; height: 1px; background: var(--line); align-self: center; }
}

/* ── components ────────────────────────────────────────────────────── */
@layer components {

  /* hero */
  .hero { padding-block: clamp(40px, 7vw, 92px) clamp(30px, 4vw, 56px); }
  .hero__meta {
    display: flex; flex-wrap: wrap; gap: 6px clamp(16px, 3vw, 40px);
    padding-bottom: 14px; border-bottom: 1px solid var(--line);
    font-family: var(--mono); font-size: 11.5px; letter-spacing: .07em;
    text-transform: uppercase; color: var(--muted);
  }
  .hero__meta b { color: var(--ink); font-weight: 500; }
  .hero h1 {
    font-size: var(--step-5); line-height: .92; letter-spacing: -.045em;
    margin: clamp(22px, 3.4vw, 44px) 0 0; max-width: 15ch;
  }
  .hero h1 em { font-style: normal; color: var(--accent); }

  @media (min-width: 1000px) {
    .hero__body {
      display: grid; grid-template-columns: minmax(0, 1.32fr) minmax(0, 1fr);
      gap: clamp(30px, 4vw, 76px); align-items: end;
      padding-top: clamp(22px, 3.4vw, 44px);
    }
    .hero__main h1 { margin-top: 0; }
    .hero__rail {
      border-top: 1px solid var(--line); padding-top: 14px; padding-bottom: 4px;
      display: grid; gap: 0; align-content: end;
    }
  }
  .railrow {
    display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto;
    gap: 14px; align-items: baseline; padding: 13px 2px;
    border-bottom: 1px solid var(--line-2);
    transition: background-color .2s var(--ease), padding-inline .22s var(--ease);
  }
  .railrow:hover { background: var(--paper-2); padding-inline: 10px; }
  .railrow__i { font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
  .railrow__b { display: grid; gap: 2px; min-width: 0; }
  .railrow__t { font-size: var(--step-1); font-weight: 500; letter-spacing: -.01em; }
  .railrow__d { font-size: var(--step--1); color: var(--muted); }
  .railrow__n { font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
  .railrow__a { color: var(--muted); transition: transform .25s var(--ease), color .2s; }
  .railrow:hover .railrow__a { transform: translateX(4px); color: var(--accent); }
  .hero__lede {
    margin-top: clamp(18px, 2.4vw, 30px); max-width: 54ch;
    font-size: var(--step-1); color: var(--ink-2); line-height: 1.55;
  }
  .hero__cta { display: flex; flex-wrap: wrap; gap: 10px; margin-top: clamp(22px, 3vw, 36px); }

  .btn {
    display: inline-flex; align-items: center; gap: 9px; padding: 12px 20px;
    border: 1px solid var(--ink); border-radius: var(--r); font-size: var(--step--1);
    font-weight: 500; letter-spacing: .01em; position: relative; overflow: hidden;
    transition: color .3s var(--ease), border-color .3s var(--ease);
  }
  .btn::before {
    content: ""; position: absolute; inset: 0; background: var(--ink);
    transform: scaleY(0); transform-origin: 50% 100%; transition: transform .34s var(--ease-out);
    z-index: -1;
  }
  .btn > * { position: relative; }
  .btn:hover { color: var(--paper); }
  .btn:hover::before { transform: scaleY(1); }
  .btn--primary { background: var(--accent-deep); border-color: var(--accent-deep); color: var(--accent-ink); }
  .btn--primary::before { background: var(--ink); }
  .btn--primary:hover { color: var(--paper); border-color: var(--ink); }
  .btn--ghost { border-color: var(--line); }
  .btn--ghost:hover { border-color: var(--ink); }
  .btn kbd {
    font: 500 11px/1 var(--mono); padding: 3px 5px; border: 1px solid currentColor;
    opacity: .6; border-radius: 2px;
  }

  /* resources strip */
  .res {
    display: grid; gap: 0; background: transparent;
    border-top: 1px solid var(--line); border-left: 1px solid var(--line);
  }
  .res__cell {
    background: var(--paper); padding: clamp(16px, 2vw, 26px);
    border-right: 1px solid var(--line); border-bottom: 1px solid var(--line);
    display: grid; gap: 8px; align-content: start; text-align: left;
    transition: background-color .25s var(--ease);
  }
  .res__cell:hover, .res__cell[aria-pressed="true"] { background: var(--paper-2); }
  .res__k { font-size: var(--step-1); font-weight: 600; display: flex; align-items: baseline; gap: 8px; }
  .res__k i {
    width: 8px; height: 8px; background: var(--accent); display: inline-block; flex: none;
    transform: translateY(-1px);
  }
  .res__d { color: var(--muted); font-size: var(--step--1); line-height: 1.6; }
  .res__n { font-family: var(--mono); font-size: 11.5px; color: var(--muted); letter-spacing: .06em; }
  .res--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

  /* stat band */
  .stats {
    display: grid; gap: 0; background: transparent;
    border: 1px solid var(--line); grid-template-columns: repeat(7, minmax(0, 1fr));
  }
  .stats__c {
    background: var(--paper); padding: clamp(16px, 2vw, 26px) clamp(12px, 1.4vw, 18px);
    border-right: 1px solid var(--line);
  }
  .stats__c:last-child { border-right: 0; }
  .stats__v { font-family: var(--mono); font-size: var(--step-2); line-height: 1; letter-spacing: -.03em; }
  .stats__k { margin-top: 10px; color: var(--muted); font-size: var(--step--1); line-height: 1.4; }

  /* generic list of links */
  .qlist { border-top: 1px solid var(--line); }
  .qlist a {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; align-items: baseline;
    padding: 14px 4px; border-bottom: 1px solid var(--line-2);
    transition: background-color .2s var(--ease), padding-inline .25s var(--ease);
  }
  .qlist a:hover { background: var(--paper-2); padding-inline: 12px; }
  .qlist a:hover .qlist__go { color: var(--accent-deep); transform: translateX(3px); }
  .qlist__q { font-size: var(--step-1); letter-spacing: -.01em; max-width: 46ch; }
  @media (min-width: 1100px) {
    .qlist {
      display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: clamp(28px, 4vw, 64px);
    }
    .qlist a:nth-last-child(2):nth-child(odd) { border-bottom: 1px solid var(--line-2); }
  }
  .qlist__go {
    font-family: var(--mono); font-size: var(--step--1); color: var(--muted);
    display: flex; align-items: center; gap: 10px; white-space: nowrap;
    transition: color .2s, transform .25s var(--ease);
  }

  /* chapter index */
  .chgrid {
    display: grid; gap: 0; background: transparent;
    border-top: 1px solid var(--line); border-left: 1px solid var(--line);
    grid-template-columns: repeat(auto-fill, minmax(248px, 1fr));
  }
  .chcard {
    background: var(--paper); padding: clamp(14px, 1.6vw, 22px); text-align: left;
    display: grid; gap: 10px; align-content: start; position: relative;
    border-right: 1px solid var(--line); border-bottom: 1px solid var(--line);
    transition: background-color .25s var(--ease);
  }
  .chcard::after {
    content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 2px;
    background: var(--accent); transform: scaleY(0); transform-origin: 50% 0;
    transition: transform .35s var(--ease-out);
  }
  .chcard:hover { background: var(--paper-2); }
  .chcard:hover::after { transform: scaleY(1); }
  .chcard__top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
  .chcard__no { font-family: var(--mono); font-size: var(--step-1); letter-spacing: .04em; }
  .chcard__n { font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
  .chcard__t { font-weight: 600; letter-spacing: -.015em; line-height: 1.2; }
  .chcard__b {
    font-size: var(--step--1); color: var(--muted); line-height: 1.55;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  }
  .chcard__bar { display: flex; height: 3px; gap: 1px; margin-top: 2px; }
  .chcard__bar i { display: block; height: 100%; background: var(--line); }
  .chcard__bar i[data-e="A"] { background: var(--ink); }
  .chcard__bar i[data-e="B"] { background: var(--muted); }
  .chcard__bar i[data-e="C"] { background: var(--paper-3); border: 1px solid var(--line); }
}

/* ── motion ────────────────────────────────────────────────────────── */
@layer motion {
  @keyframes riseIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
  @keyframes drawIn { from { transform: scaleX(0); } to { transform: scaleX(1); } }
  @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
  @keyframes sheetIn { from { transform: translateY(18px); opacity: 0; } to { transform: none; opacity: 1; } }

  /* Progressive enhancement: visible by default, only hidden once JS is live. */
  html.js .reveal { opacity: 0; }
  html.js .reveal.in { animation: riseIn .62s var(--ease-out) both; }
  .reveal.in { animation: riseIn .62s var(--ease-out) both; }

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

/* ── components: part 2 ─────────────────────────────────────────────── */
@layer components {

  /* boot */
  .boot { min-height: 52svh; display: grid; align-content: center; gap: 18px; justify-items: start; }
  .boot__bar { width: min(340px, 70vw); height: 2px; background: var(--line); overflow: hidden; }
  .boot__bar i { display: block; width: 40%; height: 100%; background: var(--accent); animation: slide 1.15s var(--ease) infinite; }
  @keyframes slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(350%); } }
  .boot--err { gap: 12px; }
  .boot--err pre {
    font-family: var(--mono); font-size: var(--step--1); background: var(--paper-2);
    border: 1px solid var(--line); padding: 12px 16px; overflow-x: auto;
  }
  .boot--err p { color: var(--muted); max-width: 60ch; }

  /* page head (chapter / long / method) */
  .pagehead { padding-block: clamp(24px, 4vw, 52px) clamp(20px, 3vw, 36px); position: relative; }
  .pagehead h1 { font-size: var(--step-4); margin-block: 6px 0; }
  .pagehead > p { max-width: 62ch; color: var(--ink-2); margin-top: 14px; line-height: 1.6; }
  .pagehead__no {
    font-size: var(--step-4); line-height: .8; color: var(--accent); letter-spacing: -.04em;
  }
  .pagehead__meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 18px; }
  .pagehead__intro { max-width: 68ch; color: var(--muted); font-size: var(--step--1); line-height: 1.7; margin-top: 16px; }
  .pagehead__tools { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin-top: 26px; padding-top: 20px; border-top: 1px solid var(--line); }

  /* split page head (chapter reader) */
  @media (min-width: 1000px) {
    .pagehead--split {
      display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr);
      gap: clamp(28px, 4vw, 72px); align-items: start;
    }
    .pagehead--split .pagehead__full { grid-column: 1 / -1; }
    .pagehead--split .pagehead__meta { margin-top: 20px; }
    .pagehead--split .pagehead__tools { margin-top: 20px; }
  }

  .crumbs {
    display: flex; gap: 8px; align-items: center; padding-top: clamp(18px, 3vw, 34px);
    font-family: var(--mono); font-size: 11.5px; letter-spacing: .05em; color: var(--muted);
    text-transform: uppercase;
  }
  .crumbs a:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
  .crumbs i { opacity: .5; font-style: normal; }

  .pager { display: flex; gap: 18px; margin-inline-start: auto; }
  .pager a { color: var(--muted); font-size: var(--step--1); max-width: 22ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .pager a:hover { color: var(--accent); }

  /* chips / tags / badges */
  .chip {
    display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px;
    font-family: var(--mono); font-size: 11px; letter-spacing: .03em;
    border: 1px solid var(--line); border-radius: 100px; color: var(--muted); white-space: nowrap;
  }
  .chip--free { border-color: color-mix(in srgb, var(--accent) 45%, transparent); color: var(--accent-deep); }
  .chip--cj { background: var(--paper-2); }
  .chip--est { border-style: dashed; }
  .chip--a { border-color: var(--ink); color: var(--ink); }
  .chip--b { color: var(--ink-2); }
  .chip--c { opacity: .8; }
  .tag {
    font-family: var(--mono); font-size: 10px; letter-spacing: .06em; text-transform: uppercase;
    padding: 3px 6px; border-radius: 2px;
  }
  .tag--warn { background: var(--accent-deep); color: var(--accent-ink); }
  .tag--mute { border: 1px solid var(--line); color: var(--muted); }

  .badge {
    display: inline-grid; place-items: center; width: 22px; height: 22px;
    font: 600 12px/1 var(--mono); border: 1px solid var(--ink); color: var(--ink);
    background: transparent;
  }
  .badge[data-ev="A"] { background: var(--ink); color: var(--paper); }
  .badge[data-ev="B"] { border-color: var(--muted); color: var(--muted); }
  .badge[data-ev="C"] { border-style: dotted; color: var(--muted); }
  .badge--big { width: 40px; height: 40px; font-size: 20px; margin-bottom: 12px; }

  /* term (glossary inline) */
  .term {
    border-bottom: 1px dashed color-mix(in srgb, var(--accent) 60%, transparent);
    color: inherit; padding: 0 1px; cursor: help; font: inherit;
    transition: background-color .15s, color .15s;
  }
  .term:hover { background: color-mix(in srgb, var(--accent) 12%, transparent); }

  mark.hl { background: color-mix(in srgb, var(--mark) 78%, transparent); color: inherit; padding: 0 1px; border-radius: 1px; }

  /* card */
  .cards { display: grid; gap: 0; }
  .cards--2, .cards--grid {
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    border-top: 1px solid var(--line); border-left: 1px solid var(--line);
  }
  .cards--2 .card, .cards--grid .card {
    border-right: 1px solid var(--line); border-bottom: 0;
  }
  @media (min-width: 1180px) {
    .cards--grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .cards--grid .card:nth-last-child(2):nth-child(odd) { border-right: 1px solid var(--line); }
  }
  .card {
    position: relative; padding: clamp(16px, 2vw, 24px) clamp(14px, 1.6vw, 22px);
    border-bottom: 1px solid var(--line-2); transition: background-color .25s var(--ease);
    scroll-margin-top: 96px;
  }
  .card::before {
    content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 2px;
    background: var(--accent); transform: scaleY(0); transform-origin: 50% 0;
    transition: transform .4s var(--ease-out);
  }
  .card:hover { background: var(--paper-2); }
  .card:hover::before, .card.is-target::before { transform: scaleY(1); }
  .card.is-marked { background: color-mix(in srgb, var(--accent) 4%, transparent); }
  .card.is-active { background: var(--paper-2); }
  .card.is-active::before { transform: scaleY(1); }
  .card:focus-within { background: var(--paper-2); }
  .card.flash { animation: flash 1.5s var(--ease); }
  @keyframes flash { 0%, 100% { background: transparent; } 20% { background: color-mix(in srgb, var(--accent) 14%, transparent); } }
  .card__head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
  .card__where {
    font-size: 11.5px; letter-spacing: .02em; color: var(--muted);
    display: flex; gap: 6px; align-items: baseline; min-width: 0;
  }
  .card__where i { opacity: .45; font-style: normal; }
  .card__chn { font-weight: 500; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .card__non { font-family: var(--mono); white-space: nowrap; }
  .card__tags { display: flex; gap: 6px; align-items: center; }
  .card__title { font-size: var(--step-1); margin-top: 8px; letter-spacing: -.01em; }
  .card__plain { margin-top: 8px; color: var(--ink-2); line-height: 1.62; max-width: 68ch; }
  .card__foot { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-top: 14px; }
  .card__chips { display: flex; flex-wrap: wrap; gap: 6px; }
  .card__actions { display: flex; gap: 6px; align-items: center; margin-inline-start: auto; }
  .btn-ghost {
    display: inline-flex; align-items: center; gap: 7px; padding: 6px 10px;
    font-size: var(--step--1); color: var(--muted); border: 1px solid var(--line);
    border-radius: var(--r); transition: color .2s, border-color .2s, background-color .2s;
  }
  .btn-ghost:hover { color: var(--ink); border-color: var(--ink); background: var(--paper); }
  .btn-ghost__i { font-family: var(--mono); }
  .iconbtn--mark { width: 32px; height: 32px; border-color: transparent; }
  .iconbtn--mark:hover { border-color: var(--line); }
  .iconbtn--mark[aria-pressed="true"] { color: var(--accent); }
  .iconbtn--mark .markicon { display: grid; place-items: center; }

  /* Touch devices get larger hit areas without changing the visual weight. */
  @media (pointer: coarse) {
    .iconbtn, .iconbtn--mark { width: 40px; height: 40px; }
    .btn-ghost { padding: 10px 13px; }
    .rail__reset, .rail__toggle { padding: 8px 12px; }
    .select, .ghostbtn { padding: 10px 12px; }
    .facet__i { padding-block: 10px; }
    .facet__box { width: 16px; height: 16px; }
    .nav a { padding: 8px 0; }
    .ref, .fchip, .chip { padding-block: 6px; }
    .qlist a { padding-block: 16px; }
    .loadmore { padding-block: 26px; }
  }

  .card__detail { margin-top: 16px; border-top: 1px solid var(--line-2); padding-top: 6px; }
  .muted-note { color: var(--muted); font-size: var(--step--1); padding: 10px 0; }
  .drow { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line-3); }
  .drow:last-child { border-bottom: 0; }
  .drow__k { padding-top: 2px; }
  .drow__v { color: var(--ink-2); line-height: 1.66; font-size: var(--step--1); min-width: 0; overflow-wrap: anywhere; }
  .drow__v a { color: var(--link); text-decoration: underline; text-underline-offset: 2px; overflow-wrap: anywhere; }
  .srcs li { margin-bottom: 6px; }
  .refs { display: flex; flex-wrap: wrap; gap: 6px; }
  .ref {
    display: inline-flex; align-items: center; gap: 6px; padding: 5px 9px; font-size: 11.5px;
    border: 1px dashed color-mix(in srgb, var(--link) 45%, transparent); color: var(--link);
    border-radius: 100px; transition: background-color .2s;
  }
  .ref:hover { background: color-mix(in srgb, var(--link) 10%, transparent); }
  .ref i { font-style: normal; }
  .ref__t { color: var(--ink-2); max-width: 22ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  /* explore: search */
  .explore { padding-block: clamp(20px, 3vw, 40px) clamp(50px, 8vw, 100px); }
  .explore__top { display: grid; gap: 12px; margin-bottom: clamp(18px, 2.4vw, 28px); }
  .search { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px; }
  .search__box {
    position: relative; display: flex; align-items: center; gap: 12px; flex: 1 1 380px;
    border-bottom: 2px solid var(--ink); padding-bottom: 6px; transition: border-color .2s;
  }
  .search__box:focus-within { border-color: var(--accent); }
  .search__i { color: var(--muted); display: grid; place-items: center; flex: none; }
  .search__input {
    flex: 1; min-width: 0; border: 0; background: none; padding: 6px 0;
    font-size: var(--step-2); letter-spacing: -.015em; font-weight: 500;
  }
  .search__input::placeholder { color: var(--muted); font-weight: 400; letter-spacing: -.01em; }
  .search__input::-webkit-search-cancel-button { display: none; }
  .search__clear { font-size: 22px; color: var(--muted); line-height: 1; padding: 0 6px; }
  .search__clear:hover { color: var(--accent); }
  .search__hint { font-family: var(--mono); font-size: 11px; color: var(--muted); letter-spacing: .03em; }
  .search__hint kbd, .search__hint code, .btn kbd {
    border: 1px solid var(--line); border-radius: 3px; padding: 1px 5px; font-family: var(--mono);
  }

  .fchips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
  .fchip {
    display: inline-flex; align-items: center; gap: 7px; padding: 5px 11px;
    border: 1px solid var(--ink); border-radius: 100px; font-size: 12px; background: var(--paper);
    animation: pop .28s var(--ease-out) both;
  }
  @keyframes pop { from { opacity: 0; transform: scale(.9); } to { opacity: 1; transform: none; } }
  .fchip i { font-style: normal; opacity: .55; font-size: 14px; line-height: 1; }
  .fchip:hover { background: var(--ink); color: var(--paper); }
  .fchip--mark { border-color: var(--accent); color: var(--accent); }
  .fchip--reset { border-color: transparent; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }
  .fchip--reset:hover { background: none; color: var(--accent); }

  .explore__body { display: grid; grid-template-columns: 224px minmax(0, 1fr); gap: clamp(20px, 3vw, 48px); align-items: start; }

  /* rail */
  .rail {
    position: sticky; top: 84px; max-height: calc(100svh - 108px); overflow-y: auto;
    padding-right: 6px; scrollbar-width: thin; display: grid; gap: 22px; align-content: start;
  }
  .rail__head { display: flex; justify-content: space-between; align-items: baseline; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
  .rail__reset { font-size: var(--step--1); color: var(--muted); }
  .rail__reset:hover { color: var(--accent); }
  .rail__toggle { display: none; font-size: var(--step--1); color: var(--ink); border: 1px solid var(--line); padding: 3px 10px; border-radius: 100px; }
  .rail__note { font-size: 11px; color: var(--muted); line-height: 1.6; border-top: 1px solid var(--line-2); padding-top: 12px; }
  .rail__note a { color: var(--link); text-decoration: underline; text-underline-offset: 3px; }

  .facet { border: 0; padding: 0; }
  .facet__t { padding: 0 0 8px; }
  .facet__list { display: grid; gap: 1px; }
  .facet__i {
    position: relative; display: grid; grid-template-columns: 16px minmax(0, 1fr) auto;
    gap: 9px; align-items: center; padding: 5px 6px; cursor: pointer; border-radius: var(--r);
    transition: background-color .16s;
  }
  .facet__i:hover { background: var(--paper-2); }
  .facet__i[data-zero="1"] { opacity: .4; }
  .facet__i input { position: absolute; opacity: 0; width: 0; }
  .facet__box {
    width: 13px; height: 13px; border: 1.5px solid var(--line); border-radius: 2px;
    display: grid; place-items: center; transition: background-color .15s, border-color .15s;
  }
  .facet__i[data-on="1"] .facet__box { background: var(--accent); border-color: var(--accent); }
  .facet__i[data-on="1"] .facet__box::after {
    content: ""; width: 6px; height: 6px; background: var(--accent-ink);
    clip-path: polygon(14% 44%, 0 60%, 40% 100%, 100% 22%, 84% 8%, 38% 68%);
  }
  .facet__i input:focus-visible + .facet__box { outline: 2px solid var(--accent); outline-offset: 2px; }
  .facet__l { font-size: var(--step--1); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .facet__i[data-on="1"] .facet__l { font-weight: 600; }
  .facet__n { font-size: 11px; color: var(--muted); }

  /* results */
  .res { min-width: 0; }
  .res__head {
    display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap;
    border-bottom: 1px solid var(--line); padding-bottom: 12px; margin-bottom: 4px;
  }
  .res__count { font-size: var(--step--1); color: var(--muted); }
  .res__count b { font-size: var(--step-2); color: var(--ink); margin-right: 2px; }
  .res__of { color: var(--muted); opacity: .7; }
  .res__tools { display: flex; gap: 8px; align-items: center; }
  .select {
    font-size: var(--step--1); padding: 6px 10px; border: 1px solid var(--line); border-radius: var(--r);
    background: var(--paper); cursor: pointer;
  }
  .ghostbtn {
    font-size: var(--step--1); padding: 6px 11px; border: 1px solid var(--line); border-radius: var(--r);
    color: var(--muted);
  }
  .ghostbtn:hover { color: var(--ink); border-color: var(--ink); }
  .ghostbtn[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }

  .loadmore {
    display: block; width: 100%; padding: 20px; margin-top: 4px; border-top: 1px solid var(--line);
    color: var(--muted); font-size: var(--step--1); letter-spacing: .04em;
  }
  .loadmore:hover { color: var(--accent); background: var(--paper-2); }

  .empty { padding: clamp(30px, 6vw, 70px) 0; max-width: 58ch; }
  .empty__t { font-size: var(--step-2); letter-spacing: -.02em; }
  .empty__d { color: var(--muted); margin-top: 12px; line-height: 1.7; }
  .empty__d code { font-family: var(--mono); font-size: .92em; border: 1px solid var(--line); padding: 1px 5px; border-radius: 3px; }
  .empty .btn { margin-top: 20px; }

  /* long-form reader */
  .long { padding-bottom: 40px; }
  .long__grid { display: grid; grid-template-columns: 208px minmax(0, 1fr); gap: clamp(24px, 4vw, 64px); align-items: start; }
  .toc { position: sticky; top: 84px; display: grid; gap: 10px; max-height: calc(100svh - 120px); overflow-y: auto; }
  .toc a {
    font-size: var(--step--1); color: var(--muted); padding: 5px 0 5px 12px;
    border-left: 2px solid var(--line-2); transition: color .2s, border-color .2s, padding-left .2s;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  }
  .toc a:hover { color: var(--ink); border-color: var(--accent); padding-left: 16px; }
  .toc__sel { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line-2); display: grid; gap: 8px; }
  .toc__sel .select { width: 100%; min-width: 0; }

  .prose { min-width: 0; max-width: 74ch; }
  .prose h1 { font-size: var(--step-3); line-height: 1.12; margin-bottom: 20px; letter-spacing: -.025em; }
  .prose .lead { font-size: var(--step-1); color: var(--ink-2); line-height: 1.62; margin-bottom: 26px; }
  .prose h2 {
    font-size: var(--step-2); margin-top: clamp(34px, 4vw, 56px); margin-bottom: 14px;
    padding-top: 18px; border-top: 1px solid var(--line); scroll-margin-top: 96px;
  }
  .prose h3 { font-size: var(--step-1); margin-top: 26px; margin-bottom: 10px; }
  .prose p { margin-bottom: 16px; line-height: 1.78; color: var(--ink-2); overflow-wrap: anywhere; }
  .prose p.li { padding-left: 20px; position: relative; }
  .prose p.li::before { content: ""; position: absolute; left: 0; top: .72em; width: 6px; height: 1.5px; background: var(--accent); }

  /* data tables */
  .tablewrap {
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    border: 1px solid var(--line); margin-block: 22px 26px; background: var(--paper);
    max-width: 100%;
  }
  .dtable { font-size: var(--step--1); width: max-content; min-width: 100%; }
  .dcaption { caption-side: top; text-align: left; font-family: var(--mono); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); padding: 12px 14px 0; }
  .dtable th, .dtable td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line-2); vertical-align: top; line-height: 1.6; }
  .dtable thead th { font-family: var(--mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 500; background: var(--paper-2); border-bottom: 1px solid var(--line); white-space: nowrap; }
  .dtable tbody tr:last-child td { border-bottom: 0; }
  .dtable tbody tr:hover { background: var(--paper-2); }
  .dtable .rowh { font-weight: 600; white-space: nowrap; }
  .dtable thead .rowh { font-weight: 500; }

  /* method */
  .method section { border-top: 1px solid var(--line); }
  .tiers { counter-reset: t; display: grid; gap: 12px; }
  .tiers li { display: grid; grid-template-columns: minmax(0, 220px) minmax(0, 1fr); gap: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--line-2); }
  .tiers b { font-size: var(--step-1); }
  .tiers span { color: var(--muted); line-height: 1.66; }
  .evgrid { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
  .evcard p { color: var(--ink-2); line-height: 1.68; }
  .note { color: var(--muted); font-size: var(--step--1); line-height: 1.7; max-width: 74ch; margin-top: 14px; }
  .note--warn { border-left: 2px solid var(--accent); padding-left: 14px; }
  .bullets { display: grid; gap: 12px; max-width: 74ch; }
  .bullets li { position: relative; padding-left: 22px; color: var(--ink-2); line-height: 1.7; }
  .bullets li::before { content: ""; position: absolute; left: 0; top: .78em; width: 8px; height: 1.5px; background: var(--accent); }
  .caveat { color: var(--muted); font-size: var(--step--1); line-height: 1.7; max-width: 74ch; margin-top: 20px; }

  .glossary { display: grid; gap: 1px; background: var(--line); border: 1px solid var(--line); grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
  .gl { background: var(--paper); padding: 16px 18px; }
  .gl dt { font-family: var(--mono); font-weight: 600; font-size: var(--step--1); margin-bottom: 6px; }
  .gl dd { color: var(--muted); font-size: var(--step--1); line-height: 1.62; margin: 0; }

  .chcard__cj { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; }
  .chgrid--long { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }

  /* sheet */
  .sheet { position: fixed; inset: 0; z-index: 120; }
  .sheet__scrim { position: absolute; inset: 0; background: color-mix(in srgb, var(--ink) 34%, transparent); opacity: 0; transition: opacity .28s var(--ease); }
  .sheet.on .sheet__scrim { opacity: 1; }
  .sheet__panel {
    position: absolute; left: 0; right: 0; bottom: 0; max-height: 82svh; overflow-y: auto;
    background: var(--paper); border-top: 1px solid var(--line);
    padding: clamp(20px, 4vw, 40px) var(--gut) clamp(26px, 5vw, 44px);
    transform: translateY(100%); transition: transform .4s var(--ease-out);
  }
  .sheet.on .sheet__panel { transform: none; }
  .sheet__panel::before {
    content: ""; display: block; width: 42px; height: 3px; background: var(--line);
    margin: 0 auto 18px;
  }
  .sheet__x { position: absolute; top: 16px; right: var(--gut); color: var(--muted); }
  .sheet__x:hover { color: var(--accent); }
  .sheet__body { max-width: 74ch; margin-inline: auto; }
  .sheethead__t { font-size: var(--step-2); margin-block: 8px 12px; letter-spacing: -.02em; }
  .sheetfoot { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }

  /* toast */
  .toast {
    position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px);
    background: var(--ink); color: var(--paper); padding: 11px 20px; border-radius: 100px;
    font-size: var(--step--1); opacity: 0; pointer-events: none; z-index: 200;
    transition: opacity .25s, transform .25s var(--ease-out); max-width: 90vw; text-align: center;
  }
  .toast.on { opacity: 1; transform: translate(-50%, 0); }

  /* tooltip */
  .tip {
    position: fixed; top: 0; left: 0; z-index: 210; max-width: min(300px, 88vw);
    background: var(--ink); color: var(--paper); padding: 10px 13px; border-radius: var(--r);
    font-size: 12.5px; line-height: 1.6; pointer-events: none; box-shadow: 0 8px 28px rgba(0, 0, 0, .2);
  }
  .tip b { display: block; font-family: var(--mono); font-size: 11px; letter-spacing: .06em; opacity: .7; margin-bottom: 3px; }

  /* responsive */
  @media (max-width: 1240px) {
    .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  }
  @media (max-width: 900px) {
    .res--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  }
  @media (max-width: 1080px) {
    .explore__body { grid-template-columns: 1fr; }
    .rail { position: static; max-height: none; display: block; }
    .rail__head { border-bottom: 1px solid var(--line); padding-bottom: 10px; }
    .rail__body {
      display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
      gap: 18px 24px; margin-top: 16px;
    }
    .rail[data-open="0"] .rail__body { display: none; }
    .rail__toggle { display: inline-block; }
    .rail[data-open="1"] { padding-bottom: 4px; }
    .rail__note { grid-column: 1 / -1; }
    .long__grid { grid-template-columns: minmax(0, 1fr); }
    .toc { position: static; max-height: none; grid-auto-flow: column; grid-auto-columns: minmax(150px, 1fr); overflow-x: auto; padding-bottom: 8px; }
    .toc__t, .toc__sel { display: none; }
  }
  @media (max-width: 760px) {
    .topbar__in { height: 54px; gap: 12px; }
    .nav { overflow-x: auto; scrollbar-width: none; }
    .nav::-webkit-scrollbar { display: none; }
    .brand__txt { display: none; }
    .cards--2, .cards--grid { grid-template-columns: 1fr; }
    .drow { grid-template-columns: 1fr; gap: 4px; }
    .drow__k { padding-top: 0; }
    .tiers li { grid-template-columns: 1fr; gap: 4px; }
    .search__input { font-size: var(--step-1); }
    .hero h1 { max-width: none; }
    .card__foot { gap: 10px; }
    .pagehead__tools { flex-direction: column; align-items: stretch; }
    .pager { margin-inline-start: 0; }
    .rail__reset, .rail__toggle, .select, .ghostbtn { padding: 9px 13px; }
    .facet__i { padding-block: 9px; }
    .qlist a { padding-block: 14px; }
  }
  @media (max-width: 480px) {
    .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .res--4 { grid-template-columns: 1fr; }
    .res__tools { width: 100%; justify-content: space-between; }
  }
  @media print {
    .topbar, .rail, .foot, .hero__cta, .card__actions, .search, .toc, .sheet, .toast, .progress { display: none !important; }
    body { background: #fff; }
    .card { break-inside: avoid; }
  }
}