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

body {
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, "Apple Color Emoji", Arial, sans-serif, "Segoe UI Emoji", "Segoe UI Symbol";
  font-size: 16px;
  line-height: 1.6;
  color: rgb(55, 53, 47);
  background: #fff;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

/* Smooth scroll for anchor links */
html {
  scroll-behavior: smooth;
}

/* Highlight target heading briefly after anchor jump */
:target {
  animation: anchor-flash 1.5s ease;
}
@keyframes anchor-flash {
  0% { background: rgba(255, 212, 0, 0.25); }
  100% { background: transparent; }
}

.page {
  max-width: 720px;
  margin: 0 auto;
  padding: 40px 24px 80px;
}

/* Title */
.page-title {
  font-size: 40px;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 4px;
  padding: 3px 2px;
}

/* Headings */
h1 {
  font-size: 30px;
  font-weight: 600;
  margin-top: 32px;
  margin-bottom: 4px;
  padding: 3px 2px;
  line-height: 1.3;
}

h2 {
  font-size: 24px;
  font-weight: 600;
  margin-top: 22px;
  margin-bottom: 4px;
  padding: 3px 2px;
  line-height: 1.3;
}

h3 {
  font-size: 20px;
  font-weight: 600;
  margin-top: 16px;
  margin-bottom: 4px;
  padding: 3px 2px;
  line-height: 1.3;
}

h4 {
  font-size: 17px;
  font-weight: 600;
  margin-top: 14px;
  margin-bottom: 4px;
  padding: 3px 2px;
  line-height: 1.3;
}

/* Strikethrough */
del, s {
  text-decoration: line-through;
  color: rgba(55, 53, 47, 0.5);
}

/* Paragraph */
p {
  margin-top: 2px;
  margin-bottom: 2px;
  padding: 3px 2px;
  min-height: 1.6em;
}

/* Links */
a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: rgba(55, 53, 47, 0.4);
  text-underline-offset: 3px;
}

a:hover {
  text-decoration-color: rgb(55, 53, 47);
}

/* Bold / Italic */
strong {
  font-weight: 600;
}

em {
  font-style: italic;
}

/* Underline */
u {
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: rgba(55, 53, 47, 0.4);
}

/* Highlight — color variants */
mark { padding: 0 2px; border-radius: 2px; color: inherit; }
mark, mark.bg-yellow { background: rgba(255, 212, 0, 0.14); }
mark.bg-gray { background: rgba(155, 154, 151, 0.15); }
mark.bg-brown { background: rgba(140, 46, 0, 0.10); }
mark.bg-orange { background: rgba(245, 93, 0, 0.10); }
mark.bg-green { background: rgba(0, 135, 107, 0.10); }
mark.bg-blue { background: rgba(0, 120, 223, 0.10); }
mark.bg-purple { background: rgba(103, 36, 222, 0.10); }
mark.bg-pink { background: rgba(221, 0, 129, 0.10); }
mark.bg-red { background: rgba(255, 0, 26, 0.10); }

/* Lists */
ul, ol {
  padding-left: 1.7em;
  margin-top: 2px;
  margin-bottom: 2px;
}

li {
  padding: 3px 0;
}

li > ul, li > ol {
  margin-top: 0;
  margin-bottom: 0;
}

/* Compact list items — remove extra spacing when markdown wraps li content in <p> */
li > p {
  margin: 0;
  padding: 0;
  min-height: auto;
}

/* Checkboxes */
li.task-list-item {
  list-style-type: none;
  margin-left: -1.5em;
}

li.task-list-item input[type="checkbox"] {
  margin-right: 6px;
  vertical-align: middle;
}

/* Table of Contents — clean navigation style */
.toc {
  margin: 4px 0;
  padding: 0;
}
.toc ul {
  list-style: none;
  padding: 0;
  margin: 0;
}
.toc li {
  padding: 5px 2px;
  line-height: 1.4;
}
.toc li a {
  color: rgb(120, 119, 116);
  text-decoration: none;
  font-size: 15px;
  transition: color 0.15s;
}
.toc li a:hover {
  color: rgb(55, 53, 47);
}
/* Nested TOC — sub-sections (H2 under H1) */
.toc ul ul {
  padding-left: 20px;
  margin-top: 2px;
  margin-bottom: 2px;
  border-left: 1px solid rgba(55, 53, 47, 0.09);
}
.toc ul ul li {
  padding: 3px 2px 3px 8px;
}
.toc ul ul li a {
  color: rgb(145, 144, 142);
  font-size: 15px;
}
.toc ul ul li a:hover {
  color: rgb(100, 99, 97);
}

