:root {
  color-scheme: dark;
  --bg: #080910;
  --bg-grid: rgba(145, 160, 200, 0.055);
  --surface: #10131d;
  --surface-raised: #151925;
  --surface-soft: #0c0e16;
  --text: #f4f5f8;
  --muted: #a8adbd;
  --faint: #747b91;
  --line: #343a4c;
  --line-strong: #596176;
  --accent: #dcff78;
  --accent-ink: #11140a;
  --cyan: #65ecf1;
  --danger: #ff6e8d;
  --shadow: rgba(0, 0, 0, 0.35);
  font-family: Inter, "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 16px;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f1e9;
  --bg-grid: rgba(31, 41, 55, 0.075);
  --surface: #fffdf7;
  --surface-raised: #ffffff;
  --surface-soft: #eeeadf;
  --text: #16181d;
  --muted: #5f6470;
  --faint: #7b7e86;
  --line: #c9c4b8;
  --line-strong: #8f8a7f;
  --accent: #242b18;
  --accent-ink: #f4ffcf;
  --cyan: #087c83;
  --danger: #b92e4a;
  --shadow: rgba(42, 35, 22, 0.12);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; scroll-padding-top: 90px; }
body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background-color: var(--bg);
  background-image: linear-gradient(var(--bg-grid) 1px, transparent 1px), linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px);
  background-size: 24px 24px;
  line-height: 1.7;
}
button, input, textarea { font: inherit; }
button, a { color: inherit; }
button { cursor: pointer; }
a { text-underline-offset: 3px; }

.skip-link { position: fixed; top: -80px; left: 20px; z-index: 100; padding: 10px 14px; color: var(--accent-ink); background: var(--accent); }
.skip-link:focus { top: 12px; }

.community-banner {
  position: relative;
  z-index: 45;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(28px, 7vw, 96px);
  min-height: 82px;
  padding: 12px max(20px, calc((100vw - 1380px) / 2));
  overflow: hidden;
  border-bottom: 3px solid var(--accent-ink);
  color: var(--accent-ink);
  background: var(--accent);
  box-shadow: inset 0 -6px 0 color-mix(in srgb, var(--cyan) 42%, transparent);
}
.community-banner::before, .community-banner::after { content: "✦"; position: absolute; color: color-mix(in srgb, var(--accent-ink) 30%, transparent); font-size: 66px; line-height: 1; }
.community-banner::before { left: 3vw; transform: rotate(14deg); }
.community-banner::after { right: 3vw; transform: rotate(-14deg); }
.community-invite { z-index: 1; display: grid; grid-template-columns: auto auto; align-items: baseline; column-gap: 12px; }
.community-invite span { grid-row: 1 / 3; align-self: center; padding: 7px 9px; border: 2px solid currentColor; font: 900 11px ui-monospace, "Cascadia Mono", monospace; letter-spacing: .08em; }
.community-invite strong { font-size: clamp(20px, 2.4vw, 29px); line-height: 1.1; letter-spacing: -.03em; }
.community-invite small { font-size: 13px; font-weight: 800; opacity: .72; }
.qq-copy-button { z-index: 1; display: flex; align-items: center; gap: 10px; min-height: 54px; padding: 7px 12px 7px 8px; border: 2px solid var(--accent-ink); color: var(--text); background: var(--bg); box-shadow: 5px 5px 0 color-mix(in srgb, var(--accent-ink) 32%, transparent); transition: transform .14s ease, box-shadow .14s ease; }
.qq-copy-button:hover, .qq-copy-button:focus-visible { transform: translate(-2px, -2px); box-shadow: 7px 7px 0 color-mix(in srgb, var(--accent-ink) 36%, transparent); }
.qq-copy-button > span { display: grid; place-items: center; align-self: stretch; min-width: 42px; color: var(--accent-ink); background: var(--cyan); font: 900 14px ui-monospace, "Cascadia Mono", monospace; }
.qq-copy-button b { color: var(--accent); font: 900 clamp(23px, 2.5vw, 32px)/1 ui-monospace, "Cascadia Mono", monospace; letter-spacing: .035em; }
.qq-copy-button em { padding-left: 10px; border-left: 1px solid var(--line-strong); color: var(--muted); font-size: 12px; font-style: normal; font-weight: 800; white-space: nowrap; }
.qq-copy-button.is-copied > em { color: var(--accent); }

