:root {
  color-scheme: light dark;
  --bg: #fbfaf7;
  --surface: #ffffff;
  --text: #24221f;
  --muted: #6d6860;
  --line: #e4e0d8;
  --accent: #1f5f8b;
  --accent-soft: #e8f0f6;
  --quote: #f3f1ec;
  --code-bg: #f6f8fa;
  --code-head: #eceff3;
  --code-muted: #8c959f;
  --font: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
  /* Japanese fallbacks keep identifiers like 子テーブル aligned in code */
  --mono: ui-monospace, "SFMono-Regular", "Menlo", "Consolas", "Osaka-Mono", "MS Gothic", "Noto Sans Mono CJK JP", monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161514;
    --surface: #1e1d1b;
    --text: #e7e3dc;
    --muted: #a39d93;
    --line: #34312d;
    --accent: #7db6dd;
    --accent-soft: #1f2a33;
    --quote: #24221f;
    --code-bg: #0d1117;
    --code-head: #161b22;
    --code-muted: #6e7681;
  }
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: 16px; line-height: 1.85;
  overflow-wrap: anywhere;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.wrap { max-width: 1200px; margin: 0 auto; padding: 0 16px; }

.site-header { border-bottom: 1px solid var(--line); background: var(--surface); }
.site-header .wrap { padding-top: 28px; padding-bottom: 20px; }
.site-title { font-size: 1.6rem; font-weight: 700; color: var(--text); letter-spacing: .02em; }
.site-title:hover { text-decoration: none; color: var(--accent); }
.site-desc { margin: 4px 0 0; color: var(--muted); font-size: .9rem; }

.layout { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 40px; padding-top: 32px; padding-bottom: 48px; }
@media (max-width: 860px) { .layout { grid-template-columns: minmax(0, 1fr); gap: 32px; } }

.entry { padding: 0 0 24px; margin: 0 0 24px; border-bottom: 1px solid var(--line); }
.entry-title { font-size: 1.2rem; line-height: 1.5; margin: 0 0 4px; }
.entry-title a { color: var(--text); }
.entry-title a:hover { color: var(--accent); }
.summary { margin: 8px 0 0; color: var(--muted); font-size: .95rem; }
.meta { color: var(--muted); font-size: .85rem; display: flex; flex-wrap: wrap; gap: 4px 14px; }
.meta a { color: var(--muted); }
.meta a:hover { color: var(--accent); }

.list-title { font-size: 1.3rem; margin: 0 0 24px; }
.post-title { font-size: 1.6rem; line-height: 1.45; margin: 0 0 6px; }
.post-body { margin-top: 28px; }
.post-body p { margin: 0 0 1.1em; }
.post-body h1, .post-body h2, .post-body h3, .post-body h4 { line-height: 1.5; margin: 2em 0 .7em; scroll-margin-top: 16px; }
.post-body h2 { font-size: 1.3rem; padding-bottom: 4px; border-bottom: 1px solid var(--line); }
.post-body h3 { font-size: 1.15rem; }
.post-body img { max-width: 100%; height: auto; vertical-align: middle; }
.post-body blockquote { margin: 1.2em 0; padding: 12px 18px; background: var(--quote); border-left: 3px solid var(--line); color: var(--text); }
.post-body blockquote p:last-child { margin-bottom: 0; }
.post-body table { border-collapse: collapse; display: block; overflow-x: auto; max-width: 100%; }
.post-body td, .post-body th { border: 1px solid var(--line); padding: 4px 8px; }
.post-body ul, .post-body ol { padding-left: 1.5em; }
/* legacy markup from 2004-era posts */
.post-body font[color] { color: inherit; }
.post-body .section { margin: 0; }
pre, code { font-family: var(--mono); font-size: .875rem; }
.post-body pre { overflow-x: auto; margin: 1.2em 0; padding: 14px 16px; border-radius: 8px; border: 1px solid var(--line); background: var(--code-bg); line-height: 1.65; tab-size: 4; }
.post-body :not(pre) > code { padding: .1em .4em; border-radius: 4px; background: var(--code-bg); border: 1px solid var(--line); font-size: .85em; }
.post-body pre code { font-size: inherit; }
.post-body .highlight { margin: 1.2em 0; background: none; }
.post-body .highlight pre { margin: 0; }

