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

html {
  background-color: var(--bg);
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: gray transparent;
  min-width: 360px;
}

:root {
  --bg: #1a1a1a;
  --text-copy: #eaeaea;
  --text-heading: #f2f2f2;
  --text-nav: #afafaf;
  --text-nav-hover: #f2f2f2;
}

[data-theme="light"] {
  --bg: #fff;
  --text-copy: #171717;
  --text-heading: #000;
  --text-nav: #6b7280;
  --text-nav-hover: #000;
}

[data-theme="light"] a {
  text-decoration-color: #d4d4d4;
}

[data-theme="light"] a:hover {
  text-decoration-color: #737373;
}

[data-theme="light"] hr {
  border-top-color: #e5e5e5;
}

[data-theme="light"] code {
  background-color: #f5f5f5;
}

[data-theme="light"] .post-card:hover {
  background-color: #f5f5f5;
}

body {
  font-family: 'STIX Two Text', 'STIX Two Text Fallback', Georgia, serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background-color: var(--bg);
  max-width: 650px;
  color: var(--text-copy);
  margin: 0 auto;
  padding: 0 2rem 4rem;
  line-height: 1.5;
}

.theme-toggle {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  border: none;
  background-color: #2d2d2d;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s ease;
}

.theme-toggle:hover {
  background-color: #3d3d3d;
}

[data-theme="light"] .theme-toggle {
  background-color: #f5f5f5;
}

[data-theme="light"] .theme-toggle:hover {
  background-color: #e5e5e5;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 6rem;
  padding-bottom: 0;
}

.site-header nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 14px;
}

.site-header nav a {
  color: var(--text-nav);
  text-decoration: none;
  padding: 0.25rem 0.75rem;
  transition: color 0.15s ease;
}

.site-header nav a:hover {
  color: var(--text-nav-hover);
}

.site-header nav a.nav-name {
  color: var(--text-heading);
  font-weight: 500;
  padding-left: 0.5rem;
  padding-right: 0.5rem;
}

h1 {
  color: var(--text-heading);
  text-wrap: balance;
  letter-spacing: -0.02em;
  font-weight: 500;
  font-size: 1.25rem;
  line-height: 3.25rem;
  margin-top: 0;
  margin-bottom: 0;
}

@media (min-width: 768px) {
  h1 {
    font-size: 1.5rem;
    margin-top: 8rem;
  }
}

h1 + p {
  margin-top: 0;
}

/* Journal/author landing-page titles can be long (e.g. full journal names) —
   smaller and tighter line-height so they fit on one line within the column. */
.listing-page-title {
  font-size: 1.1rem;
  line-height: 1.4;
  text-wrap: normal;
}

.site-header + h1 {
  margin-top: 1.5rem;
}

h2, h3, h4 {
  color: var(--text-heading);
  text-wrap: balance;
  letter-spacing: -0.025em;
  font-weight: 500;
}

h2 + p, h3 + p, h4 + p {
  margin-top: 14px;
}

p {
  color: var(--text-copy);
  font-size: 17px;
  margin-top: 1.25rem;
  margin-bottom: 1.25rem;
}

a {
  color: inherit;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2.5px;
  text-decoration-color: #737373;
  transition: text-decoration-color 0.15s ease;
}

a:hover {
  text-decoration-color: #a3a3a3;
}

ul {
  list-style: none;
  padding-left: 0;
  margin: 1.25rem 0;
}

ul li {
  color: var(--text-copy);
  font-size: 17px;
  padding-left: 1rem;
  padding-right: 0.25rem;
  position: relative;
  margin-bottom: 0.25rem;
}

ul:not(nav ul) li::before {
  content: "\25A0";
  color: #9ca3af;
  font-size: 0.5em;
  position: absolute;
  top: 0.5em;
  left: 0;
}

ul ul {
  margin-top: 4px;
}

ol li {
  color: var(--text-copy);
}

b, strong {
  color: inherit;
  font-weight: 600;
}

code {
  background-color: #2d2d2d;
  border-radius: 0.3em;
  padding: 0.2em 0.4em;
  font-family: Menlo, Monaco, 'Courier New', monospace;
  font-size: 14px;
}

pre {
  background-color: #16161e;
  border-radius: 0.5rem;
  margin: 1.5rem 0;
  padding: 1rem;
  line-height: 1;
  overflow-x: auto;
  -ms-overflow-style: none;
  scrollbar-width: none;
}

pre::-webkit-scrollbar {
  display: none;
}

pre code {
  background-color: transparent;
  border: none;
  padding: 0;
  font-size: 14px;
  line-height: 1.5;
  color: #e5e5e5;
}

hr {
  border: none;
  border-top: 1px solid #333;
  margin: 2rem 0;
}

input[type="text"],
input[type="email"] {
  appearance: none;
}

table {
  white-space: nowrap;
  max-width: fit-content;
  display: block;
  overflow-x: auto;
}

.posts {
  display: flex;
  flex-direction: column;
  gap: 2rem;
  width: 100vw;
  position: relative;
  left: 50%;
  transform: translateX(-50%);
  max-width: 750px;
  padding: 0 2rem;
  margin-top: -1rem;
}

