:root {
  --bg: #050505;
  --panel: #0d0d0d;
  --panel-2: #151515;
  --panel-3: #1f1f1f;
  --border: #2a2a2a;
  --border-strong: #3a3a3a;
  --text: #eeeeee;
  --text-muted: #9a9a9a;
  --text-soft: #6f6f6f;
  --yellow: #f5c84b;
  --yellow-soft: #3a300f;
  --danger: #ff6b6b;
  --ok: #d8d8d8;
  --fast: 120ms;
  --normal: 180ms;
  --slow: 260ms;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

* {
  box-sizing: border-box;
}

html,
body,
#app {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "IBM Plex Mono", "Geist Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  letter-spacing: 0;
  overflow-x: hidden;
}

.motion-canvas {
  position: fixed;
  inset: 0;
  z-index: 0;
  width: 100vw;
  height: 100vh;
  opacity: 0.86;
  pointer-events: none;
}

button,
input,
select {
  font: inherit;
  letter-spacing: 0;
}

button,
a,
summary,
input,
select {
  outline: none;
}

button:focus-visible,
a:focus-visible,
summary:focus-visible,
input:focus-visible,
select:focus-visible {
  box-shadow: 0 0 0 2px var(--yellow-soft), 0 0 0 3px var(--yellow);
}

a {
  color: inherit;
  text-decoration: none;
}

.app {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  padding-bottom: 64px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(120px, 1fr) auto minmax(340px, 1fr);
  gap: 16px;
  align-items: center;
  min-height: 56px;
  padding: 0 18px;
  border-bottom: 1px solid var(--border);
  background: rgba(5, 5, 5, 0.96);
}

.wordmark {
  color: var(--yellow);
  font-weight: 700;
  font-size: 15px;
}

.primary-nav,
.bottom-nav {
  display: flex;
  align-items: center;
  gap: 6px;
}

.primary-nav {
  position: relative;
}

.nav-mode {
  position: absolute;
  right: calc(100% + 14px);
  width: 248px;
  margin-right: 0;
}

.nav-mode .segmented {
  width: 100%;
}

.primary-nav a,
.bottom-nav a {
  position: relative;
  padding: 10px 12px;
  color: var(--text-muted);
  transition: color var(--fast) var(--ease), background var(--fast) var(--ease);
}

.primary-nav a.active,
.bottom-nav a.active {
  color: var(--text);
}

.primary-nav a.active::after,
.bottom-nav a.active::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 4px;
  height: 2px;
  background: var(--yellow);
}

.top-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
}

.bottom-nav {
  display: none;
}

.content {
  width: min(1120px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 22px 0 40px;
}

.page {
  display: grid;
  gap: 14px;
}

.enter {
  animation: enter var(--slow) var(--ease);
}

@keyframes enter {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  padding: 4px 0 8px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
  line-height: 1.15;
}

h2 {
  font-size: 14px;
  line-height: 1.2;
}

.page-head p,
.muted,
.field-hint,
.empty p,
.error-text,
.position span,
small {
  color: var(--text-muted);
}

.layout {
  display: grid;
  gap: 14px;
}

.layout.two {
  grid-template-columns: minmax(0, 1.05fr) minmax(320px, 0.95fr);
  align-items: start;
}

.layout.trade {
  grid-template-columns: minmax(280px, 0.8fr) minmax(0, 1.2fr);
}

.layout.settle {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: start;
}

.stack {
  display: grid;
  gap: 14px;
}

.panel,
.notice {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
  padding: 14px;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.panel-title span,
.network,
.status {
  color: var(--text-muted);
  font-size: 11px;
}

.panel-title-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.status {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 7px;
}

.status.active,
.network.ok,
.ok-text {
  color: var(--yellow);
}

.status.settled {
  color: var(--text);
}

.network.warn,
.warn-text,
.error-text {
  color: var(--danger);
}

.network-button {
  min-height: 0;
  border: 0;
  background: transparent;
  padding: 0;
}

.network-button:hover:not(:disabled) {
  transform: none;
  filter: brightness(1.25);
}

.form-grid {
  display: grid;
  gap: 12px;
  align-items: start;
}

.form-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.form-grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.series-panel .form-grid {
  align-items: start;
}

.series-panel .field,
.series-panel .metric,
.series-panel input {
  min-width: 0;
}

.series-datetime-grid {
  grid-template-columns: minmax(110px, 0.8fr) minmax(220px, 1.2fr);
}

.series-datetime-grid .series-trailing {
  grid-column: 1 / -1;
}

.field {
  display: grid;
  gap: 6px;
}

.field-label {
  min-height: 14px;
  color: var(--text-muted);
  font-size: 11px;
}

.label-with-info {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.info-icon {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 15px;
  height: 15px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  color: var(--yellow);
  font-size: 10px;
  line-height: 1;
  cursor: help;
}

.tooltip {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  z-index: 50;
  width: min(280px, 70vw);
  padding: 9px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--panel-3);
  color: var(--text);
  font-size: 11px;
  line-height: 1.4;
  transform: translateX(-50%) translateY(3px);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--fast) var(--ease), transform var(--fast) var(--ease);
}

.info-icon:hover .tooltip,
.info-icon:focus .tooltip {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

input,
select {
  width: 100%;
  min-height: 38px;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0 10px;
  transition: border-color var(--fast) var(--ease), background var(--fast) var(--ease);
}

input:focus,
select:focus {
  background: var(--panel-3);
  border-color: var(--yellow);
}

.amount-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
}

.token {
  min-width: 48px;
  color: var(--text-muted);
}

.button,
button {
  min-height: 34px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--text);
  padding: 0 11px;
  cursor: pointer;
  transition: transform var(--fast) var(--ease), filter var(--fast) var(--ease), border-color var(--fast) var(--ease), background var(--fast) var(--ease);
}

