/* aihackle — custom theme stylesheet (1rem = 16px, Japanese typography first, issue #167) */
:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --fg: #1e293b;
  --fg-2: #475569;
  --fg-3: #64748b;
  --border: #e2e8f0;
  --accent: #2563eb;
  --accent-soft: rgba(37, 99, 235, 0.1);
  --radius: 12px;
  --shadow: 0 2px 10px rgba(15, 23, 42, 0.05);
  --shadow-hover: 0 8px 22px rgba(15, 23, 42, 0.1);
  --maxw: 1320px;
  --bottom-nav-h: 60px;

  /* Compatibility aliases for existing archive / topic / blogcard templates */
  --body-background: var(--bg);
  --card-background: var(--surface);
  --card-text-color-main: var(--fg);
  --card-text-color-secondary: var(--fg-2);
  --card-text-color-tertiary: var(--fg-3);
  --card-separator-color: var(--border);
  --card-border-color: var(--border);
  --card-border-radius: var(--radius);
  --accent-color: var(--accent);
}

html[data-theme="dark"] {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-2: #283548;
  --fg: #f1f5f9;
  --fg-2: #cbd5e1;
  --fg-3: #94a3b8;
  --border: #334155;
  --accent: #60a5fa;
  --accent-soft: rgba(96, 165, 250, 0.14);
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
  --shadow-hover: 0 8px 24px rgba(0, 0, 0, 0.45);
}

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

html {
  -webkit-text-size-adjust: 100%;
  font-size: 16px;
  overflow-y: scroll;
  scrollbar-gutter: stable;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", "Meiryo", sans-serif;
  font-size: 1rem;
  line-height: 1.8;
  text-autospace: ideograph-alpha ideograph-numeric punctuation insert;
  text-spacing-trim: trim-start allow-end;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  padding-bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom));
}

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

a:hover {
  text-decoration: underline;
}

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

/* ---------- Header & Navigation ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 1rem;
  gap: 0.75rem;
}

.site-brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  color: var(--fg);
  min-width: 0;
}

.site-brand:hover {
  text-decoration: none;
}

.site-brand-avatar {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  flex-shrink: 0;
  object-fit: contain;
}

.site-brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.3;
  min-width: 0;
}

.site-brand-title {
  font-weight: 800;
  font-size: 1.1rem;
  letter-spacing: 0.01em;
  color: var(--fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.site-brand-sub {
  font-size: 0.78rem;
  color: var(--fg-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-actions {
  display: flex;
  gap: 0.45rem;
  flex-shrink: 0;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--fg-2);
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.icon-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
  text-decoration: none;
}

.icon-btn.is-active {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}

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

html:not([data-theme="dark"]) .icon-moon {
  display: none;
}

.primary-nav {
  border-top: 1px solid var(--border);
}

.primary-nav-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  display: flex;
  gap: 0.45rem;
  overflow-x: auto;
  padding: 0.5rem 1rem;
  scrollbar-width: none;
}

.primary-nav-inner::-webkit-scrollbar {
  display: none;
}

.nav-pill {
  flex: 0 0 auto;
  white-space: nowrap;
  padding: 0.32rem 0.85rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--fg-2);
  background: var(--surface-2);
  transition: color 0.15s ease, background 0.15s ease;
}

.nav-pill:hover {
  text-decoration: none;
  color: var(--accent);
}

.nav-pill.is-active {
  background: var(--accent);
  color: #ffffff;
}

/* ---------- Layout Container & Sidebar ---------- */
.site-container {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 1.25rem 1rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

.site-main {
  min-width: 0;
}

.site-sidebar {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  min-width: 0;
}

.sidebar-sticky-group,
.sidebar-discovery-group {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

@media (min-width: 1024px) {
  .site-container {
    flex-direction: row;
    align-items: flex-start;
    padding: 1.5rem 1.5rem 2.5rem;
    gap: 2rem;
  }

  .site-main {
    flex: 1 1 0;
  }

  .site-sidebar {
    flex: 0 0 300px;
    width: 300px;
    position: sticky;
    top: 6.75rem;
    max-height: calc(100vh - 7.75rem);
    overflow-y: auto;
    scrollbar-width: thin;
    overscroll-behavior: contain;
  }
}

.sidebar-widget {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow);
}

.widget-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.7rem;
}

