/* =========================================================
   4yü/專案：全站唯一樣式表
   方向：安靜、精確、像實驗室筆記；配色取自 GitHub 頭像（黑貓 × 電光藍）
   外框安靜，動態集中在幾個有意義的地方（見 AGENTS.md §6）
   ========================================================= */

/* ---------- 1. 設計變數 ---------- */
:root {
  /* 中性色階：黑貓的黑，帶一點深藍（色相統一約 219°，不偏紫） */
  --bg: #050b17;
  --surface: #0c1524;
  --raised: #141e31;
  --line: rgba(237, 243, 255, .08);
  --line-strong: rgba(237, 243, 255, .14);

  /* 文字三種角色：眼睛的白、字幕的淡藍白 */
  --text: #edf3ff;
  --text-2: #a8bbdc;
  --muted: #798ba9;

  /* 頭像背景的電光藍：填色用（主要按鈕、頁尾點陣頭像、閱讀進度） */
  --brand: #195bf5;
  --brand-hover: #3370ff;
  --on-brand: #ffffff;
  /* 電光藍提亮，給文字用的強調色 */
  --accent: #66a8ff;
  --wip: #e0b866;

  --button-highlight: inset 0 1px 0 rgba(255, 255, 255, .18);
  --image-shadow: 0 24px 48px rgba(0, 3, 10, .5);
  --float-shadow: 0 16px 40px rgba(0, 3, 10, .55);
  --scrim: rgba(2, 6, 14, .72);

  /* 英文 Times New Roman（沒有安裝的裝置用字形相同的 Tinos），中文思源黑體 */
  --font-sans: "Times New Roman", Tinos, Times, "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  /* 等寬：打字機風格的 Courier Prime，0 是乾淨的橢圓，沒有斜線或點；中文落到思源黑體 */
  --font-mono: "Courier Prime", "Courier New", "Noto Sans TC", monospace;

  --r-tag: 6px;
  --r-control: 8px;
  --r-card: 16px;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --page: 1200px;
  --gutter: 32px;
  color-scheme: dark;
}


