:root {
  color-scheme: light;
  --canvas: oklch(0.975 0.008 145);
  --surface: oklch(0.995 0.003 145);
  --surface-subtle: oklch(0.952 0.012 145);
  --ink: oklch(0.22 0.018 145);
  --ink-muted: oklch(0.46 0.018 145);
  --line: oklch(0.84 0.016 145);
  --line-strong: oklch(0.7 0.022 145);
  --brand: oklch(0.47 0.115 153);
  --brand-soft: oklch(0.93 0.035 153);
  --success: oklch(0.56 0.145 151);
  --success-soft: oklch(0.94 0.045 151);
  --warning: oklch(0.65 0.145 75);
  --warning-soft: oklch(0.95 0.052 75);
  --danger: oklch(0.56 0.19 25);
  --danger-soft: oklch(0.95 0.04 25);
  --unknown: oklch(0.64 0.018 145);
  --unknown-soft: oklch(0.94 0.01 145);
  --focus: oklch(0.48 0.16 250);
  --radius-sm: 6px;
  --radius-md: 12px;
  --content: 1560px;
  --shell: min(var(--content), calc(100vw - clamp(32px, 5vw, 80px)));
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

html[data-theme='dark'] {
  color-scheme: dark;
  --canvas: oklch(0.17 0.012 145);
  --surface: oklch(0.21 0.014 145);
  --surface-subtle: oklch(0.255 0.018 145);
  --ink: oklch(0.94 0.008 145);
  --ink-muted: oklch(0.74 0.014 145);
  --line: oklch(0.35 0.018 145);
  --line-strong: oklch(0.49 0.026 145);
  --brand: oklch(0.72 0.13 151);
  --brand-soft: oklch(0.29 0.045 151);
  --success: oklch(0.72 0.15 151);
  --success-soft: oklch(0.27 0.055 151);
  --warning: oklch(0.78 0.14 75);
  --warning-soft: oklch(0.3 0.052 75);
  --danger: oklch(0.7 0.17 25);
  --danger-soft: oklch(0.29 0.052 25);
  --unknown: oklch(0.69 0.02 145);
  --unknown-soft: oklch(0.28 0.014 145);
  --focus: oklch(0.78 0.15 250);
}

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

html {
  min-width: 320px;
  background: var(--canvas);
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  font-family: 'Noto Sans SC', 'Microsoft YaHei', 'PingFang SC', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

button,
a {
  color: inherit;
  font: inherit;
}

a {
  text-decoration: none;
}

button {
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 50;
  padding: 8px 12px;
  color: var(--surface);
  background: var(--ink);
  transform: translateY(-160%);
  transition: transform 160ms ease-out;
}

.skip-link:focus {
  transform: translateY(0);
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 0 max(clamp(16px, 2.5vw, 40px), calc((100vw - var(--content)) / 2));
  border-bottom: 1px solid var(--line);
  background: color-mix(in oklch, var(--canvas) 94%, transparent);
  backdrop-filter: blur(12px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  min-height: 44px;
}

.brand-mark {
  width: 27px;
  height: 27px;
  display: inline-flex;
  color: var(--ink);
}

.brand-mark img {
  width: 100%;
  height: 100%;
}

html[data-theme='dark'] .brand-mark img {
  filter: invert(1);
}

.brand strong {
  display: block;
  font-family: 'Familjen Grotesk', 'Arial Narrow', system-ui, sans-serif;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.05;
}

.brand-subtitle {
  display: block;
  margin-top: 3px;
  color: var(--ink-muted);
  font-size: 12px;
  line-height: 1;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-button {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  color: var(--ink);
  background: transparent;
  transition: background 160ms ease-out, color 160ms ease-out;
}

.icon-button:hover {
  color: var(--surface);
  background: var(--ink);
}

.icon-button svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
}

.return-link {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  color: var(--surface);
  background: var(--ink);
  font-size: 14px;
  font-weight: 700;
  transition: opacity 160ms ease-out;
}

.return-link:hover {
  opacity: 0.82;
}

.status-rail {
  border-bottom: 1px solid var(--line);
  background: var(--surface-subtle);
}

.status-rail-inner {
  width: var(--shell);
  min-height: 214px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(420px, 1.15fr) minmax(500px, 1fr);
  align-items: center;
  gap: clamp(36px, 5vw, 88px);
}

.overall-status {
  display: flex;
  align-items: flex-start;
  gap: 24px;
}

.status-orbit {
  position: relative;
  width: 58px;
  height: 58px;
  flex: 0 0 58px;
  margin-top: 6px;
  border: 1px solid currentColor;
  border-radius: 50%;
  color: var(--unknown);
}

.status-orbit::before,
.status-orbit::after {
  content: '';
  position: absolute;
  border-radius: 50%;
}

.status-orbit::before {
  inset: 11px;
  background: currentColor;
}

.status-orbit::after {
  width: 8px;
  height: 8px;
  top: -4px;
  left: 50%;
  background: currentColor;
  transform: translateX(-50%);
}

.status-orbit[data-status='operational'] { color: var(--success); }
.status-orbit[data-status='degraded'],
.status-orbit[data-status='timeout'] { color: var(--warning); }
.status-orbit[data-status='outage'] { color: var(--danger); }
.status-orbit[data-status='stale'],
.status-orbit[data-status='unchecked'] { color: var(--unknown); }

.section-label {
  margin: 0 0 5px;
  color: var(--ink-muted);
  font-size: 13px;
  font-weight: 650;
}

.overall-status h1 {
  max-width: 24ch;
  margin: 0;
  font-size: 34px;
  line-height: 1.18;
  letter-spacing: -0.025em;
  text-wrap: balance;
}

.overall-status p:last-child {
  max-width: 55ch;
  margin: 12px 0 0;
  color: var(--ink-muted);
  text-wrap: pretty;
}

.rail-facts {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-top: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line-strong);
}

.rail-facts > div {
  min-width: 0;
  padding: 22px 18px;
}

.rail-facts > div + div {
  border-left: 1px solid var(--line);
}

.rail-facts dt,
.rail-facts span {
  color: var(--ink-muted);
  font-size: 12px;
}

.rail-facts dd {
  margin: 8px 0 3px;
  overflow: hidden;
  font-size: 17px;
  font-weight: 720;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.freshness-banner {
  width: var(--shell);
  margin: 22px auto 0;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--warning);
  border-radius: var(--radius-sm);
  color: var(--ink);
  background: var(--warning-soft);
}

.freshness-banner[hidden] {
  display: none;
}

.freshness-icon {
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--warning-soft);
  background: var(--warning);
  font-size: 13px;
  font-weight: 800;
}

.freshness-banner strong,
.freshness-banner p {
  display: block;
  margin: 0;
}

.freshness-banner p {
  margin-top: 2px;
  color: var(--ink-muted);
  font-size: 13px;
}

.source-banner {
  width: var(--shell);
  margin: 18px auto 0;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.source-banner[data-mode='demo'] {
  border-color: var(--warning);
  background: var(--warning-soft);
}

.source-kicker {
  flex: 0 0 auto;
  padding: 3px 7px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--ink-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.source-banner[data-mode='demo'] .source-kicker {
  border-color: var(--warning);
  color: var(--ink);
}

.source-banner p {
  margin: 0;
  color: var(--ink-muted);
  font-size: 13px;
}

.models-section,
.method-section,
.site-footer {
  width: var(--shell);
  margin-inline: auto;
}

.models-section {
  padding: 52px 0 44px;
}

.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px;
  margin-bottom: 22px;
}

.section-heading h2,
.method-section h2 {
  margin: 0;
  font-size: 24px;
  line-height: 1.25;
  letter-spacing: -0.015em;
}

.section-heading p,
.method-section p {
  max-width: 68ch;
  margin: 8px 0 0;
  color: var(--ink-muted);
  font-size: 14px;
  text-wrap: pretty;
}

.section-heading-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
  flex: 0 0 auto;
}

.section-heading .history-hint {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  color: var(--ink-muted);
  font-size: 12px;
  white-space: nowrap;
}

.history-hint > span {
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--brand);
  background: var(--surface);
  font-weight: 800;
}

