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

:root {
  --void: #050508;
  --deep: #0A0A1A;
  --surface: #0F0F24;
  --border: #1A1A3A;
  --cyan: #A8B4CC;
  --cyan-dim: #A8B4CC22;
  --amber: #FF6B00;
  --amber-dim: #FF6B0022;
  --red: #FF2244;
  --red-dim: #FF224422;
  --green: #00FF88;
  --green-dim: #00FF8822;
  --white: #F0F0FF;
  --gray: #8888AA;
  --gray-dim: #444466;
}

html { scroll-behavior: smooth; }

body {
  background: var(--void);
  color: var(--white);
  font-family: 'Inter', sans-serif;
  font-size: 16px;
  line-height: 1.6;
  overflow-x: hidden;
  min-height: 100vh;
}

button, .scan-btn, .share-btn, .copy-btn, .chip, .nav-cta, .link-btn, .explorer-link {
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* Ambient glow + scanline */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(900px 500px at 50% -10%, rgba(168,180,204,0.10), transparent 60%),
    radial-gradient(600px 400px at 110% 10%, rgba(255,107,0,0.06), transparent 60%);
  pointer-events: none;
  z-index: 0;
}
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(168,180,204,0.015) 2px, rgba(168,180,204,0.015) 4px);
  pointer-events: none;
  z-index: 1000;
}

/* ── NAV ── */
nav {
  position: sticky;
  top: 0;
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px clamp(20px, 5vw, 64px);
  background: linear-gradient(to bottom, rgba(5,5,8,0.95), transparent);
  backdrop-filter: blur(12px);
}
.nav-logo { display: flex; align-items: center; text-decoration: none; }
.logo-mark { height: 40px; width: auto; display: block; }
.nav-actions { display: flex; gap: 12px; }
.nav-cta {
  display: inline-flex; align-items: center; justify-content: center;
  font-family: 'JetBrains Mono', monospace; font-size: 12px; font-weight: 700;
  color: var(--void); background: var(--white); border: 1px solid var(--white);
  padding: 0 20px; min-height: 42px; cursor: pointer;
  letter-spacing: 0.05em; text-transform: uppercase; text-decoration: none;
  transition: all 0.2s; white-space: nowrap;
}
.nav-cta:hover { background: transparent; color: var(--white); border-color: rgba(240,240,255,0.45); }
.nav-cta--outline { color: var(--gray); background: transparent; border: 2px solid var(--border); font-weight: 500; }
.nav-cta--outline:hover { color: var(--white); border-color: rgba(240,240,255,0.45); }
.nav-cta--x .nav-cta-full { display: inline; }
.nav-cta-icon { display: none; width: 18px; height: 18px; flex-shrink: 0; }

/* ── LAYOUT ── */
#scan { position: relative; z-index: 1; }
.scan-shell {
  max-width: 880px;
  margin: 0 auto;
  padding: clamp(24px, 6vw, 72px) clamp(20px, 5vw, 40px) 64px;
}

.scan-eyebrow {
  display: inline-flex; align-items: center; gap: 12px; flex-wrap: wrap;
  font-family: 'JetBrains Mono', monospace; font-size: 11px; font-weight: 700;
  letter-spacing: 0.18em; text-transform: uppercase; color: var(--cyan);
  margin-bottom: 24px;
}
.scan-status-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--green);
  box-shadow: 0 0 12px var(--green); animation: pulse 2s infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }
.scan-eyebrow-chain { color: var(--gray-dim); border-left: 1px solid var(--border); padding-left: 12px; }

.scan-headline {
  font-size: clamp(34px, 6vw, 60px); font-weight: 700;
  letter-spacing: -0.02em; line-height: 1.04; margin-bottom: 20px;
}
.line-cyan { color: var(--cyan); }

.scan-sub {
  font-size: clamp(15px, 2vw, 18px); font-weight: 300; color: var(--gray);
  max-width: 640px; line-height: 1.7; margin-bottom: 40px;
}
.scan-sub strong { color: var(--white); font-weight: 500; }

