/* ===== CSS Variables ===== */
:root {
  --bg: #ffffff;
  --bg-secondary: #f9fafb;
  --text: #111827;
  --text-secondary: #6b7280;
  --border: #e5e7eb;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --card-bg: #ffffff;
  --card-shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --card-hover-shadow: 0 10px 25px rgba(0,0,0,.1);
  --tag-bg: #eff6ff;
  --tag-text: #1d4ed8;
  --radius: 8px;
  --max-width: 860px;
}

[data-theme="dark"] {
  --bg: #0f172a;
  --bg-secondary: #1e293b;
  --text: #f1f5f9;
  --text-secondary: #94a3b8;
  --border: #334155;
  --primary: #60a5fa;
  --primary-hover: #3b82f6;
  --card-bg: #1e293b;
  --card-shadow: 0 1px 3px rgba(0,0,0,.3);
  --card-hover-shadow: 0 10px 25px rgba(0,0,0,.4);
  --tag-bg: #1e3a5f;
  --tag-text: #93c5fd;
}

/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  transition: background .3s, color .3s;
  min-height: 100vh;
}

#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

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

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

img { max-width: 100%; height: auto; }

/* ===== Header ===== */
.header {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(8px);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}
.logo {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text) !important;
}
.nav { display: flex; gap: 24px; }
.nav a {
  color: var(--text-secondary);
  font-size: .95rem;
  transition: color .2s;
}
.nav a:hover, .nav a.active { color: var(--primary); }

.theme-btn, .menu-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 10px;
  cursor: pointer;
  font-size: 1.1rem;
  color: var(--text);
  transition: background .2s;
}
.theme-btn:hover, .menu-btn:hover { background: var(--bg-secondary); }
.menu-btn { display: none; }

/* Mobile nav */
.mobile-nav {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 12px 0;
  display: flex;
  flex-direction: column;
}
.mobile-nav a {
  padding: 10px 20px;
  color: var(--text-secondary);
  font-size: 1rem;
}
.mobile-nav a:hover { color: var(--primary); background: var(--bg-secondary); }
.mobile-nav.hidden { display: none; }

/* ===== Main ===== */
.main { flex: 1; padding-top: 40px; padding-bottom: 60px; }
.loading { text-align: center; color: var(--text-secondary); padding: 60px 0; }

/* ===== Post Cards (Homepage) ===== */
.post-list { display: flex; flex-direction: column; gap: 20px; }

.post-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  transition: box-shadow .3s, transform .2s;
  cursor: pointer;
}
.post-card:hover {
  box-shadow: var(--card-hover-shadow);
  transform: translateY(-2px);
}
.post-card h2 {
  font-size: 1.4rem;
  margin-bottom: 8px;
  line-height: 1.4;
}
.post-card h2 a { color: var(--text); }
.post-card h2 a:hover { color: var(--primary); }

.post-meta {
  font-size: .85rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
  display: flex;
  gap: 16px;
  align-items: center;
}
.post-excerpt {
  color: var(--text-secondary);
  font-size: .95rem;
  line-height: 1.6;
}
.post-tags { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.tag {
  background: var(--tag-bg);
  color: var(--tag-text);
  padding: 2px 12px;
  border-radius: 20px;
  font-size: .8rem;
}

/* ===== Post Detail ===== */
.post-detail { max-width: 760px; margin: 0 auto; }
.post-detail h1 { font-size: 2rem; margin-bottom: 12px; line-height: 1.3; }
.post-detail .post-meta { margin-bottom: 32px; padding-bottom: 20px; border-bottom: 1px solid var(--border); }
.post-content {
  font-size: 1.05rem;
  line-height: 1.85;
}
.post-content h2 { font-size: 1.5rem; margin: 36px 0 16px; }
.post-content h3 { font-size: 1.25rem; margin: 28px 0 12px; }
.post-content p { margin-bottom: 18px; }
.post-content ul, .post-content ol { margin: 12px 0 18px 24px; }
.post-content li { margin-bottom: 6px; }
.post-content blockquote {
  border-left: 4px solid var(--primary);
  padding: 12px 20px;
  margin: 20px 0;
  background: var(--bg-secondary);
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--text-secondary);
}
.post-content code {
  background: var(--bg-secondary);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: .9em;
}
.post-content pre {
  background: #1e293b;
  color: #e2e8f0;
  padding: 20px;
  border-radius: var(--radius);
  overflow-x: auto;
  margin: 20px 0;
  line-height: 1.5;
  font-size: .9rem;
}
.post-content pre code { background: none; padding: 0; color: inherit; }
.post-content img { border-radius: var(--radius); margin: 20px 0; }
.post-content a { border-bottom: 1px dashed var(--primary); }
.post-content a:hover { border-bottom-style: solid; }

/* Back link */
.back-link {
  display: inline-block;
  margin-bottom: 24px;
  color: var(--text-secondary);
  font-size: .9rem;
  transition: color .2s;
}
.back-link:hover { color: var(--primary); }

/* ===== File & Video Cards ===== */
.section-title {
  font-size: 1.5rem;
  margin-bottom: 24px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--primary);
}

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

