:root {
  --fg: #242424;
  --fg-muted: #6b6b6b;
  --bg: #ffffff;
  --link: #1a8917;
  --border: #f2f2f2;
  --hover: #fafafa;
}
* { box-sizing: border-box; }
html { font-size: 16px; overflow-x: hidden; }
body {
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo,
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 24px 64px;
  line-height: 1.6;
  color: var(--fg);
  background: var(--bg);
  overflow-wrap: break-word;
  word-wrap: break-word;
}
/* iOS Safari 等で長いURLや英単語が viewport をはみ出さないように */
.post-body, .site-footer, .card-body, .pub-meta { min-width: 0; overflow-wrap: anywhere; }
.post-body img, .post-body video, .post-body iframe {
  max-width: 100%;
  height: auto;
}
.post-body pre { white-space: pre-wrap; max-width: 100%; }
.post-body table { display: block; max-width: 100%; overflow-x: auto; }
a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; }

/* Language switcher */
.lang-switch {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  font-size: 0.85em;
  padding: 4px 0 0;
}
.lang-switch a {
  color: var(--fg-muted);
  text-decoration: none;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
}
.lang-switch a.active { color: var(--fg); border-color: var(--border); }
.lang-switch a:hover { background: var(--hover); }

/* Publication header (index page) */
.pub-header {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 32px 0 28px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}
.pub-logo {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  flex-shrink: 0;
  object-fit: cover;
}
.pub-meta h1 {
  margin: 0 0 6px;
  font-size: 1.7em;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.pub-tagline { margin: 0 0 6px; color: var(--fg); font-size: 1em; }
.pub-source { margin: 0; color: var(--fg-muted); font-size: 0.85em; }
.pub-source a { color: var(--link); }

/* Tag filter (publication-wide topic chips) */
.tag-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 16px 0 4px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--border);
}
.tag-chip {
  appearance: none;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--fg);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.85em;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.tag-chip:hover { background: var(--hover); }
.tag-chip.active {
  background: var(--fg);
  color: #fff;
  border-color: var(--fg);
}

/* Keyword search */
.search-bar { padding: 12px 0 4px; }
.search-bar input[type="search"] {
  width: 100%;
  padding: 9px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.95em;
  font-family: inherit;
  color: var(--fg);
  background: #fff;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search-bar input[type="search"]:focus {
  border-color: var(--fg);
  box-shadow: 0 0 0 1px var(--fg);
}
.search-hits { margin: 6px 4px 0; color: var(--fg-muted); font-size: 0.82em; min-height: 1em; }
.empty-state { padding: 32px 0; color: var(--fg-muted); text-align: center; }

