:root{
  --bg0:#070A12;
  --bg1:#0B1020;
  --card: rgba(255,255,255,0.06);
  --card2: rgba(255,255,255,0.09);
  --text:#EAF0FF;
  --muted: rgba(234,240,255,0.72);
  --muted2: rgba(234,240,255,0.55);
  --line: rgba(234,240,255,0.14);
  --accent: #7C5CFF;
  --accent2:#00D5FF;
  --shadow: 0 20px 80px rgba(0,0,0,0.55);
  --radius: 18px;

  --good:#39d98a;
  --bad:#ff4b4b;
}

:root[data-theme="light"]{
  --bg0:#F7F9FF;
  --bg1:#FFFFFF;
  --card: rgba(0,0,0,0.03);
  --card2: rgba(0,0,0,0.06);
  --text:#0C1020;
  --muted: rgba(12,16,32,0.72);
  --muted2: rgba(12,16,32,0.55);
  --line: rgba(12,16,32,0.12);
  --shadow: 0 20px 60px rgba(0,0,0,0.12);
}

*{ box-sizing:border-box; }

body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;
  color: var(--text);
  background:
    radial-gradient(900px 600px at 15% 20%, rgba(124,92,255,0.20), transparent 55%),
    radial-gradient(900px 600px at 85% 15%, rgba(0,213,255,0.16), transparent 55%),
    radial-gradient(900px 700px at 50% 120%, rgba(124,92,255,0.12), transparent 60%),
    linear-gradient(180deg, var(--bg0), var(--bg1));
  min-height:100vh;
}

.topbar{
  position:sticky;
  top:0;
  z-index:10;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:16px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg1) 82%, transparent);
  backdrop-filter: blur(10px);
}

.brand{
  display:flex;
  align-items:center;
  gap:12px;
  min-width: 240px;
}

.brandLogo{
  width:56px;
  height:56px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.04);
  display:grid;
  place-items:center;
  position:relative;
  overflow:hidden;
}

.brandLogo img{
  width:44px;
  height:44px;
  object-fit:contain;
  filter: drop-shadow(0 10px 20px rgba(0,0,0,0.25));
}

.brandFallback{
  font-weight:800;
  font-size: 22px;
  opacity:0.7;
}

.brandText{ display:flex; flex-direction:column; line-height:1.1; }
.brandTitle{ font-weight:800; font-size: 18px; letter-spacing:-0.02em; }
.brandTitleSub{ opacity:0.8; font-weight:700; }
.brandHint{ font-size: 12px; color: var(--muted2); margin-top:4px; }

.headerStats{
  display:flex;
  gap:14px;
  align-items:flex-end;
  flex: 1;
  justify-content:center;
}

.statBlock{
  border: 1px solid var(--line);
  background: rgba(0,0,0,0.10);
  padding: 10px 12px;
  border-radius: 16px;
  min-width: 140px;
}

:root[data-theme="light"] .statBlock{
  background: rgba(255,255,255,0.72);
}

.statRight{ text-align:right; }

.statLabel{
  font-size: 12px;
  color: var(--muted2);
  display:flex;
  gap:8px;
  align-items:center;
  justify-content:flex-start;
}
.statRight .statLabel{ justify-content:flex-end; }

.statValue{
  font-size: 20px;
  font-weight: 850;
  letter-spacing: -0.02em;
  margin-top: 4px;
}

.dot{
  width:10px;
  height:10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.25);
  border: 1px solid var(--line);
}

.headerActions{
  display:flex;
  align-items:center;
  gap:10px;
}

.iconBtn{
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.05);
  color: var(--text);
  border-radius: 14px;
  padding: 10px 12px;
  cursor:pointer;
}

.iconBtn:hover{ background: rgba(255,255,255,0.08); }

.primaryBtn{
  border: 1px solid rgba(124,92,255,0.35);
  background: rgba(124,92,255,0.18);
  color: var(--text);
  border-radius: 16px;
  padding: 10px 14px;
  cursor:pointer;
  font-weight: 750;
}

.primaryBtn:hover{ background: rgba(124,92,255,0.24); }

.ghostBtn{
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  border-radius: 14px;
  padding: 10px 12px;
  cursor:pointer;
}

.container{
  width:min(980px, 100%);
  margin: 0 auto;
  padding: 18px;
}

.toolbar{
  display:flex;
  gap:10px;
  align-items:center;
  justify-content:space-between;
  margin-bottom: 14px;
}

