:root {
  /* App is dark-only — tells the browser to render native form-control
     chrome (select dropdown popups, scrollbars, etc.) in dark mode too,
     instead of defaulting to a light OS theme that clashes with the rest
     of the UI. */
  color-scheme: dark;
  --bg: #14161a;
  --panel: #1d2027;
  --panel-2: #262a33;
  --border: #333844;
  --text: #eef0f3;
  --text-dim: #9aa1ad;
  --accent: #e0a72e;
  --accent-hover: #f0b93f;
  --teal: #14a99b;
  --teal-dim: #0b6f66;
  --danger: #d9534f;
  --danger-hover: #e46864;
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.app-shell {
  display: flex;
  height: 100vh;
}

.landing {
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  scroll-behavior: smooth;
}

.landing-nav {
  position: sticky;
  top: 0;
  z-index: 5;
  background: rgba(20, 22, 26, 0.9);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--border);
}

.landing-nav-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 24px;
}

.landing-nav-logo img {
  height: 32px;
  display: block;
}

.landing-nav-links {
  display: flex;
  gap: 20px;
  margin-right: auto;
}

.landing-nav-links a {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.9rem;
}

.landing-nav-links a {
  position: relative;
  padding-bottom: 3px;
}

.landing-nav-links a::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 0;
  height: 2px;
  background: var(--teal);
  transition: width 0.18s ease;
}

.landing-nav-links a:hover {
  color: var(--text);
}

.landing-nav-links a:hover::after {
  width: 100%;
}

/* Shared backdrop for the hero AND the features section: the poster
   wall is one continuous layer behind both, so there's no seam between
   two separately-faded sections to fight with — only one fade, at the
   very bottom of this wrapper. */
.hero-backdrop {
  position: relative;
  overflow: hidden;
}

.landing-hero {
  position: relative;
  z-index: 2;
  min-height: 620px;
  display: flex;
  align-items: center;
}

/* Full-bleed poster wall behind both the hero and the features section
   (bottom: 0 reaches the bottom of .hero-backdrop, which wraps both).
   This outer box is the "window": stays perfectly axis-aligned and just
   clips (overflow: hidden), so the flat top/bottom fade overlays below
   always line up with its straight edges. The tilt lives on the
   oversized .poster-collage-inner instead — a whole-window rotation
   would skew its edges, which made the fades cover one side generously
   and undershoot the other (posters poking out past the fade). */
.poster-collage {
  position: absolute;
  z-index: 0;
  top: -70px;
  bottom: 0;
  right: 0;
  width: 68%;
  overflow: hidden;
}

/* Oversized so that after rotating, its edges still fully cover the
   straight-edged window above — no gaps at the corners. */
.poster-collage-inner {
  position: absolute;
  inset: -20%;
  display: flex;
  gap: 12px;
  transform: rotate(-9deg) scale(1.1);
  transform-origin: center;
}

/* Darkens the left edge of the poster wall so the headline stays legible,
   fading to fully transparent so the posters read at full vibrance on
   the right — same trick as streaming-service hero banners. */
.landing-hero-scrim {
  position: absolute;
  z-index: 1;
  inset: 0;
  /* Every stop shares the same RGB (matching --bg) and only the alpha
     changes — mixing in the bare "transparent" keyword here would fade
     through black (its actual value is rgba(0,0,0,0)) and show up as a
     visible dark band partway through the fade. */
  background: linear-gradient(
    100deg,
    rgba(20, 22, 26, 1) 0%,
    rgba(20, 22, 26, 1) 34%,
    rgba(20, 22, 26, 0.72) 48%,
    rgba(20, 22, 26, 0) 68%
  );
  pointer-events: none;
}

/* Blends the poster wall into the sticky nav above. Plain gradient
   overlay rather than mask-image on the posters — every stop shares
   one RGB so only alpha changes (see note on .landing-hero-scrim). */
.landing-hero-fade-top {
  position: absolute;
  z-index: 1;
  top: -70px;
  left: 0;
  right: 0;
  height: 160px;
  background: linear-gradient(to bottom, rgba(20, 22, 26, 1) 0%, rgba(20, 22, 26, 0) 100%);
  pointer-events: none;
}

