:root {
  --bg: #070b16;
  --bg-glow: #12364a;
  --card: rgba(14, 20, 36, 0.88);
  --line: rgba(255, 255, 255, 0.08);
  --text: #eaf3ff;
  --muted: #8ea0c4;
  --accent: #3ee0c5;
  --accent-dim: rgba(62, 224, 197, 0.16);
  --danger: #ff7b93;
  --send: #6d8dff;
  --pulse-ms: 1250ms;
  --pulse-color: #3ee0c5;
}

body[data-pulse="racing"] {
  --bg-glow: #4a1828;
  --pulse-color: #ff7b93;
  --accent: #ff7b93;
}

body[data-pulse="steady"] {
  --bg-glow: #143c38;
  --pulse-color: #3ee0c5;
}

body[data-pulse="still"] {
  --bg-glow: #2a2a12;
  --pulse-color: #e0c35a;
  --accent: #e0c35a;
}

body[data-pulse="dormant"] {
  --bg-glow: #141a2c;
  --pulse-color: #6d7c9c;
  --accent: #8ea0c4;
}

* {
  box-sizing: border-box;
}

body {
  font-family: "Segoe UI", system-ui, sans-serif;
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(900px 420px at 50% -8%, var(--bg-glow), transparent 58%),
    var(--bg);
  transition: background 0.6s ease;
}

.app {
  width: min(440px, calc(100% - 32px));
  margin: 32px auto 72px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

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

.pulse-mark {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff, var(--pulse-color) 46%, #0b3b34);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--pulse-color) 55%, transparent);
  animation: pulse var(--pulse-ms) ease-out infinite;
}

.brand-copy h1 {
  margin: 0;
  font-size: 1.35rem;
  letter-spacing: -0.03em;
}

.tagline,
.lede,
.field-label,
.spent-meta,
.empty,
.card-kicker,
.stat-label,
.bpm-label {
  color: var(--muted);
}

.tagline {
  margin: 2px 0 0;
  font-size: 0.85rem;
}

.lede {
  margin: 0 0 14px;
  line-height: 1.45;
  font-size: 0.92rem;
}

.network-pill {
  margin-left: auto;
  font-size: 0.75rem;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--pulse-color);
  background: var(--accent-dim);
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  backdrop-filter: blur(14px);
}

.pulse-hero {
  text-align: center;
  padding: 22px 18px 18px;
}

.pulse-orb-wrap {
  display: grid;
  place-items: center;
  min-height: 168px;
}

.pulse-orb {
  position: relative;
  width: 132px;
  height: 132px;
  display: grid;
  place-items: center;
}

.ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1px solid color-mix(in srgb, var(--pulse-color) 55%, transparent);
  animation: ring var(--pulse-ms) ease-out infinite;
}

.ring-b {
  animation-delay: calc(var(--pulse-ms) / 2);
}

.pulse-core {
  width: 92px;
  height: 92px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  align-content: center;
  background: radial-gradient(circle at 40% 32%, color-mix(in srgb, var(--pulse-color) 55%, #fff), var(--pulse-color) 58%, #07131c);
  box-shadow: 0 0 32px color-mix(in srgb, var(--pulse-color) 35%, transparent);
  color: #06231e;
}

#pulseBpm {
  font-size: 1.85rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
}

.bpm-label {
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  color: #08342d;
  font-weight: 700;
}

.pulse-state {
  margin: 4px 0 8px;
  font-size: 0.92rem;
  text-transform: capitalize;
}

.ecg {
  width: 100%;
  height: 48px;
  margin: 4px 0 12px;
}

.ecg path {
  fill: none;
  stroke: var(--pulse-color);
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-dasharray: 180;
  stroke-dashoffset: 180;
  animation: ecg calc(var(--pulse-ms) * 1.15) linear infinite;
}

.card-kicker {
  margin: 0 0 4px;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

.balance-value {
  margin: 0 0 16px;
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.04em;
}

.unit {
  font-size: 0.95rem;
  color: var(--muted);
  font-weight: 500;
}

.pulse-stats {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  text-align: center;
}

.pulse-stats div {
  padding: 10px 6px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
}

.stat-label {
  display: block;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 4px;
}

.stat-value {
  font-weight: 700;
  font-size: 0.95rem;
}

h2 {
  margin: 0 0 12px;
  font-size: 1rem;
}

select,
input,
button {
  width: 100%;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #0b1222;
  color: var(--text);
  font: inherit;
}

button {
  background: var(--pulse-color);
  color: #06231e;
  border: none;
  font-weight: 700;
  cursor: pointer;
  margin-top: 12px;
}

button:hover:not(:disabled) {
  filter: brightness(1.06);
}

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

#sendButton {
  background: var(--send);
  color: #fff;
}

.secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
  font-weight: 600;
}