.knowledge-header {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 70px;
  padding: 10px max(24px, calc((100vw - 1380px) / 2));
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(16px);
}
.knowledge-brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.knowledge-brand > span:last-child { display: grid; }
.knowledge-brand strong { font-size: 17px; letter-spacing: .02em; }
.knowledge-brand small { color: var(--faint); font: 700 10px/1.4 ui-monospace, "Cascadia Mono", monospace; letter-spacing: .08em; }
.brand-flower { display: grid; place-items: center; width: 38px; height: 38px; color: var(--accent-ink); background: var(--accent); font-size: 21px; box-shadow: 4px 4px 0 color-mix(in srgb, var(--cyan) 38%, transparent); }
.header-actions { display: flex; align-items: center; gap: 8px; }
.header-actions a, .header-actions button { min-height: 39px; padding: 8px 12px; border: 1px solid transparent; background: transparent; text-decoration: none; font-weight: 700; }
.header-actions a:hover, .header-actions button:hover { border-color: var(--line-strong); background: var(--surface); }
.header-actions .accent-button { border-color: var(--accent); color: var(--accent-ink); background: var(--accent); }

.accent-button, .plain-button { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; padding: 9px 15px; border: 1px solid var(--line-strong); text-decoration: none; font-weight: 800; }
.accent-button { border-color: var(--accent); color: var(--accent-ink); background: var(--accent); box-shadow: 4px 4px 0 color-mix(in srgb, var(--cyan) 38%, transparent); }
.accent-button:hover { transform: translate(-1px, -1px); box-shadow: 5px 5px 0 color-mix(in srgb, var(--cyan) 48%, transparent); }
.plain-button { color: var(--text); background: var(--surface); }
.plain-button:hover { border-color: var(--accent); }

.knowledge-shell { width: min(1380px, calc(100% - 48px)); margin: 0 auto; }
.knowledge-hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  min-height: 410px;
  margin-top: 34px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  box-shadow: 10px 10px 0 var(--shadow);
}
.knowledge-hero::before { content: ""; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(120deg, transparent 45%, color-mix(in srgb, var(--cyan) 7%, transparent)); }
.hero-copy { z-index: 1; align-self: center; padding: clamp(32px, 6vw, 76px); }
.eyebrow { margin: 0 0 18px; color: var(--cyan); font: 800 12px/1.4 ui-monospace, "Cascadia Mono", monospace; letter-spacing: .1em; }
.eyebrow span { display: inline-block; width: 8px; height: 8px; margin-right: 8px; background: var(--accent); box-shadow: 0 0 12px var(--accent); }
.hero-copy h1 { max-width: 760px; margin: 0; font-size: clamp(42px, 6vw, 78px); line-height: 1.02; letter-spacing: -.055em; }
.hero-intro { max-width: 670px; margin: 24px 0 0; color: var(--muted); font-size: clamp(17px, 2vw, 21px); }
.hero-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 26px; }
.hero-meta span { padding: 5px 9px; border: 1px solid var(--line); color: var(--muted); background: var(--surface); font: 700 12px ui-monospace, "Cascadia Mono", monospace; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 28px; }

