:root {
  color-scheme: light;
  --bg: #f5f5f5;
  --surface: #ffffff;
  --surface-muted: #f7f7f7;
  --text: #24292f;
  --text-muted: #66707a;
  --text-light: #8b949e;
  --border: #d8dee4;
  --border-dark: #c5ccd3;
  --link: #4078c0;
  --link-hover: #275f9e;
  --green: #609926;
  --green-dark: #4f8120;
  --green-soft: #eef6e8;
  --yellow: #9a6700;
  --yellow-soft: #fff8c5;
  --yellow-border: #e7d58a;
  --red: #cf222e;
  --red-soft: #ffebe9;
  --code: #f6f8fa;
  --header: #fafafa;
  --nav-hover: #eeeeee;
  --row-hover: #fafbfc;
  --badge: #e9ecef;
  --inline-code: #eff1f3;
  --code-hover: #eef1f4;
  --focus: #87a9d8;
  --focus-ring: rgba(64, 120, 192, .12);
  --green-border: #a8c58c;
  --blockquote-border: #b5bdc5;
  --line-number: #8c959f;
  --icon-bg: #ffffff;
  --on-strong: #ffffff;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Monaco, Consolas, "Liberation Mono", "Noto Sans Mono CJK SC", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #17191c;
  --surface: #222427;
  --surface-muted: #282b2f;
  --text: #e2e5e9;
  --text-muted: #a9b0b8;
  --text-light: #7f8893;
  --border: #3a3e44;
  --border-dark: #4a5058;
  --link: #70a8e2;
  --link-hover: #91bee9;
  --green: #7da95a;
  --green-dark: #9bc47a;
  --green-soft: #26351f;
  --yellow: #e0aa45;
  --yellow-soft: #3a301b;
  --yellow-border: #6f5a2b;
  --red: #f07178;
  --red-soft: #3b2326;
  --code: #191b1e;
  --header: #1d1f22;
  --nav-hover: #2b2e32;
  --row-hover: #26292d;
  --badge: #30343a;
  --inline-code: #30343a;
  --code-hover: #24272b;
  --focus: #6697c8;
  --focus-ring: rgba(112, 168, 226, .18);
  --green-border: #557741;
  --blockquote-border: #59616a;
  --line-number: #68717c;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #17191c;
    --surface: #222427;
    --surface-muted: #282b2f;
    --text: #e2e5e9;
    --text-muted: #a9b0b8;
    --text-light: #7f8893;
    --border: #3a3e44;
    --border-dark: #4a5058;
    --link: #70a8e2;
    --link-hover: #91bee9;
    --green: #7da95a;
    --green-dark: #9bc47a;
    --green-soft: #26351f;
    --yellow: #e0aa45;
    --yellow-soft: #3a301b;
    --yellow-border: #6f5a2b;
    --red: #f07178;
    --red-soft: #3b2326;
    --code: #191b1e;
    --header: #1d1f22;
    --nav-hover: #2b2e32;
    --row-hover: #26292d;
    --badge: #30343a;
    --inline-code: #30343a;
    --code-hover: #24272b;
    --focus: #6697c8;
    --focus-ring: rgba(112, 168, 226, .18);
    --green-border: #557741;
    --blockquote-border: #59616a;
    --line-number: #68717c;
  }
}

* { box-sizing: border-box; }

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

body {
  min-width: 320px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.6;
}

main { flex: 1 0 auto; }

button, input, select { font: inherit; }
button { color: inherit; }
a { color: inherit; text-decoration: none; }

.shell {
  width: min(1100px, calc(100% - 32px));
  margin-inline: auto;
}

.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;
}

.clipboard-helper {
  position: fixed;
  inset: 0 auto auto 0;
  opacity: 0;
  pointer-events: none;
}

.skip-link {
  position: fixed;
  top: -60px;
  left: 12px;
  z-index: 100;
  padding: 8px 12px;
  border-radius: 3px;
  background: var(--text);
  color: var(--on-strong);
}
.skip-link:focus { top: 8px; }

