html, body, .card, header, footer, section, nav, .btn, .tag {
  transition: background-color 0.35s ease, color 0.35s ease, border-color 0.35s ease;
}
:root {
  --bg: #ffffff;
  --bg-soft: #f6f7fb;
  --text: #20222a;
  --muted: #4f5565;
  --card: #ffffff;
  --border: #dfe3ec;
  --shadow: 0 10px 30px rgba(19,31,66,.08);
  --radius: 14px;
  --radius-sm: 10px;
  --space: clamp(16px, 2.2vw, 28px);
  --space-lg: clamp(28px, 4vw, 56px);
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans";
  --font-serif: "Roboto Slab", Georgia, serif;
  --maxw: 1120px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --bg-soft: #151822;
    --text: #e7e9ee;
    --muted: #aab0c0;
    --brand: #4f9cf0;
    --accent: #72e1d1;
    --card: #161a24;
    --border: #232838;
    --shadow: 0 10px 30px rgba(0,0,0,.35);
  }
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #ffffff;
    --bg-soft: #f6f7fb;
    --text: #20222a;
    --muted: #4f5565;
    --card: #ffffff;
    --border: #dfe3ec;
    --shadow: 0 10px 30px rgba(19, 31, 66, .08);
  }
}
[data-theme="light"] {
  --bg: #ffffff; --bg-soft: #f6f7fb; --text: #20222a; --muted: #4f5565; --card: #ffffff; --border: #dfe3ec;
  --shadow: 0 10px 30px rgba(19,31,66,.08);
}
.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}
html { scroll-behavior: smooth; }
html.menu-open { overflow: hidden; }
body {
  margin: 0;
  font-family: var(--font-sans);
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg-soft) 100%);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Layout */
.wrap { max-width: var(--maxw); margin: 0 auto; padding: var(--space-lg) var(--space); }
header { position: sticky; top: 0; backdrop-filter: saturate(180%) blur(12px); background: color-mix(in oklab, var(--bg) 85%, transparent); border-bottom: 1px solid var(--border); z-index: 999; }
header .bar { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: var(--space); max-width: var(--maxw); margin: 0 auto; padding: 14px var(--space); }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; }
.brand img { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; }
.brand .title { font-weight: 700; letter-spacing: .2px; }
nav { display: flex; gap: 16px; align-items: center; }
nav a { color: var(--text); text-decoration: none; padding: 10px 14px; border-radius: 10px; transition: background .2s ease; }
nav a:hover { background: var(--card); }
.theme-toggle {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
}

/* Hero */
.hero {display: grid; grid-template-columns: 1fr; gap: var(--space-lg); align-items: center; }
.hero .card {
  background: linear-gradient(180deg, color-mix(in oklab, var(--card) 94%, transparent), color-mix(in oklab, var(--card) 90%, transparent));
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
  padding: var(--space-lg);
}
.hero h1 { font-family: var(--font-serif); font-weight: 700; margin: 0 0 10px; font-size: clamp(28px, 4.6vw, 48px); }
.hero p.lead { color: var(--muted); font-size: clamp(16px, 2vw, 18px); margin-bottom: var(--space); }
.cta { display: flex; flex-wrap: wrap; gap: 12px; }
.btn {
  display: inline-flex; align-items: center; gap: 10px; border: 1px solid var(--border);
  background: var(--card); color: var(--text); padding: 10px 14px; border-radius: 10px; text-decoration: none;
  transition: transform .15s ease, box-shadow .15s ease, background .2s ease;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.btn.primary { background: linear-gradient(180deg, color-mix(in oklab, var(--brand) 35%, var(--card)), color-mix(in oklab, var(--brand) 20%, var(--card))); border-color: color-mix(in oklab, var(--brand) 25%, var(--border)); }
.portrait img { width: 100%; height: auto; display: block; object-fit: cover; }

/* Section headers */
section { margin-top: var(--space-lg); }
.section-head { display: flex; justify-content: space-between; align-items: end; margin-bottom: var(--space); }
.section-head h2 { font-family: var(--font-serif); font-weight: 700; margin: 0; font-size: clamp(22px, 3.2vw, 32px); }
.section-head p { color: var(--muted); margin: 6px 0 0; }

/* Menu toggle */
.menu-toggle {
  display: none;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
}

/* Mobile breakpoint */
@media (max-width: 640px) {
  body.menu-open::before {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 998;
    transition: opacity 0.3s ease;
  }
  nav#primaryNav {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s ease, opacity 0.35s ease;
    opacity: 0;
    flex-direction: column;
    background: var(--card);
    position: absolute;
    top: 60px;
    right: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 0 10px;    
  }
  nav#primaryNav.open {
    max-height: 500px;
    opacity: 1;
    padding: 10px;
  }
  .menu-toggle { display: block; }
  .menu-open { overflow: hidden; }
}

