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

:root {
  --color-bg: #ffffff;
  --color-surface: #f0f2f5;
  --color-text: #1a1a1a;
  --color-text-secondary: #555;
  --color-text-muted: #888;
  --color-border: #a7aaad;
  --color-border-light: #c9cacc;
  --color-accent: #3f4758;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --radius-sm: 0.5rem;
  --radius-md: 0.75rem;
  --radius-lg: 1rem;
  --content-max-width: 900px;
}

/* Hide resume and blog by default, JS will show if config allows */
#resume-link,
#nav-blog,
#blog {
  display: none;
}

/* Prevent flash of unstyled content */
.main-content {
  opacity: 0;
  transition: opacity 0.15s ease-in;
}
.main-content.loaded {
  opacity: 1;
}

body {
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.7;
  letter-spacing: -0.01em;
}
a {
  color: var(--color-text);
  text-decoration: none;
  border-bottom: 1px solid var(--color-border);
  transition: all 0.2s ease;
}

a:hover {
  color: var(--color-accent);
  border-bottom-color: var(--color-accent);
}

/* Two-Column Layout */
.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 320px;
  height: 100vh;
  background: var(--color-surface);
  box-shadow: 4px 0 20px rgba(0, 0, 0, 0.08), 
              1px 0 0 rgba(0, 0, 0, 0.05);
  overflow-y: auto;
  border-right: 1px solid var(--color-border-light);
}

.sidebar-content {
  padding: 3rem 2rem;
}

.sidebar-photo {
  width: 180px;
  height: 180px;
  margin-bottom: 2rem;
}

.sidebar-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--radius-md);
  border: 2px solid var(--color-text);
}

.sidebar h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: -0.15rem;
  letter-spacing: -0.02em;
  position: relative;
  display: inline-block;
}


.sidebar .tagline {
  font-size: 1rem;
  color: var(--color-text);
  margin-top: 0rem;
  margin-bottom: 1rem;
}

.sidebar .intro {
  font-size: 0.9rem;
  color: var(--color-text-secondary);
  line-height: 1.6;
  margin-bottom: 2rem;
  padding-bottom: 2rem;
  border-bottom: 2px solid #959799;
}

.sidebar-links {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.5rem;
  margin-bottom: 2rem;
  padding-bottom: 2rem;
  border-bottom: 2px solid #959799;
}

.sidebar-links a {
  font-size: 0.8rem;
  padding: 0.35rem 0.6rem;
  background: var(--color-bg);
  border-radius: var(--radius-sm);
  border: none;
  color: var(--color-text-secondary);
  transition: all 0.2s ease;
}

.sidebar-links a:hover {
  background: var(--color-accent);
  color: #fff;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0rem;
}

.sidebar-nav a {
  font-size: 0.9rem;
  padding: 0.5rem 0.75rem;
  margin-left: -0.75rem;
  border: none;
  color: var(--color-text-secondary);
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
}

.sidebar-nav a:hover {
  color: var(--color-accent);
  background: var(--color-bg);
}

.main-content {
  margin-left: 320px;
  flex: 1;
  padding: 3rem 4rem;
  max-width: var(--content-max-width);
}

.main-content .section {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 2rem;
  margin-bottom: 4rem;
  padding-bottom: 3rem;
  position: relative;
}

.main-content .section::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--color-border), transparent);
  border-radius: 2px;
  z-index: 1;
}

.main-content .section:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
}

.main-content .section:last-child::after {
  display: none;
}

.main-content .section h2 {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
  position: relative;
  padding-left: 0.75rem;
}

.main-content .section h2::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.2rem;
  width: 3px;
  height: 1rem;
  background: #555;
  border-radius: 2px;
}

.main-content .section > *:not(h2) {
  grid-column: 2;
}

/* Navigation - hide on index, keep for other pages */
.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: rgba(250, 250, 250, 0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--color-border-light);
  z-index: 100;
}

.nav-content {
  max-width: 900px;
  margin: 0 auto;
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.nav-logo {
  font-weight: 600;
  font-size: 1.25rem;
  border: none;
  display: flex;
  align-items: center;
}

.nav-logo svg {
  stroke: var(--color-text);
  transition: all 0.2s ease;
}

.nav-logo:hover svg {
  stroke: var(--color-accent);
}

.nav-links {
  display: flex;
  list-style: none;
  gap: 2rem;
}

.nav-links a {
  font-size: 0.9rem;
  border: none;
  color: var(--color-text-secondary);
  transition: color 0.2s ease;
}

.nav-links a:hover {
  color: var(--color-accent);
}

/* Header */
.header {
  padding: 8rem 2rem 4rem;
  max-width: 900px;
  margin: 0 auto;
}

.header-box {
  background: var(--color-surface);
  padding: 2rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border-light);
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 3rem;
}

.header-text {
  flex: 1;
}

.header-text h1 {
  font-size: 2.75rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
  letter-spacing: -0.02em;
}

.tagline {
  font-size: 1.25rem;
  color: var(--color-text-secondary);
  margin-bottom: 1rem;
  font-weight: 400;
}

