:root {
  --bg: #f5f5f7;
  --surface: #fff;
  --line: #e1e1e6;
  --line-strong: #c4c4cc;
  --text: #141416;
  --muted: #62626b;
  --hover: #ebebef;
  --accent: var(--text);
  --on-accent: var(--bg);
  --radius: 0;
  --radius-ui: 4px;
  --cols: 1;
  --home-cols: 2;
  --pad: 16px;
  --max: 1400px;
  --vh: 100vh;
  --hdr: 122px;
  color-scheme: light;
}

@supports (height: 100dvh) {
  :root {
    --vh: 100dvh;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e0e10;
  --surface: #161618;
  --line: #26262b;
  --line-strong: #3d3d44;
  --text: #f2f2f4;
  --muted: #9a9aa3;
  --hover: #1f1f23;
}

* {
  box-sizing: border-box;
  margin: 0;
}

html {
  scrollbar-gutter: stable;
}

body {
  font-family: "Archivo", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-weight: 500;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

::selection {
  background: var(--text);
  color: var(--bg);
}

a {
  color: inherit;
  text-decoration: none;
}

svg.i {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

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

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

header {
  position: -webkit-sticky;
  position: sticky;
  top: 0;
  flex: none;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  z-index: 10;
}

.bar {
  max-width: var(--max);
  margin: 0 auto;
  padding: 12px var(--pad);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 26px;
  font-weight: 800;
  font-stretch: 118%;
  line-height: 1;
  letter-spacing: -.02em;
}

.logo-img {
  width: 40px;
  height: 40px;
  flex: none;
  object-fit: contain;
}

form {
  flex: 1 1 100%;
  position: relative;
  order: 2;
}

form button {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 44px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  cursor: pointer;
  transition: color .15s;
}

form:focus-within button {
  color: var(--text);
}

form svg {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
}

input[type=search] {
  width: 100%;
  height: 44px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  border-radius: var(--radius-ui);
  padding: 0 14px 0 44px;
  text-overflow: ellipsis;
  font: inherit;
  font-size: 16px;
  font-weight: 500;
  color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none;
  appearance: none;
}

input[type=search]::placeholder {
  color: var(--muted);
  opacity: 1;
}

input[type=search]:hover {
  border-color: var(--muted);
}

input[type=search]:focus {
  border-color: var(--text);
  box-shadow: 0 0 0 1px var(--text);
}

input[type=search]::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  margin: 0;
  cursor: pointer;
  background: var(--text);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M18 6 6 18M6 6l12 12'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M18 6 6 18M6 6l12 12'/%3E%3C/svg%3E") center / contain no-repeat;
}

.theme {
  order: 1;
  display: grid;
  flex: none;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-ui);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: background-color .15s, border-color .15s;
}

.theme:hover {
  background: var(--hover);
  border-color: var(--muted);
}

.theme-icon {
  width: 24px;
  height: 24px;
  overflow: visible;
}

.theme-core {
  fill: currentColor;
  transform-origin: 12px 12px;
}

.theme-rays {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  transform-origin: 12px 12px;
}

.theme-cut {
  transform: translate(14px, -14px);
}

:root[data-theme="dark"] .theme-core {
  transform: scale(1.95);
}

:root[data-theme="dark"] .theme-cut {
  transform: translate(5.2px, -4.4px);
}

:root[data-theme="dark"] .theme-rays {
  opacity: 0;
  transform: rotate(60deg) scale(.4);
}

@media (prefers-reduced-motion: no-preference) {
  .theme-core,
  .theme-cut,
  .theme-rays {
    transition: transform .5s cubic-bezier(.4, 0, .2, 1), opacity .35s;
  }

  .theme-fade,
  .theme-fade *,
  .theme-fade *::before,
  .theme-fade *::after {
    transition: background-color .3s, color .3s, border-color .3s !important;
  }
}

.cats {
  width: 100%;
  position: relative;
  max-width: var(--max);
  min-height: 58px;
  margin: 0 auto;
  padding: 16px var(--pad) 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.cats[hidden] {
  display: none;
}

.cat {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  max-width: 100%;
  padding: 0 16px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-ui);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  transition: background-color .15s, border-color .15s, color .15s;
}

.cat > span {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cat:hover {
  background: var(--hover);
  border-color: var(--muted);
}

.cat.on,
.cat.on:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

@media (max-width: 559px) {
  .cats {
    flex-wrap: nowrap;
    padding: 20px var(--pad) 4px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
    scroll-padding-inline: var(--pad);
    scrollbar-width: none;
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - var(--pad)), transparent);
    mask-image: linear-gradient(to right, #000 calc(100% - var(--pad)), transparent);
  }

  .cats::-webkit-scrollbar {
    display: none;
  }

  .cat {
    flex: none;
    scroll-snap-align: start;
  }

  .cat > span {
    max-width: 60vw;
  }
}

main {
  flex: 1;
  width: 100%;
  max-width: var(--max);
  margin: 0 auto;
  padding: 28px var(--pad) 48px;
}

.head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 12px;
  margin-bottom: 24px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
  font-size: 22px;
  font-weight: 800;
  font-stretch: 108%;
  line-height: 1.2;
  letter-spacing: -.01em;
  overflow-wrap: anywhere;
}

