@font-face {
  font-family: "Manrope";
  src: url("https://cdn.jsdelivr.net/npm/manrope@2.0.0/complete/manrope-regular.woff2")
    format("woff2");
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Manrope";
  src: url("https://cdn.jsdelivr.net/npm/manrope@2.0.0/complete/manrope-bold.woff2")
    format("woff2");
  font-weight: bold;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light dark;

  --bg-color: #ffffff;
  --header-bg: #f6f8fa;
  --subtle-bg: #f6f8fa;
  --border-color: #d0d7de;
  --border-muted: #d8dee4;
  --text-color: #1f2328;
  --muted-color: #59636e;
  --link-color: #0969da;
  --button-bg: #f6f8fa;
  --button-hover-bg: #f3f4f6;
  --selected-border: #fd8c73;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg-color);
}

body {
  margin: 0;
  color: var(--text-color);
  background: var(--bg-color);
  font-family:
    "Manrope", "Noto Sans SC Variable", "Noto Sans SC",
    "Noto Sans Sinhala Variable", "Noto Sans Sinhala", ui-sans-serif, system-ui,
    sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol",
    "Noto Color Emoji";
  font-size: 14px;
  line-height: 1.5;
}

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

a:hover {
  text-decoration: underline;
}

/* 顶栏 */

.site-header {
  color: var(--text-color);
  background: var(--header-bg);
  border-bottom: 1px solid var(--border-color);
}

.site-header-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 64px;
  padding: 12px 16px;
}

.github-logo {
  display: inline-flex;
  flex: none;
  color: var(--text-color);
}

.site-search {
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(350px, 40vw);
  min-height: 32px;
  padding: 5px 12px;
  color: var(--muted-color);
  background: var(--bg-color);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 12px;
}

.search-icon {
  font-size: 18px;
  line-height: 1;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

.header-actions a {
  color: var(--text-color);
  font-weight: 600;
}

/* 仓库标题 */

.repo-header {
  background: var(--header-bg);
  border-bottom: 1px solid var(--border-color);
}

.repo-header-inner {
  padding: 16px 32px 8px;
}

.repo-title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 16px;
}

.repo-title a {
  display: inline-block;
  color: var(--text-color);
  background: var(--header-bg);
  border-radius: 3px;
  padding: 3px 6px;
  text-decoration-line: none;
}

.repo-title a:hover {
  background: var(--bg-color);
}

.repo-title svg {
  width: 16px;
}

.repo-name {
  font-weight: 600;
}

.visibility-badge {
  margin-left: 4px;
  padding: 1px 7px;
  color: var(--muted-color);
  border: 1px solid var(--border-color);
  border-radius: 999px;
  font-size: 10px;
  font-weight: 500;
}

/* 标签页 */

.repo-tabs {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  padding: 0 24px;
  overflow-x: auto;
  scrollbar-width: none;
}

.repo-tabs::-webkit-scrollbar {
  display: none;
}

.repo-tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex: none;
  gap: 7px;
  min-height: 48px;
  padding: 8px 12px;
  color: var(--text-color);
  border-radius: 6px 6px 0 0;
  font-weight: 500;
}

.repo-tab:hover {
  background: rgb(208 215 222 / 32%);
  text-decoration: none;
}

.repo-tab.active {
  font-weight: 600;
}

.repo-tab.active::after {
  position: absolute;
  right: 8px;
  bottom: -1px;
  left: 8px;
  height: 2px;
  background: var(--selected-border);
  border-radius: 2px 2px 0 0;
  content: "";
}

/* 主体 */

.repo-content {
  width: min(100% - 32px, 1280px);
  margin: 24px auto 48px;
}

.branch-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.branch-button,
.code-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 5px 12px;
  color: var(--text-color);
  background: var(--button-bg);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  box-shadow: 0 1px 0 rgb(31 35 40 / 4%);
  font-size: 14px;
  font-weight: 500;
}

.branch-button:hover,
.code-button:hover {
  background: var(--button-hover-bg);
  text-decoration: none;
}

.code-button {
  color: #ffffff;
  background: #1f883d;
  border-color: rgb(31 35 40 / 15%);
}

.code-button:hover {
  color: #ffffff;
  background: #1a7f37;
}

