:root {
  --brand: #625df5;
  --brand-700: #4b45e4;
  --ink: #16161e;
  --ink-2: #55555f;
  --ink-3: #85858f;
  --line: #e6e6ec;
  --line-soft: #f0f0f4;
  --surface: #ffffff;
  --bg: #fbfbfd;
  --hover: #f5f5f8;
  --r-sm: 6px;
  --r: 10px;
  --r-lg: 14px;

  /* one container width and gutter for every page, so the logo, the grid
     and the video all sit on the same left edge */
  --container: 1120px;
  --gutter: 28px;
  --shadow-1: 0 1px 2px rgba(16, 16, 30, 0.06);
  --shadow-2: 0 2px 6px rgba(16, 16, 30, 0.06), 0 12px 28px rgba(16, 16, 30, 0.08);
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

img,
svg,
video,
iframe {
  display: block;
  max-width: 100%;
}

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

button {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 6px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- header ---------- */

.header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}

.header-inner {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 var(--gutter);
  height: 64px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 680;
  font-size: 18px;
  letter-spacing: -0.02em;
}
.brand-mark {
  width: 26px;
  height: 26px;
  flex: none;
  color: var(--brand);
}
.brand-mark svg {
  width: 100%;
  height: 100%;
}

/* ---------- page ---------- */

.page {
  max-width: var(--container);
  margin: 0 auto;
  padding: 34px var(--gutter) 80px;
}

.page-title {
  margin: 0 0 4px;
  font-size: 25px;
  font-weight: 650;
  letter-spacing: -0.02em;
}
.page-sub {
  margin: 0 0 26px;
  color: var(--ink-3);
  font-size: 14px;
}

/* ---------- grid ---------- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(296px, 1fr));
  gap: 28px 22px;
}

.card {
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.card-thumb {
  position: relative;
  display: block;
  aspect-ratio: 16 / 9;
  border-radius: var(--r-lg);
  overflow: hidden;
  background: var(--line-soft);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-1);
  transition: box-shadow 0.16s ease, transform 0.16s ease;
}
.card-media {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: var(--line-soft);
  pointer-events: none;
}
.card:hover .card-thumb {
  box-shadow: var(--shadow-2);
  transform: translateY(-2px);
}

.card-play {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(16, 16, 30, 0.16);
  opacity: 0;
  transition: opacity 0.16s ease;
}
.card:hover .card-play,
.card-thumb:focus-visible .card-play {
  opacity: 1;
}
.card-play span {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: #fff;
  display: grid;
  place-items: center;
  box-shadow: var(--shadow-2);
}
.card-play span::after {
  content: "";
  border-left: 13px solid var(--brand);
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
  margin-left: 4px;
}

.duration {
  position: absolute;
  right: 8px;
  bottom: 8px;
  padding: 3px 7px;
  border-radius: 6px;
  background: rgba(16, 16, 30, 0.82);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.card-title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: -0.005em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card:hover .card-title {
  color: var(--brand-700);
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  color: var(--ink-3);
  font-size: 13px;
}
.card-meta .who {
  color: var(--ink-2);
  font-weight: 500;
}
.sep {
  color: var(--line);
}

.avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 11px;
  font-weight: 650;
  flex: none;
}
.avatar.lg {
  width: 40px;
  height: 40px;
  font-size: 14px;
}

/* ---------- video page ---------- */

.watch {
  max-width: var(--container);
  margin: 0 auto;
  padding: 30px var(--gutter) 80px;
}

/* title row sits above the player, as on Loom */
.watch-head {
  display: flex;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 18px;
}

.watch-title {
  margin: 0;
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.3;
}

.watch-byline {
  margin: 6px 0 0;
  color: var(--ink-3);
  font-size: 14px;
}
.watch-byline .sep {
  margin: 0 7px;
  color: var(--ink-3);
}

.icon-btn {
  flex: none;
  margin-left: auto;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
  color: var(--ink-2);
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.icon-btn:hover {
  background: var(--hover);
  color: var(--ink);
}
.icon-btn svg {
  width: 19px;
  height: 19px;
}
.icon-btn.is-copied {
  color: var(--ok);
  border-color: var(--ok);
}

.player {
  aspect-ratio: 16 / 9;
  background: #0d0d14;
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow-2);
  position: relative;
}

.watch-body {
  margin-top: 24px;
  max-width: 68ch;
  color: var(--ink-2);
}
.watch-body p {
  margin: 0;
}

/* ---------- reactions ---------- */

.reactions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin: 20px auto 0;
  padding: 7px;
  width: fit-content;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow-1);
}

