/* ===== tokens ===== */
:root {
  --bg: #f5f4ef;
  --surface: #ffffff;
  --surface-2: #ecebe4;
  --ink: #16181d;
  --ink-2: #3a3f48;
  --muted: #6a707b;
  --line: #dddbd2;
  --accent: #e0531c;
  --accent-ink: #b83f0f;
  --accent-soft: rgba(224, 83, 28, .1);
  --note: #8a8f99;
  --code-bg: #1b1e24;
  --code-ink: #e3e1da;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "JetBrains Mono", "Cascadia Code", "SFMono-Regular", Menlo, Consolas, monospace;
  --radius: 10px;
  --wrap: 1120px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101215; --surface: #171a1f; --surface-2: #1e2228; --ink: #ebe9e3; --ink-2: #c5c7cc; --muted: #8d939d;
    --line: #2a2e35; --accent: #ff7440; --accent-ink: #ff8f63; --accent-soft: rgba(255, 116, 64, .12); --note: #6b717b;
    --code-bg: #0b0d10; --code-ink: #e3e1da; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #101215; --surface: #171a1f; --surface-2: #1e2228; --ink: #ebe9e3; --ink-2: #c5c7cc; --muted: #8d939d;
  --line: #2a2e35; --accent: #ff7440; --accent-ink: #ff8f63; --accent-soft: rgba(255, 116, 64, .12); --note: #6b717b;
  --code-bg: #0b0d10; --code-ink: #e3e1da; color-scheme: dark;
}

/* ===== base ===== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 80px; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 17px/1.65 var(--sans); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
a { color: inherit; }
img { max-width: 100%; height: auto; }
.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 24px; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 16px; top: 12px; z-index: 10; background: var(--surface); padding: 8px 12px; border-radius: 6px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }

/* ===== header ===== */
.site-header { position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line); }
.header-row { display: flex; align-items: center; justify-content: space-between; height: 60px; gap: 16px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 600; letter-spacing: -.01em; white-space: nowrap; }
.brand-mark { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 7px; background: var(--ink); color: var(--bg); font: 700 12px/1 var(--mono); letter-spacing: .02em; }
.nav { display: flex; align-items: center; gap: 4px; font-size: 15px; }
.nav a { text-decoration: none; color: var(--ink-2); padding: 6px 10px; border-radius: 6px; }
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav-rss { display: inline-flex; align-items: center; gap: 6px; }
.theme-toggle { display: grid; place-items: center; width: 34px; height: 34px; margin-left: 4px; border: 1px solid var(--line); background: transparent; color: var(--ink-2); border-radius: 8px; cursor: pointer; }
.theme-toggle:hover { color: var(--ink); background: var(--surface-2); }

/* ===== hero ===== */
.hero { display: grid; grid-template-columns: 1.05fr 1fr; gap: 56px; align-items: end; padding-top: 72px; padding-bottom: 56px; }
.eyebrow { font: 500 13px/1 var(--mono); text-transform: uppercase; letter-spacing: .12em; color: var(--accent-ink); margin: 0 0 18px; display: flex; align-items: center; gap: 10px; }
.eyebrow::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.hero h1 { font-size: clamp(40px, 6vw, 64px); line-height: 1.02; letter-spacing: -.035em; margin: 0 0 20px; font-weight: 700; }
.tagline { font-size: 19px; line-height: 1.55; color: var(--ink-2); margin: 0 0 28px; max-width: 34em; }
.hero-links { display: flex; gap: 10px; flex-wrap: wrap; }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); text-decoration: none; font-size: 15px; font-weight: 500; white-space: nowrap; transition: border-color .15s, background .15s; }
.btn:hover { border-color: var(--ink-2); }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-ink); border-color: var(--accent-ink); }

