:root {
  --background: #ffffff;
  --foreground: #171717;
  --muted: #737373;
  --muted-light: #f5f5f5;
  --border: #e5e5e5;
  --accent: #171717;
  --accent-foreground: #ffffff;
  --grid-color: rgba(0, 0, 0, 0.04);
  --shadow: 0 4px 30px rgba(0, 0, 0, 0.03);
  --nav-bg: rgba(255, 255, 255, 0.88);
  --card-bg: rgba(0, 0, 0, 0.02);
  --card-hover-bg: #f9f9f9;
  --font-serif: 'Instrument Serif', serif;
  --font-sans: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

.dark {
  --background: #0a0a0a;
  --foreground: #ededed;
  --muted: #a3a3a3;
  --muted-light: #171717;
  --border: #262626;
  --accent: #fafafa;
  --accent-foreground: #000000;
  --grid-color: rgba(255, 255, 255, 0.03);
  --shadow: 0 4px 30px rgba(0, 0, 0, 0.5);
  --nav-bg: rgba(10, 10, 10, 0.88);
  --card-bg: rgba(255, 255, 255, 0.02);
  --card-hover-bg: #141414;
}

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

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: inherit;
  color: inherit;
}

/* Scoped Theme Transitioning - Zero repaint lag on idle */
body.theme-transitioning,
body.theme-transitioning *,
body.theme-transitioning *::before,
body.theme-transitioning *::after {
  transition: background-color 0.25s ease, border-color 0.25s ease, color 0.25s ease, fill 0.25s ease, stroke 0.25s ease !important;
}

html {
  scroll-behavior: smooth;
}

body {
  background-color: var(--background);
  color: var(--foreground);
  font-family: var(--font-sans);
  line-height: 1.6;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Typography */
.font-serif { font-family: var(--font-serif); }
.font-sans { font-family: var(--font-sans); }
.font-mono { font-family: var(--font-mono); font-size: 0.85rem; }
.font-semibold { font-weight: 600; }
.text-muted { color: var(--muted); }
.text-serif-italic { font-family: var(--font-serif); font-style: italic; }

/* Grid Background System */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-size: 40px 40px;
  background-image: 
    linear-gradient(to right, var(--grid-color) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid-color) 1px, transparent 1px);
  mask-image: linear-gradient(to bottom, black 40%, transparent 100%);
  -webkit-mask-image: linear-gradient(to bottom, black 40%, transparent 100%);
}

/* Dashed Borders Utility */
.border-dashed { border: 1px dashed var(--border); }
.border-x-dashed { border-left: 1px dashed var(--border); border-right: 1px dashed var(--border); }
.border-t-dashed { border-top: 1px dashed var(--border); }
.border-b-dashed { border-bottom: 1px dashed var(--border); }

/* Top Fixed Navigation */
.top-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--nav-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px dashed var(--border);
}

.nav-inner {
  width: 100%;
  max-width: 800px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
}

.nav-title {
  font-size: 1.5rem;
  color: var(--foreground);
  text-decoration: none;
  transition: opacity 0.2s ease;
}

.nav-title:hover {
  opacity: 0.8;
}

.nav-links {
  display: none;
  gap: 18px;
  align-items: center;
}

@media (min-width: 640px) {
  .nav-links {
    display: flex;
  }
}

.nav-link {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  position: relative;
  transition: color 0.2s ease;
  padding: 4px 0;
}

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

.nav-link.active {
  color: var(--foreground);
}

.nav-link.active::after {
  content: "";
  position: absolute;
  bottom: -2px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background-color: var(--foreground);
}

/* Nav Actions */
.nav-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.theme-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.theme-btn:hover {
  background-color: var(--muted-light);
  color: var(--foreground);
}

/* Mobile Hamburger */
.mobile-menu-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--muted);
  border-radius: 8px;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.mobile-menu-btn:hover {
  background-color: var(--muted-light);
  color: var(--foreground);
}

