:root,
[data-theme="dark"] {
  --bg: #0C0F0E;
  --surface: #131816;
  --surface-2: #1A211E;
  --ink: #F2F5F3;
  --muted: #9AA5A0;
  --hairline: rgba(255, 255, 255, 0.08);
  --accent: #10B981;
  --accent-bright: #34D399;
  --accent-soft: rgba(16, 185, 129, 0.12);
  --bar-bg: rgba(12, 15, 14, 0.88);
  --font-display: 'Space Grotesk', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

[data-theme="light"] {
  --bg: #F7F8F7;
  --surface: #FFFFFF;
  --surface-2: #EEF2F0;
  --ink: #111815;
  --muted: #52605A;
  --hairline: #E2E8E5;
  --accent: #059669;
  --accent-bright: #047857;
  --accent-soft: rgba(5, 150, 105, 0.1);
  --bar-bg: rgba(247, 248, 247, 0.9);
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: 2rem;
}

body {
  position: relative;
  margin: 0;
  background-color: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

[data-theme="dark"] body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at 18% 12%, rgba(16, 185, 129, 0.08), transparent 45%);
  z-index: -1;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0.75rem;
  z-index: 100;
  padding: 0.5rem 0.9rem;
  background: var(--accent);
  color: #062118;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
}

.skip-link:focus {
  left: 1rem;
}

/* Mobile Top Bar */
.mobile-bar {
  display: none;
}

/* Layout Shell */
.layout-shell {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 4rem;
  max-width: 1120px;
  margin: 0 auto;
  padding: 3.25rem 2rem;
  align-items: start;
}

/* Sticky Left Sidebar */
.sidebar {
  position: sticky;
  top: 2rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 1.45rem;
}

.profile-header {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.portrait-frame {
  width: 120px;
  height: 142px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.36);
  transition: border-color 0.2s ease;
}

[data-theme="light"] .portrait-frame {
  border-color: var(--hairline);
  box-shadow: 0 8px 22px rgba(17, 24, 21, 0.08);
}

.portrait-frame:hover {
  border-color: rgba(16, 185, 129, 0.55);
}

.portrait-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 47% 18%;
  border-radius: 12px;
  transition: transform 0.35s ease;
}

.portrait-frame:hover .portrait-img {
  transform: scale(1.03);
}

.profile-identity {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 7px;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 0.875rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.role-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.28rem 0.65rem;
  margin-bottom: 0.65rem;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted);
}

.status-dot {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 999px;
  background: var(--accent);
}

.sidebar h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.12;
  letter-spacing: -0.03em;
}

.sidebar-role {
  margin: 0.3rem 0 0;
  font-family: var(--font-display);
  font-size: 1.0625rem;
  font-weight: 500;
  color: var(--accent-bright);
}

.sidebar-bio {
  margin: 0.9rem 0 0;
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--muted);
}

/* Vertical Nav */
.side-nav {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  margin-top: 1.25rem;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.42rem 0.7rem;
  border-left: 2px solid transparent;
  border-radius: 0 6px 6px 0;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: color 0.15s ease, border-color 0.15s ease, background-color 0.15s ease;
}

.nav-num {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--muted);
}

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

.nav-link.is-active {
  color: var(--ink);
  border-left-color: var(--accent);
  background: var(--accent-soft);
}

.nav-link.is-active .nav-num {
  color: var(--accent-bright);
}

/* Sidebar Actions */
.sidebar-cta {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.sidebar-utility-row {
  display: flex;
  gap: 0.5rem;
}

.sidebar-utility-row .btn-ghost {
  flex: 1;
}

.btn,
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  border-radius: 8px;
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.btn {
  height: 2.35rem;
  padding: 0 0.9rem;
  border: 1px solid transparent;
}

.btn-sm {
  height: 2rem;
  padding: 0 0.7rem;
  font-size: 0.78rem;
}

.btn-block {
  width: 100%;
}

.btn-accent {
  background: var(--accent);
  color: #062118;
  font-weight: 600;
}

[data-theme="light"] .btn-accent {
  color: #FFFFFF;
}

.btn-accent:hover {
  background: var(--accent-bright);
  transform: translateY(-1px);
}

.btn-ghost {
  background: var(--surface);
  color: var(--muted);
  border-color: var(--hairline);
}

.btn-ghost:hover {
  color: var(--ink);
  border-color: var(--accent);
}

.icon-btn {
  width: 2.35rem;
  height: 2.35rem;
  padding: 0;
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--hairline);
}

