:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-hover: #fafbfc;
  --border: #e3e6eb;
  --border-strong: #cfd4dc;
  --text: #16191f;
  --muted: #5d6573;
  --faint: #8a919d;
  --accent: #0e7c86;
  --accent-soft: #e2f3f4;
  --up: #1f9d55;
  --warn: #d48806;
  --down: #d93636;
  --unknown: #a3a9b3;
  --badge-public: #e6effd;
  --badge-public-text: #1d4fa8;
  --badge-lan: #eef0f3;
  --badge-lan-text: #4a5261;
  --badge-ap: #f6ecfd;
  --badge-ap-text: #7032a8;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-hover: 0 6px 18px rgba(16, 24, 40, 0.08);
  --radius: 12px;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1216;
    --surface: #171b21;
    --surface-hover: #1c2129;
    --border: #262c35;
    --border-strong: #353d49;
    --text: #e8ebf0;
    --muted: #9aa3b0;
    --faint: #6d7684;
    --accent: #3cc3cd;
    --accent-soft: #123034;
    --up: #3fc77a;
    --warn: #f0aa2a;
    --down: #f06363;
    --unknown: #5d6573;
    --badge-public: #172741;
    --badge-public-text: #8db6f7;
    --badge-lan: #222831;
    --badge-lan-text: #aeb6c2;
    --badge-ap: #2a1d3a;
    --badge-ap-text: #c89bf2;
    --shadow: none;
    --shadow-hover: 0 6px 18px rgba(0, 0, 0, 0.35);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }
code { font-family: var(--mono); font-size: 0.92em; }

.top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 20px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px 24px 8px;
}

.brand { display: flex; align-items: center; gap: 10px; margin-right: auto; }
.brand h1 { margin: 0; font-size: 22px; font-weight: 650; letter-spacing: -0.01em; }
.mark { width: 28px; height: 28px; fill: var(--border-strong); }
.mark .mark-accent { fill: var(--accent); }

.summary {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
}
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); }
.icon-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn.spinning svg { animation: spin 0.9s linear infinite; }

.search {
  position: relative;
  display: flex;
  align-items: center;
  flex: 0 1 280px;
  min-width: 200px;
}
.search svg {
  position: absolute;
  left: 11px;
  width: 16px;
  height: 16px;
  fill: none;
  stroke: var(--faint);
  stroke-width: 2;
  stroke-linecap: round;
  pointer-events: none;
}
.search input {
  width: 100%;
  height: 36px;
  padding: 0 34px 0 34px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14px;
}
.search input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.search kbd {
  position: absolute;
  right: 9px;
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--faint);
  font: 12px var(--mono);
}
.search input:focus + kbd, .search input:not(:placeholder-shown) + kbd { display: none; }

main { max-width: 1200px; margin: 0 auto; padding: 8px 24px 16px; }

.group { margin-top: 24px; }
.group h2 {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.group h2 .count { color: var(--faint); font-weight: 500; letter-spacing: 0; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 12px;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 118px;
  padding: 14px 16px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.card.linked:hover { border-color: var(--border-strong); box-shadow: var(--shadow-hover); transform: translateY(-1px); background: var(--surface-hover); }
.card.linked:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }

.card-head { display: flex; align-items: center; gap: 9px; min-width: 0; }
.card-name {
  overflow: hidden;
  color: var(--text);
  font-size: 15.5px;
  font-weight: 600;
  text-decoration: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card-name:focus { outline: none; }
/* Stretch the name link over the whole card; the repo link sits above it. */
.card.linked .card-name::after { content: ""; position: absolute; inset: 0; border-radius: var(--radius); }

.card-desc { margin: 0; color: var(--muted); font-size: 13.5px; }

.card-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  margin-top: auto;
  padding-top: 6px;
  color: var(--faint);
  font-size: 12.5px;
}
.card-foot .where { flex: 1 0 100%; font-family: var(--mono); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-foot .detail { margin-left: auto; white-space: nowrap; }
.card-foot .detail.warn { color: var(--warn); }
.card-foot .detail.down { color: var(--down); }

.badge {
  flex: none;
  margin-left: auto;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}
.badge.public { background: var(--badge-public); color: var(--badge-public-text); }
.badge.lan { background: var(--badge-lan); color: var(--badge-lan-text); }
.badge.ap { background: var(--badge-ap); color: var(--badge-ap-text); }

.tags { display: flex; flex: 1 1 0; align-items: center; gap: 10px; min-width: 0; min-height: 18px; }
.tag { display: inline-flex; align-items: center; gap: 4px; }
.tag svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.repo {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--faint);
  text-decoration: none;
}
.repo:hover { color: var(--accent); text-decoration: underline; }
.repo { min-width: 0; }
.repo-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.dot {
  flex: none;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--unknown);
}
.dot.up { background: var(--up); box-shadow: 0 0 0 3px color-mix(in srgb, var(--up) 18%, transparent); }
.dot.warn { background: var(--warn); box-shadow: 0 0 0 3px color-mix(in srgb, var(--warn) 18%, transparent); }
.dot.down { background: var(--down); box-shadow: 0 0 0 3px color-mix(in srgb, var(--down) 18%, transparent); }
.dot.checking { animation: pulse 1.2s ease-in-out infinite; }

.empty, .error { max-width: 1200px; margin: 24px auto; padding: 0 24px; color: var(--muted); }
.error { color: var(--down); }

.foot {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 18px;
  max-width: 1200px;
  margin: 24px auto 0;
  padding: 16px 24px 32px;
  border-top: 1px solid var(--border);
  color: var(--faint);
  font-size: 12.5px;
}

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: 0.35; } }

@media (max-width: 640px) {
  .top { padding: 20px 16px 4px; }
  main { padding: 4px 16px 12px; }
  .search { flex: 1 1 100%; }
  .grid { grid-template-columns: 1fr; }
  .foot { padding: 16px 16px 28px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
