/* ============================================
   SDK 中心 — GitHub Releases + 目录树
   ============================================ */

:root {
  --bg: #ffffff;
  --bg-subtle: #f6f8fa;
  --bg-canvas-inset: #eaeef2;
  --border-default: #d1d9e0;
  --border-muted: #d8dee4;
  --fg-default: #1f2328;
  --fg-muted: #59636e;
  --fg-subtle: #6e7781;
  --accent-fg: #0969da;
  --accent-emphasis: #0550ae;
  --accent-subtle: #ddf4ff;
  --success-fg: #1a7f37;
  --success-emphasis: #1f883d;
  --success-subtle: #dafbe1;
  --success-border: #aceebb;
  --neutral-subtle: #eaeef2;
  --neutral-emphasis: #6e7781;

  --font-system: -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Noto Sans", "PingFang SC", "Microsoft YaHei", Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;

  --radius: 6px;
  --shadow-sm: 0 1px 0 rgba(31, 35, 40, 0.04);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg-default);
  font-family: var(--font-system);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-fg); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; }
::selection { background: rgba(9, 105, 218, 0.18); }

/* ============================================
   Header
   ============================================ */
.site-header {
  background: var(--bg);
  border-bottom: 1px solid var(--border-default);
  position: sticky;
  top: 0;
  z-index: 20;
}
.site-header-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 24px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--fg-default);
}
.brand-name { font-weight: 600; font-size: 15px; }
.header-nav { display: flex; gap: 4px; margin-left: 12px; height: 100%; align-items: stretch; }
.header-nav-item {
  display: flex;
  align-items: center;
  padding: 0 12px;
  font-size: 14px;
  color: var(--fg-muted);
  border-bottom: 2px solid transparent;
  margin-top: 2px;
}
.header-nav-item.active {
  color: var(--fg-default);
  font-weight: 600;
  border-bottom-color: #fd8c73;
}

/* ============================================
   Layout
   ============================================ */
.layout {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px;
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 24px;
  align-items: start;
}

/* ============================================
   Sidebar — 目录树
   ============================================ */
.sidebar { position: sticky; top: 80px; }
.sidebar-inner {
  background: var(--bg);
  border: 1px solid var(--border-default);
  border-radius: var(--radius);
  overflow: hidden;
}
.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-muted);
  background: var(--bg-subtle);
}
.sidebar-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--fg-default);
  letter-spacing: 0.02em;
}

.sidebar-tree {
  padding: 8px 4px 12px;
  max-height: calc(100vh - 200px);
  overflow-y: auto;
}

/* Tree row (shared by folder summary and leaf) */
.tree-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  user-select: none;
  font-size: 14px;
  color: var(--fg-default);
  position: relative;
  width: 100%;
  background: transparent;
  border: 0;
  text-align: left;
  font-family: inherit;
  line-height: 1.4;
}
.tree-row:hover { background: var(--bg-subtle); }

.tree-caret {
  width: 14px;
  height: 14px;
  flex: 0 0 14px;
  color: var(--fg-muted);
  transition: transform 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.tree-caret-spacer {
  width: 14px;
  flex: 0 0 14px;
}
details[open] > .tree-row > .tree-caret { transform: rotate(90deg); }

.tree-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Folder summary (details > summary) */
details.tree-folder { margin: 0; }
details.tree-folder > summary { list-style: none; }
details.tree-folder > summary::-webkit-details-marker { display: none; }
details.tree-folder > summary.tree-row {
  font-weight: 500;
}

/* Folder children container — uses left guide line */
.tree-children {
  margin-left: 14px;
  padding-left: 10px;
  border-left: 1px solid var(--border-muted);
  margin-top: 2px;
}

/* Active leaf */
.tree-row.active {
  background: var(--accent-subtle);
  color: var(--accent-emphasis);
  font-weight: 600;
}
.tree-row.active::before {
  content: "";
  position: absolute;
  left: -4px;
  top: 4px;
  bottom: 4px;
  width: 3px;
  border-radius: 2px;
  background: var(--accent-fg);
}

/* Leaf bullet (small dot before label) */
.tree-row.leaf .tree-caret-spacer::after {
  content: "";
  display: block;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--fg-muted);
  margin: 0 auto;
  opacity: 0.5;
}
.tree-row.leaf.active .tree-caret-spacer::after {
  background: var(--accent-fg);
  opacity: 1;
}

