/* ============================================================
   CryptoHub — style.css
   Dark-theme-first, purple/violet gradient accents.
   Theme is driven by [data-theme="dark"|"light"] on <html>.
   Fonts (loaded in index.html): Space Grotesk (display), Inter (body)
   ============================================================ */

/* ------------------------------ */
/* 1. Design tokens               */
/* ------------------------------ */
:root {
  --font-display: 'Space Grotesk', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, sans-serif;

  /* brand palette */
  --violet-1: #8b5cf6;
  --violet-2: #a78bfa;
  --violet-3: #7c3aed;
  --magenta: #d946ef;
  --cyan: #22d3ee;

  --grad-brand: linear-gradient(135deg, #8b5cf6 0%, #d946ef 55%, #22d3ee 120%);
  --grad-soft: linear-gradient(135deg, rgba(139,92,246,.18), rgba(217,70,239,.10));

  --green: #34d399;
  --red: #f87171;
  --amber: #fbbf24;

  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 22px;

  --header-h: 68px;

  --transition: 180ms cubic-bezier(.4, 0, .2, 1);
}

/* Dark theme (default) */
:root,
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0a0a12;
  --bg-2: #0f0f1b;
  --bg-3: #151527;
  --surface: rgba(255, 255, 255, 0.04);
  --surface-2: rgba(255, 255, 255, 0.07);
  --surface-solid: #14142a;
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #f1f0fa;
  --text-2: #b6b4cc;
  --text-3: #7d7b96;
  --accent: var(--violet-2);
  --accent-strong: var(--violet-1);
  --glow: rgba(139, 92, 246, 0.35);
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  --header-bg: rgba(10, 10, 18, 0.72);
  --table-row-hover: rgba(139, 92, 246, 0.07);
  --input-bg: rgba(255, 255, 255, 0.05);
}

/* Light theme overrides */
[data-theme="light"] {
  color-scheme: light;
  --bg: #f6f5fb;
  --bg-2: #ffffff;
  --bg-3: #efedf8;
  --surface: rgba(20, 16, 60, 0.035);
  --surface-2: rgba(20, 16, 60, 0.06);
  --surface-solid: #ffffff;
  --border: rgba(20, 16, 60, 0.10);
  --border-strong: rgba(20, 16, 60, 0.18);
  --text: #17142b;
  --text-2: #4a4666;
  --text-3: #807d99;
  --accent: var(--violet-3);
  --accent-strong: var(--violet-3);
  --glow: rgba(124, 58, 237, 0.18);
  --shadow: 0 12px 34px rgba(60, 40, 140, 0.12);
  --header-bg: rgba(246, 245, 251, 0.8);
  --table-row-hover: rgba(124, 58, 237, 0.06);
  --input-bg: rgba(20, 16, 60, 0.045);
}

/* ------------------------------ */
/* 2. Reset / base                */
/* ------------------------------ */
*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background var(--transition), color var(--transition);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 0 0 0.5em;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-strong); }

img { max-width: 100%; display: block; }

button { font-family: inherit; cursor: pointer; }

::selection { background: rgba(139, 92, 246, 0.35); }

/* subtle page background texture */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(600px 400px at 85% -5%, var(--glow), transparent 60%),
    radial-gradient(500px 380px at -10% 30%, rgba(34, 211, 238, 0.06), transparent 60%);
  z-index: -1;
}