.button:hover:not(:disabled),
button:hover:not(:disabled) {
  filter: brightness(1.18);
  transform: translateY(-1px);
}

.button:active:not(:disabled),
button:active:not(:disabled) {
  transform: translateY(0);
}

button:disabled {
  cursor: not-allowed;
  color: var(--text-soft);
  filter: grayscale(1);
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  min-height: 0;
  border: 0;
  background: transparent;
  padding: 0;
  color: var(--text-muted);
  font-size: 18px;
  line-height: 1;
}

.icon-button:hover:not(:disabled) {
  color: var(--yellow);
  background: transparent;
  transform: none;
}

.refresh-icon.spinning {
  animation: spin var(--slow) linear infinite;
}

.button.primary {
  color: #080808;
  background: var(--yellow);
  border-color: var(--yellow);
  font-weight: 700;
}

.button.full {
  width: 100%;
}

.segmented {
  --count: 2;
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--count), minmax(0, 1fr));
  gap: 0;
  min-width: 188px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel-2);
  padding: 3px;
  overflow: hidden;
}

.segmented button {
  position: relative;
  z-index: 2;
  min-height: 28px;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  padding: 0 10px;
}

.segmented button.selected {
  color: var(--yellow);
}

.segmented-indicator {
  position: absolute;
  z-index: 1;
  top: 3px;
  bottom: 3px;
  left: calc(3px + ((100% - 6px) / var(--count)) * var(--index));
  width: calc((100% - 6px) / var(--count));
  border: 1px solid var(--yellow-soft);
  border-radius: 4px;
  background: #171407;
  transition: left var(--normal) var(--ease);
}

.market-filter-grid .field,
.market-filter-grid .segmented {
  min-width: 0;
  width: 100%;
}

.receive-box,
.estimate,
.empty,
.inline-drawer,
.encrypted-line,
.balance-card,
.metric {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel-2);
}

.receive-box {
  display: grid;
  gap: 9px;
  margin-top: 12px;
  padding: 12px;
}

.active-series-panel {
  margin-top: 14px;
}

.active-series-list {
  display: grid;
  gap: 8px;
}

.active-series-row {
  display: grid;
  grid-template-columns: minmax(100px, 0.7fr) minmax(180px, 1.2fr) minmax(160px, 1fr) minmax(90px, 0.55fr);
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 0;
  padding: 10px;
  border-color: var(--border);
  background: var(--panel-2);
  text-align: left;
}

.active-series-row.selected {
  border-color: var(--yellow-soft);
  background: #171407;
}

.active-series-row.invalid {
  border-color: rgba(255, 107, 107, 0.35);
}

