@font-face {
  font-family: 'Bricolage Grotesque';
  src: url('/vendor/bricolage.woff2') format('woff2');
  font-weight: 200 800;
  font-display: swap;
}

:root {
  --ink: #0b0f14;
  --surface: #121821;
  --raised: #19212c;
  --line: #232d3a;
  --bone: #ede8dc;
  --slate: #8a93a0;
  --dim: #626c7a;
  --amber: #f2b33d;
  --teal: #4cc9c0;
  --up: #5bc08a;
  --down: #e66767;
  --display: 'Bricolage Grotesque', ui-sans-serif, system-ui, sans-serif;
  --body: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--ink);
  color: var(--bone);
  font: 15px/1.5 var(--body);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0 auto;
  max-width: 1180px;
  padding: 0 28px 96px;
}

h1,
h2,
p,
ul,
dl,
dd {
  margin: 0;
  padding: 0;
}

ul {
  list-style: none;
}

button,
input {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
  border-radius: 6px;
}

.num {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

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

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

.muted {
  color: var(--slate);
}

/* ── Top bar ─────────────────────────────────────────────── */

.top {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 20px 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 1px;
  font: 650 19px/1 var(--display);
  letter-spacing: -0.02em;
  text-decoration: none;
  color: var(--amber);
}

.brand img {
  margin-right: 10px;
  border-radius: 7px;
}

.brand span + span {
  color: var(--slate);
}

.sources {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin-left: auto;
  font-size: 13px;
  color: var(--slate);
}

.sources li {
  display: flex;
  align-items: center;
  gap: 6px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--teal);
  flex: none;
}

.dot.stale {
  background: var(--amber);
}

.dot.never {
  background: var(--dim);
}

.sources .state {
  color: var(--amber);
}

.button {
  border: 1px solid var(--line);
  background: var(--raised);
  border-radius: 9px;
  padding: 8px 14px;
  cursor: pointer;
  white-space: nowrap;
}

.button:hover {
  border-color: var(--slate);
}

.button:disabled {
  color: var(--slate);
  cursor: progress;
}

.link {
  border: 0;
  background: none;
  padding: 0;
  color: var(--slate);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.link:hover {
  color: var(--bone);
}

/* ── Summary ─────────────────────────────────────────────── */

main > section {
  margin-top: 56px;
}

main > .summary {
  margin-top: 28px;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px 48px;
}

.worth h1 {
  font: 400 15px/1.4 var(--body);
  color: var(--slate);
}

.worth-value {
  font: 600 clamp(44px, 8vw, 84px) / 1 var(--display);
  letter-spacing: -0.035em;
  font-variant-numeric: tabular-nums;
  margin: 6px 0 10px -3px;
}

.worth-value .cents {
  color: var(--slate);
  font-weight: 400;
}

.worth-meta {
  font-size: 13px;
  color: var(--slate);
}

.facts {
  display: flex;
  flex-wrap: wrap;
  gap: 18px 36px;
  padding-bottom: 6px;
}

.facts dt {
  font-size: 13px;
  color: var(--slate);
}

.facts dd {
  font: 500 22px/1.3 var(--display);
  font-variant-numeric: tabular-nums;
}

.facts dd small {
  font: 400 13px var(--body);
  color: var(--slate);
  margin-left: 6px;
}

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 20px;
  margin-bottom: 16px;
}

h2 {
  font: 600 22px/1.2 var(--display);
  letter-spacing: -0.015em;
}

.segmented {
  display: flex;
  max-width: 100%;
  overflow-x: auto;
  gap: 2px;
  padding: 3px;
  border-radius: 10px;
  background: var(--surface);
}

.segmented button {
  flex: none;
  border: 0;
  background: none;
  border-radius: 7px;
  padding: 5px 12px;
  font-size: 13px;
  color: var(--slate);
  cursor: pointer;
}

.segmented button:hover {
  color: var(--bone);
}

.segmented button[aria-pressed='true'] {
  background: var(--raised);
  color: var(--bone);
  box-shadow: inset 0 0 0 1px var(--line);
}

/* ── Allocation strip: the logo's stacked bars, laid end to end ───────── */

.strip {
  display: flex;
  gap: 2px;
  height: 44px;
}

.strip span {
  min-width: 3px;
  border-radius: 5px;
  transition: opacity 0.12s;
}

.strip span:first-child {
  border-radius: 22px 5px 5px 22px;
}

.strip span:last-child {
  border-radius: 5px 22px 22px 5px;
}

