/* ==========================================================================
   Naive Icons — Official Website
   温暖手绘 (warm hand-drawn) design system
   ========================================================================== */

/* ------------------------------------------------------------- 1. Tokens */
:root {
  /* type */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Naive Sans", sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Naive Sans", sans-serif;
  /* 保留手写感（悠哉字体）的区块：主标题、引导语、页脚品牌 */
  --font-hand: "Naive Sans", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-mono: "SF Mono", "JetBrains Mono", Menlo, Consolas, "Courier New", monospace;

  /* 品牌色：完整 9 色板以 src/types.ts 的 NAIVE_PALETTE 为准，
     这里只保留站点骨架真正会引用到的几个 */
  --c-navy: #264653;
  --c-yellow: #e9c46a;
  --c-green: #588157;
  --c-teal: #2a9d8f;

  /* spacing scale — 4px base */
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 32px;
  --s7: 48px;
  --s8: 64px;
  --s9: 96px;

  /* radius — slightly uneven, keeps the hand-cut feel */
  --r-xs: 6px;
  --r-sm: 10px;
  --r: 14px;
  --r-lg: 20px;
  --r-xl: 28px;
  --r-hand: 20px 24px 18px 22px;
  --r-full: 999px;

  --shell: 1180px;
  --header-h: 66px;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);

  /* paper grain */
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)'/%3E%3C/svg%3E");
}

:root[data-theme="light"] {
  --paper: #fbf6ea;
  --paper-2: #f5eddc;
  --paper-3: #efe4cf;
  --card: #fffdf8;
  --card-2: #faf4e6;
  --line: #e8dcc4;
  --line-2: #d5c3a2;

  --text: #2b2620;
  --text-2: #5f574a;
  --text-3: #8e8577;

  --brand: var(--c-navy);
  --brand-ink: #fbf6ea;
  --accent: #d9603f;
  --accent-soft: rgba(231, 111, 81, 0.13);
  --mark: var(--c-yellow);

  --sh-1: 0 1px 2px rgba(96, 74, 42, 0.06);
  --sh-2: 0 2px 5px rgba(96, 74, 42, 0.06), 0 10px 24px rgba(96, 74, 42, 0.07);
  --sh-3: 0 10px 40px rgba(96, 74, 42, 0.15);
  --grain-opacity: 0.055;

  --code-bg: #2b3a44;
  --code-text: #f7f1e2;
  --code-dim: #93aeb8;
  --code-mark: var(--c-yellow);
  --code-key: #f2836a;
  --code-type: #7fd1c1;

  --grid-dark: #22303a;
}

:root[data-theme="dark"] {
  --paper: #1b1915;
  --paper-2: #221f1a;
  --paper-3: #2a261f;
  --card: #262219;
  --card-2: #2d2820;
  --line: #3a3428;
  --line-2: #4e4636;

  --text: #f2ead9;
  --text-2: #bdb3a1;
  --text-3: #8a8072;

  --brand: var(--c-yellow);
  --brand-ink: #1b1915;
  --accent: #f2836a;
  --accent-soft: rgba(242, 131, 106, 0.16);
  --mark: var(--c-yellow);

  --sh-1: 0 1px 2px rgba(0, 0, 0, 0.3);
  --sh-2: 0 2px 6px rgba(0, 0, 0, 0.32), 0 12px 28px rgba(0, 0, 0, 0.26);
  --sh-3: 0 14px 48px rgba(0, 0, 0, 0.55);
  --grain-opacity: 0.05;

  --code-bg: #14120e;
  --code-text: #efe7d5;
  --code-dim: #8c8171;
  --code-mark: var(--c-yellow);
  --code-key: #f2836a;
  --code-type: #7fd1c1;

  --grid-dark: #141b21;
}

/* --------------------------------------------------------------- 2. Base */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 24px);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.65;
  background: var(--paper);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior-y: none;
  transition: background 0.3s var(--ease), color 0.3s var(--ease);
}

/* 保留手写感（悠哉字体）的区块：首屏主标题、引导语、页脚品牌 */
.hero__title,
.hero__lead,
.footer__brand,
.footer__brand .brand {
  font-family: var(--font-hand);
}

