:root {
  --bg: #0a0a0b;
  --surface: #131315;
  --surface-2: #1a1a1d;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.16);
  --text: #f4f4f5;
  --muted: #8b8b93;
  --dim: #5f5f67;
  --accent: #ff4d4f;
  --radius: 10px;
  --topbar-h: 60px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  font-family: inherit;
  color: inherit;
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.14);
  border-radius: 4px;
}
::-webkit-scrollbar-track {
  background: transparent;
}

/* ---------------- 顶栏 ---------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 24px;
  background: rgba(10, 10, 11, 0.86);
  backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.3px;
  flex-shrink: 0;
}
.brand svg {
  color: var(--text);
}

.search {
  flex: 1;
  max-width: 460px;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--dim);
  transition: border-color 0.15s, background 0.15s;
}
.search:focus-within {
  border-color: var(--line-strong);
  background: #1f1f23;
}
.search input {
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 13.5px;
  color: var(--text);
}
.search input::placeholder {
  color: var(--dim);
}
.search input::-webkit-search-cancel-button {
  filter: invert(0.6);
}

.top-actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
}

/* ---------------- 按钮 ---------------- */

.btn {
  height: 34px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  white-space: nowrap;
}
.btn:hover {
  background: #232327;
  border-color: var(--line-strong);
}
.btn:active {
  transform: scale(0.98);
}
.btn.primary {
  background: var(--text);
  color: #0a0a0b;
  border-color: transparent;
  font-weight: 600;
}
.btn.primary:hover {
  background: #fff;
}
.btn.ghost {
  background: transparent;
}
.btn.block {
  width: 100%;
  height: 40px;
}
.btn.small {
  height: 28px;
  padding: 0 10px;
  font-size: 12px;
  border-radius: 7px;
}

.icon-btn {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
}
.icon-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}

/* ---------------- 布局 ---------------- */

.view {
  max-width: 1440px;
  margin: 0 auto;
  padding: 26px 24px 80px;
}

.section-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin: 34px 0 14px;
}
.section-head:first-child {
  margin-top: 6px;
}
.section-head h2 {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
  letter-spacing: 0.2px;
}
.section-head .sub {
  font-size: 12.5px;
  color: var(--dim);
}

.row {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 6px;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
}
.row::-webkit-scrollbar {
  display: none;
}
.row .card {
  flex: 0 0 148px;
  scroll-snap-align: start;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 20px 14px;
}

/* ---------------- 卡片 ---------------- */

.card {
  display: block;
  cursor: pointer;
  min-width: 0;
}

