:root {
  --bg: #f5f5f7;
  --surface: #fff;
  --text: #1d1d1f;
  --muted: #626670;
  --brand: #0071e3;
  --brand-hover: #005bb5;
  --brand-soft: #edf5ff;
  --brand-line: #c7dffb;
  --line: #e4e6eb;
  --warning-bg: #fff8ed;
  --warning-text: #785121;
  --warning-line: #f3dfb9;
  --danger-bg: #fff1ef;
  --danger-text: #a0271c;
  --danger-line: #ffd9d2;
  --shadow-card: 0 1px 3px rgba(16, 24, 40, 0.04);
  --shadow-dialog: 0 24px 80px rgba(23, 44, 70, 0.22);
  --radius: 20px;
  --radius-sm: 12px;
  --space: 24px;
  --motion: 160ms;
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: radial-gradient(900px 420px at 50% -120px, #e8f1ff 0%, transparent 70%), var(--bg);
  color: var(--text);
  font: 15px/1.7 var(--font-ui);
  -webkit-font-smoothing: antialiased;
}

button, input, summary { font: inherit; }
button, a, summary { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
a { color: var(--brand); text-underline-offset: 3px; }
button, a { transition: background var(--motion), color var(--motion), border-color var(--motion), transform var(--motion); }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 4px; }

.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 10;
  padding: 12px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  transform: translateY(-200%);
}
.skip-link:focus { transform: translateY(0); }

[hidden] { display: none !important; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { line-height: 1.35; text-wrap: balance; }

.page {
  display: grid;
  gap: var(--space);
  width: min(960px, calc(100% - 48px));
  margin: auto;
  padding: 32px 0 56px;
}

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

.block, .intro { padding: 28px; }

/* Intro */
.intro-top, .intro-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.intro-label {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-hover);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
}

.intro-help {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
}
.intro-help:hover { text-decoration: underline; }

.intro-heading { margin-top: 16px; align-items: flex-end; }
.intro h1 { font-size: 32px; font-weight: 700; line-height: 1.22; letter-spacing: -0.03em; }
.intro-description { margin-top: 10px; color: var(--muted); }

.intro-action, .dialog-button, .cta, .gate-cancel, .retry-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 44px;
  padding: 10px 20px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.5;
  cursor: pointer;
  text-decoration: none;
}

.intro-action, .dialog-button {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 4px 12px rgba(0, 113, 227, 0.2);
}
.intro-action { flex: none; }
.intro-action:hover, .dialog-button:hover:not(:disabled) { background: var(--brand-hover); }
.intro-action:active, .dialog-button:active:not(:disabled) { transform: translateY(1px); }

.gate-cancel, .retry-button {
  background: var(--bg);
  color: var(--text);
  border-color: var(--line);
}
.gate-cancel:hover, .retry-button:hover { background: var(--line); }

.dialog-button:disabled {
  background: #e6e8ed;
  color: #626670;
  box-shadow: none;
  cursor: not-allowed;
}

.usage-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 24px;
  margin: 24px 0 0;
  padding: 24px 0;
  border-top: 1px solid var(--line);
  list-style: none;
}
.usage-steps li { display: flex; align-items: flex-start; gap: 12px; min-width: 0; }

.step-number {
  flex: none;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--brand-soft);
  color: var(--brand-hover);
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.usage-steps h2 { font-size: 14px; font-weight: 600; line-height: 1.5; }
.usage-steps p { margin-top: 4px; color: var(--muted); font-size: 13px; }

.safety-note {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 16px;
  border: 1px solid var(--warning-line);
  border-radius: var(--radius-sm);
  background: var(--warning-bg);
  color: var(--warning-text);
}
.safety-note svg { flex: none; margin-top: 2px; }
.safety-note p { font-size: 13px; }

/* Promo */
.promo-shell { overflow: hidden; }

