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

:root {
  color-scheme: dark;
  --bg: #0b0f14;
  --surface: #121821;
  --surface-2: #1a2230;
  --border: #2a3548;
  --text: #e8edf5;
  --muted: #8b98ab;
  --accent: #5b8def;
  --accent-hover: #7aa3f5;
  --success: #3dd68c;
  --warning: #f5b942;
  --danger: #f07178;
  --radius: 12px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  font-family: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(91, 141, 239, 0.18), transparent),
    var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 2.5rem 1.25rem 4rem;
}

header {
  margin-bottom: 2rem;
}

h1 {
  margin: 0 0 0.5rem;
  font-size: clamp(1.75rem, 4vw, 2.25rem);
  font-weight: 600;
  letter-spacing: -0.02em;
}

.subtitle {
  margin: 0;
  color: var(--muted);
  max-width: 52ch;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

label {
  display: block;
  font-weight: 500;
  margin-bottom: 0.5rem;
}

textarea {
  width: 100%;
  min-height: 160px;
  resize: vertical;
  padding: 0.875rem 1rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.9rem;
  line-height: 1.6;
}

textarea:focus {
  outline: 2px solid rgba(91, 141, 239, 0.45);
  border-color: var(--accent);
}

.hint {
  margin: 0.5rem 0 1rem;
  color: var(--muted);
  font-size: 0.875rem;
}

.actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: center;
}

button {
  appearance: none;
  border: none;
  border-radius: 10px;
  padding: 0.75rem 1.25rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

button:active {
  transform: translateY(1px);
}

#scan-btn {
  background: var(--accent);
  color: #fff;
}

#scan-btn:hover:not(:disabled) {
  background: var(--accent-hover);
}

#scan-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

#clear-btn {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}

#clear-btn:hover {
  color: var(--text);
  border-color: var(--muted);
}

#status {
  margin-top: 1rem;
  min-height: 1.25rem;
  color: var(--muted);
  font-size: 0.875rem;
}

#status.error {
  color: var(--danger);
}

.summary {
  display: none;
  margin-top: 1.5rem;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.summary.visible {
  display: grid;
}

.stat {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.875rem 1rem;
}

.stat-label {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat-value {
  font-size: 1.35rem;
  font-weight: 600;
}

.stat-value.highlight {
  color: var(--success);
}

#results {
  margin-top: 1.5rem;
  display: grid;
  gap: 1rem;
}

.result-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.result-card.empty {
  opacity: 0.75;
}

.result-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  padding: 1rem 1.25rem;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}

.address {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.85rem;
  word-break: break-all;
}

.badge {
  flex-shrink: 0;
  padding: 0.25rem 0.625rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge.found {
  background: rgba(61, 214, 140, 0.15);
  color: var(--success);
}

.badge.none {
  background: rgba(139, 152, 171, 0.15);
  color: var(--muted);
}

.protocol-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.protocol-item {
  padding: 0.875rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.25rem 1rem;
  align-items: start;
}

.protocol-item:last-child {
  border-bottom: none;
}

.protocol-name {
  font-weight: 500;
}

.protocol-meta {
  color: var(--muted);
  font-size: 0.8rem;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
}

.protocol-balance {
  text-align: right;
  font-weight: 600;
  color: var(--success);
  font-variant-numeric: tabular-nums;
}

.empty-msg {
  padding: 1rem 1.25rem;
  color: var(--muted);
}

#invalid {
  margin-top: 1rem;
  padding: 0.875rem 1rem;
  border-radius: 10px;
  background: rgba(240, 113, 120, 0.1);
  border: 1px solid rgba(240, 113, 120, 0.25);
  color: var(--danger);
  font-size: 0.875rem;
  display: none;
}

footer {
  margin-top: 2.5rem;
  color: var(--muted);
  font-size: 0.8rem;
  text-align: center;
}

footer a {
  color: var(--accent);
  text-decoration: none;
}

footer a:hover {
  text-decoration: underline;
}

@media (max-width: 600px) {
  .protocol-item {
    grid-template-columns: 1fr;
  }

  .protocol-balance {
    text-align: left;
  }
}
