:root {
  --bg: #000;
  --fg: #f2f2f2;
  --dim: #8a8a8a;
  --line: rgba(255, 255, 255, 0.14);
  --glass: rgba(20, 20, 20, 0.6);
  --red: #ff3b4e;
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); overflow: hidden; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

.top {
  position: fixed; inset: 0 0 auto 0; z-index: 10;
  display: flex; justify-content: space-between; align-items: center;
  padding: max(14px, env(safe-area-inset-top)) 16px 14px;
  background: linear-gradient(rgba(0,0,0,.6), transparent);
  pointer-events: none;
}
.top > * { pointer-events: auto; }
.logo { font-weight: 700; letter-spacing: -0.02em; font-size: 18px; }

.icon-btn {
  width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center;
  background: var(--glass); border: 1px solid var(--line);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
/* Icons are PNG cutouts used as masks, so their color follows the button state. */
.ico {
  display: block; width: 22px; height: 22px; background: var(--fg);
  -webkit-mask: var(--icon) center / contain no-repeat; mask: var(--icon) center / contain no-repeat;
}
.icon-btn .ico { --icon: url(/icons/sound-off.png); }
.icon-btn.is-on .ico { --icon: url(/icons/sound-on.png); }

.pill {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 8px 14px; border-radius: 999px; font-size: 13px;
  background: var(--glass); border: 1px solid var(--line);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.pill.solid { background: var(--fg); color: #000; border-color: var(--fg); font-weight: 600; }
.pill.wide { width: 100%; padding: 14px; cursor: pointer; }

/* Feed: one slide on screen; the next ones wait below and slide up. */
.feed { position: fixed; inset: 0; overflow: hidden; touch-action: none; }

.slide {
  position: absolute; inset: 0; transform: translateY(100%); transition: transform .3s ease;
  display: flex; justify-content: center; align-items: center; background: var(--bg); overflow: hidden;
}
.slide.current { transform: none; }
.slide.out { transform: translateY(-100%); }
/* Centered 9:16 column, black bars either side on wide screens. */
.frame {
  position: relative; height: 100%; aspect-ratio: 9 / 16; max-width: 100%;
  background: #0b0b0b; overflow: hidden;
}
.frame video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.frame video.tall { object-fit: cover; }
/* Dead feed: next in line to be deleted. */
.frame::after {
  content: ""; position: absolute; inset: 0; border: 4px solid #ff2d2d; border-radius: inherit;
  pointer-events: none; display: none; z-index: 4;
}
.slide.dead .frame::after { display: block; }
.why { display: block; color: #ff6b6b; }
.why:empty { display: none; }

/* Testing only: videos on the site / maximum. */
.site-count {
  position: fixed; z-index: 10; left: 0; bottom: 0; padding: 4px 8px; border-radius: 0 8px 0 0;
  background: rgba(0, 0, 0, .75); font: 11px/1.35 ui-monospace, Menlo, monospace;
}
.site-count:empty { display: none; }

/* Testing only: feed weight readout. */
.debug {
  position: absolute; top: 0; left: 0; padding: 4px 6px; border-radius: 0 0 8px 0;
  background: rgba(0, 0, 0, .75); font: 11px/1.35 ui-monospace, Menlo, monospace; pointer-events: none; z-index: 5;
}
/* Phones: the video fills the screen, so sit just under the logo instead of on it. */
@media (max-width: 699px) {
  .debug { top: calc(max(14px, env(safe-area-inset-top)) + 32px); border-radius: 0 8px 8px 0; }
}
@media (min-width: 700px) {
  .slide { padding: 12px 0; }
  .frame { border-radius: 14px; }
}

.side {
  position: absolute; right: 12px; bottom: calc(max(24px, env(safe-area-inset-bottom)) + 84px);
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.vote {
  width: 50px; height: 50px; border-radius: 50%; display: grid; place-items: center;
  background: var(--glass); border: 1px solid var(--line);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  transition: transform .08s ease;
}
.vote:active { transform: scale(0.9); }
.vote .ico { --icon: url(/icons/thumb.png); width: 24px; height: 24px; }
.dislike .ico { transform: scaleY(-1); } /* same sprite, flipped */
.vote.on { background: var(--fg); }
.vote.on .ico { background: #000; }
.dislike { margin-top: 14px; }
.count { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }

.empty {
  position: fixed; inset: 0; display: grid; place-content: center; text-align: center; gap: 0;
}
.empty p { margin: 4px; font-size: 18px; }
.dim { color: var(--dim); }

.create {
  position: fixed; z-index: 20; right: 16px; bottom: max(20px, env(safe-area-inset-bottom));
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--fg); color: #000; font-size: 30px; line-height: 1; font-weight: 300;
  box-shadow: 0 6px 24px rgba(0,0,0,.5);
}

/* Create sheet */
.sheet {
  position: fixed; inset: 0; z-index: 30; background: rgba(0,0,0,.85);
  display: grid; place-items: center; padding: 16px;
}
.sheet-inner {
  width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 12px;
}
.sheet-head { display: flex; justify-content: space-between; align-items: center; }
.tabs { display: flex; gap: 4px; padding: 4px; border-radius: 999px; background: #111; border: 1px solid var(--line); }
.tab { padding: 7px 16px; border-radius: 999px; font-size: 14px; color: var(--dim); }
.tab.active { background: var(--fg); color: #000; font-weight: 600; }
.x { font-size: 28px; width: 40px; height: 40px; color: var(--dim); }

.stage {
  position: relative; aspect-ratio: 9 / 16; width: min(100%, calc(62dvh * 9 / 16));
  margin: 0 auto; border-radius: 18px; overflow: hidden; background: #0b0b0b; border: 1px solid var(--line);
}
.stage video { width: 100%; height: 100%; object-fit: cover; }
#preview.mirror { transform: scaleX(-1); }
.timer {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  padding: 4px 12px; border-radius: 999px; background: var(--red); font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.stage-msg {
  position: absolute; inset: 0; display: grid; place-items: center; text-align: center;
  padding: 24px; color: var(--dim); font-size: 14px; background: #0b0b0b;
}

.controls { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 76px; }
.controls .pill { min-width: 84px; }
.controls.center { justify-content: center; }
.rec {
  width: 72px; height: 72px; border-radius: 50%; border: 4px solid var(--fg);
  display: grid; place-items: center; position: relative;
}
.rec span { width: 54px; height: 54px; border-radius: 50%; background: var(--red); transition: all .2s ease; }
.rec.on span { width: 26px; height: 26px; border-radius: 6px; }
.rec svg { position: absolute; inset: -4px; width: 72px; height: 72px; transform: rotate(-90deg); }

/* Trimmer */
.trim { display: flex; flex-direction: column; gap: 8px; width: min(100%, calc(62dvh * 9 / 16)); margin: 0 auto; }
.trim-track {
  position: relative; height: 44px; border-radius: 10px; background: #161616; border: 1px solid var(--line);
  touch-action: none;
}
.trim-sel {
  position: absolute; top: -1px; bottom: -1px; border: 2px solid var(--fg); border-radius: 10px;
  background: rgba(255, 255, 255, 0.12); cursor: grab;
}
.trim-sel:active { cursor: grabbing; }
.trim-head { position: absolute; top: 4px; bottom: 4px; width: 2px; margin-left: -1px; background: var(--red); pointer-events: none; }
.trim-handle {
  position: absolute; top: 50%; width: 18px; height: 52px; margin: -26px 0 0 -9px;
  border-radius: 6px; background: var(--fg); cursor: ew-resize; touch-action: none;
}
.trim-handle::after {
  content: ""; position: absolute; inset: 16px 7px; border-left: 2px solid #000; border-right: 2px solid #000; opacity: .35;
}
.trim-info { text-align: center; font-size: 12px; color: var(--dim); font-variant-numeric: tabular-nums; }

.rules { margin: 0; text-align: center; font-size: 12px; color: var(--dim); line-height: 1.5; }

.toast {
  position: fixed; z-index: 40; left: 50%; bottom: 96px; transform: translateX(-50%);
  max-width: calc(100% - 32px); padding: 10px 16px; border-radius: 12px;
  background: #1c1c1c; border: 1px solid var(--line); font-size: 14px; text-align: center;
}
