/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", Helvetica, Arial, sans-serif;
  background: #0f0f1a;
  color: #e8e8f0;
  min-height: 100vh;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button { cursor: pointer; border: none; outline: none; font-family: inherit; }
input { outline: none; font-family: inherit; }
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #333; border-radius: 2px; }

/* ===== HEADER ===== */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  padding: 0 16px;
  height: 52px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.header-back {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 22px;
  transition: opacity 0.2s;
  flex-shrink: 0;
}
.header-back:active { opacity: 0.6; }
#header-logo {
  height: 24px;
  width: auto;
  max-width: 80px;
  object-fit: contain;
  flex-shrink: 0;
}
.header-title {
  flex: 1;
  text-align: left;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.header-right {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 18px;
  flex-shrink: 0;
}

/* ===== HERO / 一言栏 ===== */
.motto-bar {
  padding: 14px 20px;
  text-align: center;
  font-size: 13px;
  color: rgba(255,255,255,0.5);
  letter-spacing: 0.5px;
  line-height: 1.6;
  background: #0f0f1a;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}

/* ===== COVER CAROUSEL（封面轮播） ===== */
.cover-carousel {
  position: relative;
  width: 100%;
  height: 150px;
  overflow: hidden;
  background: #0a0a16;
}
.cover-carousel img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.6s ease;
}
.cover-carousel img.active { opacity: 1; }
.cover-dots {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  z-index: 2;
}
.cover-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: rgba(255,255,255,0.4);
  transition: background 0.3s;
}
.cover-dot.active { background: #fff; }

/* 宽屏：完整显示图片（不裁切），居中限宽 */
@media (min-width: 768px) {
  .cover-carousel {
    max-width: 760px;
    margin: 0 auto;
    height: 240px;
    border-radius: 0 0 14px 14px;
  }
  .cover-carousel img {
    object-fit: contain;
    background: #0a0a16;
  }
  .cover-dots { bottom: 12px; }
}

/* ===== 访问权限门（密码 / 部分预览 / 引导） ===== */
.gate-box {
  margin: 16px 0;
  padding: 20px 18px;
  background: rgba(99,102,241,0.06);
  border: 1px solid rgba(99,102,241,0.25);
  border-radius: 14px;
  text-align: center;
}
.gate-guide-img {
  max-width: 100%;
  max-height: 220px;
  border-radius: 10px;
  margin: 0 auto 12px;
  display: block;
}
.gate-guide-text {
  font-size: 14px;
  line-height: 1.7;
  color: rgba(255,255,255,0.78);
  text-align: left;
  margin-bottom: 14px;
}
.gate-guide-text p { margin: 0 0 8px; }
.gate-input-row {
  display: flex;
  gap: 8px;
  max-width: 340px;
  margin: 0 auto;
}
.gate-pwd {
  flex: 1;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.05);
  color: #fff;
  font-size: 14px;
  outline: none;
}
.gate-pwd:focus { border-color: rgba(139,92,246,0.6); }
.gate-btn {
  padding: 10px 20px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg,#6366f1,#8b5cf6);
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}
.gate-btn:active { transform: scale(0.97); }
.gate-btn:disabled { opacity: 0.6; }
.gate-msg {
  color: #ff8080;
  font-size: 13px;
  margin-top: 10px;
  min-height: 18px;
}

.detail-preview {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 15px;
  line-height: 1.9;
  color: rgba(255,255,255,0.9);
  background: rgba(255,255,255,0.04);
  border-left: 3px solid rgba(99,102,241,0.5);
  border-radius: 8px;
  padding: 14px 16px;
  margin: 14px 0;
}

/* ===== SEARCH BAR ===== */
.search-bar {
  padding: 12px 16px 16px;
  background: #0f0f1a;
}
.search-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 0 14px;
  height: 42px;
  transition: border-color 0.2s;
}
.search-wrap:focus-within { border-color: rgba(99,102,241,0.5); }
.search-icon { color: rgba(255,255,255,0.4); font-size: 15px; flex-shrink: 0; }
.search-input {
  flex: 1;
  background: none;
  border: none;
  color: #e8e8f0;
  font-size: 14px;
}
.search-input::placeholder { color: rgba(255,255,255,0.3); }
.search-clear {
  color: rgba(255,255,255,0.3);
  font-size: 16px;
  display: none;
  padding: 4px;
  transition: color 0.2s;
}
.search-clear.show { display: block; }
.search-clear:active { color: rgba(255,255,255,0.6); }

/* ===== SECTION ===== */
.section { padding: 16px; }
.section-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.section-title {
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 6px;
}
.section-title::before {
  content: '';
  width: 3px;
  height: 16px;
  background: linear-gradient(180deg, #6366f1, #8b5cf6);
  border-radius: 2px;
}

/* ===== CATEGORY GRID ===== */
.cat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.cat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 8px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 12px;
  transition: all 0.2s;
  cursor: pointer;
}
.cat-item:active { transform: scale(0.96); background: rgba(255,255,255,0.07); }
.cat-icon {
  width: 44px; height: 44px;
  border-radius: 12px;
  object-fit: cover;
  background: rgba(99,102,241,0.15);
}
.cat-icon-text {
  width: 44px; height: 44px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  background: linear-gradient(135deg, rgba(99,102,241,0.3), rgba(139,92,246,0.3));
}
.cat-name { font-size: 12px; color: rgba(255,255,255,0.8); text-align: center; }

