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

:root {
  --bg: #ffffff;
  --bg-secondary: #f8f9fa;
  --text: #1a1a2e;
  --text-secondary: #6c757d;
  --border: #e9ecef;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --card-bg: #ffffff;
  --tag-bg: #eef2ff;
  --tag-text: #4f46e5;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --radius: 8px;
  --max-width: 720px;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Cascadia Code', Consolas, monospace;
}

[data-theme="dark"] {
  --bg: #0f172a;
  --bg-secondary: #1e293b;
  --text: #e2e8f0;
  --text-secondary: #94a3b8;
  --border: #334155;
  --accent: #60a5fa;
  --accent-hover: #3b82f6;
  --card-bg: #1e293b;
  --tag-bg: #1e1b4b;
  --tag-text: #a5b4fc;
  --shadow: 0 1px 3px rgba(0,0,0,0.3);
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  transition: background .3s, color .3s;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

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

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

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

[data-theme="dark"] .header {
  background: rgba(15,23,42,.85);
}

.header-inner {
  display: flex;
  align-items: center;
  height: 56px;
  gap: 24px;
}

.logo {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.02em;
}
.logo:hover { color: var(--accent); }

.nav { display: flex; gap: 8px; flex: 1; }

.nav-link {
  color: var(--text-secondary);
  font-size: .9rem;
  padding: 4px 12px;
  border-radius: 6px;
  transition: all .2s;
}
.nav-link:hover,
.nav-link.active {
  color: var(--text);
  background: var(--bg-secondary);
}

.header-actions { display: flex; gap: 4px; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all .2s;
}
.icon-btn:hover {
  background: var(--bg-secondary);
  color: var(--text);
}

[data-theme="dark"] .sun-icon { display: none; }
[data-theme="light"] .moon-icon { display: none; }

/* Search Bar */
.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
}
.search-bar[hidden] { display: none; }

.search-input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: .9rem;
  outline: none;
  transition: border-color .2s;
}
.search-input:focus { border-color: var(--accent); }

/* ===== Main ===== */
.main {
  flex: 1;
  padding-top: 40px;
  padding-bottom: 60px;
}
.main-home {
  max-width: 960px;
}

/* ===== Section Header ===== */
.section-header {
  margin-bottom: 24px;
}
.section-header h2 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -.01em;
}
.section-footer {
  text-align: center;
  margin-top: 20px;
}
.see-all {
  display: inline-block;
  font-size: .9rem;
  color: var(--text-secondary);
  padding: 8px 20px;
  border: 1px solid var(--border);
  border-radius: 6px;
  transition: all .2s;
}
.see-all:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* ===== Hero ===== */
.hero {
  padding: 40px 0 0;
}
.hero-inner {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 64px;
  align-items: start;
}
.hero-left {
  position: sticky;
  top: 80px;
}
.hero-avatar {
  width: 80px;
  height: 80px;
  margin-bottom: 16px;
  border-radius: 50%;
  overflow: hidden;
}
.hero-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}
.hero-avatar-placeholder {
  display: block;
  width: 80px;
  height: 80px;
}
.hero-name {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 4px;
  letter-spacing: -.02em;
}
.hero-slogan {
  font-size: .95rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
  line-height: 1.5;
}
.hero-bio {
  font-size: .88rem;
  color: var(--text-secondary);
  line-height: 1.6;
}
.hero-motto {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: .88rem;
  color: var(--text-secondary);
  line-height: 1.5;
  font-style: italic;
}
.hero-motto::before {
  content: '\201C';
  margin-right: 2px;
}
.hero-motto::after {
  content: '\201D';
  margin-left: 2px;
}
.hero-stats {
  margin-top: 20px;
}
.hero-stat {
  font-size: .85rem;
  color: var(--text-secondary);
}
.hero-stat strong {
  font-size: 1.1rem;
  color: var(--text);
  font-weight: 600;
  display: block;
}
.hero-right .section-header {
  margin-bottom: 20px;
}
.hero-right .section-header h2 {
  font-size: 1rem;
}
.hero-right .post-card {
  padding: 16px 20px;
}

/* ===== Post List ===== */
.post-list { display: flex; flex-direction: column; gap: 32px; }

.post-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  transition: box-shadow .2s, transform .2s;
  cursor: pointer;
}
.post-card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.post-card-title {
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
  line-height: 1.4;
}
.post-card-title:hover { color: var(--accent); }