.icon-btn:hover {
  color: var(--ink);
  border-color: var(--accent);
}

.icon-moon {
  display: none;
}

[data-theme="dark"] .icon-sun { display: block; }
[data-theme="dark"] .icon-moon { display: none; }
[data-theme="light"] .icon-sun { display: none; }
[data-theme="light"] .icon-moon { display: block; }

/* Contact List */
.contact-list {
  list-style: none;
  padding: 1rem 0 0;
  margin: 1rem 0 0;
  border-top: 1px solid var(--hairline);
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.contact-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem;
}

.contact-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.8125rem;
  transition: color 0.15s ease;
}

.contact-link span:not(.ext-arrow) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.contact-link svg {
  flex-shrink: 0;
}

.contact-link:hover {
  color: var(--ink);
}

.ext-arrow {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--accent-bright);
  opacity: 0.75;
}

.copy-btn {
  flex-shrink: 0;
  padding: 0.15rem 0.45rem;
  border-radius: 5px;
  border: 1px solid var(--hairline);
  background: var(--surface);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background-color 0.15s ease;
}

.copy-btn:hover {
  color: var(--ink);
  border-color: var(--accent);
}

.copy-btn.is-copied {
  color: var(--accent-bright);
  border-color: var(--accent);
  background: var(--accent-soft);
}

/* Main Column */
.main-col {
  min-width: 0;
}

.cv-section {
  padding-bottom: 3.25rem;
  margin-bottom: 3.25rem;
  border-bottom: 1px solid var(--hairline);
}

.cv-section:last-of-type {
  margin-bottom: 2rem;
}

.section-head {
  margin-bottom: 1.65rem;
}

.section-head-split {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
}

.section-index {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--accent-bright);
  letter-spacing: 0.04em;
  margin-bottom: 0.2rem;
}

.section-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* Experience Editorial List */
.experience-list {
  display: flex;
  flex-direction: column;
}

.exp-item {
  padding: 1.65rem 0;
  border-top: 1px solid var(--hairline);
}

.exp-item:first-child {
  padding-top: 0;
  border-top: none;
}

.exp-item:last-child {
  padding-bottom: 0;
}

.exp-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.exp-org {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.015em;
}

.exp-role {
  margin: 0.15rem 0 0;
  font-size: 0.9375rem;
  color: var(--muted);
}

.exp-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  text-align: right;
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--ink);
}

.exp-loc {
  color: var(--muted);
}

.exp-bullets {
  margin: 0.85rem 0 0;
  padding-left: 1.15rem;
}

.exp-bullets li {
  margin-bottom: 0.45rem;
  font-size: 0.9375rem;
  color: var(--ink);
}

.exp-bullets li:last-child {
  margin-bottom: 0;
}

.exp-bullets strong {
  color: var(--accent-bright);
  font-weight: 600;
}

.role-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.9rem;
}

.role-tags span {
  padding: 0.16rem 0.5rem;
  border-radius: 5px;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--muted);
}

/* Education */
.education-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.15rem;
}

.edu-card {
  padding: 1.35rem;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 10px;
}

.edu-meta {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--accent-bright);
  margin-bottom: 0.55rem;
}

.edu-org {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.0625rem;
  font-weight: 600;
  line-height: 1.3;
}

.edu-degree {
  margin: 0.2rem 0 0.75rem;
  font-size: 0.9rem;
  font-style: italic;
  color: var(--muted);
}

.edu-thesis {
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.55;
  color: var(--ink);
}

/* Skills Matrix */
.skill-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.filter-btn {
  padding: 0.3rem 0.75rem;
  border-radius: 7px;
  border: 1px solid var(--hairline);
  background: var(--surface);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.76rem;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.filter-btn:hover {
  color: var(--ink);
  border-color: var(--accent);
}

.filter-btn[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #062118;
  font-weight: 600;
}

[data-theme="light"] .filter-btn[aria-pressed="true"] {
  color: #FFFFFF;
}

.skills-matrix {
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
}

.skill-row {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr);
  gap: 1rem;
  padding: 1.15rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  align-items: start;
}

