/*
 * Site stylesheet for howard0911.github.io. Implements DESIGN.md (Notebook direction).
 * Design tokens live in :root. Dark mode follows the OS until the visitor picks a theme;
 * js/theme.js then sets html[data-theme] from localStorage before first paint.
 */

/* ===== Design tokens ===== */
:root {
  --font-serif: "Source Serif 4", "Noto Serif TC", "Songti TC", serif;
  --font-sans: "IBM Plex Sans", "Noto Sans TC", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --radius: 2px;
  --container: 1120px;
  --gutter: 24px;
  --margin-col: 170px;
  --nav-h: 64px;
  /* The one motion curve: fast start, long settle (DESIGN.md, Motion) */
  --ease-out: cubic-bezier(.22, 1, .36, 1);

  --paper: #F7F4EE;
  --paper-2: #EFEBE3;
  --surface: #FFFDF8;
  --ink: #1A1A1A;
  /* Long-form reading text; slightly softer than --ink */
  --ink-body: #2A2724;
  --muted: #6B6560;
  --rule: #D9D3C7;
  --accent: #8A1C2B;
  --on-ink: #F7F4EE;
  /* Glass nav: tinted paper plus a specular top edge */
  --glass: color-mix(in srgb, var(--paper) 70%, transparent);
  --glass-edge: rgba(255, 255, 255, .7);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #141311;
    --paper-2: #1C1A17;
    --surface: #1A1816;
    --ink: #E8E4DC;
    --ink-body: #D6D1C7;
    --muted: #9A938A;
    --rule: #2E2B27;
    --accent: #D97A86;
    --on-ink: #141311;
    --glass: color-mix(in srgb, var(--paper) 66%, transparent);
    --glass-edge: rgba(255, 255, 255, .09);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #141311;
  --paper-2: #1C1A17;
  --surface: #1A1816;
  --ink: #E8E4DC;
  --ink-body: #D6D1C7;
  --muted: #9A938A;
  --rule: #2E2B27;
  --accent: #D97A86;
  --on-ink: #141311;
  --glass: color-mix(in srgb, var(--paper) 66%, transparent);
  --glass-edge: rgba(255, 255, 255, .09);
  color-scheme: dark;
}

/* ===== Base ===== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: calc(var(--nav-h) + 16px); }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: 18px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  transition: background-color .25s, color .25s;
  /* Keeps the footer at the bottom of the window on short pages */
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1 0 auto; }
img { max-width: 100%; height: auto; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4, h5, h6 { margin: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.container { max-width: var(--container); margin: 0 auto; padding: 0 var(--gutter); }
.icon { width: 18px; height: 18px; flex: none; }
/* Underlined text link: a rule-colored line at rest; on hover an accent line draws over it from the left.
   Each background layer is one flat color used as a 1px line, not a gradient. */
.text-link, .plain-list a {
  padding-bottom: 2px;
  background-image: linear-gradient(var(--accent), var(--accent)), linear-gradient(var(--rule), var(--rule));
  background-size: 0% 1px, 100% 1px;
  background-position: 0 100%, 0 100%;
  background-repeat: no-repeat;
  transition: background-size .45s var(--ease-out), color .2s var(--ease-out);
}
.text-link:hover, .text-link:focus-visible, .plain-list a:hover, .plain-list a:focus-visible {
  color: var(--accent); background-size: 100% 1px, 100% 1px;
}

/* ===== Nav (glass) ===== */
/* The include slot is the sticky element: a sticky child inside a same-height wrapper would never stick. */
.nav-slot { position: sticky; top: 0; z-index: 50; min-height: var(--nav-h); }
.site-nav {
  position: relative;
  background: var(--glass);
  -webkit-backdrop-filter: blur(18px) saturate(170%);
  backdrop-filter: blur(18px) saturate(170%);
  /* Specular highlight along the top edge of the glass */
  box-shadow: inset 0 1px 0 var(--glass-edge);
  border-bottom: 1px solid var(--rule);
  font-family: var(--font-sans);
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .site-nav { background: var(--paper); }
}
.nav-inner { display: flex; align-items: center; justify-content: space-between; height: var(--nav-h); gap: 16px; }
.brand { font-family: var(--font-serif); font-weight: 600; font-size: 19px; }
.nav-right { display: flex; align-items: center; gap: 10px; }
.nav-links { display: flex; align-items: center; gap: 26px; list-style: none; margin: 0 8px 0 0; padding: 0; }
.nav-links a {
  display: block; padding: 6px 0;
  color: var(--muted); font-size: 15px;
  border-bottom: 2px solid transparent;
  transition: color .15s;
}
.nav-links a:hover { color: var(--ink); }
.nav-links a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); }
.icon-btn {
  display: inline-grid; place-items: center;
  width: 36px; height: 36px; border-radius: var(--radius);
  border: 0; background: none; color: var(--muted);
  cursor: pointer; transition: color .15s;
}
.icon-btn:hover { color: var(--ink); }
.icon-btn .icon { width: 17px; height: 17px; }
.i-sun { display: none; }
:root[data-theme="dark"] .i-sun { display: block; }
:root[data-theme="dark"] .i-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .i-sun { display: block; }
  :root:not([data-theme="light"]) .i-moon { display: none; }
}
.menu-btn { display: none; }
/* Resume link inside the mobile menu; desktop shows the .nav-resume button instead */
.nav-menu-resume { display: none; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 42px; padding: 0 18px; border-radius: var(--radius);
  border: 1px solid var(--ink); background: transparent; color: var(--ink);
  font-family: var(--font-sans); font-size: 15px; font-weight: 500; white-space: nowrap;
  transition: background-color .15s, border-color .15s, color .15s;
}
.btn:hover { background: var(--paper-2); }
.btn-primary { background: var(--ink); color: var(--on-ink); }
.btn-primary:hover { background: var(--accent); border-color: var(--accent); color: var(--on-ink); }
.btn-sm { height: 34px; padding: 0 14px; font-size: 14px; }

