:root {
  --bg: #070b17;
  --bg-elevated: #0d1424;
  --panel: rgba(17, 24, 39, 0.72);
  --panel-strong: rgba(23, 31, 46, 0.88);
  --panel-soft: rgba(27, 36, 55, 0.8);
  --border: rgba(148, 163, 184, 0.18);
  --text: #edf2ff;
  --muted: #a8b3c7;
  --primary: #8b5cf6;
  --primary-strong: #7c3aed;
  --secondary: #22d3ee;
  --accent: #f59e0b;
  --success: #34d399;
  --warning: #fbbf24;
  --danger: #fb7185;
  --shadow-soft: 0 18px 40px rgba(9, 12, 21, 0.45);
  --shadow-strong: 0 26px 60px rgba(80, 53, 160, 0.34);
  --glass: rgba(15, 23, 42, 0.5);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  touch-action: manipulation;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at top, rgba(139, 92, 246, 0.28), transparent 28%),
    radial-gradient(circle at bottom right, rgba(34, 211, 238, 0.12), transparent 22%),
    linear-gradient(180deg, #070b17 0%, #0b1220 100%);
  color: var(--text);
  font-family: "Inter", "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  letter-spacing: -0.01em;
  text-rendering: optimizeLegibility;
}

img {
  max-width: 100%;
  display: block;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem clamp(1rem, 2vw, 2rem);
  background: rgba(9, 13, 24, 0.72);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border);
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 166.02px;
  min-height: 35.19px;
  flex: 0 0 auto;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* Brand logo tile.
   Sized in rem so it scales with the wordmark next to it. The image IS the
   tile (see the <img class="brand-mark"> in each page), so every dimension has
   to live on .brand-mark itself -- a `img.brand-mark { width: 100% }` rule would
   out-specify this one and stretch the logo across the whole brand block. */
.brand-mark {
  position: relative;
  width: 2.2rem;
  height: 2.2rem;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  overflow: hidden;
  border-radius: 0.8rem;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #fff;
  box-shadow: var(--shadow-soft);
  object-fit: cover;
  object-position: 50% 50%;
}

.brand-mark .logo-stage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0;
}

.brand-mark .logo-stage-three {
  opacity: 1;
}

html.logo-entrance-pending .app-shell > :not(.topbar) {
  opacity: 0;
}

html.logo-entrance-pending .topbar > :not(.brand-block),
html.logo-entrance-pending .brand-block > :not(.brand-mark) {
  opacity: 0;
}

html.logo-entrance-pending .brand-mark {
  visibility: hidden;
}

html.logo-entrance-running .app-shell > :not(.topbar),
html.logo-entrance-running .topbar > :not(.brand-block),
html.logo-entrance-running .brand-block > :not(.brand-mark) {
  animation: app-entrance-fade 720ms ease-out 420ms both;
}

html.logo-entrance-running .brand-mark {
  position: relative;
  z-index: 1;
  visibility: visible;
  animation: brand-logo-flight 1.8s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

html.logo-entrance-running .logo-stage-one {
  animation: logo-stage-one 1.8s ease-in-out both;
}

html.logo-entrance-running .logo-stage-two {
  animation: logo-stage-two 1.8s ease-in-out both;
}

html.logo-entrance-running .logo-stage-three {
  animation: logo-stage-three 1.8s ease-in-out both;
}

@keyframes brand-logo-flight {
  0%, 14% {
    transform: translate3d(var(--logo-start-x), var(--logo-start-y), 0) scale(0.55);
    filter: drop-shadow(0 0 0 rgba(255, 80, 80, 0));
  }
  22% {
    transform: translate3d(var(--logo-start-x), var(--logo-start-y), 0) scale(4.4);
    filter: drop-shadow(0 0 22px rgba(255, 64, 64, 0.95));
  }
  52% {
    transform: translate3d(var(--logo-start-x), var(--logo-start-y), 0) scale(3.8);
    filter: drop-shadow(0 0 18px rgba(255, 64, 64, 0.8));
  }
  100% {
    transform: translate3d(0, 0, 0) scale(1);
    filter: drop-shadow(0 0 0 rgba(255, 80, 80, 0));
  }
}

@keyframes app-entrance-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes logo-stage-one {
  0%, 25% { opacity: 1; }
  40%, 100% { opacity: 0; }
}

@keyframes logo-stage-two {
  0%, 25% { opacity: 0; }
  40%, 53% { opacity: 1; }
  67%, 100% { opacity: 0; }
}

@keyframes logo-stage-three {
  0%, 53% { opacity: 0; }
  67%, 100% { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  html.logo-entrance-running .app-shell > :not(.topbar),
  html.logo-entrance-running .topbar > :not(.brand-block),
  html.logo-entrance-running .brand-block > :not(.brand-mark),
  html.logo-entrance-running .brand-mark,
  html.logo-entrance-running .logo-stage {
    animation: none;
  }

  .brand-mark .logo-stage-one,
  .brand-mark .logo-stage-two {
    display: none;
  }
}

/* Only applies when an image is nested inside a .brand-mark wrapper element,
   not when the <img> carries the class itself. */
.brand-mark > img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 50%;
  border-radius: inherit;
  display: block;
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;
}

.main-nav a {
  padding: 0.6rem 0.9rem;
  border-radius: 999px;
  color: var(--muted);
  transition: 0.2s ease;
}

.main-nav a:hover,
.main-nav a.active {
  color: var(--text);
  background: rgba(139, 92, 246, 0.14);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.profile-avatar-button {
  display: grid;
  place-items: center;
  width: 2.8rem;
  height: 2.8rem;
  padding: 0;
  border: 1px solid rgba(139, 92, 246, 0.42);
  border-radius: 50%;
  background: rgba(139, 92, 246, 0.18);
  transition: transform 0.18s ease, border-color 0.18s ease;
}

.profile-avatar-button:hover,
.profile-avatar-button:focus-visible {
  transform: scale(1.06);
  border-color: var(--secondary);
}

.profile-avatar-button-image {
  display: grid;
  place-items: center;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #fff;
  font-weight: 800;
  overflow: hidden;
}

.profile-avatar-button-image img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.admin-header-button {
  min-height: 2.4rem;
  padding-inline: 0.8rem;
}

.page-wrap {
  width: min(1280px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 2rem 0 4rem;
}

.hero-panel {
  display: grid;
  grid-template-columns: 1.5fr 0.9fr;
  gap: 1.5rem;
  margin-top: 2rem;
  margin-bottom: 2rem;
  align-items: stretch;
}

.hero-panel > div,
.info-card,
.featured-card {
  background: linear-gradient(180deg, rgba(17, 24, 39, 0.78), rgba(13, 20, 36, 0.92));
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 1.4rem;
  box-shadow: var(--shadow-soft);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}

.hero-panel > div:first-child {
  padding: clamp(1.5rem, 3vw, 2.5rem);
}

.hero-copy {
  max-width: 62ch;
  margin-top: 1rem;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.7;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.featured-panel {
  display: flex;
  align-items: center;
  min-height: 100%;
}

.featured-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  width: 100%;
  min-height: 100%;
  padding: 1.5rem;
  background:
    linear-gradient(145deg, rgba(124, 58, 237, 0.5), rgba(34, 211, 238, 0.14)),
    rgba(18, 25, 38, 0.9);
  color: inherit;
  text-decoration: none;
}

.featured-card:focus-visible,
.home-link-card:focus-visible {
  outline: 2px solid var(--secondary);
  outline-offset: 3px;
}

.mini-label {
  display: inline-block;
  width: fit-content;
  margin-bottom: 0.75rem;
  padding: 0.4rem 0.6rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--secondary);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.65rem;
  font-weight: 700;
}

.featured-card h2 {
  margin-bottom: 0.5rem;
  font-size: clamp(1.5rem, 2vw, 2.2rem);
}

.featured-card p {
  color: var(--muted);
  margin-bottom: 1rem;
}

.featured-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  color: var(--text);
  font-weight: 600;
}

.home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.info-card {
  padding: 1.4rem;
}

.home-link-card {
  display: block;
  color: inherit;
  text-decoration: none;
  transition: transform 160ms ease, border-color 160ms ease;
}

.home-link-card:hover {
  transform: translateY(-3px);
  border-color: rgba(148, 163, 184, 0.42);
}

.info-card h2 {
  margin-bottom: 0.65rem;
  font-size: 1.3rem;
}

.info-card p:last-child {
  color: var(--muted);
  line-height: 1.7;
  margin-bottom: 0;
}

.page-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.page-header.compact {
  margin-top: 1rem;
}

.eyebrow {
  margin: 0 0 0.5rem;
  color: var(--secondary);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 0.72rem;
  font-weight: 700;
}

h1, h2, h3, p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2.1rem, 4vw, 3.5rem);
  line-height: 0.98;
  letter-spacing: -0.06em;
  font-weight: 800;
}

