html,
body {
  margin: 0;
  overflow-x: hidden;
  background-color: #dce2e8;
  /* Matches 3D Scene Background */
  /* Hide Scrollbar */
  scrollbar-width: none;
  /* Firefox */
  -ms-overflow-style: none;
  /* IE/Edge */
  transition: background-color 0.3s ease;
}

/* Dark mode body */
/* Support both html.dark-mode and body.dark-mode for immediate theme application */
html.dark-mode body,
body.dark-mode {
  background-color: #0a0a0a;
}

canvas {
  display: block;
}

body::-webkit-scrollbar {
  display: none;
  /* Chrome/Safari */
}

/* ... existing text styles ... */

/* Scroll Indicator (Left Side) */
/* Scroll Indicator (Left Side) */
#scroll-wrapper {
  position: fixed;
  left: 30px;
  top: 50%;
  transform: translateY(-50%);
  height: 40vh;
  width: 24px;
  /* Pill shape container */
  z-index: 20;
  display: flex;
  justify-content: center;
  /* User Request: Background white with rounded corners */
  background-color: white;
  border-radius: 20px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05), 0 0 0 1px rgba(65, 184, 255, 0.3), 0 0 20px rgba(65, 184, 255, 0.2);
  /* Padding to ensure thumb stays inside */
  padding: 15px 0;
  box-sizing: border-box;
  transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

/* Dark mode scroll wrapper */
body.dark-mode #scroll-wrapper {
  background-color: #1a1a1a;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.25), 0 0 20px rgba(255, 255, 255, 0.1);
}

/* Background Track (Empty) */
#scroll-track {
  position: absolute;
  top: 15px;
  /* Match padding */
  bottom: 15px;
  /* Match padding */
  width: 2px;
  background-color: transparent;
  /* Text hidden as per request */
  /* border-radius: 2px; */
}

/* Filled Progress Bar */
#scroll-progress {
  position: absolute;
  top: 15px;
  /* Start inside padding */
  width: 2px;
  /* Same as track */
  background-color: #999;
  /* Solid Black -> Grey */
  height: 0%;
  /* Driven by JS */
  max-height: calc(100% - 30px);
  /* Constrain to padded area */
  border-radius: 2px;
  transition: background-color 0.3s ease;
}

/* Dark mode scroll progress */
body.dark-mode #scroll-progress {
  background-color: #666;
}

/* Thumb (Leading Edge) */
#scroll-thumb {
  position: absolute;
  bottom: 0;
  /* Sticks to the end of progress bar */
  left: 50%;
  transform: translate(-50%, 50%);
  /* Center on the tip */
  width: 10px;
  height: 10px;
  background-color: #999;
  /* Solid Black -> Grey */
  border-radius: 50%;
  box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);
  z-index: 2;
  transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

/* Dark mode scroll thumb */
body.dark-mode #scroll-thumb {
  background-color: #666;
  box-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
}

#loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 200px;
  /* Doubled size */
  height: 200px;
  /* Doubled size */
  pointer-events: none;
  transition: opacity 0.5s ease;
  z-index: 1000;
  display: flex;
  justify-content: center;
  align-items: center;
}

#loading-text {
  position: absolute;
  font-family: 'Inter', sans-serif;
  font-size: 24px;
  /* Bigger text */
  font-weight: 700;
  color: white;
}

/* Text Overlays - Hidden until loaded */
#text-container {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 60%;
  text-align: center;
  pointer-events: none;
  z-index: 10;
  opacity: 0;
  /* Hidden initially */
  transition: opacity 1.0s ease;
}

body.loaded #text-container {
  opacity: 1;
  /* Fade in when loaded */
}

.loader-svg {
  transform: rotate(-90deg);
  /* Start from top */
}

.loader-progress-ring {
  stroke-dasharray: 565;
  /* 2 * PI * 45 ≈ 282.7 */
  stroke-dashoffset: 565;
  /* Start empty */
  transition: stroke-dashoffset 0.3s ease;
  stroke-linecap: round;
}

#loading.hidden {
  opacity: 0;
}

/* Name Container - Centered Left */
#name-container {
  position: absolute;
  top: 50%;
  left: 10%;
  transform: translateY(-50%);
  pointer-events: none;
  z-index: 10;
  opacity: 1;
  transition: box-shadow 0.3s ease, background-color 0.3s ease, border 0.3s ease;
  padding: 20px 30px;
  border-radius: 12px;
}

/* Dark mode name container glow */
body.dark-mode #name-container {
  background-color: rgba(26, 26, 26, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 0 20px rgba(255, 255, 255, 0.15), 0 0 40px rgba(255, 255, 255, 0.05);
}

#name {
  font-family: 'Poppins', sans-serif;
  font-size: 4.5rem;
  font-weight: 300;
  color: white;
  margin: 0;
  line-height: 1.2;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
  letter-spacing: -0.02em;
}