.strip span:only-child {
  border-radius: 22px;
}

.strip.focus span:not(.on),
.legend.focus li:not(.on) {
  opacity: 0.3;
}

.allocation {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
  gap: 24px 56px;
  margin-top: 20px;
}

.legend {
  columns: 2;
  column-gap: 40px;
}

.legend li {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr) auto 52px;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  break-inside: avoid;
  transition: opacity 0.12s;
}

.legend .name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.legend .share {
  text-align: right;
  color: var(--slate);
}

.swatch {
  width: 12px;
  height: 12px;
  border-radius: 4px;
  flex: none;
}

.notes h3 {
  font: 400 13px/1.4 var(--body);
  color: var(--slate);
  margin: 0 0 6px;
}

.notes ol {
  margin: 0 0 20px;
  padding: 0;
  list-style: none;
}

.notes ol li {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 4px 0;
}

.notes .stable {
  font: 500 22px/1.3 var(--display);
}

/* ── History ─────────────────────────────────────────────── */

.chart {
  height: 320px;
}

.empty {
  padding: 28px 24px;
  border: 1px dashed var(--line);
  border-radius: 14px;
  color: var(--slate);
  max-width: 62ch;
}

/* ── Positions ───────────────────────────────────────────── */

.table-wrap {
  overflow-x: auto;
}

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

th,
td {
  padding: 11px 12px;
  text-align: right;
  border-bottom: 1px solid var(--line);
}

th:first-child,
td:first-child {
  text-align: left;
  padding-left: 0;
}

th:last-child,
td:last-child {
  padding-right: 0;
}

th {
  font-weight: 400;
  font-size: 13px;
  color: var(--slate);
  white-space: nowrap;
}

th button {
  border: 0;
  background: none;
  padding: 0;
  color: inherit;
  cursor: pointer;
}

th button:hover,
th[aria-sort] button {
  color: var(--bone);
}

.asset {
  display: flex;
  align-items: center;
  gap: 10px;
}

.asset button {
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
  text-align: left;
  font-weight: 600;
}

.asset .category {
  color: var(--slate);
  font-size: 13px;
}

.chevron {
  width: 16px;
  color: var(--dim);
  transition: transform 0.15s;
}

tr[aria-expanded='true'] .chevron {
  transform: rotate(90deg);
}

.share-cell {
  display: inline-grid;
  grid-template-columns: 48px 46px;
  align-items: center;
  gap: 8px;
}

.share-bar {
  height: 6px;
  border-radius: 3px;
  background: var(--raised);
  overflow: hidden;
}

.share-bar i {
  display: block;
  height: 100%;
  border-radius: 3px;
  background: var(--bone);
}

.places td {
  padding: 0 0 14px 26px;
  border-bottom: 1px solid var(--line);
}

.places table {
  background: var(--surface);
  border-radius: 10px;
}

.places th,
.places td td {
  padding: 8px 14px;
  border-bottom: 0;
  font-size: 13.5px;
}

.places th:first-child,
.places td td:first-child {
  padding-left: 14px;
}

.places th:last-child,
.places td td:last-child {
  padding-right: 14px;
}

.places th:nth-child(-n + 3),
.places td td:nth-child(-n + 3) {
  text-align: left;
}

/* ── Heat and signals ────────────────────────────────────── */

:root {
  --overheated: #ff7a52;
}

.heat {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 2px 9px 2px 8px;
  border-radius: 999px;
  font-size: 13px;
  white-space: nowrap;
  box-shadow: inset 0 0 0 1px var(--line);
}

.heat b {
  font-weight: 600;
}

.heat::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  align-self: center;
  background: var(--bone);
}

.heat.cold::before {
  background: var(--teal);
}

.heat.warm::before {
  background: var(--amber);
}

.heat.overheated {
  box-shadow: inset 0 0 0 1px var(--overheated);
}

.heat.overheated::before {
  background: var(--overheated);
}

.signals {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px 56px;
}

.signals h3 {
  margin: 0 0 4px;
  font: 400 13px/1.4 var(--body);
  color: var(--slate);
}

.signals li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px 16px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}

