/* Cave — code forge CSS
 *
 * Design system: "Terminal Warmth"
 * Monospace-forward typography, amber accent on deep charcoal.
 * Dense where it matters, spacious where it counts.
 */

:root {
  /* Dark by default — keeps native controls (selects, scrollbars,
     date pickers) in the matching color scheme instead of light-on-dark. */
  color-scheme: dark;

  /* Palette — warm charcoal base, amber accent */
  --bg:             #131216;
  --bg-warm:        #18171c;
  --surface:        #1e1d23;
  --surface-hover:  #26252c;
  --border:         #2e2d35;
  --border-subtle:  #242329;

  --text:           #d4d0c8;
  --text-secondary: #9e9a8f;
  /* Lifted from #6e6b63 (~3.5:1) to meet WCAG AA 4.5:1 on --bg for the
     secondary text it carries: timestamps, "opened by", helper copy. */
  --text-muted:     #8a857b;

  --accent:         #e8a84c;
  --accent-dim:     #c4893a;
  --accent-bg:      rgba(232, 168, 76, 0.08);

  --link:           #d4a054;
  --link-hover:     #e8b86c;

  --green:          #7c9a5e;
  --green-bright:   #9ab87a;
  --green-bg:       rgba(124, 154, 94, 0.12);

  --red:            #c25450;
  --red-bg:         rgba(194, 84, 80, 0.10);

  --yellow:         #c9a03e;
  --yellow-bg:      rgba(201, 160, 62, 0.10);

  --blue:           #6b8fb5;
  --blue-bg:        rgba(107, 143, 181, 0.08);

  /* Typography */
  --font-mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --font-body: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* Spacing — 4px base grid */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-10: 40px;
  --sp-12: 48px;

  --radius: 3px;
  --radius-lg: 5px;
}

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; -webkit-font-smoothing: antialiased; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
}
a { color: var(--link); text-decoration: none; }
a:hover { color: var(--link-hover); }
code, pre, kbd { font-family: var(--font-mono); }
::selection { background: rgba(232, 168, 76, 0.25); }

/* Keyboard focus — the browser default outline (auto, near-black) is invisible
   on dark themes. Use an explicit accent ring; mouse clicks stay ring-free. */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius);
}

/* --- Typography --- */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-mono);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}
h1 { font-size: 1.35rem; margin-bottom: var(--sp-3); }
h2 { font-size: 1rem; margin: var(--sp-8) 0 var(--sp-4); color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 500; }
h3 { font-size: .9rem; margin: var(--sp-6) 0 var(--sp-3); }
section { margin-bottom: var(--sp-8); }

/* --- Navigation --- */
.nav {
  background: var(--bg-warm);
  border-bottom: 1px solid var(--border);
  padding: var(--sp-3) var(--sp-4);
  font-family: var(--font-mono);
  font-size: .85rem;
}
.nav-inner {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.nav-brand {
  color: var(--accent);
  font-weight: 700;
  font-size: .95rem;
  letter-spacing: 0.04em;
  display: inline-flex;
  align-items: center;
  gap: 0.45em;
}
.nav-brand:hover { color: var(--accent); }
.nav-logo { width: 1.25em; height: 1.25em; flex: 0 0 auto; }
.nav-right { display: flex; align-items: center; gap: var(--sp-4); }
.nav-user {
  color: var(--text-secondary);
  font-weight: 500;
}

/* --- Container --- */
.container { max-width: 960px; margin: 0 auto; padding: var(--sp-6) var(--sp-4); }

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  padding: var(--sp-1) var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: .8rem;
  cursor: pointer;
  line-height: 1.5;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  gap: var(--sp-2);
}
.btn:hover {
  border-color: var(--text-muted);
  color: var(--text);
  text-decoration: none;
}
.btn-primary {
  background: var(--accent-dim);
  border-color: transparent;
  color: var(--bg);
  font-weight: 500;
}
.btn-primary:hover { background: var(--accent); color: var(--bg); }
.btn-sm { padding: 2px var(--sp-2); font-size: .75rem; }
.btn-active { background: var(--accent-bg); border-color: var(--accent-dim); color: var(--accent); }

/* --- Badges --- */
.badge {
  display: inline-block;
  padding: 1px var(--sp-2);
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: .7rem;
  color: var(--text-muted);
  text-transform: lowercase;
  letter-spacing: 0.02em;
}