#title {
  font-family: 'Poppins', sans-serif;
  font-size: 1.8rem;
  font-weight: 700;
  color: white;
  margin: 0.5rem 0 0 0;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
  letter-spacing: 0.05em;
}

#text-container {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 60%;
  /* Narrower to make left/right more pronounced */
  text-align: center;
  pointer-events: none;
  z-index: 10;
}

.overlay-text {
  font-family: 'Playfair Display', serif;
  font-style: italic;
  font-size: 4.5rem;
  /* Increased from 3rem */
  font-weight: 400;
  color: white;
  opacity: 0;
  position: absolute;
  width: 100%;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
  transition: opacity 0.5s ease;
  z-index: 20;
  /* Ensure on top */
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
  /* improved legibility over glow */
  /* REMOVED GLOW */
}

#line1 {
  /* text-align: left; Removed, using flex for internal align */
  transform: translate(-50%, -50%) translateX(-60%);
  display: flex;
  flex-direction: column;
  justify-content: center;
  width: 60%;
  /* Restrict width so "right" isn't off-screen */
}

#line1 .text-left {
  align-self: flex-start;
  text-align: left;
}

#line1 .text-right {
  align-self: flex-end;
  text-align: right;
}

#line2 {
  text-align: right;
  transform: translate(-50%, -50%) translateX(20%);
  /* Shift further right */
}

#line3 {
  text-align: center;
}

/* Legacy Navbar Styles Removed to prevent conflict with Morphing Dropdown */

/* -- PAGE LAYOUT UTILITIES -- */
.page-content {
  padding-top: 140px;
  /* Clear fixed navbar */
  max-width: 1200px;
  margin: 0 auto;
  padding-left: 20px;
  padding-right: 20px;
  min-height: 100vh;
}

/* Typography */
h1.page-title {
  font-family: 'Inter', sans-serif;
  font-size: 3.5rem;
  font-weight: 800;
  margin-bottom: 1.5rem;
  letter-spacing: -0.02em;
  color: #1a1a1a;
}

body.dark-mode h1.page-title {
  color: #ffffff;
}

h2.section-title {
  font-family: 'Inter', sans-serif;
  font-size: 2.2rem;
  font-weight: 700;
  margin-top: 4rem;
  margin-bottom: 2rem;
  border-bottom: 2px solid #e0e0e0;
  padding-bottom: 10px;
  color: #222;
}

p.lead {
  font-family: 'Inter', sans-serif;
  font-size: 1.35rem;
  color: #555;
  line-height: 1.7;
  max-width: 800px;
  margin-bottom: 3rem;
  font-weight: 300;
}

body.dark-mode p.lead {
  color: #aaa;
}

p {
  font-family: 'Inter', sans-serif;
  line-height: 1.6;
  margin-bottom: 1rem;
  color: #333;
}

/* -- GRID LAYOUTS -- */
.grid-layout {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 40px;
  margin-bottom: 60px;
}

/* Card Style */
.card {
  background: white;
  border-radius: 20px;
  padding: 30px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
  transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.3s ease;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  color: inherit;
  border: 1px solid rgba(0, 0, 0, 0.02);
}

.card:hover {
  transform: translateY(-8px);
  box-shadow: 0 15px 30px rgba(0, 0, 0, 0.08);
}

.card-title {
  font-family: 'Inter', sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0 0 10px 0;
  color: #1a1a1a;
}

