:root {
  color-scheme: light;
  --ink: #1c1915;
  --muted: #6d645b;
  --paper: #f3efe6;
  --card: #fffdf8;
  --line: #e2d9cc;
  --navy: #1e3348;
  --rust: #b85c38;
  --danger: #8f2d2d;
  --ok: #1f6b45;
  --shadow: 0 16px 40px rgba(28, 25, 21, 0.08);
  font-family: "Segoe UI", "Helvetica Neue", sans-serif;
  line-height: 1.45;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  color: var(--ink);
  background: var(--paper);
}
a { color: var(--navy); }
button, input, textarea, select { font: inherit; color: inherit; }
button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  padding: 0.65rem 1.1rem;
  background: var(--navy);
  color: #f7f3ea;
  text-decoration: none;
  cursor: pointer;
}
button.secondary, .button.secondary {
  background: transparent;
  color: var(--navy);
  border: 1px solid var(--navy);
}
button.danger { background: var(--danger); color: #fff; }
button:disabled { opacity: 0.55; cursor: not-allowed; }
button.linkish {
  background: transparent;
  color: #f7f3ea;
  padding: 0.2rem 0;
  text-decoration: underline;
  text-underline-offset: 0.15em;
}
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
}
textarea { min-height: 5rem; resize: vertical; }
input[type="color"] { width: 4.5rem; height: 2.7rem; padding: 0.25rem; }
input[type="file"] { padding: 0.4rem; }
.thumb {
  width: 9rem;
  height: 5rem;
  object-fit: contain;
  background: #14181c;
  border-radius: 8px;
}
.preview-frame {
  margin-top: 0.4rem;
  border-radius: 12px;
  overflow: hidden;
  background: #14181c;
}
.preview-frame iframe { width: 100%; aspect-ratio: 16 / 9; border: 0; display: block; }
.invite { margin-top: 1.2rem; padding-top: 0.2rem; }
.invite img {
  display: block;
  width: min(100%, 28rem);
  height: auto;
  margin: 0.8rem 0 1rem;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--paper);
}
fieldset { border: 0; margin: 0; padding: 0; }
legend { padding: 0; }
label { display: grid; gap: 0.35rem; font-size: 0.92rem; }
label.check { display: flex; align-items: center; gap: 0.55rem; }
label.check input { width: auto; }
.choice-row { display: flex; flex-wrap: wrap; gap: 0.4rem 1.2rem; margin-top: 0.35rem; }
.skip {
  position: absolute;
  left: 1rem;
  top: -3rem;
  background: #fff;
  padding: 0.4rem 0.7rem;
}
.skip:focus { top: 0.5rem; z-index: 30; }
:focus-visible { outline: 3px solid #d08963; outline-offset: 2px; }

.top {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem 1.2rem;
  align-items: center;
  padding: 0.85rem 1.2rem;
  background: var(--navy);
  color: #f7f3ea;
}
.brand { display: flex; flex-direction: column; min-width: 7rem; color: inherit; text-decoration: none; }
.mark {
  font-family: Palatino, "Palatino Linotype", Georgia, serif;
  font-size: 1.35rem;
}
.product { font-size: 0.75rem; letter-spacing: 0.14em; text-transform: uppercase; opacity: 0.75; }
.nav { display: flex; gap: 0.9rem; flex: 1; }
.nav a { color: #f7f3ea; text-decoration: none; }
.top form { margin-left: auto; }

main {
  width: min(980px, calc(100% - 2rem));
  margin: 1.25rem auto 2.5rem;
  flex: 1 0 auto;
}
.site-footer {
  width: min(980px, calc(100% - 2rem));
  margin: 0 auto 1.4rem;
  color: var(--muted);
  font-size: 0.88rem;
}
.site-footer a { color: inherit; }
h1, h2 { font-family: Palatino, "Palatino Linotype", Georgia, serif; font-weight: 600; line-height: 1.15; }
h1 { margin: 0 0 0.8rem; font-size: 2rem; }
h2 { margin: 0 0 0.45rem; font-size: 1.35rem; }
.hint, .meta { color: var(--muted); }
.meta { font-size: 0.92rem; }
.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.75rem;
  color: var(--rust);
}
.flash {
  margin: 0 0 1rem;
  padding: 0.75rem 0.9rem;
  border-radius: 12px;
  background: #d9efe3;
  color: #14523a;
}
.login .flash, main > .flash { margin-bottom: 1rem; }

.panel, .login, .video-card, .card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}
.panel, .card { padding: 1.1rem 1.15rem 1.25rem; }
.panel + .panel, .cards { margin-top: 0.9rem; }
.narrow { width: min(720px, 100%); }
.login { width: min(440px, 100%); margin: 8vh auto; padding: 1.4rem; }
.stack { display: grid; gap: 0.8rem; }
.split, .row-actions { display: flex; flex-wrap: wrap; gap: 0.7rem; align-items: center; }
.target-edit { margin-top: 0.8rem; }
.target-edit summary { cursor: pointer; color: var(--navy); }
.target-edit form { margin-top: 0.8rem; }
.target-edit { margin-top: 0.8rem; }
.target-edit summary { cursor: pointer; color: var(--navy); }
.target-edit form { margin-top: 0.8rem; }
.monitor-low { width: 426px; max-width: 100%; background: #000; }
.monitor-low iframe { display: block; width: 100%; aspect-ratio: 16 / 9; border: 0; }
.split { justify-content: space-between; align-items: start; }
.event-meta {
  margin-left: auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.55rem;
}
.event-meta .stats { margin: 0; }
.event-meta .stats div { text-align: right; }
.grid-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.75rem;
}
.cards { list-style: none; padding: 0; display: grid; gap: 0.8rem; }
.card h2 { font-size: 1.25rem; }
.card h2 a { text-decoration: none; }
.when {
  margin: 0.05rem 0 0.55rem;
  display: flex;
  align-items: center;
  gap: 0.38rem;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 400;
}
.when-icon {
  width: 1.25rem;
  height: 1.25rem;
  flex: none;
  color: var(--navy);
}
.when-icon circle,
.when-icon path { stroke-width: 2.15; }
.embed-code {
  width: 100%;
  min-height: 6.5rem;
  padding: 0.7rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.84rem;
  line-height: 1.45;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.2rem 0.65rem;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: #ece7e0;
  color: #5c534a;
}
.badge[data-phase="sending"] { background: #d9efe3; color: var(--ok); }
.badge[data-phase="waiting"] { background: #e7eef5; color: var(--navy); }
.badge[data-phase="error"] { background: #f0d0d0; color: var(--danger); }

.encoder-row {
  display: grid;
  gap: 0.35rem 0.7rem;
  align-items: center;
  padding: 0.65rem 0;
  border-top: 1px solid var(--line);
}
@media (min-width: 720px) {
  .encoder-row { grid-template-columns: 9rem minmax(0, 1fr) auto; }
}
.encoder-label { font-size: 0.92rem; color: var(--muted); }
.encoder-value {
  display: block;
  overflow-wrap: anywhere;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.88rem;
  padding: 0.45rem 0.55rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.stage { display: grid; gap: 0.4rem; }
.video-card { padding: 0.7rem; }
.video-frame { position: relative; }
.video-frame video { width: 100%; aspect-ratio: 16 / 9; background: #14181c; border-radius: 12px; display: block; }
.video-frame video:not(.is-playing) { opacity: 0; }
.video-frame video::-webkit-media-controls-timeline,
.video-frame video::-webkit-media-controls-current-time-display,
.video-frame video::-webkit-media-controls-time-remaining-display { display: none !important; }
.player-hold {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 1.2rem;
  background: #14181c;
  color: #f3efe6;
  border-radius: 12px;
}
.player-hold p { margin: 0.35rem 0; }
.player-hold .waiting-title { font-family: Palatino, Georgia, serif; font-size: 1.4rem; }
.player-hold button { margin-top: 0.9rem; background: #f3efe6; color: var(--navy); }
.player-hold .waiting-pulse {
  display: flex;
  justify-content: center;
  gap: 0.38rem;
  margin: 1.45rem 0 0;
}
.waiting-pulse span {
  width: 0.42rem;
  height: 0.42rem;
  border-radius: 50%;
  background: #f3efe6;
  opacity: 0.35;
  animation: waiting-dot 1.05s infinite ease-in-out;
}
.waiting-pulse span:nth-child(2) { animation-delay: 0.15s; }
.waiting-pulse span:nth-child(3) { animation-delay: 0.3s; }
.player-hold:has(#player-retry:not([hidden])) .waiting-pulse { display: none; }
@keyframes waiting-dot {
  0%, 80%, 100% { opacity: 0.28; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-0.22rem); }
}
@media (prefers-reduced-motion: reduce) {
  .waiting-pulse span { animation: none; opacity: 0.8; }
}
.video-tools { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; margin-top: 0.7rem; }
.video-tools:not(:has(:not([hidden]))) { display: none; }
.quality {
  display: none;
  position: absolute;
  z-index: 4;
  right: 7.4rem;
  bottom: 0.55rem;
}
.video-frame.is-bar:has(video.is-playing) .quality,
.video-frame.is-menu:has(video.is-playing) .quality { display: block; }
.powered {
  display: none;
  position: absolute;
  z-index: 4;
  left: 50%;
  bottom: 0.62rem;
  transform: translateX(-50%);
  color: #f3efe6;
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  line-height: 1;
  text-decoration: none;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.85);
  white-space: nowrap;
}
.powered:hover { text-decoration: underline; }
.video-frame.is-bar:has(video.is-playing) .powered,
.video-frame.is-menu:has(video.is-playing) .powered { display: block; }
.quality-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  min-height: 1.65rem;
  padding: 0.05rem 0.4rem;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: #f3efe6;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.85);
}
.quality-toggle::after {
  content: "";
  width: 0;
  height: 0;
  border-left: 0.26em solid transparent;
  border-right: 0.26em solid transparent;
  border-top: 0.32em solid currentColor;
}
.quality-toggle:hover,
.quality-toggle[aria-expanded="true"] { background: rgba(243, 239, 230, 0.16); }
.quality-menu {
  position: absolute;
  right: 0;
  bottom: calc(100% + 0.45rem);
  min-width: 8.4rem;
  padding: 0.28rem;
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
  background: rgba(20, 24, 28, 0.94);
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
}
.quality-menu[hidden] { display: none; }
.quality-menu button {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 0;
  padding: 0.38rem 0.6rem;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #f3efe6;
  font-size: 0.84rem;
  font-weight: 500;
}
.quality-menu button[aria-checked="true"] {
  background: #f3efe6;
  color: var(--navy);
  font-weight: 650;
}
.quality-menu button.is-current:not([aria-checked="true"]) {
  background: rgba(232, 184, 120, 0.28);
  color: #f6e7c8;
}
.quality-size { margin-left: auto; padding-left: 0.75rem; opacity: 0.72; font-size: 0.75rem; }
.player-status { margin: 0; color: var(--muted); }
.viewers {
  position: absolute;
  z-index: 4;
  top: 0.7rem;
  right: 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.32rem;
  margin: 0;
  color: #f3efe6;
  font-size: 0.84rem;
  font-weight: 650;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.75);
  pointer-events: none;
}
.viewers-icon { width: 1.05rem; height: 1.05rem; display: block; flex: none; }
.stats dd { display: flex; align-items: center; gap: 0.4rem; }
.event-meta .stats dd { justify-content: flex-end; }
.stats .viewers-icon { width: 1.15rem; height: 1.15rem; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.7rem; margin: 0 0 0.8rem; }
.stats div { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 0.7rem 0.8rem; }
.stats dt { color: var(--muted); font-size: 0.82rem; }
.stats dd { margin: 0.15rem 0 0; font-size: 1.4rem; font-weight: 650; }
@media (max-width: 640px) {
  .stats { grid-template-columns: 1fr; }
}
.share-block { margin-top: 0.85rem; }
.share { display: flex; align-items: center; gap: 0.45rem; }
.share-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.05rem;
  height: 2.05rem;
  padding: 0;
  border-radius: 999px;
  color: #fff;
  text-decoration: none;
}
.share-link svg { width: 1.05rem; height: 1.05rem; display: block; }
.share-link.facebook { background: #1877f2; }
.share-link.instagram { background: #c13584; }
.share-link.whatsapp { background: #25d366; }
.share-note { margin: 0.55rem 0 0; color: var(--muted); font-size: 0.9rem; }
.share-more { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.75rem; }
.share-more button { padding: 0.42rem 0.9rem; font-size: 0.9rem; }
.player-modal {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 1rem 1.1rem 1.15rem;
  width: min(34rem, calc(100% - 2rem));
  max-height: calc(100dvh - 2rem);
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 24px 60px rgba(20, 24, 28, 0.28);
}
.player-modal:has([data-panel="qr"]:not([hidden])) {
  width: min(26rem, calc(100% - 2rem));
}
.player-modal::backdrop { background: rgba(20, 24, 28, 0.55); }
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.85rem;
}
.modal-head h2 { margin: 0; font-size: 1.15rem; }
.player-qr {
  display: block;
  width: 100%;
  height: auto;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--paper);
}
.player-modal .embed-code { min-height: 0; margin: 0.75rem 0 0; }
.player-modal .hint { margin: 0.75rem 0 0; }
.player-modal .row-actions { margin-top: 0.85rem; }
body.is-gated { overflow: hidden; }
body.is-gated::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(20, 24, 28, 0.78);
}
.access-gate {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 1.15rem 1.2rem 1.25rem;
  width: min(22rem, calc(100% - 2rem));
  max-height: calc(100dvh - 2rem);
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 24px 60px rgba(20, 24, 28, 0.35);
}
.access-gate::backdrop { background: rgba(20, 24, 28, 0.78); }
.access-gate h2 { margin: 0 0 0.35rem; font-size: 1.2rem; }
.access-gate > p { margin: 0; }
.access-gate form { margin-top: 0.9rem; }
.access-gate .hint { color: var(--danger); }

body.is-embed {
  background: #14181c;
  color: #f3efe6;
  height: 100dvh;
  min-height: 100dvh;
  overflow: hidden;
}
body.is-embed .video-card {
  border: 0;
  box-shadow: none;
  border-radius: 0;
  background: #14181c;
  padding: 0;
}
body.is-embed .video-frame,
body.is-embed .count-stage { min-height: 100dvh; height: 100dvh; }
body.is-embed .video-frame video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 0;
  aspect-ratio: auto;
  border-radius: 0;
}
body.is-embed .player-hold { border-radius: 0; }
body.is-embed #fullscreen { background: #f3efe6; color: var(--navy); }
body.is-embed .video-tools {
  position: absolute;
  z-index: 3;
  left: calc(0.8rem + env(safe-area-inset-left));
  bottom: calc(0.8rem + env(safe-area-inset-bottom));
  margin: 0;
}
body.is-embed .quality {
  right: calc(7.4rem + env(safe-area-inset-right));
  bottom: calc(0.55rem + env(safe-area-inset-bottom));
}
body.is-embed .powered { bottom: calc(0.62rem + env(safe-area-inset-bottom)); }
body.is-embed .video-card { position: relative; }
body.is-embed .viewers {
  top: calc(0.7rem + env(safe-area-inset-top));
  right: calc(0.8rem + env(safe-area-inset-right));
}
