:root {
  --ink: #f4eadc;
  --muted: #cbb59a;
  --faint: #9c8670;
  --brass: #c6a15b;
  --brass-hot: #d6b874;
  --brass-press: #a88745;
  --on-brass: #1a120c;
  --ground: #14100e;
  --deep: #0e0b09;
  --well: #241c16;
  --well-hot: #33271e;
  --still: #1c1612;
  --line: #3a2c22;
  --gutter: 24px;
  --radius: 6px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --bar: 108px;
  color-scheme: dark;
  font-family: "Noto Sans Myanmar", system-ui, sans-serif;
  background: var(--ground);
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scrollbar-color: var(--line) var(--deep);
  scroll-padding-top: var(--bar);
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100svh;
  margin: 0;
  background: var(--ground);
  font-size: 1rem;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

main {
  flex: 1 0 auto;
}

img,
video,
svg {
  display: block;
}

a,
button {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

[hidden] {
  display: none !important;
}

::selection {
  background: var(--brass);
  color: var(--on-brass);
}

:focus {
  outline: none;
}

:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 3px;
  border-radius: 4px;
}

.sr,
.skip {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip:focus {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 60;
  width: auto;
  height: auto;
  margin: 0;
  padding: 10px 14px;
  clip: auto;
  border-radius: 4px;
  background: var(--brass);
  color: var(--on-brass);
  font-weight: 700;
  text-decoration: none;
}

/* ---------- Header: logo row + catalog tab strip ---------- */

.bar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--ground);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
  transition: transform 280ms var(--ease);
}

.bar.is-hidden {
  transform: translateY(-100%);
}

.bar-row {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 60px;
  padding: 0 var(--gutter);
  padding-left: max(var(--gutter), env(safe-area-inset-left));
  padding-right: max(var(--gutter), env(safe-area-inset-right));
}

.mark {
  display: inline-flex;
  flex: none;
  border-radius: 10px;
  color: var(--ink);
  text-decoration: none;
}

/* Wordmark: brass play tile + "Found" in crema, "die" in brass. */
.mark-lockup,
.gate-lockup {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1;
}

.mark-icon {
  width: 1.3em;
  height: 1.3em;
  flex: none;
  color: var(--brass);
  filter: drop-shadow(0 4px 10px rgba(198, 161, 91, 0.22));
  transition: transform 320ms var(--ease), color 160ms var(--ease);
}

.mark-word {
  padding-bottom: 0.06em;
}

.mark-word span {
  color: var(--brass);
}

.mark:hover .mark-icon {
  color: var(--brass-hot);
  transform: rotate(-8deg) scale(1.04);
}

.bar-badge {
  margin-left: auto;
  padding: 4px 7px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.02em;
}

.tabs {
  position: relative;
  height: 48px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  background: var(--deep);
  border-top: 1px solid var(--line);
}

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

.tabs-track {
  display: flex;
  align-items: stretch;
  height: 100%;
  width: max-content;
  min-width: 100%;
  padding: 0 calc(var(--gutter) - 12px);
}

.tabs a {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex: none;
  padding: 0 14px;
  white-space: nowrap;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
  transition: color 160ms var(--ease);
}

.tabs a svg {
  width: 14px;
  height: 14px;
}

.tabs a::after {
  content: "";
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 0;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: var(--brass);
  transform: scaleX(0);
  transition: transform 240ms var(--ease);
}

.tabs a:hover {
  color: var(--ink);
}

.tabs a[aria-current="page"] {
  color: var(--brass);
}

.tabs a[aria-current="page"]::after {
  transform: scaleX(1);
}

.tabs a:focus-visible {
  outline-offset: -6px;
}

/* ---------- Page ---------- */

.sheet {
  width: 100%;
  max-width: 1920px;
  margin: 0 auto;
  padding: 22px var(--gutter) 48px;
}

.head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.3;
  text-wrap: balance;
}

.head-sub {
  margin-left: 4px;
  color: var(--muted);
  font-weight: 600;
}

.head-note {
  margin: 0;
  color: var(--faint);
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
}

.notice {
  margin: 10px 0 20px;
  max-width: 62ch;
  color: var(--muted);
}

