/* disperce — mobile-first, dark, tool-grade */

:root {
  --bg: #0b0d12;
  --bg-2: #11151c;
  --bg-3: #181d27;
  --line: #232a37;
  --text: #e7ecf3;
  --muted: #8a93a4;
  --muted-2: #5a6273;
  --accent: #00c2a8;
  --accent-soft: #00c2a833;
  --accent-strong: #00d9bd;
  --danger: #ff5d6c;
  --danger-soft: #ff5d6c1f;
  --warn: #ffb547;
  --warn-soft: #ffb5471f;
  --ok: #5ee29c;
  --radius: 14px;
  --radius-sm: 10px;
  --space: 16px;
  --mono: ui-monospace, "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
  --safe-bot: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  overscroll-behavior-y: contain;
}
body { padding-bottom: calc(96px + var(--safe-bot)); }
button { font: inherit; color: inherit; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ---- LOGIN ---- */
#screen-login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 32px 24px;
}
.brand {
  margin: 0;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.brand-sub {
  margin: 4px 0 24px;
  color: var(--muted);
  font-size: 14px;
}
#login-form { display: grid; gap: 14px; }
#pw, #addr {
  width: 100%;
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px 14px;
  color: var(--text);
  font-size: 16px;
  min-height: 52px;
  outline: none;
  transition: border-color 0.15s;
}
#pw { font-family: var(--mono); letter-spacing: 0.05em; }
#pw:focus, #addr:focus { border-color: var(--accent); }
.error-line {
  color: var(--danger);
  font-size: 14px;
}

/* ---- BUTTONS ---- */
.btn-primary {
  background: var(--accent);
  color: #001813;
  border: 0;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 16px;
  padding: 16px;
  min-height: 52px;
  cursor: pointer;
  transition: background 0.15s, transform 0.05s;
}
.btn-primary:hover:not(:disabled) { background: var(--accent-strong); }
.btn-primary:active:not(:disabled) { transform: scale(0.99); }
.btn-primary:disabled {
  background: var(--bg-3);
  color: var(--muted-2);
  cursor: not-allowed;
}
.link-btn {
  background: none;
  border: 0;
  color: var(--accent);
  font-size: 14px;
  cursor: pointer;
  padding: 8px 4px;
  text-decoration: none;
}
.link-btn:hover { color: var(--accent-strong); }

/* ---- MAIN LAYOUT ---- */
#screen-main { max-width: 560px; margin: 0 auto; padding: 0 16px; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 4px 8px;
}
.brand-row { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, var(--accent-strong), var(--accent) 60%, #006658);
  box-shadow: 0 0 12px var(--accent-soft);
}
.brand-name {
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.01em;
}

/* ---- TABS ---- */
.tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  padding: 4px;
  border-radius: 12px;
  margin: 8px 0 16px;
}
.tab {
  flex: 1;
  background: transparent;
  border: 0;
  padding: 11px;
  border-radius: 8px;
  font-weight: 500;
  font-size: 14px;
  color: var(--muted);
  cursor: pointer;
  min-height: 40px;
}
.tab.active {
  background: var(--bg-3);
  color: var(--text);
}

.tab-panel { display: block; }
.tab-panel[hidden] { display: none; }

