/* ── tokens ─────────────────────────────────────────────── */
:root,
[data-theme="light"] {
  color-scheme: light;
  --bg: #f5f5f7;
  --tile: #ffffff;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --faint: #86868b;
  --blue: #0071e3;
  --blue-hover: #0077ed;
  --pill-bg: #e8e8ed;
  --pill-active-bg: #1d1d1f;
  --pill-active-text: #ffffff;
  --line: rgba(0, 0, 0, .08);
  --tile-shadow: 0 2px 14px rgba(0, 0, 0, .045);
  --tile-shadow-hover: 0 16px 44px rgba(0, 0, 0, .09);
  --ok: #34c759;
  --bad: #ff3b30;
  --unknown: #c7c7cc;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #000000;
  --tile: #1c1c1e;
  --text: #f5f5f7;
  --muted: #a1a1a6;
  --faint: #86868b;
  --blue: #2997ff;
  --blue-hover: #47a6ff;
  --pill-bg: #2c2c2e;
  --pill-active-bg: #f5f5f7;
  --pill-active-text: #1d1d1f;
  --line: rgba(255, 255, 255, .1);
  --tile-shadow: none;
  --tile-shadow-hover: 0 16px 44px rgba(0, 0, 0, .55);
  --ok: #30d158;
  --bad: #ff453a;
  --unknown: #636366;
}

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

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

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
    "Segoe UI Variable Text", "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }

::selection { background: color-mix(in srgb, var(--blue) 22%, transparent); }

:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 4px;
  border-radius: 6px;
}

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

/* ── nav ────────────────────────────────────────────────── */
.nav {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid transparent;
  transition: border-color .3s ease;
}

.nav.scrolled { border-bottom-color: var(--line); }

.nav-inner {
  width: min(1180px, 100% - 2 * clamp(20px, 4vw, 40px));
  margin-inline: auto;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -.015em;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: var(--muted);
  font-size: 12px;
  transition: color .2s;
}

.nav-link:hover { color: var(--text); }

.nav-link svg {
  width: 10px;
  height: 10px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ── page ───────────────────────────────────────────────── */
.page {
  width: min(1180px, 100% - 2 * clamp(20px, 4vw, 40px));
  margin-inline: auto;
  padding-bottom: 64px;
}

.page-head { padding: clamp(44px, 6vw, 76px) 0 0; }

.page-head h1 {
  margin: 0;
  font-size: clamp(2.5rem, 4.6vw, 3.5rem);
  font-weight: 600;
  line-height: 1.08;
  letter-spacing: -.025em;
}

.page-head p {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 15px;
}

.tabs {
  display: inline-flex;
  gap: 2px;
  max-width: 100%;
  margin-top: clamp(22px, 3vw, 30px);
  padding: 4px;
  border-radius: 980px;
  background: var(--pill-bg);
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar { display: none; }

.tab {
  flex: none;
  padding: 7px 17px;
  border: 0;
  border-radius: 980px;
  background: none;
  color: var(--text);
  font-size: 14px;
  line-height: 1.4;
  white-space: nowrap;
  cursor: pointer;
  transition: background .2s ease, color .2s ease;
}

.tab:hover { background: color-mix(in srgb, var(--text) 6%, transparent); }

.tab[aria-selected="true"] {
  background: var(--pill-active-bg);
  color: var(--pill-active-text);
}

/* ── grid ───────────────────────────────────────────────── */
.grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(44px, 5vw, 68px) clamp(18px, 2.2vw, 28px);
  margin-top: clamp(36px, 4.5vw, 52px);
}

.item {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.tile {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 20px;
  background:
    radial-gradient(62% 62% at 50% 54%, color-mix(in srgb, var(--accent) 8%, transparent), transparent 72%),
    var(--tile);
  box-shadow: var(--tile-shadow);
  overflow: hidden;
  transition: transform .45s cubic-bezier(.2, .8, .2, 1), box-shadow .45s ease;
}

.tile:hover {
  transform: translateY(-2px);
  box-shadow: var(--tile-shadow-hover);
}

.app-icon {
  position: relative;
  display: grid;
  place-items: center;
  width: clamp(84px, 9vw, 104px);
  height: clamp(84px, 9vw, 104px);
  border-radius: 23%;
  background: linear-gradient(
    160deg,
    color-mix(in srgb, var(--accent) 84%, white),
    color-mix(in srgb, var(--accent) 92%, black)
  );
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .38),
    0 14px 30px -14px color-mix(in srgb, var(--accent) 65%, transparent);
  transition: transform .45s cubic-bezier(.2, .8, .2, 1);
}

.tile:hover .app-icon { transform: scale(1.035); }

.app-icon svg {
  width: 46%;
  height: 46%;
  fill: none;
  stroke: #fff;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 17px;
  margin: 24px 0 0;
  color: var(--faint);
  font-size: 12px;
  line-height: 1.4;
}

.state.is-empty { visibility: hidden; }

.state i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--unknown);
}

.state[data-state="online"] i {
  background: var(--ok);
}

.state[data-state="offline"] i {
  background: var(--bad);
}

.state .sep { opacity: .55; }
.state .lock { display: inline-flex; align-items: center; gap: 4px; }
.state .lock svg { width: 10px; height: 10px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }

.item h2 {
  margin: 8px 0 0;
  font-size: clamp(20px, 1.9vw, 26px);
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -.015em;
}

.desc {
  max-width: 32ch;
  min-height: 3em;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.5;
}

.actions {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-top: 17px;
}

.btn {
  display: inline-block;
  padding: 8px 20px;
  border-radius: 980px;
  background: var(--blue);
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  transition: background .2s ease;
}

.btn:hover { background: var(--blue-hover); }

.link {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: var(--blue);
  font-size: 14px;
}

.link svg {
  width: 11px;
  height: 11px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.empty {
  padding: 64px 0;
  color: var(--faint);
  font-size: 15px;
  text-align: center;
}

/* ── footer ─────────────────────────────────────────────── */
.foot {
  margin-top: 24px;
  border-top: 1px solid var(--line);
}

.foot p {
  width: min(1180px, 100% - 2 * clamp(20px, 4vw, 40px));
  margin: 0 auto;
  padding: 22px 0 30px;
  color: var(--faint);
  font-size: 12px;
}

/* ── responsive ─────────────────────────────────────────── */
@media (max-width: 1000px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .nav-inner { height: 48px; }
  .grid { grid-template-columns: 1fr; gap: 46px; }
  .page-head h1 { font-size: 2.35rem; }
  .desc { max-width: 34ch; }
  .tile { border-radius: 18px; }
  .app-icon { width: 88px; height: 88px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; }
}
