/* ===========================================================================
   read-only-git — 主题层

   视觉语言对齐 GitHub 的公开设计规范：1px 细边框、6px 圆角、灰底面板头、
   选中 tab 用底部色条标记。配色取 GitHub 的实际色值，样式全部自己写。

   换肤：改下面这段变量即可。
   =========================================================================== */

:root {
  --bg:                #ffffff;
  --bg-subtle:         #f6f8fa;
  --bg-inset:          #f6f8fa;
  --text:              #1f2328;
  --text-muted:        #59636e;
  --border:            #d1d9e0;
  --border-strong:     #b7bfc7;
  --accent:            #0969da;
  --accent-soft:       #ddf4ff;
  --accent-mark:       #fd8c73;
  --success:           #1a7f37;
  --danger:            #cf222e;
  --warn:              #9a6700;
  --pill-bg:           #eff2f5;
  --hover:             #f6f8fa;

  --radius:            6px;
  --radius-sm:         4px;

  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
          "Liberation Mono", "Courier New", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica,
          Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;

  --page-width:        1280px;
  --side-width:        296px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:            #0d1117;
    --bg-subtle:     #151b23;
    --bg-inset:      #151b23;
    --text:          #f0f6fc;
    --text-muted:    #9198a1;
    --border:        #3d444d;
    --border-strong: #656c76;
    --accent:        #4493f8;
    --accent-soft:   #121d2f;
    --accent-mark:   #f78166;
    --success:       #3fb950;
    --danger:        #f85149;
    --warn:          #d29922;
    --pill-bg:       #212830;
    --hover:         #151b23;
  }
}

:root[data-theme="dark"] {
  --bg:            #0d1117;
  --bg-subtle:     #151b23;
  --bg-inset:      #151b23;
  --text:          #f0f6fc;
  --text-muted:    #9198a1;
  --border:        #3d444d;
  --border-strong: #656c76;
  --accent:        #4493f8;
  --accent-soft:   #121d2f;
  --accent-mark:   #f78166;
  --success:       #3fb950;
  --danger:        #f85149;
  --warn:          #d29922;
  --pill-bg:       #212830;
  --hover:         #151b23;
}

/* --- base ---------------------------------------------------------------- */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

code, pre, .mono { font-family: var(--mono); font-size: 0.92em; }

.muted { color: var(--text-muted); }

h1 { font-size: 20px; font-weight: 600; margin: 0 0 8px; }
h2 { font-size: 16px; font-weight: 600; margin: 0 0 8px; }
h3 { font-size: 14px; font-weight: 600; margin: 0 0 8px; }

/* --- 外层框架 ------------------------------------------------------------ */

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px max(16px, calc((100% - var(--page-width)) / 2));
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
  flex-wrap: wrap;
}

.brand {
  font-weight: 600;
  color: var(--text);
  font-size: 14px;
}

.crumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 14px;
}

.crumbs .sep { color: var(--text-muted); }

.page {
  max-width: var(--page-width);
  margin: 0 auto;
  padding: 24px 16px 64px;
}

.footer {
  max-width: var(--page-width);
  margin: 0 auto;
  padding: 24px 16px 48px;
  color: var(--text-muted);
  font-size: 12px;
  border-top: 1px solid var(--border);
}

/* --- 仓库头 -------------------------------------------------------------- */

.repo-header { margin-bottom: 16px; }

.repo-title {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.repo-mark { font-size: 18px; color: var(--text-muted); }

.repo-name { font-size: 20px; font-weight: 600; }

.repo-desc {
  margin: 6px 0 0;
  color: var(--text-muted);
  font-size: 14px;
  max-width: 820px;
}

.pill {
  display: inline-block;
  padding: 0 7px;
  font-size: 12px;
  font-weight: 500;
  line-height: 18px;
  color: var(--text-muted);
  background: var(--pill-bg);
  border: 1px solid var(--border);
  border-radius: 2em;
  white-space: nowrap;
}

.pill-muted { color: var(--text-muted); }

/* --- tab 导航 ------------------------------------------------------------ */

.repo-nav {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
  overflow-x: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  color: var(--text);
  font-size: 14px;
  border-bottom: 2px solid transparent;
  border-radius: var(--radius) var(--radius) 0 0;
  white-space: nowrap;
}

.nav-item:hover {
  background: var(--hover);
  text-decoration: none;
  border-bottom-color: var(--border-strong);
}

.nav-item.is-active {
  font-weight: 600;
  border-bottom-color: var(--accent-mark);
}

.nav-count {
  padding: 0 6px;
  font-size: 12px;
  font-weight: 500;
  line-height: 18px;
  background: var(--pill-bg);
  border: 1px solid var(--border);
  border-radius: 2em;
  color: var(--text-muted);
}

/* --- 两栏 ---------------------------------------------------------------- */

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--side-width);
  gap: 24px;
  align-items: start;
}

.layout-main { min-width: 0; }
.layout-side { position: sticky; top: 68px; }

@media (max-width: 1012px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .layout-side { position: static; }
}

