:root {
  --primary: #10b981;
  --primary-hover: #059669;
  --bg-body: #f8fafc;
  --bg-card: rgba(255, 255, 255, 0.85);
  --text-main: #1e293b;
  --text-muted: #64748b;
  --border-color: rgba(226, 232, 240, 0.7);
  --glass-bg: rgba(255, 255, 255, 0.88);
  --glass-border: rgba(255, 255, 255, 0.3);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
  --shadow-lg: 0 10px 25px -5px rgba(0,0,0,0.05), 0 8px 10px -6px rgba(0,0,0,0.01);
  --shadow-emerald: 0 10px 20px -5px rgba(16, 185, 129, 0.3);
  --radius-lg: 1rem;
  --radius-xl: 1.25rem;
  --radius-full: 9999px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-body);
  color: var(--text-main);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

a {
  text-decoration: none;
  color: inherit;
  transition: var(--transition);
}

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

/* ── Container ── */
.container {
  width: 100%;
  max-width: 1024px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ── Glass Header ── */
.glass-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--glass-border);
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.header-inner {
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
@media (min-width: 768px) {
  .header-inner { height: 80px; }
}

.logo-link {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, #10b981, #14b8a6);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 20px;
  box-shadow: var(--shadow-emerald);
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.logo-link:hover .logo-icon { transform: scale(1.1) rotate(5deg); }

.logo-text {
  display: flex;
  flex-direction: column;
}
.logo-title {
  font-size: 1.25rem;
  font-weight: 900;
  color: var(--text-main);
  letter-spacing: -0.5px;
  transition: var(--transition);
}
.logo-link:hover .logo-title { color: var(--primary); }
.logo-subtitle {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-top: -2px;
  display: none;
}
@media (min-width: 768px) { .logo-subtitle { display: block; } }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-full);
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  border: none;
  outline: none;
  transition: var(--transition);
}

.btn-primary {
  background: var(--primary);
  color: white;
  box-shadow: var(--shadow-emerald);
}
.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-2px);
  box-shadow: 0 12px 24px -5px rgba(16, 185, 129, 0.4);
}

.btn-secondary {
  background: rgba(16, 185, 129, 0.1);
  color: var(--primary);
}
.btn-secondary:hover {
  background: rgba(16, 185, 129, 0.2);
}

/* ── Main Layout ── */
.main-content {
  flex: 1;
  padding: 30px 0 60px;
}
@media (min-width: 768px) { .main-content { padding: 40px 0 80px; } }

.hero-section {
  margin-bottom: 30px;
  text-align: left;
}
@media (max-width: 767px) { .hero-section { text-align: center; } }
.hero-title {
  font-size: 1.75rem;
  font-weight: 900;
  margin-bottom: 8px;
  letter-spacing: -0.5px;
}
@media (min-width: 768px) { .hero-title { font-size: 2.25rem; } }
.hero-desc {
  color: var(--text-muted);
  font-size: 1rem;
  max-width: 600px;
}
@media (max-width: 767px) { .hero-desc { margin: 0 auto; } }

/* ── Categories Filter ── */
.category-filter {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 10px;
  margin-bottom: 30px;
  scrollbar-width: none;
  -ms-overflow-style: none;
  scroll-snap-type: x mandatory;
}
.category-filter::-webkit-scrollbar { display: none; }
.cat-btn {
  scroll-snap-align: start;
  flex-shrink: 0;
  padding: 8px 18px;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 700;
  background: white;
  color: var(--text-muted);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}
.cat-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  box-shadow: var(--shadow-emerald);
}
.cat-btn:not(.active):hover {
  border-color: rgba(16, 185, 129, 0.4);
  color: var(--primary);
}

/* ── Post Grid ── */
.post-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}
@media (min-width: 640px) { .post-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 768px) { .post-grid { grid-template-columns: repeat(3, 1fr); gap: 24px; } }

.post-card {
  background: var(--bg-card);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.4s ease;
}
.post-card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-lg);
  border-color: rgba(16, 185, 129, 0.2);
}

.post-thumb-wrap {
  position: relative;
  width: 100%;
  padding-top: 56.25%; /* 16:9 Aspect Ratio */
  overflow: hidden;
  background: #e2e8f0;
}
.post-thumb {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.7s ease-out;
}
.post-card:hover .post-thumb {
  transform: scale(1.05);
}

.post-badge {
  position: absolute;
  bottom: 10px;
  left: 10px;
  background: rgba(16, 185, 129, 0.9);
  backdrop-filter: blur(4px);
  color: white;
  font-size: 0.6rem;
  font-weight: 800;
  text-transform: uppercase;
  padding: 4px 8px;
  border-radius: 6px;
  letter-spacing: 0.5px;
}

