:root {
  --bg: #efefed;
  --bg-top: #f8f8f6;
  --card: #ffffff;
  --ink: #111111;
  --muted: #6b6b68;
  --line: rgba(17, 17, 17, 0.08);
  --placeholder: #f1f1ef;
  --radius: 14px;
  --shadow:
    0.3px 0.5px 0.7px rgba(17, 17, 17, 0.03),
    0.9px 1.8px 2.5px -0.6px rgba(17, 17, 17, 0.04),
    2px 4px 5.5px -1.2px rgba(17, 17, 17, 0.045),
    4.6px 9.3px 12.8px -1.7px rgba(17, 17, 17, 0.05);
  --shadow-hover:
    0.6px 1px 1.4px rgba(17, 17, 17, 0.04),
    2px 4px 6px -1px rgba(17, 17, 17, 0.06),
    6px 12px 20px -3px rgba(17, 17, 17, 0.08);
  --grain-opacity: 0.05;
  --sheen: rgba(255, 255, 255, 0.55);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

body.theme-dark {
  --bg: #0f0f0e;
  --bg-top: #1b1b19;
  --card: #1c1c1a;
  --ink: #f5f3ee;
  --muted: #9a978f;
  --line: rgba(245, 243, 238, 0.1);
  --placeholder: #2a2a27;
  --shadow: 0 0 0 1px rgba(245, 243, 238, 0.06), 0 6px 16px -6px rgba(0, 0, 0, 0.6);
  --shadow-hover: 0 0 0 1px rgba(245, 243, 238, 0.12), 0 12px 24px -8px rgba(0, 0, 0, 0.7);
  --grain-opacity: 0.07;
  --sheen: rgba(255, 255, 255, 0.07);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: radial-gradient(120% 60% at 50% 0%, var(--bg-top) 0%, var(--bg) 60%) fixed, var(--bg);
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.3s ease;
}

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: var(--grain-opacity);
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.page {
  position: relative;
  max-width: 580px;
  margin: 0 auto;
  padding: 72px 16px calc(56px + env(safe-area-inset-bottom));
}
.page[aria-busy="true"] { visibility: hidden; }

/* ---------- Profile ---------- */
.profile { text-align: center; margin-bottom: 28px; }
.avatar {
  width: 96px; height: 96px;
  border-radius: 50%;
  object-fit: cover;
  background: #f5f2ea;
  display: block;
  margin: 0 auto 16px;
}
.profile h1 { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; margin: 0 0 6px; }
.bio { font-size: 16px; margin: 0; }

/* ---------- Block grid ---------- */
.blocks {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
}
.blocks > * { grid-column: 1 / -1; min-width: 0; }
.blocks > .half { grid-column: auto; }
.blocks > .half.solo { grid-column: 1 / -1; justify-self: center; width: calc(50% - 6px); }

/* Entrance: blocks rise in as they scroll into view. "backwards" fill means the
   animation lets go when it ends, so hover transitions stay smooth afterwards. */
.blocks > .pending { opacity: 0; }
.blocks > .in { animation: rise 0.75s var(--ease) backwards; }
@keyframes rise { from { opacity: 0; transform: translateY(18px) scale(0.98); filter: blur(4px); } }

/* ---------- Headers & text ---------- */
.b-header {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-align: center;
  margin: 22px 0 2px;
}
.blocks > .b-header:first-child { margin-top: 0; }
.b-text {
  margin: 6px 8px;
  text-align: center;
  font-size: 15px;
  line-height: 1.5;
  color: var(--muted);
}

/* ---------- Link blocks (shared) ---------- */
.b-link {
  position: relative;
  display: flex;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: var(--ink);
  text-decoration: none;
  isolation: isolate;
  transition: transform 0.55s var(--ease), box-shadow 0.55s var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.b-link:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.b-link:active { transform: scale(0.975); transition-duration: 0.18s; }
.art { display: block; overflow: hidden; background: var(--placeholder); flex: none; }
.art img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform 0.9s var(--ease); }

@media (hover: hover) {
  .b-link:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); }
  .b-link:active { transform: translateY(-1px) scale(0.98); }
  .b-link:hover .art img { transform: scale(1.06); }
  .b-link:hover .go { transform: translateX(3px); }
}

/* Featured: outline plus a slow sheen that sweeps across now and then */
.b-link.featured { box-shadow: var(--shadow), inset 0 0 0 1.5px var(--ink); overflow: hidden; }
@media (hover: hover) { .b-link.featured:hover { box-shadow: var(--shadow-hover), inset 0 0 0 1.5px var(--ink); } }
.b-link.featured::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: linear-gradient(110deg, transparent 35%, var(--sheen) 50%, transparent 65%);
  background-size: 300% 100%;
  background-position: 120% 0;
  animation: sheen 5s var(--ease) 1.2s infinite;
}
@keyframes sheen { 0% { background-position: 120% 0; } 40%, 100% { background-position: -40% 0; } }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.badge::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #e5484d;
  box-shadow: 0 0 0 0 rgba(229, 72, 77, 0.5);
  animation: pulse 1.8s ease-out infinite;
}
@keyframes pulse { 70% { box-shadow: 0 0 0 6px rgba(229, 72, 77, 0); } 100% { box-shadow: 0 0 0 0 rgba(229, 72, 77, 0); } }

