/* Wallet Trace — "security print" design system.
   Bottle-green banknote ink, gold foil only for money, a guilloche rosette as the one ornament.
   Logical properties throughout: the same rules lay out Persian/Arabic (rtl) and English (ltr). */

/* ---- type ------------------------------------------------------------------------------------ */
@font-face { font-family: "Vazirmatn"; font-weight: 100 900; font-display: swap; src: url("/static/fonts/Vazirmatn-wght.woff2") format("woff2"); }
@font-face { font-family: "Plex Mono"; font-weight: 400; font-display: swap; src: url("/static/fonts/ibm-plex-mono-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Plex Mono"; font-weight: 500; font-display: swap; src: url("/static/fonts/ibm-plex-mono-latin-500-normal.woff2") format("woff2"); }

/* ---- tokens ---------------------------------------------------------------------------------- */
:root {
  --paper: #0f241d;        /* bottle-green ink: the page */
  --surface: #15312a;      /* the vault: panels */
  --surface-2: #1b3b32;    /* raised: rows on hover, chips */
  --line: #264a3f;
  --line-strong: #3a5e51;
  --ink: #e4eee8;
  --muted: #93ada1;
  --jade: #2e9e76;         /* actions */
  --jade-ink: #f2fbf6;
  --jade-soft: #2e9e7626;
  --foil: #cfae62;         /* money and the traced wallet */
  --risk: #d9614f;
  --warn: #e2b04a;
  --in: #59c99c;
  --out: #e2b04a;
  --scrim: rgba(4, 12, 9, .62);
  --shadow: 0 18px 48px rgba(0, 0, 0, .35);
  --r-sheet: 22px; --r-panel: 16px; --r-row: 12px; --r-ctl: 10px;
  --fs-xs: 12.5px; --fs-s: 13.5px; --fs-m: 15px; --fs-l: 17px; --fs-xl: 21px; --fs-2xl: 28px; --fs-3xl: 36px;
  --gutter: 16px; --tab-h: 62px;
  --sans: "Vazirmatn", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --paper: #edf2ec; --surface: #fbfcf9; --surface-2: #eef4ee; --line: #d3ded5; --line-strong: #b8c9bd;
  --ink: #13291f; --muted: #587064; --jade: #1e7d5b; --jade-ink: #ffffff; --jade-soft: #1e7d5b1f;
  --foil: #8f7027; --risk: #c2493a; --warn: #a8761b; --in: #1e7d5b; --out: #a8761b;
  --scrim: rgba(19, 41, 31, .38); --shadow: 0 18px 44px rgba(19, 41, 31, .14);
  color-scheme: light;
}

/* ---- base ------------------------------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; background: var(--paper); color: var(--ink); }
body { font: 400 var(--fs-m)/1.75 var(--sans); min-height: 100vh; -webkit-tap-highlight-color: transparent; }
:lang(en) body, body:lang(en) { line-height: 1.6; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; text-align: inherit; }
a { color: inherit; text-decoration: none; }
p { margin: 0; }
h1, h2, h3 { margin: 0; font-weight: 600; }
.i { width: 1.15em; height: 1.15em; flex: none; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
[dir="rtl"] .i-back, [dir="rtl"] .i-chevron, [dir="rtl"] .i-arrowIn, [dir="rtl"] .i-arrowOut, [dir="rtl"] .i-flow { transform: scaleX(-1); }
.mono { font-family: var(--mono); font-size: .92em; letter-spacing: -.01em; }
.num { font-variant-numeric: tabular-nums; unicode-bidi: isolate; direction: ltr; }
.display { font-family: var(--sans); font-weight: 800; letter-spacing: -.01em; }
.muted { color: var(--muted); }
.small { font-size: var(--fs-s); }
.fine { font-size: var(--fs-xs); color: var(--muted); line-height: 1.7; }
.hidden { display: none !important; }
.bad-text { color: var(--risk); }
:focus-visible { outline: 2px solid var(--foil); outline-offset: 2px; border-radius: 6px; }
::selection { background: var(--jade-soft); }

#app { max-width: 1120px; margin: 0 auto; padding: 8px var(--gutter) calc(var(--tab-h) + 32px + env(safe-area-inset-bottom)); }
.page { display: flex; flex-direction: column; gap: 18px; }

/* ---- app bar --------------------------------------------------------------------------------- */
.bar { display: flex; align-items: center; gap: 12px; min-height: 52px; position: sticky; top: 0; z-index: 20; margin: 0 calc(-1 * var(--gutter));
  padding: 6px var(--gutter); background: color-mix(in srgb, var(--paper) 88%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.mark { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; border: 1px solid var(--line-strong); color: var(--foil); flex: none; }
.mark-svg { width: 30px; height: 30px; }
.mark-svg path { stroke-width: 3.2; opacity: .9; }
.bar-title { flex: 1; min-width: 0; font-size: var(--fs-xl); line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-end { display: flex; align-items: center; gap: 8px; }
.pill { font-size: var(--fs-xs); padding: 4px 11px; border-radius: 999px; border: 1px solid var(--line-strong); color: var(--muted); white-space: nowrap; }
.pill.ok { color: var(--in); border-color: color-mix(in srgb, var(--in) 45%, var(--line)); }
.pill.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); }
.icon-btn { width: 38px; height: 38px; display: grid; place-items: center; border-radius: var(--r-ctl); border: 1px solid var(--line); background: var(--surface); color: var(--ink); flex: none; transition: border-color .15s, background .15s; }
.icon-btn:hover { border-color: var(--line-strong); }
.icon-btn .i { width: 18px; height: 18px; }

/* ---- buttons, inputs, choices ---------------------------------------------------------------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 18px; border-radius: var(--r-ctl);
  font-weight: 600; font-size: var(--fs-m); line-height: 1.3; transition: transform .08s ease, background .15s, border-color .15s, opacity .15s; }
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .42; pointer-events: none; }
.btn.primary { background: var(--jade); color: var(--jade-ink); }
.btn.primary:hover { background: color-mix(in srgb, var(--jade) 88%, #fff); }
.btn.quiet { border: 1px solid var(--line-strong); color: var(--ink); background: transparent; }
.btn.quiet:hover { background: var(--surface-2); }
.btn.danger { border: 1px solid color-mix(in srgb, var(--risk) 55%, var(--line)); color: var(--risk); background: transparent; }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: var(--fs-s); }
.btn.block { width: 100%; min-height: 50px; font-size: var(--fs-l); }
.btn .i { width: 17px; height: 17px; }
.text-link { color: var(--jade); font-size: var(--fs-s); font-weight: 600; }
:root[data-theme="dark"] .text-link { color: var(--in); }

.input { width: 100%; min-height: 46px; padding: 10px 14px; border-radius: var(--r-ctl); border: 1px solid var(--line-strong); background: var(--paper); outline: none; transition: border-color .15s, box-shadow .15s; }
.input:focus { border-color: var(--jade); box-shadow: 0 0 0 3px var(--jade-soft); }
.input::placeholder, .slip-input::placeholder { color: var(--muted); opacity: .8; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field > label { font-size: var(--fs-s); color: var(--muted); }

.seg { display: flex; gap: 2px; padding: 3px; border-radius: var(--r-ctl); background: var(--paper); border: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg button { flex: 1 0 auto; min-height: 34px; padding: 5px 12px; border-radius: 8px; color: var(--muted); font-size: var(--fs-s); white-space: nowrap; text-align: center; transition: background .15s, color .15s; }
.seg button.on { background: var(--surface-2); color: var(--ink); font-weight: 600; box-shadow: inset 0 0 0 1px var(--line-strong); }

.tabs { display: flex; gap: 22px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; position: sticky; top: 52px; z-index: 15;
  background: color-mix(in srgb, var(--paper) 92%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { position: relative; flex: none; padding: 12px 0 11px; color: var(--muted); font-size: var(--fs-m); white-space: nowrap; transition: color .15s; }
.tabs button::after { content: ""; position: absolute; inset-inline: 0; bottom: -1px; height: 2px; border-radius: 2px; background: var(--foil); transform: scaleX(0); transition: transform .2s ease; }
.tabs button.on { color: var(--ink); font-weight: 600; }
.tabs button.on::after { transform: scaleX(1); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { min-height: 32px; padding: 4px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-size: var(--fs-s); color: var(--ink); transition: background .15s, border-color .15s; }
.chip.on { background: var(--jade-soft); border-color: var(--jade); color: var(--ink); font-weight: 600; }
.tag { display: inline-flex; align-items: center; gap: 5px; padding: 1px 9px; border-radius: 999px; font-size: var(--fs-xs); border: 1px solid var(--line-strong); color: var(--muted); white-space: nowrap; font-weight: 500; }
.tag[style*="--k"] { border-color: color-mix(in srgb, var(--k) 55%, var(--line)); color: var(--ink); }
.tag.ok { color: var(--in); border-color: color-mix(in srgb, var(--in) 45%, var(--line)); }
.tag.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); }
.tag.bad { color: var(--risk); border-color: color-mix(in srgb, var(--risk) 55%, var(--line)); }
.tag.soft { border-style: dashed; }
.tag.foil { color: var(--foil); border-color: color-mix(in srgb, var(--foil) 55%, var(--line)); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }

details.more > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px; min-height: 40px; color: var(--muted); font-size: var(--fs-s); }
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::after { content: ""; width: 7px; height: 7px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: translateY(-2px) rotate(45deg); margin-inline-start: auto; transition: transform .2s; flex: none; }
details.more[open] > summary::after { transform: translateY(2px) rotate(225deg); }
details.more[open] > summary { color: var(--ink); }
details.more > :not(summary) { margin-top: 10px; }
details.more > .field + .field { margin-top: 14px; }

.switch { display: flex; align-items: center; gap: 10px; width: 100%; padding: 11px 13px; border-radius: var(--r-ctl); border: 1px dashed var(--line-strong); font-size: var(--fs-s); text-align: start; }
.switch-box { width: 20px; height: 20px; border-radius: 6px; border: 1.5px solid var(--line-strong); display: grid; place-items: center; flex: none; }
.switch.on { border-color: var(--risk); border-style: solid; background: color-mix(in srgb, var(--risk) 9%, transparent); }
.switch.on .switch-box { background: var(--risk); border-color: var(--risk); color: #fff; }
.switch-box .i { width: 14px; height: 14px; stroke-width: 2.4; }

/* ---- sections and lists ---------------------------------------------------------------------- */
.section { display: flex; flex-direction: column; gap: 12px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.section-head h2 { font-size: var(--fs-l); }
.block { padding: 16px; border-radius: var(--r-panel); background: var(--surface); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 12px; }
.block-title { display: flex; align-items: center; gap: 8px; font-size: var(--fs-m); }
details.block > summary { min-height: 28px; color: var(--ink); font-weight: 600; font-size: var(--fs-m); }
.panel-stack { display: flex; flex-direction: column; gap: 14px; }
.stack-gap { display: flex; flex-direction: column; gap: 12px; }

.rows { display: flex; flex-direction: column; border-radius: var(--r-panel); background: var(--surface); border: 1px solid var(--line); overflow: hidden; }
.rows > .row + .row, .rows > .entry + .entry { border-top: 1px solid var(--line); }
.row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 14px; min-height: 60px; text-align: start; transition: background .15s; position: relative; }
button.row:hover, a.row:hover { background: var(--surface-2); }
.row.static { cursor: default; }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.row-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; gap: 6px; }
.row-title.mono { font-weight: 500; }
.row-sub { font-size: var(--fs-s); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: pre; }
.row-end { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; flex: none; text-align: end; }
.badge { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; flex: none; color: var(--k, var(--muted)); border: 1.5px solid color-mix(in srgb, var(--k, var(--muted)) 60%, transparent);
  background: color-mix(in srgb, var(--k, var(--muted)) 10%, transparent); }
.badge .i { width: 18px; height: 18px; }
.badge.plain { --k: var(--muted); }
.amount { font-weight: 600; font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; white-space: nowrap; display: inline-flex; align-items: center; gap: 3px; }
.amount.in, .in-text { color: var(--in); } .amount.out, .out-text { color: var(--out); }
.amount .i { width: 14px; height: 14px; }
.flows { gap: 0; }
.more-btn { align-self: center; }

.ledger { display: flex; flex-direction: column; border-radius: var(--r-panel); background: var(--surface); border: 1px solid var(--line); overflow: hidden; }
.ledger-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px 15px; position: relative; text-align: start; width: 100%; }
.ledger-row + .ledger-row { border-top: 1px solid var(--line); }
.row-bar { position: absolute; inset-inline-start: 14px; bottom: 6px; height: 2px; width: calc(var(--w) * .92); background: var(--foil); opacity: .55; border-radius: 2px; }
.share { font-size: var(--fs-xs); color: var(--muted); }
.token { width: 36px; height: 36px; border-radius: 50%; flex: none; display: grid; place-items: center; overflow: hidden; position: relative; background: var(--surface-2); border: 1px solid var(--line);
  font-size: 11px; font-weight: 700; color: var(--muted); font-family: var(--mono); }
