:root {
  --bg: #fbf1c7;
  --surface: #f9f5d7;
  --text: #3c3836;
  --muted: #7c6f64;
  --border: #d5c4a1;
  --accent: #076678;
  --accent-soft: #ebdbb2;
  --warm: #af3a03;
  --mark: rgba(215, 153, 33, .35);
  --on-accent: #fbf1c7;
  --shadow: 0 1px 2px rgba(60, 56, 54, .06), 0 4px 16px rgba(60, 56, 54, .06);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #282828;
    --surface: #32302f;
    --text: #ebdbb2;
    --muted: #a89984;
    --border: #504945;
    --accent: #83a598;
    --accent-soft: #3c3836;
    --warm: #fe8019;
    --mark: rgba(250, 189, 47, .22);
    --on-accent: #282828;
    --shadow: none;
  }
}

:root[data-theme="dark"] {
  --bg: #282828;
  --surface: #32302f;
  --text: #ebdbb2;
  --muted: #a89984;
  --border: #504945;
  --accent: #83a598;
  --accent-soft: #3c3836;
  --warm: #fe8019;
  --mark: rgba(250, 189, 47, .22);
  --on-accent: #282828;
  --shadow: none;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 72px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", "Noto Sans TC", sans-serif;
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

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

h1, h2, h3 { line-height: 1.25; margin: 0; }
h1, h2 { font-family: "Source Serif 4", Georgia, serif; font-weight: 600; }

/* Nav */
.nav {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.nav-inner {
  max-width: 920px; margin: 0 auto; padding: 0 16px;
  height: 56px; display: flex; align-items: center; gap: 24px;
}
.brand { font-weight: 700; color: var(--text); white-space: nowrap; }
.brand:hover { text-decoration: none; }
.nav nav { display: flex; gap: 20px; margin-left: auto; overflow-x: auto; scrollbar-width: none; }
.nav nav::-webkit-scrollbar { display: none; }
.nav nav a { color: var(--muted); font-size: 14px; font-weight: 500; white-space: nowrap; }
.nav nav a:hover { color: var(--text); text-decoration: none; }

.theme-toggle {
  flex: none; width: 34px; height: 34px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--muted);
  display: grid; place-items: center; cursor: pointer;
}
.theme-toggle:hover { color: var(--text); }
.icon-sun { display: none; }
:root[data-theme="dark"] .icon-sun { display: block; }
:root[data-theme="dark"] .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-sun { display: block; }
  :root:not([data-theme="light"]) .icon-moon { display: none; }
}

/* Layout */
main { max-width: 920px; margin: 0 auto; padding: 0 16px; }
section { padding: 48px 0; border-bottom: 1px solid var(--border); }
section:last-child { border-bottom: none; }
section > h2 { font-size: 28px; margin-bottom: 24px; }

/* Hero */
.hero { display: flex; gap: 40px; align-items: flex-start; padding-top: 64px; }
.avatar {
  flex: none; width: 148px; height: 148px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--warm));
  color: #fff; display: grid; place-items: center;
  font-family: "Source Serif 4", Georgia, serif; font-size: 52px; font-weight: 600;
  box-shadow: var(--shadow);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.hero h1 { font-size: 40px; letter-spacing: -.01em; }
.role { color: var(--muted); margin: 8px 0 16px; font-weight: 500; }
.bio { margin: 0 0 16px; }

.tags { list-style: none; padding: 0; margin: 0 0 20px; display: flex; flex-wrap: wrap; gap: 8px; }
.tags li {
  background: var(--accent-soft); color: var(--accent);
  font-size: 13px; font-weight: 600; padding: 4px 12px; border-radius: 999px;
}

.links { display: flex; flex-wrap: wrap; gap: 8px; }
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: 8px; font-size: 14px; font-weight: 500;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
.btn:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { color: var(--on-accent); opacity: .9; }

/* News */
.news { list-style: none; padding: 0; margin: 0; }
.news li { display: flex; gap: 16px; padding: 6px 0; }
.news .date { flex: none; width: 48px; color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 500; }