/* ===== Margin grid: a narrow column of mono notes beside the content ===== */
.margin-grid { display: grid; grid-template-columns: var(--margin-col) minmax(0, 1fr); gap: 32px; }
.margin-note { padding-top: 6px; font-family: var(--font-mono); font-size: 13px; line-height: 1.7; color: var(--muted); }
.margin-grid .margin-note p { margin: 0; }
.margin-note h2 { font: inherit; color: var(--ink); }

/* ===== Home ===== */
/* Vertical padding only: the element is also a .container and keeps its side gutters */
.home-intro { padding-top: 72px; padding-bottom: 56px; }
.home-intro h1 {
  max-width: 20em;
  font-size: clamp(30px, 2.4vw + 12px, 44px); line-height: 1.3; font-weight: 600; letter-spacing: -.005em;
  text-wrap: balance;
}
.home-intro h1 em { font-style: italic; font-weight: 400; color: var(--accent); }
.home-intro p { margin: 20px 0 0; max-width: 36em; color: var(--ink-body); }
.inline-links { display: flex; flex-wrap: wrap; gap: 8px 24px; margin-top: 24px; font-family: var(--font-sans); font-size: 15px; }
.home-photo { margin: 0 0 72px; }
.home-photo img { display: block; width: 100%; aspect-ratio: 16 / 6.5; object-fit: cover; }
.home-photo figcaption { display: flex; justify-content: space-between; gap: 16px; margin-top: 10px; font-family: var(--font-mono); font-size: 12.5px; color: var(--muted); }
.home-block { padding-bottom: 72px; }
.more-link { margin: 16px 0 0; font-family: var(--font-sans); font-size: 15px; }

/* ===== Writing index (home and articles.html) ===== */
.index-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--ink); }
.entry { border-bottom: 1px solid var(--rule); }
.entry[hidden] { display: none; }
.entry a { position: relative; display: grid; grid-template-columns: 108px minmax(0, 1fr) 90px; gap: 20px; align-items: baseline; padding: 16px 0; }
/* On hover the row's bottom rule is redrawn in accent from the left */
.entry a::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px;
  background: var(--accent); transform: scaleX(0); transform-origin: left;
  transition: transform .5s var(--ease-out);
}
.entry a:hover::after, .entry a:focus-visible::after { transform: scaleX(1); }
.entry-date { font-family: var(--font-mono); font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; transition: color .2s var(--ease-out); }
.entry a:hover .entry-date, .entry a:focus-visible .entry-date { color: var(--accent); }
.entry-title { font-size: 19px; line-height: 1.5; text-wrap: pretty; transition: color .15s; }
.entry-gloss { display: block; margin-top: 2px; font-style: italic; font-size: 16px; color: var(--muted); }
.entry-topic { font-family: var(--font-sans); font-size: 13.5px; color: var(--muted); text-align: right; }
.entry a:hover .entry-title { color: var(--accent); }

