/* ==========================================================================
   ACG 星屑站 · 样式表
   结构：变量 → 基础重置 → 布局 → 头部 → 列表卡片 → 侧边栏 → 详情页 → 页脚 → 响应式
   ========================================================================== */

:root {
  /* 品牌色：ACG 站常见的紫粉青组合 */
  --brand: #7c3aed;
  --brand-2: #ec4899;
  --brand-3: #06b6d4;

  /* 浅色主题（默认） */
  --bg: #f5f6fa;
  --bg-soft: #eceefb;
  --surface: #ffffff;
  --surface-2: #f8f9fd;
  --border: #e5e7f2;
  --text: #1f2233;
  --text-soft: #5b6079;
  --text-mute: #8a90a8;

  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 2px 12px rgba(31, 34, 51, 0.06);
  --shadow-hover: 0 8px 28px rgba(124, 58, 237, 0.14);

  --maxw: 1200px;
  --sidebar: 300px;
  --gap: 24px;

  --font: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", -apple-system,
    BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

[data-theme="dark"] {
  --bg: #12131c;
  --bg-soft: #171826;
  --surface: #1c1e2b;
  --surface-2: #222435;
  --border: #2c2f42;
  --text: #eceefb;
  --text-soft: #a9aec4;
  --text-mute: #7a8098;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
  --shadow-hover: 0 8px 28px rgba(124, 58, 237, 0.28);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.75;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.25s ease, color 0.25s ease;
}

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

img {
  max-width: 100%;
  display: block;
}

button {
  font: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

input {
  font: inherit;
}

/* 焦点可见性：键盘导航必须能看清焦点位置（a11y） */
:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 3px;
  border-radius: 4px;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 200;
  background: var(--brand);
  color: #fff;
  padding: 10px 18px;
  border-radius: 0 0 var(--radius-sm) 0;
}
.skip-link:focus {
  left: 0;
}

.container {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 20px;
}

/* ============================ 顶部公告条 ============================ */
.topbar {
  background: linear-gradient(90deg, var(--brand) 0%, var(--brand-2) 100%);
  color: #fff;
  font-size: 13px;
}
.topbar .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 38px;
  flex-wrap: wrap;
}
.topbar-text {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}
.topbar-badge {
  background: rgba(255, 255, 255, 0.22);
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 12px;
  flex-shrink: 0;
}
.topbar-ad {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
  color: #fff;
  text-decoration: none;
}
.topbar-ad:hover .topbar-ad-text {
  text-decoration: underline;
}
.topbar-ad-img {
  height: 22px;
  width: auto;
  max-width: 140px;
  object-fit: contain;
  flex-shrink: 0;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.18);
}
.topbar-ad-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topbar-links {
  display: flex;
  gap: 16px;
  flex-shrink: 0;
}
.topbar-links a {
  opacity: 0.9;
}
.topbar-links a:hover {
  opacity: 1;
  text-decoration: underline;
}

