:root {
  color-scheme: dark;
  --bg: #0b0d0d;
  --surface: #121616;
  --surface-strong: #191e1d;
  --line: #303837;
  --line-soft: #202726;
  --text: #e5e9e7;
  --muted: #9aa5a1;
  --cyan: #69d2e2;
  --green: #a6d66d;
  --amber: #f0c563;
  --pink: #e47c9e;
  --danger: #ff8d7d;
  --max: 1160px;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 15px;
  line-height: 1.55;
}

button, input, select { font: inherit; }
a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 3px; }
code { font-family: inherit; color: #d6efeb; }

.top {
  position: sticky;
  top: 0;
  z-index: 20;
  max-width: var(--max);
  min-height: 78px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  background: rgba(11, 13, 13, 0.96);
  border-bottom: 1px solid var(--line);
}

.brand { display: inline-flex; align-items: center; gap: 12px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand img { width: 44px; height: 44px; border-radius: 3px; }
.brand span { display: grid; line-height: 1.2; }
.brand strong { font-size: 16px; }
.brand small { margin-top: 4px; color: var(--muted); font-size: 11px; font-weight: 400; }

nav { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px; }
nav a { min-height: 38px; padding: 8px 11px; display: inline-flex; align-items: center; color: var(--muted); border-bottom: 2px solid transparent; }
nav a:hover { color: var(--text); text-decoration: none; border-color: var(--line); }
nav a[aria-current="page"] { color: var(--cyan); border-color: var(--cyan); }

main { max-width: var(--max); margin: 0 auto; padding: 44px 20px 72px; }
h1, h2, h3, p { overflow-wrap: anywhere; }
h1 { margin: 0; font-size: 38px; line-height: 1.12; letter-spacing: 0; }
h2 { margin: 0; font-size: 22px; line-height: 1.25; letter-spacing: 0; }
h3 { letter-spacing: 0; }
.eyebrow, .metric-label { margin: 0 0 8px; color: var(--green); font-size: 12px; text-transform: uppercase; letter-spacing: 0; }
.quiet { color: var(--muted); font-size: 13px; }

.mirror-intro { max-width: 860px; padding: 26px 0 48px; }
.mirror-intro > p { max-width: 760px; margin: 18px 0 24px; color: var(--muted); font-size: 17px; }
.status-line { margin-bottom: 18px; display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 12px; text-transform: uppercase; }
.status-dot { width: 8px; height: 8px; flex: 0 0 auto; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px rgba(166, 214, 109, 0.12); }

.endpoint-line, .code-block {
  position: relative;
  border: 1px solid var(--line);
  background: #080a0a;
  border-radius: 3px;
}
.endpoint-line { width: min(100%, 760px); min-height: 52px; padding: 13px 78px 13px 15px; display: flex; align-items: center; overflow: hidden; }
.endpoint-line code { overflow-x: auto; white-space: nowrap; }
.copy-button {
  min-width: 60px;
  min-height: 32px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--surface-strong);
  color: var(--cyan);
  cursor: pointer;
}
.endpoint-line .copy-button, .code-block .copy-button { position: absolute; top: 9px; right: 9px; }
.copy-button:hover { border-color: var(--cyan); }

.mirror-summary, .diagnostic-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.mirror-summary > div, .diagnostic-grid > div { min-width: 0; padding: 22px 18px; border-right: 1px solid var(--line); }
.mirror-summary > div:first-child, .diagnostic-grid > div:first-child { padding-left: 0; }
.mirror-summary > div:last-child, .diagnostic-grid > div:last-child { border-right: 0; }
.mirror-summary strong, .mirror-summary small, .diagnostic-grid strong, .diagnostic-grid small { display: block; }
.mirror-summary strong, .diagnostic-grid strong { min-height: 25px; font-size: 16px; overflow-wrap: anywhere; }
.mirror-summary small, .diagnostic-grid small { margin-top: 5px; color: var(--muted); font-size: 11px; }

.repo-section, .operations-band, .tool-section { padding-top: 54px; }
.section-heading { margin-bottom: 20px; display: flex; justify-content: space-between; align-items: end; gap: 24px; }
.section-heading .eyebrow { margin-bottom: 5px; }
.repo-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.repo-item { min-height: 132px; padding: 18px; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); color: var(--text); }
.repo-item:hover { border-color: var(--cyan); text-decoration: none; }
.repo-item span { font-size: 17px; font-weight: 700; }
.repo-item small { margin-top: 8px; color: var(--muted); }
.repo-item b { margin-top: auto; padding-top: 12px; color: var(--cyan); font-size: 12px; font-weight: 400; }

.operations-band { display: grid; grid-template-columns: minmax(220px, 0.8fr) minmax(0, 1.5fr); gap: 40px; }
.operations-band dl { margin: 0; display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--line); }
.operations-band dl div { padding: 14px 0; border-bottom: 1px solid var(--line); }
.operations-band dt { color: var(--muted); font-size: 12px; }
.operations-band dd { margin: 3px 0 0; }

