:root {
  --bg: #fff;
  --alt: #f6f6f4;
  --ink: #1d1d1b;
  --muted: #6e6e69;
  --line: #dcdcd7;
  --link: #1f4fbf;
  --err: #b42318;
  --err-bg: #fdf1ef;
  --ok: #2f6b2f;
  --ok-bg: #eef5ec;
  --hl: #fff6d6;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light dark;
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Noto Sans", sans-serif;
  color: var(--ink);
  background: var(--bg);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161615;
    --alt: #1f1f1d;
    --ink: #e6e6e1;
    --muted: #9a9a93;
    --line: #34342f;
    --link: #8cb0ff;
    --err: #ff8a7a;
    --err-bg: #2c1a17;
    --ok: #8fcf8f;
    --ok-bg: #1a2a1a;
    --hl: #3a3420;
  }
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 20px; font-weight: 600; }
h2 { font-size: 15px; font-weight: 600; }
p + p { margin-top: 8px; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre, .mono { font-family: var(--mono); font-size: 13px; }
pre { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.err { color: var(--err); }
.mt { margin-top: 16px; }
.mt-s { margin-top: 4px; }
.mb { margin-bottom: 12px; }
.light { font-weight: 400; }
.col { max-width: 480px; }
select.auto { width: auto; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Header */
.top { border-bottom: 1px solid var(--line); }
.top-inner { max-width: 1040px; margin: 0 auto; padding: 0 16px; height: 48px; display: flex; align-items: center; gap: 24px; }
.brand { font-family: var(--mono); font-weight: 600; color: var(--ink); }
.brand:hover { text-decoration: none; }
.nav { display: flex; gap: 16px; }
.nav a { color: var(--muted); }
.nav a:hover, .nav a[aria-current=page] { color: var(--ink); text-decoration: none; }
.who { margin-left: auto; display: flex; align-items: center; gap: 12px; color: var(--muted); }
.who form { margin: 0; }
.linkish { border: 0; background: none; padding: 0; color: var(--link); cursor: pointer; }
.linkish:hover { text-decoration: underline; }

/* Layout */
main { max-width: 1040px; margin: 0 auto; padding: 24px 16px 48px; }
main.narrow { max-width: 380px; padding-top: 64px; }
.head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.head p { margin-top: 4px; }
.crumb { font-size: 13px; color: var(--muted); margin-bottom: 6px; display: block; }
section { margin-bottom: 32px; }
section > h2 { padding-bottom: 6px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
section > h2 + p { margin-bottom: 12px; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 0 40px; }

/* Messages */
.msg { padding: 8px 12px; border: 1px solid var(--line); border-left-width: 3px; margin-bottom: 16px; background: var(--alt); overflow-wrap: anywhere; }
.msg.ok { border-color: var(--ok); background: var(--ok-bg); }
.msg.bad { border-color: var(--err); background: var(--err-bg); color: var(--err); }

/* Forms */
.form { display: flex; flex-direction: column; gap: 12px; max-width: 480px; }
label { display: block; font-weight: 500; }
label > input, label > select, label > textarea { margin-top: 4px; }
input:not([type=hidden]):not([type=checkbox]), select, textarea {
  width: 100%; min-width: 0; padding: 6px 8px; border: 1px solid var(--line); border-radius: 3px; background: var(--bg);
}
input:focus, select:focus, textarea:focus { border-color: var(--link); outline: none; }
textarea { resize: vertical; }
.hint { display: block; margin-top: 4px; font-size: 12px; font-weight: 400; color: var(--muted); }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 0; }
.row input:not([type=hidden]) { width: auto; flex: 1; min-width: 140px; max-width: 320px; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.btn {
  display: inline-flex; align-items: center; height: 30px; padding: 0 12px; border: 1px solid var(--line); border-radius: 3px;
  background: var(--alt); color: var(--ink); cursor: pointer; white-space: nowrap; font-size: 13px;
}
.btn:hover { border-color: var(--muted); text-decoration: none; }
.btn.main { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.btn.main:hover { opacity: .88; }
.btn.bad { color: var(--err); background: var(--bg); }
.btn.bad:hover { border-color: var(--err); }
.btn.sm { height: 26px; padding: 0 8px; font-size: 12px; }
.form > .btn { align-self: flex-start; }

/* Tags */
.tag { display: inline-block; padding: 0 5px; border: 1px solid var(--line); border-radius: 3px; font-size: 11px; line-height: 17px; color: var(--muted); vertical-align: 1px; white-space: nowrap; }
.tag.ok { color: var(--ok); border-color: currentColor; }

/* Tables and lists */
.box { border: 1px solid var(--line); border-radius: 4px; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 7px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-weight: 500; font-size: 12px; color: var(--muted); background: var(--alt); }
tr:last-child > td { border-bottom: 0; }
tbody tr:hover > td { background: var(--alt); }
td.empty { color: var(--muted); padding: 24px 12px; text-align: center; }
.list { list-style: none; margin: 0; padding: 0; }
.list > li { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list > li:last-child { border-bottom: 0; }
.list > li.empty { color: var(--muted); }
.list p { margin-top: 2px; overflow-wrap: anywhere; }

/* Repository */
.repo-head { margin-bottom: 12px; }
.repo-head h1 { font-weight: 400; overflow-wrap: anywhere; }
.repo-head h1 b { font-weight: 600; }
.repo-head p { margin-top: 4px; }
.tabs { display: flex; gap: 20px; box-shadow: inset 0 -1px var(--line); margin-bottom: 16px; overflow-x: auto; overflow-y: hidden; }
.tabs a { padding: 6px 0; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a[aria-current=page] { color: var(--ink); border-bottom-color: var(--ink); }
.clone { display: flex; gap: 6px; align-items: center; margin-bottom: 16px; max-width: 560px; }
.clone input { font-family: var(--mono); font-size: 12px; }
.bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; flex-wrap: wrap; }
.bar input { max-width: 180px; height: 26px; padding: 2px 6px; font-size: 12px; }
.path { font-family: var(--mono); font-size: 13px; overflow-wrap: anywhere; }
.tree td:first-child { font-family: var(--mono); font-size: 13px; overflow-wrap: anywhere; }
.tree td:last-child { width: 1%; }
.tree a.dir { font-weight: 600; }
.readme { margin-top: 24px; }
.readme > .label, .file > .label { padding: 7px 12px; border-bottom: 1px solid var(--line); background: var(--alt); font-size: 12px; display: flex; justify-content: space-between; gap: 12px; overflow-wrap: anywhere; }
.md { padding: 16px 20px; overflow-wrap: anywhere; line-height: 1.6; }
.md > :first-child { margin-top: 0; }
.md h1, .md h2, .md h3, .md h4 { margin: 20px 0 8px; }
.md h1 { font-size: 22px; }
.md h2 { font-size: 18px; border: 0; }
.md p, .md ul, .md ol, .md pre, .md blockquote, .md table { margin: 10px 0; }
.md code { background: var(--alt); padding: 1px 4px; border-radius: 3px; }
.md pre { background: var(--alt); padding: 12px; overflow: auto; }
.md pre code { padding: 0; background: none; }
.md blockquote { margin-left: 0; padding-left: 12px; border-left: 3px solid var(--line); color: var(--muted); }
.md table { width: auto; border: 1px solid var(--line); }
.code { overflow: auto; }
.code table { font-family: var(--mono); font-size: 12px; line-height: 20px; }
.code td { padding: 0; border: 0; }
.code tbody tr:hover > td { background: none; }
.code tr:target > td { background: var(--hl); }
.code .ln { width: 1%; padding: 0 10px; text-align: right; user-select: none; border-right: 1px solid var(--line); }
.code .ln a { color: var(--muted); }
.code pre { padding: 0 12px; white-space: pre; font-size: 12px; min-height: 20px; }
.placeholder { padding: 32px 16px; text-align: center; color: var(--muted); }
.placeholder pre { display: inline-block; text-align: left; margin-top: 12px; padding: 10px 14px; background: var(--alt); border-radius: 3px; color: var(--ink); max-width: 100%; overflow: auto; }
.commit-msg { white-space: pre-wrap; overflow-wrap: anywhere; margin: 12px 0; color: var(--muted); font-size: 13px; }
.diff { padding: 12px; overflow: auto; font-size: 12px; line-height: 1.5; tab-size: 4; }
.pager { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }

/* Secrets and misc */
.secret { border: 1px solid var(--ok); background: var(--ok-bg); padding: 12px; border-radius: 4px; margin-bottom: 24px; }
.secret h2 { border: 0; padding: 0; margin-bottom: 4px; }
.secret textarea, textarea.mono { font-family: var(--mono); font-size: 12px; margin: 8px 0; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.stats b { display: block; font-size: 17px; font-weight: 600; }
.audit td:last-child { font-family: var(--mono); font-size: 11px; white-space: pre-wrap; overflow-wrap: anywhere; max-width: 360px; }
.danger > div { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.danger > div:last-child { border-bottom: 0; }
.danger input { max-width: 240px; }
details { margin: 8px 0; color: var(--muted); font-size: 12px; }
summary { cursor: pointer; }
hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }
.toast { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); padding: 6px 12px; border-radius: 3px; background: var(--ink); color: var(--bg); font-size: 12px; display: none; z-index: 10; }
.toast.visible { display: block; }
.import-root { font-family: var(--mono); font-size: 13px; padding: 6px 10px; background: var(--alt); border-radius: 3px; display: inline-block; overflow-wrap: anywhere; margin: 8px 0; }
.import-pick { max-height: 520px; overflow: auto; margin: 12px 0; }
.import-pick th { position: sticky; top: 0; z-index: 1; }
.import-pick td:first-child { width: 1%; }
.import-pick input[type=checkbox] { width: 15px; height: 15px; margin: 2px 0 0; accent-color: var(--ink); }
.import-result { max-width: 360px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 12px; }

@media (max-width: 720px) {
  .top-inner { height: auto; flex-wrap: wrap; gap: 8px 16px; padding: 10px 16px; }
  .nav { order: 3; width: 100%; overflow-x: auto; }
  main { padding-top: 16px; }
  main.narrow { padding-top: 32px; }
  .cols { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr 1fr; }
  .danger > div, .list > li { flex-direction: column; align-items: flex-start; gap: 8px; }
  .danger form, .list form.row { width: 100%; }
  .row input:not([type=hidden]) { max-width: none; }
  th, td { padding: 6px 8px; }
  .import-pick table, .import-jobs { min-width: 640px; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
