.dialog {
  --dialog-ink: #f7f6f4;
  --dialog-muted: #a6a9b2;
  --dialog-border: rgb(255 255 255 / 11%);
  --dialog-accent: #ff573d;
  box-sizing: border-box;
  width: min(720px, calc(100% - 32px));
  max-width: none;
  max-height: calc(100vh - 40px);
  max-height: calc(100dvh - 40px);
  margin: auto;
  padding: 0;
  overflow: auto;
  overscroll-behavior: contain;
  color: var(--dialog-ink);
  color-scheme: dark;
  background: #16181d;
  border: 1px solid var(--dialog-border);
  border-radius: 24px;
  box-shadow: 0 28px 100px rgb(0 0 0 / 55%);
  scrollbar-color: #4b4d54 transparent;
  scrollbar-width: thin;
}

.dialog::backdrop {
  background: rgb(8 9 12 / 78%);
  backdrop-filter: blur(9px);
}

[data-dialog-fallback] .dialog:not([open]) { display: none; }
[data-fallback-modal-open], [data-fallback-modal-open] body { overflow: hidden; }

[data-dialog-fallback] .dialog[open], [data-fallback-backdrop] {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
}

[data-dialog-fallback] .dialog[open] {
  display: block;
  height: -webkit-fit-content;
  height: fit-content;
  z-index: 20;
}

[data-fallback-backdrop] { z-index: 21; background: rgb(8 9 12 / 78%); }
[data-dialog-fallback] .dialog[open][data-fallback-active] { z-index: 22; }

.dialog[open] {
  animation: dialog-enter 180ms ease-out both;
}

@keyframes dialog-enter {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.dialog-inner {
  position: relative;
  padding: 28px;
}

.dialog-close {
  position: absolute;
  z-index: 1;
  inset-block-start: 16px;
  inset-inline-end: 16px;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  color: var(--dialog-ink);
  background: rgb(255 255 255 / 6%);
  border: 1px solid var(--dialog-border);
  border-radius: 50%;
  cursor: pointer;
  transition: background 140ms ease;
}

.dialog-close:hover {
  background: rgb(255 255 255 / 14%);
}

.dialog-close svg {
  width: 20px;
  height: 20px;
}

.dialog :is(button, a):focus-visible {
  outline: 2px solid var(--dialog-accent);
  outline-offset: 3px;
}

#movie-dialog {
  width: min(756px, calc(100% - 32px));
  overflow: hidden;
}

#movie-dialog[open] {
  display: flex;
  flex-direction: column;
}

.detail-scroll {
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
}

.detail-scroll:focus-visible {
  outline: 2px solid var(--dialog-accent);
  outline-offset: -3px;
}

.detail-close {
  z-index: 2;
  background: #23252b;
}

.detail-close:hover {
  background: #373942;
}

.detail-close span {
  display: none;
}

.detail-header {
  display: grid;
  grid-template-columns: clamp(104px, 21vw, 144px) minmax(0, 1fr);
  align-items: center;
  gap: 24px;
}

.detail-poster {
  position: relative;
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 2 / 3;
  overflow: hidden;
  background: #202227;
  border: 1px solid var(--dialog-border);
  border-radius: 13px;
}

.detail-poster img { display: block; width: 100%; height: auto; }

.detail-info {
  min-width: 0;
}

.detail-info h2 {
  margin: 0 0 4px;
  margin-inline-end: 34px;
  font-size: clamp(1.48rem, 4.2vw, 2.45rem);
  line-height: 1.22;
  overflow-wrap: anywhere;
}

.detail-original {
  margin: 0 0 10px;
  margin-inline-end: 34px;
  color: var(--dialog-muted);
  font-size: .9rem;
  line-height: 1.5;
}

.detail-genres {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-block: 9px;
  color: var(--dialog-muted);
  font-size: .85rem;
  line-height: 1.5;
}

.detail-genres > span {
  padding: 2px 8px;
  color: #d5d5db;
  background: rgb(255 255 255 / 4%);
  border: 1px solid var(--dialog-border);
  border-radius: 5px;
}

.detail-facts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 23px 0 0;
  padding: 13px 0;
  background: #201f24;
  border: 1px solid var(--dialog-border);
  border-radius: 12px;
}

.detail-facts > div {
  min-width: 0;
  padding-inline: clamp(9px, 2vw, 18px);
}

