:root {
  --blue: #1740c4;
  --yellow: #ffcc1f;
  --ink: #0f1b3d;
  --muted: #4d5877;
  --paper: #ffffff;
  --ground: #e8ecf5;
  --line: #b9c2da;
  --red: #b3261e;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

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

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 16px/1.5 Archivo, system-ui, sans-serif;
}

.wrap { width: min(100% - 32px, 520px); margin-inline: auto; }
a { color: var(--blue); }

header { background: var(--blue); color: #fff; }
header .wrap { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 0; }
header a { color: #fff; }
.brand { font-weight: 800; font-stretch: 118%; font-size: 1.1rem; text-decoration: none; }

.demo { margin: 0; padding: 8px 16px; background: var(--yellow); text-align: center; font-weight: 700; }

main { padding: 24px 0 8px; }
h1 { margin: 0; font-size: clamp(2.9rem, 15vw, 4.6rem); font-stretch: 68%; font-weight: 800; line-height: .95; }
h2 { margin: 0 0 6px; font-size: 1.7rem; font-stretch: 82%; line-height: 1.15; }
.intro { margin-bottom: 24px; }
.intro p { max-width: 38ch; margin: 10px 0 0; }

fieldset { border: 0; margin: 0 0 16px; padding: 0; min-width: 0; }
legend, label { display: block; padding: 0; margin-bottom: 6px; font-weight: 700; }

.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.choices label { position: relative; margin: 0; flex: 1 1 88px; }
.choices input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.choices span {
  display: block;
  padding: 11px 8px;
  text-align: center;
  background: var(--paper);
  border: 2px solid var(--line);
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
}
.choices input:checked + span { background: var(--ink); border-color: var(--ink); color: #fff; }
.choices input:focus-visible + span { outline: 3px solid var(--yellow); outline-offset: 2px; }

input:not([type="radio"]) {
  width: 100%;
  padding: 12px;
  font: 600 1rem var(--mono);
  color: var(--ink);
  background: var(--paper);
  border: 2px solid var(--line);
  border-radius: 6px;
}
input:focus-visible, button:focus-visible, a:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }
.hint { margin: 4px 0 14px; color: var(--muted); font-size: .875rem; }

button { font: 700 1rem Archivo, system-ui, sans-serif; cursor: pointer; border-radius: 6px; }
button:disabled { opacity: .55; cursor: wait; }
.primary { background: var(--blue); color: #fff; border: 2px solid var(--blue); padding: 13px 20px; }
.plain { background: var(--paper); color: var(--ink); border: 2px solid var(--ink); padding: 8px 14px; }

.stepper { display: grid; grid-template-columns: 60px minmax(0, 1fr) 60px; gap: 8px; }
.stepper button { background: var(--ink); color: #fff; border: 0; font-size: 1.6rem; }
.stepper input[type="number"] {
  text-align: center;
  font: 800 2.4rem/1.2 Archivo, system-ui, sans-serif;
  padding: 4px;
  appearance: textfield;
}
.stepper input::-webkit-inner-spin-button { display: none; }
.quick { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 20px; }
.quick button { flex: 1; padding: 6px 4px; background: transparent; border: 1px solid var(--line); color: var(--ink); font-weight: 600; font-size: .875rem; }
.quick button[aria-pressed="true"] { background: var(--paper); border-color: var(--ink); }

.bill { background: var(--yellow); padding: 16px; border-radius: 6px; }
.bill dl { margin: 0; }
.bill dl div { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.bill dd { margin: 0; font-weight: 700; text-align: right; }
.bill #bill-price { font-size: 2rem; font-weight: 800; font-stretch: 75%; }
.bill .hint { color: var(--ink); }
.bill .primary { width: 100%; background: var(--ink); border-color: var(--ink); }
.error { color: var(--red); background: var(--paper); border-left: 4px solid var(--red); padding: 8px 10px; margin: 0 0 12px; font-weight: 600; }

#view-pay { text-align: center; }
.amount { margin: 0; font-size: clamp(3rem, 17vw, 5rem); font-weight: 800; font-stretch: 70%; line-height: 1; color: var(--blue); }
.qr { background: var(--paper); border-radius: 6px; padding: 8px; max-width: 320px; margin: 16px auto 10px; }
.qr canvas { display: block; width: 100%; height: auto; image-rendering: pixelated; }
.waiting { background: var(--yellow); padding: 10px; border-radius: 6px; }

.code-line { font: .875rem var(--mono); overflow-wrap: anywhere; color: var(--muted); }
#rename { margin: 16px 0; }
#rename input { margin-bottom: 10px; }

.actions { display: flex; gap: 8px; margin: 16px 0; }
.actions .primary { flex: 1; }
.account { margin: 0 0 24px; background: var(--paper); border-radius: 6px; padding: 4px 14px; }
.account .row { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--ground); }
.account .row:last-child { border-bottom: 0; }
.account dt { grid-column: 1; color: var(--muted); font-size: .8125rem; }
.account dd { grid-column: 1; margin: 0; font: 600 .9375rem/1.45 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; }
.account button { grid-column: 2; grid-row: 1 / span 2; align-self: center; padding: 5px 10px; font-size: .8125rem; background: transparent; border: 1px solid var(--line); color: var(--ink); }

#history { list-style: none; margin: 0 0 20px; padding: 0; }
#history li { margin-bottom: 8px; }
#history a { display: block; padding: 12px; background: var(--paper); border-radius: 6px; color: var(--ink); }

footer { padding: 16px 0 40px; color: var(--muted); font-size: .875rem; }

.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  margin: 0; padding: 10px 16px; border-radius: 6px;
  background: var(--ink); color: #fff; font-weight: 600; white-space: nowrap;
}
.toast:empty { display: none; }
