:root {
  --bg: #ffffff;
  --text: #111111;
  --text-muted: #555555;
  --border: #dddddd;
  --link: #111111;
  --link-hover: #2d6a4f;
  --accent: #2d6a4f;
  --accent-soft: #e8f3ed;
  --surface: #f5f5f5;
  --max-width: 780px;
  --nav-height: 48px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

[data-theme="dark"] {
  --bg: #0a0a0a;
  --text: #ededed;
  --text-muted: #999999;
  --border: #2a2a2a;
  --link: #ededed;
  --link-hover: #74c69d;
  --accent: #52b788;
  --accent-soft: #14241c;
  --surface: #141414;
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  background-image: linear-gradient(180deg, var(--accent-soft) 0%, var(--bg) 120px);
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--link);
  text-decoration: underline;
  text-underline-offset: 2px;
}

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

img {
  max-width: 100%;
  height: auto;
}

.container {
  width: min(var(--max-width), calc(100% - 2rem));
  margin: 0 auto;
}

/* Navigation */
.site-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--nav-height);
  gap: 1rem;
}

.nav-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
}

.nav-brand img {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: block;
  flex-shrink: 0;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.nav-links {
  display: flex;
  gap: 1rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-links a {
  font-size: 14px;
  color: var(--text-muted);
  text-decoration: none;
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: var(--accent);
}

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
  padding: 0.2rem 0.45rem;
  line-height: 1.4;
  font-family: var(--font);
}

.theme-toggle:hover {
  background: var(--surface);
}

.nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.25rem 0.5rem;
  cursor: pointer;
  font-size: 14px;
}

/* Profile header */
.profile-header {
  padding: 2rem 0 1.5rem;
}

.profile-grid {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 2rem;
  align-items: start;
}

.profile-wrap {
  width: 240px;
  flex-shrink: 0;
  overflow: visible;
}

.profile-wrap .profile-placeholder {
  display: none;
  width: 240px;
  min-height: 320px;
}

.profile-photo {
  display: block;
  width: 240px;
  max-width: none;
  height: auto;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.profile-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
}

.profile-header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.2;
  margin: 0 0 0.35rem;
  letter-spacing: -0.02em;
}

.subtitle {
  color: var(--text-muted);
  font-size: 14px;
  margin: 0 0 0.5rem;
  line-height: 1.45;
}

.contact-line {
  font-size: 14px;
  color: var(--text-muted);
  margin: 0 0 0.75rem;
}

.contact-line a {
  color: var(--text-muted);
}

.bio p {
  margin: 0 0 0.65rem;
  font-size: 15px;
}

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

.interests-line {
  margin-top: 0.85rem;
  font-size: 14px;
  color: var(--text-muted);
}

.interests-line strong {
  color: var(--text);
  font-weight: 600;
}

.social-line {
  margin-top: 0.65rem;
  font-size: 14px;
}

.social-line a {
  margin-right: 0.75rem;
}

/* Sections */
section {
  padding: 1.25rem 0;
}

.section-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0 0 0.75rem;
  letter-spacing: -0.01em;
  padding-left: 0.65rem;
  border-left: 3px solid var(--accent);
}

/* News */
.news-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.news-table tr {
  border-bottom: 1px solid var(--border);
}

.news-table tr:last-child {
  border-bottom: none;
}

.news-table td {
  padding: 0.5rem 0;
  vertical-align: top;
}

.news-date {
  width: 6.5rem;
  color: var(--accent);
  white-space: nowrap;
  padding-right: 1rem;
}

.news-text a {
  color: inherit;
}

/* Publications */
.pub-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.pub-item {
  display: grid;
  grid-template-columns: 4rem 1fr;
  gap: 0.75rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--border);
}

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

.pub-venue {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  line-height: 1.3;
  padding-top: 2px;
}

.pub-body {
  min-width: 0;
}

.pub-title {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.35;
  margin: 0 0 0.2rem;
}

.pub-authors {
  font-size: 14px;
  color: var(--text-muted);
  margin: 0 0 0.15rem;
}

.pub-meta {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0;
}

.pub-award {
  font-size: 13px;
  font-weight: 600;
  margin-top: 0.25rem;
}

.pub-links {
  margin-top: 0.35rem;
  font-size: 13px;
}

