/* ─────────────────────────────────────────────────────────────────────────
   Design tokens
   ───────────────────────────────────────────────────────────────────── */
:root {
  --font-sans: system-ui, -apple-system, sans-serif;
  --font-mono: ui-monospace, 'SF Mono', Monaco, Consolas, monospace;

  /* Surface ladder — cyan-tinted near-blacks */
  --surface-0: #05070c;
  --surface-1: #0a0d12;
  --surface-2: #0f131c;
  --surface-3: #161d2b;
  --surface-4: #1e2636;

  /* Accent */
  --accent: #38bdf8;
  --accent-muted: #0e7490;

  /* Semantic */
  --good: #6ee7b7;
  --good-surface: #065f46;
  --bad: #fca5a5;
  --bad-surface: #7f1d1d;
  --warn: #fbbf24;
  --warn-surface: #78350f;

  /* Text */
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-tertiary: #94a3b8;
  --text-dim: #64748b;

  /* Spacing */
  --s-xs: 0.25rem;
  --s-sm: 0.5rem;
  --s-md: 0.75rem;
  --s-lg: 1rem;
  --s-xl: 1.5rem;
  --s-2xl: 2rem;

  /* Radius */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 12px;
  --r-pill: 999px;
  --r-circle: 50%;
}

/* ─────────────────────────────────────────────────────────────────────────
   Base
   ───────────────────────────────────────────────────────────────────── */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  background: var(--surface-0);
  color: var(--text-secondary);
  font: clamp(15px, 1.8vw, 16px)/1.6 var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

main {
  width: min(760px, 100%);
  margin: 0 auto;
  padding: clamp(1.5rem, 4vw, 3rem) clamp(1rem, 3vw, 1.5rem) 4rem;
}

h1 {
  font-size: clamp(1.5rem, 4vw, 1.75rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0 0 var(--s-sm);
  color: var(--text-primary);
  line-height: 1.2;
}

h2 {
  font-size: clamp(1.125rem, 3vw, 1.25rem);
  font-weight: 600;
  margin: var(--s-2xl) 0 var(--s-lg);
  color: var(--text-primary);
  letter-spacing: -0.01em;
  line-height: 1.3;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.15s;
}

a:hover {
  color: var(--good);
}

code {
  background: var(--surface-2);
  padding: 0.125rem 0.5rem;
  border-radius: var(--r-sm);
  font: 0.875em/1.4 var(--font-mono);
  color: var(--accent);
}

/* ─────────────────────────────────────────────────────────────────────────
   Utility
   ───────────────────────────────────────────────────────────────────── */
.lede {
  color: var(--text-tertiary);
  margin: var(--s-sm) 0 var(--s-xl);
  font-size: clamp(0.9375rem, 2vw, 1rem);
  line-height: 1.5;
}

.hint {
  color: var(--text-tertiary);
  margin: var(--s-md) 0;
  font-size: 0.9rem;
  line-height: 1.5;
}

.note {
  color: var(--text-dim);
  font-size: 0.875rem;
  margin: var(--s-md) 0 0;
  line-height: 1.5;
}

.mono {
  font: 0.8125rem/1.4 var(--font-mono);
  color: var(--text-tertiary);
}

.error {
  background: var(--bad-surface);
  border: 1px solid var(--bad);
  border-radius: var(--r-md);
  padding: var(--s-md) var(--s-lg);
  margin: 0 0 var(--s-xl);
  color: var(--bad);
  font-size: 0.9375rem;
}

.flash {
  background: var(--good-surface);
  border: 1px solid var(--good);
  border-radius: var(--r-md);
  padding: var(--s-md) var(--s-lg);
  margin: 0 0 var(--s-xl);
  color: var(--good);
}

/* ─────────────────────────────────────────────────────────────────────────
   Forms
   ───────────────────────────────────────────────────────────────────── */
label {
  display: block;
  margin: 0 0 var(--s-lg);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
}

input,
textarea,
button,
select {
  font: inherit;
}

input[type="email"],
input[type="password"],
input[type="text"],
input[type="number"],
textarea {
  width: 100%;
  margin-top: var(--s-sm);
  border: 1px solid var(--surface-4);
  border-radius: var(--r-md);
  padding: 0.75rem 0.875rem;
  background: var(--surface-1);
  color: var(--text-primary);
  transition: all 0.15s;
}

input::placeholder,
textarea::placeholder {
  color: var(--text-dim);
}

input:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface-2);
}