/* The single fade-out for the whole backdrop, at the bottom of the
   features section — not at the seam between hero and features, which
   is what kept leaving a visible line no matter how that seam-fade was
   tuned. Columns end at slightly different heights (stagger offsets),
   so this stays tall/gradual enough that every column's actual last
   image falls inside the fade rather than stopping dead above it. */
.landing-hero-fade-bottom {
  position: absolute;
  z-index: 1;
  bottom: 0;
  left: 0;
  right: 0;
  height: 600px;
  background: linear-gradient(to bottom, rgba(20, 22, 26, 0) 0%, rgba(20, 22, 26, 1) 75%);
  pointer-events: none;
}

.poster-col {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.poster-col:nth-child(2) { margin-top: 36px; }
.poster-col:nth-child(4) { margin-top: 60px; }
.poster-col:nth-child(5) { margin-top: 18px; }
.poster-col:nth-child(6) { margin-top: 44px; }
.poster-col:nth-child(7) { margin-top: 8px; }

.poster-col img {
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.5);
  margin-bottom: 12px;
}

.landing-hero-content {
  position: relative;
  z-index: 2;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  padding: 0 24px;
}

.landing-hero-content-inner {
  max-width: 560px;
}

.landing-eyebrow {
  display: inline-block;
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  border: 1px solid rgba(224, 167, 46, 0.35);
  background: rgba(224, 167, 46, 0.08);
  border-radius: 999px;
  padding: 5px 12px;
  margin-bottom: 20px;
}

.landing-hero-logo {
  height: 40px;
  margin-bottom: 20px;
}

.landing-hero h1 {
  font-size: clamp(2.2rem, 4vw, 3.1rem);
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin: 0 0 20px;
}

.landing-hero h1 em {
  display: block;
  font-style: normal;
  color: var(--accent);
}

.landing-hero p {
  color: var(--text-dim);
  font-size: 1.05rem;
  line-height: 1.6;
  margin: 0 0 28px;
  max-width: 46ch;
}

.landing-hero-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.landing-hero-actions .btn {
  padding: 12px 20px;
  font-size: 1rem;
}

.landing-section {
  position: relative;
  z-index: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding: 72px 24px;
  scroll-margin-top: 70px;
}

/* Explicit z-index above the shared hero-backdrop's poster/scrim/fade
   layers (all z-index 0/1), matching .landing-hero, rather than relying
   on DOM-order tie-breaking at the same z-index. */
#features {
  z-index: 2;
}

.landing-section h2 {
  font-size: clamp(1.6rem, 2.6vw, 2.1rem);
  letter-spacing: -0.015em;
  text-align: center;
  margin: 0 0 12px;
}

.landing-section-sub {
  text-align: center;
  color: var(--text-dim);
  margin: 0 auto 44px;
  max-width: 54ch;
  line-height: 1.6;
}

/* Full-bleed background, but content still lines up with the 1100px
   column the other sections use. */
.landing-section-alt {
  background: var(--panel);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  max-width: none;
  padding-left: max(24px, calc((100% - 1100px) / 2));
  padding-right: max(24px, calc((100% - 1100px) / 2));
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
}

.feature-card {
  background: linear-gradient(180deg, var(--panel), #191c22);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 26px;
  transition: transform 0.18s ease, border-color 0.18s ease;
}

.feature-card:hover {
  transform: translateY(-3px);
  border-color: #454b58;
}

.feature-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: rgba(20, 169, 155, 0.12);
  border: 1px solid rgba(20, 169, 155, 0.28);
  color: var(--teal);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  margin-bottom: 16px;
}

.feature-card h3 {
  margin: 0 0 8px;
  font-size: 1.1rem;
}

.feature-card p {
  color: var(--text-dim);
  font-size: 0.92rem;
  line-height: 1.55;
  margin: 0;
}

.music-highlight {
  display: flex;
  align-items: center;
  gap: 40px;
  background: linear-gradient(135deg, rgba(216, 30, 84, 0.1), rgba(20, 169, 155, 0.06));
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 36px 40px;
}

