:root {
  --bg: #101614;
  --surface: #18211d;
  --raised: #212c27;
  --fg: #e8f0eb;
  --muted: #93a399;
  --line: #314039;
  --signal: #e6b325;
  --sans: "Outfit", ui-sans-serif, system-ui, sans-serif;
  --display: "Fraunces", ui-serif, Georgia, serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 16px;
}

button, [role="button"] { cursor: pointer; }
button { font: inherit; color: inherit; background: none; border: 0; }
button:disabled { cursor: default; }

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

a { color: var(--fg); }

.wrap {
  width: min(48rem, 100%);
  margin: 0 auto;
  padding: 1.25rem 1rem 0;
  min-height: 100dvh;
}

.top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.mark {
  position: relative;
  display: grid;
  place-items: center;
  width: 3rem;
  height: 3rem;
  flex: none;
  border-radius: 1rem;
  background: var(--raised);
  box-shadow: inset 0 0 0 1px var(--line);
}

.mark span.ring {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 999px;
  box-shadow: inset 0 0 0 2px var(--signal);
}

.live-dot {
  position: absolute;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 999px;
  background: var(--signal);
  animation: pulse 1.4s ease-in-out infinite;
}

h1 {
  margin: 0;
  font-family: var(--display);
  font-weight: 560;
  font-size: 1.5rem;
  line-height: 1;
  letter-spacing: -0.02em;
}

h1 em { color: var(--signal); font-style: italic; }

.sub { margin: 0.25rem 0 0; color: var(--muted); font-size: 0.875rem; }

.icon-btn {
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  flex: none;
  border-radius: 1rem;
  background: var(--raised);
  box-shadow: inset 0 0 0 1px var(--line);
}

.icon-btn:disabled { opacity: 0.6; }
.icon-btn.spin svg { animation: spin 0.8s linear infinite; }

.search {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1.25rem;
  min-height: 3rem;
  padding: 0 0.75rem;
  border-radius: 1rem;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
}

.search input {
  width: 100%;
  height: 3rem;
  border: 0;
  background: transparent;
  color: var(--fg);
  font: inherit;
  outline: none;
}

.search input::placeholder { color: var(--muted); }

.chips {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
  scrollbar-width: none;
}

.chips::-webkit-scrollbar { display: none; }

.chip {
  height: 2.75rem;
  flex: none;
  padding: 0 1rem;
  border-radius: 999px;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
  font-size: 0.875rem;
  font-weight: 500;
}

.chip.on, .chip.on:hover {
  background: var(--signal);
  color: var(--bg);
  box-shadow: none;
}

.note, .warn {
  margin: 0.75rem 0 0;
  font-size: 0.875rem;
}

.note { color: var(--muted); }
.warn { color: var(--signal); }

.wide {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 3rem;
  margin-top: 1rem;
  padding: 0 1rem;
  border-radius: 1rem;
  background: var(--raised);
  box-shadow: inset 0 0 0 1px var(--line);
  font-size: 0.875rem;
  font-weight: 500;
}

.bar {
  height: 0.25rem;
  margin-top: 1rem;
  overflow: hidden;
  border-radius: 999px;
  background: var(--raised);
}

.bar > div { height: 100%; background: var(--signal); }

.empty {
  margin-top: 2.5rem;
  padding: 2rem 1.25rem;
  border-radius: 1.5rem;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
  text-align: center;
}

.empty p { margin: 0.75rem 0 0; }
.empty .hint { margin-top: 0.25rem; color: var(--muted); font-size: 0.875rem; }

.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
  margin: 1rem 0 0;
  padding: 0;
  list-style: none;
}

@media (min-width: 640px) {
  .grid { grid-template-columns: 1fr 1fr; }
}

.card {
  position: relative;
  overflow: hidden;
  border-radius: 1.5rem;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
}

.open {
  display: block;
  width: 100%;
  text-align: left;
}

.frame {
  position: relative;
  aspect-ratio: 16 / 9;
  background: var(--raised);
}

.frame img { width: 100%; height: 100%; object-fit: cover; display: block; }

.fallback {
  display: flex;
  align-items: flex-end;
  height: 100%;
  padding: 1rem;
}

.fallback p {
  margin: 0;
  font-family: var(--display);
  font-size: 1.5rem;
  line-height: 1.15;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.badge {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  height: 1.75rem;
  padding: 0 0.5rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted);
}

.badge.live { color: var(--signal); }
.badge .pip {
  width: 0.375rem;
  height: 0.375rem;
  border-radius: 999px;
  background: var(--signal);
  animation: pulse 1.4s ease-in-out infinite;
}

.meta { padding: 0.75rem 3.5rem 0.75rem 1rem; }
.meta strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.meta span { display: block; margin-top: 0.125rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 0.875rem; }

.fav {
  position: absolute;
  right: 0.5rem;
  bottom: 0.5rem;
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 1rem;
  z-index: 1;
}

.fav.on { color: var(--signal); }
.fav:not(.on) { color: var(--muted); }

.text-btn {
  display: block;
  min-height: 2.75rem;
  margin-top: 1rem;
  color: var(--signal);
  font-size: 0.875rem;
  font-weight: 500;
}

footer {
  margin-top: 2rem;
  padding-bottom: max(1rem, env(safe-area-inset-bottom));
  color: var(--muted);
  font-size: 0.875rem;
}

footer a { text-underline-offset: 2px; }

[hidden] {
  display: none !important;
}

.player {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.player[hidden] { display: none; }

.player-top {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1rem 0;
}

.player-top .who { min-width: 0; }
.player-top strong, .player-top span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.player-top span { color: var(--muted); font-size: 0.875rem; }

.stage {
  position: relative;
  flex: 1;
  min-height: 0;
  margin-top: 1rem;
  background: #000;
}

.stage video { width: 100%; height: 100%; object-fit: contain; background: #000; }

.stage .connecting {
  position: absolute;
  left: 0;
  right: 0;
  top: 1rem;
  margin: 0;
  text-align: center;
  color: var(--muted);
  font-size: 0.875rem;
}

.stage .overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  text-align: center;
  font-size: 0.875rem;
}

.stage .connecting[hidden],
.stage .overlay[hidden] {
  display: none;
}

.player-foot {
  padding: 1rem 1rem max(1rem, env(safe-area-inset-bottom));
  color: var(--muted);
  font-size: 0.875rem;
}

.player-foot a {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  margin-top: 0.75rem;
  color: var(--signal);
  font-weight: 500;
  text-decoration: none;
}

@keyframes pulse { 50% { opacity: 0.4; } }
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .live-dot, .badge .pip, .icon-btn.spin svg { animation: none; }
}