.branch-button svg,
.code-button svg {
  display: block;
  width: 16px;
}

/* 正文容器 */
.markdown-body {
  width: 100%;
  max-width: none;
  min-width: 0;
  padding: 32px;
  color: var(--text-color);
  background: var(--bg-color);
  font-family:
    "Manrope", "Noto Sans SC Variable", "Noto Sans SC",
    "Noto Sans Sinhala Variable", "Noto Sans Sinhala", ui-sans-serif, system-ui,
    sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol",
    "Noto Color Emoji" !important;
}

.markdown-body code,
.markdown-body samp,
.markdown-body tt {
  font-family:
    Ubuntu Mono,
    等距更纱黑体 SC,
    Noto Sans Sinhala,
    ui-monospace,
    SFMono-Regular,
    SF Mono,
    Menlo,
    Consolas,
    Liberation Mono,
    monospace !important;
}

/*
 * 不要使用下面这种全局覆盖：
 *
 * .markdown-body * {
 *   all: unset;
 * }
 *
 * 或：
 *
 * .markdown-body h1,
 * .markdown-body h2,
 * .markdown-body p {
 *   margin: 0;
 * }
 */

/* 页面标题 */

.post-header,
.collection-header {
  margin-bottom: 24px;
}

.post-header h1,
.collection-header h1 {
  margin-top: 0;
}

.post-meta,
.collection-header > p {
  color: var(--muted-color);
}

/* 文档与推文列表 */

.github-file-list {
  overflow: hidden;
  margin: 16px 0;
  border: 1px solid var(--border-color);
  border-radius: 6px;
}

.github-file-row {
  display: grid;
  grid-template-columns:
    20px
    minmax(160px, 0.55fr)
    minmax(0, 1fr)
    auto;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 8px 16px;
  color: var(--text-color);
  border-bottom: 1px solid var(--border-color);
}

.github-file-row:last-child {
  border-bottom: 0;
}

.github-file-row:hover {
  background: var(--subtle-bg);
  text-decoration: none;
}

.file-icon {
  display: inline-flex;
  color: var(--muted-color);
}

.file-name {
  min-width: 0;
  overflow: hidden;
  color: var(--link-color);
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-description,
.file-date {
  min-width: 0;
  overflow: hidden;
  color: var(--muted-color);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 文章翻页 */

.post-navigation {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 24px;
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--border-color);
}

.post-navigation-next {
  text-align: right;
}

.post-navigation-label {
  display: block;
  margin-bottom: 4px;
  color: var(--muted-color);
  font-size: 12px;
}

/* 移动端 */

@media (max-width: 767px) {
  .markdown-body {
    padding: 16px;
  }

  .github-file-row {
    grid-template-columns: 20px minmax(0, 1fr);
  }

  .file-description,
  .file-date {
    display: none;
  }

  .post-navigation {
    grid-template-columns: 1fr;
  }

  .post-navigation-next {
    text-align: left;
  }
}

/* 文章卡片 */

.article-box {
  overflow: hidden;
  border: 1px solid var(--border-color);
  border-radius: 6px;
}

.article-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 48px;
  padding: 8px 16px;
  background: var(--subtle-bg);
  border-bottom: 1px solid var(--border-color);
}

.article-header a {
  font-size: 12px;
}

.article-content {
  padding: 32px;
}

.markdown-body {
  max-width: none;
  color: var(--text-color);
  background: transparent;
}

/* 避免 Markdown 图片撑宽 */

.markdown-body img {
  max-width: 100%;
}

.markdown-body blockquote.markdown-alert {
  padding: 0.5rem 1rem;
  color: inherit;
  background: transparent;
  border-left: 0.25rem solid var(--alert-color);
}

.markdown-body .markdown-alert > :first-child {
  margin-top: 0;
}

.markdown-body .markdown-alert > :last-child {
  margin-bottom: 0;
}

.markdown-body .markdown-alert-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.5rem;
  color: var(--alert-color);
  font-weight: 500;
  line-height: 1;
}

.markdown-body .markdown-alert-icon {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 1rem;
  height: 1rem;
  color: currentColor;
}

.markdown-body .markdown-alert-icon svg {
  display: block;
  width: 1rem;
  height: 1rem;
  overflow: visible;
  fill: currentColor;
}