.music-highlight-logo {
  flex: 0 0 auto;
  width: 220px;
  max-width: 40%;
  height: auto;
}

.music-highlight-body h2 {
  margin: 6px 0 10px;
  font-size: 1.5rem;
}

.music-highlight-body p {
  color: var(--text-dim);
  line-height: 1.6;
  margin: 0;
  max-width: 60ch;
}

@media (max-width: 700px) {
  .music-highlight {
    flex-direction: column;
    text-align: center;
    padding: 28px 24px;
    gap: 20px;
  }

  .music-highlight-logo {
    width: 180px;
    max-width: 70%;
  }

  .music-highlight-body p {
    max-width: none;
  }
}

.landing-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 24px;
  counter-reset: step;
}

.landing-steps li {
  position: relative;
  background: linear-gradient(180deg, var(--panel-2), #1b1e25);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 32px 24px 26px;
}

/* Connector line between step cards on wide screens. */
.landing-steps li:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 50px;
  right: -14px;
  width: 12px;
  height: 2px;
  background: var(--teal-dim);
}

.step-number {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--teal);
  color: #06231f;
  font-weight: 700;
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 18px;
}

.landing-steps h3 {
  margin: 0 0 8px;
  font-size: 1.08rem;
}

.landing-steps p {
  color: var(--text-dim);
  margin: 0;
  line-height: 1.6;
  font-size: 0.93rem;
}

@media (max-width: 800px) {
  .landing-steps li::after {
    display: none;
  }
}

.landing-cta {
  text-align: center;
}

.landing-cta > p {
  color: var(--text-dim);
  margin: 0 0 28px;
}

.landing-cta .landing-hero-actions {
  justify-content: center;
}

/* ---- Invite request form ---- */

.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;
}

.invite-form {
  max-width: 520px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: left;
}

.invite-form-row {
  display: flex;
  gap: 12px;
}

#bulkImportInput {
  width: 100%;
  min-width: 0;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 11px 13px;
  font-family: inherit;
  font-size: 0.9rem;
  resize: vertical;
  margin-bottom: 10px;
}

#bulkImportInput:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(20, 169, 155, 0.18);
}

.invite-form input,
.invite-form textarea {
  width: 100%;
  min-width: 0;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 11px 13px;
  font-family: inherit;
  font-size: 0.95rem;
  resize: vertical;
}

.invite-form input:focus,
.invite-form textarea:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(20, 169, 155, 0.18);
}

.invite-form input::placeholder,
.invite-form textarea::placeholder {
  color: var(--text-dim);
}

.invite-submit {
  justify-content: center;
  padding: 12px 20px;
  font-size: 1rem;
}

.invite-form-status {
  margin: 0;
  font-size: 0.9rem;
  min-height: 1.2em;
  text-align: center;
}

.invite-form-status.is-success {
  color: var(--teal);
}

.invite-form-status.is-error {
  color: var(--danger);
}

.invite-login-hint {
  margin: 20px 0 0;
  color: var(--text-dim);
  font-size: 0.9rem;
}

.link-btn {
  background: none;
  border: none;
  padding: 0;
  color: var(--teal);
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
}

.link-btn:hover {
  color: var(--text);
}

/* ---- Not-invited notice ---- */

.access-notice {
  background: rgba(224, 167, 46, 0.1);
  border-bottom: 1px solid rgba(224, 167, 46, 0.35);
}

.access-notice-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 0.92rem;
}

.access-notice-inner span {
  color: var(--text-dim);
  flex: 1 1 260px;
}

.access-notice-inner .btn {
  text-decoration: none;
}

.access-notice-inner .icon-btn {
  margin-left: auto;
}

@media (max-width: 800px) {
  .invite-form-row {
    flex-direction: column;
  }
}

.landing-footer {
  text-align: center;
  padding: 32px 24px 48px;
  color: var(--text-dim);
  font-size: 0.85rem;
  border-top: 1px solid var(--border);
}

.landing-footer p {
  margin: 0 0 6px;
}