/* 顶部栏保持紧凑，接近常见代码托管平台的工具导航。 */
.site-header {
  height: 54px;
  border-bottom: 1px solid var(--border);
  background: var(--header);
}

.header-inner,
.footer-inner {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-weight: 600;
}

.brand-mark {
  display: grid;
  width: 27px;
  height: 27px;
  place-items: center;
  border-radius: 3px;
  background: var(--green);
  color: var(--on-strong);
  font-family: var(--mono);
  font-size: 10px;
}

.header-actions {
  height: 100%;
  display: flex;
  align-items: center;
  gap: 4px;
}

.header-actions a {
  height: 100%;
  display: flex;
  align-items: center;
  padding: 0 12px;
  color: var(--text-muted);
  font-size: 13px;
}
.header-actions a:hover,
.header-actions a.is-active { color: var(--text); background: var(--nav-hover); }

.theme-toggle {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  margin-left: 5px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
}
.theme-toggle:hover { border-color: var(--border-dark); background: var(--surface-muted); color: var(--text); }
.theme-toggle span { font-size: 16px; line-height: 1; }

/* 首页直接进入脚本库，不设置营销首屏。 */
.library-section { padding-block: 30px 56px; }

.page-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.page-heading h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.35;
  font-weight: 600;
}
.page-heading p { margin: 4px 0 0; color: var(--text-muted); }

.script-count {
  margin-top: 5px;
  padding: 3px 9px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 12px;
  white-space: nowrap;
}

.search-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 180px;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--border);
  border-bottom: 0;
  border-radius: 4px 4px 0 0;
  background: var(--surface-muted);
}

.search-box {
  height: 36px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding-inline: 10px;
  border: 1px solid var(--border-dark);
  border-radius: 3px;
  background: var(--surface);
}
.search-box:focus-within { border-color: var(--focus); box-shadow: 0 0 0 2px var(--focus-ring); }
.search-box > span:not(.sr-only) { color: var(--text-light); font-size: 17px; }
.search-box input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--text); }
.search-box input::placeholder { color: var(--text-light); }

.select-box select {
  width: 100%;
  height: 36px;
  padding: 0 9px;
  border: 1px solid var(--border-dark);
  border-radius: 3px;
  outline: 0;
  background: var(--surface);
  color: var(--text);
}
.select-box select:focus { border-color: var(--focus); }

.tag-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 9px 12px;
  border-inline: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.filter-chip,
.tag {
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--surface-muted);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 11px;
}
.filter-chip { padding: 3px 9px; }
.tag { padding: 1px 7px; }
.filter-chip:hover,
.filter-chip.is-active,
.tag:hover { border-color: var(--green-border); background: var(--green-soft); color: var(--green-dark); }

.script-list {
  overflow: hidden;
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
}

.script-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 24px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}
.script-row:last-child { border-bottom: 0; }
.script-row:hover { background: var(--row-hover); }

.script-main { min-width: 0; }
.script-main h3 { margin: 0 0 3px; font-size: 15px; line-height: 1.4; font-weight: 600; }
.script-main h3 a { color: var(--link); }
.script-main h3 a:hover { color: var(--link-hover); text-decoration: underline; }
.script-main p { margin: 0; color: var(--text-muted); font-size: 13px; }
.tag-row { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 9px; }

.script-meta {
  display: grid;
  grid-template-columns: minmax(88px, 1fr) 86px 48px;
  align-items: center;
  justify-content: end;
  gap: 8px;
  color: var(--text-light);
  font-size: 11px;
}

.os-preview {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.os-icons {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
}

.os-icons img {
  width: 20px;
  height: 20px;
  margin-left: -4px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--icon-bg);
  object-fit: contain;
}
.os-icons img:first-child { margin-left: 0; }
.os-icons > span {
  min-width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  margin-left: -4px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface-muted);
  color: var(--text-muted);
  font-size: 9px;
}

.detail-link {
  padding: 3px 8px;
  border: 1px solid var(--border-dark);
  border-radius: 3px;
  background: var(--surface-muted);
  color: var(--text);
  text-align: center;
}
.detail-link:hover { border-color: var(--green-border); background: var(--green-soft); color: var(--green-dark); }

