/* GoBond — design tokens
 *
 * Adopts the VybeSale visual system (see frontend-design.md) while keeping
 * the existing variable NAMES (--bg0, --t1, --g, etc.) so every existing
 * component picks up the new look without grep-and-replace across 30+
 * page files. Only the hex VALUES change.
 *
 * VybeSale mapping (kept as comments next to each declaration):
 *   --bg0      → --color-bg            page background
 *   --bg1      → --color-surface       cards, sidebar, topbar
 *   --bg2      → --color-surface-2     inputs, nested cards
 *   --border   → --color-line          visible borders
 *   --border-soft → --color-line-soft  internal hairline dividers (new)
 *   --t1/--t2/--t3 → --color-text/2/3  three contrast levels
 *   --g        → --color-cyan          signature accent (#1FE5DC)
 *   --g2       → --color-cyan-deep     hover state of cyan
 *
 * Component authors: ALWAYS reference --bg*, --t*, --border* etc. Never
 * hardcode #0A0D11 or rgba(0,0,0,…) — those get baked in and the light
 * theme breaks. Use --shadow, --overlay, --hdr-bg for effects that need
 * theme-aware rgbs.
 */
:root, :root[data-theme="dark"] {
  /* ─── Surface — three levels, dark by default ─────────────────── */
  --bg0: #0A0D11;            /* page background */
  --bg1: #11151B;            /* card */
  --bg2: #161B23;            /* nested card / input bg */
  --bg3: #1C232D;            /* deeper still (used sparingly) */
  --border: #232A35;         /* visible border */
  --border-soft: #1A2029;    /* internal hairline divider */
  --border2: #2D3543;        /* slightly stronger border for emphasis */

  /* ─── Brand — VybeSale cyan, used sparingly for accents ───────── */
  --g:    #1FE5DC;
  --g2:   #0FB8B0;
  --cyan: #1FE5DC;
  /* Tinted helpers (alpha-on-cyan), used for soft fills + glows */
  --gd: rgba(31, 229, 220, 0.08);
  --gg: rgba(31, 229, 220, 0.18);
  --cyan-soft: rgba(31, 229, 220, 0.12);
  --cyan-glow: rgba(31, 229, 220, 0.35);

  /* ─── Semantic — kept muted, never neon ───────────────────────── */
  --red:    #F87171;
  --yellow: #F59E0B;
  --green:  #34D399;
  --gain-soft: rgba(52, 211, 153, 0.12);
  --loss-soft: rgba(248, 113, 113, 0.12);
  --warn-soft: rgba(245, 158, 11, 0.12);

  /* ─── Text — three contrast levels with tuned AA ──────────────── */
  --t1: #E6EBF2;             /* primary */
  --t2: #B7C0CE;             /* secondary */
  --t3: #8B95A5;             /* tertiary / mono labels */

  /* ─── Chrome effects (theme-aware) ────────────────────────────── */
  --hdr-bg:    rgba(10, 13, 17, 0.86);
  --overlay:   rgba(10, 13, 17, 0.72);
  --shadow:    0 2px 8px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.5);

  /* ─── Typography — Switzer for UI, Fragment Mono for numbers ──── */
  --sans: 'Switzer', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'Fragment Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  /* ─── Radius — three sizes, used consistently ─────────────────── */
  --r-sm: 6px;               /* chips, badges */
  --r:    10px;              /* cards, buttons */
  --r-lg: 14px;              /* hero containers */

  /* ─── Motion — one curve everywhere ───────────────────────────── */
  --tr:          0.16s cubic-bezier(0.2, 0.7, 0.1, 1);
  --ease-snappy: cubic-bezier(0.2, 0.7, 0.1, 1);

  /* ─── Layout ──────────────────────────────────────────────────── */
  --layout-topbar:  58px;
  --layout-sidebar: 248px;

  /* ─── Legacy aliases used by page fragments (don't rename) ────── */
  --bg: var(--bg0);
  --brand-primary: var(--g);
  --brand-accent: var(--cyan);
  --brand-warn: var(--yellow);
  --brand-danger: var(--red);
  --border-strong: var(--border2);
  --font: var(--sans);
}

/* Light theme — hand-tuned palette for a clean, professional look.
 * Key choices:
 *   - Off-white main bg with a cool-blue hint (#f3f6fa) so cyan accents
 *     feel native instead of jarring on pure white.
 *   - Cards are pure white with a soft elevated shadow — real depth, not
 *     just borders.
 *   - Brand cyan uses #0099bb for hyperlink / button text (WCAG AA on
 *     white), with a brighter #00c0e5 for hover + accent fills.
 *   - Slightly warmer grays on text so it doesn't feel clinical. */