h2 {
  letter-spacing: -0.04em;
}

h3 {
  letter-spacing: -0.03em;
}

.catalog-panel,
.admin-card,
.auth-card {
  background: linear-gradient(180deg, rgba(17, 24, 39, 0.8), rgba(15, 23, 42, 0.76));
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 1.4rem;
  box-shadow: var(--shadow-soft);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
}

.catalog-panel {
  padding: 1.4rem;
}

.toolbar-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.4rem;
}

.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.chip,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 999px;
  padding: 0.72rem 1.05rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.button:hover {
  transform: translateY(-1px);
}

.chip {
  background: transparent;
  color: var(--muted);
}

.chip.active {
  background: rgba(34, 211, 238, 0.12);
  border-color: rgba(34, 211, 238, 0.38);
  color: var(--text);
}

@media (hover: hover) and (pointer: fine) {
  .chip:hover {
    background: rgba(34, 211, 238, 0.12);
    border-color: rgba(34, 211, 238, 0.38);
    color: var(--text);
    transform: translateY(-1px);
  }
}


.button {
  font-weight: 700;
  border: 1px solid transparent;
}

.button-primary {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white;
  box-shadow: 0 12px 28px rgba(124, 58, 237, 0.4);
}

.button-secondary {
  background: rgba(148, 163, 184, 0.08);
  color: var(--text);
  border-color: var(--border);
}

.notification-status {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.9rem;
  padding: 0.5rem 0.75rem;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.18);
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.2;
}

.notification-status-dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: #34d399;
  box-shadow: 0 0 0 4px rgba(52, 211, 153, 0.18);
}

.search-box {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  min-width: min(100%, 320px);
  color: var(--muted);
  font-size: 0.85rem;
}

.search-box input,
.auth-form input,
.stacked-form input {
  width: 100%;
  min-height: 3rem;
  border-radius: 0.8rem;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.9);
  color: var(--text);
  padding: 0.8rem 0.9rem;
}

.anime-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.1rem;
}

.browse-load-more-card {
  min-height: 430px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.7rem;
  padding: 1.2rem;
  border: 1px dashed rgba(34, 211, 238, 0.5);
  border-radius: 1rem;
  background: linear-gradient(145deg, rgba(34, 211, 238, 0.12), rgba(17, 24, 39, 0.9));
  color: var(--text);
  cursor: pointer;
  text-align: center;
}

.browse-load-more-card:hover:not(:disabled) {
  border-color: var(--secondary);
  transform: translateY(-3px);
}

.browse-load-more-card span:last-child,
.browse-load-more-card.is-disabled p {
  color: var(--muted);
  font-size: 0.78rem;
}

.browse-load-more-card.is-disabled {
  cursor: default;
  opacity: 0.62;
  border-style: solid;
}

.browse-load-more-plus {
  width: 76px;
  height: 76px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white;
  font-size: 2.5rem;
  font-weight: 700;
}

.anime-card {
  position: relative;
  min-height: 430px;
  border-radius: 1rem;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(17, 24, 39, 0.84);
  transform-style: preserve-3d;
  perspective: 1000px;
  box-shadow: 0 16px 32px rgba(7, 11, 23, 0.28);
  transition: transform 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease;
}

.anime-card:hover,
.anime-card:focus-within {
  transform: translateY(-4px);
  border-color: rgba(34, 211, 238, 0.38);
  box-shadow: var(--shadow-strong);
}

