:root {
  --bg: #F6F1E8;
  --surface: #EFE7D8;
  --text: #2D2926;
  --muted: #7A7268;
  --accent: #6B7A4B;
  --border: #D6C9B8;
  --serif: "Source Serif 4", Georgia, serif;
  --heading: "IBM Plex Serif", Georgia, serif;
  --mono: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
}

:root[data-theme="dark"] {
  --bg: #101311;
  --surface: #171B17;
  --text: #ECE8E1;
  --muted: #A39C90;
  --accent: #7A9B68;
  --border: #2C332D;
}

* { box-sizing: border-box; }
html { background: var(--bg); scroll-behavior: smooth; }
body { margin: 0; color: var(--text); background: var(--bg); font: 400 18px/1.68 var(--serif); text-rendering: optimizeLegibility; }
a { color: inherit; text-decoration-color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--accent); }
button { font: inherit; }

.site-shell { width: min(100% - 3rem, 760px); margin: 0 auto; }
.site-header { display: flex; align-items: center; gap: 12px; margin-bottom: 48px; padding-top: 60px; font-family: var(--heading); font-size: 14px; font-weight: 700; line-height: 1.3; }
nav { display: flex; flex: 1; gap: 4px; margin-right: auto; }
nav a, .theme-toggle, .eyebrow, .mono, .stack, .library-kind, .entry-meta, .tag-list, footer { font-family: var(--mono); font-size: .69rem; letter-spacing: .035em; text-transform: lowercase; }
nav a { min-width: 70px; padding: 6px 14px; border: 1px dotted var(--border); color: var(--muted); font-family: var(--heading); font-size: inherit; letter-spacing: normal; text-align: center; white-space: nowrap; text-decoration: none; text-transform: uppercase; }
nav a:hover { color: var(--accent); border-color: var(--accent); }
.theme-toggle { display: inline-flex; align-items: center; justify-content: center; padding: 7px 10px; border: 1px dotted var(--border); color: var(--muted); background: transparent; cursor: pointer; line-height: 0; text-transform: none; }
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); }
.theme-icon { transform: rotate(-40deg); transition: transform .4s ease; }
.theme-icon-core { r: 8; transition: r .4s ease; }
.theme-icon-mask circle { cx: 17; cy: 7; transition: cx .4s ease, cy .4s ease; }
.theme-icon-rays { transform-box: view-box; transform-origin: center; transform: scale(0); opacity: 0; transition: transform .4s ease, opacity .25s ease; }
:root[data-theme="dark"] .theme-icon { transform: rotate(0deg); }
:root[data-theme="dark"] .theme-icon-core { r: 5; }
:root[data-theme="dark"] .theme-icon-mask circle { cx: 30; cy: 4; }
:root[data-theme="dark"] .theme-icon-rays { transform: scale(1); opacity: 1; }
@media (prefers-reduced-motion: reduce) {
  .theme-icon, .theme-icon-core, .theme-icon-mask circle, .theme-icon-rays { transition: none; }
}

main { min-height: calc(100vh - 180px); }
.hero { padding: .3rem 0 4.5rem; }
.eyebrow { margin: 0 0 1rem; color: var(--muted); }
.eyebrow span { color: var(--accent); padding: 0 .25rem; }
h1, h2, h3 { margin: 0; font-family: var(--heading); font-weight: 600; line-height: 1.18; letter-spacing: -.025em; }
h1 { font-size: clamp(2.85rem, 9vw, 5.2rem); }
h2 { font-size: 1.48rem; }
.hero h1 { margin-bottom: .75rem; }
.jp { margin: 0 0 1.9rem; color: var(--accent); font-size: 1.35rem; }
.hero-copy { max-width: 37rem; margin: 0; font-size: clamp(1.2rem, 3vw, 1.45rem); line-height: 1.55; }
blockquote { max-width: 28rem; margin: 3rem 0 0; padding: 1.1rem 0 1.1rem 1.3rem; border-left: 2px solid var(--accent); color: var(--muted); font-style: italic; }

