/* ============ Màu sắc & biến (mặc định: tối — phong cách công nghệ) ============ */
:root {
  --bg: #05070d;
  --surface: rgba(12, 18, 32, .62);
  --surface-2: rgba(20, 30, 52, .55);
  --text: #e6edf7;
  --muted: #8d9bb2;
  --border: rgba(120, 170, 255, .16);
  --accent: #22d3ee;
  --accent-2: #a855f7;
  --accent-soft: rgba(34, 211, 238, .1);
  --on-accent: #031018;
  --me: #67e8f9;
  --ok: #4ade80; --ok-soft: rgba(74, 222, 128, .12);
  --warn: #fbbf24; --warn-soft: rgba(251, 191, 36, .12);
  --glow: 0 0 0 1px rgba(34, 211, 238, .25), 0 0 28px rgba(34, 211, 238, .18);
  --shadow: 0 10px 40px rgba(0, 0, 0, .35);
  --radius: 16px;
  --font: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #eef3fb;
  --surface: rgba(255, 255, 255, .72);
  --surface-2: rgba(240, 246, 255, .8);
  --text: #0b1220;
  --muted: #4f5d73;
  --border: rgba(30, 70, 140, .16);
  --accent: #0891b2;
  --accent-2: #7c3aed;
  --accent-soft: rgba(8, 145, 178, .1);
  --on-accent: #ffffff;
  --me: #0e7490;
  --ok: #15803d; --ok-soft: rgba(21, 128, 61, .1);
  --warn: #a16207; --warn-soft: rgba(161, 98, 7, .1);
  --glow: 0 0 0 1px rgba(8, 145, 178, .25), 0 8px 30px rgba(8, 145, 178, .15);
  --shadow: 0 10px 30px rgba(15, 40, 90, .08);
  color-scheme: light;
}

/* ============ Nền tảng ============ */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 76px; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.65 var(--font); -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.3; margin: 0; }
svg { width: 1em; height: 1em; fill: currentColor; flex: none; }
svg.flag { width: 1.35em; height: .9em; border-radius: 2px; box-shadow: 0 0 0 1px rgba(0,0,0,.15); }
.container { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
::selection { background: var(--accent); color: var(--on-accent); }

/* Nền 3D + nền dự phòng */
#bg3d { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: 0; pointer-events: none; display: block; }
.bg-fallback {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(60vmax 50vmax at 85% 10%, color-mix(in srgb, var(--accent-2) 22%, transparent), transparent 60%),
    radial-gradient(50vmax 40vmax at 0% 80%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 60%);
  opacity: .9;
}
.has-3d .bg-fallback { opacity: .55; }
.topbar, main, .footer { position: relative; z-index: 1; }

/* ============ Thanh trên ============ */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  backdrop-filter: blur(14px) saturate(140%); -webkit-backdrop-filter: blur(14px) saturate(140%);
  border-bottom: 1px solid var(--border);
}
.topbar-inner { display: flex; align-items: center; gap: 16px; height: 60px; max-width: 1200px; }
.brand { font: 600 15px var(--mono); color: var(--text); white-space: nowrap; letter-spacing: -.02em; }
.brand::before { content: "<"; color: var(--accent); }
.brand::after { content: " />"; color: var(--accent); }
.brand:hover { text-decoration: none; }
.nav {
  display: flex; gap: 2px; overflow-x: auto; flex: 1; scrollbar-width: none;
  -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 40px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 40px), transparent);
}
.nav::-webkit-scrollbar { display: none; }
.nav a { color: var(--muted); font-size: 14px; padding: 6px 10px; border-radius: 8px; white-space: nowrap; transition: color .2s, background .2s; }
.nav a:hover { color: var(--accent); background: var(--accent-soft); text-decoration: none; }
.toolbar { display: flex; gap: 6px; margin-left: auto; }
.icon-btn {
  min-width: 36px; height: 36px; padding: 0 8px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: 600 13px var(--mono); transition: border-color .2s, color .2s, box-shadow .2s;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); box-shadow: var(--glow); }