/* ── FORM ── */
.scan-form {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: clamp(20px, 4vw, 32px);
}
.chain-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.chip {
  font-family: 'JetBrains Mono', monospace; font-size: 12px; font-weight: 500;
  color: var(--gray); background: transparent; border: 1px solid var(--border);
  padding: 8px 16px; cursor: pointer; letter-spacing: 0.05em;
  text-transform: uppercase; transition: all 0.18s;
}
.chip:hover { color: var(--white); border-color: rgba(240,240,255,0.35); }
.chip.is-active { color: var(--void); background: var(--cyan); border-color: var(--cyan); font-weight: 700; }

.input-row { display: flex; gap: 10px; }
.addr-input {
  flex: 1; min-width: 0;
  background: var(--void); border: 1px solid var(--border); color: var(--white);
  font-size: 14px; padding: 16px 18px; outline: none; transition: border-color 0.2s;
}
.addr-input::placeholder { color: var(--gray-dim); opacity: 1; }
.addr-input:focus { border-color: var(--cyan); }
.scan-btn {
  font-family: 'JetBrains Mono', monospace; font-size: 13px; font-weight: 700;
  color: var(--void); background: var(--white); border: 2px solid var(--white);
  padding: 0 28px; cursor: pointer; letter-spacing: 0.05em; text-transform: uppercase;
  transition: all 0.2s; white-space: nowrap;
}
.scan-btn:hover:not(:disabled) { background: transparent; color: var(--white); border-color: rgba(240,240,255,0.45); }
.scan-btn:disabled { opacity: 0.55; cursor: progress; }

.input-meta {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  margin-top: 12px; flex-wrap: wrap;
}
.detect-hint { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--gray-dim); letter-spacing: 0.05em; }
.detect-hint b { color: var(--cyan); }
.link-btn {
  background: none; border: none; color: var(--gray); cursor: pointer;
  font-family: 'JetBrains Mono', monospace; font-size: 11px; text-decoration: underline;
  text-underline-offset: 3px; letter-spacing: 0.05em;
}
.link-btn:hover { color: var(--white); }
.privacy-note { margin-top: 16px; font-size: 12px; color: var(--gray-dim); line-height: 1.5; }

/* ── STATUS ── */
.scan-status {
  margin-top: 20px; padding: 16px 18px; border: 1px solid var(--border);
  background: var(--deep); font-family: 'JetBrains Mono', monospace; font-size: 13px;
  color: var(--gray); display: flex; align-items: center; gap: 12px;
  min-height: 52px;
}
.scan-status[hidden],
.result[hidden] {
  display: none !important;
}
.scan-status.is-error { border-color: var(--red); color: var(--red); background: var(--red-dim); }
.spinner {
  width: 16px; height: 16px; border: 2px solid var(--border); border-top-color: var(--cyan);
  border-radius: 50%; animation: spin 0.7s linear infinite; flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── RESULT ── */
.result {
  margin-top: 20px; border: 1px solid var(--border); background: var(--surface);
  animation: rise 0.4s ease both;
  scroll-margin-top: 92px;
}
@keyframes rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }

.result-chain-badge {
  font-family: 'JetBrains Mono', monospace; font-size: 10px; font-weight: 700;
  letter-spacing: 0.1em; padding: 4px 8px; background: var(--cyan-dim); color: var(--cyan);
  flex-shrink: 0; line-height: 1.2;
}
.result-identity {
  display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1;
}
.result-address {
  font-size: 13px; color: var(--white); overflow: hidden; text-overflow: ellipsis;
  min-width: 0; line-height: 1.35;
}
.result-action-btns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  flex-shrink: 0;
  width: 100%;
}
.copy-btn, .explorer-link {
  font-family: 'JetBrains Mono', monospace; font-size: 10px; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--gray); background: var(--void);
  border: 1px solid var(--border); padding: 8px 12px; cursor: pointer;
  text-decoration: none; white-space: nowrap;
  transition: color 0.2s, border-color 0.2s;
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px;
  width: 100%;
  -webkit-tap-highlight-color: rgba(168, 180, 204, 0.12);
}
.copy-btn:hover, .explorer-link:hover { color: var(--cyan); border-color: rgba(168,180,204,0.35); }
.copy-btn:active, .explorer-link:active { opacity: 0.85; }