/* --- Forms --- */
.auth-form { max-width: 340px; margin: var(--sp-12) auto; }
.field { margin-bottom: var(--sp-4); }
.field label {
  display: block;
  margin-bottom: var(--sp-1);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: .8rem;
}
.field input[type="text"],
.field input[type="password"],
.field input[type="email"],
.field textarea {
  width: 100%;
  padding: var(--sp-2) var(--sp-3);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: .9rem;
  font-family: var(--font-body);
}
.field textarea { resize: vertical; }
.field input:focus, .field textarea:focus {
  outline: none;
  border-color: var(--accent-dim);
  box-shadow: 0 0 0 2px rgba(232, 168, 76, 0.12);
}

/* --- Alerts --- */
.alert {
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius);
  margin-bottom: var(--sp-4);
  font-size: .9rem;
  border-left: 3px solid var(--accent);
  background: var(--surface);
}
.alert-error {
  border-left-color: var(--red);
  background: var(--red-bg);
  color: var(--red);
}

/* --- Breadcrumb --- */
.breadcrumb {
  margin-bottom: var(--sp-4);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: .85rem;
}
.breadcrumb a { color: var(--text-secondary); }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb strong { color: var(--text); }

/* --- Lists (repos, orgs, issues) --- */
.org-list, .repo-list, .issue-list { list-style: none; }
.org-list li, .repo-list li, .issue-list li {
  padding: var(--sp-3) var(--sp-4);
  border: none;
  border-left: 2px solid var(--border-subtle);
  border-radius: 0;
  margin-bottom: 1px;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  background: var(--surface);
  transition: border-color 0.15s, background 0.15s;
}
.org-list li:hover, .repo-list li:hover, .issue-list li:hover {
  border-left-color: var(--accent-dim);
  background: var(--surface-hover);
}
.repo-list .desc, .issue-list .issue-status {
  margin-left: auto;
  color: var(--text-muted);
  font-size: .8rem;
}
.issue-number {
  font-family: var(--font-mono);
  color: var(--text-muted);
  font-size: .8rem;
}
.issues-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--sp-4); }
.issue-filters { display: flex; gap: 2px; }

/* --- Issues list (triage rows) --- */
.issues { list-style: none; }
.issues li.issue-row {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border-left: 2px solid var(--border-subtle);
  background: var(--surface);
  margin-bottom: 1px;
  transition: border-color 0.15s, background 0.15s;
}
.issues li.issue-row:hover { border-left-color: var(--accent-dim); background: var(--surface-hover); }
.issue-icon { flex: 0 0 auto; width: 10px; height: 10px; border-radius: 50%; margin-top: 0.3rem; }
.issue-main { flex: 1 1 auto; min-width: 0; }
.issue-titleline { display: flex; align-items: center; flex-wrap: wrap; gap: 0.4rem; }
.issue-title { font-weight: 600; color: var(--text); text-decoration: none; }
.issue-title:hover { color: var(--accent); }
.issue-pin { font-size: 0.85rem; }
.issue-label {
  font-size: 0.72rem;
  padding: 0.05rem 0.5rem;
  border-radius: 999px;
  border: 1px solid transparent;
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.6;
}
.issue-label:hover { filter: brightness(0.96); }
.issue-label-active { outline: 2px solid var(--accent-dim); outline-offset: 1px; }
.issue-meta {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

/* --- Issue detail --- */
.issue-header {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-2);
}
.issue-header h1 { font-size: 1.25rem; margin-bottom: 0; }
.issue-meta {
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: .8rem;
  margin-bottom: var(--sp-6);
}
.issue-body {
  padding: var(--sp-4);
  background: var(--surface);
  border-left: 2px solid var(--border);
  font-size: .9rem;
  line-height: 1.6;
}
/* Restore block spacing inside markdown-rendered bodies — the universal
   reset zeros margins/padding everywhere, which collapses paragraphs,
   lists, and headings into a single dense wall of text. */