/* Timeline */
.timeline { display: grid; gap: var(--space); }
.item {
  display: grid; grid-template-columns: 64px 1fr; gap: 16px;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow);
}
.item .logo img { 
  width: 64px; 
  height: 64px; 
  object-fit: cover; 
  border-radius: 12px; 
  border: 1px solid var(--border); 
}
.item h3 { 
  margin: 0; 
  font-weight: 700; 
}
.item .sub { 
  color: var(--muted); 
  margin: 4px 0 10px; 
}
.tags { 
  display: flex; 
  flex-wrap: wrap; 
  gap: 8px; 
}
.tag { 
  font-size: 13px; 
  padding: 6px 10px; 
  border-radius: 20px; 
  background: color-mix(in oklab, var(--accent) 12%, var(--card)); 
  border: 1px solid var(--border); 
  color: var(--text); 
}

/* Projects grid */
.grid { 
  display: grid; 
  grid-template-columns: repeat(3, 1fr); 
  gap: var(--space); 
}
.card {
  background: var(--card); 
  border: 1px solid var(--border); 
  border-radius: var(--radius);
  overflow: hidden; 
  box-shadow: var(--shadow); 
  display: flex; 
  flex-direction: column;
}
.card img { 
  width: 100%; 
  aspect-ratio: 16 / 9; 
  object-fit: cover; 
}
.card .body { 
  padding: 14px 16px; 
}
.card h3 { 
  margin: 0 0 8px; 
  font-weight: 700; 
}
.card p { 
  margin: 0 0 12px; 
  color: var(--muted); 
}
.card .actions { 
  display: flex; 
  flex-wrap: wrap; 
  gap: 10px; 
  margin-top: auto; 
  padding: 0 16px 16px; 
}

/* Interests */
.list { 
  display: grid; 
  gap: 12px; 
}
.list .row {
  display: grid; 
  grid-template-columns: 36px 1fr; 
  gap: 12px; 
  align-items: start;
  padding: 14px; 
  border: 1px solid var(--border); 
  border-radius: var(--radius-sm); 
  background: var(--card);
}
.list i { 
  color: var(--brand); 
}

/* Footer */
footer { 
  margin-top: var(--space-lg); 
  padding: var(--space) var(--space); 
  border-top: 1px solid var(--border); 
  color: var(--muted); 
}
.foot { 
  max-width: var(--maxw); 
  margin: 0 auto; 
  display: grid; 
  gap: 10px; 
  align-items: center; 
}
.foot a { 
  color: var(--text); 
  text-decoration: none; 
}
.foot small { 
  font-size: 13px; 
}

/* Modal (native <dialog>) */
dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0;
  width: min(720px, 92vw);
  background: var(--card);
  color: var(--text);
  box-shadow: var(--shadow);
}
dialog::backdrop { 
  background: rgba(0,0,0,.45); 
}
.modal-head { 
  padding: 16px; 
  border-bottom: 1px solid var(--border); 
  display: flex; 
  justify-content: space-between; 
  align-items: center; 
}
.modal-body { 
  padding: 16px; 
}
.modal-foot { 
  padding: 12px 16px; 
  border-top: 1px solid var(--border); 
  display: flex; 
  justify-content: flex-end; 
}
.close-btn { 
  background: transparent; 
  border: 1px solid var(--border); 
  color: var(--text); 
  padding: 8px 12px; 
  border-radius: 8px; 
  cursor: pointer; 
}

/* Responsive */
@media (max-width: 980px) {
  .hero { grid-template-columns: 1fr; }
  .grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .grid { grid-template-columns: 1fr; }
  .item { grid-template-columns: 48px 1fr; }
  .item .logo img { 
    width: 48px; 
    height: 48px; 
    border-radius: 10px; 
  }
}

/* Focus styles */
:focus-visible { 
  outline: 3px solid color-mix(in oklab, var(--brand) 60%, white); 
  outline-offset: 2px; 
  border-radius: 6px; 
}