*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg:    #0a0a0a;
  --fg:    #ededed;
  --sub:   #888888;
  --muted: #404040;
  --dim:   #171717;
  --line:  #262626;
  --sans:  'Geist', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono:  'Geist Mono', ui-monospace, 'SF Mono', Menlo, monospace;
}

[data-theme="light"] {
  --bg:    #fafafa;
  --fg:    #0a0a0a;
  --sub:   #737373;
  --muted: #d4d4d4;
  --dim:   #f0f0f0;
  --line:  #e5e5e5;
}

html { font-size: 15px; scroll-behavior: smooth; }

@media (min-width: 1024px) {
  html { font-size: 16px; }
}

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--fg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background .2s, color .2s;
  font-feature-settings: 'ss01' 1, 'cv11' 1;
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
:focus-visible { outline: 1px solid var(--sub); outline-offset: 3px; border-radius: 2px; }

.page {
  max-width: 620px;
  margin: 0 auto;
  padding: 0 24px 96px;
}

.topbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding: 24px 0 0;
  min-height: 48px;
}

.theme-btn {
  background: none;
  border: none;
  color: var(--sub);
  padding: 6px;
  display: inline-flex;
  align-items: center;
  border-radius: 4px;
  transition: color .15s, background .15s;
}
.theme-btn:hover { color: var(--fg); background: var(--dim); }
.theme-btn svg { display: block; }

.header {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 28px 0 8px;
  gap: 14px;
}

.avatar {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--dim);
  box-shadow: 0 1px 2px rgba(0,0,0,.08), 0 4px 24px rgba(0,0,0,.18);
}

[data-theme="light"] .avatar {
  box-shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 18px rgba(0,0,0,.06);
}

.identity-bio {
  font-size: .82rem;
  color: var(--sub);
  line-height: 1.65;
  max-width: 44ch;
  letter-spacing: -.005em;
}

.socials {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}

.social-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  color: var(--sub);
  border-radius: 6px;
  transition: color .15s, background .15s;
}
.social-link:hover { color: var(--fg); background: var(--dim); }
.social-link svg { display: block; }

.divider {
  width: 32px;
  height: 1px;
  background: var(--line);
  border: none;
  margin: 36px auto 32px;
}

#pinned-section { margin-bottom: 28px; }

.pinned-header {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--sub);
  margin-bottom: 4px;
  padding-bottom: 2px;
}

.pinned-header svg { flex-shrink: 0; }

.pinned-rule {
  flex: 1;
  height: 1px;
  background: var(--line);
}

.tag-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  padding: 20px 0 14px;
}

.tag-btn {
  background: none;
  border: none;
  font-size: .72rem;
  color: var(--sub);
  padding: 2px 0;
  letter-spacing: .02em;
  transition: color .15s, border-color .15s;
  font-weight: 400;
  line-height: 1;
  font-family: var(--mono);
  border-bottom: 1px solid transparent;
}
.tag-btn:hover { color: var(--fg); }
.tag-btn.active { color: var(--fg); border-bottom-color: var(--fg); }

#posts { display: flex; flex-direction: column; }

.post {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 20px;
  padding: 13px 0;
  color: var(--fg);
  border-bottom: 1px solid var(--line);
  transition: opacity .15s, padding-left .15s;
}
.post:first-child { border-top: 1px solid var(--line); }
.post:hover { opacity: .55; }

.post-title {
  font-size: .9rem;
  line-height: 1.5;
  font-weight: 400;
  letter-spacing: -.005em;
}

.post-date {
  font-size: .72rem;
  color: var(--sub);
  white-space: nowrap;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
  font-family: var(--mono);
}

.posts-empty {
  font-size: .8rem;
  color: var(--sub);
  padding: 20px 0;
  text-align: center;
  border-top: 1px solid var(--line);
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: .72rem;
  color: var(--sub);
  font-family: var(--mono);
  letter-spacing: .02em;
  margin-bottom: 28px;
  transition: color .15s;
}
.back-link:hover { color: var(--fg); }
.back-link svg { display: block; }

.article-header { margin-bottom: 44px; }

.article-title {
  font-size: clamp(1.35rem, 3.8vw, 1.7rem);
  font-weight: 600;
  letter-spacing: -.025em;
  line-height: 1.2;
  margin-bottom: 18px;
}

