:root {
  --bg: #0f0f0f;
  --surface: #212121;
  --surface-2: #272727;
  --surface-3: #383838;
  --ink: #f1f1f1;
  --muted: #aaaaaa;
  --red: #ff0033;
  --line: #303030;
  --mast-h: 56px;
  --side-w: 240px;
  --rail-w: 72px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

svg {
  width: 24px;
  height: 24px;
  display: block;
}

/* keep the hidden attribute working for icon swaps */
[hidden] {
  display: none !important;
}

/* ===================== MASTHEAD ===================== */
.masthead {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--mast-h);
  z-index: 50;
  background: var(--bg);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.5rem;
  padding: 0 1rem;
  padding-top: env(safe-area-inset-top, 0px);
  height: calc(var(--mast-h) + env(safe-area-inset-top, 0px));
  box-sizing: border-box;
}

.mast-left,
.mast-right {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.icon-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
}

.icon-btn:hover {
  background: var(--surface-2);
}

.logo {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0 0.5rem;
  cursor: pointer;
}

.logo-mark svg {
  width: 28px;
  height: 20px;
}

.logo-text {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: #fff;
}

.logo-text::first-letter {
  color: var(--red);
}

.mast-center {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
}

/* mobile-only affordances */
.search-back,
.m-search {
  display: none;
}

.search-wrap {
  display: flex;
  width: 100%;
  max-width: 560px;
  height: 40px;
}

.search-input {
  flex: 1;
  min-width: 0;
  background: #121212;
  border: 1px solid var(--line);
  border-right: 0;
  border-radius: 20px 0 0 20px;
  color: var(--ink);
  font: inherit;
  font-size: 0.95rem;
  padding: 0 1rem;
}

.search-input::placeholder {
  color: #888;
}

.search-input:focus {
  outline: none;
  border-color: #3ea6ff;
}

.search-input::-webkit-search-cancel-button {
  filter: invert(1);
}

.search-btn {
  appearance: none;
  width: 64px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink);
  border-radius: 0 20px 20px 0;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.search-btn:hover {
  background: var(--surface-3);
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ff0033, #7a1fa2);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 0.85rem;
  font-weight: 700;
  margin-left: 0.35rem;
  flex-shrink: 0;
  appearance: none;
  border: 0;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
}

.avatar:hover {
  filter: brightness(1.1);
}

.mast-right {
  position: relative;
}

.account-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 200px;
  background: #212121;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.75rem;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  z-index: 60;
}

.account-name {
  margin: 0;
  font-weight: 600;
  font-size: 0.95rem;
}

.account-email {
  margin: 0.15rem 0 0.65rem;
  color: var(--muted);
  font-size: 0.78rem;
  word-break: break-all;
}

.account-item {
  appearance: none;
  width: 100%;
  border: 0;
  background: var(--surface-2);
  color: var(--ink);
  border-radius: 8px;
  padding: 0.55rem 0.75rem;
  font: inherit;
  font-size: 0.88rem;
  cursor: pointer;
  text-align: left;
  display: block;
  text-decoration: none;
  box-sizing: border-box;
  margin-top: 0.35rem;
}

.account-item:hover {
  background: #3a3a3a;
}

.auth-modal {
  max-width: 400px;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem;
  margin-bottom: 1rem;
}

.auth-tab {
  appearance: none;
  border: 0;
  background: var(--surface-2);
  color: var(--muted);
  border-radius: 999px;
  padding: 0.45rem 0.75rem;
  font: inherit;
  font-size: 0.88rem;
  cursor: pointer;
}

.auth-tab.active {
  background: #fff;
  color: #111;
  font-weight: 600;
}

.auth-form {
  display: grid;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.auth-field {
  display: grid;
  gap: 0.35rem;
  font-size: 0.82rem;
  color: var(--muted);
  text-align: left;
}

.auth-field input {
  appearance: none;
  border: 1px solid var(--line);
  background: #121212;
  color: var(--ink);
  border-radius: 10px;
  padding: 0.7rem 0.85rem;
  font: inherit;
  font-size: 16px;
}

.auth-field input:focus {
  outline: 2px solid rgba(255, 0, 51, 0.45);
  border-color: var(--red);
}

.auth-error {
  margin: 0;
  color: #ff6b81;
  font-size: 0.85rem;
  text-align: left;
}

.pill.active {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
}

.pwa-banner {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 70;
  padding: 0.65rem 0.75rem calc(0.65rem + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.85) 30%);
  pointer-events: none;
}

