/* FACE wallet — built for a cheap phone in bad light on a slow connection. */

:root {
  --bg: #070b0a;
  --bg-soft: #0c1311;
  --panel: #101916;
  --panel-2: #16221d;
  --line: #1e2f27;
  --line-soft: #182420;
  --green: #34d399;
  --green-dim: #10b981;
  --green-deep: #065f46;
  --green-soft: rgba(52, 211, 153, 0.1);
  --text: #e8f3ee;
  --muted: #8ba79b;
  --muted-2: #61796f;
  --amber: #fbbf24;
  --red: #f87171;
  --blue: #60a5fa;
  --mono: "SF Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --radius: 14px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html { -webkit-text-size-adjust: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100dvh;
  overflow-x: hidden;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom));
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ------------------------------- boot ------------------------------- */

.boot { margin: auto; text-align: center; }
.boot-mark {
  font-size: 34px; font-weight: 700; letter-spacing: 0.24em;
  color: var(--green); animation: pulse 1.8s ease-in-out infinite;
}
.boot-note { color: var(--muted); font-size: 13px; margin-top: 10px; }
@keyframes pulse { 0%, 100% { opacity: 0.45; } 50% { opacity: 1; } }

/* ------------------------------ chrome ------------------------------ */

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 18px;
}
.brand { display: flex; align-items: baseline; gap: 8px; }
.brand b { font-size: 17px; font-weight: 700; letter-spacing: 0.16em; color: var(--green); }
.brand span { font-size: 11px; color: var(--muted-2); letter-spacing: 0.06em; }

.netpill {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 999px; padding: 5px 11px 5px 9px;
  font-size: 11.5px; color: var(--muted); cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.netpill:hover { border-color: var(--muted-2); color: var(--text); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted-2); flex: none; }
.dot.ok { background: var(--green); box-shadow: 0 0 7px var(--green); }
.dot.warn { background: var(--amber); }
.dot.err { background: var(--red); }
.dot.busy { background: var(--blue); animation: pulse 1s infinite; }

/* ------------------------------ blocks ------------------------------ */

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}
.card + .card { margin-top: 14px; }
.card h2 {
  font-size: 10.5px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.11em; color: var(--muted-2); margin-bottom: 13px;
}

