:root {
  --background: #f6f7f9;
  --surface: #ffffff;
  --border: #d9dde3;
  --text: #1b2330;
  --muted: #5b6676;
  --accent: #2456c9;
  --accent-text: #ffffff;
  --wallet: #1b2330;
  --source: #1f8a5b;
  --destination: #c2571a;
  --both: #7a4bc4;
  --edge: #8792a2;
  --highlight: #d4a106;
  --warning-surface: #fff6dc;
  --warning-border: #e2c463;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --background: #12161c;
    --surface: #1b2129;
    --border: #2f3844;
    --text: #e6eaf0;
    --muted: #9aa5b4;
    --accent: #6f9bff;
    --accent-text: #0e1420;
    --wallet: #e6eaf0;
    --source: #4fc48e;
    --destination: #f0935a;
    --both: #b08cf0;
    --edge: #7c8798;
    --highlight: #f2c94c;
    --warning-surface: #2e2a18;
    --warning-border: #6d5f24;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--background);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

h1 {
  margin: 0 0 12px;
  font-size: 20px;
}

h2 {
  margin: 0 0 8px;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.top {
  padding: 16px 20px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.lookup {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
}

.lookup label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: var(--muted);
}

.lookup .grow {
  flex: 1 1 320px;
}

input[type="text"],
select {
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--background);
  color: var(--text);
  font: inherit;
}

input[type="text"] {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 14px;
}

button {
  height: 38px;
  padding: 0 14px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: var(--accent-text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

button.secondary {
  background: transparent;
  color: var(--accent);
}

button.small {
  height: 30px;
  padding: 0 10px;
  font-size: 13px;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
.clickable li:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.top[hidden] {
  display: none;
}

.account {
  margin: 0 0 14px;
  padding: 0 0 12px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.account-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  align-items: flex-end;
}

.account-row + .account-row {
  margin-top: 8px;
  align-items: center;
}

.account-row[hidden],
.account [hidden] {
  display: none;
}

.account label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: var(--muted);
}

.account label.check {
  flex-direction: row;
  align-items: center;
  gap: 6px;
  color: var(--text);
}

.account input[type="email"] {
  min-width: 260px;
}

.account .status {
  margin-top: 6px;
}

.saved {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.saved li {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.saved button {
  height: 28px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--accent);
  font-size: 12.5px;
  font-weight: 500;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
}

.saved button.remove {
  border-left: 1px solid var(--border);
  color: var(--muted);
  font-family: inherit;
}

button.danger {
  border-color: var(--destination);
  color: var(--destination);
}

#confirm-header .lead {
  max-width: 70ch;
  margin: 0 0 14px;
}

.sample-intro h1 {
  font-size: 24px;
  max-width: 34ch;
}

.sample-intro .lead {
  max-width: 78ch;
  margin: 0 0 14px;
}

.sample-intro .muted {
  max-width: 78ch;
  margin-top: 8px;
}

.sample-flag {
  display: inline-block;
  margin: 0 0 10px;
  padding: 2px 10px;
  border: 1px solid var(--warning-border);
  border-radius: 12px;
  background: var(--warning-surface);
  font-size: 13px;
  font-weight: 600;
}

/* A field people never see. Automated form-fillers fill it in and give
   themselves away. */
.trap {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

input[type="email"] {
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--background);
  color: var(--text);
  font: inherit;
}

.status.success {
  color: var(--source);
  font-weight: 600;
}

.status {
  margin: 10px 0 0;
  color: var(--muted);
}

.status.error {
  color: var(--destination);
  font-weight: 600;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 16px;
  padding: 16px 20px 24px;
  align-items: start;
}

.layout[hidden] {
  display: none;
}

.map-area {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  min-width: 0;
}

.map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 8px;
}

.map-legend button:first-of-type {
  margin-left: auto;
}

.swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 6px;
}

.swatch.source {
  background: var(--source);
}

.swatch.destination {
  background: var(--destination);
}

.swatch.both {
  background: var(--both);
}

.swatch.wallet {
  background: var(--wallet);
}

.map {
  position: relative;
  height: 62vh;
  min-height: 420px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--background);
}

.note {
  margin: 0 0 8px;
  padding: 8px 10px;
  border: 1px solid var(--warning-border);
  border-radius: 6px;
  background: var(--warning-surface);
  font-size: 13px;
}

.timeline {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 10px;
}

.timeline input[type="range"] {
  flex: 1;
  accent-color: var(--accent);
}

.timeline output {
  min-width: 230px;
  font-size: 13px;
  color: var(--muted);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.side {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
}

.panel.always {
  border-color: var(--warning-border);
  background: var(--warning-surface);
}

.panel h2:not(:first-child) {
  margin-top: 12px;
}

.facts {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 12px;
  margin: 0;
  font-size: 14px;
}

.facts dt {
  color: var(--muted);
}

.facts dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
}

.plain {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 14px;
}

.plain li {
  padding: 5px 0;
  border-top: 1px solid var(--border);
  overflow-wrap: anywhere;
}

.plain li:first-child {
  border-top: 0;
}

.clickable li {
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 4px;
}

.clickable li:hover {
  background: var(--background);
}

.clickable li.active {
  background: var(--background);
  box-shadow: inset 3px 0 0 var(--highlight);
}

.pnl-total {
  margin: 0 0 4px;
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.gain {
  color: var(--source);
}

.loss {
  color: var(--destination);
}

.pnl-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-variant-numeric: tabular-nums;
}