/* ===== Albums ===== */
.album-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; }
/* A cover and a second photo from the album stacked in one 4:5 frame; on hover the second fades in (no zoom) */
.album-media { position: relative; display: block; aspect-ratio: 4 / 5; overflow: hidden; background: var(--paper-2); }
.album-media img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.album-media img + img { opacity: 0; transition: opacity .5s var(--ease-out); }
.album:hover .album-media img + img, .album:focus-visible .album-media img + img { opacity: 1; }
.album-title { display: block; margin-top: 10px; font-size: 18px; line-height: 1.4; transition: color .15s; }
.album:hover .album-title { color: var(--accent); }
.album-meta { display: block; font-family: var(--font-mono); font-size: 12.5px; color: var(--muted); }
.album-sub { margin: 6px 0 0; font-size: 16px; line-height: 1.55; color: var(--ink-body); }

/* ===== Page heads and sections ===== */
.page-head { padding: 72px 0 40px; }
.page-head h1 { font-size: clamp(32px, 2vw + 20px, 44px); line-height: 1.25; font-weight: 600; text-wrap: balance; }
.kicker { margin: 0 0 10px; font-family: var(--font-mono); font-size: 13px; color: var(--accent); }
.lede { margin: 16px 0 0; max-width: 36em; color: var(--muted); font-size: 19px; line-height: 1.6; }
.intro { margin-top: 28px; max-width: 38em; color: var(--ink-body); }
.intro p { margin: 0 0 1em; }
.intro p:last-child { margin-bottom: 0; }

.section { padding: 72px 0; }
.section + .section, .page-head + .section { border-top: 1px solid var(--rule); }
.page-head + .section { padding-top: 40px; }
.section-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 20px 32px; margin-bottom: 32px; }
.section h2 { font-size: clamp(25px, 1vw + 18px, 30px); line-height: 1.3; font-weight: 600; }
.section-sub { margin: 12px 0 0; max-width: 36em; color: var(--muted); }
.subhead { margin: 48px 0 16px; font-size: 20px; font-weight: 600; }

/* ===== Timeline (experience and projects) ===== */
.timeline { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--ink); }
.tl-item { display: grid; grid-template-columns: var(--margin-col) minmax(0, 1fr); gap: 32px; padding: 28px 0; border-bottom: 1px solid var(--rule); }
.tl-date { padding-top: 5px; font-family: var(--font-mono); font-size: 13px; color: var(--muted); }
.tl-item.is-current .tl-date { color: var(--accent); }
.tl-role { font-size: 20px; font-weight: 600; line-height: 1.4; }
.tl-role a:hover { color: var(--accent); }
.tl-org { margin: 2px 0 12px; font-family: var(--font-sans); color: var(--muted); font-size: 15px; }
.tl-group { margin: 20px 0 8px; font-size: 17px; font-weight: 600; }
.tl-item ul:not(.tags) { margin: 0; padding-left: 1.15em; max-width: 40em; display: grid; gap: 8px; color: var(--ink-body); font-size: 17px; line-height: 1.65; }
.tl-item li::marker { color: var(--muted); }
.tl-item .tags { margin: 4px 0 14px; }
.tl-links { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 4px 0 12px; font-family: var(--font-sans); font-size: 14.5px; }
.tl-links a { display: inline-flex; align-items: center; gap: 4px; color: var(--accent); }
.tl-links a:hover { text-decoration: underline; text-underline-offset: .25em; }

/* Tags read as a plain dot-separated line, not pills */
.tags { display: flex; flex-wrap: wrap; gap: 2px 0; list-style: none; margin: 0; padding: 0; font-family: var(--font-sans); font-size: 13.5px; color: var(--muted); }
.tag:not(:last-child)::after { content: "·"; margin: 0 8px; }

