/* Palette and type match yurysergeev.github.io (amber theme) */
:root {
  --bg: #0e0f11;
  --text: #a8a29e;
  --head: #ece7df;
  --accent: #f2b54a;
  --line: #3a3733;
  --card: rgba(255, 255, 255, 0.035);
  --accent-chip: color-mix(in srgb, var(--accent) 12%, transparent);
  --muted-bar: #6b655f;
  --pass: #7fc79a;
  --sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html { background: var(--bg); -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--accent); color: var(--bg); }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
[hidden] { display: none !important; }

.page { max-width: 64rem; margin: 0 auto; padding: 2.5rem 1rem 3rem; }
@media (min-width: 768px) { .page { padding: 4.5rem 3rem 4rem; } }

/* ---------- Hero ---------- */

.back {
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  transition: color 0.15s ease;
}
.back:hover { color: var(--accent); }

h1 {
  margin: 1.25rem 0 0;
  color: var(--head);
  font-size: clamp(2rem, 5vw, 2.75rem);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.1;
}

.lede { max-width: 40rem; margin: 0.9rem 0 0; }

.status {
  display: inline-flex;
  align-items: flex-start;
  gap: 0.6rem;
  margin: 1rem 0 0;
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.02em;
}
.status-dot {
  flex: none;
  margin-top: 0.5em;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-chip);
}

.stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  margin-top: 2rem;
}
@media (min-width: 768px) { .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

.stat {
  padding: 0.9rem 1rem;
  border-radius: 0.5rem;
  background: var(--card);
  box-shadow: inset 0 1px 0 0 color-mix(in srgb, var(--head) 8%, transparent);
}
.stat-label { font-size: 0.8125rem; }
.stat-value {
  margin-top: 0.15rem;
  color: var(--head);
  font-size: 1.625rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}
.stat-value--accent { color: var(--accent); }
.stat-sub { margin-top: 0.15rem; font-family: var(--mono); font-size: 0.6875rem; }

.finding {
  max-width: 44rem;
  margin: 1.25rem 0 0;
  padding: 0.1rem 0 0.1rem 1rem;
  border-left: 2px solid var(--accent);
  color: var(--head);
}

/* ---------- Sections ---------- */

.section { margin-top: 3.5rem; }
@media (min-width: 768px) { .section { margin-top: 4.5rem; } }

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.25rem 1rem;
}

.label {
  margin: 0 0 0.9rem;
  color: var(--head);
  font-family: var(--mono);
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.hint, .caption { margin: 0 0 0.9rem; font-size: 0.875rem; }
.hint { font-family: var(--mono); font-size: 0.6875rem; }
.hint-touch { display: none; }
@media (hover: none) { .hint-touch { display: inline; } .hint-mouse { display: none; } }
.caption { max-width: 44rem; }

.inline-link {
  color: var(--head);
  font-weight: 500;
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: 3px;
  transition: color 0.15s ease, text-decoration-color 0.15s ease;
}
.inline-link:hover, .inline-link:focus-visible { color: var(--accent); text-decoration-color: currentColor; }

/* ---------- Drive cards ---------- */

.drive-groups { display: grid; gap: 1.75rem; }
.drive-group-label {
  margin: 0 0 0.6rem;
  font-family: var(--mono);
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.drives {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: 0.75rem;
}

.drive {
  display: block;
  width: 100%;
  padding: 0.9rem 1rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}
.drive:hover { background: var(--card); }
.drive[aria-pressed="true"] { border-color: var(--accent); background: var(--card); }
.drive-title { display: block; color: var(--head); font-weight: 600; }
.drive-meta { display: block; margin-top: 0.2rem; font-family: var(--mono); font-size: 0.6875rem; letter-spacing: 0.02em; }
.drive-note { display: block; margin-top: 0.4rem; font-size: 0.875rem; }
.drive--upcoming { border-style: dashed; cursor: default; opacity: 0.7; }
.drive--upcoming:hover { background: transparent; }

.badge {
  display: inline-block;
  margin-left: 0.4rem;
  padding: 0 0.45rem;
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  border-radius: 999px;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 0.625rem;
  line-height: 1.5;
  vertical-align: 1px;
}

/* ---------- Trace ---------- */

.signals { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.75rem; }

.chip {
  padding: 0.2rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.6875rem;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background-color 0.15s ease;
}
.chip:hover { color: var(--head); }
.chip[aria-pressed="true"] { border-color: color-mix(in srgb, var(--accent) 55%, transparent); background: var(--accent-chip); color: var(--accent); }

.readout {
  min-height: 1.4rem;
  margin: 0 0 0.25rem;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--head);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.readout span { color: var(--text); }

.trace { position: relative; }
.panel { position: relative; }
.panel-title {
  position: absolute;
  top: 2px;
  left: 56px;
  z-index: 2;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--head);
  pointer-events: none;
}
.panel-title span { font-weight: 400; color: var(--text); font-family: var(--mono); font-size: 0.6875rem; }
.uplot { font-family: var(--mono); }
.uplot .u-select { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.uplot .u-cursor-x { border-right: 1px dashed var(--muted-bar); }

/* ---------- Fuel trim bands ---------- */

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.9rem;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--head);
  cursor: pointer;
}
.toggle input { width: 1rem; height: 1rem; margin: 0; accent-color: var(--accent); }