.pixel-jasmine { position: relative; min-height: 100%; overflow: hidden; border-left: 1px solid var(--line); background: radial-gradient(circle at 50% 40%, color-mix(in srgb, var(--cyan) 16%, transparent), transparent 42%), var(--surface); }
.pixel-jasmine .moon { position: absolute; top: 58px; right: 70px; width: 128px; height: 128px; border: 16px solid var(--accent); border-left-color: transparent; border-radius: 50%; filter: drop-shadow(0 0 18px color-mix(in srgb, var(--accent) 25%, transparent)); transform: rotate(-25deg); }
.pixel-jasmine .stem { position: absolute; right: 115px; bottom: -20px; width: 8px; height: 250px; background: var(--line-strong); transform: rotate(27deg); transform-origin: bottom; }
.pixel-jasmine .flower { position: absolute; color: #faf8e9; font-size: 64px; font-style: normal; text-shadow: 5px 5px 0 color-mix(in srgb, var(--cyan) 40%, transparent); }
.flower-one { right: 98px; bottom: 95px; }.flower-two { right: 205px; bottom: 135px; font-size: 48px !important; }.flower-three { right: 50px; bottom: 202px; font-size: 40px !important; }
.pixel-jasmine > span { position: absolute; right: 26px; bottom: 24px; color: var(--faint); font: 800 11px/1.5 ui-monospace, "Cascadia Mono", monospace; letter-spacing: .12em; text-align: right; }

.resource-jumpbar { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin: 26px 0 0; }
.resource-jumpbar a { display: grid; grid-template-columns: 54px minmax(0, 1fr); grid-template-rows: auto auto; column-gap: 14px; padding: 18px 20px; border: 1px solid var(--line); color: var(--text); background: var(--surface); text-decoration: none; box-shadow: 5px 5px 0 var(--shadow); }
.resource-jumpbar a:hover { border-color: var(--accent); transform: translate(-1px, -1px); }
.resource-jumpbar span { grid-row: 1 / 3; display: grid; place-items: center; color: var(--accent-ink); background: var(--accent); font: 900 15px ui-monospace, "Cascadia Mono", monospace; }
.resource-jumpbar strong { font-size: 18px; }
.resource-jumpbar small { color: var(--muted); font-size: 13px; }

.reading-grid { display: grid; grid-template-columns: 320px minmax(0, 900px); justify-content: center; gap: 34px; margin: 58px 0 100px; }
.knowledge-sidebar { position: relative; }
.sidebar-panel { position: sticky; top: 96px; max-height: calc(100vh - 120px); overflow: auto; padding: 16px; border: 1px solid var(--line); background: var(--surface); }
.find-box { display: flex; align-items: center; gap: 8px; padding: 0 10px; border: 1px solid var(--line); background: var(--surface-soft); }
.find-box:focus-within { border-color: var(--cyan); }
.find-box input { width: 100%; height: 42px; border: 0; outline: 0; color: var(--text); background: transparent; }
.sidebar-label { margin: 20px 0 8px; color: var(--faint); font: 800 11px ui-monospace, "Cascadia Mono", monospace; letter-spacing: .12em; }
#knowledge-toc { display: grid; gap: 1px; }
#knowledge-toc a { padding: 8px 9px; border-left: 2px solid transparent; color: var(--muted); font-size: 14px; line-height: 1.35; text-decoration: none; overflow-wrap: anywhere; }
#knowledge-toc a.toc-section { margin-top: 8px; border-top: 1px solid var(--line); color: var(--text); background: color-mix(in srgb, var(--surface-soft) 72%, transparent); font-weight: 800; }
#knowledge-toc a.toc-section:first-child { margin-top: 0; }
#knowledge-toc a[data-level="3"] { padding-left: 20px; color: color-mix(in srgb, var(--cyan) 72%, var(--text)); font-size: 13px; font-weight: 750; }
#knowledge-toc a[data-level="4"] { padding: 7px 9px 7px 34px; font-size: 12.5px; }
#knowledge-toc a[data-level="5"] { padding: 6px 9px 6px 50px; color: var(--faint); font-size: 12px; }
#knowledge-toc a[data-level="4"]::before, #knowledge-toc a[data-level="5"]::before { content: "└"; display: inline-block; width: 14px; margin-left: -14px; color: color-mix(in srgb, var(--cyan) 58%, var(--faint)); font-family: ui-monospace, "Cascadia Mono", monospace; }
#knowledge-toc a:hover, #knowledge-toc a.active { border-left-color: var(--accent); color: var(--text); background: var(--surface-soft); }

.knowledge-article { min-width: 0; padding: clamp(26px, 5vw, 58px); border: 1px solid var(--line); background: var(--surface); box-shadow: 10px 10px 0 var(--shadow); font-size: 18px; line-height: 1.9; }
.knowledge-article h2, .knowledge-article h3, .knowledge-article h4, .knowledge-article h5 { position: relative; scroll-margin-top: 95px; line-height: 1.25; letter-spacing: -.025em; }
.knowledge-article h2 { margin: 76px 0 28px; padding: 18px 0 16px 22px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); font-size: clamp(28px, 4vw, 38px); }
.knowledge-article h2::before { content: ""; position: absolute; left: 0; top: 21px; width: 7px; height: 30px; background: var(--accent); }
.knowledge-article h2:first-child { margin-top: 0; }
.knowledge-article h3 { margin: 52px 0 18px; color: var(--cyan); font-size: 24px; }
.knowledge-article h4 { margin: 38px 0 14px; font-size: 20px; }
.knowledge-article h5 { margin: 28px 0 12px; color: color-mix(in srgb, var(--text) 88%, var(--cyan)); font-size: 18px; }
.knowledge-article .resource-section-title { margin: 96px -18px 36px; padding: 28px 28px 26px 40px; border: 1px solid var(--line-strong); color: var(--text); background: linear-gradient(110deg, color-mix(in srgb, var(--accent) 12%, var(--surface-soft)), var(--surface-soft)); font-size: clamp(32px, 5vw, 48px); box-shadow: 8px 8px 0 var(--shadow); }
.knowledge-article .resource-section-title:first-of-type { margin-top: 20px; }
.knowledge-article .resource-section-title::before { top: 30px; left: 18px; height: 38px; }
.knowledge-article p { margin: 0 0 18px; color: color-mix(in srgb, var(--text) 92%, var(--muted)); overflow-wrap: anywhere; }
.knowledge-article a { color: var(--cyan); font-weight: 700; }
.knowledge-article strong { color: var(--text); }
.knowledge-article :not(pre) > code { padding: 2px 5px; color: var(--cyan); background: var(--surface-soft); font: .88em ui-monospace, "Cascadia Mono", monospace; }
.knowledge-article blockquote { margin: 28px 0; padding: 18px 22px; border: 1px solid var(--line); border-left: 6px solid var(--accent); color: var(--text); background: var(--surface-soft); }
.knowledge-article blockquote p { margin: 0; }
.knowledge-article ul, .knowledge-article ol { margin: 0 0 22px; padding-left: 30px; }
.knowledge-article li { margin: 8px 0; }
.knowledge-article pre { overflow: auto; margin: 24px 0; padding: 20px; border: 1px solid var(--line); color: #dff5b2; background: #070910; font: 14px/1.7 ui-monospace, "Cascadia Mono", monospace; }
.knowledge-figure { margin: 30px 0 36px; }
.knowledge-figure button { display: block; width: 100%; padding: 0; overflow: hidden; border: 1px solid var(--line); background: #070910; }
.knowledge-figure img { display: block; width: 100%; max-height: 760px; object-fit: contain; }
.knowledge-figure figcaption { margin-top: 8px; color: var(--faint); font: 12px ui-monospace, "Cascadia Mono", monospace; text-align: center; }
.loading-state { display: grid; place-items: center; min-height: 460px; color: var(--muted); }
.loading-state span { width: 28px; height: 28px; border: 4px solid var(--line); border-top-color: var(--accent); animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.knowledge-footer { display: flex; justify-content: space-between; gap: 20px; padding: 28px max(24px, calc((100vw - 1380px) / 2)); border-top: 1px solid var(--line); color: var(--muted); background: var(--surface-soft); font-size: 13px; }

dialog { color: var(--text); }
dialog::backdrop { background: rgba(0, 0, 0, .75); backdrop-filter: blur(4px); }
.editor-dialog { width: min(1240px, calc(100% - 30px)); max-width: none; padding: 0; border: 1px solid var(--line-strong); background: var(--surface); }
.editor-panel { padding: 24px; }
.editor-head, .editor-actions { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.editor-head span { color: var(--cyan); font: 800 11px ui-monospace, monospace; }
.editor-head h2 { margin: 4px 0 0; }
.icon-button { width: 42px; height: 42px; border: 1px solid var(--line); color: var(--text); background: var(--surface-soft); font-size: 24px; }
.title-field, .content-field { display: grid; gap: 8px; font-weight: 800; }
.title-field { margin-top: 22px; }
.title-field input, .content-field textarea { width: 100%; border: 1px solid var(--line); outline: 0; color: var(--text); background: var(--surface-soft); }
.title-field input { height: 46px; padding: 0 12px; }
.editor-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-top: 18px; }
.content-field textarea { min-height: 58vh; padding: 16px; resize: vertical; font: 14px/1.65 ui-monospace, "Cascadia Mono", monospace; }
.title-field input:focus, .content-field textarea:focus { border-color: var(--cyan); }
.editor-preview { min-width: 0; height: 58vh; overflow: auto; padding: 16px; border: 1px solid var(--line); background: var(--surface-raised); }
.editor-preview > span, .content-field > span { color: var(--faint); font: 800 11px ui-monospace, monospace; letter-spacing: .08em; }
#preview-content { margin-top: 14px; font-size: 15px; }
#preview-content img { max-width: 100%; }
.editor-hint { color: var(--muted); font-size: 13px; }
.editor-error { min-height: 24px; color: var(--danger); }
.editor-actions { justify-content: flex-end; }

.image-dialog { width: min(96vw, 1500px); max-width: none; max-height: 94vh; padding: 48px 18px 18px; overflow: auto; border: 1px solid var(--line-strong); background: #050609; }
.image-dialog > button { position: fixed; top: calc(3vh + 8px); right: calc(2vw + 10px); z-index: 2; width: 38px; height: 38px; border: 1px solid #73788a; color: white; background: #11131c; font-size: 24px; }
.image-dialog img { display: block; max-width: 100%; max-height: calc(94vh - 70px); margin: 0 auto; object-fit: contain; }
.age-dialog { width: min(520px, calc(100% - 30px)); padding: 0; border: 1px solid var(--line-strong); background: var(--surface); }
.age-panel { padding: 34px; }
.age-mark { float: right; color: var(--accent); font: 900 46px ui-monospace, monospace; }
.age-panel h2 { margin: 10px 0; font-size: 28px; }
.age-panel > p:not(.eyebrow) { color: var(--muted); }
.age-panel > div { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 24px; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 90; padding: 11px 15px; border: 1px solid var(--line-strong); color: var(--text); background: var(--surface-raised); box-shadow: 5px 5px 0 var(--shadow); opacity: 0; transform: translateY(10px); pointer-events: none; transition: .18s ease; }
.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 980px) {
  .knowledge-header { align-items: flex-start; }
  .knowledge-brand small { display: none; }
  .header-actions a { display: none; }
  .knowledge-hero { grid-template-columns: 1fr; }
  .pixel-jasmine { min-height: 220px; border-top: 1px solid var(--line); border-left: 0; }
  .reading-grid { grid-template-columns: 1fr; }
  .knowledge-sidebar { z-index: 10; }
  .sidebar-panel { position: static; max-height: none; }
  #knowledge-toc { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .editor-layout { grid-template-columns: 1fr; }
  .editor-preview { height: auto; max-height: 42vh; }
}

@media (max-width: 620px) {
  :root { font-size: 15px; }
  .community-banner { display: grid; gap: 9px; min-height: 0; padding: 13px 14px 16px; }
  .community-banner::before { left: -18px; }
  .community-banner::after { right: -18px; }
  .community-invite { justify-self: center; }
  .community-invite span { display: none; }
  .community-invite strong { font-size: 22px; }
  .community-invite small { font-size: 12px; }
  .qq-copy-button { justify-self: stretch; justify-content: center; min-height: 58px; }
  .qq-copy-button b { font-size: clamp(24px, 8vw, 31px); }
  .knowledge-header { min-height: 60px; padding: 9px 14px; }
  .knowledge-brand strong { font-size: 14px; }
  .brand-flower { width: 34px; height: 34px; }
  .header-actions { gap: 4px; }
  .header-actions button { min-height: 36px; padding: 6px 8px; font-size: 12px; }
  .knowledge-shell { width: min(100% - 20px, 1380px); }
  .knowledge-hero { margin-top: 10px; box-shadow: 5px 5px 0 var(--shadow); }
  .hero-copy { padding: 30px 22px 36px; }
  .hero-copy h1 { font-size: 42px; }
  .pixel-jasmine { min-height: 180px; }
  .pixel-jasmine .moon { top: 26px; right: 36px; width: 100px; height: 100px; }
  .reading-grid { gap: 16px; margin-top: 28px; }
  .resource-jumpbar { grid-template-columns: 1fr; gap: 10px; }
  .resource-jumpbar a { grid-template-columns: 46px minmax(0, 1fr); padding: 14px; }
  .sidebar-panel { max-height: 48vh; overflow-y: auto; }
  #knowledge-toc { grid-template-columns: 1fr; }
  #knowledge-toc a[data-level="4"] { padding-left: 26px; }
  #knowledge-toc a[data-level="5"] { padding-left: 38px; }
  .knowledge-article { padding: 24px 20px; font-size: 17px; line-height: 1.85; box-shadow: 5px 5px 0 var(--shadow); }
  .knowledge-article h2 { margin-top: 58px; font-size: 28px; }
  .knowledge-article .resource-section-title { margin: 70px -8px 28px; padding: 24px 18px 22px 32px; font-size: 31px; }
  .knowledge-footer { flex-direction: column; padding: 22px 16px; }
  .editor-panel { padding: 16px; }
  .editor-head h2 { font-size: 20px; }
}