.detail-facts > div + div {
  border-inline-start: 1px solid var(--dialog-border);
}

.detail-facts dt,
.detail-directors dt,
.detail-muted {
  color: var(--dialog-muted);
  font-size: .875rem;
  overflow-wrap: anywhere;
}

.detail-facts dd,
.detail-directors dd {
  margin: .28rem 0 0;
  color: var(--dialog-ink);
  font-size: .9375rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.detail-section {
  margin-top: 24px;
}

.detail-section + .detail-section {
  padding-top: 20px;
  border-top: 1px solid var(--dialog-border);
}

.detail-section h3 {
  margin: 0 0 .7rem;
  font-size: 1.15rem;
}

.detail-synopsis p {
  margin: 0;
  color: #dadbe0;
  font-size: 1rem;
  line-height: 1.78;
}

.detail-synopsis p + p { margin-top: .55em; }

.detail-directors {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .2rem .8rem;
  margin: 0 0 1rem;
}

.detail-directors dd { margin: 0; }

#detail-cast-label {
  margin: 0 0 .52rem;
  font-size: .875rem;
  color: var(--dialog-muted);
  font-weight: 600;
}

.detail-cast {
  margin: 0;
  padding: 0;
  list-style: none;
}

.detail-cast {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.detail-cast li {
  display: grid;
  align-content: start;
  gap: 3px;
  min-width: 0;
  padding: .64rem .75rem;
  background: #1e2026;
  border: 1px solid var(--dialog-border);
  border-radius: 8px;
  overflow-wrap: anywhere;
}

.detail-cast strong { font-size: .9375rem; }
.cast-original { color: var(--dialog-muted); font-size: .8125rem; }
.cast-role { color: #e2d7d4; font-size: .875rem; }
.detail-muted { margin: .4rem 0 0; }

.detail-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
  padding: 12px 28px;
  background: #16181d;
  border-block-start: 1px solid var(--dialog-border);
}

.detail-actions :is(a, button) {
  min-width: 0;
  min-height: 44px;
  white-space: normal;
  overflow-wrap: anywhere;
}

#login-dialog {
  --dialog-ink: #faf7f5;
  --dialog-muted: #bcb9c1;
  --dialog-accent: #f38f76;
  --dialog-border: #414149;
  width: min(414px, calc(100% - 32px));
  background: #111214;
  scroll-padding-block: 16px;
}

#login-dialog .dialog-close {
  position: sticky;
  inset-block-start: 12px;
  inset-inline-end: auto;
  margin-inline: auto 12px;
  margin-block-end: -44px;
  background: rgb(19 18 20 / 75%);
  border-color: rgb(255 255 255 / 30%);
}

#login-dialog[data-compact] {
  position: fixed;
  top: var(--login-visible-top);
  bottom: auto;
  height: var(--login-visible-height);
  max-height: var(--login-visible-height);
  margin-top: 0;
  margin-bottom: 0;
  border-radius: 0;
  scroll-padding-block: 62px 8px;
  animation: none;
}

#login-dialog[data-compact] :is(.login-hero, .login-grip) {
  display: none;
}

#login-dialog[data-compact] .login-sheet {
  min-block-size: 100%;
  margin-top: 0;
  padding-block: 58px 12px;
  border: 0;
  border-radius: 0;
}

#login-dialog[data-compact] .login-form { gap: 8px; }
#login-dialog[data-compact] #login-title { font-size: 1.375rem; }

.login-hero {
  position: relative;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 20px;
  min-height: clamp(190px, 35dvh, 300px);
  padding: 20px 23px 33px;
}

.login-backdrop,
.login-art,
.login-hero::after {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.login-backdrop { z-index: -2; }
.login-art {
  object-fit: cover;
  object-position: 54% 44%;
}

.login-art-poster {
  object-position: 50% 24%;
}

.login-hero::after {
  z-index: -1;
  content: "";
  background: linear-gradient(180deg, rgb(16 15 18 / 78%), transparent 38%, rgb(17 18 20 / 62%) 72%, #111214);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-inline-end: 43px;
  font-size: .8125rem;
  font-weight: 700;
}

.login-brand-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 28px;
  height: 28px;
  color: var(--dialog-accent);
  background: #27201d;
  border: 1px solid rgb(242 160 143 / 42%);
  border-radius: 8px;
}

.login-brand-icon svg {
  width: 17px;
  height: 17px;
}

.login-film-caption {
  overflow-wrap: anywhere;
  text-shadow: 0 2px 12px #111214;
}

.login-film-caption p {
  margin: 0;
}

#login-film {
  font-size: 1.5rem;
  font-weight: 750;
  line-height: 1.2;
}

