:root {
  color-scheme: light dark;
  --bg: #111;
  --ink: #ddd;
  --accent: #999;
  --accent-hover: #bbb;
  --card: #1a1a1a;
  --card-hover: #222;
  --border: #333;
  --shadow: rgba(0, 0, 0, 0.4);
  --link-hover: rgba(255, 255, 255, 0.05);
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f5f5f5;
    --ink: #222;
    --accent: #555;
    --accent-hover: #333;
    --card: #fff;
    --card-hover: #eee;
    --border: #ddd;
    --shadow: rgba(0, 0, 0, 0.08);
    --link-hover: rgba(0, 0, 0, 0.04);
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  line-height: 1.6;
}

.card {
  max-width: 720px;
  width: 100%;
  padding: 48px;
  border-radius: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  box-shadow: 0 4px 12px var(--shadow);
}

h1 {
  font-size: 2.5rem;
  font-weight: 700;
  margin: 0 0 12px;
  text-align: center;
  color: var(--ink);
}

.subtitle {
  font-size: 1rem;
  color: var(--accent);
  margin: 0 0 32px;
  text-align: center;
}

h2 {
  font-size: 0.875rem;
  margin: 32px 0 16px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
  color: var(--accent);
}

.links-container {
  display: grid;
  gap: 24px;
}

.category-tabs {
  display: none;
}

.category {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.link-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  text-decoration: none;
  color: var(--ink);
  transition: all 250ms cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 3px 3px 0 var(--border);
}

.link-card:hover {
  background: var(--card-hover);
  border-color: var(--accent);
  transform: translate(-2px, -2px);
  box-shadow: 5px 5px 0 var(--accent);
}

.link-icon {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  filter: invert(1);
}

@media (prefers-color-scheme: light) {
  .link-icon {
    filter: none;
  }
}

.link-content {
  flex: 1;
  min-width: 0;
}

.link-content strong {
  display: block;
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 4px;
  word-break: break-word;
}

.link-content p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--accent);
  line-height: 1.5;
  word-break: break-word;
}

.boost-badge {
  display: inline-flex;
  align-items: center;
  color: var(--muted, #888);
  opacity: 0.5;
  flex-shrink: 0;
  transition: opacity 0.2s;
}
.boost-badge:hover {
  opacity: 0.8;
}

.verified-badge {
  display: inline-flex;
  align-items: center;
  color: var(--accent, #4caf50);
  flex-shrink: 0;
  margin-left: 4px;
}

@media (max-width: 768px) {
  .card {
    padding: 32px 24px;
  }

  h1 {
    font-size: 2rem;
  }
}

@media (max-width: 480px) {
  .card {
    padding: 24px 20px;
  }

  h1 {
    font-size: 1.75rem;
  }

  .link-card {
    padding: 14px 16px;
    gap: 12px;
  }

  .link-icon {
    width: 36px;
    height: 36px;
  }

  .link-content strong {
    font-size: 0.95rem;
  }

  .link-content p {
    font-size: 0.85rem;
  }
}

/* ===== Badges Section ===== */
.badges-section {
  margin-top: 32px;
  padding-top: 32px;
  border-top: 1px solid var(--border);
}

.badges-heading {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0 0 16px;
  text-align: center;
  color: var(--ink);
}

.badges-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(115px, 139px));
  justify-content: center;
  gap: 14px;
}

.badge-card {
  position: relative;
  display: block;
  width: 100%;
  text-decoration: none;
  color: inherit;
  outline: none;
}

.badge-media {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  aspect-ratio: 1;
  padding: 10px;
  border-radius: 18px;
  border: 1px solid var(--badge-tile-border, var(--border));
  background: var(--badge-tile-bg, var(--card, #fff));
  box-shadow: 0 8px 22px var(--badge-tile-shadow, transparent);
  transition: transform 200ms ease, box-shadow 200ms ease, border-color 200ms ease;
}

.badge-card:hover .badge-media,
.badge-card:focus-visible .badge-media,
.badge-card:focus-within .badge-media,
.badge-card:active .badge-media {
  transform: translateY(-4px);
  border-color: var(--accent);
  box-shadow: 0 16px 32px var(--badge-hover-shadow, var(--shadow, rgba(0,0,0,0.12)));
}

.badge-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 12px;
}

.badge-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  background: var(--border);
}

.badge-info {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 12px);
  z-index: 5;
  width: min(240px, calc(100vw - 48px));
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--badge-tooltip-border, var(--border));
  background: var(--badge-tooltip-bg, var(--card, #fff));
  box-shadow: 0 18px 40px var(--badge-tooltip-shadow, var(--shadow, rgba(0,0,0,0.14)));
  text-align: left;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 8px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.badge-info::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  width: 12px;
  height: 12px;
  background: inherit;
  border-right: 1px solid var(--badge-tooltip-border, var(--border));
  border-bottom: 1px solid var(--badge-tooltip-border, var(--border));
  transform: translate(-50%, -6px) rotate(45deg);
}

.badge-card:hover .badge-info,
.badge-card:focus-visible .badge-info,
.badge-card:focus-within .badge-info,
.badge-card:active .badge-info {
  opacity: 1;
  transform: translate(-50%, 0);
}

.badge-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.badge-title {
  display: block;
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--ink);
}

.badge-date {
  display: block;
  font-size: 0.72rem;
  color: var(--muted, #888);
  margin-top: 4px;
}

.badge-description {
  margin: 8px 0 0;
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--ink);
}

.badge-link-hint {
  display: inline-block;
  margin-top: 8px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--accent);
}