.poster {
  position: relative;
  aspect-ratio: 2 / 3;
  border-radius: var(--radius);
  overflow: hidden;
  background: linear-gradient(160deg, #1d1d20, #131315);
  border: 1px solid var(--line);
}
.poster img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0;
  transition: opacity 0.35s, transform 0.45s cubic-bezier(0.2, 0.7, 0.3, 1);
}
.poster img.loaded {
  opacity: 1;
}
.card:hover .poster img {
  transform: scale(1.045);
}
.poster .badge {
  position: absolute;
  left: 7px;
  top: 7px;
  padding: 2px 6px;
  font-size: 10.5px;
  line-height: 1.5;
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.62);
  color: #e9e9ea;
  backdrop-filter: blur(6px);
  max-width: calc(100% - 14px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.poster .score {
  position: absolute;
  right: 7px;
  bottom: 7px;
  font-size: 11px;
  font-weight: 700;
  color: #ffd166;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

.card .title {
  margin-top: 9px;
  font-size: 13px;
  line-height: 1.35;
  color: #dededf;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.card .meta {
  margin-top: 3px;
  font-size: 11.5px;
  color: var(--dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card:hover .title {
  color: #fff;
}

/* ---------------- 详情 ---------------- */

.detail {
  display: flex;
  gap: 28px;
  padding-top: 8px;
}
.detail-poster {
  flex: 0 0 220px;
}
.detail-poster .poster {
  border-radius: 12px;
}
.detail-body {
  flex: 1;
  min-width: 0;
}
.detail h1 {
  font-size: 26px;
  margin: 0 0 10px;
  font-weight: 650;
  letter-spacing: -0.2px;
}
.detail .meta-line {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 14px;
}
.detail .genres {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.tag {
  font-size: 11.5px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--muted);
}
.detail .desc {
  font-size: 13.5px;
  line-height: 1.75;
  color: #b4b4ba;
  max-width: 780px;
  margin-bottom: 22px;
  white-space: pre-wrap;
}
.detail-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 26px;
  flex-wrap: wrap;
}

.panel-title {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.panel-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.episodes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
  gap: 8px;
  max-height: 260px;
  overflow-y: auto;
  padding-right: 4px;
}
.ep {
  height: 34px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 12.5px;
  color: #c9c9ce;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0 6px;
  transition: all 0.14s;
}
.ep:hover {
  border-color: var(--line-strong);
  color: #fff;
  background: var(--surface-2);
}
.ep.active {
  background: var(--text);
  color: #0a0a0b;
  border-color: transparent;
  font-weight: 600;
}

/* ---------------- 播放页 ---------------- */

.watch {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 20px;
  align-items: start;
}
.watch.no-room {
  grid-template-columns: minmax(0, 1fr);
}

.stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
}
.stage video {
  width: 100%;
  height: 100%;
  display: block;
  background: #000;
}
.stage-status {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  gap: 10px;
  background: rgba(0, 0, 0, 0.55);
  color: #d6d6da;
  font-size: 13px;
  text-align: center;
  padding: 24px;
  line-height: 1.7;
}
.stage-status[hidden] {
  display: none;
}

/* ---------------- 自绘控制条（手机友好） ---------------- */

.ctrl {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  margin-top: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.ctrl-btn {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.ctrl-btn:hover {
  background: var(--surface-2);
}
.ctrl-btn:active {
  background: #2a2a2f;
}
.ctrl-btn.jump-btn {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: -0.2px;
  color: #d9d9dd;
}
.ctrl-btn.rate-btn {
  font-size: 12px;
  font-weight: 600;
  min-width: 44px;
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}
.ctrl-btn.rate-btn:hover {
  background: rgba(255, 255, 255, 0.18);
}

.ctrl-time {
  flex: 0 0 auto;
  min-width: 40px;
  text-align: center;
  font-size: 12px;
  color: #d2d2d6;
  font-variant-numeric: tabular-nums;
}

.seek {
  flex: 1;
  height: 40px; /* 大触控区，手机上也好抓 */
  display: flex;
  align-items: center;
  padding: 0 2px;
  cursor: pointer;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

.seek-track {
  position: relative;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.22);
}

.seek-buf {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.42);
}

.seek-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0;
  border-radius: 3px;
  background: #ffffff;
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.45);
}

.seek-knob {
  position: absolute;
  top: 50%;
  left: 0;
  width: 16px;
  height: 16px;
  margin-left: -8px;
  margin-top: -8px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.2), 0 2px 8px rgba(0, 0, 0, 0.6);
  pointer-events: none;
}

/* 倍速菜单 */
.rate-wrap {
  position: relative;
  flex: 0 0 auto;
}
.rate-menu {
  position: absolute;
  right: 0;
  bottom: 46px;
  min-width: 104px;
  padding: 6px;
  background: #1f1f23;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6);
  display: none;
  z-index: 30;
}
.rate-menu.open {
  display: block;
}
.rate-menu button {
  display: block;
  width: 100%;
  padding: 9px 12px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
}
.rate-menu button:hover {
  background: rgba(255, 255, 255, 0.1);
}
.rate-menu button.active {
  background: #fff;
  color: #0a0a0b;
  font-weight: 600;
}

/* 手机上进度条独占一行，拉满整行宽度，拖动精度更高 */
@media (max-width: 560px) {
  .ctrl {
    flex-wrap: wrap;
    row-gap: 2px;
    column-gap: 4px;
    padding: 10px 10px 8px;
  }
  .seek {
    order: -1;
    flex: 0 0 100%;
    height: 40px;
  }
  .ctrl-btn {
    width: 34px;
  }
  .ctrl-btn.rate-btn {
    min-width: 42px;
  }
  .ctrl-time {
    min-width: 0;
    text-align: left;
  }
  #tDur::before {
    content: "/";
    margin: 0 5px;
    color: var(--dim);
  }
  .ctrl-btn#btnFs {
    margin-left: auto;
  }
}
.spinner {
  width: 22px;
  height: 22px;
  border: 2px solid rgba(255, 255, 255, 0.18);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.watch-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 2px 4px;
  flex-wrap: wrap;
}
.watch-bar h1 {
  font-size: 16px;
  margin: 0;
  font-weight: 600;
}
.watch-bar .sub {
  font-size: 12.5px;
  color: var(--dim);
}
.watch-bar .spacer {
  flex: 1;
}