.post-pin-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(4px);
  color: #d97706;
  font-size: 0.65rem;
  font-weight: 800;
  padding: 4px 8px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.post-info {
  padding: 16px;
  display: flex;
  flex-direction: column;
  flex: 1;
}
.post-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 12px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  transition: var(--transition);
}
.post-card:hover .post-title { color: var(--primary); }

.post-meta {
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 12px;
  border-top: 1px solid rgba(0,0,0,0.04);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}
.meta-views {
  background: rgba(0,0,0,0.03);
  padding: 2px 6px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: var(--transition);
}
.post-card:hover .meta-views {
  background: rgba(16, 185, 129, 0.1);
  color: var(--primary);
}

/* ── Post Detail Page ── */
.post-detail {
  background: white;
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  max-width: 800px;
  margin: 0 auto;
}
.post-detail-thumb {
  width: 100%;
  max-height: 50vh;
  object-fit: cover;
  background: #e2e8f0;
}
.post-detail-content {
  padding: 24px 20px;
}
@media (min-width: 768px) { .post-detail-content { padding: 40px 48px; } }

.post-detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
}
.cat-tag {
  background: rgba(16, 185, 129, 0.1);
  color: var(--primary-hover);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.date-tag {
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
}

.post-detail-title {
  font-size: 1.5rem;
  font-weight: 900;
  line-height: 1.3;
  margin-bottom: 24px;
  letter-spacing: -0.5px;
}
@media (min-width: 768px) { .post-detail-title { font-size: 2.25rem; } }

.author-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 30px;
}
.author-info { display: flex; align-items: center; gap: 12px; }
.author-avatar {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, #10b981, #06b6d4);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 1rem;
}
.author-name { font-weight: 800; font-size: 0.9rem; color: var(--text-main); }
.author-role { font-size: 0.75rem; color: var(--text-muted); }
.view-count { font-size: 0.8rem; font-weight: 700; color: var(--text-muted); background: var(--bg-body); padding: 4px 10px; border-radius: 8px; display: flex; align-items: center; gap: 6px; }

/* ── Prose (Rich Text Formatting) ── */
.prose {
  font-size: 1.05rem;
  line-height: 1.8;
  color: #334155;
}
.prose h2, .prose h3 {
  font-weight: 800;
  color: #0f172a;
  margin: 2rem 0 1rem;
}
.prose h2 { font-size: 1.6rem; border-left: 4px solid var(--primary); padding-left: 12px; }
.prose h3 { font-size: 1.3rem; }
.prose p { margin-bottom: 1.5rem; }
.prose a { color: var(--primary); font-weight: 600; text-decoration: underline; }
.prose a:hover { color: var(--primary-hover); }
.prose blockquote {
  border-left: 4px solid var(--primary);
  background: rgba(16, 185, 129, 0.05);
  padding: 1rem 1.5rem;
  border-radius: 0 12px 12px 0;
  font-style: italic;
  margin: 1.5rem 0;
  color: #065f46;
}

/* Responsive Image Handling within Prose */
.prose img {
  width: 100%; /* Default to 100% on mobile */
  max-width: 100%;
  height: auto;
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  margin: 2rem auto;
  cursor: zoom-in;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  display: block;
}
@media (min-width: 768px) {
  .prose img {
    width: auto; /* Allow image to be its natural size up to container width on PC */
  }
}

.prose img:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.prose iframe {
  width: 100%;
  aspect-ratio: 16/9;
  border-radius: 12px;
  border: none;
  margin: 1.5rem 0;
}

/* ── Back Buttons ── */
.post-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 40px;
  padding-top: 24px;
  border-top: 1px solid var(--border-color);
}

/* ── Comments Section ── */
.comments-section {
  max-width: 800px;
  margin: 40px auto 0;
}
.comments-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}
.comments-icon {
  width: 36px; height: 36px;
  background: rgba(16, 185, 129, 0.15);
  color: var(--primary);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.comments-title {
  font-size: 1.3rem; font-weight: 900;
}
.comments-count {
  font-size: 0.8rem; font-weight: 700; background: var(--bg-body); color: var(--text-muted); padding: 2px 10px; border-radius: var(--radius-full); margin-left: 8px;
}

.comment-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 30px;
}
.comment-card {
  background: white;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 20px;
  display: flex;
  gap: 16px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}