.head .count {
  font-size: 14px;
  font-weight: 600;
  font-stretch: 100%;
  letter-spacing: 0;
  color: var(--muted);
  white-space: nowrap;
}

.grid {
  align-items: start;
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  gap: 28px 16px;
}

.shelf .grid {
  --cols: var(--home-cols);
}

.shelf + .shelf,
.more {
  margin-top: 48px;
}

.shelf-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.shelf-head h2 {
  min-width: 0;
  font-size: 18px;
  font-weight: 800;
  font-stretch: 108%;
  line-height: 1.2;
  letter-spacing: -.01em;
  overflow-wrap: anywhere;
}

.shelf-head h2 small {
  margin-left: 10px;
  font-size: 13px;
  font-weight: 600;
  font-stretch: 100%;
  letter-spacing: 0;
  color: var(--muted);
  white-space: nowrap;
}

.shelf-all {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 2px;
  font-size: 14px;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
  transition: color .15s;
}

.shelf-all .i {
  transition: transform .15s;
}

.shelf-all:hover {
  color: var(--text);
}

.shelf-all:hover .i {
  transform: translateX(3px);
}

@media (max-width: 639px) {
  .shelf .grid {
    display: flex;
    gap: 12px;
    margin: -4px calc(var(--pad) * -1) 0;
    padding: 4px var(--pad);
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
    scroll-padding-inline: var(--pad);
    scrollbar-width: none;
  }

  .shelf .grid::-webkit-scrollbar {
    display: none;
  }

  .shelf .card {
    flex: none;
    width: min(76%, 300px, calc(var(--cover-ar, 1.7778) * 230px));
    scroll-snap-align: start;
  }
}

.sk-title {
  width: 9ch;
  background: var(--hover);
}

.cover {
  position: relative;
  display: block;
  aspect-ratio: var(--cover-ar, 16 / 9);
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--hover);
}

.cover video,
.cover .thumb {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0;
  background: #000;
  pointer-events: none;
  transition: opacity .2s, transform .4s cubic-bezier(.2, .7, .2, 1);
}

.cover.ld video,
.cover.ld .thumb {
  opacity: 1;
}

.cover[data-fit] video,
.cover[data-fit] .thumb {
  object-fit: contain;
}

.cover.bad video,
.cover.bad .thumb {
  display: none;
}

.cover video ~ .thumb {
  display: none;
}

a.cover::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 52px;
  height: 52px;
  background: rgba(0, 0, 0, .72) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='white' d='M9 6.5v11l9-5.5z'/%3E%3C/svg%3E") center / 28px no-repeat;
  opacity: 0;
  transform: scale(.85);
  transition: opacity .2s, transform .2s;
  pointer-events: none;
}

.time {
  z-index: 1;
  position: absolute;
  right: 0;
  bottom: 0;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.5;
  color: #fff;
  background: rgba(0, 0, 0, .8);
  font-variant-numeric: tabular-nums;
}

.time[hidden] {
  display: none;
}

.meta {
  padding: 12px 0 0;
  user-select: text;
  -webkit-user-select: text;
}

.meta a {
  display: block;
}

.meta b {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.35;
  overflow-wrap: anywhere;
  text-decoration: underline transparent;
  text-underline-offset: 3px;
  text-decoration-thickness: 1.5px;
  transition: text-decoration-color .15s;
}

a.cover:focus-visible::after {
  opacity: 1;
  transform: none;
}