/* Version count meta */
.tree-meta {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--fg-muted);
  margin-left: 4px;
  padding: 1px 6px;
  background: var(--bg-subtle);
  border-radius: 999px;
  flex: 0 0 auto;
}
.tree-row.active .tree-meta {
  background: rgba(9, 105, 218, 0.1);
  color: var(--accent-emphasis);
}

/* ============================================
   Content
   ============================================ */
.content { min-width: 0; }
.content-inner { display: flex; flex-direction: column; gap: 16px; }

.breadcrumb {
  font-size: 14px;
  color: var(--fg-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}
.breadcrumb .sep { color: var(--border-default); }
.breadcrumb .current { color: var(--fg-default); font-weight: 600; }

.repo-header {
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-muted);
}
.repo-title {
  font-size: 26px;
  font-weight: 600;
  margin: 0 0 4px;
  letter-spacing: -0.01em;
}
.repo-desc {
  margin: 0;
  color: var(--fg-muted);
  font-size: 14px;
}
.repo-meta {
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 13px;
  color: var(--fg-muted);
  flex-wrap: wrap;
}
.repo-meta-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.repo-meta-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--accent-fg);
}

/* ============================================
   Releases (GitHub-style)
   ============================================ */
.releases { display: flex; flex-direction: column; }

.release {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 24px;
  padding: 24px 0;
  border-bottom: 1px solid var(--border-muted);
  animation: fadeIn 0.3s ease;
}
.release:last-child { border-bottom: 0; }
.release:first-child { padding-top: 12px; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.release-aside {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 6px;
}
.release-tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--fg-muted);
  background: var(--bg-subtle);
  border: 1px solid var(--border-default);
  border-radius: 999px;
  align-self: flex-start;
}
.release-date {
  font-size: 12px;
  color: var(--fg-muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding-left: 4px;
}

.release-main { min-width: 0; }

.release-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.release-name {
  font-size: 24px;
  font-weight: 600;
  margin: 0;
  color: var(--fg-default);
  letter-spacing: -0.01em;
}
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0 7px;
  height: 22px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
}
.badge-latest {
  background: var(--success-subtle);
  color: var(--success-fg);
  border: 1px solid var(--success-border);
}

.release-body { font-size: 14px; color: var(--fg-default); margin-bottom: 16px; }
.release-empty { font-size: 13px; color: var(--fg-muted); font-style: italic; }

/* Assets */
.release-assets {
  border: 1px solid var(--border-default);
  border-radius: var(--radius);
  background: var(--bg);
  overflow: hidden;
}
.assets-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  cursor: pointer;
  user-select: none;
  font-weight: 600;
  font-size: 14px;
  color: var(--fg-default);
  list-style: none;
  background: var(--bg-subtle);
  border-bottom: 1px solid transparent;
  transition: background 0.15s ease;
}
.assets-summary::-webkit-details-marker { display: none; }
.assets-summary:hover { background: #eef1f4; }
.release-assets[open] .assets-summary { border-bottom-color: var(--border-default); }
.assets-caret {
  width: 12px;
  height: 12px;
  transition: transform 0.2s ease;
}
.release-assets[open] .assets-caret { transform: rotate(90deg); }
.assets-count {
  font-weight: normal;
  color: var(--fg-muted);
  font-size: 12px;
  margin-left: 4px;
}

.assets-list { list-style: none; margin: 0; padding: 0; }
.asset-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-top: 1px solid var(--border-muted);
}
.asset-row:first-child { border-top: 0; }
.asset-row:hover { background: var(--bg-subtle); }
.asset-icon { color: var(--fg-muted); flex: 0 0 auto; }
.asset-name {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--accent-fg);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.asset-name:hover { text-decoration: underline; }
.asset-size { color: var(--fg-muted); font-size: 12px; font-family: var(--font-mono); flex: 0 0 auto; }
.asset-download {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--fg-muted);
  flex: 0 0 auto;
  padding: 4px;
  border-radius: 4px;
}
.asset-download:hover { background: var(--neutral-subtle); color: var(--fg-default); }

