/* =========================================================
 * styles.css — Excel 函数大全 / 函数志
 * 视觉：暖纸底色 + 深墨绿侧栏 + 宋体标题的「技术手册」气质
 * ========================================================= */

/* ---------- 1. Tokens ---------- */
:root {
  --paper: #f4f1e9;
  --paper-2: #ebe6d9;
  --surface: #fffdf8;
  --surface-2: #f7f4ea;
  --ink: #1b211c;
  --ink-2: #4a5148;
  --ink-3: #7c8377;
  --line: #ddd7c6;
  --line-strong: #c9c1ab;

  --brand: #0f5138;
  --brand-2: #176b49;
  --brand-tint: #e6f0e9;
  --clay: #b25a26;
  --clay-tint: #fbeade;

  --rail: #0e2a21;
  --rail-2: #15352a;
  --rail-line: rgba(255, 255, 255, .09);
  --rail-text: #c6d3c9;
  --rail-dim: #7f968a;

  --font-display: "Songti SC", "Noto Serif CJK SC", "Source Han Serif SC", Georgia, serif;
  --font-body: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  --font-mono: "SFMono-Regular", "JetBrains Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;

  --sh-sm: 0 1px 2px rgba(27, 33, 28, .04), 0 10px 24px -18px rgba(27, 33, 28, .35);
  --sh-md: 0 2px 4px rgba(27, 33, 28, .05), 0 24px 48px -30px rgba(27, 33, 28, .45);

  --ease: cubic-bezier(.22, .61, .36, 1);
  --rail-w: 256px;
}

/* ---------- 2. Reset ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.6;
  background-color: var(--paper);
  background-image:
    radial-gradient(1100px 560px at 8% -8%, rgba(15, 81, 56, .09), transparent 62%),
    radial-gradient(900px 500px at 96% 4%, rgba(178, 90, 38, .06), transparent 60%),
    linear-gradient(to right, rgba(27, 33, 28, .038) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(27, 33, 28, .038) 1px, transparent 1px);
  background-size: auto, auto, 34px 34px, 34px 34px;
  background-attachment: fixed;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
p, h1, h2, h3, ul, ol, dl, dd { margin: 0; }
ul, ol { padding: 0; list-style: none; }
code, pre { font-family: var(--font-mono); }
::selection { background: rgba(23, 107, 73, .18); }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon {
  width: 16px; height: 16px;
  fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
  flex: none;
}

/* ---------- 3. Shell ---------- */
.shell {
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr);
  min-height: 100vh;
}

