:root {
  color-scheme: dark;
  --bg: #050505;
  --panel: #101010;
  --panel-2: #181818;
  --panel-3: #1f1f1f;
  --text: #f4f4f4;
  --muted: #a5a5a5;
  --border: #2c2c2c;
  --accent: #ffffff;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button { font: inherit; }
body.modal-open { overflow: hidden; }
.app {
  min-height: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 28px 24px 40px;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 22px;
}
.topbar {
  display: grid;
  grid-template-columns: 56px 1fr 56px;
  align-items: center;
  gap: 18px;
}
.title-wrap { text-align: center; }
h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 3.8rem);
  line-height: 1;
  font-weight: 760;
  letter-spacing: -0.045em;
}
.genre-row {
  margin-top: 8px;
  display: inline-flex;
  align-items: baseline;
  gap: 10px;
}
.label {
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
}
h2 {
  margin: 0;
  font-size: clamp(1.25rem, 3vw, 2rem);
  line-height: 1.1;
  font-weight: 680;
}
.controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.mode-group {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  background: var(--panel);
}
.mode-btn {
  border: 0;
  border-right: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  padding: 10px 14px;
  cursor: pointer;
}
.mode-btn:last-child { border-right: 0; }
.mode-btn.is-active {
  background: var(--panel-3);
  color: var(--text);
}
.icon-btn,
.nav-btn {
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  border-radius: 12px;
  cursor: pointer;
}
.icon-btn {
  width: 56px;
  height: 56px;
  font-size: 2rem;
  line-height: 1;
}
.nav-btn {
  min-width: 108px;
  padding: 11px 16px;
}
.nav-btn.secondary {
  min-width: auto;
}
.icon-btn:disabled,
.nav-btn:disabled,
.mode-btn:disabled {
  opacity: 0.4;
  cursor: default;
}
.movies-section {
  display: grid;
  align-content: center;
  min-height: 56vh;
}
.status {
  min-height: 24px;
  text-align: center;
  color: var(--muted);
  font-size: 0.95rem;
  margin-bottom: 24px;
}
.movies {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}
.movie-card {
  display: grid;
  grid-template-rows: auto 70px;
  gap: 12px;
  align-content: start;
  transition: opacity 160ms ease, transform 160ms ease;
}
.movie-card.is-hidden {
  opacity: 0;
  pointer-events: none;
}
.poster-button {
  all: unset;
  cursor: pointer;
  display: block;
}
.poster-wrap {
  width: 100%;
  aspect-ratio: 2 / 3;
  overflow: hidden;
  background: var(--panel-2);
  border-radius: 12px;
}
.poster-wrap img,
.modal-poster {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.poster-fallback,
.modal-poster-fallback {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 18px;
  color: var(--muted);
  background: var(--panel-2);
}
.movie-meta {
  display: grid;
  grid-template-rows: 44px 18px;
  gap: 6px;
}
.title-btn {
  all: unset;
  cursor: pointer;
  display: grid;
  align-content: start;
}
.movie-title {
  font-size: 1.03rem;
  font-weight: 620;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.movie-subtitle {
  color: var(--muted);
  font-size: 0.93rem;
  line-height: 1.2;
}
.skeleton {
  animation: pulse 1.2s ease-in-out infinite;
}
.skeleton.poster-wrap,
.skeleton .skeleton-line {
  background: linear-gradient(90deg, var(--panel) 0%, var(--panel-3) 50%, var(--panel) 100%);
  background-size: 200% 100%;
}
.skeleton .skeleton-line {
  height: 14px;
  border-radius: 8px;
}
.skeleton .skeleton-line.short { width: 55%; }
@keyframes pulse {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.pager {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 18px;
}
.page-info {
  min-width: 72px;
  text-align: center;
  color: var(--muted);
}
.modal-overlay {
  position: fixed;
  inset: 0;
  padding: 28px;
  background: rgba(0, 0, 0, 0.72);
  display: grid;
  place-items: center;
}
.modal-overlay.hidden { display: none; }
.modal-shell { width: min(880px, 100%); }
.modal-card {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 24px;
  padding: 24px;
  background: #0d0d0d;
  border: 1px solid var(--border);
  border-radius: 18px;
}
.modal-poster-wrap {
  aspect-ratio: 2 / 3;
  overflow: hidden;
  background: var(--panel-2);
  border-radius: 14px;
}
.modal-poster.hidden,
.modal-poster-fallback.hidden { display: none; }
.modal-copy {
  display: grid;
  align-content: start;
  gap: 16px;
}
.modal-copy h3 {
  margin: 0;
  font-size: clamp(1.6rem, 4vw, 2.3rem);
  line-height: 1.05;
}
.modal-meta {
  color: var(--muted);
  font-size: 0.98rem;
}
.modal-overview {
  margin: 0;
  color: var(--text);
  line-height: 1.6;
}
.modal-facts {
  margin: 0;
  display: grid;
  gap: 14px;
}
.modal-facts div {
  display: grid;
  gap: 4px;
}
.modal-facts dt {
  color: var(--muted);
  font-size: 0.88rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.modal-facts dd {
  margin: 0;
}
@media (max-width: 960px) {
  .movies { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .movie-card:nth-child(5) {
    grid-column: 1 / -1;
    max-width: 280px;
    margin: 0 auto;
    width: 100%;
  }
  .modal-card { grid-template-columns: 1fr; }
  .modal-poster-wrap { max-width: 280px; }
}
@media (max-width: 640px) {
  .app { padding: 20px 16px 28px; gap: 18px; }
  .topbar { grid-template-columns: 48px 1fr 48px; gap: 12px; }
  .icon-btn { width: 48px; height: 48px; }
  .controls { flex-direction: column; align-items: stretch; }
  .mode-group { width: 100%; }
  .mode-btn { flex: 1; }
  .movies { grid-template-columns: 1fr; }
  .movie-card:nth-child(5) { max-width: none; }
  .pager { flex-wrap: wrap; }
  .modal-overlay { padding: 16px; }
  .modal-card { padding: 18px; }
}