/* ============================ 头部导航 ============================ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.header-inner {
  display: flex;
  align-items: center;
  gap: 20px;
  min-height: 68px;
  position: relative; /* 让用户下拉菜单以 header 为定位基准 */
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}
.logo-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--brand), var(--brand-3));
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 17px;
  font-weight: 700;
}
.logo-text {
  background: linear-gradient(90deg, var(--brand), var(--brand-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.nav {
  display: flex;
  gap: 4px;
  margin-left: auto;
  overflow-x: auto;
  scrollbar-width: none;
}
.nav::-webkit-scrollbar {
  display: none;
}
.nav a {
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 14.5px;
  color: var(--text-soft);
  white-space: nowrap;
  transition: background-color 0.18s ease, color 0.18s ease;
}
.nav a:hover {
  background: var(--bg-soft);
  color: var(--text);
}
.nav a.is-active {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.search-box {
  position: relative;
}
.search-box input {
  width: 190px;
  padding: 9px 14px 9px 34px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--text);
  transition: width 0.2s ease, border-color 0.2s ease;
}
.search-box input:focus {
  width: 240px;
  border-color: var(--brand);
  outline: none;
  background: var(--surface);
}
.search-box::before {
  content: "";
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  width: 12px;
  height: 12px;
  border: 2px solid var(--text-mute);
  border-radius: 50%;
}
.search-box::after {
  content: "";
  position: absolute;
  left: 22px;
  top: 50%;
  width: 6px;
  height: 2px;
  background: var(--text-mute);
  transform: rotate(45deg);
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--bg-soft);
  color: var(--text-soft);
  transition: background-color 0.18s ease, color 0.18s ease;
}
.icon-btn:hover {
  background: var(--brand);
  color: #fff;
}
.icon-btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ============================ 站点标语 ============================ */
.hero {
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.1), rgba(6, 182, 212, 0.08)),
    var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 34px 0;
  text-align: center;
}
.hero h1 {
  margin: 0 0 8px;
  font-size: 26px;
  letter-spacing: 1px;
}
.hero p {
  margin: 0;
  color: var(--text-soft);
  font-size: 15px;
}

/* ============================ 主体布局 ============================ */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--sidebar);
  gap: var(--gap);
  padding: var(--gap) 0 40px;
  align-items: start;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 17px;
  font-weight: 700;
  margin: 0;
}
.section-title::before {
  content: "";
  width: 4px;
  height: 18px;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--brand), var(--brand-2));
}

.sort-tabs {
  display: flex;
  gap: 6px;
  font-size: 13.5px;
}
.sort-tabs button {
  padding: 5px 12px;
  border-radius: 999px;
  color: var(--text-mute);
  transition: all 0.18s ease;
}
.sort-tabs button:hover {
  color: var(--text);
  background: var(--bg-soft);
}
.sort-tabs button.is-active {
  background: var(--brand);
  color: #fff;
}

/* ============================ 文章卡片列表 ============================ */
.post-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.post-card {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.post-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
  border-color: rgba(124, 58, 237, 0.35);
}

.post-thumb {
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-soft);
  aspect-ratio: 16 / 10;
}
.post-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.35s ease;
}
.post-card:hover .post-thumb img {
  transform: scale(1.05);
}
.thumb-cat {
  position: absolute;
  left: 8px;
  top: 8px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
}
.thumb-size {
  position: absolute;
  right: 8px;
  bottom: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
}

.post-body {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.post-title {
  margin: 0 0 8px;
  font-size: 16.5px;
  line-height: 1.5;
  font-weight: 700;
}
.post-title a {
  transition: color 0.18s ease;
}
.post-card:hover .post-title a {
  color: var(--brand);
}
.post-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}
.badge {
  padding: 1px 9px;
  border-radius: 999px;
  font-size: 12px;
  background: var(--bg-soft);
  color: var(--text-soft);
  border: 1px solid var(--border);
}
.badge-new {
  background: linear-gradient(135deg, var(--brand-2), var(--brand));
  color: #fff;
  border-color: transparent;
}
.badge-zh {
  background: rgba(6, 182, 212, 0.12);
  color: #0891b2;
  border-color: rgba(6, 182, 212, 0.3);
}
[data-theme="dark"] .badge-zh {
  color: #67e8f9;
}

.post-excerpt {
  margin: 0 0 10px;
  color: var(--text-soft);
  font-size: 14px;
  line-height: 1.7;
  /* 超出两行截断，保证卡片高度一致 */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: auto;
  font-size: 13px;
  color: var(--text-mute);
}
.post-meta span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.post-meta svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
}

.btn-dl-sm {
  margin-left: auto;
  padding: 6px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  transition: filter 0.18s ease, transform 0.18s ease;
}
.btn-dl-sm:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