.menu-btn { display: none; }
.music-btn[hidden] { display: none; }
.eq { display: inline-flex; align-items: flex-end; gap: 2px; height: 14px; }
.eq i { width: 3px; height: 4px; border-radius: 1px; background: currentColor; }
.music-btn.playing { color: var(--accent); border-color: var(--accent); box-shadow: var(--glow); }
.music-btn.playing .eq i { animation: eq 1s ease-in-out infinite; }
.music-btn.playing .eq i:nth-child(2) { animation-delay: -.4s; }
.music-btn.playing .eq i:nth-child(3) { animation-delay: -.7s; }
@keyframes eq { 0%, 100% { height: 4px; } 50% { height: 14px; } }

/* ============ Hero ============ */
.hero {
  display: flex; flex-direction: row-reverse; justify-content: space-between; align-items: center; gap: 48px;
  max-width: 1200px; min-height: min(calc(100vh - 60px), 820px); padding-top: 40px; padding-bottom: 56px;
}
.hero-body { max-width: 600px; }
.avatar-wrap {
  position: relative; flex: none; width: 220px; height: 220px; margin-right: clamp(0px, 8vw, 120px);
  border-radius: 50%; transition: transform .25s ease-out;
}
.avatar-wrap::before {
  content: ""; position: absolute; inset: -6px; border-radius: 50%;
  background: conic-gradient(from 0deg, var(--accent), var(--accent-2), transparent 60%, var(--accent));
  animation: spin 6s linear infinite; filter: blur(.5px);
}
.avatar-wrap::after {
  content: ""; position: absolute; inset: -30px; border-radius: 50%; z-index: -1;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--accent) 35%, transparent), transparent);
}
.avatar {
  position: relative; width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block;
  border: 4px solid var(--bg);
}
.avatar-initials {
  display: grid; place-items: center; font: 700 72px var(--mono); color: #fff; letter-spacing: -.04em;
  background: radial-gradient(circle at 30% 25%, var(--accent), var(--accent-2) 75%);
  text-shadow: 0 2px 20px rgba(0, 0, 0, .35);
}
@keyframes spin { to { transform: rotate(360deg); } }