.divider {
  margin: 16px 0 8px;
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
}

.ghost {
  width: auto;
  margin: 0;
  padding: 6px 10px;
  background: transparent;
  color: var(--pulse-color);
  border: 1px solid var(--line);
  font-weight: 600;
  font-size: 0.8rem;
}

.status-row,
.address-row,
.amount-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-row {
  justify-content: flex-start;
}

.address-row,
.amount-row {
  justify-content: space-between;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--pulse-color);
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.92rem;
}

.help {
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.85rem;
}

.help p {
  margin: 8px 0 0;
}

.ai-card {
  background: linear-gradient(180deg, color-mix(in srgb, var(--pulse-color) 12%, transparent), var(--card));
}

#aiSuggestion {
  margin: 0;
  line-height: 1.45;
}

.spent-meta {
  margin: 10px 0 0;
  font-size: 0.8rem;
}

.history-card ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.history-card li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.92rem;
}

.history-card li:last-child {
  border-bottom: none;
}

.tx-dir.sent {
  color: var(--danger);
}

.tx-dir.received {
  color: var(--pulse-color);
}

.tx-meta a {
  color: var(--muted);
  font-size: 0.78rem;
}

.error-banner {
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255, 123, 147, 0.12);
  color: var(--danger);
  font-size: 0.9rem;
}

.loading {
  display: none;
  width: 22px;
  height: 22px;
  margin: 4px auto 0;
  border: 3px solid var(--line);
  border-top-color: var(--pulse-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.address-row {
  flex-wrap: wrap;
}

.network-card .network-line {
  margin: 0 0 6px;
  font-size: 1.15rem;
  font-weight: 700;
}

.network-feed {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
}

.network-feed li {
  padding: 8px 0;
  border-top: 1px solid var(--line);
  font-size: 0.88rem;
  color: var(--muted);
}

.beat-toast {
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--pulse-color) 18%, transparent);
  color: var(--text);
  font-weight: 600;
  text-align: center;
}

.pulse-hero.beat-flash .pulse-core {
  animation: beatflash 0.9s ease;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.84em;
}

@keyframes beatflash {
  0% { transform: scale(1); }
  35% { transform: scale(1.12); }
  100% { transform: scale(1); }
}

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

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--pulse-color) 50%, transparent); }
  70% { box-shadow: 0 0 0 16px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

@keyframes ring {
  0% { transform: scale(0.82); opacity: 0.7; }
  100% { transform: scale(1.18); opacity: 0; }
}

@keyframes ecg {
  to { stroke-dashoffset: 0; }
}

/* ============================================================
   Presentation layer, appended so the working styles above stay
   the source of truth for anything these rules do not override.
   Everything here is driven by the same --pulse-color and
   --pulse-ms the chain state already sets, so the page breathes
   at the network's real rate rather than a decorative one.
   ============================================================ */

:root {
  --ink: #f2f7ff;
  --shell: rgba(11, 17, 32, 0.72);
  --edge: rgba(255, 255, 255, 0.09);
  --edge-lit: color-mix(in srgb, var(--pulse-color) 38%, transparent);
  --sans: "Sora", "Segoe UI", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "Cascadia Mono", monospace;
}

body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--bg);
  overflow-x: hidden;
}

