:root {
  --color-bg: #ffffff;
  --color-text: #1a1a1a;
  --color-text-secondary: #666666;
  --color-link: #4a4a4a;
  --color-link-hover: #1a1a1a;
  --color-code-bg: #f5f5f5;
  --color-border: #e5e5e5;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: Menlo, Monaco, "Courier New", monospace;
  --content-width: 800px;
  --spacing-section: 64px;
  --spacing-paragraph: 1.5em;
  --line-height-body: 1.7;
}

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

body {
  font-family: var(--font-sans);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: var(--line-height-body);
  font-size: 16px;
}

/* Header */
header {
  border-bottom: 1px solid var(--color-border);
  /*position: sticky;*/
  top: 0;
  background: var(--color-bg);
  z-index: 100;
}

.header-content {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 1.5rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

header nav ul {
  list-style: none;
  display: flex;
  gap: 2rem;
}

header nav a {
  color: var(--color-text);
  text-decoration: none;
  font-size: 0.95rem;
}

header nav a:hover {
  color: var(--color-link);
}

.mobile-toggle {
  display: none;
  flex-direction: column;
  gap: 4px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
}

.mobile-toggle span {
  width: 20px;
  height: 2px;
  background: var(--color-text);
  transition: 0.3s;
}

/* Main Content */
main {
  min-height: calc(100vh - 200px);
}

.content {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: var(--spacing-section) 1.5rem;
}

/* Post layout with sidebar */
.post-layout {
  display: grid;
  grid-template-columns: 250px minmax(0, 800px) 1fr;
  gap: 3rem;
  max-width: 1400px;
  margin: 0 auto;
  padding: var(--spacing-section) 1.5rem;
  align-items: start;
}

.post-main {
  min-width: 0;
}

.post-sidebar {
  position: sticky;
  top: 100px;
  align-self: start;
}

/* Table of Contents - Left sidebar version */
.toc {
  font-size: 0.85rem;
  line-height: 1.6;
}

.toc-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 1rem;
  color: var(--color-text-secondary);
}

.toc ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: block;
}

.toc li {
  margin-bottom: 0.5rem;
  display: block;
}

.toc a {
  color: var(--color-text-secondary);
  text-decoration: none;
  display: block;
  padding: 0.25rem 0;
  border-left: 2px solid transparent;
  padding-left: 0.75rem;
  transition: all 0.2s;
}

.toc a:hover,
.toc a.active {
  color: var(--color-text);
  border-left-color: var(--color-text);
}

.toc > ul > li > a {
  font-weight: 500;
  color: var(--color-text);
}

.toc ul ul {
  margin-left: 0;
  margin-top: 0.5rem;
  display: block;
}

.toc ul ul li {
  margin-bottom: 0.5rem;
  display: block;
}

.toc ul ul a {
  font-size: 0.85rem;
  color: var(--color-text-secondary);
  padding-left: 0.75rem;
}

/* Citations - Inline in right margin */
.citation {
  float: right;
  width: 200px;
  margin-left: 2rem;
  margin-right: -240px;
  margin-top: 0.25rem;
  margin-bottom: 1rem;
  font-size: 0.75rem;
  line-height: 1.4;
  color: var(--color-text-secondary);
  clear: right;
}

.citation-number {
  display: inline;
  font-weight: 700;
  color: var(--color-text);
  margin-right: 0.25rem;
}

.citation a {
  color: var(--color-link);
  text-decoration: underline;
}

.citation a:hover {
  color: var(--color-link-hover);
}

/* Superscript and Subscript */
sup, sub {
  font-size: 0.75em;
  line-height: 0;
  position: relative;
  vertical-align: baseline;
}

sup {
  top: -0.5em;
}

sub {
  bottom: -0.25em;
}

.post-content sup,
.post-content sub {
  font-weight: 500;
}

.page-title {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.page-subtitle {
  color: var(--color-text-secondary);
  font-size: 1.1rem;
  margin-bottom: 3rem;
}

/* Post Preview */
.post-preview {
  margin-bottom: 3rem;
  padding-bottom: 3rem;
  border-bottom: 1px solid var(--color-border);
}

.post-preview:last-child {
  border-bottom: none;
}

.post-date {
  display: block;
  color: var(--color-text-secondary);
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

.post-preview h3 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  line-height: 1.3;
}

.post-preview h3 a {
  color: var(--color-text);
  text-decoration: none;
}

.post-preview h3 a:hover {
  color: var(--color-link);
}

.post-meta {
  color: var(--color-text-secondary);
  font-size: 1rem;
  line-height: 1.6;
}

/* Footer */
footer {
  border-top: 1px solid var(--color-border);
  padding: 2rem 0;
  color: var(--color-text-secondary);
  font-size: 0.9rem;
}

footer a {
  color: var(--color-text-secondary);
  text-decoration: underline;
}

footer a:hover {
  color: var(--color-link-hover);
}

/* Post Page Specific */
.post-header {
  margin-bottom: 3rem;
}

.post-title {
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 1rem;
  line-height: 1.2;
}

.post-cover {
  width: 100%;
  height: auto;
  margin: 2rem 0;
}

.post-info {
  color: var(--color-text-secondary);
  font-size: 0.95rem;
  margin-bottom: 2rem;
}

.post-content h2 {
  font-size: 1.75rem;
  font-weight: 700;
  margin: 2.5rem 0 1rem;
}

.post-content h3 {
  font-size: 1.35rem;
  font-weight: 700;
  margin: 2rem 0 0.75rem;
}

.post-content p {
  margin-bottom: var(--spacing-paragraph);
}

.post-content a {
  color: var(--color-link);
  text-decoration: underline;
}

.post-content a:hover {
  color: var(--color-link-hover);
}

.post-content img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 2rem 0;
}

