:root {
  --fg: #1f2328;
  --fg-muted: #656d76;
  --border: #d0d7de;
  --border-muted: #d8dee4;
  --bg: #ffffff;
  --bg-subtle: #f6f8fa;
  --canvas-inset: #f6f8fa;
  --accent: #0969da;
  --green: #1f883d;
  --green-hover: #1a7f37;
  --red: #cf222e;
  --open: #1a7f37;
  --merged: #8250df;
  --closed: #d1242f;
  --header-bg: #24292f;
  --radius: 6px;
}

* { box-sizing: border-box; }

/* inline SVG icons inherit text color and align with adjacent text */
.icn { display: inline-block; vertical-align: -0.15em; flex: none; }
.tab .icn, .btn .icn, .subnav a .icn { vertical-align: -0.15em; }
.istate .icn { vertical-align: -0.2em; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", "Hiragino Sans", "Noto Sans JP", Helvetica, Arial, sans-serif;
  color: var(--fg);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.5;
}

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

/* ---- top bar ---- */
.topbar { background: var(--header-bg); color: #fff; }
.topbar-inner {
  max-width: 1280px; margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; gap: 16px;
}
.brand { color: #fff; font-weight: 600; font-size: 16px; display: flex; align-items: center; gap: 6px; }
.brand:hover { text-decoration: none; opacity: .9; }
.brand-mark { font-size: 18px; }
.search { flex: 1; max-width: 480px; }
.search input {
  width: 100%; padding: 5px 12px; border-radius: var(--radius);
  border: 1px solid #3d444d; background: #1c2128; color: #fff; font-size: 13px;
}
.search input::placeholder { color: #8b949e; }
.topbar-nav { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.topbar-nav .btn { color: #fff; border-color: #3d444d; background: transparent; }
.topbar-nav .btn:hover { background: #3d444d; }

/* ---- avatar / menu ---- */
.ident-avatar {
  display: inline-block; border-radius: 50%; text-align: center; color: #fff;
  vertical-align: middle; overflow: hidden; font-weight: 600;
}
.avatar-btn { background: none; border: 0; padding: 0; cursor: pointer; }
.menu { position: relative; }
.menu-list {
  position: absolute; right: 0; top: 36px; background: #fff; color: var(--fg);
  border: 1px solid var(--border); border-radius: var(--radius); min-width: 180px;
  box-shadow: 0 8px 24px rgba(140,149,159,.2); padding: 6px; z-index: 20;
}
.menu-list a, .menu-list .linklike {
  display: block; padding: 6px 8px; border-radius: var(--radius); color: var(--fg);
  width: 100%; text-align: left; background: none; border: 0; cursor: pointer; font-size: 14px;
}
.menu-list a:hover, .menu-list .linklike:hover { background: var(--bg-subtle); text-decoration: none; }
.menu-list form { margin: 0; }

/* ---- layout ---- */
.content { max-width: 1280px; margin: 0 auto; padding: 24px 16px 60px; }
.footer { border-top: 1px solid var(--border); color: var(--fg-muted); text-align: center; padding: 24px; font-size: 12px; }

/* ---- flashes ---- */
.flashes { margin-bottom: 16px; }
.flash { padding: 10px 14px; border-radius: var(--radius); border: 1px solid var(--border); margin-bottom: 8px; }
.flash-error { background: #ffebe9; border-color: #ffcecb; }
.flash-success { background: #dafbe1; border-color: #aceebb; }

/* ---- buttons ---- */
.btn {
  display: inline-block; padding: 5px 16px; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--bg-subtle); color: var(--fg);
  font-size: 14px; font-weight: 500; cursor: pointer; line-height: 20px;
}
.btn:hover { background: #f3f4f6; text-decoration: none; }
.btn-sm { padding: 3px 12px; font-size: 12px; }
.btn-primary, .btn-green { background: var(--green); border-color: rgba(31,35,40,.15); color: #fff; }
.btn-primary:hover, .btn-green:hover { background: var(--green-hover); color: #fff; }
.btn-danger { color: var(--red); }
.btn-danger:hover { background: var(--red); color: #fff; border-color: var(--red); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ---- forms ---- */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-weight: 600; margin-bottom: 6px; }
input[type=text], input[type=search], input[type=email], textarea, select {
  width: 100%; padding: 6px 12px; border: 1px solid var(--border);
  border-radius: var(--radius); font-size: 14px; font-family: inherit; background: #fff;
}
textarea { min-height: 140px; resize: vertical; }
.input-inline { display: inline-block; width: auto; }
.help { color: var(--fg-muted); font-size: 12px; margin-top: 4px; }
.radio-row { display: flex; gap: 8px; align-items: flex-start; margin-bottom: 8px; }
.radio-row input { margin-top: 4px; }

/* ---- box ---- */
.Box { border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }
.Box-header { padding: 10px 16px; background: var(--bg-subtle); border-bottom: 1px solid var(--border); border-radius: var(--radius) var(--radius) 0 0; font-size: 13px; display: flex; align-items: center; gap: 8px; }
.Box-row { padding: 10px 16px; border-bottom: 1px solid var(--border-muted); display: flex; align-items: center; gap: 8px; }
.Box-row:last-child { border-bottom: 0; }
.Box-row:hover { background: #f6f8fafa; }

/* ---- repo header ---- */
.repohead { border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.repohead-title { font-size: 20px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.repohead-title .sep { color: var(--fg-muted); }
.repohead-title .name { font-weight: 600; }
.repohead-meta { color: var(--fg-muted); margin: 6px 0 12px; }
.lock { font-size: 12px; border: 1px solid var(--border); border-radius: 2em; padding: 1px 8px; color: var(--fg-muted); }
.tabs { display: flex; gap: 4px; }
.tab { padding: 8px 12px; border-bottom: 2px solid transparent; color: var(--fg); display: flex; align-items: center; gap: 6px; }
.tab:hover { background: var(--bg-subtle); text-decoration: none; border-radius: var(--radius) var(--radius) 0 0; }
.tab.active { border-bottom-color: #fd8c73; font-weight: 600; }
.counter { background: rgba(175,184,193,.2); border-radius: 2em; padding: 0 6px; font-size: 12px; }
.repohead-actions { float: right; display: flex; gap: 8px; }

/* ---- ref switcher / toolbar ---- */
.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.refswitch { position: relative; }
.refswitch-list { position: absolute; top: 36px; left: 0; z-index: 10; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); min-width: 240px; box-shadow: 0 8px 24px rgba(140,149,159,.2); max-height: 320px; overflow: auto; }
.refswitch-list a { display: block; padding: 8px 12px; color: var(--fg); border-bottom: 1px solid var(--border-muted); }
.refswitch-list a:hover { background: var(--accent); color: #fff; text-decoration: none; }
.breadcrumb { font-size: 16px; }
.breadcrumb a { font-weight: 600; }
.spacer { flex: 1; }

/* ---- file listing ---- */
.filelist .Box-row { gap: 10px; }
.filelist .icon { width: 16px; text-align: center; color: var(--fg-muted); }
.filelist .icon-dir { color: var(--accent); }
.filelist .name { flex: 1; }
.filelist .name a { color: var(--fg); }
.filelist .thumb { width: 28px; height: 28px; object-fit: contain; background: var(--canvas-inset); border-radius: 3px; border: 1px solid var(--border-muted); }
.latest-commit { background: var(--bg-subtle); }
.latest-commit .msg { flex: 1; color: var(--fg-muted); }

/* ---- commit rows / thumbnails ---- */
.commit-day { color: var(--fg-muted); font-size: 13px; margin: 18px 0 8px; }
.commit-row { display: flex; gap: 14px; align-items: center; }
.commit-row .commit-thumb { width: 64px; height: 64px; object-fit: contain; background: var(--canvas-inset); border: 1px solid var(--border-muted); border-radius: var(--radius); flex: none; }
.commit-row .commit-thumb.empty { display: flex; align-items: center; justify-content: center; color: #afb8c1; font-size: 22px; }
.commit-row .commit-main { flex: 1; min-width: 0; }
.commit-row .commit-title { font-weight: 600; }
.commit-row .commit-sub { color: var(--fg-muted); font-size: 12px; }
.mono, code, .sha { font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace; }
.sha { background: var(--bg-subtle); border-radius: var(--radius); padding: 1px 6px; font-size: 12px; }

/* ---- commit graph (git-graph style rail) ---- */
.commit-graph { overflow-x: auto; }
/* zero the row's vertical padding so each per-row SVG fills the full fixed
   height and the rails meet edge-to-edge between stacked rows */
.graph-row { box-sizing: border-box; padding-top: 0; padding-bottom: 0; }
.graph-row .graph-gutter { flex: none; align-self: stretch; display: block; }
.graph-row .commit-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.graph-line { fill: none; stroke-width: 2; }
.graph-node { stroke: #fff; stroke-width: 1.5; }
.ref-badge {
  display: inline-flex; align-items: center; gap: 3px; font-weight: 500;
  font-size: 11px; line-height: 1; padding: 2px 6px; border-radius: 999px;
  border: 1px solid var(--accent); color: var(--accent); margin-right: 6px;
}
.ref-badge.tag { border-color: var(--green); color: var(--green); }

/* lane colour palette — shared by lines (stroke) and nodes (fill) */
.graph-line.c0 { stroke: #0969da; } .graph-node.c0 { fill: #0969da; }
.graph-line.c1 { stroke: #1f883d; } .graph-node.c1 { fill: #1f883d; }
.graph-line.c2 { stroke: #8250df; } .graph-node.c2 { fill: #8250df; }
.graph-line.c3 { stroke: #cf222e; } .graph-node.c3 { fill: #cf222e; }
.graph-line.c4 { stroke: #bc4c00; } .graph-node.c4 { fill: #bc4c00; }
.graph-line.c5 { stroke: #0550ae; } .graph-node.c5 { fill: #0550ae; }
.graph-line.c6 { stroke: #1b7c83; } .graph-node.c6 { fill: #1b7c83; }
.graph-line.c7 { stroke: #a16207; } .graph-node.c7 { fill: #a16207; }

/* ---- markdown / readme ---- */
.markdown { line-height: 1.7; }
.markdown h1, .markdown h2 { border-bottom: 1px solid var(--border-muted); padding-bottom: .3em; }
.markdown pre { background: var(--bg-subtle); padding: 12px; border-radius: var(--radius); overflow: auto; }
.markdown code { background: rgba(175,184,193,.2); padding: .2em .4em; border-radius: 3px; }
.markdown pre code { background: none; padding: 0; }
.markdown table { border-collapse: collapse; }
.markdown table th, .markdown table td { border: 1px solid var(--border); padding: 6px 12px; }
.markdown img { max-width: 100%; }

/* ---- blob ---- */
.blob-text { margin: 0; padding: 16px; background: #fff; overflow: auto; font-size: 12.5px; }
.blob-image { text-align: center; padding: 24px; background: var(--canvas-inset); }
.blob-image img { max-width: 100%; }
.preview-canvas { display: block; max-width: 100%; margin: 0 auto; background: var(--canvas-inset); }
.layer-table { width: 100%; border-collapse: collapse; }
.layer-table th, .layer-table td { text-align: left; padding: 6px 12px; border-bottom: 1px solid var(--border-muted); }
.layer-table th { color: var(--fg-muted); font-weight: 600; }
.indent { color: var(--fg-muted); }

/* ---- diff ---- */
.diff-file { margin-bottom: 24px; }
.diff-file .Box-header { justify-content: space-between; }
.diff-modes { display: flex; gap: 6px; }
.diff-modes button { font-size: 12px; padding: 2px 10px; border: 1px solid var(--border); background: #fff; border-radius: var(--radius); cursor: pointer; }
.diff-modes button.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.diff-view { padding: 16px; text-align: center; background: var(--canvas-inset); }
.diff-view img { max-width: 100%; }
.layerdiff { padding: 8px 16px 16px; }
.layerdiff .lrow { display: flex; gap: 12px; align-items: center; padding: 6px 0; border-top: 1px solid var(--border-muted); }
.layerdiff img { width: 72px; height: 72px; object-fit: contain; background: var(--canvas-inset); border: 1px solid var(--border-muted); border-radius: 4px; }
.tag-added { color: var(--green); }
.tag-deleted, .tag-removed { color: var(--red); }
.tag-modified { color: #9a6700; }

/* ---- badges / state ---- */
.badge { display: inline-block; padding: 4px 10px; border-radius: 2em; font-size: 12px; font-weight: 600; color: #fff; }
.badge-open { background: var(--open); }
.badge-merged { background: var(--merged); }
.badge-closed { background: var(--closed); }

/* ---- issue / pr lists ---- */
.issue-row { display: flex; gap: 10px; align-items: baseline; }
.issue-row .istate { color: var(--open); }
.issue-row.closed .istate { color: var(--closed); }
.issue-title a { color: var(--fg); font-weight: 600; font-size: 15px; }
.subnav { display: flex; gap: 16px; margin-bottom: 12px; }
.subnav a { color: var(--fg-muted); font-weight: 600; }
.subnav a.active { color: var(--fg); }

/* ---- comments / timeline ---- */
.timeline { margin: 16px 0; }
.comment { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 16px; }
.comment-head { background: var(--bg-subtle); padding: 8px 16px; border-bottom: 1px solid var(--border); border-radius: var(--radius) var(--radius) 0 0; color: var(--fg-muted); }
.comment-body { padding: 16px; }

/* ---- misc ---- */
.grid-repos { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.repo-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.repo-card h3 { margin: 0 0 6px; font-size: 16px; }
.repo-card .desc { color: var(--fg-muted); min-height: 20px; }
.repo-card .meta { color: var(--fg-muted); font-size: 12px; margin-top: 12px; }
.empty-state { text-align: center; padding: 48px 16px; color: var(--fg-muted); }
.page-title { font-size: 22px; margin: 0 0 16px; }
.muted { color: var(--fg-muted); }
.clone-box { display: flex; gap: 8px; align-items: center; }
.clone-box input { font-family: ui-monospace, monospace; font-size: 12px; }
.pagination { display: flex; gap: 8px; justify-content: center; margin-top: 24px; }
.cols { display: grid; grid-template-columns: 1fr 296px; gap: 24px; align-items: start; }
@media (max-width: 900px) { .cols { grid-template-columns: 1fr; } }
.sidebar h4 { margin: 0 0 8px; font-size: 14px; }
.sidebar .section { padding-bottom: 16px; margin-bottom: 16px; border-bottom: 1px solid var(--border-muted); }
hr.div { border: 0; border-top: 1px solid var(--border-muted); margin: 16px 0; }
.copybtn { cursor: pointer; }

/* ---- plans / quotas ---- */
.plan-card { margin-top: 16px; }
.plan-card.compact { margin: 0 0 16px; }
.plan-body { padding: 16px; }
.plan-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; margin-bottom: 14px; }
.plan-name { font-size: 18px; font-weight: 600; }
.quota-block { margin-bottom: 14px; }
.quota-line { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.quota-bar { height: 8px; overflow: hidden; border-radius: 999px; background: var(--bg-subtle); border: 1px solid var(--border-muted); }
.quota-bar div { height: 100%; background: var(--accent); }
.quota-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.quota-grid div { padding: 10px; background: var(--bg-subtle); border-radius: var(--radius); }
.quota-grid strong, .quota-grid span { display: block; }
.quota-grid span { color: var(--fg-muted); margin-top: 2px; }
.dev-plan-form { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border-muted); }
.dev-plan-form label { display: block; font-weight: 600; margin-bottom: 6px; }
.inline-form { display: flex; gap: 8px; align-items: center; }
.inline-form select { flex: 1; }
