:root {
  --bg:          #eceae6;
  --bg-subtle:   #f0ede6;
  --bg-card:     #fff;
  --text:        #2a2a2a;
  --text-muted:  #888;
  --border:      #d4c9b4;
  --border-mid:  #c8bfaa;
  --border-dark: #b0a890;
  --accent:      #2c3e3a;
  --accent-link: #4a7c6f;
  --nav-bg:      #2c3e3a;
}

[data-theme="dark"] {
  --bg:          #1a1c1b;
  --bg-subtle:   #222624;
  --bg-card:     #2a2e2d;
  --text:        #ddd8d0;
  --text-muted:  #7a8a85;
  --border:      #3a4440;
  --border-mid:  #3a4440;
  --border-dark: #4a5550;
  --accent:      #5aafa0;
  --accent-link: #6ec9b8;
  --nav-bg:      #111413;
}

@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600&display=swap');

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

body {
  font-family: 'Montserrat', Arial, sans-serif;
  font-size: 16px;
  background: var(--bg);
  color: var(--text);
}

/* ── Header / nav bar ── */
.top-bar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--nav-bg);
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}

.top-bar .logo-img {
  height: 52px;
  width: auto;
  display: block;
}

.top-nav {
  display: flex;
  gap: 0;
  list-style: none;
}

.top-nav a {
  display: block;
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #c8bfaa;
  text-decoration: none;
  border-radius: 3px;
  transition: color 0.15s, background 0.15s;
}

.top-nav a:hover {
  color: #fff;
  background: rgba(255,255,255,0.08);
}

.top-nav a.active {
  color: #fff;
  background: rgba(255,255,255,0.15);
}

/* ── Main content ── */
.content {
  max-width: 860px;
  margin: 48px auto;
  padding: 0 28px 72px;
  font-size: 16px;
  line-height: 1.75;
  color: var(--text);
}

.content p {
  margin-bottom: 16px;
}

.content a {
  color: var(--accent-link);
  text-decoration: none;
}

.content a:hover {
  text-decoration: underline;
}

.content h1 {
  font-size: 26px;
  font-weight: 600;
  margin: 0 0 20px 0;
}

.content h2 {
  font-size: 19px;
  font-weight: 600;
  margin: 28px 0 10px 0;
}

.content h3 {
  font-size: 16px;
  font-weight: 600;
  margin: 22px 0 8px 0;
}

.content ul {
  margin: 0 0 16px 24px;
}

.content ul li {
  margin-bottom: 6px;
}

.content ol {
  margin: 0 0 16px 24px;
}

.content ol li {
  margin-bottom: 6px;
}

.content img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 0 0 24px 0;
}



/* ── Random tweet ── */
/* ── Book layout ── */
.book-entry {
  display: flex;
  gap: 28px;
  align-items: flex-start;
  margin-bottom: 40px;
}

.book-entry .book-cover {
  flex: 0 0 188px;
  width: 188px;
}

.book-entry .book-cover img,
.book-entry .book-cover .book-placeholder {
  width: 188px;
  aspect-ratio: 1305 / 1911;
  display: block;
  border: 1px solid var(--border-mid);
}

.book-entry .book-cover .book-placeholder {
  background: transparent;
}

.book-entry .book-text {
  flex: 1;
}

.book-entry .book-text h2 {
  margin-top: 0;
  font-size: 16px;
}


/* ── Intro block ── */
.intro-block {
  display: flex;
  gap: 28px;
  align-items: flex-start;
  margin-bottom: 8px;
}

.intro-photo {
  flex: 0 0 25%;
  width: 25%;
  height: auto;
  display: block;
  border-radius: 3px;
  margin: 0;
}

/* ── Patents TOC ── */
.toc {
  margin-bottom: 32px;
}

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

.toc ul li {
  margin-bottom: 4px;
}

.toc ul li a {
  color: var(--accent-link);
  text-decoration: none;
}

.toc ul li a:hover {
  text-decoration: underline;
}

/* ── About photo ── */
.about-photo {
  float: right;
  margin: 0 0 24px 32px;
  max-width: 220px;
}

/* ── Section headings ── */
.section-heading {
  font-size: 39px;
  font-weight: 600;
  margin: 0 0 16px 0;
  letter-spacing: 0.01em;
}

/* ── Tweet band ── */
.tweet-band {
  background: transparent;
  padding: 14px 20px 14px 0;
  margin: 0 0 8px 0;
  display: flex;
  align-items: stretch;
  gap: 0;
}

.tweet-nav {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  padding: 10px 14px 10px;
  flex: 0 0 auto;
  align-self: flex-start;
  border-right: 1px solid var(--border-mid);
  margin-right: 18px;
}

.tweet-btn {
  background: none;
  border: 1px solid var(--border-dark);
  border-radius: 3px;
  padding: 4px 8px;
  font-size: 13px;
  cursor: pointer;
  color: var(--accent);
  line-height: 1;
}

.tweet-btn:hover {
  background: #e0d8c8;
}

.tweet-text {
  font-style: italic;
  font-size: 15px;
  color: var(--text);
  line-height: 1.6;
  flex: 1;
  align-self: flex-start;
  padding-top: 10px;
}

.tweet-counter {
  display: none;
}

/* ── Substack posts ── */
.substack-grid {
  display: flex;
  gap: 20px;
  margin-bottom: 8px;
}

.substack-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
  background: #faf7f2;
  transition: box-shadow 0.15s;
}

.substack-card:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.10);
  text-decoration: none;
}

.substack-thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  display: block;
}

.substack-thumb-empty {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: transparent;
  display: block;
}

