:root {
  --bg-canvas: #0d1117;
  --bg-surface: #161b22;
  --bg-subtle: #1c2128;
  --bg-control: #21262d;
  --bg-control-hover: #30363d;
  --border-default: #30363d;
  --border-muted: #21262d;
  --text-primary: #e6edf3;
  --text-muted: #8b949e;
  --accent-link: #58a6ff;
  --accent-tab: #f78166;
  --btn-primary-bg: #238636;
  --btn-primary-hover: #2ea043;
  --btn-primary-border: rgba(240, 246, 252, 0.1);
  --badge-latest: #3fb950;
  --badge-latest-bg: rgba(63, 185, 80, 0.12);
  --badge-pre: #d29922;
  --badge-pre-bg: rgba(210, 153, 34, 0.12);
  --badge-topic-bg: rgba(56, 139, 253, 0.12);
  --badge-topic: #58a6ff;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, SF Mono, Menlo, Consolas, Liberation Mono, monospace;
}

* {
  box-sizing: border-box;
}

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

a {
  color: var(--accent-link);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.hidden {
  display: none !important;
}

/* Header */
.site-header {
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-default);
}

.header-inner {
  max-width: 1040px;
  margin: 0 auto;
  padding: 16px 24px 0;
}

.header-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.profile-block {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-logo-link {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  border-radius: 50%;
}

.site-logo {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: block;
  flex-shrink: 0;
  transition: transform 0.15s ease, filter 0.15s ease;
}

.brand-logo-link:hover .site-logo {
  transform: scale(1.05);
  filter: brightness(1.08);
}

.profile-avatar {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1px solid var(--border-default);
  background-color: var(--bg-control);
  vertical-align: middle;
  flex-shrink: 0;
}

.profile-meta {
  min-width: 0;
}

.brand-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 16px;
}

.brand-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--text-primary);
  font-weight: 600;
}

.brand-link:hover {
  color: var(--accent-link);
  text-decoration: none;
}

.brand-icon {
  color: var(--text-muted);
}

.brand-sep {
  color: var(--text-muted);
}

.profile-name {
  font-weight: 600;
  color: var(--text-primary);
}

.profile-handle {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
}

.profile-bio {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

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

.btn.is-syncing .sync-icon {
  animation: spin 0.9s linear infinite;
}

/* Tabs */
.tab-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.tab-group {
  display: flex;
  align-items: center;
  gap: 4px;
}

.tab-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px 11px;
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
}

.tab-item:hover {
  color: var(--text-primary);
}

.tab-item.active {
  color: var(--text-primary);
  font-weight: 600;
  border-bottom-color: var(--accent-tab);
}

.counter-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
  color: var(--text-primary);
  background-color: rgba(110, 118, 129, 0.4);
  border-radius: 2em;
}

.tab-right {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 8px;
}

.tab-stat {
  color: var(--text-muted);
  font-size: 12px;
}

.sync-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 500;
  border-radius: 2em;
  border: 1px solid var(--border-default);
  color: var(--text-muted);
  background-color: var(--bg-canvas);
}

.sync-pill.live {
  color: var(--badge-latest);
  background-color: var(--badge-latest-bg);
  border-color: rgba(63, 185, 80, 0.35);
}

.sync-pill.cache {
  color: var(--accent-link);
  background-color: var(--badge-topic-bg);
  border-color: rgba(88, 166, 255, 0.35);
}

.sync-pill.fallback {
  color: var(--badge-pre);
  background-color: var(--badge-pre-bg);
  border-color: rgba(210, 153, 34, 0.35);
}

/* Main container */
.container {
  max-width: 1040px;
  margin: 0 auto;
  padding: 24px;
}

/* Toolbar */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 16px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border-muted);
}

.search-box {
  position: relative;
  flex: 1 1 280px;
  max-width: 480px;
}

.search-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.search-box input {
  width: 100%;
  padding: 6px 12px 6px 34px;
  font-size: 14px;
  font-family: var(--font-sans);
  color: var(--text-primary);
  background-color: var(--bg-canvas);
  border: 1px solid var(--border-default);
  border-radius: 6px;
  outline: none;
}