/* ---------- 2. 基礎 ---------- */
* { box-sizing: border-box; }
html { scroll-padding-top: 80px; }
html, body { overflow-x: clip; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 18px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--text); text-decoration-color: var(--line-strong); text-underline-offset: 4px; transition: color 150ms var(--ease), text-decoration-color 150ms var(--ease); }
a:hover { color: var(--accent); text-decoration-color: currentColor; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
html { -webkit-tap-highlight-color: transparent; text-size-adjust: 100%; -webkit-text-size-adjust: 100%; }

/* 觸控裝置：可點的東西至少 40px 高，手指才點得準 */
@media (pointer: coarse) {
  .nav > a, .nav > button { height: 40px; }
  .search-trigger { height: 40px; }
  .segmented button, .segmented .thumb { height: 40px; }
  .back-link { padding: 8px 0; margin-bottom: 16px; }
  .hero > .backdrop-next { width: 40px; height: 40px; }
  .wordmark { min-height: 40px; }
}
img { max-width: 100%; display: block; }
kbd {
  font-family: var(--font-mono); font-size: 14px; line-height: 1;
  padding: 3px 6px; border-radius: 4px; color: var(--text-2);
  background: var(--raised); border: 1px solid var(--line-strong);
}
.part + .part { margin-left: 12px; }
.meta { color: var(--muted); font-family: var(--font-mono); font-size: 16px; font-variant-numeric: tabular-nums; }
.stack { color: var(--muted); font-family: var(--font-mono); font-size: 16px; }
.loading { color: var(--muted); }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* 閱讀 / 捲動進度：頁面頂端一條電光藍細條 */
.progress { position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: 50; background: var(--brand); transform: scaleX(0); transform-origin: 0 50%; pointer-events: none; }

/* ---------- 3. 頁首 / 頁尾 ---------- */
.site-header {
  position: sticky; top: 0; z-index: 30;
  height: 64px; padding: 0 var(--gutter);
  display: flex; align-items: center; justify-content: space-between;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.wordmark { font-family: var(--font-mono); font-size: 26px; line-height: 1; font-weight: 500; text-decoration: none; color: var(--text); letter-spacing: 0; }
.wordmark { display: inline-flex; align-items: center; gap: 10px; }
.wordmark-logo { height: 30px; width: auto; display: block; }
.wordmark-tld { color: var(--accent); }
.wordmark:hover { color: var(--text); }
.nav { position: relative; display: flex; align-items: center; gap: 4px; font-size: 18px; }
.nav > a, .nav > button {
  position: relative; z-index: 1; height: 32px; padding: 0 12px; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--text-2); text-decoration: none; border-radius: var(--r-control);
  font: inherit; background: transparent; border: 0; cursor: pointer;
  transition: color 150ms var(--ease);
}
.nav > a:hover, .nav > button:hover { color: var(--text); }
/* 流體 hover：一塊底色跟著游標滑到目前的連結 */
.nav-hover { position: absolute; left: 0; top: 50%; height: 32px; width: 0; margin-top: -16px; border-radius: var(--r-control); background: var(--raised); opacity: 0; pointer-events: none; }
.search-trigger { border: 1px solid var(--line-strong) !important; margin-left: 8px; width: 38px; padding: 0 !important; justify-content: center; }
.search-trigger .icon { width: 17px; height: 17px; }

.site-footer { max-width: var(--page); margin: 160px auto 0; padding: 0 var(--gutter) 40px; }
.contact {
  padding-top: 40px; border-top: 1px solid var(--line);
  display: grid; grid-template-columns: minmax(0, 1fr) 320px; grid-template-areas: "mail field" "links field";
  column-gap: 64px; row-gap: 32px; align-items: end;
}
.contact > div:first-child { grid-area: mail; align-self: center; }
.contact .meta { margin: 0 0 12px; }
.contact-mail {
  font-size: clamp(35px, 6.6vw, 79px); line-height: 1.05; font-weight: 500; letter-spacing: -0.03em;
  text-decoration: none; display: inline-block; padding: 0; background: none; border: 0; color: var(--text); cursor: pointer; font-family: inherit;
  transition: color 150ms var(--ease);
}
.contact-mail:hover { color: var(--accent); }
.contact-links { grid-area: links; align-self: start; display: flex; flex-wrap: wrap; align-items: center; gap: 24px; font-size: 18px; }
.contact-links .icon-btn:hover { color: var(--accent); }
.contact-links a { color: var(--text-2); text-decoration: none; }
.contact-links a:hover { color: var(--text); }

/* 點陣頭像：GitHub 頭像的黑貓，用點畫成；游標靠近時散開 */
.dotfield { grid-area: field; margin: 0; }
.dotfield-frame { position: relative; aspect-ratio: 1; border-radius: var(--r-card); overflow: hidden; border: 1px solid var(--line); background: var(--bg); }
.dotfield canvas { position: absolute; inset: 0; width: 100%; height: 100%; cursor: crosshair; }
.footer-base { margin-top: 64px; display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; color: var(--muted); font-size: 17px; }
.footer-base a { color: var(--text-2); }

/* ---------- 4. 按鈕 ---------- */
.button {
  height: 44px; padding: 0 20px; display: inline-flex; align-items: center; gap: 8px;
  border-radius: var(--r-control); font-size: 18px; font-weight: 500; text-decoration: none;
  border: 1px solid var(--line-strong); color: var(--text); background: var(--surface);
  transition: background-color 150ms var(--ease), transform 120ms var(--ease);
}
.button:hover { background: var(--raised); color: var(--text); }
.button:active { transform: scale(.98); }
.button.primary { background: var(--brand); color: var(--on-brand); border-color: transparent; box-shadow: var(--button-highlight); }
.button.primary:hover { background: var(--brand-hover); color: var(--on-brand); }
.button svg, .icon { width: 16px; height: 16px; stroke: currentColor; stroke-width: 1.5; fill: none; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* 只有圖示的按鈕：社群連結（GitHub、LinkedIn、Instagram） */
.socials { display: inline-flex; gap: 8px; }
.icon-btn {
  width: 40px; height: 40px; display: inline-grid; place-items: center; flex: none;
  border: 1px solid var(--line-strong); border-radius: var(--r-control); color: var(--text-2);
  transition: color 150ms var(--ease), border-color 150ms var(--ease), background-color 150ms var(--ease);
}
.icon-btn .icon { width: 18px; height: 18px; }
.icon-btn:hover { color: var(--accent); border-color: var(--accent); background: var(--surface); }

/* ---------- 5. 首頁：自我介紹 ---------- */
main { display: block; overflow-x: clip; }  /* 左右滑入時不要撐出水平捲軸 */
/* 首屏：導覽列以下剛好填滿一個畫面高度 */
.hero {
  max-width: var(--page); margin: 0 auto; padding: 64px var(--gutter) 112px;
  min-height: calc(100vh - 64px); min-height: calc(100svh - 64px);
  display: grid; grid-template-columns: minmax(0, max-content) auto; justify-content: space-between; column-gap: clamp(48px, 6vw, 88px); row-gap: 40px; align-items: center; align-content: center;
}
.hero h1 {
  font-size: clamp(40px, 5.3vw, 66px); line-height: 1.15; font-weight: 500;
  letter-spacing: -0.02em; margin: 0 0 28px;
}
.hero h1 .line { overflow: hidden; padding-bottom: .06em; }
.hero .bio { font-size: clamp(18px, 1.5vw, 21px); line-height: 1.85; color: var(--text); max-width: 56rem; text-wrap: pretty; margin: 0 0 40px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; }

.hero .bio p { margin: 0; text-wrap: pretty; }
/* 自我介紹一句一行；手機版一句折成兩行時，句與句之間多一點間距 */
.hero .bio-line { display: block; }
/* 量測每句的原始寬度用（app.js 的 fitBio） */
.hero .bio.is-measuring .bio-line, .hero .bio.is-measuring a { display: inline-block; white-space: nowrap; }
.hero .bio.is-measuring { display: block; }
/* 連結名稱不要被拆到兩行 */
.hero .bio a { white-space: nowrap; }
.hero .bio p + p { margin-top: 0.9em; }
.hero .bio a { color: var(--text); text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 5px; transition: color 150ms var(--ease), text-decoration-color 150ms var(--ease); }
.hero .bio a:hover { color: var(--accent); text-decoration-color: var(--accent); }

/* 人像：圓形小照片 */
.portrait { margin: 0; justify-self: center; display: grid; justify-items: center; gap: 16px; }
.portrait img {
  width: clamp(220px, 25vw, 340px); height: auto; aspect-ratio: 1; border-radius: 50%; object-fit: cover; object-position: 50% 30%;
  border: 1px solid var(--line-strong); box-shadow: 0 0 0 8px var(--bg), 0 0 0 9px var(--line);
}

/* ---------- 6. 首頁：專案 ---------- */
.projects { max-width: var(--page); margin: 0 auto; padding: 0 var(--gutter); }
.projects-head {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px;
  padding-top: 24px; border-top: 1px solid var(--line); margin-bottom: 72px;
}
.controls { display: flex; flex-wrap: wrap; gap: 12px; }
.views button span { font-size: 17px; }
.projects-head h2 { font-size: 31px; font-weight: 500; margin: 0; display: flex; align-items: baseline; gap: 12px; }

.segmented { position: relative; display: flex; flex-wrap: wrap; gap: 4px; padding: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.segmented button {
  position: relative; z-index: 1;
  font: inherit; font-size: 17px; height: 36px; padding: 0 14px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  background: transparent; color: var(--text-2); border: 0; border-radius: var(--r-control);
  transition: color 150ms var(--ease);
}
.segmented button .count { font-family: var(--font-mono); font-size: 14px; color: var(--muted); }
.segmented button:hover { color: var(--text); }
.segmented button[aria-selected="true"], .segmented button[aria-checked="true"] { color: var(--text); }
/* 選取中的底色會滑到被點的按鈕 */
.segmented .thumb { position: absolute; z-index: 0; top: 4px; left: 0; height: 36px; width: 0; border-radius: var(--r-control); background: var(--raised); box-shadow: inset 0 0 0 1px var(--line-strong); }

/* 精選：圖文交錯的大列 */
.lead { display: grid; gap: 112px; }
.feature { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 56px; align-items: center; text-decoration: none; color: var(--text); }
.feature:nth-child(even) { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); }
.feature:nth-child(even) .feature-shot { order: 2; }
.feature:hover { color: var(--text); }
.feature-shot { border-radius: var(--r-card); overflow: hidden; border: 1px solid var(--line); background: var(--surface); box-shadow: var(--image-shadow); }
.feature-shot img { width: 100%; height: auto; aspect-ratio: 16 / 10; object-fit: cover; object-position: top; transform-origin: 50% 0; }
.feature-shot .gen-cover { padding: 7%; }
.feature h3 { font-size: 37px; line-height: 1.25; font-weight: 500; margin: 12px 0; letter-spacing: -0.01em; }
.feature p { color: var(--text-2); margin: 0 0 20px; font-size: 20px; }
.feature p.meta, .feature p.stack { font-size: 16px; color: var(--muted); }
.feature .stack { margin: 0 0 28px; }
.feature p.meta { margin: 0; }
.read-more { display: inline-flex; align-items: center; gap: 8px; font-size: 18px; color: var(--text); }
.read-more .icon { }
.read-more span { border-bottom: 1px solid var(--line-strong); padding-bottom: 2px; transition: border-color 150ms var(--ease), color 150ms var(--ease); }
.feature:hover .read-more { color: var(--accent); }
.feature:hover .read-more span { border-color: var(--accent); }
.feature:hover .read-more .icon { transform: translateX(4px); }

/* 矩陣：全部專案排成一整面，一眼看完 */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 32px 24px; }
.tile { display: flex; flex-direction: column; text-decoration: none; color: var(--text); }
.tile:hover { color: var(--text); }
.tile-shot { border-radius: 12px; overflow: hidden; border: 1px solid var(--line); background: var(--surface); transition: border-color 150ms var(--ease); }
.tile:hover .tile-shot { border-color: var(--line-strong); }
.tile-shot img, .tile-shot .gen-cover { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; object-position: top; transition: transform 600ms var(--ease); }
.tile:hover .tile-shot img, .tile:hover .tile-shot .gen-cover { transform: scale(1.04); }
.tile-text { padding-top: 16px; }
.tile-text .meta { margin: 0 0 4px; }
.tile h3 { font-size: 22px; font-weight: 500; margin: 0 0 4px; transition: color 150ms var(--ease); }
.tile:hover h3 { color: var(--accent); }
.tile p:not(.meta) { margin: 0; color: var(--text-2); font-size: 18px; line-height: 1.6; }

/* 沒有截圖時用程式畫的專案資訊卡 */
.gen-cover {
  position: relative; display: flex; flex-direction: column; justify-content: flex-end; gap: 8px;
  width: 100%; height: 100%; aspect-ratio: 16 / 10; padding: 8%; overflow: hidden;
  background-color: var(--surface);
  background-image: radial-gradient(var(--line-strong) 1px, transparent 1.5px);
  background-size: 20px 20px; background-position: 10px 10px;
}
.gc-path { font-family: var(--font-mono); font-size: 16px; color: var(--accent); }
.gc-title { font-size: clamp(28px, 3.5vw, 48px); font-weight: 500; line-height: 1.1; letter-spacing: -0.02em; color: var(--text); }
.gc-stack { font-family: var(--font-mono); font-size: 16px; color: var(--muted); }
.gc-no { position: absolute; top: 6%; right: 7%; font-family: var(--font-mono); font-size: clamp(53px, 9.9vw, 132px); line-height: 1; color: var(--raised); font-weight: 500; }
.tile .gen-cover { padding: 7%; }
.tile .gc-title { font-size: 25px; }
.tile .gc-path, .tile .gc-stack { font-size: 13px; }
.tile .gc-no { font-size: 70px; }

/* 索引：像筆記本目錄的條列，hover 時旁邊浮出截圖預覽 */
.index-head, .index a { display: grid; grid-template-columns: 64px minmax(0, 1fr) 160px 48px; gap: 24px; }
.index-head { padding: 0 16px 12px; border-bottom: 1px solid var(--line); color: var(--muted); font-family: var(--font-mono); font-size: 16px; }
.index-head span:last-child { text-align: right; }
.index { list-style: none; margin: 0; padding: 0; }
.index li { border-bottom: 1px solid var(--line); }
.index a {
  align-items: baseline; padding: 24px 16px; text-decoration: none; color: var(--text);
  transition: background-color 150ms var(--ease);
}
.index a:hover { background: var(--surface); color: var(--text); }
.index .title { font-size: 22px; font-weight: 500; display: inline-flex; align-items: baseline; gap: 10px; }
.index .team { font-family: var(--font-mono); font-size: 14px; color: var(--muted); font-weight: 400; }
.index .tagline { display: block; color: var(--text-2); font-size: 18px; margin-top: 4px; }
.index .cat { color: var(--text-2); font-size: 17px; }
.index .year { text-align: right; }
.index .no { transition: color 150ms var(--ease); }
.index a:hover .no { color: var(--accent); }
.empty { color: var(--muted); padding: 24px 16px; margin: 0; }

.preview {
  position: fixed; left: 0; top: 0; z-index: 40; width: 280px; pointer-events: none;
  border-radius: 12px; overflow: hidden; border: 1px solid var(--line-strong); background: var(--surface);
  box-shadow: var(--float-shadow); opacity: 0; transform: scale(.96);
}
.preview img, .preview .gen-cover { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; object-position: top; }
.preview .gen-cover { padding: 7%; gap: 4px; }
.preview .gc-title { font-size: 23px; }
.preview .gc-path, .preview .gc-stack { font-size: 12px; }
.preview .gc-no { font-size: 62px; }

/* ---------- 7. 搜尋面板（⌘K） ---------- */
.palette {
  width: min(720px, calc(100vw - 32px)); max-height: min(600px, 80vh); margin: 14vh auto 0; padding: 0;
  color: var(--text); background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-card);
  box-shadow: var(--float-shadow); overflow: hidden;
}
.palette[open] { display: flex; flex-direction: column; animation: palette-in 220ms var(--ease); }
.palette::backdrop { background: var(--scrim); }
@keyframes palette-in { from { opacity: 0; transform: translateY(-8px) scale(.98); } }
/* 搜尋框：左邊放大鏡、右邊標出快捷鍵 ⌘K */
.palette-field { display: flex; align-items: center; gap: 14px; padding: 0 20px; border-bottom: 1px solid var(--line); }
.palette-field > .icon { width: 22px; height: 22px; color: var(--muted); }
.palette input {
  flex: 1; min-width: 0; font: inherit; font-size: 22px; height: 72px; padding: 0; color: var(--text);
  background: transparent; border: 0; outline: none;
}
.palette input::-webkit-search-cancel-button { display: none; }
.palette-kbd { flex: none; font-family: var(--font-mono); font-size: 15px; color: var(--text-2); padding: 4px 8px; border: 1px solid var(--line-strong); border-radius: var(--r-tag); }
.palette input::placeholder { color: var(--muted); }
.palette-list { list-style: none; margin: 0; padding: 8px; overflow-y: auto; flex: 1; }
.palette-list a { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: 12px; align-items: baseline; padding: 10px 12px; border-radius: var(--r-control); text-decoration: none; color: var(--text); }
.palette-list a small { display: block; color: var(--text-2); font-size: 17px; }
.palette-list a[aria-selected="true"] { background: var(--raised); }
.palette-list .empty { padding: 16px 12px; }
.palette-hint { margin: 0; padding: 10px 20px; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 6px; }

