* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #0b0b0d;
  --panel: #141417;
  --border: #26262b;
  --gold: #d4a843;
  --text: #e8e8ea;
  --muted: #8a8a92;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
}

/* ---- top bar ---- */
#topbar {
  height: 52px;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; }
.brand-logo { height: 40px; display: block; }

.stat { display: flex; flex-direction: column; line-height: 1.2; }
.stat-label { font-size: 10px; text-transform: uppercase; color: var(--muted); letter-spacing: .5px; }
.stat-value { font-size: 15px; font-weight: 700; color: var(--gold); }

.timeframes { display: flex; gap: 4px; margin-left: auto; }
.timeframes button {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.timeframes button:hover { color: var(--text); }
.timeframes button.active { background: var(--gold); border-color: var(--gold); color: #111; }

.refresh { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); }
.refresh .dot { width: 7px; height: 7px; border-radius: 50%; background: #3fb950; animation: pulse 2s infinite; }
@keyframes pulse { 50% { opacity: .3; } }

@keyframes blip { 0% { color: #3fb950; } 100% { color: var(--muted); } }
#refresh-text.blip { animation: blip 1.2s ease-out; }

/* ---- sticker ---- */
#market-sticker {
  pointer-events: none;
  padding: 4px 12px;
  border: 2px solid var(--gold);
  border-radius: 10px;
  color: var(--gold);
  background: rgba(11, 11, 13, .72);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 2px;
  text-transform: uppercase;
  box-shadow: 0 4px 18px rgba(0, 0, 0, .5), inset 0 0 12px rgba(212, 168, 67, .15);
  opacity: .85;
  animation: sticker-wobble 6s ease-in-out infinite;
}
@keyframes sticker-wobble {
  0%, 100% { transform: rotate(-4deg); }
  50% { transform: rotate(-1.5deg) translateY(-2px); }
}

/* ---- heatmap ---- */
#heatmap {
  position: relative;
  height: calc(100% - 52px);
  width: 100%;
}

.tile {
  position: absolute;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(0, 0, 0, .45);
  cursor: pointer;
  transition:
    left .6s cubic-bezier(.4, 0, .2, 1),
    top .6s cubic-bezier(.4, 0, .2, 1),
    width .6s cubic-bezier(.4, 0, .2, 1),
    height .6s cubic-bezier(.4, 0, .2, 1),
    background .8s ease,
    filter .12s;
  text-align: center;
}
.tile:hover {
  filter: brightness(1.18);
  z-index: 5;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .35);
}

@keyframes tile-in {
  from { opacity: 0; transform: scale(.92); }
  to { opacity: 1; transform: scale(1); }
}
.tile.enter { animation: tile-in .45s cubic-bezier(.2, .8, .3, 1) backwards; }

@keyframes flash-up {
  0% { box-shadow: inset 0 0 0 2px rgba(63, 185, 80, .95); filter: brightness(1.4); }
  100% { box-shadow: inset 0 0 0 2px rgba(63, 185, 80, 0); }
}
@keyframes flash-down {
  0% { box-shadow: inset 0 0 0 2px rgba(240, 84, 92, .95); filter: brightness(1.4); }
  100% { box-shadow: inset 0 0 0 2px rgba(240, 84, 92, 0); }
}
.tile.flash-up { animation: flash-up 1.2s ease-out; }
.tile.flash-down { animation: flash-down 1.2s ease-out; }

.tile .row { display: flex; align-items: center; gap: 6px; min-width: 0; }
.tile img.avatar {
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, .35);
  flex: none;
  background: #222;
}
.tile .sym { font-weight: 800; color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,.5); white-space: nowrap; }
.tile .price, .tile .chg { color: rgba(255,255,255,.92); text-shadow: 0 1px 2px rgba(0,0,0,.5); white-space: nowrap; }
.tile .chg { font-weight: 600; }

/* ---- tooltip ---- */
#tooltip {
  position: fixed;
  z-index: 50;
  pointer-events: none;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  width: 240px;
  box-shadow: 0 8px 30px rgba(0,0,0,.6);
  font-size: 12px;
  opacity: 1;
  transition: opacity .15s ease;
}
#tooltip.hidden { opacity: 0; visibility: hidden; }
#tooltip img.card {
  display: block;
  max-height: 130px;
  max-width: 60%;
  width: auto;
  margin: 0 auto 8px;
  border-radius: 6px;
  background: #1c1c20;
}
#tooltip .t-name { font-weight: 700; font-size: 13px; margin-bottom: 2px; }
#tooltip .t-card-name { color: var(--gold); font-size: 11px; margin-bottom: 6px; }
#tooltip .t-grid { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; color: var(--muted); }
#tooltip .t-grid b { color: var(--text); font-weight: 600; text-align: right; }

