
/* Repository viewer.

   No framework and no build step: the service ships as one binary, and a
   stylesheet that needed compiling would mean a toolchain in the release path.

   Written for people who have never used a code host: soft cards, plain words,
   big touch targets, and a repository front page that reads as a document. */

*, *::before, *::after { box-sizing: border-box; }

:root {
  --bg: #f6f7fb;
  --card: #ffffff;
  --raised: #f1f2f8;
  --line: #e2e4ef;
  --ink: #191d27;
  --muted: #646c7f;
  --link: #2f56d8;
  --accent: #6c53e6;
  --accent-soft: #efeaff;
  --ok-bg: #e2f6ea;
  --ok-ink: #157a43;
  --warn-bg: #fdf2dc;
  --warn-ink: #8a5a08;
  --bad-bg: #fde8ec;
  --bad-ink: #c0334b;
  --note-bg: #e9f0fe;
  --note-ink: #2d63c8;
  --radius: 14px;
  --radius-small: 8px;
  --shadow: 0 1px 2px rgba(20, 24, 40, 0.05), 0 8px 24px -18px rgba(20, 24, 40, 0.25);
  --mono: ui-monospace, "SF Mono", SFMono-Regular, "JetBrains Mono", Menlo,
          Consolas, "Liberation Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
          Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1117;
    --card: #161b24;
    --raised: #1c222d;
    --line: #2a313e;
    --ink: #e8eaf1;
    --muted: #98a1b3;
    --link: #82aaff;
    --accent: #a08dff;
    --accent-soft: #262040;
    --ok-bg: #123322;
    --ok-ink: #5fd08a;
    --warn-bg: #34280f;
    --warn-ink: #e0b055;
    --bad-bg: #3a1a22;
    --bad-ink: #ff8ba0;
    --note-bg: #16233c;
    --note-ink: #8ab2ff;
    --shadow: none;
  }
}

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15.5px;
  line-height: 1.65;
}

.wrap { max-width: 1020px; margin: 0 auto; padding: 0 20px; }

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

/* ── header ─────────────────────────────────────────────────────────────── */

.bar {
  border-bottom: 1px solid var(--line);
  background: var(--card);
  position: sticky;
  top: 0;
  z-index: 10;
}

.bar-inner {
  display: flex;
  align-items: center;
  gap: 14px;
  height: 54px;
}

.brand {
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink);
  font-size: 17px;
}
.brand:hover { text-decoration: none; color: var(--accent); }

.crumbs {
  font-size: 14px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.crumbs a { font-weight: 550; }
.crumbs .sep { color: var(--line); margin: 0 3px; }

/* ── repository head ────────────────────────────────────────────────────── */

.repo-head { padding: 30px 0 0; }

.repo-title {
  margin: 0;
  font-size: 27px;
  font-weight: 700;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.repo-owner { color: var(--muted); font-weight: 500; }

.repo-desc { margin: 8px 0 0; color: var(--muted); max-width: 70ch; font-size: 16px; }

.badge {
  font-size: 11px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: var(--card);
}
.badge.public { background: var(--ok-bg); color: var(--ok-ink); border-color: transparent; }

.clone {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 16px;
}
.clone-label { font-size: 13px; color: var(--muted); }
.clone code {
  font-family: var(--mono);
  font-size: 12.5px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-small);
  padding: 8px 12px;
  color: var(--ink);
  user-select: all;
}

/* ── tabs: the one row that never goes away ─────────────────────────────── */

.tabs {
  display: flex;
  gap: 6px;
  margin: 20px 0 22px;
  padding: 4px;
  background: var(--raised);
  border: 1px solid var(--line);
  border-radius: 999px;
  width: fit-content;
  max-width: 100%;
  overflow-x: auto;
}

.tab {
  padding: 7px 16px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 550;
  white-space: nowrap;
}
.tab:hover { color: var(--ink); text-decoration: none; }
.tab.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }

/* ── toolbar and the branch menu ────────────────────────────────────────── */

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 14px;
  flex-wrap: wrap;
}

.spacer { flex: 1; }

.menu { position: relative; }
.menu > summary {
  list-style: none;
  cursor: pointer;
  font-size: 13.5px;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 14px;
  user-select: none;
}
.menu > summary::-webkit-details-marker { display: none; }
.menu > summary .menu-label { color: var(--muted); margin-right: 6px; }
.menu[open] > summary { border-color: var(--accent); }

.menu-list {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 220px;
  max-height: 320px;
  overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 6px;
  z-index: 20;
}
.menu-list a {
  display: block;
  padding: 8px 12px;
  border-radius: var(--radius-small);
  color: var(--ink);
  font-size: 14px;
}
.menu-list a:hover { background: var(--raised); text-decoration: none; }
.menu-list a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.menu-list a.menu-all { color: var(--link); border-top: 1px solid var(--line); border-radius: 0; margin-top: 6px; }

