:root {
  --bg: #0b0b0f;
  --card: #16161d;
  --text: #f5f6f8;
  --sub: #9aa0a6;
  --pink: #fb7299;
  --line: #2a2a33;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "PingFang SC", "HarmonyOS Sans SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
}
html { -webkit-text-size-adjust: 100%; }
body {
  padding-bottom: calc(76px + var(--safe-bottom));
  overscroll-behavior-y: contain;
}
.top {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: calc(12px + var(--safe-top)) 16px 8px;
  background: linear-gradient(180deg, #0b0b0f 70%, rgba(11,11,15,0.6));
}
.brand h1 { margin: 0; font-size: 20px; letter-spacing: 0.02em; }
.brand p { margin: 6px 0 0; color: var(--sub); font-size: 12px; line-height: 1.4; }
.ghost, .tab {
  border: 0;
  color: var(--text);
  background: #22222b;
  border-radius: 999px;
  min-height: 44px;
  padding: 0 14px;
  font-size: 13px;
}
.tabs {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 8px 16px calc(10px + var(--safe-bottom));
  background: linear-gradient(0deg, #0b0b0f 80%, rgba(11,11,15,0.55));
  max-width: 980px;
  margin: 0 auto;
}
.tab { min-height: 46px; font-size: 16px; font-weight: 600; }
.tab.on { background: var(--pink); color: #fff; }
.feed {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  padding: 4px 16px 24px;
}
.feed[data-mode="all"] { grid-template-columns: 1fr; }
.card {
  display: block;
  color: inherit;
  text-decoration: none;
  background: var(--card);
  border-radius: 14px;
  overflow: hidden;
}
.cover {
  position: relative;
  background: #111;
  overflow: hidden;
}
.feed[data-mode="all"] .cover { aspect-ratio: 16 / 10; }
.feed[data-mode="vertical"] .cover { aspect-ratio: 9 / 16; max-height: 68vh; }
.cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.badge, .dur {
  position: absolute;
  bottom: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  background: rgba(0,0,0,.62);
}
.badge { left: 8px; background: var(--pink); max-width: 70%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dur { right: 8px; }
.info { padding: 10px 12px 12px; }
.title {
  margin: 0 0 6px;
  font-size: 15px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.sub { color: var(--sub); font-size: 12px; }
.status {
  text-align: center;
  color: var(--sub);
  font-size: 13px;
  padding: 8px 16px 20px;
}
.empty { padding: 48px 20px; text-align: center; color: var(--sub); }
.stage { display: none; }
.player-wrap iframe { display: none; width: 100%; height: 100%; border: 0; background: #000; }
.player-wrap.has-video iframe { display: block; }
.player-wrap.has-video .player-empty { display: none; }
.card.playing { outline: 2px solid var(--pink); outline-offset: -2px; }
.queue { list-style: none; margin: 0; padding: 0 12px 16px; }
.queue li {
  display: grid;
  grid-template-columns: 28px 86px 1fr;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border-radius: 10px;
  cursor: pointer;
  color: var(--text);
}
.queue li:hover, .queue li.on { background: #22222b; }
.queue li.on { outline: 1px solid var(--pink); }
.queue .idx { color: var(--sub); font-size: 12px; text-align: center; }
.queue img { width: 86px; height: 54px; object-fit: cover; border-radius: 8px; background: #111; }
.queue .qt { font-size: 13px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.now { padding: 12px 16px 8px; }
.now h2 { margin: 0 0 6px; font-size: 16px; line-height: 1.35; }
.now p { margin: 0 0 10px; color: var(--sub); font-size: 12px; }
.player-bar { display: flex; flex-wrap: wrap; gap: 8px; }
.player-bar .on { background: var(--pink); color: #fff; }
.player-bar .link { display: inline-flex; align-items: center; text-decoration: none; }
.player-empty {
  min-height: 220px;
  display: grid;
  place-items: center;
  color: var(--sub);
  font-size: 14px;
  padding: 24px;
  text-align: center;
}
@media (min-width: 720px) and (max-width: 959px) {
  .feed[data-mode="all"] { grid-template-columns: 1fr 1fr; }
  .feed[data-mode="vertical"] { grid-template-columns: 1fr 1fr 1fr; }
  #app { max-width: 980px; margin: 0 auto; }
}
.reels, .tk-chrome { display: none; }
body.tiktok {
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: #000;
}
body.tiktok #app { display: none; }
body.tiktok .reels {
  display: flex;
  flex-direction: row;
  height: 100dvh;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  overscroll-behavior-x: contain;
  background: #000;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x;
}
body.tiktok .tk-chrome {
  display: flex;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 40;
  align-items: center;
  gap: 8px;
  padding: calc(10px + var(--safe-top)) 12px 8px;
  pointer-events: none;
}
body.tiktok .tk-chrome .tabs,
body.tiktok .tk-chrome .ghost { pointer-events: auto; }
body.tiktok .tk-chrome .tabs {
  position: static;
  flex: 1;
  min-width: 0;
  padding: 0;
  background: transparent;
  max-width: none;
}
body.tiktok .tk-chrome .tab {
  min-height: 36px;
  font-size: 14px;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(10px);
}
body.tiktok .tk-chrome .tab.on { background: var(--pink); color: #fff; }
.reel {
  position: relative;
  flex: 0 0 100vw;
  width: 100vw;
  height: 100dvh;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  background: #000;
  overflow: hidden;
}
.reel-zoom {
  position: absolute;
  inset: 0;
  transform-origin: center center;
  will-change: transform;
}
.reel video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}
.reel.portrait video { object-fit: cover; }
.reel .poster {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 1;
}
.reel.ready .poster { opacity: 0; pointer-events: none; transition: opacity .25s; }
.reel-ui {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  pointer-events: none;
  background: linear-gradient(180deg, transparent 55%, rgba(0,0,0,.62) 100%);
}
.reel-bottom { pointer-events: auto; }
.reel-bottom {
  padding: 0 16px calc(18px + var(--safe-bottom));
}
.reel-bottom h2 {
  margin: 0 0 6px;
  font-size: 16px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.reel-bottom p { margin: 0 0 10px; color: #ddd; font-size: 13px; }
.progress {
  width: 100%;
  height: 18px;
  margin: 0;
  accent-color: var(--pink);
}
.progress.late { opacity: 0; pointer-events: none; }
.heart {
  position: absolute;
  left: 50%;
  top: 46%;
  transform: translate(-50%, -50%) scale(.4);
  font-size: 86px;
  color: var(--pink);
  opacity: 0;
  pointer-events: none;
  z-index: 6;
  text-shadow: 0 8px 24px rgba(0,0,0,.35);
}
.heart.pop { animation: heartpop .7s ease forwards; }
@keyframes heartpop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.3); }
  25% { opacity: 1; transform: translate(-50%, -50%) scale(1.15); }
  100% { opacity: 0; transform: translate(-50%, -80%) scale(1.4); }
}
.fast-mark {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 5;
  background: rgba(0,0,0,.45);
  color: #fff;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 13px;
  display: none;
}
.reel.fast .fast-mark { display: block; }
.side-actions {
  position: absolute;
  right: 12px;
  bottom: calc(108px + var(--safe-bottom));
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: auto;
}
.side-actions button, .side-actions a {
  min-height: 44px;
  min-width: 44px;
  border-radius: 50%;
  background: rgba(0,0,0,.45);
  color: #fff;
  border: 0;
  font-size: 12px;
  text-decoration: none;
  display: grid;
  place-items: center;
}
.tk-list {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 50;
  background: #0b0b0f;
  overflow: auto;
  padding: calc(12px + var(--safe-top)) 12px calc(20px + var(--safe-bottom));
}
body.tk-list-on .tk-list { display: block; }
body.tk-list-on .reels { visibility: hidden; }
.tk-list header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.tk-list header p { margin: 0; color: var(--sub); font-size: 13px; }
.tk-list .feed { grid-template-columns: 1fr 1fr; gap: 10px; padding: 0; }
.tk-list .cover { aspect-ratio: 9 / 16; }
.pause-mark {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: rgba(0,0,0,.45);
  color: #fff;
  display: none;
  place-items: center;
  font-size: 28px;
  z-index: 4;
  pointer-events: none;
}
.reel.paused .pause-mark { display: grid; }
.unmute {
  position: absolute;
  right: 14px;
  bottom: calc(96px + var(--safe-bottom));
  z-index: 4;
  pointer-events: auto;
  min-height: 40px;
}
@media (min-width: 960px) {
  html, body { height: 100%; }
  body { padding-bottom: 0; overflow: hidden; }
  #app {
    max-width: none;
    margin: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    height: 100vh;
    min-height: 0;
  }
  .list-pane {
    min-width: 0;
    min-height: 0;
    height: 100%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--line);
  }
  .list-pane .top {
    position: static;
    flex: 0 0 auto;
  }
  .tabs {
    position: static;
    bottom: auto;
    left: auto;
    right: auto;
    max-width: none;
    width: 100%;
    padding: 0 16px 10px;
    background: var(--bg);
    flex: 0 0 auto;
    align-self: stretch;
  }
  .list-pane .feed {
    flex: 1 1 auto;
    overflow: auto;
    min-height: 0;
  }
  .list-pane .status { flex: 0 0 auto; }
  .feed { grid-template-columns: 1fr; padding-bottom: 32px; }
  .feed[data-mode="all"], .feed[data-mode="vertical"] { grid-template-columns: 1fr; }
  .feed .card {
    display: grid;
    grid-template-columns: 168px 1fr;
    gap: 0;
  }
  .feed[data-mode="all"] .cover,
  .feed[data-mode="vertical"] .cover {
    aspect-ratio: 16 / 10;
    max-height: none;
    min-height: 94px;
  }
  .stage {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    height: 100%;
    overflow: auto;
    background: #0e0e14;
  }
  .stage[hidden] { display: flex; }
  .player-wrap {
    position: relative;
    background: #000;
    aspect-ratio: 16 / 9;
    flex: 0 0 auto;
  }
  .player-wrap.portrait {
    aspect-ratio: 9 / 16;
    max-height: min(72vh, calc(100vh - 240px));
    width: min(100%, calc((100vh - 240px) * 9 / 16));
    margin: 0 auto;
  }
  .player-wrap iframe {
    position: absolute;
    inset: 0;
  }
  .player-empty { min-height: 100%; }
}