.widget-title {
  margin: 0 0 0.7rem;
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--fg);
}

.widget-header .widget-title {
  margin: 0;
}

.widget-more {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
}

.sidebar-search-form {
  display: flex;
  gap: 0.45rem;
}

.sidebar-search-input {
  flex: 1 1 auto;
  min-width: 0;
  font: inherit;
  font-size: 0.9rem;
  padding: 0.48rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--fg);
}

.sidebar-search-input:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}

.sidebar-search-btn {
  flex: 0 0 auto;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 0.48rem 0.85rem;
  border-radius: 8px;
  border: 0;
  background: var(--accent);
  color: #ffffff;
  cursor: pointer;
}

.sidebar-search-btn:hover {
  filter: brightness(1.06);
}

.widget-cat-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.widget-cat-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.35rem 0.5rem;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--fg-2);
}

.widget-cat-link:hover {
  background: var(--surface-2);
  color: var(--accent);
  text-decoration: none;
}

.widget-cat-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.widget-cat-count {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--fg-3);
  background: var(--surface-2);
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  flex-shrink: 0;
}

.widget-tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.widget-archive-years {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.widget-archive-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.7rem;
  border-radius: 8px;
  font-size: 0.84rem;
  font-weight: 700;
  background: var(--surface-2);
  color: var(--fg-2);
  border: 1px solid var(--border);
}

.widget-archive-pill:hover {
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
}

.widget-archive-count {
  font-size: 0.74rem;
  color: var(--fg-3);
}

/* ---------- Footer & Mobile Bottom Nav ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  margin-top: 2rem;
}

.footer-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 1.5rem 1rem;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem 1.1rem;
  font-size: 0.85rem;
}

.footer-links a {
  color: var(--fg-2);
}

.footer-copy {
  color: var(--fg-3);
  font-size: 0.82rem;
  margin: 0.9rem 0 0;
}

.mobile-bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 60;
  display: flex;
  justify-content: space-around;
  height: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.mob-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--fg-3);
  font-size: 0.7rem;
  font-weight: 600;
  gap: 2px;
}

.mob-nav-item:hover {
  text-decoration: none;
}

.mob-nav-icon {
  font-size: 1.2rem;
  line-height: 1;
}

.mob-nav-item.is-active {
  color: var(--accent);
}

@media (min-width: 900px) {
  .mobile-bottom-nav {
    display: none;
  }

  body {
    padding-bottom: 0;
  }
}

/* ---------- Badges, Tags & Page Headers ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0.16rem 0.6rem;
  border-radius: 6px;
  font-size: 0.76rem;
  font-weight: 700;
  line-height: 1.5;
}

.badge:hover {
  text-decoration: none;
  filter: brightness(0.96);
}

.badge-cat {
  background: var(--accent-soft);
  color: var(--accent);
}

.tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--fg-2);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 0.18rem 0.6rem;
  border-radius: 999px;
}

.tag-pill:hover {
  text-decoration: none;
  border-color: var(--accent);
  color: var(--accent);
}

.tag-pill-count {
  font-size: 0.72rem;
  color: var(--fg-3);
}

.page-header {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.35rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow);
}

.page-eyebrow {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--fg-3);
}

.page-title {
  font-size: 1.45rem;
  line-height: 1.4;
  margin: 0.25rem 0 0.35rem;
  font-weight: 800;
  color: var(--fg);
}

.page-term-desc {
  margin: 0.35rem 0 0.45rem;
  font-size: 0.94rem;
  color: var(--fg-2);
  line-height: 1.65;
}

.page-subtitle {
  margin: 0;
  color: var(--fg-3);
  font-size: 0.88rem;
}

.section-title {
  font-size: 1.2rem;
  font-weight: 800;
  margin: 0 0 0.85rem;
  color: var(--fg);
}

/* ---------- 2-Column 16:9 Post Card Grid ---------- */
.article-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
}