/* 纸张颗粒：极低透明度的一层噪点，让底色不再是死板的纯色 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background-image: var(--grain);
  background-size: 180px 180px;
  opacity: var(--grain-opacity);
}

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

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

h1,
h2,
h3,
h4,
p {
  margin: 0;
}

img,
svg {
  display: block;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

::selection {
  background: var(--mark);
  color: #2b2620;
}

/* ---------------------------------------------------------- 3. Utilities */
.shell {
  width: 100%;
  max-width: var(--shell);
  margin: 0 auto;
  padding: 0 var(--s5);
  position: relative;
  z-index: 2;
}

.shell--narrow {
  max-width: 820px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip {
  position: absolute;
  left: var(--s5);
  top: -60px;
  z-index: 500;
  padding: 10px 18px;
  border-radius: var(--r);
  background: var(--brand);
  color: var(--brand-ink);
  font-size: 14px;
  font-weight: 600;
  transition: top 0.18s var(--ease);
}

.skip:focus {
  top: var(--s3);
}

.sec {
  padding: var(--s9) 0;
  position: relative;
}

.sec--soft {
  background: var(--paper-2);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.sec__head {
  max-width: 640px;
  margin-bottom: var(--s6);
}

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

.sec__title {
  font-family: var(--font-display);
  font-size: clamp(26px, 3.2vw, 36px);
  line-height: 1.22;
  font-weight: 700;
  letter-spacing: -0.025em;
  margin-bottom: var(--s3);
}

.sec__lead {
  font-size: 16px;
  color: var(--text-2);
  max-width: 60ch;
}

/* ------------------------------------------------------------ 4. Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  padding: 11px 20px;
  border-radius: var(--r-full);
  border: 1px solid transparent;
  font-size: 14.5px;
  font-weight: 600;
  white-space: nowrap;
  transition: transform 0.16s var(--ease), background 0.18s, border-color 0.18s,
    box-shadow 0.18s, color 0.18s;
}

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

.btn:active {
  transform: translateY(0);
}

.btn--solid {
  background: var(--brand);
  color: var(--brand-ink);
}

.btn--solid:hover {
  box-shadow: 0 6px 18px rgba(38, 70, 83, 0.26);
}

:root[data-theme="dark"] .btn--solid:hover {
  box-shadow: 0 6px 18px rgba(233, 196, 106, 0.22);
}

.btn--line {
  background: var(--card);
  border-color: var(--line);
  color: var(--text);
}

.btn--line:hover {
  border-color: var(--line-2);
  background: var(--card-2);
}

.btn--sm {
  padding: 8px 15px;
  font-size: 13.5px;
}

.iconbtn {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text-2);
  transition: color 0.18s, border-color 0.18s, background 0.18s;
}

.iconbtn:hover {
  color: var(--text);
  border-color: var(--line-2);
}

.linkbtn {
  padding: 0;
  border: 0;
  background: none;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: var(--line-2);
  text-underline-offset: 3px;
}

.linkbtn:hover {
  color: var(--accent);
  text-decoration-color: var(--accent);
}

/* ------------------------------------------------------------- 5. Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 60;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

@supports (backdrop-filter: blur(1px)) {
  .topbar {
    background: color-mix(in srgb, var(--paper) 82%, transparent);
    backdrop-filter: saturate(180%) blur(14px);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
  }
}

.topbar__inner {
  display: flex;
  align-items: center;
  gap: var(--s5);
  height: var(--header-h);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  flex-shrink: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16.5px;
  letter-spacing: -0.015em;
}

.brand__name {
  font-family: "Dynamix", "Naive Sans", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-weight: 700;
}

.brand__mark {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
}

.brand__mark svg {
  width: 100%;
  height: 100%;
}

.topnav {
  display: flex;
  gap: 2px;
  margin-left: auto;
}

.topnav a {
  padding: 7px 13px;
  border-radius: var(--r-full);
  font-size: 14px;
  color: var(--text-2);
  transition: color 0.18s, background 0.18s;
}

.topnav a:hover {
  color: var(--text);
  background: var(--card-2);
}

.topbar__actions {
  display: flex;
  align-items: center;
  gap: var(--s2);
  flex-shrink: 0;
}

/* --------------------------------------------------------------- 6. Hero */
.hero {
  position: relative;
  overflow: hidden;
  padding: var(--s9) 0 calc(var(--s9) - 8px);
}

.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.hero__inner {
  display: grid;
  grid-template-columns: minmax(0, 1.02fr) minmax(0, 0.98fr);
  gap: var(--s8);
  align-items: center;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  padding: 6px 14px;
  border-radius: var(--r-full);
  border: 1px solid var(--line);
  background: var(--card);
  box-shadow: var(--sh-1);
  font-size: 13px;
  color: var(--text-2);
}

.pill b {
  font-weight: 700;
  color: var(--accent);
}

.hero__title {
  font-size: clamp(34px, 4.9vw, 54px);
  line-height: 1.12;
  font-weight: 800;
  letter-spacing: -0.035em;
  margin: var(--s5) 0 var(--s4);
}

.hero__title em {
  position: relative;
  font-style: normal;
  display: inline-block;
  padding-bottom: 6px;
}

.squiggle {
  position: absolute;
  left: -4px;
  bottom: -4px;
  width: calc(100% + 8px);
  height: 12px;
  overflow: visible;
}

.hero__lead {
  font-size: 16.5px;
  color: var(--text-2);
  max-width: 46ch;
  margin-bottom: var(--s6);
}

.hero__cta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s3);
  margin-bottom: var(--s5);
}