.bands { display: grid; gap: 0.6rem; max-width: 44rem; }

.band {
  display: grid;
  grid-template-columns: 10.5rem minmax(0, 1fr) 3.75rem;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.875rem;
}
.band-label { color: var(--head); }
.band-label small { display: block; font-family: var(--mono); font-size: 0.6875rem; color: var(--text); }
.band-track { position: relative; height: 0.75rem; }
.band-track::before {
  content: "";
  position: absolute;
  top: -0.3rem;
  bottom: -0.3rem;
  left: var(--zero);
  border-left: 1px solid var(--line);
}
.band-bar {
  position: absolute;
  top: 0;
  height: 100%;
  background: var(--muted-bar);
}
.band-bar.pos { border-radius: 0 4px 4px 0; }
.band-bar.neg { border-radius: 4px 0 0 4px; }
.band-bar.hot { background: var(--accent); }
.band-value { color: var(--head); font-family: var(--mono); font-size: 0.8125rem; text-align: right; font-variant-numeric: tabular-nums; }
.band--empty .band-value { color: var(--text); }
@media (max-width: 639px) {
  .band { grid-template-columns: minmax(0, 1fr) 3.75rem; gap: 0.25rem 0.75rem; }
  .band-label { grid-column: 1 / -1; }
  .band-label small { display: inline; margin-left: 0.5rem; }
}

/* ---------- Checks ---------- */

.checks { display: grid; gap: 0; max-width: 44rem; margin: 0; padding: 0; list-style: none; }
.check {
  display: grid;
  grid-template-columns: 1.25rem minmax(0, 1fr);
  gap: 0.75rem;
  padding: 0.65rem 0;
  border-top: 1px solid var(--line);
}
.check:last-child { border-bottom: 1px solid var(--line); }
.check-icon { font-family: var(--mono); color: var(--pass); }
.check-icon.fail { color: #f08a7e; }
.check-icon.skip { color: var(--text); }
.check-name { color: var(--head); font-weight: 500; }
.check-measured { font-family: var(--mono); font-size: 0.8125rem; color: var(--head); }
.check-ref { font-size: 0.8125rem; }
.check-body > span { display: block; }
@media (min-width: 640px) {
  .check-body { display: grid; grid-template-columns: 11rem minmax(0, 1fr); gap: 0 1rem; }
  .check-ref { grid-column: 2; }
}

/* ---------- Pipeline + footer ---------- */

.pipeline {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0 0 1rem;
  padding: 0;
  list-style: none;
  font-family: var(--mono);
  font-size: 0.75rem;
}
.pipeline li { padding: 0.3rem 0.7rem; border: 1px solid var(--line); border-radius: 0.375rem; color: var(--head); }
.pipeline li:not(:last-child)::after { content: "→"; margin-left: 0.9rem; margin-right: -0.4rem; color: var(--text); }
.pipeline li:last-child { border-color: color-mix(in srgb, var(--accent) 55%, transparent); color: var(--accent); }

.footer { margin-top: 4rem; padding-top: 1.25rem; border-top: 1px solid var(--line); font-family: var(--mono); font-size: 0.75rem; }

.load-error { margin: 0.9rem 0 0; font-family: var(--mono); font-size: 0.75rem; color: #f08a7e; }

.error {
  padding: 0.9rem 1rem;
  border: 1px solid #7a3b34;
  border-radius: 0.5rem;
  color: var(--head);
}

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