.reaction {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-width: 44px;
  height: 40px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
  transition: background 0.13s ease, transform 0.13s ease;
}
.reaction:hover {
  background: var(--hover);
  transform: translateY(-1px);
}
.reaction.is-on {
  background: var(--brand-50, #f1f0fe);
  box-shadow: inset 0 0 0 1px var(--brand);
}

.reaction-emoji {
  font-size: 19px;
  line-height: 1;
}
.reaction-count {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
.reaction-count:empty {
  display: none;
}
.reaction.is-on .reaction-count {
  color: var(--brand-700);
}

.reaction.pop .reaction-emoji {
  animation: pop 0.32s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes pop {
  0% {
    transform: scale(1);
  }
  45% {
    transform: scale(1.42) translateY(-3px);
  }
  100% {
    transform: scale(1);
  }
}

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 12px);
  background: var(--ink);
  color: #fff;
  padding: 11px 18px;
  border-radius: var(--r);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-2);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 60;
}
.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}
.player video,
.player iframe {
  width: 100%;
  height: 100%;
  border: 0;
}

/* ---------- custom player controls ---------- */

.player.has-controls video {
  cursor: pointer;
}

.player.has-controls.is-idle {
  cursor: none;
}

/* centre play button — hidden once playback has started */
.pl-big {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: transparent;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.pl-big::after {
  grid-area: 1 / 1;
  content: "";
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 6px 28px rgba(0, 0, 0, 0.34);
  transition: transform 0.16s ease;
}
.pl-big::before {
  grid-area: 1 / 1;
  content: "";
  z-index: 1;
  justify-self: center;
  align-self: center;
  margin-left: 6px;
  border-left: 20px solid var(--brand);
  border-top: 12px solid transparent;
  border-bottom: 12px solid transparent;
  transition: transform 0.16s ease;
}
.pl-big:hover::after {
  transform: scale(1.06);
}
.pl-big:hover::before {
  transform: scale(1.06);
}
.player.has-started .pl-big {
  display: none;
}

/* control bar */
.pl-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 30px 14px 12px;
  background: linear-gradient(
    to top,
    rgba(8, 8, 16, 0.82),
    rgba(8, 8, 16, 0.42) 55%,
    transparent
  );
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.player.is-idle .pl-bar {
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
}

.pl-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}
.pl-spacer {
  flex: 1;
}

.pl-btn {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #fff;
  cursor: pointer;
  transition: background 0.12s ease;
}
.pl-btn:hover {
  background: rgba(255, 255, 255, 0.16);
}
.pl-btn svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}
.pl-rate {
  width: auto;
  padding: 0 9px;
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.pl-time {
  margin-left: 4px;
  color: rgba(255, 255, 255, 0.92);
  font-size: 12.5px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

/* seek bar */
.pl-seek {
  --pct: 0%;
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  height: 16px;
  margin: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
}
.pl-seek::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(
    to right,
    var(--brand) var(--pct),
    rgba(255, 255, 255, 0.32) var(--pct)
  );
}
.pl-seek::-moz-range-track {
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(
    to right,
    var(--brand) var(--pct),
    rgba(255, 255, 255, 0.32) var(--pct)
  );
}
.pl-seek::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  margin-top: -4px;
  border: 0;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
  opacity: 0;
  transition: opacity 0.15s ease;
}
.pl-seek::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border: 0;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
  opacity: 0;
  transition: opacity 0.15s ease;
}
.player:hover .pl-seek::-webkit-slider-thumb,
.pl-seek:focus-visible::-webkit-slider-thumb {
  opacity: 1;
}
.player:hover .pl-seek::-moz-range-thumb,
.pl-seek:focus-visible::-moz-range-thumb {
  opacity: 1;
}
.pl-seek:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

