:root {
  --background: #f4f4f5;
  --surface: #ffffff;
  --text: #18181b;
  --muted: #71717a;
  --line: #e4e4e7;
  --accent: #18181b;
  --radius: 24px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html,
body { min-height: 100%; }

body {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: max(24px, env(safe-area-inset-top)) 18px max(24px, env(safe-area-inset-bottom));
  color: var(--text);
  background: var(--background);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; }

.download-card {
  width: min(100%, 390px);
  padding: 36px 24px 22px;
  background: var(--surface);
  border: 1px solid rgba(24, 24, 27, 0.06);
  border-radius: var(--radius);
  box-shadow: 0 18px 50px rgba(24, 24, 27, 0.08);
}

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

.logo-box,
.loading-logo {
  display: grid;
  place-items: center;
  width: 88px;
  height: 88px;
  padding: 4px;
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 22px;
}

.logo-box img,
.loading-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 18px;
}

.brand p {
  margin-top: 18px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.download-options {
  display: grid;
  gap: 12px;
  margin-top: 30px;
}

.download-btn {
  position: relative;
  width: 100%;
  min-height: 72px;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 13px 16px;
  color: var(--text);
  text-align: left;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 17px;
  cursor: pointer;
  transition: border-color 160ms ease, background-color 160ms ease, transform 160ms ease;
}

.platform-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 13px;
}

.android-icon { background: #edf9f1; }
.ios-icon { background: #f1f1f3; }

.platform-icon img {
  width: 23px;
  height: 23px;
  object-fit: contain;
}

.platform-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.platform-copy strong {
  font-size: 15px;
  font-weight: 650;
  line-height: 1.2;
}

.platform-copy small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
}

.button-arrow {
  color: #a1a1aa;
  font-size: 28px;
  font-weight: 300;
  line-height: 1;
}

.platform-badge {
  position: absolute;
  top: -8px;
  right: 14px;
  display: none;
  padding: 4px 8px;
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  line-height: 1;
  background: var(--accent);
  border-radius: 999px;
}

.download-btn.is-recommended .platform-badge { display: block; }

.download-btn.is-loading {
  pointer-events: none;
  opacity: 0.65;
}

.download-btn.is-loading .platform-copy strong { font-size: 0; }

.download-btn.is-loading .platform-copy strong::after {
  content: "正在打开…";
  font-size: 15px;
}

.page-note {
  margin-top: 22px;
  color: #a1a1aa;
  font-size: 11px;
  text-align: center;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--background);
}

.loading-overlay[hidden] { display: none; }

.loading-panel {
  width: min(100%, 320px);
  text-align: center;
}

.loading-logo { margin: 0 auto; }

.loading-panel h1 {
  margin-top: 20px;
  font-size: 19px;
  font-weight: 650;
}

.loading-panel p {
  min-height: 22px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.loading-progress {
  height: 3px;
  margin: 22px auto 0;
  overflow: hidden;
  background: #dedee3;
  border-radius: 999px;
}

.loading-progress span {
  display: block;
  width: 36%;
  height: 100%;
  background: var(--accent);
  border-radius: inherit;
  animation: loading-progress 1.2s ease-in-out infinite;
}

#loadingRetry {
  display: none;
  width: 100%;
  min-height: 48px;
  margin-top: 20px;
  color: #fff;
  font-weight: 650;
  background: var(--accent);
  border: 0;
  border-radius: 14px;
  cursor: pointer;
}

.loading-panel.is-error .loading-progress { display: none; }
.loading-panel.is-error #loadingRetry { display: block; }

@media (hover: hover) and (pointer: fine) {
  .download-btn:hover {
    background: #fafafa;
    border-color: #d4d4d8;
    transform: translateY(-1px);
  }
}

.download-btn:active { transform: scale(0.985); }

.download-btn:focus-visible,
#loadingRetry:focus-visible {
  outline: 3px solid rgba(24, 24, 27, 0.2);
  outline-offset: 3px;
}

@keyframes loading-progress {
  from { transform: translateX(-110%); }
  to { transform: translateX(285%); }
}

@media (max-width: 380px) {
  .download-card { padding: 30px 18px 20px; }
}

@media (prefers-reduced-motion: reduce) {
  .download-btn,
  .loading-progress span {
    transition: none;
    animation: none;
  }
}