.signals .who {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.signals li p {
  grid-column: 1 / -1;
  font-size: 13px;
}

.signals-note {
  margin-top: 16px;
  font-size: 13px;
  color: var(--slate);
  max-width: 78ch;
}

/* ── DeFi ────────────────────────────────────────────────── */

.protocol {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(0, 3fr);
  gap: 8px 32px;
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
}

.protocol h3 {
  margin: 0;
  font: 600 16px/1.4 var(--body);
}

.protocol .where {
  color: var(--slate);
  font-size: 13px;
}

.protocol .total {
  font: 500 20px/1.4 var(--display);
}

.protocol li {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr) auto auto;
  gap: 16px;
  padding: 4px 0;
}

.protocol li .kind {
  color: var(--slate);
}

/* ── Wallets ─────────────────────────────────────────────── */

.wallets li {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) 70px minmax(0, 1fr) 110px 250px;
  align-items: center;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.wallets .label {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wallets .problem {
  grid-column: 1 / -1;
  color: var(--amber);
  font-size: 13px;
  margin-top: -6px;
}

.wallets li > .num {
  text-align: right;
}

.wallets .actions {
  display: flex;
  gap: 14px;
  justify-content: flex-end;
}

.wallets input {
  width: 100%;
}

.add-wallet {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 1.2fr) auto;
  align-items: end;
  gap: 12px;
  margin-top: 20px;
}

.add-wallet label span {
  display: block;
  font-size: 13px;
  color: var(--slate);
  margin-bottom: 5px;
}

input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 8px 12px;
}

input::placeholder {
  color: var(--dim);
}

.form-error {
  grid-column: 1 / -1;
  color: var(--down);
}

/* ── Sign in ─────────────────────────────────────────────── */

.login-page {
  max-width: 400px;
  padding-top: 14vh;
}

.login h1 {
  font: 600 30px/1.2 var(--display);
  letter-spacing: -0.02em;
  margin: 40px 0 24px;
}

.login label {
  display: block;
  margin-bottom: 16px;
}

.login label span {
  display: block;
  font-size: 13px;
  color: var(--slate);
  margin-bottom: 5px;
}

.login .lead {
  color: var(--slate);
  margin: -12px 0 24px;
}

.login small {
  display: block;
  font-size: 13px;
  color: var(--dim);
  margin-top: 5px;
}

.login .qr {
  display: block;
  width: 220px;
  height: 220px;
  border-radius: 12px;
  margin: 0 0 16px;
}

.login .key span {
  display: block;
  font-size: 13px;
  color: var(--slate);
}

.login .key code {
  display: block;
  font:
    500 15px/1.6 ui-monospace,
    SFMono-Regular,
    Menlo,
    monospace;
  letter-spacing: 0.04em;
  margin: 2px 0 20px;
  overflow-wrap: anywhere;
  user-select: all;
}

.login .link {
  display: block;
  margin: 16px auto 0;
}

.login [hidden] {
  display: none;
}

.login input {
  padding: 11px 12px;
  font-size: 16px;
}

.login .button {
  width: 100%;
  margin-top: 8px;
  padding: 11px 14px;
}

.button.primary {
  background: var(--amber);
  border-color: var(--amber);
  color: var(--ink);
  font-weight: 600;
}

.button.primary:hover {
  filter: brightness(1.08);
}

.button.primary:disabled {
  filter: saturate(0.4);
  color: var(--ink);
}

.login .form-error {
  margin-top: 16px;
}

/* ── Tooltip ─────────────────────────────────────────────── */

.tip {
  position: fixed;
  z-index: 10;
  pointer-events: none;
  background: var(--raised);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 8px 12px;
  font-size: 13px;
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.4);
}

.tip b {
  display: block;
  font-weight: 600;
}

/* ── Small screens ───────────────────────────────────────── */

@media (max-width: 760px) {
  body {
    padding: 0 16px 64px;
  }

  .top {
    flex-wrap: wrap;
    gap: 12px;
  }

  .sources {
    order: 3;
    width: 100%;
    margin-left: 0;
  }

  .top .button {
    margin-left: auto;
  }

  main > section {
    margin-top: 44px;
  }

  .allocation,
  .signals,
  .protocol,
  .add-wallet {
    grid-template-columns: minmax(0, 1fr);
  }

  .legend {
    columns: 1;
  }

  .strip {
    height: 36px;
  }

  .chart {
    height: 260px;
  }

  .optional,
  .share-bar {
    display: none;
  }

  .share-cell {
    display: inline;
  }

  th,
  td {
    padding: 11px 8px;
  }

  .wallets li {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .wallets .address,
  .wallets .kind {
    display: none;
  }

  .wallets li > .num {
    text-align: right;
  }

  .wallets .actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }
}

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