/* ---------- 4. Rail ---------- */
.rail {
  position: sticky;
  top: 0;
  z-index: 30;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 22px 16px 18px;
  color: var(--rail-text);
  background: var(--rail);
  background-image:
    radial-gradient(420px 240px at 0% 0%, rgba(127, 196, 160, .14), transparent 70%),
    linear-gradient(180deg, rgba(255, 255, 255, .03), transparent 26%);
  border-right: 1px solid rgba(0, 0, 0, .25);
  overflow-y: auto;
  scrollbar-width: thin;
}
.rail__brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 6px 22px;
  animation: rise .5s var(--ease) both;
}
.brand-mark {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: 10px;
  color: #cfe8d9;
  background: rgba(207, 232, 217, .08);
  border: 1px solid rgba(207, 232, 217, .28);
  box-shadow: inset 0 0 18px rgba(127, 196, 160, .12);
}
.brand-mark .icon { width: 20px; height: 20px; stroke-width: 1.9; }
.brand-text strong {
  display: block;
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: .04em;
  color: #f0f5f0;
  line-height: 1.2;
  white-space: nowrap;
}
.brand-text span {
  display: block;
  margin-top: 3px;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--rail-dim);
}
.rail__label {
  padding: 0 8px 10px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .2em;
  color: var(--rail-dim);
  text-transform: uppercase;
}
.rail__nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border-radius: var(--r-sm);
  color: var(--rail-text);
  font-size: 13.5px;
  text-align: left;
  position: relative;
  transition: background .18s var(--ease), color .18s var(--ease), transform .18s var(--ease);
  animation: rise .5s var(--ease) both;
}
.nav-item:nth-child(1) { animation-delay: .04s; }
.nav-item:nth-child(2) { animation-delay: .07s; }
.nav-item:nth-child(3) { animation-delay: .10s; }
.nav-item:nth-child(4) { animation-delay: .13s; }
.nav-item:nth-child(5) { animation-delay: .16s; }
.nav-item:nth-child(6) { animation-delay: .19s; }
.nav-item:nth-child(7) { animation-delay: .22s; }
.nav-item:nth-child(8) { animation-delay: .25s; }
.nav-item:nth-child(9) { animation-delay: .28s; }
.nav-item:nth-child(10) { animation-delay: .31s; }
.nav-item:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav-item:focus-visible { outline: 2px solid #8fc7a6; outline-offset: 1px; }
.nav-item[aria-current="true"] {
  background: rgba(255, 255, 255, .09);
  color: #fff;
}
.nav-item[aria-current="true"]::before {
  content: "";
  position: absolute;
  left: -16px; top: 8px; bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: #8fc7a6;
}
.nav-item .icon { color: var(--rail-dim); transition: color .18s var(--ease); }
.nav-item:hover .icon,
.nav-item[aria-current="true"] .icon { color: #a9d9bd; }
.nav-item__label { flex: 1; min-width: 0; }
.nav-item__count {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--rail-dim);
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .05);
}
.rail__nav.is-ready .nav-item { animation: none; }
.nav-item[aria-current="true"] .nav-item__count { color: #d8ece0; background: rgba(255, 255, 255, .1); }
.rail__divider { height: 1px; margin: 12px 8px; background: var(--rail-line); }
.rail__foot {
  margin-top: auto;
  padding: 16px 8px 0;
  border-top: 1px solid var(--rail-line);
  font-size: 11px;
  line-height: 1.8;
  color: var(--rail-dim);
}
.rail__foot strong { color: #a9d9bd; font-weight: 500; }
.rail__directory {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 12px;
  padding: 8px 9px;
  border: 1px solid var(--rail-line);
  border-radius: 8px;
  color: #c6d3c9;
  text-decoration: none;
  transition: color .18s var(--ease), background .18s var(--ease);
}
.rail__directory:hover { color: #fff; background: rgba(255, 255, 255, .06); }

/* ---------- 5. Main / Topbar ---------- */
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 16px 28px;
  background: rgba(244, 241, 233, .82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.search {
  position: relative;
  flex: 1;
  max-width: 620px;
  display: flex;
  align-items: center;
}
.search .icon {
  position: absolute;
  left: 14px;
  width: 18px; height: 18px;
  color: var(--ink-3);
  pointer-events: none;
  transition: color .2s var(--ease);
}
.search input {
  width: 100%;
  height: 46px;
  padding: 0 58px 0 44px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  font-size: 14px;
  color: var(--ink);
  outline: none;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .7) inset;
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease), background .2s var(--ease);
}
.search input::placeholder { color: #9a9d91; }
.search input::-webkit-search-cancel-button,
.search input::-webkit-search-decoration { -webkit-appearance: none; appearance: none; }
.search input:hover { border-color: #b8b096; }
.search input:focus {
  border-color: var(--brand-2);
  box-shadow: 0 0 0 3px rgba(23, 107, 73, .14);
  background: #fffefa;
}
.search:focus-within .icon { color: var(--brand); }
.search kbd {
  position: absolute;
  right: 12px;
  padding: 2px 7px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 6px;
}
.search__clear {
  position: absolute;
  right: 42px;
  display: none;
  width: 24px; height: 24px;
  place-items: center;
  border-radius: 50%;
  color: var(--ink-3);
}
.search__clear:hover { background: var(--paper-2); color: var(--ink); }
.search.has-value .search__clear { display: grid; right: 12px; }
.search.has-value kbd { display: none; }

.topbar__stats {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-left: auto;
}
.stat {
  display: flex;
  align-items: baseline;
  gap: 6px;
  white-space: nowrap;
}
.stat strong {
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 600;
  color: var(--brand);
  letter-spacing: .02em;
}
.stat span { font-size: 11px; color: var(--ink-3); letter-spacing: .06em; }

/* ---------- 6. Workspace ---------- */
.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: 22px;
  align-items: start;
  padding: 24px 28px 64px;
  max-width: 1560px;
  margin: 0 auto;
  width: 100%;
}
.list-col { min-width: 0; }

.list-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: 2px 2px 16px;
}
.list-head h1 {
  font-family: var(--font-display);
  font-size: 27px;
  font-weight: 600;
  letter-spacing: .06em;
  line-height: 1.25;
}
.list-head p {
  margin-top: 4px;
  font-size: 12.5px;
  color: var(--ink-3);
}
.list-head p em {
  font-style: normal;
  color: var(--brand);
  font-family: var(--font-mono);
  font-weight: 600;
}
.sort {
  display: flex;
  padding: 3px;
  gap: 2px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
}
.sort button {
  padding: 5px 13px;
  border-radius: 999px;
  font-size: 12px;
  color: var(--ink-3);
  transition: background .18s var(--ease), color .18s var(--ease), box-shadow .18s var(--ease);
}
.sort button:hover { color: var(--ink); }
.sort button[aria-pressed="true"] {
  color: var(--brand);
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(27, 33, 28, .08);
  font-weight: 600;
}

/* ---------- 7. Function list ---------- */
.fn-list { display: flex; flex-direction: column; gap: 8px; }

.fn-row {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  cursor: pointer;
  position: relative;
  text-align: left;
  transition: transform .18s var(--ease), border-color .18s var(--ease), box-shadow .18s var(--ease), background .18s var(--ease);
  animation: rise .42s var(--ease) both;
  animation-delay: calc(var(--i, 0) * 18ms);
}
.fn-row:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
  box-shadow: var(--sh-sm);
  background: #fffefa;
}
.fn-row:focus-visible {
  outline: 2px solid var(--brand-2);
  outline-offset: 2px;
}
.fn-row[aria-current="true"] {
  background: #f5faf6;
  border-color: rgba(23, 107, 73, .45);
  box-shadow: inset 3px 0 0 var(--brand), var(--sh-sm);
}
.fn-row__sigil {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 10px;
  background: var(--paper-2);
  color: var(--brand);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  border: 1px solid rgba(27, 33, 28, .05);
  transition: background .18s var(--ease), color .18s var(--ease);
}
.fn-row[aria-current="true"] .fn-row__sigil { background: var(--brand); color: #eaf4ed; border-color: var(--brand); }
.fn-row__body { min-width: 0; }
.fn-row__line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.fn-row__name {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -.01em;
}
.fn-row__cn { font-size: 12.5px; color: var(--ink-3); }
.fn-row__desc {
  display: block;
  margin-top: 2px;
  font-size: 12.5px;
  color: var(--ink-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fn-row__desc mark,
.fn-row__name mark,
.fn-row__cn mark {
  background: rgba(178, 90, 38, .16);
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
}
.fn-row__side { display: flex; align-items: center; gap: 6px; }
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10.5px;
  line-height: 1.6;
  white-space: nowrap;
}
.badge--hot { color: var(--brand); background: var(--brand-tint); }
.badge--soft { color: var(--ink-3); background: var(--surface-2); border: 1px solid var(--line); }
.badge--clay { color: var(--clay); background: var(--clay-tint); }
.fav-btn, .page-btn {
  display: grid;
  place-items: center;
  width: 28px; height: 28px;
  border-radius: 8px;
  color: #b3b6aa;
  transition: color .18s var(--ease), background .18s var(--ease), transform .18s var(--ease);
}
.fav-btn:hover, .page-btn:hover { color: var(--brand); background: var(--brand-tint); transform: translateY(-1px); }
.page-btn .icon { width: 14px; height: 14px; }
.fav-btn[aria-pressed="true"] { color: var(--brand); }
.fav-btn[aria-pressed="true"] .icon { fill: currentColor; }
.fav-btn .icon { width: 15px; height: 15px; }

/* skeleton */
.sk-row { height: 66px; border-radius: var(--r-md); border: 1px solid var(--line); background: var(--surface); }
.sk {
  position: relative;
  overflow: hidden;
  background: var(--paper-2);
  border-radius: 6px;
}
.sk-row { position: relative; overflow: hidden; }
.sk::after, .sk-row::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .75), transparent);
  transform: translateX(-100%);
  animation: shimmer 1.2s infinite;
}
.sk-line { height: 10px; border-radius: 4px; background: var(--paper-2); }