:root[data-theme="light"] {
  /* Surfaces — subtle blue-gray hierarchy */
  --bg0: #F3F6FA;            /* page background */
  --bg1: #FFFFFF;            /* card background */
  --bg2: #EBF0F6;            /* hover / secondary surface */
  --bg3: #DDE4ED;
  --border: #D4DCE5;
  --border-soft: #E4EAF1;
  --border2: #B5C1CF;

  /* Brand — VybeSale teal-cyan deepened for AA contrast on white */
  --g:    #0FB8B0;
  --g2:   #098A85;
  --cyan: #1FE5DC;
  --gd: rgba(15, 184, 176, 0.08);
  --gg: rgba(15, 184, 176, 0.22);
  --cyan-soft: rgba(15, 184, 176, 0.12);
  --cyan-glow: rgba(15, 184, 176, 0.35);

  /* Semantic — saturated for legibility on white */
  --red:    #DC2626;
  --yellow: #B45309;
  --green:  #059669;
  --gain-soft: rgba(5, 150, 105, 0.10);
  --loss-soft: rgba(220, 38, 38, 0.10);
  --warn-soft: rgba(180, 83, 9, 0.10);

  /* Text — warm charcoal tones */
  --t1: #111827;
  --t2: #4B5563;
  --t3: #6B7686;

  /* Chrome effects */
  --hdr-bg:    rgba(255, 255, 255, 0.92);
  --overlay:   rgba(15, 25, 40, 0.48);
  --shadow:    0 1px 2px rgba(14, 25, 40, 0.06), 0 4px 12px rgba(14, 25, 40, 0.06);
  --shadow-lg: 0 8px 24px rgba(14, 25, 40, 0.12), 0 2px 6px rgba(14, 25, 40, 0.08);
}

/* ─── Fontshare CDN — Switzer (UI) + Fragment Mono (numbers).
 *     Free for most use cases. Self-host the woff2 in assets/fonts/
 *     for production-grade caching + privacy later. ─────────────── */
@import url('https://api.fontshare.com/v2/css?f[]=switzer@300,400,500,600,700,800&f[]=fragment-mono@400,700&display=swap');

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg0);
  color: var(--t1);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Heading defaults — tightened for editorial feel */
h1, h2, h3, h4 {
  font-family: var(--sans);
  font-weight: 700;
  letter-spacing: -0.015em;
}

/* Chain-aware ambient glow. The two radials tint to the ACTIVE chain's
   brand colour via --chain-accent-* (set by app.js _applyChainTheme on
   load + every chain render), so the whole page background signals which
   chain you're on — cyan wash on BESC, green on Robinhood, etc. Defaults
   below keep the original cyan look before JS runs / on single-chain
   sites. Subtle, never noisy; low opacity is safe in both themes.
   Transitions the colour smoothly if the vars change without a reload. */
:root {
  --chain-accent:       var(--cyan);
  --chain-accent-soft:  var(--cyan-soft);
  --chain-accent-faint: rgba(31, 229, 220, 0.05);
}
/* GoBond frontpage BEFORE a chain is chosen: pin the accent vars to the
   GoBond brand so the top line + ambient glow stay GoBond-branded, not
   tinted to the default chain. The home fragment adds `home-neutral`
   only while no chain selection exists in localStorage, and removes it
   the moment the visitor picks a chain (then the page reflects that
   chain like everywhere else). Defined on <body> — closer to
   body::before/::after than <html> — so it beats the per-chain values
   app.js writes inline on <html>. */
body.home-neutral {
  --chain-accent:       var(--cyan);
  --chain-accent-soft:  var(--cyan-soft);
  --chain-accent-faint: rgba(31, 229, 220, 0.05);
}
body::before {
  content: '';
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(900px 500px at 88% -200px, var(--chain-accent-soft), transparent 60%),
    radial-gradient(700px 400px at -200px 100%, var(--chain-accent-faint), transparent 60%);
  transition: background 400ms ease;
}
/* Thin accent line at the very top of the page in the active chain's
   colour — a persistent, always-visible chain cue that survives scroll. */
body::after {
  content: '';
  position: fixed; top: 0; left: 0; right: 0; height: 3px;
  background: var(--chain-accent);
  opacity: 0.9;
  pointer-events: none;
  z-index: 101;                    /* above the sticky header (z 100) */
  transition: background 400ms ease;
}
/* Single-chain sites: no chain to distinguish, so drop the top line. */
body:not([data-chain]) ::after,
body[data-chain=""]::after { display: none; }
/* Lift everything else above the radial */
.hdr, main, .wrap, footer, .modal, #toast-stack { position: relative; z-index: 1; }

/* ─── Mono helper — tabular numbers so prices don't reflow ──── */
.mono {
  font-family: var(--mono);
  font-feature-settings: 'tnum';
}

/* ─── Hairline divider in the soft line color ──────────────── */
.hairline { border-top: 1px dashed var(--border-soft); }

::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: var(--bg1); }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }

a { color: var(--g); text-decoration: none; }
a:hover { color: var(--g2); }

/* ───────── Nav (matches gobond.xyz) ───────── */
.hdr {
  position: fixed; top: 0; left: 0; right: 0; height: 58px;
  background: var(--hdr-bg);
  backdrop-filter: blur(10px) saturate(1.1);
  -webkit-backdrop-filter: blur(10px) saturate(1.1);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px;
}
.hdr-inner {
  max-width: 1440px; width: 100%; margin: 0 auto;
  display: flex; align-items: center; gap: 18px;
}
.logo {
  font-family: var(--sans);
  font-weight: 800; font-size: 17px; letter-spacing: -0.5px;
  display: flex; align-items: center; gap: 8px; cursor: pointer;
  color: var(--t1);
}
.logo-icon {
  width: 36px; height: 36px; flex-shrink: 0;
  filter: drop-shadow(0 0 10px rgba(31, 229, 220, 0.7))
          drop-shadow(0 0 20px rgba(31, 229, 220, 0.35));
}
.logo-icon img { width: 100%; height: 100%; object-fit: contain; }
.logo span { color: var(--g); }