/* ---------- 8. 專案頁：標頭 ---------- */
.project-head { max-width: var(--page); margin: 0 auto; padding: 80px var(--gutter) 0; }
.project-head .meta { margin: 0 0 16px; }
.project-head h1 { font-size: clamp(40px, 5.5vw, 66px); line-height: 1.1; font-weight: 500; letter-spacing: -0.02em; margin: 0 0 16px; }
.project-head h1 .line { overflow: hidden; padding-bottom: .06em; }
.project-head .tagline { font-size: 22px; color: var(--text-2); margin: 0 0 32px; max-width: 40rem; }
.project-head .row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.project-head .stack { margin-left: 12px; }
.project-cover { margin: 56px 0 0; width: fit-content; max-width: 100%; border-radius: var(--r-card); overflow: hidden; border: 1px solid var(--line); box-shadow: var(--image-shadow); }
.project-cover img { width: auto; max-width: 100%; max-height: 640px; object-fit: cover; object-position: top; }

/* ---------- 9. 專案頁：版面與目錄 ---------- */
.project-body {
  max-width: var(--page); margin: 0 auto; padding: 64px var(--gutter) 0;
  display: grid; grid-template-columns: 200px minmax(0, 720px); gap: 80px;
}
.toc { position: sticky; top: 96px; align-self: start; font-size: 17px; line-height: 1.5; }
.toc-title { color: var(--muted); font-size: 16px; margin-bottom: 12px; }
.toc ol { position: relative; list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--line); }
.toc a { display: block; padding: 6px 0 6px 14px; color: var(--text-2); text-decoration: none; transition: color 150ms var(--ease); }
.toc li.lv3 a { padding-left: 26px; color: var(--muted); font-size: 16px; }
.toc a:hover, .toc a.active { color: var(--text); }
/* 目錄的目前位置：一條細線滑到目前章節 */
.toc-marker { position: absolute; left: -1px; top: 0; width: 1px; height: 0; background: var(--accent); transition: transform 240ms var(--ease), height 240ms var(--ease); }
.toc-toggle { display: none !important; }