.post-card {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 1.5rem;
  align-items: center;
  text-decoration: none;
  border-radius: 0.5rem;
  padding: 1rem;
  transition: background-color 0.15s ease;
}

.post-card:hover {
  background-color: #222;
}

.post-text h3 {
  color: var(--text-heading);
  font-size: 17px;
  font-weight: 500;
  letter-spacing: -0.02em;
  margin: 0;
}

.post-text p {
  color: var(--text-nav);
  font-size: 15px;
  margin: 0.5rem 0 0;
}

.post-date {
  color: #737373;
  font-size: 14px;
  display: block;
  margin-top: 0.5rem;
}

.post-image {
  overflow: hidden;
  border-radius: 0.375rem;
  height: 100%;
}

.post-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 0.375rem;
}

@media (max-width: 768px) {
  .post-card {
    grid-template-columns: 1fr;
  }

  .post-image {
    order: -1;
  }
}

.byline {
  color: var(--text-nav);
  font-size: 14px;
  text-decoration: none;
  display: block;
  margin-bottom: 1.5rem;
}

.byline:hover {
  color: var(--text-nav-hover);
}

.post-list {
  margin: 1.25rem 0;
  padding-left: 0.25rem;
  overflow-x: auto;
}

/* Keep the list's left edge aligned with the heading (stay in the column), but
   stretch its right edge out toward the window so long one-line titles show in
   full. Scroll only kicks in for titles wider than that. */
@media (min-width: 720px) {
  .post-list {
    margin-right: calc(2rem - (100vw - 650px) / 2);
  }
}

.post-list li {
  margin-bottom: 0.25rem;
  display: flex;
  align-items: baseline;
  gap: 1rem;               /* date trails the title (no space-between push) */
}

.post-list li a {
  white-space: nowrap;     /* keep each title on one line */
}

/* Research listing: journal name as a header above each .post-list block. */
.research-journal {
  font-weight: 700;
  color: var(--text-heading, #fff);
  margin: 2.4rem 0 0.6rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid #333;
  font-size: 1.2rem;
  letter-spacing: 0.01em;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.research-journal:first-of-type { margin-top: 1.25rem; }
[data-theme="light"] .research-journal { border-bottom-color: #e5e5e5; }
.research-journal .journal-more {
  font-size: 0.75rem;
  font-weight: 400;
  letter-spacing: 0;
  color: #737373;
  border: 1px solid var(--border, #333);
  border-radius: 6px;
  padding: 2px 10px;
  white-space: nowrap;
  flex-shrink: 0;
  text-decoration: none;
}
.research-journal .journal-more:hover { color: var(--text-copy, #ddd); border-color: #555; }
[data-theme="light"] .research-journal .journal-more { border-color: #ddd; }

/* Note listing: parts as category headings, chapters indented under them. */
.note-list {
  list-style: none;
  margin: 1.25rem 0;
  padding-left: 0;
}
.note-list li::before,
.note-list .note-book::before,
.note-list .note-part::before,
.note-list .note-chapter::before {
  content: none !important;               /* remove the global ■ bullet */
  display: none !important;
}
.note-list .note-book {
  font-weight: 700;
  color: var(--text-heading, #fff);
  margin: 2.4rem 0 0.6rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid #333;
  font-size: 1.35rem;
  letter-spacing: 0.01em;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.note-list .note-book:first-child { margin-top: 0; }
[data-theme="light"] .note-list .note-book { border-bottom-color: #e5e5e5; }
.note-list .note-book .book-more {
  font-size: 0.75rem;
  font-weight: 400;
  letter-spacing: 0;
  color: #737373;
  border: 1px solid var(--border, #333);
  border-radius: 6px;
  padding: 2px 10px;
  white-space: nowrap;
  flex-shrink: 0;
  text-decoration: none;
}
.note-list .note-book .book-more:hover { color: var(--text-copy, #ddd); border-color: #555; }
[data-theme="light"] .note-list .note-book .book-more { border-color: #ddd; }
.note-list .note-part {
  font-weight: 600;
  color: var(--text-copy, #ddd);
  margin: 1.4rem 0 0.5rem;
  padding-left: 0;                          /* category heading: flush left, no bullet */
  font-size: 1.05rem;
}
.note-list .note-part:first-child { margin-top: 0; }
.note-list .note-chapter {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.25rem;
  padding-left: 1.5rem;                     /* chapter: indented under its part */
}

.post-list-venue {
  color: #9ca3af;
  font-variant-numeric: tabular-nums;
  margin-right: 0.35rem;
}

.post-list-date {
  color: #737373;
  font-size: 14px;
  white-space: nowrap;
  flex-shrink: 0;
}

.post-list li::before {
  content: "\25A0";
  color: #9ca3af;
  font-size: 0.5em;
  position: absolute;
  top: 0.5em;
  left: 0;
}

.post-list li {
  padding-left: 1rem;
  position: relative;
}

/* Sort control on listing pages */
.post-sort {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0.5rem 0 1.25rem;
  font-size: 13px;
}
.post-sort-label { color: var(--text-nav, #888); }
.sort-select {
  font-size: 13px;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--border-color, #444);
  background: transparent;
  color: var(--text-copy, inherit);
  cursor: pointer;
}
.sort-select:hover { border-color: #888; }