/* Blockquote — legacy markdown (>) fallback: callout style */
blockquote {
  margin: 4px 0;
  padding: 16px 16px 16px 12px;
  background: rgb(241, 241, 239);
  border-radius: 4px;
  border: none;
  font-size: 16px;
}
blockquote p {
  margin: 0;
  padding: 0;
}

/* Notion Quote — left border, no background */
.notion-quote {
  margin: 8px 0;
  padding: 12px 0 12px 16px;
  border-left: 3px solid rgb(55, 53, 47);
  background: none;
  border-radius: 0;
  font-size: 16px;
  font-style: italic;
}

/* Notion Callout — colored background with inline emoji icon */
.notion-callout {
  margin: 8px 0;
  padding: 16px;
  border-radius: 4px;
  font-size: 16px;
}
.notion-callout > p:first-child { margin-top: 0; }
.notion-callout > p:last-child { margin-bottom: 0; }
/* Callout color variants */
.callout-gray { background: rgb(241, 241, 239); }
.callout-brown { background: rgba(140, 46, 0, 0.06); }
.callout-orange { background: rgba(245, 93, 0, 0.06); }
.callout-yellow { background: rgba(255, 212, 0, 0.06); }
.callout-green { background: rgba(0, 135, 107, 0.06); }
.callout-blue { background: rgba(0, 120, 223, 0.06); }
.callout-purple { background: rgba(103, 36, 222, 0.06); }
.callout-pink { background: rgba(221, 0, 129, 0.06); }
.callout-red { background: rgba(255, 0, 26, 0.06); }
.callout-gray_background, .callout-default { background: rgb(241, 241, 239); }

/* Inline math */
.math { font-family: "KaTeX_Main", "Times New Roman", serif; font-style: italic; }
.math-block { font-family: "KaTeX_Main", "Times New Roman", serif; text-align: center; margin: 16px 0; font-size: 1.2em; }

/* Notion columns — side-by-side layout */
.notion-columns {
  display: flex;
  gap: 16px;
  margin: 8px 0;
}
.notion-column {
  flex: 1;
  min-width: 0;
}
.notion-column img {
  width: 100%;
}
@media (max-width: 600px) {
  .notion-columns {
    flex-direction: column;
    gap: 8px;
  }
}

/* Divider — extra space before next heading */
hr {
  border: none;
  border-top: 1px solid rgba(55, 53, 47, 0.16);
  margin: 24px 0 8px;
}

/* Code inline */
code {
  font-family: "SFMono-Regular", Menlo, Consolas, "PT Mono", "Liberation Mono", Courier, monospace;
  font-size: 85%;
  background: rgba(135, 131, 120, 0.15);
  border-radius: 4px;
  padding: 0.2em 0.4em;
  color: #eb5757;
}

/* Code block — wrap lines, copy button */
.code-wrapper {
  position: relative;
  margin: 8px 0;
}

.code-wrapper .copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 4px 8px;
  font-size: 12px;
  background: rgba(255,255,255,0.8);
  border: 1px solid rgba(55,53,47,0.16);
  border-radius: 4px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
  color: rgb(55,53,47);
  font-family: inherit;
}
.code-wrapper:hover .copy-btn {
  opacity: 1;
}
.code-wrapper .copy-btn.copied {
  background: rgb(0,135,107);
  color: #fff;
  border-color: transparent;
}

pre {
  margin: 0;
  padding: 24px 20px;
  background: rgb(247, 246, 243);
  border-radius: 4px;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  font-size: 85%;
  line-height: 1.5;
  tab-size: 2;
}

pre code {
  background: none;
  padding: 0;
  color: inherit;
  font-size: inherit;
}

/* Images — progressive loading */
img {
  max-width: 100%;
  height: auto;
  border-radius: 2px;
  margin: 4px 0;
  display: block;
}
img[loading="lazy"] {
  opacity: 0;
  transition: opacity 0.3s ease;
}
img.loaded {
  opacity: 1;
}
/* Blur placeholder wrapper */
.img-placeholder {
  background-size: cover;
  background-position: center;
  border-radius: 2px;
  overflow: hidden;
}