.balance-card {
  background: linear-gradient(160deg, #0f221b 0%, var(--panel) 62%);
  border-color: var(--green-deep);
  text-align: center;
  padding: 26px 18px 22px;
}
.balance-amount {
  font-family: var(--mono); font-size: clamp(30px, 10vw, 42px);
  font-weight: 700; letter-spacing: -0.02em; line-height: 1.05;
  overflow-wrap: anywhere;
}
.balance-unit { color: var(--green); font-size: 0.42em; margin-left: 8px; letter-spacing: 0.1em; }
.balance-sub { color: var(--muted); font-size: 12.5px; margin-top: 9px; min-height: 18px; }
.balance-sub b { color: var(--amber); font-weight: 600; }

.addr-row {
  display: flex; align-items: center; gap: 8px; justify-content: center;
  margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line-soft);
}
.addr-row code {
  font-family: var(--mono); font-size: 11.5px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ------------------------------ buttons ----------------------------- */

button {
  font: inherit; border: 0; cursor: pointer;
  border-radius: 11px; padding: 13px 16px;
  font-size: 15px; font-weight: 600;
  transition: background .12s, border-color .12s, opacity .12s;
}
button:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary { background: var(--green-dim); color: #04120c; width: 100%; }
.btn-primary:not(:disabled):hover { background: var(--green); }
.btn-ghost {
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); font-weight: 500;
}
.btn-ghost:not(:disabled):hover { border-color: var(--muted-2); }
.btn-sm { padding: 7px 11px; font-size: 12.5px; border-radius: 9px; }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.btn-danger { background: transparent; color: var(--red); border: 1px solid rgba(248,113,113,0.3); }

/* ------------------------------- forms ------------------------------ */

label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
input, textarea {
  width: 100%; font: inherit; font-size: 15px;
  background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: 11px; padding: 12px 13px; color: var(--text);
}
input:focus, textarea:focus { outline: 0; border-color: var(--green-dim); }
input.mono, textarea.mono { font-family: var(--mono); font-size: 13px; letter-spacing: 0.02em; }
input::placeholder, textarea::placeholder { color: var(--muted-2); }
.field { margin-bottom: 14px; }
.field-note { font-size: 11.5px; color: var(--muted-2); margin-top: 6px; }
.field-note.err { color: var(--red); }
.field-note.ok { color: var(--green); }
.amount-wrap { position: relative; }
.amount-wrap .max {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  background: var(--panel-2); border: 1px solid var(--line);
  color: var(--muted); font-size: 11px; padding: 5px 9px; border-radius: 8px;
}

/* -------------------------------- tabs ------------------------------ */

.tabs {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 4px; margin: 14px 0;
}
.tabs button {
  background: transparent; color: var(--muted); padding: 9px 6px;
  font-size: 13.5px; font-weight: 600; border-radius: 9px;
}
.tabs button[aria-selected="true"] { background: var(--panel-2); color: var(--green); }

/* ------------------------------ activity ---------------------------- */

.tx { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
.tx:last-child { border-bottom: 0; }
.tx-icon {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-size: 15px;
  background: var(--panel-2); border: 1px solid var(--line);
}
.tx-icon.in { color: var(--green); }
.tx-icon.out { color: var(--amber); }
.tx-icon.mint { color: var(--blue); }
.tx-main { flex: 1; min-width: 0; }
.tx-title { font-size: 14px; font-weight: 500; }
.tx-sub { font-size: 11.5px; color: var(--muted-2); font-family: var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx-amt { font-family: var(--mono); font-size: 13.5px; font-weight: 600; text-align: right; flex: none; }
.tx-amt.in { color: var(--green); }
.tx-amt.pending { color: var(--amber); }
.empty { color: var(--muted-2); font-size: 13px; text-align: center; padding: 22px 0; }

/* ------------------------------- camera ----------------------------- */

.cam {
  position: relative; width: 100%; aspect-ratio: 3/4; max-height: 52dvh;
  background: #040706; border-radius: 12px; overflow: hidden;
  border: 1px solid var(--line);
}
.cam video, .cam canvas {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; transform: scaleX(-1);
}
.cam-msg {
  position: absolute; inset: 0; display: grid; place-items: center;
  color: var(--muted); font-size: 13px; text-align: center; padding: 20px; z-index: 2;
}
.challenge {
  position: absolute; left: 0; right: 0; top: 0; z-index: 3;
  background: rgba(4, 7, 6, 0.9); backdrop-filter: blur(6px);
  padding: 16px 14px; text-align: center; display: none;
}
.challenge.on { display: block; }
.challenge .say { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.13em; }
.challenge .digits {
  font-family: var(--mono); font-size: 40px; font-weight: 700;
  color: var(--amber); letter-spacing: 0.3em; margin: 6px 0 2px; text-indent: 0.3em;
}
.challenge .heard { font-family: var(--mono); font-size: 12px; color: var(--green); min-height: 17px; }
.beacon-note { font-size: 10.5px; color: var(--muted-2); font-family: var(--mono); margin-top: 6px; }

.statusline {
  display: flex; align-items: center; gap: 9px;
  margin-top: 12px; font-size: 13px; color: var(--muted); min-height: 20px;
}

/* ------------------------------ receive ----------------------------- */

.qr {
  background: #fff; border-radius: 12px; padding: 12px;
  width: min(220px, 62vw); margin: 0 auto 14px; display: block;
}
.qr svg { display: block; width: 100%; height: auto; }
.addr-box {
  background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: 11px; padding: 13px;
  font-family: var(--mono); font-size: 12.5px; line-height: 1.7;
  word-break: break-all; text-align: center; color: var(--green);
}

/* ------------------------------- sheet ------------------------------ */

.sheet-bg {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(3px); z-index: 40; display: flex;
  align-items: flex-end; justify-content: center;
}
.sheet {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 18px 18px 0 0; box-shadow: var(--shadow);
  width: 100%; max-width: 480px; max-height: 88dvh; overflow-y: auto;
  padding: 18px 16px calc(24px + env(safe-area-inset-bottom));
  animation: rise .18s ease-out;
}
@keyframes rise { from { transform: translateY(18px); opacity: 0; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.sheet-head h3 { font-size: 16px; font-weight: 600; }
.sheet-close { background: transparent; color: var(--muted); font-size: 22px; padding: 0 6px; line-height: 1; }

/* ------------------------------- stats ------------------------------ */

.kv { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line-soft); font-size: 13px; }
.kv:last-child { border-bottom: 0; }
.kv dt { color: var(--muted); }
.kv dd { font-family: var(--mono); font-variant-numeric: tabular-nums; text-align: right; overflow-wrap: anywhere; }
.kv dd.good { color: var(--green); }
.kv dd.warn { color: var(--amber); }

.peerline { display: flex; align-items: center; gap: 9px; font-size: 12px; padding: 7px 0; border-bottom: 1px solid var(--line-soft); }
.peerline code { font-family: var(--mono); color: var(--muted); }
.badge {
  font-size: 10px; font-weight: 600; padding: 2px 7px; border-radius: 999px;
  background: var(--panel-2); color: var(--muted); border: 1px solid var(--line);
  letter-spacing: 0.04em;
}
.badge.direct { color: var(--green); border-color: var(--green-deep); }
.badge.ws { color: var(--blue); }
.badge.http { color: var(--amber); }
.badge.local { color: var(--muted); }

/* ------------------------------- misc ------------------------------- */

.notice {
  border-radius: 11px; padding: 12px 13px; font-size: 12.5px; line-height: 1.55;
  border: 1px solid; margin-bottom: 14px;
}
.notice.warn { background: rgba(251,191,36,0.07); border-color: rgba(251,191,36,0.28); color: #f5d68a; }
.notice.err { background: rgba(248,113,113,0.07); border-color: rgba(248,113,113,0.28); color: #f6a3a3; }
.notice.ok { background: var(--green-soft); border-color: var(--green-deep); color: #a5e8cd; }
.notice.info { background: rgba(96,165,250,0.06); border-color: rgba(96,165,250,0.25); color: #a9cbf7; }

.hero { text-align: center; padding: 8px 0 4px; }
.hero h1 { font-size: 25px; font-weight: 700; letter-spacing: -0.015em; margin-bottom: 10px; }
.hero h1 em { font-style: normal; color: var(--green); }
.hero p { color: var(--muted); font-size: 14px; line-height: 1.6; margin: 0 auto 8px; max-width: 34ch; }

.emission {
  display: flex; align-items: baseline; justify-content: center; gap: 8px;
  font-family: var(--mono); margin: 16px 0 6px;
}
.emission .n { font-size: 27px; font-weight: 700; color: var(--amber); }
.emission .u { font-size: 12px; color: var(--muted); letter-spacing: 0.08em; }
.countdown { text-align: center; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.countdown b { color: var(--text); font-family: var(--mono); }

.steps { list-style: none; margin: 16px 0 4px; }
.steps li { display: flex; gap: 11px; padding: 9px 0; font-size: 13.5px; color: var(--muted); }
.steps li b { color: var(--green); font-family: var(--mono); flex: none; }

.footer { margin-top: auto; padding-top: 22px; text-align: center; font-size: 11.5px; color: var(--muted-2); line-height: 1.7; }
.footer a { color: var(--muted); text-decoration: none; border-bottom: 1px solid var(--line); }
.footer a:hover { color: var(--green); }

.spin { display: inline-block; width: 13px; height: 13px; border: 2px solid var(--line); border-top-color: var(--green); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed; left: 50%; bottom: calc(22px + env(safe-area-inset-bottom));
  transform: translateX(-50%); z-index: 60;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 11px; padding: 11px 16px; font-size: 13px;
  box-shadow: var(--shadow); max-width: min(420px, 92vw); text-align: center;
  animation: rise .16s ease-out;
}
.toast.err { border-color: rgba(248,113,113,0.4); color: #f6a3a3; }
.toast.ok { border-color: var(--green-deep); color: #a5e8cd; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
