:root {
  --bg: #0b0a10;
  --surface: #14121c;
  --surface-2: #1c1928;
  --line: #2a2639;
  --text: #f4f2fa;
  --muted: #9a94ad;
  --faint: #6b6580;
  --accent: #a78bfa;
  --accent-strong: #8b5cf6;
  --accent-ink: #120a24;
  --heart: #f472b6;
  --star: #c4b5fd;
  --radius: 12px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: clip;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }
h1, h2, h3 { margin: 0; letter-spacing: -0.02em; line-height: 1.15; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; padding: 48px 0; }

.icon,
.nav svg {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px max(16px, calc((100vw - 1160px) / 2));
  background: rgba(11, 10, 16, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.03em;
  text-decoration: none;
}
.brand-mark {
  width: 22px;
  height: 28px;
  border-radius: 5px;
  background: linear-gradient(160deg, var(--accent), var(--accent-strong));
  box-shadow: inset -5px 0 0 rgba(0, 0, 0, 0.18);
}

.nav { display: flex; gap: 2px; }
.nav a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  color: var(--muted);
  font-weight: 600;
  text-decoration: none;
  border-radius: 999px;
}
.nav a:hover { color: var(--text); background: var(--surface); }
.nav a.active { color: var(--text); background: var(--surface-2); }
.nav a.active svg { color: var(--accent); }

main {
  flex: 1;
  width: 100%;
  max-width: 1160px;
  margin: 0 auto;
  padding: 8px 16px 64px;
}

/* ---------- buttons + form bits ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  font: inherit;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
}
.btn:hover { border-color: var(--faint); }
.btn.primary { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }
.btn.primary:hover { background: #b9a3fc; }
.btn.small { padding: 7px 14px; font-size: 13px; }

.link {
  padding: 0;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  background: none;
  border: none;
  cursor: pointer;
}
.link:hover { color: var(--text); }
.link.danger:hover { color: #fb7185; }

input[type="text"],
input[type="search"],
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
}
input:focus,
select:focus,
textarea:focus { outline: none; border-color: var(--accent); }
textarea { resize: vertical; }
select { width: auto; cursor: pointer; }

.label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: lowercase; letter-spacing: 0.02em; }

.chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
}
.chips:empty { display: none; }

.chip {
  flex: none;
  padding: 6px 14px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
}
.chip:hover { color: var(--text); }
.chip.active { color: var(--accent-ink); background: var(--text); border-color: var(--text); }
.count { opacity: 0.6; margin-left: 2px; font-weight: 500; }

.seg {
  display: flex;
  gap: 2px;
  padding: 3px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
}
.seg-btn {
  padding: 6px 14px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  background: none;
  border: none;
  border-radius: 999px;
  cursor: pointer;
}
.seg-btn.active { color: var(--text); background: var(--surface-2); }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 28px 0 18px;
}
.page-head h1 { font-size: 34px; font-weight: 800; }

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 22px;
}

.empty {
  max-width: 440px;
  margin: 48px auto;
  text-align: center;
}
.empty h2 { font-size: 22px; margin-bottom: 6px; }
.empty p { margin: 0 0 20px; }

/* ---------- hero ---------- */

.hero { padding: 56px 0 40px; }
.hero h1 {
  font-size: clamp(40px, 7vw, 76px);
  font-weight: 800;
  letter-spacing: -0.045em;
  line-height: 1;
}
.hero-points {
  margin: 24px 0 28px;
  padding: 0;
  list-style: none;
  color: var(--muted);
  font-size: 17px;
}
.hero-points li { display: flex; align-items: center; gap: 10px; padding: 3px 0; }
.hero-points li::before {
  content: "";
  width: 6px;
  height: 6px;
  flex: none;
  background: var(--accent);
  border-radius: 2px;
}
.hero-cta { display: flex; flex-wrap: wrap; gap: 10px; }

/* ---------- sections + posters ---------- */

.section { margin: 0 0 40px; }
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.section-head h2 { font-size: 20px; font-weight: 700; }
.section-head a { color: var(--muted); font-size: 13px; font-weight: 600; text-decoration: none; }
.section-head a:hover { color: var(--text); }