#login-original {
  margin-top: 5px;
  color: #f3e9dd;
  font-size: .75rem;
  font-weight: 650;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.login-sheet {
  position: relative;
  margin-top: -12px;
  padding: 11px clamp(16px, 6%, 26px) calc(10px + env(safe-area-inset-bottom, 0px));
  background: #1b1b20;
  border-top: 1px solid rgb(255 255 255 / 15%);
  border-radius: 27px 27px 0 0;
}

.login-grip {
  width: 31px;
  height: 4px;
  margin: 0 auto 15px;
  background: #77747d;
  border-radius: 4px;
}

#login-title,
#login-verify-title {
  margin: 0;
  line-height: 1.18;
  font-weight: 760;
  overflow-wrap: anywhere;
}

#login-title {
  margin-bottom: 4px;
  font-size: clamp(1.75rem, 8.1vw, 2.25rem);
  letter-spacing: -.025em;
}

.login-benefit-lead {
  display: block;
  margin-bottom: 7px;
  color: var(--dialog-accent);
  font-size: .9375rem;
  letter-spacing: normal;
}

#login-verify-title {
  font-size: 1.4rem;
}

.login-form {
  display: grid;
  gap: 12px;
}

.login-field {
  display: grid;
  gap: 7px;
  min-inline-size: 0;
}

.login-form label {
  font-size: .875rem;
  font-weight: 650;
}

.otp-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(94px, 39%);
  align-items: stretch;
  gap: 8px;
}

.login-form :is(#login-email, #login-code) {
  width: 100%;
  min-width: 0;
  min-height: 48px;
  padding: 10px 12px;
  color: var(--dialog-ink);
  font-size: 1rem;
  background: #25252c;
  border: 1px solid var(--dialog-border);
  border-radius: 10px;
}

.login-form input::placeholder {
  color: #9b9da6;
}

.login-form input[aria-invalid="true"],
.login-form input:focus {
  border-color: var(--dialog-accent);
}

.login-form input:focus {
  outline: 2px solid rgb(255 87 61 / 22%);
  outline-offset: 1px;
}

.login-form input:read-only {
  color: var(--dialog-muted);
}

#login-code {
  font-variant-numeric: tabular-nums;
}

#login-code:not(:placeholder-shown) {
  letter-spacing: .13em;
}

.login-form .button {
  min-inline-size: 0;
  min-height: 48px;
  white-space: normal;
  overflow-wrap: anywhere;
}

.login-form .otp-resend {
  padding-inline: .45rem;
  color: var(--dialog-accent);
  background: #28272f;
  border-color: var(--dialog-border);
  font-size: .8125rem;
  font-variant-numeric: tabular-nums;
}

.login-form .button-primary {
  color: #271414;
  background: var(--dialog-accent);
}

.login-form .button-primary:hover:not(:disabled) {
  background: #ffa791;
}

.login-form .button:disabled {
  color: var(--dialog-muted);
  background: #322c32;
  border-color: var(--dialog-border);
  cursor: not-allowed;
}

.login-receipt {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 8px;
  padding: 10px 11px;
  color: #cde0d6;
  background: #252f2c;
  border: 1px solid #3a5449;
  border-radius: 10px;
  line-height: 1.45;
  font-size: .8125rem;
  overflow-wrap: anywhere;
}

.login-receipt svg {
  width: 18px;
  height: 18px;
  color: #a7debf;
}

.login-receipt strong {
  color: #c5f2d8;
  font-size: .875rem;
}

.login-receipt p {
  margin: 2px 0 0;
}

.login-status {
  margin: 10px 0 0;
  padding: 10px 12px;
  color: #d9dbe2;
  background: rgb(255 255 255 / 5%);
  border: 1px solid var(--dialog-border);
  border-radius: 9px;
  font-size: .875rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.login-status[data-kind="error"] {
  color: #ffd3cb;
  background: rgb(255 87 61 / 9%);
  border-color: rgb(255 115 93 / 27%);
}

.login-status[data-kind="success"] {
  color: #b7ead6;
  background: rgb(107 207 170 / 8%);
  border-color: rgb(107 207 170 / 25%);
}

.login-text-button {
  justify-self: center;
  min-height: 44px;
  padding: 5px 12px;
  color: var(--dialog-accent);
  background: transparent;
  border: 0;
  border-radius: 8px;
  font-size: .875rem;
  cursor: pointer;
}

.login-text-button:hover {
  text-decoration: underline;
}

#otp-edit-email {
  margin-block: -6px;
}