.result-actions {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap; margin-bottom: 12px; padding: 10px 12px;
  border: 1px solid var(--border); background: var(--deep);
}

.result.risk-high   { border-color: rgba(255,34,68,0.35); }
.result.risk-medium { border-color: rgba(255,107,0,0.35); }
.result.risk-low    { border-color: rgba(0,255,136,0.25); }
.result.risk-info   { border-color: rgba(168,180,204,0.35); }

.result-explain {
  padding: clamp(16px, 3vw, 22px) clamp(18px, 4vw, 28px);
  border-top: 1px solid var(--border);
}
.result-explain p { color: var(--gray); font-size: 14px; line-height: 1.65; }
.result-explain p + p { margin-top: 10px; }
.result-explain strong { color: var(--white); font-weight: 500; }
.result-explain code {
  font-family: 'JetBrains Mono', monospace; font-size: 13px; color: var(--cyan);
  background: var(--cyan-dim); padding: 1px 6px;
}

/* ── QP2 CTA ── */
.qp2-cta {
  margin: 0 clamp(18px, 4vw, 28px) clamp(16px, 3vw, 20px);
  padding: clamp(16px, 3vw, 22px);
  border: 1px solid var(--border);
  background: var(--deep);
}
.qp2-cta-label { font-family: 'JetBrains Mono', monospace; font-size: 10px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--cyan); margin-bottom: 10px; }
.qp2-cta-title { font-size: clamp(20px, 3vw, 26px); font-weight: 600; line-height: 1.15; margin-bottom: 12px; }
.qp2-cta-body { color: var(--gray); font-size: 15px; line-height: 1.7; max-width: 620px; }
.qp2-cta-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 22px; }
.qp2-cta-foot { margin-top: 18px; font-size: 12px; color: var(--gray-dim); line-height: 1.5; }

.btn-primary {
  font-family: 'JetBrains Mono', monospace; font-size: 13px; font-weight: 700;
  color: var(--void); background: var(--white); border: 2px solid var(--white);
  padding: 14px 28px; text-decoration: none; letter-spacing: 0.05em;
  text-transform: uppercase; cursor: pointer; transition: all 0.2s; display: inline-block;
  box-shadow: 0 0 24px rgba(168,180,204,0.25);
}
.btn-primary:hover { background: transparent; color: var(--white); border-color: rgba(240,240,255,0.45); box-shadow: 0 0 40px rgba(168,180,204,0.4); }
.btn-secondary {
  font-family: 'JetBrains Mono', monospace; font-size: 13px; font-weight: 500;
  color: var(--gray); background: transparent; border: 2px solid var(--border);
  padding: 14px 28px; text-decoration: none; letter-spacing: 0.05em;
  text-transform: uppercase; cursor: pointer; transition: all 0.2s; display: inline-block;
}
.btn-secondary:hover { border-color: rgba(240,240,255,0.45); color: var(--white); }