/* ---------- 10. 專案頁：內文 ---------- */
.prose { font-size: 20px; }
.prose > h1:first-child { display: none; }
.prose h2 { font-size: 28px; font-weight: 500; margin: 72px 0 20px; padding-top: 24px; border-top: 1px solid var(--line); }
.prose h3 { font-size: 22px; font-weight: 500; margin: 40px 0 12px; }
.prose .anchor { margin-left: 8px; color: var(--muted); text-decoration: none; opacity: 0; transition: opacity 150ms var(--ease); }
.prose h2:hover .anchor, .prose h3:hover .anchor { opacity: 1; }
.prose p, .prose ul, .prose ol { margin: 0 0 20px; color: var(--text-2); }
.prose li { margin: 8px 0; }
.prose li::marker { color: var(--muted); }
.prose strong { color: var(--text); font-weight: 500; }
.prose a { color: var(--text); text-decoration: underline; text-decoration-color: var(--line-strong); }
.prose a:hover { color: var(--accent); text-decoration-color: currentColor; }
.prose img { margin: 8px 0 32px; border-radius: 12px; border: 1px solid var(--line); max-height: 720px; width: auto; }
.prose :not(pre) > code { font-family: var(--font-mono); font-size: .86em; background: var(--raised); color: var(--text); padding: 2px 6px; border-radius: var(--r-tag); }
.prose pre {
  position: relative; background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; padding: 20px; overflow-x: auto; margin: 0 0 24px;
  font-size: 17px; line-height: 1.7;
}
.prose pre code { font-family: var(--font-mono); background: none !important; padding: 0 !important; }
.copy-btn {
  position: absolute; top: 8px; right: 8px; height: 28px; padding: 0 12px; cursor: pointer;
  font: 13px var(--font-sans); color: var(--text-2); background: var(--raised);
  border: 1px solid var(--line); border-radius: var(--r-tag); opacity: 0;
  transition: opacity 150ms var(--ease), color 150ms var(--ease);
}
.prose pre:hover .copy-btn, .copy-btn:focus-visible { opacity: 1; }
.copy-btn:hover { color: var(--text); }
.prose table { width: 100%; border-collapse: collapse; margin: 0 0 32px; font-size: 18px; display: block; overflow-x: auto; font-variant-numeric: tabular-nums; }
.prose th, .prose td { padding: 12px 20px 12px 0; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.prose th { color: var(--muted); font-weight: 400; font-size: 17px; white-space: nowrap; }
.prose td { color: var(--text-2); }
.prose td:first-child { color: var(--text); white-space: nowrap; }

/* ---------- 11. 提示框：SUMMARY / HIGHLIGHT / NOTE / WIP ---------- */
.lede { margin: 0 0 8px; }
.lede p { font-size: clamp(19px, 2vw, 24px); line-height: 1.7; color: var(--text); margin: 0; }
.callout { margin: 0 0 32px; padding: 4px 0 4px 20px; border-left: 2px solid var(--line-strong); }
.callout > :last-child { margin-bottom: 0; }
.callout-title { color: var(--text); font-weight: 500; margin-bottom: 4px; }
.callout-highlight { border-left-color: var(--accent); }
.callout-highlight .callout-title { color: var(--accent); }
.callout-wip { border-left-color: var(--wip); }
.callout-wip .callout-title { color: var(--wip); }

/* ---------- 12. 上一個 / 下一個 ---------- */
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 96px; }
.pager a { padding: 20px 0; border-top: 1px solid var(--line-strong); text-decoration: none; color: var(--text); font-size: 21px; font-weight: 500; }
.pager a:hover { color: var(--accent); }
.pager .meta { display: block; margin-bottom: 4px; font-weight: 400; }
.pager .next { text-align: right; grid-column: 2; }
.error-box { border-left: 2px solid var(--wip); padding: 4px 0 4px 20px; color: var(--text-2); }