.card-meta {
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  color: #888;
  margin-bottom: 15px;
  display: block;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

.card-excerpt {
  font-family: 'Inter', sans-serif;
  font-size: 1rem;
  color: #666;
  flex-grow: 1;
  line-height: 1.6;
}

.card-tag {
  display: inline-block;
  background: #f4f4f4;
  padding: 6px 12px;
  border-radius: 20px;
  font-family: 'Inter', sans-serif;
  font-size: 0.75rem;
  font-weight: 700;
  margin-top: 20px;
  align-self: flex-start;
  color: #555;
  transition: background 0.2s, color 0.2s;
}

.card:hover .card-tag {
  background: #1a1a1a;
  color: white;
}

/* -- TIMELINE -- */
.timeline-item {
  padding: 20px 30px;
  border-left: 3px solid #e0e0e0;
  margin-left: 20px;
  position: relative;
  padding-bottom: 50px;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: -10px;
  top: 28px;
  width: 16px;
  height: 16px;
  background: white;
  border: 4px solid #1a1a1a;
  border-radius: 50%;
}

.timeline-date {
  font-family: 'Inter', sans-serif;
  font-weight: 700;
  color: #0077ff;
  margin-bottom: 5px;
  display: block;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.timeline-section-subtitle {
  font-family: 'Inter', sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  margin-top: 3rem;
  margin-bottom: 1.5rem;
  margin-left: 20px;
  color: #222;
}

/* Filter Buttons */
.filter-bar {
  display: flex;
  gap: 15px;
  margin-bottom: 40px;
}

.btn-filter {
  background: white;
  border: 1px solid #e0e0e0;
  padding: 10px 24px;
  border-radius: 30px;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 0.95rem;
  transition: all 0.2s ease;
  color: #555;
}

.btn-filter:hover,
.btn-filter.active {
  background: #1a1a1a;
  color: white;
  border-color: #1a1a1a;
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}


/* -- BLOG ARTICLE STYLES (Medium-esque) -- */
.article-container {
  max-width: 740px;
  margin: 0 auto;
  padding-top: 140px;
  /* Clear fixed navbar */
  padding-bottom: 100px;
  font-family: 'Georgia', serif;
  /* Use serif for body text readability */
  color: #292929;
}

.back-link {
  display: inline-block;
  margin-bottom: 40px;
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  color: #666;
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s;
}

.back-link:hover {
  color: #000;
}

/* Header */
.article-header {
  margin-bottom: 40px;
}

.article-title {
  font-family: 'Inter', sans-serif;
  font-size: 3rem;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 15px;
  color: #1a1a1a;
  letter-spacing: -0.02em;
}

.article-subtitle {
  font-family: 'Inter', sans-serif;
  font-size: 1.5rem;
  font-weight: 400;
  line-height: 1.4;
  color: #757575;
  margin-bottom: 30px;
}

.article-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid #eee;
  padding-top: 20px;
  font-family: 'Inter', sans-serif;
  font-size: 0.95rem;
}

.author-name {
  font-weight: 600;
  color: #1a1a1a;
  margin-right: 10px;
}

.meta-date {
  color: #757575;
}

.meta-right {
  display: flex;
  gap: 15px;
}

.meta-link {
  color: #1a1a1a;
  text-decoration: none;
  border-bottom: 1px solid #ccc;
  transition: border-color 0.2s;
}

.meta-link:hover {
  border-color: #000;
}

/* Article Body */
.article-body p {
  font-family: 'Georgia', 'Cambria', serif;
  font-size: 1.25rem;
  line-height: 1.6;
  margin-bottom: 2rem;
  color: #292929;
}

.article-body h3 {
  font-family: 'Inter', sans-serif;
  font-size: 1.75rem;
  font-weight: 700;
  margin-top: 3rem;
  margin-bottom: 1rem;
  color: #1a1a1a;
}

.article-body pre {
  background: #f4f4f4;
  padding: 20px;
  border-radius: 5px;
  overflow-x: auto;
  margin-bottom: 2rem;
  font-family: 'Courier New', monospace;
  font-size: 0.95rem;
}

strong {
  font-weight: 700;
}

.article-divider {
  border: 0;
  height: 1px;
  background: #eee;
  margin: 60px auto;
  width: 100px;
}

.article-sources h4 {
  font-family: 'Inter', sans-serif;
  font-size: 1.2rem;
  margin-bottom: 15px;
}

.source-list {
  padding-left: 20px;
}

.source-list li {
  margin-bottom: 10px;
  font-family: 'Georgia', serif;
}

.source-list a {
  color: #0077ff;
  text-decoration: none;
}

/* ========================================= */
/* MORPHING DROPDOWN NAVIGATION STYLES       */
/* ========================================= */

.morph-dropdown {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  width: auto;
  height: 60px;
  /* Base height for trigger area */
  z-index: 1000;
  transition: transform 0.3s ease;
}

.morph-dropdown.nav-hidden {
  transform: translate(-50%, -150%);
}

/* The visual "Pill" */
.nav-container {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-radius: 50px;
  padding: 0 40px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05), 0 0 0 1px rgba(65, 184, 255, 0.3), 0 0 20px rgba(65, 184, 255, 0.2);
  height: 60px;
  display: flex;
  align-items: center;
  position: relative;
  z-index: 2;
  /* Sits above the morphing bg-layer */
  transition: background 0.3s ease, box-shadow 0.3s ease;
}

/* Dark mode navbar */
body.dark-mode .nav-container {
  background: rgba(26, 26, 26, 0.95);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.25), 0 0 20px rgba(255, 255, 255, 0.1);
}

.main-nav ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  gap: 30px;
  align-items: center;
  height: 100%;
}

.nav-link {
  text-decoration: none;
  color: #555;
  font-weight: 500;
  font-family: 'Inter', sans-serif;
  font-size: 0.95rem;
  transition: all 0.3s ease;
  cursor: pointer;
  display: block;
  /* line-height: 60px; Removed for explicit padding */
  padding: 8px 16px;
  border-radius: 30px;
  position: relative;
  z-index: 5;
  /* Above the slider */
}

.nav-link:hover {
  color: #000;
}

/* Dark mode nav links */
body.dark-mode .nav-link {
  color: #ccc;
}

body.dark-mode .nav-link:hover {
  color: #fff;
}

/* Active / Current State: Text Color Only */
/* Only make text white if it really IS active (has the slider) */
.nav-item.active .nav-link,
.nav-link.active {
  color: white;
  /* background-color: #1a1a1a; Handled by Slider */
  font-weight: 500;
}

