/* =========================================================
   Bunkei Log - main stylesheet
   設計トークン → ベース → レイアウト → コンポーネント → レスポンシブ
   配色は CSS 変数 + [data-theme] でライト/ダークを切替
   ========================================================= */

/* ---------- Design tokens (light) ---------- */
:root {
	--accent: #3b5bdb;
	--accent-hover: #2f49b0;
	--accent-soft: #e7ecff;
	--text: #1f2430;
	--text-muted: #5b6472;
	--bg: #ffffff;
	--surface: #f6f7f9;
	--surface-2: #eef0f4;
	--border: #e3e6ec;
	--code-bg: #0f1729;
	--code-text: #e6edf3;
	--shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px rgba(16, 24, 40, .06);
	--radius: 14px;
	--radius-sm: 9px;
	--wrap: 1180px;
	--gap: clamp(1rem, .8rem + 1vw, 1.75rem);
	--header-h: 64px;
	--font-sans: "Noto Sans JP", -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
	--font-mono: "JetBrains Mono", "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

/* ---------- Design tokens (dark) ---------- */
[data-theme="dark"] {
	--accent: #8aa2ff;
	--accent-hover: #a8b9ff;
	--accent-soft: #1d2440;
	--text: #e6e8ee;
	--text-muted: #9aa3b2;
	--bg: #0e1117;
	--surface: #161b24;
	--surface-2: #1d2430;
	--border: #2a313d;
	--code-bg: #0a0e1a;
	--code-text: #e6edf3;
	--shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .35);
	color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
	margin: 0;
	font-family: var(--font-sans);
	font-size: 1rem;
	line-height: 1.85;
	color: var(--text);
	background: var(--bg);
	-webkit-font-smoothing: antialiased;
	text-rendering: optimizeLegibility;
	transition: background-color .2s ease, color .2s ease;
}
img { max-width: 100%; height: auto; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }

h1, h2, h3, h4 { line-height: 1.4; font-weight: 700; }

.wrap { width: min(100% - 2rem, var(--wrap)); margin-inline: auto; }

.screen-reader-text {
	position: absolute !important; width: 1px; height: 1px;
	padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.skip-link {
	position: fixed; top: -100px; left: 1rem; z-index: 1000;
	background: var(--accent); color: #fff; padding: .6rem 1rem; border-radius: 8px;
}
.skip-link:focus { top: 1rem; }

/* ---------- Progress bar ---------- */
.site-progress {
	position: fixed; inset: 0 0 auto 0; height: 3px; z-index: 60; background: transparent; pointer-events: none;
}
.site-progress span {
	display: block; height: 100%; width: 0; background: var(--accent);
	transition: width .1s linear;
}

/* ---------- Header ---------- */
.site-header {
	position: sticky; top: 0; z-index: 50;
	background: color-mix(in srgb, var(--bg) 86%, transparent);
	backdrop-filter: saturate(180%) blur(10px);
	border-bottom: 1px solid var(--border);
	transition: box-shadow .2s ease;
}
.site-header[data-scrolled="true"] { box-shadow: var(--shadow); }
.site-header__inner {
	display: flex; align-items: center; gap: 1.25rem;
	height: var(--header-h);
}
.site-title { margin: 0; font-size: 1.1rem; font-weight: 800; letter-spacing: .01em; }
.site-title a { color: var(--text); }
.custom-logo { max-height: 40px; width: auto; }

.site-nav { margin-inline-start: auto; }
.site-nav__list {
	display: flex; gap: .25rem; list-style: none; margin: 0; padding: 0;
}
.site-nav__list a {
	display: inline-block; padding: .5rem .8rem; border-radius: 8px;
	color: var(--text-muted); font-size: .95rem; font-weight: 600;
}
.site-nav__list a:hover { color: var(--text); background: var(--surface); text-decoration: none; }

.site-header__actions { display: flex; align-items: center; gap: .5rem; }

.theme-toggle, .nav-toggle {
	display: inline-flex; align-items: center; justify-content: center;
	width: 40px; height: 40px; border: 1px solid var(--border); background: var(--surface);
	border-radius: 10px; cursor: pointer; color: var(--text);
}
.theme-toggle__icon { font-size: 1.05rem; line-height: 1; }
[data-theme="light"] .theme-toggle__icon--moon,
:root:not([data-theme="dark"]) .theme-toggle__icon--moon { display: none; }
[data-theme="dark"] .theme-toggle__icon--sun { display: none; }
.nav-toggle { display: none; flex-direction: column; gap: 4px; }
.nav-toggle span { width: 18px; height: 2px; background: currentColor; border-radius: 2px; transition: .2s; }

/* ---------- Layout ---------- */
.site-content { padding-block: clamp(1.5rem, 1rem + 2vw, 3rem); }
.content-area.layout-with-sidebar {
	display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: clamp(1.5rem, 1rem + 2vw, 3rem); align-items: start;
}
.content-area__main { min-width: 0; }
.content-area__main--narrow { max-width: 760px; margin-inline: auto; }

/* ---------- Page header ---------- */
.page-header { margin-bottom: var(--gap); }
.page-header__title { margin: 0; font-size: clamp(1.4rem, 1.1rem + 1.2vw, 2rem); }
.page-header__title span { color: var(--accent); }

/* ---------- Card grid ---------- */
.card-grid {
	display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--gap);
}
.card {
	position: relative; display: flex; flex-direction: column;
	background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
	overflow: hidden; transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); }
