:root {
  --bg: #f5f5f4;
  --surface: #ffffff;
  --border: #e2e1df;
  --text: #1c1917;
  --muted: #625d58;
  --primary: #0f766e;
  --primary-press: #0b5f58;
  --error: #b42318;
  --error-bg: #fdf1ef;
  --warn-bg: #fdf7e8;
  --warn-border: #ecd9a6;
  --radius: 10px;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161514;
    --surface: #1f1e1c;
    --border: #34322f;
    --text: #ecebe9;
    --muted: #a19c96;
    --primary: #2a9d8f;
    --primary-press: #23867a;
    --error: #f0857a;
    --error-bg: #2a1c1a;
    --warn-bg: #29241a;
    --warn-border: #4d4430;
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

.page {
  max-width: 560px;
  margin: 0 auto;
  padding: 24px 16px calc(32px + env(safe-area-inset-bottom));
}

.top { padding: 8px 4px 16px; }
.top h1 { margin: 0 0 4px; font-size: 26px; font-weight: 650; }
.top p { margin: 0; color: var(--muted); font-size: 15px; }

h2 { margin: 0 0 12px; font-size: 17px; font-weight: 600; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 12px;
}

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.hint { margin: 12px 0 0; color: var(--muted); font-size: 14px; }

.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 8px;
  padding: 10px 16px;
  font: inherit;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease;
}
.btn:active { background: var(--bg); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:active { background: var(--primary-press); border-color: var(--primary-press); }
.btn.big { display: block; width: 100%; padding: 14px 16px; font-size: 17px; font-weight: 600; }
.btn:disabled { opacity: .55; cursor: default; }

.link {
  appearance: none;
  border: 0;
  background: none;
  padding: 4px 0;
  color: var(--primary);
  font: inherit;
  font-size: 15px;
  cursor: pointer;
}

.actions { display: flex; gap: 8px; margin-top: 16px; }
.actions .btn { flex: 1; }

/* 结果字段 */
.fields { margin: 0; }
.field {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 12px;
  padding: 12px 0;
  border-top: 1px solid var(--border);
}
.field:first-child { border-top: 0; padding-top: 4px; }
.field dt { grid-column: 1; color: var(--muted); font-size: 13px; }
.field dd {
  grid-column: 1;
  margin: 0;
  font-size: 16px;
  word-break: break-all;
  -webkit-user-select: all;
  user-select: all;
}
.field dd.mono { font-family: var(--mono); font-size: 15px; }
.field dd small { display: block; color: var(--muted); font-size: 13px; font-family: var(--mono); }
.field .copy { grid-column: 2; grid-row: 1 / span 2; align-self: center; }

/* 步骤 */
.steps { list-style: none; margin: 0; padding: 0; counter-reset: step; }
.steps li {
  position: relative;
  padding: 0 0 16px 36px;
  counter-increment: step;
}
.steps li:last-child { padding-bottom: 0; }
.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 1px;
  width: 24px;
  height: 24px;
  border: 1px solid var(--border);
  border-radius: 6px;
  text-align: center;
  font-size: 13px;
  line-height: 22px;
  color: var(--muted);
}
.steps li strong { display: block; font-weight: 600; }
.steps li span { display: block; color: var(--muted); font-size: 15px; }
.steps li.done::before { content: "✓"; background: var(--primary); border-color: var(--primary); color: #fff; }
.steps li.current::before { border-color: var(--primary); color: var(--primary); font-weight: 600; }

/* 提示 */
.notice { background: var(--warn-bg); border-color: var(--warn-border); }
.notice p { margin: 0; }
.notice p + p { margin-top: 8px; }
.notice code {
  font-family: var(--mono);
  font-size: 14px;
  word-break: break-all;
}
.notice-error { background: var(--error-bg); border-color: var(--error); }
.notice-error h2 { color: var(--error); }
.notice-error p { margin: 0; }

/* 常见问题 */
.faq details { border-top: 1px solid var(--border); }
.faq details:first-of-type { border-top: 0; }
.faq summary {
  padding: 12px 0;
  cursor: pointer;
  list-style: none;
  font-size: 15px;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; float: right; color: var(--muted); }
.faq details[open] summary::after { content: "−"; }
.faq details p { margin: 0 0 12px; color: var(--muted); font-size: 14px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  margin-left: -60px;
  width: 120px;
  padding: 8px 0;
  border-radius: 8px;
  background: rgba(28, 25, 23, .9);
  color: #fff;
  font-size: 14px;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 150ms ease;
}
.toast.show { opacity: 1; }