.problem {
  max-width: 640px;
  margin: 8vh auto;
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--still);
  text-align: center;
}

.problem .notice {
  margin-inline: auto;
}

.recover {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin: 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 18px;
  border: 0;
  border-radius: 6px;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 160ms var(--ease), color 160ms var(--ease);
}

.btn-brass {
  background: var(--brass);
  color: var(--on-brass);
}

.btn-brass:hover {
  background: var(--brass-hot);
}

.btn-brass:active {
  background: var(--brass-press);
}

.btn-quiet {
  background: var(--well);
  color: var(--ink);
}

.btn-quiet:hover {
  background: var(--well-hot);
}

/* ---------- Grid + cards ---------- */

.grid {
  display: grid;
  grid-template-columns: repeat(var(--cols, 4), minmax(0, 1fr));
  gap: 26px 14px;
}

.card,
.rel {
  color: var(--ink);
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

.card {
  display: block;
  min-width: 0;
}

.thumb {
  position: relative;
  display: block;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: var(--radius);
  background: linear-gradient(100deg, var(--still) 30%, var(--well) 50%, var(--still) 70%) 0 0 / 300% 100%;
  animation: shimmer 1.4s linear infinite;
  isolation: isolate;
}

.thumb.is-loaded,
.thumb.is-broken {
  animation: none;
  background: var(--still);
}

.thumb.is-broken::before {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 34px;
  height: 34px;
  background: var(--line);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4 5h16v14H4zM6 15l3.5-4 3 3 2-2.5L18 15' fill='none' stroke='black' stroke-width='2' stroke-linejoin='round'/%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'%3E%3Cpath d='M4 5h16v14H4zM6 15l3.5-4 3 3 2-2.5L18 15' fill='none' stroke='black' stroke-width='2' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
}

.thumb.is-broken img {
  visibility: hidden;
}

@keyframes shimmer {
  to {
    background-position: -150% 0;
  }
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity 260ms var(--ease), transform 320ms var(--ease);
}

.js .thumb:not(.is-loaded) img {
  opacity: 0;
}

.thumb::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px rgba(244, 234, 220, 0.06);
  pointer-events: none;
}

.duration,
.quality {
  position: absolute;
  bottom: 6px;
  z-index: 1;
  padding: 3px 6px 2px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.duration {
  right: 6px;
  background: rgba(14, 11, 9, 0.86);
  color: var(--ink);
}

.quality {
  top: 6px;
  bottom: auto;
  left: 6px;
  background: var(--brass);
  color: var(--on-brass);
  text-transform: uppercase;
}

.play {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 52px;
  height: 52px;
  margin: auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--brass);
  color: var(--on-brass);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5);
  opacity: 0;
  transform: scale(0.85);
  transition: opacity 180ms var(--ease), transform 280ms var(--ease);
  pointer-events: none;
}

.play svg {
  width: 22px;
  height: 22px;
  margin-left: 2px;
}

.card:hover .thumb img,
.card:focus-visible .thumb img,
.rel:hover .thumb img,
.rel:focus-visible .thumb img {
  transform: scale(1.05);
}

.card:hover .play,
.card:focus-visible .play,
.rel:hover .play,
.rel:focus-visible .play {
  opacity: 1;
  transform: scale(1);
}

.card:focus-visible,
.rel:focus-visible {
  outline-offset: 4px;
}

.card-title {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-top: 9px;
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.5;
  overflow-wrap: anywhere;
  transition: color 160ms var(--ease);
}

/* Burmese stacks marks above and below the line; give it room so the clamp never cuts them. */
.card-title:lang(my),
.watch-title:lang(my) {
  line-height: 1.7;
}

.card:hover .card-title,
.card:focus-visible .card-title,
.rel:hover .card-title,
.rel:focus-visible .card-title {
  color: var(--brass);
}

.card-meta,
.watch-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
  margin-top: 5px;
  color: var(--faint);
  font-size: 0.78rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1.4;
}

.card-meta > span,
.watch-meta > span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.card-meta svg,
.watch-meta svg {
  width: 14px;
  height: 14px;
  flex: none;
}

.meta-rating {
  color: var(--brass);
}