.home-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; }
.notebook-section, .latest, .project-card, .library-list article { border: 1px solid var(--border); background: var(--surface); }
.notebook-section { padding: 1.7rem; }
.notebook-section h2, .latest h2 { font-size: 1.2rem; }
.notebook-section p { margin: 1rem 0 0; }
.muted { color: var(--muted); }
.log-list, .latest-list { margin: 1.1rem 0 0; padding: 0; list-style: none; }
.log-list li { display: grid; grid-template-columns: 5.8rem 1fr; gap: .75rem; padding: .6rem 0; border-top: 1px solid var(--border); font-size: .91rem; }
.log-list time, .latest time { color: var(--muted); font: .64rem var(--mono); }
.latest { margin-top: 1.2rem; padding: 1.7rem; background: transparent; }
.section-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.section-heading a { color: var(--muted); font: .7rem var(--mono); }
.latest-list li { display: flex; justify-content: space-between; gap: 1rem; padding: .8rem 0; border-top: 1px solid var(--border); }
.latest-list a { text-decoration: none; }
.buttons { display: flex; flex-wrap: wrap; gap: .5rem; margin: 4.2rem 0 1rem; }
.buttons span { display: grid; width: 88px; height: 31px; place-items: center; border: 1px solid var(--border); color: var(--muted); font: .52rem var(--mono); text-align: center; }

.page-intro { padding: 0 0 3.8rem; }
.page-intro:has(+ .prose) { padding-bottom: 0; }
.page-intro h1 { margin-bottom: 1.2rem; }
.page-intro > p:last-child { max-width: 32rem; margin: 0; color: var(--muted); font-size: 1.18rem; }
.entry-list { margin-bottom: 4rem; }
.entry-card { padding: 1.8rem 0; border-top: 1px solid var(--border); }
.entry-card:last-child { border-bottom: 1px solid var(--border); }
.entry-meta { display: flex; gap: .7rem; color: var(--muted); }
.entry-card h2 { margin: .65rem 0 .5rem; font-size: 1.7rem; }
.entry-card h2 a { text-decoration: none; }
.entry-card p { max-width: 37rem; margin: 0; color: var(--muted); }
.tag-list { display: flex; flex-wrap: wrap; gap: .45rem; margin-top: 1rem; color: var(--accent); }
.tag-list a { color: var(--accent); text-decoration: none; }

.project-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.2rem; margin-bottom: 4rem; }
.project-card { display: flex; min-height: 235px; flex-direction: column; padding: 1.7rem; }
.project-card h2 { font-size: 1.5rem; }
.project-card > p:nth-child(2) { margin: .8rem 0 1.2rem; color: var(--muted); }
.stack { margin: auto 0 1.3rem; color: var(--accent); }
.project-links { display: flex; justify-content: space-between; margin: 0; font: .7rem var(--mono); }
.project-links span { color: var(--muted); }

.library-list { margin-bottom: 4rem; border-top: 1px solid var(--border); }
.library-list article { padding: 1.6rem 0; border-width: 0 0 1px; background: transparent; }
.library-kind { margin: 0 0 .4rem; color: var(--accent); }
.library-list h2 { font-size: 1.42rem; }
.byline { margin: .25rem 0 .75rem; color: var(--muted); font-style: italic; }
.library-list article > p:last-child { max-width: 34rem; margin: 0; }
.prose { max-width: 41rem; margin-bottom: 4rem; }
.prose p { margin: 0 0 2rem; }
.prose h2 { margin: 3rem 0 .7rem; font-size: 1.45rem; }
.contact-note { color: var(--muted); }

.post { max-width: 42rem; padding: 5.3rem 0 4rem; }
.post h1 { margin: 1rem 0; font-size: clamp(2.6rem, 7vw, 4.2rem); }
.post-body { margin-top: 3.5rem; }
.post-body p { margin: 0 0 1.55rem; }
.post-back { margin-top: 4rem; font: .72rem var(--mono); }

.system-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 0; margin-top: 58px; padding: 10px 0 32px; border-top: 1px solid var(--border); color: var(--muted); font-size: .8rem; letter-spacing: .02em; text-transform: uppercase; }
.system-bar > span, .system-bar > a { display: inline-flex; align-items: center; }
.system-bar > span:not(:last-child)::after, .system-bar > a::after { content: "|"; margin: 0 .55rem; color: var(--border); }
.system-bar a { color: var(--muted); text-decoration: none; }
.system-bar a:hover { color: var(--accent); }
.site-counter { gap: 2px; }
.site-counter span { min-width: 1.1em; padding: .05rem .12rem; border: 1px solid var(--border); color: var(--accent); font-variant-numeric: tabular-nums; line-height: 1.25; text-align: center; }

@media (max-width: 620px) {
  .site-shell { width: min(100% - 2rem, 760px); }
  .site-header { gap: 8px; padding-top: 40px; flex-wrap: wrap; }
  nav { gap: 4px; margin-right: 0; flex-wrap: wrap; }
  nav a { min-width: auto; }
  .home-grid, .project-grid { grid-template-columns: 1fr; }
  .page-intro { padding-top: 0; }
  .post { padding-top: 4rem; }
  .latest-list li { align-items: baseline; }
  .latest-list time { white-space: nowrap; }
}