/* Dark mode active link */
body.dark-mode .nav-item.active .nav-link,
body.dark-mode .nav-link.active {
  color: #1a1a1a;
}

/* Sliding Background Pill */
#nav-active-background {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  /* Will be set by JS via rect */
  background-color: #1a1a1a;
  border-radius: 30px;
  /* Match nav-link radius */
  z-index: 1;
  /* Behind text */
  transition: all 0.4s cubic-bezier(0.25, 1, 0.5, 1);
  /* Smooth spring-like ease */
  opacity: 0;
  pointer-events: none;
}

/* Dark mode active background */
body.dark-mode #nav-active-background {
  background-color: #ffffff;
}

/* Wrapper that holds all dropdown content & background */
.morph-dropdown-wrapper {
  /* display: none; Replaced with visibility for JS measuring */
  visibility: hidden;
  opacity: 0;
  pointer-events: none;

  position: absolute;
  top: 70px;
  /* Offset from top of .morph-dropdown */
  left: 0;
  width: auto;
  padding: 0;
  overflow: visible;
  /* Allow border to render fully outside the wrapper */

  transform: translateZ(0);
  /* Hardware accelerate */
  will-change: transform, width, height;
  perspective: 1000px;
  transition: opacity 0.3s ease;
}

.morph-dropdown.is-dropdown-visible .morph-dropdown-wrapper {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
}

/* The Animated White Background */
.bg-layer {
  position: absolute;
  top: 0;
  left: 0;
  background: #FFFFFF;
  border-radius: 24px;
  /* Increased rounding */
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
  border: 1px solid rgba(0, 0, 0, 0.1);
  z-index: 1;
  /* Behind content */
  overflow: hidden;
  /* Prevent content overflow */
  box-sizing: border-box;
  /* Include border in width/height calculations */

  width: 1px;
  height: 1px;
  opacity: 0;

  transform-origin: top left;
  /* We animate translateX on this or its wrapper */
  transition: opacity 0.2s, width 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94), height 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94), transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94), background 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease, border-width 0.3s ease;
}

/* Dark mode dropdown background */
body.dark-mode .bg-layer {
  background: #1a1a1a;
  border: 1px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5), 0 0 20px rgba(255, 255, 255, 0.1);
}

.morph-dropdown.is-dropdown-visible .bg-layer {
  opacity: 1;
}

/* List that holds individual dropdowns - Moves with the background */
.dropdown-list {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  /* Will be set match bg-layer width by JS */
  height: 100%;
  overflow: hidden;
  /* Keep content within rounded corners */
  border-radius: 24px;
  /* Match bg-layer border radius to prevent black corners */
  box-sizing: border-box;

  transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94), width 0.3s, height 0.3s;
}

.dropdown-list>ul {
  list-style: none;
  padding: 0;
  margin: 0;
  position: relative;
  z-index: 10;
  /* Keep content above bg-layer */
}

/* Individual Dropdown Sections */
.dropdown-list .dropdown {
  position: absolute;
  left: 0;
  top: 0;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  /* Prevent clicks on inactive dropdowns */
  /* width: 100%; REMOVED to allow proper measurement of content */
  width: auto;
  min-width: 100%;

  /* Fade Transition */
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.dropdown-list .dropdown.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  /* Allow clicks only on active dropdown */
}

/* Content Styling (Mega Menu) */
.content {
  padding: 20px;
  /* Allows content to define width */
  background: transparent;
  /* Ensure transparent background to show bg-layer */
}

.dropdown-menu.wide {
  /* Reset old absolute styles */
  position: static;
  transform: none;
  background: transparent;
  box-shadow: none;
  padding: 0;
  opacity: 1;
  visibility: visible;

  /* Grid Layout */
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
  min-width: 650px;
  /* Increased from 500px */
  list-style: none;
  margin: 0;
}

/* Link Items inside Dropdown */
.dropdown-link-rich {
  display: flex;
  align-items: flex-start;
  /* Align icon with top of text */
  text-decoration: none;
  padding: 10px;
  border-radius: 12px;
  transition: background-color 0.2s ease;
}

.dropdown-link-rich:hover {
  background-color: #f5f7f9;
}

/* Dark mode dropdown links */
body.dark-mode .dropdown-link-rich:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.dd-icon-box {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  flex-shrink: 0;
  margin-right: 12px;
  /* Color defined inline in HTML */
}

.dd-text-group {
  display: flex;
  flex-direction: column;
}

.dd-title {
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 0.95rem;
  color: #333;
  margin-bottom: 2px;
  white-space: nowrap;
  /* Prevent wrapping */
  transition: color 0.3s ease;
}

body.dark-mode .dd-title {
  color: #e0e0e0;
}

.dd-desc {
  font-family: 'Inter', sans-serif;
  font-size: 0.8rem;
  color: #777;
  line-height: 1.3;
  transition: color 0.3s ease;
}

body.dark-mode .dd-desc {
  color: #aaa;
}

/* Head Model Fade In */
/* Head Model Fade In handled by JS based on scroll */
#canvas {
  opacity: 0;
  transition: opacity 0.5s ease;
}

