/* ── Design tokens & reset ──────────────────────────────────── */

:root {
  --color-accent:       #2f7d25;
  --color-accent-dark:  #236a19;
  --color-bg:           #fbfcf6;
  --color-bg-secondary: #edf6e8;
  --color-bg-white:     #ffffff;
  --color-text:         #1e261d;
  --color-text-sub:     #667064;
  --color-text-muted:   #8a9185;
  --color-border:       #dfe9db;
  --color-border-light: #e8f0e3;
  --color-brand-dark:   #1e261d;
  --color-success:      #16a34a;
  --color-warning:      #d97706;
  --color-error:        #dc2626;
  --font-body:    "M PLUS Rounded 1c", "Hiragino Sans", "Yu Gothic", "Meiryo", system-ui, sans-serif;
  --font-heading: "M PLUS Rounded 1c", "Hiragino Sans", "Yu Gothic", "Meiryo", system-ui, sans-serif;
  --font-mono:    'SFMono-Regular', 'Consolas', 'Menlo', monospace;
  --transition:   0.3s cubic-bezier(0.4, 0.4, 0, 1);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

/* ── フォントメトリクス補正（CLS軽減） ───────────────────────── */
@font-face {
  font-family: 'Noto Sans JP Fallback';
  src: local('Hiragino Sans'), local('Yu Gothic Medium'), local('Meiryo'), local('Arial');
  ascent-override: 88%; descent-override: 22%; line-gap-override: 0%; size-adjust: 105%;
}

body {
  margin: 0;
  padding: 0;
  background: linear-gradient(180deg, #fff 0%, var(--color-bg) 460px, #fff 100%);
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--color-text);
  line-height: 1.7;
  letter-spacing: 0;
  overflow-wrap: break-word;
  line-break: strict;
}

/* ── Header ─────────────────────────────────────────────────── */
header {
  height: 70px;
  background: rgba(255, 255, 255, .98);
  border-bottom: 1px solid #e7eee2;
  padding: 0;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 1px 12px rgba(39, 83, 33, .05);
}
.header-inner {
  width: min(1160px, calc(100vw - 64px));
  height: 100%;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 28px;
}
.site-title {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
}
.site-title img {
  display: block;
  width: 160px;
  height: auto;
}
header nav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 26px;
  margin-left: auto;
  white-space: nowrap;
}
header nav a {
  color: #273025;
  font-weight: 700;
  font-size: 13px;
  padding: 24px 0 21px;
  border-bottom: 3px solid transparent;
  text-decoration: none;
}
header nav a:hover,
header nav a.active {
  color: var(--color-accent);
  border-color: #5aa143;
}

/* ── Footer ─────────────────────────────────────────────────── */
footer {
  margin-top: 3rem;
  text-align: center;
  padding: 34px 1rem 30px;
  font-size: .8rem;
  color: rgba(255, 255, 255, .82);
  background: linear-gradient(135deg, #14572d, #063b20);
}
footer a { color: inherit; text-decoration: none; }
.footer-logo {
  display: inline-flex;
  align-items: center;
}
.footer-logo img {
  width: 190px;
  height: auto;
  filter: brightness(0) invert(1);
}
footer p {
  margin: 16px 0 0;
}

/* ── Article layout ─────────────────────────────────────────── */
.article-container {
  max-width: 900px;
  margin: 0 auto;
  padding: 3rem 1.5rem;
}

/* ── Article header ─────────────────────────────────────────── */
.article-header {
  position: static;
  top: auto;
  z-index: auto;
  height: auto;
  margin-bottom: 2rem;
  padding: 30px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: white;
  box-shadow: 0 5px 16px rgba(55, 89, 44, .06);
  min-width: 0;
}
.article-title {
  font-family: var(--font-heading);
  font-size: clamp(1.55rem, 4vw, 2rem);
  font-weight: 800;
  line-height: 1.4;
  letter-spacing: 0;
  color: var(--color-brand-dark);
  margin: 0 0 0.75rem;
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: normal;
  line-break: strict;
}
.article-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.8125rem;
  color: var(--color-text-sub);
  min-width: 0;
}
.article-meta time { font-variant-numeric: tabular-nums; }
.article-reading-time-sep { color: var(--color-text-muted); }
.article-reading-time {
  white-space: nowrap;
}
.article-tags {
  display: flex;
  flex: 1 1 100%;
  flex-wrap: wrap;
  gap: 0.35rem;
  min-width: 0;
}
.article-tag {
  display: inline-block;
  padding: 0.2rem 0.65rem;
  background: var(--color-bg-secondary);
  border: 1px solid #cfe2c7;
  border-radius: 4px;
  font-size: 0.75rem;
  color: var(--color-text-sub);
  text-decoration: none;
}
.article-tag--cat {
  background: #edf6e8;
  color: var(--color-accent);
  font-weight: 700;
  transition: background 0.2s;
}
.article-tag--cat:hover {
  background: #dcebd2;
}