.hdr-nav { display: flex; gap: 2px; flex: 1; margin-left: 10px; }
.nl, .hdr-nav a {
  padding: 7px 12px; color: var(--t2);
  font-family: var(--sans); font-size: 13px; font-weight: 600;
  cursor: pointer; border-radius: var(--r); border: 1px solid transparent;
  transition: var(--tr); letter-spacing: -0.01em;
}
.nl:hover, .hdr-nav a:hover { color: var(--t1); background: var(--bg2); }
.nl.active, .hdr-nav a.active { color: var(--g); border-color: var(--border2); background: var(--gd); }

.hdr-right { display: flex; gap: 8px; align-items: center; margin-left: auto; }

/* Header search — routes to Discover with the query. Compact; collapses
   to an icon-width field on small screens, hidden entirely on phones
   (Discover's own search covers mobile). */
.hdr-search {
  display: flex; align-items: center; gap: 6px;
  background: var(--bg2); border: 1px solid var(--border); border-radius: 999px;
  padding: 0 12px; height: 34px; transition: border-color .15s, box-shadow .15s;
}
.hdr-search:focus-within { border-color: var(--chain-accent, var(--brand-primary)); box-shadow: 0 0 0 3px var(--chain-accent-faint, rgba(31,229,220,0.08)); }
.hdr-search-ico { color: var(--t3); font-size: 15px; line-height: 1; }
.hdr-search input {
  background: transparent; border: 0; outline: 0; color: var(--t1);
  font-size: 13px; width: 150px; font-family: inherit;
}
.hdr-search input::placeholder { color: var(--t3); }
@media (max-width: 1024px) { .hdr-search input { width: 96px; } }
@media (max-width: 720px)  { .hdr-search { display: none; } }

.chain-pill {
  position: relative; padding: 4px 10px;
  /* Tint the switcher to the active chain's colour so the current chain
     is unmistakable: faint accent-tinted fill, accent border + text. */
  background: var(--chain-accent-soft, var(--bg2));
  border: 1px solid var(--chain-accent, var(--border)); border-radius: var(--r);
  font-family: var(--mono); font-size: 10px; color: var(--chain-accent, var(--cyan));
  letter-spacing: 0.5px; cursor: pointer; user-select: none;
  display: flex; align-items: center; gap: 6px; transition: var(--tr);
}
.chain-pill:hover { filter: brightness(1.15); background: var(--chain-accent-soft, var(--bg3)); }
/* The dot inside the pill also carries the accent (JS sets it inline
   too, but this is the CSS fallback + a matching glow). */
.chain-pill .chain-pill-dot { box-shadow: 0 0 6px var(--chain-accent, var(--cyan)); }
.chain-pill-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--g); box-shadow: 0 0 6px var(--gg);
}

.btn-connect, .wallet-btn {
  padding: 7px 14px;
  background: var(--gd);
  border: 1px solid rgba(31, 229, 220, 0.25);
  border-radius: var(--r); color: var(--g);
  font-family: var(--mono); font-size: 11px; font-weight: 700;
  cursor: pointer; transition: var(--tr);
  text-transform: uppercase; letter-spacing: 0.5px;
}
.btn-connect:hover, .wallet-btn:hover { background: rgba(31, 229, 220, 0.14); }
.btn-connect.connected, .wallet-btn.on {
  color: var(--t1); border-color: var(--border2); background: var(--bg2);
  text-transform: none;
}

/* Dropdown that appears when the connected wallet button is clicked.
   Built dynamically by app.js's _walletOpenMenu(); the .wallet-menu-item
   rule styles the action rows (Copy / Explorer / Disconnect). */
.wallet-menu-item {
  display: block; width: 100%; text-align: left;
  background: transparent; color: var(--t1);
  border: 0; padding: 9px 12px; border-radius: 6px;
  font-family: inherit; font-size: 13px; cursor: pointer;
  text-decoration: none; transition: background 0.1s;
}
.wallet-menu-item:hover { background: var(--bg3); }
.wallet-menu-item.wallet-menu-danger { color: var(--red); }
.wallet-menu-item.wallet-menu-danger:hover { background: rgba(227, 74, 74, 0.1); }

/* ───────── Main layout ───────── */
main, .wrap {
  max-width: 1440px; margin: 0 auto; padding: 78px 20px 40px;
}
.page { display: none; padding-bottom: 80px; }
.page.active { display: block; }

.ph { padding: 28px 0 20px; }
.ph h1 {
  font-size: 34px; margin: 0 0 6px; font-weight: 800;
  letter-spacing: -0.025em; color: var(--t1);
}
.ph p { color: var(--t2); margin: 0; font-size: 14px; max-width: 720px; }

/* ───────── Cards ───────── */
.card {
  background: var(--bg1);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  transition: var(--tr);
  /* Light theme uses elevation to create card hierarchy; dark theme relies
     on the border since shadows on near-black backgrounds are invisible.
     --shadow resolves to a minimal shadow in dark mode (intentional). */
  box-shadow: var(--shadow);
}
.ch { padding: 12px 14px; border-bottom: 1px solid var(--border); background: var(--bg2); }
.ct { font-family: var(--mono); font-size: 11px; font-weight: 700; color: var(--t2); letter-spacing: 1px; text-transform: uppercase; }
.cb { padding: 14px; }

