@font-face {
  font-family: '0xProto';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/0xProtoNerdFont-Regular.woff2') format('woff2');
}
@font-face {
  font-family: '0xProto';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/fonts/0xProtoNerdFont-Bold.woff2') format('woff2');
}

:root {
  --bg: #2d2a2e;
  --bg-dark: #221f22;
  --bg-light: #403e41;
  --fg: #fcfcfa;
  --fg-muted: #939293;
  --fg-dim: #727072;
  --border: #49474a;
  --red: #ff6188;
  --orange: #fc9867;
  --yellow: #ffd866;
  --green: #a9dc76;
  --blue: #78dce8;
  --purple: #ab9df2;
  --purple-hover: #c1b6f5;
  --purple-bg: #342d47;
  --code-bg: #403e41;
  --pre-bg: #221f22;
}
[data-theme="light"] {
  --bg: #fafaf8;
  --bg-dark: #f0edec;
  --bg-light: #e8e5e4;
  --fg: #2d2a2e;
  --fg-muted: #6e6b6e;
  --fg-dim: #908e8f;
  --border: #d1cfd0;
  --red: #d3325b;
  --orange: #c75b1a;
  --yellow: #9d7a00;
  --green: #5a8c1a;
  --blue: #2b8da0;
  --purple: #7c5ec5;
  --purple-hover: #6548b0;
  --purple-bg: #ece6f8;
  --code-bg: #e8e5e4;
  --pre-bg: #f0edec;
}