/* --- panel --------------------------------------------------------------- */

.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
  background: var(--bg);
}

/* 面板不能用 overflow: hidden 来修圆角：那样会把内部浮层（比如 ref 下拉）
   连同它溢出边框的部分一起剪掉，且被剪掉的部分点不到。
   改成让首尾子元素各自贴合圆角。 */
.panel > :first-child {
  border-top-left-radius: calc(var(--radius) - 1px);
  border-top-right-radius: calc(var(--radius) - 1px);
}

.panel > :last-child {
  border-bottom-left-radius: calc(var(--radius) - 1px);
  border-bottom-right-radius: calc(var(--radius) - 1px);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 16px;
  background: var(--bg-inset);
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  flex-wrap: wrap;
}

.panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.doc-ico { font-size: 14px; }

/* --- 文件工具栏 ---------------------------------------------------------- */

.file-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  background: var(--bg-inset);
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  flex-wrap: wrap;
}

.branch-chip {
  padding: 3px 10px;
  font-family: var(--mono);
  font-size: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
}

/* --- ref 选择器 ---------------------------------------------------------- */

.ref-wrap {
  position: relative;
  display: inline-flex;
}

.ref-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font: inherit;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
  padding: 3px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.ref-button:hover { background: var(--bg-subtle); }

.ref-caret {
  font-size: 10px;
  opacity: .65;
}

.ref-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 40;
  min-width: 220px;
  max-height: 320px;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .14);
  overflow: hidden;
}

/* hidden 属性只是 UA 样式里的 [hidden]{display:none}，优先级最低，
   会被上面的 display:flex 盖掉——表现得就像菜单永远展开、点也切不动。
   这里显式让 [hidden] 生效。 */
.ref-menu[hidden] { display: none; }

/* 分支 / 标签两个平级分页，避免两组混在一列里分不清 */
.ref-tabs {
  display: flex;
  flex: none;
  padding: 4px 4px 0;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
}

.ref-tab {
  flex: 1;
  font: inherit;
  font-size: 12px;
  padding: 6px 8px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
}

.ref-tab:hover { color: var(--text); }

.ref-tab.is-active {
  color: var(--text);
  font-weight: 600;
  border-bottom-color: var(--accent-mark);
}

.ref-menu-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px 0;
  /* Firefox */
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

/* 默认滚动条带一层白底，在菜单里很抢眼；把轨道改成透明 */
.ref-menu-list::-webkit-scrollbar { width: 8px; }
.ref-menu-list::-webkit-scrollbar-track { background: transparent; }
.ref-menu-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}
.ref-menu-list::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

.ref-menu-empty {
  padding: 10px 12px;
  font-size: 12px;
  color: var(--text-muted);
}

.ref-menu-item {
  display: block;
  padding: 5px 12px;
  font-size: 13px;
  color: var(--text);
  text-decoration: none;
}

.ref-menu-item:hover { background: var(--bg-subtle); }
.ref-menu-item.is-current { font-weight: 600; }

.toolbar-commit {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}

.toolbar-right { white-space: nowrap; }

/* --- 文件列表 ------------------------------------------------------------ */

.file-list { list-style: none; margin: 0; padding: 0; }

.file-list li { border-bottom: 1px solid var(--border); }
.file-list li:last-child { border-bottom: none; }

.file-list a {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  color: var(--text);
  font-size: 13px;
}

.file-list a:hover { background: var(--hover); text-decoration: none; }

.file-icon { text-align: center; color: var(--text-muted); }
.file-icon.is-dir { color: var(--accent); }

.file-name {
  font-family: var(--mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-name.is-dir { color: var(--accent); }

.file-sha {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-muted);
}

/* --- blob ---------------------------------------------------------------- */

.blob-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 16px;
  background: var(--bg-inset);
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  flex-wrap: wrap;
}

.blob-path { font-family: var(--mono); }

.blob-meta { display: flex; align-items: center; gap: 10px; }

.blob-image { padding: 16px; text-align: center; background: var(--bg); }
.blob-image img { max-width: 100%; }

pre.blob {
  margin: 0;
  padding: 16px;
  overflow-x: auto;
  background: var(--bg);
  line-height: 1.45;
  tab-size: 4;
}

pre.blob .line-no {
  display: inline-block;
  width: 3.5em;
  margin-right: 14px;
  text-align: right;
  color: var(--text-muted);
  user-select: none;
}

.notice {
  padding: 16px;
  background: var(--bg-inset);
  color: var(--text-muted);
  font-size: 13px;
}

.binary-note { color: var(--warn); }

.error {
  padding: 16px;
  border: 1px solid var(--danger);
  border-radius: var(--radius);
  color: var(--danger);
  background: var(--bg-subtle);
  font-family: var(--mono);
  font-size: 13px;
  white-space: pre-wrap;
}

/* --- 提交历史 ------------------------------------------------------------ */

.commit-list { list-style: none; margin: 0; padding: 0; }

.commit-list li {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}

.commit-list li:last-child { border-bottom: none; }

.commit-body { flex: 1; min-width: 0; }