@media (min-width: 680px) {
  .article-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.post-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.post-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
}

.post-card-image {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: 220px;
  overflow: hidden;
  background: var(--surface-2);
}

.post-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease;
}

.post-card:hover .post-card-image img {
  transform: scale(1.03);
}

.post-card-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.25rem;
  color: var(--fg-3);
}

.post-card-details {
  flex: 1 1 auto;
  padding: 1rem 1.15rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.7rem;
  min-width: 0;
}

.post-card-top {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.post-card-categories {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.post-card-title {
  margin: 0;
  font-size: 1.08rem;
  line-height: 1.48;
  font-weight: 700;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

@media (min-width: 1200px) {
  .post-card-title {
    font-size: 1.15rem;
  }
}

.post-card-title a {
  color: var(--fg);
}

.post-card-title a:hover {
  color: var(--accent);
  text-decoration: none;
}

.post-card-subtitle {
  margin: 0;
  font-size: 0.86rem;
  line-height: 1.55;
  color: var(--fg-2);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.9rem;
  padding-top: 0.45rem;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--fg-3);
  font-variant-numeric: tabular-nums;
}

/* ---------- Pagination ---------- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin: 1.75rem 0 0.5rem;
  flex-wrap: wrap;
}

.page-numbers {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  justify-content: center;
}

.page-link,
.page-num,
.page-ellipsis {
  min-width: 38px;
  height: 38px;
  padding: 0 0.7rem;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.88rem;
  font-weight: 700;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--fg-2);
}

.page-link:hover,
.page-num:hover {
  text-decoration: none;
  border-color: var(--accent);
  color: var(--accent);
}

.page-num.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.page-disabled {
  opacity: 0.45;
}

.page-ellipsis {
  border: 0;
  background: none;
}

/* ---------- Single Article & ToC ---------- */
.single-article {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem 1.25rem;
  box-shadow: var(--shadow);
}

@media (min-width: 720px) {
  .single-article {
    padding: 2rem 2.25rem;
  }
}

.single-header {
  margin-bottom: 1.5rem;
}

.single-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.single-title {
  font-size: 1.5rem;
  line-height: 1.45;
  margin: 0.65rem 0 0.55rem;
  font-weight: 800;
  color: var(--fg);
}

@media (min-width: 720px) {
  .single-title {
    font-size: 1.85rem;
  }
}

.single-description {
  margin: 0.35rem 0 0.75rem;
  font-size: 0.98rem;
  line-height: 1.7;
  color: var(--fg-2);
}

.single-meta-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1rem;
  font-size: 0.85rem;
  color: var(--fg-3);
  font-variant-numeric: tabular-nums;
}

.single-tags-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.75rem;
}

.single-hero-cover {
  margin: 1.25rem 0 0;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface-2);
}

.single-hero-cover img {
  display: block;
  width: 100%;
  max-height: 460px;
  object-fit: cover;
}

/* Table of Contents */
.toc-inline {
  margin: 1.25rem 0 1.5rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
}

.toc-inline > summary {
  cursor: pointer;
  padding: 0.7rem 1rem;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--fg);
}

.toc-inline[open] > summary {
  border-bottom: 1px solid var(--border);
}

.toc-inline .toc-body {
  padding: 0.75rem 1rem;
}

@media (min-width: 1024px) {
  .toc-inline {
    display: none;
  }
}

.toc-body nav#TableOfContents ul {
  list-style: none;
  margin: 0;
  padding-left: 0;
}

.toc-body nav#TableOfContents ul ul {
  padding-left: 0.95rem;
  margin-top: 0.2rem;
}

.toc-body nav#TableOfContents li {
  margin: 0.28rem 0;
  line-height: 1.45;
}

.toc-body nav#TableOfContents a {
  font-size: 0.86rem;
  color: var(--fg-2);
  display: block;
  padding: 0.12rem 0.25rem;
  border-radius: 4px;
}