/* ------------------------------ */
/* 3. Utilities                   */
/* ------------------------------ */
.container {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

.hidden { display: none !important; }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent-strong);
  color: #fff;
  padding: 0.6rem 1rem;
  border-radius: 0 0 var(--radius-sm) 0;
  z-index: 200;
}
.skip-link:focus { left: 0; color: #fff; }

.grad-text {
  background: var(--grad-brand);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.empty-state {
  text-align: center;
  color: var(--text-3);
  padding: 3rem 1rem;
  font-size: 1.05rem;
}

/* ------------------------------ */
/* 4. Buttons                     */
/* ------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 0.95rem;
  padding: 0.75rem 1.5rem;
  border-radius: 999px;
  border: 1px solid transparent;
  transition: transform var(--transition), box-shadow var(--transition),
              background var(--transition), border-color var(--transition), opacity var(--transition);
  white-space: nowrap;
}
.btn:active { transform: translateY(1px) scale(0.99); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--grad-brand);
  color: #fff;
  box-shadow: 0 6px 24px rgba(139, 92, 246, 0.35);
}
.btn-primary:hover:not(:disabled) {
  color: #fff;
  box-shadow: 0 8px 32px rgba(139, 92, 246, 0.55);
  transform: translateY(-1px);
}

.btn-ghost {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--text);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--surface-2);
  border-color: var(--accent);
  color: var(--text);
}

.btn-full { width: 100%; }
.btn-sm { padding: 0.45rem 1rem; font-size: 0.85rem; }

.btn-wallet {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 0.55rem 1.1rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.88rem;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: var(--transition);
}
.btn-wallet:hover { border-color: var(--accent); background: var(--surface-2); }
.wallet-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-3);
  transition: var(--transition);
}
.btn-wallet.connected .wallet-dot { background: var(--green); box-shadow: 0 0 8px var(--green); }

/* ------------------------------ */
/* 5. Header / nav                */
/* ------------------------------ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--header-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}

.nav {
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--text);
}
.brand-gem {
  background: var(--grad-brand);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-size: 1.35rem;
  filter: drop-shadow(0 0 8px var(--glow));
}
.brand-text em { font-style: normal; color: var(--accent); }

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-link {
  display: block;
  padding: 0.5rem 0.95rem;
  border-radius: 999px;
  color: var(--text-2);
  font-weight: 500;
  font-size: 0.93rem;
  transition: var(--transition);
}
.nav-link:hover { color: var(--text); background: var(--surface-2); }
.nav-link.active {
  color: var(--text);
  background: var(--grad-soft);
  box-shadow: inset 0 0 0 1px rgba(139, 92, 246, 0.35);
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-2);
  margin-left: 0.5rem;
  transition: var(--transition);
}
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); }
[data-theme="dark"] .icon-moon { display: none; }
[data-theme="light"] .icon-sun { display: none; }

.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  padding: 8px;
}
.nav-toggle span {
  width: 22px; height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: var(--transition);
}
.nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ------------------------------ */
/* 6. Layout / views              */
/* ------------------------------ */
.main { flex: 1; }
.view { padding-bottom: 5rem; animation: viewIn 0.3s ease; }
@keyframes viewIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.page-head { padding: 3.5rem 0 2rem; }
.page-head.center { text-align: center; }
.page-head h1 { font-size: clamp(2rem, 4.5vw, 3rem); margin-bottom: 0.35em; }
.page-sub { color: var(--text-2); font-size: 1.05rem; margin: 0; }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin: 3rem 0 1.4rem;
}
.section-head h2 { font-size: clamp(1.4rem, 3vw, 1.9rem); margin: 0; }
.section-link { font-weight: 600; font-size: 0.95rem; white-space: nowrap; }

/* ------------------------------ */
/* 7. Hero                        */
/* ------------------------------ */
.hero {
  position: relative;
  text-align: center;
  padding: 5.5rem 1.25rem 3rem;
  overflow: hidden;
}
.hero-glow {
  position: absolute;
  top: -120px; left: 50%;
  transform: translateX(-50%);
  width: 720px; height: 480px;
  background: radial-gradient(ellipse at center, var(--glow), transparent 65%);
  filter: blur(20px);
  pointer-events: none;
}
.hero-eyebrow {
  color: var(--accent);
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.8rem;
  margin: 0 0 1rem;
}
.hero-title {
  font-size: clamp(2.6rem, 7vw, 4.6rem);
  font-weight: 700;
  margin: 0 0 1.1rem;
}
.hero-sub {
  max-width: 640px;
  margin: 0 auto 2.2rem;
  color: var(--text-2);
  font-size: 1.1rem;
}
.hero-cta {
  display: flex;
  gap: 0.9rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 3rem;
}

/* market ticker strip */
.market-strip {
  display: flex;
  gap: 0.6rem;
  overflow-x: auto;
  padding: 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  backdrop-filter: blur(10px);
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.market-strip::-webkit-scrollbar { height: 5px; }
.market-strip::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
.market-strip-loading {
  color: var(--text-3);
  font-size: 0.88rem;
  padding: 0.3rem 0.6rem;
  white-space: nowrap;
}
.strip-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 0.85rem;
  white-space: nowrap;
  flex-shrink: 0;
  transition: var(--transition);
}
.strip-item:hover { border-color: var(--accent); }
.strip-sym { font-weight: 700; font-family: var(--font-display); }
.strip-price { color: var(--text-2); }

/* change colors */
.up { color: var(--green); }
.down { color: var(--red); }

/* ------------------------------ */
/* 8. Cards & grids               */
/* ------------------------------ */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.25rem;
}