.landing-credit a {
  color: var(--teal);
  text-decoration: none;
}

.landing-credit a:hover {
  text-decoration: underline;
}

/* ---- App preview mockup ---- */

.landing-preview {
  position: relative;
}

.app-shot {
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  background: var(--bg);
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.55);
}

.app-shot-bar {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 10px 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.app-shot-bar .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.dot-r { background: #ec6a5e; }
.dot-y { background: #f4bf4f; }
.dot-g { background: #61c554; }

.app-shot-url {
  margin-left: 12px;
  font-size: 0.72rem;
  color: var(--text-dim);
}

.app-shot-body {
  display: flex;
  min-height: 340px;
}

.app-shot-side {
  width: 180px;
  flex-shrink: 0;
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.app-shot-side-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  margin: 0 0 8px;
}

.app-shot-cat {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-dim);
  padding: 6px 8px;
  border-radius: 6px;
}

.app-shot-cat em {
  font-style: normal;
  opacity: 0.6;
}

.app-shot-cat.is-active {
  background: rgba(20, 169, 155, 0.14);
  color: var(--teal);
}

.app-shot-main {
  flex: 1;
  min-width: 0;
  padding: 14px;
}

.app-shot-toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
}

.app-shot-search {
  flex: 1;
  min-width: 0;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 0.76rem;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-shot-chip {
  font-size: 0.76rem;
  padding: 7px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  white-space: nowrap;
}

.app-shot-chip.is-accent {
  background: var(--accent);
  border-color: var(--accent);
  color: #1a1a1a;
  font-weight: 600;
}

.app-shot-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
}

.app-shot-grid figure {
  margin: 0;
  min-width: 0;
}

.app-shot-grid img {
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
  display: block;
}

.app-shot-grid figcaption {
  font-size: 0.72rem;
  margin-top: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-shot-grid figcaption span {
  color: var(--text-dim);
}

@media (max-width: 800px) {
  .landing-hero {
    display: block;
    min-height: 0;
    padding-top: 40px;
  }

  .landing-hero-scrim,
  .landing-hero-fade-top,
  .landing-hero-fade-bottom {
    display: none;
  }

  .landing-hero-content {
    padding: 0 20px;
    text-align: center;
  }

  .landing-hero-content-inner {
    max-width: none;
  }

  .landing-hero p {
    max-width: none;
    margin-left: auto;
    margin-right: auto;
  }

  .landing-hero-actions {
    justify-content: center;
  }

  /* Full-bleed-under-header only works with room to spare; on small
     screens the poster wall goes back to a normal in-flow block below
     the text instead of an absolutely positioned background, and the
     rotate/oversize trick collapses to a plain contained block (no
     window to keep axis-aligned, since there's no fade overlay to
     align to here). */
  .poster-collage {
    position: static;
    width: 100%;
    height: 300px;
    margin-top: 32px;
    overflow: hidden;
  }

  .poster-collage-inner {
    position: static;
    inset: auto;
    width: 100%;
    height: 100%;
    transform: rotate(-6deg) scale(1.15);
  }

  .app-shot-side {
    display: none;
  }

  .app-shot-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .app-shot-body {
    min-height: 0;
  }

  .landing-hero h1 {
    font-size: 1.8rem;
  }

  .landing-nav-links {
    display: none;
  }

  .landing-section {
    padding: 48px 20px;
  }

  .landing-section h2 {
    font-size: 1.4rem;
    margin-bottom: 28px;
  }
}

.shared-banner {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px 10px;
  font-size: 0.85rem;
  color: var(--text-dim);
}

.share-link-input {
  flex: 1;
  min-width: 0;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 8px 10px;
  font-family: inherit;
}

.sidebar {
  width: 240px;
  min-width: 240px;
  flex-shrink: 0;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width 0.15s ease, min-width 0.15s ease;
}

.sidebar.collapsed {
  width: 0;
  min-width: 0;
  border-right: none;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 72px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  white-space: nowrap;
  box-sizing: border-box;
}

select {
  color-scheme: dark;
}

select option {
  background: var(--panel-2);
  color: var(--text);
}

.library-type-select {
  margin: 8px;
  padding: 8px 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.library-type-select:hover {
  background: var(--surface-hover, rgba(255, 255, 255, 0.05));
}

.icon-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: var(--radius);
  width: 34px;
  height: 34px;
  line-height: 1;
  cursor: pointer;
  font-size: 0.95rem;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-btn svg {
  display: block;
}

.btn svg {
  display: block;
  vertical-align: middle;
}

.icon-btn:hover {
  color: var(--text);
  border-color: #454b58;
}

.category-nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  white-space: nowrap;
}

.category-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.88rem;
}

.category-item:hover {
  background: var(--panel-2);
}

.category-item.active {
  background: var(--accent);
  color: #1a1a1a;
  font-weight: 600;
}

.category-expand {
  flex-shrink: 0;
  width: 14px;
  text-align: center;
  font-size: 0.7rem;
  color: var(--text-dim);
  cursor: pointer;
}

.category-item.active .category-expand {
  color: #1a1a1a;
}

.category-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.category-edit {
  background: transparent;
  border: none;
  color: inherit;
  cursor: pointer;
  padding: 2px 4px;
  font-size: 0.8rem;
  border-radius: 4px;
  opacity: 0;
  flex-shrink: 0;
}

.subcategory-item:hover .category-edit,
.category-item:hover .category-edit {
  opacity: 0.6;
}

.category-edit:hover {
  opacity: 1 !important;
  color: var(--accent);
}

.subcategory-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-left: 22px;
  margin-bottom: 2px;
}

.subcategory-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.82rem;
  color: var(--text-dim);
}

