:root {
  color-scheme: light dark;
  --bg: #f6f2ea;
  --bg-alt: #ece4d6;
  --fg: #1a1613;
  --fg-muted: #6b6058;
  --accent: #7d1f2b;
  --accent-fg: #f9f5ee;
  --border: #ddd2c1;
  --card-bg: #fffdf8;
  --max-width: 880px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17120f;
    --bg-alt: #211913;
    --fg: #f0e8dd;
    --fg-muted: #a99c8d;
    --accent: #d97682;
    --accent-fg: #2a1013;
    --border: #33271f;
    --card-bg: #201812;
  }
}

:root[data-theme="light"] {
  --bg: #f6f2ea;
  --bg-alt: #ece4d6;
  --fg: #1a1613;
  --fg-muted: #6b6058;
  --accent: #7d1f2b;
  --accent-fg: #f9f5ee;
  --border: #ddd2c1;
  --card-bg: #fffdf8;
}

:root[data-theme="dark"] {
  --bg: #17120f;
  --bg-alt: #211913;
  --fg: #f0e8dd;
  --fg-muted: #a99c8d;
  --accent: #d97682;
  --accent-fg: #2a1013;
  --border: #33271f;
  --card-bg: #201812;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.55;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.nav {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.nav-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  color: var(--fg);
  text-decoration: none;
}
.brand:hover { text-decoration: none; }
.logo-mark { flex-shrink: 0; display: block; border-radius: 9px; }

.nav-links {
  display: flex;
  gap: 20px;
  font-size: 0.92rem;
}

.nav-links a { color: var(--fg-muted); }
.nav-links a:hover { color: var(--fg); text-decoration: none; }
.nav-links a.active { color: var(--fg); font-weight: 600; }

main { max-width: var(--max-width); margin: 0 auto; padding: 0 20px; }

.hero {
  padding: 72px 0 40px;
}

.hero-layout {
  display: flex;
  align-items: center;
  gap: 48px;
}
.hero-intro { flex: 1 1 auto; min-width: 0; }

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
  margin: 0 0 10px;
}

.hero h1 {
  font-size: clamp(2.25rem, 6vw, 3.5rem);
  font-weight: 800;
  margin: 0 0 16px;
  letter-spacing: -0.03em;
}

.hero-sub {
  max-width: 640px;
  color: var(--fg-muted);
  font-size: 1.1rem;
}

.hero-links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 28px;
}

.hero-photo {
  flex: 0 0 auto;
  width: 220px;
  height: 220px;
  border-radius: 24px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-alt);
  position: relative;
}
.hero-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.hero-photo-placeholder {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  color: var(--fg-muted);
}

.btn {
  display: inline-block;
  padding: 12px 22px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--fg);
  font-size: 0.92rem;
  font-weight: 600;
}
.btn:hover { text-decoration: none; border-color: var(--accent); }

.btn-primary {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
}
.btn-primary:hover { opacity: 0.9; }

.stat-band {
  margin: 0 -20px;
  padding: 40px 20px;
  background: var(--bg-alt);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.stat-band-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
}
.stat-band .stat {
  flex: 1 1 0;
  min-width: 160px;
  text-align: center;
  padding: 8px 20px;
  border-left: 1px solid var(--border);
}
.stat-band .stat:first-child { border-left: none; }
.stat-value { display: block; font-size: 2rem; font-weight: 800; color: var(--accent); }
.stat-label {
  display: block;
  margin-top: 6px;
  font-size: 0.85rem;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.section { padding: 48px 0; border-top: 1px solid var(--border); }
main > .section:first-child { border-top: none; }

.section h2 {
  font-size: 1.5rem;
  margin: 0 0 28px;
}

.job { margin-bottom: 40px; }
.job:last-child { margin-bottom: 0; }

.job-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}

.job-head h3 { margin: 0; font-size: 1.15rem; }
.job-meta { color: var(--fg-muted); font-size: 0.9rem; white-space: nowrap; }

.job h4 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--fg-muted);
  margin: 18px 0 8px;
}
.job h4:first-of-type { margin-top: 4px; }

.job ul { margin: 0 0 0; padding-left: 20px; }
.job li { margin-bottom: 6px; }

.job-summary { margin: 0; color: var(--fg-muted); font-size: 0.98rem; max-width: 720px; }

.resume-summary {
  font-size: 1.05rem;
  color: var(--fg-muted);
  margin: 0 0 24px;
  max-width: 640px;
}
.resume-summary strong { color: var(--fg); }
.resume-links { display: flex; gap: 12px; flex-wrap: wrap; }

.case-study {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 32px;
}

.case-head { margin-bottom: 4px; }
.case-head h3 { margin: 0 0 4px; font-size: 1.3rem; }
.case-tag { color: var(--accent); font-size: 0.85rem; font-weight: 600; margin: 0; }

.case-lede {
  font-size: 1.05rem;
  color: var(--fg-muted);
  margin: 16px 0 28px;
  max-width: 640px;
}

.case-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
  margin-bottom: 28px;
}

.case-grid-3 { grid-template-columns: repeat(3, 1fr); }
.case-phase .case-grid { margin-bottom: 0; }

.case-grid h4 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--fg-muted);
  margin: 0 0 6px;
}
.case-grid p { margin: 0; font-size: 0.95rem; }