.login-back {
  display: block;
  margin: 4px auto 0;
  color: var(--dialog-muted);
}

#language-dialog {
  width: min(456px, calc(100% - 32px));
}

#language-dialog .dialog-inner {
  display: flex;
  flex-direction: column;
  max-block-size: inherit;
}

#language-title {
  margin: 2px 0 16px;
  margin-inline-end: 48px;
  font-size: 1.45rem;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.language-status {
  flex: none;
  margin: 0 0 12px;
  color: var(--dialog-muted);
  font-size: .875rem;
  overflow-wrap: anywhere;
}

.language-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  min-block-size: 0;
  margin: -5px;
  padding: 5px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.language-option {
  display: grid;
  align-content: center;
  gap: .22rem;
  min-height: 48px;
  padding: .53rem .7rem;
  border: 1px solid var(--dialog-border);
  border-radius: 10px;
  color: var(--dialog-ink);
  background: #202227;
  text-align: start;
  overflow-wrap: anywhere;
}

.language-option:has(small) {
  grid-column: 1 / -1;
}

.language-option small {
  color: var(--dialog-muted);
  font-size: .8125rem;
  line-height: 1.35;
}

.language-option:hover {
  background: #2c2e35;
}

.language-option[aria-pressed="true"] {
  border-color: rgb(255 115 93 / 55%);
  color: #ffb2a3;
  background: rgb(255 87 61 / 10%);
}

#search-dialog {
  width: min(560px, calc(100% - 32px));
  overflow: hidden;
}

#search-dialog .dialog-inner {
  display: flex;
  flex-direction: column;
  max-block-size: calc(100vh - 42px);
  max-block-size: calc(100dvh - 42px);
}

#search-dialog h2 {
  flex: none;
  margin: 2px 0 16px;
  margin-inline-end: 48px;
  font-size: 1.45rem;
  line-height: 1.3;
}

.search-controls {
  display: flex;
  flex: none;
  align-items: stretch;
  gap: 8px;
}

