:root {
  color-scheme: dark;
  --bg: #101113;
  --ink: #f7f2e8;
  --muted: #b6b0a5;
  --soft: #1a1d20;
  --card: #202429;
  --card-2: #2b3036;
  --line: #3a4148;
  --gold: #edc56d;
  --green: #78c6a3;
  --red: #e56b6f;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
}

button, input { font: inherit; }

button {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  padding: 0 16px;
  background: var(--gold);
  color: #16130d;
  font-weight: 800;
  cursor: pointer;
}

button:hover { filter: brightness(1.06); }
button:disabled { opacity: 0.55; cursor: wait; }

input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #15181b;
  color: var(--ink);
  padding: 0 13px;
  outline: none;
}

input:focus { border-color: var(--gold); }

.app-shell {
  width: min(1220px, calc(100% - 28px));
  margin: 0 auto;
  padding-bottom: 32px;
}

.hero {
  min-height: 250px;
  display: grid;
  align-content: space-between;
  gap: 34px;
  padding: 18px 0 26px;
  border-bottom: 1px solid var(--line);
}

.top-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 850;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 6px;
  background: var(--gold);
  color: #141414;
}

.nav-links {
  display: flex;
  gap: 4px;
}

.nav-links a {
  color: var(--muted);
  text-decoration: none;
  padding: 9px 11px;
  border-radius: 6px;
}

.nav-links a:hover {
  background: var(--soft);
  color: var(--ink);
}

.hero-content {
  max-width: 780px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--gold);
  font-size: 0.78rem;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1, h2, p { margin-top: 0; }
h1 { max-width: 780px; margin-bottom: 12px; font-size: 3.45rem; line-height: 0.96; letter-spacing: 0; }
h2 { margin-bottom: 0; font-size: 1.6rem; line-height: 1.1; letter-spacing: 0; }

.hero-copy {
  max-width: 560px;
  margin-bottom: 16px;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.55;
}

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

.hero-actions a {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  color: var(--ink);
  text-decoration: none;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--soft);
}

.quick-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.message {
  min-height: 20px;
  margin: 0;
  color: var(--muted);
}

.hero-message {
  margin-top: 10px;
}

.message.error { color: var(--red); }

.request-confirmation {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  margin: 0 0 16px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.request-confirmation[hidden] {
  display: none;
}

.request-poster {
  width: 72px;
  height: 106px;
  overflow: hidden;
  border-radius: 7px;
  background: var(--card-2);
}

.request-poster img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.request-confirmation-body {
  display: grid;
  gap: 7px;
}

.request-confirmation h2 {
  font-size: 1.3rem;
}

.request-state {
  margin: 0;
  color: var(--muted);
  line-height: 1.35;
}

.request-progress {
  max-width: 420px;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: 16px;
  align-items: start;
  margin-top: 18px;
}

.section-main, .review-band, .family-band, .panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  overflow: hidden;
}

.section-heading, .panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.filter-input { max-width: 260px; }

.side-panel {
  display: grid;
  gap: 16px;
}

.explore-section {
  margin-top: 18px;
}

.catalogue-hero {
  min-height: 230px;
}

.catalogue-section {
  margin-top: 18px;
}

.catalogue-search-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  width: min(680px, 100%);
}

.catalogue-row {
  margin-top: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.catalogue-row-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.quick-rows {
  display: grid;
  gap: 18px;
}

.quick-row {
  display: grid;
  gap: 10px;
}

.quick-row h3 {
  margin: 0;
  font-size: 1rem;
}

.poster-row {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 150px;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 4px;
  scroll-snap-type: x proximity;
}

.row-card {
  position: relative;
  display: grid;
  grid-template-rows: 220px auto auto auto;
  gap: 7px;
  min-height: 322px;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--ink);
  text-align: left;
  scroll-snap-align: start;
}

.row-poster {
  overflow: hidden;
  border-radius: 7px;
  background: var(--card-2);
}

.row-poster img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.row-title {
  overflow-wrap: anywhere;
  font-weight: 820;
  line-height: 1.15;
}

.row-meta {
  color: var(--muted);
  font-size: 0.82rem;
}

.catalogue-heading {
  align-items: flex-start;
}

.segmented-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  justify-content: flex-end;
}

