/* Satoshi Acres — NostrNitro palette: deep blacks, electric purples, bitcoin orange. */
:root {
  --bg: #07040d;
  --bg-2: #0e0819;
  --panel: rgba(20, 11, 36, 0.72);
  --line: rgba(160, 110, 255, 0.22);
  --line-strong: rgba(170, 120, 255, 0.55);
  --purple: #7b2ff7;
  --purple-2: #a66bff;
  --purple-3: #d4b8ff;
  --orange: #f7931a;
  --orange-2: #ffb347;
  --text: #f1eaff;
  --muted: #a99bc4;
  --danger: #ff6b8b;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: 'Space Grotesk', system-ui, -apple-system, Segoe UI, sans-serif;
  --radius: 14px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: radial-gradient(1200px 700px at 15% -10%, #2a0f55 0%, transparent 60%),
              radial-gradient(900px 600px at 110% 110%, #3a1260 0%, transparent 55%),
              var(--bg);
  color: var(--text);
  font-family: var(--sans);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--purple-3); }
button { font: inherit; color: inherit; }

.bg-grid {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse at 50% 30%, #000 0%, transparent 75%);
  opacity: .35;
}

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ── Header ───────────────────────────────────────────── */
.top {
  position: relative; z-index: 2;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px clamp(16px, 3vw, 32px);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.brand-mark { width: 30px; height: 30px; color: var(--purple-2); }
.brand-name { font-family: var(--mono); font-weight: 600; letter-spacing: .22em; font-size: 14px; }
.brand-name span { display: inline-block; white-space: pre; }
.top-actions { display: flex; align-items: center; gap: 10px; }

.icon-toggle {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; cursor: pointer;
  background: rgba(20, 11, 36, .8); border: 1px solid var(--line-strong); color: var(--purple-3);
  transition: border-color .2s, color .2s;
}
.icon-toggle svg { width: 18px; height: 18px; }
.icon-toggle:hover { border-color: var(--orange); }
.icon-toggle[aria-pressed="true"] { color: var(--muted); }
.icon-toggle:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; }
.units { display: flex; border: 1px solid var(--line-strong); border-radius: 999px; overflow: hidden; }
.units button {
  background: none; border: 0; padding: 7px 12px; cursor: pointer;
  font-family: var(--mono); font-size: 12px; color: var(--muted);
}
.units button[aria-pressed="true"] { background: var(--purple); color: #fff; }

/* ── Buttons ──────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: 999px; padding: 10px 16px; cursor: pointer;
  border: 1px solid var(--line-strong); background: rgba(123, 47, 247, .12);
  font-weight: 500; font-size: 14px; white-space: nowrap;
  transition: transform .15s ease, background .2s ease, border-color .2s ease, box-shadow .2s ease;
}
.btn svg { width: 18px; height: 18px; flex: none; }
.btn:hover { transform: translateY(-1px); border-color: var(--purple-2); background: rgba(123, 47, 247, .25); }
.btn:focus-visible, .chip:focus-visible, .rail-step:focus-visible, select:focus-visible, input:focus-visible, .units button:focus-visible {
  outline: 2px solid var(--orange); outline-offset: 2px;
}
.btn-zap {
  background: linear-gradient(135deg, var(--orange), #ff6a00); color: #1a0b00; border-color: transparent;
  font-weight: 700; box-shadow: 0 0 24px rgba(247, 147, 26, .35);
}
.btn-zap:hover { background: linear-gradient(135deg, var(--orange-2), var(--orange)); box-shadow: 0 0 36px rgba(247, 147, 26, .55); }
.btn-x { background: #000; border-color: #3a3150; }
.btn-nostr { background: linear-gradient(135deg, var(--purple), #5a1ccf); border-color: transparent; color: #fff; }
.btn-ghost { background: transparent; }
.btn[disabled] { opacity: .5; cursor: progress; }

/* ── Layout ───────────────────────────────────────────── */
.layout {
  position: relative; z-index: 1;
  display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(320px, 1fr); gap: 20px;
  padding: 0 clamp(16px, 3vw, 32px) 24px;
  max-width: 1500px; margin: 0 auto;
}
@media (max-width: 960px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
}

/* ── Map ──────────────────────────────────────────────── */
.map-panel { min-width: 0; }
.map-frame {
  position: relative; border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(25, 10, 48, .85), rgba(8, 4, 16, .9));
  overflow: hidden;
  box-shadow: 0 0 0 1px rgba(0,0,0,.6) inset, 0 30px 80px -30px rgba(123, 47, 247, .45);
  touch-action: pan-y;
}
#map { display: block; width: 100%; height: auto; }
.map-bg { fill: url(#fine-grid); }
.grid-line { stroke: rgba(166, 107, 255, .07); stroke-width: 1; }

.graticule path { fill: none; stroke: rgba(166, 107, 255, .28); stroke-width: .7; stroke-dasharray: 2 3; }
.context path { fill: rgba(123, 47, 247, .07); stroke: rgba(166, 107, 255, .35); stroke-width: .6; }
.context path.crater { fill: rgba(0,0,0,.18); stroke: rgba(212, 184, 255, .3); }
.morph path { fill: url(#shape-fill); stroke: var(--purple-2); stroke-width: 1.6; stroke-linejoin: round; filter: url(#glow); }
.detail path { fill: url(#shape-fill); stroke: var(--purple-3); stroke-width: 1.2; stroke-linejoin: round; filter: url(#glow); }
.detail path.sphere-edge { fill: rgba(123, 47, 247, .1); stroke: var(--purple-2); stroke-width: 1.5; }
.detail path.land { fill: rgba(166, 107, 255, .32); stroke: var(--purple-3); stroke-width: .6; filter: none; }
.detail path.land.dim { fill: rgba(166, 107, 255, .12); stroke: rgba(212,184,255,.5); }
.detail path.sphere-edge.ocean { fill: rgba(166, 107, 255, .35); }
.body-mars .morph path, .body-mars .detail path.sphere-edge { stroke: var(--orange-2); }
.body-mars .detail path.sphere-edge { fill: rgba(247, 100, 26, .18); }
.body-mars .context path.crater { stroke: rgba(255, 179, 71, .35); }

.hud text { font-family: var(--mono); fill: var(--muted); font-size: 11px; letter-spacing: .08em; }
.hud .hud-strong { fill: var(--text); font-size: 13px; font-weight: 600; }
.hud .hud-accent { fill: var(--orange); }
.hud .bracket { fill: none; stroke: var(--purple-2); stroke-width: 2; }
.hud .tick { stroke: var(--line-strong); stroke-width: 1; }
.hud .scale-bar { stroke: var(--purple-3); stroke-width: 2; fill: none; }

.plot g, .plot circle, .lens g { transform-box: fill-box; transform-origin: center; }
.plot .reticle-ring { fill: none; stroke: var(--orange); stroke-width: 1.5; }
.plot .reticle-cross { stroke: var(--orange); stroke-width: 1; }
.plot .reticle-dot { fill: var(--orange); filter: url(#glow-strong); }
.plot .leader { fill: none; stroke: var(--orange); stroke-width: 1; stroke-dasharray: 3 3; opacity: .8; }
.plot text { font-family: var(--mono); font-size: 11px; fill: var(--orange); letter-spacing: .06em; }

.lens .lens-box { fill: rgba(7, 4, 13, .88); stroke: var(--orange); stroke-width: 1.2; }
.lens .lens-grid { stroke: rgba(166, 107, 255, .18); stroke-width: .6; }
.lens .lens-ref { fill: rgba(123, 47, 247, .18); stroke: var(--purple-2); stroke-width: 1.2; stroke-dasharray: 4 3; }
.lens .lens-btc { fill: var(--orange); filter: url(#glow); }
.lens text { font-family: var(--mono); font-size: 11px; fill: var(--muted); letter-spacing: .05em; }
.lens .lens-title { fill: var(--orange); font-weight: 600; }
.lens .lens-label-btc { fill: var(--orange-2); }
.lens .lens-label-ref { fill: var(--purple-3); }

.scanline {
  position: absolute; left: 0; right: 0; height: 120px; top: -120px; pointer-events: none;
  background: linear-gradient(180deg, transparent, rgba(166, 107, 255, .08) 70%, rgba(212, 184, 255, .22) 100%);
  animation: scan 6s linear infinite;
}
@keyframes scan { to { transform: translateY(calc(100vh + 240px)); } }

/* ── Location rail ───────────────────────────────────── */
.rail { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.chips {
  display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x proximity; padding: 4px 2px;
  scrollbar-width: none; flex: 1; min-width: 0;
  mask-image: linear-gradient(90deg, transparent, #000 16px, #000 calc(100% - 16px), transparent);
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; scroll-snap-align: center; cursor: pointer;
  border: 1px solid var(--line); border-radius: 999px; background: rgba(20, 11, 36, .8);
  padding: 8px 14px; font-size: 13px; color: var(--muted); white-space: nowrap;
  transition: color .2s, border-color .2s, background .2s;
}
.chip:hover { color: var(--text); border-color: var(--line-strong); }
.chip[aria-current="true"] { color: #1a0b00; background: var(--orange); border-color: var(--orange); font-weight: 600; }
.chip .pin { margin-right: 4px; }
.rail-step {
  flex: none; width: 40px; height: 40px; border-radius: 50%; cursor: pointer;
  border: 1px solid var(--line-strong); background: rgba(20, 11, 36, .8);
  display: grid; place-items: center;
}
.rail-step svg { width: 18px; height: 18px; fill: none; stroke: var(--text); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.rail-step:hover { border-color: var(--orange); }

/* ── Readout ─────────────────────────────────────────── */
.readout {
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel);
  backdrop-filter: blur(10px); padding: clamp(18px, 2.4vw, 28px);
  display: flex; flex-direction: column; gap: 18px; min-width: 0;
}
.eyebrow { margin: 0; font-family: var(--mono); font-size: 12px; letter-spacing: .18em; text-transform: uppercase; color: var(--purple-2); }
.loc-head h1 { margin: 4px 0 10px; font-size: clamp(30px, 4vw, 44px); line-height: 1.05; letter-spacing: -.01em; }
.loc-head h1 span { display: inline-block; white-space: pre; }
.picker select {
  width: 100%; appearance: none; cursor: pointer;
  background: rgba(7, 4, 13, .6) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 9l6 6 6-6' fill='none' stroke='%23a66bff' stroke-width='2'/%3E%3C/svg%3E") no-repeat right 12px center / 16px;
  border: 1px solid var(--line-strong); border-radius: 10px; color: var(--text);
  padding: 10px 36px 10px 12px; font: inherit; font-size: 14px;
}
.picker option { background: var(--bg-2); }

.hero-stat {
  display: grid; gap: 2px; padding: 16px 18px; border-radius: 12px;
  background: linear-gradient(135deg, rgba(247, 147, 26, .14), rgba(123, 47, 247, .12));
  border: 1px solid rgba(247, 147, 26, .4);
}
.hero-label { font-family: var(--mono); font-size: 14px; color: var(--muted); }
.btc { color: var(--orange); }
.hero-value { font-family: var(--mono); font-weight: 600; font-size: clamp(34px, 4.6vw, 52px); color: var(--orange); line-height: 1.1; text-shadow: 0 0 30px rgba(247, 147, 26, .45); word-break: break-word; }
.hero-unit { font-size: .55em; color: var(--orange-2); }
.hero-of { color: var(--muted); font-size: 14px; }
.approx { margin-left: 4px; color: var(--purple-2); cursor: help; }

.blurb { margin: 0; color: var(--text); opacity: .85; line-height: 1.5; }

.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 0; }
.stat { padding: 12px; border-radius: 10px; border: 1px solid var(--line); background: rgba(7, 4, 13, .45); min-width: 0; }
.stat dt { font-family: var(--mono); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.stat dd { margin: 4px 0 0; font-family: var(--mono); font-size: 16px; font-weight: 600; overflow-wrap: anywhere; }
.stat dd small { display: block; font-family: var(--sans); font-weight: 400; color: var(--muted); font-size: 12px; margin-top: 2px; }

.stack { border-top: 1px solid var(--line); padding-top: 14px; }
.stack-label { font-family: var(--mono); font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--purple-2); }
.stack-row { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.stack-row input {
  flex: 1; min-width: 0; background: rgba(7, 4, 13, .6); color: var(--text);
  border: 1px solid var(--line-strong); border-radius: 10px; padding: 10px 12px;
  font-family: var(--mono); font-size: 18px;
}
.stack-btc { font-family: var(--mono); font-size: 22px; color: var(--orange); }
.stack-out { margin: 8px 0 0; color: var(--text); line-height: 1.5; }
.stack-out b { color: var(--orange); font-family: var(--mono); }

.share { display: flex; flex-wrap: wrap; gap: 8px; }

.foot {
  position: relative; z-index: 1; max-width: 1500px; margin: 0 auto;
  padding: 8px clamp(16px, 3vw, 32px) 32px; color: var(--muted); font-size: 13px; line-height: 1.6;
}
.foot p { margin: 4px 0; }

/* ── Dialogs ─────────────────────────────────────────── */
.dialog {
  width: min(440px, calc(100vw - 32px)); border-radius: 18px; padding: 22px;
  background: linear-gradient(180deg, #170b2b, #0b0614); color: var(--text);
  border: 1px solid var(--line-strong); box-shadow: 0 30px 80px rgba(0,0,0,.6), 0 0 60px rgba(123, 47, 247, .3);
}
.dialog::backdrop { background: rgba(4, 2, 8, .7); backdrop-filter: blur(4px); }
.dialog h2 { margin: 0 0 14px; font-size: 20px; display: flex; align-items: center; gap: 8px; }
.dialog h2 svg { width: 22px; height: 22px; color: var(--orange); }
.dialog-close-form { position: absolute; top: 12px; right: 12px; margin: 0; }
.icon-btn { background: none; border: 0; color: var(--muted); font-size: 18px; cursor: pointer; padding: 6px; }
.dialog textarea {
  width: 100%; resize: vertical; background: rgba(7, 4, 13, .6); color: var(--text);
  border: 1px solid var(--line-strong); border-radius: 10px; padding: 10px; font: inherit; font-size: 14px;
}
.dialog-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.hint { color: var(--muted); font-size: 13px; line-height: 1.5; margin: 8px 0 0; }
.hint.error { color: var(--danger); }

.amounts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.amount {
  border: 1px solid var(--line-strong); border-radius: 10px; background: rgba(7, 4, 13, .5);
  padding: 10px 4px; cursor: pointer; font-family: var(--mono); font-size: 14px;
}
.amount[aria-pressed="true"] { background: var(--orange); color: #1a0b00; border-color: var(--orange); font-weight: 700; }
.zap-field { display: grid; gap: 6px; margin-top: 12px; font-size: 13px; color: var(--muted); }
.zap-field input {
  background: rgba(7, 4, 13, .6); color: var(--text); border: 1px solid var(--line-strong);
  border-radius: 10px; padding: 10px; font: inherit; font-size: 14px;
}
.qr { background: #fff; border-radius: 12px; padding: 10px; width: min(260px, 100%); margin: 6px auto 12px; }
.qr svg { display: block; width: 100%; height: auto; }
.invoice {
  font-family: var(--mono); font-size: 11px; color: var(--muted); word-break: break-all;
  max-height: 3.6em; overflow: hidden; margin: 0 0 10px;
}
.zap-done { text-align: center; padding: 16px 0; }
.zap-done .big-bolt { width: 72px; height: 72px; color: var(--orange); filter: drop-shadow(0 0 18px rgba(247,147,26,.8)); }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 140%); z-index: 50;
  background: #1b0e33; border: 1px solid var(--purple-2); color: var(--text);
  padding: 10px 16px; border-radius: 999px; font-size: 14px; max-width: calc(100vw - 32px);
  box-shadow: 0 10px 40px rgba(0,0,0,.5); opacity: 0;
}

@media (max-width: 520px) {
  .brand-name { font-size: 12px; letter-spacing: .14em; }
  .units button { padding: 6px 9px; }
  .btn-zap span { display: none; }
  .btn-zap { padding: 10px 12px; }
  .share .btn { flex: 1 1 calc(50% - 8px); }
}

@media (prefers-reduced-motion: reduce) {
  .scanline { display: none; }
}
