:root {
  --color-bg: #ffffff;
  --color-surface: #f5f5f7;
  --color-surface-2: #fafafc;
  --color-ink: #1d1d1f;
  --color-muted: #6e6e73;
  --color-accent: #0071e3;
  --color-accent-strong: #0077ed;
  --color-line: rgba(0, 0, 0, 0.1);
  --color-ink-invert: #f5f5f7;
  --radius-ap: 18px;
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.04), 0 10px 30px -14px rgba(0, 0, 0, 0.14);
  --shadow-card-hover: 0 2px 6px rgba(0, 0, 0, 0.06), 0 26px 56px -18px rgba(0, 0, 0, 0.22);
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
    "Helvetica Neue", Helvetica, Arial, "PingFang SC", sans-serif;
  --nav-h: 48px;
  --c-blue: #0071e3;
  --c-indigo: #5a4be0;
  --c-purple: #a23ad8;
  --c-pink: #ff2d78;
  --c-teal: #0ea5a0;
  --c-green: #22a95b;
  --c-amber: #e8820e;
  --c-cyan: #0aa5d8;
  color-scheme: light;
}

html.dark {
  --color-bg: #000000;
  --color-surface: #16161a;
  --color-surface-2: #202026;
  --color-ink: #f5f5f7;
  --color-muted: #a7a7ad;
  --color-accent: #2997ff;
  --color-accent-strong: #3aa0ff;
  --color-line: rgba(255, 255, 255, 0.14);
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.5), 0 12px 32px -16px rgba(0, 0, 0, 0.7);
  --shadow-card-hover: 0 2px 8px rgba(0, 0, 0, 0.6), 0 30px 60px -20px rgba(0, 0, 0, 0.85);
  --c-blue: #2997ff;
  --c-indigo: #7d7aff;
  --c-purple: #cf6bf2;
  --c-pink: #ff6b9d;
  --c-teal: #40d6c8;
  --c-green: #30d158;
  --c-amber: #ff9f0a;
  --c-cyan: #5ac8fa;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-h) + 16px);
}

body {
  margin: 0;
  min-width: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--color-bg);
  color: var(--color-ink);
  font-family: var(--font-sans);
  letter-spacing: -0.012em;
}

:lang(zh) {
  letter-spacing: 0;
}

a {
  color: inherit;
}

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

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 100;
  transform: translateY(-150%);
  padding: 10px 16px;
  border-radius: 10px;
  background: var(--color-ink);
  color: #fff;
  font-size: 14px;
  text-decoration: none;
}

.skip-link:focus {
  transform: none;
}

.nav-bar {
  position: fixed;
  inset: 0 0 auto;
  z-index: 50;
  height: var(--nav-h);
  border-bottom: 0.5px solid var(--color-line);
  background: color-mix(in srgb, var(--color-bg) 80%, transparent);
  transition: box-shadow 0.3s ease, background-color 0.3s ease;
}

.nav-bar.scrolled {
  box-shadow: 0 0.5px 0 var(--color-line), 0 10px 30px -18px rgba(0, 0, 0, 0.35);
  background: color-mix(in srgb, var(--color-bg) 92%, transparent);
}

.nav-bar-frost {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: color-mix(in srgb, var(--color-bg) 72%, transparent);
  -webkit-backdrop-filter: blur(20px) saturate(1.5);
  backdrop-filter: blur(20px) saturate(1.5);
}

.nav-inner,
.wrap {
  width: 100%;
  max-width: 1080px;
  margin-inline: auto;
  padding-inline: 22px;
}

.nav-inner {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.brand img {
  display: block;
}

.nav-links {
  display: none;
  align-items: center;
  gap: 28px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.nav-links a {
  text-decoration: none;
  font-size: 12px;
  font-weight: 400;
  color: var(--color-ink);
  opacity: 0.8;
}

.nav-links a:hover {
  opacity: 1;
}

.nav-tools {
  display: flex;
  align-items: center;
  gap: 4px;
}

.lang-switch {
  display: flex;
  align-items: center;
  padding: 2px;
  border-radius: 999px;
}

.lang-switch button,
.icon-button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--color-ink);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.lang-switch button {
  min-width: 36px;
  height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font: 600 12px/1 var(--font-sans);
  color: var(--color-muted);
}

.lang-switch button[aria-pressed="true"] {
  background: color-mix(in srgb, var(--color-ink) 8%, transparent);
  color: var(--color-ink);
}

.icon-button {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  color: color-mix(in srgb, var(--color-ink) 80%, transparent);
}

.icon-button:hover,
.lang-switch button:hover {
  background: color-mix(in srgb, var(--color-ink) 8%, transparent);
  color: var(--color-ink);
}

.icon-button svg {
  width: 18px;
  height: 18px;
}

html:not(.dark) .icon-sun,
html.dark .icon-moon {
  display: none;
}

body[data-auth="0"] .auth-only {
  display: none;
}

.page {
  flex: 1;
  padding-top: var(--nav-h);
}

#app {
  padding-bottom: 72px;
}

.ambient {
  position: relative;
  isolation: isolate;
}

.ambient::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: radial-gradient(
    60% 42% at 50% -4%,
    color-mix(in srgb, var(--color-accent) 12%, transparent),
    transparent 70%
  );
}