.segmented-controls button {
  min-height: 34px;
  border: 1px solid var(--line);
  background: var(--card-2);
  color: var(--ink);
}

.segmented-controls button.is-active {
  background: var(--gold);
  color: #16130d;
  border-color: var(--gold);
}

.genre-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: #15181b;
}

.provider-list {
  display: flex;
  gap: 8px;
  padding: 14px 16px;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
  background: #15181b;
}

.genre-chip {
  min-height: 32px;
  border: 1px solid var(--line);
  background: var(--card-2);
  color: var(--ink);
  padding: 0 11px;
}

.provider-chip {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: var(--card-2);
  color: var(--ink);
  padding: 0 11px;
}

.provider-chip img {
  width: 22px;
  height: 22px;
  border-radius: 5px;
  object-fit: cover;
}

.genre-chip.is-active {
  background: var(--gold);
  color: #16130d;
  border-color: var(--gold);
}

.provider-chip.is-active {
  background: var(--gold);
  color: #16130d;
  border-color: var(--gold);
}

.explore-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 1px;
  max-height: none;
}

.explore-card {
  position: relative;
  min-height: 300px;
  display: grid;
  grid-template-rows: 1fr auto auto auto;
  gap: 8px;
  padding: 10px;
  border: 0;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: var(--card);
  color: var(--ink);
  text-align: left;
}

.explore-poster {
  min-height: 220px;
  overflow: hidden;
  border-radius: 7px;
  background: var(--card-2);
}

.explore-poster img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.explore-title {
  overflow-wrap: anywhere;
  font-weight: 820;
  line-height: 1.15;
}

.explore-rating {
  color: var(--muted);
  font-size: 0.85rem;
}

.availability-badge {
  justify-self: start;
  min-height: 22px;
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--card-2);
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.load-more-row {
  display: flex;
  justify-content: center;
  padding: 14px;
  border-top: 1px solid var(--line);
}

.catalogue-settings {
  margin-top: 16px;
}

.poster-grid, .library-list {
  display: grid;
  gap: 1px;
  max-height: 760px;
  overflow: auto;
}

.poster-grid {
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
}

.library-list {
  grid-template-columns: 1fr;
}

.library-row {
  min-height: 116px;
  display: grid;
  grid-template-columns: 66px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}

.library-row:last-child {
  border-bottom: 0;
}

.library-art {
  width: 58px;
  height: 86px;
  border-radius: 8px;
  background: var(--card-2);
  color: var(--gold);
  overflow: hidden;
}

.library-art img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.library-art-fallback {
  display: grid;
  place-items: center;
  font-size: 1.25rem;
  font-weight: 900;
}

.library-content {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.library-title, .movie-title, .item-title {
  min-width: 0;
  overflow-wrap: anywhere;
  font-weight: 820;
}

.library-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.library-link {
  text-decoration: none;
}

.movie-meta, .item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  color: var(--muted);
  font-size: 0.85rem;
}

.pill {
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--card-2);
  color: var(--muted);
}

.pill.green { color: var(--green); }
.pill.red { color: #ffd7d9; background: #4d2529; }

.compact-list, .review-list, .profile-list {
  display: grid;
  max-height: 380px;
  overflow: auto;
}

.list-item, .review-item, .profile-item {
  display: grid;
  gap: 8px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--card);
}

.list-item:last-child, .review-item:last-child, .profile-item:last-child { border-bottom: 0; }

.item-top {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.item-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.item-actions button, .icon-button {
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  background: var(--card-2);
  color: var(--ink);
}

.want-button {
  background: var(--gold) !important;
  color: #16130d !important;
  border: 0 !important;
}

.ghost-button {
  border: 1px solid var(--line) !important;
  background: var(--card-2) !important;
  color: var(--ink) !important;
}

.remove-button {
  background: #4d2529 !important;
  color: #ffd7d9 !important;
}

.empty {
  padding: 18px;
  color: var(--muted);
}

.review-band, .family-band {
  margin-top: 16px;
}

.review-list, .profile-list {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  max-height: none;
}

.quick-form {
  grid-template-columns: minmax(180px, 1fr) minmax(130px, 0.7fr) auto;
  min-width: min(100%, 580px);
}

.settings-toggle {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--muted);
}