.issue-body p, .comment-body p { margin: 0 0 var(--sp-3); }
.issue-body p:last-child, .comment-body p:last-child { margin-bottom: 0; }
.issue-body ul, .comment-body ul { list-style: disc outside; padding-left: var(--sp-6); margin: var(--sp-3) 0; }
.issue-body ol, .comment-body ol { list-style: decimal outside; padding-left: var(--sp-6); margin: var(--sp-3) 0; }
.issue-body li, .comment-body li { margin-bottom: var(--sp-2); }
.issue-body li:last-child, .comment-body li:last-child { margin-bottom: 0; }
.issue-body ul ul, .issue-body ol ol, .issue-body ul ol, .issue-body ol ul,
.comment-body ul ul, .comment-body ol ol, .comment-body ul ol, .comment-body ol ul { margin: var(--sp-2) 0; }
.issue-body h1, .issue-body h2, .issue-body h3, .issue-body h4, .issue-body h5, .issue-body h6,
.comment-body h1, .comment-body h2, .comment-body h3, .comment-body h4, .comment-body h5, .comment-body h6 {
  margin: var(--sp-4) 0 var(--sp-2);
}
.issue-body blockquote, .comment-body blockquote {
  margin: var(--sp-3) 0;
  padding-left: var(--sp-3);
  border-left: 2px solid var(--border);
  color: var(--text-secondary);
}
.issue-body pre, .comment-body pre { margin: var(--sp-3) 0; }
.issue-body table, .comment-body table { border-collapse: collapse; margin: var(--sp-3) 0; }
.issue-body th, .issue-body td, .comment-body th, .comment-body td {
  padding: var(--sp-2) var(--sp-3); border: 1px solid var(--border); font-size: .85rem;
}
.issue-body th, .comment-body th { background: var(--bg); }

/* --- Clone URL --- */
.clone-url {
  display: block;
  padding: var(--sp-2) var(--sp-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: .8rem;
  color: var(--text-secondary);
  word-break: break-all;
}

/* --- Repo tabs --- */
.repo-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--sp-6);
}
.repo-tab {
  padding: var(--sp-2) var(--sp-4);
  font-family: var(--font-mono);
  font-size: .85rem;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
}
.repo-tab:hover { color: var(--text); }
.repo-tab-active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* --- Repo info bar --- */
.repo-info-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-2) var(--sp-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  font-family: var(--font-mono);
  font-size: .8rem;
}
.repo-info-left { display: flex; align-items: center; gap: var(--sp-3); }
.repo-info-stat { color: var(--text-muted); font-size: .8rem; }
.repo-last-commit {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: none;
  font-size: .8rem;
}
.repo-last-hash { color: var(--link); font-size: .75rem; }
.repo-last-msg { color: var(--text); flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.repo-last-author { color: var(--text-muted); margin-left: auto; white-space: nowrap; }

/* --- Repo actions --- */
.repo-actions { margin-bottom: var(--sp-6); display: flex; gap: var(--sp-2); }

/* --- Tables --- */
.data-table, .dep-alerts, .dep-list { width: 100%; border-collapse: collapse; margin-bottom: var(--sp-4); }
.data-table th, .data-table td,
.dep-alerts th, .dep-alerts td,
.dep-list th, .dep-list td {
  padding: var(--sp-2) var(--sp-3);
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
  font-size: .85rem;
  white-space: nowrap;
}
.data-table th,
.dep-alerts th,
.dep-list th {
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 500;
}
.data-table td, .dep-alerts td, .dep-list td { font-family: var(--font-mono); }
/* Let the package column take the slack so versions/scope don't crowd it. */
.dep-alerts td:nth-child(2), .dep-list td:nth-child(2) { width: 100%; }

/* --- Data list --- */
.data-list { list-style: none; }
.data-list li {
  padding: var(--sp-3) var(--sp-4);
  border: none;
  border-left: 2px solid var(--border-subtle);
  border-radius: 0;
  margin-bottom: 1px;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  background: var(--surface);
}
.data-list code { color: var(--text-muted); font-size: .75rem; }

/* --- Reviews --- */
.review {
  padding: var(--sp-3) var(--sp-4);
  border-left: 3px solid var(--border);
  background: var(--surface);
  margin-bottom: var(--sp-3);
}
.review-stale { opacity: .55; }
.review-header {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-2);
  font-family: var(--font-mono);
  font-size: .85rem;
}
.review-version {
  color: var(--text-muted);
  font-size: .75rem;
  margin-left: auto;
}
.review-body {
  color: var(--text);
  margin-top: var(--sp-2);
  font-size: .9rem;
  line-height: 1.55;
}
.review-actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.review-state-approve {
  background: var(--green-bg);
  border-color: var(--green);
  color: var(--green-bright);
}
.review-state-approve_with_concerns {
  background: var(--yellow-bg);
  border-color: var(--yellow);
  color: var(--yellow);
}
.review-state-request_changes {
  background: var(--red-bg);
  border-color: var(--red);
  color: var(--red);
}
.review-state-comment { background: var(--surface); }

/* --- Concerns --- */
.concern-list { list-style: none; margin-top: var(--sp-2); padding-left: var(--sp-4); }
.concern {
  padding: var(--sp-2) var(--sp-3);
  border-left: 2px solid var(--yellow);
  margin-bottom: var(--sp-1);
  font-size: .85rem;
}
.concern-resolved { border-left-color: var(--green); opacity: .65; }
.concern-text { font-size: .85rem; }

