:root {
  color-scheme: dark;
  --bg: #0d1117;
  --panel: #161b22;
  --panel-hover: #1c2128;
  --border: #30363d;
  --row-border: #21262d;
  --text: #f0f6fc;
  --text-strong: #e6edf3;
  --muted: #8b949e;
  --accent: #4a7c9a;
  --link: #58a6ff;
  --font: "JetBrains Mono", "Fira Code", "SF Mono", Consolas, monospace;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  margin: -1px;
  padding: 0;
  border: 0;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

html { background: var(--bg); }

body {
  min-height: 100vh;
  margin: 0;
  padding: 40px 20px 20px;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.7;
}

a { color: var(--link); }
a:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.main-container { max-width: 1200px; margin: 0 auto; }
.profile-section { margin-bottom: 30px; text-align: center; }
.profile-picture { display: inline-block; }
.profile-picture img {
  display: block;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  object-fit: cover;
}

.navigation { margin-bottom: 40px; text-align: center; }
.nav-row { margin-bottom: 10px; }
.nav-link {
  margin: 0 15px;
  color: var(--muted);
  font-size: 18px;
  text-decoration: underline;
}
.nav-link:hover, .nav-link.active { color: var(--accent); }
.social-icon {
  margin: 0 15px;
  color: var(--muted);
  font-size: 24px;
  text-decoration: none;
}
.social-icon:hover { color: var(--text-strong); }
.content { max-width: 1000px; margin: 0 auto; }

.about-page, .writing-page, .miscellany-page { padding: 40px 20px; }
.writing-page { position: relative; }
.about-container, .posts-container, .miscellany-container {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
}
.about-container { padding: 30px 24px; }
.about-title { margin: 0 0 24px; color: var(--text-strong); font-size: 1.75rem; font-weight: 500; }
.about-content p { margin: 0 0 16px; color: var(--muted); font-size: 16px; line-height: 1.6; }
.about-content a { text-decoration: none; }
.about-content a:hover { text-decoration: underline; }
.about-footer { margin: 30px 0 0 !important; color: var(--muted); font-size: 14px !important; }

.writing-search {
  position: absolute;
  z-index: 2;
  top: 2px;
  right: 24px;
  display: flex;
  height: 32px;
  align-items: center;
  border: 1px solid transparent;
  border-radius: 6px;
  background: var(--bg);
  transition: border-color 120ms ease, background 120ms ease, box-shadow 120ms ease;
}
.writing-search-toggle, .writing-search-clear {
  display: inline-flex;
  border: 0;
  background: transparent;
  color: #6e7681;
  cursor: pointer;
}
.writing-search-toggle {
  width: 32px;
  height: 32px;
  align-items: center;
  justify-content: center;
  padding: 0;
  opacity: .38;
  font: inherit;
  transition: color 120ms ease, opacity 120ms ease;
}
.writing-search-toggle:hover, .writing-search-toggle:focus-visible, .writing-search-clear:hover, .writing-search-clear:focus-visible { color: var(--text-strong); }
.writing-search-toggle:focus-visible, .writing-search-clear:focus-visible { outline: 1px solid var(--accent); outline-offset: -2px; }
.writing-search:hover .writing-search-toggle, .writing-search-toggle:focus-visible { opacity: .75; }
.writing-search-field {
  display: flex;
  width: min(220px, calc(100vw - 150px));
  height: 30px;
  align-items: center;
}
.writing-search-field input {
  min-width: 0;
  flex: 1;
  padding: 4px 6px 4px 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text-strong);
  font: 13px var(--font);
}
.writing-search-field input::placeholder { color: #6e7681; }
.writing-search-field input::-webkit-search-cancel-button { display: none; }
.writing-search-clear { align-items: center; align-self: stretch; padding: 0 8px; }
.writing-search-status { color: #6e7681; font-size: 10px; }
.writing-search-status:not(:empty) { padding-right: 8px; }
.writing-search.is-open { border-color: var(--border); background: var(--panel); box-shadow: 0 8px 24px rgb(0 0 0 / 24%); }
.writing-search.is-open .writing-search-toggle { color: var(--accent); opacity: 1; }
.writing-search-empty { margin: 0; padding: 36px 20px; color: var(--muted); font-size: 14px; text-align: center; }

.posts-list, .miscellany-list { margin: 0; padding: 0; list-style: none; }
.post-row, .miscellany-row { border-bottom: 1px solid var(--row-border); }
.post-row:last-child, .miscellany-row:last-child { border-bottom: 0; }
.post-row:hover, .miscellany-row:hover { background: var(--panel-hover); }
.post-link, .miscellany-link {
  display: grid;
  grid-template-columns: 110px 1fr 120px;
  gap: 16px;
  align-items: start;
  padding: 16px 20px;
  text-decoration: none;
}
.date-code { color: var(--muted); font-size: 14px; }
.col-title { display: flex; flex-direction: column; gap: 6px; }
.post-title, .miscellany-title { color: var(--text-strong); font-size: 16px; font-weight: 500; line-height: 1.4; }
.post-row:hover .post-title, .miscellany-row:hover .miscellany-title { color: var(--link); }
.post-excerpt, .miscellany-excerpt {
  display: -webkit-box;
  overflow: hidden;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.col-category { display: flex; justify-content: flex-end; }
.category-tag, .tag {
  display: inline-block;
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--row-border);
  color: var(--muted);
  font-size: 12px;
  letter-spacing: .3px;
  text-transform: uppercase;
}

.blog-post { max-width: 1000px; margin: 0 auto; padding: 20px; }
.post-header { margin-bottom: 30px; padding-bottom: 20px; border-bottom: 2px solid var(--border); }
.post-header h1 { margin: 0 0 20px; color: #fff; font-size: 2.5rem; line-height: 1.2; }
.post-meta { margin-bottom: 15px; color: var(--muted); font-size: .9rem; }
.post-meta span { margin-right: 20px; }
.post-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 15px; }
.tag { color: var(--accent); text-transform: none; }
.post-content { margin-bottom: 40px; color: var(--text); line-height: 1.7; font-size: var(--reader-zoom, 100%); }
.post-content h2, .post-content h3, .post-content h4 { margin: 30px 0 15px; color: #fff; }
.post-content h2 { padding-bottom: 10px; border-bottom: 1px solid var(--border); font-size: 1.8rem; }
.post-content h3 { font-size: 1.4rem; }
.post-content p, .post-content ul, .post-content ol { margin-bottom: 15px; }
.post-content li { margin-bottom: 8px; }
.post-content code { padding: 2px 6px; border-radius: 4px; background: var(--panel); color: var(--text-strong); font-family: var(--font); }
.post-content pre { overflow-x: auto; margin-bottom: 20px; padding: 16px; border: 1px solid var(--row-border); border-radius: 8px; background: #090c10; color: var(--text-strong); }
.post-content pre code { padding: 0; background: transparent; }
.post-content blockquote { margin: 20px 0; padding-left: 20px; border-left: 4px solid var(--accent); color: var(--muted); font-style: italic; }
.post-content table { width: 100%; margin: 24px 0; border-collapse: collapse; font-size: .9rem; }
.post-content th, .post-content td { padding: 10px 12px; border: 1px solid var(--border); text-align: left; }
.post-content th { background: var(--panel); color: var(--text-strong); }
.post-content td { color: var(--muted); }
.post-graphic { margin: 28px 0 34px; }
.post-graphic img { display: block; width: 100%; height: auto; border: 1px solid var(--border); border-radius: 10px; background: var(--panel); }
.post-graphic figcaption { margin-top: 10px; color: var(--muted); font-size: .82rem; line-height: 1.5; text-align: center; }
.post-graphic-wide { margin-right: -40px; margin-left: -40px; }
.post-footer { margin-top: 40px; padding-top: 20px; border-top: 2px solid var(--border); }
.post-navigation { margin-bottom: 20px; }
.back-link { color: var(--accent); font-weight: 700; text-decoration: none; }
.post-share { display: flex; flex-wrap: wrap; gap: 15px; align-items: center; }
.post-share > span { color: var(--muted); font-weight: 700; }
.share-link { display: flex; align-items: center; padding: 8px 15px; border: 1px solid var(--accent); border-radius: 4px; color: var(--accent); text-decoration: none; }
.reading-progress { position: fixed; z-index: 1000; top: 0; left: 0; width: 100%; height: 2px; background: rgb(74 124 154 / 12%); pointer-events: none; }
.reading-progress-bar { width: 100%; height: 100%; transform: scaleX(0); transform-origin: left; background: linear-gradient(90deg, var(--accent), #6f9bb4); }

.text-zoom {
  position: fixed;
  z-index: 900;
  right: 22px;
  bottom: 22px;
  display: flex;
  gap: 2px;
  padding: 6px;
  border: 1px solid rgb(48 54 61 / 55%);
  border-radius: 999px;
  background: rgb(22 27 34 / 45%);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: .38;
  filter: blur(.4px);
  transition: opacity .25s ease, filter .25s ease, background .25s ease, border-color .25s ease;
}
.text-zoom:hover,
.text-zoom:focus-within {
  opacity: 1;
  filter: none;
  background: rgb(22 27 34 / 92%);
  border-color: var(--border);
}
.text-zoom-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-family: var(--font);
  font-size: .78rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.text-zoom-btn:hover,
.text-zoom-btn:focus-visible { background: var(--panel-hover); color: var(--text-strong); }
.text-zoom-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.text-zoom-reset { font-size: .68rem; color: var(--accent); }

@media (max-width: 428px) {
  .text-zoom { right: 14px; bottom: 14px; }
}

.not-found { padding: 60px 20px; text-align: center; }
.not-found h1 { color: var(--text-strong); }

@media (max-width: 768px) {
  body { padding: 24px 14px 14px; }
  .about-page, .writing-page, .miscellany-page { padding: 20px 16px; }
  .writing-search { top: -20px; right: 20px; }
  .post-link, .miscellany-link { grid-template-columns: 90px 1fr 100px; }
  .reading-progress { height: 3px; }
  .post-header h1 { font-size: 2rem; }
  .post-graphic-wide { margin-right: 0; margin-left: 0; }
}

@media (max-width: 428px) {
  body { padding: 18px 12px 12px; }
  .profile-section { margin-bottom: 24px; }
  .navigation { margin-bottom: 28px; }
  .nav-link { margin: 0 8px; font-size: 15px; }
  .social-icon { margin: 0 10px; font-size: 22px; }
  .about-page, .writing-page, .miscellany-page { padding: 16px; }
  .about-container { padding: 20px 16px; }
  .about-title { font-size: 1.4rem; }
  .about-content p { font-size: 14px; }
  .writing-search { top: -28px; right: 16px; height: 40px; }
  .writing-search-toggle { width: 40px; height: 40px; }
  .writing-search-field { width: min(210px, calc(100vw - 130px)); height: 38px; }
  .post-link, .miscellany-link { grid-template-columns: 75px 1fr; gap: 12px; padding: 12px 14px; }
  .col-category { display: none; }
  .date-code, .post-excerpt, .miscellany-excerpt { font-size: 12px; }
  .post-title, .miscellany-title { font-size: 14px; }
  .post-excerpt, .miscellany-excerpt { -webkit-line-clamp: 1; }
  .blog-post { padding: 12px 4px; }
  .post-header h1 { font-size: 1.65rem; }
  .post-content { font-size: calc(var(--reader-zoom, 100%) - 5%); }
}

@media (max-width: 375px) {
  body { padding: 14px 10px 10px; }
  .nav-link { margin: 0 6px; font-size: 14px; }
  .post-link, .miscellany-link { grid-template-columns: 70px 1fr; gap: 10px; padding: 10px 12px; }
  .date-code { font-size: 11px; }
  .post-title, .miscellany-title { font-size: 13px; }
}
