* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  min-height: 100dvh;
  background: #0a0a0f;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  color: #f4f4f5;
  -webkit-tap-highlight-color: transparent;
}

a { color: #a78bfa; }

.app-header {
  padding: max(0.75rem, env(safe-area-inset-top)) 1rem 0.5rem;
  text-align: center;
  position: sticky;
  top: 0;
  z-index: 10;
  background: linear-gradient(180deg, rgba(10,10,15,0.97) 70%, transparent);
}

.app-header h1 {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.02em;
}

.tabs {
  display: flex;
  gap: 0.35rem;
  justify-content: center;
  padding: 0.65rem 1rem 0.35rem;
}

.tabs button {
  flex: 1;
  max-width: 7.5rem;
  padding: 0.5rem 0.45rem;
  border-radius: 999px;
  border: 1px solid #3f3f46;
  background: #18181b;
  color: #e4e4e7;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}

.tabs button[aria-selected="true"] {
  background: linear-gradient(135deg, #7c3aed, #db2777);
  border-color: transparent;
  color: #fff;
}

.panel { display: none; padding: 0 1rem max(1rem, env(safe-area-inset-bottom)); }
.panel.is-active { display: block; }

.stack-wrap {
  max-width: 420px;
  margin: 0 auto;
  padding-top: 0.5rem;
}

.card-outer {
  position: relative;
  border-radius: 20px;
  overflow: hidden;
  background: #18181b;
  box-shadow: 0 20px 50px rgba(0,0,0,0.55);
  min-height: min(72vh, 560px);
}

.card-outer::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 35%, rgba(0,0,0,0.92) 100%);
  z-index: 1;
  pointer-events: none;
}

.card-media {
  position: relative;
  width: 100%;
  height: min(52vh, 400px);
  background: #27272a;
  overflow: hidden;
}

.card-media-fallback {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: opacity 0.45s ease;
}

.card-media-empty {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #71717a;
  font-size: 0.85rem;
}

.card-media-loading {
  position: absolute;
  bottom: 0.65rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  font-size: 0.72rem;
  color: #e4e4e7;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.9);
  pointer-events: none;
}

.card-media-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  z-index: 2;
}

.card-media--video .card-media-fallback {
  opacity: 0;
}

/* Short vertical na home (pesquisa «corte + título»). */
.card-media--shorts {
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-media--shorts .card-media-frame--short {
  position: relative;
  inset: auto;
  width: min(58vw, 232px);
  height: min(52vh, 400px);
  max-height: 100%;
  aspect-ratio: 9 / 16;
  border: 0;
  border-radius: 14px;
  z-index: 2;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.55);
}

/* Vídeo da cena TMDB no modal (16:9): abaixo da caixa da galeria, antes da sinopse */
.modal-gallery-wrap + .modal-scene-video {
  margin-top: 0.15rem;
}

.modal-scene-video {
  margin: 0 -0.35rem 0.9rem;
}

.modal-scene-video__frame {
  position: relative;
  width: 100%;
  border-radius: 12px;
  overflow: hidden;
  background: #27272a;
  aspect-ratio: 16 / 9;
}

.modal-scene-video__iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

.card-body {
  position: relative;
  z-index: 2;
  padding: 0 1.1rem 1rem;
  margin-top: -4.5rem;
  /* Deixa toques passarem para o player do YouTube na zona sobreposta ao vídeo */
  pointer-events: none;
}

.card-body > * {
  pointer-events: auto;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 0.75rem;
  margin-bottom: 0.55rem;
}

.badge-row__left {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
}

.card-year {
  font-size: 0.8rem;
  font-weight: 600;
  color: #a1a1aa;
  letter-spacing: 0.02em;
}