/* 空状态 / 载入提示 */
.empty {
  padding: 60px 20px;
  text-align: center;
  color: var(--text-mute);
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}
.empty strong {
  display: block;
  color: var(--text-soft);
  font-size: 16px;
  margin-bottom: 6px;
}

/* ============================ 分页 ============================ */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  margin-top: 24px;
  flex-wrap: wrap;
}
.pagination button {
  min-width: 38px;
  height: 38px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-soft);
  font-size: 14px;
  transition: all 0.18s ease;
}
.pagination button:hover:not(:disabled) {
  border-color: var(--brand);
  color: var(--brand);
}
.pagination button.is-active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
.pagination button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ============================ 侧边栏 ============================ */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: sticky;
  top: 88px;
}

.widget {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.widget-head {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.widget-head::before {
  content: "";
  width: 3px;
  height: 15px;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--brand), var(--brand-2));
}
.widget-body {
  padding: 12px 16px 16px;
}

/* 热门排行 */
.rank-list {
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: rank;
}
.rank-list li {
  counter-increment: rank;
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 9px 0;
  border-bottom: 1px dashed var(--border);
}
.rank-list li:last-child {
  border-bottom: none;
}
.rank-list li::before {
  content: counter(rank);
  width: 22px;
  height: 22px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-mute);
  background: var(--bg-soft);
}
.rank-list li:nth-child(1)::before {
  background: linear-gradient(135deg, #f43f5e, #fb923c);
  color: #fff;
}
.rank-list li:nth-child(2)::before {
  background: linear-gradient(135deg, #f59e0b, #facc15);
  color: #fff;
}
.rank-list li:nth-child(3)::before {
  background: linear-gradient(135deg, #06b6d4, #38bdf8);
  color: #fff;
}
.rank-item {
  min-width: 0;
}
.rank-item a {
  display: block;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: color 0.18s ease;
}
.rank-item a:hover {
  color: var(--brand);
}
.rank-item small {
  color: var(--text-mute);
  font-size: 12px;
}

/* 分类列表 */
.cat-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.cat-list li + li {
  border-top: 1px dashed var(--border);
}
.cat-list a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 0;
  font-size: 14px;
  color: var(--text-soft);
  transition: color 0.18s ease, padding-left 0.18s ease;
}
.cat-list a:hover,
.cat-list a.is-active {
  color: var(--brand);
  padding-left: 6px;
}
.cat-list .count {
  font-size: 12px;
  color: var(--text-mute);
  background: var(--bg-soft);
  padding: 1px 8px;
  border-radius: 999px;
}

/* 公告小部件 */
.notice-box {
  font-size: 13.5px;
  color: var(--text-soft);
  line-height: 1.8;
}
.notice-box p {
  margin: 0 0 8px;
}
.notice-box p:last-child {
  margin-bottom: 0;
}
.notice-box strong {
  color: var(--brand-2);
}
.notice-box a {
  color: var(--brand-2);
  text-decoration: underline;
}

/* ============================ 详情页 ============================ */
.breadcrumb {
  padding: 14px 0;
  font-size: 13.5px;
  color: var(--text-mute);
}
.breadcrumb a:hover {
  color: var(--brand);
}
.breadcrumb .sep {
  margin: 0 6px;
  opacity: 0.6;
}

.article {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.article-header {
  padding: 26px 28px 20px;
  border-bottom: 1px solid var(--border);
}
.article-cat {
  display: inline-block;
  padding: 3px 12px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  margin-bottom: 12px;
}
.article-title {
  margin: 0 0 12px;
  font-size: 24px;
  line-height: 1.45;
  font-weight: 800;
}
.article-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  font-size: 13.5px;
  color: var(--text-mute);
}
.article-meta span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.article-meta svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
}

.article-cover {
  padding: 0;
  margin: 0;
}
.article-cover img {
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

.article-content {
  padding: 24px 28px 28px;
  font-size: 15.5px;
  line-height: 1.9;
  color: var(--text);
}
.article-content h2 {
  font-size: 18px;
  margin: 28px 0 12px;
  padding-left: 12px;
  border-left: 4px solid var(--brand);
}
.article-content h2:first-child {
  margin-top: 0;
}
.article-content p {
  margin: 0 0 14px;
}

/* 特色列表 */
.feature-list {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  display: grid;
  gap: 8px;
}
.feature-list li {
  position: relative;
  padding-left: 24px;
  color: var(--text-soft);
  font-size: 15px;
}
.feature-list li::before {
  content: "";
  position: absolute;
  left: 6px;
  top: 10px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
}

/* 截图画廊 */
.shots {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
  margin: 0 0 16px;
}
.shots figure {
  margin: 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-soft);
}
.shots img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  transition: transform 0.35s ease;
}
.shots figure:hover img {
  transform: scale(1.04);
}
.shots figcaption {
  padding: 7px 10px;
  font-size: 12.5px;
  color: var(--text-mute);
  text-align: center;
}

