/* ================= THEME TOKENS ================= */
:root {
  --bg: #f6f8fc;
  --bg-alt: #edf1f8;
  --surface: #ffffff;
  --text: #0d1628;
  --text-muted: #58637a;
  --border: #dbe1ec;
  --accent: #1f5eff;
  --accent-soft: rgba(31, 94, 255, 0.1);
  --accent-2: #ff6b35;          /* "afterburner" orange */
  --hud: #0f9d78;               /* HUD green */
  --star: #8d9ab3;
  --shadow: 0 1px 2px rgba(13, 22, 40, 0.04), 0 8px 24px rgba(13, 22, 40, 0.06);
  --radius: 14px;
  --maxw: 1280px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --scroll-thumb: #b8c2d4;
  --scroll-thumb-hover: #97a3b9;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #060a14;
    --bg-alt: #0a1020;
    --surface: #0f182b;
    --text: #e6ecf7;
    --text-muted: #93a0b8;
    --border: #1d2840;
    --accent: #5b8cff;
    --accent-soft: rgba(91, 140, 255, 0.14);
    --accent-2: #ff8a5c;
    --hud: #3ee6a8;
    --star: #ffffff;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
    --scroll-thumb: #2a3654;
    --scroll-thumb-hover: #3d4d74;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #060a14;
  --bg-alt: #0a1020;
  --surface: #0f182b;
  --text: #e6ecf7;
  --text-muted: #93a0b8;
  --border: #1d2840;
  --accent: #5b8cff;
  --accent-soft: rgba(91, 140, 255, 0.14);
  --accent-2: #ff8a5c;
  --hud: #3ee6a8;
  --star: #ffffff;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
  --scroll-thumb: #2a3654;
  --scroll-thumb-hover: #3d4d74;
  color-scheme: dark;
}

/* ================= SCROLLBARS (follow the theme) ================= */
* { scrollbar-width: thin; scrollbar-color: var(--scroll-thumb) transparent; }
html { scrollbar-width: auto; scrollbar-color: var(--scroll-thumb) var(--bg); }
::-webkit-scrollbar { width: 12px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
html::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb {
  background: var(--scroll-thumb); border-radius: 999px;
  border: 3px solid transparent; background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--scroll-thumb-hover); background-clip: padding-box; }
::-webkit-scrollbar-corner, ::-webkit-scrollbar-button { display: none; background: transparent; }

/* ================= BASE ================= */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 72px; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
body.modal-open { overflow: hidden; }
img { max-width: 100%; display: block; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 0.5em; letter-spacing: -0.02em; }
h1 { font-size: clamp(2.4rem, 6vw, 4rem); font-weight: 700; }
h2 { font-size: clamp(1.8rem, 3.5vw, 2.5rem); font-weight: 700; margin-bottom: 0.9em; }
h3 { font-size: 1.1rem; font-weight: 600; }
p { margin: 0 0 1em; }
.mono { font-family: var(--mono); }
.muted { color: var(--text-muted); }
.accent { color: var(--accent); }

.container { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 16px; }
@media (min-width: 720px) { .container { padding: 0 32px; } }

/* ================= NAV ================= */
.nav {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(160%) blur(12px);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
  --progress: 0;
}
.nav-inner { display: flex; align-items: center; justify-content: space-between; height: 64px; gap: 16px; }
nav { margin-left: auto; }
.nav-links { list-style: none; display: flex; gap: 4px; margin: 0; padding: 0; }
.nav-links a {
  display: block; padding: 6px 12px; border-radius: 8px;
  color: var(--text-muted); font-size: 0.92rem; font-weight: 500;
}
.nav-links a:hover, .nav-links a.active { color: var(--text); background: var(--accent-soft); text-decoration: none; }

.theme-toggle {
  display: grid; place-items: center; width: 38px; height: 38px;
  border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); cursor: pointer;
}
.theme-toggle .icon-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: none; }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: block; }
}