.comment-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.comment-avatar {
  width: 44px; height: 44px;
  background: linear-gradient(135deg, #e2e8f0, #cbd5e1);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; color: #475569; font-size: 1.1rem;
  flex-shrink: 0;
}
.comment-body { flex: 1; }
.comment-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
.comment-author { font-weight: 800; font-size: 0.95rem; }
.comment-date { font-size: 0.75rem; color: var(--text-muted); font-weight: 500; }
.comment-text { font-size: 0.95rem; color: #334155; white-space: pre-wrap; line-height: 1.6; }

.admin-reply {
  margin-top: 16px;
  background: rgba(16, 185, 129, 0.05);
  border-left: 3px solid var(--primary);
  padding: 12px 16px;
  border-radius: 0 12px 12px 0;
}
.admin-reply-header { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.admin-badge { background: rgba(16, 185, 129, 0.15); color: var(--primary-hover); font-size: 0.7rem; font-weight: 800; padding: 2px 8px; border-radius: var(--radius-full); }
.admin-reply-text { font-size: 0.9rem; color: #065f46; white-space: pre-wrap; }

.comment-form-card {
  background: white;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}
.comment-form-title { font-weight: 800; margin-bottom: 20px; display: flex; align-items: center; gap: 8px; }
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 0.85rem; font-weight: 700; margin-bottom: 8px; color: #334155; }
.form-input {
  width: 100%; padding: 12px 16px;
  background: var(--bg-body); border: 1px solid var(--border-color);
  border-radius: 12px; font-family: inherit; font-size: 0.95rem;
  transition: var(--transition);
  outline: none;
}
.form-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(16,185,129,0.15); background: white; }
.form-input.textarea { resize: vertical; min-height: 100px; }
.char-count { text-align: right; font-size: 0.75rem; color: var(--text-muted); margin-top: 4px; }

.form-actions { display: flex; justify-content: flex-end; align-items: center; gap: 16px; margin-top: 20px; }
.msg-alert { font-size: 0.85rem; font-weight: 600; padding: 8px 12px; border-radius: 8px; display: none; }
.msg-alert.success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; display: block; }
.msg-alert.error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; display: block; }

/* ── Lightbox ── */
.lightbox {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.92); z-index: 9999;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity 0.3s ease;
  padding: 20px;
}
.lightbox.active { opacity: 1; pointer-events: auto; }
.lightbox-img {
  max-width: 100%; max-height: 80vh; object-fit: contain;
  border-radius: 12px; box-shadow: 0 20px 50px rgba(0,0,0,0.5);
  transform: translateY(20px) scale(0.95); transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.lightbox.active .lightbox-img { transform: translateY(0) scale(1); }
.lightbox-toolbar { display: flex; gap: 16px; margin-top: 24px; }
.lb-btn {
  padding: 10px 24px; border-radius: var(--radius-full); font-weight: 800; font-size: 0.9rem;
  cursor: pointer; border: none; display: inline-flex; align-items: center; gap: 8px; transition: var(--transition);
}
.lb-btn-dl { background: var(--primary); color: white; }
.lb-btn-dl:hover { background: var(--primary-hover); transform: translateY(-2px); }
.lb-btn-close { background: rgba(255,255,255,0.15); color: white; }
.lb-btn-close:hover { background: rgba(255,255,255,0.25); }

/* ── Footer ── */
.footer {
  background: white; border-top: 1px solid var(--border-color);
  padding: 30px 20px; margin-top: auto;
}
.footer-inner {
  max-width: 1024px; margin: 0 auto; display: flex; flex-direction: column; align-items: center; gap: 16px; text-align: center;
}
@media (min-width: 768px) {
  .footer-inner { flex-direction: row; justify-content: space-between; text-align: left; }
}
.footer-logo { font-weight: 900; font-size: 1.2rem; display: flex; align-items: center; gap: 8px; color: var(--text-main); }
.footer-text { font-size: 0.85rem; color: var(--text-muted); font-weight: 500; }

/* ── Loaders ── */
.spinner {
  border: 3px solid rgba(255,255,255,0.3); border-radius: 50%; border-top: 3px solid white;
  width: 18px; height: 18px; animation: spin 1s linear infinite;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
.loader-container { padding: 60px 0; display: flex; justify-content: center; }
.loader-dot {
  width: 12px; height: 12px; background: var(--primary); border-radius: 50%; margin: 0 6px;
  animation: bounce 1.4s infinite ease-in-out both;
}
.loader-dot:nth-child(1) { animation-delay: -0.32s; }
.loader-dot:nth-child(2) { animation-delay: -0.16s; }
@keyframes bounce { 0%, 80%, 100% { transform: scale(0); } 40% { transform: scale(1); } }
