:root {
  --bg: #ffffff;
  --fg: #14181d;
  --muted: #5c6670;
  --faint: #8b949e;
  --line: #e2e6ea;
  --surface: #f7f8f9;
  --surface-hover: #eef0f2;
  --accent: #2f6f8f;
  /* The accent, worn as a surface rather than as ink: a whole row can carry it
     without shouting. Same three roles as --surface / --surface-hover / --line. */
  --accent-soft: #edf3f6;
  --accent-soft-hover: #e1ecf1;
  --accent-line: #b7d0dc;
  --maxw: 760px;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", "Segoe UI Mono",
          "Roboto Mono", Menlo, Consolas, monospace;
}

/* Dark by system preference, unless the user forced light. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1013;
    --fg: #e8ebee;
    --muted: #98a1ab;
    --faint: #6b7580;
    --line: #232931;
    --surface: #14181d;
    --surface-hover: #1c222a;
    --accent: #6fb3d1;
    --accent-soft: #131d24;
    --accent-soft-hover: #17242d;
    --accent-line: #2e4a58;
  }
}

/* Dark when the user explicitly chose it. */
:root[data-theme="dark"] {
  --bg: #0d1013;
  --fg: #e8ebee;
  --muted: #98a1ab;
  --faint: #6b7580;
  --line: #232931;
  --surface: #14181d;
  --surface-hover: #1c222a;
  --accent: #6fb3d1;
  --accent-soft: #131d24;
  --accent-soft-hover: #17242d;
  --accent-line: #2e4a58;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               Helvetica, Arial, sans-serif;
  font-size: 19px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

.mono { font-family: var(--mono); }

/* ---------- Hero ---------- */
header.hero {
  padding: 96px 0 60px;
  text-align: center;
  border-bottom: 1px solid var(--line);
}

.hero h1 {
  margin: 0;
  font-family: var(--mono);
  font-size: clamp(2.7rem, 8.5vw, 4.6rem);
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1.02;
  white-space: nowrap;
}

.hero h1 .w-tech { color: var(--fg); }
.hero h1 .w-down { color: var(--accent); }

.hero h1 .caret {
  color: var(--accent);
  font-weight: 400;
  margin-left: 0.06em;
  animation: blink 1.15s steps(1) infinite;
}

@keyframes blink { 50% { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .hero h1 .caret { animation: none; }
}

.hero .caption {
  margin: 22px auto 0;
  max-width: 500px;
  color: var(--muted);
  font-size: 1.12rem;
}

/* ---------- Counters ---------- */
.counters {
  display: flex;
  justify-content: center;
  gap: 56px;
  margin-top: 48px;
}

.counter .num {
  font-family: var(--mono);
  font-size: 2.3rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.counter .label {
  font-family: var(--mono);
  margin-top: 10px;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--faint);
}

.counter .subcount {
  font-family: var(--mono);
  margin-top: 6px;
  font-size: 0.62rem;
  letter-spacing: 0.06em;
  color: var(--faint);
}

/* ---------- Sections ---------- */
section {
  padding: 72px 0;
  border-bottom: 1px solid var(--line);
}

section:last-of-type { border-bottom: none; }

h2.section-title {
  margin: 0 0 32px;
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  display: flex;
  align-items: baseline;
  gap: 12px;
}

h2.section-title .tag {
  font-family: var(--mono);
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0;
  color: var(--accent);
}

/* ---------- Filters ---------- */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.filter {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint);
  background: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 12px;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.filter:hover { color: var(--muted); }
.filter.active { color: var(--accent); border-color: var(--accent); }

/* A family: one generic model and the machines that realise it. The head row
   unfolds; its members sit indented under it, indexed with a dot because the
   family, not each member, is the entry in the catalogue. */
.family-head {
  width: 100%;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.family-count,
.family-note {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  color: var(--faint);
  margin-left: auto;
  padding-right: 14px;
}

.family-children {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 8px 0 0 26px;
  padding-left: 18px;
  border-left: 1px solid var(--line);
}
/* A flex container ignores [hidden] — display wins over the browser default —
   so a closed family went on showing everything it was meant to fold away. */
.family-children[hidden] { display: none; }
.family-children:not([hidden]) { margin-bottom: 8px; }

.system-child { padding: 10px 20px; }
.system-child .name { font-size: 1rem; font-weight: 500; }

/* Kept only because a variant matched the filter, not because it did. */
.system.carrier { opacity: 0.55; }

/* A type filter carries the colour that type has in the diagram. */
.filter.chip-dot::before {
  content: '';
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--chip-color, var(--muted));
  margin-right: 7px;
  vertical-align: 1px;
}

/* ---------- System list ---------- */
.systems { display: flex; flex-direction: column; gap: 8px; }

.system {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 12px 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  text-decoration: none;
  color: var(--fg);
  transition: background 0.15s ease, transform 0.15s ease, border-color 0.15s ease;
}

.system:hover {
  background: var(--surface-hover);
  border-color: var(--accent);
  transform: translateX(3px);
}

.system .idx {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  min-width: 2ch;
}

.system .name { font-size: 1.05rem; font-weight: 600; flex: 1; }

/* A family and its model carry the interface blue: they are the way in, so the
   whole box wears it — surface, border and text — and not the title alone.
   A real machine stays in the ordinary colours. */
.system.is-generic {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--accent);
}
.system.is-generic .name,
.system.is-generic .idx,
.system.is-generic .arrow { color: var(--accent); }
.system.is-generic:hover { background: var(--accent-soft-hover); border-color: var(--accent); }
.system.is-generic.wip:hover { background: var(--accent-soft); border-color: var(--accent-line); }

.system .arrow {
  font-family: var(--mono);
  color: var(--faint);
  font-size: 1.1rem;
  line-height: 1;
  transition: color 0.15s ease, transform 0.15s ease;
}

.system:hover .arrow { color: var(--accent); transform: translateX(2px); }

.system .badge {
  font-family: var(--mono);
  font-size: 0.66rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--faint);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 11px;
  white-space: nowrap;
}