.menu-toggle { display: none; }
@media (max-width: 860px) {
  .menu-toggle {
    display: flex; flex-direction: column; justify-content: center; gap: 5px;
    width: 38px; height: 38px; padding: 0 9px;
    background: none; border: 1px solid var(--border); border-radius: 10px; cursor: pointer;
  }
  .menu-toggle span { display: block; height: 2px; background: var(--text); border-radius: 2px; }
  .nav-links {
    position: absolute; top: 64px; left: 0; right: 0;
    flex-direction: column; gap: 0; padding: 8px 16px 16px;
    background: var(--bg); border-bottom: 1px solid var(--border);
    display: none;
  }
  .nav-links.open { display: flex; }
  .nav-links a { padding: 12px; }
}

/* Flight-path scroll progress */
.flight-progress {
  position: relative; height: 2px;
  background-image: linear-gradient(90deg, var(--border) 50%, transparent 50%);
  background-size: 10px 2px;
}
.contrail {
  position: absolute; left: 0; top: 0; height: 2px;
  width: calc(var(--progress) * 100%);
  background: linear-gradient(90deg, transparent, var(--accent) 70%, var(--accent-2));
}
.progress-marker {
  position: absolute; top: -3px; width: 8px; height: 8px; border-radius: 50%;
  left: calc(var(--progress) * (100% - 8px));
  background: var(--accent-2);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-2) 25%, transparent), 0 0 10px var(--accent-2);
}