.article-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
  position: relative;
  overflow: hidden;
}
.article-card::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: var(--grad-brand);
  opacity: 0;
  transition: var(--transition);
}
.article-card:hover {
  transform: translateY(-4px);
  border-color: rgba(139, 92, 246, 0.45);
  box-shadow: var(--shadow);
  color: var(--text);
}
.article-card:hover::before { opacity: 1; }

.card-category {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--grad-soft);
  border: 1px solid rgba(139, 92, 246, 0.3);
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  margin-bottom: 0.9rem;
  align-self: flex-start;
}
.article-card h3 {
  font-size: 1.12rem;
  margin: 0 0 0.6rem;
  line-height: 1.35;
}
.article-card p {
  color: var(--text-2);
  font-size: 0.92rem;
  margin: 0 0 1.1rem;
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-meta {
  display: flex;
  gap: 0.9rem;
  color: var(--text-3);
  font-size: 0.8rem;
  font-weight: 500;
}

/* feature grid (home tools) */
.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}
.feature-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.8rem 1.5rem;
  color: var(--text);
  transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
}
.feature-card:hover {
  transform: translateY(-4px);
  border-color: rgba(139, 92, 246, 0.45);
  box-shadow: var(--shadow);
  color: var(--text);
}
.feature-icon {
  font-size: 1.8rem;
  width: 56px; height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  background: var(--grad-soft);
  border: 1px solid rgba(139, 92, 246, 0.3);
  margin-bottom: 1rem;
}
.feature-card h3 { font-size: 1.15rem; margin-bottom: 0.4rem; }
.feature-card p { color: var(--text-2); font-size: 0.92rem; margin: 0; }

/* ------------------------------ */
/* 9. Articles toolbar            */
/* ------------------------------ */
.articles-toolbar {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 2rem;
}
.search-box {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.7rem 1.2rem;
  color: var(--text-3);
  transition: var(--transition);
  max-width: 480px;
}
.search-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--glow); color: var(--accent); }
.search-box input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
}
.search-box input::placeholder { color: var(--text-3); }

.chip-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.chip {
  padding: 0.42rem 1rem;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-2);
  font-size: 0.85rem;
  font-weight: 600;
  transition: var(--transition);
}
.chip:hover { border-color: var(--accent); color: var(--text); }
.chip.active {
  background: var(--grad-brand);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 4px 16px rgba(139, 92, 246, 0.35);
}

/* ------------------------------ */
/* 10. Article reader             */
/* ------------------------------ */
.article-container { max-width: 780px; }
.back-link {
  display: inline-block;
  margin: 2rem 0 1rem;
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--text-2);
}
.back-link:hover { color: var(--accent); }