/* Theme Toggle Button - Desktop: Top Right Corner */
/* Mobile styles are defined in the mobile media query below */
.theme-toggle {
  position: fixed;
  top: 20px;
  right: 30px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border: none;
  cursor: pointer;
  padding: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  transition: background-color 0.3s ease, box-shadow 0.3s ease, transform 0.2s ease;
  z-index: 1001;
}

.theme-toggle:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}

.theme-toggle:active {
  transform: scale(0.95);
}

body.dark-mode .theme-toggle {
  background: rgba(26, 26, 26, 0.95);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

body.dark-mode .theme-toggle:hover {
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.5);
}

/* Ensure desktop positioning - override any parent positioning */
@media (min-width: 769px) {
  .theme-toggle {
    position: fixed !important;
    top: 20px !important;
    right: 30px !important;
    transform: none !important;
    width: 44px !important;
    height: 44px !important;
    padding: 10px !important;
    background: rgba(255, 255, 255, 0.95) !important;
    backdrop-filter: blur(10px) !important;
    border: none !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1) !important;
    border-radius: 50% !important;
  }

  .theme-toggle:hover {
    transform: scale(1.05) !important;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15) !important;
  }

  body.dark-mode .theme-toggle {
    background: rgba(26, 26, 26, 0.95) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3) !important;
  }

  body.dark-mode .theme-toggle:hover {
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.5) !important;
  }
}

.theme-icon {
  width: 20px;
  height: 20px;
  stroke: #555;
  transition: stroke 0.3s ease, transform 0.3s ease;
}

body.dark-mode .theme-icon {
  stroke: #ccc;
}

.theme-icon.moon-icon {
  display: none;
}

body.dark-mode .theme-icon.sun-icon {
  display: none;
}

body.dark-mode .theme-icon.moon-icon {
  display: block;
}

/* Intro Card at Bottom */
#intro-card {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%) translateZ(0);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-radius: 50px 50px 0 0;
  padding: 50px 80px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05), 0 0 0 1px rgba(65, 184, 255, 0.3), 0 0 20px rgba(65, 184, 255, 0.2);
  z-index: 100;
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s ease;
  pointer-events: auto;
  width: 70%;
  max-width: 900px;
  min-width: 500px;
  max-height: auto;
  height: auto;
  overflow: visible;
  will-change: transform, opacity;
}

/* Dark mode intro card */
body.dark-mode #intro-card {
  background: rgba(26, 26, 26, 0.95);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.25), 0 0 20px rgba(255, 255, 255, 0.1);
}

#intro-card.hidden {
  transform: translateX(-50%) translateY(150%) translateZ(0);
  opacity: 0;
}

#intro-card.expanded {
  transform: translateX(-50%) translateY(0) translateZ(0);
  max-height: none;
  border-radius: 50px 50px 0 0;
  will-change: transform, max-height;
  overflow: visible;
}

.intro-card-content {
  text-align: left;
}

.intro-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
}

.intro-card-button {
  background: transparent;
  border: 2px solid #1a1a1a;
  border-radius: 50%;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  flex-shrink: 0;
  padding: 0;
}

.intro-card-button:hover {
  background: #1a1a1a;
  transform: scale(1.1);
}

.intro-card-button:hover .toggle-icon {
  stroke: white;
}

body.dark-mode .intro-card-button {
  border-color: #e0e0e0;
}

body.dark-mode .intro-card-button:hover {
  background: #e0e0e0;
}

body.dark-mode .intro-card-button:hover .toggle-icon {
  stroke: #1a1a1a;
}

.toggle-icon {
  width: 24px;
  height: 24px;
  stroke: #1a1a1a;
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), stroke 0.3s ease;
  will-change: transform;
}

body.dark-mode .toggle-icon {
  stroke: #e0e0e0;
}

#intro-card.expanded .toggle-icon {
  transform: rotate(180deg);
}

.intro-card-expanded {
  height: 0;
  overflow: hidden;
  opacity: 0;
  transition: height 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.35s cubic-bezier(0.4, 0, 0.2, 1) 0.05s, margin-top 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  margin-top: 0;
  will-change: height, opacity, margin-top;
  contain: layout style paint;
  transform: translateZ(0);
}

#intro-card.expanded .intro-card-expanded {
  opacity: 1;
  margin-top: 30px;
  will-change: height, opacity, margin-top;
  overflow: visible;
}

.about-content {
  padding-bottom: 20px;
}

.about-text {
  font-family: 'Inter', sans-serif;
  font-size: 1.1rem;
  line-height: 1.7;
  color: #555;
  margin-bottom: 30px;
}

body.dark-mode .about-text {
  color: #ccc;
}

.about-details {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 30px;
}

.about-section {
  margin-bottom: 20px;
}