/* Dark mode: the marker becomes a pale crescent moon */
:root[data-theme="dark"] .contrail { background: linear-gradient(90deg, transparent, var(--accent) 70%, #dfe6f5); }
:root[data-theme="dark"] .progress-marker {
  top: -5px; width: 12px; height: 12px;
  left: calc(var(--progress) * (100% - 12px));
  background: #f1f4fb;
  box-shadow: inset -3px 1px 0 0 #b9c3d8, 0 0 8px rgba(225, 232, 250, 0.7), 0 0 18px rgba(170, 190, 235, 0.35);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .contrail { background: linear-gradient(90deg, transparent, var(--accent) 70%, #dfe6f5); }
  :root:not([data-theme="light"]) .progress-marker {
    top: -5px; width: 12px; height: 12px;
    left: calc(var(--progress) * (100% - 12px));
    background: #f1f4fb;
    box-shadow: inset -3px 1px 0 0 #b9c3d8, 0 0 8px rgba(225, 232, 250, 0.7), 0 0 18px rgba(170, 190, 235, 0.35);
  }
}

/* ================= BUTTONS ================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 22px; border-radius: 10px; font-weight: 600; font-size: 0.95rem;
  border: 1px solid transparent; transition: transform 0.15s, background 0.2s, border-color 0.2s;
  cursor: pointer;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, #000); }
.btn-ghost { border-color: var(--border); color: var(--text); background: var(--surface); }
.btn-ghost:hover { border-color: var(--accent); }
.btn-lg { padding: 16px 28px; font-size: 1.05rem; }

/* ================= HERO ================= */
.hero { position: relative; padding: 72px 0 52px; overflow: hidden; }
/* Fixed page-wide starfield behind all content */
.starfield { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.stars { position: absolute; left: 0; top: 0; width: 100%; will-change: transform; }
.stars span {
  position: absolute; border-radius: 50%; background: var(--star);
  opacity: 0.25; animation: twinkle 3s ease-in-out infinite;
}
@keyframes twinkle { 50% { opacity: 0.9; } }

.hero-grid { position: relative; display: grid; gap: 40px; align-items: center; }
@media (min-width: 960px) {
  .hero-grid { grid-template-columns: minmax(0, 1.6fr) minmax(280px, 1fr); gap: 56px; align-items: start; }
  .hero-edu { margin-top: 46px; }
}
.hero-edu {
  width: fit-content; max-width: 100%; justify-self: center;
  padding: 24px 28px; border: 1px solid var(--border); border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 70%, transparent);
}
.hero-edu-title { font-size: 1.25rem; margin: 0 0 20px; }
.hero-edu .timeline { padding-left: 0; border-left: 0; }
.hero-edu .timeline li { padding-left: 0; padding-bottom: 26px; }
.hero-edu .timeline li::before { content: none; }
.hero-edu .timeline li:last-child { padding-bottom: 0; }
.hero-edu .timeline h3 { font-size: 1.05rem; }
.hero-edu .timeline .org { font-size: 0.92rem; }
.hero-edu .timeline p:last-child { margin-bottom: 0; }

.eyebrow {
  display: inline-block; font-size: 0.8rem; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--accent); background: var(--accent-soft); padding: 4px 10px; border-radius: 6px; margin-bottom: 20px;
}
.lead { font-size: 1.12rem; color: var(--text-muted); max-width: 600px; }



/* ================= SECTIONS ================= */
.section { padding: 68px 0; position: relative; }
@media (max-width: 600px) { .section { padding: 52px 0; } }
.section-alt { background: color-mix(in srgb, var(--bg-alt) 55%, transparent); }

.two-col { display: grid; gap: 24px; }
@media (min-width: 860px) { .two-col { grid-template-columns: 1fr 1.4fr; gap: 64px; } }
.prose .muted { color: var(--text-muted); }

/* ================= TIMELINE (flight path) ================= */
.timeline { list-style: none; margin: 0; padding: 0 0 0 26px; border-left: 2px dashed var(--border); }
.timeline li { position: relative; padding: 0 0 40px 26px; }
.timeline li:last-child { padding-bottom: 0; }
.timeline li::before {
  content: ""; position: absolute; left: -32px; top: 5px;
  width: 10px; height: 10px; border-radius: 50%; background: var(--accent);
}
.timeline .date { font-size: 0.8rem; color: var(--text-muted); }
.timeline h3 { margin: 4px 0 2px; font-size: 1.25rem; }
.timeline .org { color: var(--text-muted); margin-bottom: 8px; }
.timeline .bullets { margin: 0 0 12px; padding-left: 18px; color: var(--text-muted); }
.timeline .bullets li { padding: 0; margin-bottom: 6px; }
.timeline .bullets li::before { content: none; }

/* Supporting-work strip inside a timeline entry: kept compact and quiet so the
   role and bullets above stay the focus. Thumbnails sit left, text right. */
.timeline .research {
  display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 18px; align-items: start;
  margin-top: 16px; padding: 12px 14px; max-width: 720px;
  background: color-mix(in srgb, var(--surface) 45%, transparent);
  border: 1px solid var(--border); border-radius: 10px;
}
.research > * { grid-column: 2; }
.research .research-docs { grid-column: 1; grid-row: 1 / span 4; }
.research-kicker { font-size: 0.68rem; color: var(--text-muted); letter-spacing: 0.06em; margin: 0 0 2px; }
.research h4 { margin: 0 0 4px; font-size: 0.95rem; font-weight: 600; }
.research-summary { color: var(--text-muted); font-size: 0.85rem; line-height: 1.55; margin: 0; }
/* Collapsed: show about two lines, fading out at the bottom */
.research:not(.expanded) .research-summary {
  max-height: calc(1.55em * 2.4); overflow: hidden;
  -webkit-mask-image: linear-gradient(to bottom, #000 35%, transparent 100%);
          mask-image: linear-gradient(to bottom, #000 35%, transparent 100%);
}
.research-docs { display: flex; gap: 8px; }
.research-doc { display: block; }
.research-thumb { display: block; }
.research-thumb img {
  display: block; width: 84px; height: 64px; object-fit: cover; object-position: top;
  background: #fff; border-radius: 6px; border: 1px solid var(--border); transition: transform 0.2s, box-shadow 0.2s;
}
.research-thumb.full img { object-fit: contain; }
.research-link { display: inline-block; margin-top: 6px; font-size: 0.8rem; }
.research-thumb:hover img { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0, 0, 0, 0.18); }
@media (max-width: 560px) {
  .timeline .research { grid-template-columns: 1fr; }
  .research > *, .research .research-docs { grid-column: 1; grid-row: auto; }
  .research .research-docs { margin-top: 10px; }
}

/* Clickable: the compact strip expands into the full card */
.timeline .research { cursor: pointer; transition: border-color 0.2s, background 0.25s, padding 0.25s; }
.timeline .research:hover { border-color: var(--accent); }
.timeline .research:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.research-toggle {
  display: inline-flex; align-items: center; gap: 4px; margin-top: 6px;
  font-size: 0.75rem; color: var(--accent); font-family: var(--mono);
}
.research-toggle::after { content: "▾"; transition: transform 0.25s; }
.research.expanded .research-toggle::after { transform: rotate(180deg); }
.research.expanded .research-toggle-label::before { content: "Show less"; }
.research:not(.expanded) .research-toggle-label::before { content: "Show more"; }

.timeline .research.expanded {
  grid-template-columns: 1fr; padding: 20px; background: var(--surface); border-radius: var(--radius); cursor: default;
}
.research.expanded > *, .research.expanded .research-docs { grid-column: 1; grid-row: auto; }
.research.expanded .research-kicker { font-size: 0.75rem; color: var(--accent); margin-bottom: 4px; }
.research.expanded h4 { font-size: 1.15rem; margin-bottom: 8px; }
.research.expanded .research-summary { font-size: 1rem; line-height: 1.65; margin-bottom: 18px; }
.research.expanded .research-docs {
  display: grid; gap: 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 0; order: 1;
  animation: research-in 0.3s ease;
}
.research:not(.expanded) .research-link { display: none; }
.research.expanded .research-link { order: 2; margin-top: 16px; font-size: 0.9rem; }
.research.expanded .research-toggle { order: 3; margin-top: 14px; cursor: pointer; }
.research.expanded .research-thumb img { width: 100%; height: auto; aspect-ratio: 4 / 3; border-radius: 8px; }
.research.expanded .research-thumb.full img { aspect-ratio: auto; }
.research.expanded .research-docs:has(.full) { align-items: center; }
@media (max-width: 520px) { .research.expanded .research-docs { grid-template-columns: 1fr; } }
@keyframes research-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tags span {
  font-size: 0.78rem; padding: 3px 10px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text-muted);
}

/* ================= PROJECTS ================= */
.project-grid { display: grid; gap: 24px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
@media (max-width: 380px) { .project-grid { grid-template-columns: 1fr; } }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow);
  transition: transform 0.25s, border-color 0.2s, opacity 0.6s;
}
.card:hover { transform: translateY(-4px); border-color: var(--accent); }
.card-hit {
  all: unset; display: flex; flex-direction: column; width: 100%; height: 100%; cursor: pointer;
}
.card-hit:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: var(--radius); }
.thumb { aspect-ratio: 16 / 9; position: relative; overflow: hidden; background: #0b1a3a; }
.thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.5s; }
.card:hover .thumb img { transform: scale(1.05); }
.photo-count {
  position: absolute; top: 10px; right: 10px; display: inline-flex; align-items: center; gap: 5px;
  font-size: 0.72rem; color: #fff; background: rgba(6, 10, 20, 0.65); padding: 3px 8px; border-radius: 6px;
}
.thumb-hover {
  position: absolute; inset: auto 0 0 0; padding: 10px 14px; font-size: 0.78rem; color: #fff;
  background: linear-gradient(transparent, rgba(6, 10, 20, 0.85));
  transform: translateY(100%); transition: transform 0.25s;
}
.card:hover .thumb-hover, .card-hit:focus-visible .thumb-hover { transform: none; }
.card-body { padding: 18px 22px 22px; display: flex; flex-direction: column; flex: 1; }
.card-cat { font-size: 0.7rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent-2); margin-bottom: 6px; }
.card-body h3 { color: var(--text); }
.card-body p { color: var(--text-muted); font-size: 0.93rem; }
.tech { list-style: none; padding: 0; margin: auto 0 0; display: flex; flex-wrap: wrap; gap: 6px; }
.tech li {
  font-family: var(--mono); font-size: 0.72rem; padding: 2px 8px; border-radius: 6px;
  background: var(--accent-soft); color: var(--accent);
}
/* Card preview: one row of tags; any that don't fit fade out at the edge (full list is in the pop-up) */
.card .tech { flex-wrap: nowrap; overflow: hidden; }
.card .tech li { flex: none; white-space: nowrap; }
.card .tech.overflowing {
  -webkit-mask-image: linear-gradient(to right, #000 70%, transparent);
          mask-image: linear-gradient(to right, #000 70%, transparent);
}

/* Hover: cards with hidden tags grow taller to show every tag. script.js sets each card's
   height, and on hover grows it while shrinking its bottom margin by the same amount (same
   transition), so the grid row keeps its size; only the card directly below slides down. */
.project-grid { align-items: start; }
.project-grid .card {
  display: flex; flex-direction: column;
  transition: transform 0.3s ease, height 0.3s ease, margin-bottom 0.3s ease, border-color 0.2s, opacity 0.6s;
}
.project-grid .card:hover { position: relative; z-index: 2; }
.project-grid.measuring .card { transition: none !important; }
.card-hit { flex: 1 1 auto; height: auto; }
.card.tags-open .tech { flex-wrap: wrap; -webkit-mask-image: none; mask-image: none; }

/* ================= PROJECT MODAL ================= */
.modal {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 24px 16px;
}
.modal[hidden] { display: none; }
.modal-backdrop {
  position: absolute; inset: 0; background: rgba(4, 8, 18, 0.72);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  opacity: 0; transition: opacity 0.25s;
}
.modal-panel {
  position: relative; width: 100%; max-width: 960px; max-height: calc(100vh - 48px);
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); border-radius: 18px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.4);
  opacity: 0; transform: translateY(24px) scale(0.98); transition: opacity 0.25s, transform 0.25s;
}
.modal.open .modal-backdrop { opacity: 1; }
.modal.open .modal-panel { opacity: 1; transform: none; }
/* The panel clips; this inner element scrolls, so the scrollbar stays inside the rounded corners */
.modal-scroll {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
}
/* Chrome/Edge only honor the ::-webkit-scrollbar styles below when the standard
   scrollbar-width/color properties are unset, so reset them here (Firefox keeps the
   thin themed bar from the global rule via @supports below). */
