:root {
  --bg: #ffffff;
  --bg-alt: #f5f7fb;
  --text: #1a1a1a;
  --muted: #5b6475;
  --line: #e3e7ef;
  --accent: #1b3a6b;
  --accent-soft: #e8eef8;
  --link: #1d5bbf;
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1420;
    --bg-alt: #161d2c;
    --text: #e8ebf2;
    --muted: #a3acbd;
    --line: #273149;
    --accent: #8fb3ff;
    --accent-soft: #1d2a45;
    --link: #8fb3ff;
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 72px; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
b { font-weight: 650; }
.wrap { max-width: 1040px; margin: 0 auto; padding: 0 20px; }
.muted { color: var(--muted); }

/* Nav */
.nav { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.nav-inner { display: flex; align-items: center; justify-content: space-between; height: 60px; }
.brand { font-weight: 700; color: var(--accent); font-size: 18px; }
.links a { color: var(--text); margin-left: 22px; font-size: 15px; }
.links a:hover { color: var(--accent); text-decoration: none; }
.menu-btn { display: none; background: none; border: 0; font-size: 24px; color: var(--text); cursor: pointer; }

/* Hero */
.hero { display: grid; grid-template-columns: 180px 1fr; gap: 40px; align-items: center; padding-top: 64px; padding-bottom: 32px; }
.avatar { width: 180px; height: 180px; border-radius: 50%; object-fit: cover; border: 4px solid var(--accent-soft); }
.eyebrow { margin: 0; color: var(--accent); font-weight: 600; letter-spacing: .02em; }
h1 { font-size: 44px; line-height: 1.15; margin: 6px 0 14px; }
.lead { font-size: 18px; color: var(--muted); margin: 0 0 22px; max-width: 720px; }
.meta { color: var(--muted); font-size: 14px; margin: 16px 0 0; }
.cta { display: flex; flex-wrap: wrap; gap: 10px; }
.btn { display: inline-block; padding: 9px 18px; border: 1px solid var(--line); border-radius: 999px; color: var(--text); font-weight: 550; font-size: 15px; background: var(--bg); }
.btn:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--bg); }
.btn.primary:hover { opacity: .9; color: var(--bg); }
.btn.small { padding: 6px 14px; font-size: 14px; }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 24px; }
.stats div { background: var(--bg-alt); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.stats strong { display: block; font-size: 28px; color: var(--accent); line-height: 1.2; }
.stats span { font-size: 14px; color: var(--muted); }

/* Sections */
.section { padding-top: 48px; padding-bottom: 8px; }
h2 { font-size: 26px; margin: 0 0 22px; padding-bottom: 8px; border-bottom: 2px solid var(--accent-soft); }
h2.mt { margin-top: 40px; }
h3 { font-size: 18px; margin: 0; }

/* Experience */
.role { padding: 0 0 22px; margin-bottom: 22px; border-bottom: 1px solid var(--line); }
.role:last-child { border-bottom: 0; }
.role-head { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; align-items: baseline; }
.role-head span { font-weight: 400; color: var(--muted); }
.role-head time { color: var(--muted); font-size: 15px; white-space: nowrap; }
.role ul, .card ul { margin: 10px 0; padding-left: 20px; }
.role li, .card li { margin-bottom: 6px; }
.tags { font-size: 14px; color: var(--muted); margin: 6px 0 0; }

/* Cards */
.cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
.cards.three { grid-template-columns: repeat(3, 1fr); }
.card { background: var(--bg-alt); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; display: flex; flex-direction: column; }
.card p { margin: 6px 0; }
.card .sub { color: var(--muted); margin-top: 2px; }
.card-meta { font-size: 13px; color: var(--muted); margin: 0 0 4px !important; }
.card-links { margin-top: auto; padding-top: 10px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; font-size: 15px; }
.metric { display: inline-block; align-self: flex-start; background: var(--accent-soft); color: var(--accent); font-weight: 700; padding: 2px 10px; border-radius: 999px; font-size: 14px; margin-bottom: 8px; }
.compact .card { padding: 16px; }
.compact p { font-size: 15px; color: var(--muted); }

/* Skills */
.skills { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; }
.skills div { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 18px; }
.skills h3 { font-size: 15px; color: var(--accent); }
.skills p { margin: 4px 0 0; font-size: 15px; }

/* Education */
.edu { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.edu p { margin: 4px 0; font-size: 15px; }
ul.plain { padding-left: 20px; }
ul.plain li { margin-bottom: 6px; }

/* Publications */
.pubs { padding-left: 22px; }
.pubs li { margin-bottom: 12px; }
.pubs span { display: block; font-size: 14px; color: var(--muted); }

/* Contact & footer */
.contact { padding-bottom: 32px; }
.footer { color: var(--muted); font-size: 14px; padding-top: 24px; padding-bottom: 40px; border-top: 1px solid var(--line); margin-top: 24px; }

/* Notes pages */
.note { max-width: 760px; padding-top: 48px; padding-bottom: 48px; }
.note h1 { font-size: 34px; }
.note .meta { margin-bottom: 24px; }

/* Responsive */
@media (max-width: 860px) {
  .cards, .cards.three, .edu { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 720px) {
  .menu-btn { display: block; }
  .links { display: none; position: absolute; top: 60px; left: 0; right: 0; background: var(--bg); border-bottom: 1px solid var(--line); padding: 8px 20px 16px; }
  .links.open { display: flex; flex-direction: column; }
  .links a { margin: 8px 0; }
  .hero { grid-template-columns: 1fr; gap: 20px; padding-top: 36px; text-align: left; }
  .avatar { width: 120px; height: 120px; }
  h1 { font-size: 34px; }
  .lead { font-size: 17px; }
}

/* ── Multi-page additions ── */
.links a.active { color: var(--accent); font-weight: 650; }
.footer { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
.center { text-align: center; margin-top: 22px; }
.mt-cards { margin-top: 18px; }

/* Home */
.home { display: grid; grid-template-columns: 240px 1fr; gap: 48px; align-items: center; min-height: calc(100vh - 200px); padding-top: 48px; padding-bottom: 48px; }
.home .avatar { width: 240px; height: 240px; }
.home h1 { font-size: 40px; margin: 0 0 12px; }
.home-lead { font-size: 20px; line-height: 1.6; margin: 0 0 14px; max-width: 680px; }
.home .cta { margin-top: 26px; }

/* Quote */
.quote { margin: 22px 0 0; padding: 6px 0 6px 18px; border-left: 3px solid var(--accent); font-family: Georgia, "Times New Roman", serif; font-style: italic; font-size: 18px; color: var(--muted); max-width: 640px; }
.quote cite { display: block; margin-top: 6px; font-style: normal; font-size: 14px; }
.quote cite::before { content: "— "; }

/* Page headers */
.page-head { padding-top: 48px; }
.page-head h1 { font-size: 36px; margin: 0 0 10px; }
.page-head .lead { margin-bottom: 18px; }

/* Research page */
.timeline > div { border-left: 2px solid var(--accent-soft); padding: 0 0 18px 18px; position: relative; }
.timeline > div::before { content: ""; position: absolute; left: -6px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.timeline time { font-size: 14px; color: var(--muted); }
.timeline h3 { font-size: 17px; margin: 2px 0; }
.timeline p { margin: 2px 0 0; color: var(--muted); }
.talks { padding-left: 20px; }
.talks li { margin-bottom: 10px; }
.talks span { display: block; font-size: 14px; color: var(--muted); }

/* Others page */
a.card.blog { color: var(--text); }
a.card.blog:hover { text-decoration: none; border-color: var(--accent); }
.blog .more { margin-top: auto; padding-top: 10px; color: var(--link); font-weight: 550; }
.feature-video { display: grid; grid-template-columns: 3fr 2fr; gap: 28px; align-items: center; margin-bottom: 24px; }
.embed { position: relative; aspect-ratio: 16 / 9; border-radius: var(--radius); overflow: hidden; background: #000; }
.embed iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.feature-video h3 { margin: 4px 0 8px; }
.videos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.video { display: flex; flex-direction: column; color: var(--text); }
.video:hover { text-decoration: none; }
.video:hover .vt { color: var(--accent); }
.thumb { position: relative; display: block; aspect-ratio: 16 / 9; overflow: hidden; border-radius: 10px; background: var(--bg-alt); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.dur { position: absolute; right: 8px; bottom: 8px; background: rgba(0,0,0,.75); color: #fff; font-size: 12px; padding: 1px 6px; border-radius: 4px; }
.vt { font-weight: 600; margin-top: 8px; line-height: 1.35; }
.vh { font-size: 14px; color: var(--muted); }

@media (max-width: 860px) {
  .feature-video { grid-template-columns: 1fr; }
  .videos { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 720px) {
  .home { grid-template-columns: 1fr; gap: 24px; min-height: 0; padding-top: 32px; }
  .home .avatar { width: 150px; height: 150px; }
  .home h1 { font-size: 32px; }
  .home-lead { font-size: 18px; }
  .page-head h1 { font-size: 30px; }
}
@media (max-width: 520px) { .videos { grid-template-columns: 1fr; } }

/* ── Polish pass ── */
body { background: var(--bg); }
main { overflow-x: clip; }
.home { position: relative; }
.home::before { content: ""; position: absolute; inset: 0 -40vw; z-index: -1;
  background: radial-gradient(ellipse 40% 60% at 20% 50%, var(--accent-soft), transparent 70%); }
.home .avatar, .avatar { box-shadow: 0 10px 30px rgba(27,58,107,.18); }

/* Page header panel */
.page-head { margin-top: 32px; padding: 36px 40px; border-radius: 18px;
  background: linear-gradient(135deg, var(--accent-soft) 0%, var(--bg-alt) 100%); border: 1px solid var(--line); }
.page-head .lead { color: var(--text); opacity: .85; font-size: 17px; max-width: 820px; }
.page-head + .stats { margin-top: 22px; }

/* Section titles: short accent bar instead of full rule */
h2 { border-bottom: 0; padding-bottom: 0; position: relative; margin-bottom: 26px; }
h2::after { content: ""; display: block; width: 44px; height: 3px; border-radius: 3px; background: var(--accent); margin-top: 10px; }
.section { padding-top: 56px; }

/* Chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chip { font-size: 14px; padding: 4px 12px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-weight: 550; }
.chips.small .chip { font-size: 12.5px; padding: 2px 10px; background: transparent; border: 1px solid var(--line); color: var(--muted); font-weight: 500; }
.skills h3 { margin-bottom: 4px; }
.page-head .chips { margin-top: 4px; margin-bottom: 18px; }
.page-head .chip { background: var(--bg); }

/* Cards: gentle lift on hover */
.card, .skills > div, .stats > div, .case { transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease; }
.card:hover, .skills > div:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(15,30,60,.08); border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); }
.stats strong { font-size: 30px; }

/* Experience as clean cards */
.role { border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; margin-bottom: 16px; }
.role:last-child { border-bottom: 1px solid var(--line); }

/* Publications */
.pubs li { padding: 10px 12px; border-radius: 10px; margin-bottom: 6px; }
.pubs li:hover { background: var(--bg-alt); }
.badge { display: inline-block; font-size: 11.5px; font-weight: 650; padding: 1px 8px; border-radius: 999px; background: #fff1e0; color: #a3530b; margin-left: 6px; vertical-align: 2px; }
@media (prefers-color-scheme: dark) { .badge { background: #3a2a17; color: #ffc48a; } }

/* Videos: 4 per row on wide screens */
.videos { grid-template-columns: repeat(4, 1fr); }
.thumb { box-shadow: 0 4px 14px rgba(15,30,60,.10); }
@media (max-width: 1000px) { .videos { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 860px) { .videos { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 520px) { .videos { grid-template-columns: 1fr; } }

@media (max-width: 720px) {
  .page-head { padding: 26px 22px; margin-top: 20px; }
  .role { padding: 16px; }
}
.pubs .badge { display: inline-block; }
.skills .chips { border: 0; padding: 0; border-radius: 0; }
.skills .chips:hover { transform: none; box-shadow: none; }

/* Research intro with sketch */
.research-intro { display: grid; grid-template-columns: 300px 1fr; gap: 36px; align-items: start; }
.research-intro .sketch { width: 100%; height: auto; border-radius: 12px; background: #fafafa; border: 1px solid var(--line); }
.research-intro .eyebrow { margin: 0 0 6px; }
.research-intro h1 { color: #c2571a; font-size: 34px; line-height: 1.2; margin-bottom: 16px; }
.research-intro p { margin: 0 0 14px; }
@media (prefers-color-scheme: dark) { .research-intro h1 { color: #ff9a5c; } }
@media (max-width: 760px) {
  .research-intro { grid-template-columns: 1fr; gap: 20px; }
  .research-intro .sketch { max-width: 300px; }
  .research-intro h1 { font-size: 28px; }
}
.sketch-col { display: flex; flex-direction: column; gap: 10px; }
.sketch-link { font-size: 14.5px; font-weight: 550; }
@media (max-width: 760px) { .sketch-col { max-width: 300px; } }

/* Portfolio header: compact title */
.page-head h1.small-title { font-size: 22px; font-weight: 650; color: var(--accent); letter-spacing: .01em; margin-bottom: 8px; }
.page-head + .section { padding-top: 40px; }

/* Professional pass: compact header, skills as a single table-like panel */
.page-head > :last-child, .page-head > div > :last-child { margin-bottom: 0; }
.skills { display: block; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.skills > div { display: grid; grid-template-columns: 200px 1fr; gap: 16px; align-items: center; border: 0; border-radius: 0; border-bottom: 1px solid var(--line); padding: 14px 20px; }
.skills > div:last-child { border-bottom: 0; }
.skills > div:nth-child(odd) { background: var(--bg-alt); }
.skills > div:hover { transform: none; box-shadow: none; }
.skills h3 { margin: 0; font-size: 15px; }
.skills .chips { margin-top: 0; gap: 6px; }
.skills .chip { font-size: 13.5px; padding: 3px 11px; background: var(--bg); border: 1px solid var(--line); color: var(--text); font-weight: 500; }
@media (max-width: 720px) {
  .skills > div { grid-template-columns: 1fr; gap: 8px; padding: 14px 16px; }
}

/* ── Portfolio page: resume-style layout ── */
.cv { padding-bottom: 24px; }
.cv-head { padding-top: 44px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.cv-kicker { margin: 0 0 10px; font-size: 13px; font-weight: 650; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.cv-summary { margin: 0; font-size: 19px; line-height: 1.6; max-width: 780px; }
.cv-jump { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 18px; font-size: 14px; }
.cv-jump a { color: var(--muted); }
.cv-jump a:hover { color: var(--accent); text-decoration: none; }
.cv-section { padding-top: 36px; }
.cv-section h2 { font-size: 13px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); margin: 0 0 14px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.cv-section h2::after { display: none; }
.cv-skills { display: grid; grid-template-columns: 190px 1fr; gap: 8px 20px; margin: 0; font-size: 15px; }
.cv-skills dt { font-weight: 600; }
.cv-skills dd { margin: 0; color: var(--text); }
.cv-item { padding: 6px 0 18px; }
.cv-item.compact { padding-bottom: 8px; }
.cv-item-head { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; flex-wrap: wrap; }
.cv-item h3 { font-size: 17px; margin: 0; }
.cv-item h3 span, .cv-project h3 span { font-weight: 400; color: var(--muted); }
.cv-item time, .cv-project time { font-size: 14px; color: var(--muted); white-space: nowrap; }
.cv-org { margin: 2px 0 0; color: var(--muted); font-size: 15px; }
.cv-item ul, .cv-list { margin: 8px 0 0; padding-left: 20px; }
.cv-item li, .cv-list li { margin-bottom: 5px; }
.cv-tech { margin: 6px 0 0; font-size: 13.5px; color: var(--muted); }
.cv-project { padding: 4px 0 16px; }
.cv-project h3 { font-size: 17px; margin: 0; }
.cv-project p { margin: 4px 0 0; }
.cv-repos { width: 100%; border-collapse: collapse; margin-top: 6px; font-size: 15px; }
.cv-repos td { padding: 8px 0; border-top: 1px solid var(--line); vertical-align: top; }
.cv-repos td:first-child { width: 190px; font-weight: 600; padding-right: 20px; }
.cv-repos td:last-child { color: var(--muted); }
.cv-more { margin: 12px 0 0; font-size: 15px; }
@media (max-width: 720px) {
  .cv-summary { font-size: 17px; }
  .cv-skills { grid-template-columns: 1fr; gap: 2px; }
  .cv-skills dd { margin-bottom: 10px; }
  .cv-repos td:first-child { width: 120px; }
}

/* ── Fixes: portfolio header rule, calmer research page ── */
.cv-head { border-bottom: 0; padding-bottom: 6px; }
.research-intro { padding-top: 44px; gap: 40px; }
.research-intro .eyebrow { font-size: 13px; font-weight: 650; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.research-intro h1 { font-size: 30px; margin: 0 0 14px; }
.research-intro p { font-size: 16px; color: var(--text); }
.research-links { margin-top: 6px; }
.research-links a { color: var(--link); font-weight: 550; }
.cv .timeline > div { display: grid; grid-template-columns: 150px 1fr; column-gap: 20px; border-left: 0; padding: 0 0 14px 0; }
.cv .timeline > div::before { display: none; }
.cv .timeline time { grid-row: 1 / span 2; padding-top: 2px; }
.cv .timeline h3 { font-size: 16px; margin: 0; }
.cv .timeline p { font-size: 15px; }
.cv .cv-section ul.plain { margin: 0; }
.cv .pubs { padding-left: 26px; margin: 0; }
.cv .pubs li { padding: 4px 6px; margin-bottom: 8px; }
.cv .pubs li::marker { color: var(--muted); font-size: 14px; }
.cv .pubs li a { font-weight: 550; }
.cv .talks li { margin-bottom: 8px; }
.cv .talks b { font-weight: 600; }
@media (max-width: 720px) {
  .cv .timeline > div { grid-template-columns: 1fr; }
  .cv .timeline time { grid-row: auto; }
  .research-intro h1 { font-size: 26px; }
}
.research-intro p.focus { margin-top: 26px; }

/* Portfolio title in the same style as the Research headline */
.cv-title { color: #c2571a; font-size: 30px; line-height: 1.2; margin: 0 0 14px; }
.cv-head .cv-summary { font-size: 17px; max-width: 820px; }
@media (prefers-color-scheme: dark) { .cv-title { color: #ff9a5c; } }
@media (max-width: 720px) { .cv-title { font-size: 26px; } }
.first-section { padding-top: 40px; }
.home-next { margin-top: 22px; }

/* Home: calmer, professional hero */
.home { gap: 56px; }
.home::before { opacity: .6; }
.home-eyebrow { margin: 0 0 8px; font-size: 13px; font-weight: 650; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.home h1 { color: #c2571a; font-size: 38px; line-height: 1.15; margin: 0 0 18px; }
.home-lead { font-size: 18px; line-height: 1.65; margin: 0 0 12px; max-width: 640px; }
.home .quote { margin-top: 28px; padding-top: 2px; padding-bottom: 2px; font-size: 16px; border-left-width: 2px; max-width: 600px; }
@media (prefers-color-scheme: dark) { .home h1 { color: #ff9a5c; } }
@media (max-width: 720px) { .home h1 { font-size: 30px; } .home-lead { font-size: 17px; } }