.empty-state {
  padding: 60px 20px;
  text-align: center;
  color: var(--text-muted);
}
.empty-state > span { color: var(--text-light); font-size: 30px; }
.empty-state h3 { margin: 5px 0 2px; color: var(--text); font-size: 16px; }
.empty-state p { margin: 0 0 16px; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 11px;
  border: 1px solid var(--border-dark);
  border-radius: 3px;
  background: var(--surface-muted);
  cursor: pointer;
  font-weight: 500;
}
.button.primary { border-color: var(--green-dark); background: var(--green); color: var(--on-strong); }
.button.primary:hover { background: var(--green-dark); }

/* 详情页沿用同一套浅色工具界面。 */
.detail-page { padding-block: 24px 56px; }

.breadcrumb {
  display: flex;
  gap: 7px;
  margin-bottom: 18px;
  color: var(--text-light);
  font-size: 12px;
}
.breadcrumb a { color: var(--link); }
.breadcrumb a:hover { text-decoration: underline; }

.detail-header {
  padding: 0 2px 18px;
}
.detail-header h1 { margin: 0 0 3px; font-size: 25px; line-height: 1.35; font-weight: 600; }
.detail-header p { max-width: 760px; margin: 0; color: var(--text-muted); }

.detail-tabs {
  display: flex;
  gap: 22px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--border);
}
.detail-tabs button {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 2px;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-weight: 500;
}
.detail-tabs button::after { content: ""; position: absolute; right: 0; bottom: -1px; left: 0; height: 2px; background: transparent; }
.detail-tabs button:hover { color: var(--text); }
.detail-tabs button.is-active { color: var(--text); font-weight: 600; }
.detail-tabs button.is-active::after { background: var(--green); }
.detail-tabs button span { min-width: 18px; padding-inline: 5px; border-radius: 9px; background: var(--badge); color: var(--text-muted); font-size: 10px; text-align: center; }

.overview-layout { display: grid; grid-template-columns: minmax(0, 1fr) 290px; gap: 18px; align-items: start; }
.info-sidebar { position: sticky; top: 16px; display: flex; flex-direction: column; gap: 10px; }
.info-card { padding: 14px; border: 1px solid var(--border); border-radius: 4px; background: var(--surface); }
.info-card h3 { display: flex; align-items: center; gap: 7px; margin: 0 0 9px; font-size: 13px; font-weight: 600; }
.info-card > p { margin: 0; color: var(--text-muted); font-size: 12px; }
.risk-card { border-left-width: 3px; }
.risk-card.safe { border-left-color: var(--green); background: var(--green-soft); }
.risk-card.warning { border-left-color: var(--yellow); background: var(--yellow-soft); }
.risk-card.danger { border-left-color: var(--red); background: var(--red-soft); }
.risk-icon { flex: 0 0 19px; height: 19px; display: grid; place-items: center; border: 1px solid currentColor; border-radius: 50%; font-size: 11px; font-weight: 700; }
.risk-card.safe .risk-icon { color: var(--green-dark); }
.risk-card.warning .risk-icon { color: var(--yellow); }
.risk-card.danger .risk-icon { color: var(--red); }
.info-os-list { display: flex; flex-direction: column; gap: 7px; margin: 0; padding: 0; list-style: none; }
.info-os-list li { min-width: 0; display: flex; align-items: center; gap: 9px; color: var(--text-muted); font-size: 12px; }
.info-os-list img,
.os-placeholder { width: 20px; height: 20px; flex: 0 0 20px; object-fit: contain; }
.info-os-list img { padding: 1px; border-radius: 3px; background: var(--icon-bg); }
.os-placeholder { display: block; border: 1px solid var(--border); border-radius: 50%; background: var(--surface-muted); }
.facts-card dl { margin: 0; }
.facts-card dl div { display: flex; justify-content: space-between; gap: 14px; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 11px; }
.facts-card dl div:last-child { border-bottom: 0; padding-bottom: 0; }
.facts-card dt { color: var(--text-light); }
.facts-card dd { margin: 0; color: var(--text); text-align: right; }
.execute-card > p { margin-bottom: 10px; }

