/* 基础布局：外壳、邀请横幅、入口卡片与提示，所有视觉取值来自 theme.css 中的变量 */
:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  --font-display: var(--font-sans);
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --radius-shell: 28px;
  --radius-card: 18px;
  --radius-chip: 999px;
  --radius-button: 10px;
  --border-width: 1px;
  --duration: .2s;
  --ease: cubic-bezier(.16, 1, .3, 1);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

button {
  font: inherit;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  color: var(--ink);
  background: var(--bg);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

body.has-invite-modal {
  overflow: hidden;
}

a {
  color: inherit;
}

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

/* ---------- 顶部线路检测 ---------- */
.hero {
  position: fixed;
  top: 20px;
  left: 50%;
  z-index: 10;
  display: flex;
  justify-content: center;
  width: min(1040px, calc(100% - 32px));
  transform: translateX(-50%);
  pointer-events: none;
}

.hero-inner {
  padding: 8px 16px;
  border: var(--border-width) solid var(--line);
  border-radius: var(--radius-chip);
  background: var(--chip-bg);
  box-shadow: var(--shadow-chip, none);
}

.latency-text {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
}

/* 浅色 / 深色切换：与客户端右上角的月亮按钮一致，桌面端对齐外壳右缘 */
.theme-toggle {
  position: fixed;
  top: 20px;
  right: max(16px, calc(50% - 520px));
  z-index: 11;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: var(--border-width) solid var(--line);
  border-radius: 50%;
  color: var(--ink);
  background: var(--hero-chip-bg, var(--chip-bg));
  box-shadow: var(--shadow-chip, none);
  cursor: pointer;
  transition: transform var(--duration) var(--ease), color var(--duration) ease;
}

.theme-toggle:hover {
  color: var(--eyebrow);
}

.theme-toggle:active {
  transform: scale(.92);
}

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

.theme-toggle svg {
  width: 18px;
  height: 18px;
}

.theme-toggle .icon-sun,
[data-theme="dark"] .theme-toggle .icon-moon {
  display: none;
}

[data-theme="dark"] .theme-toggle .icon-sun {
  display: block;
}

/* ---------- 外壳 ---------- */
.page {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  width: min(1040px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 88px 0 32px;
}

.shell {
  position: relative;
  border: var(--border-width) solid var(--line);
  border-radius: var(--radius-shell);
  background: var(--shell-bg);
  box-shadow: var(--shadow-shell);
  overflow: hidden;
}

.card-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 32px 32px 24px;
}

.brand-lockup {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: start;
  gap: 18px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: calc(var(--radius-card) - 2px);
  color: var(--brand-ink);
  background: var(--brand-bg);
  box-shadow: var(--brand-shadow, none);
}

.brand-mark svg {
  width: 30px;
  height: 30px;
}

.eyebrow {
  margin: 2px 0 8px;
  color: var(--eyebrow, var(--muted));
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .12em;
}

h1 {
  margin: 0;
  color: var(--ink-strong, var(--ink));
  font-family: var(--font-display);
  font-size: clamp(28px, 2rem + 1.6vw, 46px);
  line-height: 1.08;
}

.card-lead {
  max-width: 560px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.75;
}

.status-stack {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  max-width: 230px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  padding: 6px 12px;
  border: var(--border-width) solid var(--line);
  border-radius: var(--radius-chip);
  color: var(--ink);
  background: var(--chip-bg);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--live);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--live) 22%, transparent);
  animation: live-pulse 2.4s ease-in-out infinite;
}

@keyframes live-pulse {
  50% { box-shadow: 0 0 0 7px color-mix(in srgb, var(--live) 0%, transparent); }
}

/* ---------- 邀请横幅 ---------- */
.invite-banner {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, .85fr);
  align-items: center;
  gap: 28px;
  padding: 24px 32px;
  border-block: var(--border-width) solid var(--invite-line);
  background: var(--invite-bg);
  overflow: hidden;
}

.invite-offer {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 18px;
}

