:root {
  --bg: #f5f8fa;
  --surface: #ffffff;
  --surface-warm: var(--surface);
  --fg: #16222c;
  --fg-2: var(--fg);
  --muted: #647481;
  --meta: var(--muted);
  --border: #dbe4ea;
  --border-soft: var(--border);
  --accent: #00aeec;
  --accent-on: #ffffff;
  --accent-hover: #009bd4;
  --accent-active: #0089bc;
  --brand-detail: #fb7299;
  --success: #17845f;
  --warn: #eab308;
  --danger: #c6424f;
  --font-display: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --font-body: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  --font-mono: ui-monospace, "JetBrains Mono", "SFMono-Regular", Menlo, Consolas, monospace;
  --text-xs: 12px;
  --text-sm: 14px;
  --text-base: 16px;
  --text-lg: 20px;
  --text-xl: 24px;
  --text-2xl: 32px;
  --text-3xl: 48px;
  --text-4xl: 64px;
  --leading-body: 1.55;
  --leading-tight: 1.2;
  --tracking-display: 0;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-12: 48px;
  --space-20: 80px;
  --section-y-desktop: 80px;
  --section-y-tablet: 48px;
  --section-y-phone: 32px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-pill: 9999px;
  --elev-flat: none;
  --elev-ring: 0 0 0 1px var(--border);
  --elev-raised: 0 2px 8px color-mix(in oklab, var(--fg), transparent 92%);
  --focus-ring: 0 0 0 3px color-mix(in oklab, var(--accent), transparent 70%);
  --motion-fast: 150ms;
  --motion-base: 200ms;
  --ease-standard: cubic-bezier(0.2, 0, 0, 1);
  --container-max: 1120px;
  --container-gutter-desktop: 24px;
  --container-gutter-tablet: 16px;
  --container-gutter-phone: 12px;
}

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

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

body {
  min-width: 320px;
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: var(--text-base);
  letter-spacing: 0;
  line-height: var(--leading-body);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: var(--accent-active); }
p { text-wrap: pretty; }
h1, h2, h3 { font-family: var(--font-display); text-wrap: balance; }

.skip-link {
  position: fixed;
  top: var(--space-4);
  left: var(--space-4);
  z-index: 40;
  padding: 10px var(--space-4);
  border-radius: var(--radius-sm);
  background: var(--fg);
  color: var(--surface);
  transform: translateY(-180%);
}

.skip-link:focus { transform: translateY(0); }

.page-shell {
  width: min(var(--container-max), 100%);
  min-height: 100dvh;
  margin-inline: auto;
  padding: 0 var(--container-gutter-desktop) var(--space-20);
}

.page-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  min-height: 64px;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  background: color-mix(in oklch, var(--bg) 94%, transparent);
  backdrop-filter: blur(12px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--fg);
  font-weight: 600;
  text-decoration: none;
}

.brand-mark {
  position: relative;
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--accent-on);
  font-size: 17px;
  font-weight: 700;
  box-shadow: var(--elev-raised);
}

.brand-mark::after {
  content: "";
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 7px;
  height: 7px;
  border: 2px solid var(--bg);
  border-radius: 50%;
  background: var(--brand-detail);
}

.time-note {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0;
}

.intro {
  max-width: 720px;
  padding-block: var(--space-12) var(--space-8);
}

.eyebrow, .step-kicker, .rail-label {
  display: block;
  margin: 0 0 var(--space-2);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0;
}

.intro h1, .message-page h1 {
  margin: 0;
  font-size: 42px;
  font-weight: 600;
  letter-spacing: var(--tracking-display);
  line-height: var(--leading-tight);
}

.intro p {
  max-width: 58ch;
  margin: var(--space-3) 0 0;
  color: var(--muted);
  font-size: var(--text-base);
}

.setup-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: var(--space-8);
  align-items: start;
}

.step-rail {
  position: sticky;
  top: 88px;
  min-width: 0;
}

.rail-label { margin-bottom: var(--space-4); }

.progress ol {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.progress li {
  position: relative;
  display: grid;
  min-height: 44px;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: var(--space-3);
  align-items: center;
  color: var(--muted);
  font-size: var(--text-sm);
}

.progress li:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 38px;
  bottom: -12px;
  left: 15px;
  width: 1px;
  background: var(--border);
}

.progress li span {
  position: relative;
  z-index: 1;
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--bg);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 600;
}

.progress li b {
  min-width: 0;
  font-weight: 500;
}