/* ── the latest-change strip ────────────────────────────────────────────── */

.pulse {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  margin: 0 0 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
}
.pulse:hover { text-decoration: none; border-color: var(--accent); }
.pulse-subject {
  font-weight: 550;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pulse-meta { color: var(--muted); font-size: 13px; white-space: nowrap; margin-left: auto; }

/* ── panels and listings ────────────────────────────────────────────────── */

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--card);
  box-shadow: var(--shadow);
}

.panel + .panel, .toolbar + .panel { margin-top: 18px; }

.panel-head {
  padding: 11px 16px;
  background: var(--raised);
  border-bottom: 1px solid var(--line);
  font-size: 13.5px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.panel-head .name { color: var(--ink); font-weight: 600; }

table.listing { width: 100%; border-collapse: collapse; }

table.listing td {
  padding: 11px 16px;
  border-top: 1px solid var(--line);
  vertical-align: middle;
}
table.listing tr:first-child td { border-top: none; }
table.listing tr:hover td { background: var(--raised); }

td.name { width: 100%; }
td.name a { color: var(--ink); font-weight: 500; }
td.name a:hover { color: var(--link); }

td.size, td.when {
  color: var(--muted);
  font-size: 12.5px;
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.chip {
  display: inline-block;
  min-width: 34px;
  margin-right: 10px;
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--raised);
  border: 1px solid var(--line);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 600;
  text-align: center;
  letter-spacing: 0.04em;
}
.chip.dir { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

/* ── documents: a README rendered as a page ─────────────────────────────── */

.doc-source { font-size: 12.5px; color: var(--muted); margin: 0 0 10px; }
.doc-source a { color: var(--muted); }
.doc-source a:hover { color: var(--link); }

.doc {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 36px clamp(20px, 6vw, 56px);
  font-size: 16.5px;
  line-height: 1.7;
  overflow-wrap: break-word;
}
.doc > :first-child, .md-details-body > :first-child { margin-top: 0; }
.doc > :last-child, .md-details-body > :last-child { margin-bottom: 0; }

.doc h1, .doc h2, .doc h3 { letter-spacing: -0.02em; line-height: 1.25; margin: 1.5em 0 0.5em; }
.doc h1 { font-size: 30px; }
.doc h2 { font-size: 22px; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.doc h3 { font-size: 18px; }
.doc p, .doc ul, .doc ol { margin: 0 0 1em; }
.doc li { margin-bottom: 0.3em; }
.doc img { max-width: 100%; border-radius: var(--radius-small); }
.doc hr { border: none; border-top: 1px solid var(--line); margin: 2em 0; }
.doc blockquote {
  margin: 0 0 1em;
  padding: 4px 18px;
  border-left: 3px solid var(--accent);
  color: var(--muted);
  background: var(--raised);
  border-radius: 0 var(--radius-small) var(--radius-small) 0;
}
.doc code {
  font-family: var(--mono);
  font-size: 0.85em;
  background: var(--raised);
  padding: 2px 6px;
  border-radius: 6px;
}
.doc pre {
  background: var(--raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-small);
  padding: 14px 16px;
  overflow-x: auto;
}
.doc pre code { background: none; padding: 0; font-size: 13px; }
.doc table { border-collapse: collapse; margin-bottom: 1em; display: block; overflow-x: auto; }
.doc th, .doc td { border: 1px solid var(--line); padding: 7px 13px; }
.doc th { background: var(--raised); }

.doc-more {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 18px;
}
.doc-more a {
  flex: 1;
  min-width: 200px;
  padding: 14px 18px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  font-weight: 550;
}
.doc-more a:hover { text-decoration: none; border-color: var(--accent); color: var(--accent); }

/* a README shown under a file listing rather than as the page itself */
.panel .doc { border: none; border-radius: 0; box-shadow: none; }

/* ── the tag dialect ────────────────────────────────────────────────────── */

.md-hero {
  text-align: center;
  padding: 30px 0 26px;
  margin-bottom: 8px;
}
.md-hero h1 {
  font-size: clamp(32px, 6vw, 44px);
  margin: 0 0 0.3em;
  border: none;
  letter-spacing: -0.03em;
}
.md-hero p {
  font-size: 18px;
  color: var(--muted);
  max-width: 44ch;
  margin: 0 auto 1em;
}
.md-hero a {
  display: inline-block;
  margin: 4px 6px;
  padding: 10px 22px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--ink);
  font-weight: 600;
  font-size: 15px;
}
.md-hero a:hover { text-decoration: none; border-color: var(--accent); color: var(--accent); }
.md-hero p:last-of-type a:first-child {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}
.md-hero p:last-of-type a:first-child:hover { opacity: 0.9; color: #ffffff; }

.md-callout {
  border-radius: var(--radius-small);
  padding: 14px 18px;
  margin: 0 0 1em;
  background: var(--note-bg);
  border-left: 3px solid var(--note-ink);
}
.md-callout > :last-child { margin-bottom: 0; }
.md-callout-title { font-weight: 650; margin: 0 0 4px; }
.md-note { background: var(--note-bg); border-color: var(--note-ink); }
.md-note .md-callout-title { color: var(--note-ink); }
.md-tip { background: var(--ok-bg); border-color: var(--ok-ink); }
.md-tip .md-callout-title { color: var(--ok-ink); }
.md-warn { background: var(--warn-bg); border-color: var(--warn-ink); }
.md-warn .md-callout-title { color: var(--warn-ink); }
.md-danger { background: var(--bad-bg); border-color: var(--bad-ink); }
.md-danger .md-callout-title { color: var(--bad-ink); }

.md-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin: 0 0 1em;
}
.md-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  background: var(--raised);
}
.md-card > :last-child { margin-bottom: 0; }
.md-card-title { font-weight: 650; margin: 0 0 6px; }

.md-details {
  border: 1px solid var(--line);
  border-radius: var(--radius-small);
  margin: 0 0 1em;
  background: var(--raised);
}
.md-details > summary {
  cursor: pointer;
  padding: 12px 16px;
  font-weight: 600;
  user-select: none;
}
.md-details[open] > summary { border-bottom: 1px solid var(--line); }
.md-details-body { padding: 14px 16px; }

/* ── code ───────────────────────────────────────────────────────────────── */

.code { overflow-x: auto; }

table.code-table {
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.55;
  width: 100%;
}

table.code-table td.ln {
  width: 1%;
  min-width: 46px;
  padding: 0 12px 0 14px;
  text-align: right;
  color: var(--muted);
  user-select: none;
  vertical-align: top;
  border-right: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}

table.code-table td.ln a { color: inherit; }
table.code-table td.src { padding: 0 14px; white-space: pre; vertical-align: top; }
table.code-table tr:target td { background: var(--warn-bg); }
table.code-table tr:target td.ln { color: var(--warn-ink); }

/* ── history: a feed, not a table ───────────────────────────────────────── */

.feed { display: flex; flex-direction: column; }

.feed-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  color: var(--ink);
}
.feed-item:first-child { border-top: none; }
.feed-item:hover { background: var(--raised); text-decoration: none; }