/* --- Merge eligibility --- */
.eligibility-list { list-style: none; margin-bottom: var(--sp-4); }
.eligibility-list li {
  padding: var(--sp-1) 0;
  font-family: var(--font-mono);
  font-size: .85rem;
}
.rule-pass { color: var(--green-bright); }
.rule-fail { color: var(--red); }

/* --- Stack --- */
.stack-list { padding-left: 0; counter-reset: stack; list-style: none; }
.stack-list li {
  padding: var(--sp-2) var(--sp-3);
  border-left: 2px solid var(--border-subtle);
  margin-bottom: 1px;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  background: var(--surface);
  font-family: var(--font-mono);
  font-size: .85rem;
}
.stack-current {
  border-left-color: var(--accent);
  background: var(--accent-bg);
}

/* --- Footer --- */
.site-footer {
  margin-top: var(--sp-12);
  padding: var(--sp-4) var(--sp-4);
  border-top: 1px solid var(--border-subtle);
  text-align: center;
  font-family: var(--font-mono);
  font-size: .7rem;
  color: var(--text-muted);
}

/* --- Avatars --- */
.avatar {
  border-radius: 50%;
  vertical-align: middle;
  margin-right: var(--sp-1);
}

/* --- Utility --- */
.empty { color: var(--text-muted); font-style: italic; font-size: .9rem; }

/* --- Code blocks (inline in views) --- */
pre {
  background: var(--surface);
  padding: var(--sp-4);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  font-size: .8rem;
  overflow-x: auto;
  line-height: 1.6;
}
code {
  font-size: .85em;
  color: var(--accent);
}

/* --- File tree --- */
.file-tree { width: 100%; border-collapse: collapse; border: 1px solid var(--border); border-top: none; }
.file-tree td {
  padding: var(--sp-2) var(--sp-3);
  border-bottom: 1px solid var(--border-subtle);
  font-family: var(--font-mono);
  font-size: .85rem;
}
.file-tree tr:hover { background: var(--surface-hover); }
.file-tree .file-icon {
  width: 20px;
  color: var(--text-muted);
  font-size: .75rem;
}
.file-tree .file-dir .file-icon { color: var(--accent-dim); }
.file-tree a { color: var(--link); }
.file-tree a:hover { color: var(--link-hover); }
.file-tree .file-size { text-align: right; color: var(--text-muted); font-size: .75rem; white-space: nowrap; }
.file-tree .file-commit {
  color: var(--text-muted);
  font-size: .8rem;
  max-width: 1px;
  width: 60%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-tree .file-commit a { color: var(--text-muted); }
.file-tree .file-commit a:hover { color: var(--link); }
.file-tree .file-age { text-align: right; color: var(--text-muted); font-size: .75rem; white-space: nowrap; }
.file-tree .file-icon .ficon { vertical-align: text-bottom; }

/* Language breakdown bar + legend */
.lang-bar {
  display: flex;
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
  margin: var(--sp-3) 0 var(--sp-2);
  background: var(--surface);
}
.lang-seg { height: 100%; }
.lang-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
  margin-bottom: var(--sp-3);
  font-size: .8rem;
}
.lang-legend-item { display: inline-flex; align-items: center; gap: .35rem; }
.lang-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.lang-name { color: var(--text); font-weight: 600; }
.lang-pct { color: var(--text-muted); }

/* --- Blob view --- */
.blob-meta {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
  font-family: var(--font-mono);
  font-size: .8rem;
  color: var(--text-secondary);
}
.blob-meta .blob-size { margin-left: auto; color: var(--text-muted); }
#editor-container {
  border: 1px solid var(--border);
  border-radius: 0 0 var(--radius) var(--radius);
}