.substack-info {
  padding: 10px 12px 12px;
}

.substack-title {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: 4px;
  color: var(--text);
}

.substack-date {
  font-size: 12px;
  color: var(--text-muted);
}

.substack-loading {
  font-size: 14px;
  color: var(--text-muted);
  font-style: italic;
}

/* ── Social buttons ── */
.social-buttons {
  display: flex;
  gap: 14px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.social-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 14px 28px;
  border: 1.5px solid;
  border-radius: 10px;
  background: var(--bg-card);
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  transition: box-shadow 0.15s, background 0.15s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  min-width: 140px;
  justify-content: center;
}

.social-btn:hover {
  text-decoration: none;
  box-shadow: 0 3px 8px rgba(0,0,0,0.12);
}

.social-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: block;
}

.social-btn-substack {
  border-color: #FF6719;
  color: #FF6719;
}
.social-btn-substack:hover {
  background: var(--bg-card);
}

.social-btn-x {
  border-color: #555;
  color: #555;
}
.social-btn-x:hover {
  background: var(--bg-subtle);
}

.social-btn-linkedin {
  border-color: #0A66C2;
  color: #0A66C2;
}
.social-btn-linkedin:hover {
  background: var(--bg-card);
}

/* ── Intro greeting ── */
.intro-hi {
  font-size: 28px;
  font-weight: 600;
  margin-bottom: 4px;
  line-height: 1.3;
}

.intro-name {
  font-size: 24px;
  font-weight: 500;
  margin-bottom: 16px;
  line-height: 1.3;
}

/* ── Logo link ── */
.top-bar a:has(.logo-img) {
  display: flex;
  align-items: flex-start;
  line-height: 0;
}


.section-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 48px 0;
}




/* ── Tech timeline ── */
.tech-timeline {
  position: relative;
  margin: 28px 0 36px 16px;
  padding-left: 28px;
  border-left: 2px solid #d4c9b4;
}

.tl-item {
  position: relative;
  margin-bottom: 20px;
  opacity: 0;
  transform: translateX(-12px);
  transition: opacity 0.45s ease, transform 0.45s ease;
}

.tl-item.tl-visible {
  opacity: 1;
  transform: translateX(0);
}

.tl-dot {
  position: absolute;
  left: -36px;
  top: 4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #c8bfaa;
  border: 2px solid #eceae6;
  box-shadow: 0 0 0 1px #c8bfaa;
}

.tl-next .tl-dot {
  background: var(--nav-bg);
  box-shadow: 0 0 0 1px #2c3e3a;
}

.tl-content {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.tl-item::before {
  display: none;
}

.tl-label {
  font-size: 18px;
  font-weight: 500;
  color: var(--text);
}

.tl-next .tl-label {
  color: var(--accent);
  font-weight: 700;
}

/* ── Stat row ── */
.stat-row {
  display: flex;
  gap: 24px;
  margin: 28px 0;
  flex-wrap: wrap;
}

.stat-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 24px;
  min-width: 90px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}

.stat-num {
  font-size: 36px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.1;
}

.stat-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 4px;
  text-align: center;
}

/* ── Publications grouped by decade ── */
.pub-groups {
  margin-top: 8px;
}

.pub-group {
  margin-bottom: 20px;
}

.pub-decade-btn {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0 6px 0;
  background: transparent;
  border: none;
  border-bottom: 2px solid var(--border);
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  letter-spacing: 0.02em;
}

.pub-decade-btn:hover {
  background: transparent;
  border-bottom-color: var(--accent);
}

.pub-count {
  font-weight: 400;
  color: var(--text-muted);
  margin-left: 6px;
}

.pub-chevron {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: auto;
  padding-left: 12px;
}

.pub-list {
  list-style: disc;
  margin: 0;
  padding: 10px 20px 12px 36px;
}

.pub-list li {
  padding: 3px 0;
  font-size: 13px;
  line-height: 1.5;
  border-bottom: 1px solid #ece7dc;
}

.pub-list li:last-child {
  border-bottom: none;
}

/* ── Collapsible patenting sections ── */
.collapsible-section {
  margin-bottom: 4px;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.collapsible-btn {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 13px 18px;
  background: transparent;
  border: none;
  font-size: 16px;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: color 0.15s;
}

.collapsible-btn:hover {
  background: transparent;
  opacity: 0.8;
}

.collapsible-chevron {
  font-size: 12px;
  color: var(--text-muted);
  padding-left: 12px;
  flex-shrink: 0;
}

.collapsible-body {
  padding: 16px 20px 20px;
  border-top: 1px solid var(--border);
}

.collapsible-body[hidden] {
  display: none;
}

/* ── Dark mode toggle ── */
.theme-toggle {
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.35);
  border-radius: 20px;
  color: rgba(255,255,255,0.85);
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  padding: 4px 12px;
  margin-left: 18px;
  transition: border-color 0.15s, color 0.15s;
  white-space: nowrap;
  line-height: 1.4;
}
.theme-toggle:hover {
  border-color: rgba(255,255,255,0.7);
  color: #fff;
}

/* ── Expand / collapse all bar ── */
.expand-collapse-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}

.ec-btn {
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  border: 1px solid var(--border-dark);
  border-radius: 4px;
  color: var(--accent);
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  padding: 5px 14px;
  transition: border-color 0.15s, background 0.15s;
}

.ec-btn:hover {
  border-color: var(--accent);
  background: var(--bg-subtle);
}

/* ── SVG book cover ── */
.book-cover-svg {
  width: 188px;
  height: auto;
  display: block;
  border: 1px solid var(--border-mid);
}