/* Note */

.markdown-body .markdown-alert-note {
  --alert-color: #0969da;
}

/* Tip */

.markdown-body .markdown-alert-tip {
  --alert-color: #1a7f37;
}

/* Important */

.markdown-body .markdown-alert-important {
  --alert-color: #8250df;
}

/* Warning */

.markdown-body .markdown-alert-warning {
  --alert-color: #9a6700;
}

/* Caution */

.markdown-body .markdown-alert-caution {
  --alert-color: #cf222e;
}

@media (prefers-color-scheme: dark) {
  .markdown-alert-note {
    --alert-color: #4493f8;
  }

  .markdown-alert-tip {
    --alert-color: #3fb950;
  }

  .markdown-alert-important {
    --alert-color: #ab7df8;
  }

  .markdown-alert-warning {
    --alert-color: #d29922;
  }

  .markdown-alert-caution {
    --alert-color: #f85149;
  }
}

.counter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  background: rgb(175 184 193 / 20%);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
}

.breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
  min-width: 0;
}

.breadcrumb strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.github-file-list {
  overflow: hidden;
  margin: 16px 0;
  border: 1px solid var(--border-color);
  border-radius: 6px;
}

.github-file-row {
  display: grid;
  grid-template-columns: 20px minmax(160px, 0.6fr) minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 8px 16px;
  color: var(--text-color);
  border-bottom: 1px solid var(--border-color);
}

.github-file-row:last-child {
  border-bottom: 0;
}

.github-file-row:hover {
  background: var(--subtle-bg);
  text-decoration: none;
}

.file-icon {
  display: inline-flex;
  color: var(--muted-color);
}

.file-name {
  min-width: 0;
  overflow: hidden;
  color: var(--link-color);
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-description,
.file-date {
  min-width: 0;
  overflow: hidden;
  color: var(--muted-color);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.post-meta {
  color: var(--muted-color);
}

.post-navigation {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--border-color);
}

.post-navigation > div:last-child {
  text-align: right;
}

.post-navigation span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted-color);
  font-size: 12px;
}

@media (max-width: 640px) {
  .github-file-row {
    grid-template-columns: 20px minmax(0, 1fr);
  }

  .file-description,
  .file-date {
    display: none;
  }

  .post-navigation {
    grid-template-columns: 1fr;
  }

  .post-navigation > div:last-child {
    text-align: left;
  }
}

/* 页脚 */

.site-footer {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 24px;
  width: min(100% - 32px, 1280px);
  margin: 0 auto;
  padding: 32px 16px;
  color: var(--muted-color);
  border-top: 1px solid var(--border-muted);
  font-size: 12px;
}

.site-footer address {
  display: flex;
  justify-items: center;
  align-items: center;
  gap: 6px;
}

.site-footer address a {
  color: var(--text-color);
}

.site-footer address a:hover {
  color: var(--link-color);
}

.site-footer address a img {
  width: 12px;
}

.site-footer address a svg {
  width: 16px;
}

/* 深色模式 */

@media (prefers-color-scheme: dark) {
  :root {
    --bg-color: #0d1117;
    --header-bg: #010409;
    --subtle-bg: #161b22;
    --border-color: #3d444d;
    --border-muted: #21262d;
    --text-color: #f0f6fc;
    --muted-color: #9198a1;
    --link-color: #4493f8;
    --button-bg: #212830;
    --button-hover-bg: #262c36;
    --selected-border: #f78166;
  }

  .site-search {
    background: #0d1117;
  }

  .repo-tab:hover {
    background: rgb(177 186 196 / 12%);
  }
}

/* 移动端 */

@media (max-width: 767px) {
  .site-header-inner {
    min-height: 56px;
  }

  .site-search {
    display: none;
  }

  .repo-header-inner {
    padding: 14px 16px 6px;
  }

  .repo-title {
    font-size: 14px;
  }

  .repo-tabs {
    padding: 0 8px;
  }

  .repo-content {
    width: min(100% - 16px, 1280px);
    margin-top: 16px;
  }

  .article-content {
    padding: 16px;
  }

  .site-footer {
    flex-direction: column;
    align-items: center;
    gap: 8px;
  }
}