.row {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 150px;
  gap: 14px;
  padding-bottom: 8px;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}
.row > * { scroll-snap-align: start; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 22px 14px;
}

.poster {
  display: flex;
  flex-direction: column;
  min-width: 0;
  text-decoration: none;
}
.poster .cover {
  aspect-ratio: 2 / 3;
  border-radius: var(--radius);
  outline: 1px solid rgba(255, 255, 255, 0.06);
  outline-offset: -1px;
  transition: transform 0.15s;
}
.poster:hover .cover { transform: translateY(-3px); }
.poster:hover .poster-title { color: var(--accent); }
.poster-title {
  margin-top: 8px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.poster-meta {
  display: flex;
  margin-top: 3px;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.poster-meta > span { overflow: hidden; text-overflow: ellipsis; }

.skeleton { pointer-events: none; }
.skeleton .cover,
.skeleton .poster-title,
.rank-row.skeleton .thumb,
.rank-row.skeleton strong {
  background: var(--surface-2);
  animation: pulse 1.3s ease-in-out infinite;
}
.skeleton .poster-title { height: 12px; width: 70%; border-radius: 6px; }
@keyframes pulse { 50% { opacity: 0.45; } }

.cover {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: linear-gradient(160deg, hsl(var(--hue) 45% 30%), hsl(calc(var(--hue) + 25) 40% 14%));
}
.cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cover-initials { font-size: 34px; font-weight: 800; color: rgba(255, 255, 255, 0.55); letter-spacing: -0.04em; }

.badge-heart,
.badge-want,
.badge-date {
  position: absolute;
  z-index: 1;
  font-size: 11px;
  font-weight: 700;
  border-radius: 999px;
  backdrop-filter: blur(6px);
}
.badge-heart {
  top: 8px;
  right: 8px;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  color: var(--heart);
  background: rgba(11, 10, 16, 0.7);
}
.badge-heart svg { width: 14px; height: 14px; fill: currentColor; }
.badge-want { top: 8px; left: 8px; padding: 3px 8px; background: rgba(11, 10, 16, 0.75); }
.badge-date { left: 8px; bottom: 8px; padding: 3px 8px; color: var(--accent-ink); background: var(--accent); }

/* ---------- stars + scores ---------- */

.stars {
  position: relative;
  display: inline-flex;
  flex: none;
  line-height: 0;
}
.stars-bg,
.stars-fg { display: flex; gap: 1px; }
.stars-fg {
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--fill);
  overflow: hidden;
}
.stars svg { width: 13px; height: 13px; flex: none; }
.stars-bg svg { fill: var(--line); }
.stars-fg svg { fill: var(--star); }

.score {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.score svg { width: 14px; height: 14px; fill: var(--star); }

.my-score {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.my-score svg { width: 12px; height: 12px; fill: currentColor; }

/* ---------- rankings ---------- */

.top-columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}
.top-col { padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; }
.top-col-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.top-col-head h3 { font-size: 16px; }
.top-col-head a { color: var(--muted); font-size: 13px; font-weight: 600; text-decoration: none; }
.top-col-head a:hover { color: var(--text); }

.rank-list { margin: 0; padding: 0; list-style: none; }
.rank-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 6px;
  text-decoration: none;
  border-radius: 10px;
}
a.rank-row:hover { background: var(--surface-2); }
.rank { width: 24px; flex: none; color: var(--faint); font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.rank-text { display: grid; flex: 1; min-width: 0; gap: 2px; }
.rank-text strong { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank-text small { display: flex; font-size: 12px; color: var(--muted); }
.rank-row.skeleton strong { height: 12px; width: 60%; border-radius: 6px; }

.thumb {
  flex: none;
  width: 36px;
  height: 52px;
  overflow: hidden;
  background: var(--surface-2);
  border-radius: 6px;
}
.thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }

.rank-list.big .rank-row { padding: 10px 12px; border-bottom: 1px solid var(--line); border-radius: 0; }
.rank-list.big .rank { width: 36px; font-size: 18px; }
.rank-list.big .thumb { width: 46px; height: 68px; }
.rank-list.big .rank-text strong { font-size: 16px; }

/* ---------- search ---------- */

.searchbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 28px 0 16px;
  padding: 4px 18px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
}
.searchbar:focus-within { border-color: var(--accent); }
.searchbar .icon { width: 22px; height: 22px; }
.searchbar input {
  padding: 14px 0;
  font-size: 18px;
  background: none;
  border: none;
}
.searchbar input:focus { border: none; }
.searchbar + .chips { margin-bottom: 26px; }

.search-intro { padding: 48px 16px; text-align: center; }
.search-intro h2 { font-size: 24px; margin-bottom: 8px; }
.search-intro p { margin: 0 auto; max-width: 460px; }

/* ---------- title page ---------- */

.detail { position: relative; padding-top: 24px; }
.detail-backdrop {
  position: absolute;
  inset: -8px calc(50% - 50vw) auto;
  height: 420px;
  z-index: -1;
  background-color: var(--surface);
  background-position: center 25%;
  background-size: cover;
  background-repeat: no-repeat;
  opacity: 0.35;
  mask-image: linear-gradient(to bottom, #000 20%, transparent);
  -webkit-mask-image: linear-gradient(to bottom, #000 20%, transparent);
}
.detail-backdrop.soft { filter: blur(40px) saturate(1.3); opacity: 0.3; }

.detail-main {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 32px;
  align-items: start;
  padding-top: 80px;
}
.detail-cover .cover {
  aspect-ratio: 2 / 3;
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.55);
}
.detail-cover .cover-initials { font-size: 64px; }

.detail-info { padding-top: 40px; min-width: 0; }
.eyebrow { margin: 0 0 8px; color: var(--muted); font-size: 13px; font-weight: 600; }
.detail-info h1 { font-size: clamp(30px, 5vw, 52px); font-weight: 800; letter-spacing: -0.035em; }
.detail-by { margin: 8px 0 0; font-size: 16px; color: var(--muted); }
.community { display: flex; align-items: center; gap: 8px; margin: 16px 0 0; font-size: 18px; }
.community .muted { font-size: 13px; }

.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 16px; }
.tag {
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
}

.overview {
  max-width: 680px;
  margin: 18px 0 0;
  color: #d6d2e3;
  white-space: pre-line;
}

.actions {
  display: grid;
  gap: 18px;
  margin-top: 32px;
  padding: 20px;
}
.actions-rating { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; }
.rating-value { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }

.star-input { display: inline-flex; cursor: pointer; border-radius: 6px; }
.star-input .stars svg { width: 28px; height: 28px; }
.star-input .stars-bg,
.star-input .stars-fg { gap: 0; }

.actions-buttons { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
}
.pill:hover { border-color: var(--faint); }
.pill.on { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }
.pill svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; }
.pill.heart.on { color: #2a0a1c; background: var(--heart); border-color: var(--heart); }
.pill.heart.on svg { fill: currentColor; }
.actions-buttons .link { margin-left: auto; }

.note { display: grid; gap: 6px; }

/* ---------- profile ---------- */

.profile-card {
  position: relative;
  margin: 28px 0 40px;
  overflow: hidden;
  background:
    radial-gradient(600px 240px at 100% 0%, rgba(167, 139, 250, 0.16), transparent 70%),
    repeating-linear-gradient(135deg, transparent 0 22px, rgba(255, 255, 255, 0.012) 22px 23px),
    var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
}

.profile-strip {
  display: flex;
  justify-content: space-between;
  padding: 10px 22px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--accent);
  border-bottom: 1px dashed var(--line);
}