.cmd {
  display: inline-flex;
  align-items: center;
  gap: var(--s3);
  max-width: 100%;
  padding: 9px 9px 9px 16px;
  border-radius: var(--r);
  background: var(--code-bg);
  color: var(--code-text);
  font-family: var(--font-mono);
  font-size: 13.5px;
  box-shadow: var(--sh-2);
}

.cmd__sign {
  color: var(--code-mark);
  user-select: none;
}

.cmd code {
  font-family: inherit;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cmd button {
  flex-shrink: 0;
  padding: 6px 12px;
  border-radius: var(--r-xs);
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.08);
  color: var(--code-text);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  transition: background 0.18s;
}

.cmd button:hover {
  background: rgba(255, 255, 255, 0.2);
}

.cmd button.is-ok {
  color: var(--code-type);
  border-color: var(--code-type);
}

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s6);
  margin: var(--s6) 0 0;
  padding-top: var(--s5);
  border-top: 1px dashed var(--line-2);
}

.stats div {
  min-width: 74px;
}

.stats dt {
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.stats dd {
  margin: 0;
  font-size: 13px;
  color: var(--text-3);
}

/* hero 贴纸墙 */
.hero__stage {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  padding: var(--s6);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-2);
}

.hero__stage::after {
  content: "";
  position: absolute;
  inset: 10px;
  border-radius: var(--r-lg);
  pointer-events: none;
}

.sticker {
  position: relative;
  z-index: 1;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  padding: 14%;
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: var(--r);
  transform: rotate(var(--rot, 0deg)) translateY(var(--dy, 0));
  transition: transform 0.3s var(--ease), box-shadow 0.3s var(--ease),
    border-color 0.3s;
}

.sticker svg {
  width: 100%;
  height: 100%;
}

.sticker:hover {
  transform: rotate(0deg) translateY(-5px) scale(1.06);
  border-color: var(--line-2);
  box-shadow: var(--sh-2);
  z-index: 3;
}

/* ----------------------------------------------------------- 7. Explorer */
.explorer {
  border: 1px solid var(--line);
  border-radius: var(--r-hand);
  background: var(--card);
  box-shadow: var(--sh-2);
}

.explorer__bar {
  position: relative;
  z-index: 20;
  border-radius: var(--r-hand) var(--r-hand) 0 0;
  background: var(--card-2);
  border-bottom: 1px solid var(--line);
}

@media (min-width: 900px) {
  .explorer__bar {
    position: sticky;
    top: var(--header-h);
    box-shadow: 0 6px 16px rgba(96, 74, 42, 0.05);
  }

  :root[data-theme="dark"] .explorer__bar {
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
  }
}

.explorer__tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s3) var(--s5);
  padding: var(--s4) var(--s5);
}

.search {
  position: relative;
  flex: 1 1 250px;
  min-width: 190px;
}

.search > svg {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-3);
  pointer-events: none;
}

.search input {
  width: 100%;
  padding: 10px 36px 10px 38px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  transition: border-color 0.18s, box-shadow 0.18s;
}

.search input::placeholder {
  color: var(--text-3);
}

.search input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.search input::-webkit-search-cancel-button {
  display: none;
}

.search__clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text-3);
  font-size: 17px;
  line-height: 1;
}

.search__clear:hover {
  color: var(--text);
  background: var(--paper-3);
}

.tools__group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s4);
}

.tool {
  display: flex;
  align-items: center;
  gap: var(--s2);
  font-size: 13px;
  color: var(--text-2);
}

