@property --spin {
  syntax: "<angle>";
  initial-value: 0deg;
  inherits: false;
}

:root {
  color-scheme: dark;
  --ink: #fff8f3;
  --muted: #f0e2d4;
  --line: rgba(255, 236, 220, 0.72);
  --focus: #ffd7a8;
  --accent: #e8893a;
  --plyr-color-main: #e8893a;
  --plyr-video-control-color: #fff8f2;
  --plyr-video-control-color-hover: #fff;
  --plyr-badge-background: #e8893a;
  --plyr-menu-background: rgba(18, 10, 14, 0.94);
  --plyr-menu-color: #fff8f2;
  --plyr-tooltip-background: rgba(18, 10, 14, 0.94);
  --plyr-tooltip-color: #fff8f2;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 1rem;
  line-height: 1.5;
  background-color: #07040a;
}

.backdrop {
  position: fixed;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  pointer-events: none;
}

.visually-hidden {
  position: absolute;
  clip-path: inset(50%);
  overflow: hidden;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  white-space: nowrap;
}

main {
  position: relative;
  z-index: 1;
  width: min(72rem, calc(100% - 2rem));
  min-height: 100dvh;
  margin-inline: auto;
  padding: max(5rem, 16vh) 0 2rem;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
}

h1,
.tagline,
#parse-form,
footer,
.seo {
  width: min(40rem, 100%);
}

h1 {
  margin: 0 0 1.25rem;
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, "Songti SC", "Noto Serif SC", serif;
  font-size: clamp(1.8rem, 4vw, 2.75rem);
  font-weight: 560;
  letter-spacing: 0.06em;
  line-height: 1.25;
  text-align: center;
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.45);
  view-transition-name: brand;
}

h1 label {
  cursor: text;
}

#parse-form {
  view-transition-name: search;
}

body.is-result main {
  justify-content: flex-start;
  align-items: stretch;
  padding-top: 1.5rem;
}

body.is-result h1,
body.is-result .tagline,
body.is-result #parse-form,
body.is-result footer,
body.is-result .seo {
  width: min(36rem, 100%);
  align-self: flex-start;
  text-align: start;
}

body.is-result footer {
  align-self: center;
  text-align: center;
}

body.is-result h1 {
  margin-bottom: 0.85rem;
  font-size: clamp(1.15rem, 2vw, 1.45rem);
}

.field {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: stretch;
  gap: 4px;
  height: 56px;
  min-height: 56px;
  padding: 4px;
  border: 2px solid rgba(255, 214, 170, 0.85);
  border-radius: 12px;
  background: rgba(12, 8, 14, 0.72);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(16px);
}

@supports (background: conic-gradient(from 0deg, #6d4dff, #e8893a)) {
  .field {
    border-color: transparent;
    background:
      linear-gradient(rgba(12, 8, 14, 0.72), rgba(12, 8, 14, 0.72)) padding-box,
      conic-gradient(from var(--spin), #6d4dff, #e8893a, #ffd7b0, #6d4dff) border-box;
    animation: field-spin 3.6s linear infinite;
  }
}

@keyframes field-spin {
  to { --spin: 1turn; }
}

input,
button,
.primary,
.secondary,
.qualities :is(a, button),
.gallery a,
.cover-row a,
.episodes button {
  font: inherit;
  font-size: max(1rem, 1em);
}

#link {
  min-width: 0;
  height: 100%;
  min-height: 0;
  padding: 0 0.9rem;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--ink);
}

#link::placeholder {
  color: var(--muted);
  opacity: 1;
}

.primary[hidden] {
  display: none;
}

#submit,
.primary,
.secondary,
.qualities :is(a, button),
.gallery a,
.cover-row a,
.episodes button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0.4rem 1.15rem;
  border: 2px solid transparent;
  border-radius: 999px;
  background: #f6efe8;
  color: #1c100c;
  text-decoration: none;
  cursor: pointer;
}

#submit {
  position: relative;
  align-self: stretch;
  width: 5.5rem;
  height: auto;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 12px;
  overflow: hidden;
  transition: width 0.28s ease, background-color 0.28s ease, color 0.28s ease;
}

#link:focus,
#link:focus-visible {
  outline: none;
  background: transparent;
}

.submit-label,
.submit-mark {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}

.submit-mark {
  display: none;
  width: 1.65rem;
  height: 1.65rem;
  margin: auto;
}

#submit[data-state="spin"],
#submit[data-state="done"],
#submit[data-state="fail"] {
  width: 3rem;
  min-width: 3rem;
  padding-inline: 0;
  background: var(--accent);
  color: #1a0d08;
}

#submit[data-state="spin"] .submit-label,
#submit[data-state="done"] .submit-label,
#submit[data-state="fail"] .submit-label {
  visibility: hidden;
}

#submit[data-state="spin"] .submit-mark,
#submit[data-state="done"] .submit-mark,
#submit[data-state="fail"] .submit-mark {
  display: grid;
}

.mark-ring,
.mark-check,
.mark-x {
  fill: none;
  stroke: currentColor;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mark-ring {
  stroke-dasharray: 22 90;
  transform-box: fill-box;
  transform-origin: center;
}

#submit[data-state="spin"] .mark-ring {
  animation: mark-spin 0.7s linear infinite;
}

#submit[data-state="done"] .mark-ring,
#submit[data-state="fail"] .mark-ring {
  animation: none;
  transform: rotate(-90deg);
  opacity: 0;
}

.mark-check,
.mark-x {
  stroke-dashoffset: 28;
}

.mark-check {
  stroke-dasharray: 28;
}