.search-box input:focus {
  border-color: var(--accent-link);
  box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.15);
}

.sort-box {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sort-label {
  color: var(--text-muted);
  font-size: 13px;
}

.sort-select {
  padding: 6px 12px;
  font-size: 13px;
  font-family: var(--font-sans);
  font-weight: 500;
  color: var(--text-primary);
  background-color: var(--bg-control);
  border: 1px solid var(--border-default);
  border-radius: 6px;
  cursor: pointer;
}

.sort-select:hover {
  background-color: var(--bg-control-hover);
}

/* Content Root */
.content-root {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Repository Card */
.repo-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: 6px;
  overflow: hidden;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.repo-card.highlighted,
.release-row.highlighted .release-card {
  border-color: var(--accent-link);
  box-shadow: 0 0 0 2px rgba(88, 166, 255, 0.25);
}

.repo-header {
  padding: 18px 20px;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--border-default);
}

.repo-title-block {
  flex: 1 1 320px;
  min-width: 0;
}

.repo-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.repo-icon {
  color: var(--text-muted);
  flex-shrink: 0;
}

.repo-name {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  line-height: 1.25;
}

.repo-name a {
  color: var(--accent-link);
}

.repo-desc {
  margin: 0 0 10px;
  color: var(--text-primary);
  font-size: 14px;
}

.repo-desc.empty {
  color: var(--text-muted);
  font-style: italic;
}

.topics-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.topic-pill {
  display: inline-flex;
  align-items: center;
  padding: 1px 9px;
  font-size: 12px;
  font-weight: 500;
  color: var(--badge-topic);
  background-color: var(--badge-topic-bg);
  border-radius: 2em;
}

.repo-stats-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  font-size: 12px;
  color: var(--text-muted);
}

.stat-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.lang-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: var(--accent-link);
  display: inline-block;
}

.repo-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.repo-releases-section {
  padding: 16px 20px 20px;
  background-color: var(--bg-canvas);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.repo-releases-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.older-releases-details {
  border: 1px solid var(--border-default);
  border-radius: 6px;
  background-color: var(--bg-surface);
  overflow: hidden;
}

.older-releases-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.older-releases-summary::-webkit-details-marker {
  display: none;
}

.older-releases-details[open] .chevron-icon {
  transform: rotate(90deg);
}

.older-releases-body {
  padding: 12px;
  border-top: 1px solid var(--border-default);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Badges & Buttons */
.pill {
  display: inline-flex;
  align-items: center;
  padding: 1px 8px;
  font-size: 12px;
  font-weight: 500;
  border-radius: 2em;
  border: 1px solid transparent;
  line-height: 18px;
}

.pill-public {
  color: var(--text-muted);
  border-color: var(--border-default);
}

.pill-latest {
  color: var(--badge-latest);
  background-color: var(--badge-latest-bg);
  border-color: rgba(63, 185, 80, 0.4);
}

.pill-prerelease {
  color: var(--badge-pre);
  background-color: var(--badge-pre-bg);
  border-color: rgba(210, 153, 34, 0.4);
}

.pill-local {
  color: var(--accent-link);
  background-color: var(--badge-topic-bg);
  border-color: rgba(88, 166, 255, 0.35);
}

.pill-tag {
  font-family: var(--font-mono);
  color: var(--text-muted);
  background-color: var(--bg-control);
  border-color: var(--border-default);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font-sans);
  line-height: 20px;
  border-radius: 6px;
  border: 1px solid var(--border-default);
  background-color: var(--bg-control);
  color: var(--text-primary);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover {
  background-color: var(--bg-control-hover);
  text-decoration: none;
}

.btn-primary {
  background-color: var(--btn-primary-bg);
  border-color: var(--btn-primary-border);
  color: #ffffff;
  font-weight: 600;
}

.btn-primary:hover {
  background-color: var(--btn-primary-hover);
}

.btn-sm {
  padding: 3px 10px;
  font-size: 12px;
  line-height: 18px;
}

/* Release Card (standalone & nested) */
.release-row {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 24px;
  align-items: start;
}

.release-meta-col {
  padding-top: 4px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--text-muted);
  font-size: 13px;
}

.meta-date {
  color: var(--text-primary);
  font-weight: 500;
}

.meta-tag-row {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  word-break: break-all;
}

.meta-stats {
  font-size: 12px;
  color: var(--text-muted);
}

.release-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: 6px;
  overflow: hidden;
}