/* ===== Education, coursework, skills, lists ===== */
.edu-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 32px; }
.edu { display: flex; justify-content: space-between; gap: 16px; padding: 18px 0; border-top: 1px solid var(--ink); }
.edu-school { margin: 0; font-weight: 600; font-size: 19px; }
.edu-school a:hover { color: var(--accent); }
.edu-degree { margin: 2px 0 0; color: var(--muted); font-size: 16px; }
.edu-years { font-family: var(--font-mono); font-size: 13px; color: var(--muted); white-space: nowrap; padding-top: 5px; }

.course-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 32px; }
.course { padding: 16px 0; border-top: 1px solid var(--rule); }
.course h4 { margin-bottom: 8px; font-size: 17px; font-weight: 600; }
.course ul { margin: 0; padding-left: 1.1em; display: grid; gap: 4px; color: var(--ink-body); font-size: 16px; }
.course li::marker { color: var(--muted); }

.skills { display: grid; grid-template-columns: 1fr 1fr; gap: 0 40px; margin: 0; }
.skills div { display: grid; grid-template-columns: 170px 1fr; gap: 16px; padding: 14px 0; border-top: 1px solid var(--rule); }
.skills dt { font-weight: 600; font-size: 17px; }
.skills dd { margin: 0; color: var(--ink-body); font-size: 16px; }

.split { display: grid; grid-template-columns: 1fr 1fr; gap: 48px; }
.split h2 { margin-bottom: 20px; }
.plain-list { list-style: none; margin: 0; padding: 0; }
.plain-list li { display: flex; justify-content: space-between; gap: 16px; padding: 12px 0; border-top: 1px solid var(--rule); font-size: 17px; }
.plain-list li:last-child { border-bottom: 1px solid var(--rule); }
.issuer { flex: none; font-family: var(--font-sans); color: var(--muted); font-size: 14px; }

/* ===== Category filter (text tabs) ===== */
/* Tabs sit directly on the list's top rule */
.section-head:has(.filters) { margin-bottom: 0; }
.filters { display: flex; flex-wrap: wrap; gap: 4px 26px; }
.chip {
  padding: 0 0 10px; margin-bottom: -1px;
  border: 0; border-bottom: 2px solid transparent; background: none; color: var(--muted);
  font-family: var(--font-sans); font-size: 15px; cursor: pointer;
  transition: color .15s, border-color .15s;
}
.chip:hover { color: var(--ink); }
.chip[aria-pressed="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.chip-count { margin-left: 5px; font-family: var(--font-mono); font-size: 12px; }

/* ===== Article page ===== */
.post { padding: 56px 0 88px; }
.post-layout .prose { margin: 0 auto; }
.toc { display: none; font-family: var(--font-sans); }
.toc-title { margin: 0 0 10px; font-size: 14px; color: var(--muted); }
.toc ol { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--ink); }
.toc li { border-bottom: 1px solid var(--rule); }
.toc a { display: block; padding: 7px 0; color: var(--muted); font-size: 13.5px; line-height: 1.45; transition: color .15s; }
.toc a:hover, .toc a[aria-current="true"] { color: var(--ink); }
.toc a[aria-current="true"] { font-weight: 500; }

