.postgis-ci-status {
  --ci-border: color-mix(in srgb, var(--body-font-color) 18%, transparent);
  --ci-failure: #c92335;
  --ci-muted: color-mix(in srgb, var(--body-font-color) 68%, transparent);
  --ci-running: #1473d1;
  --ci-stale: #8a6500;
  --ci-success: #16843c;
  --ci-surface: var(--body-background);
  --ci-surface-muted: color-mix(in srgb, var(--body-font-color) 4%, var(--body-background));
  margin-top: 1.15rem;
  max-width: 72rem;
  min-width: 0;
}

.ci-loading,
.ci-error {
  border-bottom: 1px solid var(--ci-border);
  border-top: 1px solid var(--ci-border);
  margin: 0;
  padding: 0.85rem 0;
}

.ci-error {
  color: var(--ci-failure);
}

.ci-meta {
  align-items: baseline;
  color: var(--ci-muted);
  display: flex;
  flex-wrap: wrap;
  font-size: 0.86rem;
  gap: 0.35rem 0.75rem;
  margin-bottom: 0.8rem;
}

.ci-meta a {
  white-space: nowrap;
}

.ci-status-banner {
  align-items: center;
  background: var(--ci-surface);
  border: 1px solid var(--ci-border);
  border-left: 4px solid var(--ci-stale);
  border-radius: 8px;
  display: grid;
  gap: 0.75rem;
  grid-template-columns: auto minmax(0, 1fr);
  margin-bottom: 1rem;
  padding: 0.9rem 1rem;
}

.ci-status-banner.ci-status--success {
  border-left-color: var(--ci-success);
}

.ci-status-banner.ci-status--failure {
  border-left-color: var(--ci-failure);
}

.ci-status-banner.ci-status--in-progress {
  border-left-color: var(--ci-running);
}

.ci-status-banner > .ci-status-dot {
  height: 0.72rem;
  width: 0.72rem;
}

.ci-banner-heading {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 0.16rem;
}

.ci-banner-summary {
  color: var(--ci-muted);
  font-size: 0.88rem;
}

.ci-required-failures strong {
  color: var(--header-font-color);
}

.ci-panel,
.ci-detail-section {
  background: var(--ci-surface);
  border: 1px solid var(--ci-border);
  border-radius: 8px;
  overflow: hidden;
}

.ci-panel {
  margin-bottom: 1rem;
}

.ci-panel-heading,
.ci-detail-heading {
  background: var(--ci-surface-muted);
  color: var(--header-font-color);
  font-weight: 700;
}

.ci-panel-heading {
  border-bottom: 1px solid var(--ci-border);
  padding: 0.78rem 1rem;
}

.ci-detail-section {
  margin-top: 0.9rem;
  scroll-margin-top: 1rem;
}

.ci-detail-heading {
  align-items: center;
  border-bottom: 1px solid var(--ci-border);
  display: grid;
  gap: 0.55rem;
  grid-template-columns: auto minmax(0, 1fr) auto;
  padding: 0.72rem 0.9rem;
}

.ci-detail-heading h2 {
  font-size: 1rem;
  letter-spacing: 0;
  margin: 0;
}

.ci-table-wrap {
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  touch-action: pan-x pan-y;
}

.gdoc-markdown table.ci-branch-table:not(.lntable):not(.highlight),
.gdoc-markdown table.ci-check-table:not(.lntable):not(.highlight) {
  border: 0;
  border-collapse: collapse;
  display: table;
  margin: 0;
  max-width: none;
  width: 100%;
}

.ci-branch-table {
  min-width: 40rem;
}

.ci-check-table {
  min-width: 44rem;
  table-layout: fixed;
}