/* Slow drifting colour field behind everything. */
.aurora {
  position: fixed;
  inset: -30vh -30vw;
  z-index: -2;
  pointer-events: none;
  background:
    radial-gradient(38vw 38vw at 22% 18%, color-mix(in srgb, var(--pulse-color) 26%, transparent), transparent 62%),
    radial-gradient(34vw 34vw at 82% 8%, color-mix(in srgb, var(--send) 22%, transparent), transparent 60%),
    radial-gradient(46vw 46vw at 60% 92%, color-mix(in srgb, var(--pulse-color) 14%, transparent), transparent 66%);
  filter: blur(38px) saturate(130%);
  animation: drift 26s ease-in-out infinite alternate;
  transition: background 1.2s ease;
}

@keyframes drift {
  from { transform: translate3d(-2%, -1%, 0) scale(1); }
  to   { transform: translate3d(3%, 2%, 0) scale(1.08); }
}

/* Full-bleed trace across the top, drawing itself at the pulse rate. */
.hero-trace {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 220px;
  z-index: -1;
  pointer-events: none;
  opacity: 0.55;
  mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent);
}

.hero-trace path {
  fill: none;
  stroke: var(--pulse-color);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1400;
  stroke-dashoffset: 1400;
  animation: sweep calc(var(--pulse-ms) * 3.2) linear infinite;
}

#heroPathGlow {
  stroke-width: 7;
  opacity: 0.16;
  filter: blur(5px);
}

@keyframes sweep {
  to { stroke-dashoffset: -1400; }
}

.app {
  width: min(1080px, calc(100% - 40px));
  margin: 48px auto 96px;
  gap: 20px;
}

/* --- brand --- */

.brand {
  gap: 14px;
  margin-bottom: 8px;
}

.brand-copy h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.035em;
}

.pulse-mark {
  width: 40px;
  height: 40px;
  box-shadow:
    0 0 0 0 color-mix(in srgb, var(--pulse-color) 55%, transparent),
    0 6px 26px color-mix(in srgb, var(--pulse-color) 40%, transparent);
}

.network-pill {
  font-family: var(--mono);
  letter-spacing: 0.04em;
  backdrop-filter: blur(10px);
}

/* --- hero --- */

.hero {
  padding: 30px 0 14px;
  max-width: 30ch;
}

.hero-kicker {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--pulse-color);
  margin: 0 0 14px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
}

.hero-kicker::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--pulse-color);
  box-shadow: 0 0 12px var(--pulse-color);
  animation: pulse var(--pulse-ms) ease-out infinite;
}