.progress li.is-current { color: var(--fg); }
.progress li.is-current b { font-weight: 650; }
.progress li.is-current span {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-on);
  box-shadow: 0 0 0 4px color-mix(in oklab, var(--accent), transparent 84%);
}

.progress li.is-done { color: var(--fg); }
.progress li.is-done span {
  border-color: color-mix(in oklab, var(--success), var(--border) 35%);
  background: color-mix(in oklab, var(--success), var(--surface) 91%);
  color: var(--success);
}

.progress li.is-done:not(:last-child)::after {
  background: color-mix(in oklab, var(--success), var(--border) 45%);
}

.setup-main { min-width: 0; }

.workflow {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--elev-raised);
}

.workflow-wrap { margin-top: var(--space-5); }

.task-step {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: var(--space-4);
  padding: 18px var(--space-6);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  transition: padding var(--motion-base) var(--ease-standard), background var(--motion-base) var(--ease-standard);
}

.task-step:last-child { border-bottom: 0; }

.task-step.is-current {
  padding-block: 28px;
  border-inline-start: 3px solid var(--accent);
  background: color-mix(in oklab, var(--accent), var(--surface) 96%);
}

.task-step:not(.is-current) .task-content > p {
  margin-top: var(--space-1);
  color: color-mix(in oklab, var(--muted), var(--surface) 10%);
  font-size: 13px;
}

.task-step:not(.is-current) .task-content h2 {
  color: color-mix(in oklab, var(--fg), var(--muted) 34%);
  font-size: 18px;
}

.task-number {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 600;
}

.task-step.is-current .task-number {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-on);
  box-shadow: 0 5px 12px color-mix(in oklab, var(--accent), transparent 78%);
}

.task-step.is-done .task-number {
  border-color: color-mix(in oklab, var(--success), var(--border) 35%);
  background: color-mix(in oklab, var(--success), var(--surface) 91%);
  color: var(--success);
}

.task-state {
  display: block;
  margin-bottom: 2px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0;
}

.task-step.is-current .task-state { color: var(--accent-active); }

.task-content h2 {
  margin: 0;
  font-size: var(--text-lg);
  font-weight: 600;
  line-height: 1.35;
}

.task-content > p {
  max-width: 62ch;
  margin: 7px 0 0;
  color: var(--muted);
  font-size: var(--text-sm);
}

.action-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: var(--space-4);
}

.action-row.centered { justify-content: center; }

.button {
  appearance: none;
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 10px var(--space-4);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0;
  line-height: 1.4;
  text-align: center;
  text-decoration: none;
  transition: background var(--motion-fast) var(--ease-standard), border-color var(--motion-fast) var(--ease-standard), box-shadow var(--motion-fast) var(--ease-standard), transform var(--motion-fast) var(--ease-standard);
}

.button:hover { transform: translateY(-1px); }
.button:active { transform: translateY(1px); }
.button:focus-visible, input:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}
.button:disabled { cursor: wait; opacity: 0.64; transform: none; }
.button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-on);
  box-shadow: 0 4px 10px color-mix(in oklab, var(--accent), transparent 78%);
}
.button.primary:hover { background: var(--accent-hover); }
.button.primary:active { background: var(--accent-active); }
.button.secondary { border-color: var(--border); background: var(--surface); color: var(--fg); }
.button.secondary:hover { border-color: color-mix(in oklab, var(--fg), var(--border) 74%); background: var(--bg); }
.button.text { min-height: 40px; padding-inline: var(--space-2); background: transparent; color: var(--fg); }
.button.text:hover { color: var(--accent-active); }
.button.text[data-next-step]::after { content: "→"; margin-left: var(--space-1); font-size: var(--text-base); }
.button.danger {
  border-color: color-mix(in oklab, var(--danger), var(--border) 60%);
  background: color-mix(in oklab, var(--danger), var(--surface) 93%);
  color: var(--danger);
}
.button.full { width: 100%; }

.manual-help, .quick-notes, .danger-zone {
  color: var(--muted);
  font-size: 13px;
}

summary {
  border-radius: var(--radius-sm);
  color: var(--fg);
  cursor: pointer;
  font-weight: 600;
}

.manual-help { margin-top: var(--space-4); }
.manual-help summary { color: var(--muted); }
.manual-help ol { margin: 10px 0 0; padding-left: 20px; }
.manual-help li + li { margin-top: 5px; }

.field { margin-top: 18px; }
.field:first-child { margin-top: var(--space-4); }

.field-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: 7px;
}

