/* === Repo Header === */
.repo-header {
  margin-bottom: 1rem;
}

.repo-title {
  font-size: 1.125rem;
  display: flex;
  align-items: center;
  gap: 0.375rem;
  flex-wrap: wrap;
}

.repo-desc {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-top: 0.375rem;
}

/* === Repo Nav tabs === */
.repo-nav {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.25rem;
  gap: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.repo-nav::-webkit-scrollbar { display: none; }

.repo-nav-link {
  padding: 0.6rem 1rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
}

.repo-nav-link:hover { color: var(--text); text-decoration: none; }
.repo-nav-link.active {
  color: var(--text);
  border-bottom-color: var(--accent);
  font-weight: 500;
}

/* === Repo toolbar === */
.repo-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.branch-selector select {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.375rem 0.625rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-family: var(--font-mono);
  cursor: pointer;
}

.repo-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

/* === File tree === */
.file-tree {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 1.25rem;
}

.file-tree-header {
  padding: 0.5rem 0.875rem;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
  color: var(--text-muted);
}

.file-tree-entry {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.4rem 0.875rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
  font-size: 0.875rem;
  transition: background 0.1s;
}

.file-tree-entry:last-child { border-bottom: none; }
.file-tree-entry:hover { background: var(--surface2); text-decoration: none; }

.file-icon { font-size: 1rem; flex-shrink: 0; }
.dir-icon { }

/* === README === */
.readme-container {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.readme-header {
  padding: 0.5rem 0.875rem;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
}

.readme-body { padding: 1.25rem; }

/* === Markdown body === */
.markdown-body h1 { font-size: 1.375rem; margin-bottom: 0.75rem; padding-bottom: 0.375rem; border-bottom: 1px solid var(--border); }
.markdown-body h2 { font-size: 1.125rem; margin-bottom: 0.625rem; padding-bottom: 0.25rem; border-bottom: 1px solid var(--border); }
.markdown-body h3 { font-size: 1rem; margin-bottom: 0.5rem; }
.markdown-body p { margin-bottom: 0.875rem; line-height: 1.7; }
.markdown-body ul, .markdown-body ol { margin-bottom: 0.875rem; padding-left: 1.5rem; }
.markdown-body li { margin-bottom: 0.25rem; }
.markdown-body code {
  background: var(--code-bg);
  padding: 0.125rem 0.375rem;
  border-radius: var(--radius-sm);
  font-size: 0.85em;
}
.markdown-body pre {
  background: var(--code-bg);
  padding: 1rem;
  border-radius: var(--radius);
  overflow-x: auto;
  margin-bottom: 0.875rem;
  border: 1px solid var(--border);
}
.markdown-body pre code { background: none; padding: 0; }
.markdown-body blockquote {
  border-left: 4px solid var(--border);
  padding-left: 1rem;
  color: var(--text-muted);
  margin-bottom: 0.875rem;
}
.markdown-body a { color: var(--accent); }
.markdown-body hr { border: none; border-top: 1px solid var(--border); margin: 1.25rem 0; }
.markdown-body strong { font-weight: 600; }
.markdown-body em { font-style: italic; }
.markdown-body table {
  border-collapse: collapse;
  margin-bottom: 0.875rem;
  overflow-x: auto;
  display: block;
  width: max-content;
  max-width: 100%;
}
.markdown-body th, .markdown-body td {
  border: 1px solid var(--border);
  padding: 0.375rem 0.75rem;
}
.markdown-body th {
  background: var(--code-bg);
  font-weight: 600;
  text-align: left;
}
.markdown-body tr:nth-child(2n) { background: var(--code-bg); }

/* === Code block === */
.code-block {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  overflow-x: auto;
  font-size: 0.8125rem;
  line-height: 1.6;
  white-space: pre;
  color: var(--text);
}

/* === File view (blob) === */
.file-breadcrumb {
  font-size: 0.875rem;
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.125rem;
}

.file-view {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.file-view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.875rem;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
}

.file-name { font-family: var(--font-mono); }
.file-size { font-size: 0.8125rem; }

.file-view-info {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.file-view-info .separator { opacity: 0.5; }

.file-view-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.file-action-link {
  font-size: 0.8125rem;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-muted, inherit);
  cursor: pointer;
  border-radius: var(--radius);
}

.icon-btn:hover {
  background: var(--surface3, rgba(127, 127, 127, 0.15));
  color: var(--text);
}

.icon-btn svg {
  width: 1rem;
  height: 1rem;
}

.file-content {
  overflow-x: auto;
}

.code-view {
  counter-reset: line;
  display: table;
  min-width: 100%;
  margin: 0;
  padding: 0;
  border-radius: 0;
  background: var(--code-bg);
  border: none;
  font-size: 0.8125rem;
  line-height: 1.6;
}

.code-view code {
  display: table-cell;
  padding: 0.75rem 1rem;
  white-space: pre;
  tab-size: 4;
  -moz-tab-size: 4;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  line-height: 1.6;
  vertical-align: top;
}

.line-numbers {
  display: table-cell;
  padding: 0.75rem 0.75rem;
  white-space: pre;
  text-align: right;
  color: var(--text-muted);
  background: var(--surface2);
  border-right: 1px solid var(--border);
  user-select: none;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  line-height: 1.6;
  vertical-align: top;
}

.file-binary-notice {
  padding: 2rem;
  text-align: center;
  color: var(--text-muted);
}

/* === Commits === */
.commits-header { margin-bottom: 1rem; }

.commit-list { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }

.commit-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}

.commit-main { min-width: 0; flex: 1; }

.commit-side {
  flex-shrink: 0;
  text-align: right;
  font-size: 0.8125rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.commit-committer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.375rem;
}

.commit-committer-avatar {
  width: 20px;
  height: 20px;
  border-radius: 50%;
}

.commit-side-label {
  color: var(--text-muted);
  margin-right: 0.25rem;
}

.commit-tree code, .commit-parents .commit-sha {
  font-size: 0.75rem;
}

.commit-parents {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.25rem;
  flex-wrap: wrap;
}

.commit-item:last-child { border-bottom: none; }
.commit-item:hover { background: var(--surface2); }

.commit-message {
  font-weight: 500;
  margin-bottom: 0.25rem;
}

.commit-message a { color: var(--text); }
.commit-message a:hover { color: var(--accent); }

.commit-meta {
  display: flex;
  gap: 0.75rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
  flex-wrap: wrap;
  align-items: center;
}

.commit-sha {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  background: var(--surface2);
  padding: 0.125rem 0.375rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

/* === Commit detail === */
.commit-detail-header {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

.commit-sha-full {
  margin-top: 0.625rem;
}

.commit-sha-full code {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.diff-files-summary {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
  font-size: 0.875rem;
}

.changed-files-list {
  margin-top: 0.5rem;
  list-style: none;
  padding: 0;
}

.changed-files-list li { color: var(--text-muted); padding: 0.125rem 0; }
.changed-files-list code { font-size: 0.8125rem; }

/* === Diff view === */
.diff-view {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  line-height: 1.5;
}

.diff-file-header {
  background: var(--surface2);
  padding: 0.5rem 0.875rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  font-weight: 600;
}

.diff-hunk-header {
  background: rgba(47, 129, 247, 0.08);
  padding: 0.25rem 0.875rem;
  color: #79c0ff;
  border-bottom: 1px solid var(--border);
}

.diff-line {
  padding: 0 0.875rem;
  white-space: pre;
  overflow-x: auto;
}

.diff-add { background: rgba(63, 185, 80, 0.12); color: #aff5b4; }
.diff-del { background: rgba(248, 81, 73, 0.12); color: #ffa198; }
.diff-ctx { color: var(--text-muted); }

/* === Branches === */
.branch-list { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }

.branch-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.625rem 1rem;
  border-bottom: 1px solid var(--border);
  gap: 1rem;
  flex-wrap: wrap;
}

.branch-item:last-child { border-bottom: none; }
.branch-item:hover { background: var(--surface2); }

.branch-name {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.default-branch { font-weight: 600; }

.branch-actions { display: flex; gap: 0.5rem; }

.branches-section { margin-bottom: 1.5rem; }

/* === Empty repo === */
.empty-repo {
  padding: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.empty-repo h2 { margin-bottom: 1rem; }
.empty-repo p { color: var(--text-muted); margin-bottom: 0.5rem; }
.empty-repo pre { margin-bottom: 1.25rem; }

/* === Mobile === */
@media (max-width: 600px) {
  .repo-toolbar { flex-direction: column; align-items: flex-start; }
  .repo-actions { width: 100%; flex-wrap: wrap; }
  .clone-input { max-width: none; width: 100%; }
  .commit-meta { flex-direction: column; gap: 0.25rem; }
  .commit-item { flex-direction: column; }
  .commit-side { text-align: left; width: 100%; }
  .commit-committer { justify-content: flex-start; }
  .commit-parents { justify-content: flex-start; }
  .diff-line { font-size: 0.75rem; }
  .branch-item { flex-direction: column; align-items: flex-start; }
  .file-breadcrumb { font-size: 0.8125rem; }
}