/* タイトルリンクをカード全体へ拡張（stretched link）。入れ子 <a> を避ける */
.card__title-link { color: inherit; }
.card__title-link::after { content: ""; position: absolute; inset: 0; z-index: 1; }
.card__title-link:hover { text-decoration: none; }
.card:hover .card__title-link { color: var(--accent); }
.card .entry-meta__cat { position: relative; z-index: 2; } /* カテゴリは拡張リンクより上で独立クリック可 */
.card__thumb { aspect-ratio: 16 / 9; background: var(--surface); overflow: hidden; }
.card__image { width: 100%; height: 100%; object-fit: cover; display: block; }
.card__body { padding: 1rem 1.1rem 1.2rem; display: flex; flex-direction: column; gap: .5rem; flex: 1; }
.card__title { margin: 0; font-size: 1.02rem; line-height: 1.55; font-weight: 700; }
.card__excerpt { margin: 0; font-size: .86rem; color: var(--text-muted); line-height: 1.7; }
.card__more { margin-top: auto; font-size: .8rem; font-weight: 700; color: var(--accent); }

/* テキスト先行カード（アイキャッチ無し）：タイトルを主役に、上部に細いアクセントバー */
.card--no-thumb { position: relative; }
.card--no-thumb::before {
	content: ""; position: absolute; inset: 0 0 auto 0; height: 4px;
	background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 40%, transparent));
}
.card--no-thumb .card__body { padding-top: 1.3rem; gap: .6rem; }
.card--no-thumb .card__title { font-size: 1.12rem; }
.card--no-thumb .card__excerpt { -webkit-line-clamp: 3; line-clamp: 3; display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; }

