:root {
  color-scheme: light;
  --bg: #ffffff;
  --text: #222222;
  --muted: #666666;
  --link: #1a5fb4;
  --border: #e5e5e5;
  --map-land: #dcdcdc;
  --map-visited: #1a5fb4;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #161618;
    --text: #e4e4e4;
    --muted: #9a9a9a;
    --link: #78aeed;
    --border: #333336;
    --map-land: #3a3a3e;
    --map-visited: #78aeed;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #161618;
  --text: #e4e4e4;
  --muted: #9a9a9a;
  --link: #78aeed;
  --border: #333336;
  --map-land: #3a3a3e;
  --map-visited: #78aeed;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
}
main {
  max-width: 800px;
  margin: 0 auto;
  padding: 40px 16px 64px;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Site header */
.site-header { border-bottom: 1px solid var(--border); }
.site-header nav {
  max-width: 800px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.site-header .brand { color: var(--text); font-weight: 600; white-space: nowrap; }
.nav-links { display: flex; align-items: center; gap: 20px; }
.nav-links a { color: var(--muted); }
.nav-links a[aria-current="page"] { color: var(--text); font-weight: 500; }

.theme-toggle {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}
.theme-toggle:hover { border-color: var(--muted); }

/* Homepage intro */
.intro {
  display: flex;
  gap: 40px;
  align-items: center;
}

.avatar {
  width: 220px;
  height: 220px;
  flex-shrink: 0;
  object-fit: cover;
  border-radius: 12px;
  box-shadow: 0 0 0 1px var(--border), 0 2px 10px rgba(0, 0, 0, 0.15);
}

/* Life page: photos side by side, all the same size. On narrow phones every tile
   shrinks equally so three still fit in a row (100vw minus page padding and gaps). */
.photo-row {
  --tile: min(140px, calc((100vw - 32px - 20px) / 3));
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 16px 0 8px;
}
.photo-row a { display: block; cursor: zoom-in; }
.photo-row img {
  display: block;
  width: var(--tile);
  height: var(--tile);
  object-fit: cover;
  border-radius: 8px;
  box-shadow: 0 0 0 1px var(--border);
}

/* Enlarged photo (assets/lightbox.js) */
.lightbox {
  padding: 0;
  border: 0;
  background: transparent;
  max-width: none;
  max-height: none;
  cursor: zoom-out;
}
.lightbox::backdrop { background: rgba(0, 0, 0, 0.85); }
.lightbox img {
  display: block;
  max-width: 92vw;
  max-height: 92vh;
  border-radius: 10px;
}
h1 { font-size: 1.9rem; margin: 0 0 4px; font-weight: 600; }
h1 .zh {
  font-family: "LXGW WenKai TC", "Kaiti SC", "STKaiti", serif;
  font-weight: 400;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.subtitle { color: var(--muted); margin: 0 0 12px; }
.links a { margin-right: 14px; white-space: nowrap; }

h2 {
  font-size: 1.2rem;
  font-weight: 600;
  margin: 40px 0 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
ul { padding-left: 20px; margin: 0; }
li { margin-bottom: 10px; }
.muted { color: var(--muted); }
.venue { font-weight: 600; }
.note { font-size: 0.9rem; margin: 8px 0 0; }
/* Heading with a small note beside it (wraps under the heading on narrow screens) */
h2.with-note { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 12px; row-gap: 2px; }
h2.with-note .note { margin: 0; font-weight: 400; }
.row { display: flex; justify-content: space-between; gap: 16px; }
.row .date { color: var(--muted); white-space: nowrap; }
.gpa {
  display: inline-block;
  margin-left: 6px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.6;
  white-space: nowrap;
  vertical-align: 1px;
}
/* Education page: collapsible course lists (native <details>) */
.course-group summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}
.course-group summary::-webkit-details-marker { display: none; }
.course-group summary::before {
  content: "";
  width: 6px;
  height: 6px;
  margin: 0 2px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg);
  transition: transform 0.2s ease;
}
.course-group[open] summary::before { transform: rotate(45deg); }
.course-group summary .muted { font-weight: 400; }
.course-group .courses { margin: 0 0 12px 22px; width: calc(100% - 22px); }
.courses { border-collapse: collapse; width: 100%; table-layout: fixed; }
.courses td { padding: 8px 24px 8px 0; vertical-align: top; }
.courses .code { width: 9em; white-space: nowrap; color: var(--muted); }
.courses .grade { width: 2em; padding-right: 0; text-align: right; color: var(--muted); }

/* Life page world map (assets/travel-map.js) */
.travel-map { margin-top: 8px; }
.travel-map svg { display: block; width: 100%; height: auto; }
.travel-map .country { fill: var(--map-land); stroke: var(--bg); stroke-width: 0.5; }
.travel-map .country.visited { fill: var(--map-visited); }

footer {
  margin-top: 48px;
  color: var(--muted);
  font-size: 0.85rem;
}

@media (max-width: 600px) {
  .nav-links { gap: 14px; }
  .intro { flex-direction: column; text-align: center; gap: 16px; }
  .avatar { width: 180px; height: 180px; }
  .links a { margin: 0 7px; }
  .row { flex-direction: column; gap: 0; }
  .gpa { margin-left: 0; }
  .courses .code { width: 8em; }
  .courses td { padding: 7px 12px 7px 0; }
}

@media (max-width: 360px) {
  .site-header nav { font-size: 15px; }
  .nav-links { gap: 10px; }
}