/* Classic row */
.b-link.classic {
  align-items: center;
  justify-content: center;
  min-height: 64px;
  padding: 8px 60px;
  text-align: center;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1.3;
}
.b-link.classic .art {
  position: absolute;
  left: 8px; top: 50%;
  width: 48px; height: 48px;
  transform: translateY(-50%);
  border-radius: 8px;
}
.b-link.classic .stack { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.b-link.classic.featured { min-height: 76px; }
.b-link.classic.featured .art { width: 60px; height: 60px; border-radius: 10px; }
.b-link.classic.featured.has-img { padding-left: 80px; padding-right: 20px; }
.b-link.classic.featured .title { font-weight: 700; font-size: 16px; }

/* Large card */
.b-link.large { flex-direction: column; overflow: hidden; }
.b-link.large .art { width: 100%; aspect-ratio: 1 / 1; }
.b-link.large .meta {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 14px 14px 16px;
}
.b-link.large .meta .stack { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.b-link.large .title { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; line-height: 1.25; }
.go {
  flex: none;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--ink);
  display: grid; place-items: center;
  transition: transform 0.5s var(--ease);
}
.go svg { width: 16px; height: 16px; stroke: var(--card); fill: none; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

/* Half tile */
.b-link.half { flex-direction: column; overflow: hidden; }
.b-link.half .art { width: 100%; aspect-ratio: 1 / 1; }
.b-link.half .stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 10px 12px;
  text-align: center;
}
.b-link.half .title { font-size: 14px; font-weight: 600; line-height: 1.3; letter-spacing: -0.01em; }
.b-link.half:not(.has-img) { min-height: 120px; justify-content: center; }

/* ---------- Players (Spotify, SoundCloud, YouTube…) ---------- */
.b-embed {
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  background: var(--card);
  line-height: 0;
}
.b-embed iframe { width: 100%; border: 0; display: block; border-radius: var(--radius); }
.b-embed.featured { box-shadow: var(--shadow), inset 0 0 0 1.5px var(--ink); padding: 4px; }
.b-embed.featured iframe { border-radius: calc(var(--radius) - 4px); }
.embed-top { line-height: 1; padding: 8px 10px 9px; }
.b-embed.tall iframe { max-height: 78vh; }

/* ---------- Socials / share / toast ---------- */
.socials { display: flex; justify-content: center; gap: 8px; margin-top: 36px; }
.socials a {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border-radius: 50%;
  color: var(--ink);
  transition: background 0.15s ease;
}
.socials a:hover { background: var(--line); }
.socials svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.share {
  position: fixed;
  top: 14px; right: 14px;
  z-index: 2;
  width: 44px; height: 44px;
  border: 0;
  border-radius: 50%;
  background: var(--card);
  opacity: 0.92;
  box-shadow: var(--shadow);
  display: grid; place-items: center;
  cursor: pointer;
}
.share svg { width: 20px; height: 20px; fill: none; stroke: var(--ink); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.toast {
  position: fixed;
  left: 50%; bottom: 28px;
  transform: translate(-50%, 12px);
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--card);
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.empty { text-align: center; color: var(--muted); font-size: 14px; padding: 24px 0; }

/* ---------- Cookie consent ---------- */
.consent {
  position: fixed;
  left: 50%; bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 10;
  width: min(440px, calc(100% - 24px));
  padding: 16px 16px 14px;
  border-radius: 18px;
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 0 0 1px var(--line), 0 18px 48px -12px rgba(0, 0, 0, 0.35);
  transform: translate(-50%, 24px);
  opacity: 0;
  transition: transform 0.5s var(--ease), opacity 0.35s ease;
}
.consent.in { transform: translate(-50%, 0); opacity: 1; }
.consent.out { transform: translate(-50%, 24px); opacity: 0; }
.consent p { margin: 0 4px 12px; font-size: 14px; line-height: 1.45; }
.consent-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.consent-btn {
  height: 42px;
  border-radius: 12px;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--card);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s var(--ease), background 0.2s ease;
}
.consent-btn:active { transform: scale(0.97); }
.legal { text-align: center; margin-top: 18px; min-height: 1px; }
.legal-link { border: 0; background: none; padding: 4px 8px; font: inherit; font-size: 12px; color: var(--muted); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

@media (prefers-reduced-motion: reduce) {
  .b-link, .toast, .go, .art img, .consent { transition: none; }
  .blocks > *, .badge::before, .b-link.featured::after { animation: none; }
  .blocks > .pending { opacity: 1; }
}
