:root {
  --bg: #f3f6f7;
  --bg-light: #ffffff;
  --ink: #1d2a2e;
  --muted: #5c6d74;
  --line: #d5e0e4;
  --accent: #0f9d78;
  --accent-dark: #0f5d49;
  --link: #2563eb;
  --warn: #b45309;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.45;
}

a {
  color: inherit;
}

.container {
  width: min(1240px, calc(100% - 32px));
  margin: 0 auto;
}

.app-header {
  border-bottom: 1px solid var(--line);
  background: #fff;
  position: sticky;
  top: 0;
  z-index: 10;
}

.app-header-inner {
  min-height: 66px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

.brand-text {
  font-weight: 700;
}

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

.lang-switch {
  height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f2f8f6;
  padding: 2px;
}

.lang-pill {
  height: 28px;
  min-width: 46px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-dark);
  cursor: pointer;
  padding: 0 10px;
}

.lang-pill.active {
  background: var(--accent);
  color: #fff;
}

.icon-button {
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  font-size: 13px;
  padding: 0 10px;
  white-space: nowrap;
  cursor: pointer;
  font: inherit;
}

.icon-button svg {
  width: 15px;
  height: 15px;
}

.icon-button:hover {
  border-color: #bfd0d7;
  background: #f8fcfd;
}

.icon-button:disabled {
  opacity: 0.55;
  cursor: wait;
}

.icon-button.spinning svg {
  animation: icon-spin 1s linear infinite;
}

@keyframes icon-spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.band {
  padding: 14px 0;
}

.band-light {
  background: var(--bg-light);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.summary-bar {
  min-height: 56px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.summary-meta h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.1;
  letter-spacing: 0;
}

.summary-meta p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.summary-sync {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

.sync-alert {
  margin-top: 10px;
  border: 1px solid #f0d7bf;
  border-radius: 8px;
  background: #fffaf5;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.sync-alert-text {
  min-width: 0;
}

.sync-alert-title {
  margin: 0;
  font-size: 13px;
  color: var(--warn);
  font-weight: 700;
}

.sync-alert-detail,
.sync-alert-last {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.stat-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  min-height: 86px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.stat-label {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

.stat-value {
  margin: 0;
  font-size: 28px;
  line-height: 1;
  font-weight: 700;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1.8fr) auto auto auto auto;
  gap: 10px;
  align-items: center;
}

.search-box {
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
}

.search-box svg {
  width: 15px;
  height: 15px;
  color: var(--muted);
}

.search-box input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 14px;
}

.segmented {
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  display: inline-flex;
  align-items: center;
  padding: 3px;
  gap: 4px;
}

.seg-btn {
  height: 30px;
  min-width: 62px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 120ms ease, color 120ms ease;
}

.seg-btn:hover {
  background: #f4faf8;
}

.seg-btn.active {
  background: var(--accent);
  color: #fff;
}

.check-item {
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}

.check-item input {
  margin: 0;
}

.hub-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(330px, 0.9fr);
  gap: 12px;
  align-items: start;
}

.surface {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(15, 45, 58, 0.03);
}

.surface-head {
  min-height: 48px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 12px;
}

.surface-head h2 {
  margin: 0;
  font-size: 18px;
}

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

.table-wrap {
  width: 100%;
}

.table-row {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) 82px minmax(0, 1fr) 66px 68px;
  gap: 8px;
  align-items: center;
  min-height: 50px;
  padding: 8px 12px;
  border-top: 1px solid var(--line);
}

.table-row > div {
  min-width: 0;
  overflow-wrap: anywhere;
}

.table-row.header {
  border-top: 0;
  min-height: 42px;
  background: #f6fbfc;
  color: var(--muted);
  font-size: 12px;
}

.table-row.item {
  cursor: pointer;
  transition: background-color 120ms ease;
}

.table-row.item:hover {
  background: #f7fcfa;
}

.table-row.item.active {
  background: #eef8f5;
}

.table-row.item:focus-visible {
  outline: 2px solid #8ed9c4;
  outline-offset: -2px;
}

.cell-mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
}

.cell-kind {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-dark);
}

.cell-center {
  text-align: center;
}

.cell-link {
  color: var(--link);
}

.detail-surface {
  position: sticky;
  top: 82px;
}

.detail-pane {
  padding: 12px;
}

.detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.detail-head h2 {
  margin: 0;
  font-size: 22px;
  word-break: break-word;
}

.detail-tags {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  display: inline-flex;
  align-items: center;
  height: 24px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 8px;
  font-size: 12px;
  color: var(--muted);
}

.install-box {
  margin-top: 10px;
}