/* ── Breadcrumb ─────────────────────────────────────────────── */
.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  margin-bottom: 1.25rem;
}
.breadcrumb a { color: var(--color-accent); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb-sep { color: var(--color-border); }

/* ── Table of contents ──────────────────────────────────────── */
.toc {
  background: #f7fbf3;
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-accent);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin: 1.75rem 0;
  font-size: 0.875rem;
}
.toc-title {
  font-weight: 700;
  margin: 0 0 0.5rem;
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-sub);
}
.toc ol, .toc ul { margin: 0; padding-left: 1.25rem; }
.toc li { margin: 0.25rem 0; }
.toc a { color: var(--color-text); text-decoration: none; }
.toc a:hover { color: var(--color-accent); }
.toc .toc-h3 { font-size: 0.8125rem; color: var(--color-text-sub); margin-left: 1.25em; }

/* ── Article body ───────────────────────────────────────────── */
.article-body {
  line-height: 1.85;
  letter-spacing: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
  padding: 30px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: white;
  box-shadow: 0 5px 16px rgba(55, 89, 44, .06);
}
.article-body h2 {
  font-size: 1.35rem;
  font-weight: 800;
  margin: 2.4rem 0 0.85rem;
  padding-left: 0.8rem;
  border-left: 4px solid var(--color-accent);
  color: var(--color-brand-dark);
}
.article-body h2:first-child { margin-top: 0; }
.article-body h3 {
  font-size: 1.12rem;
  font-weight: 800;
  margin: 1.75rem 0 0.5rem;
  color: var(--color-brand-dark);
}
.article-body h4 {
  font-size: 1rem;
  font-weight: 700;
  margin: 1.5rem 0 0.4rem;
}
.article-body p    { margin: 0 0 1rem; }
.article-body ul, .article-body ol { margin: 0 0 1rem; padding-left: 1.5rem; }
.article-body li   { margin: 0.3rem 0; }
.article-body li ul, .article-body li ol { margin-bottom: 0; }
.article-body blockquote {
  margin: 1rem 0;
  padding: 0.75rem 1rem;
  border-left: 3px solid var(--color-accent);
  background: var(--color-bg-secondary);
  border-radius: 0 8px 8px 0;
  color: var(--color-text-sub);
  font-style: italic;
}
.article-body hr { border: none; border-top: 1px solid var(--color-border); margin: 2rem 0; }
.article-body img { max-width: 100%; height: auto; border-radius: 8px; margin: 0.5rem 0; }
.article-body a { color: var(--color-accent); font-weight: 700; }
.article-body a:hover { text-decoration: underline; }
.article-body strong { font-weight: 700; color: var(--color-brand-dark); }

/* ── Code ───────────────────────────────────────────────────── */
.article-body code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--color-bg-secondary);
  padding: 0.1em 0.4em;
  border-radius: 4px;
  border: 1px solid var(--color-border-light);
}
.article-body pre {
  background: #12331f;
  border-radius: 10px;
  padding: 1.1rem 1.25rem;
  overflow-x: auto;
  margin: 1rem 0;
  line-height: 1.6;
}
.article-body pre code {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  background: none;
  border: none;
  padding: 0;
  color: #e2e8f0;
}

/* ── Table ──────────────────────────────────────────────────── */
.article-body .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 1rem 0; }
.article-body table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.article-body th {
  background: #f7fbf3;
  font-weight: 700;
  text-align: left;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--color-border);
}
.article-body td { padding: 0.5rem 0.75rem; border: 1px solid var(--color-border-light); vertical-align: top; }

/* ── Related links ──────────────────────────────────────────── */
.related-tools {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--color-border);
}
.related-tools-title {
  font-size: 0.8125rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-sub);
  margin: 0 0 0.75rem;
}
.related-tools-list { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.related-tool-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.9rem;
  background: var(--color-bg-white);
  border: 1px solid var(--color-border);
  border-radius: 50px;
  font-size: 0.8125rem;
  color: var(--color-text);
  text-decoration: none;
  transition: all var(--transition);
}
.related-tool-link:hover { border-color: var(--color-accent); color: var(--color-accent); }