/* Catalog index */

.grid-cats {
  --cols: 4;
}

.cat .thumb::before {
  content: "";
  position: absolute;
  inset: 40% 0 0;
  z-index: 1;
  background: linear-gradient(to top, rgba(14, 11, 9, 0.92), rgba(14, 11, 9, 0));
  pointer-events: none;
}

.cat-label {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 12px;
  z-index: 2;
  color: var(--ink);
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  transition: color 160ms var(--ease);
}

.cat:hover .cat-label,
.cat:focus-visible .cat-label {
  color: var(--brass);
}

/* ---------- Pager ---------- */

.pager {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 6px;
  margin-top: 40px;
}

.pager a,
.pager .current,
.pager-gap {
  min-width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 0 12px;
  border-radius: 6px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-decoration: none;
}

.pager a {
  background: var(--well);
  color: var(--ink);
  transition: background-color 160ms var(--ease), color 160ms var(--ease);
}

.pager a:hover {
  background: var(--well-hot);
  color: var(--brass);
}

.pager .current {
  background: var(--brass);
  color: var(--on-brass);
}

.pager-gap {
  min-width: 24px;
  padding: 0;
  color: var(--faint);
}

.pager svg {
  width: 18px;
  height: 18px;
}

.pager-step {
  padding: 0 16px;
}

/* ---------- Watch ---------- */

.stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 24px;
  align-items: start;
}

.feature {
  min-width: 0;
}

.player,
.unplayable {
  position: relative;
  width: 100%;
  max-height: calc(100svh - var(--bar) - 9rem);
  aspect-ratio: 16 / 9;
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
}

.player video {
  width: 100%;
  height: 100%;
  background: #000;
  accent-color: var(--brass);
}

.player.is-failed::after {
  content: "This file did not play. The source may have moved or expired.";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(14, 11, 9, 0.86);
  color: var(--ink);
  font-weight: 600;
  text-align: center;
}

.unplayable {
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 16px;
  padding: 24px;
  background-size: cover;
  background-position: center;
  text-align: center;
}

.unplayable p {
  margin: 0;
  max-width: 36ch;
  font-size: 1.05rem;
  font-weight: 600;
}

.watch-title {
  margin-top: 16px;
  font-size: 1.35rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.watch-info {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  margin-top: 12px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.watch-info .watch-meta {
  margin: 0 0 0 4px;
  font-size: 0.85rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 11px;
  border-radius: 999px;
  background: var(--well);
  color: var(--brass);
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
  font-variant-numeric: tabular-nums;
}

a.chip:hover {
  background: var(--well-hot);
}

.chip-flat {
  color: var(--muted);
}

.up-next {
  position: sticky;
  top: calc(var(--bar) + 16px);
  max-height: calc(100svh - var(--bar) - 32px);
  overflow: auto;
  overscroll-behavior: contain;
  padding-right: 6px;
  scrollbar-width: thin;
}

.up-next h2 {
  margin: 0 0 12px;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.related {
  display: grid;
  gap: 12px;
}

.rel {
  display: grid;
  grid-template-columns: 168px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 4px;
  margin: -4px;
  border-radius: 8px;
  transition: background-color 160ms var(--ease);
}

.rel:hover {
  background: var(--still);
}

.rel-body {
  min-width: 0;
}

.rel .card-title {
  margin-top: 0;
  font-size: 0.84rem;
  line-height: 1.5;
}

.rel .card-meta {
  font-size: 0.72rem;
}

.rel .play {
  width: 38px;
  height: 38px;
}

.rel .play svg {
  width: 16px;
  height: 16px;
}

.rel .duration,
.rel .quality {
  font-size: 0.68rem;
}

/* ---------- Footer ---------- */

.foot {
  flex: none;
  margin-top: 24px;
  padding: 28px var(--gutter) calc(32px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--deep);
  color: var(--faint);
  font-size: 0.82rem;
  text-align: center;
}

.foot-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 18px;
  margin-bottom: 14px;
}

.foot-links a {
  padding: 6px 0;
  color: var(--muted);
  font-weight: 600;
  text-decoration: none;
}

.foot-links a:hover {
  color: var(--brass);
}

.foot p {
  max-width: 62ch;
  margin: 0 auto 6px;
}

.foot-small {
  font-size: 0.75rem;
}

/* ---------- Age gate ---------- */

.gate {
  width: min(460px, calc(100vw - 32px));
  padding: 32px 28px 28px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--ground);
  color: var(--ink);
  text-align: center;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
}

.gate::backdrop {
  background: rgba(10, 8, 6, 0.82);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}

.gate[open] {
  animation: gate-in 320ms var(--ease);
}

@keyframes gate-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
}

