:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --ink: #111827;
  --ink-2: #4b5563;
  --muted: #8a94a6;
  --line: #e7eaef;
  --accent: #f7931a;

  --green-bg: #e7f6ec; --green-fg: #146c37;
  --amber-bg: #fdf1dc; --amber-fg: #8a5300;
  --red-bg:   #fde8e8; --red-fg:   #a12020;
  --gray-bg:  #eef0f3; --gray-fg:  #4b5563;

  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.04);
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 1360px; margin: 0 auto; padding: 0 32px; }

/* ---------- Header ---------- */

.topbar {
  position: sticky; top: 0; z-index: 10;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner { display: flex; align-items: center; gap: 32px; height: 68px; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand h1 { font-size: 16px; font-weight: 600; margin: 0; letter-spacing: -0.01em; }
.logo {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 15px;
}
.ticker { display: flex; align-items: baseline; gap: 10px; }
.price { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.change { font-size: 13px; font-weight: 500; padding: 2px 8px; border-radius: 999px; font-variant-numeric: tabular-nums; }
.change.up { background: var(--green-bg); color: var(--green-fg); }
.change.down { background: var(--red-bg); color: var(--red-fg); }
.price-stale { font-size: 12px; color: var(--amber-fg); }

.actions { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.updated { color: var(--muted); font-size: 13px; }
.refresh {
  display: inline-flex; align-items: center; gap: 8px;
  font: inherit; font-weight: 500; font-size: 13px;
  padding: 8px 16px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  cursor: pointer; transition: background 0.15s, border-color 0.15s;
}
.refresh:hover { background: #f3f4f6; border-color: #d6dae1; }
.refresh:disabled { cursor: default; color: var(--muted); }
.spinner {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent;
  display: none; animation: spin 0.8s linear infinite;
}
.refresh.loading .spinner { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Sections ---------- */

.section { margin: 44px 0 0; }
.section-head { display: flex; align-items: baseline; gap: 14px; margin-bottom: 16px; }
.section-head h2 { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; margin: 0; }
.section-head p { margin: 0; color: var(--muted); font-size: 13px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 20px; }

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

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 20px 16px;
  display: flex; flex-direction: column;
  min-width: 0;
}
.card.is-stale { border-color: #f1d9ac; }

.card-head { position: relative; display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.card-head h3 { font-size: 13px; font-weight: 500; color: var(--ink-2); margin: 0; flex: 1; }
.info {
  width: 20px; height: 20px; border-radius: 50%;
  border: 1px solid var(--line); background: transparent; color: var(--muted);
  font: inherit; font-size: 11px; font-weight: 600; line-height: 1;
  cursor: pointer; flex-shrink: 0;
}
.info:hover, .card-head.open .info { color: var(--ink); border-color: #cfd4dc; }
.tip {
  position: absolute; top: 28px; left: 0; right: 0; z-index: 5;
  background: #111827; color: #f3f4f6;
  font-size: 12.5px; line-height: 1.5;
  padding: 10px 12px; border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  opacity: 0; visibility: hidden; transform: translateY(-4px);
  transition: opacity 0.12s, transform 0.12s, visibility 0.12s;
}
.tip strong { color: #fff; font-weight: 600; }
.info:hover ~ .tip, .info:focus-visible ~ .tip, .card-head.open .tip { opacity: 1; visibility: visible; transform: none; }

.card-body { display: flex; flex-direction: column; flex: 1; }
.value-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; }
.value { font-size: 30px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.unit { font-size: 15px; font-weight: 500; color: var(--muted); margin-left: 2px; letter-spacing: 0; }
.sub { color: var(--ink-2); font-size: 12.5px; margin: 4px 0 14px; min-height: 19px; }

.pill {
  display: inline-block; white-space: nowrap;
  font-size: 12px; font-weight: 600;
  padding: 4px 10px; border-radius: 999px;
}
.pill-green { background: var(--green-bg); color: var(--green-fg); }
.pill-amber { background: var(--amber-bg); color: var(--amber-fg); }
.pill-red   { background: var(--red-bg);   color: var(--red-fg); }
.pill-gray  { background: var(--gray-bg);  color: var(--gray-fg); }

.chart { position: relative; height: 140px; margin-top: auto; }

.note { font-size: 12px; color: var(--muted); margin-top: 10px; }
.note.warn { color: var(--amber-fg); }

.error p { color: var(--ink-2); margin: 10px 0 6px; font-size: 13px; }
.error small { color: var(--muted); font-size: 11.5px; word-break: break-word; }

/* Halving timeline */
.custom { margin-top: auto; padding-top: 18px; }
.timeline { position: relative; padding-top: 22px; }
.track { display: flex; height: 10px; border-radius: 999px; overflow: hidden; gap: 2px; }
.seg { display: block; height: 100%; }
.seg-green { background: #a7dfb9; }
.seg-amber { background: #f6d08f; }
.seg-red   { background: #f3b0b0; }
.seg-gray  { background: #d6dae1; }
.marker { position: absolute; top: 0; bottom: -4px; width: 2px; background: var(--ink); transform: translateX(-1px); }
.marker span {
  position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  font-size: 11px; font-weight: 600; white-space: nowrap; line-height: 1;
}
.timeline-ends { display: flex; justify-content: space-between; margin-top: 10px; font-size: 12px; color: var(--ink-2); line-height: 1.35; }
.timeline-ends small { color: var(--muted); font-size: 11px; }
.timeline-ends .right { text-align: right; }

/* Skeletons */
.sk {
  border-radius: 8px;
  background: linear-gradient(90deg, #eef0f3 25%, #f6f7f9 50%, #eef0f3 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}
.sk-value { width: 45%; height: 34px; }
.sk-pill { width: 80px; height: 24px; border-radius: 999px; }
.sk-line { width: 70%; height: 14px; margin: 10px 0 18px; }
.sk-chart { height: 140px; margin-top: auto; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ---------- Footer ---------- */

.footer { margin-top: 56px; padding-top: 24px; padding-bottom: 48px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12.5px; }
.footer p { margin: 0 0 6px; }
.disclaimer strong { color: var(--ink-2); font-weight: 600; }
.footer a { color: var(--ink-2); text-decoration: none; border-bottom: 1px solid var(--line); }
.footer a:hover { color: var(--ink); border-color: var(--ink-2); }

/* ---------- Small screens: just don't break ---------- */

@media (max-width: 720px) {
  .wrap { padding: 0 16px; }
  .topbar { position: static; }
  .topbar-inner { flex-wrap: wrap; height: auto; padding: 12px 0; gap: 10px 16px; }
  .actions { margin-left: 0; width: 100%; justify-content: space-between; }
  .section-head { flex-direction: column; gap: 2px; }
  .grid { grid-template-columns: 1fr; }
}