.subcategory-item:hover {
  background: var(--panel-2);
  color: var(--text);
}

.subcategory-item.active {
  background: var(--accent);
  color: #1a1a1a;
  font-weight: 600;
}

.add-subcategory-form {
  display: flex;
  gap: 4px;
  padding: 4px 10px 4px 22px;
}

.add-subcategory-form input {
  flex: 1;
  min-width: 0;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 5px 7px;
  font-size: 0.8rem;
}

.category-count {
  font-size: 0.75rem;
  opacity: 0.7;
  flex-shrink: 0;
}

.category-delete {
  background: transparent;
  border: none;
  color: inherit;
  cursor: pointer;
  padding: 2px 5px;
  font-size: 0.9rem;
  border-radius: 4px;
  opacity: 0;
  flex-shrink: 0;
}

.category-item:hover .category-delete {
  opacity: 0.6;
}

.category-delete:hover:not(:disabled) {
  opacity: 1 !important;
  color: var(--danger);
}

.category-delete:disabled {
  cursor: not-allowed;
  opacity: 0 !important;
}

.add-category-form {
  display: flex;
  gap: 6px;
  padding: 12px;
  border-top: 1px solid var(--border);
}

.add-category-form input {
  flex: 1;
  min-width: 0;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 8px;
  font-size: 0.85rem;
}

.btn-small {
  padding: 6px 10px;
  font-size: 0.85rem;
}

.main {
  flex: 1;
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar,
.toolbar {
  flex-shrink: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  padding: 8px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 12px;
  box-sizing: border-box;
}

.topbar h1 {
  flex: 1;
}

.topbar h1 {
  margin: 0;
  font-size: 1.4rem;
}

.app-title {
  font-size: 1.4rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.status {
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-right: 4px;
}

.status.dirty {
  color: var(--accent);
}

.btn {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 14px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn:hover:not(:disabled) {
  background: #30353f;
  border-color: #454b58;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #1a1a1a;
  border-color: var(--accent);
  font-weight: 600;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border-color: var(--danger);
}

.btn-danger:hover:not(:disabled) {
  background: var(--danger);
  color: white;
}

.toolbar {
  display: flex;
  gap: 10px;
  padding: 14px 24px;
  flex-wrap: wrap;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.toolbar input,
.toolbar select {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  font-size: 0.9rem;
}

#search {
  flex: 1;
  min-width: 200px;
}

.view-toggle {
  display: flex;
  gap: 4px;
}

.view-toggle .icon-btn.active {
  background: var(--accent);
  color: #1a1a1a;
  border-color: var(--accent);
}

.filter-menu {
  position: relative;
}

.filter-menu-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.filter-badge {
  background: var(--accent);
  color: #1a1a1a;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
  border-radius: 999px;
  padding: 3px 6px;
  min-width: 1em;
  text-align: center;
}

.filter-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 20;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 220px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.4);
}

.filter-panel-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.85rem;
  color: var(--text-dim);
}