/* ---------- Entry meta ---------- */
.entry-meta { display: flex; align-items: center; gap: .6rem; font-size: .8rem; color: var(--text-muted); }
.entry-meta__cat {
	display: inline-flex; align-items: center; gap: .3em;
	background: var(--accent-soft); color: var(--accent);
	padding: .22rem .6rem; border-radius: 6px;
	font-weight: 700; font-size: .72rem; letter-spacing: .04em; text-transform: uppercase;
	border: 1px solid color-mix(in srgb, var(--accent) 28%, transparent); line-height: 1.3;
	transition: background .15s ease, color .15s ease, transform .15s ease;
}
.entry-meta__cat::before {
	content: ""; width: .85em; height: .85em; flex: 0 0 auto; background: currentColor;
	-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M10 4H4a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-8l-2-2z'/%3E%3C/svg%3E") center / contain no-repeat;
	        mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M10 4H4a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-8l-2-2z'/%3E%3C/svg%3E") center / contain no-repeat;
}
.entry-meta__cat:hover { background: var(--accent); color: #fff; transform: translateY(-1px); text-decoration: none; }

/* ---------- Single ---------- */
.entry-header { margin-bottom: var(--gap); }
.entry-title { margin: .5rem 0 .6rem; font-size: clamp(1.5rem, 1.2rem + 1.8vw, 2.25rem); }
.entry-header__meta { display: flex; gap: 1rem; font-size: .85rem; color: var(--text-muted); }
.entry-eyecatch { margin: 0 0 var(--gap); border-radius: var(--radius); overflow: hidden; }
.entry-eyecatch img { width: 100%; display: block; }

.entry-content { font-size: 1.02rem; }
.entry-content > * + * { margin-top: 1.25em; }
.entry-content h2 {
	margin-top: 2.4em; padding-bottom: .4em; font-size: 1.5rem;
	border-bottom: 2px solid var(--border);
}
.entry-content h3 { margin-top: 1.8em; font-size: 1.2rem; }
.entry-content h2, .entry-content h3 { scroll-margin-top: calc(var(--header-h) + 16px); }
.entry-content a { text-decoration: underline; text-underline-offset: 2px; }
.entry-content ul, .entry-content ol { padding-left: 1.4em; }
.entry-content li + li { margin-top: .35em; }
.entry-content blockquote {
	margin: 1.5em 0; padding: .8em 1.2em; border-left: 4px solid var(--accent);
	background: var(--surface); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; color: var(--text-muted);
}
.entry-content img { border-radius: var(--radius-sm); }
.entry-content table { width: 100%; border-collapse: collapse; }
.entry-content th, .entry-content td { border: 1px solid var(--border); padding: .6em .8em; }
.entry-content th { background: var(--surface); }

/* ---------- Code blocks ---------- */
.entry-content :not(pre) > code {
	font-family: var(--font-mono); font-size: .88em;
	background: var(--surface-2); padding: .15em .45em; border-radius: 6px;
	border: 1px solid var(--border);
}
.entry-content pre {
	position: relative; margin: 1.6em 0; padding: 1.1rem 1.1rem; overflow: auto;
	background: var(--code-bg); color: var(--code-text); border-radius: var(--radius-sm);
	font-family: var(--font-mono); font-size: .86rem; line-height: 1.7; tab-size: 2;
}
.entry-content pre code { font-family: inherit; background: none; border: 0; padding: 0; color: inherit; }
/* highlight.js: pre 側が背景を持つので code(.hljs) は透明にして二重背景を防ぐ */
.entry-content pre code.hljs { background: transparent; padding: 0; }
/* Highlighting Code Block の名残マークアップ（.hcb_wrap）も自前preに馴染ませる */
.entry-content .hcb_wrap { margin: 1.6em 0; }
.entry-content .hcb_wrap pre { margin: 0; }

/* ---------- Prism トークンのダーク配色（既存記事の焼き込みコードを上書き） ----------
   .entry-content 接頭辞で、自前CSS(custom-css-js)より詳細度を高くして確実に上書きする。 */
.entry-content pre[class*="language-"],
.entry-content .code-toolbar > pre[class*="language-"] {
	background: var(--code-bg) !important;
	color: #c9d3e0;
	text-shadow: none;
}
.entry-content .code-toolbar { position: relative; margin: 1.6em 0; }
.entry-content :not(pre) > code[class*="language-"] {
	background: var(--surface-2);
	color: var(--text);
	text-shadow: none;
	padding: .15em .45em;
	border-radius: 6px;
}
.entry-content pre[class*="language-"] .token { background: none !important; }
.entry-content .token.comment,
.entry-content .token.prolog,
.entry-content .token.doctype,
.entry-content .token.cdata { color: #6b7689; font-style: italic; }
.entry-content .token.punctuation { color: #abb2bf; }
.entry-content .token.property,
.entry-content .token.tag,
.entry-content .token.constant,
.entry-content .token.symbol,
.entry-content .token.deleted,
.entry-content .token.variable { color: #e06c75; }
.entry-content .token.boolean,
.entry-content .token.number { color: #d19a66; }
.entry-content .token.selector,
.entry-content .token.attr-name,
.entry-content .token.string,
.entry-content .token.char,
.entry-content .token.builtin,
.entry-content .token.inserted { color: #98c379; }
.entry-content .token.operator,
.entry-content .token.entity,
.entry-content .token.url { color: #56b6c2; }
.entry-content .token.atrule,
.entry-content .token.attr-value,
.entry-content .token.keyword { color: #c678dd; }
.entry-content .token.function,
.entry-content .token.class-name { color: #61afef; }
.entry-content .token.regex,
.entry-content .token.important { color: #e5c07b; }
.entry-content .token.important,
.entry-content .token.bold { font-weight: 700; }
.entry-content .token.italic { font-style: italic; }
/* Prism のツールバー（コピー/言語ラベル）の体裁を整える */
.entry-content .code-toolbar > .toolbar { opacity: 0; transition: opacity .15s ease; }
.entry-content .code-toolbar:hover > .toolbar { opacity: 1; }
.entry-content .code-toolbar > .toolbar .toolbar-item > button,
.entry-content .code-toolbar > .toolbar .toolbar-item > span {
	font: 600 .72rem/1 var(--font-sans); color: #cdd5e0; background: rgba(255,255,255,.08);
	border: 1px solid rgba(255,255,255,.16); border-radius: 7px; padding: .4rem .6rem; cursor: pointer;
}

/* ---------- Callouts (block patterns) ---------- */
.callout {
	border: 1px solid var(--border); border-radius: var(--radius-sm);
	padding: 1rem 1.2rem; background: var(--surface);
}
.callout__label { font-weight: 800; font-size: .78rem; letter-spacing: .05em; margin: 0 0 .3rem; }
.callout--point { border-left: 4px solid var(--accent); }
.callout--point .callout__label { color: var(--accent); }
.callout--note { border-left: 4px solid #e8590c; }
.callout--note .callout__label { color: #e8590c; }
.cta {
	border: 1px solid var(--border); border-radius: var(--radius);
	padding: 1.4rem 1.5rem; background: var(--surface); text-align: center;
}

/* ---------- Internal blog card ---------- */
.journal-blog-card {
	display: grid; grid-template-columns: minmax(120px, 168px) minmax(0, 1fr) auto;
	align-items: center; gap: 1rem; margin: 1.6em 0; padding: .8rem;
	border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg);
	color: var(--text); box-shadow: var(--shadow); text-decoration: none;
	transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.journal-blog-card:hover {
	border-color: var(--accent); box-shadow: var(--shadow); transform: translateY(-2px); text-decoration: none;
}
.journal-blog-card:focus-visible, .journal-blog-card-fallback:focus-visible {
	outline: 3px solid var(--accent); outline-offset: 3px;
}
.journal-blog-card--no-image { grid-template-columns: minmax(0, 1fr) auto; }
.journal-blog-card__media { align-self: stretch; min-height: 104px; overflow: hidden; border-radius: var(--radius-sm); background: var(--surface); }
.journal-blog-card__image { width: 100%; height: 100%; min-height: 104px; object-fit: cover; display: block; }
.journal-blog-card__body { display: flex; min-width: 0; flex-direction: column; gap: .25rem; }
.journal-blog-card__meta { color: var(--accent); font-size: .72rem; font-weight: 800; }
.journal-blog-card__title { color: var(--text); font-size: 1rem; font-weight: 800; line-height: 1.5; }
.journal-blog-card__excerpt {
	display: -webkit-box; overflow: hidden; color: var(--text-muted); font-size: .8rem; line-height: 1.65;
	-webkit-box-orient: vertical; -webkit-line-clamp: 2;
}
.journal-blog-card__arrow { color: var(--accent); font-size: 1.25rem; font-weight: 800; }
.journal-blog-card-fallback { overflow-wrap: anywhere; }

/* ---------- Writing patterns ---------- */
.journal-steps, .journal-faq, .journal-comparison {
	margin-block: 1.6em; padding: 1.2rem 1.3rem; border: 1px solid var(--border);
	border-radius: var(--radius); background: var(--surface);
}
.journal-steps__label { margin: 0 0 .75rem; color: var(--accent); font-size: .75rem; font-weight: 800; letter-spacing: .08em; }
.journal-steps__list { margin: 0; padding: 0; list-style: none; counter-reset: journal-step; }
.journal-steps__list > li {
	position: relative; min-height: 2.2rem; margin: 0; padding: 0 0 1.1rem 3rem; counter-increment: journal-step;
}
.journal-steps__list > li:last-child { padding-bottom: 0; }
.journal-steps__list > li::before {
	content: counter(journal-step); position: absolute; top: 0; left: 0; display: grid; place-items: center;
	width: 2rem; height: 2rem; border-radius: 50%; background: var(--accent); color: #fff; font-size: .8rem; font-weight: 800;
}
.journal-steps__list > li:not(:last-child)::after {
	content: ""; position: absolute; top: 2.15rem; bottom: .15rem; left: calc(1rem - 1px); border-left: 2px solid var(--border);
}
.journal-faq > h3:first-child, .journal-comparison > h3:first-child { margin-top: 0; }
.journal-faq__item { margin: .7rem 0 0; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg); }
.journal-faq__item summary { padding: .8rem 2.5rem .8rem 1rem; color: var(--text); font-weight: 700; cursor: pointer; }
.journal-faq__item summary:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: var(--radius-sm); }
.journal-faq__item > :not(summary) { margin-inline: 1rem; }
.journal-faq__item > :last-child { margin-bottom: 1rem; }
.journal-comparison__grid { gap: 1rem; }
.journal-comparison__item { padding: 1rem 1.1rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg); }
.journal-comparison__item > h4:first-child { margin-top: 0; }
.journal-comparison__item--a { border-top: 4px solid var(--accent); }
.journal-comparison__item--b { border-top: 4px solid #e8590c; }

@media (max-width: 600px) {
	.journal-blog-card { grid-template-columns: 96px minmax(0, 1fr); gap: .75rem; padding: .65rem; }
	.journal-blog-card--no-image { grid-template-columns: minmax(0, 1fr); }
	.journal-blog-card__media, .journal-blog-card__image { min-height: 76px; }
	.journal-blog-card__title { font-size: .9rem; }
	.journal-blog-card__excerpt { -webkit-line-clamp: 1; }
	.journal-blog-card__arrow { display: none; }
	.journal-steps, .journal-faq, .journal-comparison { padding: 1rem; }
}

/* ---------- 装飾：会話吹き出し / ボックス / マーカー（最低限） ---------- */
.balloon { display: flex; gap: .9rem; align-items: flex-start; margin: 1.6em 0; }
.balloon--right { flex-direction: row-reverse; }
.balloon__icon { flex: 0 0 auto; width: 56px; text-align: center; }
.balloon__icon img { width: 56px; height: 56px; border-radius: 50%; object-fit: cover; border: 1px solid var(--border); display: block; }
.balloon__name { display: block; font-size: .68rem; color: var(--text-muted); margin-top: .2rem; line-height: 1.2; }
.balloon__body { position: relative; flex: 1; min-width: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: .8rem 1.1rem; }
.balloon__body > :first-child { margin-top: 0; }
.balloon__body > :last-child { margin-bottom: 0; }
.balloon__body::before { content: ""; position: absolute; top: 16px; width: 10px; height: 10px; background: var(--surface); border-left: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.balloon--left .balloon__body::before { left: -6px; transform: rotate(45deg); }
.balloon--right .balloon__body::before { right: -6px; transform: rotate(-135deg); }

.dbox { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); padding: .9rem 1.2rem 1rem; margin: 1.6em 0; }
.dbox__title { margin: 0 0 .4rem; font-weight: 800; font-size: .82rem; letter-spacing: .04em; }
.dbox__body > :first-child { margin-top: 0; }
.dbox__body > :last-child { margin-bottom: 0; }
.dbox--point { border-left: 4px solid var(--accent); }
.dbox--point .dbox__title { color: var(--accent); }
.dbox--note { border-left: 4px solid #e8a33d; }
.dbox--note .dbox__title { color: #e8a33d; }
.dbox--memo { border-left: 4px solid var(--text-muted); }
.dbox--memo .dbox__title { color: var(--text-muted); }
.dbox--warning { border-left: 4px solid #e0524b; }
.dbox--warning .dbox__title { color: #e0524b; }
.dbox--summary { border-left: 4px solid #2fa37a; }
.dbox--summary .dbox__title { color: #2fa37a; }

.entry-content .marker { background: linear-gradient(transparent 62%, rgba(255, 233, 89, .85) 62%); }
.entry-content .marker-r { background: linear-gradient(transparent 62%, rgba(255, 138, 138, .7) 62%); }
[data-theme="dark"] .entry-content .marker { background: linear-gradient(transparent 62%, rgba(214, 184, 74, .5) 62%); }
[data-theme="dark"] .entry-content .marker-r { background: linear-gradient(transparent 62%, rgba(224, 108, 117, .45) 62%); }

/* ---------- TOC ---------- */
.toc {
	border: 1px solid var(--border); border-radius: var(--radius);
	background: var(--bg); overflow: hidden;
}
.toc__toggle {
	display: flex; align-items: center; justify-content: space-between; width: 100%;
	padding: .85rem 1rem; background: var(--surface); border: 0; cursor: pointer; color: var(--text);
	font-weight: 700; font-size: .95rem;
}
.toc__chevron { width: 9px; height: 9px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); transition: transform .2s; }
.toc__toggle[aria-expanded="false"] .toc__chevron { transform: rotate(-45deg); }
.toc__list { list-style: none; margin: 0; padding: .7rem 1rem 1rem; counter-reset: toc; max-height: 70vh; overflow: auto; }
.toc__item { line-height: 1.5; }
.toc__item + .toc__item { margin-top: .35rem; }
.toc__item--h3 { padding-left: 1rem; font-size: .9rem; }
.toc__list a { color: var(--text-muted); display: block; padding: .15rem 0; border-left: 2px solid transparent; padding-left: .6rem; }
.toc__list a:hover { color: var(--text); text-decoration: none; }
.toc__list a.is-active { color: var(--accent); border-left-color: var(--accent); font-weight: 600; }

.entry-toc-mobile { display: none; margin-bottom: var(--gap); }

/* ---------- Breadcrumbs ---------- */
.breadcrumbs { margin-bottom: 1rem; }
.breadcrumbs__list { display: flex; flex-wrap: wrap; gap: .35rem; list-style: none; margin: 0; padding: 0; font-size: .82rem; color: var(--text-muted); }
.breadcrumbs__item + .breadcrumbs__item::before { content: "›"; margin-right: .35rem; color: var(--text-muted); }

/* ---------- Sidebar ---------- */
/* グリッド項目である .sidebar 自体を sticky に（親セルが本文と同じ高さなので追従できる） */
.sidebar { display: flex; flex-direction: column; gap: 1rem; align-self: start; position: sticky; top: calc(var(--header-h) + 16px); }
.sidebar__sticky { display: flex; flex-direction: column; gap: 1rem; }
.widget { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: .85rem 1rem; }
.widget__title { margin: 0 0 .6rem; font-size: .9rem; }

/* ウィジェットのリスト系（カテゴリー/アーカイブ/固定ページ/最近の投稿/メニュー）を素の箇条書きから整形 */
.widget_categories ul, .widget_archive ul, .widget_pages ul, .widget_recent_entries ul,
.widget_nav_menu ul, .widget_meta ul,
.wp-block-categories, .wp-block-archives, .wp-block-page-list, .wp-block-latest-posts {
	list-style: none; margin: 0; padding: 0;
}
.widget_categories li, .widget_archive li, .widget_pages li, .widget_recent_entries li,
.widget_nav_menu li, .widget_meta li,
.wp-block-categories li, .wp-block-archives li, .wp-block-page-list li, .wp-block-latest-posts li {
	margin: 0; display: flex; align-items: center; flex-wrap: wrap; border-bottom: 1px solid var(--border);
}
.widget li > ul { flex-basis: 100%; } /* 子カテゴリのネストは次の行へ折り返す */
.widget_categories li:last-child, .widget_archive li:last-child, .widget_pages li:last-child,
.widget_recent_entries li:last-child, .widget_nav_menu li:last-child, .widget_meta li:last-child,
.wp-block-categories li:last-child, .wp-block-archives li:last-child,
.wp-block-page-list li:last-child, .wp-block-latest-posts li:last-child {
	border-bottom: none;
}
.widget_categories a, .widget_archive a, .widget_pages a, .widget_recent_entries a,
.widget_nav_menu a, .widget_meta a,
.wp-block-categories a, .wp-block-archives a, .wp-block-page-list a, .wp-block-latest-posts a {
	flex: 1; display: flex; align-items: center; gap: .55em;
	padding: .55rem .15rem;
	color: var(--text); font-size: .88rem; font-weight: 600; line-height: 1.5;
	transition: color .15s ease, padding-left .15s ease;
}
.widget_categories a:hover, .widget_archive a:hover, .widget_pages a:hover, .widget_recent_entries a:hover,
.widget_nav_menu a:hover, .widget_meta a:hover,
.wp-block-categories a:hover, .wp-block-archives a:hover, .wp-block-page-list a:hover, .wp-block-latest-posts a:hover {
	color: var(--accent); padding-left: .45rem; text-decoration: none;
}
.widget_categories a::before, .wp-block-categories a::before {
	content: ""; width: .95em; height: .95em; flex: 0 0 auto; background: currentColor; opacity: .85;
	-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M10 4H4a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-8l-2-2z'/%3E%3C/svg%3E") center / contain no-repeat;
	        mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M10 4H4a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-8l-2-2z'/%3E%3C/svg%3E") center / contain no-repeat;
}
/* 件数バッジ（投稿数を表示ON時、" (12)" を <span class="cat-count"> に変換して装飾） */
.cat-count {
	flex: 0 0 auto; margin-left: .5em; min-width: 1.7em; padding: .05rem .5em;
	border-radius: 999px; background: var(--surface-2); color: var(--text-muted);
	font-size: .72rem; font-weight: 700; text-align: center; line-height: 1.6;
}

.profile-card { text-align: center; }
.profile-card__avatar { width: 92px; height: 92px; border-radius: 50%; object-fit: cover; margin-inline: auto; }
.profile-card__avatar--placeholder { display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-size: 2rem; font-weight: 800; }
.profile-card__name { margin: .5rem 0 .25rem; font-size: .95rem; }
.profile-card__bio { margin: 0; font-size: .8rem; color: var(--text-muted); line-height: 1.65; }

/* ---------- Search form ---------- */
.search-form { display: flex; gap: .4rem; }
.search-form__field {
	flex: 1; min-width: 0; padding: .6rem .8rem; border: 1px solid var(--border);
	border-radius: 10px; background: var(--bg); color: var(--text); font: inherit; font-size: .9rem;
}
.search-form__submit {
	display: inline-grid; place-items: center; width: 42px; border: 1px solid var(--border);
	background: var(--accent); color: #fff; border-radius: 10px; cursor: pointer;
}

/* ---------- Pagination ---------- */
.pagination { margin-top: 2rem; }
.pagination .nav-links { display: flex; flex-wrap: wrap; gap: .4rem; justify-content: center; }
.pagination .page-numbers {
	display: inline-grid; place-items: center; min-width: 40px; height: 40px; padding: 0 .6rem;
	border: 1px solid var(--border); border-radius: 10px; color: var(--text); background: var(--bg); font-weight: 600;
}
.pagination .page-numbers.current { background: var(--accent); color: #fff; border-color: var(--accent); }
.pagination a.page-numbers:hover { border-color: var(--accent); text-decoration: none; }

/* ---------- Buttons / misc ---------- */
.button, .wp-block-button__link {
	display: inline-block; background: var(--accent); color: #fff; padding: .7rem 1.4rem;
	border-radius: 10px; font-weight: 700;
}
.button:hover, .wp-block-button__link:hover { background: var(--accent-hover); text-decoration: none; }
.entry-tags { display: flex; flex-wrap: wrap; gap: .4rem; list-style: none; padding: 0; margin: 1.5rem 0 0; }
.entry-tags a { font-size: .8rem; background: var(--surface); border: 1px solid var(--border); padding: .25rem .7rem; border-radius: 999px; color: var(--text-muted); }
.entry-footer { margin-top: var(--gap); }

/* ---------- Share buttons ---------- */
.share { margin-top: var(--gap); }
.share__label { display: block; font-size: .8rem; color: var(--text-muted); margin-bottom: .5rem; font-weight: 700; }
.share__list { display: flex; flex-wrap: wrap; gap: .5rem; list-style: none; margin: 0; padding: 0; }
.share__btn {
	display: inline-flex; align-items: center; justify-content: center; gap: .3rem;
	min-width: 44px; height: 44px; padding: 0 .9rem; border: 1px solid var(--border);
	border-radius: 10px; background: var(--bg); color: var(--text); font-weight: 700; font-size: .85rem;
	cursor: pointer; transition: transform .12s ease, filter .12s ease, background .12s ease;
}
.share__btn:hover { transform: translateY(-2px); text-decoration: none; }
.share__btn--x { background: #000; color: #fff; border-color: #000; }
.share__btn--hatena { background: #00a4de; color: #fff; border-color: #00a4de; }
.share__btn--facebook { background: #1877f2; color: #fff; border-color: #1877f2; }
.share__btn--line { background: #06c755; color: #fff; border-color: #06c755; }
.share__btn--copy[data-copied="true"] { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.share__txt { line-height: 1; }
.share__copied { font-size: .75rem; }

/* ---------- Contact form ---------- */
.contact { max-width: 640px; }
.contact__notice { padding: .8rem 1rem; border-radius: var(--radius-sm); font-weight: 700; }
.contact__notice--success { background: #e7f7ec; color: #1b7a3e; border: 1px solid #b7e3c5; }
.contact__notice--error { background: #fdecec; color: #b3261e; border: 1px solid #f3c0bd; }
[data-theme="dark"] .contact__notice--success { background: #11301f; color: #7ee2a8; border-color: #1f5235; }
[data-theme="dark"] .contact__notice--error { background: #3a1715; color: #ff9d96; border-color: #5e2521; }
.contact__row { display: flex; flex-direction: column; gap: .35rem; margin-bottom: 1.1rem; }
.contact__row label { font-weight: 700; font-size: .9rem; }
.contact__req { color: #e8590c; }
.contact__row input, .contact__row textarea {
	width: 100%; padding: .65rem .85rem; border: 1px solid var(--border); border-radius: 10px;
	background: var(--bg); color: var(--text); font: inherit; font-size: .95rem;
}
.contact__row textarea { resize: vertical; }
.contact__hp { position: absolute; left: -9999px; height: 0; overflow: hidden; }
.contact__submit button {
	background: var(--accent); color: #fff; border: 0; padding: .75rem 2rem;
	border-radius: 10px; font-weight: 700; font-size: 1rem; cursor: pointer;
}
.contact__submit button:hover { background: var(--accent-hover); }

/* ---------- Post navigation (prev/next) ---------- */
.post-nav { margin-top: clamp(2rem, 1.5rem + 2vw, 3rem); }
.post-nav .nav-links { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.post-nav .nav-previous a, .post-nav .nav-next a {
	display: flex; flex-direction: column; gap: .3rem; height: 100%;
	padding: 1rem 1.2rem; border: 1px solid var(--border); border-radius: var(--radius);
	background: var(--bg); color: var(--text); transition: border-color .15s ease, transform .15s ease;
}
.post-nav .nav-previous a:hover, .post-nav .nav-next a:hover { border-color: var(--accent); transform: translateY(-2px); text-decoration: none; }
.post-nav .nav-next { text-align: right; }
.post-nav__label { font-size: .78rem; color: var(--text-muted); font-weight: 700; }
.post-nav__title { font-size: .95rem; line-height: 1.5; color: var(--text); }
@media (max-width: 600px) { .post-nav .nav-links { grid-template-columns: 1fr; } .post-nav .nav-next { text-align: left; } }

/* ---------- Comments ---------- */
.comments-area { margin-top: clamp(2rem, 1.5rem + 2vw, 3.5rem); }
.comments-area .comments-title, .comments-area .comment-reply-title { font-size: 1.3rem; margin: 0 0 var(--gap); padding-left: .6rem; border-left: 4px solid var(--accent); }
.comment-list { list-style: none; margin: 0; padding: 0; }
.comment-list .comment { margin-bottom: 1.2rem; }
.comment-list .comment-body { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.2rem; }
.comment-list .children { list-style: none; margin: 1rem 0 0; padding-left: clamp(.8rem, 3vw, 2rem); }
.comment-author { display: flex; align-items: center; gap: .6rem; }
.comment-author .avatar { border-radius: 50%; }
.comment-author .fn { font-weight: 700; font-style: normal; }
.comment-metadata { font-size: .78rem; color: var(--text-muted); }
.comment-metadata a { color: var(--text-muted); }
.comment-content { margin-top: .6rem; }
.comment-content a { word-break: break-all; }
.comment-respond { margin-top: var(--gap); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.2rem 1.4rem; }
.comment-form label { display: block; font-size: .85rem; font-weight: 700; margin-bottom: .3rem; }
.comment-form input[type="text"],
.comment-form input[type="email"],
.comment-form input[type="url"],
.comment-form textarea {
	width: 100%; padding: .6rem .8rem; border: 1px solid var(--border); border-radius: 10px;
	background: var(--bg); color: var(--text); font: inherit; font-size: .95rem; margin-bottom: 1rem;
}
.comment-form .form-submit input, .comment-list .reply a {
	display: inline-block; background: var(--accent); color: #fff; border: 0;
	padding: .6rem 1.4rem; border-radius: 10px; font-weight: 700; cursor: pointer;
}
.comment-list .reply a:hover { background: var(--accent-hover); text-decoration: none; }

/* ---------- Related posts ---------- */
.related { margin-top: clamp(2rem, 1.5rem + 2vw, 3.5rem); }
.related__title { margin: 0 0 var(--gap); font-size: 1.3rem; padding-left: .6rem; border-left: 4px solid var(--accent); }
.card-grid--related { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }

/* ---------- Author box ---------- */
.author-box { display: flex; gap: 1rem; margin-top: var(--gap); padding: 1.2rem 1.4rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.author-box__avatar img { border-radius: 50%; width: 72px; height: 72px; display: block; }
.author-box__main { min-width: 0; }
.author-box__label { font-size: .72rem; color: var(--text-muted); font-weight: 700; margin: 0 0 .2rem; }
.author-box__name { margin: 0 0 .4rem; font-weight: 800; font-size: 1.05rem; }
.author-box__bio { margin: 0 0 .6rem; font-size: .86rem; color: var(--text-muted); line-height: 1.7; }
.author-box__link { font-size: .85rem; font-weight: 700; }

/* ---------- Mobile floating share bar ---------- */
.share-float { display: none; }
@media (max-width: 720px) {
	.share-float {
		display: flex; position: fixed; inset: auto 0 0 0; z-index: 45;
		gap: 1px; background: var(--border); border-top: 1px solid var(--border);
	}
	.share-float__btn {
		flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: .3rem;
		height: 48px; background: var(--bg); color: var(--text); font-weight: 700; font-size: .82rem; border: 0; cursor: pointer;
	}
	.share-float__btn--x { background: #000; color: #fff; }
	.share-float__btn--hatena { background: #00a4de; color: #fff; }
	.share-float__btn--line { background: #06c755; color: #fff; }
	.share-float__btn--copy[data-copied="true"] { background: var(--accent-soft); color: var(--accent); }
	body.single { padding-bottom: 48px; }
	body.single .to-top { bottom: 60px; }
}

/* ---------- 404 ---------- */
.error-404 { text-align: center; padding-block: clamp(1rem, 2vw, 2rem); }
.error-404__code { font-size: clamp(3rem, 2rem + 6vw, 5rem); font-weight: 800; color: var(--accent); margin: 0; line-height: 1; }
.error-404__title { font-size: 1.4rem; margin: .5rem 0; }
.error-404__desc { color: var(--text-muted); }
.error-404__recent { margin-top: 2.5rem; text-align: left; }
.error-404__subtitle { font-size: 1.2rem; margin: 0 0 var(--gap); padding-left: .6rem; border-left: 4px solid var(--accent); }
.no-results { color: var(--text-muted); }

/* ---------- Footer ---------- */
.site-footer { margin-top: clamp(2.5rem, 2rem + 3vw, 5rem); border-top: 1px solid var(--border); background: var(--surface); }
.site-footer__inner { display: flex; flex-direction: column; align-items: center; gap: .8rem; padding-block: 2rem; text-align: center; }
.site-footer__list { display: flex; flex-wrap: wrap; gap: 1rem; list-style: none; margin: 0; padding: 0; }
.site-footer__list a { color: var(--text-muted); font-size: .9rem; }
.site-footer__copy { margin: 0; color: var(--text-muted); font-size: .82rem; }

.to-top {
	position: fixed; right: 1rem; bottom: 1rem; width: 44px; height: 44px; border-radius: 50%;
	border: 1px solid var(--border); background: var(--bg); color: var(--text); cursor: pointer;
	box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: opacity .2s ease; z-index: 40;
}
.to-top[data-visible="true"] { opacity: 1; pointer-events: auto; }

/* ---------- Lightbox（画像拡大） ---------- */
.entry-content a.has-lightbox { cursor: zoom-in; }
.lightbox {
	position: fixed; inset: 0; z-index: 200; display: none; place-items: center;
	background: rgba(0, 0, 0, .85); padding: 2rem; cursor: zoom-out;
}
.lightbox.is-open { display: grid; }
.lightbox__img { max-width: 95vw; max-height: 90vh; border-radius: 8px; box-shadow: 0 10px 40px rgba(0, 0, 0, .5); }
.lightbox__close {
	position: absolute; top: 1rem; right: 1rem; width: 44px; height: 44px;
	border: 0; border-radius: 50%; background: rgba(255, 255, 255, .15); color: #fff;
	font-size: 1.6rem; line-height: 1; cursor: pointer;
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
	.content-area.layout-with-sidebar { grid-template-columns: 1fr; }
	.sidebar { order: 2; position: static; }
	.sidebar__sticky { position: static; }
	.sidebar .toc { display: none; } /* PCサイドバーのTOCはモバイルで隠す */
	.entry-toc-mobile { display: block; }
}

@media (max-width: 720px) {
	.site-nav { display: none; }
	.nav-toggle { display: inline-flex; }
	.site-nav.is-open {
		display: block; position: fixed; inset: var(--header-h) 0 auto 0; margin: 0;
		background: var(--bg); border-bottom: 1px solid var(--border); box-shadow: var(--shadow);
	}
	.site-nav.is-open .site-nav__list { flex-direction: column; padding: .5rem; }
	.site-nav.is-open .site-nav__list a { display: block; }
}

/* スマホで本文が左右いっぱいにならないよう、余白（ガター）を広げる */
@media (max-width: 600px) {
	.wrap { width: min(100% - 3rem, var(--wrap)); }
}