.project-group { margin-bottom: 20px; }
.project-group--divider { margin-top: 48px; padding-top: 40px; border-top: 1px solid var(--border); }

.project-group-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
  color: var(--accent);
  margin: 0 0 6px;
}
.project-group-note {
  margin: 0;
  color: var(--fg-muted);
  font-size: 0.95rem;
}

.case-study + .case-study { margin-top: 32px; }

.case-phase { margin-bottom: 24px; }
.case-phase h4 { font-size: 1.05rem; margin: 0 0 8px; }
.case-phase p { margin: 0 0 12px; font-size: 0.95rem; color: var(--fg-muted); }
.case-phase p:last-child { margin-bottom: 0; }
.case-phase p strong { color: var(--fg); }
.case-phase ul { margin: 8px 0 0; padding-left: 20px; }
.case-phase li { margin-bottom: 6px; font-size: 0.95rem; color: var(--fg-muted); }
.case-phase li strong { color: var(--fg); }

.case-metrics-caption {
  font-size: 0.85rem;
  color: var(--fg-muted);
  margin: 24px 0 8px;
}

.case-metrics {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}
.metric {
  flex: 1;
  min-width: 150px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.metric-value { font-size: 1.2rem; font-weight: 700; }
.metric-value .arrow { color: var(--accent); font-weight: 400; margin: 0 4px; }
.metric-label {
  font-size: 0.8rem;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.case-challenge { font-size: 0.92rem; color: var(--fg-muted); margin: 0 0 24px; }
.case-challenge strong { color: var(--fg); }

.case-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
}
.case-stack span {
  font-size: 0.8rem;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--bg-alt);
  color: var(--fg-muted);
  border: 1px solid var(--border);
}

.case-links { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 4px; }

.case-details { margin-top: 4px; }
.case-details summary.case-toggle {
  cursor: pointer;
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  padding: 10px 0;
  user-select: none;
}
.case-details summary.case-toggle::-webkit-details-marker { display: none; }
.case-details summary.case-toggle::marker { content: ""; }
.case-toggle-icon { transition: transform 0.2s ease; flex-shrink: 0; }
.case-details[open] .case-toggle-icon { transform: rotate(180deg); }
.case-toggle-open { display: none; }
.case-details[open] .case-toggle-open { display: inline; }
.case-details[open] .case-toggle-closed { display: none; }
.case-details-body { padding-top: 12px; }
.case-details-body > *:last-child { margin-bottom: 0; }

.skills-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
}

.skill-group h4 {
  font-size: 0.95rem;
  margin: 0 0 6px;
}
.skill-group p {
  margin: 0;
  color: var(--fg-muted);
  font-size: 0.92rem;
}

.awards-edu {
  display: grid;
  grid-template-columns: 3fr 2fr;
  gap: 40px;
}

.awards ul { padding-left: 20px; margin: 0; }
.awards li { margin-bottom: 10px; color: var(--fg-muted); }
.awards li strong { color: var(--fg); }

.education p { color: var(--fg-muted); margin: 0; }
.education strong { color: var(--fg); }

.contact { text-align: center; }
.contact .hero-links { justify-content: center; }

.footer {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 24px 20px 48px;
  color: var(--fg-muted);
  font-size: 0.85rem;
}

/* Chatbot widget */
#chat-widget {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 14px;
}

#chat-launcher {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: var(--accent-fg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.22);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  align-self: flex-end;
}
#chat-launcher:hover { transform: translateY(-2px); box-shadow: 0 8px 26px rgba(0, 0, 0, 0.28); }
#chat-launcher .icon-close { display: none; }
#chat-widget.open #chat-launcher .icon-open { display: none; }
#chat-widget.open #chat-launcher .icon-close { display: block; }

#chat-frame-wrap {
  width: 380px;
  height: 560px;
  max-height: calc(100vh - 120px);
  border-radius: 16px;
  overflow: hidden;
  background: var(--card-bg);
  border: 1px solid var(--border);
  box-shadow: 0 14px 44px rgba(0, 0, 0, 0.28);
  opacity: 0;
  transform: translateY(12px) scale(0.98);
  transform-origin: bottom right;
  transition: opacity 0.18s ease, transform 0.18s ease;
  pointer-events: none;
}
#chat-widget.open #chat-frame-wrap {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
#chat-frame { width: 100%; height: 100%; border: 0; display: block; }

@media (max-width: 640px) {
  .nav-inner { flex-wrap: wrap; row-gap: 8px; }
  .brand { flex: 1 0 100%; }
  .nav-links { flex-wrap: wrap; gap: 8px 14px; font-size: 0.85rem; }
  .case-grid, .case-grid-3 { grid-template-columns: 1fr; }
  .skills-grid { grid-template-columns: 1fr; }
  .awards-edu { grid-template-columns: 1fr; gap: 32px; }
  .hero-layout { flex-direction: column-reverse; gap: 28px; }
  .hero-photo { width: 160px; height: 160px; }
  .stat-band { margin: 0 -20px; }
  .stat-band .stat { border-left: none; border-top: 1px solid var(--border); flex: 1 1 100%; }
  .stat-band .stat:first-child { border-top: none; }

  #chat-widget { right: 16px; bottom: 16px; left: 16px; align-items: flex-end; }
  #chat-frame-wrap {
    width: 100%;
    height: 70vh;
    max-height: calc(100vh - 100px);
  }
}