.search{
  flex: 1;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  border-radius: 16px;
  padding: 12px 14px;
  outline:none;
}

.select{
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  border-radius: 16px;
  padding: 12px 14px;
  outline:none;
}

.list{
  display:flex;
  flex-direction:column;
  gap:12px;
}

.cardRow{
  border: 1px solid var(--line);
  background: linear-gradient(180deg, var(--card), rgba(255,255,255,0.03));
  border-radius: 22px;
  padding: 14px;
  display:grid;
  grid-template-columns: 100px 1fr 130px;
  gap: 10px;
  align-items:center;
  box-shadow: 0 12px 40px rgba(0,0,0,0.20);
  cursor:pointer;
}

:root[data-theme="light"] .cardRow{
  box-shadow: 0 12px 30px rgba(0,0,0,0.10);
}

.left{
  display:flex;
  align-items:center;
  gap:12px;
}

.coinIcon{
  width:46px;
  height:46px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.06);
  display:grid;
  place-items:center;
  overflow:hidden;
  flex: 0 0 auto;
}

.coinIcon img{
  width: 34px;
  height: 34px;
  object-fit:contain;
}

.tickerBlock{
  display:flex;
  flex-direction:column;
  gap:4px;
}

.ticker{
  font-size: 18px;
  font-weight: 900;
  letter-spacing: -0.02em;
}

.mini{
  font-size: 12px;
  color: var(--muted2);
}

.mid{
  display:flex;
  align-items:center;
  gap: 10px;
  min-width: 0;
}

.mid .price{
  font-size: 16px;
  font-weight: 850;
  white-space: nowrap;
  flex: 0 0 auto;
}

.mid .units{
  font-size: 14px;
  font-weight: 750;
  color: var(--muted);
  white-space: nowrap;
  flex: 0 0 auto;
}

.mid .pct{
  font-size: 16px;
  font-weight: 900;
  margin-left: auto;
  white-space: nowrap;
  flex: 0 0 auto;
}

.right{
  text-align:right;
  font-size: 22px;
  font-weight: 900;
}

.pct.good{ color: var(--good); }
.pct.bad{ color: var(--bad); }

.empty{
  border: 1px dashed var(--line);
  border-radius: 20px;
  padding: 22px;
  text-align:center;
  color: var(--muted);
}

.emptyTitle{
  font-weight: 850;
  color: var(--text);
  margin-bottom: 6px;
}

/* Modal */
.modalBackdrop, .drawerBackdrop{
  position:fixed;
  inset:0;
  background: rgba(0,0,0,0.55);
  z-index: 50;
}

.modal{
  position:fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(720px, calc(100% - 24px));
  border: 1px solid var(--line);
  border-radius: 22px;
  background: linear-gradient(180deg, var(--bg1), color-mix(in srgb, var(--bg1) 80%, black));
  box-shadow: var(--shadow);
  z-index: 60;
  overflow:hidden;
}

.modalHeader{
  display:flex;
  justify-content:space-between;
  align-items:center;
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--line);
}

.modalTitle{
  font-weight: 900;
  font-size: 16px;
}

.modalBody{ padding: 14px; }
.modalFooter{
  padding: 14px;
  border-top: 1px solid var(--line);
  display:flex;
  align-items:center;
  gap:10px;
}

.fieldRow{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}

