:root {
  color-scheme: dark;
  font-family: Inter, system-ui, sans-serif;
  --page: #0d1015;
  --surface: #151b24;
  --text: #f9fafb;
  --muted: #b8c0cd;
  --accent: #def68a;
  --viewport-height: 100vh;
}

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

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  overflow: hidden;
  background: var(--page);
  color: var(--text);
}

button, input { font: inherit; }

button {
  color: inherit;
  cursor: pointer;
  touch-action: manipulation;
}

button:disabled { cursor: default; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

.app {
  --stage-height: min(calc(var(--viewport-height) - 48px), 940px);
  --stage-width: calc(var(--stage-height) * 0.5625);
  position: relative;
  display: grid;
  place-items: center;
  min-height: var(--viewport-height);
  background: radial-gradient(ellipse at 50% 38%, #202934 0, var(--page) 65%);
}

.masthead {
  position: absolute;
  z-index: 3;
  top: 28px;
  left: 28px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px 8px 8px;
  border: 1px solid #ffffff22;
  border-radius: 999px;
  background: #0b0e14d9;
  pointer-events: none;
}

.masthead h1 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.brand-mark {
  position: relative;
  display: grid;
  place-items: center;
  width: 25px;
  height: 25px;
  border-radius: 8px;
  background: var(--accent);
}

.brand-mark::after {
  width: 11px;
  height: 14px;
  border: solid #11160e;
  border-width: 2px 0 2px 2px;
  border-radius: 2px;
  transform: skew(-12deg);
  content: "";
}

.stage {
  position: relative;
  isolation: isolate;
  width: var(--stage-width);
  height: var(--stage-height);
  overflow: hidden;
  border-radius: 21px;
  outline: 1px solid #ffffff26;
  background: var(--surface);
  box-shadow: 0 22px 70px #0008;
}

.feed {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: #080a0e;
  cursor: pointer;
  touch-action: none;
  touch-action: pinch-zoom;
  user-select: none;
}

.feed:focus-visible { outline-offset: -4px; }

.slide {
  position: relative;
  height: 100%;
  overflow: hidden;
}

.slide video {
  display: block;
  width: 100%;
  height: 100%;
  background: #080a0e;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
}

.slide video.portrait { object-fit: cover; }

.feed-status, .player-feedback {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  text-align: center;
}

.feed-status {
  gap: 14px;
  padding: 20px;
  background: radial-gradient(ellipse at 50% 43%, #283547 0, #151b24 56%, #11161e);
}

.status-mark {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 48px;
  margin-bottom: 6px;
  padding: 0 13px;
  border: 1px solid #def68a38;
  border-radius: 15px;
  background: #def68a12;
  color: var(--accent);
}

.status-mark i {
  width: 3px;
  height: 12px;
  border-radius: 4px;
  background: currentColor;
}

.status-mark i:nth-child(2) { height: 23px; }
.status-mark i:nth-child(3) { height: 17px; }

.feed-status h2 { margin: 0; font-size: clamp(1.15rem, 4vh, 1.6rem); }
.feed-status p { margin: 0; color: var(--muted); font-size: 0.875rem; line-height: 1.6; }
.feed-status p:empty { display: none; }

.player-feedback {
  z-index: 1;
  pointer-events: none;
}

.player-feedback button { pointer-events: auto; }

.feedback-text {
  margin: 0;
  padding: 8px 13px;
  border-radius: 8px;
  background: #0b0e15d9;
  font-size: 0.875rem;
}

.video-error {
  display: grid;
  justify-items: center;
  gap: 10px;
}

.controls {
  position: absolute;
  z-index: 2;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  gap: 5px;
  padding: 44px 18px 16px;
  background: linear-gradient(transparent, #07090ddd 45%, #07090dfc 100%);
  pointer-events: none;
}

.clip-heading { min-width: 0; }

.clip-count {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.055em;
}

.clip-heading h2 {
  margin: 0;
  overflow: hidden;
  font-size: clamp(1.15rem, 4vh, 1.8rem);
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.timeline {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.6875rem;
  font-variant-numeric: tabular-nums;
}

.timeline input {
  --progress: 0%;
  width: 100%;
  height: 34px;
  margin: 0;
  border-radius: 5px;
  appearance: none;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  pointer-events: auto;
  touch-action: none;
}

.timeline input::-webkit-slider-runnable-track {
  height: 3px;
  border-radius: 99px;
  background: linear-gradient(to right, currentColor var(--progress), #ffffff52 var(--progress));
}

.timeline input::-moz-range-track {
  height: 3px;
  border-radius: 99px;
  background: linear-gradient(to right, currentColor var(--progress), #ffffff52 var(--progress));
}

.timeline input::-webkit-slider-thumb {
  width: 11px;
  height: 11px;
  margin-top: -4px;
  border: 0;
  border-radius: 50%;
  appearance: none;
  background: currentColor;
}

.timeline input::-moz-range-thumb {
  width: 11px;
  height: 11px;
  border: 0;
  border-radius: 50%;
  background: currentColor;
}

.timeline input:disabled { color: #ffffff70; cursor: default; }

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 10px;
  border: 1px solid #ffffff36;
  border-radius: 999px;
  background: #1b2430e8;
  font-size: 0.75rem;
  white-space: nowrap;
  pointer-events: auto;
}

.pill:disabled { opacity: 0.45; }
.back-to-start { justify-self: end; }

.pill.start-playback {
  gap: 8px;
  padding-inline: 16px;
  color: var(--accent);
  font-weight: 700;
}

.icon-play {
  width: 14px;
  height: 14px;
  background: currentColor;
  clip-path: polygon(25% 9%, 96% 50%, 25% 91%);
}

@media (hover: hover) {
  button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
}

@media (max-width: 720px), (max-aspect-ratio: 4/5) {
  .app { --stage-height: var(--viewport-height); --stage-width: 100%; }

  .stage { border-radius: 0; outline: none; box-shadow: none; }

  .masthead {
    top: max(14px, calc(env(safe-area-inset-top) + 8px));
    left: max(14px, calc(env(safe-area-inset-left) + 8px));
  }

  .controls {
    padding-right: max(15px, calc(env(safe-area-inset-right) + 9px));
    padding-bottom: max(13px, calc(env(safe-area-inset-bottom) + 6px));
    padding-left: max(15px, calc(env(safe-area-inset-left) + 9px));
  }
}

@media (max-height: 390px) and (min-width: 721px) and (min-aspect-ratio: 4/5) {
  .app { --stage-height: var(--viewport-height); --stage-width: 300px; }
  .controls { padding: 16px 12px 8px; }
}
