/* ==========================================================================
   X 视频收藏站 · 全站样式
   移动优先：基准宽度 375px，断点向上加列
   约束：不引入任何框架，纯 CSS 变量 + 原生布局
   ========================================================================== */

/* -------------------- 设计令牌 -------------------- */
:root {
  /* 主题色：深色为主（视频站看片舒服），可整体替换下面 4 个即可换肤 */
  --bg: #0e1013;
  --bg-elevated: #171a20;
  --bg-hover: #1f242c;
  --border: #2a2f38;

  --text: #e8eaed;
  --text-dim: #9aa3af;
  --text-faint: #6b7480;

  --accent: #3b9dff;
  --accent-strong: #1a7fdd;
  --danger: #ff5c5c;
  --ok: #35c07f;

  /* 尺码 */
  --radius: 10px;
  --radius-sm: 6px;
  --tap: 44px; /* 最小可点击区域，DESIGN 硬性要求 */
  --gap: 10px;
  --page-pad: 12px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", Roboto, sans-serif;

  /* 布局 */
  --max-w: 1200px;
  --grid-min: 150px; /* 网格最小列宽，手机单列/双列由它和容器宽决定 */

  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f7f9;
    --bg-elevated: #ffffff;
    --bg-hover: #eef1f5;
    --border: #e0e4ea;
    --text: #1a1d21;
    --text-dim: #5b6470;
    --text-faint: #8a939f;
    --accent: #1a7fdd;
    --accent-strong: #1466b8;
    color-scheme: light;
  }
}

/* -------------------- 基础重置 -------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  /* 双重保险：任何意外的宽元素都不产生横向滚动条 */
  overflow-x: hidden;
}

img,
video {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

/* 键盘可达性：不要用 outline:none 干掉焦点环 */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* 无障碍：只给读屏用的文本 */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* -------------------- 顶栏 -------------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px var(--page-pad);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.topbar__brand {
  font-weight: 700;
  font-size: 16px;
  color: var(--text);
  white-space: nowrap;
}

.topbar__brand:hover {
  text-decoration: none;
  color: var(--accent);
}

.topbar__search {
  flex: 1 1 140px;
  display: flex;
  gap: 6px;
  min-width: 0;
}

/* -------------------- 表单控件 -------------------- */
.field {
  flex: 1 1 auto;
  min-width: 0;
  min-height: var(--tap);
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 16px; /* iOS 下 <16px 会触发聚焦缩放 */
}

.field::placeholder {
  color: var(--text-faint);
}

.field:focus {
  border-color: var(--accent);
  outline: none;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: var(--tap);
  min-width: var(--tap);
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 15px;
  white-space: nowrap;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.btn:hover {
  background: var(--bg-hover);
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

.btn--primary:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

.btn--ghost {
  background: transparent;
}

.btn--block {
  width: 100%;
}

/* -------------------- 页面容器 -------------------- */
.page {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: var(--page-pad);
}

.page__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin: 4px 0 12px;
}

.page__title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

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

/* -------------------- 网格卡片 -------------------- */
.grid {
  display: grid;
  /* auto-fill + minmax：375px 下自然 2 列，桌面自动铺满；不写固定列数以免溢出 */
  grid-template-columns: repeat(auto-fill, minmax(var(--grid-min), 1fr));
  gap: var(--gap);
  margin: 0;
  padding: 0;
  list-style: none;
}

.card {
  display: flex;
  flex-direction: column;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  color: inherit;
  /* 卡片整体是链接：保证触控区域够大 */
  min-height: 100%;
}

.card:hover,
.card:focus-visible {
  background: var(--bg-hover);
  text-decoration: none;
}

.card__thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  background: #000;
  overflow: hidden;
}

.card__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card__img--empty {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  color: var(--text-faint);
  font-size: 12px;
  background: var(--bg-hover);
}

.card__badge {
  position: absolute;
  right: 6px;
  bottom: 6px;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgb(0 0 0 / 0.72);
  color: #fff;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  line-height: 1.5;
}

.card__badge--type {
  right: auto;
  left: 6px;
}

.card__body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px 10px;
  min-width: 0;
}

