:root {
  color-scheme: dark;
  --bg: #070a0b;
  --panel: #0b1012;
  --panel-2: #0e1518;
  --ink: #f3f7f4;
  --muted: #849197;
  --faint: #3a464a;
  --line: #1d2a2e;
  --cyan: #38f2e0;
  --blue: #3b82ff;
  --lime: #c9ff42;
  --orange: #ff985c;
  --danger: #ff5e68;
  --mono: "SFMono-Regular", "Roboto Mono", "Cascadia Code", "Liberation Mono", monospace;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  background: var(--bg);
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(rgba(56, 242, 224, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(56, 242, 224, 0.025) 1px, transparent 1px),
    var(--bg);
  background-size: 40px 40px;
  color: var(--ink);
  font-family: var(--sans);
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

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

button {
  border: 0;
}

.scanline {
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
  opacity: 0.09;
  background: repeating-linear-gradient(
    0deg,
    transparent 0,
    transparent 3px,
    rgba(255, 255, 255, 0.035) 4px
  );
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: 66px;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(7, 10, 11, 0.94);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: max-content;
  font-family: var(--mono);
}

.brand strong {
  font-size: 18px;
  letter-spacing: 0;
}

.brand > span:last-child {
  color: var(--muted);
  font-size: 10px;
}

.brand-logo {
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 3px;
  object-fit: cover;
}

.site-header nav {
  display: flex;
  gap: 30px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
}

.site-header nav a:hover,
.site-header nav a:focus-visible {
  color: var(--cyan);
}

.wallet-button {
  justify-self: end;
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid var(--faint);
  border-radius: 3px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.wallet-button:hover,
.wallet-button:focus-visible {
  border-color: var(--cyan);
  color: var(--cyan);
}

.emergency-banner {
  position: sticky;
  top: 66px;
  z-index: 45;
  padding: 11px 28px;
  border-bottom: 1px solid var(--danger);
  background: #2a0b10;
  color: #ffdadd;
  font-family: var(--mono);
  font-size: 12px;
}

.emergency-banner strong {
  margin-right: 18px;
  color: var(--danger);
}

.trade-stage,
.mechanism-section,
.invariant-section,
.stable-section,
.contract-section,
footer {
  width: min(1600px, calc(100% - 56px));
  margin: 0 auto;
}

.trade-stage {
  padding: 24px 0 58px;
}

.market-ident {
  display: flex;
  align-items: end;
  justify-content: space-between;
  margin-bottom: 15px;
}

.eyebrow,
.panel-kicker,
.section-index {
  color: var(--cyan);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.market-ident h1 {
  margin: 5px 0 0;
  font-family: var(--mono);
  font-size: clamp(32px, 5vw, 68px);
  line-height: 0.95;
}

.market-ident h1 span {
  color: var(--faint);
  font-size: 0.42em;
  font-weight: 500;
}

.market-status {
  display: grid;
  grid-template-columns: auto auto;
  gap: 3px 8px;
  align-items: center;
  justify-items: end;
  font-family: var(--mono);
  font-size: 11px;
}

.social-rail {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 15px;
  padding: 8px;
  border: 1px solid var(--line);
  background: rgba(8, 16, 17, 0.9);
  font-family: var(--mono);
  font-size: 10px;
}

.social-rail > span {
  margin: 0 6px;
  color: var(--muted);
}

.social-rail a {
  padding: 9px 13px;
  border: 1px solid var(--cyan);
  color: var(--cyan);
  font-weight: 800;
}

.social-rail a:last-child {
  border-color: var(--blue);
  color: #7fb0ff;
}

.social-rail a:hover,
.social-rail a:focus-visible {
  background: var(--cyan);
  color: #041011;
}

.social-rail a:last-child:hover,
.social-rail a:last-child:focus-visible {
  background: #7fb0ff;
  color: #06101c;
}

.market-status small {
  grid-column: 1 / -1;
  color: var(--muted);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--orange);
  box-shadow: 0 0 14px rgba(255, 152, 92, 0.8);
}

.status-dot.live {
  background: var(--cyan);
  box-shadow: 0 0 14px rgba(56, 242, 224, 0.8);
}

.metric-rail {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  border: 1px solid var(--line);
  border-bottom: 0;
  background: var(--panel);
}

.metric-rail article {
  min-width: 0;
  padding: 12px 16px 11px;
  border-right: 1px solid var(--line);
}

.metric-rail article:last-child {
  border-right: 0;
}

.metric-rail span,
.metric-rail small {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric-rail strong {
  display: block;
  overflow: hidden;
  margin: 5px 0 3px;
  color: var(--ink);
  font-family: var(--mono);
  font-size: clamp(14px, 1.5vw, 22px);
  text-overflow: ellipsis;
}

.terminal-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.72fr) minmax(350px, 0.72fr);
  min-height: 520px;
  border: 1px solid var(--line);
}

.curve-panel,
.trade-panel {
  min-width: 0;
  background: rgba(11, 16, 18, 0.96);
}

.curve-panel {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
}

.panel-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  min-height: 78px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
}

.panel-head h2 {
  margin: 5px 0 0;
  font-size: 16px;
  font-weight: 600;
}

.legend {
  display: flex;
  gap: 18px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 9px;
}

.legend span {
  display: flex;
  align-items: center;
  gap: 7px;
}

.legend .line {
  display: inline-block;
  width: 17px;
  height: 2px;
}

.legend .spot { background: var(--cyan); }
.legend .floor { background: var(--orange); }

.chart-wrap {
  position: relative;
  flex: 1;
  min-height: 350px;
  background: #080d0f;
}

#curve-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

.chart-crosshair {
  position: absolute;
  z-index: 2;
  min-width: 136px;
  padding: 9px 11px;
  border: 1px solid var(--faint);
  border-radius: 2px;
  background: rgba(7, 10, 11, 0.94);
  pointer-events: none;
  font-family: var(--mono);
}

.chart-crosshair strong,
.chart-crosshair span {
  display: block;
  font-size: 10px;
}

.chart-crosshair strong { color: var(--cyan); }
.chart-crosshair span { margin-top: 4px; color: var(--muted); }

.curve-tape {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 49px;
  padding: 0 22px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 9px;
}

.curve-tape code,
.curve-tape strong {
  color: var(--ink);
}

.tape-spacer { flex: 1; }

.trade-panel {
  display: flex;
  flex-direction: column;
  padding: 15px;
}

.trade-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--line);
}