/* ============================================
   Page view (for 错误码 etc.)
   ============================================ */
.page-view {
  padding: 8px 0 40px;
  animation: fadeIn 0.3s ease;
}
.page-view .markdown { max-width: 820px; }

/* ============================================
   Markdown
   ============================================ */
.markdown { line-height: 1.6; }
.markdown > *:first-child { margin-top: 0 !important; }
.markdown > *:last-child { margin-bottom: 0 !important; }
.markdown h1, .markdown h2, .markdown h3, .markdown h4 {
  font-weight: 600;
  margin: 24px 0 12px;
  line-height: 1.25;
  letter-spacing: -0.005em;
}
.markdown h1 { font-size: 26px; padding-bottom: 8px; border-bottom: 1px solid var(--border-muted); margin-top: 0; }
.markdown h2 { font-size: 20px; padding-bottom: 6px; border-bottom: 1px solid var(--border-muted); }
.markdown h3 { font-size: 16px; }
.markdown h4 { font-size: 14px; }
.markdown p { margin: 0 0 12px; }
.markdown ul, .markdown ol { margin: 0 0 12px; padding-left: 28px; }
.markdown li + li { margin-top: 4px; }
.markdown code {
  font-family: var(--font-mono);
  font-size: 85%;
  padding: 2px 6px;
  background: rgba(175, 184, 193, 0.2);
  border-radius: 4px;
}
.markdown pre {
  margin: 0 0 12px;
  padding: 14px 16px;
  background: var(--bg-subtle);
  border-radius: var(--radius);
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.45;
}
.markdown pre code { background: transparent; padding: 0; font-size: inherit; }
.markdown blockquote {
  margin: 0 0 12px;
  padding: 4px 14px;
  color: var(--fg-muted);
  border-left: 4px solid var(--border-default);
}
.markdown table {
  border-collapse: collapse;
  margin: 0 0 16px;
  font-size: 13px;
  width: 100%;
  display: block;
  overflow-x: auto;
}
.markdown th, .markdown td {
  border: 1px solid var(--border-default);
  padding: 6px 12px;
  text-align: left;
}
.markdown th { background: var(--bg-subtle); font-weight: 600; }
.markdown tbody tr:nth-child(2n) { background: var(--bg-subtle); }
.markdown hr {
  border: 0;
  border-top: 1px solid var(--border-muted);
  margin: 16px 0;
}
.markdown strong { font-weight: 600; }

/* ============================================
   Footer
   ============================================ */
.site-footer {
  border-top: 1px solid var(--border-default);
  margin-top: 40px;
  padding: 24px 0;
}
.site-footer-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px;
  color: var(--fg-muted);
  font-size: 12px;
  text-align: center;
}

/* ============================================
   Empty / error states
   ============================================ */
.error {
  margin: 40px 0;
  padding: 16px;
  border-radius: var(--radius);
  background: #ffebe9;
  border: 1px solid #ffcecb;
  color: #82071e;
  font-size: 14px;
}

/* ============================================
   Mobile
   ============================================ */
.mobile-menu {
  display: none;
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--fg-default);
  color: #fff;
  border: 0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  z-index: 30;
  align-items: center;
  justify-content: center;
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
    padding: 16px;
    gap: 16px;
  }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 25;
    background: rgba(0,0,0,0.4);
    padding: 16px;
    display: none;
  }
  .sidebar.open { display: block; }
  .sidebar-inner {
    max-width: 320px;
    max-height: calc(100vh - 32px);
    overflow-y: auto;
  }
  .mobile-menu { display: flex; }

  .release {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 20px 0;
  }
  .release-aside {
    flex-direction: row;
    align-items: center;
    padding-top: 0;
  }
  .release-name { font-size: 20px; }
  .site-header-inner { padding: 0 16px; }
  .header-nav { margin-left: 8px; }
}