.settings-body {
  padding: 0 16px 16px;
}

.settings-body label {
  display: grid;
  gap: 8px;
  color: var(--muted);
}

.search-modal {
  width: min(1040px, calc(100% - 28px));
  max-height: min(840px, calc(100vh - 28px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  background: var(--soft);
  color: var(--ink);
}

.details-modal {
  width: min(980px, calc(100% - 28px));
  max-height: min(860px, calc(100vh - 28px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  overflow: hidden;
  background: #111417;
  color: var(--ink);
}

.details-modal::backdrop {
  background: rgb(0 0 0 / 0.76);
}

.details-shell {
  position: relative;
  max-height: min(860px, calc(100vh - 28px));
  overflow: auto;
}

.details-close {
  position: absolute;
  z-index: 3;
  top: 14px;
  right: 14px;
}

.details-backdrop {
  min-height: 250px;
  background-position: center;
  background-size: cover;
  background-color: var(--card-2);
}

.details-backdrop::after {
  content: "";
  display: block;
  min-height: 250px;
  background: linear-gradient(to top, #111417 4%, rgb(17 20 23 / 0.2));
}

.details-content {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 22px;
  padding: 0 22px 22px;
  margin-top: -110px;
  position: relative;
  z-index: 2;
}

.details-poster {
  width: 190px;
  height: 285px;
  overflow: hidden;
  border-radius: 8px;
  background: var(--card-2);
  box-shadow: 0 18px 45px rgb(0 0 0 / 0.35);
}

.details-poster img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.details-copy {
  display: grid;
  align-content: start;
  gap: 12px;
  padding-top: 92px;
}

.details-copy h2 {
  font-size: 2rem;
}

.details-overview {
  color: var(--muted);
  line-height: 1.55;
}

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

.detail-link-button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  padding: 0 16px;
  border-radius: 6px;
  background: var(--card-2);
  color: var(--ink);
  text-decoration: none;
  border: 1px solid var(--line);
  font-weight: 800;
}

.details-seasons,
.details-episodes,
.details-providers,
.details-cast,
.details-similar {
  display: grid;
  gap: 10px;
  margin-top: 4px;
}

.details-seasons h3,
.details-episodes h3,
.details-providers h3,
.details-cast h3,
.details-similar h3 {
  margin: 0;
}

.provider-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.provider-token {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--muted);
  font-size: 0.88rem;
}

.provider-token img {
  width: 22px;
  height: 22px;
  border-radius: 5px;
  object-fit: cover;
}

.cast-strip {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 118px;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.cast-card {
  display: grid;
  gap: 6px;
  align-content: start;
  color: var(--muted);
  font-size: 0.78rem;
}

.cast-card img {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--card-2);
}

.cast-card strong {
  color: var(--ink);
  font-size: 0.88rem;
  line-height: 1.1;
}

.season-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 8px;
}

.season-action {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.season-button {
  min-height: 34px;
  border: 1px solid var(--line);
  background: var(--card-2);
  color: var(--ink);
  overflow-wrap: anywhere;
}

.season-request-button {
  min-height: 34px;
  padding: 0 11px;
  border: 1px solid var(--line);
  background: var(--gold);
  color: #16130d;
}

.episode-list {
  display: grid;
  gap: 8px;
  max-height: 300px;
  overflow: auto;
}

.episode-item {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--card);
}

.episode-top {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
}

.episode-top strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.episode-top button {
  flex: 0 0 auto;
  min-height: 30px;
  padding: 0 9px;
  font-size: 0.82rem;
}

.episode-item p {
  margin: 5px 0 0;
  color: var(--muted);
  line-height: 1.4;
}

.search-modal::backdrop {
  background: rgb(0 0 0 / 0.72);
}

.modal-shell {
  display: grid;
  max-height: min(840px, calc(100vh - 28px));
}

.modal-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.close-button {
  min-height: 34px;
  border: 1px solid var(--line);
  background: var(--card-2);
  color: var(--ink);
}

.modal-search-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.modal-results-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
}

.carousel-controls {
  display: flex;
  gap: 8px;
}

.carousel-controls .icon-button {
  width: 36px;
  min-height: 36px;
  padding: 0;
  font-size: 1.4rem;
}

.modal-results {
  min-height: 430px;
  max-height: 560px;
  overflow: auto;
}

.result-carousel {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(340px, 420px);
  gap: 14px;
  padding: 18px;
  overflow-x: auto;
  overflow-y: auto;
  scroll-snap-type: x mandatory;
  scroll-padding: 18px;
}

.result-carousel::-webkit-scrollbar {
  height: 10px;
}

.result-carousel::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 999px;
}