.pwa-banner-inner {
  pointer-events: auto;
  display: grid;
  grid-template-columns: 40px 1fr auto auto;
  gap: 0.65rem;
  align-items: center;
  max-width: 560px;
  margin: 0 auto;
  background: #1c1c1c;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.65rem 0.75rem;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.pwa-icon {
  border-radius: 10px;
}

.pwa-text {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.35;
  color: var(--ink);
}

.pwa-btn {
  appearance: none;
  border: 0;
  background: var(--red);
  color: #fff;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  border-radius: 999px;
  padding: 0.45rem 0.85rem;
  cursor: pointer;
  white-space: nowrap;
}

.pwa-x {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.15rem 0.35rem;
}

@media (min-width: 801px) {
  .pwa-banner {
    display: none;
  }
}

/* ===================== SHELL ===================== */
.app {
  padding-top: calc(var(--mast-h) + env(safe-area-inset-top, 0px));
  display: flex;
}

/* ===================== SIDEBAR ===================== */
.sidebar {
  position: fixed;
  top: calc(var(--mast-h) + env(safe-area-inset-top, 0px));
  bottom: 0;
  left: 0;
  width: var(--side-w);
  overflow-y: auto;
  padding: 0.75rem 0.75rem 2rem;
  background: var(--bg);
  z-index: 40;
  scrollbar-width: thin;
}

.sidebar::-webkit-scrollbar {
  width: 8px;
}

.sidebar::-webkit-scrollbar-thumb {
  background: #565656;
  border-radius: 99px;
}

.side-section {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.side-heading {
  margin: 0.5rem 0 0.35rem;
  padding: 0 0.75rem;
  font-size: 1rem;
  font-weight: 500;
  color: var(--ink);
}

.side-link {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  width: 100%;
  padding: 0.55rem 0.75rem;
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
}

.side-link:hover {
  background: var(--surface-2);
}

.side-link.active {
  background: var(--surface-3);
  font-weight: 500;
}

.side-link span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.side-link .dot {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--surface-3);
  display: grid;
  place-items: center;
  font-size: 0.7rem;
  font-weight: 700;
  flex-shrink: 0;
}

.side-divider {
  height: 1px;
  background: var(--line);
  margin: 0.75rem 0.5rem;
}

.side-foot {
  margin: 0;
  padding: 0 0.75rem;
  font-size: 0.75rem;
  color: #717171;
}

.side-foot a {
  color: #909090;
}

.scrim {
  position: fixed;
  inset: calc(var(--mast-h) + env(safe-area-inset-top, 0px)) 0 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 39;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

body.drawer .scrim {
  opacity: 1;
  pointer-events: auto;
}

/* ===================== CONTENT ===================== */
.content {
  flex: 1;
  min-width: 0;
  margin-left: var(--side-w);
  padding: 1rem 1.5rem 3rem;
}

/* chips */
.chips {
  display: flex;
  gap: 0.65rem;
  overflow-x: auto;
  padding-bottom: 0.85rem;
  scrollbar-width: none;
}

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

.chip {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.5rem 0.85rem;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  flex: 0 0 auto;
}

.chip:hover {
  background: var(--surface-3);
}

.chip.active {
  background: var(--ink);
  color: #0f0f0f;
  border-color: var(--ink);
}

.grid-head {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  margin: 0.35rem 0 1rem;
}

.grid-head h2 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
}

.count {
  font-size: 0.8rem;
  color: var(--muted);
}

/* video grid */
.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.5rem 1rem;
}

.card {
  appearance: none;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: 12px;
  overflow: hidden;
  background: #181818;
  display: grid;
  place-items: center;
}

.thumb img {
  max-width: 72%;
  max-height: 72%;
  object-fit: contain;
}

.thumb-letter {
  font-size: 2.6rem;
  font-weight: 700;
  color: #4d4d4d;
}

.card:hover .thumb {
  border-radius: 4px;
}

.thumb.previewing img,
.thumb.previewing .thumb-letter,
.thumb.preview-loading img,
.thumb.preview-loading .thumb-letter {
  opacity: 0.25;
}

.thumb.previewing img,
.thumb.previewing .thumb-letter {
  opacity: 0;
}

.thumb-preview {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
  z-index: 1;
  pointer-events: none;
}