/* ───────── Buttons ───────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 20px;
  border-radius: var(--r);
  font-family: var(--sans); font-size: 14px; font-weight: 700;
  cursor: pointer; transition: var(--tr);
  border: none; white-space: nowrap; text-decoration: none;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.bp {
  background: var(--g); color: var(--bg0);
  box-shadow: 0 0 14px rgba(31, 229, 220, 0.18);
}
.bp:hover:not(:disabled) {
  background: var(--g2);
  box-shadow: 0 0 22px rgba(31, 229, 220, 0.28);
  transform: translateY(-1px);
}
.bs {
  background: var(--bg2); color: var(--t1);
  border: 1px solid var(--border2);
}
.bs:hover:not(:disabled) { background: var(--bg3); }
.bd {
  background: rgba(255, 51, 85, 0.12); color: var(--red);
  border: 1px solid rgba(255, 51, 85, 0.25);
}
.bo {
  background: transparent; color: var(--g);
  border: 1px solid rgba(31, 229, 220, 0.35);
}
.bo:hover:not(:disabled) { background: var(--gd); }
.bsm { padding: 6px 10px; font-size: 11px; font-family: var(--mono); letter-spacing: 0.3px; }

/* ───────── Inputs ───────── */
input, select, textarea {
  width: 100%; padding: 10px 12px;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--r); color: var(--t1);
  font-family: var(--mono); font-size: 14px;
  outline: none; transition: var(--tr);
}
input:focus, select:focus, textarea:focus {
  border-color: rgba(31, 229, 220, 0.35);
  background: var(--bg3);
  box-shadow: 0 0 0 2px rgba(31, 229, 220, 0.05);
}
select option { background: var(--bg2); }

/* Placeholders — readable but clearly distinguished from entered text.
   Browsers vary in defaults; set explicitly for consistency across Firefox/Safari/Chrome. */
input::placeholder,
textarea::placeholder {
  color: #7f9ab2;          /* lighter than --t3, sits between --t3 and --t2 */
  opacity: 1;              /* Firefox defaults to 0.54 — override */
  font-weight: 400;
}
input:focus::placeholder,
textarea:focus::placeholder {
  color: var(--t3);        /* dim slightly while user is typing */
}

/* Form labels — use .lbl for consistent type across pages. Softened from
   mono-uppercase to a readable sentence-case label; the call sites already
   write labels in sentence case ("Name *" / "Image URL *"). */
.lbl,
label.lbl {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--t2);
  margin-bottom: 6px;
}

/* ───────── Utility ───────── */
.spin {
  width: 24px; height: 24px; margin: 0 auto;
  border: 3px solid var(--border); border-top-color: var(--g);
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.es { padding: 40px; text-align: center; color: var(--t3); font-size: 13px; }

.pw {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 100px; height: 6px; overflow: hidden; margin: 6px 0;
}
.pf {
  height: 100%;
  background: linear-gradient(90deg, var(--g), var(--cyan));
  border-radius: 100px; transition: width 0.5s ease;
  box-shadow: 0 0 5px var(--gg);
}

/* ───────── Toast ───────── */
#toast-stack {
  position: fixed; bottom: 20px; right: 20px; z-index: 200;
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.toast {
  background: var(--bg1); border: 1px solid var(--border);
  border-left: 3px solid var(--g);
  padding: 12px 16px; border-radius: var(--r); font-size: 13px;
  color: var(--t1); max-width: 360px; pointer-events: auto;
  font-family: var(--mono);
  animation: toast-in 0.18s ease-out;
  box-shadow: var(--shadow-lg);
}
.toast.error { border-left-color: var(--red); }
.toast.success { border-left-color: #00ff88; }
.toast.info { border-left-color: var(--cyan); }
@keyframes toast-in {
  from { opacity: 0; transform: translateX(10px); }
  to { opacity: 1; transform: none; }
}

/* ───────── Chain selector modal ───────── */
#chain-modal {
  position: fixed; inset: 0; z-index: 300;
  background: var(--overlay); backdrop-filter: blur(6px);
  display: none; align-items: center; justify-content: center;
}
#chain-modal.open { display: flex; }
.chain-modal-box {
  background: var(--bg1); border: 1px solid var(--border2);
  border-radius: 10px; padding: 20px; width: 92%; max-width: 420px;
  box-shadow: var(--shadow-lg);
  /* Constrain total modal height so it never overflows the viewport — the
     chain-list child scrolls internally. max-height plus flex column so
     the header stays pinned while the list scrolls. */
  max-height: 85vh; display: flex; flex-direction: column;
}
/* Scrollable chain list. Height computed to fill the modal box after the
   fixed header area — works at any viewport size including short mobile
   landscape. Styled scrollbar so it doesn't feel native-bulky on Chrome. */
#chain-list {
  overflow-y: auto; flex: 1 1 auto; min-height: 0;
  scrollbar-width: thin; scrollbar-color: var(--border2) transparent;
}
#chain-list::-webkit-scrollbar { width: 6px; }
#chain-list::-webkit-scrollbar-track { background: transparent; }
#chain-list::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }
#chain-list::-webkit-scrollbar-thumb:hover { background: var(--t3); }
/* Group divider inserted between enabled and disabled chains. */
.chain-group-sep {
  font-size: 10px; color: var(--t3); font-family: var(--mono);
  text-transform: uppercase; letter-spacing: 1px;
  padding: 12px 12px 6px; border-top: 1px dashed var(--border2);
  margin-top: 6px;
}
.chain-opt {
  display: flex; gap: 12px; align-items: center; padding: 10px 12px;
  border-radius: var(--r); cursor: pointer; border: 1px solid transparent;
  transition: var(--tr);
}
.chain-opt:hover { background: var(--bg3); }
.chain-opt.active { background: var(--gd); color: var(--g); border-color: rgba(31, 229, 220, 0.2); }
.chain-opt.disabled { opacity: 0.4; cursor: not-allowed; }