/* 配置要求表（已下线：系统要求与 admin 一并移除，保留空 class 占位以防旧样式冲突） */

.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin: 0 0 20px;
  padding: 16px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.info-grid div {
  font-size: 14px;
}
.info-grid dt {
  color: var(--text-mute);
  font-size: 12.5px;
  margin-bottom: 2px;
}
.info-grid dd {
  margin: 0;
  font-weight: 600;
}

/* 下载区块 */
.download-box {
  margin: 24px 0 8px;
  padding: 22px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.1), rgba(236, 72, 153, 0.08));
  border: 1px dashed rgba(124, 58, 237, 0.4);
  text-align: center;
}
.download-box h3 {
  margin: 0 0 6px;
  font-size: 17px;
}
.download-box .dl-note {
  margin: 0 0 16px;
  font-size: 13.5px;
  color: var(--text-soft);
}
.dl-buttons {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}
/* 下载区锁定态（未登录）：登录后才显示完整下载区 */
.download-box.dl-locked {
  border-style: solid;
}
.dl-locked-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 10px 0 6px;
}
.dl-lock-icon {
  width: 42px;
  height: 42px;
  fill: none;
  stroke: var(--brand);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.85;
}
.dl-locked-text {
  margin: 0;
  font-size: 14px;
  color: var(--text-soft);
}
.dl-guide {
  margin: 12px 0 0;
  font-size: 13px;
}
.dl-guide a {
  color: var(--brand);
  text-decoration: underline;
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 28px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 15px;
  transition: transform 0.18s ease, filter 0.18s ease;
}
.btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.btn:hover {
  transform: translateY(-2px);
  filter: brightness(1.06);
}
.btn-primary {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  box-shadow: 0 6px 18px rgba(124, 58, 237, 0.3);
}
.btn-ghost {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-soft);
}
.btn-ghost:hover {
  color: var(--brand);
  border-color: var(--brand);
}

/* 文章标签 */
.article-tags {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  font-size: 13.5px;
  color: var(--text-mute);
}
.article-tags a {
  padding: 3px 11px;
  border-radius: 999px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--text-soft);
}
.article-tags a:hover {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}

