:root {
  --bg: #f8f7f4;
  --bg-glow: #eef0ff;
  --panel: #ffffff;
  --ink: #17171a;
  --muted: #74737b;
  --faint: #a3a2a9;
  --line: #e8e6e1;
  --accent: #5b53e0;
  --accent-soft: #efeeff;
  --accent-2: #12a396;
  --good: #12a396;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(23, 23, 26, .04), 0 8px 24px -16px rgba(23, 23, 26, .18);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d0d0f;
    --bg-glow: #171a33;
    --panel: #16161a;
    --ink: #f3f2ee;
    --muted: #94939c;
    --faint: #6b6a73;
    --line: #26262c;
    --accent: #8d86ff;
    --accent-soft: #1d1b33;
    --accent-2: #3ec9b8;
    --good: #3ec9b8;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 12px 32px -20px rgba(0, 0, 0, .8);
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background:
    radial-gradient(900px 420px at 50% -160px, var(--bg-glow), transparent 70%),
    var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

main {
  max-width: 980px;
  margin: 0 auto;
  padding: 28px 20px 64px;
}

/* ---------- top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 56px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  letter-spacing: -.01em;
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.tagline {
  color: var(--faint);
  font-size: 11.5px;
  font-weight: 400;
  letter-spacing: 0;
  line-height: 1.35;
}

.mark {
  width: 22px;
  height: 22px;
  border-radius: 7px;
  background: linear-gradient(145deg, var(--accent), var(--accent-2));
  box-shadow: 0 2px 10px -2px color-mix(in srgb, var(--accent) 60%, transparent);
  position: relative;
}
.mark::after {
  content: "";
  position: absolute;
  inset: 6px 5px;
  border-radius: 2px;
  background: repeating-linear-gradient(90deg, rgba(255,255,255,.95) 0 2px, transparent 2px 4px);
  opacity: .9;
}

.name { font-size: 17px; }

.chips { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chip.status i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--faint);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--faint) 18%, transparent);
}
.chip.status.on i {
  background: var(--good);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--good) 18%, transparent);
}

/* ---------- hero ---------- */

.hero { margin-bottom: 32px; }

.eyebrow {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: .02em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(48px, 9vw, 76px);
  line-height: 1;
  font-weight: 600;
  letter-spacing: -.045em;
  font-variant-numeric: tabular-nums;
}

h1 .unit {
  font-size: .38em;
  font-weight: 500;
  letter-spacing: -.01em;
  color: var(--faint);
  margin-left: .3em;
}

.sub {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 15px;
}
.sub b { color: var(--ink); font-weight: 600; }

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

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.statgrid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.stat { display: flex; flex-direction: column; gap: 6px; padding: 18px; }

.stat-label {
  color: var(--muted);
  font-size: 12.5px;
  letter-spacing: .01em;
}

.stat-value {
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.stat-foot { color: var(--faint); font-size: 12px; }

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 8px;
}

h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -.01em;
}

.card-sub {
  margin: 3px 0 0;
  color: var(--faint);
  font-size: 12.5px;
}

/* ---------- chart ---------- */

.chart-card { margin-bottom: 12px; padding-bottom: 12px; }

.chart { height: 300px; width: 100%; }

.empty {
  margin: 0;
  padding: 0 4px 12px;
  color: var(--faint);
  font-size: 13px;
  text-align: center;
}

.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: color-mix(in srgb, var(--bg) 60%, var(--panel));
}

.segmented button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12.5px;
  padding: 4px 10px;
  border-radius: 7px;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}

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

.segmented button.on {
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(0,0,0,.08);
}

/* ---------- two-column ---------- */

.use-card { margin-top: 12px; }

.use-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 28px;
  align-items: start;
  margin-top: 14px;
}

.use-grid > * { min-width: 0; }

/* ---------- how to use ---------- */

.steps {
  margin: 0 0 18px;
  padding: 0 0 0 18px;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.65;
}
.steps li { padding-left: 2px; margin-bottom: 4px; }
.steps b { color: var(--ink); font-weight: 600; }

.endpoints { display: flex; flex-direction: column; gap: 8px; }

.endpoint {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px 9px 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: color-mix(in srgb, var(--bg) 45%, var(--panel));
}

.endpoint-label {
  color: var(--faint);
  font-size: 11px;
  letter-spacing: .04em;
  text-transform: uppercase;
  flex: 0 0 58px;
}

.endpoint code {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12.5px;
  color: var(--ink);
}

.also {
  margin: 14px 0 0;
  color: var(--faint);
  font-size: 12.5px;
  line-height: 1.55;
}
.also code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12px;
  color: var(--muted);
}

.ghost {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 8px;
  cursor: pointer;
  flex: none;
}
.ghost:hover { color: var(--ink); border-color: var(--faint); }

/* ---------- footer ---------- */

footer {
  margin-top: 28px;
  color: var(--faint);
  font-size: 12.5px;
  text-align: center;
}

/* ---------- dialog ---------- */

dialog {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 22px;
  background: var(--panel);
  color: var(--ink);
  width: min(360px, calc(100vw - 32px));
  box-shadow: 0 24px 60px -20px rgba(0,0,0,.45);
}
dialog::backdrop { background: rgba(10, 10, 12, .45); backdrop-filter: blur(3px); }
dialog h3 { margin: 0 0 6px; font-size: 16px; }
dialog p { margin: 0 0 14px; color: var(--muted); font-size: 13px; }
dialog input {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
}
dialog menu {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin: 16px 0 0;
  padding: 0;
}
dialog menu button {
  border: 0;
  border-radius: 9px;
  padding: 8px 14px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
}
dialog menu .ghost { background: transparent; border: 1px solid var(--line); color: var(--muted); }

/* ---------- responsive ---------- */

@media (max-width: 560px) {
  #chip-model { display: none; }

  .endpoint {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "label copy"
      "value copy";
    row-gap: 3px;
    align-items: center;
  }
  .endpoint-label { grid-area: label; flex-basis: auto; }
  .endpoint code {
    grid-area: value;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  .endpoint .copy { grid-area: copy; margin-left: 8px; }
}

@media (max-width: 900px) {
  .statgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .statgrid > .stat:last-child { grid-column: 1 / -1; }
  .use-grid { grid-template-columns: minmax(0, 1fr); gap: 18px; }
}

@media (max-width: 520px) {
  main { padding: 20px 14px 48px; }
  .topbar { margin-bottom: 36px; }
  .statgrid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat { padding: 14px; }
  .stat-value { font-size: 24px; }
  .chart { height: 240px; }
  .chip.status span { display: none; }
}

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