/* ── SHARE ── */
.share-block {
  padding: clamp(16px, 3vw, 22px) clamp(18px, 4vw, 28px) clamp(14px, 2vw, 18px);
}
.share-block--hero {
  background: linear-gradient(180deg, rgba(168,180,204,0.04), transparent 48%);
}
.share-head {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  flex-wrap: wrap; margin-bottom: 12px;
}
.share-label {
  font-family: 'JetBrains Mono', monospace; font-size: 11px; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--cyan); margin-bottom: 0;
}
.share-privacy {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}
.privacy-toggle {
  display: inline-flex; align-items: center; gap: 7px; cursor: pointer;
  font-family: 'JetBrains Mono', monospace; font-size: 10px; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--gray); user-select: none;
}
.privacy-toggle input {
  position: absolute; opacity: 0; width: 0; height: 0; pointer-events: none;
}
.privacy-toggle-box {
  width: 14px; height: 14px; border: 1px solid var(--border); background: var(--void);
  flex-shrink: 0; transition: background 0.15s, border-color 0.15s;
}
.privacy-toggle input:checked + .privacy-toggle-box {
  background: var(--cyan); border-color: var(--cyan);
  box-shadow: inset 0 0 0 2px var(--void);
}
.privacy-toggle:hover .privacy-toggle-label { color: var(--white); }
.privacy-toggle input:focus-visible + .privacy-toggle-box { outline: 2px solid var(--cyan); outline-offset: 2px; }

.share-preview {
  margin: 0 0 12px; border: 1px solid var(--border); background: var(--void);
  line-height: 0; position: relative; aspect-ratio: 1200 / 630; overflow: hidden;
}
.share-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.share-preview img[hidden] { display: none !important; }
.share-preview-loading {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  font-family: 'JetBrains Mono', monospace; font-size: 12px; color: var(--gray);
}
.share-preview-loading[hidden] { display: none !important; }