/* ───────── Mobile nav hamburger + drawer ─────────
   The desktop nav (.hdr-nav) is hidden on narrow viewports and
   replaced with a hamburger icon that toggles a slide-down drawer.
   The drawer reuses the SAME .hdr-nav element — we just re-style
   it as a fixed-position card under the header when .open is set
   on the <header>. Keeps DOM single-source-of-truth so nav state
   (active link, badges) doesn't need to be mirrored. */
.nav-hamburger {
  display: none;
  background: transparent;
  border: 0;
  cursor: pointer;
  padding: 10px;
  margin-left: auto;
  width: 44px; height: 44px;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
}
.nav-hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--t1);
  border-radius: 2px;
  transition: transform 200ms ease, opacity 150ms ease;
  transform-origin: center;
}
/* Animated X when the drawer is open. */
.hdr.nav-open .nav-hamburger span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hdr.nav-open .nav-hamburger span:nth-child(2) { opacity: 0; }
.hdr.nav-open .nav-hamburger span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ───────── Responsive ───────── */
@media (max-width: 900px) {
  .nav-hamburger { display: flex; }
  /* Default state on mobile: nav hidden. */
  .hdr-nav {
    display: none;
    position: fixed;
    top: 56px;                       /* sits flush under the header */
    left: 0; right: 0;
    flex-direction: column;
    gap: 0;
    margin: 0;
    padding: 8px 12px 16px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
    z-index: 49;                     /* under chain pill but over content */
    max-height: calc(100vh - 56px);
    overflow-y: auto;
  }
  /* Open state: revealed as a drawer. */
  .hdr.nav-open .hdr-nav { display: flex; }
  .hdr-nav a {
    display: block;
    padding: 14px 16px;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 600;
  }
  .hdr-nav a + a {
    margin-top: 2px;
  }
}
@media (max-width: 640px) {
  main, .wrap { padding: 78px 12px 40px; }
  .ph { padding: 16px 0 12px; }
  .ph h1 { font-size: 24px; }
  .ph p  { font-size: 13px; }

  /* Touch-friendly tap targets — buttons + nav links get min 44px hit area */
  .btn, .bp, .bs, .bd, .bo { padding: 12px 18px; min-height: 44px; }
  .btn.bsm { padding: 8px 12px; min-height: 36px; }
  .nl, .hdr-nav a { padding: 10px 14px; }

  /* Inputs — bigger tap targets, iOS zoom protection (font-size >= 16px stops the auto-zoom).
     !important is needed because many inputs across pages have inline font-size overrides. */
  input, select, textarea { font-size: 16px !important; padding: 12px !important; }

  /* Card spacing tighter on mobile */
  .cb { padding: 12px; }

  /* Chain modal — take full width on mobile */
  .chain-modal-box { max-width: calc(100vw - 24px); }
}

/* ───────── Token-detail mobile trade panel (pinned to bottom) ─────────
   When enabled via the `mcd-mobile-pin` class on <body>, the trade panel
   floats above the viewport bottom for one-tap buy/sell. Applied by JS
   on narrow screens when the detail page is active. */
@media (max-width: 768px) {
  body.mcd-mobile-pin #mcd-main {
    padding-bottom: 300px;   /* reserve room for the pinned panel */
  }
  body.mcd-mobile-pin .mcd-trade-panel {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 90;
    margin: 0; border-radius: 14px 14px 0 0;
    background: var(--bg1); border-top: 1px solid var(--g);
    box-shadow: var(--shadow-lg);
    max-height: 60vh; overflow-y: auto;
  }
}

/* ───────── Tooltips ─────────
 * Two flavors of inline help:
 *
 * 1. Inline hint — just add `data-tip="short text"` to any element.
 *    Shows on hover (desktop) or tap (mobile).
 *
 * 2. Explainer icon — add `<span class="tip" data-tip="longer explanation">?</span>`
 *    next to a label. Small round "?" badge. Clicking it on mobile pops the
 *    tooltip; hovering shows it on desktop. Use this for form fields, column
 *    headers, and anywhere a concept needs defining.
 *
 * The popup itself is a single floating element (#pp-tooltip) positioned by
 * JS in app.js → bootTooltips(). This lets us clamp to the viewport edges and
 * flip above/below based on available space — something pure-CSS `::after`
 * tooltips can't do. The `title` attribute is also mirrored for SR fallback.
 */
.tip {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--bg3); color: var(--t2);
  font-family: var(--mono); font-size: 10px; font-weight: 700;
  cursor: help; margin-left: 6px; user-select: none;
  border: 1px solid var(--border); transition: var(--tr);
  vertical-align: middle;
}
.tip:hover, .tip.open { background: var(--g); color: var(--bg0); border-color: var(--g); }