/* ---------- 13. 響應式 ---------- */
@media (max-width: 1000px) {
  .project-body { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .toc {
    display: none; position: fixed; top: 64px; left: 0; right: 0; max-height: 60vh; overflow-y: auto;
    background: var(--surface); border-bottom: 1px solid var(--line); padding: 16px var(--gutter); z-index: 25;
  }
  .toc.open { display: block; }
  .toc-toggle { display: inline-flex !important; }
}
@media (max-width: 760px) {
  :root { --gutter: 20px; }
  .palette { margin-top: 12px; width: calc(100vw - 16px); max-height: calc(100svh - 24px); }
  .palette input { font-size: 18px; height: 60px; }
  .palette-kbd { display: none; }
  .palette-hint { display: none; }
  /* 手機版搜尋結果：不放右邊的分類欄，名稱與說明用滿整行 */
  .palette-list a { grid-template-columns: 28px minmax(0, 1fr); gap: 8px; }
  .palette-list a > .meta:last-child { display: none; }
  .palette-list a small { font-size: 15px; }
  /* 篩選列在手機上改成一排、可左右滑，不要折成好幾排把內容擠下去 */
  #filters, #exp-fields { flex-wrap: nowrap; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; max-width: 100%; }
  #filters::-webkit-scrollbar, #exp-fields::-webkit-scrollbar { display: none; }
  #filters button, #exp-fields button { flex: none; }
  .controls { width: 100%; }
  .site-header .wordmark { font-size: 18px; gap: 6px; }
  .site-header .wordmark-logo { height: 22px; }
  .nav { font-size: 16px; gap: 0; }
  .nav > a, .nav > button { padding: 0 8px; }
  .search-trigger { margin-left: 4px; width: 34px; }
  .hero { grid-template-columns: 1fr; gap: 40px; padding: 40px var(--gutter) 104px; }
  .hero h1 { font-size: 35px; }
  .hero .bio { font-size: 16px; line-height: 1.7; }
  .hero .bio-line + .bio-line { margin-top: 8px; }
  .hero .bio a { white-space: normal; }
  /* 手機版文字在頭貼下方：上面全亮、文字那一段變淡 */
  .hero-grid { --quiet-text: linear-gradient(180deg, #000 0%, #000 22%, rgba(0, 0, 0, .18) 34%, rgba(0, 0, 0, .18) 100%); }
  .portrait { justify-self: start; order: -1; }
  .portrait img { width: 120px; height: 120px; box-shadow: none; }
  .portrait figcaption { display: none; }
  .feature, .feature:nth-child(even) { grid-template-columns: 1fr; gap: 24px; }
  .feature:nth-child(even) .feature-shot { order: 0; }
  .feature h3 { font-size: 29px; }
  .lead { gap: 72px; }
  .views button span { display: none; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px 12px; }
  .tile h3 { font-size: 18px; }
  .tile p:not(.meta) { display: none; }
  .tile .gen-cover { gap: 4px; }
  .tile .gc-title { font-size: 20px; }
  .tile .gc-stack { display: none; }
  .tile .gc-path { font-size: 12px; }
  .tile .gc-no { font-size: 44px; }
  .projects-head { margin-bottom: 40px; }
  .index-head { display: none; }
  .index a { grid-template-columns: 32px minmax(0, 1fr); gap: 12px; padding: 20px 4px; }
  .index .cat, .index .year { display: none; }
  .project-head { padding-top: 48px; }
  .project-head .stack { margin-left: 0; flex-basis: 100%; }
  .pager { grid-template-columns: 1fr; }
  .pager .next { grid-column: 1; text-align: left; }
  .contact { grid-template-columns: 1fr; grid-template-areas: "mail" "links" "field"; }
  .dotfield { max-width: 320px; }
  .site-footer { margin-top: 112px; }
}

/* ---------- 14. 互動與動態（見 AGENTS.md §6.5） ---------- */

/* Lenis 平滑捲動 */
html.lenis, html.lenis body { height: auto; }
.lenis:not(.lenis-autoToggle).lenis-stopped { overflow: clip; }
.lenis [data-lenis-prevent] { overscroll-behavior: contain; }

/* 自訂游標：小點 + 跟隨的圓圈，移到專案上變成文字標籤 */
.cursor { position: fixed; inset: 0; z-index: 90; pointer-events: none; display: none; }
.has-cursor .cursor { display: block; }
.cursor-dot, .cursor-ring { position: absolute; left: 0; top: 0; border-radius: 999px; }
.cursor-dot { width: 6px; height: 6px; margin: -3px 0 0 -3px; background: var(--text); }
.cursor-ring {
  width: 36px; height: 36px; margin: -18px 0 0 -18px;
  border: 1px solid var(--line-strong); display: grid; place-items: center;
  transition: width 220ms var(--ease), height 220ms var(--ease), margin 220ms var(--ease), background-color 220ms var(--ease), border-color 220ms var(--ease), opacity 200ms var(--ease);
}
.cursor-label { font: 500 12px var(--font-mono); color: var(--on-brand); white-space: nowrap; opacity: 0; transition: opacity 160ms var(--ease); }
.cursor.is-link .cursor-ring { width: 56px; height: 56px; margin: -28px 0 0 -28px; border-color: var(--accent); }
.cursor.is-label .cursor-ring { width: 72px; height: 72px; margin: -36px 0 0 -36px; background: var(--brand); border-color: transparent; }
.cursor.is-label .cursor-label { opacity: 1; }
.cursor.is-label .cursor-dot, .cursor.is-hidden .cursor-dot, .cursor.is-hidden .cursor-ring { opacity: 0; }

/* 第一次進站的加載畫面：點陣聚合成 4yü.dev 再炸開（app.js 的 FX.loader） */
html.is-loading::before { content: ""; position: fixed; inset: 0; z-index: 199; background: var(--bg); }
html.is-loading, html.is-loading body { overflow: hidden; }
.loader-screen { position: fixed; inset: 0; z-index: 200; background: var(--bg); pointer-events: none; }
.loader-screen canvas { position: absolute; inset: 0; width: 100%; height: 100%; }

/* 換頁布幕 */
.curtain {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center;
  background: var(--raised); transform: scaleY(0); transform-origin: 50% 100%; pointer-events: none;
}
.curtain .wordmark { font-size: 36px; opacity: 0; gap: 14px; }
.curtain .wordmark-logo { height: 44px; }
.is-leaving .curtain, .is-entering .curtain { pointer-events: all; }

/* Hero 背景：會流動的等高線地形 */
.hero { position: relative; }
.hero > :not(.hero-grid) { position: relative; z-index: 1; }
.hero-grid {
  position: absolute; z-index: 0; top: 0; bottom: 0; left: 50%; width: 100vw; height: 100%; transform: translateX(-50%); pointer-events: none;
  /* 兩層遮罩取交集：①四周邊緣淡出 ②左邊自我介紹後面只留約 20% 亮度，往右（頭貼）漸漸恢復，文字不被動態干擾 */
  --fade-edges: radial-gradient(ellipse 130% 120% at 55% 45%, #000 55%, transparent 100%);
  --quiet-text: linear-gradient(90deg, rgba(0, 0, 0, .2) 0%, rgba(0, 0, 0, .2) 50%, #000 66%);
  -webkit-mask-image: var(--fade-edges), var(--quiet-text); -webkit-mask-composite: source-in;
  mask-image: var(--fade-edges), var(--quiet-text); mask-composite: intersect;
}
/* 首屏底部中間的往下箭頭：緩慢上下浮動，捲動後淡出 */
.hero > .scroll-down {
  position: absolute; z-index: 2; left: 50%; bottom: 24px; transform: translateX(-50%);
  width: 40px; height: 40px; display: grid; place-items: center; padding: 0;
  border: 1px solid var(--line-strong); border-radius: 50%; background: transparent; color: var(--text-2); cursor: pointer;
  transition: color 150ms var(--ease), border-color 150ms var(--ease), opacity 300ms var(--ease);
}
.hero > .scroll-down .icon { animation: scroll-bob 1.8s var(--ease) infinite; }
.hero > .scroll-down:hover { color: var(--accent); border-color: var(--accent); }
.hero > .scroll-down.is-hidden { opacity: 0; pointer-events: none; }
@keyframes scroll-bob { 0%, 100% { transform: translateY(-2px); } 50% { transform: translateY(3px); } }
@media (prefers-reduced-motion: reduce) { .hero > .scroll-down .icon { animation: none; } }

/* 頁尾的回到頂端 */
.to-top {
  width: 40px; height: 40px; display: grid; place-items: center; padding: 0;
  border: 1px solid var(--line-strong); border-radius: 50%; background: transparent; color: var(--text-2); cursor: pointer;
  transition: color 150ms var(--ease), border-color 150ms var(--ease);
}
.to-top .icon { transition: transform 300ms var(--ease); }
.to-top:hover { color: var(--accent); border-color: var(--accent); }
.to-top:hover .icon { transform: translateY(-3px); }

/* 背景的「下一個」小圖示 */
.hero > .backdrop-next {
  position: absolute; z-index: 2; right: var(--gutter); bottom: 24px;
  width: 32px; height: 32px; display: grid; place-items: center; padding: 0;
  border: 1px solid var(--line); border-radius: var(--r-control); background: transparent; color: var(--muted); cursor: pointer;
  transition: color 150ms var(--ease), border-color 150ms var(--ease);
}
.hero > .backdrop-next:hover { color: var(--accent); border-color: var(--line-strong); }
.portrait { perspective: 800px; }
.portrait img { will-change: transform; }
.hero h1 .char { display: inline-block; will-change: transform; }

/* 技術標籤跑馬燈：速度與方向跟著捲動 */
.marquee { overflow: hidden; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 20px 0; margin-bottom: 96px; }
.marquee-track { display: flex; width: max-content; gap: 0; font-family: var(--font-mono); font-size: clamp(23px, 2.9vw, 35px); color: var(--muted); white-space: nowrap; will-change: transform; }
.marquee-track span { padding: 0 20px; transition: color 150ms var(--ease); }
.marquee-track span:hover { color: var(--text); }
.marquee-track .sep { color: var(--line-strong); padding: 0; }

/* 精選截圖：hover 時 3D 傾斜、捲動時圖片視差 */
.feature-shot { transform-style: preserve-3d; will-change: transform; }
.feature-shot > * { scale: 1.12; will-change: transform; }

/* 索引列 hover：標題右移、出現箭頭 */
.index a { position: relative; }
.index .title { transition: transform 300ms var(--ease); }
.index a:hover .title { transform: translateX(12px); }
.index .go { position: absolute; right: 16px; top: 50%; margin-top: -8px; color: var(--accent); opacity: 0; transform: translateX(-8px); transition: opacity 200ms var(--ease), transform 300ms var(--ease); }
.index a:hover .go { opacity: 1; transform: none; }
.index a:hover .year { opacity: 0; }
.index .year { transition: opacity 150ms var(--ease); }

/* 頁尾信箱：字母靠近游標時浮起 */
.contact-mail .char { display: inline-block; will-change: transform; }

@media (max-width: 760px) {
  .marquee { margin-bottom: 64px; padding: 16px 0; }
}

/* ---------- 15. 經歷（content/experience.json，見 AGENTS.md §9） ---------- */
/* 窄欄；時間線（年 / 月 + 年級）為預設，分類與年級檢視用分區標題；每筆是履歷式排版 */
.exp-preview { max-width: var(--page); margin: 0 auto; padding: 0 var(--gutter); }
.exp-preview + .projects { margin-top: 160px; }
.exp-preview .projects-head { margin-bottom: 24px; }
.exp-preview .exp-list { max-width: none; }
/* 首頁區塊底下：置中的「更多」（主要按鈕）與右邊的「全部」 */
.section-more { display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 16px; margin-top: 64px; }
/* 比一般按鈕大一號，讓人一眼看到；數字是還沒顯示的筆數與總數 */
.section-more .button { height: 50px; padding: 0 26px; font-size: 18px; border-radius: 10px; gap: 8px; }
.section-more .button .icon { width: 18px; height: 18px; transition: transform 300ms var(--ease); }
.section-more .count { font-family: var(--font-mono); font-size: 15px; font-weight: 400; opacity: .75; }
.section-more .button.primary:hover .icon { transform: translateY(3px); }
.section-more .button-all { border-color: var(--accent); color: var(--accent); background: transparent; }
.section-more .button-all:hover { background: var(--surface); color: var(--text); border-color: var(--text); }
.section-more .button-all:hover .icon { transform: translateX(4px); }
.section-more .button.primary[hidden] { display: none; }

/* 專案頁、經歷頁左上的返回首頁 */
.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); text-decoration: none; font-size: 16px; margin-bottom: 24px; transition: color 150ms var(--ease); }
.back-link:hover { color: var(--accent); }
.back-link .icon { transition: transform 300ms var(--ease); }
.back-link:hover .icon { transform: translateX(-3px); }

/* 專案頁 */
.projects-page { padding-top: 80px; }
.projects-page .projects-head { border-top: 0; padding-top: 0; }
.projects-head h1 { font-size: clamp(44px, 6.6vw, 70px); font-weight: 500; letter-spacing: -.02em; margin: 0; display: flex; align-items: baseline; gap: 16px; }
.projects-head h1 .meta { font-size: 18px; letter-spacing: 0; }

.exp-page { max-width: 880px; margin: 0 auto; padding: 80px var(--gutter) 0; }
.exp-head { margin-bottom: 64px; }
.exp-head h1 { font-size: clamp(44px, 6.6vw, 70px); font-weight: 500; letter-spacing: -.02em; margin: 12px 0 32px; }

.exp-group + .exp-group { margin-top: 80px; }
.exp-group-head { display: flex; align-items: center; gap: 12px; margin: 0 0 8px; font-size: 18px; font-weight: 500; color: var(--text-2); }
.exp-group-head .meta { font-size: 14px; }
.exp-group-head i { flex: 0 0 40px; height: 1px; background: var(--line-strong); }

.exp-list { list-style: none; margin: 0; padding: 0; }

/* 一筆經歷（履歷排版）：日期 → 標題 - - - 身分 → ▫ 單位、標籤，右側成果 */
.exp { padding: 20px 0; border-bottom: 1px solid var(--line); }
.exp-list .exp:last-child { border-bottom: 0; }
.exp-date { margin: 0 0 6px; font-size: 14px; display: flex; gap: 8px; align-items: baseline; }
.exp-soon { color: var(--accent); }
.exp-line { display: flex; align-items: baseline; gap: 12px; }
.exp h3 { flex: 0 1 auto; font-size: 18px; font-weight: 500; line-height: 1.5; margin: 0; color: var(--text); }
.exp h3 a { color: inherit; text-decoration: none; }
.exp h3 a .icon { width: 14px; height: 14px; margin-left: 4px; color: var(--muted); vertical-align: -1px; transition: color .2s var(--ease); }
.exp h3 a:hover, .exp h3 a:hover .icon { color: var(--accent); }
/* 標題與身分之間的虛線，像履歷的點線引導 */
.exp-leader { flex: 1 1 24px; min-width: 24px; align-self: center; border-bottom: 1px dashed var(--line-strong); transform: translateY(2px); }
.exp-role { flex: none; font-size: 18px; font-weight: 500; color: var(--text); white-space: nowrap; transition: color .2s var(--ease); }
.exp:hover .exp-role { color: var(--accent); }
.exp-detail { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-top: 6px; }
.exp-org { margin: 0; font-size: 17px; color: var(--text-2); display: flex; gap: 10px; align-items: baseline; }
.exp-org::before { content: ""; flex: none; width: 6px; height: 6px; border: 1px solid var(--muted); border-radius: 1px; transform: translateY(-2px); }
.exp-tags { margin: 6px 0 0; font-size: 14px; }
.exp-result { margin: 0; flex: none; max-width: 50%; text-align: right; font-size: 16px; color: var(--accent); }

/* 時間線：左側一條細線，年份是大段落，月份節點附年級 */
.exp-year + .exp-year { margin-top: 72px; }
.exp-year-head { display: flex; align-items: baseline; gap: 12px; margin: 0 0 16px; font-family: var(--font-mono); font-size: 44px; font-weight: 400; letter-spacing: -.02em; color: var(--text); font-variant-numeric: tabular-nums; }
.exp-year-head .meta { font-size: 14px; letter-spacing: 0; }
.exp-month { position: relative; padding: 0 0 8px 32px; border-left: 1px solid var(--line-strong); margin-left: 5px; }
.exp-month:last-child { padding-bottom: 0; }
.exp-month-head { position: relative; margin: 0 0 0 -32px; padding: 4px 0 0 32px; font-family: var(--font-mono); font-size: 16px; font-weight: 400; color: var(--text-2); font-variant-numeric: tabular-nums; }
.exp-month-head span:not(.exp-node) { color: var(--muted); font-family: var(--font-sans); }
.exp-node { position: absolute; left: -6px; top: 7px; width: 11px; height: 11px; border-radius: 50%; background: var(--bg); border: 1px solid var(--muted); transition: border-color .2s var(--ease), background-color .2s var(--ease); }
.exp-month:hover .exp-node { border-color: var(--accent); background: var(--accent); }
.exp-month .exp:first-child { padding-top: 12px; }

@media (max-width: 760px) {
  .exp-preview + .projects { margin-top: 112px; }
  .exp-page { padding-top: 48px; }
  .exp-head { margin-bottom: 40px; }
  .exp-line { flex-wrap: wrap; gap: 4px 12px; }
  .exp-leader { display: none; }
  .exp-role { flex-basis: 100%; font-size: 17px; }
  .exp-detail { flex-direction: column; gap: 6px; }
  .exp-result { max-width: none; text-align: left; }
  .exp-year-head { font-size: 35px; }
  .exp-month { padding-left: 20px; }
  .exp-month-head { margin-left: -20px; padding-left: 20px; }
}