.filter-panel-row select {
  flex: 1;
  max-width: 150px;
}

.scroll-area {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-dim);
}

.empty-state p { margin: 4px 0; }
.empty-sub { font-size: 0.9rem; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 20px;
  padding: 24px;
}

.hidden {
  display: none !important;
}

.grid-group-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 2px;
  margin-top: 4px;
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--text);
  border-bottom: 1px solid var(--border);
}

.grid-group-header:first-child {
  margin-top: 0;
}

.grid-group-count {
  font-weight: 400;
  font-size: 0.85rem;
  color: var(--text-dim);
}

.grid-group-bulk-tag-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px 2px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--border);
}

.grid-group-bulk-tag-form input {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 10px;
  font-size: 0.85rem;
}

.grid-group-back {
  background: none;
  border: none;
  color: var(--teal);
  font-size: 0.95rem;
  cursor: pointer;
  padding: 4px 2px 8px;
  text-align: left;
  width: fit-content;
}

.grid-group-back:hover {
  text-decoration: underline;
}

.stack-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s;
  display: flex;
  flex-direction: column;
}

.stack-card:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
}

.stack-covers {
  position: relative;
  width: 100%;
  aspect-ratio: 2 / 3;
  margin-bottom: 10px;
}

body.library-type-music .stack-covers {
  aspect-ratio: 1 / 1;
}

.stack-cover {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: calc(var(--radius) - 4px);
  border: 1px solid var(--border);
  background: var(--panel-2);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
  display: block;
}

.stack-cover.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
}

.stack-cover:nth-child(1) {
  z-index: 3;
}

.stack-cover:nth-child(2) {
  z-index: 2;
  transform: translate(6px, 6px) rotate(2deg);
  filter: brightness(0.85);
}

.stack-cover:nth-child(3) {
  z-index: 1;
  transform: translate(12px, 12px) rotate(4deg);
  filter: brightness(0.7);
}

.genre-block {
  width: 100%;
  aspect-ratio: 2 / 3;
  border-radius: calc(var(--radius) - 4px);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 12px;
  margin-bottom: 10px;
}

.genre-block-label {
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.stack-card .card-title {
  margin: 0 0 2px;
}

.stack-count {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-dim);
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s;
  display: flex;
  flex-direction: column;
}

.card:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
}

.card-cover {
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  background: var(--panel-2);
  display: block;
}

/* Hides the img until it's actually decoded and painted — otherwise
   there's a visible pop when a lazy cover's src is assigned, and a
   failed load flashes the browser's own broken-image icon for a frame
   before JS swaps in the placeholder div. */
.lazy-cover {
  opacity: 0;
}

.lazy-cover.loaded {
  opacity: 1;
  transition: opacity 0.2s ease;
}

/* Shimmer behind a cover for as long as it hasn't loaded yet — the img
   itself is invisible (opacity: 0 above) until then, so this lives on
   the surrounding card/stack instead, showing through in exactly the
   area the cover will occupy once it fades in. */
@keyframes cover-shimmer {
  0% { background-position: -150% 0; }
  100% { background-position: 150% 0; }
}

.card:has(> .lazy-cover:not(.loaded)),
.stack-card:has(.stack-cover.lazy-cover:not(.loaded)) .stack-covers {
  background: linear-gradient(90deg, var(--panel-2) 35%, rgba(255, 255, 255, 0.05) 50%, var(--panel-2) 65%);
  background-color: var(--panel-2);
  background-size: 200% 100%;
  animation: cover-shimmer 2.2s ease-in-out infinite;
}

