:root {
  color-scheme: dark;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
  background: #0b0b0d;
  color: #f7f7f8;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top, rgba(255,255,255,0.08), transparent 38%),
    #0b0b0d;
}

body {
  min-height: 100dvh;
  overscroll-behavior: none;
}

button, input, select { font: inherit; }

button { cursor: pointer; }

.app-shell {
  min-height: 100dvh;
  max-width: 520px;
  margin: 0 auto;
}

.view {
  display: none;
  min-height: 100dvh;
  padding:
    max(18px, env(safe-area-inset-top))
    18px
    max(18px, env(safe-area-inset-bottom));
}

.view.active { display: grid; }

#watchView {
  grid-template-rows: auto 1fr auto;
  gap: 18px;
}

#libraryView {
  grid-template-rows: auto 1fr;
  gap: 18px;
}

.topbar,
.library-header,
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.topbar { align-items: end; }

.library-header {
  justify-content: flex-start;
}

.eyebrow {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.2em;
  color: #9a9aa3;
  margin-bottom: 4px;
}

h1 {
  margin: 0;
  font-size: clamp(22px, 6vw, 30px);
  line-height: 1.05;
}

.show-filter {
  max-width: 145px;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(255,255,255,0.06);
  color: white;
  border-radius: 999px;
  padding: 9px 12px;
}

.card-stage {
  min-height: 0;
  display: grid;
  place-items: center;
  perspective: 1000px;
}

.episode-card {
  width: 100%;
  background: #151519;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 26px;
  overflow: hidden;
  box-shadow: 0 26px 70px rgba(0,0,0,0.45);
  transform: translateX(0) rotate(0);
  transition: transform 220ms ease, opacity 220ms ease;
  touch-action: pan-y;
}

.episode-card.leaving-left {
  transform: translateX(-115%) rotate(-7deg);
  opacity: 0;
}

.episode-card.leaving-right {
  transform: translateX(115%) rotate(7deg);
  opacity: 0;
}

.poster-wrap {
  position: relative;
  aspect-ratio: 2 / 2.25;
  background: #202027;
  overflow: hidden;
}

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

.poster-wrap::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 45%;
  background: linear-gradient(to bottom, transparent, #151519);
  pointer-events: none;
}

.favourite-button {
  position: absolute;
  z-index: 2;
  top: 14px;
  right: 14px;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: rgba(10,10,12,0.62);
  backdrop-filter: blur(14px);
  color: white;
  font-size: 25px;
}

.favourite-button.active {
  background: white;
  color: #111;
}

.episode-content {
  padding: 2px 20px 22px;
}

.show-name {
  font-size: 13px;
  font-weight: 700;
  color: #aaaab2;
  margin-bottom: 5px;
}

.episode-title {
  font-size: clamp(28px, 8vw, 40px);
  letter-spacing: -0.035em;
  line-height: 0.98;
  margin: 0;
}

.episode-meta {
  display: flex;
  gap: 7px;
  align-items: center;
  margin-top: 12px;
  font-size: 14px;
  color: #b7b7bf;
}

.dot { opacity: 0.45; }

.plot {
  margin: 14px 0 0;
  color: #d3d3d8;
  line-height: 1.48;
  font-size: 15px;
}

.bottom-actions {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 12px;
}

.bottom-actions button,
.empty-state button,
.search-button {
  min-height: 54px;
  border-radius: 17px;
  font-weight: 800;
}

.secondary-button,
.icon-button {
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(255,255,255,0.06);
  color: white;
}

.next-button,
.search-button {
  border: 0;
  background: #f3f3f5;
  color: #0c0c0e;
}

.icon-button {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 32px;
  line-height: 1;
}

.hidden { display: none !important; }

.empty-state {
  text-align: center;
  max-width: 330px;
  padding: 28px 12px;
}

.empty-icon {
  width: 66px;
  height: 66px;
  display: grid;
  place-items: center;
  margin: 0 auto 16px;
  border-radius: 22px;
  background: rgba(255,255,255,0.07);
  font-size: 36px;
}

.empty-state h2 {
  margin: 0 0 8px;
  font-size: 26px;
}

.empty-state p {
  margin: 0 0 20px;
  color: #aaaab2;
  line-height: 1.45;
}

.empty-state button { padding: 0 22px; }

.library-content {
  overflow-y: auto;
  padding-bottom: 24px;
}

.search-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.search-form input {
  width: 100%;
  min-width: 0;
  min-height: 52px;
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 16px;
  background: #151519;
  color: white;
  padding: 0 15px;
  outline: none;
}

.search-form input:focus {
  border-color: rgba(255,255,255,0.35);
}

.search-button {
  min-height: 52px;
  padding: 0 18px;
}

.status-text {
  min-height: 20px;
  color: #9a9aa3;
  font-size: 13px;
  margin: 10px 3px;
}

.result-list,
.library-list {
  display: grid;
  gap: 10px;
}

.search-result,
.library-item {
  display: grid;
  grid-template-columns: 58px 1fr auto;
  gap: 12px;
  align-items: center;
  background: #151519;
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 18px;
  padding: 10px;
}

.thumb {
  width: 58px;
  height: 82px;
  border-radius: 11px;
  object-fit: cover;
  background: #25252b;
}

.item-title {
  font-weight: 800;
  line-height: 1.2;
}

.item-subtitle {
  color: #9898a1;
  font-size: 13px;
  margin-top: 5px;
}

.small-button {
  border: 0;
  border-radius: 12px;
  min-height: 38px;
  padding: 0 12px;
  background: rgba(255,255,255,0.10);
  color: white;
  font-weight: 700;
}

.small-button.primary {
  background: white;
  color: #111;
}

.small-button.danger {
  color: #ffb7b7;
}

.item-actions {
  display: grid;
  gap: 7px;
}

.section-heading {
  margin: 26px 2px 12px;
  justify-content: flex-start;
}

.section-heading h2 {
  margin: 0;
  font-size: 20px;
}

.count-badge {
  display: inline-grid;
  place-items: center;
  min-width: 27px;
  height: 27px;
  padding: 0 8px;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  color: #aaaab2;
  font-size: 12px;
  font-weight: 700;
}

.library-empty {
  color: #8f8f98;
  border: 1px dashed rgba(255,255,255,0.12);
  border-radius: 18px;
  padding: 20px;
  text-align: center;
}

@media (min-height: 780px) {
  .poster-wrap { aspect-ratio: 2 / 2.45; }
}