/* ===== ARTICLE LIST ===== */
.list-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.art-item {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 12px;
  overflow: hidden;
  transition: all 0.2s;
  cursor: pointer;
  display: block;
}
.art-item:active { transform: scale(0.98); }
.art-cover {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  background: rgba(255,255,255,0.04);
}
.art-cover-wrap { position: relative; overflow: hidden; }
.art-count {
  position: absolute;
  bottom: 6px; right: 6px;
  background: rgba(0,0,0,0.6);
  color: #fff;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  backdrop-filter: blur(4px);
}
.art-info { padding: 10px 10px 12px; }
.art-title {
  font-size: 13px;
  color: #e8e8f0;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 6px;
}
.art-meta {
  font-size: 11px;
  color: rgba(255,255,255,0.35);
}

/* ===== LOAD MORE ===== */
.load-more {
  text-align: center;
  padding: 24px 16px 40px;
}
.load-more-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 28px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 20px;
  color: rgba(255,255,255,0.6);
  font-size: 13px;
  transition: all 0.2s;
}
.load-more-btn:active { background: rgba(255,255,255,0.1); }
.load-more-btn.loading { opacity: 0.5; pointer-events: none; }

/* ===== DETAIL PAGE ===== */
.detail-cover {
  width: 100%;
  max-height: 300px;
  object-fit: cover;
  background: rgba(255,255,255,0.04);
}

/* 图片轮播预览（横向滑动，完整显示图片） */
.detail-swiper {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  gap: 10px;
  padding: 12px 16px;
  scrollbar-width: none;
  -ms-overflow-style: none;
  background: #0a0a16;
  align-items: flex-start;
}
.detail-swiper::-webkit-scrollbar { display: none; }
.detail-swiper-item {
  flex-shrink: 0;
  width: 160px;
  height: 220px;
  scroll-snap-align: start;
  border-radius: 10px;
  overflow: hidden;
  position: relative;
  cursor: pointer;
  background: rgba(255,255,255,0.04);
}
.detail-swiper-item img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: transform 0.2s;
  background: #0a0a16;
}
.detail-swiper-item:active img { transform: scale(0.97); }
.detail-swiper-count {
  position: absolute;
  bottom: 8px; right: 8px;
  background: rgba(0,0,0,0.65);
  color: #fff;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  backdrop-filter: blur(4px);
}
.detail-swiper-empty {
  padding: 24px 16px;
  color: rgba(255,255,255,0.25);
  font-size: 13px;
  text-align: center;
}

/* 详情正文 MD 内容 */
.detail-wrap { padding: 16px; }
.detail-body {
  color: rgba(255,255,255,0.88);
  font-size: 15px;
  line-height: 1.9;
  word-break: break-word;
  overflow-wrap: break-word;
}
.detail-body h1,
.detail-body h2,
.detail-body h3,
.detail-body h4 {
  color: #fff;
  font-weight: 700;
  margin: 20px 0 10px;
  line-height: 1.4;
}
.detail-body h1 { font-size: 20px; }
.detail-body h2 { font-size: 17px; border-bottom: 1px solid rgba(255,255,255,0.08); padding-bottom: 6px; }
.detail-body h3 { font-size: 15px; }
.detail-body h4 { font-size: 14px; }
.detail-body p { margin-bottom: 12px; }
.detail-body strong { color: #fff; font-weight: 600; }
.detail-body em { color: rgba(255,255,255,0.7); font-style: italic; }
.detail-body a {
  color: #818cf8;
  text-decoration: underline;
  text-underline-offset: 2px;
  word-break: break-all;
}
.detail-body a:active { color: #a5b4fc; }
.detail-body blockquote {
  margin: 12px 0;
  padding: 12px 16px;
  background: rgba(99,102,241,0.1);
  border-left: 3px solid #6366f1;
  border-radius: 0 8px 8px 0;
  color: rgba(255,255,255,0.75);
}
.detail-body blockquote p { margin-bottom: 0; }
.detail-body hr {
  border: none;
  border-top: 1px solid rgba(255,255,255,0.1);
  margin: 20px 0;
}
.detail-body ul,
.detail-body ol {
  margin: 8px 0 12px 20px;
}
.detail-body li { margin-bottom: 6px; }
.detail-body code {
  font-family: 'Fira Code', 'Cascadia Code', Consolas, monospace;
  font-size: 13px;
  background: rgba(255,255,255,0.08);
  padding: 2px 6px;
  border-radius: 4px;
  color: #c4b5fd;
  word-break: break-all;
}
.detail-body pre {
  background: rgba(0,0,0,0.4);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  padding: 14px;
  overflow-x: auto;
  margin: 12px 0;
}
.detail-body pre code {
  background: none;
  padding: 0;
  font-size: 12px;
  color: #e2e8f0;
}
.detail-body img {
  max-width: 100%;
  border-radius: 8px;
  margin: 12px auto;
  cursor: pointer;
  transition: transform 0.2s;
}
.detail-body img:active { transform: scale(0.98); }

/* 详情页底部图片网格（备用） */
.detail-images {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 16px;
}
.detail-images img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.2s;
}
.detail-images img:active { transform: scale(0.97); }

.detail-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 16px;
  font-size: 12px;
  color: rgba(255,255,255,0.4);
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.detail-meta span { white-space: nowrap; }

/* ===== SEARCH RESULTS ===== */
.search-panel { display: none; flex-direction: column; }
.search-panel.active { display: flex; }
.suggest-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  color: rgba(255,255,255,0.8);
  font-size: 14px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  transition: background 0.15s;
  cursor: pointer;
}
.suggest-item:active { background: rgba(255,255,255,0.05); }
.suggest-empty { text-align: center; padding: 32px 16px; color: rgba(255,255,255,0.3); font-size: 13px; }