.article-body {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: clamp(1.5rem, 4vw, 3rem);
}
.article-body h1 {
  font-size: clamp(1.7rem, 4vw, 2.4rem);
  margin: 0 0 1.2rem;
  background: var(--grad-brand);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.article-body h2 {
  font-size: 1.45rem;
  margin: 2.2rem 0 0.8rem;
  padding-top: 1.4rem;
  border-top: 1px solid var(--border);
}
.article-body h2:first-of-type { border-top: none; padding-top: 0; }
.article-body h3 { font-size: 1.15rem; margin: 1.6rem 0 0.6rem; color: var(--violet-2); }
[data-theme="light"] .article-body h3 { color: var(--violet-3); }
.article-body p { color: var(--text-2); margin: 0 0 1.1rem; }
.article-body ul, .article-body ol {
  color: var(--text-2);
  padding-left: 1.4rem;
  margin: 0 0 1.2rem;
}
.article-body li { margin-bottom: 0.45rem; }
.article-body li::marker { color: var(--accent); }
.article-body strong { color: var(--text); }
.article-body code {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0.1em 0.4em;
  font-size: 0.88em;
  font-family: 'SFMono-Regular', Menlo, Consolas, monospace;
  color: var(--magenta);
}
.article-body a { text-decoration: underline; text-underline-offset: 2px; }

.article-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 2rem;
}
.article-nav a {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  color: var(--text);
  font-weight: 600;
  font-size: 0.92rem;
  transition: var(--transition);
  max-width: 48%;
}
.article-nav a:hover { border-color: var(--accent); transform: translateY(-2px); }
.article-nav .nav-dir {
  display: block;
  font-size: 0.75rem;
  color: var(--text-3);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.25rem;
}
.article-nav .next { text-align: right; margin-left: auto; }

/* ------------------------------ */
/* 11. Prices                     */
/* ------------------------------ */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.75rem;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.3rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  transition: var(--transition);
}
.stat-card:hover { border-color: rgba(139, 92, 246, 0.4); }
.stat-label {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
}
.stat-value {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
}
.stat-sub { font-size: 0.8rem; color: var(--text-3); }

.prices-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}
.tab-btn {
  padding: 0.55rem 1.2rem;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-2);
  font-weight: 600;
  font-size: 0.9rem;
  transition: var(--transition);
}
.tab-btn:hover { border-color: var(--accent); color: var(--text); }
.tab-btn.active {
  background: var(--grad-brand);
  border-color: transparent;
  color: #fff;
}
.count-badge {
  display: inline-block;
  background: rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  padding: 0 0.5em;
  font-size: 0.78em;
  margin-left: 0.3em;
}
.tab-btn:not(.active) .count-badge { background: var(--surface-2); color: var(--text-2); }

.table-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.table-scroll { overflow-x: auto; }

.price-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  min-width: 760px;
}
.price-table th {
  text-align: left;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-3);
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  user-select: none;
}
.price-table th.num, .price-table td.num { text-align: right; }
.price-table th[data-sort] { cursor: pointer; transition: color var(--transition); }
.price-table th[data-sort]:hover { color: var(--accent); }
.price-table th[data-sort]::after { content: ' ⇅'; opacity: 0.4; font-size: 0.85em; }
.price-table th[data-sort].sorted-asc::after { content: ' ↑'; opacity: 1; color: var(--accent); }
.price-table th[data-sort].sorted-desc::after { content: ' ↓'; opacity: 1; color: var(--accent); }

.price-table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  vertical-align: middle;
}
.price-table tbody tr {
  cursor: pointer;
  transition: background var(--transition);
}
.price-table tbody tr:hover { background: var(--table-row-hover); }
.price-table tbody tr:last-child td { border-bottom: none; }

.table-loading, .table-empty {
  text-align: center;
  color: var(--text-3);
  padding: 3rem 1rem !important;
  cursor: default;
}

.coin-cell {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}
.coin-cell img {
  width: 26px; height: 26px;
  border-radius: 50%;
  flex-shrink: 0;
}
.coin-name { font-weight: 600; }
.coin-sym {
  color: var(--text-3);
  font-size: 0.82rem;
  text-transform: uppercase;
  margin-left: 0.35rem;
}
.rank-cell { color: var(--text-3); font-weight: 500; }

.star-btn {
  background: none;
  border: none;
  font-size: 1.05rem;
  color: var(--text-3);
  padding: 0.2rem;
  line-height: 1;
  transition: var(--transition);
}
.star-btn:hover { color: var(--amber); transform: scale(1.2); }
.star-btn.starred { color: var(--amber); }