/* empty */
.empty {
  display: grid;
  place-items: center;
  text-align: center;
  padding: 64px 24px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-lg);
  background: rgba(255, 253, 248, .6);
  animation: fadeIn .3s var(--ease) both;
}
.empty__icon {
  width: 48px; height: 48px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--paper-2);
  color: var(--ink-3);
  margin-bottom: 14px;
}
.empty__icon .icon { width: 22px; height: 22px; }
.empty h3 { font-family: var(--font-display); font-size: 17px; font-weight: 600; letter-spacing: .04em; }
.empty p { margin-top: 6px; font-size: 12.5px; color: var(--ink-3); max-width: 320px; }
.empty button {
  margin-top: 16px;
  padding: 7px 16px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  font-size: 12.5px;
  color: var(--ink-2);
  transition: border-color .18s var(--ease), color .18s var(--ease), transform .18s var(--ease);
}
.empty button:hover { border-color: var(--brand); color: var(--brand); transform: translateY(-1px); }

/* ---------- 8. Detail panel ---------- */
.detail {
  position: sticky;
  top: 86px;
  max-height: calc(100vh - 110px);
  display: block;
  overflow-y: auto;
  padding: 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-sm);
  scrollbar-width: thin;
  animation: rise .45s var(--ease) both;
}
.detail::-webkit-scrollbar { width: 6px; }
.detail::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 3px; }