/* ── Mobile ────────────────────────────────────────────────────── */
@media (max-width: 620px){

  /* Topbar — wrap onto two rows */
  .topbar{
    flex-wrap: wrap;
    padding: 10px 14px;
    gap: 8px;
  }

  .brand{
    min-width: unset;
    flex: 1;
  }

  .brandLogo{ width: 42px; height: 42px; border-radius: 12px; }
  .brandLogo img{ width: 32px; height: 32px; }
  .brandTitle{ font-size: 15px; }
  .brandHint{ font-size: 11px; }

  /* Stats row below brand/actions */
  .headerStats{
    order: 3;
    width: 100%;
    justify-content: space-between;
    border-top: 1px solid var(--line);
    padding-top: 8px;
    margin-top: 2px;
  }

  .headerActions{ gap: 6px; }

  /* Shrink export/import to icon-only */
  #exportBtn, #importBtn{
    font-size: 0;
    padding: 10px 11px;
  }
  #exportBtn::before{ content: "\2B07"; font-size: 14px; }
  #importBtn::before{ content: "\2B06"; font-size: 14px; }

  /* Search + sort toolbar */
  .search{ font-size: 13px; padding: 10px 12px; }
  .select{ font-size: 12px; padding: 10px 8px; max-width: 128px; }

  /* Tabs */
  .tabNav{ gap: 4px; padding: 0 10px; }
  .tabBtn{ font-size: 13px; padding: 10px 12px; }

  /* Holdings rows — 2-row layout within card on mobile */
  .cardRow{
    grid-template-columns: 52px 1fr auto;
    grid-template-rows: auto auto;
    gap: 2px 8px;
    padding: 12px 10px;
    border-radius: 18px;
  }

  /* Icon spans both rows */
  .left{
    grid-column: 1;
    grid-row: 1 / 3;
    align-self: center;
  }

  .coinIcon{ width: 40px; height: 40px; }
  .coinIcon img{ width: 28px; height: 28px; }

  /* Row 1 col 2: ticker + name */
  .tickerBlock{
    grid-column: 2;
    grid-row: 1;
    align-self: end;
  }
  .ticker{ font-size: 15px; }
  .mini{ font-size: 11px; }

  /* Row 1 col 3: holding value */
  .right{
    grid-column: 3;
    grid-row: 1;
    font-size: 14px;
    font-weight: 800;
    align-self: end;
    justify-self: end;
  }

  /* Row 2 col 2-3: price, units, pct */
  .mid{
    grid-column: 2 / 4;
    grid-row: 2;
    display: flex;
    align-items: center;
    gap: 8px;
    align-self: start;
  }

  .mid .price{ font-size: 13px; }
  .mid .units{ font-size: 12px; }
  .mid .pct{   font-size: 13px; margin-left: auto; }

  /* Modal */
  .modal{ width: 96vw; padding: 20px 16px; border-radius: 24px; }
  .fieldRow{ grid-template-columns: 1fr; }

  /* Drawer — slides up from bottom full width */
  .drawer{
    width: 100vw;
    height: auto;
    max-height: 92vh;
    border-radius: 24px 24px 0 0;
    border-left: none;
    border-top: 1px solid var(--line);
    bottom: 0;
    top: auto;
    right: 0;
  }

  /* Allocation */
  .donutWrap{
    width: min(280px, 80vw);
    height: min(280px, 80vw);
  }
  .allocLegend{ grid-template-columns: 1fr 1fr; gap: 8px; }
  .allocCard{ padding: 10px; border-radius: 14px; }
  .allocCardIcon{ width: 36px; height: 36px; }
  .allocCardIcon img{ width: 26px; height: 26px; }
  .allocCardTicker{ font-size: 13px; }
  .allocCardUnits{ font-size: 11px; }
  .allocCardPct{ font-size: 14px; }

  /* Charts */
  .chartsTopRow{ flex-direction: column; gap: 8px; align-items: stretch; }
  .chartCoinCards{ grid-template-columns: repeat(2, 1fr); }

  /* News */
  .newsThumb{ width: 60px; height: 60px; border-radius: 10px; }
  .newsTitle{ font-size: 13px; }

  /* Drawer simulators */
  .simGrid{ grid-template-columns: 1fr; }
  .recoveryGrid{ grid-template-columns: 1fr 1fr; }
}

.field{ display:flex; flex-direction:column; gap:6px; }
.fieldLabel{ font-size: 12px; color: var(--muted2); }

.input{
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  border-radius: 16px;
  padding: 12px 14px;
  outline:none;
}

.hint{
  margin-top: 10px;
  color: var(--muted2);
  font-size: 12px;
  line-height: 1.5;
}

.spacer{ flex:1; }

/* Ensure hidden attribute works — display:flex/grid overrides it without this */
.modal[hidden],
.modalBackdrop[hidden],
.drawer[hidden],
.drawerBackdrop[hidden]{
  display: none !important;
}

/* Drawer */
.drawer{
  position: fixed;
  right: 0;
  top: 0;
  height: 100vh;
  width: min(420px, 92vw);
  border-left: 1px solid var(--line);
  background: linear-gradient(180deg, var(--bg1), color-mix(in srgb, var(--bg1) 85%, black));
  z-index: 70;
  display:flex;
  flex-direction:column;
}

.drawerHeader{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.drawerTitle{ font-weight: 950; font-size: 16px; }
.drawerSub{ font-size: 12px; color: var(--muted2); margin-top: 4px; }

.drawerBody{
  padding: 14px;
  overflow:auto;
  flex:1;
}

.drawerFooter{
  padding: 14px;
  border-top: 1px solid var(--line);
}

.panel{
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.04);
  border-radius: 18px;
  padding: 12px;
  margin-bottom: 12px;
}