@media (min-width: 640px) {
  .mobile-menu-btn {
    display: none;
  }
}

/* Mobile Dropdown */
.mobile-nav {
  display: none;
  width: 100%;
  max-width: 800px;
  flex-direction: column;
  padding: 8px 24px 16px;
  gap: 4px;
}

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

.mobile-nav-link {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 8px 12px;
  border-radius: 8px;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.mobile-nav-link:hover,
.mobile-nav-link.active {
  background-color: var(--muted-light);
  color: var(--foreground);
}

/* Layout Wrapper */
.layout-wrapper {
  display: flex;
  justify-content: center;
  width: 100%;
  min-height: 100vh;
  padding-top: 60px;
}

.layout-container {
  width: 100%;
  max-width: 800px;
  background-color: var(--background);
  box-shadow: 0 0 100px 50px var(--background);
  position: relative;
}

/* Section Blocks */
.section-block {
  padding: 40px 24px;
}

.section-title {
  font-size: 1.8rem;
  margin-bottom: 24px;
  font-weight: 400;
}

/* Hero Section */
#intro {
  padding-top: 24px;
  padding-bottom: 24px;
}

.banner-wrapper {
  width: 100%;
  height: 140px;
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: -50px;
  position: relative;
  border: 1px dashed var(--border);
}

@media (min-width: 600px) {
  .banner-wrapper {
    height: 180px;
    margin-bottom: -60px;
  }
}

.banner-bg {
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #1e293b, #0f172a);
  background-image: 
    radial-gradient(at 0% 0%, hsla(253,16%,7%,1) 0, transparent 50%), 
    radial-gradient(at 50% 0%, hsla(225,39%,30%,1) 0, transparent 50%), 
    radial-gradient(at 100% 0%, hsla(339,49%,30%,1) 0, transparent 50%);
}

.profile-header {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 0 12px;
}

@media (min-width: 600px) {
  .profile-header {
    flex-direction: row;
    align-items: flex-end;
    gap: 24px;
  }
}

.avatar-wrapper {
  width: 100px;
  height: 100px;
  border-radius: 16px;
  background-color: var(--background);
  padding: 6px;
  position: relative;
  z-index: 10;
}

@media (min-width: 600px) {
  .avatar-wrapper {
    width: 120px;
    height: 120px;
  }
}

.avatar, .avatar-fallback {
  width: 100%;
  height: 100%;
  border-radius: 12px;
  object-fit: cover;
  background-color: var(--muted-light);
}

.avatar-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  color: white;
  font-weight: 600;
  font-size: 1.5rem;
}

.profile-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}

.name-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.name-row h1 {
  font-size: 2.2rem;
  font-weight: 400;
  line-height: 1;
}

.verified-icon {
  width: 20px;
  height: 20px;
  color: var(--foreground);
}

.title-animation-wrapper {
  overflow: hidden;
}

