:root {
  color-scheme: light dark;
  --bg: #0f1115;
  --surface: #181b22;
  --surface-2: #20242d;
  --text: #f3f4f6;
  --muted: #9ca3af;
  --accent: #635bff;
  --accent-hover: #4d47cc;
  --ok: #22c55e;
  --err: #ef4444;
  --border: #2a2f3a;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f7f9;
    --surface: #ffffff;
    --surface-2: #f1f3f7;
    --text: #111827;
    --muted: #6b7280;
    --border: #e5e7eb;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

.page {
  max-width: 520px;
  margin: 0 auto;
  padding: 24px 20px 40px;
  padding-top: max(24px, env(safe-area-inset-top));
  padding-bottom: max(40px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.topbar h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
}

.mode-form { margin: 0; }
.mode-pill {
  border: 0;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 6px 12px;
  border-radius: 999px;
  touch-action: manipulation;
  transition: transform 60ms ease, filter 120ms ease;
}
.mode-pill:active { transform: scale(0.96); }
.mode-pill-test {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  color: var(--accent);
}
.mode-pill-live {
  background: var(--err);
  color: white;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--err) 25%, transparent);
}

.live-mode .topbar h1::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--err);
  margin-right: 10px;
  vertical-align: middle;
  animation: pulse 1.8s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}
.live-mode .btn-primary { background: var(--err); }
.live-mode .btn-primary:hover { background: color-mix(in srgb, var(--err) 80%, black); }
.live-mode .spinner { border-top-color: var(--err); }

.flash {
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 15px;
}
.flash-alert {
  background: color-mix(in srgb, var(--err) 15%, transparent);
  color: var(--err);
  border: 1px solid color-mix(in srgb, var(--err) 40%, transparent);
}
.flash-notice {
  background: color-mix(in srgb, var(--ok) 15%, transparent);
  color: var(--ok);
  border: 1px solid color-mix(in srgb, var(--ok) 40%, transparent);
}

.form { display: flex; flex-direction: column; gap: 18px; }

.field { display: flex; flex-direction: column; gap: 8px; }
.field-label { font-size: 14px; color: var(--muted); font-weight: 500; }

.amount-input {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
}
.amount-prefix {
  padding: 0 12px 0 18px;
  font-size: 28px;
  color: var(--muted);
}
.amount-input input {
  flex: 1;
  font-size: 36px;
  font-weight: 600;
  padding: 18px 18px 18px 0;
  background: transparent;
  border: 0;
  outline: none;
  color: var(--text);
  width: 100%;
  letter-spacing: -0.02em;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}
.chip {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 60ms ease, background 120ms ease;
}
.chip:hover { background: var(--surface-2); }
.chip:active { transform: scale(0.96); }

.select {
  width: 100%;
  appearance: none;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 44px 16px 16px;
  font-size: 17px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
                    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 22px) 50%, calc(100% - 16px) 50%;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}

.btn {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 18px 20px;
  border-radius: 14px;
  font-size: 17px;
  font-weight: 600;
  border: 0;
  cursor: pointer;
  text-decoration: none;
  transition: transform 60ms ease, background 120ms ease, opacity 120ms ease;
  touch-action: manipulation;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}

.summary { text-align: center; padding: 8px 0; }
.amount-big {
  font-size: 48px;
  font-weight: 700;
  letter-spacing: -0.03em;
}
.subtle { color: var(--muted); font-size: 14px; margin-top: 4px; }

.status-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
}
.status-card.status-ok { border-color: color-mix(in srgb, var(--ok) 60%, var(--border)); }
.status-card.status-err { border-color: color-mix(in srgb, var(--err) 60%, var(--border)); }

.status-title { font-size: 20px; font-weight: 600; }
.status-card.status-ok .status-title { color: var(--ok); }
.status-card.status-err .status-title { color: var(--err); }
.status-detail { color: var(--muted); font-size: 15px; }

.spinner {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.actions { display: flex; flex-direction: column; gap: 12px; }
[hidden] { display: none !important; }