.spark-cell svg { display: block; }

.table-error {
  padding: 1.5rem;
  text-align: center;
  color: var(--text-2);
  border-top: 1px solid var(--border);
}
.table-error p { margin: 0 0 0.9rem; }

/* ------------------------------ */
/* 12. Swap                       */
/* ------------------------------ */
.swap-container { max-width: 520px; }

.swap-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
}

.swap-top-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  margin-bottom: 1.1rem;
}
.network-select-wrap { display: flex; flex-direction: column; gap: 0.35rem; }
.network-select-wrap label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
}
.select {
  background: var(--input-bg);
  border: 1px solid var(--border-strong);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.8rem;
  font-size: 0.92rem;
  font-family: inherit;
  font-weight: 600;
  outline: none;
  cursor: pointer;
  transition: var(--transition);
}
.select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--glow); }
.select option { background: var(--surface-solid); color: var(--text); }

.token-panel {
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  transition: var(--transition);
}
.token-panel:focus-within { border-color: var(--accent); }
.token-panel-head {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-3);
  font-weight: 600;
  margin-bottom: 0.5rem;
}
.balance-label { color: var(--accent); cursor: pointer; }
.token-input-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.amount-input {
  flex: 1;
  min-width: 0;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 600;
}
.amount-input::placeholder { color: var(--text-3); }
.amount-input[readonly] { color: var(--text-2); }

.token-select {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 0.5rem 0.9rem;
  color: var(--text);
  font-weight: 700;
  font-size: 0.95rem;
  flex-shrink: 0;
  transition: var(--transition);
}
.token-select:hover { border-color: var(--accent); }
.token-logo {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--bg-3);
}
.token-logo[src=""], .token-logo:not([src]) { display: none; }

.flip-row {
  display: flex;
  justify-content: center;
  margin: -0.55rem 0;
  position: relative;
  z-index: 2;
}
.flip-btn {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--surface-solid);
  border: 1px solid var(--border-strong);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}
.flip-btn:hover {
  background: var(--grad-brand);
  color: #fff;
  border-color: transparent;
  transform: rotate(180deg);
}

.slippage-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1.1rem 0;
  flex-wrap: wrap;
}
.slippage-label { font-size: 0.85rem; color: var(--text-3); font-weight: 600; }
.slippage-options { display: flex; gap: 0.4rem; align-items: center; flex-wrap: wrap; }
.slip-btn {
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-2);
  font-size: 0.82rem;
  font-weight: 600;
  transition: var(--transition);
}
.slip-btn:hover { border-color: var(--accent); color: var(--text); }
.slip-btn.active {
  background: var(--grad-brand);
  border-color: transparent;
  color: #fff;
}
.slip-custom {
  width: 90px;
  background: var(--input-bg);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  color: var(--text);
  padding: 0.35rem 0.8rem;
  font-size: 0.82rem;
  font-family: inherit;
  outline: none;
  transition: var(--transition);
}
.slip-custom:focus { border-color: var(--accent); }

.quote-summary {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1.1rem;
  margin-bottom: 1.1rem;
}
.quote-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.85rem;
  padding: 0.28rem 0;
}
.quote-row span:first-child { color: var(--text-3); }
.quote-row span:last-child { font-weight: 600; text-align: right; }

.swap-status {
  min-height: 1.3rem;
  font-size: 0.85rem;
  margin-bottom: 0.7rem;
  color: var(--text-2);
}
.swap-status.error { color: var(--red); }
.swap-status.success { color: var(--green); }
.swap-status.loading { color: var(--accent); }
.swap-status.loading::after {
  content: '';
  display: inline-block;
  width: 12px; height: 12px;
  margin-left: 0.5rem;
  border: 2px solid var(--accent);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.swap-disclaimer {
  text-align: center;
  color: var(--text-3);
  font-size: 0.82rem;
  margin-top: 1.4rem;
  line-height: 1.5;
}

/* ------------------------------ */
/* 13. Portfolio                  */
/* ------------------------------ */
.portfolio-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.portfolio-layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 1.5rem;
  align-items: start;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
}