.panelTitle{
  font-size: 12px;
  color: var(--muted2);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  font-weight: 700;
  margin-bottom: 10px;
}

.panelRow{
  display:flex;
  justify-content:space-between;
  padding: 8px 10px;
  border-radius: 14px;
  border: 1px solid rgba(234,240,255,0.10);
  background: rgba(0,0,0,0.14);
  margin-bottom: 10px;
}
.panelRow:last-child{ margin-bottom: 0; }

.k{ color: var(--muted2); font-size: 12px; }
.v{ color: var(--text); font-size: 12px; font-weight: 800; }

.todo{ margin:0; padding-left: 18px; color: var(--muted); font-size: 13px; }

/* ---- Coin search dropdown ---- */

.coinSearchWrap{
  position: relative;
}

.coinSearchWrap .input{
  width: 100%;
}

.coinSuggestions{
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 200;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: color-mix(in srgb, var(--bg1) 96%, black);
  box-shadow: 0 16px 48px rgba(0,0,0,0.45);
  overflow: hidden;
  max-height: 300px;
  overflow-y: auto;
}

.coinSuggestion{
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--line);
  transition: background 0.1s;
}

.coinSuggestion:last-child{
  border-bottom: none;
}

.coinSuggestion:hover{
  background: rgba(124,92,255,0.10);
}

.coinSImg{
  width: 28px;
  height: 28px;
  border-radius: 999px;
  object-fit: contain;
  flex: 0 0 auto;
  background: rgba(255,255,255,0.05);
}

