:root {
  color-scheme: light;
  --page: #fbfbfa;
  --surface: #fff;
  --text: #222;
  --muted: #737373;
  --line: #dededb;
  --soft: #f1f1ef;
  --code: #ececea;
  --width: 780px;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #181818;
  --surface: #202020;
  --text: #e8e8e5;
  --muted: #aaa;
  --line: #3a3a38;
  --soft: #252525;
  --code: #2b2b2b;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #181818;
    --surface: #202020;
    --text: #e8e8e5;
    --muted: #aaa;
    --line: #3a3a38;
    --soft: #252525;
    --code: #2b2b2b;
  }
}

* { box-sizing: border-box; }
html { min-height: 100%; scroll-behavior: smooth; }
body {
  min-height: 100vh;
  margin: 0;
  background: var(--page);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", sans-serif;
  font-size: 17px;
  line-height: 1.75;
  text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration: none; }
a:hover { color: var(--muted); text-decoration: underline; text-underline-offset: .18em; }
button, input, textarea { font: inherit; }
.site-shell {
  display: flex;
  flex-direction: column;
  width: min(calc(100% - 40px), var(--width));
  min-height: 100vh;
  margin: 0 auto;
}
.site-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 30px;
  padding: 72px 0 28px;
}
.site-title, .article-title {
  max-width: 660px;
  color: var(--text);
  font-size: clamp(2.6rem, 8vw, 4rem);
  font-weight: 760;
  letter-spacing: -.055em;
  line-height: 1.05;
}
.site-title:hover, .article-title:hover { text-decoration: none; color: var(--text); }
.article-title { font-size: clamp(2rem, 6vw, 3rem); }
.header-tools { display: flex; gap: 5px; margin-top: 5px; }
.icon-button {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}
.icon-button:hover { color: var(--text); background: var(--soft); }
.site-main { flex: 1; padding: 44px 0 20px; animation: enter .45s ease both; }
@keyframes enter { from { opacity: 0; transform: translateY(8px); } }
.post-list { display: grid; gap: 4px; }
.post-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 24px;
  padding: 4px 0;
}
.post-row a { min-width: 0; overflow-wrap: anywhere; }
.post-row time, .article-meta time {
  flex: none;
  color: var(--muted);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: .92rem;
  white-space: nowrap;
}
.compact { padding-top: 12px; }
.pagination { display: flex; gap: 8px; margin: 72px 0 12px; }
.pagination a {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 4px;
  background: var(--soft);
  color: var(--muted);
}
.pagination a.current, .pagination a:hover {
  background: var(--text);
  color: var(--page);
  text-decoration: none;
}
.site-footer {
  margin-top: 45px;
  padding: 26px 0 44px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  font-size: .78rem;
  line-height: 1.8;
}
.site-footer p { margin: 2px 0; }
.site-footer nav { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.site-footer a:hover { color: var(--text); }
.article-meta {
  display: flex;
  gap: 8px;
  margin: -6px 0 38px;
  color: var(--muted);
  font-size: .9rem;
}
.article-body { overflow-wrap: anywhere; }
.article-body h1, .article-body h2, .article-body h3 {
  line-height: 1.28;
  letter-spacing: -.025em;
}
.article-body h1 { margin: 1.8em 0 .55em; font-size: 2rem; }
.article-body h2 { margin: 2em 0 .55em; font-size: 1.45rem; }
.article-body h3 { margin: 1.8em 0 .5em; font-size: 1.15rem; }
.article-body p { margin: 1em 0; }
.article-body a { text-decoration: underline; text-underline-offset: .18em; }
.article-body ul, .article-body ol { padding-left: 1.35em; }
.article-body blockquote {
  margin: 1.6em 0;
  padding: 14px 18px;
  border-left: 4px solid var(--text);
  border-radius: 0 5px 5px 0;
  background: var(--soft);
  font-weight: 620;
}
.article-body blockquote p { margin: 0; }
.article-body hr { margin: 2.4em 0; border: 0; border-top: 1px dashed var(--muted); }
.article-body code {
  padding: .15em .32em;
  border-radius: 4px;
  background: var(--code);
  font: .88em "SFMono-Regular", Consolas, monospace;
}
.codehilite {
  position: relative;
  overflow: hidden;
  margin: 1.4em 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--code);
}
.codehilite pre {
  max-height: 460px;
  margin: 0;
  padding: 20px;
  overflow: auto;
}
.codehilite code { padding: 0; background: transparent; }
.copy-code {
  position: absolute;
  top: 9px;
  right: 9px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--muted);
  background: var(--surface);
  font-size: .72rem;
  cursor: pointer;
}
.codehilite .k, .codehilite .kd, .codehilite .kn { color: #9b3e9f; }
.codehilite .s, .codehilite .s1, .codehilite .s2 { color: #387b38; }
.codehilite .c, .codehilite .c1, .codehilite .cm { color: #7b7b75; font-style: italic; }
.codehilite .nf, .codehilite .nc { color: #285f9e; }
.codehilite .mi, .codehilite .mf { color: #9a5d16; }
.article-body table { display: block; width: 100%; margin: 1.5em 0; overflow-x: auto; border-collapse: collapse; }
.article-body th, .article-body td { padding: 9px 12px; border: 1px solid var(--line); text-align: left; }
.article-body th { background: var(--soft); }
.article-body video { width: 100%; border-radius: 7px; background: #000; }
.reveal-image { margin: 1.5em 0; }
.reveal-image img { display: block; width: 100%; border-radius: 7px; animation: reveal .35s ease both; }
.reveal-image img[hidden] { display: none; }
@keyframes reveal { from { opacity: 0; filter: blur(6px); } }
.image-reveal-button {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  padding: 15px 17px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--text);
  background: var(--soft);
  cursor: pointer;
}
.image-reveal-button small { color: var(--muted); }
.reveal-image.is-open .image-reveal-button { margin-bottom: 10px; }
.article-tags { display: flex; flex-wrap: wrap; gap: 5px 12px; margin-top: 48px; color: var(--muted); font-size: .84rem; }
.post-neighbors {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-top: 74px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
  font-size: .85rem;
}
.post-neighbors a:last-child { text-align: right; }
.page-search { display: flex; gap: 10px; margin-bottom: 20px; }
.page-search input, .search-row input {
  flex: 1;
  min-width: 0;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--text);
  background: var(--surface);
}
.page-search button, .search-row button {
  padding: 10px 16px;
  border: 0;
  border-radius: 5px;
  color: var(--page);
  background: var(--text);
  cursor: pointer;
}
.result-count, .empty-state { color: var(--muted); }
.search-dialog {
  width: min(540px, calc(100% - 32px));
  padding: 25px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  background: var(--surface);
  box-shadow: 0 24px 80px rgb(0 0 0 / .18);
}
.search-dialog::backdrop { background: rgb(0 0 0 / .28); backdrop-filter: blur(3px); }
.search-form > label { display: block; margin-bottom: 12px; font-size: 1.2rem; font-weight: 700; }
.search-form p { margin: 12px 0 0; color: var(--muted); font-size: .75rem; }
.search-row { display: flex; gap: 8px; }
.dialog-close { position: absolute; top: 10px; right: 12px; border: 0; color: var(--muted); background: none; cursor: pointer; }
kbd { padding: 1px 5px; border: 1px solid var(--line); border-radius: 3px; background: var(--soft); }
.error-page { display: grid; min-height: 40vh; place-content: center; text-align: center; }
.error-page strong { font-size: 5rem; letter-spacing: -.06em; }

@media (max-width: 620px) {
  body { font-size: 16px; }
  .site-shell { width: min(calc(100% - 32px), var(--width)); }
  .site-header { padding-top: 48px; }
  .header-tools { margin-top: -5px; }
  .post-row { gap: 12px; }
  .post-row time { font-size: .78rem; }
  .post-neighbors { grid-template-columns: 1fr; }
  .post-neighbors a:last-child { text-align: left; }
}