.toc-body nav#TableOfContents a:hover {
  color: var(--accent);
  background: var(--surface-2);
  text-decoration: none;
}

.toc-widget .toc-body {
  max-height: 55vh;
  overflow-y: auto;
}

/* Article Content Typography */
.article-content {
  font-size: 1rem;
  line-height: 1.9;
  overflow-wrap: anywhere;
  color: var(--fg);
}

@media (min-width: 720px) {
  .article-content {
    font-size: 1.05rem;
  }
}

.article-content h2 {
  font-size: 1.35rem;
  line-height: 1.45;
  margin: 2.35rem 0 0.95rem;
  padding: 0.55rem 0.85rem;
  background: var(--surface-2);
  border-left: 5px solid var(--accent);
  border-radius: 6px;
}

.article-content h3 {
  font-size: 1.18rem;
  line-height: 1.5;
  margin: 1.85rem 0 0.75rem;
  padding-bottom: 0.3rem;
  border-bottom: 2px dotted var(--border);
}

.article-content h4 {
  font-size: 1.05rem;
  margin: 1.45rem 0 0.55rem;
}

.article-content p {
  margin: 0 0 1.25em;
}

.article-content strong {
  font-weight: 700;
  color: var(--fg);
}

/* issue #104: 本文画像の縦長・正方形の巨大化を抑止（横長は全幅維持） */
.article-content img {
  display: block;
  max-width: 100%;
  max-height: 480px;
  width: auto;
  height: auto;
  margin: 1rem auto;
  border-radius: 6px;
}

.article-content blockquote {
  margin: 1.25rem 0;
  padding: 0.85rem 1.1rem;
  border-left: 4px solid var(--accent);
  background: var(--surface-2);
  color: var(--fg-2);
  border-radius: 6px;
}

.article-content blockquote p:last-child {
  margin-bottom: 0;
}

.article-content ul,
.article-content ol {
  padding-left: 1.5rem;
  margin: 0 0 1.25em;
}

.article-content li {
  margin-bottom: 0.35em;
}

.article-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.25rem 0;
  font-size: 0.92rem;
  display: block;
  overflow-x: auto;
}

.article-content th,
.article-content td {
  border: 1px solid var(--border);
  padding: 0.55rem 0.75rem;
  text-align: left;
}

.article-content th {
  background: var(--surface-2);
  font-weight: 700;
}

.article-content hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}

.article-content code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.88em;
  background: var(--surface-2);
  padding: 0.12em 0.38em;
  border-radius: 4px;
}

.article-content pre {
  overflow-x: auto;
  padding: 1rem 1.15rem;
  border-radius: 8px;
  background: #0d1117;
  color: #e6edf3;
  font-size: 0.9rem;
  line-height: 1.6;
  margin: 1.25rem 0;
}

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

.article-content .highlight {
  margin: 1.25rem 0;
}

.article-content .highlight pre {
  margin: 0;
}

.article-content pre.mermaid {
  background: transparent;
  color: var(--fg);
  text-align: center;
  padding: 0.75rem 0;
}

.article-content mjx-container {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
}

/* SWELL / WordPress Shortcode & Block Styles */
.article-content dl.swell-block-faq dt {
  font-weight: 800;
  margin-top: 1rem;
}

.article-content dl.swell-block-faq dt::before {
  content: "Q. ";
  color: var(--accent);
}

.article-content dl.swell-block-faq dd {
  margin: 0.35rem 0 0 0;
  padding: 0.7rem 1rem;
  background: var(--surface-2);
  border-radius: 8px;
}

.wp-accordion {
  margin: 1.25rem 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}

.wp-accordion > summary {
  cursor: pointer;
  padding: 0.75rem 1rem;
  font-weight: 700;
}

.wp-accordion[open] > summary {
  border-bottom: 1px solid var(--border);
}

.wp-accordion-panel {
  padding: 0.75rem 1rem 1rem;
}

.wp-accordion-panel > :first-child {
  margin-top: 0;
}

.wp-accordion-panel > :last-child {
  margin-bottom: 0;
}