.anime-card .card-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  transition: transform 0.55s ease, opacity 0.35s ease;
}

.anime-card .card-front {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.card-image-frame {
  position: relative;
  width: 100%;
  height: 220px;
  min-height: 220px;
  max-height: 220px;
  overflow: hidden;
  background: rgba(15, 23, 42, 0.9);
  flex-shrink: 0;
}

.card-image-frame img,
.anime-card .card-front img {
  width: 100%;
  height: 100%;
  /* contain keeps the whole image reachable (matches the editor preview exactly) */
  object-fit: contain;
  object-position: 50% 50%;
  display: block;
  transform-origin: center;
}

/* Blurred photo background option saved from the admin image editor.
   Mirrors the editor preview layer: blur(12px) brightness(0.6) saturate(1.5),
   slightly scaled to hide blurred edges. Only active when getCardBgStyle()
   emitted the --card-blur-bg custom property on the frame's style attribute. */
.card-image-frame[style*="--card-blur-bg"]::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: var(--card-blur-bg);
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  filter: blur(12px) brightness(0.6) saturate(1.5);
  transform: scale(1.12);
  z-index: 0;
}

.card-image-frame[style*="--card-blur-bg"] img {
  position: relative;
  z-index: 1;
}

.anime-card .card-body {
  padding: 0.95rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  flex: 1;
  min-height: 182px;
}

.anime-card .card-title-row {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: flex-start;
}

.anime-card .card-title-row h3,
.anime-card .card-back h3 {
  word-break: break-word;
  overflow-wrap: anywhere;
}

.admin-edit-image-button {
  -webkit-appearance: none;
  appearance: none;
  border: 1px solid rgba(99, 102, 241, 0.4);
  background: rgba(99, 102, 241, 0.12);
  color: #c7d2fe;
  border-radius: 999px;
  padding: 0.28rem 0.65rem;
  font-size: 0.72rem;
  cursor: pointer;
}

.anime-rating-button {
  -webkit-appearance: none;
  appearance: none;
  border: 1px solid rgba(251, 191, 36, 0.4);
  background: rgba(251, 191, 36, 0.12);
  color: #fde68a;
  cursor: pointer;
}

.rating-modal {
  position: fixed;
  inset: 0;
  z-index: 130;
  display: grid;
  place-items: center;
  background: rgba(7, 11, 23, 0.7);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.rating-modal.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.rating-modal-panel {
  width: min(680px, calc(100% - 2rem));
  max-height: min(82vh, 760px);
  overflow-y: auto;
  background: rgba(15, 23, 42, 0.96);
  border: 1px solid var(--border);
  border-radius: 1.2rem;
  padding: 1.2rem;
  box-shadow: var(--shadow-strong);
}

.rating-breakdown {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
  margin: 1rem 0;
}

.rating-metric {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.8rem;
  border-radius: 0.9rem;
  background: rgba(148, 163, 184, 0.06);
  border: 1px solid rgba(148, 163, 184, 0.14);
}

.rating-metric span {
  color: var(--muted);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.rating-metric strong {
  font-size: 1.5rem;
  line-height: 1.2;
}

.rating-metric.highlight {
  background: rgba(124, 58, 237, 0.12);
  border-color: rgba(139, 92, 246, 0.26);
}

.review-list {
  display: grid;
  gap: 0.8rem;
}

.rating-review-card {
  padding: 0.9rem 1rem;
  border-radius: 0.9rem;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(148, 163, 184, 0.14);
}

.rating-review-header {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  margin-bottom: 0.4rem;
  color: var(--muted);
}

.rating-review-card p {
  margin-bottom: 0;
  color: var(--text);
  line-height: 1.55;
}

.image-editor-modal {
  position: fixed;
  inset: 0;
  z-index: 140;
  display: grid;
  place-items: center;
  background: rgba(7, 11, 23, 0.75);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.image-editor-modal.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.image-editor-panel {
  width: min(760px, calc(100% - 2rem));
  max-height: min(86vh, 820px);
  overflow-y: auto;
  background: rgba(15, 23, 42, 0.96);
  border: 1px solid var(--border);
  border-radius: 1.2rem;
  padding: 1.2rem;
  box-shadow: var(--shadow-strong);
}

.image-editor-stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 390px;
  margin-top: 1rem;
  border-radius: 1rem;
  overflow: hidden;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.18);
}

.image-editor-blur-layer {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.62);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.image-crop-zone {
  position: relative;
  z-index: 1;
  width: min(100%, 520px);
  height: 320px;
  border-radius: 1rem;
  overflow: hidden;
  border: 2px solid rgba(236, 72, 153, 0.7);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18), 0 0 0 9999px rgba(15, 23, 42, 0.22);
  background: rgba(15, 23, 42, 0.9);
}

.image-crop-zone::before {
  content: "";
  position: absolute;
  inset: 0;
  border: 1px solid rgba(255, 255, 255, 0.14);
  pointer-events: none;
  z-index: 2;
}

#image-editor-preview {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: 50% 50%;
  filter: none;
  transform-origin: center;
  transition: transform 0.08s ease;
  pointer-events: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-user-drag: none;
}

.image-editor-action-box {
  position: absolute;
  z-index: 3;
  inset: auto 0 1rem 0;
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.image-editor-choice {
  display: grid;
  gap: 0.75rem;
  margin-top: 1rem;
}

.image-editor-choice .button {
  width: 100%;
  min-height: 2.9rem;
}

.image-editor-controls {
  display: grid;
  gap: 1rem;
  margin-top: 1rem;
}

.image-editor-controls label {
  display: grid;
  gap: 0.45rem;
  color: var(--muted);
}

.image-editor-controls input[type="url"],
.image-editor-controls input[type="range"] {
  width: 100%;
}

.editor-slider-group {
  display: grid;
  gap: 0.8rem;
}

.list-review-field {
  display: grid;
  gap: 0.45rem;
  margin-top: 0.75rem;
}

.list-notes-input,
.review-field-wrap textarea {
  width: 100%;
  min-height: 74px;
  resize: vertical;
  border-radius: 0.8rem;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.9);
  color: var(--text);
  padding: 0.75rem 0.8rem;
}