body.library-type-music .card-cover {
  aspect-ratio: 1 / 1;
}

.card-cover.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
  color: var(--text-dim);
}

.card-body {
  padding: 10px 12px;
}

.card-title {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0 0 4px;
  line-height: 1.25;
}

.card-meta {
  font-size: 0.8rem;
  color: var(--text-dim);
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.card-meta span:first-child {
  flex-shrink: 0;
}

.card-meta span:last-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: right;
}

.card-sub {
  font-size: 0.72rem;
  color: var(--text-dim);
  margin: 4px 0 0;
  opacity: 0.75;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.card-tag {
  font-size: 0.68rem;
  color: var(--text-dim);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 8px;
  white-space: nowrap;
}

.grid.list-view {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 24px;
}

.list-view .card {
  flex-direction: row;
  align-items: center;
  gap: 14px;
  padding: 6px 12px;
}

.list-view .card:hover {
  transform: none;
}

.list-view .card-cover {
  width: 40px;
  aspect-ratio: 2 / 3;
  flex-shrink: 0;
  border-radius: 4px;
}

body.library-type-music .list-view .card-cover {
  aspect-ratio: 1 / 1;
}

.list-view .card-cover.placeholder {
  font-size: 1.2rem;
}

.list-view .card-body {
  padding: 6px 0;
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 20px;
}

.list-view .card-title {
  flex: 1;
  min-width: 0;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-view .card-meta {
  flex-shrink: 0;
  width: 260px;
  justify-content: flex-start;
  gap: 16px;
}

.list-view .card-meta span:first-child {
  width: 42px;
}

.list-view .card-meta span:last-child {
  flex: 1;
  text-align: left;
  min-width: 0;
}

.list-view .card-sub {
  flex-shrink: 0;
  width: 220px;
  margin: 0;
}

@media (max-width: 700px) {
  .list-view .card-meta,
  .list-view .card-sub {
    display: none;
  }
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  padding: 20px;
  overflow-y: auto;
}

.modal {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 380px;
  max-height: 100%;
  overflow-y: auto;
  position: relative;
}

.modal h2 {
  margin-top: 0;
}

/* Settings reads as its own page rather than a small popup — there's too
   much in it for a centered card, and there's no router in this app to
   give it a real URL, so a full-viewport overlay is the cheap substitute. */
#settingsOverlay {
  padding: 0;
  align-items: stretch;
  justify-content: stretch;
}

#settingsOverlay .modal {
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  border-radius: 0;
  border: none;
  padding: 32px 24px 64px;
}

#settingsOverlay .modal-inner {
  max-width: min(920px, 94vw);
  margin: 0 auto;
}

.settings-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 16px 0 4px;
  border-bottom: 1px solid var(--border);
}

.settings-tab {
  padding: 8px 16px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-dim);
  font-size: 0.95rem;
  cursor: pointer;
}

.settings-tab:hover {
  color: var(--text);
}

.settings-tab.active {
  color: var(--text);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

#settingsOverlay .modal-close {
  top: 24px;
  right: 24px;
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  padding: 4px;
}

.modal-close:hover {
  color: var(--text);
}

#movieForm {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#movieForm label {
  display: flex;
  flex-direction: column;
  font-size: 0.85rem;
  color: var(--text-dim);
  gap: 4px;
}

#movieForm input {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px;
  font-size: 0.95rem;
}

.modal-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
}

.modal-actions-right {
  display: flex;
  gap: 8px;
}

.detail-modal {
  max-width: 560px;
}

.detail-body {
  display: flex;
  gap: 18px;
}

.detail-cover {
  width: 140px;
  height: 210px;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--panel-2);
}

body.library-type-music .detail-cover {
  height: 140px;
}

.detail-cover.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.4rem;
}

.detail-main {
  min-width: 0;
  flex: 1;
}

.detail-title {
  margin: 0 0 2px;
  font-size: 1.2rem;
}

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  color: var(--text-dim);
  font-size: 0.85rem;
  margin-bottom: 8px;
}

.detail-rating {
  color: #f5c518;
  font-weight: 600;
}

