:root {
  color-scheme: dark;
  --bg: #0d0f12;
  --panel: #16191e;
  --line: #2a2f37;
  --text: #eceef1;
  --dim: #9aa3ae;
  --accent: #ffb454;
  --accent-ink: #1b1305;
  --danger: #ff8f8f;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
button, input { font: inherit; color: inherit; }
button, .button {
  border: 0; border-radius: 10px; padding: 0 16px; min-height: 44px; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); font-weight: 600; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center;
}
button.ghost, .button.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); font-weight: 500; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ── make-a-link page ── */
body.home { min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px; }
.card { width: 100%; max-width: 520px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 28px 24px; }
.card h1 { margin: 0 0 8px; font-size: 1.6rem; letter-spacing: -0.01em; }
.lead { margin: 0 0 24px; color: var(--dim); line-height: 1.5; }
.kinds { border: 0; padding: 0; margin: 0 0 20px; display: flex; flex-wrap: wrap; gap: 8px; }
.kinds legend, .field { display: block; padding: 0; margin: 0 0 8px; font-size: 0.85rem; color: var(--dim); }
.kind { position: relative; }
.kind input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.kind span { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); }
.kind input:checked + span { border-color: var(--accent); color: var(--accent); }
.kind input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.kind.off span { color: var(--dim); opacity: 0.6; }
.kind.off input { cursor: not-allowed; }
.kind small { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; }
.row { display: flex; gap: 8px; }
.row input { flex: 1; min-width: 0; min-height: 44px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); }
.row input::placeholder { color: #6b7480; }
.msg { min-height: 1.4em; margin: 8px 0 0; color: var(--danger); font-size: 0.9rem; }
.result { margin-top: 16px; padding-top: 20px; border-top: 1px solid var(--line); }
.actions { margin-top: 8px; }
.actions > * { flex: 1; }
.ver { margin-top: 16px; color: #5d6570; font-size: 0.75rem; }

/* ── viewer ── */
body.view { background: #000; }
.stage { display: flex; justify-content: center; gap: 24px; height: 100dvh; padding: 16px; }
.player {
  --r: 0.5625;   /* width / height of the video; view.js sets it for files */
  position: relative; flex: 0 1 auto; min-width: 0; height: 100%; aspect-ratio: var(--r); max-width: 100%;
  background: #000; border-radius: 14px; overflow: hidden;
}
.screen, .screen > * { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; pointer-events: none; }
.screen video { object-fit: contain; background: #000; }
/* YouTube draws its own buttons along the top and bottom edge of its frame. The frame is made taller than the
   video (which stays centred) so those edges fall outside the visible box. */
.screen iframe { top: -200px; height: calc(100% + 400px); }
.poster { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #000; }
.player.playing .poster { visibility: hidden; }
.player.failed .poster { filter: brightness(0.25); }
.shield { position: absolute; inset: 0; width: 100%; height: 100%; min-height: 0; padding: 0; border-radius: 0; background: transparent; cursor: pointer; }
.shield:focus-visible { outline-offset: -4px; }
.big {
  position: absolute; left: 50%; top: 50%; width: 84px; height: 84px; margin: -42px 0 0 -42px; border-radius: 50%;
  background: rgba(0, 0, 0, 0.55); pointer-events: none; display: none;
}
.big::after {
  content: ""; position: absolute; left: 33px; top: 24px;
  border-style: solid; border-width: 18px 0 18px 28px; border-color: transparent transparent transparent #fff;
}
.player.paused .big { display: block; }
.player.paused .poster { filter: brightness(0.7); }
.player.facebook.paused .screen { filter: brightness(0.7); }
.note {
  position: absolute; left: 24px; right: 24px; top: 50%; transform: translateY(-50%); margin: 0;
  text-align: center; line-height: 1.5; pointer-events: none;
}
.pill {
  position: absolute; min-height: 40px; padding: 0 16px; border-radius: 999px;
  background: rgba(0, 0, 0, 0.65); color: #fff; font-weight: 600; border: 1px solid rgba(255, 255, 255, 0.25);
}
.sound { left: 50%; top: 16px; transform: translateX(-50%); white-space: nowrap; }
.round {
  position: absolute; right: 12px; top: 12px; width: 44px; height: 44px; min-height: 0; padding: 0; border-radius: 50%;
  background: rgba(0, 0, 0, 0.55); border: 1px solid rgba(255, 255, 255, 0.25);
}
/* speaker icon drawn in CSS */
.mute::before {
  content: ""; position: absolute; left: 12px; top: 16px; width: 7px; height: 10px; background: #fff;
}
.mute::after {
  content: ""; position: absolute; left: 13px; top: 11px;
  border-style: solid; border-width: 10px 10px 10px 0; border-color: transparent #fff transparent transparent;
}
.bar { position: absolute; left: 0; right: 0; bottom: 0; height: 18px; cursor: pointer; touch-action: none; }
.bar::before { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(255, 255, 255, 0.25); }
.fill { position: absolute; left: 0; bottom: 0; height: 4px; width: 0; background: var(--accent); transition: width 0.25s linear; }
.bar:hover::before, .bar:hover .fill { height: 6px; }
.player.failed .bar { display: none; }

.side {
  flex: 0 1 420px; min-width: 0; height: 100%; overflow-y: auto; overscroll-behavior: contain;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 20px;
}
.meta h1 { margin: 0; font-size: 1.1rem; line-height: 1.35; overflow-wrap: anywhere; }
.meta p { margin: 4px 0 0; color: var(--dim); font-size: 0.9rem; }
.meta:has(h1:empty) { display: none; }
.side.nocomments h2, .side.nocomments .cstate, .side.nocomments .comments, .side.empty { display: none; }
.side.nocomments { height: auto; align-self: flex-start; }
.side h2 { margin: 20px 0 4px; font-size: 0.95rem; }
.meta:has(h1:empty) + h2 { margin-top: 0; }
.cstate { margin: 0 0 12px; color: var(--dim); font-size: 0.85rem; }
.comments { list-style: none; margin: 0; padding: 0; }
.comment { display: flex; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.avatar {
  flex: none; width: 32px; height: 32px; border-radius: 50%; background: #2b313a; color: var(--dim);
  display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 0.85rem;
}
.cbody { min-width: 0; flex: 1; }
.chead { margin: 0 0 2px; font-size: 0.8rem; color: var(--dim); display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; }
.author { color: var(--text); font-weight: 600; overflow-wrap: anywhere; }
.author.owner { color: var(--accent); }
.tag { border: 1px solid var(--line); border-radius: 999px; padding: 0 8px; font-size: 0.7rem; }
.ctext { margin: 0; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.likes { margin: 4px 0 0; font-size: 0.78rem; color: var(--dim); }

/* phone / narrow: the video fills the screen, comments follow underneath */
@media (max-width: 820px), (max-aspect-ratio: 1/1) {
  .stage { display: block; height: auto; padding: 0; }
  .player { width: min(100vw, calc(100dvh * var(--r))); height: auto; margin: 0 auto; border-radius: 0; }
  .side { height: auto; overflow: visible; border: 0; border-radius: 0; padding: 20px 16px 32px; }
}
@media (prefers-reduced-motion: reduce) {
  .fill { transition: none; }
}

/* make-a-link page: state of the chat preview */
.prep { margin: 8px 0 0; min-height: 1.4em; font-size: 0.85rem; color: var(--dim); }
.prep.ok { color: #8fd694; }
.prep.bad { color: var(--danger); }