.pub-links a,
.pub-links button {
  color: var(--text-muted);
  text-decoration: none;
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  cursor: pointer;
}

.pub-links a:hover,
.pub-links button:hover {
  color: var(--text);
  text-decoration: underline;
}

.pub-links span {
  color: var(--border);
  margin: 0 0.35rem;
}

.pub-abstract {
  display: none;
  margin: 0.5rem 0 0;
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.5;
}

.pub-abstract.visible,
.pub-item.open .pub-abstract {
  display: block;
}

.pub-citations {
  white-space: nowrap;
}

/* Featured pubs with thumbnail (homepage) */
.pub-item--featured {
  grid-template-columns: 120px 1fr;
  align-items: start;
}

.pub-item--featured .pub-thumb {
  grid-column: 1;
  grid-row: 1 / 3;
  width: 120px;
  height: 78px;
  object-fit: cover;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--surface);
}

.pub-art-note {
  margin: 0.35rem 0 0;
  font-size: 10px;
  color: var(--text-muted);
  opacity: 0.65;
  letter-spacing: 0.01em;
}

.pub-item--featured .pub-venue {
  grid-column: 2;
  grid-row: 1;
}

.pub-item--featured .pub-body {
  grid-column: 2;
  grid-row: 2;
}

/* Timeline (publications page) */
.timeline {
  position: relative;
  padding-left: 1.25rem;
  border-left: 2px solid var(--accent);
}

.timeline-year {
  margin-bottom: 1.25rem;
}

.timeline-year:last-child {
  margin-bottom: 0;
}

.timeline-year-label {
  position: relative;
  font-size: 1rem;
  font-weight: 700;
  margin: 0 0 0.5rem -1.25rem;
  padding-left: 1.25rem;
}

.timeline-year-label::before {
  content: "";
  position: absolute;
  left: -5px;
  top: 0.45em;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg);
}

.timeline-year-list .pub-item {
  grid-template-columns: 4.5rem 1fr;
}

.timeline-year-list .pub-abstract.visible {
  display: block;
  margin-top: 0.4rem;
  padding-top: 0.4rem;
  border-top: 1px dashed var(--border);
}

/* Google Scholar stats */
.scholar-stats {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1.25rem;
  padding: 0.75rem 0;
  margin-bottom: 0.25rem;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.scholar-stat {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.scholar-num {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1;
}

.scholar-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.scholar-link {
  margin-left: auto;
  font-size: 14px;
  text-decoration: none;
}

.scholar-link:hover {
  text-decoration: underline;
  color: var(--accent);
}

.scholar-note {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0.35rem 0 0.75rem;
}

.scholar-note code {
  font-family: var(--mono);
  font-size: 11px;
}

.bibtex-block {
  display: none;
  margin-top: 0.5rem;
  padding: 0.6rem;
  background: var(--surface);
  border: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.45;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.bibtex-block.visible {
  display: block;
}

.see-all-link:hover {
  color: var(--accent);
}

.see-all-link {
  display: inline-block;
  margin-top: 0.75rem;
  font-size: 14px;
}

/* Filters */
.pub-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  font-size: 13px;
}

.filter-btn {
  background: none;
  border: none;
  padding: 0;
  color: var(--text-muted);
  cursor: pointer;
  font: inherit;
}

.filter-btn:hover,
.filter-btn.active {
  color: var(--accent);
  text-decoration: underline;
}

.filter-btn + .filter-btn::before {
  content: "·";
  margin-right: 0.5rem;
  color: var(--border);
  text-decoration: none;
}

/* Page header */
.page-header {
  padding: 1.75rem 0 0.5rem;
}

.page-header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin: 0 0 0.35rem;
}

.page-header .subtitle {
  margin: 0;
}

/* CV page */
.cv-page {
  padding: 1.5rem 0 3rem;
}

.cv-layout {
  display: grid;
  grid-template-columns: 11rem 1fr;
  gap: 2.5rem;
  align-items: start;
}

.cv-outline-wrap {
  position: sticky;
  top: calc(var(--nav-height) + 1rem);
}

.cv-outline-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin: 0 0 0.5rem;
}

.cv-outline ul {
  list-style: none;
  margin: 0 0 0.75rem;
  padding: 0;
  font-size: 13px;
}

.cv-outline li {
  margin-bottom: 0.35rem;
}

