/* SwapView — swap rate charts, powered by CypherGoat. Follows the CypherGoat dark theme. */
:root {
  --bg: #0b0d14;
  --panel: #11151c;
  --panel-2: #161a22;
  --panel-3: #1c212b;
  --line: rgba(255, 255, 255, 0.07);
  --line-2: rgba(255, 255, 255, 0.12);
  --text: #f3f5f7;
  --muted: #98a1b1;
  --dim: #64748b;
  --accent: #a5b4fc;
  --accent-bg: rgba(165, 180, 252, 0.12);
  --cta: #f3eee2;
  --cta-hover: #faf7ef;
  --up: #4ade80;
  --down: #f87171;
  --amber: #fbbf24;

  --r-sm: 6px;
  --r: 10px;
  --r-lg: 16px;

  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  --top: 56px;
  --topbar-bg: rgba(11, 13, 20, 0.88);
  --cta-text: #0b0d14;
  /* chart palette (read by JS) */
  --c-bg: #0b0d14;
  --c-text: #98a1b1;
  --c-grid: rgba(255, 255, 255, 0.04);
  --c-border: rgba(255, 255, 255, 0.07);
  --c-cross: rgba(255, 255, 255, 0.25);
  --c-label: #1c212b;
  --c-main: #f3f5f7;
  --c-median: #a5b4fc;
  --c-worst: rgba(248, 113, 113, 0.6);
  --c-edge: rgba(251, 191, 36, 0.6);
  --c-depth: #67e8f9;
  color-scheme: dark;
}