.intro {
  color: var(--color-text-secondary);
  margin-bottom: 1.5rem;
  font-size: 1.05rem;
}

.header-links {
  display: flex;
  gap: 1.5rem;
}

.header-links a {
  font-size: 0.9rem;
  padding: 0.5rem 0;
}

.header-photo img {
  width: 180px;
  height: 180px;
  object-fit: cover;
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-text);
  transition: transform 0.3s ease;
}

.header-photo img:hover {
  transform: scale(1.02);
}

/* Main Content */
main {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 2rem;
}

.section {
  margin-bottom: 4rem;
}

.section h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--color-border);
  letter-spacing: -0.01em;
  color: var(--color-text);
}

/* About */
.about-content {
  background: var(--color-surface);
  padding: 1.5rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border-light);
}

.about-content p {
  color: var(--color-text-secondary);
  margin-bottom: 1rem;
  text-align: justify;
}

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

/* Experience */
.experience-list {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.experience-item {
  background: var(--color-surface);
  padding: 1.5rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border-light);
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.experience-item:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.experience-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.25rem;
}

.experience-header h3 {
  font-size: 1.1rem;
  font-weight: 600;
}

.experience-date {
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.experience-company-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.75rem;
}

.experience-company {
  color: var(--color-text-secondary);
  font-size: 0.95rem;
}