.detail__close {
  display: none;
  position: absolute;
  top: 12px; right: 12px;
  width: 32px; height: 32px;
  place-items: center;
  border-radius: 50%;
  color: var(--ink-3);
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.detail__close:hover { color: var(--ink); }

.detail__eyebrow {
  display: flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.detail__eyebrow .dot { color: var(--line-strong); }
.detail__name {
  margin-top: 6px;
  font-family: var(--font-mono);
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -.02em;
  line-height: 1.15;
  color: var(--ink);
}
.detail__cn {
  margin-top: 4px;
  font-family: var(--font-display);
  font-size: 15px;
  letter-spacing: .08em;
  color: var(--brand);
}
.detail__desc { margin-top: 10px; font-size: 13px; line-height: 1.75; color: var(--ink-2); }

.detail__bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--line);
}
.detail__bar .badge { flex: none; }
.detail__page {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
  color: var(--brand);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
}
.detail__page:hover { text-decoration: underline; }
.detail__page .icon { width: 14px; height: 14px; }
.meter {
  flex: 1;
  height: 4px;
  border-radius: 999px;
  background: var(--paper-2);
  overflow: hidden;
}
.meter i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--brand-2), #6fae8c);
  animation: grow .8s var(--ease) both;
}
.meter-label { font-size: 10.5px; color: var(--ink-3); white-space: nowrap; }