.watch-panels {
  margin-top: 14px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 14px;
}
.tab {
  padding: 6px 12px;
  font-size: 13px;
  border-radius: 7px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.tab.active {
  background: var(--surface-2);
  color: var(--text);
}

.lines {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
}
.line {
  padding: 7px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 12.5px;
  color: #c9c9ce;
  cursor: pointer;
  transition: all 0.14s;
}
.line:hover {
  border-color: var(--line-strong);
  color: #fff;
}
.line.active {
  border-color: var(--text);
  color: #fff;
  background: var(--surface-2);
  font-weight: 600;
}
.line .dot {
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #3ddc84;
  margin-right: 7px;
  vertical-align: middle;
}

/* ---------------- 房间面板 ---------------- */

.room-panel {
  position: sticky;
  top: calc(var(--topbar-h) + 16px);
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--topbar-h) - 48px);
  max-height: 720px;
  overflow: hidden;
}
.room-head {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 8px;
}
.room-head .code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 15px;
  letter-spacing: 2px;
  font-weight: 600;
}
.room-head .live {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--accent);
}
.room-head .live::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.6s infinite;
}
@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.25;
  }
}

.chat-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  font-size: 13px;
}
.chat-item .who {
  color: var(--dim);
  font-size: 11.5px;
  margin-bottom: 2px;
}
.chat-item .text {
  color: #dcdcdf;
  line-height: 1.5;
  word-break: break-word;
}
.chat-item.me .who {
  color: #9aa0ff;
}
.sys {
  font-size: 11.5px;
  color: var(--dim);
  text-align: center;
  padding: 2px 0;
}

.chat-input {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
}
.chat-input input {
  flex: 1;
  height: 34px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  outline: 0;
  font-size: 13px;
}
.chat-input input:focus {
  border-color: var(--line-strong);
}

.members {
  flex: 1;
  overflow-y: auto;
  padding: 10px 8px;
}
.member {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
}
.member:hover {
  background: var(--surface-2);
}
.member .avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #2a2a2f;
  display: grid;
  place-items: center;
  font-size: 11px;
  color: #b9b9c0;
}
.member .crown {
  font-size: 11px;
  color: #ffd166;
  margin-left: auto;
}

/* ---------------- 弹窗 / 提示 ---------------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.66);
  backdrop-filter: blur(4px);
  padding: 20px;
}
.modal[hidden] {
  display: none;
}
.modal-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.modal-head h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}
.hint {
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.65;
  margin: 0 0 16px;
}
.or {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0;
  font-size: 11.5px;
  color: var(--dim);
}
.or::before,
.or::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}
.join-row {
  display: flex;
  gap: 8px;
}
.join-row input {
  flex: 1;
  height: 40px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  outline: 0;
  font-size: 14px;
  letter-spacing: 2px;
  text-transform: uppercase;
}
.join-row input:focus {
  border-color: var(--line-strong);
}
.join-row .btn {
  height: 40px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translateX(-50%);
  background: #fff;
  color: #0a0a0b;
  font-size: 13px;
  font-weight: 500;
  padding: 9px 16px;
  border-radius: 999px;
  z-index: 200;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
}
.toast[hidden] {
  display: none;
}

.skeleton {
  aspect-ratio: 2 / 3;
  border-radius: var(--radius);
  background: linear-gradient(100deg, #141416 30%, #1c1c20 50%, #141416 70%);
  background-size: 220% 100%;
  animation: shimmer 1.3s infinite;
}
@keyframes shimmer {
  to {
    background-position: -120% 0;
  }
}

.empty {
  text-align: center;
  color: var(--dim);
  font-size: 13px;
  padding: 60px 0;
}

/* ---------------- 响应式 ---------------- */

@media (max-width: 1080px) {
  .watch {
    grid-template-columns: minmax(0, 1fr);
  }
  .room-panel {
    position: static;
    height: 420px;
    max-height: none;
  }
}

@media (max-width: 720px) {
  .view {
    padding: 18px 14px 60px;
  }
  .topbar {
    padding: 0 14px;
    gap: 10px;
  }
  .brand span {
    display: none;
  }
  .detail {
    flex-direction: column;
    gap: 18px;
  }
  .detail-poster {
    flex: 0 0 auto;
    width: 140px;
  }
  .detail h1 {
    font-size: 21px;
  }
  .row .card {
    flex-basis: 118px;
  }
  .grid {
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 16px 10px;
  }
  .watch-bar h1 {
    font-size: 14.5px;
  }
}