.anime-card h3 {
  margin: 0;
  font-size: 1.05rem;
}

.rating-pill {
  border-radius: 999px;
  background: rgba(251, 191, 36, 0.12);
  color: #fde68a;
  padding: 0.28rem 0.52rem;
  font-weight: 700;
  font-size: 0.78rem;
}

.genre-line {
  display: flex;
  flex-wrap: wrap;
  gap: 0.38rem;
}

.genre-tag {
  background: rgba(148, 163, 184, 0.08);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.25rem 0.5rem;
  font-size: 0.72rem;
}

.media-type-tag {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  background: rgba(245, 158, 11, 0.16);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.45);
  border-radius: 999px;
  padding: 0.25rem 0.55rem;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
}

.american-studio-tag {
  background: rgba(34, 211, 238, 0.12);
  color: var(--secondary);
  border-color: rgba(34, 211, 238, 0.4);
}

.card-back {
  transform: rotateY(180deg);
  background: linear-gradient(180deg, rgba(23, 31, 46, 0.96), rgba(11, 18, 32, 0.98));
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  overflow: visible;
}

.card-back .reminder-text {
  overflow-wrap: anywhere;
  line-height: 1.5;
  max-height: none;
  overflow: visible;
}

.anime-card.flipped .card-front {
  transform: rotateY(180deg);
}

.anime-card.flipped .card-back {
  transform: rotateY(360deg);
}

.card-meta {
  color: var(--muted);
  font-size: 0.8rem;
}

.card-actions {
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}

.card-actions button {
  flex: 1;
}

.duplicate-entry-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  align-items: stretch;
  width: 100%;
  margin-top: 0.5rem;
}

.duplicate-entry-actions .button,
.duplicate-entry-secondary-actions .button {
  width: 100%;
  min-width: 0;
  min-height: 2.9rem;
  padding-inline: 0.75rem;
  white-space: normal;
  line-height: 1.2;
  text-align: center;
}

.duplicate-entry-secondary-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.reminder-text {
  color: var(--muted);
  font-size: 0.78rem;
}

.genre-sections {
  display: grid;
  gap: 1rem;
  margin-top: 1.25rem;
}

.genre-section {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 1rem;
}

.genre-section h2 {
  margin-bottom: 0.8rem;
}

.list-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  margin-bottom: 1.2rem;
}

.summary-pill {
  background: rgba(139, 92, 246, 0.12);
  border: 1px solid rgba(139, 92, 246, 0.25);
  color: var(--text);
  padding: 0.65rem 0.9rem;
  border-radius: 999px;
}

.my-list-summary-filters {
  width: 100%;
  gap: 0.65rem;
}

.my-list-summary-filters .summary-pill {
  flex: 1 1 9rem;
  min-height: 2.8rem;
  white-space: nowrap;
  cursor: pointer;
}

@media (max-width: 640px) {
  .my-list-summary-filters .summary-pill {
    flex-basis: calc(50% - 0.65rem);
    white-space: normal;
    line-height: 1.2;
  }
}

.my-list-grid {
  display: grid;
  gap: 0.9rem;
}

.my-list-grid [hidden] {
  display: none !important;
}

.list-item {
  display: grid;
  grid-template-columns: 90px minmax(0, 1fr) auto;
  gap: 1rem;
  align-items: center;
  padding: 0.85rem;
  border: 1px solid var(--border);
  border-radius: 0.9rem;
  background: rgba(15, 23, 42, 0.7);
}

.list-item img {
  width: 90px;
  height: 120px;
  object-fit: cover;
  border-radius: 0.7rem;
}

.list-add-card {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 1rem;
  align-items: center;
  padding: 1rem;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 1.2rem;
  background: linear-gradient(145deg, rgba(139, 92, 246, 0.18), rgba(15, 23, 42, 0.92));
  box-shadow: var(--shadow-soft);
}

.list-add-visual {
  height: 160px;
  display: grid;
  place-items: center;
  border-radius: 1rem;
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.95), rgba(30, 41, 59, 0.86));
  border: 1px solid rgba(148, 163, 184, 0.18);
}

.list-add-plus {
  width: 78px;
  height: 78px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  font-size: 2.4rem;
  font-weight: 700;
  color: white;
  box-shadow: 0 18px 42px rgba(124, 58, 237, 0.42);
}

.list-add-entry-button,
.list-share-button {
  padding: 1rem;
  font-size: 0.8rem;
  line-height: 1.15;
  text-align: center;
}

.list-share-card .list-add-visual {
  background: linear-gradient(135deg, rgba(34, 211, 238, 0.2), rgba(15, 23, 42, 0.95));
}

.list-add-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 160px;
}

.list-add-copy h3 {
  margin-bottom: 0.8rem;
}

.list-add-copy .button {
  width: fit-content;
  margin-top: 0.5rem;
}
.my-list-action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  width: 100%;
  margin-bottom: 0.9rem;
}
.my-list-action-button {
  flex: 1 1 10rem;
  min-height: 2.8rem;
  border-color: rgba(34, 211, 238, 0.42);
  background: rgba(34, 211, 238, 0.14);
  color: var(--text);
  white-space: normal;
  line-height: 1.2;
}
.my-list-action-button.is-sharing {
  animation: my-list-action-progress 0.7s ease both;
}
@keyframes my-list-action-progress {
  0% { background: rgba(34, 211, 238, 0.22); border-color: rgba(34, 211, 238, 0.62); }
  50% { background: rgba(139, 92, 246, 0.45); border-color: rgba(167, 139, 250, 0.7); }
  100% { background: rgba(239, 68, 68, 0.38); border-color: rgba(248, 113, 113, 0.72); }
}
.my-top-ten-mode-card {
  display: flex;
  flex: 1 1 10rem;
  min-width: 10rem;
}

.my-top-ten-mark {
  font-size: 1.5rem;
}

.top-ten-mode-actions {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.6rem;
  align-items: center;
  width: 100%;
}

.top-ten-mode-actions .button {
  flex: 1 1 0;
  min-width: 0;
  margin-top: 0;
}