/* Blog Card */
.blog-card-wrapper {
  margin: 1.5rem 0;
}

.blog-card {
  display: flex;
  justify-content: space-between;
  align-items: stretch;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  box-shadow: var(--shadow);
}

.blog-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
  border-color: var(--accent);
  text-decoration: none;
}

.blog-card-content {
  flex: 1 1 auto;
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}

.blog-card-label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 0.35rem;
  letter-spacing: 0.04em;
}

.blog-card-title {
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.45;
  color: var(--fg);
  margin-bottom: 0.35rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.blog-card-url {
  font-size: 0.78rem;
  color: var(--fg-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.blog-card-thumbnail {
  flex: 0 0 160px;
  width: 160px;
  position: relative;
  overflow: hidden;
  background: var(--surface-2);
}

.blog-card-thumbnail img {
  width: 100%;
  height: 100%;
  max-height: none;
  margin: 0;
  border-radius: 0;
  object-fit: cover;
  display: block;
  transition: transform 0.2s ease;
}

.blog-card:hover .blog-card-thumbnail img {
  transform: scale(1.05);
}

@media (max-width: 640px) {
  .blog-card-thumbnail {
    flex: 0 0 110px;
    width: 110px;
  }

  .blog-card-content {
    padding: 0.75rem 1rem;
  }

  .blog-card-title {
    font-size: 0.92rem;
  }
}

/* Prev / Next & Related Posts */
.post-prev-next {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: 1fr;
  margin-top: 2.25rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

@media (min-width: 640px) {
  .post-prev-next {
    grid-template-columns: 1fr 1fr;
  }
}

.prev-next-card {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.85rem 1rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--fg);
}

.prev-next-card:hover {
  text-decoration: none;
  border-color: var(--accent);
}

.next-card {
  text-align: right;
}

.prev-next-label {
  font-size: 0.78rem;
  color: var(--fg-3);
  font-weight: 700;
}

.prev-next-title {
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.48;
}

.related-posts-section {
  margin-top: 2.25rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.umami-pv-ranking {
  margin: 1rem 0;
}

/* ---------- Archives Page (.template-archives) ---------- */
.template-archives .archives-header {
  margin-bottom: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.template-archives .archives-main-title {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0 0 0.4rem 0;
  color: var(--fg);
}

.template-archives .archives-subtitle {
  margin: 0;
  font-size: 0.95rem;
  color: var(--fg-2);
  line-height: 1.5;
}

.template-archives .archives-year-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  padding: 0.55rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.template-archives .year-nav-item {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 1.1rem;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--fg-2);
  text-decoration: none;
  background: transparent;
  transition: all 0.2s ease;
}

.template-archives .year-nav-item .year-badge {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--fg-3);
  transition: all 0.2s ease;
}

.template-archives .year-nav-item:hover {
  background: var(--surface-2);
  color: var(--accent);
}

.template-archives .year-nav-item:hover .year-badge {
  background: var(--accent-soft);
  color: var(--accent);
}

.template-archives .year-nav-item.active {
  background: var(--accent);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.template-archives .year-nav-item.active .year-label {
  color: #ffffff;
}

.template-archives .year-nav-item.active .year-badge {
  background: rgba(255, 255, 255, 0.28);
  color: #ffffff;
}

.template-archives .archives-year-content {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.template-archives .archives-year-heading-wrap {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  border-bottom: 2px solid var(--accent);
  padding-bottom: 0.5rem;
  margin-bottom: 1.5rem;
}

.template-archives .archives-current-year-heading {
  margin: 0;
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--fg);
}

.template-archives .archives-current-year-heading .year-title {
  margin-right: 0.6rem;
}

.template-archives .archives-current-year-heading .total-posts {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--fg-3);
}

.template-archives .archives-month-group {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow);
}

.template-archives .archives-month-header {
  margin-bottom: 1rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px dashed var(--border);
}

.template-archives .archives-month-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--fg);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.template-archives .archives-month-title .month-icon {
  font-size: 1rem;
}

.template-archives .archives-month-title .month-count {
  font-size: 0.82rem;
  font-weight: 600;
  margin-left: auto;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--fg-2);
}