/* code block chrome added by /js/code.js */
.code-block { margin: 1.4em 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--code-bg); }
.code-block .highlight, .code-block pre { margin: 0; border: 0; border-radius: 0; }
.code-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 8px 4px 14px; background: var(--code-head); border-bottom: 1px solid var(--line); font-size: .75rem; line-height: 1.6; }
.code-lang { color: var(--muted); font-family: var(--mono); letter-spacing: .02em; }
.code-copy { padding: 2px 10px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); color: var(--muted); font: inherit; cursor: pointer; }
.code-copy:hover { color: var(--text); border-color: var(--muted); }
.code-copy.done { color: var(--accent); border-color: var(--accent); }
.post-body pre.has-ln { display: flex; padding-left: 0; }
.post-body pre.has-ln > code { flex: none; }
.code-ln { flex: none; position: sticky; left: 0; padding: 0 12px 0 14px; margin-right: 14px; text-align: right; color: var(--code-muted); background: var(--code-bg); border-right: 1px solid var(--line); user-select: none; -webkit-user-select: none; white-space: pre; }

.toc { margin: 24px 0 0; padding: 12px 18px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font-size: .9rem; }
.toc summary { cursor: pointer; font-weight: 700; color: var(--muted); }
.toc ul { margin: 6px 0 0; padding-left: 1.2em; }
.toc li { margin: 2px 0; }
.toc ul ul { list-style: none; }
.toc nav > ul { padding-left: 0; list-style: none; }
/* Hatena / Vim style classes (<pre class="syntax-highlight">) in old posts */
.syntax-highlight .synComment { color: #60a0b0; font-style: italic; }
.syntax-highlight .synConstant { color: #4070a0; }
.syntax-highlight .synIdentifier { color: #bb60d5; }
.syntax-highlight .synStatement { color: #007020; font-weight: bold; }
.syntax-highlight .synPreProc { color: #007020; }
.syntax-highlight .synType { color: #902000; }
.syntax-highlight .synSpecial { color: #c65d09; }
@media (prefers-color-scheme: dark) {
  .syntax-highlight .synComment { color: #8b949e; }
  .syntax-highlight .synConstant { color: #a5d6ff; }
  .syntax-highlight .synIdentifier { color: #d2a8ff; }
  .syntax-highlight .synStatement { color: #ff7b72; }
  .syntax-highlight .synPreProc { color: #ff7b72; }
  .syntax-highlight .synType { color: #ffa657; }
  .syntax-highlight .synSpecial { color: #79c0ff; }
}
.video { position: relative; aspect-ratio: 16 / 9; margin: 1.2em 0; max-width: 640px; }
.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

.post-nav { display: flex; justify-content: space-between; gap: 16px; margin-top: 48px; padding-top: 20px; border-top: 1px solid var(--line); font-size: .9rem; }
.post-nav a { max-width: 48%; }
.post-nav .prev { text-align: right; margin-left: auto; }
.pager { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; font-size: .95rem; }
.pager .pos { color: var(--muted); font-size: .85rem; }

.archive-list { list-style: none; padding: 0; margin: 0 0 24px; }
.archive-list li { padding: 6px 0; border-bottom: 1px dashed var(--line); }
.archive-list time { display: inline-block; min-width: 4.5em; color: var(--muted); font-size: .85rem; }
.month-head { font-size: 1.05rem; margin: 24px 0 8px; }
.month-links a { margin-right: 10px; white-space: nowrap; }
.term-list { columns: 2; padding-left: 1.2em; }

.sidebar { font-size: .9rem; }
.sidebar section { margin-bottom: 32px; }
.sidebar h3 { font-size: .8rem; letter-spacing: .12em; color: var(--muted); margin: 0 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.sidebar ul { list-style: none; margin: 0; padding: 0; }
.sidebar li { padding: 3px 0; line-height: 1.6; }
.sidebar .cats { display: flex; flex-wrap: wrap; gap: 6px; }
.sidebar .cats li { padding: 0; }
.sidebar .cats a { display: inline-block; padding: 2px 8px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); }
.count { color: var(--muted); font-size: .78rem; }
.years details summary { cursor: pointer; }
.years details ul { padding: 4px 0 4px 1.2em; display: flex; flex-wrap: wrap; gap: 0 10px; }
.search-form { display: flex; gap: 6px; }
.search-form input { flex: 1; min-width: 0; padding: 7px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--text); font: inherit; }
.search-form button { padding: 7px 12px; border: 1px solid var(--accent); border-radius: 6px; background: var(--accent); color: var(--bg); font: inherit; cursor: pointer; }

.site-footer { border-top: 1px solid var(--line); color: var(--muted); font-size: .85rem; }
.site-footer .wrap { padding-top: 20px; padding-bottom: 28px; }

#search { --pagefind-ui-primary: var(--accent); --pagefind-ui-text: var(--text); --pagefind-ui-background: var(--surface); --pagefind-ui-border: var(--line); --pagefind-ui-font: var(--font); }