.animated-title {
  display: inline-block;
  animation: slideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.location-text {
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  gap: 6px;
}

.location-text::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: #10b981;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* About Section */
.about-section {
  padding-top: 32px;
}

.about-content {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.about-item {
  display: flex;
  gap: 12px;
  color: var(--foreground);
  font-size: 0.95rem;
}

.about-item .bullet {
  margin-top: 2px;
}

.highlight-text {
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-color: var(--muted);
}

/* Contact Grid */
.contact-section {
  padding-top: 32px;
}

.contact-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  width: 100%;
}

@media (min-width: 600px) {
  .contact-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.contact-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  text-decoration: none;
  color: var(--foreground);
  background: var(--card-bg);
  border: 1px dashed var(--border);
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
  transition: transform 0.2s ease, background-color 0.2s ease, border-color 0.2s ease;
  position: relative;
  text-align: left;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
}

.contact-card:hover {
  background-color: var(--card-hover-bg);
  border-color: var(--muted);
  transform: translateY(-2px);
}

.contact-icon-box {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background-color: var(--muted-light);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  flex-shrink: 0;
  transition: background-color 0.2s ease;
}

.contact-card:hover .contact-icon-box {
  background-color: var(--background);
}

.contact-text-col {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.contact-name {
  font-weight: 500;
  font-size: 0.88rem;
  color: var(--foreground);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.contact-subtext {
  font-size: 0.68rem;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.contact-arrow {
  color: var(--muted);
  opacity: 0;
  transform: translate(-4px, 4px);
  transition: opacity 0.2s ease, transform 0.2s ease, color 0.2s ease;
  flex-shrink: 0;
}

.contact-card:hover .contact-arrow {
  opacity: 1;
  transform: translate(0, 0);
  color: var(--foreground);
}

/* Skills Matrix Section */
.skills-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media (min-width: 600px) {
  .skills-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.skill-category-card {
  padding: 16px;
  border-radius: 12px;
  background-color: var(--card-bg);
  border: 1px dashed var(--border);
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: border-color 0.2s ease, transform 0.2s ease, background-color 0.2s ease;
}

.skill-category-card:hover {
  border-color: var(--muted);
  background-color: var(--card-hover-bg);
  transform: translateY(-2px);
}

.skill-category-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.category-icon {
  display: inline-flex;
  color: var(--muted);
}

.category-title {
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--foreground);
}

.skills-tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.skill-tag {
  font-size: 0.72rem;
  padding: 3px 8px;
  border-radius: 6px;
  background-color: var(--muted-light);
  color: var(--foreground);
  border: 1px dashed var(--border);
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
  user-select: none;
}

.skill-tag:hover {
  background-color: var(--foreground);
  color: var(--background);
  border-color: var(--foreground);
  transform: translateY(-1px);
}

/* Experience Accordion */
.accordion {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.accordion-item {
  border-radius: 12px;
  padding: 16px;
  background-color: var(--card-bg);
  border: 1px dashed var(--border);
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.accordion-item:hover, .accordion-item.active {
  background-color: var(--card-hover-bg);
  border-color: var(--muted);
}

.accordion-header {
  width: 100%;
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  color: var(--foreground);
}

@media (min-width: 500px) {
  .accordion-header {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }
}

.accordion-title-container {
  display: flex;
  align-items: center;
  gap: 16px;
}

.company-logo {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background-color: var(--background);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  overflow: hidden;
  flex-shrink: 0;
}

.company-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 600;
  font-size: 1.1rem;
}

.job-meta {
  display: flex;
  flex-direction: column;
}

.company-name {
  font-weight: 600;
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.accordion-icon {
  width: 16px;
  height: 16px;
  color: var(--muted);
  transition: transform 0.2s ease;
}

.accordion-item.active .accordion-icon {
  transform: rotate(90deg);
}

.accordion-content {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.3s ease, opacity 0.3s ease;
  padding-left: 64px;
}

.accordion-item.active .accordion-content {
  opacity: 1;
  padding-top: 16px;
}

.experience-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  line-height: 1.55;
}

.experience-bullet {
  position: relative;
  padding-left: 14px;
  color: var(--muted);
}

.experience-bullet::before {
  content: "•";
  position: absolute;
  left: 0;
  color: var(--muted);
}

/* Projects Section */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 24px;
}

.view-all-link {
  display: flex;
  align-items: center;
  gap: 4px;
  text-decoration: none;
  font-size: 0.85rem;
  transition: color 0.2s ease;
}

.view-all-link svg {
  transition: transform 0.2s ease;
}

.view-all-link:hover {
  color: var(--foreground);
}

.view-all-link:hover svg {
  transform: translate(2px, -2px);
}

.projects-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
}

@media (min-width: 600px) {
  .projects-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.project-card {
  display: flex;
  flex-direction: column;
  border-radius: 12px;
  overflow: hidden;
  background-color: var(--background);
  border: 1px dashed var(--border);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.project-card:hover {
  transform: translateY(-4px);
  border-color: var(--muted);
  box-shadow: 0 10px 40px rgba(0,0,0,0.05);
}

.dark .project-card:hover {
  box-shadow: 0 10px 40px rgba(0,0,0,0.4);
}

.project-banner-link {
  display: block;
  width: 100%;
  text-decoration: none;
  color: inherit;
  overflow: hidden;
}

/* Real Project Screenshot Banners */
.project-banner-preview {
  position: relative;
  width: 100%;
  height: 200px;
  background-color: var(--muted-light);
  overflow: hidden;
  border-bottom: 1px dashed var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
}

.project-preview-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), filter 0.3s ease;
  display: block;
}

.project-card:hover .project-preview-img {
  transform: scale(1.04);
}

.dark .project-preview-img {
  filter: brightness(0.92) contrast(1.05);
}

.dark .project-card:hover .project-preview-img {
  filter: brightness(1) contrast(1.05);
}

.project-banner-overlay {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 5;
}

.banner-tag {
  background: rgba(0, 0, 0, 0.7);
  color: #ffffff;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  padding: 3px 8px;
  border-radius: 6px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  font-weight: 500;
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.project-details {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.project-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.project-title {
  font-size: 1.1rem;
  font-weight: 600;
}

.project-badge {
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.badge-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background-color: var(--muted);
}

.project-desc {
  font-family: var(--font-sans);
  font-size: 0.875rem;
  line-height: 1.55;
  margin-bottom: 12px;
  flex: 1;
}

.project-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: auto;
}

.tech-stack-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.tech-tag {
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 4px;
  background-color: var(--muted-light);
  color: var(--foreground);
  border: 1px dashed var(--border);
}

.project-links {
  display: flex;
  gap: 8px;
}

.icon-link {
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  transition: color 0.2s ease, background-color 0.2s ease;
}

.icon-link:hover {
  color: var(--foreground);
  background-color: var(--muted-light);
}

/* Writing Section */
.writing-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.writing-card {
  border-radius: 12px;
  background-color: var(--card-bg);
  border: 1px dashed var(--border);
  transition: background-color 0.2s ease, border-color 0.2s ease;
  overflow: hidden;
}

.writing-card:hover {
  background-color: var(--card-hover-bg);
  border-color: var(--muted);
}

.writing-header-clickable {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  cursor: pointer;
  user-select: none;
}

.writing-icon-box {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background-color: var(--background);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  flex-shrink: 0;
  transition: background-color 0.2s ease;
}

.writing-card:hover .writing-icon-box {
  background-color: var(--muted-light);
  color: var(--foreground);
}

.writing-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.writing-title {
  font-size: 1rem;
}

.writing-date {
  font-size: 0.75rem;
}

.writing-chevron {
  width: 18px;
  height: 18px;
  color: var(--muted);
  transition: transform 0.25s ease;
}

.writing-card.expanded .writing-chevron {
  transform: rotate(90deg);
}

.writing-expanded-content {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.35s ease, opacity 0.3s ease;
}

.writing-card.expanded .writing-expanded-content {
  opacity: 1;
}

.abstract-box {
  padding: 0 16px 16px 76px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 0.8rem;
}

.abstract-heading {
  font-size: 0.72rem;
  letter-spacing: 0.06em;
}

.abstract-text {
  color: var(--foreground);
  line-height: 1.55;
}

.abstract-guarantees {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--foreground);
}

.guarantee-item {
  display: flex;
  gap: 8px;
}

.writing-links-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
  flex-wrap: wrap;
}

.read-paper-btn, .bibtex-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.75rem;
  text-decoration: none;
  color: var(--foreground);
  background-color: var(--muted-light);
  cursor: pointer;
  border: 1px dashed var(--border);
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.15s ease;
}

.read-paper-btn:hover, .bibtex-btn:hover {
  background-color: var(--foreground);
  color: var(--background);
  border-color: var(--foreground);
  transform: translateY(-1px);
}

/* Coding Activity Section */
.activity-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.activity-card {
  border-radius: 12px;
  padding: 22px 24px;
  background-color: var(--card-bg);
  border: 1px dashed var(--border);
  transition: border-color 0.2s ease, transform 0.2s ease, background-color 0.2s ease;
}

.activity-card:hover {
  border-color: var(--muted);
  background-color: var(--card-hover-bg);
}

.activity-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.activity-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.activity-card-title {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--foreground);
}

