:root {
  --bg: #faf7f2;
  --surface: #ffffff;
  --ink: #1f2430;
  --muted: #565d6b;
  --faint: #8a8f99;
  --line: #ebe4d8;
  --accent: #1d6b86;
  --accent-ink: #ffffff;
  --accent-soft: #e3f0f4;
  --warm: #c8643b;
  --warm-soft: #fbece3;
  --glow-1: rgba(29, 107, 134, 0.10);
  --glow-2: rgba(200, 100, 59, 0.09);
  --shadow: 0 1px 2px rgba(31, 36, 48, 0.04), 0 6px 20px rgba(31, 36, 48, 0.05);
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12161c;
    --surface: #1a2029;
    --ink: #e9ebef;
    --muted: #a7aebb;
    --faint: #7d8491;
    --line: #29303b;
    --accent: #6cc0d9;
    --accent-ink: #0f1a20;
    --accent-soft: #173039;
    --warm: #efa27f;
    --warm-soft: #33251f;
    --glow-1: rgba(108, 192, 217, 0.10);
    --glow-2: rgba(239, 162, 127, 0.07);
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background:
    radial-gradient(900px 480px at 85% -120px, var(--glow-1), transparent 70%),
    radial-gradient(700px 420px at -10% 60px, var(--glow-2), transparent 70%),
    var(--bg);
  background-repeat: no-repeat;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

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

.wrap { max-width: 880px; margin: 0 auto; padding: 0 24px; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar .wrap {
  display: flex; align-items: center; justify-content: space-between;
  height: 56px; gap: 16px;
}
.brand { font-weight: 600; color: var(--ink); letter-spacing: -0.01em; }
.brand:hover { text-decoration: none; }
.nav { display: flex; gap: 22px; font-size: 14px; }
.nav a { color: var(--muted); }
.nav a:hover { color: var(--ink); text-decoration: none; }

/* ---------- Language toggle ---------- */
.lang-toggle {
  font-family: var(--mono); font-size: 12.5px; line-height: 1;
  color: var(--muted); background: var(--surface);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 12px; cursor: pointer; margin-left: 4px;
  transition: border-color 0.15s, color 0.15s;
}
.lang-toggle:hover { color: var(--ink); border-color: var(--accent); }
.lang-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Chinese sets a wider line height and a CJK-capable stack. */
:root[data-lang="zh"] body {
  font-family: "IBM Plex Sans", "Noto Sans SC", "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  line-height: 1.75;
}
:root[data-lang="zh"] .hero h1,
:root[data-lang="zh"] .detail-head h1 { letter-spacing: 0; }
:root[data-lang="zh"] .card p,
:root[data-lang="zh"] .entry li,
:root[data-lang="zh"] .detail-body li { line-height: 1.7; }

/* ---------- Hero ---------- */
.hero { padding: 88px 0 56px; }
.eyebrow {
  font-family: var(--mono); font-size: 13px; color: var(--warm);
  margin: 0 0 14px;
}
.hero h1 {
  font-size: clamp(40px, 7vw, 60px); line-height: 1.05;
  letter-spacing: -0.03em; font-weight: 600; margin: 0 0 18px;
}
.hero .lede { font-size: 19px; color: var(--muted); max-width: 36em; margin: 0 0 28px; }
.links { display: flex; flex-wrap: wrap; gap: 10px; }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--surface);
  color: var(--ink); font-size: 14px; font-weight: 500;
}
.btn:hover { border-color: var(--accent); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { opacity: 0.88; }
.btn svg { width: 16px; height: 16px; flex: none; }

/* ---------- Sections ---------- */
.section {
  display: grid; grid-template-columns: 170px 1fr; gap: 32px;
  padding: 48px 0; border-top: 1px solid var(--line);
}
.section-label {
  font-family: var(--mono); font-size: 12px; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--accent); margin: 4px 0 0;
  position: sticky; top: 80px; align-self: start;
}
.prose p { margin: 0 0 14px; max-width: 38em; }
@media (min-width: 640px) { .prose p { text-align: justify; } }
.prose p:last-child { margin-bottom: 0; }