textarea {
  min-height: 42vh;
  resize: vertical;
  font: 0.875rem/1.5 var(--font-mono);
}

button {
  cursor: pointer;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  padding: 0.75rem 1.125rem;
  background: var(--surface-3);
  color: var(--text-primary);
  font-weight: 600;
  font-size: 0.9375rem;
  transition: all 0.15s;
  white-space: nowrap;
}

button:hover {
  background: var(--surface-4);
}

button.primary {
  background: var(--accent);
  color: var(--surface-0);
}

button.primary:hover {
  background: var(--good);
}

button.ghost {
  background: var(--surface-2);
  border-color: var(--surface-4);
}

button.ghost:hover {
  border-color: var(--text-dim);
}

button.link {
  background: none;
  border: 0;
  padding: 0;
  color: var(--accent);
  font-weight: 500;
}

button.link:hover {
  color: var(--good);
  background: none;
}

.btn {
  display: inline-block;
  text-decoration: none;
  background: var(--accent);
  color: var(--surface-0);
  border-radius: var(--r-md);
  padding: 0.625rem 1.125rem;
  font-weight: 600;
  font-size: 0.9375rem;
  transition: all 0.15s;
}

.btn:hover {
  background: var(--good);
  color: var(--surface-0);
}

.block {
  display: block;
  width: 100%;
}

/* ─────────────────────────────────────────────────────────────────────────
   Auth page
   ───────────────────────────────────────────────────────────────────── */
.auth .brand {
  text-align: center;
  margin: var(--s-md) 0 var(--s-2xl);
}

.auth .card {
  margin-bottom: var(--s-xl);
}

.auth button {
  width: 100%;
  margin-top: var(--s-sm);
}

/* ─────────────────────────────────────────────────────────────────────────
   Card
   ───────────────────────────────────────────────────────────────────── */
.card {
  border: 1px solid var(--surface-3);
  background: var(--surface-1);
  border-radius: var(--r-lg);
  padding: var(--s-xl);
  margin-bottom: var(--s-lg);
}

.card h2 {
  margin-top: 0;
}

/* ─────────────────────────────────────────────────────────────────────────
   Shop header & wallet
   ───────────────────────────────────────────────────────────────────── */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: var(--s-lg);
  border-bottom: 1px solid var(--surface-3);
  gap: var(--s-lg);
}

.greet {
  font-size: 1.0625rem;
  color: var(--text-secondary);
}

.greet strong {
  color: var(--text-primary);
}

.wallet-bar {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: var(--s-lg);
  background: var(--surface-1);
  border: 1px solid var(--surface-3);
  border-radius: var(--r-lg);
  padding: var(--s-xl);
  margin: var(--s-xl) 0;
}

.wallet-bar span {
  display: block;
  color: var(--text-tertiary);
  font-size: 0.8125rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 0.25rem;
}

.wallet-bar strong {
  font-size: clamp(1.5rem, 4vw, 1.75rem);
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

/* ─────────────────────────────────────────────────────────────────────────
   Steps
   ───────────────────────────────────────────────────────────────────── */
.steps {
  counter-reset: step;
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--s-md);
  padding: 0;
  margin: 0 0 var(--s-xl);
}

.steps li {
  counter-increment: step;
  background: var(--surface-1);
  border: 1px solid var(--surface-3);
  border-radius: var(--r-md);
  padding: var(--s-lg) var(--s-lg) var(--s-lg) 3rem;
  position: relative;
  font-size: 0.9rem;
  color: var(--text-tertiary);
  line-height: 1.4;
}

.steps li::before {
  content: counter(step);
  position: absolute;
  left: var(--s-lg);
  top: var(--s-lg);
  width: 1.625rem;
  height: 1.625rem;
  border-radius: var(--r-circle);
  background: var(--accent);
  color: var(--surface-0);
  font-weight: 700;
  font-size: 0.8125rem;
  display: grid;
  place-items: center;
}