.tool input[type="range"] {
  width: 92px;
  accent-color: var(--accent);
}

.tool output {
  min-width: 26px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text);
}

.swatches {
  display: flex;
  align-items: center;
  gap: 5px;
}

.swatch-btn {
  width: 20px;
  height: 20px;
  padding: 0;
  border-radius: 50%;
  border: 1.5px solid var(--line-2);
  background: var(--sw);
  transition: transform 0.15s var(--ease), box-shadow 0.15s;
}

.swatch-btn:hover {
  transform: scale(1.14);
}

.swatch-btn[aria-pressed="true"] {
  box-shadow: 0 0 0 2px var(--card-2), 0 0 0 4px var(--accent);
}

/* 自定义颜色：把原生取色器压成与色板一致的圆形 */
.swatches input[type="color"] {
  width: 20px;
  height: 20px;
  padding: 0;
  border: 1.5px dashed var(--line-2);
  border-radius: 50%;
  background: var(--card);
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  transition: transform 0.15s var(--ease);
}

.swatches input[type="color"]:hover {
  transform: scale(1.14);
}

.swatches input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

.swatches input[type="color"]::-webkit-color-swatch {
  border: 0;
  border-radius: 50%;
}

.segmented {
  display: inline-flex;
  padding: 3px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--card);
}

.segmented button {
  padding: 5px 12px;
  border: 0;
  border-radius: 7px;
  background: none;
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 600;
  transition: background 0.16s, color 0.16s;
}

.segmented button[aria-pressed="true"] {
  background: var(--brand);
  color: var(--brand-ink);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: var(--s3) var(--s5);
  border-bottom: 1px solid var(--line);
}

.chip {
  padding: 6px 13px;
  border-radius: var(--r-full);
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  transition: border-color 0.16s, color 0.16s, background 0.16s;
}

.chip:hover {
  border-color: var(--line-2);
  color: var(--text);
}

.chip[aria-pressed="true"] {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--brand-ink);
}

.chip__count {
  margin-left: 5px;
  font-size: 11.5px;
  opacity: 0.62;
}

.explorer__status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  padding: 11px var(--s5);
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  color: var(--text-3);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 6px;
  padding: var(--s4) var(--s4) var(--s5);
  border-radius: 0 0 var(--r-hand) var(--r-hand);
}

.grid[data-bg="dark"] {
  background: var(--grid-dark);
  color: #ede4d3;
}

.grid[data-bg="grid"] {
  background-color: var(--card);
  background-image: linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 24px 24px;
}

.cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 16px 6px 11px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: none;
  text-align: center;
  transition: background 0.16s, border-color 0.16s, transform 0.16s var(--ease);
}

.cell:hover {
  background: var(--card-2);
  border-color: var(--line);
  transform: translateY(-2px);
}

.grid[data-bg="dark"] .cell:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.16);
}

.cell__icon {
  display: grid;
  place-items: center;
  height: calc(var(--icon-size, 32px) + 16px);
}

.cell__icon svg {
  width: var(--icon-size, 32px);
  height: var(--icon-size, 32px);
}

.cell__name {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-2);
  word-break: break-all;
  line-height: 1.32;
}

.cell__zh {
  font-family: var(--font-sans);
  font-size: 11px;
  color: var(--text-3);
  letter-spacing: 0.04em;
}

.grid[data-bg="dark"] .cell__name {
  color: #cfc4b0;
}

.grid[data-bg="dark"] .cell__zh {
  color: #8f8474;
}

.empty {
  grid-column: 1 / -1;
  padding: var(--s8) 0;
  text-align: center;
  color: var(--text-3);
  font-size: 15px;
}

/* ------------------------------------------------------- 8. Code panels */
.codetabs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s1);
  margin-bottom: var(--s3);
}

.codetabs button {
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: var(--r-full);
  background: none;
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 600;
  transition: background 0.16s, color 0.16s, border-color 0.16s;
}

.codetabs button:hover {
  background: var(--card);
  color: var(--text);
}

.codetabs button[aria-selected="true"] {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--brand-ink);
}

.codepane {
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
  box-shadow: var(--sh-1);
}

.codepane__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  padding: 10px var(--s5);
  background: var(--card);
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
}

.copy {
  padding: 5px 12px;
  border-radius: var(--r-xs);
  border: 1px solid var(--line);
  background: var(--card-2);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  transition: color 0.16s, border-color 0.16s;
}