.article-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.tag {
  font-size: .7rem;
  color: var(--sub);
  letter-spacing: .02em;
  font-family: var(--mono);
}

.article-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  font-size: .72rem;
  color: var(--sub);
  font-family: var(--mono);
}

.meta-sep { color: var(--muted); }

.share-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: none;
  border: none;
  color: var(--sub);
  font-size: .7rem;
  padding: 2px 4px;
  letter-spacing: .02em;
  border-radius: 3px;
  transition: color .15s, background .15s;
  font-family: var(--mono);
}
.share-btn:hover { color: var(--fg); background: var(--dim); }
.share-btn svg { display: block; }
.share-label { line-height: 1; }

.reading-progress {
  position: fixed;
  top: 0; left: 0;
  width: 0%;
  height: 2px;
  background: var(--fg);
  z-index: 100;
  transition: width .08s linear;
  opacity: .5;
}

.article-body {
  font-size: .92rem;
  line-height: 1.78;
  padding-bottom: 56px;
}

.article-body h1, .article-body h2,
.article-body h3, .article-body h4 {
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -.02em;
}

.article-body h1 { font-size: 1.35rem; margin: 52px 0 16px; }
.article-body h2 { font-size: 1.15rem; margin: 40px 0 14px; }
.article-body h3 { font-size: 1rem;    margin: 32px 0 12px; }
.article-body h4 { font-size: .92rem;  margin: 24px 0 10px; }

.article-body h1[id],
.article-body h2[id],
.article-body h3[id],
.article-body h4[id] { scroll-margin-top: 32px; }

.article-body p { margin-bottom: 20px; }
.article-body ul, .article-body ol { padding-left: 22px; margin-bottom: 20px; }
.article-body li { margin-bottom: 6px; }
.article-body li::marker { color: var(--sub); }

.article-body a {
  color: var(--fg);
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-thickness: 1px;
  text-decoration-color: var(--muted);
  transition: text-decoration-color .15s;
}
.article-body a:hover { text-decoration-color: var(--fg); }
.article-body strong { font-weight: 600; }
.article-body em { font-style: italic; }

.article-body blockquote {
  border-left: 2px solid var(--muted);
  padding-left: 18px;
  color: var(--sub);
  margin: 28px 0;
  font-style: italic;
}
.article-body blockquote p:last-child { margin-bottom: 0; }
.article-body hr { border: none; border-top: 1px solid var(--line); margin: 44px 0; }

.article-body code {
  font-family: var(--mono);
  font-size: .84em;
  background: var(--dim);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--line);
}

.article-body pre {
  background: var(--dim);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 18px 20px;
  margin: 24px 0;
  overflow-x: auto;
  position: relative;
}
.article-body pre code {
  background: none;
  padding: 0;
  font-size: .82rem;
  line-height: 1.7;
  border: none;
  border-radius: 0;
}

.code-lang {
  display: block;
  font-size: .65rem;
  color: var(--sub);
  text-transform: uppercase;
  letter-spacing: .14em;
  margin-bottom: 10px;
  font-family: var(--mono);
}

.hljs { background: transparent !important; }

.copy-btn {
  position: absolute; top: 10px; right: 10px;
  font-family: var(--mono); font-size: .65rem;
  color: var(--sub); background: var(--bg);
  border: 1px solid var(--line); border-radius: 4px;
  padding: 3px 8px;
  opacity: .5; transition: opacity .15s, color .15s, background .15s;
}
.article-body pre:hover .copy-btn { opacity: 1; }
.copy-btn:hover { color: var(--fg); background: var(--dim); }

.article-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 24px 0;
  font-size: .88em;
  display: block;
  overflow-x: auto;
}
.article-body th, .article-body td {
  padding: 10px 14px;
  border: 1px solid var(--line);
  text-align: left;
}
.article-body th { font-weight: 600; background: var(--dim); }

.article-body img {
  max-width: 100%;
  margin: 32px auto;
  display: block;
  border-radius: 4px;
}