.share-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  align-items: stretch;
}
.share-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font-family: 'JetBrains Mono', monospace; font-size: 11px; font-weight: 700;
  color: var(--white); background: var(--void); border: 1px solid var(--border);
  min-height: 42px; padding: 0 10px; cursor: pointer; letter-spacing: 0.03em;
  transition: border-color 0.18s, color 0.18s, background 0.18s;
  white-space: nowrap;
}
.share-btn svg { width: 14px; height: 14px; flex-shrink: 0; }
.share-btn-label { overflow: hidden; text-overflow: ellipsis; }
.share-btn:hover { border-color: var(--cyan); color: var(--cyan); }
.share-btn--card {
  color: var(--void); background: var(--cyan); border-color: var(--cyan);
}
.share-btn--card:hover { color: var(--void); background: var(--white); border-color: var(--white); }
.share-btn--x:hover { border-color: var(--white); color: var(--white); }
.share-btn--tg:hover { border-color: #29a9ea; color: #29a9ea; }
.share-btn--wa:hover { border-color: #25d366; color: #25d366; }
.share-btn--rd:hover { border-color: #ff4500; color: #ff4500; }
.share-btn.copied { border-color: var(--green); color: var(--green); }

@media (max-width: 720px) {
  .share-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  nav {
    padding: 12px max(16px, env(safe-area-inset-right)) 12px max(16px, env(safe-area-inset-left));
    padding-top: max(12px, env(safe-area-inset-top));
  }
  .logo-mark { height: 34px; width: auto; }
  .nav-actions { gap: 8px; }
  .nav-cta { min-height: 40px; padding: 0 14px; font-size: 11px; }
  .nav-cta--outline { display: none; }
  .nav-cta--x {
    width: 40px;
    min-width: 40px;
    padding: 0;
    background: transparent;
    color: var(--white);
    border: 2px solid var(--border);
  }
  .nav-cta--x .nav-cta-full { display: none; }
  .nav-cta--x .nav-cta-icon { display: block; }

  .scan-shell {
    padding: 20px max(16px, env(safe-area-inset-right)) 48px max(16px, env(safe-area-inset-left));
  }
  .scan-eyebrow-chain { display: none; }
  .scan-sub { margin-bottom: 28px; }

  .chain-chips {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 6px;
    margin: 0 -4px 16px;
    padding: 0 4px 2px;
  }
  .chain-chips::-webkit-scrollbar { display: none; }
  .chip {
    flex: 0 0 auto;
    min-height: 44px;
    padding: 10px 14px;
    font-size: 11px;
  }

  .input-row {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .addr-input {
    font-size: 16px;
    padding: 14px 16px;
    text-align: center;
  }
  .addr-input:focus,
  .addr-input:not(:placeholder-shown) {
    text-align: left;
  }
  .addr-input::placeholder {
    font-size: 14px;
    letter-spacing: 0.02em;
  }
  .scan-btn {
    width: 100%;
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .input-meta { flex-direction: column; align-items: flex-start; gap: 8px; }

  .result { scroll-margin-top: 72px; }
  .share-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  .share-privacy { gap: 10px 14px; }
  .result-actions {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 12px;
  }
  .result-identity {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 8px;
  }
  .result-chain-badge { margin-top: 0; }
  .result-address {
    font-size: 12px;
    white-space: normal;
    word-break: break-all;
    overflow: visible;
    text-overflow: unset;
    text-align: center;
    width: 100%;
  }

  .qp2-cta { margin-inline: 16px; }
  .qp2-cta-actions { flex-direction: column; }
  .qp2-cta-actions .btn-primary,
  .qp2-cta-actions .btn-secondary {
    width: 100%;
    text-align: center;
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .scan-footer {
    flex-direction: column;
    gap: 10px;
    padding-bottom: max(48px, env(safe-area-inset-bottom));
  }
}

@media (max-width: 520px) {
  .share-row { grid-template-columns: 1fr; }
  .share-btn {
    font-size: 11px;
    padding: 0 12px;
    min-height: 44px;
    white-space: normal;
  }
  .share-btn svg { width: 14px; height: 14px; }
  .how-grid { grid-template-columns: 1fr; }
}

/* ── Debug log panel (?debug=1) ── */
.qp2-log-panel {
  position: fixed;
  right: max(12px, env(safe-area-inset-right));
  bottom: max(12px, env(safe-area-inset-bottom));
  z-index: 9999;
  width: min(360px, calc(100vw - 24px));
  max-height: min(240px, 40vh);
  background: rgba(5, 5, 8, 0.96);
  border: 1px solid var(--border);
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--gray);
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}
.qp2-log-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  color: var(--cyan);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  flex-shrink: 0;
}
.qp2-log-head button {
  background: none;
  border: 1px solid var(--border);
  color: var(--gray);
  font-family: inherit;
  font-size: 9px;
  padding: 4px 8px;
  cursor: pointer;
  text-transform: uppercase;
}
.qp2-log-list {
  list-style: none;
  margin: 0;
  padding: 6px 0;
  overflow-y: auto;
  flex: 1;
}
.qp2-log-list li {
  padding: 4px 10px;
  line-height: 1.4;
  border-bottom: 1px solid rgba(26, 26, 58, 0.5);
  word-break: break-word;
}

@media (max-width: 600px) {
  .input-row { flex-direction: column; }
}

/* ── HOW GRID ── */
.how-grid {
  margin-top: 40px; display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.how-grid[hidden] { display: none !important; }
.how-card { border: 1px solid var(--border); background: var(--deep); padding: 24px; }
.how-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border: 1px solid var(--border); border-radius: 50%;
  font-size: 22px; color: var(--cyan); margin-bottom: 16px;
}
.how-title { font-family: 'Space Grotesk', sans-serif; font-size: 18px; font-weight: 600; margin-bottom: 10px; }
.how-body { font-size: 14px; color: var(--gray); line-height: 1.65; }
.how-body strong { color: var(--white); }

/* ── FOOTER ── */
.scan-footer {
  position: relative; z-index: 1;
  display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  max-width: 880px; margin: 0 auto; padding: 28px clamp(20px, 5vw, 40px) 56px;
  border-top: 1px solid var(--border);
  font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--gray-dim);
  letter-spacing: 0.04em;
}
.scan-footer a { color: var(--gray); text-decoration: none; }
.scan-footer a:hover { color: var(--cyan); }

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