/* 上一篇 / 下一篇 */
.post-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 20px;
}
.post-nav a {
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 14px;
  transition: all 0.18s ease;
  overflow: hidden;
}
.post-nav a:hover {
  border-color: var(--brand);
  color: var(--brand);
}
.post-nav a span {
  display: block;
  font-size: 12.5px;
  color: var(--text-mute);
  margin-bottom: 2px;
}
.post-nav a p {
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.post-nav a.next {
  text-align: right;
}

/* 相关推荐 */
.related {
  margin-top: 24px;
}
.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.related-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.related-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
}
.related-card img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}
.related-card p {
  margin: 0;
  padding: 10px 12px;
  font-size: 14px;
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ============================ 评论区 ============================ */
.comments {
  margin-top: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px 24px;
}
.comment-count {
  color: var(--brand);
}
.comment-composer {
  margin: 16px 0 8px;
}
.comment-input {
  width: 100%;
  min-height: 82px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  color: var(--text);
  font-family: inherit;
  font-size: 14.5px;
  line-height: 1.7;
  resize: vertical;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.comment-input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.14);
  background: var(--surface);
}
.comment-input[readonly] {
  cursor: not-allowed;
  opacity: 0.75;
}
.comment-composer-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
}
.comment-hint {
  font-size: 13px;
  color: var(--text-mute);
}
.comment-hint.is-err {
  color: #ef4444;
}
.comment-submit {
  flex-shrink: 0;
}
.comment-submit:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}
.comment-list {
  list-style: none;
  margin: 18px 0 0;
  padding: 0;
  display: grid;
  gap: 14px;
}
.comment-item {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.comment-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.comment-user {
  font-weight: 700;
  font-size: 14px;
  color: var(--brand);
}
.comment-time {
  font-size: 12.5px;
  color: var(--text-mute);
}
.comment-del {
  margin-left: auto;
  padding: 2px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--text-mute);
  font-size: 12px;
  cursor: pointer;
  transition: color 0.18s ease, border-color 0.18s ease;
}
.comment-del:hover {
  color: #ef4444;
  border-color: #ef4444;
}
.comment-body {
  margin: 8px 0 0;
  font-size: 14.5px;
  line-height: 1.75;
  color: var(--text);
  word-break: break-word;
}
.comment-empty {
  margin: 18px 0 0;
}

/* ============================ 页脚 ============================ */
.site-footer {
  margin-top: 20px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 34px 0 24px;
  font-size: 14px;
  color: var(--text-soft);
}
.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 28px;
  margin-bottom: 24px;
}
.footer-col h4 {
  margin: 0 0 12px;
  font-size: 15px;
  color: var(--text);
}
.footer-col ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 7px;
}
.footer-col a:hover {
  color: var(--brand);
}
.footer-bottom {
  padding-top: 18px;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 13px;
  color: var(--text-mute);
  line-height: 1.9;
}
.footer-icp a {
  color: inherit;
  text-decoration: none;
}
.footer-icp a:hover {
  color: var(--brand);
  text-decoration: underline;
}

/* 返回顶部 */
.to-top {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  display: grid;
  place-items: center;
  box-shadow: 0 6px 18px rgba(124, 58, 237, 0.35);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
  z-index: 90;
}
.to-top.is-show {
  opacity: 1;
  visibility: visible;
}
.to-top svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ============================ 响应式 ============================ */
@media (max-width: 1024px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: static;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  }
  .search-box input {
    width: 150px;
  }
}

@media (max-width: 768px) {
  .topbar-links {
    display: none;
  }
  .header-inner {
    flex-wrap: wrap;
    padding: 10px 0;
    gap: 12px;
  }
  .nav {
    order: 3;
    width: 100%;
    margin-left: 0;
    padding-bottom: 4px;
  }
  .hero {
    padding: 24px 0;
  }
  .hero h1 {
    font-size: 21px;
  }
  .post-card {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .post-thumb {
    aspect-ratio: 16 / 9;
  }
  .post-title {
    font-size: 16px;
  }
  .article-header {
    padding: 20px 18px 16px;
  }
  .article-title {
    font-size: 20px;
  }
  .article-content {
    padding: 18px;
  }
  .post-nav {
    grid-template-columns: 1fr;
  }
  .post-nav a.next {
    text-align: left;
  }
  .sidebar {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .container {
    padding: 0 14px;
  }
  .logo-text {
    font-size: 17px;
  }
  .search-box {
    display: none;
  }
  .dl-buttons {
    flex-direction: column;
  }
  .btn {
    justify-content: center;
  }
}

/* ============================ 用户登录 / 注册 ============================ */
/* 头部用户按钮：图标 + 文字 */
.user-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: auto;
  padding: 0 14px;
  border-radius: 999px;
}
.user-btn span {
  font-size: 13px;
  font-weight: 600;
  color: inherit;
  white-space: nowrap;
}
.user-btn .caret {
  width: 12px;
  height: 12px;
  opacity: 0.7;
}

/* 已登录下拉菜单 */
.user-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 200px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-hover);
  padding: 8px;
  z-index: 60;
}
.user-menu[hidden] { display: none; }
.user-menu-head {
  padding: 8px 10px 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}