.card-rating {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  flex-shrink: 0;
  padding: 0.38rem 0.75rem 0.4rem;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  border: 1px solid transparent;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

.card-rating__star {
  font-size: 0.95rem;
  margin-right: 0.05rem;
  opacity: 0.95;
}

.card-rating__value {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.card-rating__suffix {
  font-size: 0.72rem;
  font-weight: 700;
  opacity: 0.82;
  margin-left: 0.05rem;
}

.card-rating--high {
  color: #ecfccb;
  background: linear-gradient(145deg, rgba(34, 197, 94, 0.38), rgba(21, 128, 61, 0.55));
  border-color: rgba(74, 222, 128, 0.45);
}

.card-rating--mid {
  color: #fffbeb;
  background: linear-gradient(145deg, rgba(245, 158, 11, 0.42), rgba(180, 83, 9, 0.5));
  border-color: rgba(251, 191, 36, 0.5);
}

.card-rating--low {
  color: #f4f4f5;
  background: linear-gradient(145deg, rgba(113, 113, 122, 0.45), rgba(63, 63, 70, 0.65));
  border-color: rgba(161, 161, 170, 0.35);
}

.card-rating--na {
  color: #e4e4e7;
  background: rgba(39, 39, 42, 0.85);
  border-color: #52525b;
}

.card-rating--na .card-rating__star {
  opacity: 0.5;
}

.badge {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.2rem 0.45rem;
  border-radius: 6px;
  background: rgba(255,255,255,0.12);
}

.badge--movie { background: rgba(59, 130, 246, 0.35); }
.badge--tv { background: rgba(236, 72, 153, 0.35); }

.meta {
  font-size: 0.85rem;
  color: #d4d4d8;
}

.card-title {
  font-size: 1.35rem;
  font-weight: 800;
  line-height: 1.2;
  margin: 0.35rem 0 0.5rem;
}

.card-release-date {
  font-size: 0.82rem;
  line-height: 1.4;
  color: #a1a1aa;
  margin: 0 0 0.5rem;
}

.card-overview {
  font-size: 0.85rem;
  line-height: 1.5;
  color: #d4d4d8;
  margin: 0;
}

.card-overview--loading {
  color: #a1a1aa;
  font-style: italic;
}

.actions-row {
  display: flex;
  gap: 0.6rem;
  margin-top: 1rem;
  flex-wrap: wrap;
  justify-content: center;
}

.actions-row button {
  flex: 1;
  min-width: 6.5rem;
  padding: 0.75rem 1rem;
  border-radius: 14px;
  border: none;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
}

.btn-nope {
  background: #27272a;
  color: #f87171;
  border: 1px solid #3f3f46;
}

.btn-like {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: #fff;
}

.actions-row--tv .btn-agenda {
  flex: 1 1 100%;
  min-width: 100%;
}

.btn-agenda {
  background: rgba(139, 92, 246, 0.22);
  color: #e9d5ff;
  border: 1px solid #7c3aed;
}

.btn-agenda:hover {
  background: rgba(139, 92, 246, 0.35);
  border-color: #a78bfa;
}

.card-outer.anim-out-left {
  animation: outLeft 0.35s ease forwards;
}

.card-outer.anim-out-right {
  animation: outRight 0.35s ease forwards;
}

@keyframes outLeft {
  to { transform: translateX(-120%) rotate(-8deg); opacity: 0; }
}

@keyframes outRight {
  to { transform: translateX(120%) rotate(8deg); opacity: 0; }
}

.empty-state, .error-banner {
  text-align: center;
  padding: 2rem 1rem;
  color: #a1a1aa;
  font-size: 0.92rem;
  line-height: 1.5;
}

.error-banner {
  background: rgba(127, 29, 29, 0.35);
  border: 1px solid #7f1d1d;
  border-radius: 12px;
  color: #fecaca;
  margin: 0 1rem 1rem;
}

.saved-list {
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.saved-item {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  padding: 0.65rem 0.75rem;
  background: #18181b;
  border-radius: 14px;
  border: 1px solid #27272a;
  cursor: pointer;
  text-align: left;
}

.saved-item img {
  width: 52px;
  height: 78px;
  object-fit: cover;
  border-radius: 8px;
  background: #27272a;
}

.saved-item__body { flex: 1; min-width: 0; }

.saved-item__title {
  font-weight: 700;
  font-size: 0.95rem;
  margin: 0 0 0.2rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.saved-item__meta {
  font-size: 0.78rem;
  color: #a1a1aa;
  margin: 0;
}

.saved-item__side {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.4rem;
  flex-shrink: 0;
}

.saved-remove {
  padding: 0.38rem 0.55rem;
  font-size: 0.72rem;
  font-weight: 600;
  border-radius: 8px;
  border: 1px solid rgba(248, 113, 113, 0.45);
  background: rgba(127, 29, 29, 0.28);
  color: #fca5a5;
  cursor: pointer;
  white-space: nowrap;
}

.saved-remove:hover {
  background: rgba(153, 27, 27, 0.45);
  border-color: rgba(248, 113, 113, 0.65);
  color: #fecaca;
}

.saved-remove:active {
  transform: scale(0.98);
}

.watched-toggle {
  flex-shrink: 0;
  padding: 0.4rem 0.65rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 999px;
  border: 1px solid #52525b;
  background: transparent;
  color: #e4e4e7;
  cursor: pointer;
}

.watched-toggle.is-on {
  background: rgba(34, 197, 94, 0.2);
  border-color: #22c55e;
  color: #86efac;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.72);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: env(safe-area-inset-top) 0 0;
}

.modal-sheet {
  width: 100%;
  max-width: 480px;
  max-height: 92vh;
  overflow-y: auto;
  background: #18181b;
  border-radius: 20px 20px 0 0;
  padding: 1rem 1.1rem max(1.25rem, env(safe-area-inset-bottom));
  border: 1px solid #3f3f46;
  border-bottom: none;
}

.modal-sheet--detail {
  max-width: 520px;
  display: flex;
  flex-direction: column;
  max-height: 92vh;
  overflow: hidden;
}

.modal-sheet--schedule {
  max-width: 480px;
  max-height: 88vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.modal-schedule-series {
  font-size: 0.95rem;
  color: #d4d4d8;
  margin: 0 0 0.85rem;
}

.modal-schedule-status {
  margin: 0 0 1rem;
}

.modal-schedule-block {
  margin: 0 0 1.1rem;
  padding: 0.75rem 0.85rem;
  background: rgba(39, 39, 42, 0.65);
  border: 1px solid #3f3f46;
  border-radius: 14px;
}

.modal-schedule-block--muted {
  background: transparent;
}

.modal-schedule-ep-title {
  font-size: 0.92rem;
  font-weight: 600;
  color: #fafafa;
  margin: 0 0 0.35rem;
  line-height: 1.45;
}

.modal-schedule-date {
  font-size: 0.88rem;
  color: #a78bfa;
  margin: 0 0 0.35rem;
}

.modal-schedule-overview {
  margin: 0.6rem 0 0.5rem;
  padding-top: 0.55rem;
  border-top: 1px solid #3f3f46;
}

.modal-schedule-overview__label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #a1a1aa;
  margin: 0 0 0.35rem;
}

.modal-schedule-overview__text {
  font-size: 0.85rem;
  line-height: 1.55;
  color: #d4d4d8;
  margin: 0;
}

.modal-schedule-note,
.modal-schedule-flag {
  font-size: 0.8rem;
  color: #a1a1aa;
  margin: 0;
  line-height: 1.45;
}

.modal-schedule-flag {
  color: #d8b4fe;
}

.modal-close {
  position: sticky;
  top: 0;
  z-index: 40;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 0.65rem 1rem;
  margin: 0 0 0.5rem;
  background: linear-gradient(180deg, #18181b 88%, rgba(24, 24, 27, 0));
  border: 1px solid #3f3f46;
  border-radius: 14px;
  color: #fafafa;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.modal-close:hover {
  background: #27272a;
  border-color: #71717a;
}

.modal-sheet--detail #modal-inner {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.modal-detail-title {
  font-size: 1.25rem;
  margin: 0.65rem 0 0.35rem;
}

.modal-section-title {
  font-size: 0.95rem;
  font-weight: 700;
  margin: 0 0 0.45rem;
  color: #fafafa;
}

.modal-muted {
  color: #a1a1aa;
  font-size: 0.88rem;
  margin: 0;
}

.modal-async-hint {
  margin: 0.85rem 0 0;
  font-size: 0.82rem;
  color: #a78bfa;
  animation: modal-async-pulse 1.2s ease-in-out infinite;
}

@keyframes modal-async-pulse {
  0%,
  100% {
    opacity: 0.65;
  }
  50% {
    opacity: 1;
  }
}

.modal-gallery-wrap {
  margin: 0 -0.35rem 0.75rem;
}

.modal-gallery__hint {
  margin: 0 0.35rem 0.45rem;
  font-size: 0.78rem;
  color: #a1a1aa;
}

.modal-gallery {
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  padding-bottom: 0.35rem;
}

.modal-gallery__track {
  display: flex;
  gap: 0.65rem;
  padding: 0 0.35rem 0.25rem;
}

.modal-gallery__slide {
  flex: 0 0 min(88vw, 400px);
  scroll-snap-align: center;
  border-radius: 12px;
  overflow: hidden;
  background: #27272a;
}

.modal-gallery__slide img {
  display: block;
  width: 100%;
  height: min(268px, 44vh);
  object-fit: cover;
}

.modal-seasons {
  margin: 1rem 0 1.1rem;
  padding: 0.75rem 0 0;
  border-top: 1px solid #3f3f46;
}

.modal-seasons__list {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  margin-top: 0.5rem;
}

.modal-season {
  padding: 0.65rem 0.75rem;
  background: rgba(24, 24, 27, 0.65);
  border: 1px solid #3f3f46;
  border-radius: 12px;
}

.modal-season__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.35rem 0.75rem;
  margin-bottom: 0.45rem;
}

.modal-season__title {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 700;
  color: #fafafa;
  letter-spacing: -0.02em;
}

.modal-season__meta {
  font-size: 0.75rem;
  font-weight: 600;
  color: #a1a1aa;
  white-space: nowrap;
}

.modal-season__overview {
  margin: 0;
  font-size: 0.86rem;
  line-height: 1.55;
  color: #d4d4d8;
  white-space: pre-wrap;
}

.modal-synopsis {
  margin: 0.85rem 0 1rem;
}

.modal-overview--full {
  font-size: 0.9rem;
  line-height: 1.6;
  color: #d4d4d8;
  margin: 0;
  white-space: pre-wrap;
}

.modal-watch {
  margin: 1rem 0;
  padding: 0.75rem 0 0;
  border-top: 1px solid #3f3f46;
}

.modal-watch__region {
  margin: 0 0 0.5rem;
  font-size: 0.82rem;
  color: #a1a1aa;
}

.modal-watch__region strong {
  color: #e4e4e7;
}

.modal-watch__note {
  margin: 0 0 0.65rem;
  font-size: 0.78rem;
  line-height: 1.45;
  color: #a1a1aa;
}

.modal-watch__block {
  margin-bottom: 0.85rem;
}

.modal-watch__subtitle {
  margin: 0 0 0.4rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: #d4d4d8;
}

.modal-watch__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.modal-watch__item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.35rem 0.45rem;
  background: #27272a;
  border-radius: 10px;
  border: 1px solid #3f3f46;
}

.modal-watch__logo {
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  background: #18181b;
}

.modal-watch__name {
  font-size: 0.88rem;
  color: #f4f4f5;
}

.modal-watch__tmdb {
  margin: 0.65rem 0 0;
}

.modal-watch__link {
  font-size: 0.88rem;
  color: #a78bfa;
}

.modal-reviews {
  margin: 1rem 0 0;
  padding-top: 0.75rem;
  border-top: 1px solid #3f3f46;
}

.modal-reviews__scroll {
  max-height: min(45vh, 400px);
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 0.15rem 0.25rem 0.25rem 0;
  margin-right: -0.15rem;
  scrollbar-gutter: stable;
  border: 1px solid #3f3f46;
  border-radius: 12px;
  background: rgba(15, 15, 20, 0.45);
}

.modal-reviews__list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding: 0.35rem 0.4rem 0.5rem 0.15rem;
}

.modal-review {
  padding: 0.65rem 0.75rem;
  background: #27272a;
  border-radius: 12px;
  border: 1px solid #3f3f46;
}

.modal-review__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}