/* ---- CARDS ---- */
.card {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}
.card-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 10px;
}
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* status card */
.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--bg-3);
  font-size: 13px;
  font-weight: 500;
}
.pill .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--muted-2);
  display: inline-block;
}
.pill.online .dot { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.pill.offline .dot { background: var(--danger); }
#block-height { font-family: var(--mono); font-size: 13px; }

.balance-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: baseline;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}
.balance-row:first-of-type { border-top: 0; padding-top: 0; }
.balance-ticker {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.02em;
}
.balance-amounts { text-align: right; font-family: var(--mono); font-size: 14px; }
.balance-amounts .unlocked { color: var(--text); font-size: 18px; font-weight: 600; }
.balance-amounts .total { color: var(--muted); font-size: 12px; margin-top: 2px; }
.outs-chip {
  font-family: var(--mono);
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--bg-3);
  color: var(--muted);
  grid-column: 1 / -1;
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.outs-chip.green { background: #093023; color: var(--ok); }
.outs-chip.amber { background: var(--warn-soft); color: var(--warn); }
.outs-chip.red { background: var(--danger-soft); color: var(--danger); }
.outs-chip .num { font-weight: 700; font-size: 14px; }

.totals-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.totals-row strong { font-size: 22px; font-family: var(--mono); }

/* recipe */
.recipe-summary {
  font-size: 18px;
  font-weight: 600;
  font-family: var(--mono);
  letter-spacing: 0.01em;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.card-head .card-label { margin-bottom: 0; }

/* recipe edit form */
.recipe-edit { display: grid; gap: 12px; }
.field { display: grid; gap: 6px; }
.field-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.recipe-edit input,
.recipe-edit select {
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 12px;
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  min-height: 48px;
  outline: none;
  width: 100%;
}
.recipe-edit input:focus { border-color: var(--accent); }
.recipe-edit input.mono { font-family: var(--mono); font-size: 13px; word-break: break-all; }
.asset-block {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px;
  display: grid;
  gap: 8px;
  background: var(--bg-3);
}
.asset-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.asset-row .field { gap: 4px; }
.asset-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 4px;
}
.btn-ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: var(--radius-sm);
  font-size: 14px;
  padding: 10px 14px;
  min-height: 44px;
  cursor: pointer;
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn-ghost.danger { color: var(--danger); }
.btn-ghost.danger:hover { border-color: var(--danger); color: var(--danger); }
.btn-small { padding: 10px 16px; min-height: 44px; font-size: 14px; }
.recipe-edit-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

/* input */
#addr {
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.5;
  resize: none;
  min-height: 64px;
  word-break: break-all;
}
.addr-status {
  font-size: 13px;
  padding: 8px 0 0;
  min-height: 20px;
}
.addr-status.valid { color: var(--ok); }
.addr-status.invalid { color: var(--danger); }
.addr-status.warn { color: var(--warn); }
.addr-status.checking { color: var(--muted); }

.paste-btn { padding-left: 0; }

.addr-actions { display: flex; gap: 20px; }
.addr-actions .paste-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-icon { width: 15px; height: 15px; flex-shrink: 0; }

/* ---- QR SCANNER ---- */
.qr-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: #000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.qr-overlay[hidden] { display: none; }
#qr-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.qr-frame {
  position: relative;
  width: min(65vw, 280px);
  aspect-ratio: 1;
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 16px;
  box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.45);
}
.qr-hint {
  position: relative;
  margin-top: 18px;
  color: #fff;
  font-size: 14px;
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
}
.qr-close {
  position: absolute;
  bottom: calc(24px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  width: auto;
  padding: 12px 36px;
}

/* ---- SEND BAR ---- */
.send-bar {
  position: fixed;
  left: 0; right: 0;
  bottom: 0;
  background: linear-gradient(to top, var(--bg) 60%, transparent);
  padding: 12px 16px calc(12px + var(--safe-bot));
  z-index: 50;
}
.btn-send {
  width: 100%;
  min-height: 56px;
  font-size: 17px;
  max-width: 560px;
  margin: 0 auto;
  display: block;
}
.btn-send.loading {
  background: var(--bg-3);
  color: var(--muted);
}
.btn-send.loading::after {
  content: "";
  display: inline-block;
  width: 16px; height: 16px;
  margin-left: 10px;
  vertical-align: -3px;
  border: 2px solid var(--muted-2);
  border-top-color: var(--text);
  border-radius: 50%;
  animation-name: spin;
  animation-duration: 0.8s;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- HISTORY ---- */
.history-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0 12px;
}
.history-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 8px;
}
.history-row {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}
.history-line {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
}
.history-addr {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text);
  word-break: break-all;
}
.history-time { color: var(--muted); font-size: 12px; white-space: nowrap; }
.history-meta {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}
.history-tx {
  font-family: var(--mono);
  color: var(--accent);
  text-decoration: none;
}
.history-tx:hover { color: var(--accent-strong); }

/* ---- TOAST ---- */
.toast-region {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: grid;
  gap: 8px;
  max-width: 92vw;
}
.toast {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  animation-name: slidein;
  animation-duration: 0.18s;
  animation-timing-function: ease-out;
}
.toast.ok { border-color: var(--accent-soft); }
.toast.err { border-color: var(--danger); color: var(--danger); }
.toast a { color: var(--accent); text-decoration: none; margin-left: 8px; }
.toast a:hover { color: var(--accent-strong); }
@keyframes slidein { from { transform: translateY(-8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* desktop tidy */
@media (min-width: 720px) {
  #screen-main { padding: 0 24px; }
  .topbar { padding-top: 24px; }
  .send-bar { padding-bottom: 20px; }
  .btn-send { max-width: 560px; }
}