.thumb.preview-loading::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 28px;
  height: 28px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: preview-spin 0.55s linear infinite;
  z-index: 2;
}

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

.thumb.previewing .live-tag,
.thumb.preview-loading .live-tag {
  z-index: 3;
}

.thumb .live-tag {
  position: absolute;
  right: 6px;
  bottom: 6px;
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 4px;
  letter-spacing: 0.02em;
}

.thumb .live-tag.on {
  background: var(--red);
}

.card-row {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 0.75rem;
}

.card-av {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--surface-3);
  display: grid;
  place-items: center;
  font-size: 0.9rem;
  font-weight: 700;
  overflow: hidden;
}

.card-av img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.card-text {
  min-width: 0;
}

.card-title {
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-sub {
  margin-top: 0.2rem;
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card.active .card-title {
  color: var(--red);
}

.empty {
  color: var(--muted);
  font-size: 0.95rem;
  padding: 2rem 0;
}

.note {
  margin: 0 0 1rem;
  padding: 0.75rem 0.9rem;
  background: var(--surface-2);
  border-left: 3px solid var(--red);
  border-radius: 0 8px 8px 0;
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--muted);
}

.note strong {
  color: var(--ink);
}

/* ===================== VIEW SWITCHING ===================== */
body.mode-watch #home-view {
  display: none;
}

/* Home with nothing playing: watch view fully hidden */
body.mode-home:not(.miniplayer) #watch-view {
  display: none;
}

/* Home with a stream playing: keep only the (mini) player alive */
body.mode-home.miniplayer #watch-view .watch-layout {
  display: block;
}

body.mode-home.miniplayer #watch-view .watch-title,
body.mode-home.miniplayer #watch-view .watch-meta,
body.mode-home.miniplayer #watch-view .desc,
body.mode-home.miniplayer #watch-view .watch-side {
  display: none;
}

/* ===================== WATCH ===================== */
.watch-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 1.5rem;
  max-width: 1600px;
}

.player {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
}

.player video {
  width: 100%;
  height: 100%;
  display: block;
  background: #000;
}

/* ---------- custom player controls ---------- */
.big-play {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  appearance: none;
  border: 0;
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  z-index: 3;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.big-play svg {
  width: 34px;
  height: 34px;
  margin-left: 3px;
}

.player.paused .big-play {
  opacity: 1;
  pointer-events: auto;
}

.big-play:hover {
  background: var(--red);
}

.spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 44px;
  height: 44px;
  margin: -22px 0 0 -22px;
  border: 3px solid rgba(255, 255, 255, 0.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  z-index: 3;
  pointer-events: none;
}

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

.ctrls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 4;
  padding: 2.2rem 0.75rem 0.4rem;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.75));
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  pointer-events: none;
}

.player.show-ctrls .ctrls,
.player.paused .ctrls {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

.ctrls-bar {
  padding: 0 0.15rem 0.35rem;
}

.progress {
  position: relative;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.3);
  cursor: default;
  transition: height 0.12s ease;
}

.player.show-ctrls .progress:hover {
  height: 6px;
}

.progress-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 100%;
  border-radius: 2px;
  background: var(--red);
}

.progress-fill::after {
  content: "";
  position: absolute;
  right: -5px;
  top: 50%;
  width: 12px;
  height: 12px;
  margin-top: -6px;
  border-radius: 50%;
  background: var(--red);
}

.ctrls-row {
  display: flex;
  align-items: center;
  gap: 0.15rem;
}

.ctrls-spacer {
  flex: 1;
}

.cbtn {
  appearance: none;
  border: 0;
  padding: 0;
  background: transparent;
  color: #fff;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.cbtn svg {
  width: 22px;
  height: 22px;
}

.cbtn:hover {
  background: rgba(255, 255, 255, 0.15);
}

.vol-wrap {
  display: flex;
  align-items: center;
}

.vol {
  appearance: none;
  width: 0;
  opacity: 0;
  height: 4px;
  margin: 0;
  background: rgba(255, 255, 255, 0.35);
  border-radius: 2px;
  cursor: pointer;
  transition: width 0.18s ease, opacity 0.18s ease;
}

.vol-wrap:hover .vol,
.vol:focus-visible {
  width: 72px;
  opacity: 1;
  margin-right: 0.5rem;
}

.vol::-webkit-slider-thumb {
  appearance: none;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #fff;
}

.vol::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border: 0;
  border-radius: 50%;
  background: #fff;
}