.result-card {
  position: relative;
  display: grid;
  grid-template-columns: 118px minmax(0, 1fr);
  min-height: 252px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #131619;
  scroll-snap-align: start;
}

.result-card.is-expanded {
  border-color: var(--gold);
}

.result-poster {
  position: relative;
  min-height: 100%;
  background: var(--card-2);
}

.result-poster::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to right, transparent 65%, rgb(19 22 25 / 0.8));
  pointer-events: none;
}

.result-poster img {
  width: 100%;
  height: 100%;
  min-height: 252px;
  display: block;
  object-fit: cover;
}

.poster-fallback {
  display: grid;
  place-items: center;
  color: var(--gold);
  font-size: 2.4rem;
  font-weight: 900;
}

.result-card-body {
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 15px;
  background: #131619;
}

.result-card-body h3 {
  margin: 0;
  font-size: 1.12rem;
  line-height: 1.18;
  overflow-wrap: anywhere;
}

.result-release {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.result-card .want-button {
  width: 100%;
}

.torrent-info-button {
  min-height: 34px;
  width: 100%;
  border: 1px solid var(--line);
  background: var(--card-2);
  color: var(--ink);
}

.torrent-details {
  display: grid;
  gap: 7px;
  padding-top: 2px;
  color: var(--muted);
  font-size: 0.84rem;
}

.torrent-details[hidden] {
  display: none;
}

.torrent-details > div:not(.torrent-links) {
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr);
  gap: 8px;
}

.torrent-details span {
  color: var(--muted);
}

.torrent-details strong {
  min-width: 0;
  color: var(--ink);
  font-weight: 750;
  overflow-wrap: anywhere;
}

.torrent-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 2px;
}

.torrent-links a {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--card-2);
  color: var(--ink);
  text-decoration: none;
  font-weight: 800;
}

.progress {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #333940;
}

.progress > span {
  display: block;
  height: 100%;
  width: var(--progress);
  background: var(--gold);
}

@media (max-width: 980px) {
  .content-grid {
    grid-template-columns: 1fr;
  }

  h1 { font-size: 3rem; }
}

@media (max-width: 680px) {
  .app-shell { width: min(100% - 18px, 680px); }
  .top-nav, .section-heading, .panel-heading, .item-top { align-items: stretch; flex-direction: column; }
  .nav-links { flex-wrap: wrap; }
  .quick-form, .modal-search-form { grid-template-columns: 1fr; }
  .catalogue-search-form { grid-template-columns: 1fr; }
  .filter-input { max-width: none; }
  h1 { font-size: 2.35rem; }
  .hero { min-height: auto; gap: 28px; }
  .library-row {
    grid-template-columns: 54px minmax(0, 1fr);
    align-items: start;
  }
  .library-art {
    width: 50px;
    height: 74px;
  }
  .library-actions {
    grid-column: 2;
    justify-content: flex-start;
  }
  .modal-heading { align-items: stretch; flex-direction: column; }
  .segmented-controls { justify-content: flex-start; }
  .modal-results { min-height: 390px; }
  .result-carousel {
    grid-auto-columns: minmax(300px, 88vw);
    padding: 12px;
    scroll-padding: 12px;
  }
  .result-card {
    grid-template-columns: 104px minmax(0, 1fr);
    min-height: 242px;
  }
  .result-poster, .result-poster img { min-height: 242px; }
  .details-content {
    grid-template-columns: 1fr;
    margin-top: -90px;
  }
  .details-poster {
    width: 132px;
    height: 198px;
  }
  .details-copy {
    padding-top: 0;
  }
  .details-copy h2 {
    font-size: 1.55rem;
  }
  .poster-row {
    grid-auto-columns: 138px;
  }
  .row-card {
    grid-template-rows: 205px auto auto auto;
  }
}
