/* ============================================================
   抖一下 · 竖屏视频流
   单人 9:16 竖屏内容 → 手机全屏沉浸 / 电脑居中手机框
   ============================================================ */

:root {
  --dur: .22s;
  --ease: cubic-bezier(.22, .61, .36, 1);
  --phone-w: 430px;
  --radius: 14px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

/* ---- 夜间（默认）---- */
html[data-theme='dark'] {
  --bg: #0b0b0f;
  --bg-soft: #14141b;
  --fg: #f2f2f5;
  --fg-dim: #9a9aa8;
  --line: rgba(255, 255, 255, .1);
  --card: #17171f;
  --card-hi: #1f1f2a;
  --accent: #fe2c55;
  --accent-2: #25f4ee;
  --shadow: 0 10px 40px rgba(0, 0, 0, .55);
  --scrim: linear-gradient(to top, rgba(0, 0, 0, .82) 0%, rgba(0, 0, 0, .45) 38%, rgba(0, 0, 0, 0) 72%);
  --btn-bg: rgba(255, 255, 255, .12);
}

/* ---- 日间 ---- */
html[data-theme='light'] {
  --bg: #f6f7fb;
  --bg-soft: #ffffff;
  --fg: #14141b;
  --fg-dim: #6b6b7b;
  --line: rgba(0, 0, 0, .1);
  --card: #ffffff;
  --card-hi: #f0f1f6;
  --accent: #ff2d55;
  --accent-2: #00b8c4;
  --shadow: 0 10px 30px rgba(20, 20, 40, .12);
  --scrim: linear-gradient(to top, rgba(0, 0, 0, .7) 0%, rgba(0, 0, 0, .35) 40%, rgba(0, 0, 0, 0) 74%);
  --btn-bg: rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* 任何组件设了 display 都会盖掉 [hidden]，这里统一兜底 */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overscroll-behavior: none;
}

body {
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB',
        'Microsoft YaHei', system-ui, sans-serif;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; color: inherit; -webkit-appearance: none; appearance: none; border: 0; background: none; cursor: pointer; }
img { display: block; max-width: 100%; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9em;
       background: var(--card-hi); padding: .1em .35em; border-radius: 5px; }

#app { position: relative; height: 100dvh; height: 100vh; overflow: hidden; }

/* ---------------- 顶栏 ---------------- */
.topbar {
  position: fixed;
  inset: var(--safe-t) 0 auto 0;
  height: 52px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  z-index: 40;
  pointer-events: none;
  background: linear-gradient(to bottom, rgba(0, 0, 0, .42), transparent);
}
html[data-theme='light'] .topbar { background: linear-gradient(to bottom, rgba(255, 255, 255, .65), transparent); }
.topbar > * { pointer-events: auto; }
.logo {
  font-weight: 800;
  letter-spacing: .5px;
  font-size: 17px;
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
  background: var(--btn-bg);
  backdrop-filter: blur(10px);
}
html[data-theme='dark'] .logo { color: #fff; }
.top-actions { margin-left: auto; display: flex; gap: 8px; }

.warn-pill {
  margin-left: auto;
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 4px 14px rgba(254, 44, 85, .35);
}
.warn-pill + .top-actions { margin-left: 8px; }
.hint-list { font-size: 12px; color: var(--fg-dim); line-height: 1.8; padding-left: 1.2em; margin: 6px 0; }

.icon-btn {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--btn-bg);
  backdrop-filter: blur(10px);
  font-size: 16px;
  color: inherit;
  transition: transform var(--dur) var(--ease), background-color var(--dur) var(--ease);
}
html[data-theme='dark'] .icon-btn { color: #fff; }
.icon-btn:active { transform: scale(.9); }

/* ---------------- 视图 ---------------- */
.view {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.view::-webkit-scrollbar { width: 0; }

/* 列表页统一内边距；播放页不加内边距，保持沉浸 */
.view.list-view { padding: calc(64px + var(--safe-t)) 16px calc(76px + var(--safe-b)); }

/* ---------------- 播放器舞台 ---------------- */
.feed-view { overflow: hidden; }

.stage {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: #000;
  touch-action: none;
  will-change: transform;
  transition: transform var(--dur) var(--ease);
}
html[data-theme='light'] .stage { background: #0a0a0c; }

.player, .poster {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;   /* 竖屏源居中完整显示，不裁脸 */
  background: transparent;
  transition: opacity .3s var(--ease);
}

/* 站点参数：自适应填充开关（config.behavior.posterFill） */
html[data-fit='cover'] .player,
html[data-fit='cover'] .poster { object-fit: cover; }
.poster { object-fit: contain; opacity: 0; transition: opacity .25s var(--ease); }
.poster.loaded { opacity: 1; }
.player { opacity: 0; }
.player.ready { opacity: 1; }

.spinner {
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  pointer-events: none;
}
.feed-view.buffering .spinner { display: grid; }
.spinner i {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, .22);
  border-top-color: var(--accent-2);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.fallback {
  position: absolute;
  inset: auto 0 42% 0;
  text-align: center;
  color: #fff;
  font-size: 13px;
  padding: 0 24px;
  opacity: .85;
}

/* 播放/暂停中央提示 */
.feed-view.paused .stage::after {
  content: '▶';
  position: absolute;
  font-size: 26px;
  width: 74px; height: 74px;
  display: grid; place-items: center;
  color: #fff;
  background: rgba(0, 0, 0, .38);
  border-radius: 50%;
  backdrop-filter: blur(4px);
  animation: pop .2s var(--ease);
}
@keyframes pop { from { transform: scale(.7); opacity: 0; } }

/* 进度条 */
.progress {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 2px;
  background: rgba(255, 255, 255, .16);
  pointer-events: none;
}
.progress i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .15s linear; }

/* 元信息 */
.meta {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 56px 76px calc(30px + var(--safe-b)) 16px;
  background: var(--scrim);
  color: #fff;
  text-shadow: 0 1px 8px rgba(0, 0, 0, .4);
  pointer-events: none;
}
.meta .u { font-weight: 700; font-size: 16px; margin-bottom: 4px; }
.meta .t { font-size: 14px; opacity: .95; margin-bottom: 6px; word-break: break-word; }
.meta .d { font-size: 12px; opacity: .78; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.meta .g { background: rgba(255, 255, 255, .16); border-radius: 999px; padding: 1px 8px; }
.meta .path { font-size: 11px; opacity: .42; margin-top: 6px; word-break: break-all;
  max-height: 2.6em; overflow: hidden; }
.meta .path.compact { display: none; }
.stage:hover .meta .path.compact { display: block; }

.badge {
  position: absolute;
  top: calc(58px + var(--safe-t));
  left: 12px;
  padding: 3px 9px;
  font-size: 11px;
  border-radius: 999px;
  background: rgba(0, 0, 0, .45);
  color: #fff;
  backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity var(--dur);
}
.badge.on { opacity: 1; }

/* 右侧操作列 */
.actions {
  position: absolute;
  right: 10px;
  bottom: calc(72px + var(--safe-b));
  display: flex;
  flex-direction: column;
  gap: 14px;
  z-index: 12;
}
.act {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  color: #fff;
  font-size: 20px;
  text-shadow: 0 1px 6px rgba(0, 0, 0, .5);
}
.act em { font-size: 11px; font-style: normal; opacity: .9; }
.act.on { color: var(--accent); }
.act:active { transform: scale(.88); }

/* ---------------- 底栏 ---------------- */
.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: calc(56px + var(--safe-b));
  padding-bottom: var(--safe-b);
  display: flex;
  z-index: 30;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(18px);
  border-top: 1px solid var(--line);
}
.tab {
  flex: 1;
  font-size: 12px;
  color: var(--fg-dim);
  display: grid;
  place-items: center;
  transition: color var(--dur);
}
.tab.on { color: var(--fg); font-weight: 700; }
.tab.on::before { content: ''; position: absolute; }

/* 播放页底栏半透明压在视频上 */
.feed-view ~ .tabbar { background: linear-gradient(to top, rgba(0, 0, 0, .5), transparent); border-top: 0; }
.feed-view ~ .tabbar .tab { color: rgba(255, 255, 255, .7); }
.feed-view ~ .tabbar .tab.on { color: #fff; }

/* ---------------- 搜索条 ---------------- */
.searchbar {
  position: fixed;
  left: 0; right: 0;
  top: calc(56px + var(--safe-t));
  display: flex;
  gap: 8px;
  padding: 8px 16px;
  z-index: 35;
}
.searchbar input {
  flex: 1;
  height: 40px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--fg);
  padding: 0 16px;
  font-size: 14px;
  outline: none;
}
.searchbar input:focus { border-color: var(--accent); }

/* ---------------- 页面 ---------------- */
.page { padding-bottom: 40px; }
.page-title { font-size: 22px; margin: 8px 0 4px; }
.page-sub { color: var(--fg-dim); font-size: 13px; margin: 0 0 16px; }
.sec-title { font-size: 14px; color: var(--fg-dim); margin: 22px 0 10px; font-weight: 600; }

.sec { border-top: 1px solid var(--line); padding: 10px 0; }
.sec summary { cursor: pointer; font-weight: 600; list-style: none; padding: 6px 0; }
.sec summary::-webkit-details-marker { display: none; }
.sec summary::after { content: '▾'; float: right; color: var(--fg-dim); }
.sec[open] summary::after { content: '▴'; }
.sec-body { padding-top: 6px; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 13px; margin: 0; }
.kv dt { color: var(--fg-dim); }
.kv dd { margin: 0; word-break: break-all; }

.row-btns { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.btn {
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--line);
  font-size: 14px;
  transition: transform var(--dur);
}
.btn:active { transform: scale(.96); }
.btn.danger { color: var(--accent); border-color: var(--accent); }

/* ---------------- 主播网格 ---------------- */
.author-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 14px 12px;
}
.author-card { text-align: left; }
.author-card .thumb {
  position: relative;
  aspect-ratio: 3 / 4;
  border-radius: 12px;
  overflow: hidden;
  background: var(--card-hi);
}
.author-card .thumb img { width: 100%; height: 100%; object-fit: cover; }
.author-card .count {
  position: absolute;
  right: 6px; bottom: 6px;
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(0, 0, 0, .55);
  color: #fff;
}
.author-card .name { margin-top: 6px; font-size: 13px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.author-card .sub { font-size: 11px; color: var(--fg-dim); }

/* ---------------- 视频网格 ---------------- */
.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 14px 12px;
}
.video-card { text-align: left; }
.video-card .thumb {
  position: relative;
  aspect-ratio: 3 / 4;
  border-radius: 12px;
  overflow: hidden;
  background: var(--card-hi);
}
.video-card .thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform .3s var(--ease); }
.video-card:hover .thumb img { transform: scale(1.05); }
.video-card .tag {
  position: absolute; left: 6px; top: 6px;
  font-size: 10px; padding: 1px 7px; border-radius: 999px;
  background: rgba(0, 0, 0, .55); color: #fff;
}
.video-card .cap { margin-top: 6px; display: flex; flex-direction: column; }
.video-card .cap .t { font-size: 13px; line-height: 1.35; display: -webkit-box;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.video-card .cap .u { font-size: 11px; color: var(--fg-dim); margin-top: 2px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chip {
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--fg-dim);
}
.chip:active { transform: scale(.95); }

.empty { padding: 40vh 24px 0; text-align: center; color: var(--fg-dim); font-size: 14px; line-height: 1.8; }

/* ---------------- 设置面板 ---------------- */
.sheet-back {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .5);
  backdrop-filter: blur(2px);
  z-index: 60;
  display: grid;
  align-items: end;
  opacity: 0;
  transition: opacity var(--dur) var(--ease);
}
.sheet-back.on { opacity: 1; }
.sheet {
  background: var(--bg-soft);
  border-radius: 18px 18px 0 0;
  max-height: 86dvh;
  display: flex;
  flex-direction: column;
  transform: translateY(16px);
  transition: transform var(--dur) var(--ease);
  box-shadow: var(--shadow);
}
.sheet-back.on .sheet { transform: none; }
.sheet-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.sheet-hd .icon-btn { background: var(--card-hi); width: 32px; height: 32px; font-size: 14px; }
.sheet-bd { padding: 8px 16px calc(24px + var(--safe-b)); overflow-y: auto; }
.sheet-bd h4 { margin: 18px 0 6px; font-size: 13px; color: var(--fg-dim); font-weight: 600; }

.set-line {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.set-line .lb { flex: 0 0 44%; }
.set-line .val { font-size: 12px; color: var(--fg-dim); min-width: 26px; text-align: right; }
.set-line input[type='range'] { flex: 1; accent-color: var(--accent); }
.set-line select {
  flex: 1;
  height: 34px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--fg);
  padding: 0 10px;
}
.set-line input[type='checkbox'] { width: 20px; height: 20px; accent-color: var(--accent); margin-left: auto; }
.hint { font-size: 12px; color: var(--fg-dim); margin-top: 18px; line-height: 1.7; }
.row-btn {
  display: block;
  width: 100%;
  text-align: left;
  padding: 14px 4px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.row-btn:active { color: var(--accent); }

/* ---------------- Toast ---------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(90px + var(--safe-b));
  transform: translate(-50%, 10px);
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(0, 0, 0, .82);
  color: #fff;
  font-size: 13px;
  z-index: 80;
  opacity: 0;
  transition: opacity var(--dur), transform var(--dur);
  pointer-events: none;
  max-width: 80vw;
  text-align: center;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ============================================================
   布局模式：电脑 = 居中手机框 + 侧边留白背景
   手机 = 全屏铺满
   ============================================================ */
html[data-nav='pc'] .feed-view .stage {
  /* 交回给 .phone 容器控制 */
  position: absolute;
}
html[data-nav='pc'] { background:
  radial-gradient(60% 50% at 20% 25%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 70%),
  radial-gradient(55% 45% at 82% 78%, color-mix(in srgb, var(--accent-2) 14%, transparent), transparent 70%),
  var(--bg);
  background-attachment: fixed;
}
html[data-nav='pc'] .view.feed-view {
  display: grid;
  place-items: center;
}
html[data-nav='pc'] .stage {
  position: relative;
  inset: auto;
  width: min(var(--phone-w), calc((100dvh - 32px) * 9 / 16 + 2px));
  height: min(calc(100dvh - 32px), calc(var(--phone-w) * 16 / 9));
  max-height: calc(100dvh - 32px);
  border-radius: 22px;
  overflow: hidden;
  box-shadow: var(--shadow), 0 0 0 1px var(--line);
}
html[data-nav='pc'] .meta { padding-right: 16px; }
html[data-nav='pc'] .actions { right: calc(50% - min(var(--phone-w), calc((100dvh - 32px) * 9 / 16 + 2px)) / 2 + 10px); }
html[data-nav='pc'] .progress { left: auto; right: auto; width: min(var(--phone-w), calc((100dvh - 32px) * 9 / 16 + 2px));
  left: 50%; transform: translateX(-50%); bottom: calc((100dvh - min(calc(100dvh - 32px), calc(var(--phone-w) * 16 / 9))) / 2); }
html[data-nav='pc'] .badge { left: calc(50% - min(var(--phone-w), calc((100dvh - 32px) * 9 / 16 + 2px)) / 2 + 12px); }
html[data-nav='pc'] .tabbar { left: 50%; transform: translateX(-50%); width: min(var(--phone-w), 100%);
  border-radius: 0 0 22px 22px; border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
html[data-nav='pc'] .list-view { max-width: 1000px; margin: 0 auto; }
html[data-nav='pc'] .searchbar { left: 50%; transform: translateX(-50%); width: min(1000px, 100%); }
html[data-nav='pc'] .sheet-back { place-items: center; }
html[data-nav='pc'] .sheet { width: min(520px, 92vw); border-radius: 18px; max-height: 80dvh; }
html[data-nav='pc'] .toast { bottom: 40px; }

/* 手机横屏时缩小留白 */
@media (max-height: 480px) and (orientation: landscape) {
  html[data-nav='auto'] .stage { width: auto; }
  .meta { padding-bottom: calc(16px + var(--safe-b)); padding-top: 36px; }
  .actions { flex-direction: row; right: auto; left: 12px; bottom: calc(60px + var(--safe-b)); }
}

/* 列表页在手机上更紧凑 */
@media (max-width: 420px) {
  .author-grid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 12px 10px; }
  .video-grid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