.copy:hover {
  color: var(--text);
  border-color: var(--line-2);
}

.copy.is-ok {
  color: var(--c-green);
  border-color: var(--c-green);
}

:root[data-theme="dark"] .copy.is-ok {
  color: var(--code-type);
  border-color: var(--code-type);
}

.code {
  margin: 0;
  padding: var(--s5);
  overflow-x: auto;
  background: var(--code-bg);
  color: var(--code-text);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.75;
  tab-size: 2;
}

.code .k {
  color: var(--code-key);
}

.code .s {
  color: var(--code-mark);
}

.code .c {
  color: var(--code-dim);
}

.code .t {
  color: var(--code-type);
}

/* ------------------------------------------------------------- 9. Table */
.tablewrap {
  margin-top: var(--s5);
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--card);
}

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

th,
td {
  padding: 12px var(--s5);
  text-align: left;
  border-bottom: 1px solid var(--line);
}

th {
  background: var(--card-2);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-2);
}

tbody tr:last-child td {
  border-bottom: 0;
}

td code {
  padding: 2px 6px;
  border-radius: 5px;
  background: var(--paper-3);
  font-family: var(--font-mono);
  font-size: 12.5px;
}

/* ----------------------------------------------------------- 10. Palette */
.palette {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: var(--s3);
  margin-bottom: var(--s6);
}

.swatch {
  padding: 0;
  height: 125px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
  background: var(--card);
  text-align: left;
  transition: transform 0.18s var(--ease), box-shadow 0.18s, border-color 0.18s;
}

.swatch:hover {
  transform: translateY(-3px);
  border-color: var(--line-2);
  box-shadow: var(--sh-2);
}

.swatch__color {
  display: block; /* 空 span 默认 inline，height 不生效会导致色块塌陷 */
  height: 74px;
  border-bottom: 1px solid var(--line);
}

.swatch__meta {
  padding: 0 12px 0;
  height: 74px;
}

.swatch__name {
  /* display: block; */
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
}

.swatch__hex {
  display: block;
  margin-top: 0;
  margin-left: 12px;
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1;
  color: var(--text-3);
}

/* ------------------------------------------------------------- 11. Rules */
.rules {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: var(--s6) var(--s7);
  margin: 0;
  padding: var(--s6) 0 0;
  border-top: 1px dashed var(--line-2);
  list-style: none;
}

.rules li {
  position: relative;
}

.rules__num {
  display: block;
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: 6px;
}

.rules h3 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 7px;
}

.rules p {
  font-size: 14px;
  color: var(--text-2);
}

/* --------------------------------------------------------------- 12. FAQ */
.faq {
  border-top: 1px solid var(--line);
}

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

.faq__q {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s4);
  padding: 19px var(--s1);
  border: 0;
  background: none;
  text-align: left;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.faq__q svg {
  flex-shrink: 0;
  width: 17px;
  height: 17px;
  color: var(--text-3);
  transition: transform 0.24s var(--ease);
}

.faq__item[data-open="true"] .faq__q svg {
  transform: rotate(180deg);
}

.faq__a {
  padding: 0 var(--s1) 20px;
  font-size: 14.5px;
  color: var(--text-2);
  max-width: 68ch;
}

