﻿:root {
  --bg: #060b09;
  --bg-elev: #0a1511;
  --card: #0f1f19;
  --card-soft: #13271f;
  --text: #e6f7ef;
  --muted: #95b6a7;
  --line: #1c3b30;
  --accent: #30d07d;
  --accent-soft: #1f7a4d;
  --danger: #ff5a67;
  --shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Segoe UI", Tahoma, sans-serif;
  line-height: 1.35;
  letter-spacing: 0.01em;
  color: var(--text);
  background:
    radial-gradient(circle at 20% -10%, #14362a 0, transparent 45%),
    radial-gradient(circle at 100% 0, #0d2a20 0, transparent 35%),
    linear-gradient(180deg, #040806 0, #06100d 40%, #030705 100%);
}

#app {
  width: min(100%, 480px);
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 68px 1fr 28px;
  align-items: center;
  gap: 8px;
  padding: calc(8px + env(safe-area-inset-top)) 10px 8px;
  background: linear-gradient(180deg, rgba(6, 11, 9, 0.94) 0%, rgba(6, 11, 9, 0.8) 100%);
  border-bottom: 1px solid rgba(28, 59, 48, 0.7);
  backdrop-filter: blur(10px);
}

.topbar h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
}

.topbar h1.is-detail {
  font-size: 16px;
}

.top-btn {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  border-radius: 10px;
  min-height: 36px;
  font-size: 12px;
  padding: 0 8px;
}

.top-spacer {
  width: 28px;
  height: 36px;
}

.hidden {
  display: none !important;
}

main {
  padding: 8px 10px;
}

.page {
  display: none;
  animation: fade 0.22s ease;
}

.page.active {
  display: block;
}

h2 {
  margin: 8px 0 6px;
  font-size: 19px;
  line-height: 1.2;
  color: #e9f8f1;
}

h3 {
  margin: 0 0 6px;
  font-size: 16px;
  color: #dcf4e8;
}

p {
  font-size: 14px;
  color: #cae7d8;
}

@keyframes fade {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.search-row,
.stats-row,
.section-title,
.inline-actions,
.detail-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.search-row,
.stats-row,
.section-title,
.detail-meta {
  justify-content: space-between;
}

.search-row {
  margin-bottom: 5px;
}

.search-row input {
  flex: 1;
  min-width: 0;
}

.search-row button {
  flex: 0 0 auto;
}

input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 9px 11px;
  color: var(--text);
  background: #0b1813;
}

input::placeholder {
  color: #739a88;
}

button {
  border: none;
  border-radius: 12px;
  background: linear-gradient(180deg, #1a3329 0, #0f221b 100%);
  color: var(--text);
  padding: 9px 11px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(62, 110, 89, 0.4);
}

button:active {
  transform: translateY(1px);
}

.pill,
.tab-btn.active,
.level-btn.active,
#detail-fav-btn {
  background: linear-gradient(180deg, #35e389 0, #1f9e5c 100%);
  color: #032213;
  box-shadow: none;
}

#detail-hide-btn {
  background: linear-gradient(180deg, #7d1f2a 0, #4f111a 100%);
}

.link-btn {
  background: transparent;
  color: var(--muted);
  box-shadow: none;
  padding: 0;
}

.stats-row span,
.hint,
.detail-meta {
  color: var(--muted);
}

.empty-state {
  color: #7ba18f;
  border: 1px dashed #1f4a3a;
  border-radius: 12px;
  padding: 14px;
  text-align: center;
}

.favorites-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 8px;
}

.fav-page {
  min-width: 100%;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  scroll-snap-align: start;
}

.token-item,
.fav-card,
.card,
.detail-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(15, 31, 25, 0.95) 0, rgba(12, 24, 20, 0.95) 100%);
  box-shadow: var(--shadow);
  padding: 9px;
}

.card p {
  margin: 0;
}

.fav-card {
  min-width: 0;
}

.fav-card .address {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  word-break: break-all;
}

.fav-card strong {
  display: inline-block;
  margin-top: 6px;
  font-size: 22px;
}

.token-list {
  display: grid;
  gap: 8px;
}

.token-main {
  display: grid;
  gap: 3px;
}

.token-head {
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
}

.token-network {
  font-weight: 700;
}

.token-address {
  color: #b3d1c2;
  font-size: 12px;
  word-break: break-all;
}

.token-score {
  margin-top: 1px;
  font-size: 12px;
  font-weight: 600;
}

.token-item .actions {
  margin-top: 8px;
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) minmax(0, 1fr);
  gap: 6px;
}

.token-item .actions button {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.token-item .actions button[data-fav] {
  padding-inline: 0;
}

.section-title {
  margin-top: 8px;
}

.section-title h2 {
  margin: 0;
}

#detail-address {
  margin: 0 0 8px;
  font-size: 15px;
  word-break: break-all;
}

.chart-placeholder {
  border: 1px dashed #2b5a48;
  border-radius: 12px;
  padding: 24px 12px;
  text-align: center;
  color: var(--muted);
}

.kv-grid {
  display: grid;
  grid-template-columns: 128px minmax(0, 1fr);
  gap: 6px;
  margin-bottom: 8px;
  font-size: 12px;
}

.kv-key {
  color: var(--muted);
  text-transform: capitalize;
}

.kv-value {
  word-break: break-word;
}

.hint {
  text-align: center;
  margin: 8px 0;
  font-size: 13px;
}

.detail-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

#ref-link {
  margin: 0 0 8px;
  color: #bfead3;
  word-break: break-all;
  font-size: 13px;
}

.inline-actions,
.apply-ref-wrap {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.apply-ref-wrap {
  margin-top: 8px;
}

.level-tabs {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  margin: 8px 0;
}

.level-btn {
  padding-inline: 0;
}

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  width: min(100%, 480px);
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 6px 10px max(10px, env(safe-area-inset-bottom));
  border-top: 1px solid rgba(28, 59, 48, 0.8);
  background: rgba(5, 10, 8, 0.97);
  backdrop-filter: blur(10px);
  z-index: 30;
}

.tab-btn {
  min-width: 0;
  font-size: 11px;
  padding-inline: 8px;
}

body.keyboard-open #app {
  padding-bottom: 10px;
}

body.keyboard-open .tabbar {
  transform: translateY(130%);
  opacity: 0;
  pointer-events: none;
}

@media (max-width: 420px) {
  h2 { font-size: 18px; }
  h3 { font-size: 15px; }

  .token-item .actions {
    grid-template-columns: 48px minmax(0, 1fr) minmax(0, 1fr);
  }

  .inline-actions,
  .apply-ref-wrap,
  .detail-actions {
    grid-template-columns: 1fr;
  }

  .kv-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    grid-template-columns: 64px 1fr 24px;
  }
}