.template-archives .archives-post-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
}

.template-archives .archives-post-item {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0.65rem 0.5rem;
  border-radius: 8px;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s ease;
}

.template-archives .archives-post-item:last-child {
  border-bottom: none;
}

.template-archives .archives-post-item:hover {
  background: var(--surface-2);
}

.template-archives .archives-post-item:hover .post-title {
  color: var(--accent);
}

.template-archives .archives-post-item .post-date {
  flex: 0 0 54px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--fg-3);
  font-variant-numeric: tabular-nums;
}

.template-archives .archives-post-item .post-categories {
  flex: 0 0 auto;
  display: flex;
  gap: 0.35rem;
}

.template-archives .archives-post-item .post-categories .category-badge {
  font-size: 0.76rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 5px;
  background: var(--surface-2);
  color: var(--fg-2);
  text-decoration: none;
  border: 1px solid var(--border);
  white-space: nowrap;
  transition: all 0.15s ease;
}

.template-archives .archives-post-item .post-categories .category-badge:hover {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}

.template-archives .archives-post-item .post-title {
  flex: 1 1 auto;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--fg);
  text-decoration: none;
  line-height: 1.5;
  transition: color 0.15s ease;
}

@media (max-width: 640px) {
  .template-archives .archives-month-group {
    padding: 1rem;
  }

  .template-archives .archives-post-item {
    flex-wrap: wrap;
    gap: 0.4rem;
  }

  .template-archives .archives-post-item .post-date {
    flex: 0 0 48px;
  }

  .template-archives .archives-post-item .post-title {
    flex: 1 0 100%;
    order: 3;
  }
}

/* ---------- Topics / Categories Index (.template-topics) ---------- */
.template-topics .topics-header {
  margin-bottom: 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.template-topics .topics-main-title {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0;
  color: var(--fg);
}

.template-topics .topics-subtitle {
  margin: 0;
  font-size: 0.95rem;
  color: var(--fg-2);
  line-height: 1.7;
}

.template-topics .topics-content {
  display: flex;
  flex-direction: column;
  gap: 2.25rem;
}

.template-topics .section-heading {
  font-size: 1.3rem;
  font-weight: 800;
  margin: 0 0 0.75rem 0;
  color: var(--fg);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.template-topics .topics-categories {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.template-topics .category-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.4rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.template-topics .category-block-header {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.template-topics .category-block-title-row {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.template-topics .category-block-name {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--fg);
}

.template-topics .category-block-count {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--fg-3);
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.template-topics .category-block-desc {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.6;
  color: var(--fg-2);
}

.template-topics .category-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.template-topics .category-tag {
  display: inline-flex;
  align-items: center;
  padding: 0.32rem 0.8rem;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--fg-2);
  font-size: 0.84rem;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.15s ease;
  cursor: pointer;
}

.template-topics .category-tag:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.template-topics .category-tag.is-static {
  cursor: default;
}

.template-topics .category-tags-empty {
  font-size: 0.84rem;
  color: var(--fg-3);
}

.template-topics .category-tags-more {
  margin-top: 0.5rem;
}

.template-topics .category-tags-more > summary {
  cursor: pointer;
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--fg-2);
  list-style: none;
  user-select: none;
}

.template-topics .category-tags-more > summary::-webkit-details-marker {
  display: none;
}

.template-topics .category-tags-more > summary::before {
  content: "＋";
  margin-right: 0.35rem;
}

.template-topics .category-tags-more[open] > summary::before {
  content: "−";
}

.template-topics .category-tags-more .category-tags {
  margin-top: 0.6rem;
}

.template-topics .category-block-link {
  align-self: flex-start;
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
}

.template-topics .category-block-link:hover {
  text-decoration: underline;
}

.template-topics .topics-tag-glossary {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.4rem;
  box-shadow: var(--shadow);
}

.template-topics .tag-glossary-lead {
  margin: 0 0 1rem 0;
  font-size: 0.88rem;
  color: var(--fg-2);
}

.template-topics .tag-glossary-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.85rem 2rem;
}

@media (min-width: 820px) {
  .template-topics .tag-glossary-list {
    grid-template-columns: repeat(2, 1fr);
  }
}

.template-topics .tag-glossary-item {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding-bottom: 0.65rem;
  border-bottom: 1px solid var(--border);
}

.template-topics .tag-glossary-name {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--fg);
  text-decoration: none;
}