.pnl-row strong {
  white-space: nowrap;
}

.notes {
  margin-top: 8px;
  font-size: 13px;
  color: var(--muted);
}

.notes summary {
  cursor: pointer;
}

.muted {
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 6px;
}

.mono {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 12.5px;
  overflow-wrap: anywhere;
}

.evidence {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-top: 6px;
}

.evidence th,
.evidence td {
  text-align: left;
  padding: 4px 6px 4px 0;
  border-top: 1px solid var(--border);
  vertical-align: top;
}

.evidence th {
  color: var(--muted);
  font-weight: 600;
  border-top: 0;
}

.evidence td.amount {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

a {
  color: var(--accent);
}

.tag {
  display: inline-block;
  padding: 0 6px;
  margin-right: 4px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 12px;
  color: var(--muted);
}

@media (max-width: 980px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .timeline output {
    min-width: 0;
  }
}

/* ---------------------------------------------------------------- extra views */

.view-switch {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.view-switch button.active {
  background: var(--accent);
  color: var(--accent-text);
}

#map-view[hidden],
#other-view[hidden] {
  display: none;
}

.asset-pick {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.asset-pick select {
  height: 30px;
  max-width: 220px;
}

.muted-inline {
  flex-basis: 100%;
}

.views {
  min-height: 420px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--background);
  padding: 10px;
  overflow-x: auto;
}

.view-drawing {
  display: block;
  min-width: 640px;
}

.view-drawing text {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.view-name {
  fill: var(--text);
  font-size: 14px;
  font-weight: 600;
}

.view-detail {
  fill: var(--muted);
  font-size: 12.5px;
}

.view-wallet {
  fill: var(--wallet);
}

.view-node.in,
.view-bar.in {
  fill: var(--source);
}

.view-node.out,
.view-bar.out {
  fill: var(--destination);
}

.view-ribbon {
  opacity: 0.45;
  transition: opacity 0.15s;
}

.view-ribbon.in {
  fill: var(--source);
}

.view-ribbon.out {
  fill: var(--destination);
}

.view-ribbon.others,
.view-spoke.others,
.rank-fill.others {
  fill: var(--edge);
  stroke: var(--edge);
  background: var(--edge);
}

.view-spoke {
  stroke-linecap: round;
  opacity: 0.5;
  transition: opacity 0.15s;
}

.view-spoke.in {
  stroke: var(--source);
}

.view-spoke.out {
  stroke: var(--destination);
}

.view-axis {
  stroke: var(--muted);
  stroke-width: 1;
}

.view-grid {
  stroke: var(--border);
  stroke-dasharray: 3 3;
}

.view-target {
  cursor: pointer;
  outline: none;
}

.view-ribbon.view-target:hover,
.view-ribbon.view-target:focus-visible,
.view-spoke.view-target:hover,
.view-spoke.view-target:focus-visible {
  opacity: 0.85;
}

.view-bar.view-target:hover,
.view-bar.view-target:focus-visible,
.view-node.view-target:hover,
.view-node.view-target:focus-visible {
  stroke: var(--highlight);
  stroke-width: 2;
}

.view-empty {
  padding: 20px;
}

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

.rank h3 {
  margin: 0 0 8px;
  font-size: 14px;
}

.rank-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.rank-row {
  display: grid;
  grid-template-columns: minmax(0, 150px) minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 5px 6px;
  border-radius: 4px;
  font-size: 13px;
}

.rank-row:hover,
.rank-row:focus-visible {
  background: var(--surface);
  box-shadow: inset 3px 0 0 var(--highlight);
}

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

.rank-track {
  display: block;
  height: 12px;
}

.rank-fill {
  display: block;
  height: 100%;
  border-radius: 2px;
}

.rank-fill.in {
  background: var(--source);
}

.rank-fill.out {
  background: var(--destination);
}

.rank-amount {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: var(--muted);
}

.caution {
  margin: 0 0 0.6rem;
  padding: 0.5rem 0.65rem;
  border-left: 3px solid #b7791f;
  background: #fdf6e3;
  color: #5c4310;
  font-size: 0.9rem;
}

/* ---- staking panel ---- */

.staking-headline {
  margin: 0 0 8px;
  font-weight: 600;
}

.milestones {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 10px;
  padding: 0;
  list-style: none;
}

.milestones li {
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12px;
}

.milestones li.milestone-reached {
  border-color: var(--source);
  color: var(--source);
  font-weight: 600;
}

.milestones li.milestone-not_reached,
.milestones li.milestone-not_assessed {
  color: var(--muted);
}

.staking-main .clickable li:not([data-staking]) {
  cursor: default;
}

.staking-timeline {
  margin: 0 0 10px;
}

.staking-strip {
  display: block;
  width: 100%;
  height: 18px;
}

.strip-back {
  fill: var(--background);
  stroke: var(--border);
}

.strip-bar {
  fill: var(--edge);
}

.strip-bar.open {
  fill: var(--source);
}

.strip-labels {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
}

/* ---- page links and the staking page ---- */

.page-nav {
  display: flex;
  gap: 14px;
  margin: 0 0 8px;
  font-size: 13px;
}

.page-nav [aria-current="page"] {
  font-weight: 600;
}

.staking-main {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.staking-main .staking-headline {
  font-size: 18px;
}

.staking-main .staking-strip {
  height: 28px;
}

.staking-tokens > li + li {
  margin-top: 10px;
}