.kicker {
  display: inline-flex; align-items: center; gap: 8px; margin: 0 0 14px;
  font: 600 12px var(--font); color: var(--accent); text-transform: uppercase; letter-spacing: .1em;
  padding: 5px 12px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface);
}
.kicker-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 10px var(--ok); animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.hero h1 { font-size: clamp(36px, 6.4vw, 64px); font-weight: 800; letter-spacing: -.03em; line-height: 1.08; }
.glow-text {
  background: linear-gradient(100deg, var(--text) 20%, var(--accent) 60%, var(--accent-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 24px color-mix(in srgb, var(--accent) 25%, transparent));
}
.hero-title { font: 500 clamp(16px, 2.2vw, 20px)/1.5 var(--mono); color: var(--accent); margin: 14px 0 0; min-height: 1.5em; }
.hero-title::before { content: "> "; color: var(--accent-2); }
.hero-title.typing::after { content: "▍"; animation: blink .8s steps(1) infinite; color: var(--accent); }
@keyframes blink { 50% { opacity: 0; } }
.hero-aff { color: var(--muted); margin: 6px 0 0; }
.hero-meta { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 16px; font-size: 14px; }
.hero-meta > * { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.hero-meta a:hover { color: var(--accent); }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 24px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px 5px 8px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  color: var(--text); font-size: 13px; font-weight: 500; transition: border-color .2s, box-shadow .2s, transform .2s;
}
.chip:hover { border-color: var(--accent); box-shadow: var(--glow); text-decoration: none; transform: translateY(-2px); }
.chip svg { font-size: 16px; }
.badge {
  display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%;
  font-size: 9px; font-weight: 700; color: #fff; background: #667;
}
.badge-orcid { background: #a6ce39; }
.badge-scholar { background: #4285f4; }
.badge-researchgate { background: #00ccbb; }
.badge-scopus { background: #e9711c; }
.badge-wos { background: #5e33bf; }

.btn {
  font-family: inherit; cursor: pointer;
  position: relative; display: inline-flex; align-items: center; gap: 8px; padding: 12px 20px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  font-weight: 600; font-size: 14px; transition: transform .2s, box-shadow .2s, border-color .2s;
}
.btn:hover { border-color: var(--accent); box-shadow: var(--glow); text-decoration: none; transform: translateY(-2px); }
.btn-primary {
  border-color: transparent; color: var(--on-accent);
  background: linear-gradient(110deg, var(--accent), var(--accent-2));
  box-shadow: 0 8px 30px color-mix(in srgb, var(--accent) 35%, transparent);
}
.btn-primary:hover { box-shadow: 0 10px 40px color-mix(in srgb, var(--accent-2) 45%, transparent); }

/* ============ Các mục (thẻ kính) ============ */
#content { counter-reset: sec; }
/* Màn hình rộng: tận dụng bề ngang 1200px mà vẫn giữ dòng chữ dễ đọc */
@media (min-width: 1100px) {
  #content { display: grid; grid-template-columns: 1fr 1fr; column-gap: 22px; align-items: stretch; }
  #content > .section { grid-column: 1 / -1; }
  #content > .section.half { grid-column: auto; }
  #about .prose { columns: 2; column-gap: 40px; }
  #about .prose p { break-inside: avoid; }
  #education .timeline:has(> li + li), #experience .timeline:has(> li + li) {
    display: grid; grid-template-columns: 1fr 1fr; gap: 22px 40px; border-left: 0; padding-left: 0;
  }
  #education .timeline:has(> li + li) > li, #experience .timeline:has(> li + li) > li {
    border-left: 1px solid var(--border); padding: 0 0 0 22px;
  }
  #education .timeline:has(> li + li) > li::before, #experience .timeline:has(> li + li) > li::before { left: -6px; }
}
.section {
  position: relative; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  backdrop-filter: blur(16px) saturate(140%); -webkit-backdrop-filter: blur(16px) saturate(140%);
  box-shadow: var(--shadow); padding: 30px; margin-bottom: 22px;
}
.section::before {
  content: ""; position: absolute; inset: 0 0 auto; height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent), var(--accent-2), transparent); opacity: .7;
}
.section::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .3s;
  background: radial-gradient(420px circle at var(--mx, 50%) var(--my, 0), color-mix(in srgb, var(--accent) 9%, transparent), transparent 70%);
}
.section:hover::after { opacity: 1; }
.section > h2 {
  counter-increment: sec; font-size: 22px; font-weight: 700; margin-bottom: 20px; letter-spacing: -.01em;
  display: flex; align-items: baseline; gap: 12px;
}
.section > h2::before {
  content: counter(sec, decimal-leading-zero) " //"; font: 500 13px var(--mono); color: var(--accent);
}
.section > h2::after { content: ""; flex: 1; height: 1px; align-self: center; background: linear-gradient(90deg, var(--border), transparent); }
.prose p { margin: 0 0 10px; }
.prose p:last-child { margin-bottom: 0; }

.bullets { margin: 6px 0 0; padding-left: 20px; }
.bullets li { margin: 3px 0; }
.bullets li::marker { color: var(--accent); }

.timeline { list-style: none; margin: 0; padding: 0 0 0 22px; border-left: 1px solid var(--border); }
.timeline > li { position: relative; padding-bottom: 22px; }
.timeline > li:last-child { padding-bottom: 0; }
.timeline > li::before {
  content: ""; position: absolute; left: -28px; top: 7px; width: 11px; height: 11px;
  border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft), 0 0 14px var(--accent);
}
.tl-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.tl-head h3 { font-size: 16px; font-weight: 600; }
.tl-time { font: 12px var(--mono); color: var(--accent); white-space: nowrap; padding: 2px 8px; border-radius: 6px; background: var(--accent-soft); }
.tl-sub { margin: 2px 0 0; color: var(--muted); }

.skills { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); gap: 20px; }
.skill-group h3 { font: 600 12px var(--font); color: var(--muted); margin-bottom: 10px; text-transform: uppercase; letter-spacing: .1em; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  padding: 4px 11px; border-radius: 8px; font-size: 14px;
  background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 20%, transparent);
  transition: transform .2s, box-shadow .2s;
}
.tag:hover { transform: translateY(-2px); box-shadow: var(--glow); }
.tag em { color: var(--muted); font-style: normal; }