.top-ten-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--danger);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.top-ten-divider::before,
.top-ten-divider::after {
  content: "";
  height: 2px;
  flex: 1;
  background: var(--danger);
}

.top-ten-rearrange-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.85rem;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  background: rgba(15, 23, 42, 0.7);
  cursor: grab;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  transition: transform 0.16s ease, opacity 0.16s ease, border-color 0.16s ease;
}

.top-ten-rearrange-row.is-dragging {
  cursor: grabbing;
  opacity: 0.7;
  transform: scale(1.02);
  border-color: var(--secondary);
  box-shadow: var(--shadow-soft);
}

.top-ten-rearrange-row.is-dragging .top-ten-drag-handle {
  cursor: grabbing;
}

.top-ten-drag-handle {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 1.2rem;
  letter-spacing: -0.15em;
  cursor: grab;
}

.top-ten-row-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-ten-row-rating {
  color: var(--accent);
  white-space: nowrap;
}

.top-ten-rank-button {
  display: grid;
  grid-template-columns: 2.4rem minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  min-height: 3.2rem;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  background: rgba(15, 23, 42, 0.7);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
  transition: transform 0.16s ease, background 0.16s ease, border-color 0.16s ease;
}

.top-ten-rank-button:hover,
.top-ten-rank-button.is-selected {
  transform: translateX(0.2rem);
  border-color: rgba(34, 211, 238, 0.65);
  background: rgba(34, 211, 238, 0.14);
}

.top-ten-rank-badge {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border: 2px solid rgba(148, 163, 184, 0.28);
  border-radius: 50%;
  color: #fff;
  font-weight: 800;
}

