:root {
  --brand: #ff0033;             /* 知更鸟 YouTube 红 */
  --brand-hover: #e6002e;
  --bg: #f9f9f9;                /* 暖白底 */
  --bg-soft: #f2f2f2;
  --bg-hover: #e5e5e5;
  --text: #0f0f0f;
  --text-dim: #606060;
  --line: #e5e5e5;
  --blue: #065fd4;              /* YouTube 标题 hover 蓝 */
  --radius: 12px;
  --radius-sm: 10px;
}

html[data-theme='dark'] {
  --bg: #0f0f0f;
  --bg-soft: #272727;
  --bg-hover: #3f3f3f;
  --text: #f1f1f1;
  --text-dim: #aaaaaa;
  --line: #303030;
  --blue: #3ea6ff;
}

@media (prefers-color-scheme: dark) {
  html[data-theme='auto'] {
    --bg: #0f0f0f;
    --bg-soft: #272727;
    --bg-hover: #3f3f3f;
    --text: #f1f1f1;
    --text-dim: #aaaaaa;
    --line: #303030;
    --blue: #3ea6ff;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Roboto, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

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

/* 滚动条 YouTube 式：默认隐形，悬停浮现 */
::-webkit-scrollbar { width: 8px; height: 8px; background: transparent; }
::-webkit-scrollbar-thumb { background: transparent; border-radius: 4px; }
*:hover::-webkit-scrollbar-thumb { background: rgba(0, 0, 0, .24); }
* { scrollbar-width: thin; scrollbar-color: transparent transparent; }
*:hover { scrollbar-color: rgba(0, 0, 0, .24) transparent; }

/* ---------- 顶栏：白底 + 轻阴影 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .06);
}
html[data-theme='dark'] .topbar { background: #212121; }

.topbar-inner {
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: 1500px;
  margin: 0 auto;
  padding: 8px 16px;
}

.btn-menu {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
}
.btn-menu:hover { background: var(--bg-soft); }

.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; white-space: nowrap; }
.brand-mark { display: block; flex: 0 0 auto; }
.brand-name { font-size: 19px; letter-spacing: 0.5px; }

/* ---------- 布局：左侧栏 + 主列 ---------- */
.layout { display: flex; max-width: 1500px; margin: 0 auto; }

.sidebar {
  flex: 0 0 240px;
  padding: 12px 8px 24px;
  position: sticky;
  top: 57px;
  height: calc(100vh - 57px);
  overflow-y: auto;
  background: var(--bg);
}
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-link {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 16px;
  border-radius: 10px;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
}
.side-link:hover { background: var(--bg-soft); }
.side-link.active { background: var(--bg-hover); font-weight: 600; }
.side-ico { width: 22px; text-align: center; font-size: 16px; color: var(--text-dim); }
.side-link.active .side-ico { color: var(--text); }
.side-hr { border: none; border-top: 1px solid var(--line); margin: 8px 12px; }

.main-col { flex: 1; min-width: 0; }

.nav-links { display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.nav-link {
  padding: 6px 12px;
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
}
.nav-link:hover { background: var(--bg-soft); }
.nav-link.active { background: var(--bg-hover); font-weight: 600; }

/* ---------- 搜索框：YouTube 式胶囊，40px 高灰底圆角 ---------- */
.search {
  display: flex;
  flex: 1;
  max-width: 540px;
  margin: 0 auto;
  height: 40px;
  background: var(--bg-soft);
  border: 1px solid var(--bg-soft);
  border-radius: 20px;
  transition: background .15s ease, border-color .15s ease;
}
.search:hover { background: var(--bg-hover); border-color: var(--bg-hover); }
.search:focus-within {
  background: #ffffff;
  border-color: #1c62b9;
}
.search input {
  flex: 1;
  min-width: 0;
  padding: 0 8px 0 16px;
  border: none;
  border-radius: 20px 0 0 20px;
  background: transparent;
  color: var(--text);
  font-size: 15px;
  outline: none;
}
.search input::placeholder { color: #888; }
.search button {
  width: 48px;
  padding: 0;
  border: none;
  border-radius: 0 20px 20px 0;
  background: transparent;
  color: var(--text-dim);
  font-size: 15px;
  cursor: pointer;
}
.search button:hover { color: var(--text); }

.nav-right { display: flex; align-items: center; gap: 10px; }
.btn-ghost {
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
}
.btn-ghost:hover { background: var(--bg-soft); }
.btn-login {
  padding: 6px 16px;
  border-radius: 18px;
  border: 1px solid var(--brand);
  color: var(--brand);
  font-weight: 600;
}
.btn-login:hover { background: var(--brand); color: #fff; }
.nav-me {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 12px 4px 5px;
  border-radius: 18px;
  background: var(--bg-soft);
  font-weight: 600;
}

/* ---------- 分类 chips：YouTube 风格，黑底白字 active，可横滚 ---------- */
.cats { padding: 12px 24px 0; }
.cats-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.cats-scroll::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
  white-space: nowrap;
  transition: background .15s ease;
}
.chip:hover { background: var(--bg-hover); }
.chip.is-active { background: var(--text); color: var(--bg); }
html[data-theme='dark'] .chip.is-active { background: #f1f1f1; color: #0f0f0f; }

.page { padding: 22px 24px 20px; min-height: 60vh; }

.page-head { margin: 4px 0 18px; }
.page-head h1 { font-size: 20px; margin: 0; font-weight: 600; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 32px 16px;
}

/* ---------- 视频卡片：YouTube 无底框式 ---------- */
.card {
  display: block;
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  cursor: pointer;
}
.thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 12px;
  background: #000;
}
.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transform: scale(1);
  transition: transform .25s ease;
}
.card:hover .thumb img { transform: scale(1.05); }

/* hover 播放浮层：YouTube 式淡入 */
.play-ov {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, .18);
  opacity: 0;
  transition: opacity .2s ease;
  pointer-events: none;
  z-index: 4;
}
.card:hover .play-ov { opacity: 1; }
.play-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(0, 0, 0, .75);
  box-shadow: 0 2px 10px rgba(0, 0, 0, .35);
}

/* hover 预览播放：视频覆盖封面，静音播放 + 底部进度条 */
.hp-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 2;
  background: #000;
}
.hp-track {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 16px;               /* 命中区（YouTube 细线大命中区） */
  z-index: 6;
}
.hp-track::before {            /* 轨道视觉线 3px */
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: rgba(255, 255, 255, .35);
}
.hp-fill {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 3px;
  width: 0%;
  background: var(--brand, #f00);
  transition: width .1s linear;
}
.card:hover .hp-track::before,
.card:hover .hp-fill { height: 5px; }

.dur {
  position: absolute;
  right: 6px;
  bottom: 6px;
  padding: 2px 5px;
  border-radius: 4px;
  background: rgba(0, 0, 0, .8);
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  line-height: 16px;
  font-variant-numeric: tabular-nums;
  z-index: 5;
}

.meta { display: flex; gap: 12px; padding: 10px 0 0; }
.avatar {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 500;
  font-size: 14px;
}
.avatar.sm { width: 28px; height: 28px; font-size: 13px; }
.avatar.xs { width: 26px; height: 26px; font-size: 12px; }
.avatar.lg { width: 72px; height: 72px; font-size: 26px; }
img.avatar { object-fit: cover; display: block; }
.me-avatar { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.info { min-width: 0; }
.title {
  margin: 0 0 4px;
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}
.card:hover .title { color: var(--blue); }
.channel { margin: 0; color: var(--text-dim); font-size: 13px; line-height: 18px; }
.views { margin: 0; color: var(--text-dim); font-size: 13px; line-height: 18px; }

.pager { display: flex; align-items: center; justify-content: center; gap: 16px; margin: 32px 0; }
.pager a {
  padding: 7px 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  font-size: 13px;
}
.pager a:hover { background: var(--bg-soft); }
.pager-info { color: var(--text-dim); font-size: 13px; }

.empty {
  grid-column: 1 / -1;
  padding: 48px 0;
  text-align: center;
  color: var(--text-dim);
  list-style: none;
}

/* 播放页 */
.watch-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 400px;
  gap: 24px;
  align-items: start;
}
.watch { min-width: 0; }
.player-wrap { position: relative; border-radius: var(--radius-sm); overflow: hidden; background: #000; }
.player { display: block; width: 100%; aspect-ratio: 16 / 9; background: #000; }
.player-bar {
  display: flex;
  justify-content: flex-end;
  padding: 6px 10px;
  background: var(--bg-soft);
}
.quality { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-dim); }
.quality select {
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
}

.watch-title { font-size: 20px; margin: 16px 0 12px; }
.watch-meta { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.meta-left { display: flex; align-items: center; gap: 10px; }
.channel { margin: 0; font-weight: 600; }
.meta-actions { display: flex; gap: 8px; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border: none;
  border-radius: 18px;
  background: var(--bg-soft);
  color: var(--text);
  font-size: 13.5px;
  cursor: pointer;
}
.pill:hover { background: var(--bg-hover); }
.pill.on { background: var(--brand); color: #fff; }
.ico { font-size: 14px; }

.description {
  margin: 16px 0;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  white-space: pre-wrap;
}
.description p { margin: 0; }

.comments { margin-top: 24px; }
.comments h2 { font-size: 17px; margin: 0 0 12px; }
.comment-form { display: flex; gap: 10px; align-items: flex-start; }
.comment-form textarea {
  flex: 1;
  min-height: 68px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  resize: vertical;
}
.comment-list { list-style: none; padding: 0; margin: 18px 0 0; display: flex; flex-direction: column; gap: 16px; }
.comment { display: flex; gap: 10px; }
.comment-body p { margin: 3px 0 0; word-break: break-word; }
.comment-head { display: flex; gap: 8px; align-items: baseline; }
.comment-head span { color: var(--text-dim); font-size: 12.5px; }

/* 右侧相关视频（YouTube 风格） */
.related { min-width: 0; }
.related-title { font-size: 16px; margin: 0 0 12px; }
.rel-card {
  display: flex;
  gap: 10px;
  padding: 8px;
  border-radius: 12px;
  color: inherit;
  text-decoration: none;
}
.rel-card:hover { background: var(--bg-hover); }
.rel-thumb {
  position: relative;
  flex: 0 0 168px;
  aspect-ratio: 16 / 9;
  border-radius: 10px;
  overflow: hidden;
  background: #000;
}
.rel-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.rel-info { min-width: 0; }
.rel-title {
  margin: 0 0 4px;
  font-size: 13.5px;
  font-weight: 500;
  line-height: 18px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}
.rel-card:hover .rel-title { color: var(--blue); }
.rel-meta { margin: 0; color: var(--text-dim); font-size: 12.5px; line-height: 18px; }

@media (max-width: 1024px) {
  .watch-layout { grid-template-columns: 1fr; }
  .related { order: 2; }
}

.hint { color: var(--text-dim); font-size: 13px; }
.hint a { color: var(--brand); }

.btn-primary {
  padding: 9px 20px;
  border: none;
  border-radius: 18px;
  background: var(--brand);
  color: #fff;
  font-size: 14px;
  cursor: pointer;
}
.btn-primary:hover { filter: brightness(1.08); }

/* 表单 */
.auth { max-width: 380px; margin: 40px auto; }
.auth h1 { font-size: 20px; margin-bottom: 18px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-dim); }
.auth-form input {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}
.form-msg { min-height: 18px; margin: 0; font-size: 13px; color: var(--brand); }

/* 后台 */
.block { margin-bottom: 34px; }
.block h2 { font-size: 16px; margin: 0 0 12px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { background: var(--bg-soft); font-weight: 600; }
tr:last-child td { border-bottom: none; }
td.ellipsis { max-width: 320px; overflow: hidden; text-overflow: ellipsis; }
td.ops { display: flex; gap: 6px; flex-wrap: wrap; }
td.ops button {
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  font-size: 12.5px;
}
td.ops button:hover { background: var(--bg-soft); }
td.ops button.danger { border-color: #d33; color: #d33; }
td.ops button.danger:hover { background: #d33; color: #fff; }
td select {
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
}
.inline-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 12px; }
.inline-form input[type='text'], .inline-form input[type='number'] {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
}
.checkbox { display: inline-flex; align-items: center; gap: 6px; color: var(--text-dim); font-size: 13px; }

/* 后台编辑视频弹窗 */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, .45);
  padding: 20px;
}
.modal-overlay[hidden] { display: none; }
.modal {
  width: min(420px, 100%);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .25);
}
.modal h3 { margin: 0 0 14px; font-size: 16px; }
.field { display: block; margin-bottom: 12px; font-size: 13px; color: var(--text-dim); }
.field input,
.field select {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

.my-comments { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 14px; }
.my-comment { padding: 12px 14px; border-radius: 10px; background: var(--bg-soft); }
.my-comment a { font-weight: 600; }
.my-comment p { margin: 6px 0; word-break: break-word; }

.footer {
  margin: 40px auto 24px;
  padding: 20px 24px 0;
  border-top: 1px solid rgba(0, 0, 0, .06);
  color: var(--text-dim);
  font-size: 12.5px;
}
.footer-links { display: flex; flex-wrap: wrap; gap: 18px; margin-bottom: 14px; }
.footer-links a { color: var(--text); font-size: 13px; }
.footer-links a:hover { color: var(--brand); }
.footer-copy { color: var(--text-dim); font-size: 12px; }

@media (max-width: 760px) {
  .topbar-inner { flex-wrap: wrap; padding: 8px 14px; }
  .search { order: 3; flex-basis: 100%; max-width: none; }
  .sidebar { display: none; }
  .sidebar.open {
    display: block;
    position: fixed;
    left: 0;
    top: 57px;
    bottom: 0;
    width: 240px;
    z-index: 40;
    box-shadow: 2px 0 8px rgba(0, 0, 0, .15);
  }
  .layout { display: block; }
  .cats { padding: 10px 14px 0; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 24px 12px; }
  .avatar { width: 32px; height: 32px; font-size: 13px; }
  .page { padding: 14px; }
}