.about-section-title {
  font-family: 'Inter', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  color: #1a1a1a;
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

body.dark-mode .about-section-title {
  color: #e0e0e0;
}

.about-section-text {
  font-family: 'Inter', sans-serif;
  font-size: 0.95rem;
  line-height: 1.6;
  color: #666;
}

body.dark-mode .about-section-text {
  color: #aaa;
}

.cv-link-text {
  font-family: 'Inter', sans-serif;
  font-size: 0.95rem;
  line-height: 1.6;
  color: #666;
  margin-top: 30px;
  padding-top: 20px;
  border-top: 1px solid rgba(0, 0, 0, 0.1);
}

body.dark-mode .cv-link-text {
  color: #aaa;
  border-top-color: rgba(255, 255, 255, 0.1);
}

.cv-link {
  color: #1a1a1a;
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
  transition: color 0.2s ease;
  font-weight: 500;
}

.cv-link:hover {
  color: #0077ff;
}

body.dark-mode .cv-link {
  color: #e0e0e0;
}

body.dark-mode .cv-link:hover {
  color: #4da6ff;
}

.intro-name {
  font-family: 'Inter', sans-serif;
  font-size: 3.5rem;
  font-weight: 600;
  color: #1a1a1a;
  margin: 0;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

body.dark-mode .intro-name {
  color: #e0e0e0;
}

.intro-title {
  font-family: 'Inter', sans-serif;
  font-size: 1.8rem;
  font-weight: 400;
  color: #1a1a1a;
  margin: 0.5rem 0 0 0;
  letter-spacing: 0.05em;
}

body.dark-mode .intro-title {
  color: #e0e0e0;
}

.intro-date {
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  font-weight: 400;
  color: #888;
  margin: 0.5rem 0 0 0;
  letter-spacing: 0.02em;
}

body.dark-mode .intro-date {
  color: #999;
}

/* ========================================= */
/* PROJECT PAGES STYLES (Medium-esque)      */
/* ========================================= */

/* Project Filters */
/* Project Controls Container */
.project-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin-bottom: 40px;
  padding-bottom: 20px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

body.dark-mode .project-controls {
  border-bottom-color: rgba(255, 255, 255, 0.1);
}

.project-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

/* Project Sort Dropdown */
.project-sort {
  display: flex;
  align-items: center;
  gap: 10px;
}

.project-sort label {
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  color: #666;
  font-weight: 500;
}

body.dark-mode .project-sort label {
  color: #aaa;
}

.sort-select {
  padding: 10px 35px 10px 15px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  background: white;
  border-radius: 25px;
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  font-weight: 500;
  color: #666;
  cursor: pointer;
  transition: all 0.3s ease;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

.sort-select:hover {
  border-color: rgba(0, 0, 0, 0.2);
  background-color: #f8f8f8;
}

.sort-select:focus {
  border-color: #45B7D1;
  box-shadow: 0 0 0 3px rgba(69, 183, 209, 0.1);
}

body.dark-mode .sort-select {
  background-color: #2a2a2a;
  border-color: rgba(255, 255, 255, 0.1);
  color: #ccc;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23ccc' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}

body.dark-mode .sort-select:hover {
  border-color: rgba(255, 255, 255, 0.2);
  background-color: #333;
}

body.dark-mode .sort-select:focus {
  border-color: #45B7D1;
  box-shadow: 0 0 0 3px rgba(69, 183, 209, 0.2);
}

body.dark-mode .sort-select option {
  background-color: #2a2a2a;
  color: #ccc;
}

.filter-btn {
  padding: 10px 20px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  background: white;
  border-radius: 25px;
  font-family: 'Inter', sans-serif;
  font-size: 0.95rem;
  font-weight: 500;
  color: #666;
  cursor: pointer;
  transition: all 0.3s ease;
  outline: none;
}

.filter-btn:hover {
  background: #f5f5f5;
  border-color: rgba(0, 0, 0, 0.15);
  color: #333;
  transform: translateY(-1px);
}

.filter-btn.active {
  background: #1a1a1a;
  color: white;
  border-color: #1a1a1a;
  font-weight: 600;
}

.filter-btn.active:hover {
  background: #333;
  border-color: #333;
  color: white;
}

body.dark-mode .filter-btn {
  background: #1a1a1a;
  border-color: rgba(255, 255, 255, 0.1);
  color: #aaa;
}

body.dark-mode .filter-btn:hover {
  background: #2a2a2a;
  border-color: rgba(255, 255, 255, 0.2);
  color: #e0e0e0;
}

body.dark-mode .filter-btn.active {
  background: #e0e0e0;
  color: #1a1a1a;
  border-color: #e0e0e0;
}

body.dark-mode .filter-btn.active:hover {
  background: #f0f0f0;
  border-color: #f0f0f0;
  color: #1a1a1a;
}

/* Projects Grid */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 30px;
  margin-bottom: 60px;
}

.project-card {
  background: white;
  border-radius: 12px;
  padding: 35px;
  padding-bottom: 45px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.3s ease, opacity 0.3s ease;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  color: inherit;
  border: 1px solid rgba(0, 0, 0, 0.05);
  opacity: 1;
  transform: scale(1);
}

.project-card-image {
  width: 100%;
  max-width: 100%;
  max-height: 250px;
  height: auto;
  object-fit: cover;
  border-radius: 8px;
  margin-top: 15px;
  display: block;
}

.project-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.1);
}

.project-card-title {
  font-family: 'Inter', sans-serif;
  font-size: 1.6rem;
  font-weight: 700;
  margin: 0 0 12px 0;
  color: #1a1a1a;
  line-height: 1.3;
}

.project-card-excerpt {
  font-family: 'Inter', sans-serif;
  font-size: 1rem;
  color: #666;
  flex-grow: 1;
  line-height: 1.6;
  margin-bottom: 20px;
}

.project-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: auto;
  margin-bottom: 0;
}

