:root {
  color-scheme: light;
  --ink: #111720;
  --muted: #636c76;
  --line: #d0d7de;
  --soft: #f6f8fa;
  --accent: #cf442d;
  --add: #dafbe1;
  --green: #1a7f37;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
  color: #1f2328;
  background: #fff;
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button { font: inherit; }

.app-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  color: #f0f3f6;
  background: var(--ink);
  border-bottom: 1px solid #30363d;
}

.mark, .bot-avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-weight: 700;
}

.eyebrow { color: #8c959f; font: 10px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .12em; }
.repo { margin-top: 3px; }
.privacy { margin-left: auto; color: #8c959f; font: 10px ui-monospace, monospace; letter-spacing: .08em; }

.repo-tabs {
  display: flex;
  gap: 6px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  background: var(--soft);
  overflow-x: auto;
}

.repo-tab {
  padding: 12px 11px 10px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: #424a53;
  white-space: nowrap;
  cursor: pointer;
}

.repo-tab span { color: var(--muted); }
.repo-tab.active { border-bottom-color: #fd8c73; color: #1f2328; font-weight: 600; }
.repo-tab:focus-visible, .file-button:focus-visible { outline: 2px solid #0969da; outline-offset: -2px; }

main { padding: 16px; }

.context-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 1180px;
  margin: 0 auto 10px;
  color: var(--muted);
  font-size: 12px;
}

.context-bar strong { margin-right: 8px; color: #1f2328; }
.branch-dot { display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 50%; background: var(--green); }
.status { padding: 3px 7px; border: 1px solid var(--line); border-radius: 999px; font: 10px ui-monospace, monospace; letter-spacing: .08em; }

.explorer {
  display: grid;
  grid-template-columns: minmax(185px, 24%) minmax(0, 1fr);
  max-width: 1180px;
  height: min(35rem, calc(100vh - 10.5rem));
  min-height: 430px;
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.file-tree { overflow: auto; border-right: 1px solid var(--line); background: var(--soft); }
.tree-title { padding: 12px 13px 8px; color: var(--muted); font: 10px ui-monospace, monospace; letter-spacing: .1em; }
.scope-files { display: none; padding: 0 7px 10px; }
.scope-files.active { display: block; }

.scope-note {
  margin: 4px 1px 8px;
  padding: 9px 10px;
  border: 1px solid #9a6700;
  border-radius: 6px;
  background: #fff8c5;
  color: #57606a;
  font-size: 11px;
  line-height: 1.35;
}

.scope-note strong,
.scope-note span { display: block; }
.scope-note strong { color: #3b2f00; }
.scope-note span { margin-top: 3px; }
.scope-note code { font: 10px ui-monospace, monospace; }

.tree-directory:not(.open) > .tree-children { display: none; }

.tree-folder {
  display: grid;
  grid-template-columns: 15px 19px minmax(0, 1fr);
  align-items: center;
  width: 100%;
  min-height: 34px;
  padding: 5px 8px 5px calc(5px + (var(--tree-depth) * 14px));
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #343a40;
  text-align: left;
  cursor: pointer;
}

.tree-folder:hover { background: #eaeef2; }
.tree-folder:focus-visible { outline: 2px solid #0969da; outline-offset: -2px; }
.tree-chevron { color: var(--muted); transform: rotate(-90deg); transition: transform .14s ease; }
.tree-directory.open > .tree-folder .tree-chevron { transform: rotate(0); }
.tree-folder-icon { color: #54aeff; font-size: 11px; }
.tree-folder span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.file-button {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  align-items: center;
  width: 100%;
  min-height: 38px;
  padding: 6px 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #343a40;
  text-align: left;
  cursor: pointer;
}

.repo-file-button {
  padding-left: calc(8px + (var(--tree-depth) * 14px));
}

.file-button span:last-child { overflow-wrap: anywhere; }
.file-button:hover { background: #eaeef2; }
.file-button.active { background: #dfe6ed; color: #111720; font-weight: 600; }
.file-icon { color: #8250df; font: 11px ui-monospace, monospace; }
.file-icon.changed { color: var(--green); }
.file-icon.review { color: #0969da; }

.file-stage { min-width: 0; overflow: auto; background: white; }
.file-panel { display: none; }
.file-panel.active { display: block; }

.file-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 54px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.file-heading strong { display: block; font: 600 13px ui-monospace, SFMono-Regular, Menlo, monospace; }
.file-heading div span { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; }
.baseline-pill, .added-pill, .changed-pill, .approved-pill { padding: 3px 7px; border-radius: 999px; font: 10px ui-monospace, monospace; white-space: nowrap; }
.baseline-pill { background: #ddf4ff; color: #0969da; }
.added-pill, .changed-pill { background: #dafbe1; color: #116329; }
.approved-pill { background: #ffebe9; color: #a40e26; }

.finding {
  margin: 12px 14px;
  padding: 9px 11px;
  border-left: 3px solid #0969da;
  border-radius: 0 6px 6px 0;
  background: #ddf4ff;
  font-size: 12px;
}

.finding.warning { border-color: #bf8700; background: #fff8c5; }
.finding.critical { border-color: #cf222e; background: #ffebe9; }
.finding.safe { border-color: var(--green); background: #dafbe1; }
.finding code { font: 11px ui-monospace, monospace; }

pre {
  margin: 0;
  padding: 5px 0 18px;
  overflow: auto;
  color: #24292f;
  font: 12px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace;
  tab-size: 4;
}

pre > code {
  display: block;
  font-size: 0;
  line-height: 0;
}

.base-file-source {
  min-height: 100%;
}

.base-file-note {
  border-color: #8c959f;
  background: #f6f8fa;
}

.line {
  display: block;
  min-width: max-content;
  padding: 0 16px 0 0;
  white-space: pre;
  font: 12px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace;
}
.line i { display: inline-block; width: 42px; margin-right: 12px; color: #8c959f; font-style: normal; text-align: right; user-select: none; }
.line.add { background: var(--add); }
.line.add i { color: var(--green); }
.line.focus { box-shadow: inset 3px 0 #0969da; }
.line.danger { box-shadow: inset 3px 0 #cf222e; background: #ffebe9; }
.line.add.danger { background: #ffebe9; }

.review-card { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 12px; margin: 18px 14px; }
.bot-avatar { width: 36px; height: 36px; border-radius: 50%; }
.review-meta { color: var(--muted); font-size: 12px; }
.review-meta strong { color: #1f2328; }
blockquote { margin: 10px 0; padding: 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--soft); }
.checks { display: flex; flex-wrap: wrap; gap: 6px; }
.checks span { padding: 4px 7px; border-radius: 999px; background: #dafbe1; color: #116329; font-size: 11px; }
.checks .skipped { background: #fff8c5; color: #6e4b00; }

.review-comparison {
  max-width: 1180px;
  margin: 18px auto 4px;
}

.review-timeline {
  position: relative;
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 12px;
  margin-bottom: 14px;
}

.review-timeline::before {
  content: "";
  position: absolute;
  left: 17px;
  top: 36px;
  bottom: -15px;
  width: 2px;
  background: #d8dee4;
}

.review-timeline:last-child::before { display: none; }

.timeline-avatar {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  font-weight: 700;
}

.timeline-avatar.control { background: #cf222e; }

.review-discussion {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.review-discussion > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--soft);
  color: #57606a;
  font-size: 12px;
}

.review-discussion > header strong { color: #1f2328; }

.review-state {
  flex: 0 0 auto;
  padding: 3px 8px;
  border-radius: 999px;
  font: 10px ui-monospace, monospace;
  letter-spacing: .05em;
}

.review-state.approved { background: #dafbe1; color: #116329; }
.review-state.rejected { background: #ffebe9; color: #a40e26; }

.review-body { padding: 12px 14px 13px; }
.review-body p { margin: 9px 0 10px; color: #24292f; }
.review-body code { padding: 2px 5px; border-radius: 4px; background: #eff1f3; font: 11px ui-monospace, monospace; }
.review-body footer { color: var(--muted); font-size: 11px; }

.review-context {
  color: var(--muted);
  font: 10px ui-monospace, monospace;
  letter-spacing: .04em;
  text-transform: uppercase;
}

@media (max-width: 640px) {
  .app-header { padding: 11px 12px; }
  .privacy, #scopeDetail { display: none; }
  .repo-tabs { padding-inline: 10px; }
  main { padding: 10px; }
  .explorer { grid-template-columns: 1fr; height: auto; min-height: 0; }
  .file-tree { max-height: 220px; border-right: 0; border-bottom: 1px solid var(--line); }
  .file-stage { min-height: 350px; max-height: 500px; }
  .scope-files:not([data-files="baseline"]).active { display: flex; gap: 4px; overflow-x: auto; }
  .scope-files:not([data-files="baseline"]) .file-button { flex: 0 0 auto; width: auto; min-height: 34px; }
  .scope-files:not([data-files="baseline"]) .file-button span:last-child { white-space: nowrap; }
  .scope-note { flex: 0 0 210px; margin: 0 4px 0 0; }
  .file-heading { position: sticky; top: 0; z-index: 2; }
  .finding { margin: 10px; }
  pre { font-size: 11px; }
  .line { font-size: 11px; }
  .review-timeline { grid-template-columns: 30px minmax(0, 1fr); gap: 8px; }
  .timeline-avatar { width: 30px; height: 30px; font-size: 12px; }
  .review-timeline::before { left: 14px; top: 30px; }
  .review-discussion > header { align-items: flex-start; flex-direction: column; }
}
