/* ==========================================================================
   Falah Exchange – iOS / Revolut inspiriertes Design
   ========================================================================== */

:root {
  --bg: #f2f2f7;
  --bg-elev: #ffffff;
  --bg-fill: rgba(118, 118, 128, 0.12);
  --bg-fill-2: rgba(118, 118, 128, 0.08);
  --sidebar: rgba(255, 255, 255, 0.72);
  --label: #000000;
  --label-2: rgba(60, 60, 67, 0.62);
  --label-3: rgba(60, 60, 67, 0.36);
  --sep: rgba(60, 60, 67, 0.12);
  --up: #1fb855;
  --down: #ff3b30;
  --up-soft: rgba(52, 199, 89, 0.14);
  --down-soft: rgba(255, 59, 48, 0.12);
  --accent: #007aff;
  --thumb: #ffffff;
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(0, 0, 0, 0.05);
  --shadow-pop: 0 10px 40px rgba(0, 0, 0, 0.16), 0 2px 8px rgba(0, 0, 0, 0.08);
  --radius: 22px;
  --radius-sm: 14px;
  --spring: cubic-bezier(0.22, 1, 0.36, 1);
  --spring-bounce: cubic-bezier(0.34, 1.36, 0.64, 1);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", Inter, system-ui, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000;
    --bg-elev: #1c1c1e;
    --bg-fill: rgba(118, 118, 128, 0.24);
    --bg-fill-2: rgba(118, 118, 128, 0.14);
    --sidebar: rgba(18, 18, 20, 0.78);
    --label: #ffffff;
    --label-2: rgba(235, 235, 245, 0.62);
    --label-3: rgba(235, 235, 245, 0.32);
    --sep: rgba(84, 84, 88, 0.42);
    --up: #30d158;
    --down: #ff453a;
    --up-soft: rgba(48, 209, 88, 0.16);
    --down-soft: rgba(255, 69, 58, 0.16);
    --accent: #0a84ff;
    --thumb: #636366;
    --shadow-card: 0 0 0 1px rgba(255, 255, 255, 0.04);
    --shadow-pop: 0 20px 60px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.06);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #000000;
  --bg-elev: #1c1c1e;
  --bg-fill: rgba(118, 118, 128, 0.24);
  --bg-fill-2: rgba(118, 118, 128, 0.14);
  --sidebar: rgba(18, 18, 20, 0.78);
  --label: #ffffff;
  --label-2: rgba(235, 235, 245, 0.62);
  --label-3: rgba(235, 235, 245, 0.32);
  --sep: rgba(84, 84, 88, 0.42);
  --up: #30d158;
  --down: #ff453a;
  --up-soft: rgba(48, 209, 88, 0.16);
  --down-soft: rgba(255, 69, 58, 0.16);
  --accent: #0a84ff;
  --thumb: #636366;
  --shadow-card: 0 0 0 1px rgba(255, 255, 255, 0.04);
  --shadow-pop: 0 20px 60px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.06);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--label);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "tnum" 1, "cv11" 1;
  overflow: hidden;
  transition: background-color 0.4s ease, color 0.4s ease;
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; -webkit-tap-highlight-color: transparent; }
input { font: inherit; color: inherit; }
svg { display: block; }
a { color: var(--accent); text-decoration: none; }

/* ------------------------------------------------------------- Layout */

.app {
  display: grid;
  grid-template-columns: 384px 1fr;
  height: 100dvh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--sidebar);
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  border-right: 1px solid var(--sep);
  z-index: 2;
}

.detail { min-width: 0; min-height: 0; position: relative; }
.detail-scroll {
  height: 100%;
  overflow-y: auto;
  padding: 28px clamp(20px, 4vw, 56px) 48px;
  scroll-behavior: smooth;
}
.detail-scroll > * { max-width: 1120px; margin-left: auto; margin-right: auto; }

/* ------------------------------------------------------------- Sidebar */