.experience-location {
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.experience-item ul {
  margin-left: 1.25rem;
  color: var(--color-text-secondary);
}

.experience-item li {
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
}

/* Skills */
.skills-table {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 1rem;
}

.skills-row {
  display: flex;
  gap: 1.5rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid hsl(180, 1%, 68%);
  align-items: center;
}

.skills-row:last-child {
  border-bottom: none;
}

.skills-category {
  flex: 0 0 190px;
  font-weight: 600;
  text-align: right;
  color: var(--color-text);
}

.skills-list {
  flex: 1;
  color: var(--color-text-secondary);
}

@media (max-width: 600px) {
  .skills-row {
    flex-direction: column;
    gap: 0.25rem;
  }
  .skills-category {
    text-align: left;
    flex: none;
  }
}

/* Education */
.education-list {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.education-item {
  background: var(--color-surface);
  padding: 1.5rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border-light);
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.education-item:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.education-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.25rem;
}

.education-header h3 {
  font-size: 1.1rem;
  font-weight: 600;
}

.education-date {
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.education-school {
  color: var(--color-text-secondary);
  font-size: 0.95rem;
  margin-bottom: 0.5rem;
}

.education-detail {
  font-size: 0.9rem;
  color: var(--color-text-secondary);
}

/* Projects */
.projects-grid {
  display: grid;
  gap: 1.5rem;
}

.project-card {
  background: var(--color-surface);
  padding: 1.5rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border-light);
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.project-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.project-card h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.project-card .project-date {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-bottom: 0.5rem;
}

.project-preview {
  margin-bottom: 1rem;
  text-align: center;
}

.project-preview img {
  width: 100%;
  max-width: 300px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  margin: 0 auto;
}

.project-card p {
  color: var(--color-text-secondary);
  font-size: 0.95rem;
  margin-bottom: 0.75rem;
}

.project-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.project-tags span {
  background: var(--color-border-light);
  color: var(--color-text-secondary);
  font-size: 0.8rem;
  padding: 0.3rem 0.7rem;
  border-radius: 2rem;
  transition: background 0.2s ease;
}

.project-card .project-tags span {
  background: var(--color-bg);
}

.project-card:hover .project-tags span {
  background: var(--color-bg);
}

.project-links {
  font-size: 0.9rem;
}

.project-links a {
  margin-right: 1rem;
}

/* Read more link */
.read-more {
  margin-top: 1.5rem;
  text-align: right;
}

.read-more a {
  font-size: 0.95rem;
}

/* Blog */
.blog-list {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.blog-card {
  background: var(--color-surface);
  padding: 1.5rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border-light);
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.blog-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.blog-card h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.blog-card .blog-date {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-bottom: 0.5rem;
}

.blog-card p {
  color: var(--color-text-secondary);
  font-size: 0.95rem;
  margin-bottom: 0.75rem;
}

.blog-keywords {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.blog-keywords span {
  background: var(--color-border-light);
  color: var(--color-text-secondary);
  font-size: 0.8rem;
  padding: 0.3rem 0.7rem;
  border-radius: 2rem;
  transition: background 0.2s ease;
}

.blog-card:hover .blog-keywords span {
  background: var(--color-border);
}

.blog-links {
  font-size: 0.9rem;
}

/* Blog detail page */
.blog-page {
  padding-top: 7rem;
}

.blog-detail h1 {
  font-size: 2rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.blog-meta {
  color: var(--color-text-muted);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.blog-detail .blog-keywords {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--color-border);
}

.blog-content {
  color: var(--color-text);
}

.blog-content p {
  margin-bottom: 1.25rem;
}

.blog-content h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-top: 2rem;
  margin-bottom: 0.75rem;
}

.blog-post {
  background: var(--color-surface);
  padding: 1.25rem 1.5rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border-light);
}

.blog-post h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.placeholder {
  color: var(--color-text-muted);
  font-style: italic;
}

/* Contact */
.contact-box {
  background: var(--color-surface);
  padding: 2rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border-light);
}

.contact-list {
  margin-top: 1rem;
}

.contact-list p {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  font-size: 0.95rem;
}

.contact-icon {
  width: 18px;
  height: 18px;
  opacity: 0.6;
}

.contact-list strong {
  margin-right: 0.25rem;
}

/* Footer */
.footer {
  max-width: 900px;
  margin: 0 auto;
  padding: 3rem 2rem;
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.9rem;
  border-top: 1px solid var(--color-border);
}

/* Page content for subpages */
.page-content {
  max-width: 900px;
  margin: 0 auto;
  padding: 6rem 2rem 2rem;
}

.page-content h1 {
  font-size: 2rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.section-intro {
  color: #555;
  margin-bottom: 2rem;
}

.nav-links a.active {
  color: #1a1a1a;
  font-weight: 500;
}

/* Project detail page */
.project-page {
  padding-top: 7rem;
}

.back-link {
  display: inline-block;
  font-size: 0.9rem;
  color: #555;
  margin-bottom: 2rem;
}

.project-detail h1 {
  font-size: 2rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.project-meta {
  margin-bottom: 2.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid #eee;
}

.project-meta .project-tags {
  margin-bottom: 1rem;
}

.project-meta .project-links {
  font-size: 0.9rem;
}

.project-section {
  margin-bottom: 2rem;
}

.project-section h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  border: none;
  padding: 0;
}

.project-section p {
  color: #444;
  margin-bottom: 0.75rem;
}

.project-section ul {
  margin-left: 1.25rem;
  color: #444;
}

.project-section li {
  margin-bottom: 0.5rem;
}

.project-date {
  color: #666;
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.project-section h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
}

.project-image {
  margin: 1.5rem 0;
}

.project-image img {
  width: 100%;
  border-radius: 0.5rem;
  border: 1px solid #eee;
}

.image-caption {
  font-size: 0.85rem;
  color: #666;
  text-align: center;
  margin-top: 0.5rem;
}

/* Responsive */
@media (max-width: 900px) {
  .layout {
    flex-direction: column;
  }

  .sidebar {
    position: relative;
    width: 100%;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--color-border-light);
  }

  .sidebar-content {
    padding: 2rem;
    text-align: center;
  }

  .sidebar-photo {
    margin: 0 auto 1.5rem;
  }

  .sidebar-links {
    justify-content: center;
  }

  .sidebar-nav {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
  }

  .main-content {
    margin-left: 0;
    padding: 2rem;
  }
}

@media (max-width: 700px) {
  .header-content {
    flex-direction: column-reverse;
    text-align: center;
  }

  .header-links {
    justify-content: center;
  }

  .nav-links {
    gap: 1rem;
  }

  .experience-header {
    flex-direction: column;
    gap: 0.25rem;
  }
}

/* Code Blocks */
pre {
  background: #1e1e1e;
  color: #d4d4d4;
  padding: 1.25rem;
  border-radius: var(--radius-md);
  overflow-x: auto;
  font-size: 0.85rem;
  line-height: 1.6;
  margin: 1.5rem 0;
}

pre code {
  background: none;
  padding: 0;
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
}

code {
  background: var(--color-bg);
  padding: 0.2em 0.4em;
  border-radius: 0.25rem;
  font-size: 0.9em;
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
}

/* Math Blocks */
.math-block {
  background: var(--color-bg);
  padding: 1rem 1.25rem;
  border-radius: var(--radius-sm);
  margin: 1rem 0;
  overflow-x: auto;
  text-align: center;
  font-size: 1rem;
}

/* Project Content Enhancements */
.project-content p {
  margin-bottom: 1rem;
}

.project-content h2 {
  margin-top: 2.5rem;
}

.project-content h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
  color: var(--color-text);
}

.project-content ul {
  margin: 1rem 0;
  padding-left: 1.5rem;
}

.project-content li {
  margin-bottom: 0rem;
}

/* Project Preview Image */
.project-preview {
  margin-bottom: 2rem;
}

.project-preview img {
  width: 100%;
  max-width: 500px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
}

/* Project Figures */
.project-figure {
  margin: 2rem 0;
  text-align: center;
}

.project-figure img {
  max-width: 100%;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
}

.figure-caption {
  margin-top: 0.75rem;
  font-size: 0.9rem;
  color: var(--color-text-secondary);
  font-style: italic;
}

/* Table of Contents */
.toc {
  background: var(--color-bg);
  border-left: 3px solid var(--color-border);
  padding: 1rem 1.5rem;
  margin-bottom: 2rem;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

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

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

.toc-list li {
  margin-bottom: 0.4rem;
}

.toc-list a {
  font-size: 0.9rem;
  color: var(--color-text-secondary);
  border: none;
  transition: color 0.2s ease;
}

.toc-list a:hover {
  color: var(--color-accent);
}

.toc-list .toc-sub {
  padding-left: 1rem;
  font-size: 0.85rem;
}