.steps strong {
  color: var(--text-primary);
  font-weight: 600;
}

/* ─────────────────────────────────────────────────────────────────────────
   Method cards
   ───────────────────────────────────────────────────────────────────── */
.method-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--s-lg);
  gap: var(--s-lg);
}

.method .sub {
  color: var(--text-tertiary);
  font-size: 0.875rem;
  margin-top: 0.25rem;
}

.method .generate {
  margin: 0;
}

.scan-choice {
  color: var(--text-secondary);
  display: flex;
  gap: var(--s-md);
  align-items: flex-start;
  font-size: 0.875rem;
  line-height: 1.4;
  margin: 0 0 var(--s-lg);
}

.scan-choice input {
  accent-color: var(--accent);
  margin: 0.1875rem 0 0;
  width: auto;
}

.keys-tag {
  border: 1px solid var(--surface-4);
  color: var(--text-dim);
  border-radius: var(--r-pill);
  padding: 0.25rem 0.875rem;
  font-size: 0.8125rem;
  font-weight: 600;
  white-space: nowrap;
}

.keys-tag.good {
  border-color: var(--good);
  color: var(--good);
  background: var(--good-surface);
}

/* ─────────────────────────────────────────────────────────────────────────
   Disclosures
   ───────────────────────────────────────────────────────────────────── */
details.buy-more,
details.promo {
  margin-top: var(--s-lg);
}

details.promo {
  border: 1px solid var(--surface-3);
  border-radius: var(--r-md);
  padding: var(--s-sm) var(--s-lg);
}

summary {
  cursor: pointer;
  color: var(--text-tertiary);
  font-size: 0.9rem;
  font-weight: 500;
  padding: var(--s-sm) 0;
  list-style: none;
  user-select: none;
}

summary::-webkit-details-marker {
  display: none;
}

summary::before {
  content: "+ ";
  color: var(--text-dim);
  margin-right: 0.375rem;
}

details[open] summary::before {
  content: "− ";
}

details .inline {
  margin-top: var(--s-md);
}

/* ─────────────────────────────────────────────────────────────────────────
   Inline forms
   ───────────────────────────────────────────────────────────────────── */
.inline {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-md);
  align-items: center;
  margin: var(--s-md) 0;
}

.inline input {
  width: auto;
  flex: 1 1 160px;
  margin-top: 0;
}

/* ─────────────────────────────────────────────────────────────────────────
   Rows & lists
   ───────────────────────────────────────────────────────────────────── */
.row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: var(--s-md);
  gap: var(--s-lg);
}

.ledger,
.jobs {
  list-style: none;
  padding: 0;
  margin: var(--s-md) 0;
}

.ledger li {
  padding: var(--s-md) 0;
  border-bottom: 1px solid var(--surface-2);
  color: var(--text-secondary);
  font-size: 0.9375rem;
}

.jobs li {
  display: flex;
  gap: var(--s-md);
  align-items: center;
  padding: var(--s-md) 0;
  border-bottom: 1px solid var(--surface-2);
  font-size: 0.9375rem;
}

.tag {
  border-radius: var(--r-pill);
  padding: 0.125rem 0.75rem;
  font-size: 0.8125rem;
  font-weight: 600;
  background: var(--surface-3);
  color: var(--text-tertiary);
}

.tag.good {
  background: var(--good-surface);
  color: var(--good);
}

.tag.bad {
  background: var(--bad-surface);
  color: var(--bad);
}

/* ─────────────────────────────────────────────────────────────────────────
   QR & spinner
   ───────────────────────────────────────────────────────────────────── */
#qr {
  width: min(320px, 92%);
  margin: var(--s-xl) auto 0;
  display: block;
  border-radius: var(--r-lg);
  background: #fff;
  padding: var(--s-lg);
}

.spinner {
  display: inline-block;
  width: 0.875rem;
  height: 0.875rem;
  border: 2px solid var(--surface-4);
  border-top-color: var(--accent);
  border-radius: var(--r-circle);
  animation: spin 0.8s linear infinite;
  vertical-align: -0.125rem;
  margin-right: var(--s-sm);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.back {
  display: inline-block;
  margin-top: var(--s-lg);
}