.hero {
  padding: 56px 0 28px;
  text-align: center;
}

.eyebrow {
  margin: 0;
  font-size: clamp(17px, 1.4vw, 21px);
  font-weight: 600;
  color: var(--color-accent);
}

.display-2 {
  margin: 10px auto 0;
  max-width: 16ch;
  font-size: clamp(32px, 4.6vw, 56px);
  line-height: 1.07;
  font-weight: 600;
  letter-spacing: -0.022em;
  text-wrap: balance;
}

.lead {
  margin: 14px auto 0;
  max-width: 38ch;
  font-size: clamp(17px, 1.7vw, 21px);
  line-height: 1.35;
  font-weight: 400;
  color: var(--color-muted);
  text-wrap: balance;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 28px;
}

.segment {
  display: inline-flex;
  padding: 3px;
  border-radius: 999px;
  background: var(--color-surface);
  border: 0.5px solid var(--color-line);
}

.segment button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--color-muted);
  min-width: 72px;
  height: 32px;
  padding: 0 14px;
  border-radius: 999px;
  font: 600 13px/1 var(--font-sans);
  cursor: pointer;
}

.segment button[aria-selected="true"] {
  background: var(--color-bg);
  color: var(--color-ink);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

html.dark .segment button[aria-selected="true"] {
  background: #2c2c31;
  box-shadow: none;
}

.meta {
  font-size: 12px;
  color: var(--color-muted);
}

.status {
  margin: 18px auto 0;
  max-width: 1080px;
  padding-inline: 22px;
  text-align: center;
  font-size: 14px;
  color: var(--color-muted);
}

.status[data-kind="error"] {
  color: var(--c-pink);
}

.grid {
  display: grid;
  gap: 16px;
}

.kpis {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 8px;
}

.section {
  padding: 36px 0 8px;
  scroll-margin-top: calc(var(--nav-h) + 16px);
}

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

.section-head h2 {
  margin: 0;
  font-size: 21px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.section-head p {
  margin: 0;
  font-size: 13px;
  color: var(--color-muted);
}

.card {
  border: 0.5px solid var(--color-line);
  border-radius: var(--radius-ap);
  background: var(--color-bg);
  box-shadow: var(--shadow-card);
  padding: 22px;
  min-width: 0;
  transition: transform 0.4s cubic-bezier(0.22, 0.61, 0.36, 1), box-shadow 0.4s ease;
}

@media (hover: hover) {
  .card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-card-hover);
  }
}

.kpi {
  position: relative;
  overflow: hidden;
}

.kpi::before {
  content: "";
  position: absolute;
  inset: auto -20% -40% auto;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--tile) 16%, transparent);
  pointer-events: none;
}

.kpi .label {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--tile);
}

.kpi .value {
  margin: 10px 0 0;
  font-size: clamp(28px, 4vw, 40px);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.kpi .hint,
.card > .hint {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--color-muted);
}

.funnels,
.mixes,
.charts {
  grid-template-columns: 1fr;
}

.funnel-step {
  display: grid;
  gap: 6px;
}

.funnel-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
}

.funnel-row strong {
  font-weight: 600;
}

.funnel-row span {
  font-variant-numeric: tabular-nums;
  color: var(--color-muted);
}

.funnel-bar {
  height: 10px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--color-ink) 6%, transparent);
  overflow: hidden;
}

.funnel-bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--bar);
  min-width: 4px;
}

.funnel-rate {
  margin: 0 0 10px;
  font-size: 11px;
  font-weight: 600;
  color: var(--color-muted);
}

.mix {
  display: grid;
  grid-template-columns: 108px 1fr;
  gap: 18px;
  align-items: center;
}

.donut {
  width: 108px;
  height: 108px;
}

.legend {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.legend li {
  display: grid;
  grid-template-columns: 8px 1fr auto;
  gap: 8px;
  align-items: center;
  font-size: 13px;
}

.swatch {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--swatch);
}

.legend .pct {
  color: var(--color-muted);
  font-variant-numeric: tabular-nums;
}

.chart {
  height: 180px;
}

.chart svg,
.donut svg {
  display: block;
  width: 100%;
  height: 100%;
}

.host-row,
.path-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  border-top: 0.5px solid var(--color-line);
  font-size: 13px;
}

.host-row:first-child,
.path-row:first-child {
  border-top: 0;
  padding-top: 0;
}

.host-row code,
.path-row code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.live {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.live th,
.live td {
  padding: 8px 10px 8px 0;
  text-align: left;
  border-bottom: 0.5px solid var(--color-line);
  vertical-align: top;
}

.live th {
  color: var(--color-muted);
  font-weight: 600;
}

.live td {
  font-variant-numeric: tabular-nums;
}

.live code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
}

.notes {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--color-muted);
  font-size: 13px;
  line-height: 1.5;
}

.empty {
  margin: 0;
  color: var(--color-muted);
  font-size: 14px;
}

@media (min-width: 720px) {
  .nav-links {
    display: flex;
  }

  .kpis {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .funnels,
  .mixes {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .charts,
  .split {
    grid-template-columns: 1.2fr 0.8fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .card {
    transition: none;
  }
}