.sidebar-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 22px 20px 14px;
}
.brand { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.brand-logo { display: block; height: 26px; width: auto; max-width: 100%; fill: var(--label); transition: fill 0.4s ease; }
.brand-sub { font-size: 12.5px; color: var(--label-2); font-weight: 500; }

.icon-btn {
  width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--bg-fill-2);
  transition: transform 0.25s var(--spring), background 0.2s;
}
.icon-btn:hover { background: var(--bg-fill); }
.icon-btn:active { transform: scale(0.9); }
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.icon-btn .i-moon { display: none; }
:root[data-dark="1"] .icon-btn .i-sun { display: none; }
:root[data-dark="1"] .icon-btn .i-moon { display: block; }

.search {
  margin: 0 16px 12px;
  display: flex; align-items: center; gap: 8px;
  height: 38px; padding: 0 12px; border-radius: 12px;
  background: var(--bg-fill);
  transition: box-shadow 0.2s;
}
.search:focus-within { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent); }
.search svg { width: 17px; height: 17px; fill: none; stroke: var(--label-2); stroke-width: 2.2; stroke-linecap: round; flex: none; }
.search input { border: 0; outline: 0; background: none; width: 100%; font-size: 15.5px; }
.search input::placeholder { color: var(--label-2); }
.search input::-webkit-search-cancel-button { filter: grayscale(1); opacity: 0.5; }

.sidebar-controls { padding: 0 16px 10px; }
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  padding: 7px 13px; border-radius: 999px;
  font-size: 13.5px; font-weight: 600; color: var(--label-2);
  background: var(--bg-fill-2);
  transition: background 0.25s var(--spring), color 0.25s, transform 0.2s var(--spring);
}
.chip:active { transform: scale(0.94); }
.chip.active { background: var(--label); color: var(--bg-elev); }

.list-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 6px 16px 8px 20px;
}
.base-pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 13px; color: var(--label-2); font-weight: 500;
  padding: 6px 8px 6px 0; border-radius: 8px;
  transition: opacity 0.2s;
}
.base-pill:active { opacity: 0.5; }
.base-pill-code { color: var(--label); font-weight: 700; }
.base-pill svg { width: 15px; height: 15px; fill: none; stroke: var(--label-2); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }

.list {
  flex: 1; min-height: 0;
  overflow-y: auto;
  padding: 2px 10px 10px;
  display: flex; flex-direction: column; gap: 4px;
  overscroll-behavior: contain;
}
.list > * { flex: none; }
.row {
  display: grid;
  grid-template-columns: 44px 1fr 62px auto;
  align-items: center; gap: 12px;
  padding: 10px 10px;
  border-radius: 16px;
  cursor: pointer;
  position: relative;
  transition: background 0.25s ease, transform 0.25s var(--spring);
  animation: rowIn 0.55s var(--spring) both;
  animation-delay: calc(var(--i, 0) * 22ms);
}
.row:hover { background: var(--bg-fill-2); }
.row:active { transform: scale(0.98); }
.row.selected { background: var(--bg-elev); box-shadow: var(--shadow-card); }
@keyframes rowIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.row-name { min-width: 0; }
.row-code { font-weight: 700; font-size: 16px; letter-spacing: -0.01em; }
.row-sub { font-size: 13px; color: var(--label-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-spark { width: 62px; height: 28px; }
.row-spark path { fill: none; stroke-width: 1.7; stroke-linejoin: round; stroke-linecap: round; }
.row-right { text-align: right; min-width: 92px; }
.row-price { font-weight: 600; font-size: 15px; letter-spacing: -0.01em; white-space: nowrap; }
.row-chg {
  display: inline-block; margin-top: 3px;
  font-size: 12px; font-weight: 700; padding: 2px 7px; border-radius: 7px;
  transition: background 0.3s, color 0.3s;
}
.up { color: var(--up); }
.down { color: var(--down); }
.row-chg.up { background: var(--up-soft); }
.row-chg.down { background: var(--down-soft); }

.list-empty { text-align: center; color: var(--label-2); padding: 40px 0; font-size: 14px; }

.skeleton-row { display: grid; grid-template-columns: 44px 1fr 80px; gap: 12px; align-items: center; padding: 10px; }
.sk { border-radius: 8px; background: linear-gradient(90deg, var(--bg-fill-2) 0%, var(--bg-fill) 50%, var(--bg-fill-2) 100%); background-size: 200% 100%; animation: shimmer 1.4s infinite linear; }
.sk.circle { width: 44px; height: 44px; border-radius: 50%; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

.sidebar-foot {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 20px calc(14px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--sep);
  font-size: 12px; color: var(--label-2);
  cursor: pointer;
}
.sidebar-foot .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--label-3); flex: none; transition: background 0.3s; }
.sidebar-foot.ok .dot { background: var(--up); box-shadow: 0 0 0 3px var(--up-soft); }
.sidebar-foot.busy .dot { background: #ff9f0a; animation: pulse 1s infinite ease-in-out; }
.sidebar-foot.err .dot { background: var(--down); }
@keyframes pulse { 50% { opacity: 0.35; } }

/* ------------------------------------------------------------- Icons */

.asset-icon {
  width: 44px; height: 44px; border-radius: 50%;
  position: relative; overflow: hidden; flex: none;
  display: grid; place-items: center;
  font-weight: 800; color: #fff; font-size: 16px; letter-spacing: -0.02em;
  background: var(--bg-fill);
  box-shadow: inset 0 0 0 0.5px rgba(0, 0, 0, 0.08);
}
.asset-icon img { width: 100%; height: 100%; object-fit: cover; transform: scale(1.04); }
.asset-icon::after { content: ""; position: absolute; inset: 0; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.06); pointer-events: none; }
.asset-icon.xl { width: 64px; height: 64px; font-size: 24px; }
.asset-icon.sm { width: 32px; height: 32px; font-size: 12px; }
.asset-icon.gold { background: radial-gradient(circle at 30% 25%, #fff3b0, #f5c542 40%, #b8860b 100%); color: #5a3e00; }
.asset-icon.silver { background: radial-gradient(circle at 30% 25%, #ffffff, #c9ccd1 45%, #7d828a 100%); color: #33363b; }
.asset-icon.platinum { background: radial-gradient(circle at 30% 25%, #f4f7fb, #b6c2cf 45%, #5f6f80 100%); color: #26303a; }
.asset-icon.btc { background: linear-gradient(145deg, #ffb547, #f7931a); }
.asset-icon.eth { background: linear-gradient(145deg, #8a9cff, #4f5fd6); }
.asset-icon.fallback { background: linear-gradient(145deg, #5e5ce6, #0a84ff); }

/* ------------------------------------------------------------- Hero */

.detail-top { display: none; }
.hero {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; flex-wrap: wrap;
  margin-bottom: 22px;
}
.hero-id { display: flex; align-items: center; gap: 16px; }
.hero-name { margin: 0; font-size: 30px; font-weight: 800; letter-spacing: -0.035em; line-height: 1.05; }
.hero-pair { color: var(--label-2); font-size: 15px; font-weight: 500; margin-top: 3px; }
.hero-price { text-align: right; }
.price {
  font-size: clamp(38px, 5vw, 56px);
  font-weight: 700; letter-spacing: -0.045em; line-height: 1;
  display: inline-flex; align-items: flex-start; justify-content: flex-end;
  height: 1.05em; line-height: 1.05em;
  overflow: hidden;
}
.price .unit { font-size: 0.42em; line-height: 1; font-weight: 600; color: var(--label-2); margin-left: 0.3em; letter-spacing: -0.01em; align-self: flex-end; padding-bottom: 0.18em; }
.odo-digit { display: inline-block; height: 1.05em; overflow: hidden; position: relative; vertical-align: top; }
.odo-strip {
  display: flex; flex-direction: column;
  transition: transform 0.7s var(--spring);
  will-change: transform;
}
.odo-strip span { height: 1.05em; line-height: 1.05em; text-align: center; }
.odo-static { display: inline-block; line-height: 1.05em; }
.price.scrubbing .odo-strip { transition-duration: 0.28s; }

.hero-change { margin-top: 10px; font-size: 16px; font-weight: 600; display: inline-flex; gap: 8px; align-items: center; justify-content: flex-end; }
.hero-change .pct { padding: 3px 9px; border-radius: 9px; transition: background 0.35s, color 0.35s; }
.hero-change .pct.up { background: var(--up-soft); }
.hero-change .pct.down { background: var(--down-soft); }
.hero-change .lbl { color: var(--label-2); font-weight: 500; }
.hero-date { margin-top: 6px; font-size: 13px; color: var(--label-2); min-height: 1.2em; }

.hero.swap .hero-id, .hero.swap .hero-price { animation: heroSwap 0.55s var(--spring); }
@keyframes heroSwap { from { opacity: 0; transform: translateY(8px); filter: blur(4px); } to { opacity: 1; transform: none; filter: none; } }

/* ------------------------------------------------------------- Cards */

.card {
  background: var(--bg-elev);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 20px;
  margin-bottom: 16px;
  transition: background 0.4s;
}
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head h2 { margin: 0; font-size: 19px; font-weight: 700; letter-spacing: -0.025em; }
.card-sub { font-size: 13px; color: var(--label-2); }

/* ------------------------------------------------------------- Segmented */

.seg {
  position: relative;
  display: inline-flex;
  padding: 3px; border-radius: 11px;
  background: var(--bg-fill);
  isolation: isolate;
}
.seg button {
  position: relative; z-index: 1;
  padding: 7px 13px; border-radius: 8px;
  font-size: 13.5px; font-weight: 600; color: var(--label-2);
  transition: color 0.25s, opacity 0.2s;
  white-space: nowrap;
}
.seg button.active { color: var(--label); }
.seg button:disabled { opacity: 0.3; cursor: default; }
.seg button:not(:disabled):active { opacity: 0.6; }
.seg-thumb {
  position: absolute; z-index: 0; top: 3px; bottom: 3px; left: 0; width: 0;
  border-radius: 8px;
  background: var(--thumb);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12), 0 3px 1px rgba(0, 0, 0, 0.04);
  transition: transform 0.45s var(--spring), width 0.45s var(--spring);
}
.seg-sm button { padding: 5px 9px; font-size: 12.5px; }
.seg-ghost { background: transparent; }
.seg-ghost .seg-thumb { background: var(--bg-fill); box-shadow: none; }

/* ------------------------------------------------------------- Chart */

.chart-card { padding: 16px 16px 10px; }
.chart-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.chart-wrap { position: relative; height: clamp(260px, 42vh, 420px); touch-action: pan-y; }
.chart-wrap canvas { width: 100%; height: 100%; display: block; cursor: crosshair; }
.chart-tip {
  position: absolute; top: 0; left: 0;
  pointer-events: none;
  padding: 6px 10px; border-radius: 10px;
  font-size: 12.5px; font-weight: 600; white-space: nowrap;
  background: var(--label); color: var(--bg-elev);
  opacity: 0; transform: translate(-50%, -4px) scale(0.92);
  transition: opacity 0.18s, transform 0.25s var(--spring);
}
.chart-tip.show { opacity: 1; transform: translate(-50%, 0) scale(1); }
.chart-loading { position: absolute; inset: 0; display: grid; place-items: center; opacity: 0; pointer-events: none; transition: opacity 0.3s; }
.chart-loading.show { opacity: 1; }
.spinner { width: 26px; height: 26px; border-radius: 50%; border: 2.5px solid var(--bg-fill); border-top-color: var(--label-2); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.chart-live {
  position: absolute; left: 0; top: 0; width: 10px; height: 10px; margin: -5px 0 0 -5px;
  border-radius: 50%; background: var(--c, var(--up));
  opacity: 0; transition: opacity 0.3s; pointer-events: none;
}
.chart-live.show { opacity: 1; }
.chart-live::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%; background: var(--c, var(--up));
  animation: live 2s infinite var(--spring);
}
@keyframes live { from { transform: scale(1); opacity: 0.55; } to { transform: scale(3.4); opacity: 0; } }

/* ------------------------------------------------------------- Stats */

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 16px;
  align-items: stretch;
}
.sgroup {
  background: var(--bg-elev);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 18px 20px 8px;
  height: 100%;
  animation: statIn 0.6s var(--spring) both;
  animation-delay: calc(var(--i, 0) * 60ms);
}
@keyframes statIn { from { opacity: 0; transform: translateY(12px) scale(0.98); } to { opacity: 1; transform: none; } }
.sgroup-head { font-size: 13px; font-weight: 600; color: var(--label-2); margin-bottom: 4px; }

.srow {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 0;
}
.srow + .srow, .srange + .srow { border-top: 1px solid var(--sep); }
.sl { min-width: 0; font-size: 15px; font-weight: 500; color: var(--label); }
.sl small, .sv small { display: block; font-size: 12.5px; font-weight: 500; color: var(--label-2); margin-top: 2px; white-space: nowrap; }
.sv { text-align: right; font-size: 15px; font-weight: 600; letter-spacing: -0.01em; white-space: nowrap; }

.srange { padding: 14px 0; }
.srange-track { position: relative; height: 4px; border-radius: 2px; background: var(--bg-fill); margin: 4px 0 12px; }
.srange-track i {
  position: absolute; top: 50%; left: 0;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--label); border: 3px solid var(--bg-elev);
  transform: translate(-50%, -50%);
  transition: left 0.9s var(--spring);
}
.srange-track i.in { left: var(--x); }
.srange-ends { display: flex; justify-content: space-between; }
.srange-ends div:last-child { text-align: right; }
.srange-ends small { display: block; font-size: 12.5px; color: var(--label-2); font-weight: 500; }
.srange-ends b { display: block; font-size: 17px; font-weight: 700; letter-spacing: -0.02em; margin-top: 2px; }

/* ------------------------------------------------------------- Years */

.grid-2 { display: grid; grid-template-columns: 1.6fr 1fr; gap: 16px; }
.grid-2 .card { margin-bottom: 16px; }
.years { display: flex; align-items: stretch; gap: 3px; height: 190px; position: relative; margin-bottom: 20px; }
.years::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; border-top: 1px dashed var(--sep); }
.yr { flex: 1; display: flex; flex-direction: column; position: relative; min-width: 0; cursor: default; }
.yr-top, .yr-bot { flex: 1; display: flex; }
.yr-top { align-items: flex-end; }
.yr-bot { align-items: flex-start; }
.yr-bar {
  width: 100%; border-radius: 4px;
  transform-origin: bottom; transform: scaleY(0);
  animation: grow 0.8s var(--spring) forwards;
  animation-delay: calc(var(--i, 0) * 18ms);
}
.yr-bot .yr-bar { transform-origin: top; }
.yr-bar.up { background: var(--up); }
.yr-bar.down { background: var(--down); }
.yr:hover .yr-bar { filter: brightness(1.15); }
@keyframes grow { to { transform: scaleY(1); } }
.yr-label { position: absolute; bottom: -18px; left: 50%; transform: translateX(-50%); font-size: 10.5px; color: var(--label-3); font-weight: 600; white-space: nowrap; }
.years-wrap { padding-bottom: 20px; }
.yr-tip {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%) scale(0.9);
  background: var(--label); color: var(--bg-elev);
  font-size: 12px; font-weight: 700; padding: 5px 8px; border-radius: 8px; white-space: nowrap;
  opacity: 0; pointer-events: none; transition: opacity 0.15s, transform 0.25s var(--spring); z-index: 3;
}
.yr:hover .yr-tip { opacity: 1; transform: translate(-50%, -50%) scale(1); }

/* ------------------------------------------------------------- Converter */

.converter { display: flex; flex-direction: column; }
.conv-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-fill-2);
  border-radius: 16px; padding: 12px 14px;
  transition: box-shadow 0.2s;
}
.conv-row:focus-within { box-shadow: 0 0 0 2px var(--accent); }
.conv-row input {
  flex: 1; min-width: 0; border: 0; outline: 0; background: none;
  font-size: 26px; font-weight: 700; letter-spacing: -0.03em;
}
.conv-code { font-weight: 700; color: var(--label-2); }
.conv-swap {
  align-self: center; margin: -10px 0; z-index: 1;
  width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--bg-elev); box-shadow: 0 0 0 4px var(--bg-elev), var(--shadow-card);
  border: 1px solid var(--sep);
  transition: transform 0.5s var(--spring-bounce);
}
.conv-swap svg { width: 18px; height: 18px; fill: none; stroke: var(--label); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.conv-swap.spin { transform: rotate(180deg); }

/* ------------------------------------------------------------- Heatmap */

.heatmap { overflow-x: auto; }
.heatmap table { border-collapse: separate; border-spacing: 3px; width: 100%; min-width: 640px; font-size: 11.5px; }
.heatmap th { color: var(--label-2); font-weight: 600; padding: 2px 4px; text-align: center; }
.heatmap th.y { text-align: right; padding-right: 8px; }
.heatmap td {
  text-align: center; padding: 6px 0; border-radius: 6px; font-weight: 600;
  color: var(--label); min-width: 40px;
  animation: cellIn 0.5s var(--spring) both;
}
.heatmap td.na { color: var(--label-3); }
.heatmap td.total { font-weight: 800; }
@keyframes cellIn { from { opacity: 0; transform: scale(0.85); } to { opacity: 1; transform: none; } }

.credits { text-align: center; color: var(--label-3); font-size: 12px; padding: 16px 0 8px; }
.credits a { color: var(--label-2); }

/* ------------------------------------------------------------- Popover */

.popover {
  position: fixed; z-index: 50;
  min-width: 260px; max-height: 60vh; overflow-y: auto;
  padding: 6px;
  border-radius: 16px;
  background: color-mix(in srgb, var(--bg-elev) 82%, transparent);
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  box-shadow: var(--shadow-pop);
  transform-origin: top left;
  opacity: 0; transform: scale(0.88); pointer-events: none; filter: blur(6px);
  transition: opacity 0.2s, transform 0.4s var(--spring), filter 0.25s;
}
.popover.open { opacity: 1; transform: none; pointer-events: auto; filter: none; }
.pop-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 10px; border-radius: 10px; text-align: left; font-size: 15px;
  transition: background 0.15s;
}
.pop-item:hover { background: var(--bg-fill-2); }
.pop-item .asset-icon { width: 28px; height: 28px; font-size: 11px; }
.pop-item b { font-weight: 700; }
.pop-item span { color: var(--label-2); font-size: 13px; }
.pop-item .check { margin-left: auto; width: 18px; height: 18px; fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }

/* ------------------------------------------------------------- Onboarding */

.onboard {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  backdrop-filter: blur(24px) saturate(160%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  animation: fadeIn 0.4s ease both;
  padding: 20px;
}
.onboard[hidden] { display: none; }
.onboard.out { animation: fadeOut 0.5s ease forwards; }
.onboard-card {
  width: min(420px, 100%);
  text-align: center; padding: 36px 28px 30px;
  background: var(--bg-elev); border-radius: 30px; box-shadow: var(--shadow-pop);
  animation: popIn 0.7s var(--spring-bounce) both;
}
.onboard-card h2 { margin: 18px 0 6px; font-size: 22px; letter-spacing: -0.03em; }
.onboard-card p { margin: 0; color: var(--label-2); font-size: 14.5px; line-height: 1.45; }
.ring { position: relative; width: 120px; height: 120px; margin: 0 auto; }
.ring svg { transform: rotate(-90deg); width: 100%; height: 100%; }
.ring circle { fill: none; stroke-width: 9; }
.ring-bg { stroke: var(--bg-fill); }
.ring-fg { stroke: var(--up); stroke-linecap: round; stroke-dasharray: 326.7; stroke-dashoffset: 326.7; transition: stroke-dashoffset 0.9s var(--spring); }
.ring-label { position: absolute; inset: 0; display: grid; place-items: center; font-size: 26px; font-weight: 800; letter-spacing: -0.04em; }
.years-ticker { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; margin-top: 18px; }
.years-ticker span { font-size: 10.5px; font-weight: 700; padding: 3px 6px; border-radius: 6px; background: var(--bg-fill-2); color: var(--label-3); transition: background 0.4s, color 0.4s; }
.years-ticker span.done { background: var(--up-soft); color: var(--up); }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes fadeOut { to { opacity: 0; visibility: hidden; } }
@keyframes popIn { from { opacity: 0; transform: scale(0.9) translateY(10px); } }

/* ------------------------------------------------------------- Toast */

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 120;
  transform: translate(-50%, 20px); opacity: 0;
  padding: 11px 18px; border-radius: 999px;
  background: var(--label); color: var(--bg-elev);
  font-size: 14px; font-weight: 600;
  box-shadow: var(--shadow-pop);
  transition: transform 0.5s var(--spring), opacity 0.3s;
  pointer-events: none;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }

/* ------------------------------------------------------------- Responsive */

@media (max-width: 1180px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats .sgroup:first-child { grid-column: 1 / -1; }
  .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  body { overflow: hidden; }
  .app { grid-template-columns: 1fr; }
  .sidebar { grid-area: 1 / 1; border-right: 0; background: var(--bg); backdrop-filter: none; -webkit-backdrop-filter: none; }
  .detail {
    grid-area: 1 / 1; z-index: 5;
    background: var(--bg);
    transform: translateX(100%);
    transition: transform 0.5s var(--spring);
    box-shadow: -20px 0 50px rgba(0, 0, 0, 0.12);
  }
  .app.show-detail .detail { transform: none; }
  .app.show-detail .sidebar { transform: translateX(-24%); opacity: 0.6; }
  .sidebar { transition: transform 0.5s var(--spring), opacity 0.5s; }
  .detail-scroll { padding: 0 16px 32px; padding-top: env(safe-area-inset-top); }
  .detail-top {
    display: block; position: sticky; top: 0; z-index: 4;
    margin: 0 -16px 8px; padding: 10px 8px;
    background: color-mix(in srgb, var(--bg) 78%, transparent);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
  }
  .back-btn { display: inline-flex; align-items: center; gap: 2px; color: var(--accent); font-size: 17px; padding: 4px 6px; }
  .back-btn svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
  .hero { flex-direction: column; align-items: flex-start; gap: 14px; }
  .hero-price { text-align: left; }
  .price, .hero-change { justify-content: flex-start; }
  .chart-toolbar { flex-direction: column; align-items: stretch; }
  .chart-toolbar .seg { display: flex; }
  .chart-toolbar .seg button { flex: 1; padding: 7px 4px; }
  .stats { grid-template-columns: 1fr; gap: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-delay: 0ms !important; transition-duration: 0.12s !important; }
}
@media (prefers-reduced-transparency: reduce) {
  .sidebar, .popover, .onboard { backdrop-filter: none; -webkit-backdrop-filter: none; background: var(--bg-elev); }
}