/* Floating tooltip — singleton, mounted once to <body> by bootTooltips(). */
#pp-tooltip {
  position: fixed;
  top: 0; left: 0;
  background: var(--bg1); color: var(--t1);
  border: 1px solid var(--border2); border-radius: 6px;
  padding: 8px 10px;
  font-family: var(--sans); font-size: 12px; font-weight: 500; line-height: 1.45;
  letter-spacing: 0;
  white-space: pre-line;
  min-width: 120px; max-width: 280px; width: max-content;
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.12s ease-out, transform 0.12s ease-out;
  visibility: hidden;
}
#pp-tooltip.open {
  opacity: 1;
  transform: translateY(0);
  visibility: visible;
}
#pp-tooltip[data-dir="below"] {
  transform: translateY(-4px);
}
#pp-tooltip.open[data-dir="below"] {
  transform: translateY(0);
}
/* Arrow — a rotated square aligned via --arrow-x (pixels from tooltip left). */
#pp-tooltip::after {
  content: '';
  position: absolute;
  left: var(--arrow-x, 50%);
  width: 8px; height: 8px;
  background: var(--bg1);
  border: 1px solid var(--border2);
  transform: translateX(-50%) rotate(45deg);
}
/* Arrow on bottom edge when tooltip is above the anchor. */
#pp-tooltip:not([data-dir="below"])::after {
  bottom: -5px;
  border-top: none; border-left: none;
}
/* Arrow on top edge when tooltip is below the anchor. */
#pp-tooltip[data-dir="below"]::after {
  top: -5px;
  border-bottom: none; border-right: none;
}
@media (max-width: 520px) {
  #pp-tooltip { max-width: calc(100vw - 32px); }
}

/* ───────── Onboarding tour ─────────
 * A step-by-step guided overlay that highlights key UI regions for first-time
 * visitors. Spotlight uses an inverted shadow trick (big box-shadow on the
 * spotlight ring darkens everything else) so we don't need to reflow the DOM. */
.pptour-overlay {
  position: fixed; inset: 0; z-index: 500;
  pointer-events: auto;
  /* Inverted spotlight — the shadow spreads outward, darkening the rest */
  animation: tour-fade 0.22s ease-out;
}
.pptour-spotlight {
  position: absolute;
  border-radius: 10px;
  box-shadow: 0 0 0 9999px var(--overlay);
  transition: all 0.28s cubic-bezier(.25, 1.25, .5, 1);
  pointer-events: none;
}
.pptour-box {
  position: absolute;
  background: var(--bg1); color: var(--t1);
  border: 1px solid var(--border2); border-radius: var(--r-lg);
  padding: 16px 18px; max-width: 340px;
  box-shadow: var(--shadow-lg);
  font-family: var(--sans);
}
.pptour-box h4 {
  margin: 0 0 6px; font-size: 14px; font-weight: 800;
  color: var(--t1);
}
.pptour-box p { margin: 0 0 12px; font-size: 13px; color: var(--t2); line-height: 1.55; }
.pptour-box .pptour-ctrls {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
}
.pptour-box .pptour-step { font-family: var(--mono); font-size: 10px; color: var(--t3); letter-spacing: 0.08em; }
.pptour-box button {
  padding: 6px 12px; border-radius: var(--r); cursor: pointer;
  font-family: var(--sans); font-size: 12px; font-weight: 700;
  border: 1px solid var(--border); background: var(--bg2); color: var(--t1);
  transition: var(--tr);
}
.pptour-box button:hover { background: var(--bg3); }
.pptour-box button.pptour-next {
  background: var(--g); color: var(--bg0); border-color: var(--g);
}
.pptour-box button.pptour-skip { color: var(--t3); background: transparent; border: none; }
@keyframes tour-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ───────── Demo mode banner ─────────
 * Pure CSS — shows only when <body class="demo-active">. The banner sits
 * above the sticky header. We bump `main` + `.hdr` top offsets via the
 * `.demo-active` body class so nothing overlaps. */
#demo-banner { display: none; }
body.demo-active #demo-banner {
  display: flex; align-items: center; gap: 10px; justify-content: center;
  position: fixed; top: 0; left: 0; right: 0; height: 32px; z-index: 110;
  background: linear-gradient(90deg, #ffbb00 0%, #ff9900 100%);
  color: #2d1a00;
  font-family: var(--mono); font-size: 11px; font-weight: 700;
  letter-spacing: 0.04em; padding: 0 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}
body.demo-active #demo-banner strong { font-weight: 900; letter-spacing: 0.1em; }
body.demo-active #demo-banner a {
  color: #2d1a00; text-decoration: underline; cursor: pointer;
  font-weight: 700; letter-spacing: 0;
}
body.demo-active #demo-banner a:hover { color: #000; }
body.demo-active #demo-banner .demo-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #ff3300; box-shadow: 0 0 6px #ff3300;
  animation: demo-pulse 1.2s ease-in-out infinite;
}
@keyframes demo-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

/* Shift the rest of the chrome down when demo banner is on. */
body.demo-active .hdr { top: 32px; }
body.demo-active main, body.demo-active .wrap { padding-top: 90px; }
@media (max-width: 540px) {
  body.demo-active #demo-banner { height: auto; padding: 6px 10px; font-size: 10px; flex-wrap: wrap; }
  body.demo-active #demo-banner span:not(.demo-dot) { display: none; }   /* hide description on narrow screens */
  body.demo-active .hdr { top: 28px; }
  body.demo-active main, body.demo-active .wrap { padding-top: 86px; }
}

/* Trade buttons are visually muted but not removed while demo is active —
 * we want users to see them, just not actually trigger fake tx. JS layer
 * shows a toast if clicked. */
body.demo-active .btn.bp[onclick*="trade"],
body.demo-active #mcd-trade-btn,
body.demo-active #mcc-submit {
  opacity: 0.5; cursor: not-allowed;
}