.card__author {
  color: var(--text-dim);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card__title {
  font-size: 14px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}

/* -------------------- 状态块 -------------------- */
.state {
  padding: 28px 16px;
  text-align: center;
  color: var(--text-dim);
  font-size: 14px;
}

.state--error {
  color: var(--danger);
}

.sentinel {
  height: 1px;
}

.loading-bar {
  display: none;
  padding: 16px;
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
}

.loading-bar.is-visible {
  display: block;
}

/* -------------------- 详情页 -------------------- */
.detail {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.detail__title {
  margin: 0;
  font-size: 20px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

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

.player {
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
}

.player video {
  width: 100%;
  max-height: 78vh;
  background: #000;
}

.player + .player {
  margin-top: var(--gap);
}

.detail__content {
  /* 保留换行，长串强制断行，避免 375px 溢出 */
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 15px;
}

.detail__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* -------------------- 作者卡片 -------------------- */
.author-card {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: inherit;
}

.author-card:hover {
  background: var(--bg-hover);
  text-decoration: none;
}

.author-card__avatar {
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--bg-hover);
}

.author-card__avatar--empty {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-faint);
  font-size: 18px;
}

.author-card__body {
  min-width: 0;
  flex: 1 1 auto;
}

.author-card__name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.author-card__handle {
  color: var(--text-dim);
  font-size: 13px;
}

.author-card__bio {
  margin-top: 4px;
  color: var(--text-dim);
  font-size: 13px;
  overflow-wrap: anywhere;
}

/* 作者页：banner + 头像 */
.author-hero {
  position: relative;
  margin: calc(var(--page-pad) * -1) calc(var(--page-pad) * -1) 0;
}

.author-hero__banner {
  width: 100%;
  height: 120px;
  object-fit: cover;
  background: var(--bg-hover);
}

.author-hero__inner {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  padding: 0 var(--page-pad);
  margin-top: -28px;
  position: relative;
}

.author-hero__avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 3px solid var(--bg);
  object-fit: cover;
  background: var(--bg-hover);
}

.author-hero__info {
  padding-bottom: 4px;
  min-width: 0;
}

.author-hero__name {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.author-hero__handle {
  color: var(--text-dim);
  font-size: 13px;
}

.author-hero__bio {
  margin: 10px var(--page-pad) 0;
  color: var(--text-dim);
  font-size: 14px;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

/* -------------------- 登录页 -------------------- */
.login {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--page-pad);
}

.login__card {
  width: 100%;
  max-width: 360px;
  padding: 24px 20px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.login__title {
  margin: 0 0 4px;
  font-size: 20px;
  text-align: center;
}

.login__sub {
  margin: 0 0 20px;
  color: var(--text-dim);
  font-size: 13px;
  text-align: center;
}

.login__field {
  display: block;
  margin-bottom: 12px;
}

.login__label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  color: var(--text-dim);
}

.login__error {
  min-height: 20px;
  margin: 0 0 8px;
  color: var(--danger);
  font-size: 13px;
}

/* -------------------- 页脚 -------------------- */
.footer {
  padding: 24px var(--page-pad) 32px;
  text-align: center;
  color: var(--text-faint);
  font-size: 12px;
}

/* -------------------- 平板/桌面 -------------------- */
@media (min-width: 600px) {
  :root {
    --gap: 12px;
    --page-pad: 16px;
    --grid-min: 200px;
  }

  body {
    font-size: 16px;
  }

  .detail__title {
    font-size: 22px;
  }

  .author-hero__banner {
    height: 160px;
  }

  .author-hero__avatar {
    width: 88px;
    height: 88px;
  }
}

@media (min-width: 900px) {
  :root {
    --grid-min: 240px;
  }

  .detail {
    max-width: 820px;
    margin: 0 auto;
  }
}

/* 减少动效偏好 */
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}
