/* 1inch: Portfolio Viewer — styled after the 1inch swap dApp.
   Flat near-black blue canvas, #131823 "swap cards" with 24px radii, inset
   amount "wells", the signature translucent-blue primary button, round header
   controls, segmented pill tabs and a network rail of colored rings.
   Muted text uses 1inch's steel blue #6C86AD.
   Type: Inter everywhere (numbers tabular), Sora only for the wordmark/total. */

/* ---------- fonts ---------- */
@font-face {
  font-family: 'Sora';
  src: url('fonts/sora-var.woff2') format('woff2');
  font-weight: 100 800;
  font-display: swap;
}
@font-face {
  font-family: 'Inter';
  src: url('fonts/inter-var.woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
}

/* ---------- tokens ---------- */
:root {
  --bg: #0b0f19;
  --card: #131823;
  --card-2: #171e2c;
  --well: #0a0e17;
  --hover: #1b2431;
  --line: rgba(255, 255, 255, 0.05);
  --line-2: rgba(255, 255, 255, 0.09);
  --text: #f8fafd;
  --muted: #6c86ad;
  --faint: #465a7c;
  --blue: #2f8af5;
  --blue-hi: #4e9df5;
  --blue-soft: rgba(47, 138, 245, 0.16);
  --blue-soft-2: rgba(47, 138, 245, 0.26);
  --red: #f04832;
  --red-soft: rgba(240, 72, 50, 0.14);
  --green: #21c187;
  --gold: #ffd923;
  --r-card: 20px;
  --r-well: 16px;
  --r-btn: 14px;
  --font-display: 'Sora', 'Inter', sans-serif;
  --font-body: 'Inter', -apple-system, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
  font-family: var(--font-body);
  font-size: 13.5px;
  color: var(--text);
  background:
    radial-gradient(560px 300px at 50% -160px, rgba(47, 138, 245, 0.09), transparent 70%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
}
body.popup { width: 400px; height: 600px; overflow: hidden; }
/* Full view is an app, not a page: the frame is fixed to the viewport and
   only the content column scrolls — header, wallet bar and network rail
   stay put, like the dApp. */
body.full { height: 100vh; overflow: hidden; }

img { user-select: none; }
button { font-family: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

.sum-total, .well-amount, .trow-val, .wsel-val, .sec-usd, .h-usd, .h-pct,
.mf-addr, .pill-addr, .about-ver, .meta-chip {
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum';
}

/* ================= splash ================= */
.splash {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  overflow: hidden;
  cursor: pointer;
  transition: opacity 0.55s ease, visibility 0.55s;
}
.splash.splash-out { opacity: 0; visibility: hidden; }

/* thin loading line pinned to the top, like a dApp page load */
.splash-line {
  position: absolute; top: 0; left: 0; right: 0;
  height: 3px;
  background: rgba(47, 138, 245, 0.12);
}
.splash-line i {
  display: block; height: 100%;
  background: linear-gradient(90deg, var(--blue), #6cc4ff);
  border-radius: 0 3px 3px 0;
  animation: line-fill 2.3s cubic-bezier(0.25, 0.6, 0.35, 1) forwards;
}
@keyframes line-fill {
  0% { width: 0; } 45% { width: 52%; } 78% { width: 83%; } 100% { width: 100%; }
}

/* soft breathing halo behind the mark */
.splash-halo {
  position: absolute;
  width: 420px; height: 420px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(47, 138, 245, 0.14), transparent 65%);
  animation: halo 2.4s ease-in-out infinite alternate;
}
@keyframes halo { from { transform: scale(0.85); opacity: 0.6; } to { transform: scale(1.15); opacity: 1; } }

.splash-inner {
  position: relative; z-index: 2;
  display: flex; flex-direction: column; align-items: center;
  animation: splash-pop 0.8s cubic-bezier(0.16, 1, 0.3, 1) both;
}
@keyframes splash-pop {
  from { opacity: 0; transform: scale(0.86); }
  to   { opacity: 1; transform: none; }
}
.splash-logo { position: relative; margin-bottom: 30px; }
.splash-logo img {
  display: block;
  filter: drop-shadow(0 14px 44px rgba(47, 138, 245, 0.4));
  animation: logo-beat 2.4s ease-in-out infinite;
}
@keyframes logo-beat {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.045); }
}
/* orbiting satellite dot — nod to the routing paths of an aggregator */
.splash-orbit {
  position: absolute; inset: -26px;
  border-radius: 50%;
  border: 1px dashed rgba(108, 134, 173, 0.22);
  animation: orbit-spin 7s linear infinite;
}
.splash-orbit::before {
  content: '';
  position: absolute; top: -4px; left: 50%;
  width: 8px; height: 8px; margin-left: -4px;
  border-radius: 50%;
  background: var(--blue-hi);
  box-shadow: 0 0 12px var(--blue);
}
@keyframes orbit-spin { to { transform: rotate(360deg); } }

.splash-title {
  font-family: var(--font-display);
  font-size: 27px; font-weight: 800; letter-spacing: -0.3px;
}
.splash-title b {
  font-weight: 300; color: var(--muted);
}
.splash-sub {
  display: inline-flex; align-items: center; gap: 7px;
  margin-top: 14px;
  font-size: 11.5px; font-weight: 600;
  color: var(--muted);
  background: var(--card);
  border: 1px solid var(--line-2);
  border-radius: 999px;
  padding: 6px 14px;
}
.splash-sub::before {
  content: '';
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px rgba(33, 193, 135, 0.8);
  animation: halo 1.4s ease-in-out infinite alternate;
}

/* ================= app frame ================= */
.app { display: flex; flex-direction: column; height: 600px; }
body.full .app { height: 100vh; }
.app.wide { max-width: 860px; margin: 0 auto; padding: 0 20px; width: 100%; }

.topbar {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 14px;
}
.app.wide .topbar { padding: 18px 0 14px; }

.brand { display: flex; align-items: center; gap: 10px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text .name {
  font-family: var(--font-display);
  font-weight: 800; font-size: 14px; letter-spacing: -0.2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.brand-text .sub { font-size: 10px; color: var(--muted); white-space: nowrap; }
.brand { flex: 0 0 auto; }

.spacer { flex: 1; }

/* account-style pill, like the connected-wallet chip in the dApp */
.readonly-pill {
  display: inline-flex; align-items: center; gap: 6px;
  white-space: nowrap; flex: 0 0 auto;
  font-size: 11px; font-weight: 700;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--line-2);
  border-radius: 999px;
  padding: 7px 13px;
  margin-right: 2px;
}
.readonly-pill::before {
  content: '';
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 6px rgba(33, 193, 135, 0.7);
}

/* round header controls, 1inch style */
.icon-btn {
  width: 34px; height: 34px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  color: var(--muted);
  background: var(--card);
  transition: background 0.15s, color 0.15s, transform 0.12s;
}
.icon-btn:hover { color: var(--text); background: var(--hover); }
.icon-btn:active { transform: scale(0.93); }

/* ---------- wallet segmented bar ---------- */
.chips {
  display: flex; gap: 8px; align-items: center;
  padding: 2px 14px 8px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.app.wide .chips { padding: 2px 0 8px; }
.chips:empty { display: none; }

.wseg {
  display: inline-flex; gap: 2px;
  background: var(--card);
  border-radius: 999px;
  padding: 3px;
}
.seg {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600;
  color: var(--muted);
  border-radius: 999px;
  padding: 7px 14px;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}
.seg:hover { color: var(--text); }
.seg.on { color: var(--text); background: var(--hover); }
.seg-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--blue-hi);
  animation: halo 0.9s ease-in-out infinite alternate;
}
.seg-add {
  flex: 0 0 auto;
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  color: var(--blue-hi);
  background: var(--blue-soft);
  transition: background 0.15s, transform 0.12s;
}
.seg-add:hover { background: var(--blue-soft-2); }
.seg-add:active { transform: scale(0.92); }
.seg-add svg { width: 15px; height: 15px; }

/* ---------- network rail ---------- */
.nets {
  display: flex; gap: 6px;
  padding: 2px 14px 10px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
}
.nets::-webkit-scrollbar { display: none; }
.app.wide .nets { padding: 2px 0 10px; }

.tab.net {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 11.5px; font-weight: 600;
  color: var(--muted);
  background: var(--card);
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 7px 12px;
  transition: all 0.15s;
}
.tab.net:hover { color: var(--text); background: var(--hover); }
.tab.net.on {
  color: var(--blue-hi);
  background: var(--blue-soft);
  border-color: rgba(47, 138, 245, 0.35);
}
.net-ic {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--c, var(--muted));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--c, #6c86ad) 22%, transparent);
}
.net-all { background: conic-gradient(#627eea, #2d9cdb, #ff0420, #0052ff, #8247e5, #627eea); }

/* ---------- content ---------- */
.content {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain; /* wheel momentum stops here, never the page */
  padding: 2px 14px 16px;
  scrollbar-width: thin;
  scrollbar-color: #232c3d transparent;
}
.app.wide .content { padding: 2px 0 24px; }
.content::-webkit-scrollbar { width: 8px; }
.content::-webkit-scrollbar-thumb { background: #232c3d; border-radius: 8px; }

/* Entrance animation only when the view changes (app.js sets .animate for
   that one paint) — silent refresh re-renders must not flash or slide. */
.content.animate > section, .content.animate > .banner {
  animation: rise 0.3s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.content.animate > section:nth-child(2) { animation-delay: 0.05s; }
.content.animate > section:nth-child(3) { animation-delay: 0.1s; }
@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

/* Off-screen sections skip layout & paint entirely (long token lists). */
.net-sec { content-visibility: auto; contain-intrinsic-size: auto 240px; }

/* ---------- the swap-card ---------- */
.swap-card {
  background: var(--card);
  border-radius: var(--r-card);
  padding: 16px;
  margin-bottom: 10px;
}
.sc-flush { padding: 6px; }
.sc-title {
  font-size: 12px; font-weight: 600;
  color: var(--muted);
  margin-bottom: 12px;
}
.sc-gap { margin-top: 18px; }
.sc-pad { padding: 10px 12px 4px; margin-bottom: 2px; }

/* ---------- buttons (the 1inch signature set) ---------- */
.btn-1inch {
  width: 100%;
  font-size: 14.5px; font-weight: 700;
  color: var(--blue-hi);
  background: var(--blue-soft);
  border-radius: var(--r-btn);
  padding: 15px;
  transition: background 0.15s, transform 0.1s;
}
.btn-1inch:hover { background: var(--blue-soft-2); }
.btn-1inch:active { transform: scale(0.985); }

.btn-dark {
  width: 100%;
  font-size: 13.5px; font-weight: 600;
  color: var(--muted);
  background: var(--well);
  border-radius: var(--r-btn);
  padding: 13px;
  margin-top: 8px;
  transition: background 0.15s, color 0.15s;
}
.btn-dark:hover { color: var(--text); background: var(--hover); }

.btn-red {
  width: 100%;
  font-size: 13.5px; font-weight: 700;
  color: #ff7d6e;
  background: var(--red-soft);
  border-radius: var(--r-btn);
  padding: 13px;
  transition: background 0.15s;
}
.btn-red:hover { background: rgba(240, 72, 50, 0.24); }

/* round micro-buttons (back / edit / close) */
.rbtn {
  width: 30px; height: 30px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  color: var(--muted);
  background: var(--card-2);
  transition: background 0.15s, color 0.15s;
}
.well .rbtn { background: rgba(255, 255, 255, 0.05); }
.rbtn:hover { color: var(--text); background: var(--hover); }
.rbtn-danger:hover { color: #ff7d6e; background: var(--red-soft); }
.rbtn svg { width: 14px; height: 14px; }

/* ---------- hero ---------- */
.hero { padding-top: 16px; }
.hero-card {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: 30px 22px 22px;
}
.hero-mark {
  width: 112px; height: 112px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 38%, rgba(47, 138, 245, 0.18), transparent 70%), var(--well);
  margin-bottom: 20px;
}
.hero-card h2 {
  font-family: var(--font-display);
  font-size: 21px; font-weight: 800; letter-spacing: -0.3px;
}
.hero-card p {
  color: var(--muted);
  font-size: 13px; line-height: 1.55;
  max-width: 300px;
  margin: 10px 0 20px;
}
.hero-card p b { color: var(--text); }
.hero-trust {
  display: flex; align-items: center; gap: 10px;
  margin-top: 18px;
  font-size: 11px; font-weight: 600; color: var(--faint);
}
.hero-trust span { display: inline-flex; align-items: center; gap: 5px; }
.hero-trust svg { width: 12px; height: 12px; color: var(--green); }
.hero-trust i { width: 3px; height: 3px; border-radius: 50%; background: var(--faint); }

/* ---------- the balance "well" (swap amount input look) ---------- */
.well {
  background: var(--well);
  border-radius: var(--r-card);
  padding: 14px 16px;
  margin: 4px 0 10px;
}
.well-top { display: flex; align-items: center; gap: 8px; }
.well-label { font-size: 12px; font-weight: 600; color: var(--muted); }
.well-amount {
  font-family: var(--font-display);
  font-size: 33px; font-weight: 800; letter-spacing: -1px;
  margin: 8px 0 10px;
  transition: opacity 0.3s;
}
.well-amount.dim { opacity: 0.4; }
.well-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.meta-chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 600;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.05);
  border-radius: 9px;
  padding: 5px 10px;
}
.meta-act { cursor: pointer; transition: background 0.15s, color 0.15s; position: relative; }
.meta-act:hover { color: var(--blue-hi); background: var(--blue-soft); }
.meta-act svg { width: 12px; height: 12px; }
.meta-ens { color: var(--blue-hi); }
.copied-tag { display: none; color: var(--green); font-weight: 700; }
.copy-btn.copied .copied-tag { display: inline; }
.copy-btn.copied svg, .copy-btn.copied .pill-addr { display: none; }

.upd {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 600; color: var(--faint);
  margin-left: auto;
}
.upd.busy { color: var(--blue-hi); }
.spin { animation: orbit-spin 0.9s linear infinite; }

.whead-label { font-family: var(--font-display); font-size: 15px; font-weight: 700; }

/* ---------- allocation ---------- */
.net-shares {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(64px, 1fr));
  gap: 6px;
}
.net-share {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  background: var(--well);
  border-radius: var(--r-well);
  padding: 12px 6px 10px;
}
.net-ring {
  width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  border: 2px solid var(--c);
}
.net-ring i { width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.net-share-name { font-size: 10.5px; font-weight: 700; color: var(--muted); letter-spacing: 0.4px; }
.net-share b { font-size: 12.5px; font-weight: 700; }

.h-list { display: flex; flex-direction: column; gap: 4px; }
.h-row {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 4px;
}
.h-row .tlogo { border-radius: 50%; }
.h-mid { flex: 1; min-width: 0; }
.h-line { display: flex; justify-content: space-between; margin-bottom: 5px; }
.h-sym { font-size: 12.5px; font-weight: 700; }
.h-usd { font-size: 12px; font-weight: 600; color: var(--muted); }
.h-track {
  height: 5px; border-radius: 4px;
  background: rgba(255, 255, 255, 0.05);
  overflow: hidden;
}
.h-track i {
  display: block; height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--blue), #6cc4ff);
}
.h-pct { font-size: 11px; font-weight: 600; color: var(--faint); width: 36px; text-align: right; }

/* ---------- wallet selector rows ---------- */
.wsel {
  display: flex; align-items: center; gap: 11px;
  width: 100%;
  text-align: left;
  border-radius: var(--r-well);
  padding: 11px 12px;
  transition: background 0.14s;
}
.wsel:hover { background: var(--hover); }
.wsel-ava {
  flex: 0 0 auto;
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 800;
  color: var(--blue-hi);
  background: var(--blue-soft);
  border-radius: 50%;
}
.wsel-id { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.wsel-id b { font-size: 13.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wsel-id span { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wsel-val { margin-left: auto; display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.wsel-val b { font-size: 14px; font-weight: 700; }
.wsel-dots { display: flex; align-items: center; gap: 3px; }
.mini-dot { width: 6px; height: 6px; border-radius: 50%; }
.wsel-chev { color: var(--faint); display: flex; }
.wsel:hover .wsel-chev { color: var(--muted); }
.w-err {
  width: 15px; height: 15px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 800;
  color: var(--gold);
  border: 1.5px solid rgba(255, 217, 35, 0.5);
  border-radius: 50%;
}

/* ---------- per-network sections & token rows ---------- */
.net-sec { margin-bottom: 8px; }
.sec-head {
  display: flex; align-items: center; gap: 9px;
  padding: 10px 12px 8px;
}
.sec-ic { width: 12px; height: 12px; }
.sec-name { font-size: 13px; font-weight: 700; }
.sec-link { color: var(--faint); display: inline-flex; transition: color 0.15s; }
.sec-link:hover { color: var(--blue-hi); }
.sec-link svg { width: 12px; height: 12px; }
.sec-usd { font-size: 13px; font-weight: 700; }

.trow {
  display: flex; align-items: center; gap: 11px;
  border-radius: var(--r-well);
  padding: 9px 12px;
  transition: background 0.14s;
}
.trow:hover { background: var(--hover); }
.trow .tlogo { border-radius: 50%; background: var(--well); }
.trow-id { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.trow-id b { font-size: 13.5px; font-weight: 700; }
.trow-id span { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px; }
.trow-val { margin-left: auto; display: flex; flex-direction: column; align-items: flex-end; gap: 1px; }
.trow-val b { font-size: 13.5px; font-weight: 700; }
.trow-val span { font-size: 10.5px; color: var(--faint); }

.unpriced {
  padding: 9px 12px 10px;
  font-size: 10.5px; color: var(--faint);
}

/* long lists are capped; this expands them on demand */
.sec-more {
  display: block;
  width: calc(100% - 12px);
  margin: 2px 6px 6px;
  font-size: 12px; font-weight: 700;
  color: var(--blue-hi);
  background: var(--blue-soft);
  border-radius: 12px;
  padding: 10px;
  transition: background 0.15s;
}
.sec-more:hover { background: var(--blue-soft-2); }

.empty-card {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: 32px 18px;
}
.empty-ic {
  width: 46px; height: 46px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  color: var(--muted);
  background: var(--well);
  margin-bottom: 10px;
}
.empty-card b { font-size: 14px; }
.empty-card p { font-size: 12px; color: var(--muted); margin-top: 5px; max-width: 260px; }

.banner {
  display: flex; align-items: flex-start; gap: 8px;
  font-size: 11.5px; color: #ffc46b;
  background: rgba(255, 187, 51, 0.08);
  border-radius: var(--r-well);
  padding: 10px 12px;
  margin-bottom: 10px;
}
.banner svg { width: 14px; height: 14px; flex: 0 0 auto; margin-top: 1px; }

/* skeletons */
.skel {
  display: inline-block;
  border-radius: 6px;
  background: linear-gradient(90deg, rgba(108, 134, 173, 0.09) 25%, rgba(108, 134, 173, 0.18) 50%, rgba(108, 134, 173, 0.09) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.3s infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }
.skel-usd { width: 60px; height: 13px; }
.skel-dot { width: 12px; height: 12px; border-radius: 50%; }
.skel-name { width: 90px; height: 13px; }
.skel-ic { width: 32px; height: 32px; border-radius: 50%; flex: 0 0 auto; }
.skel-a { width: 40%; height: 12px; }
.skel-b { width: 25%; height: 12px; margin-left: auto; }

/* ---------- footer ---------- */
.footer {
  display: flex; align-items: center; justify-content: center; gap: 5px; flex-wrap: wrap;
  font-size: 10.5px; color: var(--faint);
  padding: 10px 12px;
}
.footer-link {
  font-size: 10.5px; color: var(--muted);
  text-decoration: underline; text-underline-offset: 2px;
}
.footer-link:hover { color: var(--blue-hi); }
.footer-note { width: 100%; text-align: center; opacity: 0.7; }
.app.wide .footer-note { width: auto; margin-left: 10px; }

/* ================= modal ================= */
.modal-backdrop[hidden] { display: none; }
.modal-backdrop {
  position: fixed; inset: 0; z-index: 40;
  display: flex; align-items: center; justify-content: center;
  background: rgba(4, 6, 12, 0.72);
  backdrop-filter: blur(8px);
  opacity: 0;
  transition: opacity 0.2s;
  padding: 18px;
  overflow-y: auto;
}
.modal-backdrop.open { opacity: 1; }

.modal {
  position: relative;
  width: 100%; max-width: 372px;
  max-height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--card);
  border-radius: 24px;
  padding: 18px;
  transform: translateY(14px);
  transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  scrollbar-width: thin;
}
.modal-backdrop.open .modal { transform: none; }
.modal-sm { max-width: 330px; }

.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.modal-head h3 { font-family: var(--font-display); font-size: 16px; font-weight: 700; }

.mf-sub { font-size: 12.5px; color: var(--muted); line-height: 1.55; margin-bottom: 14px; }
.mf-label {
  display: block;
  font-size: 11.5px; font-weight: 600;
  color: var(--muted);
  margin: 12px 0 6px;
}
.mf-well {
  background: var(--well);
  border-radius: var(--r-well);
  border: 1.5px solid transparent;
  transition: border-color 0.15s;
}
.mf-well:focus-within { border-color: var(--blue); }
.mf-input {
  width: 100%;
  font-family: inherit; font-size: 14px;
  color: var(--text);
  background: none; border: 0; outline: none;
  padding: 13px 14px;
}
.mf-input::placeholder { color: var(--faint); }
.mf-input.mono { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 12.5px; }
.mf-input.invalid { color: #ff9d92; }
.mf-addr {
  font-size: 12px; color: var(--faint);
  font-family: ui-monospace, Menlo, monospace;
  margin-top: 10px;
}
.mf-err { font-size: 12px; color: #ff7d6e; margin-top: 8px; }
.mf-row { display: flex; gap: 8px; margin-top: 8px; }
.mf-row .btn-dark { margin-top: 0; }

.modal .btn-1inch { margin-top: 16px; }
.modal .mf-row .btn-red, .modal .mf-row .btn-dark { margin-top: 8px; }

/* onboarding */
.ob-hero { text-align: center; padding: 4px 0; }
.ob-hero-ic {
  width: 78px; height: 78px;
  margin: 0 auto 12px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 35%, rgba(47, 138, 245, 0.2), transparent 70%), var(--well);
}
.ob-hero h2 { font-family: var(--font-display); font-size: 17px; font-weight: 800; }
.ob-hero p { font-size: 12.5px; color: var(--muted); line-height: 1.55; margin-top: 8px; }

.ob-sec-title {
  display: flex; align-items: baseline; gap: 8px;
  font-size: 12px; font-weight: 600;
  color: var(--muted);
  margin: 18px 0 10px;
}
.ob-hint { font-size: 10.5px; color: var(--faint); }

.ob-steps { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.ob-step {
  display: flex; align-items: flex-start; gap: 10px;
  background: var(--well);
  border-radius: var(--r-well);
  padding: 11px 12px;
}
.ob-num {
  flex: 0 0 auto;
  width: 21px; height: 21px;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 800;
  color: var(--blue-hi);
  background: var(--blue-soft);
  border-radius: 50%;
}
.ob-ic { flex: 0 0 auto; color: var(--muted); margin-top: 2px; }
.ob-ic svg { width: 14px; height: 14px; }
.ob-text { display: flex; flex-direction: column; gap: 2px; }
.ob-text b { font-size: 12.5px; }
.ob-text span { font-size: 11.5px; color: var(--muted); line-height: 1.45; }
.ob-text code {
  font-family: ui-monospace, Menlo, monospace;
  font-size: 10.5px;
  color: var(--blue-hi);
  background: var(--blue-soft);
  border-radius: 5px;
  padding: 1px 5px;
}

.ob-safe {
  display: flex; align-items: flex-start; gap: 9px;
  font-size: 11.5px; color: var(--muted); line-height: 1.5;
  background: rgba(33, 193, 135, 0.08);
  border-radius: var(--r-well);
  padding: 11px 12px;
  margin-top: 10px;
}
.ob-safe svg { width: 14px; height: 14px; color: var(--green); flex: 0 0 auto; margin-top: 1px; }
.ob-safe b { color: var(--text); }

.quiz { display: flex; flex-direction: column; gap: 12px; }
.quiz-q { font-size: 12.5px; font-weight: 600; margin-bottom: 7px; }
.quiz-opts { display: flex; flex-direction: column; gap: 6px; }
.quiz-opt {
  display: flex; align-items: center; gap: 9px;
  text-align: left;
  font-size: 12px;
  color: var(--muted);
  background: var(--well);
  border-radius: var(--r-well);
  padding: 10px 12px;
  transition: background 0.15s, color 0.15s;
}
.quiz-opt:not(:disabled):hover { color: var(--text); background: var(--hover); }
.qo-mark {
  flex: 0 0 auto;
  width: 15px; height: 15px;
  border: 2px solid var(--faint);
  border-radius: 50%;
  transition: all 0.15s;
}
.quiz-opt.correct { color: var(--text); background: rgba(33, 193, 135, 0.12); }
.quiz-opt.correct .qo-mark { border-color: var(--green); background: var(--green); box-shadow: inset 0 0 0 3px var(--card); }
.quiz-opt.wrong { color: var(--text); background: var(--red-soft); }
.quiz-opt.wrong .qo-mark { border-color: var(--red); background: var(--red); box-shadow: inset 0 0 0 3px var(--card); }
.quiz-why {
  display: flex; align-items: flex-start; gap: 8px;
  font-size: 11.5px; color: var(--muted); line-height: 1.5;
  margin-top: 8px;
  padding: 9px 11px;
  background: rgba(33, 193, 135, 0.06);
  border-radius: 10px;
}
.quiz-why svg { width: 13px; height: 13px; color: var(--green); flex: 0 0 auto; margin-top: 1px; }

.ob-legal { font-size: 10px; color: var(--faint); text-align: center; margin-top: 14px; }

/* ================= status strip ================= */
.status {
  display: flex; align-items: center; gap: 8px;
  background: var(--card);
  border-radius: var(--r-well);
  padding: 9px 12px;
  margin-bottom: 10px;
  overflow-x: auto;
  scrollbar-width: none;
}
.status::-webkit-scrollbar { display: none; }
.status > b { font-size: 12px; white-space: nowrap; }
.status-led { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; }
.status.ok .status-led { background: var(--green); box-shadow: 0 0 8px rgba(33, 193, 135, 0.7); }
.status.warn .status-led { background: var(--gold); box-shadow: 0 0 8px rgba(255, 217, 35, 0.6); }
.status-chips { display: flex; gap: 6px; margin-left: auto; }
.status-chips .meta-chip { white-space: nowrap; flex: 0 0 auto; }
.meta-chip.pos { color: var(--green); background: rgba(33, 193, 135, 0.1); }
.meta-chip.neg { color: #ff8a7a; background: var(--red-soft); }
.meta-chip.warnc { color: #ffce7a; background: rgba(255, 187, 51, 0.09); }

/* ================= privacy mode ================= */
.icon-btn.on { color: var(--blue-hi); background: var(--blue-soft); }
body.privacy :is(.well-amount, .sec-usd, .trow-val, .wsel-val > b, .h-usd,
  .h-pct, .net-share b, .meta-chip.pos, .meta-chip.neg) {
  filter: blur(9px);
  transition: filter 0.18s;
}
/* hover to peek one value at a time */
body.privacy :is(.well-amount, .sec-usd, .trow-val, .wsel-val > b, .h-usd,
  .h-pct, .net-share b):hover { filter: blur(0); }

/* ================= command palette ================= */
.pal-ov[hidden] { display: none; }
.pal-ov {
  position: fixed; inset: 0; z-index: 50;
  display: flex; justify-content: center; align-items: flex-start;
  background: rgba(4, 6, 12, 0.72);
  backdrop-filter: blur(8px);
  padding: 56px 16px 16px;
  opacity: 0;
  transition: opacity 0.15s;
}
.pal-ov.open { opacity: 1; }
.pal {
  width: 100%; max-width: 430px;
  background: var(--card);
  border-radius: 20px;
  padding: 8px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
}
.pal-well {
  display: flex; align-items: center; gap: 9px;
  background: var(--well);
  border-radius: 14px;
  padding: 11px 13px;
}
.pal-well > svg { width: 15px; height: 15px; color: var(--muted); flex: 0 0 auto; }
.pal-well input {
  flex: 1; min-width: 0;
  background: none; border: 0; outline: none;
  color: var(--text);
  font: inherit; font-size: 13.5px;
}
.pal-well input::placeholder { color: var(--faint); }
.pal-esc {
  font-size: 9.5px; font-weight: 700; color: var(--faint);
  border: 1px solid var(--line-2);
  border-radius: 5px;
  padding: 2px 5px;
}
.pal-list { max-height: 340px; overflow-y: auto; overscroll-behavior: contain; margin-top: 6px; scrollbar-width: thin; }
.pal-group {
  font-size: 10px; font-weight: 700; letter-spacing: 0.8px; text-transform: uppercase;
  color: var(--faint);
  padding: 9px 10px 4px;
}
.pal-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  text-align: left;
  border-radius: 12px;
  padding: 8px 10px;
  color: var(--muted);
}
.pal-item.on { background: var(--hover); }
.pal-item > b { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; }
.pi-name {
  font-size: 11px; color: var(--faint);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  min-width: 0;
}
.pi-sub { font-size: 11px; color: var(--faint); margin-left: auto; white-space: nowrap; }
.pi-sub i {
  font-style: normal; font-size: 9.5px; font-weight: 700;
  color: var(--blue-hi);
  background: var(--blue-soft);
  border-radius: 5px;
  padding: 1.5px 5px;
  margin-left: 4px;
}
.pal-ic {
  width: 28px; height: 28px; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: var(--well);
  color: var(--blue-hi);
  overflow: hidden;
}
.pal-ic svg { width: 14px; height: 14px; }
.pal-ic img { border-radius: 50%; }
.pal-ava {
  font-size: 12px; font-weight: 800; color: var(--blue-hi);
}
.pal-empty { padding: 18px 14px; text-align: center; color: var(--faint); font-size: 12px; }

/* ================= options page ================= */
.opts-page {
  max-width: 680px;
  margin: 0 auto;
  padding: 0 20px;
  min-height: 100vh;
  display: flex; flex-direction: column;
}
.opts-page .topbar { padding: 18px 0 14px; }
.content-flow { flex: 1; padding: 6px 0 18px; }
.card { background: var(--card); border-radius: var(--r-card); margin-bottom: 10px; }
.card-title {
  font-size: 12px; font-weight: 600; color: var(--muted);
  margin-bottom: 10px;
}
.opt-sec { padding: 16px; }
.opt-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; }
.opt-row + .opt-row { border-top: 1px solid var(--line); }
.opt-info { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.opt-name { font-size: 13px; font-weight: 600; }
.opt-desc { font-size: 11.5px; color: var(--muted); }
.opt-mini {
  flex: 0 0 auto;
  font-size: 12px; font-weight: 700;
  color: var(--blue-hi);
  background: var(--blue-soft);
  border-radius: 10px;
  padding: 8px 14px;
  transition: background 0.15s;
}
.opt-mini:hover { background: var(--blue-soft-2); }
.opt-mini.danger { color: #ff7d6e; background: var(--red-soft); }
.opt-mini.danger:hover { background: rgba(240, 72, 50, 0.24); }
.opt-empty { font-size: 12.5px; color: var(--faint); padding: 8px 0; }

.about-box { display: flex; gap: 14px; align-items: flex-start; }
.about-name { font-family: var(--font-display); font-size: 15px; font-weight: 800; }
.about-ver { font-size: 11px; color: var(--faint); margin: 2px 0 8px; }
.about-note { font-size: 11.5px; color: var(--muted); line-height: 1.55; margin-bottom: 6px; }
.about-link { color: var(--blue-hi); text-decoration: underline; text-underline-offset: 2px; }

/* ================= a11y & motion ================= */
:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
  border-radius: 8px;
}
button:focus:not(:focus-visible) { outline: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ================= privacy page ================= */
.legal-page { max-width: 640px; margin: 0 auto; padding: 30px 20px 50px; }
body.full:has(.legal-page), body.full:has(.opts-page) { overflow-y: auto; height: auto; }
.legal-page h1 { font-family: var(--font-display); font-size: 22px; margin-bottom: 4px; }
.legal-updated { font-size: 11.5px; color: var(--faint); margin-bottom: 22px; }
.legal-page h2 { font-family: var(--font-display); font-size: 15px; margin: 20px 0 8px; }
.legal-page p, .legal-page li { font-size: 13px; color: var(--muted); line-height: 1.65; }
.legal-page ul { padding-left: 20px; margin: 8px 0; }
.legal-page b { color: var(--text); }
.legal-page code {
  font-family: ui-monospace, Menlo, monospace;
  font-size: 11.5px;
  color: var(--blue-hi);
  background: var(--blue-soft);
  border-radius: 5px;
  padding: 1px 5px;
}

/* ---- standalone privacy-site header/footer ---- */
.legal-brand {
  display: flex; align-items: center; gap: 12px;
  padding-bottom: 22px; margin-bottom: 8px;
  border-bottom: 1px solid var(--line);
}
.legal-brand img { border-radius: 10px; }
.legal-brand-name { font-family: var(--font-display); font-size: 15px; font-weight: 800; color: var(--text); }
.legal-brand-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.legal-foot {
  margin-top: 34px; padding-top: 18px;
  border-top: 1px solid var(--line);
  font-size: 11.5px; color: var(--faint);
}