.post-content figcaption {
  font-size: 0.9rem;
  color: var(--color-text-secondary);
  text-align: center;
  margin-top: 0.5rem;
}

.post-content code {
  font-family: var(--font-mono);
  background: var(--color-code-bg);
  padding: 0.2em 0.4em;
  border-radius: 3px;
  font-size: 0.9em;
}

.post-content pre {
  background: var(--color-code-bg);
  padding: 1.5rem;
  border-radius: 6px;
  overflow-x: auto;
  margin: 1.5rem 0;
}

.post-content pre code {
  background: none;
  padding: 0;
}

.post-content ul,
.post-content ol {
  margin: 1.5rem 0;
  padding-left: 2rem;
}

.post-content li {
  margin-bottom: 0.5rem;
}

.post-content blockquote {
  margin: 2rem 0;
  padding: 1.5rem 2rem;
  border-left: 4px solid var(--color-text);
  background: var(--color-code-bg);
  font-style: italic;
  color: var(--color-text-secondary);
  position: relative;
}

.post-content blockquote p {
  margin-bottom: 0.5rem;
}

.post-content blockquote p:last-child {
  margin-bottom: 0;
}

.post-content blockquote::before {
  content: '"';
  font-size: 4rem;
  position: absolute;
  left: 0.5rem;
  top: -0.5rem;
  color: var(--color-border);
  font-family: Georgia, serif;
  line-height: 1;
}

/* Callout boxes */
.callout {
  margin: 2rem 0;
  padding: 1.5rem;
  border-left: 4px solid;
  border-radius: 0;
}

.callout p {
  margin-bottom: 0.5rem;
}

.callout p:last-child {
  margin-bottom: 0;
}

.callout-title {
  font-weight: 700;
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.callout-title::before {
  content: '';
  width: 1.25rem;
  height: 1.25rem;
  flex-shrink: 0;
}

/* Disclaimer - Orange */
.callout.disclaimer {
  border-left-color: #ff8c00;
}

.callout.disclaimer .callout-title {
  color: #c65d00;
}

.callout.disclaimer .callout-title::before {
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ff8c00' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cline x1='12' y1='8' x2='12' y2='12'/%3E%3Cline x1='12' y1='16' x2='12.01' y2='16'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* Danger - Red */
.callout.danger {
  border-left-color: #dc2626;
}

.callout.danger .callout-title {
  color: #991b1b;
}

.callout.danger .callout-title::before {
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23dc2626' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z'/%3E%3Cline x1='12' y1='9' x2='12' y2='13'/%3E%3Cline x1='12' y1='17' x2='12.01' y2='17'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* Note - Blue (bonus) */
.callout.note {
  border-left-color: #0066cc;
}

.callout.note .callout-title {
  color: #1e40af;
}

.callout.note .callout-title::before {
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230066cc' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cline x1='12' y1='16' x2='12' y2='12'/%3E%3Cline x1='12' y1='8' x2='12.01' y2='8'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* Footnotes */
.footnotes {
  margin-top: 4rem;
  padding-top: 2rem;
  border-top: 1px solid var(--color-border);
  font-size: 0.9rem;
}

.footnotes ol {
  padding-left: 2rem;
}

.footnotes li {
  margin-bottom: 0.75rem;
  color: var(--color-text-secondary);
}

.footnote-ref {
  color: var(--color-link);
  text-decoration: none;
  font-size: 0.85em;
  vertical-align: super;
}

.footnote-ref:hover {
  text-decoration: underline;
}

/* Citation Block - for bottom of article */
.citation-block {
  background: var(--color-code-bg);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 1.5rem;
  margin: 3rem 0;
}

.citation-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

.citation-text {
  color: var(--color-text-secondary);
  font-size: 0.95rem;
  line-height: 1.6;
  margin-bottom: 1rem;
}

.citation-bibtex {
  margin-top: 1.5rem;
}

.citation-bibtex summary {
  cursor: pointer;
  font-weight: 500;
  color: var(--color-link);
  text-decoration: underline;
  margin-bottom: 0.5rem;
}

.citation-bibtex summary:hover {
  color: var(--color-link-hover);
}

.citation-bibtex pre {
  margin-top: 1rem;
}

.post-nav {
  margin-top: 4rem;
  padding-top: 2rem;
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
}

.post-nav a {
  color: var(--color-link);
  text-decoration: underline;
}

.post-nav a:hover {
  color: var(--color-link-hover);
}

/* Mobile */
@media (max-width: 768px) {
  .mobile-toggle {
    display: flex;
  }

  header nav ul {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--color-bg);
    flex-direction: column;
    gap: 0;
    border-bottom: 1px solid var(--color-border);
    padding: 1rem 1.5rem;
  }

  header nav ul.active {
    display: flex;
  }

  header nav li {
    padding: 0.5rem 0;
  }

  .content {
    padding: 2rem 1.5rem;
  }

  /* Collapse sidebar on mobile */
  .post-layout {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  .post-sidebar {
    position: static;
    order: -1;
    border-bottom: 1px solid var(--color-border);
    padding-bottom: 2rem;
    margin-bottom: 2rem;
  }

  /* Hide inline citations on mobile, make them visible */
  .citation {
    float: none;
    width: 100%;
    margin: 1rem 0;
    margin-right: 0;
    padding: 1rem;
    background: var(--color-code-bg);
    border-left: 3px solid var(--color-border);
  }

  .page-title {
    font-size: 1.75rem;
  }

  .post-title {
    font-size: 2rem;
  }

  .post-preview h3 {
    font-size: 1.5rem;
  }

  .post-content h2 {
    font-size: 1.5rem;
  }

  .post-content h3 {
    font-size: 1.25rem;
  }
}