.sec { margin-top: 22px; }
.sec__title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 9px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.sec__title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.code-block {
  position: relative;
  padding: 13px 46px 13px 14px;
  border-radius: var(--r-md);
  background: #10251d;
  color: #dcebe1;
  font-size: 12px;
  line-height: 1.7;
  overflow-x: auto;
  white-space: pre;
  border: 1px solid rgba(0, 0, 0, .2);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .05);
}
.code-block--light {
  background: var(--surface-2);
  color: var(--ink);
  border: 1px solid var(--line);
  box-shadow: none;
}
.code-block__fn { color: #8fd0a9; }
.code-block--light .code-block__fn { color: var(--brand); }
.copy-btn {
  position: absolute;
  top: 7px; right: 7px;
  display: grid;
  place-items: center;
  width: 28px; height: 28px;
  border-radius: 7px;
  color: rgba(220, 235, 225, .65);
  background: rgba(255, 255, 255, .06);
  transition: color .18s var(--ease), background .18s var(--ease);
}
.copy-btn:hover { color: #fff; background: rgba(255, 255, 255, .14); }
.code-block--light .copy-btn { color: var(--ink-3); background: rgba(27, 33, 28, .05); }
.code-block--light .copy-btn:hover { color: var(--brand); background: var(--brand-tint); }
.copy-btn .icon { width: 14px; height: 14px; }

.params { display: flex; flex-direction: column; }
.param {
  padding: 9px 0;
  border-bottom: 1px dashed var(--line);
}
.param:last-child { border-bottom: 0; }
.param__head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.param__name {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--brand);
}
.param__desc { margin-top: 3px; font-size: 12.5px; line-height: 1.7; color: var(--ink-2); }

.example-result {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  padding: 9px 12px;
  border-radius: var(--r-sm);
  background: var(--brand-tint);
  font-size: 12.5px;
  color: #1d4b38;
  line-height: 1.65;
}
.example-result .icon { width: 14px; height: 14px; margin-top: 3px; color: var(--brand); }
.example-note {
  margin-top: 8px;
  font-size: 12px;
  color: var(--ink-3);
  line-height: 1.7;
  padding-left: 2px;
}

.pitfalls { display: flex; flex-direction: column; gap: 8px; }
.pitfall {
  display: flex;
  gap: 9px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  background: var(--clay-tint);
  border-left: 2px solid var(--clay);
  font-size: 12.5px;
  line-height: 1.7;
  color: #6d3a1d;
}
.pitfall .icon { width: 14px; height: 14px; margin-top: 3px; color: var(--clay); }

.related { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  padding: 4px 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink-2);
  transition: all .18s var(--ease);
}
.chip span {
  font-family: var(--font-body);
  font-size: 10.5px;
  color: var(--ink-3);
}
.chip:hover {
  border-color: var(--brand);
  color: var(--brand);
  background: var(--brand-tint);
  transform: translateY(-1px);
}
.chip:hover span { color: var(--brand-2); }
.chip:focus-visible { outline: 2px solid var(--brand-2); outline-offset: 2px; }

.detail__foot {
  margin-top: 22px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 11px;
  line-height: 1.7;
  color: var(--ink-3);
}

.detail__fav {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  font-size: 12px;
  color: var(--ink-2);
  transition: all .18s var(--ease);
}
.detail__fav:hover { border-color: var(--brand); color: var(--brand); }
.detail__fav[aria-pressed="true"] {
  border-color: var(--brand);
  color: var(--brand);
  background: var(--brand-tint);
}
.detail__fav .icon { width: 14px; height: 14px; }
.detail__fav[aria-pressed="true"] .icon { fill: currentColor; }