.prose { max-width: 680px; font-size: 18px; line-height: 1.85; color: var(--ink-body); counter-reset: section; }
.prose > h1, .prose h2, .prose h3, .prose h4, .prose h5, .prose h6, .prose b, .prose strong { color: var(--ink); }
.prose .crumbs { margin: 0; font-family: var(--font-sans); font-size: 14px; color: var(--muted); }
.prose .crumbs a { color: var(--accent); }
.prose .crumbs a:hover { text-decoration: underline; text-underline-offset: .25em; }
.prose > h1 { margin: 12px 0 8px; font-size: clamp(30px, 1.2vw + 22px, 38px); line-height: 1.4; font-weight: 700; letter-spacing: .01em; }
.prose .post-en { margin: 0 0 4px; color: var(--muted); font-style: italic; font-size: 20px; line-height: 1.5; }
.prose .post-sub { margin: 0; color: var(--muted); font-size: 18px; line-height: 1.6; }
.prose .post-meta { margin: 16px 0 32px; display: flex; flex-wrap: wrap; gap: 6px 16px; font-family: var(--font-mono); font-size: 13px; color: var(--muted); }
.prose .cover { display: block; width: 100%; aspect-ratio: 21 / 9; object-fit: cover; margin: 0 0 40px; }
/* Numbered sections: the counter sits outside the heading text, so toc.js only reads the title */
.prose h2 { counter-increment: section; margin: 2.2em 0 .7em; font-size: 25px; line-height: 1.4; font-weight: 600; }
.prose h2::before {
  content: counter(section, decimal-leading-zero);
  margin-right: 12px; vertical-align: 3px;
  font-family: var(--font-mono); font-size: 14px; font-weight: 400; color: var(--accent);
}
.prose .cover + h2 { margin-top: 0; }
.prose h3 { margin: 1.8em 0 .5em; font-size: 20px; line-height: 1.45; font-weight: 600; }
.prose h4, .prose h5, .prose h6 { margin: 1.6em 0 .4em; font-size: 18px; line-height: 1.5; font-weight: 600; }
.prose p { margin: 0 0 1.2em; }
.prose ul, .prose ol { margin: 0 0 1.2em; padding-left: 1.4em; }
.prose li { margin: .35em 0; }
.prose li::marker { color: var(--muted); }
.prose b, .prose strong { font-weight: 600; }
.prose a { color: var(--accent); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: .25em; }
.prose blockquote { margin: 1.6em 0; padding-left: 22px; border-left: 1px solid var(--ink); color: var(--ink); font-size: 20px; line-height: 1.7; }
.prose code { font-family: var(--font-mono); font-size: .85em; }
.prose pre { margin: 0 0 1.4em; padding: 14px 18px; overflow-x: auto; background: var(--paper-2); border-left: 2px solid var(--accent); font-size: 15px; line-height: 1.6; }
/* Article figures are white-background diagrams; framing them keeps them readable in dark mode. */
.prose img:not(.cover) { display: block; margin: 1.6em auto; padding: 12px; border: 1px solid var(--rule); background: #fff; }

/* ===== Contact ===== */
.contact-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 32px; }
/* Icon sits inline with the label; value and note span the full width */
.contact-card {
  display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 4px 8px;
  padding: 18px 0; border-top: 1px solid var(--ink);
}
.contact-icon { display: grid; color: var(--accent); }
.contact-icon .icon { width: 16px; height: 16px; }
.contact-label { font-family: var(--font-sans); font-size: 14px; color: var(--muted); }
.contact-value { grid-column: 1 / -1; margin-top: 6px; font-weight: 600; font-size: 19px; overflow-wrap: anywhere; transition: color .15s; }
.contact-card:hover .contact-value { color: var(--accent); }
.contact-note { grid-column: 1 / -1; color: var(--muted); font-size: 16px; }

/* ===== Footer ===== */
.site-footer { padding: 28px 0 36px; border-top: 1px solid var(--rule); font-family: var(--font-sans); }
.footer-inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; color: var(--muted); font-size: 14px; }
.footer-inner p { margin: 0; }
.socials { display: flex; gap: 4px; list-style: none; margin: 0; padding: 0; }

/* ===== Motion (DESIGN.md, Motion). js/motion.js adds the state classes; none of this runs under reduced motion ===== */
/* Pages cross-fade on same-site navigation (Chrome/Edge 126+, Safari 18.2+; others switch instantly) */
@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
}
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .32s; animation-timing-function: var(--ease-out); }

/* Home headline enters once on load, word by word; the lines under it follow */
[data-enter] .w { display: inline-block; }
[data-enter].is-entering .w { animation: word-in .7s var(--ease-out) both; animation-delay: calc(var(--i) * 45ms); }
[data-enter].is-entering .margin-note,
[data-enter].is-entering h1 ~ * { animation: fade-in .7s var(--ease-out) both; animation-delay: calc(var(--n) * 45ms + 150ms); }

