/* forge — "modern dark editorial SaaS" (hybrid)
   Fraunces (serif) for big headings, Inter for the rest; warm near-black,
   paper text, generous whitespace, ember accent. */

@font-face {
  font-family: "Inter";
  src: url("/static/fonts/InterVariable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Fraunces";
  src: url("/static/fonts/Fraunces.woff2") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}

/* The palette follows `color-scheme`, which `light-dark()` resolves at use
   time: `system` keeps `light dark` (the OS decides), while the explicit modes
   force one scheme. Everything below therefore stays in a single block. */
:root {
  color-scheme: light dark;

  --bg: light-dark(#faf8f5, #0a0a0b);
  --surface: light-dark(#ffffff, #121214);
  --surface-2: light-dark(#ffffff, #17171a);
  --surface-3: light-dark(#f3f0eb, #1e1e22);
  --border: light-dark(#e7e2da, #232327);
  --border-strong: light-dark(#d6cfc4, #33333a);
  --fg: light-dark(#1b1a17, #f4f2ee);
  --muted: light-dark(#6b6862, #a0a0a8);
  --faint: light-dark(#9a968e, #6b6b73);

  --accent: light-dark(#e2591f, #ff7a45);
  --accent-2: light-dark(#c2410c, #ff9268);
  --accent-fg: light-dark(#ffffff, #1a0d06);
  --link: light-dark(#c2410c, #ff9a6b);

  --success: light-dark(#16a34a, #3ecf8e);
  --danger: light-dark(#dc2626, #ff6b6b);
  --warning: light-dark(#b45309, #f5b544);
  --info: light-dark(#2563eb, #5aa9ff);
  --merged: light-dark(#7c3aed, #a78bfa);

  --add: light-dark(#dcfce7, #10301f);
  --del: light-dark(#fee2e2, #3a1717);
  --code-bg: light-dark(#f4f4f5, #0c0c0e);
  --topbar-bg: light-dark(rgba(255, 255, 255, 0.82), rgba(10, 10, 11, 0.82));

  --radius: 8px;
  --radius-sm: 5px;
  --radius-pill: 999px;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.03);

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;

  --font: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Helvetica, Arial, sans-serif;
  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

/* `--shadow` is the one token `light-dark()` cannot carry — it takes colours,
   not shadow lists — so it is spelled out for the light scheme. */
:root[data-theme="light"] {
  color-scheme: light;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(0, 0, 0, 0.04);
}
:root[data-theme="dark"] {
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root[data-theme="system"] {
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(0, 0, 0, 0.04);
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1,
h2,
h3,
h4 {
  line-height: 1.2;
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* Hybrid: Fraunces serif for the big headings only. */
h1,
h2 {
  font-family: var(--serif);
  font-weight: 600;
}

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

code,
pre,
kbd {
  font-family: var(--mono);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
}
.skip-link:focus {
  left: 12px;
  top: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
}

/* ---------------------------------------------------------------- topbar */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--topbar-bg);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: 9px clamp(16px, 3vw, 40px);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.01em;
  color: var(--fg);
}
.brand:hover {
  text-decoration: none;
}
.brand svg {
  color: var(--accent);
}
.session {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-left: auto;
  font-size: 13px;
}
.session a {
  color: var(--muted);
}
.session a:hover {
  color: var(--fg);
}
.session .user {
  color: var(--fg);
  font-weight: 600;
}
.topbar-search {
  flex: 1;
  max-width: 340px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  color: var(--muted);
  cursor: pointer;
}
.topbar-search:hover {
  border-color: var(--border-strong);
  color: var(--fg);
}
.topbar-search .ph {
  flex: 1;
  text-align: left;
}
.topbar-search kbd {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 5px;
  font-size: 11px;
  color: var(--faint);
}
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--muted);
  cursor: pointer;
}
.icon-btn:hover {
  color: var(--fg);
  background: var(--surface-3);
}
/* The theme toggle is a form so it works without a script; `display: contents`
   keeps its button a direct child of the topbar, where the layout expects it. */
.theme-form {
  display: contents;
}
.user-menu {
  position: relative;
}
.user-menu > summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--fg);
}
.user-menu > summary::-webkit-details-marker {
  display: none;
}
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--accent-fg);
}
.user-menu .menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 190px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 5px;
  display: flex;
  flex-direction: column;
}
.user-menu .menu a,
.user-menu .menu button {
  text-align: left;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  color: var(--fg);
  background: transparent;
  border: 0;
  font: inherit;
  cursor: pointer;
}
.user-menu .menu a:hover,
.user-menu .menu button:hover {
  background: var(--surface-3);
  text-decoration: none;
}

/* --------------------------------------------------------------- content */

.content {
  padding: var(--space-5) clamp(16px, 3vw, 40px) 72px;
}

/* ------------------------------------------------------------- repo head */

.repo-head {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}
.repo-head h1 {
  font-size: 27px;
  margin: 0;
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
}
.repo-head .slash {
  color: var(--faint);
}
.repo-head .btn {
  margin-left: auto;
}
.ref-badge {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px 8px;
}

/* segmented control */
.repo-nav {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  margin: var(--space-4) 0 var(--space-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
}
.repo-nav::-webkit-scrollbar {
  display: none;
}
.repo-nav a {
  color: var(--muted);
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  font-size: 13px;
}
.repo-nav a:hover {
  color: var(--fg);
  text-decoration: none;
}
.repo-nav a.active {
  background: var(--surface-3);
  color: var(--fg);
  font-weight: 600;
  box-shadow: inset 0 0 0 1px var(--border-strong);
}

.breadcrumb {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: var(--space-3);
  color: var(--muted);
  flex-wrap: wrap;
  font-size: 13px;
}
.breadcrumb .sep {
  color: var(--faint);
}

/* ---------------------------------------------------------------- buttons */

button,
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}
button:hover,
.btn:hover {
  border-color: var(--border-strong);
  background: var(--surface-3);
  text-decoration: none;
}
button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
  font-weight: 600;
}
.btn.primary:hover {
  background: var(--accent-2);
  border-color: var(--accent-2);
}
button.danger {
  background: transparent;
  border-color: var(--danger);
  color: var(--danger);
}
button.danger:hover {
  background: color-mix(in srgb, var(--danger) 14%, transparent);
}
.link {
  background: transparent;
  border: 0;
  color: var(--link);
  cursor: pointer;
  padding: 0;
  font: inherit;
}
.link:hover {
  text-decoration: underline;
}
.link.danger {
  color: var(--danger);
}

/* ----------------------------------------------------------------- chips */

.state-badge,
.kanban-label,
.review-state,
.label-chip,
.badge,
.ref-badge {
  font-family: var(--mono);
}
.state-badge,
.kanban-label,
.review-state,
.label-chip,
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 1px 8px;
  font-size: 11px;
  color: var(--muted);
  background: var(--surface);
}
.state-badge.open,
.state-badge.success,
.review-state.approved {
  background: color-mix(in srgb, var(--success) 16%, transparent);
  border-color: color-mix(in srgb, var(--success) 45%, transparent);
  color: var(--success);
}
.state-badge.closed,
.state-badge.failure,
.review-state.requested_changes {
  background: color-mix(in srgb, var(--danger) 16%, transparent);
  border-color: color-mix(in srgb, var(--danger) 45%, transparent);
  color: var(--danger);
}
.state-badge.running,
.state-badge.pending,
.review-state.commented {
  background: color-mix(in srgb, var(--warning) 16%, transparent);
  border-color: color-mix(in srgb, var(--warning) 45%, transparent);
  color: var(--warning);
}
.state-badge.merged {
  background: color-mix(in srgb, var(--merged) 18%, transparent);
  border-color: color-mix(in srgb, var(--merged) 45%, transparent);
  color: var(--merged);
}

/* ----------------------------------------------------------------- cards */

.card,
.notice,
.commit-head,
.issue-body,
.readme,
.registry-image,
.conflict-editor,
.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.notice {
  padding: var(--space-4);
  color: var(--muted);
}
.empty {
  padding: 40px;
  text-align: center;
  color: var(--muted);
}
.error {
  text-align: center;
  padding: 48px 0;
}
.error h1 {
  font-size: 44px;
  margin: 0;
}
.hint {
  color: var(--muted);
  font-size: 13px;
}
.muted {
  color: var(--muted);
  font-size: 13px;
}
.more {
  margin-top: var(--space-4);
}

/* ---------------------------------------------------------------- tables */

table.code,
table.diff,
table.users,
.cards-table {
  width: 100%;
  border-collapse: collapse;
}
table.users,
.cards-table {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin: var(--space-3) 0;
}
table.users th,
table.users td,
.cards-table th,
.cards-table td {
  text-align: left;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
table.users tr:last-child td,
.cards-table tr:last-child td {
  border-bottom: 0;
}
table.users th,
.cards-table th {
  font-family: var(--mono);
  color: var(--muted);
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--surface);
}
table.users tbody tr:hover,
.cards-table tbody tr:hover {
  background: var(--surface-3);
}

/* ----------------------------------------------------------- tree / code */

.tree-tools {
  margin-bottom: var(--space-2);
}
.filter {
  width: 100%;
  padding: 8px 12px;
  background: var(--surface);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.tree {
  list-style: none;
  padding: 0;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.tree .entry {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}
.tree .entry:last-child {
  border-bottom: 0;
}
.tree .entry:hover {
  background: var(--surface);
}
.tree .entry a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--fg);
}
.tree .entry svg {
  color: var(--faint);
  flex-shrink: 0;
}
.tree .entry.tree svg {
  color: var(--accent);
}
.tree .entry .size {
  font-family: var(--mono);
  color: var(--faint);
  font-size: 12px;
}

.latest-commit {
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: var(--space-4);
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
}
.latest-commit .subject {
  font-weight: 600;
}
.latest-commit .meta {
  font-family: var(--mono);
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.readme {
  margin-top: var(--space-5);
  max-width: 900px;
  overflow: hidden;
}
.readme-name {
  font-family: var(--mono);
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
}
.markdown {
  padding: var(--space-5) var(--space-6);
  max-width: 74ch;
  font-size: 15.5px;
  line-height: 1.75;
}
.markdown > :first-child {
  margin-top: 0;
}
.markdown h1 {
  font-size: 30px;
  margin: 0 0 16px;
}
.markdown h2 {
  font-size: 22px;
  margin: 34px 0 12px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}
.markdown h3 {
  font-size: 17px;
  margin: 26px 0 8px;
}
.markdown p,
.markdown ul,
.markdown ol {
  margin: 0 0 16px;
}
.markdown ul,
.markdown ol {
  padding-left: 22px;
}
.markdown li {
  margin: 4px 0;
}
.markdown a {
  text-decoration: underline;
  text-underline-offset: 2px;
}
.markdown code {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1px 5px;
  font-size: 0.9em;
}
.markdown pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  overflow: auto;
  position: relative;
}
.markdown pre code {
  background: transparent;
  border: 0;
  padding: 0;
}
.markdown blockquote {
  margin: 0 0 var(--space-3);
  padding: 2px 14px;
  border-left: 3px solid var(--border-strong);
  color: var(--muted);
}
.markdown table {
  border-collapse: collapse;
}
.markdown th,
.markdown td {
  border: 1px solid var(--border);
  padding: 6px 10px;
}
.code-copy {
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 11px;
  padding: 2px 8px;
  opacity: 0;
  transition: opacity 0.12s ease;
}
.markdown pre:hover .code-copy {
  opacity: 1;
}

.file-head {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-2);
}
.file-head .file-size {
  color: var(--muted);
  font-size: 12px;
}
.file-head .raw {
  margin-left: auto;
  font-size: 12px;
}

table.code {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
table.code td {
  vertical-align: top;
  padding: 0 8px;
  font-family: var(--mono);
  font-size: 13px;
}
table.code td.ln {
  width: 1%;
  text-align: right;
  color: var(--faint);
  background: var(--surface);
  user-select: none;
}
table.code tr:hover td {
  background: var(--surface-3);
}

/* ---------------------------------------------------------------- lists */

ul.issues,
ul.commits,
ul.comments,
ul.reviews,
ul.assignees {
  list-style: none;
  padding: 0;
  margin: 0;
}
ul.issues {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}
ul.issues li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-3);
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
ul.issues li:last-child {
  border-bottom: 0;
}
ul.issues li:hover {
  background: var(--surface-3);
}
ul.issues .title {
  font-weight: 600;
  color: var(--fg);
}
ul.issues .meta {
  font-family: var(--mono);
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
ul.issues li.empty {
  color: var(--muted);
  justify-content: center;
}
ul.issues li.unread .title {
  font-weight: 700;
}
ul.issues li.unread .title::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: var(--radius-pill);
  background: var(--accent);
  margin-right: 8px;
  vertical-align: middle;
}

.commits {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}
.commits li {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
}
.commits li:last-child {
  border-bottom: 0;
}
.commits li:hover {
  background: var(--surface-3);
}
.commits .meta {
  font-family: var(--mono);
  color: var(--muted);
  font-size: 12px;
}
.commits li.more {
  justify-content: center;
}

.commit-head {
  padding: var(--space-4) 18px;
  margin-bottom: var(--space-4);
}
.commit-head h2 {
  margin: 0 0 8px;
}
.commit-head .meta {
  color: var(--muted);
  font-size: 12px;
}
.commit-head .sha {
  margin-top: 8px;
  font-size: 12px;
}
.commit-body {
  white-space: pre-wrap;
  margin-top: var(--space-3);
}

.stats {
  margin-bottom: var(--space-3);
  font-family: var(--mono);
  font-size: 12px;
}
.stats .add {
  color: var(--success);
}
.stats .del {
  color: var(--danger);
}

table.diff {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  font-family: var(--mono);
  font-size: 13px;
}
table.diff td {
  padding: 0 8px;
  white-space: pre-wrap;
  word-break: break-word;
}
table.diff .diff-file td {
  background: var(--surface-3);
  font-weight: 600;
  padding: 8px;
}
table.diff .diff-hunk td {
  background: color-mix(in srgb, var(--info) 14%, var(--bg));
  color: var(--info);
  padding: 4px 8px;
}
table.diff .diff-meta td {
  color: var(--muted);
}
table.diff .diff-line.add {
  background: color-mix(in srgb, var(--success) 14%, transparent);
}
table.diff .diff-line.del {
  background: color-mix(in srgb, var(--danger) 14%, transparent);
}
table.diff .mark {
  width: 1%;
  text-align: center;
  color: var(--faint);
  user-select: none;
}

/* ------------------------------------------------------- issues and PRs */

.issues-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin: var(--space-3) 0;
}
.issues-toolbar .filters a {
  color: var(--muted);
  margin-left: var(--space-3);
  font-size: 13px;
}
.issues-toolbar .filters a.active {
  color: var(--fg);
  font-weight: 600;
}
.issue-head {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.issue-head h2 {
  margin: 0;
}
.issue-number {
  color: var(--faint);
  font-weight: 400;
}
.issue-meta {
  color: var(--muted);
  font-size: 12px;
  margin: var(--space-2) 0 var(--space-4);
}
.issue-body {
  padding: var(--space-4) 18px;
  margin-bottom: var(--space-4);
}
ul.comments {
  margin: var(--space-4) 0;
}
ul.comments li {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-3) 14px;
  margin-bottom: var(--space-3);
  background: var(--surface);
}
.comment-meta {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: var(--space-2);
}
.issue-layout {
  display: flex;
  gap: var(--space-5);
  align-items: flex-start;
}
.issue-main {
  flex: 1;
  min-width: 0;
}
.issue-side {
  width: 250px;
  flex-shrink: 0;
}
.side-block {
  margin-bottom: var(--space-5);
}
.side-block h4 {
  margin: 0 0 var(--space-2);
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.labels {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: var(--space-2);
}
.label-chip {
  color: #fff;
  border-color: transparent;
  background: var(--muted);
}
.label-chip button {
  background: transparent;
  border: 0;
  color: inherit;
  padding: 0 2px;
  cursor: pointer;
}
.inline {
  display: inline;
}
ul.assignees li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 2px 0;
}
ul.assignees button {
  padding: 0 6px;
}
.milestone {
  font-size: 13px;
}

.pr-branches {
  display: flex;
  gap: var(--space-3);
}
.pr-branches label {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  font-size: 12px;
  color: var(--muted);
}
.pr-actions {
  display: flex;
  gap: var(--space-3);
  align-items: center;
  margin: var(--space-4) 0;
}
.pr-commit {
  margin-bottom: var(--space-4);
}
ul.reviews li {
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}
ul.reviews li:last-child {
  border-bottom: 0;
}

/* --------------------------------------------------------------- forms */

input,
textarea,
select {
  font: inherit;
}
input[type="text"],
input[type="password"],
input[type="email"],
input[type="search"],
input[type="number"],
input[type="url"],
textarea,
select {
  background: var(--surface);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
}
input::placeholder,
textarea::placeholder {
  color: var(--faint);
}
input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}

.issue-form,
.comment-form,
.review-form,
.login form {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.issue-form,
.comment-form {
  margin-top: var(--space-4);
}
.issue-form label,
.login label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}
.issue-form input[type="checkbox"],
.issue-form input[type="radio"] {
  width: auto;
}
.issue-form button,
.comment-form button,
.review-form button {
  align-self: flex-start;
}
.inline-form {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}
.inline-form input {
  padding: 6px 9px;
}

/* --------------------------------------------------------------- kanban */

.project-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-4);
  margin: var(--space-2) 0 var(--space-4);
  flex-wrap: wrap;
}
.project-head h2,
.project-head h3 {
  margin: 0;
}
.project-actions {
  display: flex;
  gap: var(--space-3);
  align-items: center;
  flex-wrap: wrap;
}
.kanban {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
  overflow-x: auto;
  padding-bottom: var(--space-2);
}
.kanban-col {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px;
  width: 272px;
  flex: 0 0 272px;
}
.kanban-col-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-1);
  margin-bottom: var(--space-2);
}
.kanban-col-form {
  flex: 1;
}
.kanban-col-name {
  width: 100%;
  background: transparent;
  color: var(--fg);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 4px 6px;
  font-weight: 600;
}
.kanban-col-name:hover,
.kanban-col-name:focus {
  border-color: var(--border);
  background: var(--surface-3);
}
.kanban-col-handle {
  cursor: grab;
  color: var(--faint);
  user-select: none;
}
.kanban-col-count {
  font-family: var(--mono);
  color: var(--muted);
  font-size: 12px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 0 8px;
}
.kanban-cards {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 12px;
}
.kanban-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 10px;
  cursor: grab;
}
.kanban-card:hover {
  border-color: var(--border-strong);
}
.kanban-card-title {
  font-weight: 600;
}
.kanban-card-body {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
  white-space: pre-wrap;
}
.kanban-card-meta {
  display: flex;
  gap: var(--space-2);
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}
.kanban-card-actions {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  margin-top: 6px;
}
.kanban-card-labels {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}
.kanban-edit summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 12px;
}
.kanban-edit form {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
}
.kanban-add input {
  width: 100%;
  background: transparent;
  color: var(--fg);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 9px;
}
.kanban-add input:hover {
  border-color: var(--accent);
}
.kanban-new {
  border-style: dashed;
}
.project-filters {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  margin: var(--space-3) 0;
  flex-wrap: wrap;
}
.view-toggle-form {
  display: inline-flex;
}
.view-toggle {
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 5px 14px;
  cursor: pointer;
}
.view-toggle:first-child {
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}
.view-toggle:last-child {
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  border-left: 0;
}
.view-toggle.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
}

/* ----------------------------------------------------- registry/releases */

.registry-image {
  padding: var(--space-3) 14px;
  margin: var(--space-3) 0;
}
.registry-image h3 {
  margin: 0 0 4px;
}
.registry-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: var(--space-2);
}

/* ----------------------------------------------------------- search / ci */

.search-form {
  display: flex;
  gap: var(--space-2);
  margin: var(--space-3) 0;
}
.search-form input {
  flex: 1;
}
.search-lines {
  margin-top: 6px;
}
.search-lines code {
  color: var(--muted);
  font-size: 12px;
}
.ci-log {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
  overflow: auto;
  font-family: var(--mono);
  font-size: 12px;
  white-space: pre-wrap;
}

/* --------------------------------------------------------- accounts */

.login {
  max-width: 380px;
  margin: 48px auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-5);
}
.login h1 {
  margin: 0;
}
.login details {
  border-top: 1px solid var(--border);
  padding-top: var(--space-3);
}
.login details summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
}
.login details form {
  margin-top: var(--space-2);
}

/* ---------------------------------------------------- command palette */

.palette {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12vh;
  background: rgba(0, 0, 0, 0.5);
}
.palette.open {
  display: flex;
}
.palette-box {
  width: min(560px, 92vw);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.palette-box input {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  padding: 14px 16px;
  background: transparent;
  font-size: 15px;
}
.palette-list {
  list-style: none;
  margin: 0;
  padding: 6px;
  max-height: 320px;
  overflow: auto;
}
.palette-list li a {
  display: block;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--fg);
}
.palette-list li a:hover,
.palette-list li.active a {
  background: var(--surface-3);
  text-decoration: none;
}
.palette-list .hint {
  padding: 8px 10px;
}

/* --------------------------------------------------------------- density */

[data-density="compact"] {
  --space-3: 8px;
  --space-4: 12px;
  --space-5: 18px;
}
[data-density="compact"] .content {
  padding-top: var(--space-4);
}
[data-density="compact"] ul.issues li,
[data-density="compact"] .commits li,
[data-density="compact"] table.users td,
[data-density="compact"] .cards-table td {
  padding: 6px 10px;
}

/* ---------------------------------------------------------- page layout */

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
  margin-bottom: var(--space-5);
}
.page-title {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
}
.page-title h1 {
  margin: 0;
  font-size: 26px;
}
.page-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}
.toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin: var(--space-4) 0;
}
.toolbar .spacer {
  margin-left: auto;
}
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin: var(--space-5) 0 var(--space-3);
}
.section-head h2,
.section-head h3 {
  margin: 0;
  font-size: 16px;
}
.form-card {
  padding: var(--space-5);
  max-width: 480px;
}
.form-card .issue-form {
  margin-top: 0;
}