.top-ten-rank-badge:not(.rank-none) { background: #d4af37; border-color: #f8e08e; }
.rank-2 { background: #aeb7c2 !important; border-color: #e9eef4 !important; }
.rank-3 { background: #b87333 !important; border-color: #f0b37e !important; }
.rank-4 { background: #f97316 !important; border-color: #fdba74 !important; }
.rank-5 { background: #ef4444 !important; border-color: #fca5a5 !important; }
.rank-6 { background: #ec4899 !important; border-color: #f9a8d4 !important; }
.rank-7 { background: #8b5cf6 !important; border-color: #c4b5fd !important; }
.rank-8 { background: #2563eb !important; border-color: #93c5fd !important; }
.rank-9 { background: #38bdf8 !important; border-color: #bae6fd !important; }
.rank-10 { background: #22c55e !important; border-color: #86efac !important; }

.list-add-modal {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  background: rgba(7, 11, 23, 0.72);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}

.list-add-modal.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.list-add-modal-panel {
  width: min(560px, calc(100% - 2rem));
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  background: rgba(15, 23, 42, 0.96);
  border: 1px solid var(--border);
  border-radius: 1.2rem;
  padding: 1.4rem;
  box-shadow: var(--shadow-strong);
}

@media (max-width: 520px) {
  .list-add-modal {
    padding: 0.75rem;
  }

  .list-add-modal-panel {
    width: 100%;
    padding: 1rem;
    border-radius: 1rem;
  }

  .duplicate-entry-actions {
    grid-template-columns: 1fr;
  }
}

.split-field {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.modal-open .topbar,
.modal-open .page-wrap,
.modal-open .mobile-bottom-nav {
  filter: blur(4px) saturate(0.8);
  pointer-events: none;
}

.auth-shell {
  display: grid;
  place-items: center;
  padding: 2rem 1rem;
}

.auth-wrap {
  width: min(520px, 100%);
}

.auth-card {
  padding: 1.5rem;
}

.auth-form,
.stacked-form {
  display: grid;
  gap: 1rem;
  margin-top: 1rem;
}

.auth-form label,
.stacked-form label {
  display: grid;
  gap: 0.45rem;
  color: var(--muted);
}

.auth-subtitle,
.tiny-note {
  color: var(--muted);
}

.alert-banner {
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm, 8px);
  font-size: 0.88rem;
  line-height: 1.45;
  border: 1px solid transparent;
}

.alert-error {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.4);
  color: #fca5a5;
}

.alert-info {
  background: rgba(99, 102, 241, 0.15);
  border-color: rgba(99, 102, 241, 0.4);
  color: #c7d2fe;
}

.admin-panel {
  padding: 1.2rem;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr));
  gap: 1.2rem;
  align-items: start;
}

.admin-card {
  min-width: 0;
  padding: 1.1rem;
}

.admin-card label {
  display: block;
  width: 100%;
}

.admin-card input[type="search"],
.admin-card input[type="text"],
.admin-card input[type="number"],
.admin-card input[type="url"] {
  width: 100%;
  box-sizing: border-box;
}

.admin-card .form-select {
  width: 100%;
  max-height: min(44vh, 20rem);
  overflow-y: auto;
}

.stacked-form textarea {
  width: 100%;
  box-sizing: border-box;
  min-height: 8rem;
  resize: vertical;
  border-radius: 0.8rem;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.9);
  color: var(--text);
  padding: 0.8rem 0.9rem;
  font: inherit;
  line-height: 1.6;
  field-sizing: content;
}

@media (max-width: 720px) {
  .topbar {
    position: sticky;
    flex-wrap: wrap;
    justify-content: space-between;
    padding-left: 0.9rem;
    padding-right: 0.9rem;
  }

  .nav-toggle {
    display: inline-flex;
  }

  .main-nav {
    display: none;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 0.35rem;
    padding: 0.5rem 0 0.25rem;
    border-top: 1px solid var(--border);
  }

  .topbar.nav-open .main-nav {
    display: flex;
  }

  .main-nav a {
    width: 100%;
    text-align: left;
  }

  .header-actions {
    margin-left: auto;
  }

  .hero-panel {
    grid-template-columns: 1fr;
  }

  .featured-panel {
    order: 2;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .search-box {
    width: 100%;
  }

  .anime-card {
    min-height: 390px;
  }

  .anime-card .card-body {
    min-height: 0;
  }

  .card-back {
    overflow: visible;
  }

  .list-item {
    grid-template-columns: 1fr;
  }

  .mobile-bottom-nav {
    display: flex;
  }

  .page-wrap {
    padding-bottom: 5.25rem;
  }
}

.mobile-bottom-nav {
  position: fixed;
  left: 50%;
  bottom: max(0.65rem, env(safe-area-inset-bottom));
  z-index: 70;
  display: none;
  width: min(27rem, calc(100% - 1.25rem));
  min-height: 4.65rem;
  transform: translateX(-50%);
  align-items: center;
  justify-content: space-around;
  gap: 0.25rem;
  padding: 0.45rem 0.65rem;
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: 1.15rem;
  background: rgba(8, 13, 26, 0.6);
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.48);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  --footer-contrast: #f8fafc;
}

.mobile-nav-item {
  display: flex;
  min-width: 4.15rem;
  min-height: 3.5rem;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  border-radius: 0.85rem;
  color: var(--footer-contrast);
  font-size: 0.68rem;
  font-weight: 700;
  text-decoration: none;
  transition: color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.mobile-nav-item:hover,
.mobile-nav-item:focus-visible,
.mobile-nav-item.active {
  color: var(--footer-contrast);
  background: rgba(139, 92, 246, 0.26);
  outline: none;
}

.mobile-nav-item:active {
  transform: scale(0.94);
}

.mobile-nav-icon {
  display: block;
  width: 1.65rem;
  height: 1.65rem;
  object-fit: contain;
  filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.18));
}

@media (max-width: 720px) {
  .mobile-bottom-nav {
    display: flex;
  }
}

/* User Profile Badge & Logout */
.user-menu {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.8rem;
  background: rgba(139, 92, 246, 0.15);
  border: 1px solid rgba(139, 92, 246, 0.3);
  border-radius: 999px;
  font-size: 0.82rem;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.user-badge:hover,
.user-badge:focus-visible {
  background: rgba(139, 92, 246, 0.28);
  border-color: rgba(139, 92, 246, 0.65);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
  outline: none;
}

.user-badge .role-tag {
  background: var(--primary);
  color: white;
  font-size: 0.68rem;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  font-weight: 700;
  text-transform: uppercase;
}

/* Alert Banners */
.alert-banner {
  padding: 0.8rem 1.1rem;
  border-radius: 0.8rem;
  margin-bottom: 1.2rem;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.alert-error {
  background: rgba(251, 113, 133, 0.15);
  border: 1px solid rgba(251, 113, 133, 0.35);
  color: #fca5a5;
}

.alert-success {
  background: rgba(52, 211, 153, 0.15);
  border: 1px solid rgba(52, 211, 153, 0.35);
  color: #6ee7b7;
}

/* Recommendation Badges */
.rec-badge {
  display: inline-block;
  padding: 0.28rem 0.6rem;
  background: rgba(34, 211, 238, 0.16);
  border: 1px solid rgba(34, 211, 238, 0.35);
  color: var(--secondary);
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.35;
  white-space: normal;
  overflow-wrap: anywhere;
  margin-bottom: 0.2rem;
}

/* Card Back Form Controls */
.card-form {
  display: grid;
  gap: 0.55rem;
  margin-top: 0.4rem;
}

.form-control-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.form-select,
.input-compact {
  padding: 0.35rem 0.6rem;
  border-radius: 0.5rem;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.95);
  color: var(--text);
  font-size: 0.8rem;
}

/* Admin Tables & Lists */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
  font-size: 0.85rem;
}

.admin-table th,
.admin-table td {
  padding: 0.75rem 0.9rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.admin-table th {
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.05em;
}

.badge-status {
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
}

.badge-pending {
  background: rgba(251, 191, 36, 0.15);
  color: var(--warning);
}

.badge-used {
  background: rgba(52, 211, 153, 0.15);
  color: var(--success);
}

.badge-revoked {
  background: rgba(251, 113, 133, 0.15);
  color: var(--danger);
}

/* Modal styling */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(7, 11, 23, 0.85);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.modal-box,
.modal-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 1.25rem;
  padding: 1.8rem;
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.2rem;
}

.close-button,
.modal-close {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  color: var(--muted);
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 50%;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: color 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.modal-close:hover,
.close-button:hover {
  color: #fff;
  border-color: var(--secondary);
  transform: rotate(90deg);
}

/* Image editor background picker */
.editor-bg-picker {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.editor-bg-swatches {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  align-items: center;
}

.editor-bg-swatch {
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 50%;
  border: 2px solid rgba(148, 163, 184, 0.28);
  cursor: pointer;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.12s ease;
  display: grid;
  place-items: center;
  font-size: 0.85rem;
  line-height: 1;
  color: var(--muted);
  flex-shrink: 0;
}

.editor-bg-swatch:hover {
  transform: scale(1.1);
  border-color: var(--secondary);
}

.editor-bg-swatch.is-active {
  border-color: var(--secondary);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.35);
}

.editor-bg-swatch--none {
  background: rgba(15, 23, 42, 0.8);
}

.editor-bg-swatch--black {
  background: #000;
}

.editor-bg-swatch--white {
  background: #fff;
  color: #555;
}

.editor-bg-swatch--blurred {
  background: linear-gradient(135deg, #e53e3e, #667eea);
}

/* The HTML hidden attribute must always win over component display rules.
   Without this, rules like .modal-backdrop { display: flex } keep hidden
   elements (e.g. the Customize Background modal) visible on page load. */
[hidden] {
  display: none !important;
}

/* Accessibility utility */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* ==========================================
   User Profile Page & Background Customizer
   ========================================== */

.profile-hero-card {
  position: relative;
  border-radius: 1.5rem;
  overflow: hidden;
  margin-bottom: 2rem;
  border: 1px solid var(--border);
  min-height: 280px;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.45);
  background: var(--panel);
}

.profile-banner-bg {
  position: absolute;
  inset: 0;
  background-position: center center;
  background-size: cover;
  background-repeat: no-repeat;
  filter: brightness(0.65) saturate(1.25);
  transition: all 0.4s ease;
  z-index: 0;
}

.profile-banner-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.25) 0%, rgba(15, 23, 42, 0.88) 85%, var(--panel) 100%);
  z-index: 1;
}

.profile-hero-content {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: flex-end;
  gap: 1.8rem;
  padding: 2.5rem 2.2rem 2rem;
  flex-wrap: wrap;
}

.profile-avatar-wrap {
  flex-shrink: 0;
}

.profile-avatar {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.8rem;
  font-weight: 800;
  border: 4px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  overflow: hidden;
  text-transform: uppercase;
  -webkit-user-select: none;
  user-select: none;
}

.profile-avatar img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.profile-identity {
  flex: 1;
  min-width: 260px;
}

.profile-tags-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.6rem;
  flex-wrap: wrap;
}

.profile-id-tag {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 999px;
  padding: 0.2rem 0.65rem;
  font-size: 0.76rem;
  color: var(--secondary);
  font-family: monospace;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.profile-email-tag {
  color: var(--muted);
  font-size: 0.82rem;
}

.profile-name-view {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.profile-name-view h1 {
  margin: 0;
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: #fff;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.6);
}

.profile-name-form {
  margin-top: 0.5rem;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(139, 92, 246, 0.4);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  padding: 1.2rem;
  border-radius: 1rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  max-width: 480px;
}

.profile-field-label {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 0.4rem;
}

.profile-name-form input {
  width: 100%;
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 1.05rem;
  font-weight: 600;
}

.profile-name-form input:focus {
  border-color: var(--secondary);
  outline: none;
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.25);
}

.profile-helper-note {
  font-size: 0.76rem;
  color: var(--muted);
  margin: 0.45rem 0 0.85rem;
  line-height: 1.4;
}

.profile-form-actions {
  display: flex;
  gap: 0.6rem;
}

.profile-name-notice {
  margin-top: 0.6rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: #38bdf8;
  transition: all 0.3s ease;
}

.profile-top-ten-actions {
  display: flex;
  justify-content: flex-end;
  margin: 0 0 1rem;
}

.profile-hero-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  align-items: center;
  gap: 0.65rem;
  margin-top: 1rem;
}

.profile-hero-actions .button-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  padding: 0.65rem 0.9rem;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.profile-hero-actions .button-secondary:hover {
  transform: translateY(-2px);
}

/* Profile Search & Viewing Top 10 */
.profile-search-section {
  margin-top: 2rem;
}

.profile-search-header {
  margin-bottom: 1.2rem;
}

.profile-search-bar-row {
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.profile-search-box {
  flex: 1;
  min-width: 260px;
}

.profile-select-label {
  min-width: 240px;
}

.profile-viewing-card {
  position: relative;
  overflow: hidden;
  min-height: 8.5rem;
  margin-bottom: 1.5rem;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 1.25rem;
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.9), rgba(34, 211, 238, 0.48));
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.32);
  isolation: isolate;
}