@view-transition { navigation: auto; }
::view-transition-old(root) {
  animation: fade-out 150ms ease-in;
}
::view-transition-new(root) {
  animation: fade-in 150ms ease-out;
}
@keyframes fade-out { to { opacity: 0; } }
@keyframes fade-in { from { opacity: 0; } }

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; background: #2d2a2e; overflow-y: scroll; }
[data-theme="light"] { background: #fafaf8; }
body {
  font-family: '0xProto', monospace;
  background: var(--bg);
  color: var(--fg);
  min-height: 100vh;
  line-height: 1.6;
}
.container { max-width: 760px; margin: 0 auto; padding: 2rem 1.5rem; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 2rem; margin-bottom: 0.5rem; }

.theme-toggle {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  width: 40px;
  height: 40px;
  border: 1px solid var(--fg-muted);
  border-radius: 50%;
  background: var(--bg-light);
  color: var(--fg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  z-index: 200;
  transition: border-color 0.2s;
  padding: 0;
  line-height: 1;
}
.theme-toggle:hover { border-color: var(--purple); }

.blog-header { margin-bottom: 2rem; padding-bottom: 1rem; border-bottom: 1px solid var(--purple); }
.blog-header-top { display: flex; align-items: baseline; justify-content: space-between; }
.blog-header h1 a { color: var(--yellow); }
.header-link { color: var(--fg-muted); font-size: 0.9rem; transition: color 0.2s; }
.header-link:hover { color: var(--fg); text-decoration: none; }

.section-toggle {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 1.5rem 0 1rem;
}
.toggle-line { flex: 1; border-top: 1px solid var(--border); }
.toggle-btn {
  appearance: none;
  -webkit-appearance: none;
  background: none;
  border: none;
  outline: none;
  font-family: inherit;
  font-size: 1rem;
  line-height: 1;
  color: var(--fg-dim);
  cursor: pointer;
  padding: 0;
  transition: color 0.2s;
}
.toggle-btn:hover { color: var(--fg); }
.toggle-btn.active { color: var(--yellow); font-weight: 700; }

.tag-filter {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 1.5rem;
}
.tag-label { color: var(--fg-muted); font-size: 0.8rem; margin-right: 0.3rem; }
.tag {
  display: inline-block;
  font-size: 0.75rem;
  color: var(--fg-dim);
  text-decoration: none;
  transition: color 0.2s;
}
.tag:hover { color: var(--fg); text-decoration: none; }
.tag.active { color: var(--fg); font-weight: 700; }
.tag.t-red { color: var(--red); }
.tag.t-orange { color: var(--orange); }
.tag.t-yellow { color: var(--yellow); }
.tag.t-green { color: var(--green); }
.tag.t-blue { color: var(--blue); }
.tag.t-purple { color: var(--purple); }
.post-tags { display: flex; flex-wrap: wrap; gap: 0.1rem 0.5rem; margin-top: 0.4rem; }

.post-list { display: flex; flex-direction: column; }
.post-card {
  padding: 0.6rem 0;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.post-card:first-child { border-top: 1px solid var(--border); }
.post-card:hover h2 a { color: var(--yellow); }
.post-card h2 { font-size: 1.2rem; margin-bottom: 0.3rem; }
.post-card h2 a { color: var(--green); }
.post-card .post-date { font-size: 0.8rem; color: var(--fg-muted); }
.post-card .post-desc { font-size: 0.9rem; color: var(--fg-muted); margin-top: 0.3rem; }

.post-layout { position: relative; }
.post-layout .container { max-width: 1000px; }

.post-content {
  overflow-wrap: break-word;
  word-break: break-word;
}

.toc-sidebar {
  display: none;
  position: fixed;
  left: calc((100vw - 1000px) / 4 - 120px);
  top: 2rem;
  width: max-content;
  min-width: 180px;
  max-width: 280px;
  max-height: calc(100vh - 4rem);
  overflow-y: auto;
  padding: 1rem;
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.toc-sidebar.visible { display: flex; flex-direction: column; }
.toc-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--green);
  letter-spacing: 0.05em;
  margin-bottom: 0.6rem;
  padding-bottom: 0.4rem;
}
.toc-link {
  display: block;
  padding: 0.2rem 0;
  font-size: 0.8rem;
  text-decoration: none;
  transition: color 0.2s;
  white-space: nowrap;
}
.toc-link:hover { text-decoration: none; opacity: 0.7; }
.toc-h1 { padding-left: 0; color: var(--yellow); }
.toc-h2 { padding-left: 0.6rem; color: var(--orange); }
.toc-h3 { padding-left: 1.2rem; font-size: 0.75rem; color: var(--blue); }
.toc-h4 { padding-left: 1.8rem; font-size: 0.7rem; color: var(--purple); }
.toc-link.active { font-weight: 700; }
.toc-back {
  display: block;
  padding: 0.3rem 0;
  margin-top: 0.6rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--fg-muted);
  text-decoration: none;
  transition: color 0.2s;
}
.toc-back:hover { color: var(--fg); text-decoration: none; }

@media (max-width: 1250px) {
  .toc-sidebar { display: none !important; }
}

.post-content h1 { font-size: 1.8rem; margin: 1.5rem 0 0.8rem; color: var(--yellow); }
.post-content h2 { font-size: 1.4rem; margin: 1.3rem 0 0.6rem; color: var(--orange); }
.post-content h3 { font-size: 1.15rem; margin: 1rem 0 0.5rem; color: var(--blue); }
.post-content h4 { font-size: 1rem; margin: 0.8rem 0 0.4rem; color: var(--purple); }
.post-content p { margin: 0.8rem 0; color: var(--fg); }
.post-content img { max-width: 100%; border-radius: 6px; margin: 1rem 0; }
.post-content code { background: var(--code-bg); padding: 0.15rem 0.4rem; border-radius: 4px; font-size: 0.85em; font-family: '0xProto', monospace; color: var(--red); }
.post-content pre {
  position: relative;
  background: var(--pre-bg);
  padding: 1rem;
  border-radius: 8px;
  overflow-x: auto;
  margin: 1rem 0;
  border: 1px solid var(--fg-dim);
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.post-content pre.collapsed {
  max-height: 12rem;
  overflow: hidden;
}
.post-content pre.collapsed::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 4rem;
  background: linear-gradient(transparent, var(--pre-bg));
  pointer-events: none;
}
.expand-btn {
  position: absolute;
  bottom: 0.4rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-light);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--fg-muted);
  cursor: pointer;
  padding: 0.15rem 0.8rem;
  font-size: 0.75rem;
  font-family: '0xProto', monospace;
  z-index: 1;
  transition: color 0.2s, border-color 0.2s;
}
.expand-btn:hover { color: var(--fg); border-color: var(--purple); }
.code-lang {
  position: absolute;
  top: 0.3rem;
  right: 2rem;
  font-size: 0.75rem;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  user-select: none;
  pointer-events: none;
}
.copy-btn {
  position: absolute;
  top: 0.4rem;
  right: 0.4rem;
  background: none;
  border: none;
  color: var(--fg-dim);
  cursor: pointer;
  padding: 0.2rem;
  line-height: 1;
  font-size: 0.85rem;
  transition: color 0.2s;
}
.copy-btn:hover { color: var(--fg); }
.copy-btn.copied { color: var(--green); }
.post-content pre::-webkit-scrollbar { height: 6px; }
.post-content pre::-webkit-scrollbar-track { background: transparent; }
.post-content pre::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.post-content pre::-webkit-scrollbar-thumb:hover { background: var(--fg-dim); }
.post-content pre code { background: none; padding: 0; color: inherit; counter-reset: line-num; }
.code-line { display: inline-block; min-width: 100%; }
.code-line::before {
  counter-increment: line-num;
  content: counter(line-num);
  display: inline-block;
  width: 2.5em;
  text-align: right;
  margin-right: 1em;
  color: var(--fg-dim);
  opacity: 0.5;
  user-select: none;
  -webkit-user-select: none;
  pointer-events: none;
}