/* ---------- states ---------- */

.empty {
  border: 1px dashed var(--line);
  border-radius: var(--r-lg);
  padding: 56px 24px;
  text-align: center;
  background: var(--surface);
}
.empty h2 {
  margin: 0 0 6px;
  font-size: 17px;
  font-weight: 620;
}
.empty p {
  margin: 0 auto;
  max-width: 42ch;
  color: var(--ink-3);
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 15px;
  border-radius: var(--r);
  border: 1px solid var(--line);
  background: var(--surface);
  font-weight: 550;
  font-size: 14px;
  cursor: pointer;
}
.btn:hover {
  background: var(--hover);
}

.skeleton {
  border-radius: var(--r-lg);
  background: linear-gradient(90deg, #eeeef3 25%, #f6f6f9 37%, #eeeef3 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s ease infinite;
}
.skeleton.thumb {
  aspect-ratio: 16 / 9;
}
.skeleton.line {
  height: 12px;
  border-radius: 6px;
  margin-top: 10px;
}
.skeleton.line.short {
  width: 55%;
}
@keyframes shimmer {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: 0 0;
  }
}

/* ---------- responsive ---------- */

/* tablet */
@media (max-width: 1024px) {
  :root {
    --gutter: 22px;
  }
  .grid {
    grid-template-columns: repeat(auto-fill, minmax(252px, 1fr));
    gap: 24px 18px;
  }
  .watch-title {
    font-size: 21px;
  }
}

/* small tablet / large phone */
@media (max-width: 760px) {
  :root {
    --gutter: 18px;
  }
  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 22px 14px;
  }
  .page {
    padding-top: 26px;
  }
  .watch {
    padding-top: 22px;
  }
  .page-title {
    font-size: 22px;
  }
}

/* phone */
@media (max-width: 560px) {
  :root {
    --gutter: 16px;
  }

  .header-inner {
    height: 58px;
  }
  .brand {
    font-size: 17px;
  }
  .brand-mark {
    width: 24px;
    height: 24px;
  }

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

  /* title and copy button stack rather than squeezing */
  .watch-head {
    flex-wrap: wrap;
    gap: 12px;
  }
  .watch-title {
    font-size: 19px;
  }
  .watch-byline {
    font-size: 13.5px;
  }
  .icon-btn {
    width: 36px;
    height: 36px;
  }

  /* full-bleed player reads better on a narrow screen */
  .player {
    border-radius: 10px;
  }

  /* compact controls so they fit without wrapping */
  .pl-bar {
    padding: 24px 8px 8px;
  }
  .pl-btn {
    width: 32px;
    height: 32px;
  }
  .pl-btn svg {
    width: 18px;
    height: 18px;
  }
  .pl-time {
    font-size: 11.5px;
    margin-left: 2px;
  }
  .pl-rate {
    padding: 0 7px;
    font-size: 12px;
  }
  .pl-big::after {
    width: 58px;
    height: 58px;
  }
  .pl-big::before {
    border-left-width: 17px;
    border-top-width: 10px;
    border-bottom-width: 10px;
  }
  /* touch has no hover, so the scrubber handle must always show */
  .pl-seek::-webkit-slider-thumb {
    opacity: 1;
  }
  .pl-seek::-moz-range-thumb {
    opacity: 1;
  }

  .reactions {
    width: 100%;
    justify-content: space-between;
    border-radius: 16px;
    gap: 2px;
  }
  .reaction {
    min-width: 0;
    flex: 1;
    padding: 0 4px;
    justify-content: center;
  }

  .watch-body {
    margin-top: 20px;
    font-size: 14.5px;
  }
}

/* coarse pointers never hover, so keep the controls visible */
@media (hover: none) {
  .card-play {
    opacity: 0;
  }
  .player.is-idle .pl-bar {
    opacity: 1;
    transform: none;
    pointer-events: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
  .card:hover .card-thumb {
    transform: none;
  }
}
