/* ---- テーマ（ライト／ダーク） ----
   配色はZennに寄せています。
   - ライト: 白地 + ブランド青 #3ea8ff
   - ダーク: 紺色（dark-blue）
   --accent は装飾用、--link は文字用（白地でコントラスト4.5以上を確保した濃いめの青） */
:root {
  color-scheme: light dark;
  --bg: #eef3f8;
  --surface: #ffffff;
  --soft: #edf2f7;
  --text: rgba(0, 0, 0, 0.82);
  --muted: #65717b;
  --border: #e4edf4;
  --border-strong: #d6e3ed;
  --accent: #3ea8ff;
  --link: #0b72e0;
  --chip-bg: #ecf5ff;
  --chip-text: #0a66c8;
  --btn: #0b72e0;
  --btn-text: #ffffff;
  --inline-code-bg: #edf2f7;
  --mark: #ffe58a;
  --radius: 4px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #081d35;
    --surface: #0d223a;
    --soft: #0d223a;
    --text: #ecf5ff;
    --muted: #a4bcd5;
    --border: #1b324a;
    --border-strong: #2e445c;
    --accent: #3ea8ff;
    --link: #3ea8ff;
    --chip-bg: #0b2c53;
    --chip-text: #3ea8ff;
    --btn: #3ea8ff;
    --btn-text: #081d35;
    --inline-code-bg: #0b2c53;
    --mark: #5a4d12;
  }
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #081d35;
  --surface: #0d223a;
  --soft: #0d223a;
  --text: #ecf5ff;
  --muted: #a4bcd5;
  --border: #1b324a;
  --border-strong: #2e445c;
  --accent: #3ea8ff;
  --link: #3ea8ff;
  --chip-bg: #0b2c53;
  --chip-text: #3ea8ff;
  --btn: #3ea8ff;
  --btn-text: #081d35;
  --inline-code-bg: #0b2c53;
  --mark: #5a4d12;
}

/* ---- 基本 ---- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "system-ui", "Hiragino Kaku Gothic ProN", "Hiragino Sans",
    "Noto Sans JP", "Yu Gothic", Meiryo, sans-serif;
  font-size: 1rem;
  line-height: 1.9;
  overflow-wrap: anywhere;
}
.wrap { max-width: 46rem; margin: 0 auto; padding: 0 1rem; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.skip { position: absolute; left: -999px; top: 0; background: var(--btn); color: var(--btn-text); padding: .5rem 1rem; z-index: 10; }
.skip:focus { left: 0; }
.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---- ヘッダー／フッター ---- */
.site-header { border-bottom: 1px solid var(--border); background: var(--surface); }
.header-inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .25rem 1rem; padding-top: .75rem; padding-bottom: .75rem; }
.site-title { font-weight: 700; font-size: 1.15rem; color: var(--text); text-decoration: none; }
.site-title:hover { text-decoration: none; color: var(--link); }
.site-nav { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem 1rem; font-size: .95rem; }
.site-nav a { color: var(--muted); text-decoration: none; padding: .25rem 0; border-bottom: 2px solid transparent; }
.site-nav a:hover, .site-nav a[aria-current="page"] { color: var(--text); border-bottom-color: var(--accent); }
.icon-btn { background: none; border: 0; color: var(--muted); cursor: pointer; padding: .35rem; border-radius: 6px; display: inline-flex; }
.icon-btn:hover { color: var(--text); background: var(--soft); }
.site-footer { border-top: 1px solid var(--border); color: var(--muted); font-size: .875rem; padding: 1.5rem 0; }
.site-footer p { margin: 0; }

/* ---- 見出し・一覧 ---- */
.lead { color: var(--muted); margin-top: 0; }
.section-title { font-size: 1.25rem; font-weight: 700; margin: 2rem 0 .75rem; line-height: 1.4; }
h1.section-title:first-child { margin-top: 0; }
.empty { color: var(--muted); }
.meta { color: var(--muted); font-size: .875rem; margin: .25rem 0; }

.post-list { list-style: none; margin: 0; padding: 0; }
.post-item { padding: 1rem 0; border-bottom: 1px solid var(--border); }
.post-item:last-child { border-bottom: 0; }
.post-link { font-size: 1.1rem; font-weight: 700; color: var(--text); text-decoration: none; }
.post-link:hover { color: var(--link); text-decoration: underline; }
.post-item .meta { display: flex; flex-wrap: wrap; gap: .25rem .6rem; align-items: center; }
.post-item .desc { margin: .35rem 0 0; color: var(--muted); font-size: .95rem; line-height: 1.7; }

