:root {
  --color-bg: #09090b;
  --color-stage: #000000;
  --color-fg: #ffffff;
  --color-muted: #a1a1aa;
  --color-accent: #f5a623;
  --color-sheet: #121214;
  --color-ink: #1a1203;
  --font-sans: "DM Sans", "Segoe UI", sans-serif;
  --font-display: "Outfit", "Segoe UI", sans-serif;
  --radius-pill: 999px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

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

button { font: inherit; cursor: pointer; }

button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.site {
  width: min(100%, 1100px);
  margin: 0 auto;
  padding: 12px 16px 40px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.site-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
}

.domain {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 20px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-actions { display: flex; }
.icon-btn, .playbar-btn {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.08);
  color: var(--color-fg);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.categories {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
}

.category {
  min-height: 40px;
  padding: 0 16px;
  border: 0;
  border-radius: 10px;
  background: #f5a623;
  color: #1a1203;
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
  font-size: 16px;
  font-weight: 700;
}

.category.is-on {
  background: #ffb020;
  color: #1a1203;
}

.banner-row {
  width: min(100%, 980px);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.banner-row img {
  display: block;
  width: 100%;
  height: 120px;
  object-fit: contain;
  object-position: center;
  border-radius: 12px;
  background: #000;
  color: transparent;
  font-size: 0;
}

.stage {
  position: relative;
  background: var(--color-stage);
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.stage.is-closed { display: none; }

.video-window {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  margin: 0 auto;
  background: #000;
  overflow: hidden;
}

.video-window video, .embed-frame {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: #000;
  border: 0;
}

.buffering, .fail-card, .enable-sound {
  position: absolute;
  z-index: 2;
}

.buffering {
  inset: 0;
  display: grid;
  place-items: center;
}

.buffering span {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(255, 255, 255, 0.25);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.fail-card {
  left: 16px;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  padding: 16px;
  border-radius: 12px;
  background: rgba(12, 12, 14, 0.92);
}

.fail-card p { margin: 8px 0 12px; color: var(--color-muted); }

.fail-card button, .sheet-primary, .sheet-secondary {
  min-height: 44px;
  padding: 0 14px;
  border-radius: var(--radius-pill);
  border: 0;
  font-weight: 700;
}

.fail-card button, .sheet-primary {
  background: var(--color-accent);
  color: var(--color-ink);
}

.enable-sound {
  left: 12px;
  bottom: 12px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--radius-pill);
  background: rgba(0, 0, 0, 0.72);
  color: var(--color-fg);
}

.bottom-playbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: #2a2a2e;
}

.playbar-btn { background: transparent; color: #f5a623; }

.playbar-track {
  flex: 1;
  height: 28px;
  display: flex;
  align-items: center;
  touch-action: none;
}

.playbar-track i {
  display: block;
  width: 100%;
  height: 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.45);
  overflow: hidden;
}

.playbar-fill {
  display: block;
  height: 100%;
  width: 0;
  background: var(--color-accent);
}

.playbar-time {
  color: var(--color-muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.close-player {
  min-height: 36px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--color-muted);
  font-weight: 700;
}

.now-playing h1 { margin: 0; font-size: 20px; line-height: 1.35; }
.now-playing p { margin: 4px 0 0; color: var(--color-muted); font-size: 14px; }

.catalog {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 10px;
}

.catalog button {
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--color-fg);
  text-align: left;
}

.thumb {
  position: relative;
  display: block;
  aspect-ratio: 16 / 9;
  border-radius: 12px;
  overflow: hidden;
  background: #141416;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

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

.thumb svg {
  position: absolute;
  left: 8px;
  bottom: 8px;
  width: 28px;
  height: 28px;
  padding: 6px;
  box-sizing: content-box;
  border-radius: var(--radius-pill);
  background: rgba(0, 0, 0, 0.62);
}

.catalog button.is-on .thumb { border-color: var(--color-accent); }

.card-title {
  display: block;
  margin-top: 8px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.35;
}

.empty-catalog { margin: 12px 0; color: var(--color-muted); }

.pager {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin: 4px 0 8px;
  color: #fff;
  font-size: 15px;
}

.pager button {
  min-height: 36px;
  padding: 0 14px;
  border: 0;
  border-radius: 6px;
  background: #2c2c2c;
  color: #fff;
}

.pager button:disabled { opacity: 0.4; }

.pager-jump { background: #ff8a1e; font-weight: 700; }

.pager-status b { font-weight: 700; }

.pager input {
  width: 64px;
  height: 36px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: #161616;
  color: #fff;
  text-align: center;
  font: inherit;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 40;
  max-width: calc(100vw - 32px);
  padding: 10px 16px;
  border-radius: var(--radius-pill);
  background: rgba(30, 30, 35, 0.95);
  opacity: 0;
  pointer-events: none;
}

.toast.show { opacity: 1; }

.source-sheet {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.source-sheet[hidden] { display: none; }

.source-panel {
  width: min(640px, 100%);
  max-height: min(86dvh, 680px);
  overflow: auto;
  background: var(--color-sheet);
  border-top: 1px solid rgba(245, 166, 35, 0.28);
  padding: 14px 16px calc(16px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.source-head { display: flex; align-items: center; justify-content: space-between; }
.source-head h2 { margin: 0; font-family: var(--font-display); font-size: 18px; }
.source-head button { min-height: 44px; border: 0; background: transparent; color: var(--color-muted); font-weight: 700; }
.source-help { margin: 0; color: var(--color-muted); font-size: 13px; line-height: 1.5; }
.source-help code { color: var(--color-accent); }

.source-panel textarea {
  width: 100%;
  min-height: 180px;
  resize: vertical;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: #0b0b0d;
  color: var(--color-fg);
  font: 13px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  padding: 12px;
}

.source-error { margin: 0; color: #f0a8a8; font-size: 13px; }
.sheet-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.sheet-secondary { background: transparent; color: var(--color-fg); border: 1px solid rgba(255, 255, 255, 0.16); }

@media (max-width: 640px) {
  .site { padding: 10px 12px 32px; gap: 12px; }
  .domain { font-size: 16px; }
  .category { font-size: 16px; padding: 0 2px; }
  .catalog { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 8px; }
  .card-title { font-size: 13px; }
  .banner-row img { height: 72px; }
  .bottom-playbar { flex-wrap: wrap; row-gap: 4px; }
  .playbar-track { flex: 1 1 100%; order: 5; }
  .now-playing h1 { font-size: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  .buffering span { animation: none; }
}