.article-body details {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0;
  margin: 10px 0;
  background: var(--dim);
  overflow: hidden;
}
.article-body details + details { margin-top: 6px; }
.article-body summary {
  padding: 12px 16px;
  font-weight: 500;
  font-size: .88rem;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 10px;
  user-select: none;
  transition: background .15s;
}
.article-body summary::-webkit-details-marker { display: none; }
.article-body summary::before {
  content: '';
  display: inline-block;
  width: 0; height: 0;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-left: 7px solid var(--sub);
  transition: transform .15s;
  flex-shrink: 0;
}
.article-body details[open] > summary::before { transform: rotate(90deg); }
.article-body summary:hover { background: var(--bg); }

.article-body details > *:not(summary) {
  padding: 0 18px;
}
.article-body details > summary + * {
  border-top: 1px solid var(--line);
}

.article-body details > p:first-of-type,
.article-body details > ul:first-of-type,
.article-body details > ol:first-of-type,
.article-body details > blockquote:first-of-type { margin-top: 16px; }
.article-body details > *:last-child { padding-bottom: 16px; }

.label-message,
.label-description,
.label-solution {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 4px;
  font-size: .65rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  vertical-align: middle;
  margin-right: 4px;
  font-family: var(--mono);
}

.label-message     { background: #c2410c; color: #fff; }
.label-description { background: #1d4ed8; color: #fff; }
.label-solution    { background: #15803d; color: #fff; }

.article-body details p:has(> .label-description),
.article-body details p:has(> .label-solution) {
  margin-top: 18px;
  margin-bottom: 5px;
}

.toc-block {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--dim);
  margin-bottom: 36px;
  overflow: hidden;
}

.toc-block > summary::before {
  display: none;
}

.toc-block > summary {
  padding: 10px 16px;
  font-size: .75rem;
  font-family: var(--mono);
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--sub);
  cursor: pointer;
  list-style: none;
  user-select: none;
  transition: background .15s, color .15s;
}
.toc-block > summary::-webkit-details-marker { display: none; }
.toc-block > summary:hover { background: var(--bg); color: var(--fg); }

.toc-block ul {
  list-style: none;
  padding: 10px 16px 14px;
  border-top: 1px solid var(--line);
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.toc-block ul li a {
  font-size: .8rem;
  color: var(--sub);
  text-decoration: none;
  transition: color .15s;
  line-height: 1.8;
}
.toc-block ul li a:hover { color: var(--fg); }

.article-body .task-list-item { list-style: none; margin-left: -6px; }
.article-body .task-list-item input[type="checkbox"] {
  appearance: none;
  width: 14px; height: 14px;
  border: 1.5px solid var(--muted);
  border-radius: 3px;
  margin-right: 8px;
  vertical-align: middle;
  position: relative;
  top: -1px;
  flex-shrink: 0;
  cursor: default;
}
.article-body .task-list-item input[type="checkbox"]:checked {
  background: var(--fg);
  border-color: var(--fg);
}
.article-body .task-list-item input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  left: 2px; top: -1px;
  width: 5px; height: 9px;
  border: 2px solid var(--bg);
  border-top: none; border-left: none;
  transform: rotate(45deg);
}

.article-body del { color: var(--sub); }

.article-body h1 .anchor, .article-body h2 .anchor, .article-body h3 .anchor, .article-body h4 .anchor {
  opacity: 0; margin-left: 8px; color: var(--sub);
  font-weight: 400; font-size: .7em; transition: opacity .15s;
  text-decoration: none;
}
.article-body h1:hover .anchor, .article-body h2:hover .anchor,
.article-body h3:hover .anchor, .article-body h4:hover .anchor { opacity: 1; }

.post-nav {
  display: flex; justify-content: space-between;
  gap: 24px; padding-top: 40px;
  border-top: 1px solid var(--line); flex-wrap: wrap;
}
.post-nav-link {
  font-size: .8rem;
  color: var(--sub);
  transition: color .15s;
  max-width: 45%;
  line-height: 1.5;
}
.post-nav-link:hover { color: var(--fg); }
.post-nav-next { text-align: right; margin-left: auto; }
.post-nav-label {
  display: block;
  font-size: .65rem;
  color: var(--sub);
  margin-bottom: 5px;
  letter-spacing: .12em;
  opacity: .6;
  font-family: var(--mono);
  text-transform: uppercase;
}

@media (max-width: 480px) {
  .page { padding: 0 20px 80px; }
  .post { flex-direction: column; align-items: flex-start; gap: 4px; }
  .post-nav-link { max-width: 100%; }
  .post-nav-next { text-align: left; margin-left: 0; }
}