.research-grid, .cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.card {
  position: relative; border: 1px solid var(--border); border-radius: 14px; padding: 20px; background: var(--surface-2);
  transition: transform .25s ease-out, box-shadow .25s, border-color .25s; transform-style: preserve-3d;
}
.card::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; opacity: 0; transition: opacity .25s;
  background: radial-gradient(300px circle at var(--gx, 50%) var(--gy, 50%), rgba(255, 255, 255, .1), transparent 60%);
}
.card:hover { border-color: color-mix(in srgb, var(--accent) 50%, transparent); box-shadow: var(--glow); }
.card.tilting { transition: transform .06s linear, box-shadow .25s, border-color .25s; }
.card.tilting::after { opacity: 1; }
.card > h3 { font-size: 15px; margin-bottom: 10px; }
.card p { margin: 8px 0 0; }

/* Thẻ dự án: thu gọn (tiêu đề, thời gian, công nghệ) — bấm để mở chi tiết */
.cards.projects { grid-template-columns: repeat(auto-fit, minmax(min(380px, 100%), 1fr)); align-items: start; }
.proj > summary { list-style: none; cursor: pointer; position: relative; padding-right: 30px; border-radius: 8px; }
.proj > summary::-webkit-details-marker { display: none; }
.proj > summary::after {
  content: ""; position: absolute; right: 4px; top: 5px; width: 8px; height: 8px;
  border-right: 2px solid var(--accent); border-bottom: 2px solid var(--accent);
  transform: rotate(45deg); transition: transform .25s;
}
.proj[open] > summary::after { transform: translateY(4px) rotate(-135deg); }
.proj > summary:hover h3 { color: var(--accent); }
.proj > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 6px; }
.proj .tl-head { flex-wrap: nowrap; align-items: flex-start; }
.proj .tl-head h3 { flex: 1; min-width: 0; font-size: 15px; transition: color .2s; }
.proj .tl-time { margin-top: 1px; }
.proj-tech { margin: 8px 0 0; font: 12.5px/1.6 var(--mono); color: var(--muted); }
.proj-body { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--border); font-size: 15px; }
.proj-body .kv { margin: 0 0 8px; }
.proj-body .bullets { margin-top: 0; }
.card .proj-link { margin-top: 10px; font-size: 14px; overflow-wrap: anywhere; }
@supports (interpolate-size: allow-keywords) {
  .proj { interpolate-size: allow-keywords; }
  .proj::details-content { block-size: 0; overflow: hidden; transition: block-size .3s ease, content-visibility .3s allow-discrete; }
  .proj[open]::details-content { block-size: auto; }
}
.chips:first-child { margin-top: 0; }
.stats { display: flex; flex-wrap: wrap; gap: 22px; }
.stat strong {
  display: block; font: 700 34px/1.1 var(--mono);
  background: linear-gradient(120deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.stat span { font-size: 13px; color: var(--muted); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; margin: 8px 0 0; font-size: 14px; }
.kv dt { color: var(--muted); font-family: var(--mono); font-size: 12px; padding-top: 2px; }
.kv dd { margin: 0; }

.list { list-style: none; margin: 0; padding: 0; }
.list > li { padding: 14px 0; border-bottom: 1px dashed var(--border); }
.list > li:first-child { padding-top: 0; }
.list > li:last-child { border-bottom: 0; padding-bottom: 0; }

/* ============ Giải thưởng ============ */
.award { display: flex; gap: 18px; align-items: flex-start; }
.award-body { flex: 1; min-width: 0; }
.award-img {
  flex: none; display: block; width: 96px; border-radius: 8px; overflow: hidden;
  border: 1px solid var(--border); box-shadow: var(--shadow); transition: transform .25s ease-out, box-shadow .25s;
}
.award-img:hover { box-shadow: var(--glow); }
.award-img img { display: block; width: 100%; height: auto; }
.award-desc { margin: 4px 0 8px; font-size: 14px; color: var(--muted); }

/* ============ Công bố ============ */
.pub-tools { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; margin-bottom: 8px; }
.filters { display: flex; flex-wrap: wrap; gap: 6px; }
.filter {
  border: 1px solid var(--border); background: transparent; color: var(--text);
  padding: 5px 12px; border-radius: 999px; cursor: pointer; font: 500 13px var(--font); transition: all .2s;
}
.filter:hover { border-color: var(--accent); }
.filter span { color: var(--muted); margin-left: 2px; font-family: var(--mono); font-size: 12px; }
.filter.active { background: linear-gradient(110deg, var(--accent), var(--accent-2)); border-color: transparent; color: var(--on-accent); }
.filter.active span { color: inherit; opacity: .8; }
.search {
  flex: 1; min-width: 200px; max-width: 340px; padding: 8px 12px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font: 14px var(--font);
}
.search:focus { outline: none; border-color: var(--accent); box-shadow: var(--glow); }
.pub-year { font: 600 13px var(--mono); color: var(--accent); margin: 20px 0 4px; letter-spacing: .08em; }
.pub-year::before { content: "// "; color: var(--muted); }
.pub {
  display: flex; gap: 12px; padding: 12px; margin: 0 -12px; border-radius: 12px;
  border-bottom: 1px dashed var(--border); transition: background .2s;
}
.pub:hover { background: var(--accent-soft); }
.pub:last-child { border-bottom: 0; }
.pub-num { color: var(--accent); font: 13px var(--mono); min-width: 30px; padding-top: 2px; }
.pub-body { flex: 1; min-width: 0; }
.pub-title { font-weight: 600; }
.pub-authors { font-size: 14px; margin-top: 2px; }
.me { color: var(--me); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: color-mix(in srgb, var(--me) 50%, transparent); }
.pub-venue { font-size: 14px; color: var(--muted); }
.pub-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; }
.type {
  font: 600 11px var(--mono); text-transform: uppercase; letter-spacing: .06em;
  padding: 2px 8px; border-radius: 5px; background: var(--accent-soft); color: var(--accent);
}
.type-conference { background: var(--ok-soft); color: var(--ok); }
.type-preprint { background: var(--warn-soft); color: var(--warn); }
.note { font-size: 13px; color: var(--muted); }
.pub-links { display: inline-flex; flex-wrap: wrap; gap: 6px; margin-left: auto; }
.pill {
  font: 600 12px var(--mono); padding: 3px 10px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--border); background: transparent; color: var(--accent); transition: all .2s;
}
.pill:hover { border-color: var(--accent); box-shadow: var(--glow); text-decoration: none; }
.bib { position: relative; margin-top: 10px; }
.bib pre {
  margin: 0; padding: 14px; border-radius: 10px; background: color-mix(in srgb, var(--bg) 80%, transparent);
  border: 1px solid var(--border); font: 12px/1.6 var(--mono); overflow-x: auto; white-space: pre; color: var(--text);
}
.bib .copy { position: absolute; top: 8px; right: 8px; background: var(--surface); }