.view-controls {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-subtle);
}

.filter-button {
  min-height: 34px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--radius-sm);
  color: var(--ink-muted);
  background: transparent;
  font-size: 13px;
  font-weight: 650;
}

.filter-button:hover {
  color: var(--ink);
}

.filter-button.is-active {
  color: var(--surface);
  background: var(--ink);
}

.model-groups {
  overflow: clip;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.family-group {
  border-bottom: 1px solid var(--line-strong);
}

.family-group:last-of-type {
  border-bottom: 0;
}

.family-group summary {
  min-height: 72px;
  display: grid;
  grid-template-columns: minmax(190px, 0.7fr) minmax(240px, 1fr) auto;
  align-items: center;
  gap: 24px;
  padding: 14px 18px;
  cursor: pointer;
  list-style: none;
  transition: background 160ms ease-out;
}

.family-group summary::-webkit-details-marker {
  display: none;
}

.family-group summary:hover {
  background: var(--surface-subtle);
}

.family-title {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  font-size: 16px;
  font-weight: 740;
}

.family-dot {
  width: 9px;
  height: 9px;
  flex: 0 0 9px;
  border-radius: 50%;
  background: var(--unknown);
}

.family-dot.operational { background: var(--success); }
.family-dot.degraded,
.family-dot.timeout { background: var(--warning); }
.family-dot.outage { background: var(--danger); }
.family-dot.unchecked,
.family-dot.stale,
.family-dot.unknown { background: var(--unknown); }

.family-summary {
  overflow: hidden;
  color: var(--ink-muted);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.disclosure-icon {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ink-muted);
  transition: transform 180ms var(--ease);
}

.family-group[open] .disclosure-icon {
  transform: rotate(180deg);
}

.model-list {
  border-top: 1px solid var(--line);
}

.model-header,
.model-row {
  display: grid;
  grid-template-columns: minmax(260px, 1.55fr) minmax(126px, 0.55fr) 96px 132px minmax(300px, 1.6fr);
  align-items: center;
  gap: clamp(14px, 1.7vw, 28px);
  padding-inline: 18px;
}

.model-header {
  min-height: 42px;
  color: var(--ink-muted);
  background: var(--surface-subtle);
  font-size: 11px;
  font-weight: 700;
}

.model-row {
  min-height: 82px;
  border-top: 1px solid var(--line);
  transition: background 150ms ease-out;
}

.model-row:hover,
.model-row:focus-within {
  background: color-mix(in oklch, var(--brand-soft) 44%, var(--surface));
}

.model-header + .model-row {
  border-top: 0;
}

.model-row[hidden] {
  display: none;
}

.model-name {
  min-width: 0;
}

.model-name strong {
  display: block;
  overflow: hidden;
  font-size: 14px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.model-note {
  display: block;
  margin-top: 4px;
  overflow: hidden;
  color: var(--ink-muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-stamp {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  width: fit-content;
  min-height: 28px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 720;
  white-space: nowrap;
}

.status-stamp::before {
  content: '';
  width: 7px;
  height: 7px;
  flex: 0 0 7px;
  border-radius: 50%;
  background: currentColor;
}

.status-stamp.operational { color: var(--success); background: var(--success-soft); }
.status-stamp.degraded,
.status-stamp.timeout { color: var(--warning); background: var(--warning-soft); }
.status-stamp.outage { color: var(--danger); background: var(--danger-soft); }
.status-stamp.unchecked,
.status-stamp.stale,
.status-stamp.unknown { color: var(--ink-muted); background: var(--unknown-soft); }

.metric,
.time-value {
  font-variant-numeric: tabular-nums;
}

.metric {
  font-size: 13px;
  font-weight: 720;
}

.metric.muted,
.time-value {
  color: var(--ink-muted);
  font-size: 12px;
}

.history {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(24, minmax(5px, 1fr));
  gap: clamp(3px, 0.32vw, 5px);
  min-height: 36px;
  padding-block: 4px;
  border-radius: 4px;
  cursor: crosshair;
}

.history:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 4px;
}

.history-cell {
  appearance: none;
  min-width: 0;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 2px;
  background: var(--unknown);
  opacity: 0.78;
  transition: opacity 140ms ease-out, transform 140ms var(--ease), box-shadow 140ms ease-out;
}

.history-cell:hover,
.history-cell.is-selected,
.history-cell[data-tooltip-open='true'] {
  z-index: 1;
  opacity: 1;
  transform: translateY(-3px) scaleY(1.12);
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--ink);
}

.history-cell.operational { background: var(--success); }
.history-cell.degraded,
.history-cell.timeout { background: var(--warning); }
.history-cell.outage { background: var(--danger); }
.history-cell.unchecked,
.history-cell.stale,
.history-cell.unknown { background: var(--unknown); }

.history-tooltip {
  position: fixed;
  z-index: 100;
  width: min(310px, calc(100vw - 24px));
  padding: 15px 16px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  color: var(--ink);
  background: color-mix(in oklch, var(--surface) 96%, transparent);
  box-shadow: 0 18px 48px color-mix(in oklch, var(--ink) 17%, transparent);
  backdrop-filter: blur(14px);
  pointer-events: none;
}

.history-tooltip[hidden] {
  display: none;
}

.history-tooltip::after {
  content: '';
  position: absolute;
  left: 50%;
  width: 10px;
  height: 10px;
  border-right: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line-strong);
  background: var(--surface);
  transform: translateX(-50%) rotate(45deg);
}

.history-tooltip[data-placement='above']::after {
  bottom: -6px;
}

.history-tooltip[data-placement='below']::after {
  top: -6px;
  transform: translateX(-50%) rotate(225deg);
}

.history-tooltip-head {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 11px;
}

.history-tooltip-head strong {
  font-size: 14px;
}

.history-tooltip-dot {
  width: 9px;
  height: 9px;
  flex: 0 0 9px;
  border-radius: 2px;
  background: var(--unknown);
}

.history-tooltip[data-status='operational'] .history-tooltip-dot { background: var(--success); }
.history-tooltip[data-status='degraded'] .history-tooltip-dot,
.history-tooltip[data-status='timeout'] .history-tooltip-dot { background: var(--warning); }
.history-tooltip[data-status='outage'] .history-tooltip-dot { background: var(--danger); }

.history-tooltip dl {
  margin: 0;
  display: grid;
  gap: 7px;
}

.history-tooltip dl > div {
  display: grid;
  grid-template-columns: 68px minmax(0, 1fr);
  gap: 10px;
}

.history-tooltip dt,
.history-tooltip dd,
.history-tooltip p {
  margin: 0;
  font-size: 12px;
}

.history-tooltip dt {
  color: var(--ink-muted);
}

.history-tooltip dd {
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
}

.history-tooltip p {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  color: var(--ink-muted);
  line-height: 1.5;
}

.empty-filter {
  padding: 40px 12px;
  color: var(--ink-muted);
  text-align: center;
}

.loading-state {
  display: grid;
  gap: 12px;
  padding: 20px 0;
}

.loading-state span {
  height: 72px;
  border-radius: var(--radius-sm);
  background: var(--surface-subtle);
  animation: pulse 1.4s ease-in-out infinite alternate;
}

@keyframes pulse {
  from { opacity: 0.55; }
  to { opacity: 1; }
}

.method-section {
  display: grid;
  grid-template-columns: minmax(260px, 0.72fr) minmax(0, 1.28fr);
  gap: 60px;
  padding: 44px 0 58px;
  border-top: 1px solid var(--line-strong);
}

.method-list {
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 32px;
  list-style: none;
}

.method-list li {
  min-height: 54px;
  display: grid;
  grid-template-columns: 10px 96px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}

.method-list strong {
  font-size: 12px;
}

.method-list li > span:last-child {
  color: var(--ink-muted);
}

.legend-swatch {
  width: 9px;
  height: 9px;
  border-radius: 2px;
  background: var(--unknown);
}

.legend-swatch.operational { background: var(--success); }
.legend-swatch.degraded,
.legend-swatch.timeout { background: var(--warning); }
.legend-swatch.outage { background: var(--danger); }
.legend-swatch.unchecked,
.legend-swatch.stale { background: var(--unknown); }

.site-footer {
  min-height: 86px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-top: 1px solid var(--line);
  color: var(--ink-muted);
  font-size: 12px;
}

.site-footer p {
  margin: 0;
}

.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;
}