.template-topics .tag-glossary-name:hover {
  color: var(--accent);
  text-decoration: underline;
}

.template-topics .tag-glossary-desc {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.55;
  color: var(--fg-2);
}

@media (max-width: 640px) {
  .template-topics .category-block {
    padding: 1.1rem;
  }

  .template-topics .category-block-name {
    font-size: 1.08rem;
  }
}

/* ---------- Taxonomy Terms Index (/categories/, /tags/) ---------- */
.category-cards-grid {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: 1fr;
  margin-bottom: 1.25rem;
}

@media (min-width: 720px) {
  .category-cards-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.category-summary-card {
  display: block;
  color: var(--fg);
  padding: 0.95rem 1.05rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.category-summary-card:hover {
  text-decoration: none;
  border-color: var(--accent);
}

.category-summary-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
}

.category-summary-title {
  font-size: 1.05rem;
  margin: 0;
}

.category-summary-count {
  font-size: 0.8rem;
  color: var(--fg-3);
}

.category-summary-desc {
  margin: 0.35rem 0 0;
  font-size: 0.86rem;
  color: var(--fg-2);
}

.terms-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.term-chip {
  display: inline-flex;
  gap: 0.4rem;
  align-items: center;
  padding: 0.32rem 0.8rem;
  border-radius: 999px;
  font-size: 0.86rem;
  font-weight: 600;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--fg-2);
}

.term-chip:hover {
  text-decoration: none;
  border-color: var(--accent);
  color: var(--accent);
}

.term-chip-count {
  font-size: 0.75rem;
  color: var(--fg-3);
}

.tag-glossary-section {
  margin-top: 1.75rem;
}

.tag-glossary-grid {
  display: grid;
  gap: 0.7rem;
  grid-template-columns: 1fr;
  margin-top: 0.75rem;
}

@media (min-width: 720px) {
  .tag-glossary-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.tag-glossary-card {
  padding: 0.85rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.tag-glossary-title {
  font-weight: 800;
  font-size: 0.95rem;
}

.tag-glossary-desc {
  margin: 0.25rem 0 0;
  font-size: 0.84rem;
  color: var(--fg-2);
}

/* ---------- Search & 404 ---------- */
.search-box-section {
  margin-bottom: 1.25rem;
}

.search-input-lg {
  width: 100%;
  font: inherit;
  font-size: 1.05rem;
  padding: 0.8rem 1rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--fg);
}

.search-input-lg:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}

.search-status {
  margin-top: 0.55rem;
  font-size: 0.86rem;
  color: var(--fg-3);
}

.error-404-box {
  text-align: center;
  padding: 3rem 1.25rem;
}

.error-404-icon {
  font-size: 3rem;
  margin-bottom: 0.5rem;
}

.error-404-actions {
  margin-top: 1.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
}

.error-404-btn {
  padding: 0.55rem 1.15rem;
  font-size: 0.92rem;
}