.invite-icon {
  position: relative;
  display: grid;
  place-items: center;
  width: 60px;
  height: 60px;
  border: var(--border-width) solid var(--invite-line);
  border-radius: calc(var(--radius-card) - 2px);
  color: var(--invite-accent);
  background: var(--invite-icon-bg);
}

.invite-icon svg {
  width: 28px;
  height: 28px;
}

.invite-icon-badge {
  position: absolute;
  right: -8px;
  bottom: -7px;
  min-width: 34px;
  padding: 4px 6px;
  border-radius: var(--radius-chip);
  color: var(--gold-ink);
  background: var(--gold);
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
}

.invite-copy {
  min-width: 0;
}

.invite-eyebrow {
  margin: 0 0 6px;
  color: var(--invite-accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
}

.invite-copy h2 {
  margin: 0;
  color: var(--ink-strong, var(--ink));
  font-family: var(--font-display);
  font-size: 24px;
  line-height: 1.3;
}

.invite-copy h2 strong {
  color: var(--gold-text, var(--gold));
}

.invite-copy p:last-child {
  max-width: 500px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

.invite-ticket {
  position: relative;
  display: grid;
  gap: 10px;
  min-width: 0;
  padding: 15px 16px 13px 20px;
  border: var(--border-width) solid var(--invite-line);
  border-left-style: dashed;
  border-radius: var(--radius-card);
  background: var(--ticket-bg);
  box-shadow: var(--shadow-card);
}

.invite-ticket-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.invite-reward-badge {
  padding: 3px 8px;
  border-radius: var(--radius-chip);
  color: var(--gold-text, var(--gold));
  background: color-mix(in srgb, var(--gold) 16%, transparent);
  white-space: nowrap;
}

.invite-code-group {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 42px;
}

.invite-code-group code {
  min-width: 0;
  overflow: hidden;
  color: var(--ink-strong, var(--ink));
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: .06em;
  text-overflow: ellipsis;
  white-space: nowrap;
  user-select: all;
}

.invite-copy-button,
.invite-modal-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: var(--border-width) solid var(--primary-line, transparent);
  border-radius: var(--radius-button);
  color: var(--primary-ink);
  background: var(--primary-bg);
  box-shadow: var(--shadow-button, none);
  cursor: pointer;
  font-weight: 800;
  transition: transform var(--duration) var(--ease), background var(--duration) ease, box-shadow var(--duration) ease;
}

.invite-copy-button {
  min-width: 72px;
  min-height: 36px;
  padding: 7px 12px;
  font-size: 12px;
}

.invite-copy-button:hover,
.invite-modal-primary:hover {
  background: var(--primary-bg-hover);
  box-shadow: var(--shadow-button-hover, var(--shadow-button, none));
}

.invite-copy-button:active,
.invite-modal-primary:active {
  transform: translateY(1px);
}

.invite-copy-button:focus-visible,
.invite-modal-primary:focus-visible,
.invite-modal-close:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.invite-copy-button svg {
  width: 15px;
  height: 15px;
}

.invite-ticket-note {
  margin: 0;
  color: var(--faint);
  font-size: 11px;
}

/* ---------- 入口区 ---------- */
.content {
  display: grid;
  gap: 18px;
  padding: 24px;
}

.access-panel {
  scroll-margin-top: 80px;
}

.panel {
  padding: 20px;
  border: var(--border-width) solid var(--line-soft, var(--line));
  border-radius: calc(var(--radius-shell) - 6px);
  background: var(--panel-bg);
}

.section-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.section-title h2 {
  margin: 0;
  color: var(--ink-strong, var(--ink));
  font-family: var(--font-display);
  font-size: 22px;
}

.section-title p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.tag {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 10px;
  border: var(--border-width) solid var(--line);
  border-radius: var(--radius-chip);
  color: var(--muted);
  background: var(--chip-bg);
  font-size: 12px;
  font-weight: 700;
}

.tag::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--live);
}

.access-list,
.service-list {
  display: grid;
  gap: 14px;
}

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