@media (max-width: 1100px) {
  .status-rail-inner {
    grid-template-columns: 1fr;
    gap: 36px;
    padding: 48px 0;
  }

  .section-heading {
    align-items: flex-start;
  }

  .section-heading-actions {
    align-items: flex-end;
    flex-direction: column;
    gap: 10px;
  }

  .model-header,
  .model-row {
    grid-template-columns: minmax(220px, 1.25fr) minmax(120px, 0.6fr) 90px minmax(260px, 1.35fr);
  }

  .model-header > :nth-child(4),
  .model-row > :nth-child(4) {
    display: none;
  }

  .method-section {
    grid-template-columns: 1fr;
    gap: 28px;
  }
}

@media (max-width: 820px) {
  .model-header {
    display: none;
  }

  .model-row,
  .model-header + .model-row {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px 16px;
    min-height: 0;
    padding: 18px 10px;
    border-top: 1px solid var(--line);
  }

  .model-row > :nth-child(4) {
    display: block;
  }

  .model-row .metric {
    grid-column: 1;
    grid-row: 2;
  }

  .model-row .time-value {
    grid-column: 2;
    grid-row: 2;
    text-align: right;
  }

  .history {
    grid-column: 1 / -1;
    grid-row: 3;
    min-height: 44px;
    margin-top: 4px;
    padding-block: 8px;
    cursor: pointer;
  }

  .history-cell {
    height: 28px;
    pointer-events: none;
  }
}

