:root {
  color-scheme: light dark;
  --canvas: light-dark(#f5f6fa, #11131d);
  --surface: light-dark(#fff, #1a1d2b);
  --subtle: light-dark(#f4f5fa, #222638);
  --ink: light-dark(#181b2b, #f2f3fa);
  --muted: light-dark(#555d72, #aeb5cb);
  --line: light-dark(#dee2ed, #34394f);
  --accent: light-dark(#4136bd, #bbb5ff);
  --accent-hover: light-dark(#332a9e, #d1ccff);
  --accent-ink: light-dark(#fff, #171039);
  --accent-soft: light-dark(#edebff, #2b2553);
  --danger: light-dark(#a62a47, #ff9db1);
  --danger-soft: light-dark(#fceef1, #402332);
  --positive: light-dark(#0c6a50, #83dac0);
  --positive-soft: light-dark(#e6f4ef, #18392f);
  --shade: light-dark(#17183266, #080911a8);
  --shadow: light-dark(#17183218, #07091070);
  --white: #fff;
  --space-1: .25rem;
  --space-2: .5rem;
  --space-3: .75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-7: 2rem;
  --space-8: 2.5rem;
  --space-9: 3.5rem;
  --radius-1: .375rem;
  --radius-2: .625rem;
  --radius-3: .875rem;
  --radius-4: 1.25rem;
  --pill: 100vmax;
  --font: system-ui, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  --motion: 160ms ease;
}

:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font: 1rem/1.55 var(--font);
  overflow-wrap: anywhere;
}

h1, h2, h3, p, dl, dd, figure { margin: 0; }
h1, h2, h3 { line-height: 1.25; }
h1 { font-size: clamp(1.75rem, 2.5vw, 2.4rem); }
h2 { font-size: 1.125rem; }
h3 { font-size: 1rem; }
a { color: var(--accent); }
button, input, textarea { font: inherit; }
img { max-inline-size: 100%; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.muted { color: var(--muted); }
.preserve-lines { white-space: pre-wrap; }
.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: var(--space-2);
  min-block-size: 2.75rem;
  padding: var(--space-2) var(--space-4);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-2);
  color: var(--ink);
  font-size: .875rem;
  font-weight: 650;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: background-color var(--motion), border-color var(--motion), color var(--motion);
}

.button:hover { background: var(--subtle); }
.button[data-tone="primary"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.button[data-tone="primary"]:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.button[data-tone="quiet"] { background: transparent; border-color: transparent; color: var(--muted); }
.button[data-tone="quiet"]:hover { background: var(--accent-soft); color: var(--accent); }
.button[data-tone="danger"] { color: var(--danger); border-color: var(--danger); }
.button[data-tone="danger"]:hover { background: var(--danger-soft); }
.button:disabled { opacity: .55; cursor: default; }

.card {
  padding: var(--space-5);
  border: 1px solid var(--line);
  border-radius: var(--radius-3);
  background: var(--surface);
}

.progress {
  display: block;
  inline-size: 100%;
  block-size: .5rem;
  appearance: none;
  border: 0;
  border-radius: var(--pill);
  overflow: hidden;
  background: var(--progress-track, var(--subtle));
  color: var(--progress-fill, var(--accent));
}
.progress::-webkit-progress-bar { background: var(--progress-track, var(--subtle)); }
.progress::-webkit-progress-value { background: var(--progress-fill, var(--accent)); border-radius: var(--pill); }
.progress::-moz-progress-bar { background: var(--progress-fill, var(--accent)); border-radius: var(--pill); }

.field {
  display: grid;
  gap: var(--space-2);
  font-size: .875rem;
  font-weight: 600;
}
.field input, .field textarea, .manual-copy {
  inline-size: 100%;
  min-block-size: 2.75rem;
  padding: var(--space-2) var(--space-3);
  background: var(--canvas);
  border: 1px solid var(--line);
  border-radius: var(--radius-2);
  color: var(--ink);
  font-size: 1rem;
  font-weight: 400;
}
.field textarea, .manual-copy { resize: vertical; }
.form-error { color: var(--danger); font-size: .875rem; }
.form-error:empty { display: none; }
.payment-image {
  display: block;
  inline-size: auto;
  max-inline-size: min(100%, 20rem);
  max-block-size: 24rem;
  object-fit: contain;
}

.dialog {
  inline-size: min(calc(100% - var(--space-7)), 30rem);
  max-block-size: calc(100% - var(--space-7));
  padding: var(--space-5);
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius-4);
  box-shadow: 0 var(--space-5) var(--space-9) var(--shadow);
}
.dialog[open] { animation: dialog-in var(--motion) both; }
.dialog::backdrop { background: var(--shade); }
.dialog-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
  margin-block-end: var(--space-3);
}
.dialog-actions { justify-content: flex-end; margin-block-start: var(--space-4); }
.dialog-close { flex: none; }
.clipboard-buffer {
  position: fixed;
  inset: 0 auto auto -100vw;
  inline-size: 1px;
  block-size: 1px;
}

.toasts {
  position: fixed;
  z-index: 2;
  inset: auto var(--space-4) var(--space-4) var(--space-4);
  display: grid;
  justify-items: end;
  gap: var(--space-2);
  pointer-events: none;
}
.toast {
  padding: var(--space-3) var(--space-4);
  background: var(--surface);
  border: 1px solid var(--line);
  border-inline-start: .2rem solid var(--positive);
  border-radius: var(--radius-2);
  color: var(--ink);
  box-shadow: 0 var(--space-2) var(--space-6) var(--shadow);
  animation: dialog-in var(--motion) both;
}
.toast[data-tone="error"] { border-inline-start-color: var(--danger); }

@keyframes dialog-in {
  from { opacity: 0; transform: translateY(var(--space-2)); }
  to { opacity: 1; transform: translateY(0); }
}

@media (min-width: 48rem) {
  .card, .dialog { padding: var(--space-6); }
}

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