.live-dot {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  font-weight: 500;
  color: #fff;
  padding: 0 0.5rem;
  white-space: nowrap;
}

.live-dot i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--red);
}

.menu-wrap {
  position: relative;
}

.menu {
  position: absolute;
  right: 0;
  bottom: 46px;
  min-width: 150px;
  max-height: 220px;
  overflow-y: auto;
  background: rgba(28, 28, 28, 0.96);
  border-radius: 10px;
  padding: 0.4rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
}

.menu-head {
  margin: 0.2rem 0.5rem 0.35rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.menu-item {
  appearance: none;
  border: 0;
  background: transparent;
  color: #fff;
  font: inherit;
  font-size: 0.85rem;
  width: 100%;
  text-align: left;
  padding: 0.5rem 0.6rem;
  border-radius: 6px;
  cursor: pointer;
}

.menu-item:hover {
  background: rgba(255, 255, 255, 0.15);
}

.menu-item.active {
  color: var(--red);
  font-weight: 500;
}

.player-msg {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 0.75rem;
  text-align: center;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.75);
  font-size: 0.95rem;
  color: var(--ink);
  pointer-events: none;
  z-index: 3;
}

.msg-text {
  margin: 0;
  max-width: 34ch;
  line-height: 1.4;
}

.msg-btn {
  appearance: none;
  border: 0;
  background: var(--red);
  color: #fff;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.55rem 1.1rem;
  border-radius: 999px;
  cursor: pointer;
  pointer-events: auto;
  max-width: 90%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.msg-btn:hover {
  filter: brightness(1.12);
}

body.miniplayer .msg-btn {
  display: none;
}

/* ===================== MINI PLAYER ===================== */
.mini-bar {
  display: none;
}

body.miniplayer .player {
  position: fixed;
  right: 16px;
  bottom: 16px;
  width: 360px;
  max-width: calc(100vw - 32px);
  z-index: 60;
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.65);
  border: 1px solid var(--line);
  animation: mini-in 0.18s ease;
}

body.miniplayer .player-msg {
  font-size: 0.78rem;
  padding: 0.5rem;
  line-height: 1.35;
}

/* mini player: compact controls only */
body.miniplayer .ctrls {
  padding: 1.4rem 0.4rem 0.3rem;
}

body.miniplayer .ctrls-bar,
body.miniplayer .vol-wrap,
body.miniplayer .menu-wrap,
body.miniplayer #c-pip {
  display: none;
}

body.miniplayer .cbtn {
  width: 32px;
  height: 32px;
}

body.miniplayer .cbtn svg {
  width: 18px;
  height: 18px;
}

body.miniplayer .big-play svg {
  width: 24px;
  height: 24px;
}

body.miniplayer .big-play {
  width: 48px;
  height: 48px;
}

body.miniplayer .mini-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.35rem 0.4rem 0.35rem 0.5rem;
  background: linear-gradient(rgba(0, 0, 0, 0.85), rgba(0, 0, 0, 0));
  opacity: 0;
  transition: opacity 0.15s ease;
  z-index: 2;
}

body.miniplayer .player:hover .mini-bar,
body.miniplayer .player:focus-within .mini-bar {
  opacity: 1;
}

.mini-bar-title {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  flex: 1;
  min-width: 0;
  padding: 0.15rem 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mini-btn {
  appearance: none;
  border: 0;
  background: rgba(0, 0, 0, 0.5);
  color: var(--ink);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
}

.mini-btn svg {
  width: 16px;
  height: 16px;
}

.mini-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

@keyframes mini-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.watch-title {
  margin: 1rem 0 0.75rem;
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.3;
}

.watch-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem;
}

.owner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.owner-av {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--surface-3);
  display: grid;
  place-items: center;
  font-weight: 700;
  overflow: hidden;
  flex-shrink: 0;
}

.owner-av img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.owner-name {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 500;
}

.owner-sub {
  margin: 0.1rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.pill {
  appearance: none;
  border: 0;
  background: var(--surface-2);
  color: var(--ink);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 0.9rem;
  border-radius: 999px;
  cursor: pointer;
}

.pill svg {
  width: 20px;
  height: 20px;
}

.pill:hover {
  background: var(--surface-3);
}

.desc {
  margin-top: 1rem;
  background: var(--surface-2);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--ink);
}

.desc .desc-meta {
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 0.35rem;
  word-break: break-all;
}