/* ---------- Chroma Syntax Highlighting (github-dark) ---------- */
.bg { color: #e6edf3; background-color: #0d1117; }
.chroma { color: #e6edf3; background-color: #0d1117; -webkit-text-size-adjust: none; }
.chroma .err { color: #f85149; }
.chroma .lnlinks { outline: none; text-decoration: none; color: inherit; }
.chroma .lntd { vertical-align: top; padding: 0; margin: 0; border: 0; }
.chroma .lntable { border-spacing: 0; padding: 0; margin: 0; border: 0; }
.chroma .hl { background-color: #6e7681; }
.chroma .lnt { white-space: pre; -webkit-user-select: none; user-select: none; margin-right: 0.4em; padding: 0 0.4em; color: #737679; }
.chroma .ln { white-space: pre; -webkit-user-select: none; user-select: none; margin-right: 0.4em; padding: 0 0.4em; color: #6e7681; }
.chroma .line { display: flex; }
.chroma .k { color: #ff7b72; }
.chroma .kc { color: #79c0ff; }
.chroma .kd { color: #ff7b72; }
.chroma .kn { color: #ff7b72; }
.chroma .kp { color: #79c0ff; }
.chroma .kr { color: #ff7b72; }
.chroma .kt { color: #ff7b72; }
.chroma .nc { color: #f0883e; font-weight: bold; }
.chroma .no { color: #79c0ff; font-weight: bold; }
.chroma .nd { color: #d2a8ff; font-weight: bold; }
.chroma .ni { color: #ffa657; }
.chroma .ne { color: #f0883e; font-weight: bold; }
.chroma .nl { color: #79c0ff; font-weight: bold; }
.chroma .nn { color: #ff7b72; }
.chroma .nx { color: #e6edf3; }
.chroma .py { color: #79c0ff; }
.chroma .nt { color: #7ee787; }
.chroma .nv { color: #79c0ff; }
.chroma .vc { color: #79c0ff; }
.chroma .vg { color: #79c0ff; }
.chroma .vi { color: #79c0ff; }
.chroma .vm { color: #79c0ff; }
.chroma .nf { color: #d2a8ff; font-weight: bold; }
.chroma .fm { color: #d2a8ff; font-weight: bold; }
.chroma .l { color: #a5d6ff; }
.chroma .ld { color: #79c0ff; }
.chroma .s { color: #a5d6ff; }
.chroma .sa { color: #79c0ff; }
.chroma .sb { color: #a5d6ff; }
.chroma .sc { color: #a5d6ff; }
.chroma .dl { color: #79c0ff; }
.chroma .sd { color: #a5d6ff; }
.chroma .s2 { color: #a5d6ff; }
.chroma .se { color: #79c0ff; }
.chroma .sh { color: #79c0ff; }
.chroma .si { color: #a5d6ff; }
.chroma .sx { color: #a5d6ff; }
.chroma .sr { color: #79c0ff; }
.chroma .s1 { color: #a5d6ff; }
.chroma .ss { color: #a5d6ff; }
.chroma .m { color: #a5d6ff; }
.chroma .mb { color: #a5d6ff; }
.chroma .mf { color: #a5d6ff; }
.chroma .mh { color: #a5d6ff; }
.chroma .mi { color: #a5d6ff; }
.chroma .il { color: #a5d6ff; }
.chroma .mo { color: #a5d6ff; }
.chroma .o { color: #ff7b72; font-weight: bold; }
.chroma .ow { color: #ff7b72; font-weight: bold; }
.chroma .or { color: #ff7b72; font-weight: bold; }
.chroma .c { color: #8b949e; font-style: italic; }
.chroma .ch { color: #8b949e; font-style: italic; }
.chroma .cm { color: #8b949e; font-style: italic; }
.chroma .c1 { color: #8b949e; font-style: italic; }
.chroma .cs { color: #8b949e; font-weight: bold; font-style: italic; }
.chroma .cp { color: #8b949e; font-weight: bold; font-style: italic; }
.chroma .cpf { color: #8b949e; font-weight: bold; font-style: italic; }
.chroma .gd { color: #ffa198; background-color: #490202; }
.chroma .ge { font-style: italic; }
.chroma .gr { color: #ffa198; }
.chroma .gh { color: #79c0ff; font-weight: bold; }
.chroma .gi { color: #56d364; background-color: #0f5323; }
.chroma .go { color: #8b949e; }
.chroma .gp { color: #8b949e; }
.chroma .gs { font-weight: bold; }
.chroma .gu { color: #79c0ff; }
.chroma .gt { color: #ff7b72; }
.chroma .gl { text-decoration: underline; }
.chroma .w { color: #6e7681; }