.token img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.total-line { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 4px 2px; }
.total-line .value { font-size: var(--fs-2xl); color: var(--foil); font-weight: 600; }

.entry { padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.entry-head { display: flex; align-items: center; gap: 12px; }
.entry-line { font-size: var(--fs-s); line-height: 1.8; overflow-wrap: anywhere; }
.copyable { cursor: copy; text-align: start; }

.empty { text-align: center; padding: 36px 20px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 16px; }
.rows .empty { padding: 28px 16px; }
.skel { height: 64px; border-radius: var(--r-panel); background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 50%, var(--surface) 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; }
.skel.tall { height: 220px; }
@keyframes shimmer { to { background-position: -200% 0; } }

.notice { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: var(--r-row); border: 1px solid var(--line); background: var(--surface); font-size: var(--fs-s); line-height: 1.75; text-align: start; width: 100%; }
.notice .i { margin-top: 3px; }
.notice.warn { border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); color: var(--ink); }
.notice.warn .i { color: var(--warn); }
.notice.bad { border-color: color-mix(in srgb, var(--risk) 55%, var(--line)); background: color-mix(in srgb, var(--risk) 8%, var(--surface)); }
.notice.bad .i { color: var(--risk); }
.notes { padding: 0 2px; }
.note-list { margin: 0; padding-inline-start: 18px; color: var(--muted); font-size: var(--fs-s); line-height: 1.85; }
.meta-line { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }

/* ---- sheet and toast ------------------------------------------------------------------------- */
.scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 40; animation: fade .2s both; }
.sheet { position: fixed; inset-inline: 0; bottom: 0; z-index: 41; max-width: 640px; margin: 0 auto; max-height: 86vh; overflow: auto; overscroll-behavior: contain;
  background: var(--surface); border: 1px solid var(--line); border-bottom: 0; border-radius: var(--r-sheet) var(--r-sheet) 0 0; box-shadow: var(--shadow);
  padding: 22px 20px calc(24px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 16px; animation: rise .28s cubic-bezier(.2, .8, .2, 1) both; outline: none; }
.sheet::before { content: ""; position: absolute; top: 8px; inset-inline: 0; margin: 0 auto; width: 40px; height: 4px; border-radius: 2px; background: var(--line-strong); }
.sheet-x { position: absolute; top: 14px; inset-inline-end: 14px; width: 34px; height: 34px; }
.sheet-title { font-size: var(--fs-xl); line-height: 1.35; padding-inline-end: 44px; overflow-wrap: anywhere; }
.sheet-title.with-icon, .sheet-title.pair { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sheet-title.pair .i { color: var(--muted); }
@media (min-width: 720px) { .sheet { bottom: auto; top: 50%; transform: translateY(-50%); border-radius: var(--r-sheet); border-bottom: 1px solid var(--line); max-height: 82vh; animation: pop .22s ease both; } .sheet::before { display: none; } }
@keyframes rise { from { transform: translateY(100%); } to { transform: none; } }
@keyframes pop { from { opacity: 0; transform: translateY(-48%) scale(.98); } to { opacity: 1; transform: translateY(-50%); } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.kv { display: grid; grid-template-columns: minmax(84px, auto) 1fr; gap: 8px 16px; margin: 0; font-size: var(--fs-s); }
.kv dt { color: var(--muted); } .kv dd { margin: 0; overflow-wrap: anywhere; }
.addr { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; border-radius: var(--r-ctl); background: var(--paper); border: 1px solid var(--line); font-size: var(--fs-s); cursor: copy; text-align: start; }
.addr .mono { flex: 1; direction: ltr; text-align: left; overflow-wrap: anywhere; }
.addr .i { color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.node-head { display: flex; align-items: flex-start; gap: 12px; padding-inline-end: 40px; }
.node-head .sheet-title { padding-inline-end: 0; }
.grow-box, .admin-box { padding: 14px; border-radius: var(--r-row); border: 1px dashed var(--line-strong); display: flex; flex-direction: column; gap: 10px; }
.grow-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grow-row .seg { flex: 1; min-width: 200px; }
.grow-row .input { flex: 1; min-width: 160px; }
.list-title { display: flex; align-items: baseline; gap: 8px; font-size: var(--fs-m); margin-top: 4px; }
.count { font-size: var(--fs-xs); color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 500; }
.toast { position: fixed; bottom: calc(var(--tab-h) + 18px + env(safe-area-inset-bottom)); inset-inline: 16px; margin: 0 auto; width: fit-content; max-width: min(520px, calc(100vw - 32px)); z-index: 60;
  padding: 11px 18px; border-radius: var(--r-row); background: var(--ink); color: var(--paper); font-size: var(--fs-s); box-shadow: var(--shadow); animation: fade .2s both; }
.toast.bad { background: var(--risk); color: #fff; }

/* ---- transfers ------------------------------------------------------------------------------- */
.evs { display: flex; flex-direction: column; }
.ev { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 11px 2px; border-bottom: 1px solid var(--line); width: 100%; text-align: start; font-size: var(--fs-s); }
.ev:last-child { border-bottom: 0; }
.ev.link .ev-main { cursor: copy; }
.ev.link:hover { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.ev-end { display: flex; align-items: center; gap: 8px; }
.icon-btn.tiny { width: 30px; height: 30px; border-radius: 8px; background: transparent; }
.icon-btn.tiny .i { width: 15px; height: 15px; color: var(--muted); }
.ev-dir { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; border: 1px solid var(--line); color: var(--muted); }
.ev-dir.in { color: var(--in); border-color: color-mix(in srgb, var(--in) 40%, var(--line)); }
.ev-dir.out { color: var(--out); border-color: color-mix(in srgb, var(--out) 40%, var(--line)); }
.ev-dir .i { width: 15px; height: 15px; }
.ev-main { min-width: 0; display: flex; flex-direction: column; text-align: start; width: 100%; }
.ev-what { font-weight: 600; display: flex; align-items: center; gap: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ev-what .i { width: 15px; height: 15px; color: var(--muted); }
.ev-when { color: var(--muted); font-size: var(--fs-xs); white-space: pre; }
.ev-who { color: var(--muted); font-size: var(--fs-xs); display: flex; align-items: center; gap: 4px; min-width: 0; overflow: hidden; white-space: nowrap; }
.ev-who bdi { overflow: hidden; text-overflow: ellipsis; max-width: 45%; }
.ev-who .i { width: 12px; height: 12px; flex: none; }
.ev-usd { font-weight: 600; font-size: var(--fs-s); color: var(--ink); }
.ev-block { display: flex; flex-direction: column; gap: 4px; }
.list-sum { font-size: var(--fs-s); font-weight: 600; }
.filters { display: flex; flex-direction: column; gap: 10px; }

/* ---- home ------------------------------------------------------------------------------------ */
.hero { display: flex; flex-direction: column; gap: 14px; padding-top: 18px; }
.hero.compact { padding-top: 8px; gap: 8px; }
.hero.sos h1 { color: var(--risk); }
.btn.primary.sos { background: var(--risk); }
.hero h1 { font-size: var(--fs-3xl); line-height: 1.25; }
.hero.compact h1 { font-size: var(--fs-2xl); }
.lead { color: var(--muted); max-width: 46ch; font-size: var(--fs-m); }
.slip { position: relative; border-radius: var(--r-panel); background: var(--surface); border: 1px solid var(--line-strong); padding: 6px 6px 8px; transition: border-color .15s, box-shadow .15s; }
.slip::before { content: ""; position: absolute; inset: 4px; border-radius: 12px; border: 1px solid color-mix(in srgb, var(--foil) 22%, transparent); pointer-events: none; }
.slip:focus-within { border-color: var(--jade); box-shadow: 0 0 0 3px var(--jade-soft); }
.slip-input { display: block; width: 100%; min-height: 96px; resize: none; padding: 12px 12px 6px; border: 0; background: transparent; outline: none; font-family: var(--sans); font-size: var(--fs-m); line-height: 1.6; position: relative; }
.slip-input:not(:placeholder-shown) { font-family: var(--mono); font-size: 14.5px; }
.slip-tools { display: flex; gap: 6px; padding: 0 6px; position: relative; }
.btn.quiet.small.hidden { display: none; }
.detect { min-height: 24px; display: flex; flex-direction: column; gap: 6px; }
.hint { font-size: var(--fs-s); color: var(--muted); }
.hint.bad { color: var(--risk); } .hint.warn { color: var(--warn); }
.found { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: var(--fs-s); }
.found-kind { display: inline-flex; align-items: center; gap: 6px; color: var(--in); font-weight: 600; }
:root[data-theme="light"] .found-kind { color: var(--jade); }
.found-item { display: inline-flex; gap: 8px; align-items: baseline; padding: 2px 10px; border-radius: 999px; border: 1px solid var(--line); }
.found-item .muted { font-size: var(--fs-xs); }

.job, .gate { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 12px; padding: 28px 8px; }
.job h1, .gate h1 { font-size: var(--fs-2xl); }
.job-step { font-size: var(--fs-m); min-height: 1.75em; max-width: 36ch; }
.gate { min-height: 80vh; justify-content: center; }
.gate p { max-width: 38ch; }

/* ---- the rosette ----------------------------------------------------------------------------- */
.rosette path { fill: none; stroke: currentColor; stroke-width: .7; vector-effect: non-scaling-stroke; }
.rosette.draw path { stroke-dasharray: 1; stroke-dashoffset: 1; animation: engrave 2.4s cubic-bezier(.6, 0, .3, 1) forwards; animation-delay: calc(var(--i) * .45s); }
@keyframes engrave { to { stroke-dashoffset: 0; } }
.job-mark, .gate-mark { width: min(220px, 60vw); height: auto; color: var(--foil); margin-bottom: 8px; }
.job-mark path { stroke-width: 1; animation: engrave 2.4s cubic-bezier(.6, 0, .3, 1) forwards, breathe 3.6s 2.6s ease-in-out infinite; animation-delay: calc(var(--i) * .45s), calc(2.4s + var(--i) * .3s); }
@keyframes breathe { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

/* ---- result ---------------------------------------------------------------------------------- */
.result { display: grid; gap: 18px; }
.result-side, .result-main { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
@media (min-width: 980px) {
  .result { grid-template-columns: 360px minmax(0, 1fr); align-items: start; }
  .result-side { position: sticky; top: 64px; }
  .tabs { top: 52px; }
}
.subject { display: flex; align-items: center; gap: 8px; }
.subject-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.subject-text .muted { white-space: pre; }
.subject-name { font-weight: 700; font-size: var(--fs-l); line-height: 1.4; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.subject-query { font-size: var(--fs-s); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; direction: ltr; text-align: start; }

.wallet { position: relative; overflow: hidden; isolation: isolate; padding: 18px; border-radius: var(--r-panel); background: var(--surface); border: 1px solid var(--line-strong); display: flex; flex-direction: column; gap: 14px; }
.wallet::before { content: ""; position: absolute; inset: 5px; border-radius: 12px; border: 1px solid color-mix(in srgb, var(--foil) 26%, transparent); pointer-events: none; z-index: -1; }
.wallet-mark { position: absolute; inset-inline-end: -70px; top: -60px; width: 260px; height: 260px; color: var(--foil); opacity: .16; z-index: -1; pointer-events: none; }
.wallet-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.wallet-id { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.wallet-name { font-size: var(--fs-xl); line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wallet-addr { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: var(--fs-s); width: fit-content; }
.wallet-addr .i { width: 14px; height: 14px; }
.wallet-net { color: var(--muted); font-size: var(--fs-xs); }
.wallet-value { display: flex; flex-direction: column; align-items: flex-start; gap: 0; text-align: start; padding: 2px 0; }
.wallet-value[disabled] { cursor: default; }
.label { font-size: var(--fs-xs); color: var(--muted); }
.wallet-value .value { font-size: 40px; line-height: 1.15; font-weight: 600; color: var(--foil); letter-spacing: -.01em; }
.chainbar { display: flex; flex-direction: column; gap: 8px; }
.stack { display: flex; height: 6px; border-radius: 3px; overflow: hidden; gap: 2px; background: var(--surface-2); }
.stack i { display: block; height: 100%; }
.legend-line { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: var(--fs-xs); color: var(--muted); }
.legend-line span { display: inline-flex; align-items: center; gap: 6px; }
.legend-line i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.funder { display: grid; grid-template-columns: 1fr auto auto; grid-template-areas: "label label label" "who date chev"; align-items: center; gap: 2px 10px; padding: 10px 12px; border-radius: var(--r-ctl); border: 1px solid var(--line); background: color-mix(in srgb, var(--paper) 55%, transparent); text-align: start; font-size: var(--fs-s); }
.funder .label { grid-area: label; }
.funder > .i { grid-area: chev; }
.funder-who { grid-area: who; font-weight: 600; display: flex; gap: 6px; align-items: center; min-width: 0; }
.funder-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.funder-who .tag { flex: none; }
.funder .i { width: 15px; height: 15px; color: var(--muted); }
.risk-pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 999px; font-size: var(--fs-xs); font-weight: 600; border: 1px solid; white-space: nowrap; flex: none; }
.risk-pill .i { width: 14px; height: 14px; }
.risk-pill.ok { color: var(--in); border-color: color-mix(in srgb, var(--in) 45%, var(--line)); }
.risk-pill.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 50%, var(--line)); background: color-mix(in srgb, var(--warn) 8%, transparent); }
.risk-pill.bad { color: var(--risk); border-color: color-mix(in srgb, var(--risk) 60%, var(--line)); background: color-mix(in srgb, var(--risk) 10%, transparent); }
.risk-head { display: flex; gap: 16px; align-items: center; }
.risk-verdict { font-weight: 600; font-size: var(--fs-l); }
.ring { --c: var(--in); width: 84px; height: 84px; border-radius: 50%; flex: none; display: grid; place-content: center; text-align: center; position: relative; background: conic-gradient(var(--c) var(--p), var(--surface-2) 0); }
.ring::before { content: ""; position: absolute; inset: 6px; border-radius: 50%; background: var(--surface); }
.ring strong, .ring span { position: relative; line-height: 1.15; } .ring strong { font-size: var(--fs-xl); font-variant-numeric: tabular-nums; } .ring span { font-size: 11px; color: var(--muted); }
.ring.warn { --c: var(--warn); } .ring.bad { --c: var(--risk); }

.totals { display: grid; grid-template-columns: repeat(2, 1fr); border-radius: var(--r-panel); border: 1px solid var(--line); background: var(--surface); overflow: hidden; }
.ledger-cell { padding: 12px 14px; display: flex; flex-direction: column; gap: 0; min-width: 0; border-color: var(--line); border-style: solid; border-width: 0; }
.totals .ledger-cell:nth-child(odd) { border-inline-end-width: 1px; }
.totals .ledger-cell:nth-child(n+3) { border-top-width: 1px; }
.ledger-cell strong { font-size: var(--fs-xl); font-weight: 600; line-height: 1.35; text-align: start; }
.ledger-cell span { font-size: var(--fs-xs); color: var(--muted); }
.ledger-cell.in strong { color: var(--in); } .ledger-cell.out strong { color: var(--out); }
.totals.wide { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 640px) { .totals.wide { grid-template-columns: repeat(3, 1fr); } .totals.wide .ledger-cell { border-width: 0; } .totals.wide .ledger-cell:not(:nth-child(3n)) { border-inline-end-width: 1px; } .totals.wide .ledger-cell:nth-child(n+4) { border-top-width: 1px; } }
@media (max-width: 639px) { .totals.wide .ledger-cell:nth-child(odd) { border-inline-end-width: 1px; } .totals.wide .ledger-cell:nth-child(n+3) { border-top-width: 1px; } }
.tab-body { display: flex; flex-direction: column; gap: 14px; padding-top: 4px; }

.graph-wrap { position: relative; border-radius: var(--r-panel); border: 1px solid var(--line); overflow: hidden;
  background: radial-gradient(circle at 1px 1px, color-mix(in srgb, var(--line) 70%, transparent) 1px, transparent 0) 0 0 / 22px 22px, var(--paper); }
.graph { height: 62vh; min-height: 420px; direction: ltr; }
@media (min-width: 980px) { .graph { height: 70vh; } }
.graph-wrap.full { position: fixed; inset: 0; z-index: 35; border-radius: 0; border: 0; }
.graph-wrap.full .graph { height: 100vh; }
.graph-tools { position: absolute; top: 10px; inset-inline-end: 10px; display: flex; flex-direction: column; gap: 6px; z-index: 3; }
.graph-tools .icon-btn { width: 36px; height: 36px; box-shadow: 0 2px 10px rgba(0, 0, 0, .12); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 6px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; min-height: 30px; padding: 3px 10px; border-radius: 999px; font-size: var(--fs-xs); border: 1px solid var(--line); transition: opacity .15s; }
.legend-item i { width: 8px; height: 8px; border-radius: 50%; }
.legend-item.off { opacity: .38; }
.path { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-top: 4px; font-size: var(--fs-xs); color: var(--muted); }
.path .n { padding: 0 7px; border-radius: 6px; background: var(--surface-2); color: var(--ink); }
.path .n.ex { color: var(--in); }
.path .i { width: 11px; height: 11px; }
.report-msg { padding: 14px 16px; border-radius: var(--r-row); background: var(--surface); border: 1px solid var(--line); font-size: var(--fs-s); line-height: 1.9; white-space: pre-wrap; overflow-wrap: anywhere; }
.report-msg code { font-family: var(--mono); background: var(--surface-2); padding: 0 5px; border-radius: 5px; font-size: .9em; }
.report-msg a { color: var(--in); }

/* ---- watch and account ----------------------------------------------------------------------- */
.form-panel { padding: 16px; border-radius: var(--r-panel); background: var(--surface); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 14px; }
.status-panel { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 20px 18px; border-radius: var(--r-panel); background: var(--surface); border: 1px solid var(--line); position: relative; overflow: hidden; }
.status-panel h1 { font-size: var(--fs-2xl); line-height: 1.3; }
.status-panel.ok { border-color: color-mix(in srgb, var(--in) 40%, var(--line)); }
.status-panel.bad { border-color: color-mix(in srgb, var(--risk) 45%, var(--line)); }
.quota { display: flex; flex-direction: column; align-items: center; padding-inline-start: 16px; border-inline-start: 1px solid var(--line); flex: none; }
.quota strong { font-size: var(--fs-xl); font-weight: 600; } .quota span { font-size: var(--fs-xs); color: var(--muted); white-space: nowrap; }
.plans { display: grid; gap: 10px; }
@media (min-width: 640px) { .plans { grid-template-columns: repeat(3, 1fr); } }
.plan { display: flex; flex-direction: column; gap: 4px; padding: 16px; border-radius: var(--r-panel); background: var(--surface); border: 1px solid var(--line); text-align: start; transition: border-color .15s, transform .08s; }
.plan:hover { border-color: var(--line-strong); }
.plan:active { transform: scale(.99); }
.plan.best { border-color: color-mix(in srgb, var(--foil) 60%, var(--line)); }
.plan-name { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-weight: 600; }
.plan-price { font-size: var(--fs-2xl); font-weight: 600; color: var(--foil); line-height: 1.3; text-align: start; }
.plan-month { display: flex; justify-content: space-between; gap: 8px; }
.price-line { display: flex; align-items: baseline; gap: 10px; } .price-line strong { font-size: var(--fs-2xl); color: var(--foil); font-weight: 600; }
.pay-info { width: 100%; padding: 12px 14px; border-radius: var(--r-ctl); background: var(--paper); border: 1px solid var(--line); white-space: pre-wrap; overflow-wrap: anywhere; font-family: var(--mono); font-size: var(--fs-s); line-height: 1.7; cursor: copy; text-align: start; }
.code { margin: 0; padding: 12px; border-radius: var(--r-ctl); background: var(--paper); border: 1px solid var(--line); font-family: var(--mono); font-size: 12px; line-height: 1.6; overflow-x: auto; text-align: left; }

/* ---- tab bar --------------------------------------------------------------------------------- */
.tabbar { position: fixed; inset-inline: 0; bottom: 0; z-index: 30; padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--paper) 90%, transparent); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-top: 1px solid var(--line); }
.tabbar nav { display: flex; max-width: 640px; margin: 0 auto; }
.tabbar a { position: relative; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; height: var(--tab-h); color: var(--muted); font-size: 11.5px; }
.tabbar a .i { width: 22px; height: 22px; stroke-width: 1.6; }
.tabbar a.on { color: var(--ink); font-weight: 600; }
.tabbar a.on::before { content: ""; position: absolute; top: -1px; width: 28px; height: 2px; border-radius: 2px; background: var(--foil); }
body[data-route="result"] .tabbar, body[data-route="job"] .tabbar { display: none; }
body[data-route="result"] #app, body[data-route="job"] #app { padding-bottom: calc(28px + env(safe-area-inset-bottom)); }
body[data-route="result"] .toast, body[data-route="job"] .toast { bottom: calc(18px + env(safe-area-inset-bottom)); }

/* ---- wider screens --------------------------------------------------------------------------- */
@media (min-width: 720px) {
  :root { --gutter: 24px; }
  .hero { padding-top: 40px; }
  .hero h1 { font-size: 44px; }
}
/* every screen but the result reads as one centred column; the result uses the full width for its graph */
body:not([data-route="result"]) .page { max-width: 760px; margin-inline: auto; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .rosette.draw path { stroke-dashoffset: 0; }
}
@media print { .tabbar, .bar, .graph-tools, .tabs { display: none !important; } body { background: #fff; color: #000; } }