.skill-group[hidden] {
  display: none;
}

.skill-cat {
  margin: 0.2rem 0 0;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent-bright);
}

.skill-chips {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.skill-chip {
  padding: 0.28rem 0.62rem;
  border-radius: 6px;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  font-size: 0.8125rem;
  color: var(--ink);
  line-height: 1.35;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.skill-chip:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

/* Main Footer */
.main-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  font-size: 0.8125rem;
  color: var(--muted);
}

.main-footer p {
  margin: 0;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 1.1rem;
}

.footer-links a {
  color: var(--muted);
  text-decoration: none;
}

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

/* Entrance Motion */
@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.sidebar,
.main-col {
  animation: rise-in 420ms ease-out both;
}

.main-col {
  animation-delay: 80ms;
}

/* Responsive */
@media (max-width: 959px) {
  html {
    scroll-padding-top: 4.5rem;
  }

  .mobile-bar {
    position: sticky;
    top: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.7rem 1.25rem;
    background: var(--bar-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--hairline);
  }

  .mobile-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    color: var(--ink);
    text-decoration: none;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 0.9375rem;
  }

  .mobile-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
  }

  .layout-shell {
    grid-template-columns: 1fr;
    gap: 2.25rem;
    padding: 1.75rem 1.25rem 2.5rem;
  }

  .sidebar {
    position: static;
    padding-bottom: 1.75rem;
    border-bottom: 1px solid var(--hairline);
  }

  .profile-header {
    flex-direction: row;
    align-items: center;
    gap: 1.15rem;
  }

  .portrait-frame {
    width: 92px;
    height: 108px;
    flex-shrink: 0;
  }

  .side-nav {
    display: none;
  }
}

@media (max-width: 420px) {
  .portrait-frame {
    width: 78px;
    height: 92px;
  }
}

@media (max-width: 680px) {
  .education-grid {
    grid-template-columns: 1fr;
  }

  .exp-header {
    flex-direction: column;
    gap: 0.3rem;
  }

  .exp-meta {
    align-items: flex-start;
    text-align: left;
    flex-direction: row;
    gap: 0.75rem;
  }

  .skill-row {
    grid-template-columns: 1fr;
    gap: 0.65rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .sidebar,
  .main-col {
    animation: none;
  }

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
  }
}

/* Print */
@media print {
  :root,
  [data-theme="dark"],
  [data-theme="light"] {
    --bg: #FFFFFF;
    --surface: #FFFFFF;
    --surface-2: #F3F4F6;
    --ink: #111827;
    --muted: #4B5563;
    --hairline: #D1D5DB;
    --accent: #047857;
    --accent-bright: #047857;
    --accent-soft: #ECFDF5;
  }

  body {
    background: #FFFFFF;
    color: #111827;
    font-size: 9.8pt;
    line-height: 1.4;
  }

  body::before,
  .mobile-bar,
  .side-nav,
  .sidebar-cta,
  .copy-btn,
  .skill-filters,
  .main-footer {
    display: none !important;
  }

  .layout-shell {
    grid-template-columns: 1fr;
    gap: 1.1rem;
    max-width: 100%;
    padding: 0;
  }

  .sidebar {
    position: static;
    gap: 0.75rem;
    padding-bottom: 0.9rem;
    border-bottom: 1px solid #D1D5DB;
  }

  .profile-header {
    flex-direction: row;
    align-items: center;
    gap: 1rem;
  }

  .portrait-frame {
    width: 72px;
    height: 84px;
    padding: 2px;
    border-radius: 10px;
    box-shadow: none;
    border-color: #D1D5DB;
    flex-shrink: 0;
  }

  .portrait-img {
    border-radius: 8px;
  }

  .contact-list {
    padding-top: 0.5rem;
    margin-top: 0.5rem;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.35rem 1.25rem;
  }

  .cv-section {
    padding-bottom: 1rem;
    margin-bottom: 1rem;
  }

  .education-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .exp-item,
  .edu-card,
  .skill-row {
    break-inside: avoid;
  }

  .skill-group[hidden] {
    display: grid !important;
  }

  .skill-chip {
    padding: 0.12rem 0.4rem;
    font-size: 8.5pt;
  }
}