/* Publications */
.note { color: var(--muted); font-size: 14px; margin: -12px 0 16px; }
.year { font-size: 15px; color: var(--muted); font-weight: 600; margin: 24px 0 8px; }
.pubs { list-style: none; padding: 0; margin: 0; }
.pubs li {
  display: flex; gap: 20px; padding: 18px 12px; margin: 0 -12px;
  border-bottom: 1px dashed var(--border);
  transition: background-color .2s ease, box-shadow .2s ease;
}
@media (hover: hover) {
  .pubs li:hover {
    background: var(--accent-soft);
    box-shadow: inset 3px 0 0 var(--warm);
    border-bottom-color: transparent; border-radius: 12px;
  }
  .pubs li:hover .venue { background: var(--surface); }
  .pubs li:hover .pub-title a { color: var(--accent); }
  .pubs li:hover .thumb { border-color: var(--warm); }
}
.thumb {
  flex: none; width: 200px; height: 125px; border-radius: 8px;
  border: 1px solid var(--border); background: #fff;
  display: block; position: relative;
}
.thumb img {
  width: 100%; height: 100%; object-fit: contain; padding: 6px; display: block;
  background: #fff; border-radius: 8px;
  transform-origin: left center;
  transition: transform .25s ease, box-shadow .25s ease;
}
@media (hover: hover) and (min-width: 761px) {
  .thumb:hover, .thumb:focus-visible { z-index: 5; }
  .thumb:hover img, .thumb:focus-visible img {
    transform: scale(2.6);
    box-shadow: 0 0 0 1px var(--border), 0 12px 40px rgba(0, 0, 0, .18);
  }
}
a.thumb:hover { border-color: var(--warm); }
.thumb-empty { background: var(--accent-soft); border-style: dashed; display: flex; align-items: center; justify-content: center; }
.thumb-empty span {
  font-family: "Source Serif 4", Georgia, serif; font-size: 18px; font-weight: 600;
  color: var(--accent); text-align: center; padding: 0 12px; opacity: .8;
}
.pub-body { min-width: 0; }
.pubs li:last-child { border-bottom: none; }
.venue {
  display: inline-block; margin-bottom: 4px;
  font-size: 12px; font-weight: 700;
  padding: 2px 8px; border-radius: 6px;
  background: var(--accent-soft); color: var(--warm);
}
.pubs p { margin: 0; }
.pub-title { font-weight: 600; }
.authors { font-size: 15px; }
.authors b { color: var(--accent); }
.pub-venue { font-size: 14px; color: var(--muted); font-style: italic; }

/* Experience */
.timeline { display: flex; flex-direction: column; gap: 28px; }
.item { padding-left: 20px; border-left: 2px solid var(--border); position: relative; }
.item::before {
  content: ""; position: absolute; left: -7px; top: 6px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--bg); border: 2px solid var(--warm);
}
.item-head { display: flex; justify-content: space-between; gap: 16px; }
.item h3 { font-size: 18px; }
.sub { color: var(--muted); margin: 2px 0 0; font-weight: 500; }
.meta { color: var(--muted); font-size: 14px; text-align: right; display: flex; flex-direction: column; flex: none; }
.item ul { margin: 8px 0 0; padding-left: 18px; }
.item li { margin: 2px 0; }
.item strong { font-weight: 600; color: var(--text); background: linear-gradient(transparent 60%, var(--mark) 60%); }
.item li.outcome { list-style: none; margin-left: -18px; margin-top: 6px; color: var(--muted); font-size: 15px; }
.item li.outcome::before { content: "→ "; color: var(--warm); font-weight: 700; }
.chips { list-style: none; padding: 0 !important; margin: 10px 0 0 !important; display: flex; flex-wrap: wrap; gap: 6px; }
.chips li { font-size: 12px; font-weight: 600; padding: 2px 10px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); margin: 0 !important; }

/* Education */
.edu { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 20px; box-shadow: var(--shadow);
}
.card .meta { display: block; text-align: left; margin: 0 0 6px; }
.card h3 { font-size: 17px; }
.card p:last-child { margin: 10px 0 0; font-size: 14px; }

/* Skills */
.skills { display: grid; grid-template-columns: 140px 1fr; gap: 10px 16px; margin: 0; }
.skills dt { font-weight: 600; }
.skills dd { margin: 0; color: var(--muted); }

footer {
  max-width: 920px; margin: 0 auto; padding: 32px 16px 48px;
  color: var(--muted); font-size: 14px; text-align: center;
}

/* Responsive */
@media (max-width: 760px) {
  .nav nav { display: none; }
  .theme-toggle { margin-left: auto; }
  .hero { flex-direction: column; gap: 24px; padding-top: 40px; }
  .avatar { width: 112px; height: 112px; font-size: 40px; }
  .hero h1 { font-size: 30px; }
  .pubs li { flex-direction: column; gap: 10px; }
  .thumb { width: 100%; height: 180px; }
  .thumb-empty { display: none; }
  .item-head { flex-direction: column; gap: 4px; }
  .meta { text-align: left; flex-direction: row; gap: 12px; }
  .edu { grid-template-columns: 1fr; }
  .skills { grid-template-columns: 1fr; gap: 2px; }
  .skills dd { margin-bottom: 10px; }
}

.pub-title a { color: var(--text); transition: color .2s ease; }
.pub-title a:hover { color: var(--accent); }
.pub-links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px !important; }
.pub-links a {
  font-size: 12px; font-weight: 600; padding: 2px 10px; border-radius: 6px;
  border: 1px solid var(--border); color: var(--muted);
}
.pub-links a:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