.markdown-body { min-width: 0; padding: 22px 24px; border: 1px solid var(--border); border-radius: 4px; background: var(--surface); color: var(--text-muted); }
.markdown-body > :first-child { margin-top: 0; }
.markdown-body h1,
.markdown-body h2,
.markdown-body h3 { color: var(--text); line-height: 1.35; font-weight: 600; }
.markdown-body h1 { margin: 0 0 18px; font-size: 24px; }
.markdown-body h2 { margin: 32px 0 12px; padding-bottom: 7px; border-bottom: 1px solid var(--border); font-size: 19px; }
.markdown-body h3 { margin: 22px 0 8px; font-size: 15px; }
.markdown-body p,
.markdown-body ul,
.markdown-body ol { margin-block: 0 14px; }
.markdown-body a { color: var(--link); text-decoration: underline; text-underline-offset: 2px; }
.markdown-body code { padding: 2px 4px; border-radius: 3px; background: var(--inline-code); color: var(--text); font-family: var(--mono); font-size: .88em; }
.markdown-body pre { overflow: auto; margin: 16px 0; padding: 14px; border: 1px solid var(--border); border-radius: 3px; background: var(--code); }
.markdown-body pre code { padding: 0; background: transparent; color: var(--text); }
.markdown-body blockquote { margin: 16px 0; padding: 7px 12px; border-left: 3px solid var(--blockquote-border); background: var(--surface-muted); color: var(--text); }
.markdown-body table { width: 100%; margin: 16px 0; border-collapse: collapse; font-size: 12px; }
.markdown-body th,
.markdown-body td { padding: 7px 9px; border: 1px solid var(--border); text-align: left; }
.markdown-body th { background: var(--surface-muted); color: var(--text); }
.markdown-body img { max-width: 100%; }

.mini-command { overflow: hidden; border: 1px solid var(--border); border-radius: 3px; background: var(--code); }
.mini-command code { display: block; max-height: 90px; overflow: auto; padding: 10px; color: var(--text); font-family: var(--mono); font-size: 10px; line-height: 1.55; word-break: break-all; }
.mini-command button,
.source-toolbar button { border: 0; background: transparent; cursor: pointer; font-size: 11px; }
.mini-command button { width: 100%; padding: 6px; border-top: 1px solid var(--border); color: var(--link); }
.mini-command button:hover { background: var(--code-hover); color: var(--link-hover); }