.mark-x {
  stroke-dasharray: 40;
  stroke-dashoffset: 40;
}

#submit[data-state="done"] .mark-check,
#submit[data-state="fail"] .mark-x {
  animation: mark-draw 0.32s ease forwards;
}

@keyframes mark-spin {
  to { transform: rotate(360deg); }
}

@keyframes mark-draw {
  to { stroke-dashoffset: 0; }
}

.secondary,
.qualities :is(a, button),
.gallery a,
.cover-row a,
.episodes button {
  background: rgba(12, 8, 14, 0.45);
  color: var(--ink);
  border-color: var(--line);
  backdrop-filter: blur(10px);
}

#submit:disabled {
  cursor: wait;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

#status {
  min-height: 1.5rem;
  margin: 0.75rem 0 0;
  color: var(--muted);
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.45);
}

#status[data-kind="error"] {
  color: #ffd0d0;
}

.card {
  width: 100%;
  margin-top: 1.25rem;
  opacity: 1;
  translate: 0;
  transition:
    display,
    opacity ease-out,
    translate ease-out;
  transition-duration: 0.4s;
  transition-behavior: allow-discrete;
}

@starting-style {
  .card {
    opacity: 0;
    translate: none;
  }
}

.card:where([hidden], [data-closing]) {
  opacity: 0;
  translate: none;
}

.card[hidden] {
  display: none;
}

.result-head {
  text-align: start;
}

h2 {
  margin: 0;
  font-size: clamp(1.15rem, 2vw, 1.45rem);
  font-weight: 650;
  overflow-wrap: anywhere;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.5);
}

.stage {
  width: min(60rem, 100%);
  margin: 1rem auto 0;
}

.stage .plyr,
.stage > video,
.stage > audio {
  width: 100%;
  border-radius: 1rem;
  overflow: hidden;
  background: #05060a;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
}

.stage .plyr--audio {
  background: transparent;
  box-shadow: none;
}

.stage > video {
  display: block;
  height: auto;
  aspect-ratio: 16 / 9;
}

.stage .plyr__video-wrapper {
  aspect-ratio: 16 / 9;
  width: 100%;
  height: auto;
}

.stage .plyr__video-wrapper video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.stage .plyr__poster {
  background-size: contain !important;
  background-position: center !important;
  background-repeat: no-repeat !important;
}

.frame-hold {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

.plyr.quality-hold .plyr__poster {
  opacity: 0 !important;
}

.plyr.quality-hold .plyr__controls {
  opacity: 1 !important;
  pointer-events: auto !important;
  transform: none !important;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin: 0.9rem 0 0;
}

.author,
.desc,
.card h3 {
  margin: 0.75rem 0 0;
  text-align: start;
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.5);
}

.author,
.desc {
  color: var(--muted);
}

.desc {
  white-space: pre-wrap;
}

.cover-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.85rem;
}

.cover-row img,
.gallery img {
  border-radius: 0.75rem;
  background: #05060a;
}

.cover-row img {
  width: 10rem;
  height: 5.625rem;
  object-fit: cover;
  object-position: center;
}

.episodes,
.qualities,
.gallery {
  margin: 0.85rem 0 0;
  padding: 0;
  list-style: none;
}

.qualities,
.gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.episodes {
  max-height: 18rem;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.episodes form {
  margin: 0;
}

.episodes button {
  width: 100%;
  justify-content: flex-start;
  text-align: start;
}

.episodes button[aria-current="true"],
.qualities :is(a, button)[aria-current="true"] {
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.gallery {
  overflow-x: auto;
  scroll-snap-type: x mandatory;
}

.gallery li {
  flex: 0 0 auto;
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.gallery img {
  height: 12rem;
  width: auto;
  max-width: 16rem;
  object-fit: cover;
}

.tagline {
  margin: -0.65rem 0 1.25rem;
  color: var(--muted);
  font-size: 1rem;
  text-align: center;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.45);
}

body.is-result .tagline {
  margin-bottom: 0.85rem;
}

footer {
  margin-top: 2rem;
  text-align: center;
}

footer p,
.seo p,
.seo li {
  margin: 0;
  color: var(--muted);
  font-size: 0.875rem;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.45);
}

#visits {
  margin-top: 0.35rem;
}

.seo[hidden] {
  display: none;
}

.seo {
  margin-top: 1.25rem;
}

.seo h2 {
  margin: 0 0 0.45rem;
  font-size: 1rem;
  font-weight: 650;
}

.seo p {
  line-height: 1.7;
}

.seo ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.85rem;
  margin: 0.75rem 0 0;
  padding: 0;
  list-style: none;
}

@media (pointer: coarse) {
  #link,
  #submit,
  .primary,
  .secondary,
  .qualities :is(a, button),
  .gallery a,
  .cover-row a,
  .episodes button {
    min-height: 52px;
  }

  .field {
    height: 60px;
    min-height: 60px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .field,
  .mark-ring,
  .mark-check,
  .mark-x {
    animation: none;
  }

  #submit[data-state="done"] .mark-check,
  #submit[data-state="fail"] .mark-x {
    stroke-dashoffset: 0;
  }

  .card,
  .card:where([hidden], [data-closing]) {
    translate: none;
    transition-duration: 0.1s;
  }

  @starting-style {
    .card {
      translate: none;
    }
  }
}

@media (forced-colors: active) {
  body,
  .field,
  .card,
  #submit,
  .primary,
  .secondary,
  .qualities :is(a, button),
  .gallery a,
  .cover-row a,
  .episodes button {
    background: Canvas;
    color: CanvasText;
    border-color: CanvasText;
  }

  a {
    color: LinkText;
  }
}