.avatar {
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #ffffff;
}
.av0 { background: #6c53e6; }
.av1 { background: #1f9d8b; }
.av2 { background: #d76b2f; }
.av3 { background: #3b76d6; }
.av4 { background: #b84a8f; }
.av5 { background: #5a8f2e; }
.av6 { background: #c0334b; }
.av7 { background: #7b6ac2; }

.feed-main { min-width: 0; display: flex; flex-direction: column; }
.feed-subject {
  font-weight: 550;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.feed-meta { color: var(--muted); font-size: 12.5px; }

code.sha {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  background: var(--raised);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1px 6px;
  margin-left: auto;
  flex: none;
}

pre.message {
  font-family: var(--mono);
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
  padding: 16px 18px;
}

.pager { display: flex; justify-content: space-between; margin-top: 14px; }
.pager a {
  padding: 9px 18px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-weight: 550;
  font-size: 14px;
}
.pager a:hover { text-decoration: none; border-color: var(--accent); }
.pager .spacer { flex: 1; }

.delta {
  display: inline-block;
  min-width: 74px;
  margin-right: 10px;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 650;
  text-align: center;
  background: var(--raised);
  color: var(--muted);
}
.delta-add { background: var(--ok-bg); color: var(--ok-ink); }
.delta-del { background: var(--bad-bg); color: var(--bad-ink); }
.delta-mod { background: var(--note-bg); color: var(--note-ink); }

/* ── notices ────────────────────────────────────────────────────────────── */

.empty, .notice {
  padding: 40px 24px;
  text-align: center;
  color: var(--muted);
}

.notice strong { color: var(--ink); display: block; font-size: 18px; margin-bottom: 6px; }
.welcome { margin-top: 48px; }

.foot {
  margin: 48px 0 30px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12.5px;
}

@media (max-width: 640px) {
  .wrap { padding: 0 12px; }
  td.when { display: none; }
  .repo-title { font-size: 22px; }
  .doc { padding: 24px 18px; font-size: 16px; }
  .pulse-meta { display: none; }
}