.page-shell { max-width: 1000px; }
.page-shell.wide { max-width: var(--max); }
.page-heading { max-width: 800px; padding: 22px 0 38px; }
.page-heading > p, .page-heading > div > p:last-child { max-width: 760px; margin: 16px 0 0; color: var(--muted); font-size: 16px; }
.page-heading .eyebrow, .page-heading > div > .eyebrow { margin: 0 0 10px; font-size: 12px; }
.package-heading, .network-heading { max-width: none; display: flex; justify-content: space-between; align-items: end; gap: 28px; }

.install-scope { margin-bottom: 10px; padding: 14px 16px; display: flex; flex-wrap: wrap; gap: 12px 22px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); font-size: 12px; }
.install-scope strong { color: var(--amber); }
.doc-section { padding: 38px 0; display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: 24px; border-bottom: 1px solid var(--line); }
.section-index { padding-top: 3px; color: var(--pink); font-size: 12px; }
.doc-section h2 { margin-bottom: 12px; }
.doc-section p { max-width: 800px; color: var(--muted); }
.doc-section p code { color: var(--text); }
.code-block { margin-top: 18px; }
.code-block pre { max-width: 100%; min-height: 56px; margin: 0; padding: 17px 82px 17px 17px; overflow-x: auto; white-space: pre; }
.code-block.compact pre { min-height: 48px; }
.note, .danger-note { padding: 12px 15px; border-left: 3px solid var(--pink); background: var(--surface); }
.danger-note { border-color: var(--danger); color: #d7b0aa !important; }

.catalog-source { flex: 0 0 auto; padding: 7px 10px; border: 1px solid var(--line); border-radius: 3px; color: var(--muted); font-size: 11px; }
.catalog-source.live { border-color: #48653b; color: var(--green); }
.catalog-source.fallback { border-color: #725f35; color: var(--amber); }
.package-controls { padding: 18px; display: grid; grid-template-columns: minmax(240px, 1fr) 190px 170px auto; gap: 12px; align-items: end; border: 1px solid var(--line); background: var(--surface); }
.package-controls label { min-width: 0; display: grid; gap: 7px; color: var(--muted); font-size: 11px; }
.package-controls input, .package-controls select {
  width: 100%;
  height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: #080a0a;
  color: var(--text);
}
.primary-button {
  min-height: 42px;
  padding: 9px 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--cyan);
  border-radius: 3px;
  background: #173238;
  color: #bcecf3;
  cursor: pointer;
  white-space: nowrap;
}
.primary-button:hover { background: #20434a; text-decoration: none; }
.primary-button:disabled { opacity: 0.45; cursor: not-allowed; }
.results-bar { min-height: 48px; padding: 14px 2px 10px; display: flex; justify-content: space-between; gap: 16px; color: var(--muted); font-size: 12px; }
.package-table-wrap { position: relative; min-height: 390px; overflow-x: auto; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.package-table { width: 100%; min-width: 780px; border-collapse: collapse; table-layout: fixed; }
.package-table th { padding: 11px 12px; color: var(--muted); font-size: 11px; font-weight: 400; text-align: left; border-bottom: 1px solid var(--line); }
.package-table td { padding: 12px; color: var(--muted); border-bottom: 1px solid var(--line-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.package-table th:first-child { width: 34%; }
.package-table th:nth-child(2) { width: 25%; }
.package-table th:nth-child(3) { width: 16%; }
.package-table th:nth-child(4) { width: 12%; }
.package-table th:nth-child(5) { width: 13%; }
.package-table tr[data-package] { cursor: pointer; }
.package-table tr[data-package]:hover td { background: var(--surface); color: var(--text); }
.package-name { color: var(--cyan) !important; font-weight: 700; }
.package-name small { margin-top: 2px; display: block; overflow: hidden; color: var(--muted); font-weight: 400; text-overflow: ellipsis; }
.loading-state { position: absolute; inset: 48px 0 0; padding-top: 90px; background: rgba(11, 13, 13, 0.88); color: var(--muted); text-align: center; }
.pagination { padding-top: 18px; display: flex; align-items: center; justify-content: flex-end; gap: 12px; color: var(--muted); }
.pagination button { min-height: 36px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 3px; background: var(--surface); color: var(--text); cursor: pointer; }
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }

.package-dialog { width: min(680px, calc(100% - 32px)); max-height: calc(100vh - 32px); padding: 24px; overflow-y: auto; border: 1px solid var(--line); border-radius: 4px; background: var(--surface-strong); color: var(--text); }
.package-dialog::backdrop { background: rgba(0, 0, 0, 0.76); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; color: var(--green); font-size: 12px; text-transform: uppercase; }
.dialog-head form { margin: 0; }
.close-button { width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 3px; background: var(--surface); color: var(--text); font-size: 24px; line-height: 1; cursor: pointer; }
.package-dialog h2 { margin-top: 18px; font-size: 28px; }
.detail-description { color: var(--muted); font-size: 16px; }
.package-detail-list { margin: 22px 0; border-top: 1px solid var(--line); }
.package-detail-list div { padding: 10px 0; display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 15px; border-bottom: 1px solid var(--line); }
.package-detail-list dt { color: var(--muted); }
.package-detail-list dd { margin: 0; overflow-wrap: anywhere; }
.dialog-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 15px; }

.network-heading .primary-button { flex: 0 0 auto; }
.diagnostic-grid { margin-top: 8px; }
.connection-list { margin: 0; display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--line); }
.connection-list div { padding: 15px 12px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.connection-list div:nth-child(3n) { border-right: 0; }
.connection-list dt { color: var(--muted); font-size: 11px; }
.connection-list dd { margin: 4px 0 0; min-height: 23px; }
.checksum-tool { display: grid; grid-template-columns: 1fr auto; gap: 12px; }
.checksum-tool input { min-width: 0; min-height: 44px; padding: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--text); }
.checksum-output { min-height: 52px; margin-top: 12px; padding: 14px; display: block; overflow-wrap: anywhere; border: 1px solid var(--line); background: #080a0a; color: var(--muted); }
.path-list { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.path-list a { min-width: 0; padding: 14px; display: grid; border: 1px solid var(--line); background: var(--surface); }
.path-list a:hover { border-color: var(--cyan); text-decoration: none; }
.path-list code { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.path-list span { margin-top: 5px; color: var(--muted); font-size: 11px; }

.not-found { min-height: 620px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 520px); align-items: center; gap: 46px; }
.not-found p:not(.eyebrow) { max-width: 520px; margin: 16px 0 26px; color: var(--muted); }
.not-found img { width: 100%; max-height: 460px; object-fit: cover; border: 1px solid var(--line); border-radius: 3px; background: var(--surface); }

footer { max-width: var(--max); min-height: 68px; margin: 0 auto; padding: 20px; display: flex; justify-content: space-between; align-items: center; gap: 18px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }
footer > div { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 16px; }

@media (max-width: 860px) {
  .mirror-summary, .diagnostic-grid { grid-template-columns: 1fr 1fr; }
  .mirror-summary > div:nth-child(2), .diagnostic-grid > div:nth-child(2) { border-right: 0; }
  .mirror-summary > div:nth-child(-n+2), .diagnostic-grid > div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .mirror-summary > div:nth-child(3), .diagnostic-grid > div:nth-child(3) { padding-left: 0; }
  .repo-grid { grid-template-columns: 1fr 1fr; }
  .package-controls { grid-template-columns: 1fr 1fr; }
  .search-field { grid-column: 1 / -1; }
  .connection-list { grid-template-columns: 1fr 1fr; }
  .connection-list div:nth-child(3n) { border-right: 1px solid var(--line); }
  .connection-list div:nth-child(2n) { border-right: 0; }
}

@media (max-width: 620px) {
  .top { position: static; min-height: 0; padding: 13px 16px 10px; align-items: flex-start; flex-direction: column; gap: 10px; }
  nav { width: 100%; justify-content: flex-start; overflow-x: auto; flex-wrap: nowrap; }
  nav a { flex: 0 0 auto; padding: 7px 8px; }
  main { padding: 28px 16px 54px; }
  h1 { font-size: 30px; }
  .mirror-intro { padding: 15px 0 34px; }
  .endpoint-line { padding-right: 72px; }
  .mirror-summary, .diagnostic-grid, .repo-grid, .operations-band, .path-list { grid-template-columns: 1fr; }
  .mirror-summary > div, .diagnostic-grid > div { padding: 15px 0; border-right: 0; border-bottom: 1px solid var(--line); }
  .mirror-summary > div:last-child, .diagnostic-grid > div:last-child { border-bottom: 0; }
  .repo-section, .operations-band, .tool-section { padding-top: 40px; }
  .section-heading, .package-heading, .network-heading { align-items: flex-start; flex-direction: column; gap: 12px; }
  .operations-band { gap: 18px; }
  .operations-band dl { grid-template-columns: 1fr; }
  .doc-section { grid-template-columns: 32px minmax(0, 1fr); gap: 10px; padding: 30px 0; }
  .code-block pre { padding: 58px 14px 14px; font-size: 12px; }
  .package-controls { grid-template-columns: 1fr; padding: 14px; }
  .search-field { grid-column: auto; }
  .results-bar { align-items: flex-start; flex-direction: column; gap: 4px; }
  .connection-list { grid-template-columns: 1fr; }
  .connection-list div, .connection-list div:nth-child(3n) { border-right: 0; }
  .checksum-tool { grid-template-columns: 1fr; }
  .package-detail-list div { grid-template-columns: 1fr; gap: 2px; }
  .not-found { min-height: 0; grid-template-columns: 1fr; gap: 30px; }
  footer { padding: 18px 16px; align-items: flex-start; flex-direction: column; }
  footer > div { justify-content: flex-start; }
}
