:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --text: #1b1f24;
  --muted: #5d6673;
  --border: #dde1e6;
  --accent: #4f46e5;
  --accent-text: #ffffff;
  --accent-soft: #eceafd;
  --ok: #157f3b;
  --ok-soft: #e3f4e8;
  --warn: #9a5b00;
  --warn-soft: #fff3dc;
  --bad: #b42318;
  --bad-soft: #fde8e6;
  --code-bg: #fbfbfc;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1216; --surface: #171b21; --surface-2: #1f242c; --text: #e7eaee;
    --muted: #9aa4b1; --border: #2c333d; --accent: #8b85ff; --accent-text: #0f1216;
    --accent-soft: #25244a; --ok: #5fd28a; --ok-soft: #13301f; --warn: #f2b45a;
    --warn-soft: #33270f; --bad: #ff7b72; --bad-soft: #3a1714; --code-bg: #12161b;
    --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1216; --surface: #171b21; --surface-2: #1f242c; --text: #e7eaee;
  --muted: #9aa4b1; --border: #2c333d; --accent: #8b85ff; --accent-text: #0f1216;
  --accent-soft: #25244a; --ok: #5fd28a; --ok-soft: #13301f; --warn: #f2b45a;
  --warn-soft: #33270f; --bad: #ff7b72; --bad-soft: #3a1714; --code-bg: #12161b;
  --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
h1 { font-size: 26px; line-height: 1.25; margin: 0 0 6px; }
h2 { font-size: 18px; margin: 28px 0 10px; }
h3 { font-size: 15px; margin: 18px 0 8px; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }

/* header */
.top { background: var(--surface); border-bottom: 1px solid var(--border); }
.top .wrap { display: flex; align-items: center; gap: 18px; min-height: 58px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; color: var(--text); font-size: 17px; }
.brand:hover { text-decoration: none; }
.brand img { width: 26px; height: 26px; }
.top nav { display: flex; gap: 14px; align-items: center; margin-left: auto; flex-wrap: wrap; }
.top nav a { color: var(--muted); }
.top nav a:hover { color: var(--text); }
.top form { margin: 0; }
.linkbtn { background: none; border: 0; color: var(--muted); cursor: pointer; font: inherit; padding: 0; }
.linkbtn:hover { color: var(--text); }
.theme { background: none; border: 1px solid var(--border); border-radius: 8px; color: var(--muted); cursor: pointer; padding: 3px 8px; font: inherit; }

main { padding: 26px 0 60px; }
footer { border-top: 1px solid var(--border); color: var(--muted); font-size: 13px; padding: 18px 0 30px; }

/* hero */
.hero { padding: 18px 0 10px; }
.hero h1 { font-size: 30px; }
.hero p { color: var(--muted); max-width: 720px; margin: 4px 0 16px; }
.search { display: flex; gap: 8px; max-width: 720px; }
.search input { flex: 1; }

/* forms */
input[type=text], input[type=password], input[type=email], input[type=search], textarea, select {
  width: 100%; background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 9px 11px; font: inherit;
}
textarea { min-height: 120px; resize: vertical; }
textarea.code { min-height: 420px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; line-height: 1.5; tab-size: 2; white-space: pre; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
label { display: block; font-weight: 600; margin: 14px 0 5px; }
.hint { color: var(--muted); font-size: 13px; font-weight: 400; }
.btn {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); padding: 8px 14px; border-radius: 8px; cursor: pointer; font: inherit; font-weight: 600;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--bad); }
.btn.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.grow { flex: 1; }
.form-card { max-width: 440px; margin: 20px auto; }