.project-tag {
  display: inline-block;
  background: #f4f4f4;
  padding: 6px 14px;
  border-radius: 20px;
  font-family: 'Inter', sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  color: #555;
  transition: background 0.2s, color 0.2s;
}

.project-card:hover .project-tag {
  background: #e8e8e8;
}

/* Dark mode project cards */
body.dark-mode .project-card {
  background: #1a1a1a;
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

body.dark-mode .project-card:hover {
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.5);
}

body.dark-mode .project-card-title {
  color: #e0e0e0;
}

body.dark-mode .project-card-excerpt {
  color: #aaa;
}

body.dark-mode .project-tag {
  background: #2a2a2a;
  color: #ccc;
}

body.dark-mode .project-card:hover .project-tag {
  background: #333;
}

/* Project Article Page Styles */
.project-article {
  margin-top: 40px;
}

.project-header {
  margin-bottom: 50px;
  padding-bottom: 30px;
  border-bottom: 1px solid #eee;
}

body.dark-mode .project-header {
  border-bottom-color: rgba(255, 255, 255, 0.1);
}

.project-title {
  font-family: 'Inter', sans-serif;
  font-size: 3.5rem;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 10px;
  color: #1a1a1a;
  letter-spacing: -0.02em;
}

body.dark-mode .project-title {
  color: #e0e0e0;
}

.project-date {
  font-family: 'Inter', sans-serif;
  font-size: 1rem;
  color: #666;
  margin-bottom: 30px;
  font-weight: 400;
}

body.dark-mode .project-date {
  color: #aaa;
}

.project-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px;
}

.project-links {
  display: flex;
  gap: 20px;
  align-items: center;
}

.project-link {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #1a1a1a;
  text-decoration: none;
  font-family: 'Inter', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 10px 18px;
  border: 2px solid #1a1a1a;
  border-radius: 8px;
  transition: all 0.2s ease;
}

