:root {
  --bg: #ffffff;
  --bg-alt: #fafafa;
  --surface: #ffffff;
  --border: #e5e7eb;
  --text: #111827;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-soft: rgba(37, 99, 235, 0.06);
  --green: #16a34a;
  --radius: 12px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
  --font: 'DM Sans', system-ui, sans-serif;
  --mono: 'JetBrains Mono', monospace;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.container { max-width: 1140px; margin: 0 auto; padding: 0 1.25rem; }

/* Header */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.nav { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.logo { font-weight: 700; font-size: 1.25rem; color: var(--text); text-decoration: none; }
.logo span { color: var(--accent); }
.nav-links { display: flex; align-items: center; gap: 1.5rem; list-style: none; }
.nav-links a { color: var(--muted); text-decoration: none; font-size: 0.9rem; transition: color 0.2s; }
.nav-links a:hover { color: var(--text); }
.nav-toggle { display: none; background: none; border: none; cursor: pointer; padding: 4px; }
.nav-toggle span { display: block; width: 22px; height: 2px; background: var(--text); margin: 5px 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0.65rem 1.25rem; border-radius: 8px; font-weight: 600; font-size: 0.9rem;
  text-decoration: none; border: 1px solid transparent; transition: all 0.2s; cursor: pointer;
}
.btn-sm { padding: 0.45rem 0.9rem; font-size: 0.85rem; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { border-color: var(--border); color: var(--text); background: var(--surface); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

/* Hero */
.hero {
  padding: 5rem 0 4rem;
  background: #ffffff;
}
.hero-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 3rem; align-items: center; }
.eyebrow { color: var(--accent); font-size: 0.85rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 0.75rem; }
.hero h1 { font-size: clamp(2rem, 5vw, 3rem); font-weight: 700; line-height: 1.15; margin-bottom: 0.75rem; color: var(--text); }
.hero-specialty { font-size: 1.1rem; font-weight: 600; color: var(--text); max-width: 540px; margin-bottom: 0.75rem; line-height: 1.45; }
.hero-lead { color: var(--muted); font-size: 1.05rem; max-width: 520px; margin-bottom: 1.75rem; }
.hero-actions { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 2.5rem; }
.hero-stats { display: flex; gap: 2rem; flex-wrap: wrap; }
.hero-stats div { display: flex; flex-direction: column; }
.hero-stats strong { font-size: 1.5rem; color: var(--text); }
.hero-stats span { font-size: 0.8rem; color: var(--muted); }

.hero-photo-wrap {
  border-radius: 20px; overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  background: var(--surface);
  max-width: 380px; margin-left: auto;
}
.hero-photo {
  width: 100%; height: auto; display: block;
  object-fit: cover; object-position: center top;
  aspect-ratio: 4 / 5;
}

.code-window {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow);
}
.code-bar { display: flex; gap: 6px; padding: 12px 16px; background: #fafafa; border-bottom: 1px solid var(--border); }
.code-bar span { width: 10px; height: 10px; border-radius: 50%; background: var(--border); }
.code-bar span:nth-child(1) { background: #ef4444; }
.code-bar span:nth-child(2) { background: #eab308; }
.code-bar span:nth-child(3) { background: #22c55e; }
.code-window pre { padding: 1.25rem; overflow-x: auto; font-family: var(--mono); font-size: 0.8rem; line-height: 1.7; background: #fafafa; }
.c-kw { color: #7c3aed; }
.c-str { color: #059669; }

/* Sections */
.section { padding: 4.5rem 0; }
.section-alt { background: #fafafa; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.section-head { margin-bottom: 2.5rem; max-width: 600px; }
.section-head h2 { font-size: 1.75rem; margin-bottom: 0.5rem; color: var(--text); }
.section-head p { color: var(--muted); }

/* Projects */
.project-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 1.5rem; }
.project-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
.project-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow); }
.project-thumb {
  height: 180px; background: #fafafa; overflow: hidden; position: relative;
}
.project-thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top; }
.project-thumb .placeholder {
  display: flex; align-items: center; justify-content: center; height: 100%;
  color: var(--muted); font-size: 2rem;
}
.project-body { padding: 1.25rem; }
.project-tag { font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--accent); }
.project-body h3 { font-size: 1.1rem; margin: 0.35rem 0 0.5rem; }
.project-impact { color: var(--green); font-weight: 600; font-size: 0.8rem; margin-bottom: 0.5rem !important; }
.project-body p { color: var(--muted); font-size: 0.875rem; margin-bottom: 1rem; }
.project-card-compact .project-thumb { height: 140px; }
.project-grid-compact { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1.25rem; }
.project-stack { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-bottom: 1rem; }
.project-stack span {
  font-size: 0.7rem; padding: 0.2rem 0.5rem; background: #fafafa;
  border: 1px solid var(--border); border-radius: 4px; color: var(--muted);
}
.project-links { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.project-links a { font-size: 0.8rem; color: var(--accent); text-decoration: none; font-weight: 500; }
.project-links a:hover { text-decoration: underline; }

.project-meta {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0.25rem 0.75rem;
  margin: 0.75rem 0; font-size: 0.75rem; color: var(--muted);
}
.project-meta span strong { color: var(--text); font-weight: 600; }
.project-note {
  font-size: 0.78rem; color: var(--text); font-style: italic;
  margin: 0.5rem 0 0.75rem; padding: 0.5rem 0.65rem;
  background: var(--accent-soft); border-left: 3px solid var(--accent); border-radius: 4px;
}
.project-features {
  margin: 0 0 0.75rem 1rem; font-size: 0.75rem; color: var(--muted);
  columns: 2; column-gap: 1rem;
}
.project-features li { margin-bottom: 0.2rem; break-inside: avoid; }

/* Markdown doc viewer */
.doc-page { padding-top: 2rem; padding-bottom: 4rem; }
.doc-loading, .doc-error { color: var(--muted); padding: 2rem 0; text-align: center; }
.md-body {
  max-width: 820px; margin: 0 auto;
  font-size: 0.95rem; line-height: 1.75; color: var(--text);
}
.md-body h1 { font-size: 1.75rem; margin-bottom: 1rem; padding-bottom: 0.5rem; border-bottom: 1px solid var(--border); }
.md-body h2 { font-size: 1.25rem; margin: 2rem 0 0.75rem; color: var(--text); }
.md-body h3 { font-size: 1.05rem; margin: 1.25rem 0 0.5rem; }
.md-body p { margin-bottom: 0.85rem; color: var(--muted); }
.md-body ul, .md-body ol { margin: 0 0 1rem 1.25rem; color: var(--muted); }
.md-body li { margin-bottom: 0.35rem; }
.md-body a { color: var(--accent); text-decoration: none; }
.md-body a:hover { text-decoration: underline; }
.md-body code {
  font-family: var(--mono); font-size: 0.85em;
  background: var(--bg-alt); padding: 0.15rem 0.4rem; border-radius: 4px;
}
.md-body pre {
  background: #fafafa; border: 1px solid var(--border); border-radius: 8px;
  padding: 1rem; overflow-x: auto; margin-bottom: 1rem;
}
.md-body pre code { background: none; padding: 0; }
.md-body table, .md-table {
  width: 100%; border-collapse: collapse; margin: 1rem 0 1.5rem;
  font-size: 0.88rem;
}
.md-body th, .md-body td {
  border: 1px solid var(--border); padding: 0.55rem 0.75rem; text-align: left;
}
.md-body th { background: #fafafa; font-weight: 600; color: var(--text); }
.md-body hr { border: none; border-top: 1px solid var(--border); margin: 2rem 0; }
.md-body blockquote {
  border-left: 3px solid var(--accent); margin: 1rem 0; padding: 0.5rem 1rem;
  background: var(--accent-soft); color: var(--text);
}

/* Case studies */
.case-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 1.5rem; }
.case-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.5rem; border-left: 3px solid var(--green);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
.case-card h3 { font-size: 1.05rem; margin-bottom: 0.5rem; }
.case-card .impact { color: var(--green); font-weight: 600; font-size: 0.85rem; margin-bottom: 0.75rem; }
.case-card p { color: var(--muted); font-size: 0.875rem; margin-bottom: 1rem; }
.case-card a { color: var(--accent); font-size: 0.85rem; text-decoration: none; font-weight: 500; }
.case-card .case-gallery-link { display: inline-block; margin-left: 1rem; }

/* Gallery page */
.gallery-tabs { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.gallery-tab {
  padding: 0.45rem 0.9rem; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--muted); font-size: 0.85rem; cursor: pointer;
}
.gallery-tab.active { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.gallery-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; margin-bottom: 2rem;
}
.gallery-item {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; cursor: pointer; transition: border-color 0.2s, transform 0.2s;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
.gallery-item:hover { border-color: var(--accent); transform: translateY(-2px); }
.gallery-item img { width: 100%; height: 200px; object-fit: cover; object-position: top; display: block; background: #fafafa; }
.gallery-item figcaption {
  padding: 0.6rem 0.75rem; font-size: 0.75rem; color: var(--muted);
  text-transform: capitalize; border-top: 1px solid var(--border);
}
.gallery-empty { color: var(--muted); padding: 2rem; text-align: center; }
.project-doc-links { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-top: 1rem; }

.lightbox {
  position: fixed; inset: 0; z-index: 200; background: rgba(255, 255, 255, 0.96);
  display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 2rem;
}
.lightbox[hidden] { display: none !important; }
.lightbox img { max-width: min(95vw, 1200px); max-height: 80vh; object-fit: contain; border-radius: 8px; }
.lightbox-close, .lightbox-prev, .lightbox-next {
  position: absolute; background: var(--surface); border: 1px solid var(--border); color: var(--text);
  width: 44px; height: 44px; border-radius: 50%; font-size: 1.5rem; cursor: pointer;
}
.lightbox-close { top: 1rem; right: 1rem; }
.lightbox-prev { left: 1rem; top: 50%; transform: translateY(-50%); }
.lightbox-next { right: 1rem; top: 50%; transform: translateY(-50%); }
#lightbox-caption { color: var(--muted); margin-top: 1rem; font-size: 0.9rem; }

/* Ops / DevOps section */
.ops-badges { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 2rem; }
.ops-badges span {
  font-size: 0.8rem; font-weight: 600; padding: 0.4rem 0.75rem;
  background: var(--accent-soft); border: 1px solid rgba(37, 99, 235, 0.15);
  border-radius: 999px; color: var(--accent);
}
.ops-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1.25rem; }
.ops-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.25rem; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
.ops-card h3 { font-size: 1rem; margin-bottom: 0.5rem; }
.ops-card p { color: var(--muted); font-size: 0.875rem; }

/* Architecture */
.arch-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1.25rem; }
.arch-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}
.arch-card h3 { font-size: 1rem; margin-bottom: 0.5rem; }
.arch-card p { color: var(--muted); font-size: 0.85rem; margin-bottom: 0.75rem; }
.arch-card a { color: var(--accent); font-size: 0.85rem; text-decoration: none; }
.arch-link { margin-top: 1.5rem; }
.arch-link a { color: var(--accent); }

/* Docs grid */
.docs-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1.25rem; }
.doc-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.5rem; text-decoration: none; color: inherit; transition: border-color 0.2s, box-shadow 0.2s;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}
.doc-card:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.doc-icon { font-size: 1.5rem; display: block; margin-bottom: 0.75rem; }
.doc-card h3 { font-size: 1rem; margin-bottom: 0.4rem; }
.doc-card p { color: var(--muted); font-size: 0.85rem; }

/* Skills */
.skills-wrap { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1.5rem; }
.skill-group h4 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 0.75rem; }
.tags { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.tags span {
  font-size: 0.8rem; padding: 0.35rem 0.65rem; background: var(--surface);
  border: 1px solid var(--border); border-radius: 6px; color: var(--text);
}

/* Contact */
.section-contact { padding-bottom: 5rem; }
.contact-box {
  text-align: center; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 3rem 2rem;
  box-shadow: var(--shadow);
}
.contact-avatar {
  width: 96px; height: 96px; border-radius: 50%; object-fit: cover;
  border: 3px solid var(--accent-soft); box-shadow: 0 4px 16px rgba(37, 99, 235, 0.15);
  margin: 0 auto 1.25rem; display: block;
}
.contact-box h2 { margin-bottom: 0.5rem; }
.contact-box p { color: var(--muted); margin-bottom: 1.5rem; }
.contact-links { display: flex; gap: 0.75rem; justify-content: center; flex-wrap: wrap; }

.site-footer {
  border-top: 1px solid var(--border); padding: 1.5rem 0;
  text-align: center; color: var(--muted); font-size: 0.8rem;
  background: var(--surface);
}

@media (max-width: 768px) {
  .hero-grid { grid-template-columns: 1fr; }
  .hero-visual { order: -1; }
  .hero-photo-wrap { margin: 0 auto 1rem; max-width: 280px; }
  .nav-toggle { display: block; }
  .nav-links {
    display: none; position: absolute; top: 64px; left: 0; right: 0;
    flex-direction: column; background: var(--surface); padding: 1rem; border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
  }
  .nav-links.open { display: flex; }
}