/* detail empty / skeleton */
.detail__empty { padding: 28px 4px 10px; text-align: center; }
.detail__empty .stamp {
  width: 62px; height: 62px;
  margin: 0 auto 16px;
  display: grid; place-items: center;
  border-radius: 50%;
  border: 1px dashed var(--line-strong);
  color: var(--line-strong);
}
.detail__empty .stamp .icon { width: 26px; height: 26px; }
.detail__empty h3 {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: .06em;
}
.detail__empty p { margin-top: 8px; font-size: 12.5px; color: var(--ink-3); line-height: 1.8; }
.detail__empty ul {
  margin: 18px 0 0;
  padding: 16px 18px;
  text-align: left;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  font-size: 12px;
  color: var(--ink-2);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.detail__empty li { display: flex; gap: 8px; align-items: baseline; }
.detail__empty li b {
  font-family: var(--font-mono);
  color: var(--brand);
  font-weight: 600;
  font-size: 11px;
}

.sk-detail__title { height: 30px; width: 55%; margin: 10px 0 8px; }
.sk-detail__sub { height: 12px; width: 35%; margin-bottom: 18px; }
.sk-detail__block { height: 58px; margin-bottom: 12px; }
.sk-detail__line { height: 10px; margin-bottom: 8px; }

/* ---------- 9. Overlay / toast ---------- */
.backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(14, 26, 21, .42);
  backdrop-filter: blur(3px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s var(--ease);
}
.backdrop.is-open { opacity: 1; pointer-events: auto; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 30px;
  z-index: 80;
  transform: translate(-50%, 14px);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: 999px;
  background: #10251d;
  color: #e6f1ea;
  font-size: 12.5px;
  box-shadow: 0 12px 30px -12px rgba(0, 0, 0, .5);
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s var(--ease), transform .22s var(--ease);
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }
.toast .icon { width: 14px; height: 14px; color: #8fd0a9; }

/* ---------- 10. Motion ---------- */
@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes shimmer {
  to { transform: translateX(100%); }
}
@keyframes grow {
  from { width: 0; }
}

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

/* ---------- 11. Responsive ---------- */
@media (max-width: 1280px) {
  .workspace { grid-template-columns: minmax(0, 1fr) 390px; gap: 18px; padding: 20px 22px 56px; }
  .topbar { padding: 14px 22px; }
}

@media (max-width: 1080px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .detail {
    position: fixed;
    top: 0;
    right: 0;
    z-index: 60;
    width: min(460px, 100vw);
    height: 100dvh;
    max-height: none;
    border-radius: 0;
    border: 0;
    border-left: 1px solid var(--line);
    box-shadow: -24px 0 60px -30px rgba(0, 0, 0, .45);
    transform: translateX(104%);
    transition: transform .28s var(--ease), visibility .28s;
    visibility: hidden;
    padding: 26px 22px 48px;
    animation: none;
  }
  .detail.is-open { transform: translateX(0); visibility: visible; }
  .detail__close { display: grid; }
  .detail__name { padding-right: 36px; }
  .topbar__stats .stat:last-child { display: none; }
}

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .rail {
    position: relative;
    z-index: 10;
    height: auto;
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 4px 12px;
    padding: 14px 16px;
    overflow: visible;
    border-right: 0;
    border-bottom: 1px solid rgba(0, 0, 0, .3);
  }
  .rail__brand { padding: 0; animation: none; }
  .brand-mark { width: 32px; height: 32px; border-radius: 8px; }
  .brand-text strong { font-size: 16px; }
  .brand-text span { font-size: 8px; }
  .rail__label { display: none; }
  .rail__nav {
    grid-column: 1 / -1;
    flex-direction: row;
    gap: 6px;
    overflow-x: auto;
    padding: 10px 0 2px;
    scrollbar-width: none;
  }
  .rail__nav::-webkit-scrollbar { display: none; }
  .nav-item {
    width: auto;
    flex: none;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 12.5px;
    background: rgba(255, 255, 255, .05);
    animation: none;
    gap: 7px;
  }
  .nav-item[aria-current="true"]::before { display: none; }
  .nav-item .icon { width: 14px; height: 14px; }
  .nav-item__count { display: none; }
  .rail__divider, .rail__foot { display: none; }
  .topbar { padding: 12px 16px; }
  .topbar__stats { display: none; }
  .workspace { padding: 18px 16px 48px; }
  .list-head h1 { font-size: 23px; }
}

@media (max-width: 640px) {
  .detail { width: 100vw; padding: 24px 18px 44px; }
  .search input { height: 44px; font-size: 13.5px; }
  .list-head { align-items: center; }
  .list-head h1 { font-size: 21px; }
  .fn-row { grid-template-columns: 34px minmax(0, 1fr) auto; gap: 10px; padding: 11px 12px; }
  .fn-row__sigil { width: 34px; height: 34px; font-size: 12px; border-radius: 8px; }
  .fn-row__desc { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .fn-row__cn { display: none; }
  .fn-row__side .badge { display: none; }
  .detail__name { font-size: 23px; }
  .toast { bottom: 20px; max-width: calc(100vw - 32px); }
}

/* ---------- 12. 主题切换按钮 ---------- */
.theme-toggle {
  position: relative;
  width: 38px;
  height: 38px;
  margin-left: 6px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  transition: color .18s var(--ease), background .18s var(--ease), border-color .18s var(--ease);
}
.theme-toggle:hover { color: var(--brand); border-color: var(--brand-2); }
.theme-toggle:focus-visible { outline: 2px solid var(--brand-2); outline-offset: 2px; }
.theme-toggle .icon { width: 18px; height: 18px; }
.theme-toggle .icon--moon { display: none; }
html[data-theme="dark"] .theme-toggle .icon--sun { display: none; }
html[data-theme="dark"] .theme-toggle .icon--moon { display: block; }

/* ---------- 13. 暗黑模式 ---------- */
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #111815;
    --paper-2: #18201c;
    --surface: #1a231d;
    --surface-2: #1e2922;
    --ink: #e6ece8;
    --ink-2: #b3bdb6;
    --ink-3: #7d8880;
    --line: #2a332c;
    --line-strong: #3a453c;
    --brand: #4db98a;
    --brand-2: #3fa877;
    --brand-tint: #1c3328;
    --clay: #d4844f;
    --clay-tint: #3a281b;
    --rail: #0a120e;
    --rail-2: #0e1a13;
    --rail-line: rgba(255, 255, 255, .08);
    --rail-text: #c6d3c9;
    --rail-dim: #7f968a;
    --sh-sm: 0 1px 2px rgba(0, 0, 0, .35), 0 10px 24px -18px rgba(0, 0, 0, .7);
    --sh-md: 0 2px 4px rgba(0, 0, 0, .4), 0 24px 48px -30px rgba(0, 0, 0, .75);
  }
}
html[data-theme="dark"] {
  --paper: #111815;
  --paper-2: #18201c;
  --surface: #1a231d;
  --surface-2: #1e2922;
  --ink: #e6ece8;
  --ink-2: #b3bdb6;
  --ink-3: #7d8880;
  --line: #2a332c;
  --line-strong: #3a453c;
  --brand: #4db98a;
  --brand-2: #3fa877;
  --brand-tint: #1c3328;
  --clay: #d4844f;
  --clay-tint: #3a281b;
  --rail: #0a120e;
  --rail-2: #0e1a13;
  --rail-line: rgba(255, 255, 255, .08);
  --rail-text: #c6d3c9;
  --rail-dim: #7f968a;
  --sh-sm: 0 1px 2px rgba(0, 0, 0, .35), 0 10px 24px -18px rgba(0, 0, 0, .7);
  --sh-md: 0 2px 4px rgba(0, 0, 0, .4), 0 24px 48px -30px rgba(0, 0, 0, .75);
}
html[data-theme="dark"] body,
@media (prefers-color-scheme: dark) body {
  background-image:
    radial-gradient(1100px 560px at 8% -8%, rgba(77, 185, 138, .08), transparent 62%),
    radial-gradient(900px 500px at 96% 4%, rgba(212, 132, 79, .05), transparent 60%),
    linear-gradient(to right, rgba(255, 255, 255, .03) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, .03) 1px, transparent 1px);
}
@media (prefers-color-scheme: dark) {
  .topbar { background: rgba(17, 24, 21, .82); }
  .rail { border-right-color: var(--line); }
  .example-result { color: #cfe8d9; }
  .pitfall { color: #e8c8a6; }
}
html[data-theme="dark"] .topbar { background: rgba(17, 24, 21, .82); }
html[data-theme="dark"] .rail { border-right-color: var(--line); }
html[data-theme="dark"] .example-result { color: #cfe8d9; }
html[data-theme="dark"] .pitfall { color: #e8c8a6; }
html[data-theme="dark"] .fn-row[aria-current="true"] { background: var(--surface-2); border-color: var(--brand); }