.hero-data { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 22px 22px 14px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); margin: 0 0 18px; gap: 8px; }
.stats div { border-left: 2px solid var(--line); padding-left: 10px; }
.stats div:first-child { border-left-color: var(--accent); }
.stats dt { font: 12px/1.2 var(--mono); color: var(--muted); }
.stats dd { margin: 4px 0 0; font: 600 26px/1.1 var(--sans); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.chart { margin: 0; }
.chart figcaption { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font: 12px/1.4 var(--mono); color: var(--muted); margin-bottom: 6px; }
.legend { display: inline-flex; align-items: center; gap: 6px; }
.lg { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-left: 6px; }
.lg.article, .bar.article rect { background: var(--accent); fill: var(--accent); }
.lg.note, .bar.note rect { background: var(--note); fill: var(--note); }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.bar rect { transition: opacity .15s; }
.chart svg:hover .bar rect { opacity: .45; }
.chart svg .bar:hover rect, .chart svg .bar:focus rect { opacity: 1; }
.axis { font: 10px var(--mono); fill: var(--muted); }
.grid { stroke: var(--line); stroke-dasharray: 2 3; }
.baseline { stroke: var(--line); }

/* ===== sections ===== */
.section { padding-top: 40px; padding-bottom: 40px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 24px; flex-wrap: wrap; border-top: 1px solid var(--ink); padding-top: 18px; margin-bottom: 22px; }
.section-head h2 { margin: 0; font-size: 28px; letter-spacing: -.02em; }
.section-sub { margin: 0; color: var(--muted); font-size: 15px; }

.filters { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 18px; align-items: center; }
.chip { font: 13px/1 var(--mono); padding: 7px 11px; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--ink-2); cursor: pointer; }
.chip:hover { border-color: var(--ink-2); color: var(--ink); }
.chip.is-active { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chip-n { opacity: .55; margin-left: 2px; }
.filters-sep { width: 1px; height: 20px; background: var(--line); margin: 0 6px; }

/* ===== feed ===== */
.feed { list-style: none; margin: 0; padding: 0; }
.month { font: 500 12px/1 var(--mono); text-transform: uppercase; letter-spacing: .1em; color: var(--muted); padding: 26px 0 10px; }
.month span { background: var(--bg); padding-right: 10px; }
.entry { display: grid; grid-template-columns: 64px 1fr 200px; gap: 24px; padding: 22px 0; border-top: 1px solid var(--line); }
.month + .entry { border-top-color: var(--ink-2); }
.entry-date { font: 13px/1.9 var(--mono); color: var(--muted); font-variant-numeric: tabular-nums; }
.entry-title { margin: 0 0 8px; font-size: 21px; line-height: 1.3; letter-spacing: -.015em; font-weight: 650; }
.entry-title a { text-decoration: none; background: linear-gradient(var(--accent), var(--accent)) 0 100% / 0 2px no-repeat; transition: background-size .2s; }
.entry-title a:hover { background-size: 100% 2px; }
.entry-lead { margin: 0 0 10px; color: var(--ink-2); font-size: 16px; line-height: 1.55; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.entry-thumb { display: block; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); align-self: start; aspect-ratio: 16 / 9; background: var(--surface-2); }
.entry-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform .3s; }
.entry:hover .entry-thumb img { transform: scale(1.03); }
.entry-kind { display: inline-block; font: 500 11px/1 var(--mono); text-transform: uppercase; letter-spacing: .1em; color: var(--muted); border: 1px dashed var(--note); padding: 4px 7px; border-radius: 4px; margin-bottom: 10px; }
.entry.note { grid-template-columns: 64px 1fr; }
.entry.note .entry-body { background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--note); border-radius: 8px; padding: 16px 20px 6px; max-width: 760px; }
.entry.note .entry-title { font-size: 17px; }
.entry .note-text { font-size: 15.5px; line-height: 1.6; }
.entry .note-text figure { margin: 12px 0; }
.entry .note-text img { max-height: 300px; width: auto; border-radius: 6px; border: 1px solid var(--line); }
.feed-empty { color: var(--muted); padding: 24px 0; }

.meta { display: flex; flex-wrap: wrap; gap: 4px 14px; font: 13px/1.6 var(--mono); color: var(--muted); }
.meta span + span::before { content: "·"; margin-right: 14px; opacity: .6; }
.meta a { color: var(--accent-ink); text-decoration: none; }
.meta a:hover { text-decoration: underline; }
.tags { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 0; padding: 0; }
.tags li { font: 12px/1 var(--mono); color: var(--ink-2); background: var(--surface-2); padding: 5px 8px; border-radius: 4px; }