.service-list {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.link-card {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  min-height: 104px;
  padding: 16px;
  border: var(--border-width) solid var(--card-line, var(--line));
  border-radius: var(--radius-card);
  background: var(--card-bg);
  box-shadow: var(--shadow-card);
  text-decoration: none;
  overflow: hidden;
  cursor: pointer;
  transition:
    transform var(--duration) var(--ease),
    border-color var(--duration) ease,
    background var(--duration) ease,
    box-shadow var(--duration) ease;
}

.link-card:hover,
.link-card:focus-visible {
  transform: var(--card-hover-transform, translateY(-3px));
  border-color: var(--accent-line);
  background: var(--card-bg-hover, var(--card-bg));
  box-shadow: var(--shadow-hover);
  outline: none;
}

.link-card:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

.link-card:active {
  transform: translateY(0);
}

.card-icon,
.notice-icon,
.arrow {
  flex: 0 0 auto;
}

.card-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: calc(var(--radius-card) - 4px);
  color: var(--accent);
  background: var(--accent-bg);
  box-shadow: inset 0 0 0 var(--border-width) var(--accent-line);
}

.copy {
  min-width: 0;
}

.link-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  color: var(--ink-strong, var(--ink));
  font-size: 18px;
  font-weight: 800;
}

.recommend,
.limited {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-chip);
  font-size: 11px;
  font-weight: 800;
}

.recommend {
  color: var(--recommend-ink, var(--accent));
  background: var(--recommend-bg, var(--accent-bg));
}

.limited {
  color: var(--gold-text, var(--gold));
  background: color-mix(in srgb, var(--gold) 14%, transparent);
}

.link-desc {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.version-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
}

.version-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 9px;
  border: var(--border-width) solid var(--line-soft, var(--line));
  border-radius: var(--radius-chip);
  color: var(--muted);
  background: var(--chip-bg);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
}

.link-card.is-loading .version-pill {
  color: var(--faint);
}

.arrow {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  color: var(--muted);
  background: var(--chip-bg);
  transition: transform var(--duration) var(--ease), color var(--duration) ease, background var(--duration) ease;
}

.link-card:hover .arrow,
.link-card:focus-visible .arrow {
  color: var(--accent-contrast, var(--bg));
  background: var(--accent);
  transform: translateX(3px);
}

.arrow svg {
  width: 18px;
  height: 18px;
}

.android {
  --accent: var(--c-android);
}

.windows {
  --accent: var(--c-windows);
}

.web {
  --accent: var(--c-web);
}

.telegram {
  --accent: var(--c-telegram);
}

.vpn {
  --accent: var(--c-vpn);
}

.link-card {
  --accent-bg: color-mix(in srgb, var(--accent) var(--accent-bg-mix, 12%), transparent);
  --accent-line: color-mix(in srgb, var(--accent) var(--accent-line-mix, 40%), transparent);
}

/* ---------- 提示与页脚 ---------- */
.notice {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: start;
  gap: 14px;
  margin: 0 24px 24px;
  padding: 16px 18px;
  border: var(--border-width) solid var(--line-soft, var(--line));
  border-radius: var(--radius-card);
  color: var(--muted);
  background: var(--panel-bg);
  font-size: 14px;
  line-height: 1.75;
}

.notice-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: calc(var(--radius-card) - 6px);
  color: var(--c-windows);
  background: color-mix(in srgb, var(--c-windows) 12%, transparent);
}

.notice strong {
  color: var(--ink-strong, var(--ink));
}

.notice p {
  margin: 0;
}

footer {
  padding: 24px 0 0;
  color: var(--faint);
  font-size: 13px;
  text-align: center;
}

.site-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  z-index: 60;
  width: min(520px, calc(100% - 32px));
  padding: 12px 16px;
  border: var(--border-width) solid var(--toast-line, var(--line));
  border-radius: var(--radius-button);
  color: var(--toast-ink, var(--ink));
  background: var(--toast-bg);
  box-shadow: var(--shadow-modal);
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
  transform: translateX(-50%);
  animation: toast-in .3s var(--ease);
}

.site-toast[data-tone="error"] {
  border-color: var(--danger);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, 10px);
  }
}

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