.modal-review__author {
  font-size: 0.85rem;
  color: #f4f4f5;
}

.modal-review__rating {
  flex-shrink: 0;
  font-size: 0.78rem;
  font-weight: 600;
  color: #fbbf24;
}

.modal-review__body {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.5;
  color: #d4d4d8;
  white-space: pre-wrap;
}

.modal-meta-line {
  font-size: 0.82rem;
  color: #a1a1aa;
  margin: 0.35rem 0 0.75rem;
}

.loading-pulse {
  text-align: center;
  padding: 2rem;
  color: #71717a;
}

/* —— Catálogo (pesquisa TMDB) —— */
.catalog-wrap {
  max-width: 520px;
  margin: 0 auto;
  padding-bottom: 0.5rem;
}

.catalog-segment {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}

.catalog-segment__btn {
  flex: 1;
  padding: 0.5rem 0.65rem;
  border-radius: 12px;
  border: 1px solid #3f3f46;
  background: #18181b;
  color: #d4d4d8;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
}

.catalog-segment__btn.is-active {
  background: linear-gradient(135deg, #6366f1, #7c3aed);
  border-color: transparent;
  color: #fff;
}

.catalog-search {
  margin-bottom: 0.5rem;
}

.catalog-search__label {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.catalog-search__row {
  display: flex;
  gap: 0.45rem;
  align-items: stretch;
}

.catalog-search__row input {
  flex: 1;
  min-width: 0;
  padding: 0.6rem 0.75rem;
  border-radius: 12px;
  border: 1px solid #3f3f46;
  background: #18181b;
  color: #f4f4f5;
  font-size: 0.9rem;
}

.catalog-search__row input::placeholder {
  color: #71717a;
}

.catalog-search__submit {
  flex-shrink: 0;
  padding: 0.6rem 1rem;
  border-radius: 12px;
  border: none;
  background: linear-gradient(135deg, #7c3aed, #db2777);
  color: #fff;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
}

.catalog-hint {
  font-size: 0.75rem;
  line-height: 1.4;
  color: #a1a1aa;
  margin: 0 0 0.75rem;
}

.catalog-status {
  font-size: 0.82rem;
  color: #a78bfa;
  text-align: center;
  margin: 0.5rem 0;
}

.catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
  gap: 0.65rem;
  margin-bottom: 0.75rem;
}

.catalog-card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  text-align: left;
  padding: 0;
  border: 1px solid #27272a;
  border-radius: 12px;
  background: #18181b;
  cursor: pointer;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

.catalog-card:focus-visible {
  outline: 2px solid #a78bfa;
  outline-offset: 2px;
}

.catalog-card__thumb {
  aspect-ratio: 2 / 3;
  background: #27272a;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.catalog-card__ph {
  font-size: 0.7rem;
  color: #71717a;
  padding: 0.5rem;
  text-align: center;
}

.catalog-card__title {
  padding: 0.4rem 0.45rem 0.55rem;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.3;
  color: #e4e4e7;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.catalog-empty {
  text-align: center;
  color: #a1a1aa;
  font-size: 0.9rem;
  margin: 1.5rem 0;
}

.catalog-more {
  display: block;
  width: 100%;
  max-width: 280px;
  margin: 0.25rem auto 0;
  padding: 0.65rem 1rem;
  border-radius: 12px;
  border: 1px solid #52525b;
  background: #27272a;
  color: #fafafa;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.catalog-more:hover {
  background: #3f3f46;
}
