:root {
  --bg: #f8fafc;
  --card: #ffffff;
  --text: #1e293b;
  --heading: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.65;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }
img { max-width: 100%; height: auto; display: block; }

.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 16px;
}

/* Header */
.site-header {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
}
.brand-title {
  font-size: 20px;
  font-weight: 800;
  color: var(--heading);
  text-decoration: none !important;
}
.brand-sub {
  display: block;
  font-size: 12px;
  color: var(--muted);
}
.main-nav {
  display: flex;
  gap: 18px;
  font-size: 14px;
  font-weight: 600;
}
.main-nav a { color: var(--text); }
.main-nav a:hover { color: var(--accent); text-decoration: none; }

/* Index / Category List (Title on top, Thumb Left, Excerpt Right) */
.page-heading {
  font-size: 26px;
  color: var(--heading);
  margin: 28px 0 20px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--border);
}
.post-list {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-bottom: 32px;
}
.post-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}
.post-item-title {
  margin: 0 0 14px 0;
  font-size: 20px;
  line-height: 1.35;
}
.post-item-title a { color: var(--heading); }
.post-item-title a:hover { color: var(--accent); text-decoration: none; }

.post-item-body {
  display: flex;
  gap: 18px;
  align-items: flex-start;
}
.post-item-thumb {
  flex: 0 0 220px;
  width: 220px;
  height: 145px;
  border-radius: 8px;
  overflow: hidden;
  background: #f1f5f9;
  border: 1px solid var(--border);
}
.post-item-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.post-item-excerpt {
  flex: 1;
  min-width: 0;
}
.post-item-excerpt p {
  margin: 0 0 12px 0;
  color: var(--text);
  font-size: 15px;
}
.post-item-meta {
  font-size: 13px;
  color: var(--muted);
}

/* Pagination */
.pagination {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin: 32px 0;
}
.btn-page {
  background: var(--card);
  border: 1px solid var(--border);
  padding: 8px 16px;
  border-radius: 6px;
  font-weight: 600;
  color: var(--heading);
}
.btn-page:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  text-decoration: none;
}

/* 2-Column Post Layout */
.layout-2col {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 28px;
  margin: 28px 0 48px;
  align-items: start;
}

/* Post Main Column */
article.post {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px;
  min-width: 0;
}
.post-crumbs {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 10px;
}
.post-crumbs a { color: var(--muted); }
.post-crumbs a:hover { color: var(--accent); }
.post-title {
  font-size: 28px;
  line-height: 1.3;
  color: var(--heading);
  margin: 0 0 12px 0;
}
.post-meta {
  font-size: 13.5px;
  color: var(--muted);
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.post-meta strong { color: var(--text); }

figure.hero {
  margin: 0 0 24px 0;
}
figure.hero img {
  width: 100%;
  max-height: 500px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
}
figure.hero figcaption {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  margin-top: 6px;
}

/* Article Content & Hide Duplicate SQL Trigger Gallery */
.entry-content {
  font-size: 16px;
  line-height: 1.75;
  color: var(--text);
  overflow-wrap: break-word;
}
.entry-content h2, .entry-content h3 {
  color: var(--heading);
  margin-top: 28px;
  margin-bottom: 12px;
}
.entry-content .figure-block {
  display: none;
}

/* Indexable Gallery Section */
section.gallery {
  margin-top: 36px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}
.sec-title {
  font-size: 20px;
  color: var(--heading);
  margin: 0 0 16px 0;
}
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 16px;
}
.gallery-item {
  margin: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  display: flex;
  flex-direction: column;
}
.gallery-item a.gallery-thumb-link {
  display: block;
  overflow: hidden;
  border-radius: 6px;
  background: #f1f5f9;
}
.gallery-item img {
  width: 100%;
  height: 175px;
  object-fit: cover;
  margin-bottom: 8px;
  transition: transform 0.2s ease;
}
.gallery-item a.gallery-thumb-link:hover img {
  transform: scale(1.03);
}
.gallery-item figcaption {
  font-size: 13.5px;
  color: var(--text);
  font-weight: 600;
  line-height: 1.35;
  margin-top: 4px;
}
.gallery-item figcaption a { color: var(--heading); }
.gallery-item .img-meta {
  display: block;
  font-size: 12px;
  color: var(--muted);
  font-weight: 400;
  margin-top: 4px;
}

/* Bottom Random Posts (List with Thumb) */
.bottom-random {
  margin-top: 36px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}
.random-thumb-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.random-thumb-item {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8fafc;
}
.random-thumb-item img {
  flex: 0 0 90px;
  width: 90px;
  height: 64px;
  object-fit: cover;
  border-radius: 6px;
  background: #e2e8f0;
}
.random-thumb-info h3 {
  margin: 0;
  font-size: 15.5px;
  line-height: 1.35;
}
.random-thumb-info h3 a { color: var(--heading); }
.random-thumb-info h3 a:hover { color: var(--accent); }

/* Sidebar */
aside.sidebar {
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.widget {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}
.widget-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--heading);
  margin: 0 0 14px 0;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--border);
}
.widget-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.widget-list li {
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14.5px;
  line-height: 1.4;
}
.widget-list li:last-child { border-bottom: none; padding-bottom: 0; }
.widget-list li:first-child { padding-top: 0; }
.widget-list a { color: var(--text); font-weight: 500; }
.widget-list a:hover { color: var(--accent); }

/* Footer */
.site-footer {
  background: var(--card);
  border-top: 1px solid var(--border);
  padding: 28px 16px;
  margin-top: 48px;
  text-align: center;
  font-size: 14px;
  color: var(--muted);
}
.footer-links {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-bottom: 10px;
}

/* Responsive */
@media (max-width: 900px) {
  .layout-2col { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .post-item-body { flex-direction: column; }
  .post-item-thumb { width: 100%; height: 190px; flex: none; }
  article.post { padding: 18px; }
  .post-title { font-size: 22px; }
}