@media (hover: hover) {
  .card:hover a.cover::after {
    opacity: 1;
    transform: none;
  }

  .card:hover .cover .thumb {
    transform: scale(1.04);
  }

  .card:hover .meta b {
    text-decoration-color: currentColor;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cover .thumb,
  a.cover::after,
  .shelf-all .i {
    transition: none;
  }

  .card:hover .cover .thumb,
  .shelf-all:hover .i {
    transform: none;
  }
}

.sk .cover {
  animation: pulse 1s ease-in-out infinite alternate;
}

@keyframes pulse {
  from { opacity: .5; }
  to { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .sk .cover {
    animation: none;
  }
}

.empty {
  padding: 72px 0;
  text-align: center;
  font-size: 16px;
  font-weight: 600;
  color: var(--muted);
}

.head + .empty {
  padding-top: 48px;
}

.empty .btn {
  margin-top: 20px;
}

.btn {
  height: 42px;
  padding: 0 22px;
  border: 1px solid var(--text);
  border-radius: var(--radius-ui);
  background: var(--text);
  color: var(--bg);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: opacity .15s;
}

.btn:hover {
  opacity: .85;
}

.watch-page {
  padding-top: 20px;
}

.watch {
  --ar: 16/9;
  --fit: calc((var(--vh) - var(--hdr) - 56px) * var(--ar));
  width: min(100%, 1100px, max(320px, var(--fit)));
  margin-inline: auto;
}

.watch-title {
  margin-top: 18px;
  font-size: 24px;
  font-weight: 800;
  font-stretch: 106%;
  line-height: 1.25;
  letter-spacing: -.01em;
  overflow-wrap: anywhere;
  user-select: text;
  -webkit-user-select: text;
}

.poster {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  pointer-events: none;
}

.player {
  position: relative;
  aspect-ratio: var(--ar);
  width: min(100%, max(150px, var(--fit)));
  margin-inline: auto;
  background: #000;
  overflow: hidden;
  border-radius: var(--radius);
}

.player video,
.player iframe {
  width: 100%;
  height: 100%;
  display: block;
  border: 0;
  outline: none;
  background: #000;
  object-fit: contain;
}

footer {
  border-top: 1px solid var(--line);
}

nav.pages {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px;
  max-width: var(--max);
  margin: 0 auto;
  padding: 20px var(--pad) 0;
}

nav.pages:empty {
  display: none;
}

nav.pages a,
nav.pages span {
  min-width: 40px;
  height: 40px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: var(--radius-ui);
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  transition: background-color .15s, border-color .15s;
}

nav.pages a:hover {
  background: var(--hover);
  border-color: var(--line-strong);
}

nav.pages .on {
  background: var(--accent);
  color: var(--on-accent);
}

nav.pages .off {
  opacity: .3;
}

nav.pages .gap {
  min-width: 18px;
  padding: 0;
  color: var(--muted);
}

.credit {
  padding: 20px var(--pad);
  text-align: center;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
}

@media (min-width: 640px) {
  :root {
    --pad: 24px;
  }

  .bar {
    padding-block: 14px;
    gap: 12px;
  }

  .logo-img {
    width: 44px;
    height: 44px;
  }

  .grid {
    gap: 32px 20px;
  }

  .watch-title {
    font-size: 28px;
  }
}

@media (min-width: 640px) and (pointer: fine) {
  input[type=search] {
    font-size: 14px;
  }
}

@media (min-width: 640px) and (max-width: 767px) {
  :root {
    --hdr: 128px;
  }
}

@media (min-width: 768px) {
  :root {
    --hdr: 74px;
  }

  form {
    flex: 0 1 420px;
    order: 0;
    margin-left: auto;
  }
}

@media (min-width: 1024px) {
  :root {
    --pad: 32px;
  }
}

@media (min-width: 1920px) {
  :root {
    --max: 1800px;
  }
}

@media (max-width: 399px) {
  input[type=search]::placeholder {
    font-size: 14px;
  }
}

@media (pointer: coarse) {
  .cat {
    min-height: 44px;
  }

  .shelf-all {
    min-height: 44px;
    margin-block: -14px;
  }

  .meta {
    padding-top: 4px;
  }

  .meta a {
    padding: 8px 0 12px;
  }

  nav.pages a,
  nav.pages span {
    min-width: 44px;
    height: 44px;
  }
}

@media (max-width: 479px) {
  nav.pages {
    gap: 2px;
  }

  nav.pages a,
  nav.pages span {
    min-width: clamp(32px, 10vw, 44px);
    padding: 0 4px;
  }

  nav.pages .gap {
    min-width: 14px;
    padding: 0;
  }
}

@media (max-height: 500px) and (orientation: landscape) {
  .bar {
    padding-block: 7px;
  }

  .logo {
    font-size: 22px;
  }

  .logo-img {
    width: 34px;
    height: 34px;
  }

  .cats {
    padding-top: 8px;
  }

  main {
    padding-top: 14px;
  }

  .watch-page {
    padding-top: 6px;
  }
}

.player-status {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px;
  text-align: center;
  background: rgba(14, 14, 16, .72);
  color: #f2f2f4;
  font-size: 14px;
  pointer-events: none;
}

.player-status[hidden] {
  display: none;
}

.player video::-webkit-media-controls-loading-panel {
  display: none !important;
}

.player-msg {
  max-width: 36ch;
}

.player-status[data-state="error"] .spinner {
  display: none;
}

.spinner {
  width: 34px;
  height: 34px;
  border: 3px solid rgba(255, 255, 255, .28);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

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

@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation-duration: 2.4s;
  }
}

.btn-retry {
  pointer-events: auto;
  height: 38px;
  padding: 0 18px;
  border: 0;
  border-radius: 0;
  background: #fff;
  color: #000;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

@media (max-width: 379px) {
  .logo {
    gap: 6px;
    font-size: 22px;
  }

  .logo-img {
    width: 34px;
    height: 34px;
  }
}
