:root {
  --bg: #0a0a0a;
  --panel: #111110;
  --raise: #181817;
  --line: #222221;
  --ink: #f4f4f2;
  --muted: #8f8f8c;
  --faint: #4c4c4a;
  --up: #34d399;
  --down: #f87171;
  --r: 10px;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --disp: "Archivo", system-ui, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { color-scheme: dark; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

::selection { background: var(--ink); color: var(--bg); }

button, input, select {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
}

button { cursor: pointer; transition: transform 0.08s; }
button:active { transform: scale(0.96); }

:focus-visible { outline: 1px solid var(--ink); outline-offset: 2px; }

@keyframes fade { from { opacity: 0; } }
@keyframes fade-up { from { opacity: 0; transform: translateY(8px); } }
@keyframes fade-down { from { opacity: 0; transform: translateY(-8px); } }

.tape {
  overflow: hidden;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  white-space: nowrap;
  user-select: none;
  animation: fade 0.5s;
}

.tape-track {
  display: inline-flex;
  gap: 2.5rem;
  padding: 0.45rem 0;
  animation: tape-roll 90s linear infinite;
  will-change: transform;
}

.tape:hover .tape-track { animation-play-state: paused; }

@keyframes tape-roll {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

.tape-item { display: inline-flex; gap: 0.6rem; font-size: 11.5px; }
.tape-item .sym { color: var(--muted); }
.tape-item .px { color: var(--ink); }

.top {
  display: flex;
  align-items: center;
  gap: 2rem;
  padding: 1.2rem 1.5rem;
  animation: fade-down 0.35s both;
}

.brand { display: flex; align-items: baseline; gap: 0.75rem; }

.brand-mark {
  font-family: var(--disp);
  font-weight: 900;
  font-stretch: 120%;
  font-size: 1.55rem;
  letter-spacing: -0.03em;
  text-transform: lowercase;
}

.brand-sub { color: var(--faint); font-size: 11px; }

.tabs {
  display: flex;
  gap: 0.25rem;
  margin-left: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.25rem;
}

.tab {
  padding: 0.35rem 1rem;
  color: var(--muted);
  border-radius: 999px;
  transition: color 0.15s, background 0.15s, transform 0.08s;
}

.tab:hover { color: var(--ink); }
.tab.active { color: var(--bg); background: var(--ink); }

main { flex: 1; width: 100%; max-width: 980px; margin: 0 auto; padding: 1.25rem 1.5rem 2rem; }

.view { display: none; }
.view.active { display: block; animation: fade-up 0.25s ease-out; }

.toolbar { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; }

.search {
  flex: 0 1 230px;
  padding: 0.55rem 0.9rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  transition: border-color 0.15s, flex-basis 0.2s ease;
}

.search:focus { border-color: var(--faint); flex-basis: 290px; outline: none; }
.search::placeholder { color: var(--faint); }

.toolbar-note { color: var(--faint); font-size: 11px; }

.table-wrap {
  overflow-x: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: calc(var(--r) + 4px);
  padding: 0.4rem 0.9rem;
}

table { width: 100%; border-collapse: collapse; }

th {
  text-align: right;
  font-weight: 400;
  color: var(--faint);
  font-size: 11px;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--line);
}

th.col-name, th.col-rank { text-align: left; }

td {
  padding: 0.7rem 0.75rem;
  text-align: right;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

tbody tr:last-child td { border-bottom: none; }

td.col-rank { text-align: left; color: var(--faint); width: 2.5rem; }
td.col-name { text-align: left; }

.markets tbody tr, .holdings tbody tr { animation: fade-up 0.3s ease-out both; }

.markets tbody tr {
  cursor: pointer;
  transition: background 0.12s, transform 0.12s;
}

.markets tbody tr:hover { background: var(--raise); transform: translateX(3px); }
.markets tbody tr:active { transform: translateX(3px) scale(0.995); }

.coin-base { font-weight: 600; }
.coin-quote { color: var(--faint); font-size: 11px; margin-left: 0.35rem; }

.pct.up { color: var(--up); }
.pct.down { color: var(--down); }

td.col-spark { width: 110px; }
.spark { display: block; width: 100px; height: 28px; margin-left: auto; }

td.col-vol { color: var(--muted); }

@keyframes tick-up { 0% { color: var(--up); } 100% { color: var(--ink); } }
@keyframes tick-down { 0% { color: var(--down); } 100% { color: var(--ink); } }

td.price.flash-up { animation: tick-up 0.9s ease-out; }
td.price.flash-down { animation: tick-down 0.9s ease-out; }

.folio-hero {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 1.75rem 0;
}

.folio-label { color: var(--faint); font-size: 11px; }

.folio-value {
  font-family: var(--disp);
  font-weight: 900;
  font-stretch: 115%;
  font-size: clamp(2.2rem, 6vw, 3.4rem);
  letter-spacing: -0.02em;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
}

.folio-pnl { font-size: 13px; color: var(--muted); }
.folio-pnl.up { color: var(--up); }
.folio-pnl.down { color: var(--down); }

.holdings .col-x { width: 2rem; }

.remove {
  color: var(--faint);
  padding: 0.2rem 0.45rem;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s, transform 0.08s;
}

.remove:hover { color: var(--down); background: var(--raise); }

.empty { color: var(--faint); padding: 1.5rem 0.5rem; display: none; }
.empty.show { display: block; animation: fade 0.3s; }

.add-form {
  display: flex;
  gap: 0.5rem;
  margin-top: 1.25rem;
  flex-wrap: wrap;
}

.add-form select, .add-form input {
  padding: 0.55rem 0.9rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  min-width: 0;
  transition: border-color 0.15s;
}

.add-form select:focus, .add-form input:focus { border-color: var(--faint); outline: none; }
.add-form select { flex: 0 1 130px; }
.add-form input { flex: 0 1 180px; }
.add-form input::placeholder { color: var(--faint); }

.add-form button {
  padding: 0.55rem 1.2rem;
  border-radius: var(--r);
  background: var(--ink);
  color: var(--bg);
  font-weight: 600;
  transition: transform 0.12s, opacity 0.12s;
}

.add-form button:hover { opacity: 0.88; transform: translateY(-1px); }
.add-form button:active { transform: scale(0.97); }

.folio-note { color: var(--faint); font-size: 11px; margin-top: 1rem; }

.detail {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(440px, 100vw);
  background: var(--panel);
  border-left: 1px solid var(--line);
  padding: 1.5rem;
  transform: translateX(100%);
  transition: transform 0.24s cubic-bezier(0.3, 0, 0.15, 1);
  z-index: 20;
  overflow-y: auto;
}

.detail.open { transform: translateX(0); }

.detail.open > * { animation: fade-up 0.3s 0.08s ease-out both; }
.detail.open > .detail-head { animation-delay: 0.04s; }

.scrim {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 15;
  animation: fade 0.2s;
}

.detail-head { display: flex; justify-content: space-between; align-items: baseline; }

.detail-sym {
  font-family: var(--disp);
  font-weight: 900;
  font-stretch: 120%;
  font-size: 1.6rem;
  letter-spacing: -0.02em;
}

.detail-pair { color: var(--faint); font-size: 11px; margin-left: 0.5rem; }

.detail-close {
  color: var(--muted);
  font-size: 1.3rem;
  line-height: 1;
  padding: 0.25rem 0.55rem;
  border-radius: 8px;
  transition: color 0.15s, background 0.15s, transform 0.15s;
}

.detail-close:hover { color: var(--ink); background: var(--raise); transform: rotate(90deg); }

.detail-price { display: flex; align-items: baseline; gap: 0.75rem; margin: 1rem 0 1.25rem; }

.detail-last { font-size: 1.5rem; font-weight: 600; font-variant-numeric: tabular-nums; }

.detail-pct.up { color: var(--up); }
.detail-pct.down { color: var(--down); }

.tf { display: flex; gap: 0.25rem; margin-bottom: 1rem; }

.tf-btn {
  padding: 0.3rem 0.75rem;
  color: var(--muted);
  border-radius: 999px;
  font-size: 11.5px;
  transition: color 0.15s, background 0.15s, transform 0.08s;
}

.tf-btn:hover { color: var(--ink); background: var(--raise); }
.tf-btn.active { color: var(--bg); background: var(--ink); }

.chart-wrap { position: relative; height: 220px; }

#chart { width: 100%; height: 100%; display: block; cursor: crosshair; }

.chart-tip {
  position: absolute;
  pointer-events: none;
  background: var(--raise);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.35rem 0.6rem;
  font-size: 11px;
  white-space: nowrap;
  z-index: 5;
  animation: fade 0.15s;
}

.chart-tip .t { color: var(--muted); display: block; }

.detail-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin-top: 1.25rem;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.7rem 0.85rem;
  background: var(--raise);
  border: 1px solid var(--line);
  border-radius: var(--r);
  transition: border-color 0.15s, transform 0.15s;
}

.stat:hover { border-color: var(--faint); transform: translateY(-2px); }

.stat-label { color: var(--faint); font-size: 10.5px; }
.stat-val { font-variant-numeric: tabular-nums; }

.foot {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--line);
  color: var(--faint);
  font-size: 11px;
}

.foot a { color: var(--muted); text-decoration: none; transition: color 0.15s; }
.foot a:hover { color: var(--ink); }

@media (max-width: 640px) {
  .top { flex-wrap: wrap; gap: 0.75rem 1rem; padding: 1rem; }
  .tabs { margin-left: 0; order: 3; }
  main { padding: 1rem; }
  td, th { padding-left: 0.5rem; padding-right: 0.5rem; }
  .col-vol, td.col-vol { display: none; }
  .add-form select, .add-form input, .add-form button { flex: 1 1 100%; }
}

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