@supports selector(::-webkit-scrollbar) {
  .modal-scroll { scrollbar-width: auto; scrollbar-color: auto; }
  .modal-scroll::-webkit-scrollbar { width: 12px; }
  .modal-scroll::-webkit-scrollbar-button { display: none; height: 0; }
  /* Inset the track so the bar is shorter than the pop-up and clears the rounded corners */
  .modal-scroll::-webkit-scrollbar-track { background: transparent; margin: 28px 0; }
  .modal-scroll::-webkit-scrollbar-thumb {
    background: var(--scroll-thumb); border-radius: 999px;
    border: 3px solid transparent; background-clip: padding-box;
  }
  .modal-scroll::-webkit-scrollbar-thumb:hover { background: var(--scroll-thumb-hover); background-clip: padding-box; }
}
.modal-close {
  position: absolute; top: 12px; right: 20px; z-index: 3;
  width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; cursor: pointer;
  border: none; color: #fff; background: rgba(6, 10, 20, 0.6);
}
.modal-close:hover { background: rgba(6, 10, 20, 0.85); }
.modal.no-images .modal-close { color: var(--text); background: var(--bg-alt); }

.gallery { background: #070d1c; }
.modal.no-images .gallery { display: none; }
.gallery-main { position: relative; aspect-ratio: 16 / 9; }
.gallery-main img { width: 100%; height: 100%; object-fit: contain; cursor: zoom-in; }
.gallery-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 44px; height: 44px; border-radius: 50%; border: none; cursor: pointer;
  font-size: 1.8rem; line-height: 1; color: #fff; background: rgba(6, 10, 20, 0.55);
  display: grid; place-items: center; padding-bottom: 4px;
}
.gallery-nav:hover { background: rgba(6, 10, 20, 0.85); }
.gallery-nav.prev { left: 12px; }
.gallery-nav.next { right: 12px; }
.gallery-count {
  position: absolute; left: 14px; bottom: 12px; font-size: 0.75rem; color: #3ee6a8;
  background: rgba(6, 10, 20, 0.6); padding: 3px 8px; border-radius: 4px;
}
.gallery-expand {
  position: absolute; right: 12px; bottom: 12px; width: 32px; height: 32px; border-radius: 6px; border: none;
  display: grid; place-items: center; color: #fff; background: rgba(6, 10, 20, 0.6); cursor: pointer;
}
.gallery-caption { margin: 0; padding: 10px 18px 0; color: #b4c0d6; font-size: 0.88rem; min-height: 1.6em; text-align: center; }
.gallery-thumbs { display: flex; gap: 8px; padding: 12px 18px 16px; overflow-x: auto; }
.gallery-thumbs button {
  flex: 0 0 auto; width: 88px; aspect-ratio: 16 / 10; padding: 0; border-radius: 6px; overflow: hidden; cursor: pointer;
  border: 2px solid transparent; background: #0b1a3a; opacity: 0.55; transition: opacity 0.2s, border-color 0.2s;
}
.gallery-thumbs button:hover { opacity: 0.85; }
.gallery-thumbs button.active { opacity: 1; border-color: var(--accent-2); }
.gallery-thumbs img { width: 100%; height: 100%; object-fit: cover; }
.modal.single-image .gallery-nav,
.modal.single-image .gallery-thumbs,
.modal.single-image .gallery-count { display: none; }
.modal.single-image .gallery-caption { padding-bottom: 14px; }

.modal-content { padding: 28px 32px 32px; }
@media (max-width: 600px) { .modal-content { padding: 22px 18px 26px; } }
.modal-cat { font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent-2); margin-bottom: 6px; }
.modal-content h2 { font-size: clamp(1.5rem, 3vw, 2rem); margin-bottom: 18px; }
.modal-content h3 {
  font-size: 0.8rem; font-family: var(--mono); text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--accent); margin: 26px 0 8px;
}
.modal-meta {
  display: inline-flex; flex-wrap: wrap; gap: 10px 0; max-width: 100%;
  margin: 0 0 18px; padding: 12px 0; border: 1px solid var(--border); border-radius: 10px; background: var(--bg-alt);
}
.modal-meta > div { padding: 0 22px; border-left: 1px solid var(--border); }
.modal-meta > div:first-child { border-left: 0; }
.modal-meta dt { font-size: 0.68rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-muted); }
.modal-meta dd { margin: 2px 0 0; font-weight: 500; }
.modal-content .tech { margin: 0; }
.checklist { list-style: none; padding: 0; margin: 0; }
.checklist li { position: relative; padding-left: 26px; margin-bottom: 8px; }
.checklist li::before {
  content: ""; position: absolute; left: 4px; top: 0.7em; width: 10px; height: 2px; background: var(--hud);
}
.modal-links { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 26px; }
.modal-links:empty { display: none; }