.profile-body {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 22px;
  padding: 24px 22px;
}

.avatar {
  display: grid;
  place-items: center;
  flex: none;
  width: 104px;
  height: 128px;
  font-size: 40px;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.85);
  background: linear-gradient(160deg, hsl(var(--hue) 55% 45%), hsl(calc(var(--hue) + 25) 45% 22%));
  border-radius: 12px;
}

.profile-id { flex: 1; min-width: 200px; }
.profile-id h1 { font-size: 32px; font-weight: 800; }
.handle { margin: 2px 0 0; color: var(--accent); font-weight: 600; }
.bio { margin: 10px 0 6px; color: #d6d2e3; }
.profile-id .muted { margin: 6px 0 0; }
.profile-actions { display: flex; gap: 8px; align-self: flex-start; }

.profile-counts {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  border-top: 1px dashed var(--line);
}
.profile-counts a {
  display: grid;
  padding: 14px 10px;
  text-align: center;
  text-decoration: none;
  border-right: 1px dashed var(--line);
}
.profile-counts a:last-child { border-right: none; }
.profile-counts a:hover { background: rgba(255, 255, 255, 0.02); }
.profile-counts strong { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; }
.profile-counts span { font-size: 12px; color: var(--muted); }
.profile-counts .zero strong { color: var(--faint); }

.profile-form {
  display: grid;
  gap: 16px;
  max-width: 480px;
  margin: 40px auto;
  padding: 28px;
}
.profile-form h1 { font-size: 28px; font-weight: 800; }
.profile-form p { margin: -8px 0 0; }
.profile-form label { display: grid; gap: 6px; }
.handle-input {
  display: flex;
  align-items: center;
  padding-left: 12px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.handle-input:focus-within { border-color: var(--accent); }
.handle-input input { border: none; padding-left: 2px; background: none; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; }
.form-actions.start { justify-content: flex-start; }

.settings { margin-top: 20px; }
.settings summary {
  padding: 16px 20px;
  font-weight: 700;
  cursor: pointer;
  list-style-position: inside;
}
.settings-form,
.settings-data {
  display: grid;
  gap: 12px;
  padding: 4px 20px 20px;
}
.settings-data { border-top: 1px solid var(--line); padding-top: 18px; }
.settings h3 { font-size: 15px; }
.settings p { margin: 0; }
.settings label { display: grid; gap: 6px; }
.settings a { color: var(--accent); }

/* ---------- footer + toast ---------- */

.footer {
  padding: 28px max(16px, calc((100vw - 1160px) / 2)) 40px;
  font-size: 12px;
  color: var(--faint);
  border-top: 1px solid var(--line);
}
.footer p { margin: 0 0 4px; }
.footer a { color: var(--muted); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 30;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  color: var(--accent-ink);
  background: var(--accent);
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 10px);
  transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- mobile ---------- */

@media (max-width: 760px) {
  /* backdrop-filter would trap the fixed bottom nav inside the top bar. */
  .topbar { backdrop-filter: none; background: var(--bg); }
  .nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    justify-content: space-around;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    background: rgba(20, 18, 28, 0.96);
    border-top: 1px solid var(--line);
  }
  .nav a { flex: 1; flex-direction: column; gap: 2px; padding: 6px 4px; font-size: 11px; border-radius: 10px; }
  .nav a.active { background: none; }
  .nav svg { width: 22px; height: 22px; }
  .footer { padding-bottom: 96px; }
  .toast { bottom: 88px; }

  .hero { padding: 32px 0 28px; }
  .row { grid-auto-columns: 120px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 18px 10px; }
  .poster-title { font-size: 13px; }

  .detail-main { grid-template-columns: 1fr; gap: 18px; padding-top: 40px; }
  .detail-cover { width: 160px; }
  .detail-info { padding-top: 0; }
  .detail-backdrop { height: 300px; }
  .actions-buttons .link { margin-left: 0; }
  .star-input .stars svg { width: 24px; height: 24px; }

  .profile-counts { grid-template-columns: repeat(3, 1fr); }
  .profile-counts a:nth-child(3) { border-right: none; }
  .profile-counts a:nth-child(-n + 3) { border-bottom: 1px dashed var(--line); }
  .avatar { width: 84px; height: 104px; font-size: 32px; }
  .toolbar { flex-direction: column; align-items: stretch; }
}