/* ---------- Project cards ---------- */
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.card {
  display: flex; flex-direction: column; gap: 10px;
  padding: 20px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--line);
  box-shadow: var(--shadow); color: var(--ink);
  transition: border-color 0.15s, transform 0.15s;
}
.card:hover { border-color: var(--accent); transform: translateY(-2px); text-decoration: none; }
.card:hover h3 { color: var(--accent); }
.card:first-child { background: linear-gradient(135deg, var(--accent-soft), var(--surface) 60%); }
.card-meta { font-family: var(--mono); font-size: 12px; color: var(--faint); }
.card h3 { margin: 0; font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.card p { margin: 0; font-size: 14.5px; color: var(--muted); line-height: 1.55; flex: 1; }
.card-top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.card-more { font-size: 13px; color: var(--accent); white-space: nowrap; }
.card:first-child { grid-column: 1 / -1; }

.tags { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; padding: 0; margin: 0; }
.tags li {
  font-family: var(--mono); font-size: 11.5px; color: var(--accent);
  background: var(--accent-soft); border: 1px solid transparent;
  padding: 2px 8px; border-radius: 999px;
}

/* ---------- Timeline entries ---------- */
.entry { margin-bottom: 30px; }
.entry:last-child { margin-bottom: 0; }
.entry-head { display: flex; justify-content: space-between; gap: 16px; align-items: baseline; flex-wrap: wrap; }
.entry h3 { margin: 0; font-size: 16.5px; font-weight: 600; }
.entry .org { color: var(--muted); font-size: 15px; margin: 2px 0 8px; }
.date { font-family: var(--mono); font-size: 12.5px; color: var(--faint); white-space: nowrap; }
.entry ul { margin: 0; padding-left: 18px; }
.entry li { margin-bottom: 4px; font-size: 15px; }
.entry li::marker { color: var(--warm); }

.also { margin-top: 34px; padding-top: 22px; border-top: 1px dashed var(--line); }
.also h4 {
  margin: 0 0 12px; font-size: 13px; font-weight: 500; color: var(--faint);
  font-family: var(--mono); text-transform: uppercase; letter-spacing: 0.06em;
}
.also ul { list-style: none; margin: 0; padding: 0; }
.also li {
  display: flex; justify-content: space-between; gap: 16px;
  font-size: 14.5px; padding: 6px 0; flex-wrap: wrap;
}
.also li span:first-child { color: var(--ink); }
.also li .org { color: var(--muted); }

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

/* ---------- Footer ---------- */
.footer { border-top: 1px solid var(--line); padding: 48px 0 64px; background: var(--warm-soft); }
.footer h2 { font-size: 26px; letter-spacing: -0.02em; margin: 0 0 8px; font-weight: 600; }
.footer p { color: var(--muted); margin: 0 0 22px; }
.fine { font-size: 13px; color: var(--faint); margin-top: 40px !important; }

/* ---------- Project detail page ---------- */
.back { display: inline-block; margin: 36px 0 0; font-size: 14px; color: var(--muted); }
.back:hover { color: var(--ink); }
.detail-head { padding: 28px 0 32px; }
.detail-head h1 {
  font-size: clamp(32px, 5.5vw, 46px); line-height: 1.1;
  letter-spacing: -0.025em; font-weight: 600; margin: 8px 0 16px;
}
.detail-head .lede { font-size: 18px; color: var(--muted); max-width: 38em; margin: 0 0 20px; }
.detail-head .tags { margin-bottom: 24px; }
.detail-body { display: grid; gap: 40px; padding: 36px 0 72px; border-top: 1px solid var(--line); }
.detail-body h2 {
  font-family: var(--mono); font-size: 12px; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--accent); font-weight: 500; margin: 0 0 14px;
}
.detail-body ul { margin: 0; padding-left: 20px; max-width: 42em; }
.detail-body li { margin-bottom: 8px; }
.detail-body li::marker { color: var(--warm); }

/* One column, every screenshot the full width of the content, at its own height. */
.shots { display: grid; grid-template-columns: 1fr; gap: 24px; }
.shots figure { margin: 0; }
.shots a { display: block; }
/* `trim: true` in the project data: the image has a light outline baked in (top and
   sides). Enlarge it slightly so the outline falls outside the rounded clip. */
.shots a.trim { overflow: hidden; border-radius: 10px; }
.shots a.trim img { transform: scale(1.008); transform-origin: 50% 100%; }
.shots img {
  width: 100%; height: auto; display: block; border-radius: 10px;
}
.shots figcaption { font-size: 13px; color: var(--faint); margin-top: 8px; }

.pdf-frame {
  width: 100%; height: 80vh; min-height: 520px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
}
.note { font-size: 14px; color: var(--faint); margin: 12px 0 0; font-style: italic; }

.pdf-note { font-size: 14px; color: var(--muted); margin: 10px 0 0; }
.demo-note { font-size: 14px; color: var(--muted); margin: 10px 0 0; }

.missing { padding: 80px 0; }

/* ---------- Small screens ---------- */
@media (max-width: 720px) {
  .wrap { padding: 0 16px; }
  .nav { gap: 14px; font-size: 13px; }
  .nav .hide-sm { display: none; }
  .hero { padding: 56px 0 40px; }
  .hero .lede { font-size: 17px; }
  .section { grid-template-columns: 1fr; gap: 18px; padding: 40px 0; }
  .section-label { position: static; }
  .grid { grid-template-columns: 1fr; }
  .skills div { grid-template-columns: 1fr; gap: 2px; }
  .pdf-frame { height: 70vh; min-height: 420px; }
}

@media print {
  .topbar, .links, .card-more, .back { display: none; }
  body { background: #fff; color: #000; }
  .section { break-inside: avoid; }
}