.watch-side .side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
}

.watch-side h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}

.text-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: #3ea6ff;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  padding: 0.25rem;
}

.up-next {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  max-height: calc(100vh - 220px);
  overflow-y: auto;
  padding-right: 2px;
}

.up-next::-webkit-scrollbar {
  width: 8px;
}

.up-next::-webkit-scrollbar-thumb {
  background: #565656;
  border-radius: 99px;
}

.mini {
  appearance: none;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  display: grid;
  grid-template-columns: 168px 1fr;
  gap: 0.65rem;
  text-align: left;
  cursor: pointer;
  border-radius: 10px;
}

.mini:hover {
  background: var(--surface-2);
}

.mini .thumb {
  border-radius: 8px;
}

.mini-title {
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.mini-sub {
  margin-top: 0.25rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.mini.active .mini-title {
  color: var(--red);
}

/* ===================== 18+ GATE ===================== */
.modal-wrap {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 1.25rem;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(2px);
}

.modal {
  width: min(420px, 100%);
  background: #212121;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1.5rem;
  text-align: center;
  animation: modal-in 0.16s ease;
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.modal-badge {
  display: inline-grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--red);
  color: #fff;
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 0.85rem;
}

.modal-title {
  margin: 0 0 0.5rem;
  font-size: 1.2rem;
  font-weight: 700;
}

.modal-text {
  margin: 0 0 1.35rem;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--muted);
}

.modal-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  flex-wrap: wrap;
}

.modal-btn {
  appearance: none;
  border: 0;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.65rem 1.1rem;
  border-radius: 999px;
  cursor: pointer;
}

.modal-btn.ghost {
  background: var(--surface-3);
  color: var(--ink);
}

.modal-btn.danger {
  background: var(--red);
  color: #fff;
}

.modal-btn:hover {
  filter: brightness(1.12);
}

/* 18+ badge next to the section heading */
.adult-tag {
  display: none;
  background: var(--red);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  vertical-align: middle;
  margin-left: 0.4rem;
}

body.adult .adult-tag {
  display: inline-block;
}

body.adult .side-link[data-nav="adult"] {
  color: var(--red);
}

/* ===================== MOBILE NAV ===================== */
.mobile-nav {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 45;
  background: #0f0f0f;
  border-top: 1px solid var(--line);
  grid-template-columns: repeat(4, 1fr);
  padding: 0.35rem 0 calc(0.45rem + env(safe-area-inset-bottom, 0px));
}

.m-item {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.65rem;
  display: grid;
  justify-items: center;
  gap: 2px;
  cursor: pointer;
  padding: 0.25rem 0;
}

.m-item svg {
  width: 22px;
  height: 22px;
}

.m-item.active {
  color: var(--ink);
}

/* ===================== RESPONSIVE ===================== */

/* Tablet: collapse sidebar to icon rail */
@media (max-width: 1100px) {
  .sidebar {
    width: var(--rail-w);
    padding: 0.75rem 0.35rem 2rem;
    align-items: center;
  }

  .sidebar .side-heading,
  .sidebar .side-foot,
  .side-link span {
    display: none;
  }

  .side-link {
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.85rem 0;
    justify-content: center;
  }

  .content {
    margin-left: var(--rail-w);
    padding: 1rem 1rem 3rem;
  }

  .watch-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .up-next {
    max-height: none;
  }

  .mini {
    grid-template-columns: 200px 1fr;
  }
}