.hero-headline {
  margin: 0 0 16px;
  font-size: clamp(2.3rem, 6.2vw, 3.9rem);
  line-height: 1.02;
  font-weight: 700;
  letter-spacing: -0.045em;
  background: linear-gradient(180deg, var(--ink) 30%, color-mix(in srgb, var(--ink) 46%, transparent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero-headline em {
  font-style: normal;
  background: linear-gradient(96deg, var(--pulse-color), color-mix(in srgb, var(--pulse-color) 45%, #fff));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero-sub {
  margin: 0;
  max-width: 46ch;
  font-size: 1.02rem;
  line-height: 1.6;
  color: var(--muted);
}

/* --- cards --- */

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

.card {
  background: var(--shell);
  border: 1px solid var(--edge);
  border-radius: 22px;
  padding: 24px;
  backdrop-filter: blur(22px) saturate(150%);
  box-shadow: 0 20px 60px -30px rgba(0, 0, 0, 0.9);
  transition: border-color 0.35s ease, transform 0.35s ease, box-shadow 0.35s ease;
  animation: rise 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.card:hover {
  border-color: var(--edge-lit);
  transform: translateY(-2px);
  box-shadow: 0 26px 70px -30px color-mix(in srgb, var(--pulse-color) 30%, rgba(0, 0, 0, 0.9));
}

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}

.card-kicker {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin: 0 0 10px;
}

.network-line {
  font-size: 1.9rem;
  font-weight: 700;
  letter-spacing: -0.035em;
  margin: 0 0 6px;
  line-height: 1.05;
}

#networkBpm,
#offerPot {
  font-family: var(--mono);
  color: var(--pulse-color);
}

#offerWindow,
#networkState {
  font-size: 0.95rem;
  font-weight: 400;
  color: var(--muted);
  letter-spacing: 0;
}

.spent-meta,
.empty {
  font-family: var(--mono);
  font-size: 0.76rem;
  line-height: 1.7;
}

.network-feed li {
  font-family: var(--mono);
  font-size: 0.78rem;
  padding: 9px 0;
  border-bottom: 1px solid var(--edge);
}

.network-feed li:last-child { border-bottom: 0; }

/* --- the big number --- */

.pulse-hero { padding: 30px 24px 24px; }

.pulse-orb { width: 158px; height: 158px; }

.pulse-core {
  width: 112px;
  height: 112px;
  box-shadow:
    0 0 44px color-mix(in srgb, var(--pulse-color) 45%, transparent),
    inset 0 -8px 22px rgba(0, 0, 0, 0.28);
}

#pulseBpm {
  font-family: var(--mono);
  font-size: 2.3rem;
}

.pulse-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(84px, 1fr));
  gap: 12px;
}

.stat {
  padding: 12px 10px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--edge);
}

.stat-label {
  font-family: var(--mono);
  font-size: 0.6rem;
  letter-spacing: 0.16em;
}

.stat-value {
  font-family: var(--mono);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--ink);
}

/* --- controls --- */

button {
  font-family: var(--sans);
  font-weight: 600;
  letter-spacing: -0.01em;
  border-radius: 14px;
  transition: transform 0.18s ease, filter 0.18s ease, box-shadow 0.18s ease;
}

button:not(.ghost):not(:disabled) {
  box-shadow: 0 10px 30px -14px color-mix(in srgb, var(--pulse-color) 70%, transparent);
}

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

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

input, select {
  font-family: var(--mono);
  border-radius: 14px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus, select:focus {
  outline: none;
  border-color: var(--edge-lit);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--pulse-color) 14%, transparent);
}

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

/* Wide screens get the hero beside the landing cards. */
@media (min-width: 900px) {
  .hero { padding: 46px 0 26px; max-width: none; }
  .hero-sub { font-size: 1.08rem; }
}

@media (prefers-reduced-motion: reduce) {
  .aurora, .hero-trace path, .card, .pulse-mark, .hero-kicker::before {
    animation: none;
  }
}

/* --- token facts and how-it-works --- */

.fact-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  padding: 11px 0;
  border-bottom: 1px solid var(--edge);
}

.fact-row:last-of-type { border-bottom: 0; }

.fact-label {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.fact-value {
  font-size: 0.92rem;
  color: var(--ink);
  text-align: right;
}

.mono { font-family: var(--mono); }

.copyable {
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  color: var(--pulse-color);
  font-size: 0.92rem;
  box-shadow: none;
}

.copyable:hover { text-decoration: underline; }

.fact-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 18px;
  flex-wrap: wrap;
}

.fact-actions button { flex: 1 1 auto; }

.ghost-link {
  font-family: var(--mono);
  font-size: 0.76rem;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
}

.ghost-link:hover { color: var(--pulse-color); }

.how-steps {
  margin: 0 0 14px;
  padding-left: 0;
  list-style: none;
  counter-reset: step;
}

.how-steps li {
  counter-increment: step;
  position: relative;
  padding: 0 0 14px 40px;
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--muted);
}

.how-steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: -1px;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--pulse-color);
  border: 1px solid var(--edge-lit);
  background: color-mix(in srgb, var(--pulse-color) 10%, transparent);
}

.how-steps strong { color: var(--ink); font-weight: 600; }