.coinSText{
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.coinSName{
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.coinSSub{
  font-size: 11px;
  color: var(--muted2);
  display: flex;
  gap: 5px;
}

.coinSPill{
  font-size: 11px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid rgba(124,92,255,0.35);
  background: rgba(124,92,255,0.14);
  color: var(--text);
  flex: 0 0 auto;
  opacity: 0.8;
}

.coinSuggestion:hover .coinSPill{
  opacity: 1;
  background: rgba(124,92,255,0.25);
}
/* ---- Drawer: header with coin icon ---- */
.drawerHeaderLeft{
  display:flex;
  align-items:center;
  gap:12px;
}

.drawerCoinIcon{
  width:44px;
  height:44px;
  border-radius:999px;
  border:1px solid var(--line);
  background:rgba(255,255,255,0.06);
  display:grid;
  place-items:center;
  overflow:hidden;
  flex:0 0 auto;
}

.drawerCoinIcon img{
  width:32px;
  height:32px;
  object-fit:contain;
}

/* ---- Insight bar ---- */
.insightBar{
  background:rgba(124,92,255,0.10);
  border:1px solid rgba(124,92,255,0.25);
  border-radius:14px;
  padding:10px 14px;
  margin-bottom:12px;
  font-size:13px;
  color:var(--muted);
}

/* ---- Big P/L block ---- */
.plBlock{
  padding:4px 0 14px;
}

.plLabel{
  font-size:12px;
  color:var(--muted2);
  text-transform:uppercase;
  letter-spacing:0.04em;
  font-weight:700;
  margin-bottom:4px;
}

.plValue{
  font-size:28px;
  font-weight:950;
  letter-spacing:-0.02em;
}

/* ---- Analytics 2-col grid ---- */
.analyticsGrid{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:8px;
  margin-bottom:12px;
}

.analyticsCell{
  border:1px solid var(--line);
  background:rgba(0,0,0,0.12);
  border-radius:14px;
  padding:10px 12px;
}

.analyticsLabel{
  font-size:11px;
  color:var(--muted2);
  text-transform:uppercase;
  letter-spacing:0.03em;
  font-weight:700;
  margin-bottom:4px;
}

.analyticsValue{
  font-size:14px;
  font-weight:800;
  color:var(--text);
}

/* ---- Chart ---- */
.chartTimeframes{
  display:flex;
  gap:6px;
  margin-bottom:10px;
}

.tfBtn{
  border:1px solid var(--line);
  background:transparent;
  color:var(--muted);
  border-radius:10px;
  padding:6px 12px;
  font-size:13px;
  font-weight:700;
  cursor:pointer;
}

.tfBtn.active{
  background:rgba(124,92,255,0.18);
  border-color:rgba(124,92,255,0.40);
  color:var(--text);
}

.chartWrap{
  position:relative;
  height:120px;
}

.chartWrap canvas{
  width:100% !important;
  height:100% !important;
}

.chartLoading{
  position:absolute;
  inset:0;
  display:grid;
  place-items:center;
  font-size:12px;
  color:var(--muted2);
}

/* ---- Period badges ---- */
.periodRow{
  display:flex;
  gap:8px;
  margin-top:10px;
}

.periodBadge{
  border:1px solid var(--line);
  background:rgba(255,255,255,0.04);
  border-radius:999px;
  padding:5px 10px;
  font-size:12px;
  font-weight:700;
  color:var(--muted);
}

/* ---- Simulator inputs ---- */
.simInput{
  width:100%;
  margin-bottom:8px;
  display:block;
}

.simResults, .avgResults{
  margin-top:10px;
  display:flex;
  flex-direction:column;
  gap:6px;
}

/* ========== TAB NAV ========== */

.tabNav{
  display: flex;
  gap: 4px;
  padding: 10px 18px 0;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg1) 82%, transparent);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 89px;
  z-index: 9;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.tabNav::-webkit-scrollbar { display: none; }

.tabBtn{
  border: none;
  background: transparent;
  color: var(--muted2);
  font-size: 14px;
  font-weight: 700;
  padding: 10px 16px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  border-radius: 0;
  transition: color 0.15s, border-color 0.15s;
  flex-shrink: 0;
  white-space: nowrap;
}

.tabBtn:hover{
  color: var(--muted);
}

.tabBtn.active{
  color: var(--text);
  border-bottom-color: var(--accent);
}

.tabPanel[hidden]{
  display: none !important;
}

/* ========== ALLOCATION PAGE ========== */

.allocWrap{
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  padding-top: 8px;
}

.donutWrap{
  position: relative;
  width: min(340px, 90vw);
  height: min(340px, 90vw);
  padding: 14px;
  box-sizing: content-box;
}

.donutWrap canvas{
  width: 100% !important;
  height: 100% !important;
  overflow: visible;
}

.donutCenter{
  position: absolute;
  inset: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  text-align: center;
  padding: 0 20px;
}

.donutTotal{
  font-size: 18px;
  font-weight: 900;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.donutLabel{
  font-size: 12px;
  color: var(--muted2);
  margin-top: 2px;
}

/* Legend grid */
.allocLegend{
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: 100%;
}

.allocCard{
  border-radius: 18px;
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: transform 0.15s, opacity 0.15s;
  position: relative;
  overflow: hidden;
}

.allocCard:hover{
  transform: translateY(-2px);
}

.allocCard.dimmed{
  opacity: 0.35;
}

.allocCard.highlighted{
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(0,0,0,0.3);
}

.allocCardIcon{
  width: 44px;
  height: 44px;
  border-radius: 999px;
  background: rgba(0,0,0,0.20);
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  overflow: hidden;
}

.allocCardIcon img{
  width: 32px;
  height: 32px;
  object-fit: contain;
  display: block;
}

.allocCardInfo{
  flex: 1;
  min-width: 0;
}

.allocCardTicker{
  font-size: 15px;
  font-weight: 900;
  letter-spacing: -0.01em;
}

.allocCardUnits{
  font-size: 11px;
  opacity: 0.75;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.allocCardPct{
  font-size: 15px;
  font-weight: 900;
  background: rgba(0,0,0,0.22);
  border-radius: 10px;
  padding: 4px 8px;
  white-space: nowrap;
  flex: 0 0 auto;
}

/* Colour picker popup */
.colourPicker{
  position: fixed;
  z-index: 200;
  background: linear-gradient(180deg, var(--bg1), color-mix(in srgb, var(--bg1) 85%, black));
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  min-width: 220px;
}

.colourPicker[hidden]{
  display: none !important;
}

.colourPickerTitle{
  font-size: 12px;
  color: var(--muted2);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 700;
  margin-bottom: 10px;
}

.colourSwatches{
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}

.swatch{
  width: 28px;
  height: 28px;
  border-radius: 999px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.1s, border-color 0.1s;
}

.swatch:hover{
  transform: scale(1.2);
}

.swatch.selected{
  border-color: white;
}

@media (max-width: 500px){
  .allocLegend{
    grid-template-columns: 1fr;
  }
}

/* ========== CHARTS PAGE ========== */

.chartsControls{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.chartsTfRow{
  display: flex;
  gap: 6px;
}

.benchmarkRow{
  display: flex;
  align-items: center;
  gap: 6px;
}

.benchLabel{
  font-size: 12px;
  color: var(--muted2);
  font-weight: 700;
  margin-right: 2px;
}

.benchBtn{
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  border-radius: 10px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.benchBtn.active{
  background: rgba(0,213,255,0.14);
  border-color: rgba(0,213,255,0.40);
  color: var(--text);
}

.mainChartWrap{
  position: relative;
  width: 100%;
  height: 280px;
  margin-bottom: 18px;
}

.mainChartWrap canvas{
  width: 100% !important;
  height: 100% !important;
}

/* Coin selector cards */
.chartCoinCards{
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.chartCoinCard{
  border-radius: 16px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: opacity 0.15s, border-color 0.15s;
  background: rgba(255,255,255,0.05);
  border-color: var(--line);
}

.chartCoinCard.active{
  border-color: currentColor;
  opacity: 1 !important;
}

.chartCoinCard.dimmed{
  opacity: 0.3;
}

.chartCoinCardDot{
  width: 12px;
  height: 12px;
  border-radius: 999px;
  flex: 0 0 auto;
}

.chartCoinCardIcon{
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: rgba(255,255,255,0.06);
  display: grid;
  place-items: center;
  overflow: hidden;
  flex: 0 0 auto;
}

.chartCoinCardIcon img{
  width: 22px;
  height: 22px;
  object-fit: contain;
}

.chartCoinCardText{
  flex: 1;
  min-width: 0;
}

.chartCoinCardTicker{
  font-size: 13px;
  font-weight: 900;
}

.chartCoinCardPct{
  font-size: 11px;
  margin-top: 2px;
}

.chartCoinCardValue{
  font-size: 13px;
  font-weight: 800;
  text-align: right;
  flex: 0 0 auto;
}

/* Total portfolio card — full width */
.chartCoinCard.totalCard{
  grid-column: 1 / -1;
  background: rgba(124,92,255,0.08);
  border-color: rgba(124,92,255,0.25);
}

@media (max-width: 500px){
  .chartCoinCards{
    grid-template-columns: 1fr;
  }
  .chartCoinCard.totalCard{
    grid-column: 1;
  }
}

/* ========== NEWS PAGE ========== */

.newsControls{
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.newsStatus{
  font-size: 12px;
  color: var(--muted2);
}

/* Coin group */
.newsGroup{
  margin-bottom: 22px;
}

.newsGroupHeader{
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 14px;
  margin-bottom: 10px;
  font-weight: 800;
  font-size: 15px;
  color: #fff;
}

.newsGroupIcon{
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: rgba(0,0,0,0.20);
  display: grid;
  place-items: center;
  overflow: hidden;
  flex: 0 0 auto;
}

.newsGroupIcon img{
  width: 22px;
  height: 22px;
  object-fit: contain;
}

.newsGroupCount{
  margin-left: auto;
  font-size: 13px;
  background: rgba(0,0,0,0.22);
  border-radius: 999px;
  padding: 3px 10px;
  font-weight: 700;
}

/* Article cards */
.newsCard{
  display: flex;
  gap: 12px;
  padding: 12px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, var(--card), rgba(255,255,255,0.03));
  margin-bottom: 8px;
  text-decoration: none;
  color: var(--text);
  transition: background 0.15s;
}

.newsCard:hover{
  background: rgba(255,255,255,0.07);
}

.newsCardImg{
  width: 80px;
  height: 64px;
  border-radius: 10px;
  object-fit: cover;
  flex: 0 0 auto;
  background: rgba(255,255,255,0.06);
}

.newsCardBody{
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.newsCardTitle{
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.newsCardMeta{
  font-size: 11px;
  color: var(--muted2);
  display: flex;
  gap: 8px;
  align-items: center;
}

.newsCardSource{
  color: var(--accent2);
  font-weight: 700;
}

.newsEmpty{
  font-size: 13px;
  color: var(--muted2);
  padding: 8px 0;
}

/* ========== TICKER TAPE ========== */
#tickerTape {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 36px;
  background: var(--bg1);
  border-top: 1px solid rgba(124,92,255,0.2);
  overflow: hidden;
  z-index: 100;
  display: flex;
  align-items: center;
}
#tickerInner { width: 100%; overflow: hidden; }
#tickerTrack {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  animation: tickerScroll 60s linear infinite;
}
#tickerTrack:hover { animation-play-state: paused; }
@keyframes tickerScroll {
  0%   { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}
.tickerItem {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0 18px;
  font-size: 12px;
  color: var(--fg);
}
.tickerIcon { width: 16px; height: 16px; border-radius: 50%; }
.tickerSym  { font-weight: 700; opacity: 0.9; font-size: 11px; }
.tickerPrice { opacity: 0.75; font-size: 11px; }
.tickerPct  { font-size: 11px; font-weight: 600; }
.tickerSep  { opacity: 0.25; padding: 0 8px; font-size: 10px; }
body        { padding-bottom: 36px; }

/* ========== GOOGLE PLAY BADGE ========== */
.googlePlayBadge {
  position: relative;
  display: flex;
  align-items: center;
  opacity: 0.75;
  transition: opacity 0.2s;
  flex-shrink: 0;
}
.googlePlayBadge:hover { opacity: 1; }
.googlePlayBadge img {
  height: 32px;
  width: auto;
  display: block;
}
.playBadgeOverlay {
  position: absolute;
  bottom: -2px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: #fff;
  font-size: 8px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
  white-space: nowrap;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

/* Hide on mobile by default — JS shows it on Holdings tab */
@media (max-width: 620px) {
  .googlePlayBadge {
    display: none;
  }
  .googlePlayBadge.mobileVisible {
    display: flex;
  }
}

/* ========== TICKER TAPE ========== */
#tickerTape {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 36px;
  background: var(--bg1);
  border-top: 1px solid rgba(124,92,255,0.2);
  overflow: hidden;
  z-index: 100;
  display: flex;
  align-items: center;
}
#tickerInner { width: 100%; overflow: hidden; }
#tickerTrack {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  animation: tickerScroll 60s linear infinite;
}
#tickerTrack:hover { animation-play-state: paused; }
@keyframes tickerScroll {
  0%   { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}
.tickerItem {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0 18px;
  font-size: 12px;
  color: var(--fg);
}
.tickerIcon { width: 16px; height: 16px; border-radius: 50%; }
.tickerSym  { font-weight: 700; opacity: 0.9; font-size: 11px; }
.tickerPrice { opacity: 0.75; font-size: 11px; }
.tickerPct  { font-size: 11px; font-weight: 600; }
.tickerSep  { opacity: 0.25; padding: 0 8px; font-size: 10px; }
body        { padding-bottom: 36px; }

/* ========== GOOGLE PLAY BADGE ========== */
.googlePlayBadge {
  position: relative;
  display: flex;
  align-items: center;
  opacity: 0.75;
  transition: opacity 0.2s;
  flex-shrink: 0;
}
.googlePlayBadge:hover { opacity: 1; }
.googlePlayBadge img { height: 32px; width: auto; display: block; }
.playBadgeOverlay {
  position: absolute;
  bottom: -2px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: #fff;
  font-size: 8px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
  white-space: nowrap;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
@media (max-width: 620px) {
  .googlePlayBadge { display: none; }
  .googlePlayBadge.mobileVisible { display: flex; }
}

/* ========== LEDGER BANNERS ========== */

/* Desktop 728x90 — shown below tab nav on desktop only */
.ledgerDesktopBanner {
  display: flex;
  justify-content: center;
  padding: 8px 0 4px;
  overflow: hidden;
}
.ledgerDesktopBanner img { max-width: 100%; height: auto; border-radius: 6px; }
@media (max-width: 740px) {
  .ledgerDesktopBanner { display: none; }
}

/* Mobile 320x50 — shown above ticker tape on mobile only */
.ledgerMobileBanner {
  position: fixed;
  bottom: 36px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 99;
  display: none;
}
.ledgerMobileBanner img { display: block; border-radius: 4px; }
@media (max-width: 740px) {
  .ledgerMobileBanner { display: block; }
  body { padding-bottom: 86px; }
}

/* Drawer 300x250 */
.ledgerDrawerBanner {
  display: flex;
  justify-content: center;
  padding: 16px 0 8px;
}
.ledgerDrawerBanner img { max-width: 100%; height: auto; border-radius: 8px; }

/* ========== TICKER TAPE ========== */
#tickerTape {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 36px;
  background: var(--bg1);
  border-top: 1px solid rgba(124,92,255,0.2);
  overflow: hidden;
  z-index: 100;
  display: flex;
  align-items: center;
}
#tickerInner { width: 100%; overflow: hidden; }
#tickerTrack {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  animation: tickerScroll 60s linear infinite;
}
#tickerTrack:hover { animation-play-state: paused; }
@keyframes tickerScroll {
  0%   { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}
.tickerItem {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0 18px;
  font-size: 12px;
  color: var(--fg);
}
.tickerIcon { width: 16px; height: 16px; border-radius: 50%; }
.tickerSym  { font-weight: 700; opacity: 0.9; font-size: 11px; }
.tickerPrice { opacity: 0.75; font-size: 11px; }
.tickerPct  { font-size: 11px; font-weight: 600; }
.tickerSep  { opacity: 0.25; padding: 0 8px; font-size: 10px; }
@media (min-width: 741px) { body { padding-bottom: 36px; } }

/* ========== KOINLY AFFILIATE CARD ========== */
.koinlyCard {
  background: linear-gradient(135deg, rgba(124,92,255,0.12), rgba(0,213,255,0.08));
  border: 1px solid rgba(124,92,255,0.25);
  border-radius: 12px;
  margin: 24px 16px;
  padding: 16px;
}
.koinlyInner {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.koinlyText { flex: 1; min-width: 200px; }
.koinlyTitle {
  font-size: 14px;
  font-weight: 700;
  color: var(--fg);
  margin-bottom: 4px;
}
.koinlySub {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}
.koinlyBtn {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 8px;
  text-decoration: none;
  white-space: nowrap;
  transition: opacity 0.2s;
  flex-shrink: 0;
}
.koinlyBtn:hover { opacity: 0.85; }

/* ========== MARKET TAB ========== */
.marketGlobal {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.marketGlobalStat {
  flex: 1;
  min-width: 90px;
  background: var(--bg1);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 10px;
  padding: 10px 12px;
}
.marketGlobalLabel {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}
.marketGlobalValue {
  font-size: 14px;
  font-weight: 700;
  color: var(--fg);
}
.marketToolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.marketLimitBtns {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.marketLimitBtn {
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.1);
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}
.marketLimitBtn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.marketHeader {
  display: grid;
  grid-template-columns: 32px 1fr 90px 70px 110px;
  padding: 6px 12px;
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  margin-bottom: 4px;
}
.marketRow {
  border-radius: 10px;
  margin-bottom: 4px;
  overflow: hidden;
  background: var(--bg1);
  border: 1px solid rgba(255,255,255,0.05);
  transition: border-color 0.2s;
}
.marketRow.expanded {
  border-color: rgba(124,92,255,0.3);
}
.marketRowMain {
  display: grid;
  grid-template-columns: 32px 1fr 90px 70px 110px;
  align-items: center;
  padding: 10px 12px;
  cursor: pointer;
  transition: background 0.15s;
}
.marketRowMain:hover { background: rgba(255,255,255,0.03); }
.mRank { font-size: 11px; color: var(--muted); }
.mCoin { display: flex; align-items: center; gap: 8px; min-width: 0; }
.mIcon { width: 24px; height: 24px; border-radius: 50%; flex-shrink: 0; }
.mName { font-size: 13px; font-weight: 600; color: var(--fg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mSym  { font-size: 10px; color: var(--muted); flex-shrink: 0; }
.mPrice { font-size: 12px; font-weight: 600; color: var(--fg); text-align: right; }
.mPct  { font-size: 12px; font-weight: 600; text-align: right; }
.mCap  { font-size: 11px; color: var(--muted); text-align: right; }

/* Expanded row */
.marketRowExpanded {
  padding: 0 12px 14px;
  border-top: 1px solid rgba(255,255,255,0.06);
}
.marketMiniChartWrap {
  position: relative;
  height: 80px;
  margin: 10px 0;
}
.marketChartLoading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: var(--muted);
}
.marketExpandStats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 12px;
}
.marketExpandStat {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  padding: 6px 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.marketExpandStat span:first-child { color: var(--muted); }
.marketExpandStat span:last-child  { font-weight: 600; color: var(--fg); }
.marketAddBtn {
  width: 100%;
  margin-top: 4px;
}

@media (max-width: 620px) {
  .marketHeader { grid-template-columns: 28px 1fr 75px 60px; }
  .marketHeader .mhCap { display: none; }
  .marketRowMain { grid-template-columns: 28px 1fr 75px 60px; }
  .mCap { display: none; }
  .mName { font-size: 12px; }
  .marketExpandStats { grid-template-columns: 1fr; }
}

/* ===== TOOLS NAV LINK ===== */
.toolsNavLink {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent2);
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid rgba(0,213,255,0.2);
  background: rgba(0,213,255,0.06);
  white-space: nowrap;
  transition: all 0.2s;
  flex-shrink: 0;
}
.toolsNavLink:hover { background: rgba(0,213,255,0.12); border-color: rgba(0,213,255,0.4); }
@media (max-width: 480px) { .toolsNavLink { display: none; } }