.cv-outline a {
  color: var(--text-muted);
  text-decoration: none;
}

.cv-outline a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.cv-download {
  display: inline-block;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
}

.cv-download:hover {
  text-decoration: underline;
}

.cv-top {
  margin-bottom: 0.25rem;
}

.cv-top h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin: 0 0 0.25rem;
}

.cv-top .subtitle {
  margin: 0;
}

.cv-content {
  min-width: 0;
}

.cv-section {
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--border);
  scroll-margin-top: calc(var(--nav-height) + 0.75rem);
}

.cv-section:last-child {
  border-bottom: none;
}

.cv-section h2 {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0 0 0.75rem;
  padding-left: 0.65rem;
  border-left: 3px solid var(--accent);
}

.cv-contact-line {
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-muted);
  margin: 0;
}

.cv-contact-line a {
  color: var(--text-muted);
}

.cv-entry {
  margin-bottom: 1rem;
}

.cv-entry:last-child {
  margin-bottom: 0;
}

.cv-entry-head,
.cv-entry-sub {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.cv-entry-head {
  font-size: 15px;
}

.cv-entry-sub {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 0.2rem;
}

.cv-entry p,
.cv-section > p {
  font-size: 14px;
  margin: 0.25rem 0 0;
  color: var(--text-muted);
}

.cv-detail {
  font-size: 14px;
  color: var(--text-muted);
  margin: 0.5rem 0 0;
}

.cv-list {
  margin: 0;
  padding-left: 1.1rem;
  font-size: 14px;
}

.cv-list li {
  margin-bottom: 0.5rem;
  line-height: 1.45;
}

.cv-list li:last-child {
  margin-bottom: 0;
}

/* Legacy CV styles (removed iframe) */
.cv-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 1rem 0;
  font-size: 14px;
}

.cv-actions a {
  color: var(--text-muted);
}

.cv-viewer {
  width: 100%;
  height: min(80vh, 900px);
  border: 1px solid var(--border);
  background: var(--surface);
}

.cv-note {
  margin-top: 0.75rem;
  font-size: 13px;
  color: var(--text-muted);
}

.cv-note code {
  font-family: var(--mono);
  font-size: 12px;
}

.copy-toast {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--text);
  color: var(--bg);
  padding: 0.4rem 0.85rem;
  font-size: 13px;
  opacity: 0;
  transition: transform 0.2s, opacity 0.2s;
  z-index: 200;
  pointer-events: none;
}

.copy-toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* Footer */
.site-footer {
  padding: 1.5rem 0 2rem;
  margin-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-muted);
}

/* Responsive */
@media (max-width: 600px) {
  .profile-grid {
    grid-template-columns: 1fr;
  }

  .profile-wrap {
    width: min(280px, 100%);
    margin: 0 auto;
  }

  .profile-photo {
    width: 100%;
    height: auto;
  }

  .pub-item--featured {
    grid-template-columns: 1fr;
  }

  .pub-item--featured .pub-thumb {
    grid-column: 1;
    grid-row: auto;
    width: 100%;
    height: auto;
    max-height: 140px;
  }

  .pub-item--featured .pub-venue,
  .pub-item--featured .pub-body {
    grid-column: 1;
    grid-row: auto;
  }

  .pub-item,
  .timeline-year-list .pub-item {
    grid-template-columns: 1fr;
    gap: 0.35rem;
  }

  .scholar-link {
    margin-left: 0;
    width: 100%;
  }

  .cv-layout {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .cv-outline-wrap {
    position: static;
    border-bottom: 1px solid var(--border);
    padding-bottom: 1rem;
  }

  .cv-outline ul {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 0.75rem;
    margin-bottom: 0.5rem;
  }

  .cv-outline li {
    margin: 0;
  }

  .cv-download {
    display: block;
    margin-top: 0.25rem;
  }

  .nav-toggle {
    display: block;
  }

  .nav-links {
    display: none;
    position: absolute;
    top: var(--nav-height);
    left: 0;
    right: 0;
    flex-direction: column;
    gap: 0.5rem;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 1rem;
  }

  .nav-links.open {
    display: flex;
  }

  .nav-inner {
    position: relative;
  }

  .news-date {
    display: block;
    width: auto;
    padding-bottom: 0.15rem;
  }
}