/* A list's top rule draws in once when it scrolls into view, then its rows follow */
.draw-list { position: relative; border-top-color: transparent; }
.draw-list::before {
  content: ""; position: absolute; left: 0; right: 0; top: -1px; height: 1px;
  background: var(--ink); transform: scaleX(0); transform-origin: left;
}
.draw-list .entry { opacity: 0; }
.draw-list.is-in::before { transform: scaleX(1); transition: transform .9s var(--ease-out); }
.draw-list.is-in .entry { animation: row-in .6s var(--ease-out) both; animation-delay: calc(300ms + var(--i) * 70ms); }
/* Once revealed, rows shown later by the category filter appear without delay */
.draw-list.is-settled .entry { animation: none; opacity: 1; }

/* The home photograph develops once, like a print in the tray */
.home-photo.is-developing img { filter: grayscale(1) contrast(.8) brightness(1.15); opacity: .55; }
.home-photo.is-developing.is-in img { filter: none; opacity: 1; transition: filter 2.2s var(--ease-out), opacity 1.4s var(--ease-out); }

/* Reading progress on article pages: a 2px accent line under the nav */
.read-progress {
  position: fixed; top: var(--nav-h); left: 0; right: 0; z-index: 49; height: 2px;
  background: var(--accent); transform: scaleX(0); transform-origin: left;
}

@keyframes word-in { from { opacity: 0; transform: translateY(.35em); } to { opacity: 1; transform: none; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes row-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ===== Responsive ===== */
@media (min-width: 1024px) {
  .post-layout.has-toc { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 56px; }
  .post-layout.has-toc .prose { margin: 0; }
  .post-layout.has-toc .toc {
    display: block; position: sticky; top: calc(var(--nav-h) + 32px); align-self: start;
    max-height: calc(100vh - var(--nav-h) - 64px); overflow-y: auto;
  }
}
@media (min-width: 761px) {
  /* Chinese body text sets evenly on wide columns; ragged-right reads better on phones */
  .prose p { text-align: justify; text-justify: inter-character; }
}
@media (max-width: 960px) {
  .course-grid, .skills, .split { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  :root { --gutter: 18px; }
  body { font-size: 17px; }
  .menu-btn { display: inline-grid; }
  .nav-resume { display: none; }
  .nav-links {
    display: none; position: absolute; top: var(--nav-h); left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 0; margin: 0;
    padding: 8px var(--gutter) 16px; background: var(--paper); border-bottom: 1px solid var(--rule);
  }
  .site-nav.is-open .nav-links { display: flex; }
  .nav-links a { padding: 12px 0; font-size: 16px; border-bottom: 1px solid var(--rule); }
  .nav-links a[aria-current="page"] { border-bottom-color: var(--rule); color: var(--accent); }
  .nav-menu-resume { display: block; }
  .nav-menu-resume a { color: var(--accent); }

  .margin-grid, .tl-item { grid-template-columns: 1fr; gap: 6px; }
  .home-intro { padding-top: 44px; padding-bottom: 36px; }
  .home-photo { margin-bottom: 48px; }
  .home-photo img { aspect-ratio: 4 / 3; }
  .home-block { padding-bottom: 48px; }
  .entry a { grid-template-columns: 1fr; gap: 2px; padding: 14px 0; }
  .entry-topic { text-align: left; }
  .album-grid, .album-grid-compact { grid-template-columns: 1fr 1fr; gap: 16px; }
  .page-head { padding: 44px 0 28px; }
  .section { padding: 48px 0; }
  .page-head + .section { padding-top: 28px; }
  .tl-item { padding: 22px 0; }
  .edu-grid, .contact-grid { grid-template-columns: 1fr; }
  .edu { flex-direction: column; gap: 4px; }
  .skills div { grid-template-columns: 1fr; gap: 2px; }
  .plain-list li { flex-direction: column; gap: 2px; }
  .post { padding: 32px 0 56px; }
  .prose { font-size: 17px; }
  .prose h2 { font-size: 22px; }
}
@media (max-width: 480px) {
  .album-grid:not(.album-grid-compact) { grid-template-columns: 1fr; }
}
/* Touch screens: 44px minimum tap targets */
@media (pointer: coarse) {
  .icon-btn { width: 44px; height: 44px; }
  .btn { height: 44px; }
  .chip { padding-top: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
  .read-progress { display: none; }
  html { scroll-behavior: auto; }
}