/* Image grid — consecutive images auto-layout side by side */
.img-grid {
  display: grid;
  gap: 8px;
  margin: 8px 0;
}
.img-grid.cols-2 { grid-template-columns: 1fr 1fr; }
.img-grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.img-grid img {
  margin: 0;
  width: 100%;
  object-fit: cover;
  border-radius: 4px;
}
@media (max-width: 600px) {
  .img-grid.cols-2, .img-grid.cols-3 { grid-template-columns: 1fr; }
}

/* Video embed (YouTube, etc.) */
.video-embed {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%;
  margin: 8px 0;
  border-radius: 4px;
  overflow: hidden;
  background: rgb(247, 246, 243);
}

.video-embed iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
}

/* Tables */
table {
  border-collapse: collapse;
  width: 100%;
  margin: 4px 0;
  font-size: 15px;
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

th, td {
  border: 1px solid rgb(233, 233, 231);
  padding: 7px 9px;
  text-align: left;
  vertical-align: top;
  min-width: 100px;
}

th {
  background: rgb(247, 246, 243);
  font-weight: 600;
}

/* Bare URLs — make them clickable */
.bare-url {
  word-break: break-all;
  color: rgb(55, 53, 47);
  text-decoration: underline;
  text-decoration-color: rgba(55, 53, 47, 0.4);
}

/* Toggle / Accordion (<details>) */
details {
  margin: 4px 0;
  padding: 3px 2px;
}

details summary {
  cursor: pointer;
  font-weight: 600;
  padding: 3px 2px;
  list-style: none;
}

details summary::-webkit-details-marker {
  display: none;
}

details summary::before {
  content: "▶";
  display: inline-block;
  margin-right: 6px;
  font-size: 12px;
  transition: transform 0.15s ease;
}

details[open] summary::before {
  transform: rotate(90deg);
}

details > *:not(summary) {
  margin-left: 22px;
}

/* Mobile */
@media (max-width: 600px) {
  .page {
    padding: 24px 16px 60px;
  }

  .page-title {
    font-size: 30px;
  }

  h1 {
    font-size: 24px;
  }

  h2 {
    font-size: 20px;
  }

  h3 {
    font-size: 18px;
  }

  pre {
    padding: 16px 12px 16px 16px;
    font-size: 13px;
  }

  table {
    font-size: 14px;
  }

  th, td {
    padding: 6px 8px;
    min-width: 80px;
  }
}

/* Lightbox — click-to-zoom overlay for images */
.lightbox-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 15, 15, 0.6);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
  cursor: zoom-out;
  -webkit-tap-highlight-color: transparent;
}
.lightbox-overlay.active {
  opacity: 1;
  visibility: visible;
}
.lightbox-overlay img {
  max-width: 96vw;
  max-height: 96vh;
  object-fit: contain;
  border-radius: 2px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.3);
  image-rendering: high-quality;
  cursor: zoom-out;
  transform: scale(0.95);
  transition: transform 0.2s ease;
  margin: 0;
  opacity: 1;
}
.lightbox-overlay.active img {
  transform: scale(1);
}
.lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  background: rgba(255, 255, 255, 0.9);
  border: none;
  border-radius: 50%;
  font-size: 18px;
  line-height: 32px;
  text-align: center;
  cursor: pointer;
  color: rgb(55, 53, 47);
  z-index: 10000;
  transition: background 0.15s;
}
.lightbox-close:hover {
  background: #fff;
}
/* Clickable images — cursor hint */
article.page img {
  cursor: zoom-in;
}

/* File download buttons */
.file-download {
  display: flex;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid rgba(55, 53, 47, 0.16);
  border-radius: 4px;
  margin: 4px 0;
  text-decoration: none;
  color: rgb(55, 53, 47);
  transition: background 0.1s;
  cursor: pointer;
}
.file-download:hover {
  background: rgba(55, 53, 47, 0.04);
}
.file-download .file-icon {
  margin-right: 8px;
  font-size: 18px;
  flex-shrink: 0;
}
.file-download .file-name {
  flex: 1;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-download .download-icon {
  opacity: 0;
  font-size: 14px;
  margin-left: 8px;
  transition: opacity 0.15s;
  flex-shrink: 0;
}
.file-download:hover .download-icon {
  opacity: 1;
}