/* Light theme: data-theme="light" on <html>, set by theme.js before paint. */
:root[data-theme="light"] {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --panel-2: #f1f3f6;
  --panel-3: #e6e9ef;
  --line: rgba(11, 13, 20, 0.08);
  --line-2: rgba(11, 13, 20, 0.14);
  --text: #0b0d14;
  --muted: #4b5565;
  --dim: #6b7585;
  --accent: #4f5bd5;
  --accent-bg: rgba(79, 91, 213, 0.1);
  --cta: #0b1f2a;
  --cta-hover: #163445;
  --cta-text: #ffffff;
  --up: #16a34a;
  --down: #dc2626;
  --amber: #d97706;
  --topbar-bg: rgba(246, 247, 249, 0.88);
  --c-bg: #ffffff;
  --c-text: #4b5565;
  --c-grid: rgba(11, 13, 20, 0.05);
  --c-border: rgba(11, 13, 20, 0.1);
  --c-cross: rgba(11, 13, 20, 0.3);
  --c-label: #0b1f2a;
  --c-main: #0b0d14;
  --c-median: #4f5bd5;
  --c-worst: rgba(220, 38, 38, 0.55);
  --c-edge: rgba(217, 119, 6, 0.55);
  --c-depth: #0891b2;
  color-scheme: light;
}
/* Logo variants per theme */
.on-light { display: none !important; }
:root[data-theme="light"] .on-dark { display: none !important; }
:root[data-theme="light"] .on-light { display: block !important; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button, input { font: inherit; color: inherit; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.up { color: var(--up); }
.down { color: var(--down); }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.wrap { width: 100%; max-width: 1280px; margin: 0 auto; padding: 0 16px; }
@media (min-width: 720px) { .wrap { padding: 0 24px; } }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  height: var(--top);
  background: var(--topbar-bg);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar-in { height: 100%; display: flex; align-items: center; gap: 16px; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; flex-shrink: 0; }
.brand img { width: 30px; height: 30px; display: block; }
.brand-name { font-size: 1.2rem; font-weight: 750; letter-spacing: -0.04em; }
.nav { display: flex; gap: 2px; margin-left: 8px; }
.nav a { text-decoration: none; color: var(--muted); padding: 6px 10px; border-radius: var(--r-sm); font-weight: 550; font-size: 0.86rem; }
.nav a:hover { color: var(--text); background: var(--panel-2); }
.nav a[aria-current="page"] { color: var(--text); }
@media (max-width: 720px) { .nav { display: none; } }
.spacer { flex: 1; }
.search-btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 6px 10px; color: var(--muted); cursor: pointer; min-width: 0;
}
.search-btn:hover { border-color: var(--line-2); color: var(--text); }
.search-btn kbd { font: 11px var(--mono); color: var(--dim); border: 1px solid var(--line-2); border-radius: 4px; padding: 0 5px; }
@media (max-width: 480px) { .search-btn kbd, .search-btn .lbl { display: none; } }

/* ---------- ticker tape ---------- */
.tape { border-bottom: 1px solid var(--line); background: var(--panel); overflow: hidden; height: 34px; position: relative; }
.tape-track { display: flex; width: max-content; height: 100%; animation: tape 90s linear infinite; }
.tape:hover .tape-track { animation-play-state: paused; }
.tape-item { display: inline-flex; align-items: center; gap: 8px; padding: 0 18px; height: 100%; text-decoration: none; font-size: 0.8rem; white-space: nowrap; border-right: 1px solid var(--line); }
.tape-item b { font-weight: 650; }
@keyframes tape { from { transform: translateX(0); } to { transform: translateX(-50%); } }
@media (prefers-reduced-motion: reduce) { .tape-track { animation: none; } .tape { overflow-x: auto; } }

/* ---------- generic ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); }
.panel-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.panel-h h2 { margin: 0; font-size: 0.95rem; font-weight: 650; letter-spacing: -0.01em; }
.panel-h p { margin: 0; color: var(--muted); font-size: 0.8rem; }
.eyebrow { font-size: 0.72rem; font-weight: 650; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); }
.seg { display: inline-flex; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 2px; gap: 2px; }
.seg button { background: none; border: 0; padding: 4px 10px; border-radius: 4px; color: var(--muted); cursor: pointer; font-size: 0.8rem; font-weight: 600; }
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--panel-3); color: var(--text); }
.chip { display: inline-flex; align-items: center; gap: 6px; background: none; border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; color: var(--muted); cursor: pointer; font-size: 0.8rem; font-weight: 600; }
.chip:hover { color: var(--text); border-color: var(--line-2); }
.chip[aria-pressed="true"] { color: var(--text); background: var(--accent-bg); border-color: rgba(165, 180, 252, 0.35); }
.chip .sw { width: 10px; height: 2px; border-radius: 2px; background: currentColor; }
.btn { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; font-weight: 650; border-radius: var(--r); padding: 10px 16px; border: 1px solid var(--line-2); }
.btn-cta { background: var(--cta); color: var(--cta-text); border-color: transparent; }
.btn-cta:hover { background: var(--cta-hover); }
.btn-ghost:hover { background: var(--panel-2); }
.coin { width: 20px; height: 20px; border-radius: 50%; background: var(--panel-3); flex-shrink: 0; object-fit: cover; }
.pairicons { display: inline-flex; flex-shrink: 0; }
.pairicons .coin + .coin { margin-left: -4px; box-shadow: 0 0 0 2px var(--panel); }
.coin-fallback { display: inline-flex; align-items: center; justify-content: center; font-size: 9px; font-weight: 700; color: var(--muted); }

/* ---------- overview ---------- */
.hero { padding: 48px 0 28px; display: grid; gap: 28px; }
@media (min-width: 960px) { .hero { grid-template-columns: 1.25fr 1fr; align-items: end; } }
.hero h1 { margin: 10px 0 12px; font-size: clamp(2rem, 5vw, 3.1rem); line-height: 1.05; letter-spacing: -0.045em; font-weight: 750; }
.hero h1 em { font-style: normal; color: var(--accent); }
.hero p { margin: 0; color: var(--muted); font-size: 1.02rem; max-width: 38rem; }
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.kpi { background: var(--panel); padding: 14px 16px; }
.kpi-v { font: 650 1.5rem/1.1 var(--mono); letter-spacing: -0.03em; }
.kpi-l { color: var(--muted); font-size: 0.76rem; margin-top: 6px; line-height: 1.35; }
@media (max-width: 480px) { .kpi { padding: 12px; } .kpi-v { font-size: 1.15rem; } }

.grid-2 { display: grid; gap: 20px; margin-bottom: 20px; }
@media (min-width: 1000px) { .grid-2 { grid-template-columns: 1fr 340px; } }
.index-chart { height: 280px; position: relative; }
.index-side { padding: 18px; display: flex; flex-direction: column; gap: 16px; }
.index-side .big { font: 700 2.4rem/1 var(--mono); letter-spacing: -0.04em; }
.index-side p { margin: 0; color: var(--muted); font-size: 0.85rem; }
.delta { font: 600 0.85rem var(--mono); }

.screener-tools { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filter { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 6px 10px; width: 160px; }
.table-wrap { overflow-x: auto; }
table.scr { width: 100%; border-collapse: collapse; min-width: 720px; }
.scr th { text-align: right; font-size: 0.72rem; font-weight: 600; color: var(--dim); text-transform: uppercase; letter-spacing: 0.06em; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.scr th button { all: unset; cursor: pointer; }
.scr th button:hover { color: var(--text); }
.scr th[aria-sort] button::after { content: " ↓"; }
.scr th[aria-sort="ascending"] button::after { content: " ↑"; }
.scr th:first-child, .scr td:first-child { text-align: left; }
.scr td { padding: 10px 14px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
.scr tbody tr { cursor: pointer; }
.scr tbody tr:hover td { background: var(--panel-2); }
.scr tbody tr:last-child td { border-bottom: 0; }
.mkt { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; }
.mkt b { font-weight: 650; }
.mkt .net { font-size: 0.7rem; color: var(--dim); font-weight: 600; }
.spark { width: 110px; height: 28px; display: block; margin-left: auto; }
.pill { display: inline-block; min-width: 64px; text-align: right; padding: 2px 8px; border-radius: 5px; font: 600 0.82rem var(--mono); }
.pill.up { background: rgba(74, 222, 128, 0.1); }
.pill.down { background: rgba(248, 113, 113, 0.1); }
.bar { display: inline-block; width: 46px; height: 4px; background: var(--panel-3); border-radius: 2px; margin-left: 8px; vertical-align: middle; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--amber); border-radius: 2px; }

.method { display: grid; gap: 20px; margin: 20px 0; }
@media (min-width: 900px) { .method { grid-template-columns: 1fr 1fr; } }
.method .panel { padding: 22px; }
.method h3 { margin: 6px 0 12px; font-size: 1.1rem; letter-spacing: -0.02em; }
.method ul { margin: 0; padding-left: 18px; color: var(--muted); }
.method li { margin: 6px 0; }
.method li b { color: var(--text); font-weight: 600; }

.footer { border-top: 1px solid var(--line); margin-top: 32px; padding: 22px 0 36px; color: var(--dim); font-size: 0.8rem; }
.footer-in { display: flex; gap: 12px 24px; flex-wrap: wrap; justify-content: space-between; }
.footer a { color: var(--muted); }

.empty { padding: 40px 18px; text-align: center; color: var(--muted); }
.skeleton { background: linear-gradient(90deg, var(--panel-2), var(--panel-3), var(--panel-2)); background-size: 200% 100%; animation: sk 1.4s ease infinite; border-radius: 4px; color: transparent !important; }
@keyframes sk { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ---------- chart terminal ---------- */
body.terminal { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
.terminal .topbar { position: relative; }
.toolbar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--line); background: var(--panel); overflow-x: auto; scrollbar-width: none; flex-shrink: 0; }
.toolbar::-webkit-scrollbar { display: none; }
.toolbar .sep { width: 1px; align-self: stretch; background: var(--line); flex-shrink: 0; }
.sym-btn { display: inline-flex; align-items: center; gap: 8px; background: none; border: 0; border-radius: var(--r-sm); padding: 4px 8px; cursor: pointer; font-weight: 700; font-size: 0.95rem; flex-shrink: 0; }
.sym-btn:hover { background: var(--panel-2); }
.sym-btn .caret { color: var(--dim); font-size: 0.7rem; }
.icon-btn { background: none; border: 1px solid transparent; border-radius: var(--r-sm); padding: 4px 8px; cursor: pointer; color: var(--muted); font-size: 0.82rem; font-weight: 600; flex-shrink: 0; white-space: nowrap; }
.icon-btn:hover:not(:disabled) { color: var(--text); background: var(--panel-2); }
.icon-btn:disabled { opacity: 0.35; cursor: default; }
.toolbar .seg, .toolbar .chip { flex-shrink: 0; }

.term { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr; }
@media (min-width: 1000px) { .term { grid-template-columns: 1fr 320px; } }
.chart-col { position: relative; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
#chart { flex: 1; min-height: 0; position: relative; }
.legend { position: absolute; z-index: 5; top: 8px; left: 12px; right: 80px; pointer-events: none; font-size: 0.8rem; line-height: 1.6; }
.legend .l1 { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; }
.legend .ttl { font-weight: 700; font-size: 0.95rem; }
.legend .kv { color: var(--dim); }
.legend .kv b { font-weight: 500; font-family: var(--mono); color: var(--text); margin-left: 3px; }
.legend .l2 { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.legend .dot { display: inline-block; width: 8px; height: 2px; vertical-align: middle; margin-right: 5px; border-radius: 2px; }
.pane-label { position: absolute; z-index: 4; left: 12px; font-size: 0.72rem; color: var(--dim); pointer-events: none; }
.pane-label b { font-family: var(--mono); font-weight: 500; color: var(--muted); }
.statusbar { display: flex; gap: 16px; align-items: center; padding: 6px 12px; border-top: 1px solid var(--line); color: var(--dim); font-size: 0.74rem; flex-shrink: 0; overflow-x: auto; white-space: nowrap; }
.statusbar a { color: var(--muted); }
.loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--dim); z-index: 6; pointer-events: none; }

.side { border-left: 1px solid var(--line); background: var(--panel); display: none; flex-direction: column; min-height: 0; overflow-y: auto; }
@media (min-width: 1000px) { .side { display: flex; } }
.side-h { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid var(--line); font-size: 0.74rem; font-weight: 650; letter-spacing: 0.06em; text-transform: uppercase; color: var(--dim); }
.watch { flex: 0 0 auto; }
.watch a { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center; padding: 8px 14px; text-decoration: none; font-size: 0.82rem; border-left: 2px solid transparent; }
.watch a:hover { background: var(--panel-2); }
.watch a[aria-current="true"] { background: var(--accent-bg); border-left-color: var(--accent); }
.watch .w-sym { display: flex; gap: 8px; align-items: center; font-weight: 650; min-width: 0; }
.watch .w-sym span { overflow: hidden; text-overflow: ellipsis; }
.watch .w-chg { min-width: 58px; text-align: right; }
.details { border-top: 1px solid var(--line); padding: 14px; font-size: 0.82rem; }
.details h3 { margin: 0 0 2px; font-size: 1rem; }
.details .last { font: 650 1.5rem/1.2 var(--mono); letter-spacing: -0.03em; margin: 6px 0 2px; }
.dl { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; margin: 12px 0 0; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; text-align: right; font-family: var(--mono); }
.callout { margin-top: 14px; padding: 12px; border-radius: var(--r); background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); line-height: 1.5; }
.callout b { color: var(--text); }
.mobile-details { display: block; }
@media (min-width: 1000px) { .mobile-details { display: none; } }
@media (max-width: 999px) {
  body.terminal { height: auto; overflow: auto; }
  .term { display: block; }
  #chart { flex: 1; height: 68vh; min-height: 420px; }
  .mobile-details .details { border-top: 1px solid var(--line); }
}

/* ---------- symbol search dialog ---------- */
dialog.sym-dialog { width: min(560px, calc(100vw - 32px)); max-height: min(640px, calc(100vh - 64px)); padding: 0; border: 1px solid var(--line-2); border-radius: var(--r-lg); background: var(--panel); color: var(--text); box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6); }
dialog.sym-dialog[open] { display: flex; flex-direction: column; }
dialog.sym-dialog::backdrop { background: rgba(0, 0, 0, 0.55); backdrop-filter: blur(2px); }
.sym-search { display: flex; gap: 10px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.sym-search input { flex: 1; background: none; border: 0; outline: none; font-size: 1rem; min-width: 0; }
.sym-list { overflow-y: auto; padding: 6px; }
.sym-list a { display: grid; grid-template-columns: auto 1fr auto auto; gap: 12px; align-items: center; padding: 8px 10px; border-radius: var(--r-sm); text-decoration: none; }
.sym-list a:hover, .sym-list a.sel { background: var(--panel-2); }
.sym-list .s-name { font-weight: 650; }
.sym-list .s-sub { color: var(--dim); font-size: 0.75rem; }

/* ---------- CypherGoat branding ---------- */
.powered { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; padding: 5px 10px 5px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); flex-shrink: 0; transition: border-color 0.15s ease, background 0.15s ease; }
.powered:hover { border-color: var(--line-2); background: var(--panel-2); }
.powered-lbl { font-size: 0.68rem; font-weight: 600; color: var(--dim); text-transform: uppercase; letter-spacing: 0.08em; white-space: nowrap; }
.powered-wide { height: 20px; width: auto; display: block; }
.powered-icon { display: none; border-radius: 7px; }
@media (max-width: 560px) {
  .powered { padding: 0; border: 0; background: none; }
  .powered-lbl, .powered-wide { display: none; }
  .powered-icon { display: block; }
}
.cg-pill { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; font-size: 0.78rem; font-weight: 650; color: var(--text); padding: 4px 12px 4px 4px; border: 1px solid var(--line-2); border-radius: 999px; background: var(--panel); }
.cg-pill:hover { background: var(--panel-2); }
.cg-pill img { border-radius: 50%; display: block; }
.cg-band { display: grid; gap: 20px; align-items: center; margin: 20px 0; padding: 28px; border-radius: var(--r-lg); border: 1px solid rgba(103, 232, 249, 0.16); background: radial-gradient(120% 140% at 100% 100%, rgba(8, 90, 110, 0.35), transparent 60%), var(--panel); }
@media (min-width: 900px) { .cg-band { grid-template-columns: auto 1fr auto; padding: 28px 32px; gap: 32px; } }
.cg-band-logo img { height: 52px; width: auto; display: block; }
.cg-band h2 { margin: 0 0 6px; font-size: 1.2rem; letter-spacing: -0.02em; }
.cg-band p { margin: 0; color: var(--muted); max-width: 40rem; }
.cg-band .btn { justify-self: start; white-space: nowrap; }
.footer-brand { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; color: var(--muted); line-height: 1.4; }
.footer-brand b { color: var(--text); font-weight: 650; }
.footer-brand img { border-radius: 8px; flex-shrink: 0; }
.toolbar .spacer { min-width: 12px; }
.swap-cta { flex-shrink: 0; white-space: nowrap; text-decoration: none; font-size: 0.82rem; font-weight: 700; color: var(--cta-text); background: var(--cta); padding: 6px 12px; border-radius: var(--r-sm); }
.swap-cta:hover { background: var(--cta-hover); }
.callout .swap-cta { display: inline-block; margin-top: 10px; }

/* ---------- theme toggle ---------- */
.theme-btn { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; flex-shrink: 0; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--panel-2); color: var(--muted); cursor: pointer; }
.theme-btn:hover { color: var(--text); border-color: var(--line-2); }
.theme-btn .i-sun { display: none; }
:root[data-theme="light"] .theme-btn .i-sun { display: block; }
:root[data-theme="light"] .theme-btn .i-moon { display: none; }