.files-layout { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 12px; align-items: start; }
.file-list { overflow: hidden; border: 1px solid var(--border); border-radius: 4px; background: var(--surface); }
.file-list-heading { display: flex; justify-content: space-between; padding: 10px 12px; border-bottom: 1px solid var(--border); background: var(--surface-muted); font-size: 12px; font-weight: 600; }
.file-list-heading span { color: var(--text-light); font-weight: 400; }
.file-item { width: 100%; display: flex; align-items: flex-start; gap: 9px; padding: 10px 12px; border: 0; border-bottom: 1px solid var(--border); background: var(--surface); color: var(--text); text-align: left; cursor: pointer; }
.file-item:last-child { border-bottom: 0; }
.file-item:hover { background: var(--surface-muted); }
.file-item.is-active { background: var(--green-soft); box-shadow: inset 2px 0 var(--green); }
.file-item > span:last-child { min-width: 0; display: flex; flex-direction: column; }
.file-item strong { overflow: hidden; font-family: var(--mono); font-size: 11px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.file-item small { overflow: hidden; margin-top: 2px; color: var(--text-light); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.file-icon { color: var(--text-light); font-family: var(--mono); font-size: 10px; }
.file-viewer { min-width: 0; overflow: hidden; border: 1px solid var(--border); border-radius: 4px; background: var(--surface); }
.file-loading,
.file-error { min-height: 300px; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--text-light); text-align: center; }
.file-error strong { color: var(--red); }
.file-error p { margin: 3px 0 0; }
.source-toolbar { min-height: 42px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 13px; border-bottom: 1px solid var(--border); background: var(--surface-muted); color: var(--text-light); font-family: var(--mono); font-size: 10px; }
.source-toolbar > div { display: flex; align-items: center; gap: 10px; }
.source-toolbar strong { color: var(--text); font-weight: 500; }
.source-toolbar button,
.source-toolbar a { color: var(--link); }
.source-toolbar button:hover,
.source-toolbar a:hover { color: var(--link-hover); }
.source-view { max-height: 700px; overflow: auto; margin: 0; padding: 8px 0; background: var(--code); color: var(--text); font-family: var(--mono); font-size: 12px; font-weight: 400; line-height: 20px; font-variant-ligatures: none; tab-size: 4; }
.source-view code { display: block; min-width: max-content; }
.source-line { display: flex; height: 20px; }
.source-line:hover { background: var(--code-hover); }
.line-number { flex: 0 0 48px; padding: 0 12px 0 8px; color: var(--line-number); text-align: right; user-select: none; }
.line-code { flex: 1; padding-right: 16px; white-space: pre; }

.loading-page,
.detail-loading,
.status-page { min-height: 60vh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; color: var(--text-muted); }
.loading-mark { width: 20px; height: 20px; border: 2px solid var(--border-dark); border-top-color: var(--green); border-radius: 50%; animation: spin .8s linear infinite; }
.status-page h1 { margin: 6px 0 3px; font-size: 24px; }
.status-page p { margin: 0 0 18px; }
.status-code { color: var(--red); font-family: var(--mono); font-size: 12px; font-weight: 700; }
.dependency-error { margin-bottom: 16px; padding: 10px; border: 1px solid var(--yellow-border); border-radius: 3px; background: var(--yellow-soft); color: var(--yellow); }

.toast { position: fixed; left: 50%; bottom: 20px; z-index: 100; padding: 7px 12px; border-radius: 3px; background: var(--text); color: var(--bg); font-size: 12px; opacity: 0; transform: translate(-50%, 8px); pointer-events: none; transition: 140ms ease; }
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

.site-footer { height: 62px; flex: 0 0 auto; border-top: 1px solid var(--border); background: var(--header); color: var(--text-light); font-size: 11px; }

@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 820px) {
  .script-row { grid-template-columns: 1fr; gap: 12px; }
  .script-meta { grid-template-columns: minmax(88px, 1fr) 86px 48px; justify-content: start; }
  .overview-layout { grid-template-columns: 1fr; }
  .info-sidebar { position: static; display: grid; grid-template-columns: 1fr 1fr; align-items: start; }
  .files-layout { grid-template-columns: 190px minmax(0, 1fr); }
}

@media (max-width: 580px) {
  .shell { width: min(100% - 20px, 1100px); }
  .brand span:last-child { font-size: 13px; }
  .header-actions a { padding-inline: 8px; }
  .header-actions a:last-child { display: none; }
  .library-section { padding-top: 20px; }
  .page-heading { align-items: center; }
  .page-heading h1 { font-size: 21px; }
  .page-heading p { font-size: 12px; }
  .search-panel { grid-template-columns: 1fr; }
  .script-row { padding: 14px; }
  .script-meta { grid-template-columns: 1fr 1fr; gap: 8px 14px; }
  .detail-page { padding-top: 18px; }
  .detail-tabs { gap: 18px; }
  .info-sidebar { grid-template-columns: 1fr; }
  .files-layout { grid-template-columns: 1fr; }
  .file-list { display: flex; overflow-x: auto; }
  .file-list-heading { display: none; }
  .file-item { min-width: 170px; border-right: 1px solid var(--border); border-bottom: 0; }
  .markdown-body { padding: 17px 15px; }
  .source-toolbar { align-items: flex-start; flex-direction: column; padding-block: 8px; }
  .footer-inner { flex-direction: column; justify-content: center; gap: 1px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