.activity-card-icon {
  width: 15px;
  height: 15px;
  color: var(--foreground);
}

.leetcode-icon {
  fill: currentColor;
}

/* GitHub Heatmap */
.heatmap-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  margin-bottom: 14px;
}

.heatmap-wrapper::-webkit-scrollbar {
  display: none;
}

.heatmap-months {
  display: flex;
  justify-content: space-between;
  min-width: 686px;
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 8px;
  padding: 0 4px;
  user-select: none;
}

.heatmap-svg-container {
  min-width: 686px;
  min-height: 88px;
  display: flex;
  align-items: center;
}

.contrib-cell {
  transition: fill 0.2s ease, stroke 0.2s ease, transform 0.1s ease;
  cursor: pointer;
}

.dark .contrib-cell.lvl-0 { fill: #1a1e24; }
.dark .contrib-cell.lvl-1 { fill: #333842; }
.dark .contrib-cell.lvl-2 { fill: #5c6370; }
.dark .contrib-cell.lvl-3 { fill: #9da5b4; }
.dark .contrib-cell.lvl-4 { fill: #e5e9f0; }

.contrib-cell.lvl-0 { fill: #ebedf0; }
.contrib-cell.lvl-1 { fill: #d1d5db; }
.contrib-cell.lvl-2 { fill: #9ca3af; }
.contrib-cell.lvl-3 { fill: #6b7280; }
.contrib-cell.lvl-4 { fill: #1f2937; }

.contrib-cell:hover {
  stroke: var(--foreground);
  stroke-width: 1px;
}

.heatmap-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 4px;
}

.contrib-total {
  font-size: 0.78rem;
}

.heatmap-legend {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
}

.legend-cell {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  display: inline-block;
}

.dark .legend-cell.lvl-0 { background-color: #1a1e24; }
.dark .legend-cell.lvl-1 { background-color: #333842; }
.dark .legend-cell.lvl-2 { background-color: #5c6370; }
.dark .legend-cell.lvl-3 { background-color: #9da5b4; }
.dark .legend-cell.lvl-4 { background-color: #e5e9f0; }

.legend-cell.lvl-0 { background-color: #ebedf0; }
.legend-cell.lvl-1 { background-color: #d1d5db; }
.legend-cell.lvl-2 { background-color: #9ca3af; }
.legend-cell.lvl-3 { background-color: #6b7280; }
.legend-cell.lvl-4 { background-color: #1f2937; }

/* LeetCode Card */
.leetcode-stats-badge {
  font-size: 0.85rem;
  color: var(--muted);
}

.leetcode-count {
  font-weight: 700;
  color: var(--foreground);
  font-size: 0.95rem;
}

.leetcode-bars {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.leetcode-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.leetcode-row-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.88rem;
}

.difficulty-name {
  font-weight: 500;
  color: var(--foreground);
}

.difficulty-num {
  font-weight: 600;
  color: var(--muted);
  font-size: 0.82rem;
}

.progress-track {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background-color: var(--border);
  overflow: hidden;
  position: relative;
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
  background-color: #8b949e;
  transition: width 1s cubic-bezier(0.4, 0, 0.2, 1);
}

.dark .progress-fill {
  background-color: #8b949e;
}

/* Ask AI Section */
.ask-ai-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

.ask-ai-label {
  font-size: 0.8rem;
}

.ask-ai-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ai-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background-color: var(--muted-light);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  text-decoration: none;
  transition: background-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.ai-btn:hover {
  background-color: var(--foreground);
  color: var(--background);
  transform: translateY(-3px);
}

.ai-logo {
  width: 16px;
  height: 16px;
}

/* Footer */
footer {
  padding: 32px 24px;
}

.footer-row {
  display: flex;
  flex-direction: column;
  gap: 12px;
  justify-content: space-between;
}

@media (min-width: 600px) {
  .footer-row {
    flex-direction: row;
    align-items: flex-start;
  }
}

.footer-left, .footer-right {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

@media (min-width: 600px) {
  .footer-right {
    text-align: right;
    align-items: flex-end;
  }
}

.footer-highlight {
  color: var(--foreground);
  font-weight: 500;
}

/* Visitor Counter */
.visitor-counter-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 0.75rem;
  background: var(--card-bg);
  border: 1px dashed var(--border);
  margin-top: 4px;
  width: fit-content;
  user-select: none;
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.visitor-counter-badge:hover {
  border-color: var(--muted);
  transform: translateY(-1px);
}

.visitor-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
  animation: pulse-dot 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse-dot {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.4;
    transform: scale(0.85);
  }
}

.visitor-label {
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.02em;
}

.visitor-num {
  font-weight: 600;
  color: var(--foreground);
}

/* Floating Toast Notification */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background-color: var(--foreground);
  color: var(--background);
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 500;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
  z-index: 9999;
  opacity: 0;
  transform: translateY(16px);
  pointer-events: none;
  transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1), transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  align-items: center;
  gap: 8px;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* Covers for projects that have no real screenshot.
   Drawn in HTML/CSS so they follow the theme and cannot be mistaken for a product UI. */
.project-cover {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 6px;
  padding: 44px 20px 18px;
  color: var(--foreground);
  background-color: var(--muted-light);
  background-image:
    linear-gradient(var(--grid-color) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-color) 1px, transparent 1px);
  background-size: 20px 20px;
}

.cover-title {
  font-size: 1.7rem;
  line-height: 1.05;
  letter-spacing: -0.01em;
}

.cover-sub {
  font-size: 1rem;
  line-height: 1.25;
  color: var(--muted);
  max-width: 30ch;
}

/* A row of units, some of them erased: the idea of the paper, not data from it. */
.cover-nodes {
  position: absolute;
  top: 16px;
  right: 18px;
  display: flex;
  gap: 5px;
}

.cover-nodes i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--foreground);
  opacity: 0.75;
}

.cover-nodes i.erased {
  background-color: transparent;
  border: 1px dashed var(--muted);
  opacity: 1;
}

.cover-diagram {
  justify-content: center;
  align-items: center;
  gap: 14px;
  padding-top: 40px;
}

.cover-flow {
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 8px;
  width: 100%;
}

.cover-node {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  flex: 1 1 0;
  max-width: 108px;
  padding: 10px 8px;
  font-size: 0.7rem;
  line-height: 1.3;
  border: 1px dashed var(--muted);
  border-radius: 8px;
  background-color: var(--background);
}

.cover-arrow {
  display: flex;
  align-items: center;
  color: var(--muted);
  font-size: 0.9rem;
}

.cover-caption {
  font-size: 0.7rem;
  color: var(--muted);
  text-align: center;
}

/* Keyboard focus: one visible ring everywhere */
:focus-visible {
  outline: 2px solid var(--foreground);
  outline-offset: 3px;
  border-radius: 4px;
}

/* These sit inside clipped cards, so the ring is drawn inside the edge */
.project-banner-link:focus-visible,
.accordion-header:focus-visible,
.writing-header-clickable:focus-visible {
  outline-offset: -3px;
  border-radius: 10px;
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 1000;
  padding: 8px 12px;
  border-radius: 6px;
  background-color: var(--foreground);
  color: var(--background);
  transform: translateY(-200%);
}

.skip-link:focus-visible {
  transform: translateY(0);
}

/* Respect the "reduce motion" system setting */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
