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

:root {
  --color-bg: #fafaf8;
  --color-card: #fff;
  --color-text: #2c2c2c;
  --color-text-muted: #888;
  --color-accent: #d23669;
  --color-link: #1a73e8;
  --color-border: #e8e8e4;
  --font-sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --font-mono: "SF Mono", "Fira Code", "Cascadia Code", monospace;
  --max-width: 720px;
  --radius: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06);
}

html {
  font-size: 17px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  font-family: var(--font-sans);
  color: var(--color-text);
  background: var(--color-bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

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

/* ===== Header ===== */
.header {
  background: var(--color-card);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(8px);
}

.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 52px;
}

.logo {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--color-text) !important;
  letter-spacing: 0.5px;
}

.nav { display: flex; gap: 20px; }
.nav a {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  transition: color 0.15s;
}
.nav a:hover, .nav a.active { color: var(--color-accent); text-decoration: none; }

/* ===== Main ===== */
.main {
  flex: 1;
  max-width: var(--max-width);
  width: 100%;
  margin: 0 auto;
  padding: 32px 20px 60px;
}

/* ===== Home Hero ===== */
.hero {
  text-align: center;
  padding: 40px 0 24px;
}

.hero h1 {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: 2px;
  color: var(--color-text);
}

.hero-desc {
  color: var(--color-text-muted);
  font-size: 0.95rem;
  margin-top: 8px;
}

/* ===== Post Card ===== */
.post-card {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s;
}
.post-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.08); }

.post-card-img img {
  display: block;
  width: 100%;
  height: 200px;
  object-fit: cover;
}

.post-card-body { padding: 18px 22px; }
.post-card-body h2 { font-size: 1.15rem; font-weight: 700; line-height: 1.5; }
.post-card-body h2 a { color: var(--color-text); }
.post-card-body h2 a:hover { color: var(--color-accent); text-decoration: none; }

.post-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 6px 0;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.tag {
  display: inline-block;
  color: var(--color-text-muted) !important;
  font-size: 0.78rem;
}
.tag:hover { color: var(--color-accent) !important; text-decoration: none; }

.post-excerpt {
  color: var(--color-text-muted);
  font-size: 0.9rem;
  margin-top: 8px;
  line-height: 1.65;
}

.series { font-size: 0.82rem; color: var(--color-text-muted); }

/* ===== Single Post ===== */
.post-header {
  margin-bottom: 32px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--color-border);
}

.post-header h1 {
  font-size: 1.7rem;
  font-weight: 800;
  line-height: 1.4;
  letter-spacing: 0.5px;
}

.post-body {
  font-size: 1rem;
  line-height: 1.85;
  letter-spacing: 0.3px;
}

.post-body h2 {
  font-size: 1.3rem;
  margin: 32px 0 16px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--color-border);
}

.post-body h3 {
  font-size: 1.1rem;
  margin: 24px 0 12px;
}

.post-body p { margin-bottom: 16px; }
.post-body blockquote {
  border-left: 3px solid var(--color-accent);
  padding: 8px 16px;
  margin: 16px 0;
  color: var(--color-text-muted);
  background: rgba(210, 54, 105, 0.04);
  border-radius: 0 var(--radius) var(--radius) 0;
}

.post-body ul, .post-body ol { padding-left: 24px; margin-bottom: 16px; }
.post-body li { margin-bottom: 4px; }

.post-body code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: rgba(0,0,0,0.06);
  padding: 2px 6px;
  border-radius: 3px;
}

.post-body pre {
  background: #1e1e1e;
  color: #d4d4d4;
  padding: 16px 20px;
  border-radius: var(--radius);
  overflow-x: auto;
  margin: 16px 0;
  font-size: 0.85rem;
  line-height: 1.6;
}

.post-body pre code {
  background: none;
  padding: 0;
  font-size: inherit;
  color: inherit;
}

.post-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 0.9rem;
}

.post-body th, .post-body td {
  border: 1px solid var(--color-border);
  padding: 8px 12px;
  text-align: left;
}

.post-body th {
  background: rgba(0,0,0,0.03);
  font-weight: 600;
}

.post-body hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: 32px 0;
}

.post-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 48px;
  padding-top: 20px;
  border-top: 1px solid var(--color-border);
  font-size: 0.9rem;
}

/* ===== 9-Grid Gallery ===== */
.gallery-9grid {
  display: grid;
  grid-template-columns: repeat(var(--cols, 3), 1fr);
  gap: 4px;
  margin: 20px 0;
  border-radius: var(--radius);
  overflow: hidden;
}

.gallery-item {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  cursor: pointer;
  background: #eee;
}

.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s;
}

.gallery-item:hover img { transform: scale(1.05); }

.gallery-caption {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(transparent, rgba(0,0,0,0.6));
  color: #fff;
  font-size: 0.75rem;
  padding: 20px 8px 6px;
}

/* ===== Lightbox ===== */
#lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0,0,0,0.92);
  justify-content: center;
  align-items: center;
  cursor: zoom-out;
}

#lightbox.active { display: flex; }

.lb-img {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.5);
}

.lb-close {
  position: absolute;
  top: 20px;
  right: 24px;
  color: #fff;
  font-size: 2rem;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.2s;
}
.lb-close:hover { opacity: 1; }

/* ===== Password Protection ===== */
.protected-content .protected-body { display: none; }
.protected-content.unlocked .protected-body { display: block; }
.protected-content.unlocked .protected-prompt { display: none; }

.protected-prompt {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 200px;
}

.pw-box {
  text-align: center;
  padding: 32px;
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.pw-box h3 { margin-bottom: 16px; font-size: 1rem; color: var(--color-text); }

.pw-box input {
  padding: 8px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  width: 180px;
  outline: none;
}
.pw-box input:focus { border-color: var(--color-accent); }

.pw-box button {
  padding: 8px 20px;
  margin-left: 8px;
  background: var(--color-accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 0.9rem;
  cursor: pointer;
  transition: opacity 0.2s;
}
.pw-box button:hover { opacity: 0.85; }

.pw-error { margin-top: 10px; }

/* ===== Section Page ===== */
.section-page h1 {
  font-size: 1.5rem;
  margin-bottom: 24px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--color-border);
}

/* ===== Footer ===== */
.footer {
  background: var(--color-card);
  border-top: 1px solid var(--color-border);
  padding: 24px 20px;
  text-align: center;
  font-size: 0.82rem;
  color: var(--color-text-muted);
}

.footer-sub { font-size: 0.75rem; margin-top: 4px; opacity: 0.7; }

/* ===== Pagination ===== */
.pagination {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-top: 32px;
  font-size: 0.9rem;
}

/* ===== Tags Page ===== */
.tags-cloud { display: flex; flex-wrap: wrap; gap: 10px; margin: 20px 0; }
.tags-cloud .tag { font-size: 0.95rem; }

/* ===== Responsive ===== */
@media (max-width: 600px) {
  html { font-size: 15px; }
  .header-inner { padding: 0 14px; }
  .main { padding: 24px 14px 48px; }
  .nav { gap: 12px; }
  .hero { padding: 24px 0 16px; }
  .hero h1 { font-size: 1.6rem; }
  .gallery-9grid { grid-template-columns: repeat(3, 1fr); gap: 2px; }
  .post-card-body { padding: 14px 16px; }
}