.post-card-meta {
  font-size: .85rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.post-card-excerpt {
  font-size: .95rem;
  color: var(--text-secondary);
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; }

.tag {
  display: inline-block;
  padding: 2px 10px;
  font-size: .8rem;
  border-radius: 12px;
  background: var(--tag-bg);
  color: var(--tag-text);
}

/* ===== Post Detail ===== */
.post-detail { max-width: var(--max-width); }

.post-detail-title {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 16px;
}

.post-detail-meta {
  font-size: .9rem;
  color: var(--text-secondary);
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}

.post-content {
  font-size: 1rem;
  line-height: 1.8;
  color: var(--text);
}
.post-content h2 {
  font-size: 1.5rem;
  margin: 32px 0 12px;
  font-weight: 600;
}
.post-content h3 {
  font-size: 1.2rem;
  margin: 24px 0 8px;
  font-weight: 600;
}
.post-content p { margin-bottom: 16px; }
.post-content ul, .post-content ol { margin-bottom: 16px; padding-left: 24px; }
.post-content li { margin-bottom: 4px; }
.post-content blockquote {
  margin: 16px 0;
  padding: 12px 20px;
  border-left: 3px solid var(--accent);
  background: var(--bg-secondary);
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--text-secondary);
}
.post-content code {
  font-family: var(--font-mono);
  font-size: .9em;
  padding: 2px 6px;
  background: var(--bg-secondary);
  border-radius: 4px;
}
.post-content pre {
  margin: 16px 0;
  padding: 16px;
  background: var(--bg-secondary);
  border-radius: var(--radius);
  overflow-x: auto;
}
.post-content pre code {
  padding: 0;
  background: none;
}
.post-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: .9rem;
}
.post-content th,
.post-content td {
  padding: 10px 14px;
  border: 1px solid var(--border);
  text-align: left;
}
.post-content th {
  background: var(--bg-secondary);
  font-weight: 600;
}
.post-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 32px 0;
}

/* ===== Comments ===== */
.comments-section {
  margin-top: 48px;
  padding-top: 32px;
  border-top: 1px solid var(--border);
}
.comments-title {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 20px;
}

.comment-form { margin-bottom: 24px; }

.comment-input {
  width: 100%;
  min-height: 80px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: .9rem;
  resize: vertical;
  outline: none;
  transition: border-color .2s;
}
.comment-input:focus { border-color: var(--accent); }

.comment-form-bottom {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.comment-name-input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: .9rem;
  outline: none;
  transition: border-color .2s;
}
.comment-name-input:focus { border-color: var(--accent); }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 20px;
  border: none;
  border-radius: 6px;
  font-size: .9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all .2s;
  white-space: nowrap;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); }

.comment-list { display: flex; flex-direction: column; gap: 16px; }

.comment-item {
  padding: 16px;
  background: var(--bg-secondary);
  border-radius: var(--radius);
}
.comment-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.comment-author {
  font-weight: 600;
  font-size: .9rem;
}
.comment-time {
  font-size: .8rem;
  color: var(--text-secondary);
}
.comment-body {
  font-size: .9rem;
  line-height: 1.6;
}
.comment-empty {
  text-align: center;
  color: var(--text-secondary);
  font-size: .9rem;
  padding: 24px 0;
}

/* ===== About ===== */
.about-section { max-width: var(--max-width); }

.about-title {
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 8px;
}
.about-subtitle {
  color: var(--text-secondary);
  margin-bottom: 32px;
}

.about-content { line-height: 1.8; }
.about-content p { margin-bottom: 16px; }

.social-links {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}
.social-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: .9rem;
  color: var(--text);
  transition: all .2s;
}
.social-link:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--tag-bg);
}

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}
.empty-state-icon { margin-bottom: 12px; opacity: .4; }
.empty-state-text { font-size: .95rem; }

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

/* ===== Back to Top ===== */
.back-to-top {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all .3s;
  box-shadow: 0 2px 8px rgba(37,99,235,.3);
  z-index: 99;
}
.back-to-top.visible {
  opacity: 1;
  visibility: visible;
}
.back-to-top:hover {
  background: var(--accent-hover);
  transform: translateY(-2px);
}

/* ===== Loading ===== */
.loading {
  text-align: center;
  padding: 60px 0;
  color: var(--text-secondary);
}
.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .6s linear infinite;
  margin: 0 auto 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Responsive ===== */
@media (max-width: 640px) {
  .hero { padding: 24px 0 0; }
  .hero-inner { grid-template-columns: 1fr; gap: 32px; }
  .hero-left { position: static; }
  .hero-name { font-size: 1.35rem; }
  .hero-slogan { font-size: .95rem; }
  .post-detail-title { font-size: 1.5rem; }
  .header-inner { height: 48px; }
  .main { padding-top: 24px; padding-bottom: 40px; }
  .post-card { padding: 16px; }
  .post-card-title { font-size: 1.15rem; }
  .post-detail-meta { gap: 12px; flex-direction: column; }
  .social-links { flex-direction: column; }
}