.field-heading label { font-size: var(--text-sm); font-weight: 600; }
.field-heading span { color: var(--muted); font-size: var(--text-xs); }

input[type="text"], textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  background: var(--surface);
  color: var(--fg);
  transition: border-color var(--motion-fast) var(--ease-standard), box-shadow var(--motion-fast) var(--ease-standard);
}

input[type="text"] { min-height: 48px; padding: 10px 13px; }

textarea {
  min-height: 154px;
  padding: 13px;
  resize: vertical;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: var(--leading-body);
}

input[type="text"]:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}

input::placeholder, textarea::placeholder { color: color-mix(in oklab, var(--muted), transparent 22%); }

.field-help, .privacy-note {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: var(--text-xs);
}

.bound-code {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: var(--space-4);
  padding: 10px var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--muted);
  font-size: var(--text-xs);
}

.bound-code code {
  overflow-wrap: anywhere;
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
}

.inline-error {
  margin: var(--space-5);
  padding: 15px var(--space-4);
  border: 1px solid color-mix(in oklab, var(--danger), var(--border) 58%);
  border-radius: var(--radius-sm);
  background: color-mix(in oklab, var(--danger), var(--surface) 94%);
  color: var(--danger);
}

.inline-error strong { display: block; font-size: var(--text-base); }
.inline-error p { margin: var(--space-1) 0 0; font-size: 13px; }
.inline-error ol { margin: 9px 0 0; padding-left: 20px; font-size: 13px; }

.status-panel, .done-panel {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
  padding: var(--space-5);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.status-panel.success, .done-panel { border-color: color-mix(in oklab, var(--success), var(--border) 58%); }
.status-panel.danger { border-color: color-mix(in oklab, var(--danger), var(--border) 58%); }

.status-mark, .done-check {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  place-items: center;
  border-radius: 50%;
  background: color-mix(in oklab, var(--success), var(--surface) 88%);
  color: var(--success);
  font-size: 18px;
  font-weight: 700;
}

.status-panel.danger .status-mark {
  background: color-mix(in oklab, var(--danger), var(--surface) 90%);
  color: var(--danger);
}
.status-label { color: var(--success); font-size: var(--text-xs); font-weight: 600; }
.status-panel.danger .status-label { color: var(--danger); }
.status-panel h2, .done-panel h2 { margin: 1px 0 0; font-size: 18px; font-weight: 600; }
.status-panel p, .done-panel p { margin: 3px 0 0; color: var(--muted); font-size: 13px; }

.update-toggle { width: 100%; }

.quick-notes {
  margin-top: var(--space-6);
  padding-top: var(--space-5);
  border-top: 1px solid var(--border);
}

.quick-notes div, .danger-zone form { padding-top: 10px; }
.quick-notes p, .danger-zone p { margin: 5px 0; }

.danger-zone {
  margin-top: var(--space-5);
  padding: var(--space-4) 0;
  border-bottom: 1px solid var(--border);
}

.message-page {
  max-width: 680px;
  margin: var(--space-20) auto 0;
  padding: var(--space-8);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--elev-raised);
  text-align: center;
}

.message-mark {
  display: grid;
  width: 48px;
  height: 48px;
  margin: 0 auto var(--space-4);
  place-items: center;
  border-radius: 50%;
  background: var(--bg);
  color: var(--accent-active);
  font-size: var(--text-lg);
  font-weight: 700;
}

.message-page.success .message-mark { background: color-mix(in oklab, var(--success), var(--surface) 90%); color: var(--success); }
.message-page.danger .message-mark { background: color-mix(in oklab, var(--danger), var(--surface) 91%); color: var(--danger); }
.message-page p { max-width: 56ch; margin: var(--space-3) auto 0; color: var(--muted); }

.page-footer {
  display: flex;
  justify-content: space-between;
  gap: var(--space-5);
  margin-top: var(--space-12);
  padding-top: var(--space-5);
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: var(--text-xs);
}

.mobile-handoff {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: none;
  align-items: center;
  justify-content: center;
  padding: max(20px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  background: color-mix(in oklab, var(--fg), transparent 20%);
  backdrop-filter: blur(10px);
}

.mobile-handoff.show { display: flex; }

.mobile-handoff-card {
  width: min(390px, 100%);
  padding: 28px var(--space-6) var(--space-6);
  border: 1px solid color-mix(in oklab, var(--surface), transparent 50%);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: 0 24px 64px color-mix(in oklab, var(--fg), transparent 68%);
  text-align: left;
}

.mobile-step-number {
  display: grid;
  width: 44px;
  height: 44px;
  margin: 18px 0 var(--space-4);
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-on);
  font-family: var(--font-mono);
  font-size: var(--text-lg);
  font-weight: 700;
}

