:root {
  --bg: #0b0b0f;
  --surface: #15151c;
  --surface-2: #1e1e28;
  --border: #272734;
  --crimson: #e11d48;
  --crimson-bright: #f41845;
  --crimson-dark: #9f0b2c;
  --text: #f8fafc;
  --muted: #9ca3af;
  --subtle: #6b7280;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  background: #050507;
  color: var(--text);
  min-height: 100vh;
}

.app-shell {
  max-width: 960px;
  min-height: 100vh;
  margin: 0 auto;
  background: var(--bg);
  position: relative;
  padding-bottom: 92px;
}

.hidden {
  display: none !important;
}

/* Top Search Bar */
.top-bar {
  position: sticky;
  top: 0;
  z-index: 30;
  padding: 16px 18px 12px;
  background: linear-gradient(180deg, rgba(11, 11, 15, 0.98) 78%, rgba(11, 11, 15, 0));
  backdrop-filter: blur(10px);
}

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 11px 16px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-box:focus-within {
  border-color: var(--crimson);
  box-shadow: 0 0 0 3px rgba(225, 29, 72, 0.16);
}

.search-icon {
  width: 19px;
  height: 19px;
  color: var(--muted);
  flex-shrink: 0;
}

.search-box input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 0.96rem;
}

.search-box input::placeholder {
  color: var(--subtle);
}

.clear-btn {
  background: var(--surface-2);
  color: var(--muted);
  border: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}

/* Views & Sections */
.view {
  padding: 6px 18px 16px;
}

.section {
  margin-bottom: 28px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.section-header h2 {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.see-all-btn {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 13px;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease;
}

.see-all-btn:hover {
  border-color: var(--crimson);
  color: var(--text);
}

/* Now Showing Horizontal Carousel */
.poster-carousel {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 6px;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
}

.poster-carousel::-webkit-scrollbar {
  display: none;
}

.carousel-card {
  flex: 0 0 148px;
  scroll-snap-align: start;
  cursor: pointer;
}

@media (min-width: 640px) {
  .carousel-card {
    flex: 0 0 170px;
  }
}

.poster-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 2 / 3;
  border-radius: 16px;
  overflow: hidden;
  background: var(--surface);
  margin-bottom: 9px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.45);
}

.poster-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.25s ease;
}

.carousel-card:hover .poster-wrap img,
.grid-card:hover .poster-wrap img {
  transform: scale(1.04);
}

.card-title {
  font-size: 0.94rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}

.rating-line {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.78rem;
  color: var(--muted);
}

.star-icon {
  width: 13px;
  height: 13px;
  color: var(--crimson);
  flex-shrink: 0;
}

/* Popular Vertical List */
.popular-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

@media (min-width: 720px) {
  .popular-list {
    grid-template-columns: 1fr 1fr;
  }
}

.popular-item {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 10px;
  border-radius: 16px;
  background: rgba(21, 21, 28, 0.55);
  border: 1px solid rgba(39, 39, 52, 0.6);
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.popular-item:hover {
  border-color: rgba(225, 29, 72, 0.55);
  background: var(--surface);
}

.popular-thumb {
  width: 78px;
  height: 106px;
  border-radius: 12px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--surface-2);
}

.popular-info {
  min-width: 0;
  flex: 1;
}

.popular-info h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.genre-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0;
}

.genre-pill {
  background: var(--surface-2);
  color: #cbd5e1;
  font-size: 0.7rem;
  padding: 3px 9px;
  border-radius: 999px;
}

.meta-sub {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.78rem;
  color: var(--muted);
}

.meta-sub svg {
  width: 13px;
  height: 13px;
  color: var(--subtle);
}

/* Grid View */
.status-text {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 14px;
}

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(136px, 1fr));
  gap: 16px 14px;
}

@media (min-width: 640px) {
  .media-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  }
}

.grid-card {
  cursor: pointer;
}

.type-tag {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(11, 11, 15, 0.82);
  color: #fda4af;
  border: 1px solid rgba(225, 29, 72, 0.45);
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 6px;
}

/* Detail & Player View (matches right-hand mockup screen) */
.detail-view {
  min-height: 100vh;
  background: var(--bg);
}