/* --- README --- */
.readme-content {
  padding: var(--sp-4) var(--sp-6);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  line-height: 1.7;
  font-size: .9rem;
}
.readme-content h1 { font-size: 1.3rem; margin: var(--sp-6) 0 var(--sp-3); border-bottom: 1px solid var(--border); padding-bottom: var(--sp-2); }
.readme-content h2 { font-size: 1.1rem; margin: var(--sp-6) 0 var(--sp-3); text-transform: none; letter-spacing: normal; color: var(--text); }
.readme-content h3 { font-size: .95rem; margin: var(--sp-4) 0 var(--sp-2); }
.readme-content h1:first-child { margin-top: 0; }
.readme-content p { margin: var(--sp-3) 0; }
.readme-content code { background: var(--bg); padding: 2px 6px; border-radius: 2px; font-size: .85em; }
.readme-content pre { background: var(--bg); padding: var(--sp-4); border: none; margin: var(--sp-3) 0; }
.readme-content pre code { background: none; padding: 0; color: var(--text); }
.readme-content a { color: var(--link); }
.readme-content img { max-width: 100%; }
.readme-content ul, .readme-content ol { padding-left: var(--sp-6); margin: var(--sp-3) 0; }
.readme-content li { margin: var(--sp-1) 0; }
.readme-content blockquote { border-left: 3px solid var(--accent-dim); padding-left: var(--sp-4); color: var(--text-secondary); margin: var(--sp-3) 0; }
.readme-content table { border-collapse: collapse; margin: var(--sp-3) 0; }
.readme-content th, .readme-content td { padding: var(--sp-2) var(--sp-3); border: 1px solid var(--border); font-size: .85rem; }
.readme-content th { background: var(--bg); }
.readme-content hr { border: none; border-top: 1px solid var(--border); margin: var(--sp-6) 0; }

/* --- Commit page --- */
.commit-header { margin-bottom: var(--sp-3); }
.commit-subject { font-size: 1.2rem; margin-bottom: var(--sp-2); }
.commit-body {
  background: var(--surface);
  padding: var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .85rem;
  color: var(--text-secondary);
  margin-top: var(--sp-2);
  white-space: pre-wrap;
}
.commit-meta {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-family: var(--font-mono);
  font-size: .8rem;
  color: var(--text-secondary);
  margin-bottom: var(--sp-4);
}

/* --- Comments --- */
.comment {
  padding: var(--sp-3) var(--sp-4);
  border-left: 2px solid var(--border-subtle);
  background: var(--surface);
  margin-bottom: var(--sp-3);
}
.comment-header {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-2);
  font-family: var(--font-mono);
  font-size: .85rem;
}
.comment-date {
  color: var(--text-muted);
  font-size: .75rem;
  margin-left: auto;
}
.comment-body {
  font-size: .9rem;
  line-height: 1.6;
  white-space: pre-wrap;
}