.mobile-action-icon {
  display: grid;
  width: 48px;
  height: 48px;
  margin: 18px 0 var(--space-4);
  place-items: center;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--accent-on);
  font-size: var(--text-lg);
  font-weight: 700;
}

.mobile-handoff-card h2 { margin: 0; font-size: var(--text-xl); font-weight: 600; line-height: 1.3; }
.mobile-handoff-card > p { margin: 9px 0 0; color: var(--muted); font-size: var(--text-sm); }
.mobile-handoff-card [data-mobile-default-view] > p,
.mobile-handoff-card [data-mobile-code-view] > p { margin: 9px 0 0; color: var(--muted); font-size: var(--text-sm); }
.mobile-url { margin: var(--space-5) 0 10px; font-family: var(--font-mono); font-size: var(--text-xs); }
.mobile-handoff-card .mobile-next { margin-top: var(--space-3); text-align: center; font-size: var(--text-xs); }

.mobile-delete-panel, .mobile-empty-panel {
  margin-top: var(--space-5);
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
}

.mobile-delete-panel > div {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-bottom: var(--space-3);
}

.mobile-delete-panel strong, .mobile-empty-panel strong {
  display: block;
  color: var(--fg);
  font-size: var(--text-sm);
  font-weight: 650;
}

.mobile-delete-panel span, .mobile-empty-panel span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: var(--text-xs);
  line-height: var(--leading-body);
}

.mobile-empty-panel {
  border-color: color-mix(in oklab, var(--success), var(--border) 62%);
  background: color-mix(in oklab, var(--success), var(--surface) 95%);
}

.mobile-update-divider {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-5);
  color: var(--muted);
  font-size: var(--text-xs);
}

.mobile-update-divider::before, .mobile-update-divider::after {
  content: "";
  height: 1px;
  flex: 1;
  background: var(--border);
}

.mobile-update-divider + .mobile-url { margin-top: var(--space-4); }

.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  z-index: 40;
  max-width: min(380px, calc(100vw - 32px));
  padding: 10px var(--space-4);
  border-radius: var(--radius-sm);
  background: var(--fg);
  color: var(--surface);
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 18px);
  transition: opacity var(--motion-base) var(--ease-standard), transform var(--motion-base) var(--ease-standard);
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); }

[hidden] { display: none !important; }

@media (max-width: 820px) {
  .page-shell { padding-inline: var(--container-gutter-tablet); }
  .intro { padding-block: var(--space-8) var(--space-6); }
  .setup-layout { grid-template-columns: 1fr; gap: var(--space-5); }
  .step-rail { position: static; }
  .rail-label { margin-bottom: var(--space-3); }
  .progress {
    padding: var(--space-4);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
  }
  .progress ol { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; }
  .progress li {
    display: flex;
    min-height: 52px;
    flex-direction: column;
    gap: 5px;
    font-size: var(--text-xs);
    text-align: center;
  }
  .progress li:not(:last-child)::after {
    top: 15px;
    right: calc(-50% + 20px);
    bottom: auto;
    left: calc(50% + 20px);
    width: auto;
    height: 1px;
  }
  .progress li span { flex: 0 0 32px; background: var(--surface); }
  .quick-notes { margin-top: var(--space-4); padding: 0 var(--space-1); border-top: 0; }
}

@media (max-width: 640px) {
  .page-shell { padding-inline: var(--container-gutter-phone); padding-bottom: var(--space-12); }
  .page-header { min-height: 58px; }
  .time-note { display: none; }
  .intro h1, .message-page h1 { font-size: 30px; }
  .task-step { grid-template-columns: 34px minmax(0, 1fr); gap: var(--space-3); padding: var(--space-4); }
  .task-step.is-current { padding-block: var(--space-5); }
  .task-number { width: 32px; height: 32px; }
  .task-content h2, .task-step:not(.is-current) .task-content h2 { font-size: 18px; }
  .action-row { align-items: stretch; flex-direction: column; }
  .button { width: 100%; }
  .inline-error { margin: var(--space-4); }
  .page-footer { align-items: flex-start; flex-direction: column; }
  .message-page { margin-top: var(--space-8); padding: var(--space-6) var(--space-5); }
  .mobile-handoff-card { padding: var(--space-6) var(--space-5) var(--space-5); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
