/* ==========================================================================
   PixivFlow 文档站 · 设计系统 v3
   主题:跟随系统(默认)+ 手动切换(data-theme="light|dark")
   主色:#0096fa(Pixiv Blue)
   ========================================================================== */

/* ---------- Tokens ---------- */
:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", Roboto,
    Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;

  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-2: #f1f4f9;
  --text: #17202a;
  --muted: #5b6673;
  --border: #e3e8ef;
  --accent: #0096fa;
  --accent-strong: #0072c9;
  --accent-soft: rgba(0, 150, 250, 0.1);
  --ok: #12945c;
  --warn-bg: #fff7e8;
  --warn-border: #f0c36d;
  --warn-text: #7a5316;
  --danger-bg: #fdeeee;
  --danger-border: #eeaaaa;
  --danger-text: #8c2727;

  --code-bg: #10161f;
  --code-text: #dbe5f1;
  --code-accent: #7cc7ff;

  --radius: 14px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow-md: 0 8px 24px rgba(16, 24, 40, 0.08);
  --content-w: 960px;
}

[data-theme="dark"] {
  --bg: #0e1319;
  --surface: #161d26;
  --surface-2: #1c2530;
  --text: #e4ebf3;
  --muted: #93a1b1;
  --border: #2a3542;
  --accent: #33aaff;
  --accent-strong: #66c2ff;
  --accent-soft: rgba(51, 170, 255, 0.14);
  --warn-bg: #2b2314;
  --warn-border: #7a6123;
  --warn-text: #e8c37a;
  --danger-bg: #2e1919;
  --danger-border: #7a3a3a;
  --danger-text: #eda9a9;
  --code-bg: #0a0f15;
  --code-text: #cfdeed;
  --shadow-md: 0 8px 28px rgba(0, 0, 0, 0.45);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) {
    --bg: #0e1319;
    --surface: #161d26;
    --surface-2: #1c2530;
    --text: #e4ebf3;
    --muted: #93a1b1;
    --border: #2a3542;
    --accent: #33aaff;
    --accent-strong: #66c2ff;
    --accent-soft: rgba(51, 170, 255, 0.14);
    --warn-bg: #2b2314;
    --warn-border: #7a6123;
    --warn-text: #e8c37a;
    --danger-bg: #2e1919;
    --danger-border: #7a3a3a;
    --danger-text: #eda9a9;
    --code-bg: #0a0f15;
    --code-text: #cfdeed;
    --shadow-md: 0 8px 28px rgba(0, 0, 0, 0.45);
  }
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 76px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: var(--content-w);
  margin: 0 auto;
  padding: 0 20px;
}

h1, h2, h3, h4 { line-height: 1.35; color: var(--text); }
h2.section-title {
  font-size: 1.45rem;
  margin: 2.6rem 0 1rem;
  padding-top: .4rem;
}
h2.section-title::before {
  content: "";
  display: inline-block;
  width: 6px; height: 22px;
  border-radius: 3px;
  background: var(--accent);
  margin-right: 10px;
  vertical-align: -3px;
}
h3 { font-size: 1.12rem; margin: 1.8rem 0 .7rem; }

p { margin: .65rem 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-strong); text-decoration: underline; }

hr {
  border: none;
  height: 1px;
  background: var(--border);
  margin: 2.4rem 0;
}

strong { color: var(--text); }

/* ---------- Header / Nav ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  border-bottom: 1px solid var(--border);
}
.topbar .bar {
  max-width: var(--content-w);
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
}
.brand:hover { text-decoration: none; color: var(--accent); }
.brand .logo {
  width: 26px; height: 26px;
  display: grid; place-items: center;
  border-radius: 7px;
  background: linear-gradient(135deg, var(--accent), #00c8ff);
  font-size: 15px;
  color: #fff;
}
.nav-links {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1;
}
.nav-links a {
  display: block;
  padding: 6px 12px;
  border-radius: 999px;
  color: var(--muted);
  font-size: .95rem;
}
.nav-links a:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.nav-links a.active { color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.top-actions { display: flex; gap: 8px; align-items: center; }

.icon-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  border-radius: 999px;
  width: 34px; height: 34px;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  font-size: 15px;
  transition: transform .15s ease, color .15s ease, border-color .15s ease;
}
.icon-btn:hover { transform: translateY(-1px); color: var(--accent); border-color: var(--accent); }

/* ---------- Hero ---------- */
.hero {
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid var(--border);
  background:
    radial-gradient(900px 320px at 85% -60%, var(--accent-soft), transparent),
    radial-gradient(700px 300px at 0% 120%, rgba(0, 200, 255, 0.08), transparent),
    var(--surface);
}
.hero .container { padding-top: 64px; padding-bottom: 58px; }
.hero h1 {
  margin: 0 0 10px;
  font-size: clamp(2rem, 5vw, 2.9rem);
  letter-spacing: -.5px;
}
.hero .tagline {
  font-size: 1.08rem;
  color: var(--muted);
  max-width: 44em;
  margin: 0 0 22px;
}
.hero .meta-line { margin-top: 22px; font-size: .9rem; color: var(--muted); opacity: .9; }