.trade-tabs button {
  min-height: 45px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 800;
}

.trade-tabs button + button { border-left: 1px solid var(--line); }

.trade-tabs button.active {
  background: var(--cyan);
  color: #04110f;
}

.trade-tabs #sell-tab.active {
  background: var(--orange);
  color: #160a04;
}

.trade-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 13px 1px 9px;
  font-family: var(--mono);
}

.trade-heading span,
.trade-heading small { display: block; }
.trade-heading > div > span { color: var(--ink); font-size: 11px; font-weight: 800; }
.trade-heading small { margin-top: 4px; color: var(--muted); font-size: 9px; }
.wallet-balance { color: var(--muted); font-size: 9px; }

.amount-box,
.receive-box {
  display: block;
  padding: 10px 12px;
  border: 1px solid var(--faint);
  background: #080c0e;
}

.amount-box > span:first-child,
.receive-box > span:first-child {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 9px;
}

.amount-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 5px 0 7px;
}

.amount-row input {
  min-width: 0;
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 24px;
  font-weight: 700;
}

.amount-row input::-webkit-outer-spin-button,
.amount-row input::-webkit-inner-spin-button {
  appearance: none;
  margin: 0;
}

.amount-row strong {
  color: var(--cyan);
  font-family: var(--mono);
  font-size: 12px;
}

.quick-amounts {
  display: flex;
  gap: 5px;
}

.quick-amounts button {
  padding: 4px 7px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-family: var(--mono);
  font-size: 8px;
}

.quick-amounts button:hover { border-color: var(--cyan); color: var(--cyan); }

.quote-arrow {
  width: 25px;
  height: 25px;
  margin: -1px auto;
  border: 1px solid var(--faint);
  border-radius: 50%;
  background: var(--panel);
  color: var(--muted);
  font-size: 13px;
  line-height: 22px;
  text-align: center;
}

.receive-box {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  min-height: 67px;
}

.receive-box > span { grid-column: 1 / -1; }
.receive-box strong {
  overflow: hidden;
  margin-top: 8px;
  font-family: var(--mono);
  font-size: 21px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.receive-box small { color: var(--cyan); font-family: var(--mono); font-size: 11px; }

.quote-details {
  margin: 10px 1px 8px;
}

.quote-details div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 22px;
  border-bottom: 1px dotted var(--line);
  font-family: var(--mono);
  font-size: 9px;
}

.quote-details dt { color: var(--muted); }
.quote-details dd { margin: 0; color: var(--ink); }

.quote-details select {
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 9px;
}

.primary-action {
  width: 100%;
  min-height: 48px;
  margin-top: auto;
  border-radius: 3px;
  background: var(--cyan);
  color: #04110f;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 900;
}