/* Lightbox */
.lightbox {
  position: fixed; inset: 0; z-index: 110; background: rgba(2, 4, 10, 0.95);
  display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 56px 16px 24px;
}
.lightbox[hidden] { display: none; }
.lightbox img { max-width: 100%; max-height: calc(100vh - 140px); object-fit: contain; }
.lightbox-caption { color: #b4c0d6; margin: 14px 0 0; text-align: center; font-size: 0.92rem; }
.lightbox-close {
  position: absolute; top: 12px; right: 12px; width: 44px; height: 44px; border: none; border-radius: 50%;
  display: grid; place-items: center; background: rgba(255, 255, 255, 0.1); color: #fff; cursor: pointer;
}
.modal.single-image ~ .lightbox .gallery-nav { display: none; }

/* ================= THESIS & COURSEWORK ================= */
.thesis {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 28px; margin-bottom: 24px; box-shadow: var(--shadow);
}
.status {
  display: inline-flex; align-items: center; gap: 8px; font-size: 0.75rem; letter-spacing: 0.06em;
  color: var(--hud); margin-bottom: 10px;
}
.status i { width: 8px; height: 8px; border-radius: 50%; background: var(--hud); animation: blink 1.6s infinite; }
@keyframes blink { 50% { opacity: 0.25; } }
.thesis h3 { font-size: 1.35rem; }
.milestones {
  list-style: none; padding: 0; margin: 20px 0 0; display: grid; gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}
.milestones li {
  position: relative; padding: 10px 12px 10px 14px; border-radius: 8px; font-size: 0.88rem;
  background: var(--bg-alt); color: var(--text-muted); border-left: 3px solid var(--border);
}
.milestones li span { display: block; font-size: 0.7rem; color: var(--text-muted); }
.milestones li.done { border-left-color: var(--hud); color: var(--text); }
.milestones li.active { border-left-color: var(--accent-2); color: var(--text); }
.milestones li.active span { color: var(--accent-2); }

.course-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.course { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.course-code { font-size: 0.75rem; color: var(--accent-2); margin-bottom: 6px; letter-spacing: 0.06em; }
.course h3 { font-size: 1rem; }
.course p:last-child { color: var(--text-muted); font-size: 0.9rem; margin: 0; }

/* ================= ACTIVITIES ================= */
.activity-grid { display: grid; gap: 20px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
@media (max-width: 380px) { .activity-grid { grid-template-columns: 1fr; } }
.activity {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px;
  transition: border-color 0.2s, opacity 0.6s, transform 0.6s;
}
.activity:hover { border-color: var(--accent); }
.activity-icon {
  width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center;
  background: var(--accent-soft); margin-bottom: 14px;
}
.activity-icon svg {
  width: 24px; height: 24px; fill: none; stroke: var(--accent);
  stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; transition: transform 0.4s;
}
.activity:hover .activity-icon svg { transform: translateY(-3px) rotate(-6deg); }
.activity ul { margin: 0; padding-left: 18px; color: var(--text-muted); font-size: 0.93rem; }
.activity li { margin-bottom: 6px; }
.activity li strong { color: var(--text); }

/* ================= SKILLS ================= */
/* Groups are shrunk to their wrapped chips (script.js) and spaced evenly across the row */
.skills-grid { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 28px 40px; }
.skill-group { flex: 0 1 280px; min-width: 0; }
.skill-group h3 { display: flex; align-items: center; gap: 10px; width: fit-content; }
.skill-group h3 svg {
  width: 22px; height: 22px; fill: none; stroke: var(--accent);
  stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round;
}
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips span {
  font-size: 0.88rem; padding: 6px 14px; border-radius: 8px;
  background: var(--surface); border: 1px solid var(--border);
}

/* ================= CONTACT ================= */
.contact { text-align: center; }
.contact .lead { margin: 0 auto 28px; }
.contact .btn-lg { word-break: break-all; }
.socials { list-style: none; padding: 0; margin: 32px 0 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 12px 28px; }
.socials a { color: var(--text-muted); font-weight: 500; }
.socials a:hover { color: var(--accent); }

/* ================= FOOTER ================= */
.footer { border-top: 1px solid var(--border); padding: 28px 0; font-size: 0.88rem; color: var(--text-muted); }
.footer .container { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; }
.footer p { margin: 0; }

/* ================= REVEAL ANIMATION ================= */
.reveal { opacity: 0; transform: translateY(16px); transition: opacity 0.6s ease, transform 0.6s ease; }
.reveal.visible { opacity: 1; transform: none; }
.card.reveal.visible:hover { transform: translateY(-4px); }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; transition: none; }
  .stars span, .status i { animation: none; }
  .card, .btn, .thumb img, .modal-panel, .modal-backdrop { transition: none; }
}