@media (max-width: 640px) {
  .site-header {
    min-height: 62px;
    padding-inline: 16px;
  }

  .return-link {
    display: none;
  }

  .status-rail-inner,
  .models-section,
  .method-section,
  .site-footer,
  .freshness-banner,
  .source-banner {
    width: min(calc(100% - 32px), var(--content));
  }

  .source-banner {
    align-items: flex-start;
  }

  .status-rail-inner {
    gap: 30px;
    padding: 36px 0;
  }

  .overall-status {
    gap: 16px;
  }

  .status-orbit {
    width: 42px;
    height: 42px;
    flex-basis: 42px;
  }

  .status-orbit::before {
    inset: 9px;
  }

  .overall-status h1 {
    font-size: 26px;
  }

  .rail-facts > div {
    padding: 16px 10px;
  }

  .rail-facts dd {
    font-size: 14px;
  }

  .rail-facts span {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .models-section {
    padding-top: 44px;
  }

  .section-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .section-heading-actions {
    width: 100%;
    align-items: flex-start;
  }

  .family-group summary {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    padding-inline: 6px;
  }

  .family-summary {
    grid-column: 1 / -1;
    grid-row: 2;
    white-space: normal;
  }

  .method-list {
    grid-template-columns: 1fr;
  }

  .site-footer {
    align-items: flex-start;
    flex-direction: column;
    justify-content: center;
    padding-block: 24px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
