:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #f0ede7;
  --text: #1f2937;
  --muted: #5b6472;
  --accent: #0f766e;
  --accent-2: #115e59;
  --border: #dde3ea;
  --success: #166534;
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
  --radius: 18px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, #f8f7f4 0%, #eef4f2 100%);
}

.app-shell {
  max-width: 820px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 24px 16px 40px;
}

.topbar, .footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar { margin-bottom: 20px; }
.footer {
  margin-top: 20px;
  color: var(--muted);
  font-size: 14px;
  justify-content: center;
}

.brand {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.tagline {
  color: var(--muted);
  max-width: 540px;
}

.app {
  background: rgba(255,255,255,0.72);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(221, 227, 234, 0.8);
  border-radius: 28px;
  padding: 24px;
  min-height: 70vh;
  box-shadow: var(--shadow);
}

.screen {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.narrow { max-width: 620px; margin: 0 auto; width: 100%; }
.hero h1 {
  margin: 0 0 8px;
  font-size: 34px;
  letter-spacing: -0.03em;
}
.hero.compact h1 { font-size: 30px; }
.subtle { color: var(--muted); margin: 0; line-height: 1.5; }

.grid.activities {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.activity-card, .card, .chip, .primary-btn, .secondary-btn, .ghost-btn {
  border-radius: var(--radius);
}

.activity-card {
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 22px 16px;
  min-height: 130px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.activity-card:hover { transform: translateY(-2px); border-color: var(--accent); box-shadow: var(--shadow); }
.emoji { font-size: 32px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 18px;
}
.muted-card { background: var(--surface-2); }
.card h3 { margin: 0 0 10px; }
.card ul { margin: 0; padding-left: 20px; color: var(--muted); }
.card li { margin: 6px 0; }

label { font-weight: 700; display: block; margin-bottom: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip {
  border: 1px solid var(--border);
  background: #fff;
  padding: 12px 16px;
  cursor: pointer;
  font-size: 15px;
}
.chip.active { background: #e7f6f4; border-color: var(--accent); color: var(--accent-2); font-weight: 700; }

.primary-btn, .secondary-btn, .ghost-btn {
  border: none;
  cursor: pointer;
  padding: 14px 18px;
  font-size: 16px;
  font-weight: 700;
}
.primary-btn { background: var(--accent); color: white; }
.primary-btn:disabled { opacity: .45; cursor: not-allowed; }
.secondary-btn { background: #e8edf1; color: var(--text); }
.ghost-btn { background: transparent; color: var(--muted); border: 1px solid var(--border); }

.back-link {
  border: none;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  font-size: 15px;
  padding: 0;
  text-align: left;
  cursor: pointer;
}

.pill, .status-badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 14px;
  font-weight: 700;
}
.pill { background: #e8f6f4; color: var(--accent-2); }
.status-badge { background: #eef2ff; color: #4338ca; }
.status-badge.success { background: #ecfdf3; color: var(--success); }

.summary-card, .privacy-list, .toggle-card { display: flex; flex-direction: column; gap: 10px; }
.summary-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}
.summary-row span { color: var(--muted); }
.summary-row strong { text-align: right; }

.toggle-card {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
}
.toggle-title { font-weight: 700; margin-bottom: 4px; }

.switch { position: relative; display: inline-block; width: 52px; height: 30px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; inset: 0; cursor: pointer; background: #cbd5e1; transition: .2s; border-radius: 999px;
}
.slider:before {
  content: ""; position: absolute; height: 22px; width: 22px; left: 4px; top: 4px; background: white; transition: .2s; border-radius: 50%;
}
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider:before { transform: translateX(22px); }

.actions-row, .actions-col { display: flex; gap: 12px; }
.actions-col { flex-direction: column; }

#matchArrivalCard { display: none; }
#matchArrivalCard.visible { display: block; }
.match-pulse {
  width: 12px; height: 12px; border-radius: 50%; background: var(--accent); margin-bottom: 12px; box-shadow: 0 0 0 0 rgba(15, 118, 110, 0.5); animation: pulse 1.8s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(15, 118, 110, 0.5); }
  70% { box-shadow: 0 0 0 14px rgba(15, 118, 110, 0); }
  100% { box-shadow: 0 0 0 0 rgba(15, 118, 110, 0); }
}

/* ── Key management panel ──────────────────────────────────────── */

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.key-btn {
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.npub-short {
  font-family: ui-monospace, monospace;
  font-size: 11px;
  opacity: 0.6;
  letter-spacing: -0.02em;
}

.key-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.key-panel-inner {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.key-field label { font-weight: 700; font-size: 13px; margin-bottom: 6px; }

.key-value {
  font-family: ui-monospace, monospace;
  font-size: 11px;
  color: var(--muted);
  word-break: break-all;
  margin-bottom: 8px;
  line-height: 1.5;
}

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

.key-import-row {
  display: flex;
  gap: 8px;
}

.key-import-row input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px;
  font-family: ui-monospace, monospace;
  background: var(--bg);
  color: var(--text);
  min-width: 0;
}

.small-btn {
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 10px;
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text);
  white-space: nowrap;
}
.small-btn.accent { background: var(--accent); color: white; border-color: var(--accent); }
.small-btn:hover { border-color: var(--accent); }

.key-error {
  margin-top: 6px;
  color: #dc2626;
  font-size: 13px;
}

.key-note {
  font-size: 12px;
  color: var(--muted);
  margin: 0;
}

/* ── Status banner ─────────────────────────────────────────────── */

.status-banner {
  background: #f0fdf4;
  border: 1px solid #86efac;
  color: #166534;
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 14px;
  margin-bottom: 12px;
}
.status-banner.error {
  background: #fef2f2;
  border-color: #fca5a5;
  color: #dc2626;
}

/* ── Relay label ───────────────────────────────────────────────── */

.relay-label {
  font-family: ui-monospace, monospace;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
}

.relay-row { opacity: 0.75; }

/* ── Responsive ────────────────────────────────────────────────── */

@media (max-width: 700px) {
  .grid.activities { grid-template-columns: 1fr; }
  .summary-row { flex-direction: column; }
  .summary-row strong { text-align: left; }
  .topbar { flex-direction: column; align-items: flex-start; }
  .actions-row { flex-direction: column; }
  .topbar-actions { width: 100%; justify-content: flex-end; }
  .key-import-row { flex-direction: column; }
}
