:root {
  --ink: #0c0f14;
  --ink-2: #141a22;
  --panel: rgba(20, 26, 34, 0.78);
  --stroke: rgba(255, 214, 170, 0.14);
  --text: #f4efe6;
  --muted: #9aa3b2;
  --amber: #ffb454;
  --amber-2: #ff8a3d;
  --mint: #5ee4a8;
  --rose: #ff7b8a;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  --radius: 18px;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --display: "Syne", system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  color: var(--text);
  background: var(--ink);
  font-family: var(--display);
}

body {
  min-height: 100vh;
  min-height: 100dvh;
}

.grain {
  pointer-events: none;
  position: fixed;
  inset: 0;
  opacity: 0.09;
  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;
}

.orb {
  pointer-events: none;
  position: fixed;
  border-radius: 50%;
  filter: blur(50px);
  z-index: 0;
}

.orb-a {
  width: 42vw;
  height: 42vw;
  top: -12vw;
  right: -8vw;
  background: radial-gradient(circle, rgba(255, 180, 84, 0.28), transparent 65%);
}

.orb-b {
  width: 36vw;
  height: 36vw;
  bottom: -14vw;
  left: -10vw;
  background: radial-gradient(circle, rgba(94, 228, 168, 0.14), transparent 70%);
}

.shell {
  position: relative;
  z-index: 1;
  height: 100vh;
  height: 100dvh;
  max-width: 980px;
  margin: 0 auto;
  padding: clamp(14px, 2.2vh, 28px) clamp(16px, 3vw, 28px);
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  gap: clamp(10px, 1.6vh, 16px);
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand h1 {
  margin: 0;
  font-size: clamp(1.4rem, 2.4vw, 1.85rem);
  letter-spacing: -0.03em;
  line-height: 1;
}

.tag {
  margin: 4px 0 0;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.spark {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background:
    linear-gradient(145deg, var(--amber), var(--amber-2)),
    radial-gradient(circle at 30% 30%, #fff6, transparent 45%);
  box-shadow: 0 0 0 1px rgba(255, 180, 84, 0.35), 0 10px 30px rgba(255, 138, 61, 0.25);
  position: relative;
}

.spark::after {
  content: "";
  position: absolute;
  inset: 11px 15px 9px 12px;
  background: #1a1208;
  clip-path: polygon(45% 0, 70% 38%, 55% 38%, 80% 100%, 20% 52%, 40% 52%);
  opacity: 0.9;
}

.status-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.pill {
  font-family: var(--mono);
  font-size: 0.7rem;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 180, 84, 0.28);
  background: rgba(255, 180, 84, 0.08);
  color: var(--amber);
}

.pill.muted {
  border-color: rgba(154, 163, 178, 0.25);
  background: rgba(154, 163, 178, 0.08);
  color: var(--muted);
}

.pill.ok {
  border-color: rgba(94, 228, 168, 0.35);
  background: rgba(94, 228, 168, 0.1);
  color: var(--mint);
}

.panel {
  border: 1px solid var(--stroke);
  background: var(--panel);
  backdrop-filter: blur(14px);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(12px, 1.8vh, 18px) clamp(14px, 2vw, 20px);
}

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

.panel h2 {
  margin: 0;
  font-size: 0.95rem;
  letter-spacing: -0.02em;
  color: #fff8ee;
}

.pair-line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.pair {
  font-size: clamp(1.1rem, 2vw, 1.35rem);
  font-weight: 700;
  letter-spacing: -0.03em;
}

.source {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
}

.price-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.price-card {
  border-radius: 14px;
  padding: clamp(12px, 1.8vh, 16px);
  border: 1px solid transparent;
  min-height: clamp(100px, 16vh, 130px);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.price-card.buy {
  background: linear-gradient(160deg, rgba(94, 228, 168, 0.12), rgba(20, 26, 34, 0.4));
  border-color: rgba(94, 228, 168, 0.22);
}

.price-card.sell {
  background: linear-gradient(160deg, rgba(255, 123, 138, 0.12), rgba(20, 26, 34, 0.4));
  border-color: rgba(255, 123, 138, 0.22);
}

.label {
  display: block;
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}

.value {
  font-family: var(--mono);
  font-size: clamp(1.55rem, 4.2vw, 2.2rem);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.05;
}

.price-card.buy .value {
  color: var(--mint);
}

.price-card.sell .value {
  color: var(--rose);
}

.hint {
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 8px;
}

.meta-line {
  margin-top: 12px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
}

.fetch-state.ok {
  color: var(--mint);
}

.fetch-state.err {
  color: var(--rose);
}

.actions {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 14px;
  align-items: center;
}

.record-copy p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.4;
}

.record-copy em {
  color: var(--amber);
  font-style: normal;
  font-weight: 600;
}

.record-copy code {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: #ffd9a8;
}

.record-cta {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

button {
  font-family: var(--display);
  border: 0;
  cursor: pointer;
}

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

.primary {
  width: 100%;
  border-radius: 14px;
  padding: 14px 16px;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #1a1208;
  background: linear-gradient(135deg, var(--amber), var(--amber-2));
  box-shadow: 0 12px 28px rgba(255, 138, 61, 0.28);
  transition: transform 0.15s ease, filter 0.15s ease;
}

.primary:not(:disabled):hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
}

.ghost {
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.ghost:hover {
  background: rgba(255, 255, 255, 0.09);
}

.tx-status {
  font-family: var(--mono);
  font-size: 0.72rem;
  line-height: 1.45;
  color: var(--muted);
  word-break: break-all;
}

.tx-status a {
  color: var(--amber);
  text-decoration: none;
  border-bottom: 1px solid rgba(255, 180, 84, 0.4);
}

.tx-status.ok {
  color: var(--mint);
}

.tx-status.err {
  color: var(--rose);
}

.attest-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.attest-grid strong {
  display: block;
  font-family: var(--mono);
  font-size: clamp(0.78rem, 1.4vw, 0.92rem);
  font-weight: 500;
  color: #fff8ee;
  word-break: break-word;
}

.loop-note {
  margin: 10px 0 0;
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--muted);
}

@media (max-width: 760px) {
  body {
    overflow: auto;
  }

  .shell {
    height: auto;
    min-height: 100dvh;
    grid-template-rows: auto;
  }

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

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

@media (max-height: 700px) {
  .hint {
    display: none;
  }

  .price-card {
    min-height: 0;
  }

  .loop-note {
    display: none;
  }
}