/* ============ Xác minh "Tôi không phải robot" ============ */
.reveal-btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; cursor: pointer;
  border: 1px dashed color-mix(in srgb, var(--accent) 60%, transparent); background: var(--accent-soft);
  color: var(--accent); font: 500 13px var(--font);
}
.reveal-btn:hover { box-shadow: var(--glow); }
.reveal-row {
  display: inline-flex; align-items: center; gap: 10px; padding: 10px 16px; border-radius: 12px; cursor: pointer;
  border: 1px dashed color-mix(in srgb, var(--accent) 60%, transparent); background: var(--accent-soft);
  color: var(--accent); font: 500 15px var(--font); transition: all .2s;
}
.reveal-row:hover { box-shadow: var(--glow); transform: translateY(-2px); }
.reveal-row svg { font-size: 18px; }

.gate {
  width: min(440px, calc(100vw - 32px)); padding: 0; border-radius: 18px; color: var(--text);
  border: 1px solid var(--border); background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); box-shadow: var(--glow), var(--shadow);
}
.gate::backdrop { background: rgba(2, 6, 14, .6); backdrop-filter: blur(3px); }
.gate-inner { position: relative; padding: 26px 24px 24px; }
.gate h3 { font-size: 19px; margin-right: 40px; }
.gate p { margin: 8px 0 0; font-size: 14px; }
.gate-close { position: absolute; top: 14px; right: 14px; margin: 0; }
.captcha {
  display: flex; align-items: center; gap: 14px; width: 100%; margin-top: 18px; padding: 14px 16px;
  border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); color: var(--text);
  font: 500 15px var(--font); cursor: pointer; text-align: left; transition: border-color .2s, box-shadow .2s;
}
.captcha:hover:not(:disabled) { border-color: var(--accent); box-shadow: var(--glow); }
.captcha:disabled { cursor: default; }
.captcha-box {
  flex: none; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 7px;
  border: 2px solid var(--muted); background: var(--bg); font-weight: 700; color: #fff;
}
.captcha.busy .captcha-box { border-color: var(--accent); border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }
.captcha.done .captcha-box { border-color: var(--ok); background: var(--ok); }
.captcha.done { border-color: color-mix(in srgb, var(--ok) 50%, transparent); }
.captcha-label { flex: 1; }
.captcha-brand { display: inline-flex; align-items: center; gap: 4px; font: 10px var(--mono); color: var(--muted); }
.gate-msg { color: var(--warn); }
.ts-box { margin-top: 18px; min-height: 65px; display: grid; place-items: center; }
.ts-box > div, .ts-box iframe { width: 100%; }
.ts-loading { font: 12px var(--mono); color: var(--muted); }
.gate-contact { display: grid; gap: 8px; margin-top: 16px; }
.gate-contact a {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font-weight: 500;
}
.gate-contact a:hover { border-color: var(--accent); text-decoration: none; color: var(--accent); }
.gate-contact svg { color: var(--accent); font-size: 18px; }
.gate-cv { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.gate-cv .btn { flex: 1 1 180px; justify-content: center; }

/* ============ Liên hệ & chân trang ============ */
.contact { display: flex; flex-wrap: wrap; gap: 12px; }
.contact a {
  display: inline-flex; align-items: center; gap: 10px; color: var(--text); padding: 10px 16px;
  border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); transition: all .2s;
}
.contact a:hover { color: var(--accent); border-color: var(--accent); box-shadow: var(--glow); text-decoration: none; transform: translateY(-2px); }
.contact svg { color: var(--accent); font-size: 18px; }
.footer { padding: 24px 0 40px; color: var(--muted); font: 12px var(--mono); }
.footer .container { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
/* Bảng nhạc (YouTube) */
.mp {
  position: fixed; right: 16px; bottom: 16px; z-index: 20; width: min(380px, calc(100vw - 32px));
  max-height: calc(100vh - 92px); display: flex; flex-direction: column;
  border: 1px solid var(--border); border-radius: 16px; overflow: hidden;
  background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  box-shadow: var(--glow), var(--shadow);
}
.mp[hidden] { display: none; }
.mp-head { display: flex; align-items: center; gap: 8px; padding: 8px 8px 4px 14px; }
.mp-title { flex: 1; min-width: 0; font: 12px var(--mono); color: var(--accent); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mp-close, .mp-min { min-width: 30px; height: 30px; }
/* Thu nhỏ: chỉ giữ khung phát ≥ 200×200 px (yêu cầu của YouTube) */
.mp.mini { width: 220px; }
.mp.mini .mp-search, .mp.mini .mp-list { display: none; }
.mp.mini .mp-player iframe { height: 200px; }
.mp.mini .mp-head { padding: 6px 6px 6px 10px; }
.mp-search { display: flex; gap: 6px; padding: 6px 12px 10px; }
.mp-search input {
  flex: 1; min-width: 0; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); font: 14px var(--font);
}
.mp-search input:focus { outline: none; border-color: var(--accent); box-shadow: var(--glow); }
.mp-search .btn { padding: 8px 14px; }
.mp-player { flex: none; background: #000; }
.mp-player iframe { display: block; width: 100%; height: 214px; border: 0; }
.mp-player .mp-msg { color: var(--muted); padding: 24px 14px; margin: 0; background: var(--surface-2); }
.mp-list { overflow-y: auto; min-height: 0; }
.mp-msg { margin: 10px 14px; font-size: 13px; color: var(--muted); }
.mp-results { list-style: none; margin: 0; padding: 6px; }
.mp-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 6px; border: 0; border-radius: 10px;
  background: transparent; color: var(--text); text-align: left; cursor: pointer; font: inherit;
}
.mp-item:hover { background: var(--accent-soft); }
.mp-item.active { background: var(--accent-soft); box-shadow: inset 2px 0 0 var(--accent); }
.mp-item img { width: 64px; height: 48px; object-fit: cover; border-radius: 6px; flex: none; }
.mp-meta { display: flex; flex-direction: column; min-width: 0; }
.mp-t { font-size: 13px; font-weight: 500; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.mp-c { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ============ Trợ lý AI (RAG trong trình duyệt) ============ */
.rag-fab {
  position: fixed; left: 16px; bottom: 16px; z-index: 19; display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 16px; border-radius: 999px; border: 1px solid color-mix(in srgb, var(--accent) 50%, transparent); cursor: pointer;
  background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  color: var(--text); font: 600 14px var(--font); box-shadow: var(--glow); transition: transform .2s;
}
.rag-fab:hover { transform: translateY(-2px); }
.rag-fab[hidden] { display: none; }
.rag-fab-ic {
  display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; color: #fff; font-size: 13px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); animation: pulse 2.4s ease-in-out infinite;
}
.rag {
  position: fixed; left: 16px; bottom: 16px; z-index: 21; width: min(410px, calc(100vw - 32px)); height: min(600px, calc(100vh - 92px));
  display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 16px; overflow: hidden;
  background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  box-shadow: var(--glow), var(--shadow);
}
.rag[hidden] { display: none; }
.rag-head { display: flex; align-items: center; gap: 8px; padding: 10px 10px 6px 14px; }
.rag-title { flex: 1; display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; }
.rag-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 10px var(--ok); }
.rag-close { min-width: 30px; height: 30px; }
.rag-status { padding: 0 14px 8px; font: 11px var(--mono); color: var(--muted); border-bottom: 1px solid var(--border); }
.rag-status.ready { color: var(--ok); }
.rag-status.failed { color: var(--warn); }
.rag-msgs { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.rag-msg { max-width: 92%; padding: 10px 12px; border-radius: 12px; font-size: 14px; line-height: 1.55; }
.rag-msg p { margin: 0; }
.rag-msg.user { align-self: flex-end; background: linear-gradient(110deg, var(--accent), var(--accent-2)); color: var(--on-accent); border-bottom-right-radius: 4px; }
.rag-msg.bot { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.rag-list { margin: 8px 0 0; padding-left: 18px; }
.rag-list li { margin-bottom: 8px; }
.rag-list li::marker { color: var(--accent); }
.rag-ctx { display: block; font-size: 12px; font-weight: 600; color: var(--muted); }
.rag-src { display: block; margin-top: 2px; font: 11px var(--mono); color: var(--accent); }
.rag-typing { display: inline-flex; gap: 4px; }
.rag-typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: pulse 1s ease-in-out infinite; }
.rag-typing i:nth-child(2) { animation-delay: .2s; }
.rag-typing i:nth-child(3) { animation-delay: .4s; }
.rag-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.rag-chip { flex: none; margin: 0; padding: 4px 10px; cursor: pointer; font-family: inherit; font-size: 12px; }
.rag-part + .rag-part { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border); }
.rag-sub { margin: 8px 0 0 !important; }
.rag-muted { color: var(--muted); font-size: 12.5px; }
.rag-msg mark { background: color-mix(in srgb, var(--accent) 28%, transparent); color: inherit; border-radius: 3px; padding: 0 2px; }
.rag-srcs { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-top: 8px; font: 11px var(--mono); color: var(--muted); }
.rag-srcs .rag-src { display: inline; margin: 0; }
.rag-clear { min-width: 30px; height: 30px; }
.rag-form { display: flex; gap: 6px; padding: 10px 12px 12px; }
.rag-form input {
  flex: 1; min-width: 0; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); font: 14px var(--font);
}
.rag-form input:focus { outline: none; border-color: var(--accent); box-shadow: var(--glow); }
.rag-form .btn { padding: 8px 14px; }
@media (max-width: 760px) { .rag-fab-label { display: none; } .rag-fab { padding: 10px; } }

/* ============ Hiện dần khi cuộn ============ */
.reveal { opacity: 0; transform: perspective(1000px) translateY(36px) rotateX(8deg); transition: opacity .8s ease, transform .8s cubic-bezier(.2, .7, .2, 1); }
.reveal.in { opacity: 1; transform: none; }
.avatar-wrap.reveal { transform: scale(.85); }
.avatar-wrap.reveal.in { transform: none; }

/* ============ Điện thoại ============ */
@media (max-width: 760px) {
  .menu-btn { display: inline-block; }
  .nav {
    display: none; position: absolute; top: 60px; left: 0; right: 0; flex-direction: column;
    background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--border); padding: 8px 16px;
  }
  .menu-open .nav { display: flex; -webkit-mask-image: none; mask-image: none; }
  .nav a { padding: 10px; }
  .hero { flex-direction: column; text-align: center; padding-top: 56px; gap: 56px; min-height: 0; }
  .avatar-wrap { width: 150px; height: 150px; margin: 30px 0 0; }
  .avatar-initials { font-size: 50px; }
  .hero-meta, .chips, .hero-actions { justify-content: center; }
  .section { padding: 22px 16px; }
  .section > h2 { font-size: 19px; }
  .pub { margin: 0 -8px; padding: 12px 8px; }
  .pub-links { margin-left: 0; }
  .award-img { width: 72px; }
  .search { max-width: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  html { scroll-behavior: auto; }
}

/* ============ In / Lưu PDF (luôn nền trắng, không hiệu ứng) ============ */
@media print {
  :root, :root[data-theme="light"] {
    --bg: #fff; --surface: #fff; --surface-2: #fff; --text: #000; --muted: #444; --border: #ccc;
    --accent: #0e5a8a; --accent-2: #5b2bb5; --accent-soft: #eef4f8; --me: #0e5a8a; --on-accent: #fff;
    --ok: #15803d; --ok-soft: #eef7f1; --warn: #a16207; --warn-soft: #fbf5e8;
    --shadow: none; --glow: none; color-scheme: light;
  }
  @page { margin: 14mm; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  body { font-size: 12px; background: #fff; }
  #bg3d, .bg-fallback, .topbar, .no-print, .hero-actions, .bib, .kicker, .reveal-btn, .reveal-row, .gate, .mp, .rag, .rag-fab { display: none !important; }
  .reveal { opacity: 1 !important; transform: none !important; }
  .hero { flex-direction: row; justify-content: flex-start; min-height: 0; padding: 0 0 12px; gap: 20px; }
  .avatar-wrap { width: 96px; height: 96px; margin: 0; }
  .avatar-wrap::before, .avatar-wrap::after { display: none; }
  .avatar { border: 0; }
  .avatar-initials { font-size: 32px; }
  .hero h1 { font-size: 28px; }
  .glow-text { background: none; color: #000; filter: none; }
  .hero-title { font-size: 14px; margin-top: 4px; }
  .hero-title::after { display: none; }
  .section { border: 0; padding: 0; margin: 0 0 14px; box-shadow: none; border-radius: 0; backdrop-filter: none; overflow: visible; }
  .section::before, .section::after, .card::after { display: none; }
  .section > h2 { font-size: 15px; margin-bottom: 8px; break-after: avoid; }
  .timeline > li, .pub, .list > li, .card { break-inside: avoid; }
  .timeline > li::before { box-shadow: none; }
  .card { background: #fff; transform: none !important; }
  .proj > summary::after { display: none; }
  .proj-body { font-size: inherit; }
  .proj::details-content { transition: none; block-size: auto; content-visibility: visible; }
  .award-img { width: 60px; box-shadow: none; }
  .stat strong { background: none; color: var(--accent); }
  .pub { margin: 0; padding: 6px 0; }
  .contact a { border: 0; padding: 0; background: none; }
  a { color: inherit; }
  .footer { padding: 0; }
}