/* Inline tag pills shown next to author/date on each card */
.card-tags {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-left: 4px;
}
.card-tags::before { content: "·"; margin-right: 4px; color: var(--fg-muted); }
.card-tag {
  font-size: 0.78em;
  color: var(--fg-muted);
  background: var(--border);
  padding: 1px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

/* Article feed (cards) */
.article-feed { display: flex; flex-direction: column; }
.card { border-bottom: 1px solid var(--border); }
.card-link {
  display: grid;
  grid-template-columns: 1fr 112px;
  gap: 24px;
  padding: 24px 0;
  align-items: center;
  text-decoration: none;
  color: inherit;
}
.card-link:hover { text-decoration: none; background: var(--hover); }
.card-body { min-width: 0; }
.card-title {
  margin: 0 0 6px;
  font-size: 1.15em;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.3;
  color: var(--fg);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-excerpt {
  margin: 0 0 12px;
  color: var(--fg-muted);
  font-size: 0.95em;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-meta {
  margin: 0;
  font-size: 0.82em;
  color: var(--fg-muted);
  display: flex;
  gap: 8px;
  align-items: center;
}
.card-meta span:not(:last-child)::after {
  content: "·";
  margin-left: 8px;
  color: var(--fg-muted);
}
.card-thumb {
  width: 112px;
  height: 112px;
  object-fit: cover;
  background: var(--border);
  border-radius: 2px;
  display: block;
}
.card-thumb-placeholder {
  width: 112px;
  height: 112px;
  background: linear-gradient(135deg, #f5f5f5 0%, #e8e8e8 100%);
  border-radius: 2px;
}
@media (max-width: 540px) {
  .card-link { grid-template-columns: 1fr 80px; gap: 16px; }
  .card-thumb, .card-thumb-placeholder { width: 80px; height: 80px; }
  .pub-logo { width: 64px; height: 64px; }
  .pub-meta h1 { font-size: 1.4em; }
}

/* Tablet以上 (>=720px): Mediumライクなカードグリッドに切り替える */
@media (min-width: 720px) {
  .article-feed {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 36px 28px;
    border-top: 1px solid var(--border);
    padding-top: 28px;
  }
  .card { border-bottom: none; }
  .card-link {
    display: flex;
    flex-direction: column-reverse;  /* DOM順 (body, thumb) を逆転して
                                        thumb が上 / body が下になるよう描画 */
    gap: 14px;
    padding: 0;
  }
  .card-body { min-width: 0; }
  .card-thumb, .card-thumb-placeholder {
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    border-radius: 4px;
  }
  .card-title { font-size: 1.25em; -webkit-line-clamp: 3; }
  .card-excerpt { -webkit-line-clamp: 3; }
}

/* PC ワイド (>=1024px): 3列グリッド */
@media (min-width: 1024px) {
  .article-feed { grid-template-columns: repeat(3, 1fr); }
}

/* Article page */
.post-nav {
  display: flex;
  align-items: center;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 32px;
  max-width: 728px;
  margin-left: auto;
  margin-right: auto;
}
/* 記事の本文は可読性のため index より狭めの 728px に制限する */
.post { max-width: 728px; margin: 0 auto; }
.post-nav a { display: flex; align-items: center; gap: 10px; color: var(--fg); font-weight: 600; }
.post-nav-logo { width: 36px; height: 36px; border-radius: 50%; }
.post-header { margin-bottom: 28px; }
.post-header h1 {
  font-size: 2em;
  margin: 0 0 12px;
  line-height: 1.2;
  letter-spacing: -0.015em;
  font-weight: 800;
}
.post-meta { margin: 0; color: var(--fg-muted); font-size: 0.92em; }
.post-meta span + span::before { content: "·"; margin: 0 8px; }
.post-body { font-size: 1.05em; line-height: 1.75; }
.post-body h2 { margin: 36px 0 14px; font-size: 1.45em; letter-spacing: -0.01em; }
.post-body h3 { margin: 28px 0 10px; font-size: 1.2em; }
.post-body p { margin: 16px 0; }
.post-body img { max-width: 100%; height: auto; display: block; margin: 20px auto; }
.post-body pre {
  background: #f7f7f7;
  padding: 16px;
  overflow-x: auto;
  border-radius: 4px;
  font-size: 0.92em;
}
.post-body code {
  background: #f5f5f5;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 0.9em;
}
.post-body pre code { background: transparent; padding: 0; }
.post-body blockquote {
  border-left: 3px solid var(--link);
  margin: 20px 0;
  padding: 4px 16px;
  color: var(--fg-muted);
}
.post-body table { border-collapse: collapse; margin: 16px 0; }
.post-body th, .post-body td { border: 1px solid var(--border); padding: 8px 12px; }
.post-body a { color: var(--link); text-decoration: underline; text-decoration-thickness: 1px; }

/* Mediumライクな関連リンクカード */
.link-card {
  display: block;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 14px 18px;
  margin: 20px 0;
  text-decoration: none !important;
  color: var(--fg);
  transition: background 0.15s, border-color 0.15s;
}
.link-card:hover { background: var(--hover); border-color: #d8d8d8; }
.link-card-title {
  display: block;
  font-weight: 600;
  font-size: 1em;
  line-height: 1.35;
  color: var(--fg);
  margin-bottom: 4px;
}
.link-card-subtitle {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: var(--fg-muted);
  font-size: 0.9em;
  line-height: 1.45;
  margin-bottom: 6px;
}
.link-card-domain {
  display: block;
  color: var(--fg-muted);
  font-size: 0.8em;
}

/* Footer */
.site-footer {
  margin-top: 48px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  color: var(--fg-muted);
  font-size: 0.85em;
}
.site-footer p { margin: 6px 0; }
.site-footer a { color: var(--link); }
/* 記事ページの footer も 728px に揃える */
body.page-article .site-footer { max-width: 728px; margin-left: auto; margin-right: auto; }