/* ------------------------------------------------------------- 13. Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s5);
}

.modal[hidden] {
  display: none;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(28, 24, 18, 0.5);
  animation: fade 0.2s var(--ease);
}

@supports (backdrop-filter: blur(1px)) {
  .modal__backdrop {
    backdrop-filter: blur(3px);
  }
}

.modal__box {
  position: relative;
  width: min(640px, 100%);
  max-height: 88vh;
  overflow: auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-3);
  animation: pop 0.24s var(--ease);
}

@keyframes fade {
  from {
    opacity: 0;
  }
}

@keyframes pop {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.98);
  }
}

.modal__close,
.modal__nav button {
  position: absolute;
  top: 14px;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text-2);
  z-index: 3;
  transition: color 0.16s, border-color 0.16s;
}

.modal__close:hover,
.modal__nav button:hover {
  color: var(--text);
  border-color: var(--line-2);
}

.modal__close {
  right: 14px;
}

.modal__nav button {
  top: 50%;
  transform: translateY(-50%);
}

#modalPrev {
  left: 12px;
}

#modalNext {
  right: 12px;
}

.modal__preview {
  display: grid;
  place-items: center;
  padding: var(--s7) var(--s5);
  background: var(--card-2);
  border-bottom: 1px solid var(--line);
}

.modal__preview svg {
  width: var(--preview-size, 116px);
  height: var(--preview-size, 116px);
}

.modal__body {
  padding: var(--s5) var(--s6) var(--s6);
}

.modal__title {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.modal__sub {
  margin: 3px 0 var(--s4);
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text-3);
}

.tabs {
  display: inline-flex;
  padding: 3px;
  margin-bottom: var(--s3);
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--card-2);
}

.tabs button {
  padding: 6px 14px;
  border: 0;
  border-radius: 7px;
  background: none;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
  transition: background 0.16s, color 0.16s;
}

.tabs button[aria-selected="true"] {
  background: var(--brand);
  color: var(--brand-ink);
}

.modal__code {
  margin-bottom: var(--s4);
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
}

.modal__code .code {
  max-height: 230px;
  white-space: pre-wrap;
  word-break: break-all;
}

.modal__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2);
}

/* ------------------------------------------------------------- 14. Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 36px;
  z-index: 400;
  padding: 11px 22px;
  border-radius: var(--r-full);
  background: var(--brand);
  color: var(--brand-ink);
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--sh-3);
  opacity: 0;
  transform: translate(-50%, 14px);
  pointer-events: none;
  transition: opacity 0.24s, transform 0.24s var(--ease);
}

.toast[data-show="true"] {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ------------------------------------------------------------ 15. Footer */
.footer {
  padding: var(--s7) 0 var(--s5);
  border-top: 1px solid var(--line);
  background: var(--paper-2);
}

.footer__grid {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s6);
  justify-content: space-between;
  margin-bottom: var(--s6);
}

.footer__brand {
  max-width: 320px;
}

.footer__brand p {
  margin-top: var(--s3);
  font-size: 13.5px;
  color: var(--text-2);
}

.footer__col {
  min-width: 130px;
}

.footer__col h3 {
  margin-bottom: var(--s3);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-3);
}

.footer__col a {
  display: block;
  padding: 3px 0;
  font-size: 14px;
  color: var(--text-2);
  transition: color 0.16s;
}

.footer__col a:hover {
  color: var(--accent);
}

.footer__bottom {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s3);
  justify-content: space-between;
  padding-top: var(--s5);
  border-top: 1px solid var(--line);
  font-size: 13px;
  color: var(--text-3);
}

/* -------------------------------------------------------- 16. Responsive */
@media (max-width: 1000px) {
  .hero__inner {
    grid-template-columns: 1fr;
    gap: var(--s7);
  }

  .hero__stage {
    max-width: 440px;
  }
}

@media (max-width: 860px) {
  :root {
    --header-h: 60px;
  }

  html {
    scroll-padding-top: calc(var(--header-h) + 76px);
  }

  .topbar__inner {
    flex-wrap: wrap;
    height: auto;
    padding-top: 10px;
    padding-bottom: 0;
  }

  .topnav {
    order: 3;
    width: calc(100% + var(--s5) * 2);
    margin: var(--s2) calc(var(--s5) * -1) 0;
    padding: 0 var(--s5) 9px;
    gap: var(--s1);
    overflow-x: auto;
    scrollbar-width: none;
  }

  .topnav::-webkit-scrollbar {
    display: none;
  }

  .topnav a {
    white-space: nowrap;
  }

  .topbar__actions {
    margin-left: auto;
  }
}

@media (max-width: 720px) {
  .sec {
    padding: var(--s8) 0;
  }

  .hero {
    padding: var(--s7) 0 var(--s8);
  }

  .explorer__tools,
  .chips,
  .explorer__status {
    padding-left: var(--s4);
    padding-right: var(--s4);
  }

  .grid {
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    padding: var(--s3) var(--s3) var(--s4);
  }

  .stats {
    gap: var(--s5);
  }

  .rules {
    gap: var(--s5);
  }

  .modal__body {
    padding: var(--s4) var(--s5) var(--s5);
  }

  .footer__grid {
    gap: var(--s5);
  }
}

@media (max-width: 480px) {
  .hero__stage {
    grid-template-columns: repeat(3, 1fr);
    padding: var(--s5) var(--s4);
  }

  .hero__cta .btn {
    flex: 1 1 auto;
  }

  .cmd {
    width: 100%;
  }

  /* 极窄屏下让出顶栏空间，只保留图形标志 */
  .brand__name {
    display: none;
  }
}

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

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