.tags { list-style: none; display: flex; flex-wrap: wrap; gap: .4rem; margin: .5rem 0; padding: 0; }
.tag { display: inline-block; font-size: .8rem; line-height: 1.5; padding: .05rem .7rem; border-radius: 999px; background: var(--chip-bg); color: var(--chip-text); text-decoration: none; }
a.tag:hover { text-decoration: underline; }
.tags-large .tag { font-size: .95rem; padding: .15rem .9rem; }
.count { opacity: .75; font-size: .85em; margin-left: .15em; }

/* ---- 記事 ---- */
.post-header h1 { font-size: 1.9rem; line-height: 1.4; margin: 0 0 .5rem; }
.toc { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .5rem 1rem; margin: 1.5rem 0; font-size: .95rem; }
.toc summary { cursor: pointer; font-weight: 700; padding: .25rem 0; }
.toc ol { margin: .25rem 0; padding-left: 1.4rem; line-height: 1.7; }
.toc ol ol { margin: 0; }

.prose { margin-top: 1.5rem; }
.prose > :first-child { margin-top: 0; }
.prose h2 { font-size: 1.5rem; margin: 2.4rem 0 .8rem; padding-bottom: .3rem; border-bottom: 1px solid var(--border-strong); line-height: 1.4; scroll-margin-top: 1rem; }
.prose h3 { font-size: 1.2rem; margin: 1.8rem 0 .6rem; line-height: 1.4; scroll-margin-top: 1rem; }
.prose h4 { margin: 1.5rem 0 .5rem; }
.prose a { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: .2em; }
.prose a:hover { text-decoration-thickness: 2px; }
.prose p, .prose ul, .prose ol, .prose blockquote, .prose table, .prose .codehilite, .prose pre, .prose figure { margin: 1rem 0; }
.prose ul, .prose ol { padding-left: 1.6rem; }
.prose li { margin: .25rem 0; }
.prose blockquote { border-left: 4px solid var(--border-strong); margin-left: 0; padding: .1rem 1rem; color: var(--muted); }
/* *斜体* は、蛍光ペンで下半分に線を引いたような見た目にする */
.prose em { font-style: normal; background: linear-gradient(transparent 60%, var(--mark) 60%); padding: 0 .1em; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
.prose hr { border: 0; border-top: 1px solid var(--border-strong); margin: 2rem 0; }
.prose img { border-radius: var(--radius); display: block; margin: 1rem auto; }
.prose table { display: block; overflow-x: auto; border-collapse: collapse; font-size: .95rem; }
.prose th, .prose td { border: 1px solid var(--border-strong); padding: .4rem .8rem; text-align: left; }
.prose th { background: var(--soft); }
.prose code { background: var(--inline-code-bg); padding: .1em .4em; border-radius: var(--radius); font-size: .9em; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
/* コードブロックはZennと同じく、ライト・ダークとも濃い紺色 */
.prose pre { overflow-x: auto; padding: 1rem; border-radius: var(--radius); background: #151e2c; color: #e1e4e8; line-height: 1.6; }
.prose pre code { background: none; padding: 0; font-size: .875rem; color: inherit; }
.prose .codehilite { background: #151e2c; border-radius: var(--radius); overflow-x: auto; }
.codehilite pre { margin: 0; background: none; }
.footnote { font-size: .9rem; color: var(--muted); }

.app-note { margin-top: 2rem; padding: .75rem 1rem; background: var(--chip-bg); border-radius: var(--radius); font-size: .95rem; }

.post-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin: 2.5rem 0 0; }
.post-nav a { display: block; padding: .75rem 1rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); text-decoration: none; font-size: .95rem; line-height: 1.5; }
.post-nav a:hover { border-color: var(--accent); }
.post-nav a span { display: block; color: var(--muted); font-size: .8rem; margin-bottom: .15rem; }
.post-nav .next { text-align: right; grid-column: 2; }
.post-nav .prev { grid-column: 1; }

/* ---- アプリ ---- */
.app-grid { list-style: none; margin: 0; padding: 0; display: grid; gap: 1rem; }
.app-card { display: flex; gap: 1rem; padding: 1rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.app-card-body { min-width: 0; }
.app-card .desc { margin: .2rem 0; color: var(--muted); font-size: .95rem; line-height: 1.6; }
.app-name { font-weight: 700; font-size: 1.1rem; color: var(--text); text-decoration: none; }
.app-name:hover { color: var(--link); text-decoration: underline; }
.app-links { display: flex; flex-wrap: wrap; gap: .25rem 1rem; margin: .4rem 0 0; font-size: .9rem; }
.app-icon { border-radius: 22%; flex: none; width: 64px; height: 64px; object-fit: cover; }
.app-icon-lg { width: 96px; height: 96px; }
.app-header { display: flex; flex-wrap: wrap; gap: 1.25rem; align-items: center; }
.app-header h1 { margin: 0; font-size: 1.9rem; line-height: 1.3; }
.tagline { margin: .25rem 0 .75rem; color: var(--muted); }
.doc-links { list-style: none; margin: 0; padding: 0; }
.doc-links li { padding: .5rem 0; border-bottom: 1px solid var(--border); display: flex; gap: 1rem; flex-wrap: wrap; }
.doc-kind { min-width: 10rem; font-weight: 700; }

/* ---- ボタン・検索 ---- */
.btn { display: inline-block; background: var(--btn); color: var(--btn-text); border: 0; border-radius: 999px; padding: .5rem 1.25rem; font: inherit; font-size: .95rem; font-weight: 700; text-decoration: none; cursor: pointer; }
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.search-form { display: flex; gap: .5rem; }
.search-form input { flex: 1; min-width: 0; font: inherit; padding: .5rem .9rem; border: 1px solid var(--border-strong); border-radius: 999px; background: var(--surface); color: var(--text); }
.search-form input:focus { outline: 3px solid var(--accent); outline-offset: 1px; }
#search-results .snippet { margin: .35rem 0 0; color: var(--muted); font-size: .9rem; line-height: 1.7; }
mark { background: var(--mark); color: inherit; border-radius: 3px; padding: 0 .1em; }

@media (max-width: 36rem) {
  .post-header h1, .app-header h1 { font-size: 1.5rem; }
  .post-nav { grid-template-columns: 1fr; }
  .post-nav .next, .post-nav .prev { grid-column: 1; text-align: left; }
  .doc-kind { min-width: 100%; }
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
@media print {
  .site-header, .site-footer, .post-nav, .related, .toc { display: none; }
  body { background: #fff; color: #000; }
}

/* ---- サイドバー（全ページ共通：筆者情報・タグ） ---- */
.wrap-wide { max-width: 72rem; }
.layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 2.5rem; padding-top: 2rem; padding-bottom: 3rem; }
.main-col { min-width: 0; }
/* 本文は背景色の違う「カード」にして、関連記事・サイドバーと区別する */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem 1.25rem; min-height: 50vh; }
/* 関連記事も白いカードにする */
.related { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem 1.25rem .5rem; margin-top: 1.5rem; }
.related .section-title { margin: 0 0 .25rem; font-size: 1.1rem; }
@media (min-width: 40rem) { .related { padding: 1.5rem 2.5rem .75rem; } }
@media (min-width: 40rem) { .card { padding: 2.25rem 2.5rem; } }
.side { display: grid; gap: 1.25rem; align-content: start; }
.author-card, .side-tags { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; font-size: .9rem; line-height: 1.7; }
.side-title { margin: 0 0 .5rem; font-size: 1rem; line-height: 1.4; }
.side-tags .tags { margin: 0; }
.author-avatar { display: block; width: 72px; height: 72px; border-radius: 50%; object-fit: cover; margin: 0 0 .75rem; }
.author-name { margin: 0; font-weight: 700; font-size: 1.05rem; color: var(--text); }
.author-bio { margin: .4rem 0 0; color: var(--muted); }
.author-links { list-style: none; margin: .75rem 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: .25rem .9rem; }
.author-more { margin: .75rem 0 0; }
@media (min-width: 64rem) {
  .layout { grid-template-columns: minmax(0, 1fr) 17rem; align-items: start; }
  .side { position: sticky; top: 1.5rem; max-height: calc(100vh - 3rem); overflow-y: auto; }
}
@media print { .side { display: none; } }

/* ---- パンくずリスト ---- */
.breadcrumb { margin: 0 0 1.25rem; font-size: .85rem; line-height: 1.5; }
.breadcrumb ol { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; align-items: center; gap: .15rem .5rem; color: var(--muted); }
.breadcrumb li { display: flex; align-items: center; gap: .5rem; min-width: 0; }
.breadcrumb li + li::before { content: "›"; color: var(--muted); }
.breadcrumb a { color: var(--link); }
.breadcrumb [aria-current] { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 24rem; display: block; }