.commit-subject {
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.commit-meta {
  color: var(--text-muted);
  font-size: 12px;
  margin-top: 2px;
}

.commit-side {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  white-space: nowrap;
}

.commit-sha { color: var(--text-muted); }

/* --- 分支 / 标签列表 ----------------------------------------------------- */

.ref-list { list-style: none; margin: 0; padding: 0; }

.ref-list li {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}

.ref-list li:last-child { border-bottom: none; }

.ref-main { flex: 1; min-width: 0; }

.ref-name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 13px;
}

.ref-meta {
  color: var(--text-muted);
  font-size: 12px;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ref-meta code { color: var(--text-muted); }

.ref-side { font-size: 12px; white-space: nowrap; }

/* --- 右栏 ----------------------------------------------------------------- */

.side-panel { margin-bottom: 16px; }

.side-title {
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.side-body { font-size: 12px; }

.about-desc {
  margin: 0 0 12px;
  font-size: 14px;
  color: var(--text);
  overflow-wrap: break-word;
}

.about-list { list-style: none; margin: 0; padding: 0; }

.about-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  color: var(--text-muted);
  min-width: 0;
}

.about-list li a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.about-ico { flex: none; opacity: 0.8; }

.about-clone {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-muted);
  font-size: 12px;
}

.copy-btn {
  flex: none;
  font: inherit;
  font-size: 11px;
  padding: 1px 7px;
  color: var(--text-muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.copy-btn:hover { background: var(--hover); color: var(--text); }

.release-list { list-style: none; margin: 0; padding: 0; }

.release-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  min-width: 0;
}

.tag-ico { flex: none; opacity: 0.8; }

.release-list a {
  font-family: var(--mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.side-more { margin: 8px 0 0; }

/* --- 文档区（README / LICENSE / ...） ------------------------------------ */

.docs-tabs {
  display: flex;
  gap: 4px;
  padding: 0 8px;
  background: var(--bg-inset);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}

.docs-tab {
  font: inherit;
  font-size: 13px;
  padding: 8px 10px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
}

.docs-tab:hover { color: var(--text); }

.docs-tab.is-active {
  color: var(--text);
  font-weight: 600;
  border-bottom-color: var(--accent-mark);
}

.docs-panel { overflow: hidden; }

.docs-body { background: var(--bg); }

.docs-loading { margin: 0; padding: 16px 24px; }

/* 纯文本文档（LICENSE 之类）不渲染 Markdown，等宽排 */
pre.doc-text {
  margin: 0;
  padding: 20px 24px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

/* --- README -------------------------------------------------------------- */

.readme-panel .panel-head { justify-content: flex-start; }

.readme { padding: 8px 24px 24px; font-size: 15px; overflow-wrap: break-word; }

.docs-body > .readme { padding: 8px 24px 24px; }

.readme > *:first-child { margin-top: 0; }

.readme h1, .readme h2 {
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
  margin: 24px 0 16px;
}

.readme h1 { font-size: 26px; }
.readme h2 { font-size: 20px; }
.readme h3 { font-size: 17px; margin: 24px 0 16px; }
.readme p { margin: 0 0 16px; }
.readme ul, .readme ol { margin: 0 0 16px; padding-left: 28px; }
.readme li { margin: 4px 0; }

.readme img { max-width: 100%; }

.readme a { text-decoration: none; }
.readme a:hover { text-decoration: underline; }

.readme code {
  background: var(--pill-bg);
  padding: 0.2em 0.4em;
  border-radius: var(--radius-sm);
  font-size: 85%;
}

.readme pre {
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  overflow-x: auto;
}

.readme pre code { background: none; padding: 0; font-size: 100%; }

.readme blockquote {
  margin: 0 0 16px;
  padding: 0 16px;
  border-left: 4px solid var(--border);
  color: var(--text-muted);
}

.readme table {
  border-collapse: collapse;
  margin-bottom: 16px;
  display: block;
  overflow-x: auto;
}

.readme th, .readme td {
  border: 1px solid var(--border);
  padding: 6px 13px;
}

.readme th { font-weight: 600; background: var(--bg-inset); }

.readme hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 24px 0;
}

/* --- 首页 ---------------------------------------------------------------- */

.repo-list { list-style: none; margin: 0; padding: 0; }

.repo-list li {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  background: var(--bg);
}

.repo-list li:hover { border-color: var(--border-strong); }

.repo-list a { display: block; padding: 14px 16px; color: inherit; }
.repo-list a:hover { text-decoration: none; background: var(--hover); }

.repo-list .name {
  font-weight: 600;
  font-family: var(--mono);
  color: var(--accent);
  font-size: 15px;
}

.repo-list .desc {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 4px;
}

/* --- 杂项 ---------------------------------------------------------------- */

.btn {
  font: inherit;
  font-size: 12px;
  padding: 3px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
}

.btn:hover { background: var(--hover); text-decoration: none; }

.crumbs + .panel, .crumbs ~ .panel { margin-top: 0; }

.layout-main > .crumbs { margin-bottom: 16px; }