/* Mobile: drawer sidebar + bottom nav */
@media (max-width: 800px) {
  :root {
    --mast-h: 48px;
  }

  /* --- YouTube-style mobile masthead: menu+logo left, search+avatar right --- */
  .masthead {
    position: fixed;
    padding: 0 0.5rem 0 0.25rem;
    padding-top: env(safe-area-inset-top, 0px);
    gap: 0;
    /* no empty center column when search is collapsed */
    grid-template-columns: minmax(0, 1fr) auto;
    height: calc(var(--mast-h) + env(safe-area-inset-top, 0px));
  }

  .mast-left {
    min-width: 0;
    gap: 0;
  }

  .mast-right {
    gap: 0;
    justify-content: flex-end;
  }

  .icon-btn {
    width: 40px;
    height: 40px;
  }

  .icon-btn svg {
    width: 22px;
    height: 22px;
  }

  .logo {
    padding: 0 0.15rem 0 0;
    gap: 0.3rem;
    min-width: 0;
  }

  .logo-mark {
    flex-shrink: 0;
  }

  .logo-mark svg {
    width: 26px;
    height: 18px;
    display: block;
  }

  .logo-text {
    font-size: 1.1rem;
    line-height: 1;
    white-space: nowrap;
  }

  /* search collapses to an icon; the field opens over the masthead */
  .mast-center {
    display: none;
  }

  .m-search {
    display: grid;
  }

  .mast-right #btn-reload,
  .mast-right #btn-fs {
    display: none;
  }

  .avatar {
    width: 28px;
    height: 28px;
    margin-left: 0.15rem;
    font-size: 0.8rem;
  }

  body.searching .masthead {
    grid-template-columns: 1fr;
  }

  body.searching .mast-left,
  body.searching .mast-right {
    display: none;
  }

  body.searching .mast-center {
    display: flex;
    width: 100%;
    gap: 0.15rem;
    min-width: 0;
    padding: 0 0.15rem;
  }

  body.searching .search-back {
    display: grid;
    flex-shrink: 0;
  }

  .search-wrap {
    max-width: none;
    height: 36px;
    flex: 1;
    min-width: 0;
  }

  .search-input {
    font-size: 16px; /* prevents iOS zoom on focus */
    padding: 0 0.75rem;
    border-radius: 18px 0 0 18px;
  }

  .search-btn {
    width: 44px;
    border-radius: 0 18px 18px 0;
  }

  .sidebar {
    width: 260px;
    padding: 0.75rem;
    align-items: stretch;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.6);
  }

  body.drawer .sidebar {
    transform: none;
  }

  body.drawer {
    overflow: hidden;
  }

  .sidebar .side-heading,
  .sidebar .side-foot,
  .side-link span {
    display: block;
  }

  .side-link {
    flex-direction: row;
    gap: 1.25rem;
    padding: 0.6rem 0.75rem;
    justify-content: flex-start;
  }

  .content {
    margin-left: 0;
    padding: 0 0.85rem 5rem;
  }

  /* chips stay pinned under the masthead, like the YouTube app */
  .chips {
    position: sticky;
    top: 0;
    z-index: 20;
    background: var(--bg);
    padding: 0.6rem 0.85rem;
    margin: 0 -0.85rem 0.35rem;
    gap: 0.5rem;
    box-shadow: 0 1px 0 var(--line);
  }

  .chip {
    font-size: 0.82rem;
    padding: 0.45rem 0.75rem;
  }

  .grid-head {
    margin: 0.5rem 0 0.75rem;
  }

  .grid-head h2 {
    font-size: 1rem;
  }

  .video-grid {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }

  .card {
    gap: 0.5rem;
  }

  .thumb,
  .card:hover .thumb {
    border-radius: 10px;
  }

  .mobile-nav {
    display: grid;
  }

  .pwa-banner {
    bottom: calc(56px + env(safe-area-inset-bottom, 0px));
    padding-bottom: 0.65rem;
  }

  .watch-title {
    font-size: 1.05rem;
  }

  .player {
    border-radius: 0;
    margin: 0 -0.85rem;
  }

  .watch-layout {
    padding-top: 0;
  }

  .watch-meta {
    align-items: flex-start;
  }

  .desc {
    font-size: 0.85rem;
  }

  .watch-side .side-head {
    margin-top: 0.5rem;
  }

  body.miniplayer .player {
    width: 280px;
    right: 8px;
    bottom: 68px;
    margin: 0;
    border-radius: 10px;
  }

  /* touch-friendly controls */
  .cbtn {
    width: 42px;
    height: 42px;
  }

  .cbtn svg {
    width: 24px;
    height: 24px;
  }

  .ctrls {
    padding: 2rem 0.4rem 0.5rem;
  }

  /* volume slider is not useful on touch — device volume rules */
  .vol {
    display: none;
  }

  #c-pip {
    display: none;
  }

  .live-dot {
    font-size: 0.72rem;
    padding: 0 0.35rem;
  }

  body.miniplayer .mini-bar {
    opacity: 1;
  }

  .actions {
    width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
    scrollbar-width: none;
  }

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

  .mini {
    grid-template-columns: 160px 1fr;
  }
}

@media (max-width: 480px) {
  .mini {
    grid-template-columns: 130px 1fr;
    gap: 0.5rem;
  }

  .mini-title {
    font-size: 0.8rem;
  }
}