.store-feature {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
  padding: 28px;
  background: linear-gradient(120deg, #eff5ff 0%, #edeafc 100%);
}
.store-copy { max-width: 580px; min-width: 0; }
.eyebrow { margin-bottom: 8px; color: #536994; font-size: 12px; font-weight: 600; letter-spacing: 0.04em; }
.promo-title { color: #1e3159; font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.promo-copy { margin-top: 10px; color: #51627d; font-size: 14px; }

.store-art {
  flex: none;
  display: block;
  width: 112px;
  height: 112px;
  border-radius: 24px;
  border: 2px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 12px 28px rgba(48, 62, 118, 0.16);
}

.store-product {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px 28px;
  border-top: 1px solid var(--line);
}
.store-icon {
  display: block;
  flex: none;
  width: 48px;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.store-details { flex: 1; min-width: 0; }
.promo-name { font-size: 18px; font-weight: 600; overflow-wrap: anywhere; }
.promo-meta { margin-top: 2px; color: var(--muted); font-size: 13px; }
.store-buy { display: flex; flex: none; flex-direction: column; align-items: center; gap: 4px; }
.cta { background: var(--brand-soft); color: var(--brand-hover); min-width: 96px; border-radius: 999px; }
.cta:hover { background: #dce9ff; }
.store-buy > span { color: var(--muted); font-size: 12px; }

/* Sections */
.section-head { display: grid; gap: 8px; margin-bottom: 20px; }
.section-title { display: flex; align-items: center; gap: 10px; font-size: 21px; font-weight: 700; }
.section-title svg { flex: none; }
.section-copy { color: var(--muted); font-size: 14px; }

/* Account gate & iframe */
.account-shell {
  position: relative;
  min-height: 240px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg);
}
.embed-frame {
  display: block;
  width: 100%;
  height: 240px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.account-shell.is-locked .embed-frame { visibility: hidden; pointer-events: none; }

.account-gate {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px;
  text-align: center;
  background: var(--brand-soft);
  border: 1px dashed var(--brand-line);
  border-radius: var(--radius-sm);
}
.gate-lock-badge {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--surface);
  color: var(--brand);
  border: 1px solid var(--brand-line);
}
.account-gate p { color: var(--muted); font-size: 14px; }

.frame-feedback {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 16px;
}
.frame-feedback p {
  flex: 1 1 220px;
  color: var(--muted);
  font-size: 13px;
}

/* FAQ */
.faq-list {
  display: grid;
  gap: 14px;
}
.faq-item {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  transition: border-color var(--motion);
}
.faq-item:hover, .faq-item[open] {
  border-color: #cfd6e0;
}

.faq-item summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 60px;
  padding: 18px 20px;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.5;
  cursor: pointer;
  list-style: none;
}
.faq-item summary:hover { color: var(--brand); }
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after {
  content: "";
  flex: 0 0 8px;
  width: 8px;
  height: 8px;
  margin-right: 4px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg);
  transition: transform var(--motion) ease;
}
.faq-item[open] summary::after { transform: rotate(225deg); }

.faq-content { padding: 0 20px 20px; color: var(--muted); }
.faq-content img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 16px;
}
.faq-steps { margin: 0; padding-left: 22px; }
.faq-steps li + li { margin-top: 8px; }

.tutorial-login-note {
  margin-bottom: 16px;
  padding: 14px 16px;
  border: 1px solid var(--warning-line);
  border-radius: var(--radius-sm);
  background: var(--warning-bg);
  color: var(--warning-text);
  font-size: 14px;
}

.tutorial-continue {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  padding: 18px 20px;
  border: 1px solid var(--brand-line);
  border-radius: var(--radius-sm);
  background: var(--brand-soft);
}
.tutorial-continue p { font-weight: 500; color: var(--text); }

#shared-accounts, #faq, #login-tutorial { scroll-margin-top: 24px; }

/* Dialog */
.dialog {
  position: fixed;
  inset: 0;
  width: min(560px, calc(100% - 32px));
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  margin: auto;
  padding: 0;
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  background: var(--surface);
  box-shadow: var(--shadow-dialog);
}
.dialog::backdrop {
  background: rgba(24, 38, 60, 0.45);
  backdrop-filter: blur(6px);
}
body:has(dialog[open]) { overflow: hidden; }
.dialog-body { padding: 28px; }

.gate-progress {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  color: var(--brand);
  font-size: 13px;
  font-weight: 600;
}
.gate-steps { display: flex; gap: 6px; }
.gate-steps span {
  width: 22px;
  height: 5px;
  border-radius: 999px;
  background: var(--line);
}
.gate-steps span.is-done { background: #8ec3fa; }
.gate-steps span.is-current { background: var(--brand); }

.dialog-title:focus { outline: none; }
.dialog-title { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }

.gate-warning {
  margin: 18px 0;
  padding: 16px;
  border: 1px solid var(--danger-line);
  border-radius: var(--radius-sm);
  color: var(--danger-text);
  background: var(--danger-bg);
  font-size: 14px;
  line-height: 1.75;
}
.gate-intro { color: var(--muted); font-size: 14px; margin-bottom: 16px; }

.gate-place {
  display: grid;
  gap: 6px;
  padding: 16px;
  border: 1px solid var(--brand-line);
  background: var(--brand-soft);
  color: #1459a1;
  border-radius: var(--radius-sm);
  font-size: 14px;
}
.gate-place span { font-size: 13px; }

.gate-check {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 14px;
  cursor: pointer;
  transition: background var(--motion), border-color var(--motion);
}
.gate-check:has(input:checked) {
  background: var(--brand-soft);
  border-color: var(--brand);
}
.gate-check input {
  width: 20px;
  height: 20px;
  flex: none;
  margin: 3px 0 0;
  accent-color: var(--brand);
}

.gate-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 24px;
}

@media (max-width: 600px) {
  :root { --space: 16px; --radius: 16px; }
  .page { width: calc(100% - 32px); padding: 16px 0 max(32px, env(safe-area-inset-bottom)); }
  .block, .intro { padding: 20px; }
  .intro-top { gap: 12px; }
  .intro-label { font-size: 11px; letter-spacing: 0.04em; }
  .intro-heading { align-items: stretch; flex-direction: column; gap: 20px; }
  .intro h1 { font-size: 28px; }
  .desktop-break { display: none; }
  .usage-steps { grid-template-columns: 1fr; gap: 16px; padding: 20px 0; margin-top: 20px; }
  .usage-steps h2 { font-size: 15px; }
  .usage-steps p { font-size: 14px; }
  .safety-note { padding: 12px; }
  .store-feature { align-items: flex-start; gap: 16px; padding: 20px; }
  .store-art { width: 64px; height: 64px; border-radius: 16px; }
  .promo-title { font-size: 23px; }
  .store-product { flex-wrap: wrap; padding: 20px; gap: 12px; }
  .store-buy { flex-basis: 100%; flex-direction: row; align-items: center; justify-content: space-between; }
  .promo-name { font-size: 17px; }
  .section-title { font-size: 20px; }
  .account-gate { padding: 20px; }
  .faq-item { border-radius: 14px; }
  .faq-item summary { padding: 16px; }
  .faq-content { padding: 0 16px 16px; }
  .tutorial-continue { flex-direction: column; align-items: stretch; }
  .dialog-body { padding: 22px 20px; }
  .dialog-title { font-size: 22px; }
  .gate-actions { flex-direction: column-reverse; gap: 10px; margin-top: 20px; }
  .gate-actions button { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  button, a, .faq-item summary::after { transition: none; }
}