/* cards and panels */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.card { display: flex; flex-direction: column; gap: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; color: var(--text); box-shadow: var(--shadow); min-width: 0; }
.card:hover { border-color: var(--accent); text-decoration: none; }
.card h3 { margin: 0; font-size: 16px; overflow-wrap: anywhere; }
.card p { margin: 0; color: var(--muted); font-size: 14px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card .foot { margin-top: auto; display: flex; gap: 14px; color: var(--muted); font-size: 13px; flex-wrap: wrap; }
.by { color: var(--muted); font-size: 13px; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 2px 10px; font-size: 12.5px; background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
a.chip:hover { text-decoration: none; border-color: var(--accent); }
.chip.ext { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.chip.tag::before { content: "#"; color: var(--muted); }
.badge { display: inline-block; border-radius: 6px; padding: 1px 7px; font-size: 12px; font-weight: 600; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.muted { background: var(--surface-2); color: var(--muted); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: 18px 0 14px; overflow-x: auto; }
.tabs a, .tabs button { padding: 8px 14px; color: var(--muted); border: 0; background: none; border-bottom: 2px solid transparent; font: inherit; cursor: pointer; white-space: nowrap; }
.tabs a.on, .tabs button.on { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.tabs a:hover { text-decoration: none; color: var(--text); }
.filters { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 6px 0 16px; }
.filters .chips { flex: 1; }

.notice { border-radius: 8px; padding: 10px 14px; margin: 0 0 16px; border: 1px solid transparent; }
.notice.info { background: var(--accent-soft); color: var(--text); }
.notice.ok { background: var(--ok-soft); color: var(--ok); }
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.notice.bad { background: var(--bad-soft); color: var(--bad); }

/* package page */
.pkg-head { display: flex; gap: 20px; align-items: flex-start; flex-wrap: wrap; }
.pkg-head .main { flex: 1; min-width: 260px; }
.stats { display: flex; gap: 22px; color: var(--muted); font-size: 14px; margin: 10px 0; flex-wrap: wrap; }
.stats b { color: var(--text); }
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 22px; }
@media (max-width: 860px) { .layout { grid-template-columns: minmax(0, 1fr); } }
.side .panel + .panel { margin-top: 14px; }
.side h3 { margin-top: 0; }
.kv { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 12px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.copyline { display: flex; gap: 6px; align-items: stretch; margin: 6px 0 12px; }
.copyline code { flex: 1; background: var(--code-bg); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; overflow-x: auto; white-space: nowrap; display: block; min-width: 0; }
.desc { font-size: 15.5px; max-width: 760px; }

.code-wrap { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--code-bg); }
.code-bar { display: flex; gap: 8px; align-items: center; padding: 8px 10px; border-bottom: 1px solid var(--border); background: var(--surface); flex-wrap: wrap; }
.code-bar .name { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; color: var(--muted); margin-right: auto; overflow-wrap: anywhere; }
.code-scroll { overflow: auto; max-height: 640px; }
.hl, .hl pre { background: transparent !important; margin: 0; }
.hl table { border-spacing: 0; width: 100%; }
.hl td.linenos { width: 1%; padding: 0 10px; color: var(--muted); user-select: none; text-align: right; border-right: 1px solid var(--border); background: var(--surface); }
.hl td.linenos .normal { color: var(--muted); background: transparent; }
.hl td.code { padding: 0 14px; }
.hl pre { line-height: 1.55; padding: 10px 0; font-size: 13px; }

table.list { width: 100%; border-collapse: collapse; font-size: 14px; }
table.list th, table.list td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.list th { color: var(--muted); font-weight: 600; font-size: 13px; }
.table-scroll { overflow-x: auto; }
.contents h3 { display: flex; gap: 8px; align-items: center; }
.contents ul { list-style: none; padding: 0; margin: 0 0 8px; display: grid; gap: 4px; }
.contents li { display: flex; gap: 8px; justify-content: space-between; border-bottom: 1px dashed var(--border); padding: 3px 0; font-size: 14px; }
.contents li span:first-child { overflow-wrap: anywhere; }
.contents li .type { color: var(--muted); white-space: nowrap; }

.diagram { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; margin-bottom: 14px; overflow-x: auto; }
.diagram h3 { margin: 0 0 8px; }
.diagram .mermaid-out { text-align: center; }
.diagram .mermaid-out svg { max-width: 100%; height: auto; min-width: min(100%, 560px); }
.diagram .legend { color: var(--muted); font-size: 12.5px; margin-top: 6px; }

.hidden { display: none !important; }
.pager { display: flex; gap: 8px; justify-content: center; margin-top: 22px; }
.empty { text-align: center; color: var(--muted); padding: 50px 10px; }
details.danger summary { cursor: pointer; color: var(--bad); font-weight: 600; }
.token-box { background: var(--ok-soft); border: 1px solid var(--ok); border-radius: 8px; padding: 12px; margin-bottom: 16px; }
.steps { counter-reset: s; padding-left: 0; list-style: none; }
.steps > li { counter-increment: s; position: relative; padding-left: 38px; margin-bottom: 18px; }
.steps > li::before { content: counter(s); position: absolute; left: 0; top: 0; width: 26px; height: 26px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 700; font-size: 13px; }
pre.block { background: var(--code-bg); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; overflow-x: auto; }