/* --- Diff --- */
.diff-file {
  margin-bottom: var(--sp-6);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  overflow-y: hidden;
}
.diff-file-header {
  padding: var(--sp-2) var(--sp-3);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: .8rem;
  color: var(--text-secondary);
}
.diff-file-header a { color: var(--link); }
/* diff2html dark theme overrides */
#diff2html-container { margin-top: var(--sp-4); }
.d2h-wrapper { background: transparent !important; }
.d2h-file-header { background: var(--surface) !important; border-color: var(--border) !important; }
.d2h-file-name { color: var(--link) !important; }
.d2h-code-linenumber { color: var(--text-muted) !important; }
.d2h-code-line { color: var(--text) !important; }
/* diff2html inline comments */
.cave-add-comment-btn {
  position: absolute;
  left: -2px;
  top: 0;
  color: var(--accent-dim);
  cursor: pointer;
  font-size: .7rem;
  opacity: 0;
  transition: opacity 0.1s;
  user-select: none;
}
tr:hover .cave-add-comment-btn { opacity: 1; }
.cave-add-comment-btn:hover { color: var(--accent); }
.cave-comment-cell {
  background: var(--surface) !important;
  padding: var(--sp-3) var(--sp-4) !important;
  border-bottom: 1px solid var(--border) !important;
}
.cave-ic {
  border-left: 2px solid var(--accent-dim);
  padding: var(--sp-2) var(--sp-3);
  margin-bottom: var(--sp-2);
  font-family: var(--font-mono);
  font-size: .8rem;
}
.cave-ic:last-child { margin-bottom: 0; }
.cave-ic-date { color: var(--text-muted); font-size: .7rem; margin-left: var(--sp-2); }
.cave-ic-body { margin-top: var(--sp-1); white-space: pre-wrap; color: var(--text); }
.cave-comment-form-row textarea {
  width: 100%;
  min-height: 60px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-body);
  font-size: .9rem;
  padding: var(--sp-2) var(--sp-3);
}
.d2h-wrapper, .d2h-code-line, .d2h-code-linenumber,
.d2h-code-side-line, .d2h-file-name {
  font-family: var(--font-mono) !important;
  font-size: .8rem !important;
}
.diff-body { font-family: var(--font-mono); font-size: .8rem; }
.diff-line {
  display: flex;
  line-height: 1.4;
  width: max-content;
  min-width: 100%;
}
.diff-line > span { flex-shrink: 0; }
.diff-line-num { width: 3.5em; }
.diff-add-btn { width: 1.5em; }
.diff-gutter { width: 1.2em; }
.diff-line-add { background: var(--green-bg); color: var(--text); }
.diff-line-del { background: var(--red-bg); color: var(--text); }
.diff-line-hunk { display: block; background: var(--blue-bg); color: var(--blue); padding: var(--sp-1) var(--sp-3); }
.diff-line-context { background: transparent; }
code.diff-code {
  background: none;
  padding: 0 2px;
  margin: 0;
  font-size: inherit;
  color: inherit;
  white-space: pre;
  display: inline;
  flex-shrink: 0;
}
/* highlight.js token colors (no theme stylesheet needed) */
.hljs-keyword, .hljs-selector-tag { color: #ff7b72; }
.hljs-string, .hljs-attr { color: #a5d6ff; }
.hljs-comment, .hljs-quote { color: #8b949e; font-style: italic; }
.hljs-number, .hljs-literal { color: #79c0ff; }
.hljs-built_in, .hljs-type { color: #ffa657; }
.hljs-function, .hljs-title { color: #d2a8ff; }
.hljs-variable, .hljs-template-variable { color: #ffa657; }
.hljs-attribute { color: #7ee787; }
.hljs-selector-class, .hljs-selector-id { color: #7ee787; }
.hljs-name, .hljs-tag { color: #7ee787; }
.hljs-meta { color: #8b949e; }
.hljs-symbol { color: #79c0ff; }
.hljs-deletion { color: var(--red); }
.hljs-addition { color: var(--green-bright); }
.diff-line-num {
  text-align: right;
  color: var(--text-muted);
  user-select: none;
  opacity: .6;
  padding-right: var(--sp-2) !important;
}
.diff-gutter {
  text-align: center;
  color: var(--text-muted);
  user-select: none;
}
.diff-line-add .diff-gutter { color: var(--green); }
.diff-line-del .diff-gutter { color: var(--red); }
.diff-stat {
  padding: var(--sp-3) var(--sp-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: .8rem;
  margin-bottom: var(--sp-4);
  white-space: pre-wrap;
}
.diff-stat-bar { display: inline-block; height: 10px; border-radius: 2px; }
.diff-stat-add { background: var(--green); }
.diff-stat-del { background: var(--red); }
.diff-line-num {
  width: 3em;
  text-align: right;
  color: var(--text-muted);
  font-size: .75rem;
  padding: 0 var(--sp-2) !important;
  user-select: none;
  opacity: .6;
  line-height: inherit;
}
.diff-table tr:hover .diff-add-btn { opacity: 1; }
.diff-add-btn {
  width: 1.5em;
  opacity: 0;
  text-align: center;
  cursor: pointer;
  color: var(--accent-dim);
  font-size: .8rem;
  padding: 0 !important;
  user-select: none;
  transition: opacity 0.1s;
}
.diff-add-btn:hover { color: var(--accent); }
.diff-comment-row td {
  background: var(--surface);
  padding: var(--sp-3) var(--sp-4) !important;
  border-bottom: 1px solid var(--border);
}
.diff-comment-row .diff-inline-comment {
  border-left: 2px solid var(--accent-dim);
  padding: var(--sp-2) var(--sp-3);
  margin-bottom: var(--sp-2);
}
.diff-comment-row .diff-inline-comment:last-child { margin-bottom: 0; }
.diff-inline-comment-author {
  font-family: var(--font-mono);
  font-size: .8rem;
  font-weight: 500;
  color: var(--text);
}
.diff-inline-comment-date {
  color: var(--text-muted);
  font-size: .7rem;
  margin-left: var(--sp-2);
}
.diff-inline-comment-body {
  font-size: .85rem;
  line-height: 1.5;
  margin-top: var(--sp-1);
  white-space: pre-wrap;
}
.diff-comment-form {
  display: none;
  background: var(--surface);
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border);
}
.diff-comment-form.active { display: table-row; }
.diff-comment-form td { padding: var(--sp-3) var(--sp-4) !important; }
.diff-comment-form textarea {
  width: 100%;
  min-height: 60px;
  margin-bottom: var(--sp-2);
}

/* ============================================================
   Built-in themes — override :root CSS variables
   ============================================================ */

/* Solarized Dark */
html[data-theme="solarized-dark"] {
  color-scheme: dark;
  --bg: #002b36;
  --bg-warm: #073642;
  --surface: #073642;
  --surface-hover: #0a4050;
  --border: #2a5a68;
  --border-subtle: #1a4a58;
  --text: #839496;
  --text-secondary: #93a1a1;
  --text-muted: #586e75;
  --accent: #b58900;
  --accent-dim: #9a7400;
  --accent-bg: rgba(181, 137, 0, 0.08);
  --link: #268bd2;
  --link-hover: #4aa3e8;
  --green: #859900;
  --green-bright: #a3b819;
  --green-bg: rgba(133, 153, 0, 0.12);
  --red: #dc322f;
  --red-bg: rgba(220, 50, 47, 0.10);
  --yellow: #b58900;
  --yellow-bg: rgba(181, 137, 0, 0.10);
  --blue: #268bd2;
  --blue-bg: rgba(38, 139, 210, 0.08);
}

/* Nord */
html[data-theme="nord"] {
  color-scheme: dark;
  --bg: #2e3440;
  --bg-warm: #3b4252;
  --surface: #3b4252;
  --surface-hover: #434c5e;
  --border: #4c566a;
  --border-subtle: #434c5e;
  --text: #d8dee9;
  --text-secondary: #e5e9f0;
  --text-muted: #7b88a1;
  --accent: #88c0d0;
  --accent-dim: #6ba8b8;
  --accent-bg: rgba(136, 192, 208, 0.08);
  --link: #81a1c1;
  --link-hover: #8fbcbb;
  --green: #a3be8c;
  --green-bright: #b5d19c;
  --green-bg: rgba(163, 190, 140, 0.12);
  --red: #bf616a;
  --red-bg: rgba(191, 97, 106, 0.10);
  --yellow: #ebcb8b;
  --yellow-bg: rgba(235, 203, 139, 0.10);
  --blue: #81a1c1;
  --blue-bg: rgba(129, 161, 193, 0.08);
}

/* Light */
html[data-theme="light"] {
  color-scheme: light;
  --bg: #ffffff;
  --bg-warm: #f6f8fa;
  --surface: #f6f8fa;
  --surface-hover: #eef1f5;
  --border: #d0d7de;
  --border-subtle: #e1e4e8;
  --text: #1f2328;
  --text-secondary: #656d76;
  --text-muted: #8b949e;
  --accent: #c4893a;
  --accent-dim: #a87430;
  --accent-bg: rgba(196, 137, 58, 0.08);
  --link: #0969da;
  --link-hover: #0550ae;
  --green: #1a7f37;
  --green-bright: #2da44e;
  --green-bg: rgba(26, 127, 55, 0.08);
  --red: #cf222e;
  --red-bg: rgba(207, 34, 46, 0.06);
  --yellow: #9a6700;
  --yellow-bg: rgba(154, 103, 0, 0.06);
  --blue: #0969da;
  --blue-bg: rgba(9, 105, 218, 0.06);
}

/* Dracula */
html[data-theme="dracula"] {
  color-scheme: dark;
  --bg: #282a36;
  --bg-warm: #2d2f3d;
  --surface: #343746;
  --surface-hover: #3d4051;
  --border: #44475a;
  --border-subtle: #3d4051;
  --text: #f8f8f2;
  --text-secondary: #c0bfbc;
  --text-muted: #6272a4;
  --accent: #ff79c6;
  --accent-dim: #d660a8;
  --accent-bg: rgba(255, 121, 198, 0.08);
  --link: #8be9fd;
  --link-hover: #a8effd;
  --green: #50fa7b;
  --green-bright: #6dffa0;
  --green-bg: rgba(80, 250, 123, 0.10);
  --red: #ff5555;
  --red-bg: rgba(255, 85, 85, 0.10);
  --yellow: #f1fa8c;
  --yellow-bg: rgba(241, 250, 140, 0.08);
  --blue: #8be9fd;
  --blue-bg: rgba(139, 233, 253, 0.08);
}

/* --- Repo creation tabs --- */
.repo-create-tabs {
  display: flex;
  gap: 0;
  margin-bottom: var(--sp-4);
  border-bottom: 2px solid var(--border);
}
.repo-tab, .repo-tab-active {
  padding: var(--sp-2) var(--sp-4);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: .9rem;
  font-weight: 500;
  cursor: pointer;
}
.repo-tab:hover { color: var(--text); border-bottom-color: var(--text-muted); }
.repo-tab-active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* --- Search --- */
.nav-search { display: flex; align-items: center; margin-right: var(--sp-2); }
.nav-search-input {
  width: 160px;
  padding: var(--sp-1) var(--sp-2);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: .8rem;
  font-family: var(--font-mono);
  transition: width 0.2s;
}
.nav-search-input:focus { outline: none; border-color: var(--accent-dim); width: 240px; }
.nav-search-input::placeholder { color: var(--text-muted); }

.search-form { margin-bottom: var(--sp-4); }
.search-bar { display: flex; gap: var(--sp-2); align-items: center; }
.search-input {
  flex: 1;
  padding: var(--sp-2) var(--sp-3);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: .9rem;
  font-family: var(--font-mono);
}
.search-input:focus { outline: none; border-color: var(--accent-dim); }
.search-input::placeholder { color: var(--text-muted); }
.search-scope { margin-top: var(--sp-2); color: var(--text-muted); font-size: .85rem; }
.search-stats { color: var(--text-muted); font-size: .85rem; margin-bottom: var(--sp-4); }

.search-result {
  margin-bottom: var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.search-result-header {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  background: var(--surface);
  font-family: var(--font-mono);
  font-size: .85rem;
  cursor: pointer;
  user-select: none;
  list-style: none;
}
.search-result-header::-webkit-details-marker { display: none; }
.search-chevron {
  display: inline-block;
  width: 12px;
  height: 12px;
  flex-shrink: 0;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M6 4l4 4-4 4'/%3E%3C/svg%3E") center/contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M6 4l4 4-4 4'/%3E%3C/svg%3E") center/contain no-repeat;
  color: var(--text-muted);
  transition: transform 0.15s;
}
.search-result[open] > .search-result-header .search-chevron { transform: rotate(90deg); }
.search-result-link { color: var(--text); text-decoration: none; }
.search-result-link:hover { color: var(--accent); }
.search-repo { color: var(--accent); }
.search-file { color: var(--text-secondary); }
.search-lang {
  margin-left: auto;
  color: var(--text-muted);
  font-size: .75rem;
  font-family: var(--font-body);
}

.search-code {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: .8rem;
  line-height: 1.6;
  background: var(--bg-warm);
}
.search-code td { padding: 0 var(--sp-3); white-space: pre; vertical-align: top; }
.search-code .line-num {
  color: var(--text-muted);
  width: 1%;
  min-width: 4ch;
  text-align: right;
  padding-right: var(--sp-3);
  user-select: none;
}
.search-code tr[data-href]:hover { background: var(--surface-hover); }
.search-code tr[data-href]:hover .line-num { color: var(--accent); }
.search-code .line-content { width: 99%; overflow-x: auto; }

/* Context lines (dimmed) */
.search-ctx td { color: var(--text-muted); }
.search-ctx .line-content { opacity: 0.6; }

/* Matched line (highlighted background) */
.search-match { background: rgba(232, 168, 76, 0.06); }
.search-match .line-num { color: var(--accent-dim); }

/* Match highlight */
.search-code mark {
  background: rgba(232, 168, 76, 0.25);
  color: var(--accent);
  border-radius: 2px;
  padding: 0 1px;
  font-weight: 600;
}

/* Separator between match groups in same file */
.search-sep td {
  height: 1px;
  background: var(--border-subtle);
  padding: 0;
}

/* Permalink-to-line highlight (Monaco gutter click → #L42) */
.cave-line-link { background: rgba(232, 168, 76, 0.12); }
.cave-line-link-gutter { width: 3px !important; background: var(--accent); }

/* Per-line action menu in the Monaco blob view */
.cave-line-menu {
  position: absolute;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 6px 24px rgba(0, 0, 0, .35);
  padding: .25rem;
  z-index: 1000;
  min-width: 200px;
  font-size: .85rem;
}
.cave-line-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  color: var(--text);
  padding: .4rem .65rem;
  border-radius: calc(var(--radius) - 2px);
  cursor: pointer;
  text-decoration: none;
  font: inherit;
}
.cave-line-menu-item:hover { background: var(--surface-2, rgba(255, 255, 255, .04)); }

/* ============================================================
   Responsive — small screens (no breakpoints existed before, so
   the fixed-width nav ran off the right edge and scrolled the page).
   ============================================================ */
@media (max-width: 720px) {
  .nav-inner { flex-wrap: wrap; gap: var(--sp-2); }
  /* Let the action cluster wrap to a second line instead of overflowing. */
  .nav-right { flex-wrap: wrap; justify-content: flex-end; gap: var(--sp-2); }
  /* Search takes its own full-width row above the wrapped buttons. */
  .nav-search { flex: 1 1 100%; }
  .nav-search-input { width: 100%; }
  /* Tabs scroll horizontally rather than clipping the last tab. */
  .repo-tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .repo-tab { white-space: nowrap; }
  .container { padding: var(--sp-4) var(--sp-3); }
  /* Long inline-code tokens (clone URLs, hashes) must wrap, not push width. */
  .readme-content code, .issue-body code, .comment-body code { overflow-wrap: anywhere; }
}