/* ---------- drawing tools ---------- */
.chart-row { flex: 1; min-height: 0; display: flex; }
.tools { width: 42px; flex-shrink: 0; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0; border-right: 1px solid var(--line); background: var(--panel); overflow-y: auto; }
.tools button { width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: var(--r-sm); background: none; color: var(--muted); cursor: pointer; }
.tools button:hover:not(:disabled) { color: var(--text); background: var(--panel-2); }
.tools button[aria-pressed="true"] { color: var(--accent); background: var(--accent-bg); }
.tools button:disabled { opacity: 0.35; cursor: default; }
.tools-sep { width: 22px; height: 1px; background: var(--line); margin: 6px 0; }
#chart.drawing { cursor: crosshair; }
.draw-hint { position: absolute; z-index: 6; left: 50%; bottom: 14px; transform: translateX(-50%); padding: 6px 12px; border-radius: 999px; font-size: 0.78rem; color: var(--text); background: var(--panel); border: 1px solid var(--line-2); box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25); pointer-events: none; white-space: nowrap; }
.draw-hint[hidden] { display: none; }
@media (max-width: 999px) { .chart-row { flex: none; } .tools { height: auto; } }
.toolbar .swap-cta { position: sticky; right: 0; box-shadow: -14px 0 12px var(--panel); }