.profile-viewing-background,
.profile-viewing-overlay {
  position: absolute;
  inset: 0;
}

.profile-viewing-background {
  z-index: -2;
}

.profile-viewing-background img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-viewing-overlay {
  z-index: -1;
  background: linear-gradient(90deg, rgba(7, 11, 23, 0.94) 0%, rgba(7, 11, 23, 0.68) 62%, rgba(7, 11, 23, 0.35) 100%);
}

.profile-viewing-content {
  position: relative;
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: 8.5rem;
  padding: 1.25rem 1.5rem;
}

.profile-viewing-avatar {
  display: grid;
  width: 4.5rem;
  height: 4.5rem;
  flex: 0 0 auto;
  place-items: center;
  overflow: hidden;
  border: 3px solid rgba(255, 255, 255, 0.74);
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #fff;
  font-size: 1.7rem;
  font-weight: 800;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.profile-viewing-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.profile-viewing-info {
  min-width: 0;
}

.profile-viewing-badge {
  display: inline-flex;
  margin-bottom: 0.35rem;
  padding: 0.28rem 0.65rem;
  border: 1px solid rgba(251, 191, 36, 0.5);
  border-radius: 999px;
  background: rgba(245, 158, 11, 0.18);
  color: #fcd34d;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.profile-viewing-name {
  margin: 0;
  overflow: hidden;
  color: #fff;
  font-size: clamp(1.35rem, 3vw, 2rem);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-viewing-role {
  margin: 0.2rem 0 0;
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.85rem;
}

.profile-top-ten-grid {
  margin-top: 1rem;
}

.profile-top-ten-empty {
  text-align: center;
  padding: 3.5rem 1.5rem;
  background: rgba(15, 23, 42, 0.45);
  border: 1px dashed var(--border);
  border-radius: 1.2rem;
  margin-top: 1rem;
}

.profile-top-ten-empty .empty-icon {
  font-size: 3rem;
  margin-bottom: 0.8rem;
}

/* Customize Banner Modal Styles */
.customize-banner-modal {
  max-width: 760px;
  width: 92%;
  max-height: 88vh;
  overflow-y: auto;
}

.customize-emblem-modal {
  max-width: 480px;
  width: 92%;
}

.emblem-preview-box {
  display: grid;
  place-items: center;
  width: 180px;
  height: 180px;
  margin: 1.2rem auto;
  padding: 5px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

.emblem-preview-display {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: #0f172a;
  overflow: hidden;
}

.emblem-preview-display img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.banner-preview-box {
  width: 100%;
  height: 180px;
  border-radius: 1rem;
  border: 2px dashed rgba(139, 92, 246, 0.4);
  background: #0f172a;
  overflow: hidden;
  margin: 1.2rem 0;
  position: relative;
}

.banner-preview-display {
  width: 100%;
  height: 100%;
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  transition: all 0.3s ease;
}

.banner-custom-source-block {
  padding: 1.1rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 0.9rem;
  margin-bottom: 1.2rem;
}

.banner-custom-source-block h3,
.banner-preset-section h3 {
  font-size: 1rem;
  margin: 0 0 0.4rem;
  color: #fff;
}

.custom-file-upload-btn {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.banner-presets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 0.75rem;
  max-height: 220px;
  overflow-y: auto;
  padding: 0.4rem;
  border-radius: 0.8rem;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.6);
}

.banner-preset-thumb {
  height: 75px;
  border-radius: 0.6rem;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.2s ease;
  background-position: center;
  background-size: cover;
  position: relative;
}

.banner-preset-thumb:hover {
  transform: scale(1.04);
  border-color: var(--secondary);
}

.banner-preset-thumb.is-selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.45);
}