@media (max-width: 480px) {
  .badges-container {
    grid-template-columns: repeat(auto-fit, minmax(98px, 120px));
    gap: 12px;
  }

  .badge-card {
    max-width: 120px;
  }

  .badge-media {
    padding: 10px;
  }

  .badge-info {
    width: min(210px, calc(100vw - 32px));
  }
}

/* ===== Recent Posts Section ===== */
.recent-posts-section {
  margin-top: 32px;
  padding-top: 32px;
  border-top: 1px solid var(--border);
}

.recent-posts-heading {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0 0 16px;
  text-align: center;
  color: var(--ink);
}

.recent-posts-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.rp-card {
  display: block;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--card, #fff);
  text-decoration: none;
  color: inherit;
  transition: transform 200ms ease, box-shadow 200ms ease;
}

.rp-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px var(--shadow, rgba(0,0,0,0.08));
}

.rp-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.rp-body {
  min-width: 0;
}

.rp-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.rp-name {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--ink);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rp-date {
  font-size: 0.75rem;
  color: var(--muted, #888);
  flex-shrink: 0;
}

.rp-content {
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--ink);
  overflow: hidden;
  display: -webkit-box;
  line-clamp: 4;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  word-break: break-word;
}

.rp-media-wrap {
  margin: 0 0 8px;
}

.rp-media {
  display: block;
  width: 100%;
  max-height: 180px;
  object-fit: cover;
  border-radius: 10px;
  background: color-mix(in srgb, var(--border) 60%, transparent);
}

.rp-content p { margin: 0 0 0.4em; }
.rp-content p:last-child { margin-bottom: 0; }
.rp-content a { color: var(--accent); }
.rp-content img { max-width: 100%; border-radius: 8px; margin-top: 6px; }

.rp-cw summary {
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--accent);
  padding: 2px 0;
}

@media (max-width: 480px) {
  .rp-card { padding: 12px; }
  .rp-content { font-size: 0.82rem; }
  .rp-media { max-height: 140px; }
}

.info-section {
  margin-top: 32px;
  padding-top: 32px;
  border-top: 1px solid var(--border);
}

.info-section summary {
  font-size: 0.95rem;
  color: var(--accent);
  font-weight: 500;
  padding: 12px 0;
  cursor: pointer;
}

.info-section ul {
  margin: 16px 0 0;
  padding-left: 24px;
  font-size: 0.9rem;
  line-height: 1.8;
  color: var(--accent);
}

.info-section li {
  margin-bottom: 8px;
}

.info-section code {
  background: var(--border);
  padding: 3px 8px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.85rem;
}

.fedi-handle-hero {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: -4px 0 8px;
  font-size: 0.9rem;
  color: var(--accent);
}

.fedi-handle-hero [data-fedi-address] {
  font-weight: 500;
}

.copy-fedi-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  padding: 4px;
  color: var(--accent);
  opacity: 0.5;
  transition: opacity 200ms ease, color 200ms ease, transform 150ms ease;
}

.copy-fedi-btn:hover {
  opacity: 1;
}

.copy-fedi-btn:active {
  transform: scale(0.9);
}

.copy-fedi-btn.copied {
  opacity: 1;
  color: #4caf50;
}

.share-btn {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 10px 20px;
  border: 2px solid var(--accent);
  border-radius: 10px;
  background: var(--card);
  color: var(--accent);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 700;
  transition: all 250ms cubic-bezier(0.16, 1, 0.3, 1);
  -webkit-tap-highlight-color: transparent;
}

.share-btn:hover {
  background: var(--accent);
  color: var(--bg);
  box-shadow: 0 0 12px var(--shadow);
}

.share-btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ── Avatar wrapper & QR overlay button ───────────────── */
.avatar-wrapper {
  position: relative;
  width: 120px;
  margin: 0 auto 1rem;
}

.qr-avatar-btn {
  position: absolute;
  bottom: 2px;
  right: -4px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--card, #fff);
  background: var(--accent, #7c3aed);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  transition: transform 200ms ease, box-shadow 200ms ease;
  z-index: 2;
}

.qr-avatar-btn:hover {
  transform: scale(1.15);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

.qr-avatar-btn svg {
  width: 14px;
  height: 14px;
}

/* ── QR Code Modal ─────────────────────────────────────── */
.qr-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: qrFadeIn 200ms ease;
}

@keyframes qrFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.qr-modal {
  position: relative;
  background: var(--card, #fff);
  border-radius: 16px;
  padding: 32px 28px 24px;
  max-width: 340px;
  width: 90vw;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: qrSlideUp 250ms cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes qrSlideUp {
  from { opacity: 0; transform: translateY(24px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.qr-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text, #333);
  opacity: 0.5;
  transition: opacity 200ms;
  line-height: 1;
  padding: 4px 8px;
}

.qr-close:hover {
  opacity: 1;
}

.qr-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0 0 16px;
  color: var(--text, #333);
}

.qr-canvas {
  display: flex;
  justify-content: center;
  margin: 0 auto 12px;
}

.qr-canvas img {
  border-radius: 8px;
}

.qr-url {
  font-size: 0.78rem;
  color: var(--text, #888);
  opacity: 0.6;
  margin: 0 0 16px;
  word-break: break-all;
}

.qr-download-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border: 2px solid var(--accent, #333);
  border-radius: 10px;
  background: transparent;
  color: var(--accent, #333);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 200ms ease;
}

.qr-download-btn:hover {
  background: var(--accent, #333);
  color: var(--bg, #fff);
}