.cta { display: flex; gap: 12px; flex-wrap: wrap; }
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 22px;
  border-radius: 999px;
  font-weight: 600;
  font-size: .98rem;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease;
}
.btn:hover { transform: translateY(-2px); text-decoration: none; }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), #00b2ff);
  color: #fff !important;
  box-shadow: 0 6px 18px rgba(0, 150, 250, 0.32);
}
.btn-outline {
  border-color: var(--border);
  background: var(--surface);
  color: var(--text);
}
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- Cards & Grids ---------- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin: 1.2rem 0;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
  display: block;
  color: inherit;
}
.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  text-decoration: none;
}
.card h3 { margin: .1rem 0 .4rem; font-size: 1.05rem; }
.card p { margin: 0; color: var(--muted); font-size: .92rem; line-height: 1.65; }
.card .card-icon { font-size: 1.5rem; margin-bottom: 8px; }
.card .arrow { color: var(--accent); font-weight: 600; }

.feature-table { width: 100%; border-collapse: collapse; margin: 1rem 0; }
.feature-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.feature-table tr:last-child td { border-bottom: none; }

/* ---------- Tables (data) ---------- */
main table:not(.feature-table) {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0 1.4rem;
  font-size: .94rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
main thead th {
  text-align: left;
  padding: 10px 14px;
  background: var(--surface-2);
  color: var(--muted);
  font-weight: 600;
  font-size: .88rem;
  white-space: nowrap;
}
main tbody td {
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  vertical-align: top;
}
main tbody tr:hover td { background: color-mix(in srgb, var(--accent) 4%, var(--surface)); }

.table-scroll { overflow-x: auto; }
.table-scroll table { min-width: 560px; }

/* ---------- Code ---------- */
pre {
  background: var(--code-bg);
  color: var(--code-text);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: .86rem;
  line-height: 1.7;
  margin: 1rem 0;
  border: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
}
code {
  font-family: var(--font-mono);
  font-size: .88em;
  background: var(--accent-soft);
  color: var(--accent-strong);
  padding: 2px 6px;
  border-radius: 6px;
}
pre code { background: none; color: inherit; padding: 0; border-radius: 0; }
pre .cmt { color: #64748b; user-select: none; }

/* JSON syntax tint via spans in hand-written pages */
.tk-key { color: #8ad2ff; }
.tk-str { color: #ffd591; }
.tk-num { color: #ffab70; }
.tk-bool { color: #c792ea; }

/* ---------- Callouts ---------- */
.callout {
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  background: var(--accent-soft);
  padding: 13px 16px;
  margin: 1.1rem 0;
  font-size: .95rem;
}
.callout strong:first-child { display: inline-block; margin-right: 6px; }
.callout.warn { border-left-color: var(--warn-border); background: var(--warn-bg); }
.callout.warn .callout-title { color: var(--warn-text); }
.callout.danger { border-left-color: var(--danger-border); background: var(--danger-bg); }
.callout.danger .callout-title { color: var(--danger-text); }
.callout .callout-title { font-weight: 700; }

/* ---------- Steps ---------- */
ol.steps {
  list-style: none;
  counter-reset: step;
  margin: 1.4rem 0;
  padding: 0;
  display: grid;
  gap: 14px;
}
ol.steps li {
  counter-increment: step;
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px 18px 66px;
  box-shadow: var(--shadow-sm);
}
ol.steps li::before {
  content: counter(step);
  position: absolute;
  left: 18px; top: 18px;
  width: 34px; height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #00c8ff);
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
}
ol.steps h3 { margin: 0 0 .3rem; }
ol.steps p { margin: .25rem 0; color: var(--muted); }

/* ---------- Section blocks ---------- */
section.card-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 26px 20px;
  margin: 22px 0;
  box-shadow: var(--shadow-sm);
}
section.plain { background: none; border: none; box-shadow: none; padding: 0; }

.page-head { padding: 44px 0 6px; }
.page-head h1 { font-size: clamp(1.7rem, 4vw, 2.3rem); margin: 0 0 8px; }
.page-head .lede { color: var(--muted); font-size: 1.03rem; max-width: 42em; }

.toc-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 18px 0 6px;
  padding: 0;
  list-style: none;
}
.toc-inline a {
  display: inline-block;
  padding: 5px 13px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: .87rem;
}
.toc-inline a:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }

.anchor-hint { opacity: 0; margin-left: 8px; color: var(--accent); font-size: .85em; }
h2[id]:hover .anchor-hint, h3[id]:hover .anchor-hint { opacity: 1; }

.backtop {
  text-align: right;
  margin: 30px 0 8px;
  font-size: .88rem;
}

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 56px;
  padding: 30px 0 40px;
  color: var(--muted);
  font-size: .9rem;
  background: var(--surface);
}
.site-footer .cols {
  display: flex;
  flex-wrap: wrap;
  gap: 34px;
  justify-content: space-between;
}
.site-footer ul { list-style: none; margin: 6px 0 0; padding: 0; }
.site-footer li { margin: 4px 0; }
.site-footer a { color: var(--muted); }
.site-footer a:hover { color: var(--accent); }
.site-footer .foot-note { margin-top: 18px; opacity: .75; }

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  body { font-size: 15px; }
  .hero .container { padding-top: 44px; padding-bottom: 40px; }
  section.card-block { padding: 4px 16px 14px; }
  ol.steps li { padding-left: 58px; }
  .cta .btn { flex: 1; justify-content: center; }
  main pre { font-size: .8rem; }
}
