:root {
  --bg: #0a0b0d;
  --panel: #12141a;
  --panel2: #181b24;
  --line: #2a2f3d;
  --text: #e8eaf0;
  --muted: #8b92a5;
  --accent: #6ee7b7;
  --accent2: #a78bfa;
  --warn: #fbbf24;
  --danger: #f87171;
  --radius: 14px;
  --font: "Instrument Sans", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  background: radial-gradient(1200px 600px at 10% -10%, #1a2030 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #152018 0%, transparent 50%),
    var(--bg);
  color: var(--text);
  line-height: 1.45;
}

.noise {
  pointer-events: none;
  position: fixed;
  inset: 0;
  opacity: 0.04;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  z-index: 0;
}

.top, main, footer { position: relative; z-index: 1; }

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
}
.brand { display: flex; gap: 0.75rem; align-items: center; }
.mark { color: var(--accent); font-size: 1.25rem; }
.brand strong { font-size: 1.05rem; letter-spacing: -0.02em; }
.sub { color: var(--muted); font-size: 0.78rem; }
.top-meta { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.pill {
  font-family: var(--mono);
  font-size: 0.72rem;
  padding: 0.3rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
}
.pill.dim { color: var(--accent2); border-color: #3b3360; }

button, select, input {
  font: inherit;
  color: inherit;
}
button {
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--panel2);
  border-radius: 10px;
  padding: 0.5rem 0.9rem;
}
button:hover { border-color: #4a5166; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.primary {
  width: 100%;
  margin-top: 0.75rem;
  padding: 0.85rem;
  font-weight: 600;
  background: linear-gradient(135deg, #1f3d32, #163028);
  border-color: #2f6b54;
  color: var(--accent);
}
button.primary.ready {
  background: linear-gradient(135deg, #2a5c48, #1a4032);
}
button.flip {
  display: block;
  margin: -0.35rem auto;
  width: 2.2rem;
  height: 2.2rem;
  padding: 0;
  border-radius: 50%;
  position: relative;
  z-index: 2;
  background: var(--bg);
}

main { max-width: 1040px; margin: 0 auto; padding: 1.5rem; }
.hero { margin-bottom: 1.5rem; }
.hero h1 {
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin: 0 0 0.75rem;
}
.hero em { color: var(--accent); font-style: normal; }
.lede { color: var(--muted); max-width: 52ch; margin: 0; }
.lede strong { color: var(--accent2); }
code {
  font-family: var(--mono);
  font-size: 0.85em;
  background: var(--panel2);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

.grid {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 1rem;
}
@media (max-width: 800px) {
  .grid { grid-template-columns: 1fr; }
}

.card {
  background: linear-gradient(180deg, var(--panel) 0%, #0e1016 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
}
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}
.card h2 { margin: 0 0 0.75rem; font-size: 1rem; font-weight: 600; }
.card-head h2 { margin: 0; }
.slip {
  font-size: 0.8rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.slip input {
  width: 3.5rem;
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.25rem 0.4rem;
  font-family: var(--mono);
  font-size: 0.8rem;
}

.leg {
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.75rem;
  margin: 0.45rem 0;
}
.leg-top {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}
.leg-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.leg-row input {
  flex: 1;
  background: transparent;
  border: 0;
  font-size: 1.45rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  outline: none;
  min-width: 0;
}
.leg-row select {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.45rem 0.55rem;
  font-family: var(--mono);
  font-size: 0.8rem;
  max-width: 42%;
}

.asset-chip {
  flex: 0 0 auto;
  min-width: 4.5rem;
  text-align: center;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  font-family: var(--mono);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
}

/* searchable token combobox */
.combo {
  position: relative;
  flex: 0 1 52%;
  min-width: 9.5rem;
  max-width: 56%;
}
.combo[hidden],
.asset-chip[hidden] {
  display: none !important;
}
.combo-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.45rem 0.55rem;
  font-family: var(--mono);
  font-size: 0.78rem;
  text-align: left;
}
.combo-btn .caret { color: var(--muted); font-size: 0.7rem; }
.combo-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  width: min(340px, 92vw);
  z-index: 40;
  background: #0c0e14;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.55);
  padding: 0.5rem;
}
.combo-panel[hidden] { display: none !important; }
#tokenSearch {
  width: 100%;
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.55rem 0.65rem;
  font-size: 0.85rem;
  outline: none;
  margin-bottom: 0.4rem;
}
#tokenSearch:focus { border-color: #3d4a62; }
.combo-list {
  max-height: 280px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.combo-sec {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  padding: 0.35rem 0.4rem 0.15rem;
}
.combo-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.15rem 0.5rem;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0.45rem 0.5rem;
  cursor: pointer;
}
.combo-item:hover, .combo-item.active {
  background: var(--panel2);
  border-color: var(--line);
}
.combo-item .sym {
  font-weight: 600;
  font-size: 0.9rem;
}
.combo-item .meta {
  grid-column: 1 / -1;
  font-size: 0.68rem;
  color: var(--muted);
  font-family: var(--mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.combo-item .bal {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--accent);
  align-self: start;
}
.combo-item .tag {
  font-family: var(--mono);
  font-size: 0.62rem;
  color: var(--accent2);
  align-self: center;
}
.combo-empty {
  padding: 0.75rem;
  font-size: 0.8rem;
  color: var(--muted);
}
.linkish {
  background: none;
  border: 0;
  color: var(--accent);
  padding: 0;
  font-size: 0.75rem;
}
.quote-meta {
  margin-top: 0.6rem;
  font-size: 0.8rem;
  color: var(--muted);
  font-family: var(--mono);
  min-height: 1.2em;
}
.quote-meta.ok { color: var(--accent); }
.quote-meta.err { color: var(--danger); }
.path {
  margin: 0.75rem 0 0;
  padding: 0.6rem;
  background: #0a0c10;
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--muted);
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 140px;
  overflow: auto;
}

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
  margin-bottom: 0.75rem;
}
.stats > div {
  background: var(--panel2);
  border-radius: 10px;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--line);
}
.stats .n {
  display: block;
  font-family: var(--mono);
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--accent);
}
.stats .l { font-size: 0.72rem; color: var(--muted); }
.micro { font-size: 0.78rem; color: var(--muted); margin: 0 0 0.75rem; }
.token-list {
  max-height: 340px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.tok {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0.6rem;
  border-radius: 8px;
  border: 1px solid transparent;
  background: var(--panel2);
  cursor: pointer;
  text-align: left;
  width: 100%;
}
.tok:hover { border-color: var(--line); }
.tok .sym { font-weight: 600; font-size: 0.9rem; }
.tok .nm { color: var(--muted); font-size: 0.72rem; }
.tok .tag {
  font-family: var(--mono);
  font-size: 0.65rem;
  color: var(--accent2);
  align-self: center;
}

.manifesto { margin-top: 1rem; }
.manifesto ol { margin: 0; padding-left: 1.2rem; color: var(--muted); }
.manifesto li { margin-bottom: 0.4rem; }
.manifesto strong { color: var(--text); }

footer {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: center;
  padding: 2rem 1rem 3rem;
  color: var(--muted);
  font-size: 0.8rem;
}
footer a { color: var(--muted); }
footer a:hover { color: var(--accent); }