/* ── .md source link ────────────────────────────────────────── */
.md-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  color: var(--color-text-sub);
  text-decoration: none;
  letter-spacing: 0.04em;
  transition: color var(--transition);
  margin-left: 0;
}
.md-link:hover { color: var(--color-accent); }
.md-link svg { width: 13px; height: 13px; flex-shrink: 0; }

/* ── Prev/next nav ──────────────────────────────────────────── */
.article-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--color-border);
}
.article-nav a {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.75rem 1rem;
  background: var(--color-bg-white);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  text-decoration: none;
  transition: border-color var(--transition);
}
.article-nav a:hover { border-color: var(--color-accent); }
.article-nav-label { font-size: 0.75rem; color: var(--color-text-muted); }
.article-nav-title { font-size: 0.875rem; color: var(--color-text); font-weight: 400; }
.article-nav .next { text-align: right; }
.article-nav .prev:empty, .article-nav .next:empty { visibility: hidden; }

/* ── Article list ───────────────────────────────────────────── */
.article-list { display: flex; flex-direction: column; gap: 1rem; }
.article-card {
  display: block;
  padding: 1.25rem 1.5rem;
  background: var(--color-bg-white);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  text-decoration: none;
  box-shadow: 0 5px 16px rgba(55, 89, 44, .06);
  transition: border-color var(--transition);
}
.article-card:hover { border-color: var(--color-accent); }
.article-card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-text);
  margin: 0 0 0.35rem;
  line-height: 1.5;
}
.article-card-desc {
  font-size: 0.9375rem;
  color: var(--color-text-sub);
  margin: 0 0 0.5rem;
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.article-card-meta {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

/* ── Category filter ────────────────────────────────────────── */
.tag-filter { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1.25rem; }
.tag-filter-item {
  display: inline-block;
  padding: 0.3rem 0.9rem;
  border: 1px solid var(--color-border);
  border-radius: 5px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--color-text-sub);
  text-decoration: none;
  background: var(--color-bg-white);
  min-height: 32px;
  line-height: 1.6;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}
.tag-filter-item:not(.is-active):hover { border-color: var(--color-accent); color: var(--color-accent); }
.tag-filter-item.is-active { background: var(--color-accent); border-color: var(--color-accent); color: #fff; }
.tag-filter-note { font-size: 0.875rem; color: var(--color-text-sub); margin: 0 0 1rem; }
.tag-filter-note a { color: var(--color-accent); text-decoration: none; }
.tag-filter-note a:hover { text-decoration: underline; }

/* ── Pagination ─────────────────────────────────────────────── */
.pagination {
  display: flex;
  justify-content: center;
  gap: 0.35rem;
  margin-top: 2rem;
  flex-wrap: wrap;
}
.pagination a, .pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 0.6rem;
  border-radius: 8px;
  font-size: 0.875rem;
  text-decoration: none;
}
.pagination a { border: 1px solid var(--color-border); color: var(--color-text); }
.pagination a:hover { border-color: var(--color-accent); color: var(--color-accent); }
.pagination .current { background: var(--color-accent); color: #fff; font-weight: 700; }

.archive-title {
  margin: 0 0 1rem;
  font-size: 2rem;
  font-weight: 800;
  color: var(--color-brand-dark);
}

.text-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  margin-top: 1.5rem;
  padding: 0 22px;
  border-radius: 8px;
  color: #fff;
  background: linear-gradient(180deg, #357f25, #236a19);
  text-decoration: none;
  font-weight: 800;
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 600px) {
  header { height: auto; }
  .header-inner {
    width: calc(100% - 24px);
    min-height: 70px;
    flex-wrap: wrap;
    padding: 14px 0;
  }
  header nav {
    order: 3;
    width: 100%;
    overflow-x: auto;
    justify-content: flex-start;
    gap: 20px;
  }
  header nav a {
    padding: 8px 0 10px;
  }
  .article-container { padding: 1.5rem 1rem; }
  .article-header,
  .article-body { padding: 20px; }
  .article-title { font-size: 1.45rem; line-height: 1.5; }
  .archive-title { font-size: 1.6rem; }
  .article-meta { align-items: flex-start; gap: 0.55rem 0.75rem; }
  .md-link { flex-basis: 100%; }
  .article-nav { grid-template-columns: 1fr; }
  .article-nav .next { text-align: left; }
}