/* ---- detail panel ---- */
#detail {
  position: fixed;
  top: 0; right: 0;
  height: 100%;
  width: 360px;
  max-width: 92vw;
  background: var(--panel);
  border-left: 1px solid var(--border);
  z-index: 100;
  overflow-y: auto;
  padding: 20px;
  transition: transform .2s ease;
}
#detail.hidden { transform: translateX(100%); visibility: hidden; }
#detail-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 90;
}
#detail-backdrop.hidden { display: none; }

#detail-close {
  position: absolute;
  top: 12px; right: 12px;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
}
#detail-close:hover { color: var(--text); }

.d-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.d-head img { width: 52px; height: 52px; border-radius: 50%; object-fit: cover; border: 2px solid var(--gold); }
.d-head .d-sym { font-size: 20px; font-weight: 800; color: var(--gold); }
.d-head .d-name { font-size: 12px; color: var(--muted); }

.d-price { font-size: 28px; font-weight: 800; margin-bottom: 2px; }
.d-chg { font-size: 14px; font-weight: 700; margin-bottom: 14px; }
.up { color: #3fb950; }
.down { color: #f0545c; }

.d-section { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin: 16px 0 8px; }

.d-card {
  background: #1a1a1e;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 10px;
}
.d-card img { width: 100%; border-radius: 8px; display: block; margin-bottom: 8px; }
.d-card .c-name { font-size: 13px; font-weight: 700; color: var(--gold); margin-bottom: 6px; }
.d-card .c-meta { display: flex; gap: 14px; font-size: 11px; color: var(--muted); }
.d-card .c-meta b { color: var(--text); }
.d-card .c-psa { display: inline-block; margin-top: 8px; font-size: 11px; color: var(--gold); text-decoration: none; }
.d-card .c-psa:hover { text-decoration: underline; }

/* ---- fair value ---- */
.fv {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}
.fv-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.fv-badge {
  background: var(--gold);
  color: #111;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .8px;
  padding: 2px 7px;
  border-radius: 99px;
}
.fv-row {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 4px 10px;
  align-items: baseline;
  font-size: 11px;
  padding: 2px 0;
}
.fv-row .fv-k { color: var(--muted); }
.fv-row .fv-c { color: var(--muted); text-align: right; }
.fv-row .fv-v { color: var(--gold); text-align: right; font-weight: 700; }
.fv-row .fv-d { text-align: right; font-weight: 600; min-width: 52px; }
.fv-head span { font-size: 9px; text-transform: uppercase; color: var(--muted); letter-spacing: .4px; text-align: right; }
.fv-note { font-size: 10px; color: var(--muted); margin-top: 4px; }
.fv-src { font-size: 10px; color: var(--muted); margin-top: 6px; }
.fv-src a { color: var(--gold); text-decoration: none; }
.fv-src a:hover { text-decoration: underline; }

.d-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.d-grid .cell { background: #1a1a1e; border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; }
.d-grid .cell .k { font-size: 10px; color: var(--muted); text-transform: uppercase; }
.d-grid .cell .v { font-size: 14px; font-weight: 700; }

#detail svg.chart { width: 100%; height: 120px; display: block; }
#detail svg.donut { width: 110px; height: 110px; display: block; flex: 0 0 auto; }

/* ---- timeframe switcher ---- */
.d-tf { display: flex; gap: 6px; margin-bottom: 8px; }
.d-tf button {
  flex: 1;
  background: #1a1a1e;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  padding: 5px 0;
  border-radius: 6px;
  cursor: pointer;
}
.d-tf button:hover { color: var(--text); }
.d-tf button.active { background: var(--gold); color: #111; border-color: var(--gold); }

/* ---- empty / loading note ---- */
.d-empty-note { font-size: 10px; color: var(--muted); margin: 6px 0; line-height: 1.4; }

/* ---- card vs token overlay ---- */
.d-overlay-legend { display: flex; gap: 14px; margin-bottom: 4px; }
.d-legend-chip { display: flex; align-items: center; gap: 5px; font-size: 10px; color: var(--muted); }
.d-legend-chip i { width: 10px; height: 3px; border-radius: 2px; display: inline-block; }

/* ---- vault ratio ---- */
.d-vault { display: flex; align-items: center; gap: 14px; }
.d-vault-pct { fill: var(--text); font-size: 18px; font-weight: 800; }
.d-vault-leg { font-size: 11px; color: var(--muted); display: flex; flex-direction: column; gap: 5px; }
.d-vault-leg div { display: flex; align-items: center; gap: 6px; }
.d-vault-leg i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.d-vault-leg b { color: var(--text); margin-left: auto; padding-left: 8px; }
.d-vault-leg .fv-badge { margin-bottom: 2px; }

/* ---- PSA population ---- */
.d-pop-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 4px; }
.d-pop-num { font-size: 24px; font-weight: 800; color: var(--text); }
.d-pop-delta { font-size: 11px; font-weight: 600; }

/* ---- fair value spread gauge ---- */
.fv-gauge { background: #1a1a1e; border: 1px solid var(--border); border-radius: 10px; padding: 12px; }
.fv-gauge-nums { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-bottom: 8px; }
.fv-gauge-nums b { color: var(--text); }
.fv-src-mini { opacity: .55; font-size: 10px; }
.fv-bar { position: relative; height: 8px; border-radius: 99px; background: linear-gradient(90deg,#3fb950,#3a3a42,#f0545c); }
.fv-bar-mid { position: absolute; left: 50%; top: -3px; bottom: -3px; width: 1px; background: var(--muted); }
.fv-marker { position: absolute; top: 50%; width: 12px; height: 12px; border-radius: 50%; border: 2px solid #111; transform: translate(-50%,-50%); }
.fv-marker.up { background: #3fb950; }
.fv-marker.down { background: #f0545c; }
.fv-gauge-label { font-size: 11px; font-weight: 700; text-align: center; margin-top: 8px; }

/* ---- activity ---- */
.d-act-row { display: grid; grid-template-columns: 1fr auto auto auto; gap: 8px; font-size: 11px; padding: 4px 0; border-bottom: 1px solid var(--border); align-items: baseline; }
.d-act-head { font-size: 9px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); }
.d-act-row span:nth-child(2), .d-act-row span:nth-child(3) { text-align: right; color: var(--muted); }
.d-act-row .side { text-align: right; font-weight: 700; }
.d-act-row .side.buy { color: #3fb950; }
.d-act-row .side.sell { color: #f0545c; }

/* ---- similar tokens ---- */
.d-similar { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.d-sim-card {
  flex: 0 0 auto;
  width: 78px;
  background: #1a1a1e;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  cursor: pointer;
  color: var(--text);
}
.d-sim-card:hover { border-color: var(--gold); }
.d-sim-card img { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; }
.d-sim-card .s-sym { font-size: 11px; font-weight: 700; color: var(--gold); }
.d-sim-card .s-price { font-size: 11px; }
.d-sim-card .s-chg { font-size: 10px; font-weight: 600; }

.d-link {
  display: block;
  text-align: center;
  margin-top: 16px;
  padding: 10px;
  background: var(--gold);
  color: #111;
  font-weight: 700;
  font-size: 13px;
  border-radius: 8px;
  text-decoration: none;
}
.d-link:hover { filter: brightness(1.1); }

.hidden { }

#loading, #error-msg {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 14px;
}

/* ---- mobile (phone) ---- */
@media (max-width: 640px) {
  /* topbar tek satıra sığsın */
  #topbar { gap: 10px; padding: 0 10px; }
  #market-sticker { display: none; }
  .stat-label { display: none; }             /* market cap DEĞERİ kalır */
  .refresh #refresh-text { display: none; }  /* nabız noktası kalır */
  .brand-logo { height: 32px; }
  .timeframes { gap: 3px; }
  .timeframes button { padding: 5px 9px; }

  /* detay paneli -> alttan bottom-sheet */
  #detail {
    top: auto; bottom: 0; left: 0; right: 0;
    width: 100%; max-width: 100%;
    height: 82vh;
    border-left: none;
    border-top: 1px solid var(--border);
    border-radius: 16px 16px 0 0;
    padding: 14px 16px 28px;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, .6);
  }
  #detail.hidden { transform: translateY(100%); }   /* alttan kayar */
  #detail::before {                                  /* görsel tutma çubuğu */
    content: ''; display: block;
    width: 40px; height: 4px; margin: 0 auto 12px;
    border-radius: 99px; background: var(--border);
  }
  #detail-close { top: 10px; right: 12px; font-size: 22px; padding: 4px 8px; }
  #detail-backdrop { background: rgba(0, 0, 0, .3); }  /* harita şeridi seçilsin */
}
