:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --line: #d9dde3;
  --text: #1f2328;
  --muted: #656d76;
  --link: #0a5bd1;
  --accent: #d69e00;
  --accent-ink: #1f2937;
  --add-bg: #e6ffec; --add-fg: #116329;
  --del-bg: #ffebe9; --del-fg: #a3202a;
  --hunk-bg: #eef3ff;
  --hl: #fff8c5;
  --radius: 8px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --sans: -apple-system, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1216; --panel: #161b22; --line: #2d333b; --text: #e6edf3; --muted: #8b949e;
    --link: #58a6ff; --accent: #f0b429; --accent-ink: #0f1216;
    --add-bg: #12261e; --add-fg: #56d364; --del-bg: #2d1416; --del-fg: #ff7b72; --hunk-bg: #1c2333; --hl: #3b3419;
  }
}
* { box-sizing: border-box; }
html { color-scheme: light dark; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 var(--sans); }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 600; line-height: 1.25; }
h1 { font-size: 20px; }
h2 { font-size: 17px; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 14px 0 6px; }
pre, code, .mono { font-family: var(--mono); font-size: 12.5px; }
pre { margin: 0; white-space: pre; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.spacer { flex: 1; }
.sep { color: var(--muted); margin: 0 6px; }
.inline { display: inline-flex; align-items: center; gap: 8px; margin: 0; }
.pad { padding: 16px; margin: 0; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 20px; }

/* header */
.top { background: var(--accent-ink); color: #fff; border-bottom: 3px solid var(--accent); }
.top .wrap { display: flex; align-items: center; gap: 16px; height: 52px; }
.brand { display: inline-flex; align-items: center; gap: 8px; color: #fff; font-weight: 600; font-size: 15px; }
.brand svg { color: var(--accent); }
.top .user { display: inline-flex; align-items: center; gap: 6px; color: #d0d7de; margin-right: 6px; }
.top .btn { background: transparent; color: #d0d7de; border-color: #3d444d; }
.foot { color: var(--muted); font-size: 12px; padding: 30px 20px; }
main.wrap { margin-top: 10px; padding: 20px 20px 40px; }

/* buttons & forms */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--text); font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap; line-height: 20px; }
.btn:hover { text-decoration: none; border-color: var(--muted); }
.btn.small { padding: 2px 8px; font-size: 12px; }
.btn.primary { background: var(--accent); color: #1f2328; border-color: transparent; }
.btn.disabled { opacity: .5; pointer-events: none; }
.btn.mono { font-family: var(--mono); }
summary.btn { list-style: none; }
summary::-webkit-details-marker { display: none; }
input, select { font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 5px 10px; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.form { display: flex; flex-direction: column; gap: 10px; padding: 16px; }
.form label { display: flex; flex-direction: column; gap: 4px; font-weight: 500; }
.form input { font-weight: 400; }
.form pre { background: var(--bg); padding: 10px; border-radius: 6px; overflow-x: auto; }
.flash { padding: 10px 14px; border-radius: 6px; border: 1px solid var(--line); background: var(--panel); margin: 0 0 16px; }
.flash.ok { border-color: var(--add-fg); }
.flash.error { border-color: var(--del-fg); color: var(--del-fg); }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 16px; overflow: hidden; }
.card-head { display: flex; align-items: center; gap: 8px; padding: 10px 14px; background: color-mix(in srgb, var(--panel) 85%, var(--bg)); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.card-head.col { flex-direction: column; align-items: stretch; }
.card-head .row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

/* login */
.login { max-width: 360px; margin: 60px auto; text-align: center; }
.login h1 { margin-bottom: 16px; }
.login .form { text-align: left; }

/* repo list */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 14px; position: relative; }
.count { display: inline-block; background: var(--line); color: var(--text); border-radius: 10px; padding: 0 7px; font-size: 12px; font-weight: 600; vertical-align: middle; }
.new-repo { position: relative; }
.new-repo .form { position: absolute; right: 0; top: 36px; width: 380px; max-width: calc(100vw - 40px); z-index: 20; box-shadow: 0 8px 24px rgba(0,0,0,.18); }
.repo-list { list-style: none; margin: 0; padding: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.repo-row { display: flex; justify-content: space-between; gap: 16px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.repo-row:last-child { border-bottom: 0; }
.repo-row p { margin: 4px 0 0; }
.repo-name { font-size: 16px; font-weight: 600; }
.repo-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; font-size: 12px; white-space: nowrap; }

/* repo header */
.repo-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 8px; }
.repo-head h1 a { color: var(--text); }
.desc-form { display: flex; gap: 6px; flex: 1; min-width: 260px; max-width: 520px; }
.desc-form input { flex: 1; font-size: 13px; padding: 3px 8px; background: transparent; border-color: transparent; }
.desc-form input:hover, .desc-form input:focus { border-color: var(--line); background: var(--panel); }
.desc-form button { visibility: hidden; }
.desc-form:focus-within button { visibility: visible; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { padding: 8px 12px; color: var(--text); border-bottom: 2px solid transparent; white-space: nowrap; }
.tab:hover { text-decoration: none; background: color-mix(in srgb, var(--panel) 60%, var(--bg)); }
.tab.active { border-bottom-color: var(--accent); font-weight: 600; }

.toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar label { display: inline-flex; align-items: center; gap: 6px; }
.path { font-size: 15px; }
.path strong { font-weight: 600; }

/* dropdown menus */
.ref-picker, .clone { position: relative; }
.menu { position: absolute; left: 0; top: calc(100% + 4px); z-index: 30; min-width: 240px; max-height: 360px; overflow-y: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.18); padding: 6px; }
.clone .menu { left: auto; right: 0; }
.menu.wide { min-width: 340px; }
.menu a { display: block; padding: 5px 10px; border-radius: 5px; color: var(--text); font-family: var(--mono); font-size: 12.5px; }
.menu a:hover { background: var(--bg); text-decoration: none; }
.menu a.current { font-weight: 700; }
.menu a.current::before { content: "✓ "; color: var(--accent); }
.menu-title { padding: 6px 10px 2px; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.menu-filter { width: 100%; margin-bottom: 4px; }
.copy-row { display: flex; gap: 6px; padding: 4px 6px; }
.copy-row input { flex: 1; font-family: var(--mono); font-size: 12px; }

/* layout columns */
.cols { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 20px; }
.side dl { margin: 0; }
.side dt { color: var(--muted); font-size: 12px; margin-top: 8px; }
.side dd { margin: 0; word-break: break-all; }
.side .contrib { list-style: none; padding: 0; margin: 0; }
.side .contrib li { display: flex; align-items: center; gap: 6px; padding: 3px 0; }
@media (max-width: 860px) { .cols { grid-template-columns: 1fr; } .side { order: -1; } }

.avatar { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; border-radius: 50%; background: var(--accent); color: #1f2328; font-size: 11px; font-weight: 700; vertical-align: middle; flex-shrink: 0; }
.pill { display: inline-block; padding: 0 8px; border: 1px solid var(--line); border-radius: 10px; font-size: 11px; font-family: var(--mono); background: var(--bg); }

/* file tree */
table { border-collapse: collapse; width: 100%; }
.tree td { padding: 7px 14px; border-top: 1px solid var(--line); vertical-align: middle; }
.tree tr:first-child td { border-top: 0; }
.tree .name { width: 32%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 0; }
.tree .name a { color: var(--text); }
.tree .msg { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 0; }
.tree .msg a { color: var(--muted); }
.tree .when { text-align: right; white-space: nowrap; width: 120px; }
.ico { display: inline-block; width: 18px; color: var(--muted); }
.ico.dir { color: var(--link); }
.latest .commit-link { color: var(--text); }

/* readme / markdown */
.readme .md { padding: 16px 24px; }
.md { line-height: 1.6; overflow-wrap: anywhere; }
.md h1, .md h2 { border-bottom: 1px solid var(--line); padding-bottom: 6px; margin: 20px 0 12px; font-size: 22px; }
.md h2 { font-size: 18px; }
.md h3 { font-size: 15px; text-transform: none; letter-spacing: 0; color: var(--text); margin: 18px 0 8px; }
.md h4, .md h5, .md h6 { margin: 14px 0 6px; }
.md p, .md ul, .md ol, .md table, .md blockquote { margin: 0 0 12px; }
.md pre { background: var(--bg); padding: 12px; border-radius: 6px; overflow-x: auto; margin: 0 0 12px; }
.md code { background: color-mix(in srgb, var(--line) 50%, transparent); padding: 1px 5px; border-radius: 4px; }
.md pre code { background: none; padding: 0; }
.md blockquote { border-left: 4px solid var(--line); padding: 0 12px; color: var(--muted); }
.md table { width: auto; }
.md th, .md td { border: 1px solid var(--line); padding: 5px 10px; }
.md img { max-width: 100%; }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }

/* code view */
.scroll { overflow-x: auto; }
table.code { font-family: var(--mono); }
table.code td { padding: 0; vertical-align: top; }
table.code .ln { width: 1%; min-width: 50px; text-align: right; padding: 0 10px; color: var(--muted); user-select: none; }
table.code .ln a { color: inherit; }
table.code .lc pre { padding: 0 12px; white-space: pre; line-height: 20px; tab-size: 4; background: transparent !important; }
table.code .lc code, table.code .lc code.hljs { display: inline; padding: 0; background: transparent !important; font-size: inherit; line-height: inherit; overflow: visible; }
table.code .ln { line-height: 20px; }
table.code tr.hl td { background: var(--hl); }
.blob-img { padding: 20px; text-align: center; background: repeating-conic-gradient(var(--bg) 0 25%, var(--panel) 0 50%) 0 0 / 20px 20px; }
.blob-img img { max-width: 100%; }

/* commits */
.day { color: var(--muted); font-size: 12px; margin: 14px 0 6px; padding-left: 4px; }
.commits { list-style: none; margin: 0; padding: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.commits li { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-top: 1px solid var(--line); }
.commits li:first-child { border-top: 0; }
.c-main { flex: 1; min-width: 0; }
.c-main .commit-link { color: var(--text); font-weight: 600; }
.c-side { display: flex; gap: 6px; }
.c-body { display: inline; margin-left: 6px; }
.c-body summary { display: inline-block; padding: 0 6px; background: var(--line); border-radius: 4px; cursor: pointer; font-size: 11px; }
.c-body pre { white-space: pre-wrap; margin: 6px 0; padding: 8px; background: var(--bg); border-radius: 6px; }
.c-fullbody { white-space: pre-wrap; color: var(--muted); }
.pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 16px 0; }

/* diffs */
.diff-summary { margin: 0 0 12px; }
.add { color: var(--add-fg); font-weight: 600; }
.del { color: var(--del-fg); font-weight: 600; }
.stat-list { list-style: none; margin: 6px 0 0; padding: 0; font-family: var(--mono); font-size: 12px; columns: 2; column-gap: 24px; }
.stat-list li { display: flex; gap: 8px; break-inside: avoid; }
.stat-list li a { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat-list .add, .stat-list .del { min-width: 40px; text-align: right; }
@media (max-width: 700px) { .stat-list { columns: 1; } }
.status { font-size: 11px; text-transform: uppercase; padding: 1px 6px; border-radius: 4px; background: var(--line); }
.status.added { background: var(--add-bg); color: var(--add-fg); }
.status.deleted { background: var(--del-bg); color: var(--del-fg); }
table.diff { font-family: var(--mono); }
table.diff td { padding: 0; vertical-align: top; }
table.diff .ln { width: 1%; min-width: 44px; text-align: right; padding: 0 8px; color: var(--muted); user-select: none; }
table.diff .lc pre { padding: 0 10px; line-height: 20px; white-space: pre-wrap; overflow-wrap: anywhere; tab-size: 4; }
table.diff tr.add td { background: var(--add-bg); }
table.diff tr.del td { background: var(--del-bg); }
table.diff tr.hunk td { background: var(--hunk-bg); color: var(--muted); padding: 2px 10px; font-size: 12px; }
table.diff tr.meta td { color: var(--muted); }

/* branches / tags */
.refs td { padding: 9px 14px; border-top: 1px solid var(--line); vertical-align: middle; }
.refs tr:first-child td { border-top: 0; }
.refs .msg { color: var(--muted); }
.refs .msg a { color: inherit; }
.refs .actions { text-align: right; white-space: nowrap; }
.refs .actions .btn { margin-left: 4px; }

@media (max-width: 600px) {
  .tree .msg { display: none; }
  .repo-row { flex-direction: column; }
  .repo-meta { align-items: flex-start; }
  .refs .actions { display: none; }
}
