:root {
  --bg: #f3f0e8;
  --surface: #fffdf8;
  --ink: #1b2320;
  --muted: #5d6762;
  --line: #e1dccf;
  --accent: #0e5a4b;
  --accent-ink: #ffffff;
  --accent-soft: #dcebe5;
  --good: #1d7149;
  --good-soft: #dff0e5;
  --warn: #8a5300;
  --warn-soft: #f8ead2;
  --bad: #9c2f28;
  --bad-soft: #f6e0dc;
  --idle: #6b716e;
  --idle-soft: #ebe8e1;
  --focus: #0e5a4b;
  --radius: 14px;
  --shadow: 0 1px 2px rgb(27 35 32 / 6%), 0 4px 16px rgb(27 35 32 / 5%);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111513;
    --surface: #1a201d;
    --ink: #e7ece9;
    --muted: #9ba6a1;
    --line: #2b3430;
    --accent: #4cb498;
    --accent-ink: #0b1210;
    --accent-soft: #1d3530;
    --good: #5cc98f;
    --good-soft: #193326;
    --warn: #e8a948;
    --warn-soft: #382a14;
    --bad: #ec7d71;
    --bad-soft: #3a1d1a;
    --idle: #9aa19d;
    --idle-soft: #262c29;
    --focus: #4cb498;
    --shadow: none;
    color-scheme: dark;
  }
}

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

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans CJK SC", "Noto Sans SC", "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2 { margin: 0; line-height: 1.25; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1rem; font-weight: 600; }
p { margin: 0; }
button, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.muted { color: var(--muted); }
.fine { color: var(--muted); font-size: 0.8125rem; }

/* top bar: full-width background, but its contents line up with the page column below (same --page-w) */
:root { --page-w: 560px; --gutter: max(16px, calc((100% - var(--page-w)) / 2 + 16px)); }
.bar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) max(var(--gutter), env(safe-area-inset-right)) 10px max(var(--gutter), env(safe-area-inset-left));
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.mark { width: 36px; height: 36px; flex: none; border-radius: 10px; display: block; }
.brand-name { font-weight: 650; letter-spacing: 0.01em; white-space: nowrap; }
.bar-actions { display: flex; gap: 8px; }

.chip {
  min-height: 36px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); cursor: pointer; font-size: 0.875rem;
  white-space: nowrap; flex: none;
}
@media (max-width: 359px) {
  .brand-name { display: none; }
}

main {
  width: 100%; max-width: var(--page-w); margin: 0 auto;
  padding: 16px max(16px, env(safe-area-inset-right)) calc(40px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
.view { display: flex; flex-direction: column; gap: 16px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 16px;
}

/* forms */
form { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
label { font-size: 0.875rem; font-weight: 600; }
input, textarea {
  width: 100%; min-height: 48px; padding: 12px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg);
  font-size: 16px; /* no iOS zoom */
}
textarea { resize: vertical; min-height: 84px; overflow-wrap: anywhere; }
input:focus, textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }

.primary, .ghost {
  min-height: 48px; padding: 0 18px;
  border-radius: 10px; cursor: pointer; font-weight: 600;
}
.primary { border: 0; background: var(--accent); color: var(--accent-ink); margin-top: 4px; }
.primary:disabled { opacity: 0.45; cursor: not-allowed; }
.primary.busy { opacity: 0.7; cursor: progress; }
.ghost { border: 1px solid var(--line); background: transparent; flex: none; }
.ghost.small { min-height: 34px; padding: 0 12px; font-size: 0.8125rem; font-weight: 500; }

.field-msg { min-height: 1.25em; font-size: 0.875rem; color: var(--muted); }
.field-msg.ok { color: var(--good); }
.field-msg.err { color: var(--bad); }
.field-msg:empty { min-height: 0; }

/* login */
.login { margin-top: 8vh; padding: 24px 20px; display: flex; flex-direction: column; gap: 8px; }
.login .fine { margin-top: 8px; }
.login .field-msg { font-size: 1.0625rem; min-height: 1.5em; color: var(--ink); }
.login .field-msg.err { color: var(--bad); }

/* wallet */
.wallet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.wallet-head h2 { color: var(--muted); font-weight: 500; font-size: 0.875rem; }
.amount {
  margin: 4px 0 14px;
  font-size: clamp(2rem, 9vw, 2.5rem); font-weight: 700; letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums; line-height: 1.1;
}
.amount .cur { font-size: 0.6em; font-weight: 600; margin-right: 4px; color: var(--muted); }
.wallet-grid { margin: 0 0 10px; background: var(--bg); border-radius: 10px; padding: 2px 12px; }
.wallet-grid div { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 8px 0; }
.wallet-grid div + div { border-top: 1px solid var(--line); }
.wallet-grid dt { font-size: 0.875rem; color: var(--muted); }
.wallet-grid dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* how it works */
.how { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; font-size: 0.875rem; }
.how summary { cursor: pointer; font-weight: 600; color: var(--accent); min-height: 32px; }
.how ol { margin: 8px 0 0; padding-left: 1.25em; display: flex; flex-direction: column; gap: 6px; color: var(--muted); }

/* list */
.list-head { display: flex; align-items: center; justify-content: space-between; margin: 8px 2px 10px; }
.live { font-size: 0.75rem; color: var(--good); display: inline-flex; align-items: center; gap: 6px; }
.live::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.3; } }
@media (prefers-reduced-motion: reduce) { .live::before { animation: none; } }
.empty { padding: 4px 2px; }