.repo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-3);
}
.repo-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--fg);
  transition: border-color 0.12s ease, background 0.12s ease;
}
.repo-card:hover {
  border-color: var(--border-strong);
  background: var(--surface-3);
  text-decoration: none;
}
.repo-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}
.repo-card-name {
  font-weight: 600;
  font-size: 15px;
}
.repo-card-meta {
  font-family: var(--mono);
  color: var(--muted);
  font-size: 12px;
}
.repo-card-desc {
  color: var(--muted);
  font-size: 13px;
}

/* settings sidebar */
.settings-layout {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: var(--space-5);
  align-items: start;
}
.settings-nav {
  position: sticky;
  top: 72px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.settings-nav a {
  color: var(--muted);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.settings-nav a:hover {
  color: var(--fg);
  background: var(--surface-3);
  text-decoration: none;
}
.settings h2 {
  margin: var(--space-5) 0 var(--space-3);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
  font-size: 16px;
}
.settings > h2:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}
.settings .issue-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-4);
  max-width: none;
  margin-top: var(--space-3);
}

/* repo description + actions */
.repo-desc {
  color: var(--muted);
  font-size: 16px;
  line-height: 1.55;
  margin: 8px 0 0;
  max-width: 68ch;
}
.repo-actions {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  flex-wrap: wrap;
  margin-top: var(--space-3);
}
.repo-head .repo-actions {
  margin-left: auto;
  margin-top: 0;
}
.dropdown {
  position: relative;
}
.dropdown > summary {
  list-style: none;
  cursor: pointer;
}
.dropdown > summary::-webkit-details-marker {
  display: none;
}
.dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 40;
  min-width: 360px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.clone-field {
  display: flex;
  align-items: center;
  gap: 6px;
}
.clone-label {
  font-family: var(--mono);
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  width: 46px;
}
.clone-field input {
  flex: 1;
  min-width: 0;
  font-family: var(--mono);
  font-size: 12px;
  padding: 6px 8px;
}
.dropdown-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  color: var(--fg);
  background: transparent;
  border: 0;
  font: inherit;
  cursor: pointer;
}
.dropdown-item:hover {
  background: var(--surface-3);
  text-decoration: none;
}
.forked-from {
  color: var(--muted);
  font-size: 13px;
  margin: 6px 0 0;
}