.primary-action.sell { background: var(--orange); color: #160a04; }
.primary-action:disabled { background: #243034; color: #738086; cursor: not-allowed; }
.primary-action:not(:disabled):hover { filter: brightness(1.08); }

.trade-message {
  min-height: 18px;
  margin: 9px 0 0;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 9px;
  line-height: 1.5;
}

.trade-message.error { color: var(--danger); }
.trade-message.success { color: var(--lime); }

.proof-strip {
  display: flex;
  justify-content: space-between;
  margin-top: 7px;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 7px;
}

.activity-strip {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 18px;
  align-items: center;
  min-height: 45px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-top: 0;
  background: var(--panel);
  font-family: var(--mono);
  font-size: 9px;
}

.activity-title { color: var(--cyan); font-weight: 800; }
#activity-feed { overflow: hidden; color: var(--muted); white-space: nowrap; }
#all-transactions { color: var(--ink); }

.mechanism-section,
.invariant-section,
.stable-section,
.contract-section {
  padding: 90px 0;
  border-top: 1px solid var(--line);
}

.section-heading {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 50px;
  align-items: end;
  margin: 22px 0 44px;
}

.section-heading h2,
.invariant-copy h2,
.contract-layout h2 {
  margin: 0;
  max-width: 760px;
  font-size: clamp(34px, 5vw, 72px);
  line-height: 0.98;
}

.section-heading p,
.invariant-copy p,
.contract-layout p {
  margin: 0;
  max-width: 620px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.7;
}

.flow-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border: 1px solid var(--line);
}

.flow-grid article {
  min-height: 270px;
  padding: 23px;
  border-right: 1px solid var(--line);
  background: var(--panel);
}

.flow-grid article:last-child { border-right: 0; }
.flow-number { color: var(--cyan); font-family: var(--mono); font-size: 10px; }
.flow-grid h3 { margin: 48px 0 13px; font-size: 20px; }
.flow-grid p { min-height: 80px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.flow-grid code { color: var(--lime); font-family: var(--mono); font-size: 10px; }

.invariant-section {
  display: grid;
  grid-template-columns: 1fr 0.85fr;
  gap: 8vw;
  align-items: center;
}

.invariant-copy h2 { margin: 24px 0; }
.invariant-copy a {
  display: inline-block;
  margin-top: 30px;
  border-bottom: 1px solid var(--cyan);
  color: var(--cyan);
  font-family: var(--mono);
  font-size: 10px;
}

.code-window {
  margin: 0;
  min-height: 360px;
  padding: 0;
  border: 1px solid var(--faint);
  border-radius: 4px;
  background: #050708;
  white-space: pre-wrap;
}

.code-window > span {
  display: block;
  padding: 13px 17px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 9px;
}

.code-window code {
  display: block;
  padding: 42px 32px;
  color: var(--lime);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.85;
}

.stable-section {
  position: relative;
  display: grid;
  grid-template-columns: 0.9fr 1.1fr;
  gap: 6vw;
  overflow: hidden;
  border-color: #173c55;
}

.stable-word {
  position: absolute;
  top: 42px;
  right: -10px;
  z-index: -1;
  color: rgba(59, 130, 255, 0.07);
  font-family: var(--mono);
  font-size: clamp(100px, 18vw, 280px);
  font-weight: 900;
  line-height: 0.8;
}

.stable-copy {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 0.9fr 1.1fr;
  gap: 6vw;
  align-items: end;
}

.stable-copy h2 {
  margin: 22px 0 0;
  max-width: 780px;
  font-size: clamp(36px, 5vw, 72px);
  line-height: 0.98;
}

.stable-copy p {
  margin: 0;
  max-width: 620px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.7;
}

.stable-copy a {
  grid-column: 2;
  width: max-content;
  border-bottom: 1px solid var(--blue);
  color: #7fb0ff;
  font-family: var(--mono);
  font-size: 10px;
}

.stable-facts {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin: 35px 0 0;
  border: 1px solid #173c55;
  background: rgba(6, 18, 27, 0.82);
}

.stable-facts div {
  padding: 18px;
  border-right: 1px solid #173c55;
}

.stable-facts div:last-child { border-right: 0; }
.stable-facts dt { color: var(--muted); font-family: var(--mono); font-size: 9px; }
.stable-facts dd { margin: 8px 0 0; color: #7fb0ff; font-family: var(--mono); font-size: 16px; font-weight: 800; }

.contract-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8vw;
  margin-top: 25px;
}

.contract-layout h2 { font-size: clamp(38px, 5vw, 70px); }
.contract-layout p { margin-top: 25px; font-family: var(--mono); font-size: 11px; }
.contract-data { margin: 0; border-top: 1px solid var(--line); }
.contract-data div { padding: 15px 0; border-bottom: 1px solid var(--line); }
.contract-data dt { margin-bottom: 7px; color: var(--muted); font-family: var(--mono); font-size: 9px; }
.contract-data dd { overflow-wrap: anywhere; margin: 0; color: var(--cyan); font-family: var(--mono); font-size: 11px; }

footer {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: 110px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 9px;
}

footer p { color: var(--ink); }
footer > div { display: flex; justify-content: flex-end; gap: 20px; }
footer a:hover { color: var(--cyan); }

@media (max-width: 1100px) {
  .metric-rail { grid-template-columns: repeat(3, 1fr); }
  .metric-rail article:nth-child(3) { border-right: 0; }
  .metric-rail article:nth-child(n + 4) { border-top: 1px solid var(--line); }
  .terminal-layout { grid-template-columns: minmax(0, 1.35fr) minmax(330px, 0.8fr); }
  .flow-grid { grid-template-columns: repeat(2, 1fr); }
  .flow-grid article:nth-child(2) { border-right: 0; }
  .flow-grid article:nth-child(n + 3) { border-top: 1px solid var(--line); }
}

@media (max-width: 820px) {
  .site-header {
    grid-template-columns: 1fr auto;
    padding: 0 16px;
  }
  .site-header nav { display: none; }
  .trade-stage,
  .mechanism-section,
  .invariant-section,
  .stable-section,
  .contract-section,
  footer { width: min(100% - 28px, 720px); }
  .trade-stage { padding-top: 24px; }
  .market-ident { align-items: start; }
  .metric-rail { grid-template-columns: repeat(2, 1fr); }
  .metric-rail article { border-right: 1px solid var(--line) !important; border-top: 1px solid var(--line); }
  .metric-rail article:nth-child(odd) { border-right: 1px solid var(--line) !important; }
  .metric-rail article:nth-child(even) { border-right: 0 !important; }
  .metric-rail article:first-child,
  .metric-rail article:nth-child(2) { border-top: 0; }
  .metric-rail article:last-child { grid-column: 1 / -1; border-right: 0 !important; }
  .terminal-layout { display: flex; flex-direction: column; }
  .terminal-layout { flex-direction: column-reverse; }
  .curve-panel { border-right: 0; border-bottom: 1px solid var(--line); }
  .chart-wrap { min-height: 390px; }
  .trade-panel { min-height: 500px; }
  .section-heading,
  .invariant-section,
  .stable-copy,
  .contract-layout { grid-template-columns: 1fr; gap: 30px; }
  .flow-grid { grid-template-columns: 1fr; }
  .flow-grid article { min-height: 230px; border-right: 0; border-top: 1px solid var(--line); }
  .flow-grid article:first-child { border-top: 0; }
  .flow-grid p { min-height: auto; }
  .activity-strip { grid-template-columns: auto 1fr; }
  .stable-section { grid-template-columns: 1fr; }
  .stable-copy a { grid-column: 1; }
  .stable-facts { grid-template-columns: repeat(2, 1fr); }
  .stable-facts div:nth-child(2) { border-right: 0; }
  .stable-facts div:nth-child(n + 3) { border-top: 1px solid #173c55; }
  #all-transactions { display: none; }
  footer { grid-template-columns: 1fr 1fr; }
  footer p { display: none; }
}

@media (max-width: 520px) {
  .site-header { min-height: 58px; }
  .brand > span:last-child { display: none; }
  .wallet-button.compact { min-height: 34px; padding: 0 11px; }
  .emergency-banner { top: 58px; padding: 9px 14px; }
  .emergency-banner strong,
  .emergency-banner span { display: block; }
  .market-ident h1 { font-size: 35px; }
  .market-status { font-size: 9px; }
  .market-status small { max-width: 128px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .social-rail { display: grid; grid-template-columns: 1fr 1fr; }
  .social-rail > span { grid-column: 1 / -1; margin: 2px 4px; }
  .social-rail a { padding: 9px 7px; font-size: 8px; text-align: center; }
  .metric-rail article { padding: 13px 12px; }
  .metric-rail strong { font-size: 15px; }
  .panel-head { align-items: start; min-height: 116px; padding: 15px; }
  .panel-head h2 { max-width: 170px; font-size: 15px; }
  .legend { flex-direction: column; gap: 7px; }
  .chart-wrap { min-height: 330px; }
  .curve-tape { gap: 8px; padding: 0 12px; }
  .curve-tape code { display: none; }
  .trade-panel { padding: 14px; }
  .activity-strip { padding: 0 11px; }
  .mechanism-section,
  .invariant-section,
  .stable-section,
  .contract-section { padding: 65px 0; }
  .section-heading h2,
  .invariant-copy h2,
  .stable-copy h2,
  .contract-layout h2 { font-size: 36px; }
  .section-heading p,
  .invariant-copy p { font-size: 14px; }
  .stable-copy p { font-size: 14px; }
  .code-window { min-height: 300px; }
  .code-window code { padding: 30px 18px; font-size: 10px; }
  footer > div { gap: 12px; }
}

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