.user-menu-head strong {
  display: block;
  font-size: 14px;
  color: var(--text);
}
.user-menu-head small {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  color: var(--text-mute);
  word-break: break-all;
}
.user-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border-radius: 8px;
  font-size: 14px;
  color: var(--danger);
}
.user-menu-item:hover {
  background: var(--bg-soft);
}
.user-menu-item svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* 弹窗遮罩（复用后台 .mask 思路，适配前台主题变量） */
.mask {
  position: fixed;
  inset: 0;
  background: rgba(15, 18, 30, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 24px;
  backdrop-filter: blur(2px);
}
.mask[hidden] { display: none; }

.user-login {
  position: relative;
  width: 100%;
  max-width: 400px;
  max-height: 92vh;
  overflow-y: auto;
  padding: 28px 30px;
  background: var(--surface);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(15, 18, 30, 0.28);
}
.mask-close {
  position: absolute;
  top: 12px;
  right: 14px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 20px;
  line-height: 1;
  color: var(--text-mute);
}
.mask-close:hover {
  background: var(--bg-soft);
  color: var(--text);
}
.user-login .login-title {
  font-size: 20px;
  color: var(--text);
}
.user-login .login-sub {
  font-size: 13px;
  color: var(--text-mute);
  margin: 4px 0 18px;
}

/* 未登录点击下载时的提示条 */
.download-notice {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: -8px 0 16px;
  padding: 9px 12px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-radius: 10px;
}
.download-notice[hidden] { display: none; }
.download-notice svg {
  flex: none;
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.download-notice .notice-text { flex: 1; }

/* 登录 / 注册分段切换 */
.useg {
  display: flex;
  gap: 4px;
  padding: 4px;
  margin-bottom: 18px;
  background: var(--bg-soft);
  border-radius: 999px;
}
.useg-btn {
  flex: 1;
  padding: 8px 0;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-soft);
}
.useg-btn.is-active {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3);
}
.useg-body[hidden] { display: none; }

/* 表单字段 */
.user-login .field {
  margin-bottom: 14px;
}
.user-login .field label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.user-login .field label em {
  color: var(--brand);
  font-style: normal;
}
.user-login .field input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
}
.user-login .field input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.15);
}
.field-hint {
  display: block;
  margin-top: 5px;
  font-size: 12px;
  color: var(--text-mute);
}
.user-login .login-err {
  min-height: 18px;
  margin: 4px 0 10px;
  font-size: 13px;
  color: #e03131;
}
/* 验证码：输入框 + 发送按钮同行 */
.user-login .code-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.user-login .code-row input {
  flex: 1;
  min-width: 0;
  letter-spacing: 2px;
  font-variant-numeric: tabular-nums;
}
.user-login .btn-send-code {
  flex: 0 0 auto;
  padding: 0 14px;
  border: 1px solid var(--brand);
  border-radius: 10px;
  background: var(--brand);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.18s ease;
  white-space: nowrap;
}
.user-login .btn-send-code:hover:not(:disabled) {
  opacity: 0.88;
}
.user-login .btn-send-code:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.user-login .btn-block {
  width: 100%;
  justify-content: center;
  margin-top: 2px;
}

/* 响应式：窄屏下用户按钮只留图标 */
@media (max-width: 768px) {
  .user-btn span {
    display: none;
  }
  .user-btn {
    width: 38px;
    padding: 0;
  }
}

/* 尊重系统的减少动效设置 */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