.gate-mark {
  display: flex;
  justify-content: center;
  margin-bottom: 20px;
  color: var(--ink);
}

.gate-lockup {
  font-size: 1.7rem;
}

.gate h2 {
  margin: 0 0 10px;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
}

.gate p {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 0.92rem;
}

.gate-actions {
  display: grid;
  gap: 10px;
}

/* ---------- Watched progress + history ---------- */

.progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  height: 3px;
  background: rgba(244, 234, 220, 0.22);
}

.progress i {
  display: block;
  height: 100%;
  background: var(--brass);
}

.card.is-seen .duration {
  bottom: 9px;
}

.card.is-seen .card-title {
  color: var(--muted);
}

.history {
  margin-top: 44px;
}

.history h2 {
  margin: 0;
  font-size: 1.2rem;
  letter-spacing: -0.02em;
}

.link-btn {
  min-height: 36px;
  padding: 0 4px;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--line);
}

.link-btn:hover {
  color: var(--brass);
  text-decoration-color: currentColor;
}

/* ---------- Watch toolbar ---------- */

.tools {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-left: auto;
}

.tool {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition: background-color 160ms var(--ease), color 160ms var(--ease), border-color 160ms var(--ease);
}

.tool svg {
  width: 16px;
  height: 16px;
}

.tool:hover {
  background: var(--well);
  color: var(--ink);
}

.tool[aria-pressed="true"],
.tool[aria-expanded="true"] {
  border-color: var(--brass);
  color: var(--brass);
}

.tool-keys {
  padding: 0 10px;
}

.keys {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px 20px;
  margin: 14px 0 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--still);
  font-size: 0.85rem;
}

.keys div {
  display: flex;
  align-items: center;
  gap: 10px;
}

.keys dt {
  display: flex;
  gap: 4px;
  min-width: 84px;
}

.keys dd {
  margin: 0;
  color: var(--muted);
}

kbd {
  display: inline-grid;
  place-items: center;
  min-width: 26px;
  height: 24px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--well);
  color: var(--ink);
  font: inherit;
  font-size: 0.75rem;
  font-weight: 700;
}

/* Theater: the player takes the full row, Up next drops below as a grid. */

.stage.is-theater {
  grid-template-columns: minmax(0, 1fr);
}

.stage.is-theater .player,
.stage.is-theater .unplayable {
  max-height: calc(100svh - var(--bar) - 7rem);
  margin-inline: auto;
}

.stage.is-theater .up-next {
  position: static;
  max-height: none;
  overflow: visible;
  padding-right: 0;
}

.stage.is-theater .related {
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 22px 14px;
}

.stage.is-theater .rel {
  display: block;
  padding: 0;
  margin: 0;
}

.stage.is-theater .rel:hover {
  background: none;
}

.stage.is-theater .rel .card-title {
  margin-top: 8px;
  font-size: 0.9rem;
}

/* End card: next title countdown */

.endcard {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 10px;
  padding: 24px;
  background: rgba(14, 11, 9, 0.88);
  text-align: center;
  animation: fade-in 240ms var(--ease);
}

.endcard p {
  margin: 0;
}

.endcard-label {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
}

.endcard-label b {
  color: var(--brass);
  font-variant-numeric: tabular-nums;
}

.endcard-title {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  max-width: 44ch;
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.5;
}

