:root {
  --bg: #0b0d12;
  --panel: #14171f;
  --panel-2: #181c26;
  --inset: #0a0c10;
  --border: #232936;
  --border-soft: #1c212b;
  --text: #eef1f6;
  --muted: #8b93a7;
  --accent: #5b8cff;
  --accent-hover: #6f9bff;
  --good: #3ad07f;
  --bad: #ff6b6b;
  --gold: #f0b132;
  --radius: 14px;
  --radius-sm: 9px;
}

* { box-sizing: border-box; }
html {
  min-height: 100%;
  background-color: var(--bg);
}
body {
  margin: 0;
  min-height: 100vh;
  font-family: "Inter", -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
  line-height: 1.45;
  position: relative;
}
/* Fixed gradients on a separate layer — `background-attachment: fixed` can block clicks in Chromium. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-color: var(--bg);
  background-image:
    radial-gradient(1200px 600px at 80% -10%, rgba(91, 140, 255, 0.08), transparent 60%),
    radial-gradient(900px 500px at -10% 0%, rgba(199, 125, 255, 0.05), transparent 55%);
  background-repeat: no-repeat;
}

.hidden { display: none !important; pointer-events: none !important; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  padding: 16px 28px;
  border-bottom: 1px solid var(--border-soft);
  background: rgba(11, 13, 18, 0.7);
  backdrop-filter: blur(10px);
  position: relative;
  z-index: 2;
}
.brand {
  display: flex;
  align-items: center;
  text-decoration: none;
  line-height: 0;
}
.brand-logo {
  display: block;
  height: 40px;
  width: auto;
  max-width: min(320px, 72vw);
  object-fit: contain;
  object-position: left center;
}

.wrap { max-width: 920px; margin: 0 auto; padding: 40px 20px 80px; position: relative; z-index: 1; }

/* ---------- Search view ---------- */
.search { max-width: 560px; margin: 48px auto 0; text-align: center; }
.search h1 { font-size: 28px; margin: 0 0 8px; letter-spacing: -0.5px; }
.lede { color: var(--muted); margin: 0 0 28px; }
.search-form { display: flex; gap: 10px; }
.search-form input {
  flex: 1;
  background: var(--inset);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 13px 14px;
  font-size: 15px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}
.search-form input:focus { outline: none; border-color: var(--accent); }
button {
  cursor: pointer;
  border: none;
  border-radius: var(--radius-sm);
  padding: 13px 20px;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), #7b5bff);
}
button:hover { filter: brightness(1.08); }
button:disabled { opacity: 0.55; cursor: default; }
.ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.ghost:hover { color: var(--text); filter: none; background: var(--panel); }
.disclaimer { color: var(--muted); font-size: 12px; margin-top: 14px; }
.disclaimer.center { text-align: center; margin-top: 28px; }
.err { color: var(--bad); font-size: 13px; margin-top: 12px; }

/* ---------- Loading ---------- */
.loading { display: grid; place-items: center; gap: 16px; padding: 90px 0; color: var(--muted); }
.spinner {
  width: 38px; height: 38px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Profile ---------- */
.profile-top { display: flex; justify-content: space-between; margin-bottom: 22px; }
.share-btn { background: linear-gradient(135deg, #21d07a, #12a35e); }
.profile-head {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 12px 16px;
  margin-bottom: 18px;
  align-items: center;
}
.profile-head-text { min-width: 0; }
.pnl-controls {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding-top: 12px;
  margin-top: 4px;
  border-top: 1px solid var(--border-soft);
}
.chk {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}
.chk input { accent-color: var(--accent); width: 14px; height: 14px; }
.select-chk { gap: 8px; }
.select-chk select {
  padding: 6px 8px;
  font-size: 12px;
  background: var(--inset);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
}
.select-chk select:disabled { opacity: 0.45; cursor: not-allowed; }
.avatar {
  width: 56px; height: 56px; border-radius: 14px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #2a3142, #1a1f2b);
  border: 1px solid var(--border);
  font-size: 22px; font-weight: 800; color: var(--accent);
  overflow: hidden;
  flex-shrink: 0;
}
.avatar.has-img { padding: 0; background: var(--inset); }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.profile-head h2 { margin: 0; font-size: 22px; }
.wallet-line { color: var(--muted); font-size: 12px; font-family: ui-monospace, monospace; word-break: break-all; }
.wallet-line a { color: var(--accent); text-decoration: none; }
.wallet-line a:hover { text-decoration: underline; }

.pnl {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 22px;
}
.pnl-row { display: flex; align-items: baseline; gap: 14px; }
.pnl-net { font-size: 34px; font-weight: 800; letter-spacing: -1px; }
.pnl-roi { font-size: 18px; font-weight: 700; }
.pnl-sub { color: var(--muted); font-size: 12px; margin-top: 4px; }
.pos { color: var(--good); }
.neg { color: var(--bad); }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: start; }
@media (max-width: 740px) { .grid { grid-template-columns: 1fr; } }
.col { min-width: 0; }

.section-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 16px 0 8px;
}
.col .section-label:first-child { margin-top: 0; }
.itm-block { margin-top: 16px; margin-bottom: 0; }
.itm-block .section-label { margin-top: 0; }
.fp-block {
  margin-top: 22px;
  padding-top: 4px;
}
.fp-block .section-label { margin-top: 0; }

.statbox {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 14px;
}
.fpb-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 9px 0;
  border-bottom: 1px solid var(--border-soft);
}
.fpb-row:last-child { border-bottom: none; }
.fpb-k { color: var(--muted); }
.fpb-k-inner {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.info-tip {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  cursor: help;
}
.info-tip-icon {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid var(--muted);
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  font-style: italic;
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.info-tip-text {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 7px);
  transform: translateX(-50%);
  padding: 6px 10px;
  border-radius: 6px;
  background: #1a2030;
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 11px;
  font-weight: 500;
  font-style: normal;
  white-space: nowrap;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.12s ease, visibility 0.12s ease;
  z-index: 20;
}
.info-tip:hover .info-tip-text,
.info-tip:focus-visible .info-tip-text {
  opacity: 1;
  visibility: visible;
}
.fpb-v { font-weight: 600; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); font-weight: 400; }
.empty-note { color: var(--muted); padding: 10px 0; font-size: 13px; }

.chart-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.chart-head .section-label { margin: 0; }
.chart-expand-btn {
  padding: 5px 10px;
  font-size: 11px;
  font-weight: 600;
}
.chart-wrap {
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: box-shadow 0.15s ease;
}
.chart-wrap:hover { box-shadow: 0 0 0 1px var(--accent); }
.bankroll {
  width: 100%; height: 240px;
  display: block;
  background: var(--inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  pointer-events: none;
}
.chart-modal-inner { width: min(96vw, 1100px); }
.chart-modal-frame {
  width: 100%;
  background: var(--inset);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
}
.chart-modal-svg {
  width: 100%;
  height: min(62vh, 560px);
  display: block;
}

/* ---------- Share modal ---------- */
.share-modal {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: grid; place-items: center;
  z-index: 100; padding: 20px;
}
.share-inner { display: flex; flex-direction: column; gap: 14px; align-items: center; }
#shareCanvas {
  max-width: min(92vw, 720px);
  height: auto;
  border-radius: 14px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
}
.share-actions { display: flex; gap: 10px; }