.command-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px;
  gap: 8px;
  align-items: stretch;
}

.subhead {
  margin: 0 0 6px;
  font-size: 13px;
  color: var(--muted);
  font-weight: 700;
}

pre {
  margin: 0 0 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fcfd;
  padding: 8px 10px;
  font-size: 12px;
  overflow-x: auto;
}

#installChain {
  white-space: pre-wrap;
}

.mini-icon-button {
  margin: 0 0 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
}

.mini-icon-button:hover {
  background: #f8fcfd;
  border-color: #bfd0d7;
  color: var(--accent-dark);
}

.mini-icon-button svg {
  width: 16px;
  height: 16px;
}

.copy-toast {
  margin: 2px 0 0;
  color: var(--accent-dark);
  font-size: 12px;
}

.detail-actions {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.icon-button.slim {
  height: 30px;
  font-size: 12px;
  gap: 6px;
}

.kv-grid {
  margin-top: 10px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr);
  gap: 8px;
  align-items: start;
}

.kv-key {
  color: var(--muted);
  font-size: 12px;
}

.kv-value {
  font-size: 13px;
  word-break: break-word;
}

.subsection {
  margin-top: 14px;
}

.dependency-expanded {
  margin-top: 8px;
  display: grid;
  gap: 8px;
}

.dep-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fcfefe;
}

.dep-name {
  font-size: 12px;
  font-weight: 700;
  margin: 0;
}

.dep-versions {
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.dep-version {
  height: 22px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 8px;
  font-size: 11px;
  color: var(--muted);
}

.mini-table {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.mini-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  min-height: 36px;
  padding: 6px 10px;
  border-top: 1px solid var(--line);
  font-size: 12px;
}

.mini-row > div {
  min-width: 0;
  overflow-wrap: anywhere;
}

.mini-row.header {
  border-top: 0;
  background: #f6fbfc;
  color: var(--muted);
}

.mini-row.three {
  grid-template-columns: minmax(0, 1fr) 66px minmax(0, 1fr);
}

.mini-row.item {
  cursor: pointer;
  transition: background-color 120ms ease;
}

.mini-row.item:hover {
  background: #f7fcfa;
}

.mini-row.item.active {
  background: #eef8f5;
}

.mini-row.warning {
  grid-template-columns: minmax(0, 1fr);
}

.warning-title {
  font-weight: 700;
  color: var(--warn);
}

.warning-meta {
  margin-top: 2px;
  color: var(--muted);
}

.empty {
  border: 1px dashed var(--line);
  border-radius: 8px;
  margin: 10px;
  padding: 14px;
  color: var(--muted);
  font-size: 13px;
}

.hidden {
  display: none;
}

.repo-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding: 12px;
}

.repo-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  text-decoration: none;
  background: #fff;
  transition: border-color 120ms ease, box-shadow 120ms ease, transform 120ms ease;
}

.repo-card:hover {
  border-color: #bfd0d7;
  box-shadow: 0 6px 16px rgba(15, 45, 58, 0.08);
  transform: translateY(-1px);
}

.repo-thumb {
  display: block;
  width: 100%;
  aspect-ratio: 1.91 / 1;
  object-fit: cover;
  background: #e7eef1;
}

.repo-thumb-text {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  font-size: 14px;
  color: var(--accent-dark);
  font-weight: 700;
  overflow-wrap: anywhere;
}

.repo-body {
  padding: 10px;
}

.repo-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  word-break: break-word;
}

.repo-meta {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
  word-break: break-word;
}

.app-footer {
  border-top: 1px solid var(--line);
  background: #fff;
}

.app-footer-inner {
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
}

.app-footer-inner a {
  color: var(--link);
  text-decoration: none;
}

@media (max-width: 1080px) {
  .toolbar {
    grid-template-columns: minmax(220px, 1fr) auto auto;
  }

  .hub-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .detail-surface {
    position: static;
  }
}

@media (max-width: 860px) {
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .repo-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .table-row {
    grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) 70px minmax(0, 1fr) 56px 56px;
  }
}

@media (max-width: 700px) {
  .app-header-inner {
    align-items: flex-start;
    flex-direction: column;
    padding: 10px 0;
  }

  .header-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .toolbar {
    grid-template-columns: minmax(0, 1fr);
  }

  .command-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .table-row.header {
    display: none;
  }

  .table-row.item {
    grid-template-columns: minmax(0, 1fr);
    gap: 2px;
    min-height: 0;
  }

  .cell-center {
    text-align: left;
  }

  .repo-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .summary-meta h1 {
    font-size: 26px;
  }

  .sync-alert {
    flex-direction: column;
    align-items: flex-start;
  }
}