.ci-branch-table th,
.ci-check-table th {
  background: var(--ci-surface-muted);
  color: var(--ci-muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-align: left;
}

.ci-branch-table th,
.ci-branch-table td {
  padding: 0.64rem 0.8rem;
}

.ci-branch-table th:nth-child(1),
.ci-branch-table td:nth-child(1) {
  width: 24%;
}

.ci-branch-table th:nth-child(2),
.ci-branch-table td:nth-child(2) {
  width: 18%;
}

.ci-branch-table tr + tr,
.ci-check-table tr + tr {
  border-top: 1px solid var(--ci-border);
}

.ci-branch-table tbody tr:hover,
.ci-check-table tbody tr:hover {
  background: color-mix(in srgb, var(--accent-color-lite) 35%, transparent);
}

.ci-branch-cell {
  align-items: center;
  display: flex;
  gap: 0.6rem;
}

.ci-branch-cell a,
.ci-check-name a {
  color: var(--header-font-color);
  font-weight: 700;
}

.ci-status-dot {
  background: var(--ci-stale);
  border-radius: 50%;
  display: inline-block;
  flex: 0 0 auto;
  height: 0.6rem;
  width: 0.6rem;
}

.ci-status-dot.ci-status--success,
.ci-status--success > .ci-status-dot {
  background: var(--ci-success);
}

.ci-status-dot.ci-status--failure,
.ci-status--failure > .ci-status-dot {
  background: var(--ci-failure);
}

.ci-status-dot.ci-status--in-progress,
.ci-status--in-progress > .ci-status-dot {
  background: var(--ci-running);
}

.ci-status-pill {
  align-items: center;
  background: color-mix(in srgb, var(--ci-stale) 9%, var(--ci-surface));
  border: 1px solid color-mix(in srgb, var(--ci-stale) 34%, transparent);
  border-radius: 999px;
  color: var(--ci-stale);
  display: inline-flex;
  font-size: 0.78rem;
  font-weight: 700;
  gap: 0.3rem;
  line-height: 1;
  padding: 0.32rem 0.52rem;
  white-space: nowrap;
  width: fit-content;
}

.ci-status-pill.ci-status--success {
  background: color-mix(in srgb, var(--ci-success) 9%, var(--ci-surface));
  border-color: color-mix(in srgb, var(--ci-success) 34%, transparent);
  color: var(--ci-success);
}

.ci-status-pill.ci-status--failure {
  background: color-mix(in srgb, var(--ci-failure) 9%, var(--ci-surface));
  border-color: color-mix(in srgb, var(--ci-failure) 34%, transparent);
  color: var(--ci-failure);
}

.ci-status-pill.ci-status--in-progress {
  background: color-mix(in srgb, var(--ci-running) 9%, var(--ci-surface));
  border-color: color-mix(in srgb, var(--ci-running) 34%, transparent);
  color: var(--ci-running);
}

.ci-status-icon::before {
  content: "!";
}

.ci-status-pill.ci-status--success .ci-status-icon::before {
  content: "\2713";
}

.ci-status-pill.ci-status--failure .ci-status-icon::before {
  content: "\00d7";
}

.ci-status-pill.ci-status--in-progress .ci-status-icon::before {
  content: "\21bb";
}

.ci-status-pill.ci-status--unknown .ci-status-icon::before {
  content: "?";
}

.ci-summary-metrics {
  align-items: center;
  display: flex;
  gap: 0.7rem;
  min-width: 0;
}

.ci-progress {
  background: color-mix(in srgb, var(--body-font-color) 12%, transparent);
  border-radius: 999px;
  display: flex;
  flex: 0 0 10.5rem;
  height: 0.34rem;
  overflow: hidden;
}

.ci-progress-segment {
  min-width: 2px;
}

.ci-progress-segment--success {
  background: var(--ci-success);
}

.ci-progress-segment--failure {
  background: var(--ci-failure);
}

.ci-progress-segment--in-progress {
  background: var(--ci-running);
}

.ci-progress-segment--unknown,
.ci-progress-segment--stale {
  background: var(--ci-stale);
}

.ci-summary-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.ci-summary-chip {
  background: color-mix(in srgb, var(--ci-stale) 8%, var(--ci-surface));
  color: var(--ci-stale);
  font-size: 0.76rem;
  padding: 0.16rem 0.34rem;
  white-space: nowrap;
}

.ci-summary-chip.ci-status--success {
  background: color-mix(in srgb, var(--ci-success) 8%, var(--ci-surface));
  color: var(--ci-success);
}

.ci-summary-chip.ci-status--failure {
  background: color-mix(in srgb, var(--ci-failure) 8%, var(--ci-surface));
  color: var(--ci-failure);
}

.ci-summary-chip.ci-status--in-progress {
  background: color-mix(in srgb, var(--ci-running) 8%, var(--ci-surface));
  color: var(--ci-running);
}

.ci-check-table th,
.ci-check-table td {
  padding: 0.58rem 0.65rem;
  vertical-align: top;
}

.ci-check-table th:nth-child(1) {
  width: 32%;
}

.ci-check-table th:nth-child(2) {
  width: 23%;
}

.ci-check-table th:nth-child(3) {
  width: 25%;
}

.ci-check-table th:nth-child(4) {
  width: 20%;
}

.ci-check-table td {
  font-size: 0.8rem;
}

.ci-check-kind,
.ci-previous-status {
  color: var(--ci-muted);
  display: block;
  font-size: 0.7rem;
  margin-top: 0.22rem;
}

.ci-revision-cell {
  font-family: var(--code-font-family, monospace);
  overflow-wrap: anywhere;
}

.ci-age-cell {
  color: var(--ci-muted);
  white-space: nowrap;
}

.ci-check-message {
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  color: var(--ci-muted);
  display: -webkit-box;
  font-size: 0.72rem;
  font-weight: 400;
  line-height: 1.05rem;
  margin-top: 0.24rem;
  overflow: hidden;
  overflow-wrap: anywhere;
}

.ci-check-table tr.ci-status--failure {
  background: color-mix(in srgb, var(--ci-failure) 4%, var(--ci-surface));
}

.ci-check-table tr.ci-status--in-progress {
  background: color-mix(in srgb, var(--ci-running) 4%, var(--ci-surface));
}

:root[color-theme="dark"] .postgis-ci-status {
  --ci-failure: #ff8b94;
  --ci-running: #88bdf0;
  --ci-stale: #e2bd63;
  --ci-success: #78cb8a;
}

@media (prefers-color-scheme: dark) {
  :root:not([color-theme="light"]) .postgis-ci-status {
    --ci-failure: #ff8b94;
    --ci-running: #88bdf0;
    --ci-stale: #e2bd63;
    --ci-success: #78cb8a;
  }
}

@media (max-width: 48rem) {
  main.container:has(.postgis-ci-status) {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }

  .ci-status-banner {
    align-items: start;
    padding: 0.8rem;
  }

  .ci-required-failures {
    display: block;
    margin-top: 0.25rem;
  }

  .ci-detail-heading {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .ci-detail-heading .ci-status-pill {
    grid-column: 2;
    justify-self: start;
  }

  .ci-branch-table {
    min-width: 37rem;
  }

  .ci-check-table th:first-child,
  .ci-check-table td:first-child {
    background: var(--ci-surface);
    box-shadow: 1px 0 0 var(--ci-border);
    left: 0;
    position: sticky;
    z-index: 1;
  }

  .ci-check-table th:first-child {
    background: var(--ci-surface-muted);
    z-index: 2;
  }
}