.hljs { background: var(--pre-bg); color: var(--fg); }
.hljs-keyword,
.hljs-selector-tag,
.hljs-tag,
.hljs-name { color: var(--red); }
.hljs-string,
.hljs-addition,
.hljs-regexp { color: var(--yellow); }
.hljs-title,
.hljs-title.function_,
.hljs-section { color: var(--green); }
.hljs-built_in { color: var(--blue); }
.hljs-number,
.hljs-literal { color: var(--purple); }
.hljs-comment,
.hljs-meta,
.hljs-doctag { color: var(--fg-dim); font-style: italic; }
.hljs-type,
.hljs-class,
.hljs-title.class_ { color: var(--blue); }
.hljs-variable,
.hljs-template-variable { color: var(--orange); }
.hljs-attr,
.hljs-attribute { color: var(--purple); }
.hljs-symbol,
.hljs-bullet { color: var(--orange); }
.hljs-deletion { color: var(--red); }
.hljs-params { color: var(--orange); }
.hljs-property { color: var(--blue); }
.hljs-operator { color: var(--red); }
.hljs-punctuation { color: var(--fg-muted); }
.hljs-subst { color: var(--orange); }
.hljs-selector-class,
.hljs-selector-id { color: var(--blue); }
.hljs-emphasis { font-style: italic; }
.hljs-strong { font-weight: 700; }

.hl-line {
  margin: 0 -1rem;
  padding: 0 1rem;
  background: rgba(171, 157, 242, 0.18);
  border-left: 3px solid var(--purple);
  padding-left: calc(1rem - 3px);
}
[data-theme="light"] .hl-line {
  background: rgba(124, 94, 197, 0.15);
}

.post-content blockquote { border-left: 3px solid var(--purple); padding-left: 1rem; color: var(--fg-muted); margin: 1rem 0; }
.post-content ul, .post-content ol { margin: 0.8rem 0; padding-left: 1.5rem; color: var(--fg); }
.post-content li { margin: 0.3rem 0; }
.post-content a { color: var(--blue); }
.post-content hr { border: none; border-top: 1px solid var(--purple); margin: 1.5rem 0; }
.post-content table { border-collapse: collapse; width: 100%; margin: 1rem 0; }
.post-content th, .post-content td { border: 1px solid var(--border); padding: 0.5rem 0.8rem; text-align: left; }
.post-content th { background: var(--bg-light); }

.c-red { color: var(--red); }
.c-orange { color: var(--orange); }
.c-yellow { color: var(--yellow); }
.c-green { color: var(--green); }
.c-blue { color: var(--blue); }
.c-purple { color: var(--purple); }
.c-pink { color: var(--red); }
.c-white { color: var(--fg); }
.c-gray { color: var(--fg-muted); }

.post-title { color: var(--green); font-size: 1.8rem; margin-bottom: 0.3rem; }
.post-meta { color: var(--fg-muted); font-size: 0.85rem; margin-bottom: 0.5rem; }
.back-link { display: inline-block; margin-bottom: 1.5rem; font-size: 0.9rem; }