.search-field {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 12px;
  min-width: 0;
  min-height: 52px;
  padding-inline: 14px;
  color: var(--dialog-muted);
  background: #202227;
  border: 1px solid var(--dialog-border);
  border-radius: 12px;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.search-field:focus-within {
  border-color: var(--dialog-accent);
  box-shadow: 0 0 0 2px rgb(255 87 61 / 16%);
}

.search-field svg {
  flex: 0 0 20px;
  width: 20px;
  height: 20px;
}

.search-field input {
  flex: 1;
  min-width: 0;
  height: 50px;
  padding: 0;
  color: var(--dialog-ink);
  font: inherit;
  font-size: 1rem;
  background: transparent;
  border: 0;
  outline: 0;
}

.search-field input::placeholder {
  color: #9b9da6;
}

.search-field input::-webkit-search-cancel-button {
  -webkit-appearance: none;
}

.search-clear {
  flex: none;
  min-inline-size: 48px;
  padding: 0 10px;
  color: var(--dialog-ink);
  background: #202227;
  border: 1px solid var(--dialog-border);
  border-radius: 10px;
  font-size: .875rem;
}

.search-clear:hover {
  background: #2c2e35;
}

.search-hint {
  flex: none;
  margin: .45rem 0 0;
  color: var(--dialog-muted);
  font-size: .875rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.search-count {
  flex: none;
  margin: 12px 0 0;
  color: var(--dialog-muted);
  font-size: .875rem;
}

.search-count:empty {
  margin: 0;
}

.search-results {
  min-height: 0;
  max-height: min(50vh, 362px);
  margin: 12px -4px -2px;
  padding: 3px 4px;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-color: #4b4d54 transparent;
  scrollbar-width: thin;
  list-style: none;
}

.search-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 2px 2px 6px;
}

.search-suggestions :is(h3, p) {
  flex-basis: 100%;
  margin: 0 0 2px;
  color: var(--dialog-muted);
  font-size: .875rem;
}

.search-suggestion {
  min-height: 44px;
  padding: 0 16px;
  color: var(--dialog-ink);
  background: #202227;
  border: 1px solid var(--dialog-border);
  border-radius: 999px;
  font-size: .9375rem;
  text-align: start;
}

.search-suggestion:hover {
  background: #2c2e35;
}

.search-result {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 72px;
  padding: 7px 8px;
  color: var(--dialog-ink);
  font: inherit;
  text-align: start;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease;
}

.search-result:hover,
.search-result:focus-visible {
  background: #202227;
  border-color: var(--dialog-border);
}

.dialog .search-result:focus-visible {
  outline-offset: 1px;
}

.search-result picture {
  position: relative;
  flex: 0 0 40px;
  border-radius: 5px;
}

.search-result img {
  display: block;
  width: 40px;
  height: 60px;
  object-fit: cover;
  background: #202227;
  border-radius: 5px;
}

.search-result > span {
  display: grid;
  min-width: 0;
  gap: 4px;
}

.search-result :is(strong, .result-title) {
  color: var(--dialog-ink);
  font-weight: 650;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.search-result :is(small, .result-meta) {
  color: var(--dialog-muted);
  font-size: .8125rem;
  line-height: 1.45;
}

.dialog .empty-state {
  margin: 0;
  padding: 26px 12px;
  color: var(--dialog-muted);
  text-align: center;
}

@media (max-width: 680px) {
  .dialog::backdrop { backdrop-filter: none; }

  .dialog,
  #search-dialog,
  #login-dialog,
  #language-dialog,
  #movie-dialog {
    width: 100%;
    max-height: calc(100vh - 20px);
    max-height: calc(100dvh - 20px);
    margin: auto 0 0;
    border-bottom: 0;
    border-radius: 22px 22px 0 0;
  }

  .dialog-inner {
    padding: 20px 16px calc(22px + env(safe-area-inset-bottom, 0px));
  }

  .dialog-close {
    inset-block-start: 10px;
    inset-inline-end: 10px;
  }

  .detail-header {
    grid-template-columns: 82px minmax(0, 1fr);
    gap: 13px;
  }

  .detail-close {
    position: static;
    align-self: flex-start;
    flex: none;
    width: auto;
    min-width: 44px;
    margin: 6px 8px 0;
    padding-inline: 10px;
    background: transparent;
    border-color: transparent;
    border-radius: 8px;
    font-size: .9375rem;
  }

  .detail-close svg {
    display: none;
  }

  .detail-close span {
    display: inline;
  }

  .detail-scroll .dialog-inner {
    padding-top: 6px;
    padding-bottom: 22px;
  }

  .detail-info h2,
  .detail-original {
    margin-inline-end: 0;
  }

  .detail-poster {
    border-radius: 8px;
  }

  .detail-facts {
    margin-top: 17px;
  }

  .detail-actions {
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px));
  }

  .detail-actions .button-primary {
    flex: 1;
  }

  .login-hero {
    padding-block-start: 16px;
  }

  #search-dialog {
    block-size: 100vh;
    block-size: var(--search-viewport-height, 100dvh);
    max-block-size: 100vh;
    max-block-size: var(--search-viewport-height, 100dvh);
    margin: 0;
    border: 0;
    border-radius: 0;
  }

  #search-dialog .dialog-close {
    inset-block-start: calc(10px + env(safe-area-inset-top, 0px));
  }

  #search-dialog .dialog-inner {
    block-size: 100%;
    max-block-size: none;
    padding-block-start: calc(20px + env(safe-area-inset-top, 0px));
  }

  .search-results {
    flex: 1;
    max-height: none;
  }
}

@media (max-height: 540px) {
  .login-hero {
    min-height: 146px;
  }
}

@media (orientation: landscape) {
  .dialog {
    --dialog-inline-inset: max(16px, env(safe-area-inset-left, 0px), env(safe-area-inset-right, 0px));
    max-inline-size: calc(100% - var(--dialog-inline-inset) * 2);
    margin-inline: auto;
  }

  #login-dialog[data-compact] {
    scroll-padding-block: 8px;
  }

  #login-dialog[data-compact] .login-sheet {
    padding-block-start: 12px;
    padding-inline-end: 64px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .dialog[open] {
    animation: none;
  }

  .dialog :is(.dialog-close, .search-field, .search-result) {
    transition: none;
  }
}
