/* GitHub per account (github-repositories.js, github-connect.js): Settings → Connections → GitHub, the two steps after
   connecting, and an agent's Repositories. One access row everywhere: a tick, who, and Read or Read and write. */
.github-connections, .agent-repositories { display: grid; gap: 10px; min-width: 0; overflow-wrap: anywhere; }
.github-connections h2, .agent-repositories h2 { margin: 0; }
.github-connections h3, .agent-repositories h3 { margin: 12px 0 0; font-size: 1rem; }
.github-head { display: grid; gap: 4px; }
.github-head p { margin: 0; }
.github-repo, .github-accounts { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.github-repo .grow, .github-accounts .grow { flex: 1 1 12rem; min-width: 0; display: grid; gap: 2px; }
.github-repo .btn, .github-accounts .btn { min-height: 40px; }
.github-said:empty, .gh-said:empty { display: none; }
.github-more { margin: 8px 0 0; }

/* What each access allows, said once above the rows. */
.gh-legend { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 12px; margin: 4px 0 0; padding: 12px 14px; border-radius: 10px; background: var(--soft, #f2ecfa); font-size: .875rem; line-height: 1.4; }
.gh-legend dt { font-weight: 600; }
.gh-legend dd { margin: 0; color: var(--muted, #686577); }
@media (max-width: 520px) { .gh-legend { grid-template-columns: minmax(0, 1fr); gap: 0; } .gh-legend dd + dt { margin-top: 8px; } }

/* The rows: a grid of agents (or repositories), each a tick, who, and the choice once ticked. */
.gh-access-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 10px; min-width: 0; }
.gh-access-row { display: grid; gap: 10px; align-content: start; min-width: 0; padding: 12px 14px; border: 1px solid var(--line, #e7e5ee); border-radius: 12px; background: var(--surface, #fff); }
.gh-access-row[data-access="READ"], .gh-access-row[data-access="WRITE"] { border-color: var(--purple, #6d28b5); box-shadow: 0 0 0 1px var(--purple, #6d28b5) inset; }
.gh-access-who { display: flex; align-items: center; gap: 12px; min-width: 0; cursor: pointer; }
.gh-access-who input[type=checkbox] { flex: none; width: 20px; height: 20px; margin: 0; accent-color: var(--purple, #6d28b5); cursor: pointer; }
.gh-access-who input[disabled] { cursor: default; }
.gh-agent, .gh-repo-name { flex: 1; min-width: 0; display: flex; }
.gh-agent .agent-compact-name { white-space: normal; }
.gh-agent .agent-role-runtime { color: var(--muted, #686577); font-size: .8125rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.gh-choice { display: flex; gap: 3px; padding: 3px; border-radius: 10px; background: var(--soft, #f2ecfa); }
.gh-choice[hidden] { display: none; }
.gh-choice-option { flex: 1; position: relative; display: flex; }
.gh-choice-option input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.gh-choice-option span { flex: 1; display: flex; align-items: center; justify-content: center; min-height: 36px; padding: 6px 10px; border-radius: 8px; font-size: .875rem; text-align: center; color: var(--muted, #686577); }
.gh-choice-option input:checked + span { background: var(--surface, #fff); color: var(--purple, #6d28b5); font-weight: 600; box-shadow: 0 1px 4px #30204214; }
.gh-choice-option input:focus-visible + span { outline: 2px solid var(--purple, #6d28b5); outline-offset: 1px; }

/* A repository as its own section, folded or open. */
.gh-repo { border-top: 1px solid var(--line, #e7e5ee); padding: 12px 0 4px; display: grid; gap: 10px; min-width: 0; }
.gh-repo.card { border-top: 0; padding: 14px 16px; }
.gh-repo > summary { display: flex; align-items: center; gap: 8px; cursor: pointer; list-style: none; min-height: 40px; }
.gh-repo > summary::-webkit-details-marker { display: none; }
.gh-repo > summary::before { content: ""; flex: none; width: 8px; height: 8px; border-inline-end: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg); margin: 0 6px 0 2px; transition: transform .15s; }
.gh-repo[open] > summary::before { transform: rotate(45deg); }
.gh-repo-title { display: grid; gap: 2px; min-width: 0; }
.gh-repo-title small { color: var(--muted, #686577); }
.gh-repo-foot { display: flex; flex-wrap: nowrap; align-items: center; gap: 10px; min-width: 0; }
/* Save and Disconnect on one line at the section's foot, the Terminal's section gap above them (.section-gap): 24px, 18px on a phone. */
.gh-repo > .gh-repo-foot { margin-top: 24px; }
.agent-repositories > .gh-repo-foot { margin-top: 14px; }
.gh-repo-foot .btn { flex: none; min-height: 40px; }
.gh-repo-foot .gh-saved { flex: 0 1 auto; min-width: 0; }
.gh-repo-foot .gh-disconnect { margin-inline-start: auto; }
@media (max-width: 700px) { .gh-repo > .gh-repo-foot { margin-top: 18px; } .agent-repositories > .gh-repo-foot { margin-top: 8px; } }

/* A head line: what the box holds, and the list/grid switch at its right end (collections.css draws the switch). */
.gh-list-head { display: flex; align-items: center; gap: 12px; min-width: 0; }
.gh-list-head > h2 { flex: 1; min-width: 0; margin: 0; }
.gh-repo > summary > .view-toggle { margin-inline-start: auto; }
.gh-list-head > .view-toggle button, .gh-repo > summary > .view-toggle button { width: 40px; height: 40px; }

/* Lines, the default: one agent to a line, the tick and who at the left, Read / Read and write at the right. */
.gh-access-list[data-view="list"] { grid-template-columns: minmax(0, 1fr); gap: 0; border-top: 1px solid var(--line, #e7e5ee); }
.gh-access-list[data-view="list"] > .gh-access-row { grid-template-columns: minmax(0, 1fr) minmax(0, 300px); align-items: center; column-gap: 16px; padding: 10px 8px 10px 12px; border: 0; border-bottom: 1px solid var(--line, #e7e5ee); border-radius: 0; background: transparent; box-shadow: none; }
.gh-access-list[data-view="list"] > .gh-access-row[data-access="READ"], .gh-access-list[data-view="list"] > .gh-access-row[data-access="WRITE"] { box-shadow: inset 3px 0 0 var(--purple, #6d28b5); }
@media (max-width: 600px) { .gh-access-list[data-view="list"] > .gh-access-row { grid-template-columns: minmax(0, 1fr); row-gap: 8px; } }
.gh-saved { color: var(--green, #16794d); font-weight: 600; font-size: .875rem; }
.gh-saved:empty { display: none; }

/* The two steps after connecting (github-connect.js). */
.gh-flow { display: grid; gap: 14px; max-width: 980px; min-width: 0; overflow-wrap: anywhere; }
.gh-flow .page-heading { margin: 0; }
.gh-flow .page-heading h1 { overflow-wrap: anywhere; }
.gh-step { margin: 0; color: var(--purple, #6d28b5); font-size: .8125rem; font-weight: 600; letter-spacing: .02em; }
.gh-card { display: grid; gap: 12px; min-width: 0; }
.gh-card h2 { margin: 0; }
.gh-pick { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.gh-pick-row { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 10px 14px; border: 1px solid var(--line, #e7e5ee); border-radius: 12px; cursor: pointer; }
label.gh-pick-row:has(input:checked) { border-color: var(--purple, #6d28b5); box-shadow: 0 0 0 1px var(--purple, #6d28b5) inset; }
.gh-pick-row input { flex: none; width: 20px; height: 20px; margin: 0; accent-color: var(--purple, #6d28b5); }
.gh-pick-row.is-connected { cursor: default; background: var(--soft, #f2ecfa); border-color: transparent; }
.gh-pick-done { flex: none; width: 20px; text-align: center; color: var(--green, #16794d); font-weight: 700; }
.gh-pick-name { flex: 1; min-width: 0; display: grid; gap: 2px; }
.gh-pick-name small { color: var(--muted, #686577); }
.gh-change-line { margin: 0; }
.gh-change { color: var(--purple, #6d28b5); font-weight: 600; text-decoration: none; }
.gh-change::after { content: " ↗"; }
.gh-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; }
.gh-said { margin: 0; color: var(--red, #bd3551); }
@media (max-width: 520px) {
  .gh-access-list { grid-template-columns: minmax(0, 1fr); }
  .gh-actions { flex-direction: column-reverse; align-items: stretch; }
  .gh-actions .btn { width: 100%; min-height: 48px; }
}