.detail-hero {
  position: relative;
  width: 100%;
  height: 410px;
  overflow: hidden;
  background: #000;
}

@media (min-width: 640px) {
  .detail-hero {
    height: 460px;
  }
}

.detail-backdrop {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 20%;
  display: block;
}

.detail-gradient {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(11, 11, 15, 0.45) 0%,
    rgba(11, 11, 15, 0.1) 35%,
    rgba(11, 11, 15, 0.85) 78%,
    #0b0b0f 100%
  );
}

.detail-top-actions {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 16px;
  display: flex;
  justify-content: space-between;
  z-index: 5;
}

.circle-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(11, 11, 15, 0.62);
  backdrop-filter: blur(8px);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.circle-btn svg {
  width: 20px;
  height: 20px;
}

.circle-btn.saved {
  background: var(--crimson);
  border-color: var(--crimson);
}

.circle-btn.saved svg {
  fill: #fff;
}

.detail-hero-text {
  position: absolute;
  bottom: 14px;
  left: 18px;
  right: 18px;
  text-align: center;
  z-index: 4;
}

.detail-hero-text h1 {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin-bottom: 6px;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.8);
}

.detail-genres {
  font-size: 0.92rem;
  color: #d1d5db;
}

.detail-genres .dot {
  color: var(--crimson);
  margin: 0 6px;
  font-weight: 800;
}

.detail-body {
  padding: 10px 20px 30px;
}

.stats-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.trailer-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: 12px;
  background: rgba(225, 29, 72, 0.12);
  border: 1px solid rgba(225, 29, 72, 0.55);
  color: #fff;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
}

.trailer-btn svg {
  width: 16px;
  height: 16px;
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.red-icon {
  width: 22px;
  height: 22px;
  color: var(--crimson);
  flex-shrink: 0;
}

.stat-label {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
}

.stat-value {
  font-size: 0.88rem;
  color: var(--crimson-bright);
  font-weight: 700;
}

/* Player Panel */
.player-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
  margin-bottom: 20px;
}

.tv-controls {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.tv-controls label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.84rem;
  color: var(--muted);
  flex: 1;
  min-width: 140px;
}

.tv-controls select {
  flex: 1;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 0.86rem;
}

.iframe-wrapper {
  position: relative;
  width: 100%;
  padding-top: 56.25%;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 12px;
}

.iframe-wrapper iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.server-heading {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 8px;
}

.server-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.server-btn {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 13px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.server-btn.active {
  background: linear-gradient(135deg, var(--crimson-bright), var(--crimson-dark));
  border-color: transparent;
  color: #fff;
}

.player-notice {
  margin-top: 10px;
  font-size: 0.78rem;
  color: #fbbf24;
}

.detail-overview {
  color: #b8bec9;
  font-size: 0.94rem;
  line-height: 1.65;
  margin-bottom: 24px;
}

.cta-btn {
  width: 100%;
  padding: 15px 24px;
  border: none;
  border-radius: 999px;
  background: linear-gradient(90deg, #b90e31 0%, #e5103d 50%, #9b0b29 100%);
  color: #fff;
  font-size: 1.02rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow: 0 10px 26px rgba(225, 29, 72, 0.35);
  transition: transform 0.15s ease, filter 0.15s ease;
}

.cta-btn:active {
  transform: scale(0.98);
}

/* Bottom Navigation Bar */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 960px;
  background: rgba(15, 15, 21, 0.96);
  backdrop-filter: blur(12px);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  z-index: 40;
}

.nav-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  display: flex;
  justify-content: center;
  cursor: pointer;
}

.nav-pill {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-width: 62px;
  padding: 7px 10px;
  border-radius: 14px;
  font-size: 0.72rem;
  font-weight: 600;
  transition: background 0.2s ease, color 0.2s ease;
}

.nav-pill svg {
  width: 21px;
  height: 21px;
}

.nav-btn.active .nav-pill {
  background: linear-gradient(135deg, var(--crimson-bright), var(--crimson-dark));
  color: #fff;
  box-shadow: 0 6px 16px rgba(225, 29, 72, 0.35);
}