.project-link:hover {
  background: #1a1a1a;
  color: white;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

body.dark-mode .project-link {
  color: #e0e0e0;
  border-color: #e0e0e0;
}

body.dark-mode .project-link:hover {
  background: #e0e0e0;
  color: #1a1a1a;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.project-link svg {
  stroke: currentColor;
}

.project-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.project-article .article-body {
  margin-top: 40px;
}

.project-article .article-body h2 {
  font-family: 'Inter', sans-serif;
  font-size: 2rem;
  font-weight: 700;
  margin-top: 3rem;
  margin-bottom: 1.5rem;
  color: #1a1a1a;
  padding-top: 2rem;
  border-top: 1px solid #eee;
}

body.dark-mode .project-article .article-body h2 {
  color: #e0e0e0;
  border-top-color: rgba(255, 255, 255, 0.1);
}

.project-article .article-body h2:first-of-type {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.project-article .article-body p {
  font-family: 'Georgia', 'Cambria', serif;
  font-size: 1.25rem;
  line-height: 1.8;
  margin-bottom: 2rem;
  color: #292929;
}

body.dark-mode .project-article .article-body p {
  color: #ccc;
}

.project-article .article-body img {
  width: 100%;
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  margin: 2rem 0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

body.dark-mode .project-article .article-body img {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

/* ========================================= */
/* MOBILE RESPONSIVE STYLES                  */
/* ========================================= */

@media (max-width: 768px) {
  /* Navigation adjustments */
  .morph-dropdown {
    top: 10px;
    width: calc(100% - 20px);
    left: 10px;
    transform: none;
  }

  .morph-dropdown.nav-hidden {
    transform: translateY(-150%);
  }

  .nav-container {
    padding: 0 20px;
    padding-right: 60px; /* Add space for theme toggle on the right */
    width: 100%;
    box-sizing: border-box;
    position: relative; /* Ensure relative positioning for absolute children */
  }

  .main-nav ul {
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
  }

  .nav-link {
    font-size: 0.85rem;
    padding: 6px 12px;
  }

  /* Theme toggle button - inside navbar on the right on mobile */
  .theme-toggle {
    position: absolute !important;
    top: 50% !important;
    right: 12px !important;
    transform: translateY(-50%) !important;
    width: 36px !important;
    height: 36px !important;
    padding: 8px !important;
    background: transparent !important;
    backdrop-filter: none !important;
    box-shadow: 0 0 0 1px rgba(65, 184, 255, 0.3), 0 0 15px rgba(65, 184, 255, 0.2) !important;
    border: 1px solid rgba(65, 184, 255, 0.3) !important;
    border-radius: 50% !important;
  }

  body.dark-mode .theme-toggle {
    border-color: rgba(255, 255, 255, 0.2) !important;
    background: transparent !important;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.2), 0 0 15px rgba(255, 255, 255, 0.1) !important;
  }

  .theme-toggle:hover {
    transform: translateY(-50%) scale(1.05) !important;
    background: rgba(0, 0, 0, 0.05) !important;
    box-shadow: 0 0 0 1px rgba(65, 184, 255, 0.4), 0 0 20px rgba(65, 184, 255, 0.3) !important;
  }

  body.dark-mode .theme-toggle:hover {
    background: rgba(255, 255, 255, 0.1) !important;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.3), 0 0 20px rgba(255, 255, 255, 0.15) !important;
  }

  /* Scroll indicator - hide on mobile or make smaller */
  #scroll-wrapper {
    left: 10px;
    width: 16px;
    height: 30vh;
    padding: 10px 0;
  }

  /* Intro card - full width on mobile */
  #intro-card {
    width: 100%;
    left: 0;
    transform: none;
    padding: 25px 15px;
    border-radius: 30px 30px 0 0;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
    z-index: 1001; /* Above navbar which is 1000 */
  }

  #intro-card.hidden {
    transform: translateY(150%);
  }

  #intro-card.expanded {
    transform: translateY(0);
    top: 0;
    bottom: 0;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
    padding-top: 80px; /* Add padding to account for navbar area */
    will-change: transform, height;
  }

  .intro-card-header {
    flex-direction: row;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
    width: 100%;
  }

  .intro-card-header > div {
    flex: 1;
    min-width: 0; /* Allow text to shrink */
  }

  .intro-card-button {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
  }

  .intro-name {
    font-size: 2rem;
    line-height: 1.2;
    word-wrap: break-word;
  }

  .intro-title {
    font-size: 1.2rem;
    line-height: 1.3;
    word-wrap: break-word;
  }

  .about-details {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .about-text {
    font-size: 1rem;
  }

  /* CV link text - add extra white space on mobile */
  .cv-link-text {
    margin-bottom: 40px;
  }

  /* Text overlays - adjust for mobile */
  .overlay-text {
    font-size: 2.5rem;
  }

  #name {
    font-size: 3rem;
  }

  #title {
    font-size: 1.4rem;
  }

  /* Dropdown menu adjustments */
  .dropdown-menu.wide {
    grid-template-columns: 1fr;
    min-width: 0;
    gap: 10px;
  }

  .dropdown-link-rich {
    padding: 12px;
  }

  /* Page content */
  .page-content {
    padding-top: 100px;
    padding-left: 15px;
    padding-right: 15px;
  }

  h1.page-title {
    font-size: 2.5rem;
  }

  h2.section-title {
    font-size: 1.8rem;
  }

  p.lead {
    font-size: 1.1rem;
  }

  /* Grid layouts */
  .grid-layout {
    grid-template-columns: 1fr;
    gap: 20px;
  }

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

  /* Cards */
  .card {
    padding: 20px;
  }

  .card-title {
    font-size: 1.3rem;
  }

  /* Article styles */
  .article-container {
    padding-top: 100px;
    /* Clear fixed navbar on mobile */
    padding-left: 15px;
    padding-right: 15px;
  }

  .article-title {
    font-size: 2.2rem;
  }

  .article-subtitle {
    font-size: 1.2rem;
  }

  .article-body p {
    font-size: 1.1rem;
  }

  /* Project cards */
  .project-card {
    padding: 25px;
  }

  .project-card-title {
    font-size: 1.4rem;
  }

  .project-filters {
    gap: 8px;
    margin-bottom: 30px;
    padding-bottom: 15px;
  }

  .filter-btn {
    padding: 8px 16px;
    font-size: 0.9rem;
  }

  .project-title {
    font-size: 2.5rem;
  }

  /* Filter bar */
  .filter-bar {
    flex-wrap: wrap;
    gap: 10px;
  }

  .btn-filter {
    padding: 8px 16px;
    font-size: 0.85rem;
  }
}

/* Tablet adjustments */
@media (min-width: 769px) and (max-width: 1024px) {
  #intro-card {
    width: 85%;
    padding: 35px 50px;
  }

  .intro-name {
    font-size: 3rem;
  }

  .overlay-text {
    font-size: 3.5rem;
  }

  .grid-layout {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  }

  .projects-grid {
    grid-template-columns: 1fr;
  }
}


/* Prevent text selection on mobile during interactions */
@media (max-width: 768px) {
  canvas {
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
  }

  /* Improve scrolling performance */
  body {
    -webkit-overflow-scrolling: touch;
  }
}