/* NekoToon docs: neon purple, dark by default, light via toggle or system */
:root {
  --bg: #120d1c; --bg2: #1a1428; --panel: #211932; --panel2: #2a2040; --line: #3a2d55;
  --text: #ece4ff; --muted: #b3a5d3; --accent: #b77bff; --accent2: #ff8ad8; --link: #cfa6ff;
  --code-bg: #1d1530; --tip: #2b8a5f; --note: #7b55d6; --warn: #c9822a;
  --glow: 0 0 0 1px rgba(183,123,255,.35), 0 0 18px rgba(183,123,255,.18);
  --radius: 10px; --mono: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #faf7ff; --bg2: #f2ecfd; --panel: #ffffff; --panel2: #f4eefe; --line: #e0d5f5;
    --text: #231a36; --muted: #685a85; --accent: #7a3fe0; --accent2: #d4409d; --link: #6a2fd0;
    --code-bg: #f1eafd; --glow: 0 0 0 1px rgba(122,63,224,.25); color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: #faf7ff; --bg2: #f2ecfd; --panel: #ffffff; --panel2: #f4eefe; --line: #e0d5f5;
  --text: #231a36; --muted: #685a85; --accent: #7a3fe0; --accent2: #d4409d; --link: #6a2fd0;
  --code-bg: #f1eafd; --glow: 0 0 0 1px rgba(122,63,224,.25); color-scheme: light;
}

* { box-sizing: border-box; }
html { scroll-padding-top: 76px; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.65 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif; }
a { color: var(--link); text-underline-offset: 2px; }
a:hover { color: var(--accent2); }
img { max-width: 100%; height: auto; }
.skip { position: absolute; left: -999px; } .skip:focus { left: 12px; top: 12px; z-index: 50; background: var(--panel); padding: 8px 12px; }