.system.wip { cursor: default; }
.system.wip:hover {
  background: var(--surface);
  border-color: var(--line);
  transform: none;
}

.systems-empty { color: var(--muted); font-size: 1.05rem; }

/* ---------- About ---------- */
.about-block { margin-bottom: 44px; }
.about-block:last-child { margin-bottom: 0; }

h3.sub-title {
  margin: 0 0 12px;
  text-align: left;
  font-family: var(--mono);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--accent);
}

.about-block p { margin: 0; color: var(--fg); }

a.mail {
  font-family: var(--mono);
  font-size: 0.98rem;
  color: var(--fg);
  text-decoration: none;
  border-bottom: 1px solid var(--muted);
  padding-bottom: 1px;
}
a.mail:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- Footer ---------- */
footer {
  padding: 40px 0 64px;
  text-align: center;
  font-family: var(--mono);
  color: var(--faint);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
}

/* ---------- Controls (theme + language) ---------- */
.controls {
  position: fixed;
  top: 18px;
  right: 20px;
  z-index: 10;
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 14px;
}

.controls .ctrl-sep {
  width: 1px;
  height: 14px;
  background: var(--line);
}

.lang {
  display: flex;
  align-items: center;
  white-space: nowrap;
  font-family: var(--mono);
  font-size: 0.8rem;
  letter-spacing: 0.08em;
}

.lang button {
  background: none;
  border: none;
  padding: 2px 3px;
  margin: 0;
  font: inherit;
  color: var(--faint);
  cursor: pointer;
  transition: color 0.15s ease;
}

.lang button:hover { color: var(--muted); }
.lang button.active { color: var(--accent); }
.lang .sep { color: var(--line); }

@media (max-width: 520px) {
  .counters { gap: 40px; }
  header.hero { padding: 72px 0 48px; }
  section { padding: 56px 0; }
}