/* ===== EMPTY / LOADING ===== */
.empty-state { text-align: center; padding: 48px 16px; color: rgba(255,255,255,0.3); }
.empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-text { font-size: 14px; }
.loading-state {
  display: flex; align-items: center; justify-content: center;
  padding: 40px;
  color: rgba(255,255,255,0.3);
  font-size: 14px;
  gap: 8px;
}
.spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,0.1);
  border-top-color: #6366f1;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== LIGHTBOX ===== */
.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 999;
  background: rgba(0,0,0,0.95);
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 16px;
}
.lightbox.active { display: flex; }
.lightbox-img {
  max-width: 100%;
  max-height: 85vh;
  object-fit: contain;
  border-radius: 8px;
}
.lightbox-close {
  position: absolute;
  top: 12px; right: 12px;
  width: 36px; height: 36px;
  background: rgba(255,255,255,0.12);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 20px;
  backdrop-filter: blur(8px);
}
.lightbox-counter {
  margin-top: 12px;
  font-size: 13px;
  color: rgba(255,255,255,0.5);
}
.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 40px; height: 40px;
  background: rgba(255,255,255,0.12);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 20px;
  backdrop-filter: blur(8px);
  cursor: pointer;
  user-select: none;
}
.lightbox-nav:active { background: rgba(255,255,255,0.2); }
.lightbox-prev { left: 8px; }
.lightbox-next { right: 8px; }

/* ===== FOOTER ===== */
.footer {
  text-align: center;
  padding: 24px 16px 40px;
  border-top: 1px solid rgba(255,255,255,0.04);
  margin-top: 16px;
}
.join-group-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 26px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  border-radius: 22px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 4px 15px rgba(99,102,241,0.3);
  transition: transform 0.15s;
}
.join-group-link:active { transform: scale(0.96); }

/* ===== UTILS ===== */
.hidden { display: none !important; }

/* ===== RESPONSIVE - 平板 ===== */
@media (min-width: 480px) {
  .cat-grid { grid-template-columns: repeat(4, 1fr); }
  .list-grid { grid-template-columns: repeat(3, 1fr); }
  .detail-swiper-item { width: 150px; height: 200px; }
}

/* ===== RESPONSIVE - 小桌面 / 大平板 ===== */
@media (min-width: 768px) {
  body { font-size: 15px; }
  .hero { min-height: 220px; padding: 48px 32px 36px; }
  .hero-title { font-size: 30px; }
  .cat-grid { grid-template-columns: repeat(5, 1fr); gap: 14px; }
  .cat-item { padding: 20px 10px; }
  .cat-icon { width: 52px; height: 52px; }
  .cat-icon-text { width: 52px; height: 52px; font-size: 26px; }
  .cat-name { font-size: 13px; }
  .list-grid { grid-template-columns: repeat(4, 1fr); gap: 14px; }
  .art-title { font-size: 14px; }
  .section { padding: 20px; }
  .search-bar { padding: 14px 20px 18px; }
  /* PC 端：预览图固定高度，显示完整图片 */
  .detail-swiper { padding: 14px 20px; gap: 12px; }
  .detail-swiper-item { width: 140px; height: 180px; border-radius: 8px; }
  /* PC 端正文居中，最大宽度约束 */
  .detail-wrap { max-width: 720px; margin: 0 auto; padding: 20px; }
  .detail-body { font-size: 16px; }
  .detail-body h1 { font-size: 22px; }
  .detail-body h2 { font-size: 18px; }
}

/* ===== RESPONSIVE - 桌面 ===== */
@media (min-width: 1024px) {
  body { font-size: 16px; }
  .hero { min-height: 280px; padding: 56px 40px 40px; }
  .cat-grid { grid-template-columns: repeat(6, 1fr); max-width: 960px; margin: 0 auto; }
  .list-grid { grid-template-columns: repeat(4, 1fr); max-width: 960px; margin: 0 auto; }
  /* PC 桌面：预览图稍大 */
  .detail-swiper-item { width: 160px; height: 210px; }
  .detail-wrap { max-width: 860px; }
}