/* ───────── Range slider — branded ─────────
 * Browser defaults render range inputs inconsistently (Chrome has a progress
 * fill, Firefox doesn't; the thumb position at `max` often appears to stop
 * short because the thumb's halo extends past the track on both sides).
 *
 * This gives a unified look: thin track, branded cyan fill up to the current
 * value, a proper circular thumb that reaches both ends cleanly. Used by
 * the dev-token-lock slider on create and anywhere else a range input lands. */
input[type="range"] {
  -webkit-appearance: none; appearance: none;
  height: 6px; padding: 0; border: 0;
  background: var(--bg3); border-radius: 999px;
  cursor: pointer; outline: none; transition: none;
  /* Fallback chrome-style fill via a gradient when the browser can't do
     ::-moz-range-progress. --pct is set by JS on oninput (see _mccLockUpdate). */
  background-image: linear-gradient(90deg, var(--g) 0%, var(--g) var(--range-pct, 0%), var(--bg3) var(--range-pct, 0%), var(--bg3) 100%);
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 6px; background: transparent; border-radius: 999px;
}
input[type="range"]::-moz-range-track {
  height: 6px; background: var(--bg3); border-radius: 999px;
}
input[type="range"]::-moz-range-progress {
  height: 6px; background: var(--g); border-radius: 999px;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 18px; height: 18px; margin-top: -6px;  /* centers vertically on the 6px track */
  background: var(--g); border: 2px solid var(--bg0); border-radius: 50%;
  box-shadow: 0 0 0 1px var(--g), 0 2px 6px rgba(31, 229, 220,0.4);
  cursor: grab; transition: transform 0.1s ease;
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.15); }
input[type="range"]::-webkit-slider-thumb:active { cursor: grabbing; transform: scale(1.1); }
input[type="range"]::-moz-range-thumb {
  width: 18px; height: 18px;
  background: var(--g); border: 2px solid var(--bg0); border-radius: 50%;
  box-shadow: 0 0 0 1px var(--g), 0 2px 6px rgba(31, 229, 220,0.4);
  cursor: grab;
}
input[type="range"]:focus-visible {
  outline: 2px solid rgba(31, 229, 220,0.4); outline-offset: 2px;
}

/* ───────── iOS safe-area insets + touch polish ─────────
 * iPhones with notches / home indicators shove content under the
 * system UI unless we explicitly reserve safe-area padding via
 * env(safe-area-inset-*). Works on iOS 11.2+ and is a no-op on
 * desktop (all insets are 0).
 *
 * `viewport-fit=cover` in the <meta viewport> enables these env
 * values — without it, iOS ignores the inset request.                  */

.hdr {
  padding-top: env(safe-area-inset-top, 0);
  padding-left: env(safe-area-inset-left, 0);
  padding-right: env(safe-area-inset-right, 0);
}
.wrap {
  padding-bottom: env(safe-area-inset-bottom, 0);
  padding-left: max(12px, env(safe-area-inset-left, 0));
  padding-right: max(12px, env(safe-area-inset-right, 0));
}

/* Touch-target minimums — Apple HIG + Material both recommend 44×44px
 * minimum hit area. Most .btn classes are already ≥ this, but the
 * icon buttons in the header (push/theme) and .mc-quick % chips
 * were under-sized on mobile. Apply a min-size fallback that
 * doesn't override explicit width/height when the design needs
 * something tighter.                                                    */
@media (hover: none) and (pointer: coarse) {
  .chain-pill, .btn-connect,
  #push-btn, #theme-btn,
  .mc-tab, .mc-quick {
    min-height: 40px;
    min-width: 40px;
  }
  /* Slight extra breathing room for the primary CTAs on mobile. */
  .btn.bp { padding-top: 14px; padding-bottom: 14px; }
}

/* PWA standalone mode — when installed to home screen, hide any
 * "install me" hints and give the body the system background colour
 * so the status bar doesn't clash on dark/light theme switches. */
@media (display-mode: standalone) {
  body { background-color: var(--bg0); }
}

/* ───────── Site footer ─────────
   Persistent footer with the community Telegram link, FAQ shortcut,
   optional ToS / Privacy links, and the build-version stamp. Sits
   below the main content (not fixed) so it doesn't overlap long
   pages. In landing-page mode (.body.landing-mode) it's hidden so the
   single-token landing pages stay focused. */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--bg0);
  padding: 28px 20px 32px;
  margin-top: 60px;
}
.body.landing-mode .site-footer { display: none; }
.site-footer-inner {
  max-width: 1440px; margin: 0 auto;
  display: flex; flex-wrap: wrap; gap: 18px;
  align-items: center; justify-content: space-between;
}
.site-footer-brand { display: flex; align-items: center; gap: 10px; }
.site-footer-brand strong {
  font-size: 14px; font-weight: 800; color: var(--t1); letter-spacing: -0.01em;
}
.site-footer-tagline { font-size: 12px; color: var(--t3); }
.site-footer-links {
  display: flex; flex-wrap: wrap; gap: 6px;
}
.site-footer-link {
  display: inline-flex; align-items: center; gap: 4px;
  color: var(--t2); font-size: 12px; text-decoration: none;
  padding: 6px 12px; border-radius: 6px;
  border: 1px solid var(--border);
  transition: var(--tr);
}
.site-footer-link:hover {
  color: var(--t1); border-color: var(--brand-primary);
  background: rgba(31, 229, 220, 0.06);
}
.site-footer-meta {
  font-family: var(--mono); font-size: 10px; color: var(--t3);
  opacity: 0.6; letter-spacing: 0.04em;
}
.site-footer-build { cursor: default; }