.transfers { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.tr { padding: 14px 14px 12px; }
.tr-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tr-id { font-size: 0.8125rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tr-price { font-weight: 700; font-size: 1.125rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tr-note { margin-top: 8px; font-size: 0.875rem; padding: 8px 10px; border-radius: 8px; }
.tr-note.bad { background: var(--bad-soft); color: var(--bad); }
.tr-note.warn { background: var(--warn-soft); color: var(--warn); }
.tr-note.idle { background: var(--idle-soft); color: var(--muted); }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px;
  font-size: 0.8125rem; font-weight: 600; line-height: 1.4;
}
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.pill.active { background: var(--accent-soft); color: var(--accent); }
.pill.good { background: var(--good-soft); color: var(--good); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.idle { background: var(--idle-soft); color: var(--idle); }

/* 4-step progress */
.steps { list-style: none; margin: 12px 0 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; }
.steps li { font-size: 0.6875rem; color: var(--muted); line-height: 1.3; padding-top: 7px; position: relative; min-width: 0; }
.steps li::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 4px; border-radius: 2px; background: var(--line); }
.steps li.done::before { background: var(--accent); }
.steps li.now { color: var(--ink); font-weight: 600; }
.steps li.now::before { background: linear-gradient(90deg, var(--accent) 50%, var(--line) 50%); }
.steps.complete li.now::before { background: var(--good); }
.steps.complete li.done::before { background: var(--good); }

.tr-more {
  margin-top: 10px; padding: 0; min-height: 32px;
  border: 0; background: none; color: var(--accent); font-size: 0.8125rem; font-weight: 600; cursor: pointer;
}
.tr-detail { margin-top: 6px; border-top: 1px solid var(--line); padding-top: 10px; font-size: 0.8125rem; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0 0 10px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.kv dd.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 0.75rem; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 14px; border-left: 2px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.timeline li { position: relative; }
.timeline li::before { content: ""; position: absolute; left: -20px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent); }
.timeline .t-state { font-weight: 600; }
.timeline .t-time { color: var(--muted); font-variant-numeric: tabular-nums; margin-left: 6px; }
.timeline .t-detail { color: var(--muted); }

/* toast */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(20px + env(safe-area-inset-bottom));
  max-width: min(520px, calc(100vw - 32px));
  padding: 12px 16px; border-radius: 12px;
  background: var(--ink); color: var(--bg);
  font-size: 0.875rem; box-shadow: 0 6px 24px rgb(0 0 0 / 25%);
  z-index: 10;
}
.noscript { padding: 24px 16px; text-align: center; }

@media (min-width: 600px) {
  main { padding-top: 28px; }
  .card { padding: 22px 22px; }
  .tr { padding: 16px 18px 14px; }
  .steps li { font-size: 0.75rem; }
}
.warn-text { color: var(--warn); }

/* tabs */
.tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; padding: 4px; background: var(--idle-soft); border-radius: 12px; }
.tab {
  min-height: 42px; padding: 4px 6px; border: 0; border-radius: 9px; background: transparent; cursor: pointer;
  font-weight: 600; font-size: 0.875rem; line-height: 1.2; color: var(--muted);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.tab[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.tab-count { min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-size: 0.75rem; line-height: 20px; }
.panel { display: flex; flex-direction: column; gap: 10px; }

/* store */
.store-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 4px 2px 0; }
.store-head h2 { font-size: 1.0625rem; }
#store-meta, #store-msg, .min-hint { margin: 0 2px; }
.search {
  width: 100%; min-height: 44px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface); font-size: 16px;
}
.group-h { margin: 6px 2px 0; font-size: 0.8125rem; font-weight: 600; color: var(--muted); }
.grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.item {
  width: 100%; height: 100%; text-align: left; cursor: pointer;
  display: flex; flex-direction: column; gap: 6px; padding: 10px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.item:active { transform: scale(0.98); }
.item:hover { border-color: var(--accent); }
.thumb {
  aspect-ratio: 4 / 3; width: 100%; border-radius: 10px; overflow: hidden;
  background: radial-gradient(circle at 50% 40%, var(--surface), var(--idle-soft));
  display: flex; align-items: center; justify-content: center;
}
.thumb img { width: 100%; height: 100%; object-fit: contain; }
.thumb .ph { width: 40%; height: 40%; border-radius: 50%; background: var(--line); }
.item-name {
  font-size: 0.8125rem; font-weight: 600; line-height: 1.3; min-height: 2.6em;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere;
}
.item-sub { font-size: 0.6875rem; color: var(--muted); line-height: 1.35; overflow-wrap: anywhere; }
.item-price { margin-top: auto; font-weight: 700; font-size: 1rem; font-variant-numeric: tabular-nums; }
.paste { padding: 14px 16px; margin-top: 6px; }
.paste summary { cursor: pointer; font-weight: 600; color: var(--accent); font-size: 0.875rem; }
.paste form { margin-top: 10px; }
.panel > .how { border-top: 0; padding: 0 2px; margin-top: 0; }

/* confirm sheet */
.backdrop {
  position: fixed; inset: 0; z-index: 20; background: rgb(0 0 0 / 45%);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  width: 100%; max-width: 560px; background: var(--surface); color: var(--ink);
  border-radius: 18px 18px 0 0; padding: 20px 16px calc(16px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 10px; box-shadow: 0 -8px 32px rgb(0 0 0 / 25%);
  max-height: 90vh; overflow-y: auto;
}
.sheet-item { display: flex; gap: 12px; align-items: center; }
.sheet-item .thumb { width: 96px; flex: none; }
.sheet-text { min-width: 0; }
.sheet-name { font-weight: 600; overflow-wrap: anywhere; }
.sheet-q { font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.sheet-actions { display: grid; grid-template-columns: 1fr 2fr; gap: 10px; margin-top: 4px; }
.sheet-actions .primary { margin-top: 0; }
body.sheet-open { overflow: hidden; }
@media (min-width: 600px) {
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .backdrop { align-items: center; }
  .sheet { border-radius: 18px; }
}

.meter { height: 8px; border-radius: 999px; background: var(--idle-soft); overflow: hidden; }
.meter span { display: block; height: 100%; width: 0; border-radius: 999px; background: var(--accent); transition: width 0.4s ease; }
@media (prefers-reduced-motion: reduce) { .meter span { transition: none; } }
.group-note { margin: -4px 2px 2px; }
.item-later { font-size: 0.6875rem; font-weight: 600; color: var(--accent); }

/* history */
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.stat { margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; min-width: 0; }
.stat dt { font-size: 0.75rem; color: var(--muted); }
.stat dd { margin: 2px 0 0; font-weight: 700; font-size: 1.25rem; font-variant-numeric: tabular-nums; line-height: 1.25; white-space: nowrap; }
.stat .stat-sub { display: block; margin-top: 2px; font-size: 0.75rem; font-weight: 400; color: var(--muted); }
.hist-sec { display: flex; flex-direction: column; gap: 6px; }
.rows { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.rows li { padding: 10px 12px; display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; align-items: baseline; }
.rows li + li { border-top: 1px solid var(--line); }
.rows .r-main { font-weight: 600; font-variant-numeric: tabular-nums; }
.rows .r-date { font-size: 0.8125rem; color: var(--muted); text-align: right; white-space: nowrap; }
.rows .r-sub { grid-column: 1 / -1; font-size: 0.75rem; color: var(--muted); overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.rows .r-sub a { color: var(--accent); font-weight: 600; text-decoration: none; }
.rows .r-sub a:hover { text-decoration: underline; }
.rows .r-empty { color: var(--muted); font-size: 0.875rem; }
.rows .r-more { display: block; }
.rows .r-more button { border: 0; background: none; color: var(--accent); font-weight: 600; font-size: 0.8125rem; cursor: pointer; padding: 4px 0; min-height: 32px; }
@media (max-width: 379px) {
  .stats { grid-template-columns: 1fr; }
  .tab { font-size: 0.8125rem; padding: 4px 2px; }
}

/* history rows (tappable) */
.rows li { padding: 0; display: block; }
.rows li.r-empty { padding: 12px; }
.rows li.r-more { padding: 4px 12px; }
.hrow {
  width: 100%; display: flex; align-items: center; gap: 12px; padding: 10px 12px; text-align: left;
  border: 0; background: transparent; cursor: pointer; color: inherit;
}
.hrow:hover { background: var(--bg); }
.rows li:first-child .hrow { border-radius: var(--radius) var(--radius) 0 0; }
.rows li:last-child .hrow { border-radius: 0 0 var(--radius) var(--radius); }
.hrow .thumb { width: 64px; flex: none; aspect-ratio: 4 / 3; border-radius: 8px; }
.h-mid { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.h-title { font-weight: 600; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.with-thumb .h-title { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; font-size: 0.875rem; line-height: 1.3; }
.h-sub { font-size: 0.75rem; color: var(--muted); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.h-right { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.h-amount { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.h-date { font-size: 0.75rem; color: var(--muted); white-space: nowrap; }
.meter.small { height: 4px; margin-top: 3px; max-width: 220px; }

/* detail popup */
.detail { gap: 8px; }
.detail .thumb.big { width: 100%; max-width: 360px; margin: 0 auto 4px; aspect-ratio: 16 / 10; }
.detail-kind { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.detail-title { font-size: 1.125rem; overflow-wrap: anywhere; }
.detail-amount { font-size: 1.75rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; }
.detail-kv { margin: 6px 0 0; font-size: 0.875rem; }
.detail-kv dd { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.mono-wrap { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 0.8125rem; overflow-wrap: anywhere; }
.hash {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 0.8125rem; overflow-wrap: anywhere; word-break: break-all;
  background: var(--bg); border-radius: 8px; padding: 10px 12px;
}
.detail-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.link-btn { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; min-height: 40px; padding: 0 14px; margin-top: 0; font-size: 0.875rem; }
.detail-actions .ghost.small { min-height: 40px; }
.rows.mini .hrow .thumb { width: 52px; }
#detail-close { margin-top: 6px; }

/* switching tabs never collapses the page (that made the browser jump back to the top) */
.panel { min-height: calc(100vh - 72px); }

/* popups ease in instead of snapping */
.backdrop:not([hidden]) { animation: bb-fade 0.16s ease-out; }
.backdrop:not([hidden]) .sheet { animation: bb-rise 0.22s cubic-bezier(0.2, 0.8, 0.2, 1); }
@keyframes bb-fade { from { background-color: rgb(0 0 0 / 0%); } }      /* not opacity: that would fade the sheet too */
@keyframes bb-rise { from { transform: translateY(32px); } }
@media (min-width: 600px) { @keyframes bb-rise { from { transform: translateY(10px) scale(0.985); } } }
@media (prefers-reduced-motion: reduce) { .backdrop:not([hidden]), .backdrop:not([hidden]) .sheet { animation: none; } }
#detail-body { display: flex; flex-direction: column; gap: 6px; }

/* payment popup: the hash and its two actions as one block */
.sheet:focus { outline: none; }
.tx-box { margin-top: 8px; display: flex; flex-direction: column; gap: 8px; }
.tx-label { font-size: 0.75rem; font-weight: 600; color: var(--muted); }
.tx-box .hash { margin: 0; }
.detail-actions { display: grid; grid-template-columns: auto 1fr; gap: 8px; }
.detail-actions .ghost.small, .detail-actions .link-btn { min-height: 44px; font-size: 0.875rem; }
.detail-actions .ghost.small { padding: 0 18px; }

/* suggested listing sizes */
.plan { display: flex; flex-direction: column; gap: 8px; padding: 14px 16px; }
.plan h3 { margin: 0; font-size: 0.9375rem; }
.plan-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-amt {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; cursor: pointer; text-align: left;
  min-height: 52px; padding: 8px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: inherit;
}
.chip-amt b { font-size: 1.0625rem; font-variant-numeric: tabular-nums; }
.chip-amt span { font-size: 0.75rem; color: var(--muted); }
.chip-amt.now { border-color: var(--accent); }
.chip-amt.now span { color: var(--accent); font-weight: 600; }

/* multi-select */
.item { position: relative; }
.item.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.item .tick {
  position: absolute; top: 8px; right: 8px; width: 24px; height: 24px; border-radius: 50%;
  border: 2px solid var(--line); background: var(--surface); display: flex; align-items: center; justify-content: center;
  font-size: 0.875rem; font-weight: 700; color: var(--accent-ink);
}
.item.selected .tick { background: var(--accent); border-color: var(--accent); }
.selbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 15;
  padding: 10px max(16px, env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: var(--surface); border-top: 1px solid var(--line); box-shadow: 0 -6px 24px rgb(0 0 0 / 10%);
}
.selbar-in { max-width: var(--page-w); margin: 0 auto; display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center; }
.selbar-text { display: flex; flex-direction: column; min-width: 0; font-size: 0.8125rem; color: var(--muted); }
.selbar-total { font-size: 1.0625rem; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.selbar .primary { margin-top: 0; }
body.has-selbar main { padding-bottom: 110px; }
body.has-selbar .toast { bottom: calc(96px + env(safe-area-inset-bottom)); }

/* confirm sheet list + per-row result */
.sheet-list { border-radius: 12px; }
.sheet-list li { display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; align-items: center; column-gap: 12px; row-gap: 6px; padding: 10px 12px; }
.sheet-list .thumb { width: 56px; aspect-ratio: 4 / 3; border-radius: 8px; }
.sheet-list .h-mid { min-width: 0; }
.sheet-list .h-title { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; font-size: 0.875rem; line-height: 1.3; }
.sheet-list .h-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet-list .h-amount { justify-self: end; }
.sl-status { grid-column: 1 / -1; font-size: 0.8125rem; font-weight: 600; line-height: 1.35; }
.sl-status.err { background: var(--bad-soft); border-radius: 8px; padding: 8px 10px; }
.sl-status.ok { color: var(--good); }
.sl-status.err { color: var(--bad); }
.sl-status.busy { color: var(--muted); }
.sl-status.note { color: var(--muted); font-weight: 400; }

/* history: rows from before the ledger opening, collapsed */
.rows li.r-old { padding: 0; }
.r-old details summary { cursor: pointer; padding: 10px 12px; font-size: 0.8125rem; font-weight: 600; color: var(--muted); }
.r-old .rows { border: 0; border-top: 1px solid var(--line); border-radius: 0; background: transparent; }
.stats .stat.open dd { color: var(--accent); }



/* sign-in card never stretches on wide screens */
.login { width: 100%; max-width: 460px; margin-left: auto; margin-right: auto; }

/* PC: wallet in a sticky left column, tabs + content on the right, wider grids */
@media (min-width: 1000px) {
  :root { --page-w: 1200px; }
  main { padding-top: 28px; }
  #view-app { display: grid; grid-template-columns: 380px minmax(0, 1fr); column-gap: 28px; row-gap: 16px; align-items: start; }
  #view-app > .wallet { grid-column: 1; grid-row: 1 / span 2; position: sticky; top: 84px; }
  #view-app > .tabs, #view-app > .panel { grid-column: 2; }
  #view-app > .tabs { grid-row: 1; }
  #view-app > .panel { grid-row: 2; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  body.has-selbar main { padding-bottom: 100px; }
}
@media (min-width: 1400px) {
  :root { --page-w: 1320px; }
  #view-app { grid-template-columns: 400px minmax(0, 1fr); column-gap: 32px; }
}

/* whose balance + device login */
.wallet-title { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.w-owner { font-size: 1.0625rem; font-weight: 700; color: var(--ink); overflow-wrap: anywhere; }
.device-btn { margin-top: 12px; width: 100%; }
.qr-box { align-self: center; width: min(260px, 70vw); aspect-ratio: 1; border-radius: 12px; overflow: hidden; background: #fff; }
.qr-box:empty { background: var(--idle-soft); }
.qr-box svg { display: block; width: 100%; height: 100%; }
.device .detail-actions { align-items: center; }
.device-exp { margin: 0; font-size: 0.8125rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.device .sheet-actions { grid-template-columns: 1fr 1fr; }
.device #device-new[hidden] + #device-close { grid-column: 1 / -1; }

/* requests paused (owner hasn't sent /go, or buyer not enabled) */
.pause-banner { margin: 0; padding: 12px 14px; border-radius: 12px; background: var(--warn-soft); color: var(--warn); font-size: 0.875rem; font-weight: 600; }
.item:disabled { cursor: default; }
.item:disabled:active { transform: none; }
.item:disabled:hover { border-color: var(--line); }
textarea:disabled { opacity: 0.6; }
@media (min-width: 1000px) {
  #view-app { row-gap: 0; }
  #view-app > .wallet { grid-row: 1 / span 3; }
  #view-app > .tabs { grid-row: 2; margin-bottom: 16px; }
  #view-app > .panel { grid-row: 3; }
}

.plan-all { margin: 2px 0 0; font-weight: 700; font-size: 1rem; color: var(--accent); }
.sheet-actions.single { grid-template-columns: 1fr; }

/* 1 / 2 / 3 listings switch */
.plan-switch { display: flex; gap: 4px; padding: 4px; background: var(--idle-soft); border-radius: 10px; }
.plan-switch .opt {
  flex: 1; min-height: 38px; border: 0; border-radius: 7px; background: transparent; cursor: pointer; color: var(--muted);
  font-size: 0.8125rem; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 4px 6px;
}
.plan-switch .opt.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.opt-tag { font-size: 0.6875rem; font-weight: 700; color: var(--accent); background: var(--accent-soft); border-radius: 999px; padding: 1px 7px; }

/* per-listing: bought right away vs saved up first */
.item-when { font-size: 0.6875rem; font-weight: 600; color: var(--warn); }
.item-when.now { color: var(--good); }
.sheet-list .item-when { display: block; margin-top: 2px; }
/* test mode (paper) */
.paper-banner { margin: 0; padding: 12px 14px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); font-size: 0.875rem; font-weight: 600; }
.pills { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.test-tag { display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 6px; font-size: 0.6875rem; font-weight: 700; letter-spacing: 0.04em;
  color: var(--accent); border: 1px solid var(--accent); vertical-align: middle; }
.pills .test-tag { margin-left: 0; }
@media (min-width: 1000px) {
  #view-app > .banners { grid-column: 2; grid-row: 1; margin-bottom: 16px; }
}
.banners { display: flex; flex-direction: column; gap: 8px; }

/* request card: the item first, then status */
.tr-head { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: 12px; align-items: center; margin-bottom: 10px; }
.tr-head .thumb { width: 64px; aspect-ratio: 4 / 3; border-radius: 8px; }
.tr-text { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.tr-name { font-weight: 600; font-size: 0.9375rem; line-height: 1.3; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tr-sub { font-size: 0.75rem; color: var(--muted); line-height: 1.35; overflow-wrap: anywhere; }
.tr-head .tr-price { align-self: start; }
.timeline li.warn::before { border-color: var(--warn); }
.timeline li.bad::before { border-color: var(--bad); }

/* history delivery status chip */
.st-chip { display: inline-block; padding: 1px 7px; border-radius: 6px; font-size: 0.6875rem; font-weight: 700; vertical-align: middle; }
.st-chip.final { color: var(--good); background: var(--good-soft); }
.st-chip.pending { color: var(--warn); background: var(--warn-soft); }
.st-chip.closed { color: var(--muted); background: var(--line); }
.h-right .st-chip { margin-top: 2px; }

/* History: requests on their way to becoming a delivery */
.rows li.r-prog { padding: 0; border-bottom: 1px solid var(--line); }
.r-prog-h { margin: 0; padding: 10px 12px 2px; font-size: 0.8125rem; font-weight: 600; color: var(--accent); }
.r-prog .rows { border: 0; border-radius: 0; background: transparent; }
.st-chip.prog { color: var(--accent); background: var(--accent-soft); }
.tr-note.action { font-weight: 600; border-left: 3px solid var(--warn); }

/* readiness: how much of the buyer's own balance is ready to deliver now */
.ready { margin: -4px 0 14px; display: flex; flex-direction: column; gap: 6px; }
.ready.full .meter span { background: var(--good); }
.ready-line { font-weight: 600; font-size: 0.9375rem; font-variant-numeric: tabular-nums; }

/* buy more balance */
.dep-btn { width: 100%; margin-top: 12px; }
.spent h3 { margin: 0 0 6px; font-size: 1.0625rem; }
.spent p { margin: 0 0 14px; line-height: 1.45; }
.spent-actions { display: flex; flex-direction: column; gap: 8px; }
.spent-actions button { width: 100%; margin-top: 0; }
@media (min-width: 640px) { .spent-actions { flex-direction: row; } .spent-actions button { width: auto; flex: 1; } }
.dep-btn + .device-btn { margin-top: 8px; }
.dep { display: flex; flex-direction: column; gap: 14px; }
#dep-on { display: flex; flex-direction: column; gap: 14px; }
#dep-on[hidden] { display: none; }
/* buy flow: 1 amount -> 2 pay -> 3 credited */
.dep-steps { display: flex; gap: 6px; margin: 0; padding: 0; list-style: none; counter-reset: st; }
.dep-steps li { flex: 1; counter-increment: st; padding-top: 8px; border-top: 3px solid var(--line); font-size: 0.75rem; font-weight: 600; color: var(--muted); }
.dep-steps li::before { content: counter(st) " · "; }
.dep-steps li.on { border-color: var(--accent); color: var(--ink); }
.dep-steps li.done { border-color: var(--accent); color: var(--accent); }
.dep-step { display: flex; flex-direction: column; gap: 12px; }
.dep-step[hidden] { display: none; }
.dep-q { font-size: 1.0625rem; font-weight: 700; }
.dep-amt { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 4px;
  padding: 6px 6px 6px 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--bg); }
.dep-amt:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.dep-cur { font-size: 1.75rem; font-weight: 600; color: var(--muted); }
.dep-amt input { min-height: 56px; border: 0; background: transparent; padding: 0 4px; font-size: 2rem; font-weight: 700;
  font-variant-numeric: tabular-nums; box-shadow: none; }
.dep-amt input:focus { box-shadow: none; }
.dep-swap { min-height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
  cursor: pointer; font-size: 0.8125rem; font-weight: 600; color: var(--ink); white-space: nowrap; }
.dep-eq { margin: -4px 0 0 4px; font-size: 0.9375rem; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; min-height: 1.3em; }
.dep-quick { display: flex; flex-wrap: wrap; gap: 6px; }
.dep-pick { min-height: 36px; padding: 0 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
  cursor: pointer; font-size: 0.875rem; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.dep-pick.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.dep-step .field-msg:empty { display: none; }
.dep-acc { display: grid; grid-template-columns: 72px minmax(0, 1fr); align-items: center; gap: 8px; }
.dep-acc-h { font-size: 0.75rem; font-weight: 600; letter-spacing: 0.02em; color: var(--muted); }
.dep-seg { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 6px; }
.dep-opt { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; padding: 8px 12px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--surface); cursor: pointer; color: var(--ink); text-align: left; }
.dep-opt b { font-size: 0.875rem; }
.dep-opt small { font-size: 0.75rem; color: var(--muted); }
.dep-opt.on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.dep-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.dep-tag { display: inline-flex; align-items: baseline; gap: 6px; padding: 4px 10px; border-radius: 999px; background: var(--surface);
  border: 1px solid var(--line); color: var(--ink); font-weight: 700; font-size: 0.8125rem; white-space: nowrap; }
.dep-rate { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 12px; margin: 0; font-size: 0.8125rem; }
.dep-rate div { display: contents; }
.dep-rate dt { color: var(--muted); }
.dep-rate dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.dep-rate dd small { display: block; font-weight: 400; font-size: 0.75rem; color: var(--muted); }
.dep-go { width: 100%; margin-top: 4px; }

/* 2. pay: summary beside the payment box (stacked on phones) */
/* phones: one column, pay box -> status -> done -> not accepted -> summary; PC: summary | pay box, then the rest */
.dep-pay { display: contents; }
#dep-send-box { order: 1; } #dep-status { order: 2; } #dep-done { order: 3; } #dep-not { order: 4; } #dep-sum { order: 5; }
.dep-send-box[hidden], .dep-not[hidden] { display: none; }
.dep-amt input::placeholder { color: var(--muted); opacity: 0.45; }
.dep-sum { display: flex; flex-direction: column; gap: 10px; padding: 14px; border-radius: 12px; background: var(--idle-soft); align-self: start; }
.dep-sum-h { display: flex; align-items: center; justify-content: space-between; font-weight: 700; }
.dep-sum-h .link-btn { min-height: 32px; padding: 0 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); cursor: pointer; color: var(--ink); }
.dep-sum-kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 12px; margin: 0; font-size: 0.875rem; }
.dep-sum-kv dt { color: var(--muted); }
.dep-sum-kv dd { margin: 0; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.dep-sum-kv dd:nth-of-type(2) { font-size: 1rem; }
.dep-sum .fine { margin: 0; }
.dep-sum [hidden], .dep-step [hidden] { display: none; }
.dep-send-box { display: flex; flex-direction: column; align-items: center; gap: 10px; min-width: 0; }
.dep-send-h { margin: 0; font-weight: 700; text-align: center; }
.dep .qr-box { width: 200px; border: 1px solid var(--line); }
.dep-addr-box { width: 100%; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 6px;
  padding: 4px 4px 4px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); }
.dep-addr { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 0.8125rem; word-break: break-all; line-height: 1.4; }
.dep-addr-box .ghost.small { min-height: 36px; }
.dep-copy-amt { width: 100%; }
.dep-fee { margin: 0; font-size: 0.8125rem; line-height: 1.45; text-align: center; color: var(--ink); }
.dep-moved { order: 0; margin: 0; padding: 8px 12px; border-radius: 8px; background: var(--warn-soft); color: var(--warn); font-size: 0.8125rem; font-weight: 600; }
.dep-moved:empty { display: none; }
.dep-same { margin: 0; font-size: 0.8125rem; color: var(--muted); text-align: center; }
.dep-same:empty { display: none; }
.dep-not { margin: 0; padding: 8px 12px; border-left: 3px solid var(--warn); border-radius: 0 8px 8px 0; background: var(--idle-soft);
  font-size: 0.8125rem; line-height: 1.45; color: var(--ink); }
.dep-status { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line);
  font-size: 0.875rem; font-weight: 600; line-height: 1.45; }
.dep-dot { flex: none; width: 10px; height: 10px; margin-top: 5px; border-radius: 50%; background: var(--muted); }
.dep-status.wait .dep-dot, .dep-status.busy .dep-dot { background: var(--warn); animation: dep-pulse 1.4s ease-in-out infinite; }
.dep-status.ok { border-color: var(--good); color: var(--good); }
.dep-status.ok .dep-dot { background: var(--good); }
.dep-status.review .dep-dot { background: var(--warn); }
@keyframes dep-pulse { 0%, 100% { box-shadow: 0 0 0 0 var(--warn-soft, rgba(176, 106, 0, 0.35)); } 50% { box-shadow: 0 0 0 6px transparent; } }
@media (prefers-reduced-motion: reduce) { .dep-status .dep-dot { animation: none; } }
@media (min-width: 640px) {
  .dep-pay { display: grid; order: 1; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 20px; }
  .dep-pay .dep-sum { grid-column: 1; grid-row: 1; }
  .dep-pay .dep-send-box { grid-column: 2; grid-row: 1; }
  .dep-pay:has(.dep-send-box[hidden]) { grid-template-columns: 1fr; }
  .dep-go { width: auto; align-self: flex-end; min-width: 200px; }
}
.field-msg.warn-text { color: var(--warn); }