.release-card-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-default);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.release-title-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.release-title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
}

.release-title a {
  color: var(--text-primary);
}

.release-title a:hover {
  color: var(--accent-link);
  text-decoration: none;
}

.release-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.release-card-body {
  padding: 16px 18px 18px;
}

/* Safe Markdown styles */
.markdown-body {
  margin-bottom: 16px;
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.6;
  word-break: break-word;
}

.markdown-body.empty-desc {
  color: var(--text-muted);
  font-style: italic;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3 {
  margin: 14px 0 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border-muted);
  font-weight: 600;
  line-height: 1.25;
}

.markdown-body h1:first-child,
.markdown-body h2:first-child,
.markdown-body h3:first-child {
  margin-top: 0;
}

.markdown-body h1 {
  font-size: 18px;
}

.markdown-body h2 {
  font-size: 16px;
}

.markdown-body h3 {
  font-size: 14px;
  border-bottom: none;
}

.markdown-body p {
  margin: 0 0 10px;
}

.markdown-body p:last-child {
  margin-bottom: 0;
}

.markdown-body ul {
  margin: 0 0 10px;
  padding-left: 22px;
}

.markdown-body li {
  margin-bottom: 4px;
}

.markdown-body code {
  padding: 0.15em 0.4em;
  font-family: var(--font-mono);
  font-size: 85%;
  background-color: rgba(110, 118, 129, 0.25);
  border-radius: 4px;
}

/* Assets box */
.assets-details {
  border: 1px solid var(--border-default);
  border-radius: 6px;
  background-color: var(--bg-canvas);
  overflow: hidden;
}

.assets-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  font-weight: 600;
  font-size: 13px;
  background-color: var(--bg-subtle);
  border-bottom: 1px solid var(--border-default);
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.assets-details:not([open]) .assets-summary {
  border-bottom: none;
}

.assets-summary::-webkit-details-marker {
  display: none;
}

.chevron-icon {
  color: var(--text-muted);
  transition: transform 0.15s ease;
}

.assets-details[open] .chevron-icon {
  transform: rotate(90deg);
}

.assets-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.asset-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 14px;
  border-top: 1px solid var(--border-muted);
}

.asset-item:first-child {
  border-top: none;
}

.asset-item:hover {
  background-color: rgba(177, 186, 196, 0.04);
}

.asset-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.asset-icon {
  color: var(--text-muted);
  flex-shrink: 0;
}

.asset-name {
  color: var(--accent-link);
  font-family: var(--font-mono);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.asset-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.dl-count {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

.sha-btn {
  padding: 2px 7px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: 4px;
  cursor: pointer;
}

.sha-btn:hover {
  color: var(--text-primary);
  border-color: var(--text-muted);
}

.sha-btn.copied {
  color: var(--badge-latest);
  border-color: var(--badge-latest);
}

.asset-size {
  min-width: 68px;
  text-align: right;
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.empty-assets {
  padding: 14px;
  color: var(--text-muted);
  font-size: 13px;
}

/* Empty & Loading states */
.loading-state,
.empty-state {
  padding: 44px 24px;
  text-align: center;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: 6px;
  color: var(--text-muted);
}

.empty-state h2 {
  margin: 0 0 8px;
  font-size: 18px;
  color: var(--text-primary);
}

/* Footer */
.site-footer {
  max-width: 1040px;
  margin: 24px auto 40px;
  padding: 20px 24px 0;
  border-top: 1px solid var(--border-muted);
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
  color: var(--text-muted);
}

@media (max-width: 768px) {
  .release-row {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .release-meta-col {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
  }

  .asset-item {
    flex-direction: column;
    align-items: flex-start;
  }

  .asset-right {
    width: 100%;
    flex-wrap: wrap;
    justify-content: flex-end;
  }
}