/* ===== projects ===== */
.projects { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.project { display: flex; flex-direction: column; text-decoration: none; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; transition: border-color .15s, transform .15s; }
.project:hover { border-color: var(--accent); transform: translateY(-2px); }
.project-name { font: 600 17px/1.3 var(--mono); margin-bottom: 8px; }
.project-name span { color: var(--accent); }
.project p { margin: 0 0 14px; color: var(--ink-2); font-size: 15px; line-height: 1.55; flex: 1; }
.project-meta { font: 12px var(--mono); color: var(--muted); }

/* ===== article ===== */
.article-head { max-width: 860px; padding-top: 40px; padding-bottom: 24px; }
.back { display: inline-block; font: 13px var(--mono); color: var(--muted); text-decoration: none; margin-bottom: 24px; }
.back:hover { color: var(--accent-ink); }
.article-head h1 { font-size: clamp(30px, 4.4vw, 46px); line-height: 1.1; letter-spacing: -.03em; margin: 0 0 18px; }
.article.note .article-head h1 { font-size: clamp(26px, 3.4vw, 34px); }
.article-grid { max-width: 860px; }
.article.has-toc .article-grid { max-width: var(--wrap); display: grid; grid-template-columns: 220px minmax(0, 760px); gap: 56px; justify-content: start; }
.article.has-toc .article-head { max-width: var(--wrap); padding-left: calc(24px + 220px + 56px); }
.article-main { min-width: 0; }
.cover { margin: 0 0 32px; }
.cover img { display: block; width: 100%; border-radius: var(--radius); border: 1px solid var(--line); }

.toc { position: sticky; top: 84px; align-self: start; max-height: calc(100vh - 110px); overflow: auto; font-size: 14px; }
.toc summary { font: 500 12px/1 var(--mono); text-transform: uppercase; letter-spacing: .1em; color: var(--muted); cursor: pointer; margin-bottom: 12px; list-style: none; }
.toc summary::-webkit-details-marker { display: none; }
.toc ol { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--line); }
.toc li a { display: block; padding: 5px 0 5px 14px; margin-left: -1px; border-left: 2px solid transparent; color: var(--muted); text-decoration: none; line-height: 1.35; }
.toc li a:hover { color: var(--ink); border-left-color: var(--ink-2); }
.toc li a.is-current { color: var(--ink); border-left-color: var(--accent); }

/* ===== prose ===== */
.prose { font-size: 18px; line-height: 1.72; color: var(--ink); overflow-wrap: break-word; }
.prose > :first-child { margin-top: 0; }
.prose p { margin: 0 0 1.1em; }
.prose h2, .prose h3, .prose h4 { position: relative; letter-spacing: -.02em; line-height: 1.25; margin: 2em 0 .7em; }
.prose h2 { font-size: 30px; }
.prose h3 { font-size: 25px; }
.prose h4 { font-size: 20px; }
.anchor { position: absolute; left: -1.1em; color: var(--muted); text-decoration: none; opacity: 0; font-weight: 400; }
.prose :is(h2, h3, h4):hover .anchor { opacity: 1; }
.prose a { color: var(--accent-ink); text-decoration-thickness: 1px; text-underline-offset: 3px; }
.prose a:hover { text-decoration-thickness: 2px; }
.prose ul, .prose ol { padding-left: 1.4em; margin: 0 0 1.2em; }
.prose li { margin: .3em 0; }
.prose li > p { margin: 0 0 .4em; }
.prose li::marker { color: var(--muted); }
.prose blockquote { margin: 1.5em 0; padding: 4px 0 4px 20px; border-left: 3px solid var(--accent); color: var(--ink-2); }
.prose figure { margin: 1.8em 0; }
.prose figure img { display: block; margin: 0 auto; border-radius: 8px; border: 1px solid var(--line); background: #fff; }
.prose figcaption { text-align: center; font-size: 14px; color: var(--muted); margin-top: 10px; line-height: 1.45; }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 2.4em 0; }
.prose :not(pre) > code { font: .86em var(--mono); background: var(--surface-2); padding: .12em .38em; border-radius: 4px; }
.prose strong code { font-weight: 600; }
.prose .table { overflow-x: auto; margin: 1.6em 0; border: 1px solid var(--line); border-radius: 8px; }
.prose table { border-collapse: collapse; width: 100%; font-size: 15px; line-height: 1.5; }
.prose th, .prose td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.prose tr:last-child td { border-bottom: 0; }
.prose th { background: var(--surface-2); font-weight: 600; }
.prose td p, .prose th p { margin: 0; }