.holding-form h3 { margin-bottom: 1.1rem; font-size: 1.1rem; }
.holding-form label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 1rem;
  position: relative;
}
.holding-form input {
  width: 100%;
  margin-top: 0.35rem;
  background: var(--input-bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 0.65rem 0.85rem;
  font-size: 0.95rem;
  font-family: inherit;
  outline: none;
  transition: var(--transition);
}
.holding-form input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--glow); }

.coin-suggest {
  position: absolute;
  top: 100%;
  left: 0; right: 0;
  z-index: 30;
  background: var(--surface-solid);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  margin-top: 4px;
  max-height: 260px;
  overflow-y: auto;
  box-shadow: var(--shadow);
}
.suggest-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  padding: 0.6rem 0.85rem;
  background: none;
  border: none;
  color: var(--text);
  font-size: 0.9rem;
  text-align: left;
  transition: var(--transition);
}
.suggest-item:hover, .suggest-item.active { background: var(--table-row-hover); }
.suggest-item img { width: 20px; height: 20px; border-radius: 50%; }
.suggest-sym { color: var(--text-3); text-transform: uppercase; font-size: 0.78rem; margin-left: auto; }
.suggest-empty { padding: 0.8rem; color: var(--text-3); font-size: 0.85rem; text-align: center; }

.pnl-pos { color: var(--green); font-weight: 600; }
.pnl-neg { color: var(--red); font-weight: 600; }

.delete-btn {
  background: none;
  border: none;
  color: var(--text-3);
  font-size: 1rem;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}
.delete-btn:hover { color: var(--red); background: rgba(248, 113, 113, 0.1); }

/* ------------------------------ */
/* 14. Modals                     */
/* ------------------------------ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(5, 5, 12, 0.7);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  animation: fadeIn 0.2s ease;
}
[data-theme="light"] .modal-backdrop { background: rgba(40, 30, 90, 0.35); }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  position: relative;
  width: 100%;
  max-width: 720px;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--surface-solid);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  box-shadow: var(--shadow);
  animation: modalIn 0.25s cubic-bezier(.2, .9, .3, 1.2);
}
@keyframes modalIn { from { opacity: 0; transform: translateY(16px) scale(0.98); } to { opacity: 1; transform: none; } }
.modal-sm { max-width: 440px; }

.modal-close {
  position: absolute;
  top: 0.9rem; right: 0.9rem;
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-2);
  font-size: 0.9rem;
  transition: var(--transition);
  z-index: 5;
}
.modal-close:hover { color: var(--red); border-color: var(--red); }

.modal-title { font-size: 1.2rem; margin-bottom: 1rem; }

.modal-head {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
  padding-right: 2.5rem;
}
.modal-coin-img { width: 48px; height: 48px; border-radius: 50%; }
.modal-head h2 { margin: 0; font-size: 1.5rem; }
.modal-symbol {
  color: var(--text-3);
  text-transform: uppercase;
  font-weight: 600;
  font-size: 0.85rem;
}
.modal-price-block { margin-left: auto; text-align: right; }
.modal-price { font-family: var(--font-display); font-size: 1.5rem; font-weight: 700; }
.modal-change { font-weight: 600; font-size: 0.92rem; }

.modal-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.7rem;
  margin-bottom: 1.4rem;
}
.modal-stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.85rem;
}
.modal-stat .stat-label { font-size: 0.7rem; }
.modal-stat .stat-value { font-size: 0.98rem; }

.modal-chart-wrap { position: relative; margin-bottom: 1.4rem; }
.chart-range-btns {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 0.9rem;
}
.chart-range-btns button {
  padding: 0.32rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-2);
  font-size: 0.8rem;
  font-weight: 700;
  transition: var(--transition);
}
.chart-range-btns button:hover { border-color: var(--accent); color: var(--text); }
.chart-range-btns button.active {
  background: var(--grad-brand);
  color: #fff;
  border-color: transparent;
}
.chart-loading {
  position: absolute;
  inset: 2.6rem 0 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-3);
  background: var(--surface-solid);
  font-size: 0.9rem;
}

.modal-desc {
  color: var(--text-2);
  font-size: 0.9rem;
  line-height: 1.65;
  max-height: 160px;
  overflow-y: auto;
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}
.modal-desc a { word-break: break-all; }

/* token select modal */
.token-search {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 0.7rem 1rem;
  font-size: 0.95rem;
  font-family: inherit;
  outline: none;
  margin-bottom: 0.9rem;
  transition: var(--transition);
}
.token-search:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--glow); }

