:root {
  --bg: #0d1117;
  --bg-elev: #161b22;
  --bg-elev2: #1c2230;
  --border: #2a323d;
  --text: #e6edf3;
  --text-dim: #9aa7b4;
  --accent: #6ea8fe;
  --accent2: #7ee787;
  --author: #d2a8ff;
  --lang: #79c0ff;
  --warn: #f0b429;
  --error: #ff7b72;
  --radius: 12px;
  --maxw: 800px;
  font-synthesis: none;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f8fa;
    --bg-elev: #ffffff;
    --bg-elev2: #f0f3f6;
    --border: #d0d7de;
    --text: #1f2328;
    --text-dim: #656d76;
    --accent: #0969da;
    --accent2: #1a7f37;
    --author: #8250df;
    --lang: #0969da;
  }
}

* {
  box-sizing: border-box;
}

/* Reserve the embeddable widget's space before its custom element upgrades, so slow
   connections get a stable placeholder instead of a layout jump. In an external
   stylesheet (not inline) so it applies under the strict style-src 'self' CSP. */
gitchrono-widget:not(:defined) {
  display: block;
  min-height: 360px;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.55;
}

.wrap {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 20px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* header */
.site-head {
  border-bottom: 1px solid var(--border);
  padding: 28px 0 24px;
  background: linear-gradient(180deg, var(--bg-elev) 0%, var(--bg) 100%);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.logo {
  font-size: 1.6rem;
  color: var(--accent);
}
.brand-name {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.tagline {
  margin: 8px 0 0;
  color: var(--text-dim);
}

/* form */
.repo-form {
  display: flex;
  gap: 8px;
  margin: 28px 0 12px;
  flex-wrap: wrap;
}
.repo-input {
  flex: 1 1 260px;
  min-width: 0;
  padding: 12px 14px;
  font-size: 1rem;
  color: var(--text);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.repo-input:focus,
.depth:focus,
.btn:focus,
.chip:focus,
button.secondary:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.depth {
  padding: 12px 10px;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.btn {
  padding: 12px 20px;
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
}
.btn:disabled {
  opacity: 0.6;
  cursor: progress;
}

.examples {
  color: var(--text-dim);
  font-size: 0.9rem;
  margin: 0 0 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.chip {
  font: inherit;
  font-size: 0.85rem;
  color: var(--accent);
  background: var(--bg-elev2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 12px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
.chip:hover {
  border-color: var(--accent);
}

/* status */
.status {
  border-radius: var(--radius);
  padding: 12px 16px;
  margin: 6px 0 18px;
  font-size: 0.95rem;
  border: 1px solid var(--border);
  background: var(--bg-elev);
}
.status--error {
  border-color: var(--error);
  color: var(--error);
}
.status--warn {
  border-color: var(--warn);
  color: var(--warn);
}

/* shareable link */
.share-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 4px 0 18px;
}
button.secondary {
  font: inherit;
  font-size: 0.9rem;
  color: var(--text);
  background: var(--bg-elev2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 14px;
  cursor: pointer;
}
button.secondary:hover {
  border-color: var(--accent);
}
.hint {
  color: var(--text-dim);
  font-size: 0.85rem;
}

/* result cards */
.results {
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.card-head h2 {
  margin: 0;
  font-size: 1.15rem;
  overflow-wrap: anywhere;
}
.card-sub {
  margin: 4px 0 0;
  color: var(--text-dim);
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 22px;
  margin-top: 16px;
}
.stat-value {
  font-size: 1.35rem;
  font-weight: 700;
}
.stat-label {
  font-size: 0.78rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* chart */
.chart-wrap {
  margin-top: 14px;
  overflow-x: auto;
}
.chart {
  width: 100%;
  min-width: 320px;
  height: auto;
  display: block;
}
.chart .bar {
  fill: var(--accent);
}
.chart .bar:hover {
  fill: var(--accent2);
}
.chart .axis {
  stroke: var(--border);
  stroke-width: 1;
}
.chart .tick {
  fill: var(--text-dim);
  font-size: 11px;
}

/* bar lists */
.barlist {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.bar-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.bar-label {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.92rem;
}
.bar-name {
  overflow-wrap: anywhere;
}
.bar-value {
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  flex: none;
}
.bar-sub {
  font-size: 0.78rem;
  color: var(--text-dim);
}
.bar-track {
  background: var(--bg-elev2);
  border-radius: 6px;
  height: 10px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 6px;
}
.bar-fill.tone-author {
  background: var(--author);
}
.bar-fill.tone-lang {
  background: var(--lang);
}

/* recent commits */
.commits {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}
.commit {
  display: flex;
  gap: 10px;
  align-items: baseline;
  padding: 8px 0;
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
}
.commit:first-child {
  border-top: 0;
}
.sha {
  color: var(--accent);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.82rem;
  flex: none;
}
.commit-msg {
  flex: 1 1 auto;
  overflow-wrap: anywhere;
}
.commit-meta {
  color: var(--text-dim);
  font-size: 0.8rem;
  flex: none;
  white-space: nowrap;
}

/* about + footer */
.about {
  margin: 34px 0;
  color: var(--text);
}
.about h2 {
  font-size: 1.1rem;
}
.about h3 {
  font-size: 0.98rem;
  margin: 22px 0 8px;
}

/* embed page: code snippets + attribute table */
.code-block {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  overflow-x: auto;
  font-size: 0.85rem;
  line-height: 1.5;
}
.code-block code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--text);
  white-space: pre;
}
.vat-rates {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0 14px;
  font-size: 0.9rem;
}
.vat-rates th,
.vat-rates td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.vat-rates th {
  color: var(--text-dim);
  font-weight: 600;
}
.vat-rates code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--accent);
  font-size: 0.85rem;
}
.fineprint {
  color: var(--text-dim);
  font-size: 0.88rem;
}
.site-foot {
  border-top: 1px solid var(--border);
  padding: 22px 0;
  color: var(--text-dim);
  font-size: 0.88rem;
}
.site-foot a {
  color: var(--accent);
}

@media (max-width: 560px) {
  .commit {
    flex-wrap: wrap;
    gap: 4px 10px;
  }
  .commit-meta {
    width: 100%;
  }
}
