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

body {
  margin: 0;
  background: #ffffff;
  color: #24292e;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  font-size: 17px;
  line-height: 1.7;
}

a { color: #0366d6; text-decoration: none; cursor: pointer; }
a:hover { text-decoration: underline; }

.site-header {
  padding: 16px 32px;
  border-bottom: 1px solid #e1e4e8;
  display: flex;
  align-items: center;
  justify-content: center;
}

.site-title {
  font-size: 15px;
  font-weight: 600;
  color: #24292e;
}

.site-title:hover { text-decoration: none; color: #0366d6; }

.content {
  max-width: 800px;
  margin: 0 auto;
  padding: 40px 32px;
}

/* 記事一覧グリッド */
.post-list {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 20px;
}

.post-item {
  display: flex;
  flex-direction: column;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #e1e4e8;
  color: inherit;
}

.post-item:hover { background: #f6f8fa; text-decoration: none; }

.post-item-title {
  font-size: clamp(13px, 1.4vw, 17px);
  font-weight: 600;
  line-height: 1.4;
  padding: 12px 12px 8px;
  color: #24292e;
  min-height: calc(1.4em * 2 + 20px);
}

.edited-label { font-size: 11px; color: #6a737d; margin-left: 3px; }
.post-item.pinned { border-color: #0366d6; }


.pin-label {
  margin-left: auto;
  font-size: 11px;
  color: #0366d6;
  font-weight: 600;
}

.post-item-thumb {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: #e1e4e8;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #c8ccd0;
  font-size: 32px;
  overflow: hidden;
  flex-shrink: 0;
}

.post-item-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 6px 10px 10px;
}

.post-item-date {
  font-size: 12px;
  color: #6a737d;
}

/* タグ */
.tag {
  font-size: 12px;
  color: #0366d6;
  background: #f1f8ff;
  padding: 2px 8px;
  border-radius: 12px;
  white-space: nowrap;
}

.tag:hover { background: #dbedff; text-decoration: none; }

/* サイドバーレイアウト */
.page-with-sidebar {
  display: flex;
  gap: 40px;
  max-width: 1600px;
  margin: 0 auto;
  padding: 40px 32px;
}

.sidebar {
  width: 180px;
  flex-shrink: 0;
}

.sidebar h3 {
  font-size: 12px;
  font-weight: 600;
  color: #6a737d;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0 0 12px;
}

.tag-list { display: flex; flex-direction: column; gap: 4px; }

.tag-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
}

.tag-item:hover { background: #f6f8fa; }
.tag-item.active { background: #f1f8ff; color: #0366d6; font-weight: 600; }

.tag-count {
  font-size: 12px;
  color: #6a737d;
  background: #f6f8fa;
  padding: 1px 6px;
  border-radius: 10px;
}

.main-area { flex: 1; min-width: 0; }

/* 記事ページ */
.post-header {
  display: flex;
  align-items: stretch;
  gap: 24px;
  padding-bottom: 12px;
  margin-bottom: 0;
}

.post-header-left {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.post-title-area {
  flex: 1;
  display: flex;
  align-items: center;
}

.post-title {
  margin: 0;
  font-size: 24px;
  font-weight: 600;
  line-height: 1.35;
}

.post-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.post-date { font-size: 13px; color: #6a737d; white-space: nowrap; }
.post-tags { display: flex; gap: 6px; flex-wrap: wrap; }

.post-header-thumb {
  width: 280px;
  height: 280px;
  flex-shrink: 0;
  background: #e1e4e8;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #c8ccd0;
  font-size: 40px;
  overflow: hidden;
  border-radius: 6px;
}

.post-header-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.post-divider {
  border: none;
  border-top: 1px solid #e1e4e8;
  margin: 0 0 24px;
}

.post-body p { margin: 0 0 16px; }

.post-body h1,
.post-body h2,
.post-body h3,
.post-body h4,
.post-body h5,
.post-body h6 {
  margin-top: 24px;
  margin-bottom: 16px;
  font-weight: 600;
  line-height: 1.25;
}

.post-body h1,
.post-body h2 {
  padding-bottom: 8px;
  border-bottom: 1px solid #e1e4e8;
}

.post-body h1 { font-size: 2em; }
.post-body h2 { font-size: 1.5em; }
.post-body h3 { font-size: 1.25em; }

.post-body ul,
.post-body ol {
  margin: 0 0 16px;
  padding-left: 2em;
}

.post-body li { margin: 4px 0; }

.post-body blockquote {
  margin: 0 0 16px;
  padding: 0 16px;
  color: #6a737d;
  border-left: 4px solid #dfe2e5;
}

.post-body code {
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 85%;
  background: #f6f8fa;
  padding: 2px 6px;
  border-radius: 3px;
}

.post-body pre {
  background: #1e1e1e;
  color: #d4d4d4;
  padding: 16px;
  border-radius: 6px;
  overflow-x: auto;
  margin: 0 0 16px;
}

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

.post-body hr { border: none; border-top: 1px solid #e1e4e8; margin: 24px 0; }
.post-body img { max-width: 100%; }

.back-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.back-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid #e1e4e8;
  background: #f6f8fa;
  color: #6a737d;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  line-height: 1;
}

.back-btn:hover { background: #e1e4e8; color: #24292e; text-decoration: none; }

.article-info-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.article-info-text {
  display: none;
  align-items: center;
  gap: 14px;
  font-size: 13px;
  color: #6a737d;
}

.article-info-text.open { display: flex; }

.article-info-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid #e1e4e8;
  background: #f6f8fa;
  color: #6a737d;
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.article-info-btn:hover { background: #e1e4e8; }
.article-info-btn.active { background: #dbeafe; border-color: #0366d6; color: #0366d6; }

.page-heading {
  font-size: 20px;
  font-weight: 600;
  margin: 0 0 24px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.page-heading .count { font-size: 14px; color: #6a737d; font-weight: normal; }

/* ページネーション */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 32px 0 16px;
}

.page-btn {
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border: 1px solid #e1e4e8;
  border-radius: 4px;
  background: #fff;
  color: #24292e;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.page-btn:hover { background: #f6f8fa; }
.page-btn:disabled { color: #c8ccd0; cursor: default; background: #fff; }

/* カレンダー */
.calendar { margin-top: 24px; }

.calendar-select {
  width: 100%;
  font-size: 12px;
  font-family: inherit;
  font-weight: 600;
  color: #24292e;
  background: #f6f8fa;
  border: 1px solid #e1e4e8;
  border-radius: 4px;
  padding: 4px 8px;
  cursor: pointer;
  margin-bottom: 8px;
  appearance: auto;
}

.calendar-select:focus { outline: none; border-color: #0366d6; }

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  text-align: center;
}

.calendar-dow { font-size: 10px; color: #6a737d; padding: 2px 0; }

.calendar-day {
  font-size: 11px;
  padding: 3px 0;
  border-radius: 4px;
  line-height: 1.4;
  color: #6a737d;
}

.calendar-day.has-post {
  color: #0366d6;
  font-weight: 700;
  cursor: pointer;
  background: #dbeafe;
  border-radius: 4px;
}
.calendar-day.has-post:hover { background: #bfdbfe; }
.calendar-day.active { background: #0366d6; color: #fff; }
.calendar-day.active:hover { background: #0357c1; }
.calendar-day.today { text-decoration: underline; }

/* サイドバートグル（モバイルのみ） */
.sidebar-toggle {
  display: none;
  width: 100%;
  padding: 10px 14px;
  background: #f6f8fa;
  border: 1px solid #e1e4e8;
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  margin-bottom: 16px;
  color: #24292e;
}

.sidebar-toggle::after { content: ' ▼'; float: right; color: #6a737d; }
.sidebar-toggle.open::after { content: ' ▲'; }
.sidebar-inner { display: block; }

@media (max-width: 1200px) {
  .post-list { grid-template-columns: repeat(4, 1fr); }
}

@media (max-width: 900px) {
  .post-list { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 750px) {
  .post-list { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 600px) {
  .post-list { grid-template-columns: repeat(2, 1fr); }
  .page-with-sidebar { flex-direction: column; padding: 16px; }
  .sidebar { width: 100%; }
  .sidebar-toggle { display: block; }
  .sidebar-inner { display: none; }
  .sidebar-inner.open { display: block; }
  .content { padding: 20px 16px; }
  .site-header { padding: 12px 16px; }
  body { font-size: 18px; }
  .post-header { gap: 14px; }
  .post-title { font-size: 20px; }
  .post-header-thumb { width: 160px; height: 160px; border-radius: 4px; }
}