.active-series-row > span {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.active-series-row small {
  color: var(--text-muted);
}

.active-series-row strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.active-series-error {
  grid-column: 1 / -1;
}

.receive-box > div,
.estimate > div,
.encrypted-line {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.receive-box span,
.estimate span,
.metric span,
.balance-card span {
  color: var(--text-muted);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.details {
  margin-top: 12px;
  color: var(--text-muted);
}

summary {
  cursor: pointer;
}

.details-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding-top: 10px;
}

.detail {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.detail span {
  color: var(--text-soft);
  font-size: 11px;
}

.copy {
  min-height: 0;
  height: auto;
  border: 0;
  background: transparent;
  padding: 0;
  color: var(--text);
  text-align: left;
}

.metric,
.balance-card,
.empty,
.inline-drawer {
  padding: 12px;
}

.metric {
  display: grid;
  gap: 6px;
}

.series-metric {
  min-height: 38px;
  align-content: center;
}

.payout-grid,
.balance-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}

.payout-grid > div {
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel-2);
}

.payout-grid span {
  color: var(--text-muted);
}

.payout-grid small {
  color: var(--text-muted);
  font-size: 11px;
}

.drawer-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.encrypted-line {
  align-items: center;
  padding: 9px;
  flex-wrap: wrap;
}

.encrypted-line .reveal-error {
  flex-basis: 100%;
}

.reveal-card .button {
  justify-self: start;
}

.reveal-error {
  color: #ff8b8b;
}

.masked {
  color: var(--text-soft);
  animation: pulse var(--slow) var(--ease);
}

.revealed,
.flash {
  color: var(--yellow);
}

.error-line {
  border-color: rgba(255, 107, 107, 0.35);
}

@keyframes pulse {
  50% {
    opacity: 0.55;
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.notice {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  border-color: var(--yellow-soft);
  background: #0f0d06;
}

.market {
  min-width: 0;
}

.trade-list {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.trade-row {
  display: grid;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel-2);
  padding: 12px;
}

.trade-row.selected {
  border-color: var(--yellow);
}

.trade-row-main,
.trade-row-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.trade-row-main {
  justify-content: space-between;
}

.trade-row-main p {
  margin: 4px 0 0;
  color: var(--text-muted);
}

.trade-row-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.trade-details,
.trade-form,
.trade-fill {
  margin-top: 8px;
}

.trade-form .field:last-child {
  grid-column: 1 / -1;
}

table {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 6px;
}

th,
td {
  padding: 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 400;
  background: var(--panel-2);
}

tr {
  transition: background var(--fast) var(--ease);
}

tbody tr:hover {
  background: var(--yellow-soft);
}

.compact {
  margin-top: 10px;
  padding: 10px;
}

.balance-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.balance-card {
  display: grid;
  gap: 7px;
}

.position-list {
  display: grid;
  gap: 10px;
}

.position {
  display: grid;
  grid-template-columns: 1.1fr 1fr 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel-2);
}

.position > div {
  display: grid;
  gap: 4px;
}

.row-details {
  grid-column: 1 / -1;
  margin: 0;
}

.tx-panel {
  position: relative;
  overflow: hidden;
}

.tx-steps {
  display: grid;
  gap: 0;
  padding: 0;
  margin: 0;
  list-style: none;
}

.tx-steps li {
  position: relative;
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 8px;
  padding: 7px 0;
}

.tx-steps li::before {
  content: "";
  position: absolute;
  left: 6px;
  top: 20px;
  bottom: -8px;
  width: 1px;
  background: var(--border-strong);
}

.tx-steps li:last-child::before {
  display: none;
}

.dot {
  width: 13px;
  height: 13px;
  margin-top: 2px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--panel-3);
}

.tx-steps .submitted .dot,
.tx-steps .pending .dot {
  border-color: var(--yellow);
  animation: pulse var(--slow) var(--ease) infinite;
}

.tx-steps .confirmed .dot {
  background: var(--yellow);
  border-color: var(--yellow);
}

.tx-steps .failed .dot {
  background: var(--danger);
  border-color: var(--danger);
}

.tx-link {
  color: var(--yellow);
}

.footer-tools {
  margin-top: 20px;
  color: var(--text-muted);
}

.api-config {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  align-items: center;
  max-width: 100%;
  margin-top: 10px;
}

.api-config small,
.config-actions {
  grid-column: 1 / -1;
}

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

.loader {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 30;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel-2);
  padding: 10px 12px;
  color: var(--text-muted);
}

.toast {
  position: fixed;
  right: 16px;
  top: 72px;
  z-index: 40;
  max-width: min(420px, calc(100vw - 32px));
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--yellow);
  border-radius: 6px;
  background: var(--panel-2);
  padding: 12px;
  animation: toast var(--normal) var(--ease);
}

@keyframes toast {
  from {
    opacity: 0;
    transform: translateX(8px);
  }
}

@media (max-width: 860px) {
  .topbar {
    grid-template-columns: 1fr auto;
  }

  .primary-nav,
  .network {
    display: none;
  }

  .bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 25;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    border-top: 1px solid var(--border);
    background: rgba(5, 5, 5, 0.98);
  }

  .bottom-nav a {
    text-align: center;
  }

  .content {
    width: min(100% - 20px, 720px);
    padding-top: 14px;
  }

  .page-head {
    display: grid;
    align-items: start;
  }

  .layout.two,
  .layout.trade,
  .layout.settle,
  .form-grid.three,
  .active-series-row,
  .api-config,
  .balance-grid,
  .payout-grid {
    grid-template-columns: 1fr;
  }

  .position {
    grid-template-columns: 1fr;
  }

  table {
    display: block;
    overflow-x: auto;
  }
}

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