:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #16181d;
  --muted: #5d6470;
  --border: #d9dce1;
  --accent: #1f5eff;
  --accent-text: #ffffff;
  --error: #b42318;
  --error-bg: #fef3f2;
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --card: #181b21;
    --text: #eceef2;
    --muted: #a0a7b4;
    --border: #2c313a;
    --accent: #5b8cff;
    --accent-text: #0b0d11;
    --error: #ff8a80;
    --error-bg: #2a1614;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 16px;
}
.card {
  width: 100%;
  max-width: 440px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
}
h1 { margin: 0 0 4px; font-size: 1.5rem; }
h2 { font-size: 1rem; margin: 0 0 4px; }
.sub { margin: 0 0 20px; color: var(--muted); }
label { display: block; font-weight: 600; margin: 16px 0 6px; }
input[type="text"], input[type="tel"], select {
  width: 100%;
  padding: 12px;
  font-size: 1rem;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
}
input[type="text"]:focus, input[type="tel"]:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.hint { margin: 6px 0 0; font-size: 0.85rem; color: var(--muted); }
fieldset { border: 0; padding: 0; margin: 16px 0 0; }
legend { font-weight: 600; margin-bottom: 6px; }
.presets { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.preset {
  margin: 0; width: auto; padding: 10px 14px; font-size: 0.95rem; font-weight: 600;
  color: var(--text); background: var(--card); border: 1px solid var(--border); border-radius: 8px;
}
.preset[aria-pressed="true"] { border: 2px solid var(--accent); color: var(--accent); }
.amount-row { display: flex; align-items: center; gap: 8px; }
.currency { font-weight: 700; font-size: 1.15rem; }
input[type="number"] {
  width: 100%; padding: 12px; font-size: 1rem; color: var(--text); background: var(--card);
  border: 1px solid var(--border); border-radius: 8px;
}
input[type="number"]:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.sr-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); margin: 0; }
.quote { margin: 8px 0 0; font-weight: 600; }
.quote.error { color: var(--error); font-weight: 400; }
button {
  margin-top: 22px;
  width: 100%;
  padding: 14px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--accent-text);
  background: var(--accent);
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}
button:disabled { opacity: 0.6; cursor: progress; }
#progress { display: flex; align-items: center; gap: 12px; margin-top: 18px; }
#progress[hidden] { display: none; }
.spinner {
  width: 20px; height: 20px; flex: none;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }
.message { margin: 16px 0 0; padding: 12px; border-radius: 8px; }
.message.error { color: var(--error); background: var(--error-bg); }
#last-order { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }
#last-order p { margin: 0; color: var(--muted); }
footer { margin-top: 16px; font-size: 0.8rem; color: var(--muted); text-align: center; max-width: 440px; }
.methods { display: flex; flex-wrap: wrap; gap: 8px; }
.method {
  margin: 0; width: auto; flex: 1 1 30%; padding: 10px 12px; font-size: 0.95rem; font-weight: 600;
  color: var(--text); background: var(--card); border: 1px solid var(--border); border-radius: 8px;
}
.method[aria-pressed="true"] { border: 2px solid var(--accent); color: var(--accent); }
.crypto { margin-top: 20px; text-align: center; }
.crypto[hidden] { display: none; }
.crypto-amount { margin: 4px 0 12px; font-weight: 600; }
.qr { display: flex; justify-content: center; margin: 0 auto 12px; }
.qr svg { width: 240px; height: 240px; max-width: 100%; background: #fff; border-radius: 8px; padding: 8px; }
.button-link {
  display: block; padding: 12px; border-radius: 8px; background: var(--accent); color: var(--accent-text);
  font-weight: 600; text-decoration: none; margin-bottom: 12px;
}
.small-label { font-size: 0.85rem; margin: 8px 0 4px; text-align: left; }
.copy-row { display: flex; gap: 8px; }
.copy-row input { flex: 1; min-width: 0; font-family: ui-monospace, monospace; font-size: 0.8rem; }
.copy-row button { margin: 0; width: auto; padding: 0 14px; }
button.secondary { background: var(--card); color: var(--text); border: 1px solid var(--border); }
.crypto-status { margin: 12px 0 0; font-weight: 600; }
.message.ok { color: var(--text); background: var(--bg); border: 1px solid var(--border); }
.paybox { margin-top: 20px; }
.paybox[hidden] { display: none; }
.paybox h2 { font-size: 1.15rem; margin: 0 0 4px; }
.pay-amount { margin: 0 0 12px; font-weight: 600; }
.steps-list { margin: 0 0 8px; padding-left: 1.2rem; }
.steps-list li { margin: 10px 0; }
.copy-chip { display: inline-flex; align-items: center; gap: 6px; margin-left: 4px; padding: 3px 4px 3px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); }
.copy-chip.code strong { font-family: ui-monospace, monospace; letter-spacing: 2px; font-size: 1.1rem; }
.chip-btn { margin: 0; width: auto; padding: 4px 10px; font-size: .8rem; background: var(--card); color: var(--text); border: 1px solid var(--border); }
.tracker { margin-top: 20px; }
.tracker[hidden] { display: none; }
.track-steps { list-style: none; padding: 0; margin: 0; }
.track-steps li { display: flex; align-items: center; gap: 12px; padding: 8px 0; color: var(--muted); }
.track-steps .dot { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--border); flex: none; position: relative; }
.track-steps li.active { color: var(--text); font-weight: 600; }
.track-steps li.active .dot { border-color: var(--accent); border-top-color: transparent; animation: spin .9s linear infinite; }
.track-steps li.done { color: var(--text); }
.track-steps li.done .dot { background: var(--accent); border-color: var(--accent); }
.track-steps li.done .dot::after { content: ""; position: absolute; left: 5px; top: 1px; width: 4px; height: 9px; border: solid var(--accent-text); border-width: 0 2px 2px 0; transform: rotate(45deg); }
@media (prefers-reduced-motion: reduce) { .track-steps li.active .dot { animation: none; } }
.tracker-text { font-weight: 600; margin: 12px 0 4px; }
#new-order { margin-top: 12px; }

.button-link.cashapp { background: #00d632; color: #fff; }
.button-link.speed { background: #2a66ff; color: #fff; }
.button-link.alt { background: var(--card); color: var(--text); border: 1px solid var(--border); }
.link-btn { margin: 14px 0 0; width: auto; padding: 6px 4px; background: none; color: var(--muted); font-weight: 600; text-decoration: underline; }
.cancel-confirm { margin-top: 14px; padding: 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); }
.cancel-confirm[hidden] { display: none; }
.cancel-confirm p { margin: 0 0 10px; }
.receipt { margin-top: 18px; padding: 14px; border: 1px dashed var(--border); border-radius: 10px; }
.receipt[hidden] { display: none; }
.receipt h3 { margin: 0 0 8px; font-size: 1rem; }
.receipt dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0 0 12px; font-size: .9rem; }
.receipt dt { color: var(--muted); }
.receipt dd { margin: 0; font-weight: 600; word-break: break-all; }