.detail-genres {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 10px;
}

.detail-overview {
  font-size: 0.88rem;
  line-height: 1.4;
  color: var(--text);
  margin: 0 0 10px;
}

.detail-credits {
  font-size: 0.8rem;
  color: var(--text-dim);
  line-height: 1.6;
}

.detail-credits strong {
  color: var(--text);
  font-weight: 500;
}

@media (max-width: 480px) {
  .detail-body {
    flex-direction: column;
  }
  .detail-cover {
    width: 100%;
    height: auto;
    aspect-ratio: 2 / 3;
  }
  body.library-type-music .detail-cover {
    height: auto;
    aspect-ratio: 1 / 1;
  }
}

.tag-rows {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tag-row {
  display: flex;
  gap: 6px;
}

.tag-row .tag-category,
.tag-row .tag-subcategory {
  flex: 1;
  min-width: 0;
}

.tag-row-remove {
  flex-shrink: 0;
}

.picker-setup {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.picker-setup label {
  display: flex;
  flex-direction: column;
  font-size: 0.85rem;
  color: var(--text-dim);
  gap: 4px;
}

.picker-setup select {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px;
  font-size: 0.95rem;
}

.picker-pool-status {
  font-size: 0.85rem;
  color: var(--text-dim);
  margin: 0 0 12px;
}

.picker-card {
  display: flex;
  flex-direction: column;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.picker-card .card-cover {
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  display: block;
}

body.library-type-music .picker-card .card-cover {
  aspect-ratio: 1 / 1;
}

.picker-card .card-cover.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
  color: var(--text-dim);
}

.picker-empty {
  text-align: center;
  color: var(--text-dim);
  padding: 24px 0;
}

.settings-section {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.settings-section:first-of-type {
  margin-top: 12px;
  padding-top: 0;
  border-top: none;
}

.settings-section h3 {
  margin: 0 0 4px;
}

.settings-hint {
  color: var(--text-dim);
  font-size: 0.9rem;
  margin: 0 0 12px;
}

.mini-player {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  max-width: min(90vw, 360px);
}

.mini-player-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.9rem;
}

.settings-warning {
  color: var(--danger);
  font-size: 0.9rem;
  margin: 0 0 12px;
}

.settings-actions {
  display: flex;
  gap: 10px;
}

.settings-tool {
  margin-top: 12px;
}

.settings-tool h4 {
  margin: 0 0 6px;
  color: var(--text-dim);
  font-size: 0.9rem;
}

.settings-links {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.settings-links a {
  color: var(--accent);
  text-decoration: none;
}

.settings-links a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

@media (max-width: 700px) {
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 20;
    box-shadow: 4px 0 16px rgba(0, 0, 0, 0.4);
  }

  .topbar {
    min-height: auto;
    padding: 10px 12px;
    gap: 8px;
    justify-content: flex-start;
  }

  .topbar h1 {
    flex: 0 1 auto;
    font-size: 1.1rem;
    min-width: 0;
  }

  .app-title {
    font-size: 1.1rem;
  }

  .topbar-actions {
    flex: 0 0 auto;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
    margin-left: auto;
    gap: 6px;
  }

  .topbar .btn,
  .topbar .icon-btn {
    height: 36px;
    min-width: 36px;
    width: auto;
    padding: 0 10px;
    font-size: 1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .status {
    display: none;
  }

  .shared-banner {
    flex: 1 1 100%;
    order: 10;
    font-size: 0.75rem;
    padding: 3px 6px;
  }

  .btn-label {
    display: none;
  }

  .toolbar {
    flex-wrap: nowrap;
    align-items: center;
  }

  .toolbar input {
    flex: 1 1 auto;
    min-width: 0;
    height: 36px;
    padding: 0 12px;
    box-sizing: border-box;
  }

  .view-toggle .icon-btn {
    height: 36px;
    width: 36px;
  }

  .filter-menu-btn {
    height: 36px;
    padding: 0 10px;
  }

  .filter-panel {
    left: auto;
    right: 0;
    max-width: calc(100vw - 24px);
  }
}