.banner-preset-name {
  position: absolute;
  bottom: 0;
  inset-inline: 0;
  background: rgba(0, 0, 0, 0.75);
  font-size: 0.68rem;
  color: #fff;
  padding: 0.2rem 0.4rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.banner-load-more-btn {
  width: 100%;
  margin-top: 0.75rem;
  justify-content: center;
}




/* ==========================================
   9. Admin Photos (bulk artwork assignment)
   ========================================== */

.photo-assign-summary {
  margin-top: 1rem;
  padding: 0.75rem 0.9rem;
  border-radius: 0.8rem;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.9);
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.45;
}

.photo-assign-summary.is-busy { color: var(--secondary); }
.photo-assign-summary.is-ready { color: var(--text); }
.photo-assign-summary.is-error { color: var(--danger); border-color: rgba(251, 113, 133, 0.45); }

.photo-assign-workspace {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(360px, 1.6fr);
  gap: 1.2rem;
  align-items: start;
  margin-top: 1.2rem;
}

@media (max-width: 900px) {
  .photo-assign-workspace { grid-template-columns: 1fr; }
}

.photo-assign-pool-card,
.photo-assign-titles-card {
  padding: 1.1rem;
  min-width: 0;
}

/* --- Unused image pool --- */

.photo-assign-pool {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 0.6rem;
  margin-top: 0.9rem;
  max-height: 32rem;
  overflow-y: auto;
  padding: 0.3rem;
}

.photo-assign-pool-item {
  display: grid;
  gap: 0.35rem;
  padding: 0.35rem;
  border-radius: 0.7rem;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.85);
  color: var(--muted);
  text-align: left;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.photo-assign-pool-item:hover {
  border-color: var(--secondary);
  transform: translateY(-2px);
}

.photo-assign-pool-item:active { cursor: grabbing; }

.photo-assign-pool-item img {
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: 0.45rem;
  background: rgba(2, 6, 23, 0.6);
}

.photo-assign-pool-name {
  font-size: 0.66rem;
  line-height: 1.25;
  word-break: break-word;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  box-orient: vertical;
}

/* --- Title rows with cover/banner slots --- */

.photo-assign-titles {
  display: grid;
  gap: 0.7rem;
  max-height: 46rem;
  overflow-y: auto;
  padding: 0.3rem;
}

.photo-assign-row {
  display: grid;
  gap: 0.6rem;
  padding: 0.75rem 0.8rem;
  border-radius: 0.9rem;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.72);
}

.photo-assign-row-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.8rem;
  flex-wrap: wrap;
}

.photo-assign-row-title { font-weight: 700; font-size: 0.95rem; }

.photo-assign-row-slug {
  font-family: monospace;
  font-size: 0.7rem;
  color: var(--muted);
  word-break: break-all;
}

.photo-assign-slots {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.7rem;
}

@media (max-width: 560px) {
  .photo-assign-slots { grid-template-columns: 1fr; }
}

.photo-assign-slot {
  display: grid;
  gap: 0.4rem;
  padding: 0.55rem;
  border-radius: 0.7rem;
  border: 1px dashed var(--border);
  background: rgba(2, 6, 23, 0.45);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.photo-assign-slot.is-active { border-color: var(--secondary); }
.photo-assign-slot.is-dragover {
  border-color: var(--primary);
  background: rgba(139, 92, 246, 0.18);
  border-style: solid;
}

.photo-assign-slot.is-staged { border-color: var(--warning); border-style: solid; }

.photo-assign-slot-label {
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.photo-assign-slot-preview {
  width: 100%;
  aspect-ratio: 2 / 3;
  max-height: 9rem;
  object-fit: cover;
  border-radius: 0.5rem;
  background: rgba(2, 6, 23, 0.6);
}

.photo-assign-slot-preview.is-banner { aspect-ratio: 16 / 9; max-height: 6rem; }

.photo-assign-slot.is-missing .photo-assign-slot-preview { outline: 2px solid rgba(251, 191, 36, 0.55); }
.photo-assign-slot.is-wrong-format .photo-assign-slot-preview { outline: 2px solid rgba(251, 113, 133, 0.55); }

.photo-assign-select { width: 100%; min-height: 2.5rem; font-size: 0.78rem; }

.photo-assign-slot-state {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.photo-assign-slot-state.is-ok { color: var(--success); }
.photo-assign-slot-state.is-missing { color: var(--warning); }
.photo-assign-slot-state.is-wrong { color: var(--danger); }
.photo-assign-slot-state.is-staged { color: var(--secondary); }

/* ==========================================
   10. Admin Users (edit users)
   ========================================== */

.admin-users-list {
  display: grid;
  gap: 0.8rem;
  max-height: 46rem;
  overflow-y: auto;
  padding: 0.3rem;
}

.admin-user-card {
  display: grid;
  gap: 0.9rem;
  padding: 0.9rem 1rem;
  border-radius: 0.9rem;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.72);
}

.admin-user-card-head {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.admin-user-avatar {
  width: 56px;
  height: 56px;
  font-size: 1.6rem;
  border-width: 2px;
}

.admin-user-card .profile-name-view h2 {
  font-size: 1.2rem;
}

.admin-user-form {
  display: grid;
  gap: 0.8rem;
  padding-top: 0.8rem;
  border-top: 1px solid var(--border);
}

.admin-user-form[hidden] { display: none; }

.admin-user-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.8rem;
}

.admin-user-grid label {
  display: grid;
  gap: 0.4rem;
  color: var(--muted);
}

.admin-user-grid input,
.admin-user-grid select {
  width: 100%;
  min-height: 2.6rem;
  border-radius: 0.7rem;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.9);
  color: var(--text);
  padding: 0.6rem 0.7rem;
}

.admin-user-actions {
  display: flex;
  gap: 0.7rem;
  flex-wrap: wrap;
}

.admin-user-notice {
  min-height: 1.2rem;
  font-size: 0.82rem;
  color: var(--success);
}

.admin-user-notice.is-error { color: var(--danger); }