.token-list {
  max-height: 340px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.token-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.65rem 0.8rem;
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text);
  text-align: left;
  transition: var(--transition);
}
.token-item:hover { background: var(--table-row-hover); border-color: var(--border); }
.token-item.selected { border-color: var(--accent); background: var(--grad-soft); }
.token-item img { width: 30px; height: 30px; border-radius: 50%; background: var(--bg-3); }
.token-item-name { font-weight: 600; font-size: 0.93rem; }
.token-item-sym { color: var(--text-3); font-size: 0.8rem; text-transform: uppercase; }
.token-item-balance { margin-left: auto; color: var(--text-2); font-size: 0.85rem; }

/* ------------------------------ */
/* 15. Footer                     */
/* ------------------------------ */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--bg-2);
  margin-top: auto;
}
.footer-inner {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1.6fr;
  gap: 2rem;
  padding-top: 3rem;
  padding-bottom: 2rem;
}
.footer-brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15rem;
}
.footer-tag {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 0.88rem;
  color: var(--text-3);
  margin: 0.6rem 0 0;
}
.footer-col h4 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-3);
  margin-bottom: 0.9rem;
}
.footer-col a {
  display: block;
  color: var(--text-2);
  font-size: 0.92rem;
  padding: 0.22rem 0;
  transition: var(--transition);
}
.footer-col a:hover { color: var(--accent); }
.footer-disclaimer p {
  font-size: 0.82rem;
  color: var(--text-3);
  margin: 0;
  line-height: 1.6;
}
.footer-bottom {
  border-top: 1px solid var(--border);
  padding-top: 1.25rem;
  padding-bottom: 1.5rem;
  color: var(--text-3);
  font-size: 0.82rem;
}

/* ------------------------------ */
/* 16. Responsive                 */
/* ------------------------------ */
@media (max-width: 900px) {
  .portfolio-layout { grid-template-columns: 1fr; }
  .footer-inner { grid-template-columns: 1fr 1fr; }
  .footer-disclaimer { grid-column: 1 / -1; }
}

@media (max-width: 720px) {
  .nav-toggle { display: flex; }

  .nav-links {
    position: fixed;
    top: var(--header-h);
    left: 0; right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0.25rem;
    background: var(--bg-2);
    border-bottom: 1px solid var(--border);
    padding: 1rem 1.25rem 1.5rem;
    transform: translateY(-120%);
    opacity: 0;
    pointer-events: none;
    transition: transform var(--transition), opacity var(--transition);
    box-shadow: var(--shadow);
  }
  .nav-links.open { transform: translateY(0); opacity: 1; pointer-events: auto; }
  .nav-link { padding: 0.8rem 1rem; font-size: 1rem; }
  .theme-toggle { margin: 0.5rem 0 0; }

  .hero { padding-top: 3.5rem; }
  .hero-cta .btn { width: 100%; }
  .hero-cta { flex-direction: column; align-items: stretch; }

  .swap-top-row { flex-direction: column; align-items: stretch; }
  .swap-top-row .btn-wallet { align-self: flex-start; }

  .article-nav { flex-direction: column; }
  .article-nav a { max-width: 100%; }

  .modal { padding: 1.25rem; }
  .modal-head { padding-right: 2rem; }
  .modal-price-block { margin-left: 0; width: 100%; text-align: left; }

  .footer-inner { grid-template-columns: 1fr; gap: 1.5rem; }
}

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