.pay-timer { margin: 10px 0 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.pay-timer.low { color: var(--error); }
.pay-timer[hidden] { display: none; }

.chime-step { display: flex; gap: 12px; padding: 12px; margin: 10px 0; border: 1px solid var(--border); border-radius: 10px; }
.chime-step p { margin: 0 0 8px; }
.chime-step button { margin-top: 0; }
.chime-step.focus { border: 2px solid var(--accent); }
.step-no { flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: var(--accent-text); display: grid; place-items: center; font-weight: 700; }
.code-btn #chime-code { font-family: ui-monospace, monospace; letter-spacing: 2px; margin-left: 6px; }

.guide-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: flex-end; justify-content: center; z-index: 10; padding: 12px; }
.guide-backdrop[hidden] { display: none; }
.guide { width: 100%; max-width: 440px; background: var(--card); color: var(--text); border-radius: 16px; padding: 22px 20px 14px; box-shadow: 0 10px 40px rgba(0,0,0,.35); }
.guide-step { margin: 0 0 4px; color: var(--accent); font-weight: 700; font-size: .85rem; text-transform: uppercase; letter-spacing: .05em; }
.guide h2 { margin: 0 0 12px; font-size: 1.35rem; line-height: 1.25; }
.guide-body { font-size: 1.05rem; line-height: 1.5; }
.guide-body ol { padding-left: 1.3rem; margin: 6px 0; }
.guide-body li { margin: 6px 0; }
.guide-big { display: block; text-align: center; font: 700 2.2rem/1.2 ui-monospace, monospace; letter-spacing: 6px; padding: 12px; margin: 10px 0; border: 2px dashed var(--accent); border-radius: 12px; }
.guide-ok { color: #12833a; font-weight: 700; }
.guide-actions { display: grid; gap: 8px; margin-top: 14px; }
.guide-actions button { margin: 0; }
#guide-close { display: block; margin: 8px auto 0; }

.adders-label { margin: 2px 0 6px; }
.preset.add { min-width: 56px; }
.preset.add.clear { background: transparent; }

.fee-line { display: block; }
.fee-line.small { font-size: 0.85em; opacity: 0.8; }

/* Chat box ------------------------------------------------------------------ */
.chat-open {
  position: fixed; right: 16px; bottom: 16px; z-index: 50;
  width: auto; margin: 0; padding: 12px 18px; border-radius: 999px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .25);
}
.chat-dot {
  display: inline-block; width: 10px; height: 10px; margin-left: 6px; border-radius: 50%;
  background: var(--error); vertical-align: middle;
}
.chat-dot[hidden] { display: none; }
.chat-panel {
  position: fixed; right: 16px; bottom: 16px; z-index: 51;
  width: min(380px, calc(100vw - 32px)); height: min(520px, calc(100vh - 32px));
  display: flex; flex-direction: column;
  background: var(--card); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0, 0, 0, .3); overflow: hidden;
}
.chat-panel[hidden] { display: none; }
.chat-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; border-bottom: 1px solid var(--border);
}
.chat-close {
  width: auto; margin: 0; padding: 0 8px; background: none; color: var(--muted);
  border: 0; font-size: 24px; line-height: 1;
}
.chat-list { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.chat-hello { margin: 0 0 4px; color: var(--muted); font-size: 14px; }
.chat-msg { max-width: 85%; padding: 8px 12px; border-radius: 14px; overflow-wrap: anywhere; }
.chat-msg.mine { align-self: flex-end; background: var(--accent); color: var(--accent-text); border-bottom-right-radius: 4px; }
.chat-msg.theirs { align-self: flex-start; background: var(--bg); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.chat-text { white-space: pre-wrap; }
.chat-meta { font-size: 12px; opacity: .75; margin-top: 2px; }
.chat-note { margin: 0; padding: 6px 12px; color: var(--error); background: var(--error-bg); font-size: 14px; }
.chat-note[hidden] { display: none; }
.chat-form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--border); align-items: flex-end; }
.chat-form textarea {
  flex: 1; resize: none; margin: 0; font: inherit; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text);
}
.chat-form button { width: auto; margin: 0; padding: 10px 16px; }
footer { padding-bottom: 72px; }

/* Announcement banner (dashboard: Settings -> Announcement banner). Scrolls; static for reduced motion. */
.announce { overflow: hidden; white-space: nowrap; margin: 0 0 12px; padding: 10px 0; border-radius: 8px;
  background: var(--accent); color: var(--accent-text); font-weight: 700; }
.announce span { display: inline-block; padding-left: 100%; animation: announce-scroll 16s linear infinite; }
@keyframes announce-scroll { from { transform: translateX(0); } to { transform: translateX(-100%); } }
@media (prefers-reduced-motion: reduce) {
  .announce { white-space: normal; padding: 10px 12px; }
  .announce span { padding-left: 0; animation: none; }
}