.endcard-actions {
  display: flex;
  gap: 10px;
  margin-top: 6px;
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

/* ---------- Toast + back to top ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: calc(100vw - 32px);
  padding: 10px 12px 10px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--well);
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
  opacity: 0;
  transform: translate(-50%, 12px);
  transition: opacity 200ms var(--ease), transform 280ms var(--ease);
}

.toast.is-on {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast button {
  min-height: 32px;
  padding: 0 10px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--brass);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.toast button:hover {
  background: var(--well-hot);
}

.to-top {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: calc(20px + env(safe-area-inset-bottom));
  z-index: 25;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--well);
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.45);
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity 200ms var(--ease), transform 280ms var(--ease), visibility 0s linear 280ms, background-color 160ms var(--ease);
}

.to-top.is-on {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition-delay: 0s;
}

.to-top:hover {
  background: var(--well-hot);
  color: var(--brass);
}

.to-top svg {
  width: 20px;
  height: 20px;
}

@media (max-width: 760px) {
  .tools {
    width: 100%;
    margin-left: 0;
  }

  .tool[data-tool="theater"] {
    display: none;
  }

  .keys {
    display: none !important;
  }

  .tool-keys {
    display: none;
  }

  .endcard-title {
    font-size: 0.95rem;
  }
}

/* ---------- Ad slots ---------- */

/* Sized before the banner arrives so nothing below it moves. */
.ad {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 4px;
  margin: 0 auto 22px;
  max-width: 100%;
}

.ad iframe {
  display: block;
  width: var(--ad-w);
  max-width: 100%;
  height: var(--ad-h);
  border: 0;
  border-radius: 4px;
  background: var(--still);
  overflow: hidden;
}

.ad.is-empty {
  display: none;
}

.ad-label {
  justify-self: center;
  color: var(--faint);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1;
  text-transform: uppercase;
}

.ad-under {
  margin: 18px auto 0;
}

.ad-side {
  margin-bottom: 18px;
}

.stage.is-theater .ad-side {
  justify-items: start;
}

/* ---------- Responsive ---------- */

@media (min-width: 1500px) {
  .grid {
    --cols: 5;
    gap: 30px 16px;
  }

  .grid-cats {
    --cols: 4;
  }

  .stage {
    grid-template-columns: minmax(0, 1fr) 400px;
  }
}

@media (max-width: 1180px) {
  .grid {
    --cols: 3;
  }

  .stage {
    grid-template-columns: minmax(0, 1fr) 320px;
  }

  .rel {
    grid-template-columns: 144px minmax(0, 1fr);
  }
}

@media (max-width: 960px) {
  .stage {
    display: block;
  }

  .player,
  .unplayable {
    max-height: none;
  }

  .up-next {
    position: static;
    max-height: none;
    overflow: visible;
    margin-top: 24px;
    padding-right: 0;
  }

  .related {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px 14px;
  }

  .rel {
    display: block;
    padding: 0;
    margin: 0;
  }

  .rel:hover {
    background: none;
  }

  .rel .card-title {
    margin-top: 8px;
  }
}

@media (max-width: 760px) {
  :root {
    --gutter: 14px;
  }

  .grid {
    --cols: 2;
    gap: 20px 10px;
  }

  .grid-cats {
    --cols: 2;
  }

  .card-title {
    font-size: 0.875rem;
  }
}

@media (max-width: 560px) {
  :root {
    --gutter: 12px;
    --bar: 102px;
  }

  .bar-row {
    height: 52px;
  }

  .mark-lockup {
    gap: 8px;
    font-size: 1.3rem;
  }

  .bar-badge {
    padding: 3px 6px;
    font-size: 0.7rem;
  }

  /* Catalog tabs become scrollable chips on phones. */
  .tabs {
    height: 50px;
    border-top: 0;
    background: var(--ground);
    -webkit-mask: linear-gradient(to right, transparent 0, #000 12px, #000 calc(100% - 28px), transparent);
    mask: linear-gradient(to right, transparent 0, #000 12px, #000 calc(100% - 28px), transparent);
  }

  .tabs-track {
    align-items: center;
    gap: 6px;
    padding: 0 28px 0 var(--gutter);
  }

  .tabs a {
    height: 36px;
    padding: 0 14px;
    border-radius: 999px;
    background: var(--well);
    font-size: 0.85rem;
  }

  .tabs a::after {
    display: none;
  }

  .tabs a[aria-current="page"] {
    background: var(--brass);
    color: var(--on-brass);
  }

  .sheet {
    padding: 14px var(--gutter) 32px;
  }

  .head {
    margin-bottom: 12px;
  }

  h1 {
    font-size: 1.15rem;
  }

  .grid {
    gap: 18px 10px;
  }

  .thumb {
    border-radius: 5px;
  }

  .card-title {
    margin-top: 7px;
    font-size: 0.84rem;
    line-height: 1.45;
  }

  .card-meta {
    gap: 2px 10px;
    margin-top: 3px;
    font-size: 0.72rem;
  }

  .card-meta svg {
    width: 12px;
    height: 12px;
  }

  .duration,
  .quality {
    bottom: 5px;
    padding: 2px 5px 1px;
    font-size: 0.68rem;
  }

  .duration {
    right: 5px;
  }

  .quality {
    top: 5px;
    bottom: auto;
    left: 5px;
  }

  /* Pressed feedback replaces hover on touch. */
  .card:active .thumb,
  .rel:active .thumb {
    transform: scale(0.97);
  }

  .card .thumb,
  .rel .thumb {
    transition: transform 160ms var(--ease);
  }

  /* The player runs edge to edge on phones. */
  .feature .player,
  .feature .unplayable {
    width: calc(100% + 2 * var(--gutter));
    margin: -14px calc(-1 * var(--gutter)) 0;
    border-radius: 0;
  }

  .watch-title {
    margin-top: 12px;
    font-size: 1.05rem;
  }

  .watch-info {
    gap: 8px;
    margin-top: 10px;
    padding-bottom: 14px;
  }

  .tools {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
  }

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

  .tool {
    flex: none;
    min-height: 40px;
  }

  .up-next {
    margin-top: 18px;
  }

  .related {
    gap: 18px 10px;
  }

  .cat-label {
    left: 10px;
    bottom: 8px;
    font-size: 1rem;
  }

  .history {
    margin-top: 32px;
  }

  .pager {
    gap: 4px;
    margin-top: 28px;
  }

  .pager a,
  .pager .current {
    min-width: 42px;
    padding: 0 8px;
  }

  .pager-step span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
  }

  .problem {
    margin: 4vh auto;
    padding: 24px 18px;
  }

  .foot {
    padding-top: 22px;
    font-size: 0.78rem;
  }

  .foot-links {
    gap: 0 14px;
  }

  .foot-links a {
    padding: 8px 0;
  }

  .toast {
    bottom: calc(80px + env(safe-area-inset-bottom));
  }

  .to-top {
    width: 44px;
    height: 44px;
  }

  /* The age gate is a bottom sheet on phones. */
  .gate {
    width: 100%;
    max-width: 100%;
    margin: auto 0 0;
    padding: 28px 20px calc(24px + env(safe-area-inset-bottom));
    border-width: 1px 0 0;
    border-radius: 18px 18px 0 0;
  }

  .gate[open] {
    animation: sheet-in 360ms var(--ease);
  }
}

@keyframes sheet-in {
  from {
    transform: translateY(100%);
  }
}

@media (max-width: 360px) {
  :root {
    --gutter: 10px;
  }

  .grid {
    gap: 16px 8px;
  }

  .mark-lockup {
    font-size: 1.2rem;
  }
}

/* Phone held sideways: let the player use the height, header slides away on scroll. */
@media (orientation: landscape) and (max-height: 500px) {
  .player,
  .unplayable {
    max-height: calc(100svh - 24px);
  }

  .stage {
    display: block;
  }
}

@media (hover: none) {
  .play {
    display: none;
  }

  .card:hover .thumb img,
  .rel:hover .thumb img {
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
  }

  .thumb {
    animation: none;
    background: var(--still);
  }

  .thumb img,
  .play,
  .tabs a::after,
  .mark-icon,
  .bar,
  .toast,
  .to-top {
    transition: opacity 120ms linear;
  }

  .card:hover .thumb img,
  .card:focus-visible .thumb img,
  .rel:hover .thumb img,
  .rel:focus-visible .thumb img,
  .card:hover .play,
  .card:focus-visible .play,
  .rel:hover .play,
  .rel:focus-visible .play {
    transform: none;
  }
}
