:root {
  color-scheme: light dark;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f1f4;
  --text: #1b1f24;
  --muted: #5f6672;
  --border: #e1e4e8;
  --accent: #1f6feb;
  --accent-hover: #1a5fcc;
  --accent-text: #ffffff;
  --warn: #a65200;
  --warn-bg: #fff1e0;
  --ok: #1a7f37;
  --ok-bg: #e6f4ea;
  --danger: #c62828;
  --danger-bg: #fdecea;
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1216;
    --surface: #171b21;
    --surface-2: #1f242c;
    --text: #e6e9ed;
    --muted: #9aa3ae;
    --border: #2a3039;
    --accent: #4c8dff;
    --accent-hover: #6aa0ff;
    --accent-text: #0b1020;
    --warn: #ffb066;
    --warn-bg: #3a2610;
    --ok: #5bd17f;
    --ok-bg: #12301c;
    --danger: #ff8a80;
    --danger-bg: #3a1614;
  }
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
}

a {
  color: var(--accent);
}

code {
  font-family: var(--mono);
  font-size: 0.9em;
  background: var(--surface-2);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

/* Header */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 650;
}

.logo {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 15px;
}

.account {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
}

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
}

.link {
  color: var(--muted);
  text-decoration: none;
}

.link:hover {
  color: var(--text);
}

.banner {
  padding: 8px 20px;
  background: var(--warn-bg);
  color: var(--warn);
  font-size: 14px;
  text-align: center;
}

main {
  max-width: 880px;
  margin: 0 auto;
  padding: 24px 16px 64px;
}

.loading {
  color: var(--muted);
  text-align: center;
}

/* Buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 550;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}

.btn:hover {
  background: var(--surface-2);
}

.btn:disabled {
  opacity: 0.6;
  cursor: default;
}

.btn.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-text);
}

.btn.primary:hover {
  background: var(--accent-hover);
}

.btn.ghost {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

.btn.ghost:hover {
  background: var(--surface-2);
  color: var(--text);
}

/* Signed out */

.hero {
  padding: 72px 8px;
  text-align: center;
}

.hero h1 {
  margin: 0 0 12px;
  font-size: clamp(24px, 4vw, 32px);
  line-height: 1.2;
}

.hero p {
  max-width: 520px;
  margin: 0 auto 28px;
  color: var(--muted);
}

.hero .btn {
  height: 42px;
  padding: 0 22px;
  font-size: 15px;
}

/* Repo list */

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.summary {
  margin: 0;
  font-weight: 600;
}

.empty {
  padding: 40px 20px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: center;
}

.empty h2 {
  margin: 0 0 8px;
  font-size: 18px;
}

.empty p {
  margin: 0 0 20px;
  color: var(--muted);
}

.repo-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
  transition: opacity 0.15s;
}

.repo-list.loading {
  opacity: 0.5;
  pointer-events: none;
}

.repo {
  /* grid items default to min-content width; let long repo names ellipsize instead */
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.state-synced {
  opacity: 0.6;
}

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
}

.repo-head {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
}

button.repo-head {
  cursor: pointer;
}

.pill {
  display: grid;
  flex: none;
  place-items: center;
  min-width: 34px;
  height: 34px;
  padding: 0 8px;
  border-radius: 17px;
  font-size: 14px;
  font-weight: 700;
}

.state-pending .pill {
  background: var(--warn-bg);
  color: var(--warn);
}

.state-synced .pill,
.state-same-content .pill {
  background: var(--ok-bg);
  color: var(--ok);
}

.state-error .pill {
  background: var(--danger-bg);
  color: var(--danger);
}

.info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.repo-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.owner {
  color: var(--muted);
}

.tag {
  flex: none;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
}

.chev {
  flex: none;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  transition: transform 0.15s;
}

.repo-head[aria-expanded="true"] .chev {
  transform: rotate(90deg);
}

.meta {
  color: var(--muted);
  font-size: 13px;
}

.actions {
  display: flex;
  flex: none;
  gap: 6px;
}

.commits {
  margin: 0;
  padding: 4px 14px 12px 60px;
  border-top: 1px solid var(--border);
  list-style: none;
}

.commits li {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px dashed var(--border);
  font-size: 14px;
}

.commits li:last-child {
  border-bottom: 0;
}

.sha {
  flex: none;
  font-family: var(--mono);
  font-size: 12.5px;
  text-decoration: none;
}

.message {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.by {
  flex: none;
  color: var(--muted);
  font-size: 12.5px;
  white-space: nowrap;
}

.more {
  color: var(--muted);
}

.footnote {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 13px;
}

/* Dialog and toast */

dialog {
  width: min(520px, calc(100vw - 32px));
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
}

dialog::backdrop {
  background: rgb(0 0 0 / 0.45);
}

dialog h2 {
  margin: 0 0 8px;
  font-size: 18px;
}

dialog p {
  margin: 0 0 16px;
  color: var(--muted);
}

.preview {
  max-height: 300px;
  margin: 0 0 16px;
  padding: 12px;
  overflow: auto;
  border-radius: 8px;
  background: var(--surface-2);
  font-family: var(--mono);
  font-size: 12.5px;
  white-space: pre-wrap;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  max-width: calc(100vw - 32px);
  padding: 10px 16px;
  border-radius: 8px;
  background: var(--text);
  color: var(--bg);
  font-size: 14px;
  box-shadow: 0 6px 24px rgb(0 0 0 / 0.2);
  transform: translateX(-50%);
}

@media (max-width: 600px) {
  .topbar {
    padding: 10px 16px;
  }

  .login,
  .link {
    display: none;
  }

  .row {
    flex-wrap: wrap;
  }

  .actions {
    width: 100%;
    padding-left: 46px;
  }

  .commits {
    padding-left: 14px;
  }

  .commits li {
    flex-wrap: wrap;
  }

  .by {
    width: 100%;
  }
}
