:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --text: #1a1d23;
  --muted: #6b7280;
  --accent: #6366f1;
  --accent-2: #a78bfa;
  --border: #e5e7eb;
  --good: #10b981;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --card: #1a1d23;
    --text: #e5e7eb;
    --muted: #9ca3af;
    --accent: #818cf8;
    --accent-2: #c4b5fd;
    --border: #2d3138;
    --good: #34d399;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic UI",
    "Segoe UI", system-ui, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

header {
  padding: 32px 24px 16px;
  max-width: 1100px;
  margin: 0 auto;
}

header h1 {
  margin: 0 0 4px;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.status {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--border);
  font-size: 12px;
}

.status.ok {
  background: color-mix(in srgb, var(--good) 25%, transparent);
  color: var(--good);
}

.status.err {
  background: #fee2e2;
  color: #b91c1c;
}

main {
  padding: 16px 24px 48px;
  max-width: 1100px;
  margin: 0 auto;
}

h2 {
  margin: 32px 0 12px;
  font-size: 16px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
}

.stat-value {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--accent);
}

.stat-label {
  margin-top: 4px;
  font-size: 13px;
  color: var(--muted);
}

.chart-wrapper {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}

.split-section {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 12px;
}

@media (max-width: 800px) {
  .split-section {
    grid-template-columns: 1fr;
  }
}

.split-card h2 {
  margin-top: 24px;
}

.host-row {
  display: grid;
  grid-template-columns: 110px 1fr 40px;
  gap: 8px;
  align-items: center;
  padding: 4px 0;
  font-size: 13px;
}

.host-name {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.host-bar-track {
  height: 14px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.host-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 4px;
  transition: width 0.4s ease;
}

.host-count {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  text-align: right;
  color: var(--muted);
  font-size: 12px;
}

.heatmap-grid {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 10px;
  color: var(--muted);
}

.heatmap-row {
  display: grid;
  grid-template-columns: 24px repeat(24, 1fr);
  gap: 2px;
  margin-bottom: 2px;
}

.heatmap-header {
  margin-bottom: 4px;
}

.heatmap-day {
  text-align: right;
  padding-right: 4px;
  align-self: center;
}

.heatmap-cell {
  aspect-ratio: 1;
  background: var(--border);
  border-radius: 2px;
  min-height: 14px;
}

.heatmap-cell.heatmap-h {
  background: transparent;
  text-align: center;
  min-height: 0;
  font-size: 9px;
}

.empty {
  color: var(--muted);
  text-align: center;
  padding: 24px;
  font-size: 13px;
}

#chart {
  width: 100%;
  height: 220px;
  display: block;
}

#chart .bar {
  fill: var(--accent);
  transition: opacity 0.15s;
}

#chart .bar:hover {
  fill: var(--accent-2);
}

#chart .bar-label {
  font-size: 10px;
  fill: var(--muted);
}

#chart .grid-line {
  stroke: var(--border);
  stroke-dasharray: 2 4;
}

.commit-list {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.commit-list li {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}

.commit-list li:last-child {
  border-bottom: none;
}

.commit-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  flex-wrap: wrap;
}

.commit-meta {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  gap: 10px;
}

.commit-meta a {
  color: var(--muted);
  text-decoration: none;
}

.commit-meta a:hover {
  color: var(--accent);
}

.commit-host {
  display: inline-block;
  background: var(--border);
  color: var(--muted);
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 11px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}

.commit-summary {
  margin-top: 6px;
  font-size: 13px;
  color: var(--text);
  line-height: 1.5;
  padding-left: 12px;
  border-left: 2px solid var(--accent);
}

.commit-summary.loading {
  color: var(--muted);
  font-style: italic;
  border-left-color: var(--border);
}

.commit-stats {
  margin-left: 8px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11px;
}

.commit-stats .add {
  color: var(--good);
}

.commit-stats .del {
  color: #ef4444;
}

.commit-files {
  margin-top: 8px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12px;
  color: var(--muted);
}

.commit-files .file {
  display: inline-block;
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 6px;
  margin: 2px 4px 2px 0;
}

footer {
  max-width: 1100px;
  margin: 24px auto 32px;
  padding: 0 24px;
  color: var(--muted);
  font-size: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

footer button {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 4px 12px;
  font-size: 12px;
  cursor: pointer;
  margin-left: 8px;
}

footer button:hover {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}