@media (max-width: 640px) {
  .site-footer { padding: 20px 16px 24px; margin-top: 40px; }
  .site-footer-inner { gap: 12px; justify-content: center; text-align: center; }
  .site-footer-brand { flex-direction: column; gap: 2px; }
  .site-footer-links { width: 100%; justify-content: center; }
}


/* ─── Graduation progress bar ───
   Used on the detail page (.mcd-progress-fill) AND inline on the
   memecoins list + creator profile cards. Previously the rule
   lived in page-memecoins.html's local <style> — fine when the
   user lands on Discover first, but on a fresh direct visit to a
   detail page the rule wasn't loaded and the bar rendered as a
   zero-height invisible div. Moving it here makes it always
   available. */
.mc-progress {
  height: 6px;
  background: var(--bg);
  border-radius: 3px;
  overflow: hidden;
  position: relative;
}
.mc-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--g), var(--cyan));
  transition: width 0.3s;
}

/* ───────── Wallet picker modal (wallet-picker.js) ─────────
   Shown when the user clicks Connect Wallet AND there's no browser
   extension detected — gives them WalletConnect as a fallback. Also
   used inside Telegram WebView (auto-bypassed there; picker call
   returns 'walletconnect' without rendering).
   Styling mirrors .chain-modal-box so the two modals feel cohesive. */
.wp-modal {
  position: fixed; inset: 0; z-index: 310;
  display: none;
  align-items: center; justify-content: center;
}
.wp-modal.wp-open { display: flex; }
.wp-backdrop {
  position: absolute; inset: 0;
  background: var(--overlay);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.wp-sheet {
  position: relative;
  background: var(--bg1); border: 1px solid var(--border2);
  border-radius: 10px;
  width: 92%; max-width: 420px;
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
  animation: wp-in 160ms ease-out;
}
@keyframes wp-in {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}
.wp-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border);
}
.wp-head h2 {
  margin: 0; font-size: 16px; font-weight: 600; color: var(--t1);
  letter-spacing: 0.2px;
}
.wp-x {
  background: transparent; border: 0; cursor: pointer;
  color: var(--t2); font-size: 22px; line-height: 1;
  width: 28px; height: 28px; border-radius: 6px;
  transition: var(--tr);
}
.wp-x:hover { color: var(--t1); background: var(--bg3); }
.wp-body { padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.wp-opt {
  display: flex; align-items: center; gap: 12px;
  width: 100%; padding: 12px 14px;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--r); cursor: pointer;
  color: var(--t1); text-align: left;
  transition: var(--tr);
}
.wp-opt:hover, .wp-opt:focus-visible {
  background: var(--bg3); border-color: var(--border2);
  outline: none;
}
.wp-opt-disabled {
  opacity: 0.45; cursor: not-allowed;
}
.wp-opt-disabled:hover { background: var(--bg2); border-color: var(--border); }
.wp-opt-icon {
  font-size: 24px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px;
  flex-shrink: 0;
}
.wp-opt-text { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.wp-opt-title { font-size: 14px; font-weight: 600; color: var(--t1); }
.wp-opt-sub { font-size: 12px; color: var(--t3); }
.wp-opt-chev {
  font-size: 18px; color: var(--t3); margin-left: 4px;
  transition: transform 160ms ease;
}
.wp-opt:hover .wp-opt-chev { transform: translateX(2px); color: var(--t2); }
.wp-foot {
  padding: 10px 20px 16px;
  border-top: 1px solid var(--border);
}
.wp-foot-hint {
  font-size: 11px; color: var(--t3); line-height: 1.5;
}

/* ───────── Telegram Mini App mode ─────────
   telegram-init.js sets body.tg-mode and populates --tg-* variables
   from the user's Telegram theme params. These rules adapt the most
   visible surface colors so the Mini App feels native to the user's
   Telegram (light/dark/custom theme) without losing GoBond's brand
   colors (greens, accents — those stay constant).

   The variables fall back to our existing tokens if Telegram didn't
   provide them (e.g. very old clients), so no risk of unstyled surfaces. */
body.tg-mode {
  /* Background mirrors Telegram's chat background. */
  background: var(--tg-bg, var(--bg));
  color: var(--tg-text, var(--t1));
}
body.tg-mode .hdr {
  /* Header surface uses Telegram's secondary bg so it sits flat against
     the Telegram chrome edge without a visible seam. */
  background: var(--tg-bg-2, var(--bg2));
}
body.tg-mode .hdr-logo,
body.tg-mode .hdr-logo a {
  /* Logo text on a Telegram-themed bg can clash with our default —
     defer to the Telegram text color. */
  color: var(--tg-text, var(--t1));
}
/* Hide the chain pill inside Telegram — BESC is the only chain anyway,
   and the pill steals header space that's tight on narrow Mini App
   viewports. */
body.tg-mode #chain-pill { display: none !important; }
/* Hide the connect wallet button on the very edge — in Telegram the
   wallet menu still works (tap user avatar / 3-dot menu) but the visible
   "Connect Wallet" pill is redundant: anyone in Telegram who taps trade
   gets routed through WC automatically.
   Currently still visible — flip this on if we get user feedback that
   it's confusing.
   body.tg-mode #wallet-btn { display: none; } */
/* Bottom-pad the page so the Telegram MainButton (60px tall) doesn't
   overlap the last row of content when shown. */
body.tg-mode.tg-mb-visible {
  padding-bottom: 80px;
}