.code { position: relative; margin: 1.5em 0; }
.code pre { margin: 0; background: var(--code-bg); color: var(--code-ink); padding: 18px 20px; border-radius: 8px; overflow-x: auto; font: 14px/1.6 var(--mono); tab-size: 2; }
.code-lang { position: absolute; top: 8px; right: 10px; font: 11px var(--mono); color: #7d838d; text-transform: lowercase; pointer-events: none; }
.hljs-comment, .hljs-quote { color: #7d8590; font-style: italic; }
.hljs-keyword, .hljs-selector-tag, .hljs-built_in, .hljs-type { color: #ff8a5c; }
.hljs-string, .hljs-attr + .hljs-string, .hljs-regexp, .hljs-addition { color: #a6d189; }
.hljs-number, .hljs-literal, .hljs-symbol, .hljs-bullet { color: #e5c07b; }
.hljs-title, .hljs-title.function_, .hljs-section { color: #8ab4f8; }
.hljs-attr, .hljs-attribute, .hljs-variable, .hljs-template-variable, .hljs-name, .hljs-tag { color: #c4a7e7; }
.hljs-meta, .hljs-deletion { color: #f28b82; }
.hljs-params { color: inherit; }
.hljs-emphasis { font-style: italic; }
.hljs-strong { font-weight: 700; }

.article-tags { margin-top: 32px; }
.discuss { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 32px 0 0; padding: 20px 22px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.discuss-title { font-weight: 600; }
.discuss-sub { font: 13px/1.5 var(--mono); color: var(--muted); margin-top: 2px; }
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; padding-top: 48px; padding-bottom: 32px; max-width: 860px; }
.article.has-toc .pager { max-width: var(--wrap); padding-left: calc(24px + 220px + 56px); }
.pager-link { display: block; text-decoration: none; padding: 16px 18px; border: 1px solid var(--line); border-radius: var(--radius); transition: border-color .15s; }
.pager-link:hover { border-color: var(--accent); }
.pager-link.older { text-align: right; }
.pager-label { display: block; font: 12px var(--mono); color: var(--muted); margin-bottom: 4px; }
.pager-title { font-weight: 600; line-height: 1.35; }

.notfound { padding-top: 96px; padding-bottom: 96px; }
.notfound h1 { font-size: 44px; letter-spacing: -.03em; margin: 0 0 12px; }

/* ===== footer ===== */
.site-footer { border-top: 1px solid var(--line); margin-top: 40px; }
.footer-row { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 12px; padding-top: 24px; padding-bottom: 32px; font: 13px var(--mono); color: var(--muted); }
.footer-links { display: flex; gap: 18px; }
.footer-links a { text-decoration: none; }
.footer-links a:hover { color: var(--accent-ink); }

/* ===== responsive ===== */
@media (max-width: 1100px) {
  .article.has-toc .article-grid { display: block; max-width: 860px; }
  .article.has-toc .article-head, .article.has-toc .pager { padding-left: 24px; max-width: 860px; }
  .toc { position: static; max-height: none; margin-bottom: 28px; padding: 14px 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
  .toc summary { margin-bottom: 0; }
  .toc details[open] summary { margin-bottom: 12px; }
}
@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; gap: 36px; padding-top: 44px; padding-bottom: 32px; }
  .entry { grid-template-columns: 56px 1fr; }
  .entry-thumb { display: none; }
  .projects { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  body { font-size: 16px; }
  .wrap { padding: 0 16px; }
  .article.has-toc .article-head, .article.has-toc .pager { padding-left: 16px; }
  .brand-name { display: none; }
  .nav { gap: 0; font-size: 14px; }
  .nav a { padding: 6px 8px; }
  .nav-rss span { display: none; }
  .stats { grid-template-columns: repeat(2, 1fr); row-gap: 14px; }
  .entry { grid-template-columns: 1fr; gap: 6px; padding: 18px 0; }
  .entry.note { grid-template-columns: 1fr; }
  .entry-date { line-height: 1.2; }
  .entry.note .entry-body { padding: 14px 16px 4px; }
  .entry-title { font-size: 19px; }
  .prose { font-size: 17px; }
  .prose h3 { font-size: 22px; }
  .code pre { font-size: 13px; padding: 14px; border-radius: 6px; }
  .code { margin-left: -16px; margin-right: -16px; }
  .code pre { border-radius: 0; }
  .discuss { flex-direction: column; align-items: flex-start; }
  .pager { grid-template-columns: 1fr; }
  .pager-link.older { text-align: left; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