.admin-nav {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.admin-nav a {
  color: var(--muted);
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.admin-nav a:hover {
  color: var(--fg);
  text-decoration: none;
}
.admin-nav a.active {
  background: var(--surface-3);
  color: var(--fg);
  font-weight: 600;
  box-shadow: inset 0 0 0 1px var(--border-strong);
}

/* ------------------------------------------------------------- responsive */

@media (max-width: 800px) {
  .topbar-search {
    display: none;
  }
  .content {
    padding: var(--space-4) 14px 48px;
  }
  .issue-layout {
    flex-direction: column;
  }
  .issue-side {
    width: 100%;
  }
  .repo-head .btn {
    margin-left: 0;
  }
  .settings-layout {
    grid-template-columns: 1fr;
  }
  .settings-nav {
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
  }
  .cards-table,
  table.users {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
}

@media (max-width: 520px) {
  .session .label {
    display: none;
  }
  .brand .word {
    display: none;
  }
}

/* ---------------------------------------------------------------- print */

@media print {
  .topbar,
  .repo-nav,
  .pr-actions,
  .issue-form,
  .comment-form,
  .review-form,
  .palette,
  .link.danger {
    display: none !important;
  }
  body {
    background: #fff;
    color: #000;
  }
  .content {
    max-width: none;
  }
}

/* ------------------------------------------------------------- web editor */

.editor-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-top: var(--space-3);
}
.editor-form > label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}
.editor {
  width: 100%;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.5;
  background: var(--code-bg);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  resize: vertical;
  tab-size: 4;
}
.editor-actions {
  display: flex;
  gap: var(--space-2);
  align-items: center;
}
.file-head form {
  display: inline;
}

.tree-tools {
  display: flex;
  gap: var(--space-2);
  align-items: center;
}
.tree-tools .filter {
  flex: 1;
  width: auto;
}
.tree-tools form {
  display: inline-flex;
}

/* commit graph (branch tree) */
.view-toggle-form {
  margin-bottom: var(--space-4);
}
.view-toggle {
  text-decoration: none;
}
.graph-wrap {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: var(--space-4);
}
.graph-svg {
  flex: 0 0 auto;
}
.graph-svg svg.graph {
  display: block;
}
.graph-commits {
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1;
  min-width: 0;
}
.graph-commits li {
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}
.graph-commits .graph-subject {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.graph-commits .graph-subject a {
  color: var(--fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.graph-commits .meta {
  font-family: var(--mono);
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

/* project diagram (Mermaid) */
.diagram-hint {
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 var(--space-4);
}
.diagram-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: var(--space-5);
  overflow: auto;
  max-height: 78vh;
}
.diagram-wrap pre.mermaid {
  margin: 0;
  background: transparent;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
  white-space: pre;
}
.diagram-wrap svg {
  display: block;
  margin: 0 auto;
  max-width: 100%;
  height: auto;
}