/* top bar */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 14px; height: 60px; padding: 0 16px;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--text); font-weight: 700; }
.brand img { display: block; height: 34px; width: auto; filter: drop-shadow(0 0 6px rgba(183,123,255,.35)); }
.brand span { font-size: 15px; color: var(--muted); }
.search { position: relative; flex: 1; max-width: 460px; margin-left: auto; display: flex; align-items: center; gap: 8px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 0 12px; color: var(--muted); }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; font-size: 14px; height: 36px; }
.search:focus-within { box-shadow: var(--glow); border-color: var(--accent); }
#search-results { position: absolute; top: 42px; left: 0; right: 0; margin: 0; padding: 6px; list-style: none; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 12px 30px rgba(0,0,0,.35); max-height: 70vh; overflow: auto; }
#search-results a { display: block; padding: 8px 10px; border-radius: 8px; text-decoration: none; color: var(--text); }
#search-results a small { display: block; color: var(--muted); font-size: 12.5px; }
#search-results a:hover, #search-results a.sel { background: var(--panel2); }
#search-results mark { background: none; color: var(--accent2); font-weight: 600; }
.theme-btn, .menu-btn { background: none; border: 1px solid var(--line); color: var(--text); border-radius: 8px; height: 36px; width: 36px; display: grid; place-items: center; cursor: pointer; }
.theme-btn:hover, .menu-btn:hover { border-color: var(--accent); }
.menu-btn { display: none; }
.gh { text-decoration: none; font-weight: 600; font-size: 14px; padding: 7px 14px; border-radius: 999px; color: #fff;
  background: linear-gradient(135deg, #8b4dff, #d4409d); box-shadow: 0 0 14px rgba(183,123,255,.35); white-space: nowrap; }
.gh:hover { color: #fff; filter: brightness(1.1); }

/* layout */
.shell { display: grid; grid-template-columns: 260px minmax(0, 1fr) 220px; max-width: 1400px; margin: 0 auto; }
.sidebar { position: sticky; top: 60px; height: calc(100vh - 60px); overflow: auto; padding: 18px 12px 40px; border-right: 1px solid var(--line); }
.nav-group summary { cursor: pointer; list-style: none; font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: 10px 10px 6px; }
.nav-group summary::-webkit-details-marker { display: none; }
.nav-group summary::before { content: "▸"; display: inline-block; width: 14px; transition: transform .15s; }
.nav-group[open] summary::before { transform: rotate(90deg); }
.nav-group ul { list-style: none; margin: 0 0 6px; padding: 0; }
.nav-group a { display: block; padding: 5px 10px 5px 24px; border-radius: 8px; color: var(--text); text-decoration: none; font-size: 14.5px; }
.nav-group a:hover { background: var(--panel); }
.nav-group a.active { background: linear-gradient(90deg, rgba(139,77,255,.32), rgba(139,77,255,.08)); color: var(--text); box-shadow: inset 3px 0 0 var(--accent); font-weight: 600; }
.content { min-width: 0; padding: 26px 40px 40px; }
.crumb { margin: 0 0 4px; color: var(--accent); font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.toc { position: sticky; top: 60px; height: calc(100vh - 60px); overflow: auto; padding: 26px 16px; font-size: 13.5px; }
.toc.empty { visibility: hidden; }
.toc p { margin: 0 0 8px; font-weight: 700; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.toc ul { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--line); }
.toc a { display: block; padding: 3px 0 3px 12px; color: var(--muted); text-decoration: none; margin-left: -1px; border-left: 2px solid transparent; }
.toc a:hover, .toc a.current { color: var(--text); border-left-color: var(--accent); }

/* article */
.doc { max-width: 820px; }
.doc h1 { font-size: 2.1rem; line-height: 1.2; margin: 0 0 12px; background: linear-gradient(90deg, var(--text), var(--accent)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.doc h2 { font-size: 1.45rem; margin: 2.2em 0 .6em; padding-bottom: .3em; border-bottom: 1px solid var(--line); }
.doc h3 { font-size: 1.12rem; margin: 1.8em 0 .4em; }
.doc h2 .anchor, .doc h3 .anchor { margin-left: 8px; color: var(--muted); text-decoration: none; opacity: 0; font-weight: 400; }
.doc h2:hover .anchor, .doc h3:hover .anchor { opacity: .8; }
.doc .lead { font-size: 1.1rem; color: var(--muted); margin-top: 0; }
.doc code { font-family: var(--mono); font-size: .88em; background: var(--code-bg); border: 1px solid var(--line); border-radius: 5px; padding: .1em .35em; }
.doc pre { background: var(--code-bg); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; overflow: auto; }
.doc pre code { background: none; border: 0; padding: 0; }
.doc table { width: 100%; border-collapse: collapse; margin: 1em 0; font-size: .95em; display: block; overflow-x: auto; }
.doc th, .doc td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.doc th { color: var(--muted); font-weight: 600; font-size: .9em; }
.doc kbd { font-family: var(--mono); font-size: .85em; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 .35em; background: var(--panel); }
.doc .path { font-weight: 600; color: var(--text); }
.doc ol li, .doc ul li { margin: .25em 0; }

/* setting entries (reference pages) */
.setting { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px 6px; margin: 14px 0; }
.setting:target { box-shadow: var(--glow); border-color: var(--accent); }
.setting h3 { margin: 0 0 2px; font-size: 1.05rem; }
.setting .prop { margin: 0 0 6px; font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; }
.setting .prop code { font-size: 12.5px; }
.setting p { margin: .4em 0 .6em; }

/* callouts */
.tip, .note, .warn { border-radius: var(--radius); padding: 10px 14px; margin: 16px 0; border: 1px solid; }
.tip  { border-color: color-mix(in srgb, var(--tip) 60%, transparent);  background: color-mix(in srgb, var(--tip) 14%, transparent); }
.note { border-color: color-mix(in srgb, var(--note) 60%, transparent); background: color-mix(in srgb, var(--note) 14%, transparent); }
.warn { border-color: color-mix(in srgb, var(--warn) 60%, transparent); background: color-mix(in srgb, var(--warn) 14%, transparent); }
.tip::before  { content: "Tip"; }
.note::before { content: "Note"; }
.warn::before { content: "Careful"; }
.tip::before, .note::before, .warn::before { display: block; font-weight: 700; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; margin-bottom: 2px; color: var(--muted); }
.tip p:last-child, .note p:last-child, .warn p:last-child { margin-bottom: 0; }

/* cards (home) */
.hero { border-radius: 16px; overflow: hidden; border: 1px solid var(--line); box-shadow: var(--glow); margin: 4px 0 22px; }
.hero img { display: block; width: 100%; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; margin: 18px 0; }
.cards a { display: block; padding: 14px 16px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line); text-decoration: none; color: var(--text); }
.cards a:hover { border-color: var(--accent); box-shadow: var(--glow); }
.cards a strong { display: block; margin-bottom: 2px; }
.cards a span { color: var(--muted); font-size: 14px; }
.steps { counter-reset: step; list-style: none; padding: 0; }
.steps > li { counter-increment: step; position: relative; padding-left: 42px; margin: 14px 0; }
.steps > li::before { content: counter(step); position: absolute; left: 0; top: 0; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 700; font-size: 14px; color: #fff; background: linear-gradient(135deg, #8b4dff, #d4409d); }

/* pager + footer */
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; max-width: 820px; margin: 48px 0 0; }
.pager a { display: block; padding: 12px 16px; border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; color: var(--text); background: var(--panel); }
.pager a:hover { border-color: var(--accent); }
.pager a span { display: block; font-size: 12px; color: var(--muted); }
.pager .next { grid-column: 2; text-align: right; }
.footer { max-width: 820px; margin-top: 40px; padding-top: 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }

/* responsive */
@media (max-width: 1180px) { .shell { grid-template-columns: 240px minmax(0,1fr); } .toc { display: none; } }
@media (max-width: 820px) {
  .shell { grid-template-columns: minmax(0,1fr); }
  .menu-btn { display: grid; }
  .sidebar { position: fixed; top: 60px; left: 0; width: min(300px, 86vw); background: var(--bg2); z-index: 15; transform: translateX(-105%); transition: transform .2s; box-shadow: 8px 0 30px rgba(0,0,0,.35); }
  body.nav-open .sidebar { transform: none; }
  .content { padding: 20px 16px 40px; }
  .brand span, .gh { display: none; }
  .search { max-width: none; }
  .doc h1 { font-size: 1.7rem; }
}
