:root {
  /* Dark theme (default) */
  --bg: #0a1628;
  --bg-elevated: #122033;
  --bg-card: #15253a;
  --text: #e8eef5;
  --text-muted: #a0b0c0;
  --accent: #5b9bd5;
  --accent-hover: #7ab0e0;
  --border: #2a3f55;
  --focus: #7ab0e0;
  --success: #4caf7a;
  --header-height: 4rem;
  --radius: 0.5rem;
  --max-width: 72rem;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Light theme overrides */
[data-theme="light"] {
  --bg: #f4f7fb;
  --bg-elevated: #ffffff;
  --bg-card: #ffffff;
  --text: #1a2533;
  --text-muted: #4a5a6a;
  --accent: #1a6bb5;
  --accent-hover: #0d4f8a;
  --border: #d0d8e0;
  --focus: #1a6bb5;
}

/* ---------- Reset & Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-height) + 1rem);
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.65;
  color: var(--text);
  background-color: var(--bg);
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; height: auto; display: block; }

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.15em;
}

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

/* Focus (accessibility) */
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

:focus:not(:focus-visible) { outline: none; }

/* Skip link */
.skip-link {
  position: absolute;
  top: -100%;
  left: 1rem;
  background: var(--accent);
  color: #fff;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius);
  z-index: 1000;
  font-weight: 600;
  text-decoration: none;
}

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

/* Layout */
.container {
  width: min(100% - 2rem, var(--max-width));
  margin-inline: auto;
}

.section {
  padding-block: 3.5rem;
}

.section-title {
  font-size: clamp(1.6rem, 4vw, 2.1rem);
  margin: 0 0 0.5rem;
  font-weight: 700;
}

.section-intro {
  color: var(--text-muted);
  max-width: 40rem;
  margin-bottom: 2rem;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  height: var(--header-height);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  gap: 1rem;
}

.logo-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  font-size: 1.15rem;
}

.logo-link img {
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 0.3rem;
}

.logo-text { letter-spacing: -0.02em; }

/* Nav */
.primary-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: 0.15rem;
}

.primary-nav a {
  display: block;
  padding: 0.5rem 0.9rem;
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
  border-radius: var(--radius);
}

.primary-nav a:hover,
.primary-nav a[aria-current="page"] {
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  color: var(--accent);
}

/* Mobile toggle */
.nav-toggle {
  display: none;
  background: none;
  border: 2px solid transparent;
  padding: 0.4rem;
  cursor: pointer;
  border-radius: var(--radius);
  color: var(--text);
}

.nav-toggle:focus-visible { border-color: var(--focus); }

.hamburger {
  display: block;
  width: 1.5rem;
  height: 2px;
  background: currentColor;
  position: relative;
}

.hamburger::before,
.hamburger::after {
  content: "";
  position: absolute;
  left: 0;
  width: 100%;
  height: 2px;
  background: currentColor;
}

.hamburger::before { top: -6px; }
.hamburger::after  { top: 6px; }

/* Theme toggle button */
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.4rem 0.7rem;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.theme-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Hero */
.hero {
  padding-block: 4.5rem 3.5rem;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
}

.hero h1 {
  font-size: clamp(2rem, 5.5vw, 2.9rem);
  line-height: 1.15;
  margin: 0 0 0.75rem;
  font-weight: 800;
}

.hero-lead {
  font-size: 1.25rem;
  margin: 0 0 0.5rem;
  max-width: 36rem;
}

.hero-sub {
  color: var(--text-muted);
  margin: 0 0 1.75rem;
  max-width: 36rem;
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 0.7rem 1.4rem;
  font-weight: 600;
  font-size: 1rem;
  text-decoration: none;
  border-radius: var(--radius);
  border: 2px solid transparent;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #fff;
}

.btn-secondary {
  background: transparent;
  color: var(--accent);
  border-color: var(--accent);
}

.btn-secondary:hover {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}

.btn-small {
  padding: 0.45rem 0.9rem;
  font-size: 0.9rem;
}

/* Cards / Project grid */
.card-grid {
  display: grid;
  gap: 1.5rem;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 2px);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.card h3 {
  margin: 0;
  font-size: 1.2rem;
}

.card p {
  margin: 0;
  color: var(--text-muted);
  flex-grow: 1;
}

.card-tags {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.card-tags li {
  font-size: 0.78rem;
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  color: var(--accent);
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-weight: 500;
}

.course-block {
  margin-bottom: 3rem;
}

.course-block h2 {
  font-size: 1.5rem;
  margin: 0 0 1rem;
  padding-bottom: 0.4rem;
  border-bottom: 2px solid var(--border);
}

/* Resume */
.resume {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  max-width: 48rem;
}

.resume h2 {
  margin-top: 1.75rem;
  margin-bottom: 0.5rem;
  font-size: 1.25rem;
  color: var(--accent);
}

.resume h2:first-child { margin-top: 0; }

.resume ul { margin: 0.4rem 0 0; padding-left: 1.25rem; }

.resume li { margin-bottom: 0.3rem; }

/* Contact form */
.contact-form {
  max-width: 32rem;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-group label {
  font-weight: 600;
  font-size: 0.95rem;
}

.form-group input,
.form-group textarea {
  font: inherit;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  color: var(--text);
}

.form-group input:focus,
.form-group textarea:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent);
}

.form-note {
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* Footer */
.site-footer {
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
  padding-block: 2rem;
  margin-top: 2rem;
  text-align: center;
  font-size: 0.95rem;
  color: var(--text-muted);
}

.site-footer p { margin: 0.3rem 0; }

/* Responsive */
@media (min-width: 640px) {
  .card-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 900px) {
  .section { padding-block: 4.5rem; }
  .hero { padding-block: 5.5rem 4.5rem; }
}

/* Mobile navigation */
@media (max-width: 767px) {
  .nav-toggle { display: block; }

  .primary-nav {
    position: absolute;
    top: var(--header-height);
    left: 0;
    right: 0;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem;
    display: none;
  }

  .primary-nav.is-open { display: block; }

  .primary-nav ul {
    flex-direction: column;
    gap: 0.2rem;
  }

  .primary-nav a {
    padding: 0.75rem 1rem;
  }

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

@media (min-width: 768px) {
  .header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
  }
}