.file-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  transition: box-shadow .3s;
  display: flex;
  flex-direction: column;
}
.file-card:hover { box-shadow: var(--card-hover-shadow); }

.file-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
}
.file-card h3 {
  font-size: 1.05rem;
  margin-bottom: 6px;
  line-height: 1.4;
}
.file-card .file-meta {
  font-size: .8rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
}
.file-card .file-desc {
  font-size: .85rem;
  color: var(--text-secondary);
  flex: 1;
  margin-bottom: 14px;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.file-card .drive-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 4px;
  font-size: .75rem;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.btn {
  display: inline-block;
  padding: 9px 20px;
  background: var(--primary);
  color: #fff !important;
  border-radius: var(--radius);
  text-align: center;
  font-size: .9rem;
  font-weight: 500;
  transition: background .2s;
  border: none;
  cursor: pointer;
}
.btn:hover { background: var(--primary-hover); }
.btn-outline {
  background: transparent;
  color: var(--primary) !important;
  border: 1px solid var(--primary);
}
.btn-outline:hover { background: var(--primary); color: #fff !important; }

/* Video player */
.video-player {
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 20px;
}
.video-player video {
  width: 100%;
  display: block;
  max-height: 480px;
}

/* ===== About Page ===== */
.about-section {
  max-width: 700px;
  margin: 0 auto;
}
.about-section h1 { font-size: 1.8rem; margin-bottom: 20px; }
.about-section p { margin-bottom: 16px; color: var(--text-secondary); line-height: 1.8; }

/* ===== Tabs ===== */
.tabs {
  display: flex;
  gap: 0;
  margin-bottom: 24px;
  border-bottom: 2px solid var(--border);
}
.tab-btn {
  padding: 10px 24px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  font-size: .95rem;
  color: var(--text-secondary);
  transition: color .2s, border-color .2s;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* ===== Pagination ===== */
.pagination {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 32px;
}
.pagination button {
  padding: 8px 16px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: .9rem;
}
.pagination button:hover { background: var(--bg-secondary); }
.pagination button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination button:disabled { opacity: .4; cursor: not-allowed; }

/* ===== Search ===== */
.search-box {
  margin-bottom: 24px;
}
.search-box input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .95rem;
  background: var(--bg);
  color: var(--text);
  transition: border-color .2s;
}
.search-box input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: 60px 0;
  color: var(--text-secondary);
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 16px; }
.empty-state p { font-size: 1rem; }

/* ===== Footer ===== */
.footer {
  border-top: 1px solid var(--border);
  padding: 24px 0;
  text-align: center;
  font-size: .85rem;
  color: var(--text-secondary);
}

/* ===== Image Gallery ===== */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}
.gallery-item {
  position: relative;
  cursor: pointer;
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 4/3;
  background: var(--bg-secondary);
}
.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .3s;
}
.gallery-item:hover img { transform: scale(1.05); }
.gallery-overlay {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: 16px;
  background: linear-gradient(transparent, rgba(0,0,0,.7));
  color: #fff;
  font-size: .85rem;
  opacity: 0;
  transition: opacity .3s;
}
.gallery-item:hover .gallery-overlay { opacity: 1; }

/* Lightbox */
.lightbox {
  display: none;
  position: fixed;
  z-index: 9999;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,.92);
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
}
.lightbox.active { display: flex; }
.lightbox img {
  max-width: 90vw;
  max-height: 85vh;
  border-radius: 4px;
  cursor: default;
}
.lightbox-close {
  position: absolute;
  top: 16px; right: 24px;
  color: #fff;
  font-size: 2rem;
  cursor: pointer;
  z-index: 1;
}
.lightbox-close:hover { opacity: .7; }
.lightbox-caption {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  color: #ccc;
  font-size: .9rem;
  text-align: center;
  max-width: 80vw;
}
.lightbox-prev, .lightbox-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255,255,255,.1);
  border: none;
  color: #fff;
  font-size: 2rem;
  padding: 16px 12px;
  cursor: pointer;
  transition: background .2s;
  border-radius: 4px;
}
.lightbox-prev:hover, .lightbox-next:hover { background: rgba(255,255,255,.25); }
.lightbox-prev { left: 16px; }
.lightbox-next { right: 16px; }

/* ===== Responsive ===== */
@media (max-width: 640px) {
  .nav { display: none; }
  .menu-btn { display: block; }
  .header-inner { height: 52px; }
  .post-card { padding: 20px; }
  .post-card h2 { font-size: 1.15rem; }
  .post-detail h1 { font-size: 1.5rem; }
  .file-grid { grid-template-columns: 1fr; }
  .main { padding-top: 24px; }
  .post-content { font-size: 1rem; }
  .gallery-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .gallery-item { aspect-ratio: 1/1; }
  .lightbox-prev, .lightbox-next { font-size: 1.5rem; padding: 12px 8px; }
}

/* ===== Print ===== */
@media print {
  .header, .footer, .nav, .theme-btn, .menu-btn { display: none; }
  .post-detail { max-width: 100%; }
}
