/*
Theme Name: DadiBlog Pro
Theme URI: https://dadiblog.com
Author: dadi
Description: 以 Apple 產品與軟體設計語言打造的資工學習筆記主題。系統字、半透明導覽列、分組列表側欄、Xcode 風格程式碼視窗、Spotlight 搜尋與深色模式。
Version: 1.0.0
Requires at least: 6.0
Requires PHP: 8.0
License: GPL-2.0-or-later
Text Domain: dadiblog-pro
Tags: blog, minimal, dark-mode, right-sidebar, education
*/

/* ============================================================
   0. 字體：源泉圓體 GenSen Rounded（SIL OFL 1.1）
   原始檔每個字重約 15MB，這裡是只含本站用字的子集（各約 100KB）。
   之後文章出現新漢字時，要用 scratchpad/subset-font.sh 重新產生。
   ============================================================ */
@font-face {
  font-family: "GenSen Rounded";
  src: url("assets/fonts/gensen-R.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "GenSen Rounded";
  src: url("assets/fonts/gensen-B.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* ============================================================
   1. 設計 Token
   ============================================================ */
:root {
  color-scheme: light;

  --bg:           #EAEFF5;
  --surface:      #FFFFFF;
  --surface-2:    #FBFBFD;
  --fill:         rgba(118,118,128,.12);
  --fill-2:       rgba(118,118,128,.08);
  --fill-hover:   rgba(118,118,128,.16);

  --text:         #1D1D1F;
  --text-2:       #6E6E73;
  --text-3:       #86868B;
  --separator:    rgba(60,60,67,.13);
  --separator-2:  #D2D2D7;

  --accent:       #0071E3;
  --accent-hover: #0077ED;
  --link:         #0066CC;
  --accent-tint:  rgba(0,113,227,.10);
  --focus-ring:   rgba(0,113,227,.28);

  --nav-bg:       rgba(251,251,253,.78);
  --scrim:        rgba(0,0,0,.18);

  /* Liquid Glass（iOS 26） */
  --glass-bg:     rgba(255,255,255,.64);
  --glass-rim:    rgba(255,255,255,.85);
  --glass-edge:   rgba(0,0,0,.07);
  --glass-shadow: 0 1px 2px rgba(0,0,0,.05), 0 10px 32px rgba(0,0,0,.10);
  --glass-shine:  .85;

  /* 首頁區塊 */
  --home-bg:      #EAEFF5;
  --sect-alt:     #EAEFF5;
  --card-alt:     #F5F5F7;
  --shelf-pad:    max(24px, calc((100vw - var(--maxw)) / 2 + 24px));
  --tile-a:       #F5F5F7;
  --tile-b:       #E8E8ED;
  --avatar-a:     #A5ABB8;
  --avatar-b:     #858994;

  --shadow-sm:    0 1px 2px rgba(0,0,0,.04);
  --shadow:       0 2px 6px rgba(0,0,0,.04), 0 10px 28px rgba(0,0,0,.07);
  --shadow-lg:    0 16px 48px rgba(0,0,0,.16);

  --radius-xs:    8px;
  --radius-sm:    12px;
  --radius:       18px;
  --radius-lg:    28px;
  --pill:         980px;

  --maxw:         1120px;
  --nav-h:        52px;
  --gap:          24px;

  /* 源泉圓體優先；子集沒收錄的字（例如新文章的新漢字）會自動退回後面的系統字 */
  --font: "GenSen Rounded", -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
          "Helvetica Neue", "Segoe UI", "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", Arial, sans-serif;
  --font-mono: "SF Mono", SFMono-Regular, ui-monospace, Menlo, Monaco, Consolas, "Liberation Mono", monospace;

  --ease:   cubic-bezier(.25,.1,.25,1);
  --spring: cubic-bezier(.32,.72,0,1);
  --island: cubic-bezier(.34,1.56,.44,1); /* 靈動島：帶一點回彈 */

  /* 程式碼：Xcode Default (Light) */
  --code-bg:     #FFFFFF;
  --code-bar:    #F2F2F5;
  --code-text:   #262626;
  --code-border: rgba(0,0,0,.10);
  --syn-keyword: #9B2393;
  --syn-string:  #C41A16;
  --syn-comment: #5D6C79;
  --syn-number:  #1C00CF;
  --syn-type:    #0B4F79;
  --syn-func:    #326D74;
  --syn-attr:    #815F03;
  --syn-meta:    #643820;
  --syn-var:     #0F68A0;
}

html[data-theme="dark"] {
  color-scheme: dark;

  --bg:           #000000;
  --surface:      #1C1C1E;
  --surface-2:    #161617;
  --fill:         rgba(118,118,128,.24);
  --fill-2:       rgba(118,118,128,.16);
  --fill-hover:   rgba(118,118,128,.30);

  --text:         #F5F5F7;
  --text-2:       #A1A1A6;
  --text-3:       #86868B;
  --separator:    rgba(84,84,88,.55);
  --separator-2:  #424245;

  --accent:       #0A84FF;
  --accent-hover: #409CFF;
  --link:         #2997FF;
  --accent-tint:  rgba(10,132,255,.18);
  --focus-ring:   rgba(10,132,255,.40);

  --nav-bg:       rgba(22,22,23,.74);
  --scrim:        rgba(0,0,0,.50);

  --glass-bg:     rgba(40,40,44,.58);
  --glass-rim:    rgba(255,255,255,.20);
  --glass-edge:   rgba(255,255,255,.09);
  --glass-shadow: 0 1px 2px rgba(0,0,0,.35), 0 10px 32px rgba(0,0,0,.55);
  --glass-shine:  .35;

  --home-bg:      #000000;
  --sect-alt:     #101012;
  --card-alt:     #1C1C1E;
  --tile-a:       #2C2C2E;
  --tile-b:       #1C1C1E;
  --avatar-a:     #6E6E73;
  --avatar-b:     #48484A;

  --shadow-sm:    0 0 0 1px rgba(255,255,255,.05);
  --shadow:       0 0 0 1px rgba(255,255,255,.07), 0 10px 28px rgba(0,0,0,.5);
  --shadow-lg:    0 0 0 1px rgba(255,255,255,.08), 0 16px 48px rgba(0,0,0,.6);

  /* 程式碼：Xcode Default (Dark) */
  --code-bg:     #1F1F24;
  --code-bar:    #2A2A30;
  --code-text:   #FFFFFF;
  --code-border: rgba(255,255,255,.08);
  --syn-keyword: #FC5FA3;
  --syn-string:  #FC6A5D;
  --syn-comment: #6C7986;
  --syn-number:  #D0BF69;
  --syn-type:    #5DD8FF;
  --syn-func:    #67B7A4;
  --syn-attr:    #BF8555;
  --syn-meta:    #FD8F3F;
  --syn-var:     #41A1C0;
}

/* ============================================================
   2. 基礎
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-h) + 24px);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-wrap: break-word;
}

img { max-width: 100%; height: auto; display: block; }
svg { flex-shrink: 0; }

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: .18em; }

h1, h2, h3, h4, h5, h6 {
  color: var(--text);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -.015em;
  margin: 0 0 .5em;
}

p { margin: 0 0 1em; text-wrap: pretty; }
h1, h2, h3, .card-title, .post-nav .t { text-wrap: balance; }
.page-hero p, .empty-state p, .excerpt { text-wrap: balance; }
strong, b { font-weight: 600; }
code, kbd, pre, samp { font-family: var(--font-mono); }

::selection { background: var(--focus-ring); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

.screen-reader-text {
  position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link:focus {
  clip: auto; width: auto; height: auto; margin: 0; z-index: 200;
  top: 8px; left: 8px; padding: 8px 16px; border-radius: var(--pill);
  background: var(--surface); color: var(--text); box-shadow: var(--shadow);
}

.container { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }

.icon { width: 1em; height: 1em; display: inline-block; vertical-align: -.125em; }

/* ============================================================
   2b. Liquid Glass 材質（iOS 26）
   ============================================================ */
.glass {
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(24px) saturate(190%);
  backdrop-filter: blur(24px) saturate(190%);
  box-shadow: inset 0 1px 0 var(--glass-rim), inset 0 0 0 .5px var(--glass-edge), var(--glass-shadow);
}
/* 邊緣高光：左上亮、右下帶一點反光 */
.glass::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  padding: 1px; opacity: var(--glass-shine);
  background: linear-gradient(160deg, rgba(255,255,255,.95), rgba(255,255,255,0) 32%, rgba(255,255,255,0) 68%, rgba(255,255,255,.55));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
}
@supports not ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .glass { background: var(--surface); }
}

/* ============================================================
   3. 導覽列：浮動玻璃膠囊（iOS 26 Safari）
   ============================================================ */
.site-header {
  position: sticky; top: 14px; z-index: 90;
  /* 靈動島：寬度由內容決定，不再橫跨整個視窗 */
  width: max-content; max-width: calc(100% - 24px);
  height: var(--nav-h); margin: 14px auto 0;
  border-radius: var(--pill);
  transition: height .55s var(--island), top .55s var(--island),
              transform .55s var(--island), box-shadow .4s var(--ease);
  will-change: transform;
}
.site-header .container { max-width: none; height: 100%; padding: 0 10px 0 14px; }

/* 捲動時整座島縮小並輕微下沉 */
.site-header.is-compact { height: 44px; top: 10px; transform: scale(.965); }
.site-header.is-compact .brand-text { max-width: 0; opacity: 0; margin-left: -10px; }
.site-header.is-compact .search-pill-label,
.site-header.is-compact .search-pill kbd { display: none; }
.site-header.is-compact .search-pill { width: 34px; padding: 0; justify-content: center; margin-right: 0; }

/* 指標追蹤的高光，跟著滑鼠在島上移動 */
.site-header::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit;
  pointer-events: none; opacity: 0; transition: opacity .45s var(--ease);
  background: radial-gradient(220px circle at var(--mx, 50%) var(--my, 50%),
              rgba(255,255,255,.55), rgba(255,255,255,0) 60%);
}
.site-header.is-live::before { opacity: 1; }

.nav-inner { height: 100%; display: flex; align-items: center; gap: 22px; }

.brand {
  display: flex; align-items: center; gap: 10px; flex-shrink: 0;
  color: var(--text); font-size: 17px; font-weight: 600; letter-spacing: -.01em;
  transition: opacity .2s var(--ease);
}
.brand:hover { text-decoration: none; opacity: .72; }
/* 站名文字在島縮小時收起來，只留圖示 */
.brand-text {
  display: inline-block; max-width: 260px; overflow: hidden; white-space: nowrap;
  transition: max-width .55s var(--island), opacity .35s var(--ease), margin-left .55s var(--island);
}
.brand-mark { display: block; width: 28px; height: 28px; border-radius: 7px; flex-shrink: 0;
              box-shadow: 0 1px 2px rgba(0,0,0,.18), inset 0 0 0 .5px rgba(255,255,255,.12); }
.custom-logo-link img { max-height: 32px; width: auto; }

.nav-primary { margin: 0 auto; }
.nav-menu { position: relative; list-style: none; margin: 0; padding: 0; display: flex; align-items: center; gap: 2px; }
.nav-menu li { position: relative; }

/* 會滑動的選取指示器：只有一顆，在項目之間移動 */
.nav-ind {
  position: absolute; top: 50%; left: 0; height: 30px; width: 0;
  transform: translate(0, -50%) scaleX(.6); transform-origin: 50% 50%;
  border-radius: var(--pill); background: var(--fill-2);
  opacity: 0; pointer-events: none; z-index: 0;
  transition: transform .62s var(--island), width .62s var(--island),
              opacity .3s var(--ease), background .3s var(--ease);
}
.nav-menu.has-ind .nav-ind { opacity: 1; transform: translate(var(--ix, 0), -50%) scaleX(1); }
.nav-menu.is-hovering .nav-ind { background: var(--fill); }

.nav-menu a {
  position: relative; z-index: 1;
  display: block; padding: 6px 12px; border-radius: var(--pill);
  color: var(--text); font-size: 14px; opacity: .78;
  transition: opacity .25s var(--ease), color .25s var(--ease);
}
.nav-menu a:hover { opacity: 1; text-decoration: none; }
/* 選取態不再各自畫底色，底色交給會滑動的 .nav-ind */
.nav-menu .current-menu-item > a,
.nav-menu .current_page_item > a,
.nav-menu .current-menu-parent > a,
.nav-menu .current-post-ancestor > a { opacity: 1; font-weight: 600; }

/* 子選單：從島上長出來，用同一種玻璃材質 */
.nav-menu .sub-menu {
  position: absolute; top: calc(100% + 14px); left: 50%; min-width: 176px;
  margin: 0; padding: 7px; list-style: none;
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(24px) saturate(190%); backdrop-filter: blur(24px) saturate(190%);
  box-shadow: inset 0 1px 0 var(--glass-rim), inset 0 0 0 .5px var(--glass-edge), var(--glass-shadow);
  border-radius: 20px;
  opacity: 0; visibility: hidden;
  transform: translate(-50%, -14px) scale(.82);
  transform-origin: 50% 0;
  transition: opacity .28s var(--ease), transform .5s var(--island), visibility .28s;
}
.nav-menu li:hover > .sub-menu,
.nav-menu li:focus-within > .sub-menu {
  opacity: 1; visibility: visible; transform: translate(-50%, 0) scale(1);
}
/* 與島之間的小水滴，讓選單看起來是從島上滴下來的 */
.nav-menu .sub-menu::after {
  content: ""; position: absolute; left: 50%; top: -5px;
  width: 12px; height: 12px; margin-left: -6px; border-radius: 4px;
  background: var(--glass-bg); transform: rotate(45deg);
  -webkit-backdrop-filter: blur(24px) saturate(190%); backdrop-filter: blur(24px) saturate(190%);
  box-shadow: inset 0 0 0 .5px var(--glass-edge);
}
.nav-menu .sub-menu a {
  border-radius: 13px; opacity: 1; padding: 9px 14px;
  transition: background .22s var(--ease), color .22s var(--ease), transform .35s var(--island);
}
.nav-menu .sub-menu a:hover { background: var(--accent); color: #fff; transform: translateX(3px); }

.nav-tools { display: flex; align-items: center; gap: 4px; margin-left: auto; flex-shrink: 0; }

.search-pill {
  display: inline-flex; align-items: center; gap: 7px;
  height: 32px; padding: 0 8px 0 11px; margin-right: 4px;
  border: 0; border-radius: var(--pill); background: var(--fill-2);
  color: var(--text-2); font: 400 13px var(--font); cursor: pointer;
  transition: background .2s var(--ease), color .2s var(--ease);
}
.search-pill:hover { background: var(--fill); color: var(--text); }
.search-pill .icon { width: 14px; height: 14px; }
.search-pill-label { min-width: 64px; text-align: left; }

kbd, .kbd {
  display: inline-block; font: 500 11px/1 var(--font-mono);
  padding: 3px 5px; border-radius: 5px; color: var(--text-2);
  background: var(--surface); box-shadow: inset 0 0 0 1px var(--separator), 0 1px 0 var(--separator);
}

.icon-btn {
  width: 36px; height: 36px; padding: 0; border: 0; border-radius: 50%;
  background: transparent; color: var(--text); opacity: .8; cursor: pointer;
  display: grid; place-items: center;
  transition: background .2s var(--ease), opacity .2s var(--ease);
}
.icon-btn:hover { background: var(--fill-2); opacity: 1; }
.icon-btn .icon { width: 18px; height: 18px; }

/* 深淺色圖示切換 */
.icon-sun { display: none; }
html[data-theme="dark"] .icon-sun { display: inline-block; }
html[data-theme="dark"] .icon-moon { display: none; }

.nav-toggle { display: none; }
.nav-toggle .icon-close { display: none; }
html.nav-open .nav-toggle .icon-menu { display: none; }
html.nav-open .nav-toggle .icon-close { display: inline-block; }

/* ============================================================
   4. 行動版選單（iOS 26 浮動玻璃面板）
   ============================================================ */
.mobile-nav {
  position: fixed; z-index: 85;
  top: calc(var(--island-h, var(--nav-h)) + 24px); left: 12px; right: 12px;
  max-height: calc(100vh - var(--nav-h) - 44px); overflow-y: auto;
  padding: 10px; border-radius: 28px;
  opacity: 0; visibility: hidden; transform: translateY(-10px) scale(.96); transform-origin: 50% 0;
  transition: opacity .25s var(--ease), transform .45s var(--spring), visibility .25s;
}
html.nav-open .mobile-nav { opacity: 1; visibility: visible; transform: none; }
.mobile-nav ul { list-style: none; margin: 0; padding: 0; }
.mobile-nav a {
  display: block; padding: 12px 16px; border-radius: 18px; color: var(--text);
  font-size: 19px; font-weight: 600; letter-spacing: -.01em; line-height: 1.3;
  transition: background .15s var(--ease);
}
.mobile-nav a:hover, .mobile-nav a:active { text-decoration: none; background: var(--fill-2); }
.mobile-nav .current-menu-item > a { color: var(--accent); }
.mobile-nav .sub-menu { padding-left: 12px; }
.mobile-nav .sub-menu a { font-size: 16px; font-weight: 400; color: var(--text-2); }
.spotlight-panel { position: relative; }

/* ============================================================
   5. Spotlight 搜尋
   ============================================================ */
.spotlight {
  position: fixed; inset: 0; z-index: 130;
  display: flex; justify-content: center; align-items: flex-start;
  padding: 18vh 16px 16px; background: var(--scrim);
  opacity: 0; visibility: hidden; transition: opacity .2s var(--ease), visibility .2s;
}
.spotlight.is-open { opacity: 1; visibility: visible; }
.spotlight-panel {
  width: min(640px, 100%); overflow: hidden;
  background: color-mix(in srgb, var(--surface) 84%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(30px); backdrop-filter: saturate(180%) blur(30px);
  border-radius: 16px; box-shadow: var(--shadow-lg), 0 0 0 1px var(--separator);
  transform: scale(.96) translateY(-6px); transition: transform .3s var(--spring);
}
.spotlight.is-open .spotlight-panel { transform: none; }
.spotlight-form { display: flex; align-items: center; gap: 12px; padding: 14px 18px; margin: 0; }
.spotlight-form .icon { width: 22px; height: 22px; color: var(--text-2); }
.spotlight-form input {
  flex: 1; min-width: 0; border: 0; outline: none; background: transparent;
  color: var(--text); font: 400 22px/1.3 var(--font); letter-spacing: -.01em;
}
.spotlight-form input::placeholder { color: var(--text-3); }
.spotlight-form input::-webkit-search-cancel-button { display: none; }
.spotlight-hint {
  display: flex; gap: 18px; padding: 9px 18px;
  border-top: 1px solid var(--separator); color: var(--text-3); font-size: 12px;
}
.spotlight-hint span { display: inline-flex; align-items: center; gap: 6px; }

/* 一般搜尋表單（空狀態 / 404） */
.search-form { display: flex; gap: 10px; max-width: 460px; margin: 0 auto; }
.search-form input[type="search"] {
  flex: 1; min-width: 0; padding: 11px 16px;
  font: 400 17px var(--font); color: var(--text);
  background: var(--fill-2); border: 1px solid transparent; border-radius: var(--radius-sm);
  outline: none; transition: background .2s, border-color .2s, box-shadow .2s;
}
.search-form input[type="search"]:focus {
  background: var(--surface); border-color: var(--accent); box-shadow: 0 0 0 4px var(--focus-ring);
}

/* ============================================================
   6. 按鈕
   ============================================================ */
.btn, .comment-form .submit, .search-form button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 11px 22px; border: 0; border-radius: var(--pill); cursor: pointer;
  background: var(--accent); color: #fff; font: 400 17px/1.2 var(--font);
  transition: background .2s var(--ease);
}
.btn:hover, .comment-form .submit:hover, .search-form button:hover {
  background: var(--accent-hover); color: #fff; text-decoration: none;
}
.btn-plain { background: transparent; color: var(--link); padding-left: 12px; padding-right: 12px; }
.btn-plain:hover { background: transparent; color: var(--link); text-decoration: underline; }

.more-link { display: inline-flex; align-items: center; gap: 1px; color: var(--link); }
.more-link .icon { width: .78em; height: .78em; stroke-width: 2.4; }

/* ============================================================
   7. 主版面
   ============================================================ */
.site-main { padding: 48px 0 88px; min-height: 60vh; }

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 296px;
  gap: 48px;
  align-items: start;
}
.layout.no-sidebar { grid-template-columns: minmax(0, 1fr); max-width: 860px; margin: 0 auto; }

/* 大標題（iOS Large Title） */
.page-hero { margin-bottom: 36px; }
.page-hero .eyebrow { margin-bottom: 10px; }
.page-hero h1 {
  font-size: clamp(34px, 5vw, 52px); line-height: 1.07;
  letter-spacing: -.025em; margin: 0 0 12px;
}
.page-hero p { margin: 0; color: var(--text-2); font-size: clamp(17px, 2vw, 21px); line-height: 1.45; }

.eyebrow {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  font-size: 14px; font-weight: 600; color: var(--text-2);
}
.eyebrow a { color: inherit; }
.eyebrow a:hover { color: var(--link); text-decoration: none; }
.eyebrow .sep { color: var(--text-3); font-weight: 400; }
.eyebrow .flag { color: var(--accent); }
.mono { font-family: var(--font-mono); font-weight: 500; letter-spacing: 0; }

/* ============================================================
   8. 精選文章（apple.com tile）
   ============================================================ */
.featured {
  display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr);
  margin-bottom: var(--gap); overflow: hidden;
  background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
  color: var(--text);
  transition: transform .5s var(--spring), box-shadow .5s var(--ease);
}
.featured:hover { transform: translateY(-3px); box-shadow: var(--shadow); text-decoration: none; }
.featured-body { padding: 48px 40px 44px 44px; display: flex; flex-direction: column; justify-content: center; }
.featured-body h2 {
  font-size: clamp(26px, 3.2vw, 36px); line-height: 1.14; letter-spacing: -.022em; margin: 10px 0 12px;
}
.featured-body .excerpt { font-size: 17px; -webkit-line-clamp: 3; margin-bottom: 20px; }
.featured-body .more-link { font-size: 17px; }
.featured:hover .more-link span { text-decoration: underline; text-underline-offset: .18em; }

.featured-media {
  position: relative; min-height: 300px; overflow: hidden;
  background: linear-gradient(160deg, var(--tile-a) 0%, var(--tile-b) 100%);
  display: grid; place-items: center; padding: 32px 28px;
}
.featured-media img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
                      transition: transform .8s var(--spring); }
.featured:hover .featured-media img { transform: scale(1.03); }

/* 精選區的迷你 Xcode 視窗 */
.mini-editor {
  width: 100%; max-width: 380px; overflow: hidden;
  background: var(--code-bg); border-radius: 12px;
  box-shadow: var(--shadow-lg), 0 0 0 1px var(--code-border);
  transform: rotate(-1.2deg); transition: transform .6s var(--spring);
}
.featured:hover .mini-editor { transform: rotate(0deg) translateY(-2px); }
.mini-editor pre {
  margin: 0; padding: 16px 18px 18px; overflow: hidden;
  color: var(--code-text); font-size: 12.5px; line-height: 1.75; white-space: pre;
}

/* ============================================================
   9. 文章卡片
   ============================================================ */
.post-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap); }

.card {
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-sm);
  transition: transform .5s var(--spring), box-shadow .5s var(--ease);
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }

.card-media { display: block; aspect-ratio: 16 / 9; overflow: hidden; background: var(--fill-2); }
.card-media img { width: 100%; height: 100%; object-fit: cover; transition: transform .8s var(--spring); }
.card:hover .card-media img { transform: scale(1.04); }
.card-media.placeholder {
  display: grid; place-items: center; color: var(--text-3);
  background: linear-gradient(160deg, var(--tile-a) 0%, var(--tile-b) 100%);
}
.card-media.placeholder .icon { width: 52px; height: 52px; stroke-width: 1.2; transition: transform .6s var(--spring), color .3s; }
.card:hover .card-media.placeholder .icon { transform: scale(1.08); color: var(--accent); }

.card-body { padding: 20px 24px 22px; display: flex; flex-direction: column; flex: 1; }
.card .eyebrow { font-size: 13px; margin-bottom: 6px; }
.card-title { font-size: 21px; line-height: 1.3; letter-spacing: -.018em; margin: 0 0 8px; }
.card-title a { color: var(--text); }
.card-title a:hover { color: var(--link); text-decoration: none; }

.excerpt {
  color: var(--text-2); font-size: 15px; line-height: 1.6; margin: 0 0 18px;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}

.card-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-foot .more-link { font-size: 15px; flex-shrink: 0; }

.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; color: var(--text-3); font-size: 13px; }
.meta span { display: inline-flex; align-items: center; gap: 5px; }
.meta .icon { width: 14px; height: 14px; }

/* ============================================================
   10. 側邊欄（iOS 分組列表）
   ============================================================ */
.sidebar { display: grid; gap: 28px; min-width: 0; }

.group-title { margin: 0 0 8px 16px; font-size: 13px; font-weight: 600; color: var(--text-2); letter-spacing: .01em; }
.group-card { background: var(--surface); border-radius: var(--radius-sm); box-shadow: var(--shadow-sm); overflow: hidden; }

.group-list { list-style: none; margin: 0; padding: 0; }
.group-list a, .group-list .row {
  position: relative; display: flex; align-items: center; gap: 12px;
  min-height: 44px; padding: 10px 14px 10px 16px;
  color: var(--text); font-size: 15px; line-height: 1.4;
  transition: background .15s var(--ease);
}
.group-list a:hover { background: var(--fill-2); text-decoration: none; }
.group-list a:active { background: var(--fill); }
.group-list li:not(:last-child) > a::after,
.group-list li:not(:last-child) > .row::after {
  content: ""; position: absolute; left: 16px; right: 0; bottom: 0; height: 1px; background: var(--separator);
}
.group-list .has-icon::after { left: 57px !important; }
.row-icon {
  width: 29px; height: 29px; border-radius: 7px; flex-shrink: 0;
  display: grid; place-items: center; color: #fff;
  background: linear-gradient(180deg, #3D9BFF 0%, var(--accent) 100%);
}
.row-icon .icon { width: 17px; height: 17px; stroke-width: 1.9; }
.row-main { flex: 1; min-width: 0; }
.row-title { display: block; }
.row-sub { display: block; font-size: 13px; color: var(--text-3); margin-top: 1px; }
.row-clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.row-value { color: var(--text-3); font-size: 15px; flex-shrink: 0; }
.chev { width: 13px; height: 13px; color: var(--separator-2); stroke-width: 2.4; flex-shrink: 0; }

/* 分類卡：標題在卡內，每個分類是一塊淺藍填色圓角列 */
.cat-card { padding: 24px 22px; }
.cat-card-title { margin: 0 0 16px; font-size: 20px; font-weight: 700; letter-spacing: -.01em; color: var(--text); }
.cat-rows { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
/* 底色用「藍灰」而不是純藍調，和參考圖一致。
   先寫死 rgba 當後備，舊瀏覽器不支援 color-mix() 時才不會整條失效變成透明。 */
.cat-row {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 14px; border-radius: 12px;
  background: rgba(214, 225, 240, .72);
  background: color-mix(in srgb, var(--accent) 9%, var(--fill-2));
  color: var(--text);
  font-size: 16px; font-weight: 600; line-height: 1.4;
  transition: background .2s var(--ease), transform .3s var(--spring);
}
.cat-row:hover {
  background: color-mix(in srgb, var(--accent) 20%, var(--fill-2));
  color: var(--text); text-decoration: none; transform: translateX(2px);
}
.cat-row-icon { width: 22px; height: 22px; flex-shrink: 0; color: var(--accent); }
.cat-row-icon .icon { width: 100%; height: 100%; stroke-width: 1.8; }
.cat-row-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* 徽章要比列底再深一階才會浮出來（同樣先給 rgba 後備） */
.cat-row-count {
  flex-shrink: 0; min-width: 34px; padding: 3px 9px; border-radius: 10px;
  background: rgba(176, 200, 233, .85);
  background: color-mix(in srgb, var(--accent) 22%, var(--fill-2)); color: var(--link);
  font-size: 14px; font-weight: 700; text-align: center; font-variant-numeric: tabular-nums;
  transition: background .2s var(--ease);
}
.cat-row:hover .cat-row-count { background: color-mix(in srgb, var(--accent) 32%, var(--fill-2)); }

/* 個人資料卡（置中：頭像 → 暱稱 → 分隔線 → 一句話 → 社群按鈕） */
.profile-card { padding: 28px 22px 24px; text-align: center; }
.profile-avatar-ring {
  width: 104px; height: 104px; margin: 0 auto 14px; padding: 4px;
  border-radius: 50%; box-shadow: inset 0 0 0 3px var(--accent);
}
.profile-card .profile-avatar { width: 100%; height: 100%; border-radius: 50%; display: block; overflow: hidden; }
.profile-card .profile-avatar svg { width: 100%; height: 100%; display: block; }
.profile-card .profile-name {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  margin: 0 0 16px; font-size: 21px; font-weight: 700; letter-spacing: -.01em; color: var(--text);
}
.profile-badge { width: 20px; height: 20px; flex-shrink: 0; color: var(--accent); }
/* 用 border-top 畫線，避免被瀏覽器對 <hr> 的預設樣式蓋掉 */
.profile-card .profile-sep {
  height: 0; width: auto; border: 0; border-top: 1px solid var(--separator);
  margin: 0 -4px 14px; opacity: 1;
}
.profile-motto {
  margin: 0; font-family: var(--font-mono); font-size: 13px; line-height: 1.65; color: var(--text-2);
}
.profile-socials { display: flex; justify-content: center; gap: 10px; margin-top: 18px; }
.social-btn {
  width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center;
  background: var(--accent-tint); color: var(--link);
  transition: background .2s var(--ease), color .2s var(--ease), transform .3s var(--spring);
}
.social-btn:hover { background: var(--accent); color: #fff; text-decoration: none; transform: translateY(-2px); }
.social-btn .icon { width: 18px; height: 18px; }

/* 個人資訊（Apple ID 列） */
.profile-row { display: flex; align-items: center; gap: 14px; padding: 16px; }
.avatar {
  width: 58px; height: 58px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center; color: #fff;
  font-size: 25px; font-weight: 600; letter-spacing: 0;
  background: linear-gradient(180deg, var(--avatar-a) 0%, var(--avatar-b) 100%);
}
.profile-name { margin: 0 0 2px; font-size: 19px; font-weight: 600; letter-spacing: -.01em; line-height: 1.3; }
.profile-bio { margin: 0; font-size: 13px; line-height: 1.5; color: var(--text-2); }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--separator); }
.stats > div { padding: 12px 8px; text-align: center; }
.stats > div + div { box-shadow: inset 1px 0 0 var(--separator); }
.stat-num { display: block; font-size: 20px; font-weight: 600; line-height: 1.2; letter-spacing: -.01em; }
.stat-label { font-size: 12px; color: var(--text-2); }

/* 標籤 */
.tag-list { display: flex; flex-wrap: wrap; gap: 8px; }
.group-card .tag-list { padding: 14px; }
.tag-list a {
  display: inline-flex; align-items: center; gap: 2px;
  padding: 5px 12px; border-radius: var(--pill);
  background: var(--fill-2); color: var(--text); font-size: 13px; line-height: 1.4;
  transition: background .2s var(--ease), color .2s var(--ease);
}
.tag-list a:hover { background: var(--accent-tint); color: var(--link); text-decoration: none; }
.tag-list .hash { font-family: var(--font-mono); color: var(--text-3); }
.tag-list a:hover .hash { color: inherit; }

/* 文章目錄（Apple 開發者文件 On This Page） */
.toc { position: sticky; top: calc(var(--nav-h) + 32px); }
.toc-title { margin: 0 0 12px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.toc-list {
  list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--separator);
  max-height: calc(100vh - var(--nav-h) - 140px); overflow-y: auto; scrollbar-width: thin;
}
.toc-list a {
  display: block; margin-left: -1px; padding: 5px 0 5px 14px;
  border-left: 2px solid transparent;
  color: var(--text-2); font-size: 14px; line-height: 1.45;
  transition: color .15s var(--ease), border-color .15s var(--ease);
}
.toc-list a:hover { color: var(--text); text-decoration: none; }
.toc-list a.is-active { color: var(--text); font-weight: 600; border-left-color: var(--accent); }
.toc-list .toc-h3 { padding-left: 28px; font-size: 13px; }
.toc-top { display: inline-flex; align-items: center; gap: 4px; margin: 16px 0 0 15px; font-size: 13px; }
.toc-top .icon { width: 12px; height: 12px; }

/* 小工具區（block widgets） */
.widget-body { padding: 14px 16px; font-size: 15px; }
.widget-body h2, .widget-body h3 { font-size: 13px; font-weight: 600; color: var(--text-2); letter-spacing: .01em; margin: 0 0 8px; }
.widget-body ul { list-style: none; margin: 0; padding: 0; }
.widget-body li { padding: 7px 0; border-bottom: 1px solid var(--separator); }
.widget-body li:last-child { border-bottom: 0; }
.widget-body li a { color: var(--text); }
.widget-body .wp-block-search__label { display: none; }
.widget-body .wp-block-search__inside-wrapper { display: flex; gap: 8px; }
.widget-body .wp-block-search__input {
  flex: 1; min-width: 0; padding: 8px 12px; font: 15px var(--font); color: var(--text);
  background: var(--fill-2); border: 1px solid transparent; border-radius: 10px; outline: none;
}
.widget-body .wp-block-search__input:focus { border-color: var(--accent); background: var(--surface); }
.widget-body .wp-block-search__button {
  margin: 0; padding: 8px 14px; border: 0; border-radius: var(--pill);
  background: var(--accent); color: #fff; font: 15px var(--font); cursor: pointer;
}

/* ============================================================
   11. 單篇文章
   ============================================================ */
.entry {
  background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
  padding: 56px 64px 52px;
}
.entry-header { margin-bottom: 36px; }
.entry-title {
  font-size: clamp(30px, 4.2vw, 44px); line-height: 1.12; letter-spacing: -.024em; margin: 10px 0 18px;
}
.entry-header .meta { font-size: 14px; color: var(--text-2); }
.entry-header .meta .icon { color: var(--text-3); }
.entry-cover { margin: 0 0 40px; border-radius: var(--radius); overflow: hidden; }

.entry-content { font-size: 17px; line-height: 1.85; }
.entry-content > *:first-child { margin-top: 0; }
.entry-content p { margin: 0 0 1.25em; }
.entry-content h2 { font-size: 28px; line-height: 1.25; letter-spacing: -.018em; margin: 2.1em 0 .7em; }
.entry-content h3 { font-size: 21px; line-height: 1.3; letter-spacing: -.012em; margin: 1.8em 0 .6em; }
.entry-content h4 { font-size: 17px; margin: 1.6em 0 .5em; }
.entry-content a { color: var(--link); }
.entry-content ul, .entry-content ol { padding-left: 1.4em; margin: 0 0 1.35em; }
.entry-content li { margin-bottom: .4em; padding-left: .15em; }
.entry-content li::marker { color: var(--text-3); }
.entry-content ol li::marker { font-family: var(--font-mono); font-size: .9em; }

.entry-content img { border-radius: var(--radius-sm); }
.entry-content figure { margin: 2em 0; }
.entry-content figcaption { margin-top: 10px; text-align: center; font-size: 13px; color: var(--text-2); }

.entry-content blockquote {
  margin: 1.8em 0; padding: 18px 22px;
  background: var(--fill-2); border: 0; border-radius: var(--radius-sm);
  box-shadow: inset 3px 0 0 var(--accent);
}
.entry-content blockquote p:last-child { margin-bottom: 0; }
.entry-content blockquote cite { display: block; margin-top: 8px; font-size: 13px; font-style: normal; color: var(--text-2); }

.entry-content :not(pre) > code {
  font-size: .86em; padding: .15em .42em; border-radius: 6px;
  background: var(--fill-2); color: var(--text);
  box-shadow: inset 0 0 0 1px var(--separator);
}
.entry-content kbd { font-size: .8em; padding: .2em .45em; }

.entry-content hr { border: 0; height: 1px; background: var(--separator); margin: 3em 0; }

/* 表格（Apple 規格表） */
.table-wrap { overflow-x: auto; margin: 1.8em 0; -webkit-overflow-scrolling: touch; }
.table-wrap table { margin: 0; }
.entry-content table { width: 100%; border-collapse: collapse; font-size: 15px; line-height: 1.55; margin: 1.8em 0; }
.entry-content th, .entry-content td { padding: 12px 20px 12px 0; text-align: left; vertical-align: top; border-bottom: 1px solid var(--separator); }
.entry-content th { font-size: 13px; font-weight: 600; color: var(--text-2); border-bottom-color: var(--separator-2); }
.entry-content td:first-child { font-weight: 600; }
.entry-content .wp-block-table { margin: 1.8em 0; overflow-x: auto; }
.entry-content .wp-block-table table { margin: 0; }
.entry-content .wp-block-table thead { border-bottom: 0; }

/* ============================================================
   12. 程式碼（Xcode 風格視窗）
   ============================================================ */
.entry-content pre, .comment-content pre {
  margin: 1.8em 0; padding: 16px 20px; overflow-x: auto;
  background: var(--code-bg); color: var(--code-text);
  border: 1px solid var(--code-border); border-radius: var(--radius-sm);
  font-size: 14px; line-height: 1.7; tab-size: 4; white-space: pre;
}
.entry-content pre code { font-size: inherit; background: none; padding: 0; border: 0; box-shadow: none; color: inherit; }
.entry-content .wp-block-code { font-family: var(--font-mono); }

.code-window {
  margin: 1.8em 0; overflow: hidden;
  background: var(--code-bg); border-radius: var(--radius-sm);
  box-shadow: var(--shadow), 0 0 0 1px var(--code-border);
}
.code-bar {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  height: 36px; padding: 0 8px 0 14px;
  background: var(--code-bar); border-bottom: 1px solid var(--code-border);
}
.code-dots { display: flex; gap: 8px; }
.code-dots i { width: 12px; height: 12px; border-radius: 50%; background: #FF5F57; box-shadow: inset 0 0 0 .5px rgba(0,0,0,.14); }
.code-dots i:nth-child(2) { background: #FEBC2E; }
.code-dots i:nth-child(3) { background: #28C840; }
.code-lang { font: 500 12px var(--font); color: var(--text-2); letter-spacing: .01em; }
.code-copy {
  justify-self: end; display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 9px; border: 0; border-radius: 6px; cursor: pointer;
  background: transparent; color: var(--text-2); font: 500 12px var(--font);
  transition: background .15s var(--ease), color .15s var(--ease);
}
.code-copy:hover { background: var(--fill-2); color: var(--text); }
.code-copy .icon { width: 13px; height: 13px; }
.code-copy .icon-check { display: none; }
.code-copy.is-copied { color: var(--accent); }
.code-copy.is-copied .icon-copy { display: none; }
.code-copy.is-copied .icon-check { display: inline-block; }

.code-body { display: flex; }
.code-gutter {
  flex-shrink: 0; margin: 0; padding: 16px 12px 16px 14px; min-width: 3em;
  text-align: right; color: var(--text-3); opacity: .7;
  font: 14px/1.7 var(--font-mono); user-select: none; -webkit-user-select: none; white-space: pre;
}
.code-window pre, .entry-content .code-window pre {
  flex: 1; min-width: 0; margin: 0; padding: 16px 20px 16px 6px;
  background: transparent; border: 0; border-radius: 0; box-shadow: none;
}
.code-window.no-gutter pre { padding-left: 20px; }

/* 語法上色（highlight.js 類別，配 Xcode 配色） */
.hljs { color: var(--code-text); background: transparent; }
.hljs-keyword, .hljs-literal, .hljs-selector-tag, .hljs-section, .hljs-doctag { color: var(--syn-keyword); font-weight: 600; }
.hljs-string, .hljs-regexp, .hljs-char.escape_, .hljs-symbol, .hljs-link { color: var(--syn-string); }
.hljs-comment, .hljs-quote { color: var(--syn-comment); }
.hljs-number { color: var(--syn-number); }
.hljs-type, .hljs-title.class_, .hljs-title.class_.inherited__, .hljs-name, .hljs-selector-class { color: var(--syn-type); }
.hljs-title.function_, .hljs-built_in, .hljs-title { color: var(--syn-func); }
.hljs-attr, .hljs-attribute, .hljs-property, .hljs-selector-attr, .hljs-selector-id { color: var(--syn-attr); }
.hljs-meta, .hljs-meta .hljs-keyword, .hljs-meta .hljs-string { color: var(--syn-meta); }
.hljs-variable, .hljs-template-variable, .hljs-variable.language_ { color: var(--syn-var); }
.hljs-subst, .hljs-params { color: var(--code-text); }
.hljs-addition { color: #28A745; }
.hljs-deletion { color: var(--syn-string); }
.hljs-emphasis { font-style: italic; }
.hljs-strong { font-weight: 600; }

/* ============================================================
   13. 文章頁尾 / 上下篇 / 留言
   ============================================================ */
.entry-footer { margin-top: 44px; padding-top: 24px; border-top: 1px solid var(--separator); }

.post-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 20px; }
.post-nav a {
  display: block; padding: 18px 22px; border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow-sm); color: var(--text);
  transition: transform .5s var(--spring), box-shadow .5s var(--ease);
}
.post-nav a:hover { transform: translateY(-2px); box-shadow: var(--shadow); text-decoration: none; }
.post-nav .dir { display: inline-flex; align-items: center; gap: 3px; font-size: 13px; color: var(--text-2); margin-bottom: 4px; }
.post-nav .dir .icon { width: 11px; height: 11px; stroke-width: 2.6; }
.post-nav .t { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
               font-size: 17px; font-weight: 600; line-height: 1.4; letter-spacing: -.01em; }
.post-nav .next { text-align: right; }

.comments {
  margin-top: 20px; padding: 44px 64px;
  background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
}
.comments-title, .comment-reply-title { font-size: 24px; letter-spacing: -.018em; margin: 0 0 20px; }
.comment-reply-title small { font-size: 15px; font-weight: 400; margin-left: 8px; }
.comment-list { list-style: none; margin: 0 0 36px; padding: 0; }
.comment-list .children { list-style: none; margin: 0; padding-left: 24px; }
.comment-list li { margin: 0; }
.comment-body { padding: 16px 0; border-bottom: 1px solid var(--separator); }
.comment-meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; margin-bottom: 6px; }
.comment-author { font-size: 15px; font-weight: 600; }
.comment-author .fn a { color: var(--text); }
.comment-author .says { display: none; }
.comment-metadata { font-size: 13px; }
.comment-metadata a { color: var(--text-3); }
.comment-content { font-size: 16px; line-height: 1.75; }
.comment-content p:last-child { margin-bottom: 0; }
.comment-awaiting-moderation { font-size: 13px; color: var(--text-2); }
.reply { margin-top: 6px; font-size: 13px; }
.edit-link { margin-left: 8px; }

.comment-form { margin: 0; }
.comment-form p { margin: 0 0 16px; }
.comment-notes, .logged-in-as { font-size: 13px; color: var(--text-2); }
.comment-form label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.comment-form input[type="text"], .comment-form input[type="email"],
.comment-form input[type="url"], .comment-form textarea {
  width: 100%; padding: 12px 14px;
  font: 400 17px/1.5 var(--font); color: var(--text);
  background: var(--fill-2); border: 1px solid transparent; border-radius: var(--radius-sm);
  outline: none; transition: background .2s, border-color .2s, box-shadow .2s;
}
.comment-form textarea { min-height: 140px; resize: vertical; }
.comment-form input:focus, .comment-form textarea:focus {
  background: var(--surface); border-color: var(--accent); box-shadow: 0 0 0 4px var(--focus-ring);
}
.comment-form-cookies-consent { display: flex; align-items: flex-start; gap: 8px; }
.comment-form-cookies-consent label { display: inline; margin: 0; font-weight: 400; }
.comment-form-cookies-consent input { margin-top: 4px; accent-color: var(--accent); }
.form-submit { margin: 4px 0 0 !important; }
.no-comments { color: var(--text-2); font-size: 15px; }

/* ============================================================
   14. 分頁
   ============================================================ */
.pagination { margin-top: 40px; }
.pagination .nav-links { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px; }
.pagination .page-numbers {
  min-width: 36px; height: 36px; padding: 0 12px; border-radius: var(--pill);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text); font-size: 15px; transition: background .2s var(--ease);
}
.pagination a.page-numbers:hover { background: var(--fill-2); text-decoration: none; }
.pagination .page-numbers.current { background: var(--text); color: var(--surface); font-weight: 600; }
.pagination .page-numbers .icon { width: 12px; height: 12px; stroke-width: 2.4; }

/* ============================================================
   15. 空狀態 / 404
   ============================================================ */
.empty-state {
  text-align: center; padding: 72px 28px;
  background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
}
.empty-state .empty-icon { width: 56px; height: 56px; color: var(--text-3); margin: 0 auto 18px; stroke-width: 1.2; }
.empty-state .code-line { font: 500 13px var(--font-mono); color: var(--text-3); margin-bottom: 12px; }
.empty-state h1, .empty-state h2 { font-size: clamp(26px, 3.4vw, 34px); letter-spacing: -.022em; margin-bottom: 10px; }
.empty-state p { color: var(--text-2); font-size: 17px; margin: 0 auto 24px; max-width: 460px; }
.empty-state .search-form { margin-bottom: 18px; }

/* ============================================================
   16. 頁尾（apple.com footer）
   ============================================================ */
.site-footer { border-top: 1px solid var(--separator); padding: 20px 0 36px; color: var(--text-2); font-size: 12px; line-height: 1.5; }
.footer-note { margin: 0 0 14px; padding-bottom: 14px; border-bottom: 1px solid var(--separator); }
.footer-note .brand-inline { color: var(--text); font-weight: 600; }
.footer-bottom { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px; }
.footer-bottom p { margin: 0; }
.footer-links { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; }
.footer-links li + li::before { content: "|"; margin: 0 9px; color: var(--separator-2); }
.footer-links a { color: var(--text-2); }
.footer-links a:hover { color: var(--text); }

/* 回到頂端 */
.to-top {
  position: fixed; right: 24px; bottom: 24px; z-index: 80;
  width: 40px; height: 40px; padding: 0; border: 0; border-radius: 50%; cursor: pointer;
  display: grid; place-items: center; color: var(--text);
  background: var(--nav-bg);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  box-shadow: var(--shadow), 0 0 0 1px var(--separator);
  opacity: 0; visibility: hidden; transform: translateY(8px) scale(.92);
  transition: opacity .25s var(--ease), transform .4s var(--spring), visibility .25s;
}
.to-top.is-visible { opacity: 1; visibility: visible; transform: none; }
.to-top:hover { background: var(--surface); }
.to-top .icon { width: 16px; height: 16px; stroke-width: 2.2; }

/* ============================================================
   17. 響應式（Apple 斷點 1068 / 834 / 734）
   ============================================================ */
@media (max-width: 1068px) {
  .layout { grid-template-columns: minmax(0, 1fr); gap: 40px; }
  /* 窄螢幕一律不顯示側欄（首頁、文章頁、分類／標籤／搜尋頁），不堆疊到下方 */
  .sidebar { display: none; }
}

@media (max-width: 834px) {
  .nav-primary { display: none; }
  .nav-toggle { display: grid; }
  .search-pill { width: 36px; height: 36px; padding: 0; margin: 0; justify-content: center; background: transparent; color: var(--text); opacity: .8; }
  .search-pill .icon { width: 18px; height: 18px; }
  .search-pill-label, .search-pill kbd { display: none; }
  .featured { grid-template-columns: minmax(0, 1fr); }
  .featured-body { padding: 36px 32px 32px; }
  .featured-media { min-height: 0; padding: 28px 24px 32px; }
  .entry { padding: 44px 40px 40px; }
  .comments { padding: 36px 40px; }
}

@media (max-width: 734px) {
  .container { padding: 0 20px; }
  .site-main { padding: 32px 0 64px; }
  .post-grid { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .sidebar { grid-template-columns: minmax(0, 1fr); }
  .featured { border-radius: var(--radius); }
  .featured-body { padding: 28px 24px 24px; }
  .mini-editor pre { font-size: 11.5px; }
  .entry { padding: 32px 22px 30px; border-radius: var(--radius); }
  .entry-content { font-size: 17px; }
  .entry-content h2 { font-size: 24px; }
  .comments { padding: 28px 22px; border-radius: var(--radius); }
  .post-nav { grid-template-columns: minmax(0, 1fr); }
  .post-nav .next { text-align: left; }
  .code-window { margin-left: -8px; margin-right: -8px; }
  .code-gutter { display: none; }
  .code-window pre { padding-left: 16px; }
  .to-top { right: 16px; bottom: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

@media print {
  .site-header, .mobile-nav, .spotlight, .sidebar, .post-nav, .comments, .site-footer, .to-top, .code-bar, .code-gutter { display: none !important; }
  body { background: #fff; }
  .layout { display: block; }
  .entry { box-shadow: none; padding: 0; }
}

/* ============================================================
   18. 首頁（apple.com 區塊版面 + iOS 26 Liquid Glass）
   ============================================================ */
body.is-front { background: var(--home-bg); }
.is-front .site-main { padding: 0; }
.is-front .site-footer { background: var(--sect-alt); }

/* 共用排版 */
.sect { position: relative; padding: clamp(80px, 11vw, 132px) 0; overflow: hidden; }
.sect-alt { background: var(--sect-alt); }
.sect-dark { background: #000; color: #F5F5F7; }
.center { text-align: center; }
.kicker { margin: 0 0 10px; font-size: 17px; font-weight: 600; color: var(--accent); }
.kicker-dark { color: #2997FF; }
.display { margin: 0 auto 18px; max-width: 920px; font-size: clamp(38px, 5.6vw, 64px); line-height: 1.08; letter-spacing: -.028em; }
.display a { color: inherit; }
.display a:hover { text-decoration: none; opacity: .8; }
.display-left { margin-left: 0; text-align: left; color: inherit; }
.lead { margin: 0 auto; max-width: 700px; font-size: clamp(19px, 2vw, 23px); line-height: 1.45; font-weight: 600; color: var(--text-2); }
.lead-left { margin-left: 0; color: #A1A1A6; }
.fine { margin: 18px 0 0; font-size: 14px; color: var(--text-3); }
.cta-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px; margin-top: 32px; }

.duo-title { margin: 0; font-size: clamp(28px, 3.4vw, 40px); line-height: 1.15; letter-spacing: -.024em; }
.duo-title span { color: var(--text-2); }
.duo-title.center { text-align: center; }

/* 按鈕變體 */
.btn-light { background: #fff; color: #1D1D1F; }
.btn-light:hover { background: rgba(255,255,255,.86); color: #1D1D1F; }
.btn-outline { background: transparent; color: var(--link); box-shadow: inset 0 0 0 1px currentColor; }
.btn-outline:hover { background: var(--link); color: #fff; box-shadow: inset 0 0 0 1px var(--link); }
.btn-glass {
  position: relative; color: #fff; background: rgba(255,255,255,.16);
  -webkit-backdrop-filter: blur(18px) saturate(180%); backdrop-filter: blur(18px) saturate(180%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.55), inset 0 0 0 1px rgba(255,255,255,.32), 0 6px 20px rgba(10,30,80,.18);
}
.btn-glass:hover { background: rgba(255,255,255,.26); color: #fff; }
.more-link-lg { margin-top: 22px; font-size: 19px; color: #2997FF; }

/* --- 1. 主視覺 --- */
.hero {
  position: relative; isolation: isolate; overflow: hidden; text-align: center; color: #fff;
  margin-top: calc(-1 * (var(--nav-h) + 12px));
  padding: calc(var(--nav-h) + 12px + clamp(48px, 7vw, 88px)) 0 clamp(72px, 9vw, 112px);
  min-height: min(820px, 100vh);
  display: flex; flex-direction: column; justify-content: center;
}
.hero-bg {
  position: absolute; inset: 0; z-index: -2;
  background:
    radial-gradient(55% 50% at 50% 34%, rgba(255,255,255,.38), rgba(255,255,255,0) 70%),
    linear-gradient(180deg, #7AA8DF 0%, #5C8BCB 46%, #3D5E99 100%);
}
html[data-theme="dark"] .hero-bg {
  background:
    radial-gradient(55% 50% at 50% 34%, rgba(110,165,255,.30), rgba(110,165,255,0) 70%),
    linear-gradient(180deg, #1D3359 0%, #11213F 55%, #060C1B 100%);
}
.hero-emblem {
  perspective: 900px; margin: 0 auto clamp(32px, 4vw, 48px);
  transform: translateY(calc(var(--p, 0) * 80px)) scale(calc(1 + var(--p, 0) * .3));
  opacity: calc(1 - var(--p, 0) * 1.3);
  will-change: transform, opacity;
}
.emblem-float { position: relative; width: clamp(150px, 17vw, 216px); margin: 0 auto; animation: dbp-float 7s ease-in-out infinite; }
.emblem-float::before {
  content: ""; position: absolute; inset: -45%; z-index: -1; border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,.55) 0%, rgba(200,228,255,.28) 32%, rgba(255,255,255,0) 64%);
  filter: blur(8px);
}
.emblem {
  position: relative; aspect-ratio: 1; border-radius: 24%; overflow: hidden;
  display: grid; place-items: center; color: #fff;
  background:
    radial-gradient(110% 90% at 28% 12%, rgba(255,255,255,.62) 0%, rgba(255,255,255,.14) 42%, rgba(255,255,255,.05) 70%),
    linear-gradient(160deg, rgba(255,255,255,.30), rgba(255,255,255,.04));
  -webkit-backdrop-filter: blur(14px) saturate(160%); backdrop-filter: blur(14px) saturate(160%);
  box-shadow:
    inset 0 2px 1px rgba(255,255,255,.95),
    inset 0 -4px 10px rgba(255,255,255,.35),
    inset 0 0 50px rgba(255,255,255,.22),
    0 40px 90px rgba(8,30,80,.35);
  transform: rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
  transition: transform .8s var(--spring);
}
/* 稜鏡邊框：模仿 Liquid Glass 邊緣的彩色折射 */
.emblem::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; padding: 2.5px; pointer-events: none;
  background: conic-gradient(from 210deg, rgba(255,255,255,.95), rgba(168,224,255,.9), rgba(255,214,242,.85), rgba(255,244,198,.85), rgba(190,255,226,.85), rgba(255,255,255,.95));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
}
.emblem-sheen {
  position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: radial-gradient(45% 45% at var(--mx, 32%) var(--my, 18%), rgba(255,255,255,.38), rgba(255,255,255,0) 70%);
}
.emblem-glyph { position: relative; width: 52%; height: 52%; filter: drop-shadow(0 0 12px rgba(255,255,255,.85)) drop-shadow(0 3px 8px rgba(20,60,140,.35)); }
@keyframes dbp-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-12px); } }

.hero-copy { transform: translateY(calc(var(--p, 0) * -48px)); opacity: calc(1 - var(--p, 0) * 1.5); }
.hero-title {
  margin: 0 0 16px; color: #fff; font-size: clamp(42px, 6.6vw, 84px); line-height: 1.05; letter-spacing: -.03em;
  text-shadow: 0 2px 30px rgba(10,30,80,.22);
}
.hero-sub { margin: 0 auto; max-width: 640px; color: rgba(255,255,255,.88); font-size: clamp(19px, 2.2vw, 24px); line-height: 1.45; font-weight: 500; }

/* --- 2. 精選文章 --- */
.feature-stage { margin-top: clamp(48px, 6vw, 80px); display: flex; justify-content: center; perspective: 1400px; }
.mini-editor-lg {
  max-width: 760px; transform-origin: 50% 100%;
  transform: translateY(calc((1 - var(--p, 1)) * 60px)) rotateX(calc((1 - var(--p, 1)) * 26deg)) scale(calc(.9 + var(--p, 1) * .1));
  box-shadow: 0 40px 100px rgba(0,0,0,.18), 0 0 0 1px var(--code-border);
}
.mini-editor-lg pre { padding: 26px 30px 30px; font-size: clamp(12px, 1.45vw, 16px); line-height: 1.85; }
.mini-editor-lg .code-bar { height: 40px; }
.feature-media { max-width: 980px; width: 100%; border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-lg); }
.feature-media img { width: 100%; }

/* --- 3. 最新筆記（Apple Store 橫向卡片） --- */
.shelf-sect { padding-bottom: clamp(56px, 8vw, 96px); }
.sect-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.shelf-nav { display: flex; gap: 10px; flex-shrink: 0; }
.shelf-nav[hidden] { display: none; }
.gbtn-circle {
  width: 40px; height: 40px; padding: 0; border: 0; border-radius: 50%; cursor: pointer;
  display: grid; place-items: center; color: var(--text); background: var(--fill);
  transition: background .2s var(--ease), opacity .2s var(--ease), transform .3s var(--spring);
}
.gbtn-circle:hover:not(:disabled) { background: var(--fill-hover); transform: scale(1.06); }
.gbtn-circle:disabled { opacity: .35; cursor: default; }
.gbtn-circle .icon { width: 16px; height: 16px; stroke-width: 2.2; }

.shelf {
  overflow-x: auto; overflow-y: hidden; scroll-snap-type: x mandatory; scroll-padding-inline: var(--shelf-pad);
  scrollbar-width: none; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch;
}
.shelf::-webkit-scrollbar { display: none; }
.shelf-track { display: flex; gap: 20px; width: max-content; padding: 12px var(--shelf-pad) 40px; }

.scard {
  flex: 0 0 auto; width: min(400px, 82vw); scroll-snap-align: start;
  border-radius: 28px; background: var(--card-alt); overflow: hidden;
  transition: transform .6s var(--spring), box-shadow .6s var(--ease);
}
.scard:hover { transform: scale(1.015); box-shadow: 0 18px 48px rgba(0,0,0,.14); }
.scard-link { display: flex; flex-direction: column; min-height: 520px; height: 100%; padding: 32px 32px 0; color: var(--text); }
.scard-link:hover { text-decoration: none; }
.scard-eyebrow { margin-bottom: 8px; font-size: 12px; font-weight: 600; letter-spacing: .02em; color: var(--accent); }
.scard-title {
  margin: 0 0 10px; font-size: 28px; line-height: 1.18; letter-spacing: -.02em;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.scard-desc {
  margin: 0 0 12px; font-size: 15px; line-height: 1.55; color: var(--text-2);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.scard-meta { font-size: 13px; color: var(--text-3); }
.scard-visual { position: relative; margin: auto -32px 0; height: 240px; display: grid; place-items: center; overflow: hidden; }
.scard-visual::before {
  content: ""; position: absolute; left: 50%; bottom: -120px; width: 340px; height: 340px; margin-left: -170px; border-radius: 50%;
  background: radial-gradient(circle, rgba(0,113,227,.30) 0%, rgba(90,200,250,.16) 42%, rgba(90,200,250,0) 70%);
  filter: blur(16px); transition: transform .8s var(--spring);
}
.scard:hover .scard-visual::before { transform: scale(1.12); }
.scard-visual .gicon { transition: transform .7s var(--spring); }
.scard:hover .scard-visual .gicon { transform: translateY(-8px) rotate(-3deg); }
.scard-visual.has-img { height: 260px; }
.scard-visual.has-img::before { display: none; }
.scard-visual img { width: 100%; height: 100%; object-fit: cover; }

.scard-dark { background: #000; }
.scard-dark .scard-link { color: #F5F5F7; }
.scard-dark .scard-desc { color: #A1A1A6; }
.scard-dark .scard-meta { color: #86868B; }
.scard-dark .scard-eyebrow { color: #2997FF; }
.scard-dark .scard-visual::before { background: radial-gradient(circle, rgba(41,151,255,.55) 0%, rgba(90,200,250,.20) 42%, rgba(90,200,250,0) 70%); }
html[data-theme="dark"] .scard-dark { background: #0A0A0B; box-shadow: inset 0 0 0 1px rgba(255,255,255,.08); }

.scard-more .scard-link { align-items: center; justify-content: center; gap: 16px; text-align: center; }
.scard-more .gbtn-circle { width: 56px; height: 56px; }

/* --- iOS 26 玻璃 App 圖示 --- */
.gicon {
  --s: 88px;
  position: relative; isolation: isolate; flex-shrink: 0;
  width: var(--s); height: var(--s); border-radius: calc(var(--s) * .2237);
  display: grid; place-items: center; color: #fff;
  background: linear-gradient(165deg, #6DB9FF 0%, #1E86FF 44%, #0060DF 100%);
  box-shadow:
    inset 0 1.5px 1px rgba(255,255,255,.7),
    inset 0 -3px 6px rgba(0,30,90,.25),
    0 14px 30px rgba(0,90,220,.28),
    0 2px 5px rgba(0,60,160,.18);
}
.gicon::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: linear-gradient(180deg, rgba(255,255,255,.45) 0%, rgba(255,255,255,.08) 44%, rgba(255,255,255,0) 60%);
}
.gicon::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; padding: 1.5px;
  background: linear-gradient(150deg, rgba(255,255,255,.95), rgba(255,255,255,.12) 40%, rgba(255,255,255,.05) 62%, rgba(255,255,255,.6));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
}
.gicon .icon { position: relative; z-index: 1; width: 52%; height: 52%; stroke-width: 1.9; filter: drop-shadow(0 1.5px 2px rgba(0,40,120,.35)); }
.gicon-lg { --s: 128px; }
.gicon-lg .icon { stroke-width: 1.7; }

/* --- 4. 關於我（終端機） --- */
.about-glow {
  position: absolute; right: -240px; bottom: -420px; width: 980px; height: 980px; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, rgba(0,113,227,.50) 0%, rgba(90,200,250,.14) 38%, rgba(0,0,0,0) 66%);
  filter: blur(30px);
}
.about-grid { position: relative; display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); gap: clamp(40px, 6vw, 72px); align-items: center; }
.about-copy .display { color: #F5F5F7; }

.terminal {
  position: relative; overflow: hidden; border-radius: 18px;
  background: rgba(28,28,32,.55);
  -webkit-backdrop-filter: blur(30px) saturate(180%); backdrop-filter: blur(30px) saturate(180%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.18), inset 0 0 0 1px rgba(255,255,255,.08), 0 40px 100px rgba(0,0,0,.6);
  font-family: var(--font-mono); color: #E5E5EA;
}
.terminal .code-bar { background: rgba(255,255,255,.05); border-bottom-color: rgba(255,255,255,.08); }
.terminal .code-lang { color: rgba(255,255,255,.55); }
.terminal-body { min-height: 300px; padding: 18px 22px 24px; font-size: 14px; line-height: 1.8; }
.t-line { margin: 0; white-space: normal; word-break: break-word; }
.scard-title { color: inherit; }
.t-prompt { color: #30D158; }
.t-cmd { color: #FFFFFF; }
.t-out { color: #C7C7CC; }
.t-out a { color: inherit; }
.t-out a:hover { color: #fff; text-decoration: none; }
.t-dirs { display: flex; flex-wrap: wrap; gap: 2px 22px; }
.t-out .t-dir { color: #64D2FF; font-weight: 600; }
.t-out .t-dir:hover { color: #64D2FF; text-decoration: underline; }
.t-hash { color: #FFD60A; }
.t-ref { color: #64D2FF; }
.t-branch { color: #30D158; }
.t-hidden { visibility: hidden; }
.t-caret, .is-typing .t-cmd::after {
  content: ""; display: inline-block; width: .6em; height: 1.1em; margin-left: 1px; vertical-align: -.18em;
  background: #E5E5EA; animation: dbp-blink 1.1s steps(1) infinite;
}
.is-typing .t-cmd::after { animation: none; }
@keyframes dbp-blink { 50% { opacity: 0; } }

/* --- 5. 依主題瀏覽 --- */
.topic-row { list-style: none; margin: 56px 0 0; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 28px 44px; }
.topic { display: flex; flex-direction: column; align-items: center; gap: 12px; width: 140px; color: var(--text); text-align: center; }
.topic:hover { text-decoration: none; }
.topic .gicon { transition: transform .6s var(--spring); }
.topic:hover .gicon { transform: translateY(-6px) scale(1.05); }
.topic-name { font-size: 17px; font-weight: 600; }
.topic-count { margin-top: -8px; font-size: 13px; color: var(--text-3); }
.tags-block { margin-top: 64px; text-align: center; }
.mini-title { margin: 0 0 16px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.tag-list-center { justify-content: center; max-width: 760px; margin: 0 auto; }
.topics-sect .tag-list a { background: var(--surface); box-shadow: var(--shadow-sm); }
.topics-sect .tag-list a:hover { background: var(--accent-tint); }

/* --- 捲動淡入（沒有 JS 時維持可見） --- */
html.js [data-reveal] {
  opacity: 0; translate: 0 40px;
  transition: opacity .9s var(--ease) var(--d, 0ms), translate 1.2s var(--spring) var(--d, 0ms), transform .6s var(--spring), box-shadow .6s var(--ease);
}
html.js [data-reveal].is-in { opacity: 1; translate: none; }

/* --- 首頁響應式 --- */
@media (max-width: 1068px) {
  .about-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 834px) {
}
@media (max-width: 734px) {
  .hero { min-height: 0; }
  /* 這條原本會把滿版高度壓掉，首頁 hero 要維持滿版所以得自己覆寫回來 */
  .hero.hero-compact { min-height: 100vh; min-height: 100svh; }
  .emblem-float { width: 136px; }
  .sect-row { align-items: flex-start; }
  .shelf-nav { display: none; }
  .scard-link { min-height: 460px; padding: 28px 26px 0; }
  .scard-title { font-size: 24px; }
  .scard-visual { margin-left: -26px; margin-right: -26px; height: 210px; }
  .gicon { --s: 76px; }
  .gicon-lg { --s: 108px; }
  .terminal-body { min-height: 0; padding: 16px 16px 20px; font-size: 12.5px; }
  .topic { width: 116px; }
  .topic-row { gap: 24px 16px; }
}
@media (prefers-reduced-motion: reduce) {
  .emblem-float { animation: none; }
  html.js [data-reveal] { opacity: 1; translate: none; }
  .hero-emblem, .hero-copy, .mini-editor-lg { transform: none !important; opacity: 1 !important; }
}

/* ============================================================
   19. 首頁文章列表 + 文章時間線
   ============================================================ */

/* 精簡主視覺 */
.hero-compact {
  /* 滿版沉浸：100svh 讓手機網址列收合時不會跳動，不支援的瀏覽器退回 100vh */
  min-height: 100vh;
  min-height: 100svh;
  /* 下內距要留給波浪（60px）+ 呼吸空間 */
  padding: calc(var(--nav-h) + 12px + clamp(40px, 6vw, 72px)) 0 clamp(104px, 11vw, 148px);
}
.hero-compact .hero-emblem { margin-bottom: clamp(28px, 3.4vw, 44px); }
.hero-compact .emblem-float { width: clamp(96px, 11vw, 148px); animation-duration: 9s; }
.hero-compact .emblem-glyph { filter: drop-shadow(0 0 8px rgba(255,255,255,.8)); }
.hero-compact .hero-title { font-size: clamp(38px, 5.6vw, 72px); margin-bottom: 16px; }
.hero-compact .hero-sub { font-size: clamp(17px, 2vw, 22px); }

.home-main { padding-top: clamp(40px, 5vw, 64px); padding-bottom: clamp(56px, 7vw, 88px); }
.is-front .sidebar { position: sticky; top: calc(var(--nav-h) + 28px); }

/* 分類列（只在側欄隱藏時出現，見下方 1068px 的 media query）
   版型：圓形首頁鍵｜可橫滑的分類膠囊｜更多 */
.cat-bar {
  display: none; align-items: center; margin-bottom: 20px;
  padding: 10px 14px; border-radius: var(--pill);
  background: var(--surface); box-shadow: var(--shadow-card);
}

/* 圓形首頁鍵 */
.cat-home {
  flex-shrink: 0; width: 52px; height: 52px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent); color: #fff;
  transition: background .2s var(--ease), transform .3s var(--spring);
}
.cat-home:hover { background: var(--accent-hover); color: #fff; text-decoration: none; transform: scale(1.04); }
.cat-home .icon { width: 24px; height: 24px; stroke-width: 2; }

.cat-sep { flex-shrink: 0; width: 1px; height: 30px; margin: 0 14px; background: var(--separator); }

/* 可橫向捲動的膠囊區；只有真的放不下時才加淡出遮罩 */
.cat-bar-track {
  /* position:relative 讓子元素的 offsetLeft 以這裡為基準（JS 捲動定位會用到） */
  position: relative;
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px;
  overflow-x: auto; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.cat-bar-track::-webkit-scrollbar { display: none; }
.cat-bar.is-overflow .cat-bar-track {
  -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 24px), transparent 100%);
  mask-image: linear-gradient(90deg, #000 calc(100% - 24px), transparent 100%);
}

/* 「更多」與它前面的分隔線：只有分類放不下時才出現。
   顯示規則寫成 .cat-bar.is-overflow 開頭（權重 0,2,0），才不會被後面單一 class 的規則蓋掉。 */
.cat-bar.is-overflow .cat-sep-more { display: block; }
.cat-bar.is-overflow .cat-more { display: inline-flex; }

.cat-pill {
  /* grow:1 讓膠囊平均撐滿整列（避免右邊留白）；shrink:0 讓分類太多時保持原寬並改成橫滑 */
  flex: 1 0 auto; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border-radius: var(--pill); white-space: nowrap;
  background: rgba(214, 225, 240, .72);
  background: color-mix(in srgb, var(--accent) 9%, var(--fill-2));
  color: var(--link); font-size: 15px; font-weight: 700;
  transition: background .2s var(--ease), color .2s var(--ease);
}
.cat-pill:hover {
  background: color-mix(in srgb, var(--accent) 20%, var(--fill-2));
  color: var(--link); text-decoration: none;
}
.cat-pill-count {
  padding: 2px 9px; border-radius: var(--pill);
  background: rgba(176, 200, 233, .85);
  background: color-mix(in srgb, var(--accent) 22%, var(--fill-2));
  color: var(--text-2); font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums;
}
.cat-pill.is-current { background: var(--accent); color: #fff; }
.cat-pill.is-current:hover { background: var(--accent-hover); color: #fff; }
.cat-pill.is-current .cat-pill-count { background: rgba(255,255,255,.28); color: #fff; }

/* 預設隱藏，只有 .cat-bar.is-overflow 時才顯示（見上方權重較高的規則） */
.cat-sep-more { display: none; }
.cat-more {
  flex-shrink: 0; display: none; align-items: center; gap: 2px;
  padding: 10px 6px 10px 12px; color: var(--link); font-size: 15px; font-weight: 700; white-space: nowrap;
}
.cat-more:hover { color: var(--accent-hover); text-decoration: none; }
.cat-more .icon { width: 16px; height: 16px; stroke-width: 2.4; }

/* 顯示條件＝側欄被隱藏。這條必須放在上面的 display:none 之後，否則同權重會被蓋掉。
   卡片維持滿寬（縮成 fit-content 會變成只佔半個版面），右邊的空白改由膠囊撐開填滿。 */
@media (max-width: 1068px) {
  .cat-bar { display: flex; }
}
@media (max-width: 480px) {
  .cat-bar { padding: 8px 10px; }
  .cat-home { width: 44px; height: 44px; }
  .cat-home .icon { width: 20px; height: 20px; }
  .cat-sep { margin: 0 10px; height: 26px; }
  .cat-pill { padding: 8px 13px; font-size: 14px; }
  .cat-more { padding-left: 8px; font-size: 14px; }
}

/* 分隔線標題 */
.divider-title {
  display: flex; align-items: center; gap: 18px;
  margin: 0 0 24px; font-size: 15px; font-weight: 600; color: var(--text-2); letter-spacing: .01em;
}
.divider-title::before, .divider-title::after { content: ""; flex: 1; height: 1px; background: var(--separator); }
.post-rows + .divider-title { margin-top: 48px; }

/* 文章列表項目：純文字卡片 + 加深的浮起陰影 */
:root {
  --shadow-sm:         0 1px 2px rgba(0,0,0,.04), 0 6px 20px rgba(0,0,0,.08);
  --shadow-card:       0 2px 4px rgba(0,0,0,.05), 0 10px 28px rgba(0,0,0,.11);
  --shadow-card-hover: 0 8px 18px rgba(0,0,0,.10), 0 26px 60px rgba(0,0,0,.17);
}
html[data-theme="dark"] {
  --shadow-sm:         0 0 0 1px rgba(255,255,255,.06), 0 8px 24px rgba(0,0,0,.50);
  --shadow-card:       0 0 0 1px rgba(255,255,255,.07), 0 12px 32px rgba(0,0,0,.60);
  --shadow-card-hover: 0 0 0 1px rgba(255,255,255,.16), 0 22px 54px rgba(0,0,0,.75);
}

.post-rows { display: grid; gap: 20px; }

.prow {
  position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto;
  align-items: center; gap: 24px; padding: 28px;
  background: var(--surface); border-radius: 20px;
  box-shadow: var(--shadow-card);
  transition: transform .45s var(--spring), box-shadow .45s var(--ease);
}
.prow:hover { transform: translateY(-4px); box-shadow: var(--shadow-card-hover); }
.prow:active { transform: translateY(-1px); }
.prow:focus-within { box-shadow: var(--shadow-card-hover); }
.prow-body { min-width: 0; }

/* 標題列：藍色文件圖示 + 標題 */
.prow-title {
  display: flex; align-items: center; gap: 14px;
  margin: 0 0 14px; font-size: 24px; line-height: 1.3; letter-spacing: -.02em;
}
.prow-icon { width: 26px; height: 26px; flex-shrink: 0; color: var(--accent); stroke-width: 1.8; }
.prow-title a { min-width: 0; color: var(--text); transition: color .25s var(--ease); }
/* 讓整張卡片都能點 */
.prow-title a::after { content: ""; position: absolute; inset: 0; border-radius: inherit; z-index: 1; }
.prow:hover .prow-title a { color: var(--link); text-decoration: none; }

/* 日期／分類／字數藥丸 */
.prow-meta { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.meta-chip {
  position: relative; z-index: 2;
  padding: 6px 14px; border-radius: var(--pill);
  background: var(--accent-tint); color: var(--link);
  font-size: 14px; font-weight: 500; line-height: 1.4;
  transition: background .2s var(--ease);
}
a.meta-chip:hover { background: color-mix(in srgb, var(--accent) 22%, transparent); color: var(--link); text-decoration: none; }
.meta-chip.is-pin { background: var(--accent); color: #fff; font-weight: 600; }

.prow-excerpt {
  margin: 0 0 14px; font-size: 16px; line-height: 1.65; color: var(--text-2);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.prow-excerpt:last-child { margin-bottom: 0; }

/* 標籤藥丸 */
.prow-tags { display: flex; flex-wrap: wrap; gap: 10px; }
.tag-chip {
  position: relative; z-index: 2;
  padding: 6px 14px; border-radius: var(--pill);
  background: var(--fill-2); color: var(--link); font-size: 14px; line-height: 1.4;
  transition: background .2s var(--ease);
}
.tag-chip:hover { background: var(--accent-tint); color: var(--link); text-decoration: none; }

/* 右側箭頭鍵 */
.prow-arrow {
  flex-shrink: 0; width: 64px; height: 64px; border-radius: 18px;
  display: grid; place-items: center;
  background: var(--accent-tint); color: var(--link);
  transition: background .3s var(--ease), color .3s var(--ease), transform .35s var(--spring);
}
.prow-arrow .icon { width: 24px; height: 24px; stroke-width: 2; }
.prow:hover .prow-arrow { background: var(--accent); color: #fff; transform: translateX(3px); }

.rows-more { margin: 32px 0 0; text-align: center; font-size: 17px; }

/* 文章時間線 */
.tl-page .page-hero { margin-bottom: 8px; }
.tl-intro { margin-bottom: 8px; font-size: 16px; color: var(--text-2); }
.tl { position: relative; margin: 32px 0 0; padding-left: 30px; }
.tl::before {
  content: ""; position: absolute; left: 5px; top: 12px; bottom: 12px; width: 2px; border-radius: 2px;
  background: linear-gradient(180deg, var(--separator-2) 0%, var(--separator) 72%, transparent 100%);
}
.tl-head {
  position: relative; display: flex; align-items: baseline; gap: 8px;
  margin: 44px 0 14px; font-size: 22px; letter-spacing: -.015em;
}
.tl > .tl-head:first-child { margin-top: 0; }
.tl-head::before {
  content: ""; position: absolute; left: -30px; top: 50%; translate: 0 -50%;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--bg); box-shadow: inset 0 0 0 2px var(--accent);
}
.tl-head .sep { color: var(--text-3); font-weight: 400; }
.tl-head .m { font-size: 19px; font-weight: 600; color: var(--text-2); }

.tl-item { position: relative; display: flex; align-items: baseline; gap: 14px; padding: 9px 0; color: var(--text); }
.tl-item::before {
  content: ""; position: absolute; left: -27px; top: 19px; width: 7px; height: 7px; border-radius: 50%;
  background: var(--separator-2); transition: background .2s var(--ease), transform .35s var(--spring);
}
.tl-item:hover { text-decoration: none; }
.tl-item:hover::before { background: var(--accent); transform: scale(1.4); }
.tl-date { flex-shrink: 0; font-family: var(--font-mono); font-size: 13px; color: var(--text-3); }
.tl-title { font-size: 17px; line-height: 1.5; }
.tl-item:hover .tl-title { color: var(--link); }

@media (max-width: 1068px) {
  /* 窄螢幕直接不顯示首頁側欄（作者、分類、標籤、最新文章），不堆疊到下方 */
  .is-front .sidebar { display: none; }
}
@media (max-width: 860px) {
  .prow { padding: 24px; gap: 18px; }
  .prow-title { font-size: 21px; gap: 12px; }
  .prow-icon { width: 23px; height: 23px; }
  .prow-arrow { width: 54px; height: 54px; border-radius: 16px; }
}
@media (max-width: 734px) {
  /* 手機版收成單欄，箭頭鍵隱藏把寬度讓給文字（整張卡片本來就可點） */
  .prow { grid-template-columns: minmax(0, 1fr); padding: 20px; gap: 0; }
  .prow-arrow { display: none; }
  .prow-title { font-size: 19px; gap: 10px; margin-bottom: 12px; }
  .prow-icon { width: 21px; height: 21px; }
  .prow-excerpt { font-size: 15px; }
  .meta-chip, .tag-chip { font-size: 13px; padding: 5px 12px; }
}
/* ============================================================
   20. 單篇文章：滿版封面 + 內容卡 + 文章目錄
   ============================================================ */
body.single .site-main { padding-top: 0; }

.post-cover {
  position: relative; isolation: isolate; overflow: hidden; color: #fff;
  margin-top: calc(-1 * (var(--nav-h) + 12px));
  /* 下內距要扣掉 60px 的波浪，剩下的才是資訊列底下的留白 */
  padding: calc(var(--nav-h) + 12px + clamp(56px, 8vw, 108px)) 0 clamp(110px, 11vw, 154px);
}
.post-cover-bg {
  position: absolute; inset: 0; z-index: -2;
  background:
    radial-gradient(70% 60% at 18% 12%, rgba(255,255,255,.30), rgba(255,255,255,0) 62%),
    linear-gradient(140deg, #5182D6 0%, #3C60BA 46%, #2C4694 100%);
}
html[data-theme="dark"] .post-cover-bg {
  background:
    radial-gradient(70% 60% at 18% 12%, rgba(120,170,255,.26), rgba(120,170,255,0) 62%),
    linear-gradient(140deg, #1E3762 0%, #142748 46%, #0A1730 100%);
}
.post-cover.has-img .post-cover-bg {
  background-image: linear-gradient(180deg, rgba(12,26,58,.55) 0%, rgba(12,26,58,.78) 100%), var(--cover);
  background-size: cover, cover; background-position: center, center;
}
/* 會動的波浪：同一條波形疊四層，各自用不同速度左右漂移 */
.cover-wave {
  position: absolute; left: 0; right: 0; bottom: -1px; z-index: -1;
  width: 100%; height: 60px; color: var(--bg);
}
.cover-wave use { fill: currentColor; animation: dbp-wave 20s cubic-bezier(.55,.5,.45,.5) infinite; will-change: transform; }
.cover-wave .w1 { opacity: .74; animation-duration: 7s;  animation-delay: -2s; }
.cover-wave .w2 { opacity: .51; animation-duration: 10s; animation-delay: -3s; }
.cover-wave .w3 { opacity: .21; animation-duration: 13s; animation-delay: -4s; }
.cover-wave .w4 { opacity: 1;   animation-duration: 20s; animation-delay: -5s; }
@keyframes dbp-wave {
  0%   { transform: translateX(-90px); }
  100% { transform: translateX(85px); }
}
@media (prefers-reduced-motion: reduce) {
  .cover-wave use { animation: none; }
}

.post-cover-inner { position: relative; }
.cover-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-bottom: 18px; }
.cover-chip {
  padding: 5px 14px; border-radius: var(--pill); font-size: 13px; font-weight: 600; color: #fff;
  background: rgba(255,255,255,.22);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.32);
  transition: background .2s var(--ease);
}
.cover-chip:hover { background: rgba(255,255,255,.36); color: #fff; text-decoration: none; }
.cover-tag { font-size: 14px; color: rgba(255,255,255,.82); }
.cover-tag:hover { color: #fff; text-decoration: none; }

.cover-title {
  margin: 0 0 22px; max-width: 22em; color: #fff;
  font-size: clamp(30px, 4.6vw, 54px); line-height: 1.16; letter-spacing: -.026em;
  text-shadow: 0 2px 26px rgba(10,25,60,.30);
}
.cover-meta { display: flex; flex-wrap: wrap; gap: 10px 24px; font-size: 14px; color: rgba(255,255,255,.9); }

/* 分類／標籤頁共用同一個封面 */
body.archive .site-main { padding-top: 0; }
.cover-desc {
  margin: 0 0 18px; max-width: 42em; color: rgba(255,255,255,.88);
  font-size: clamp(16px, 1.8vw, 19px); line-height: 1.55;
}
.cover-meta span { display: inline-flex; align-items: center; gap: 6px; }
.cover-meta .icon { width: 15px; height: 15px; opacity: .85; }

.post-main { padding-top: clamp(32px, 4vw, 56px); padding-bottom: clamp(48px, 6vw, 80px); }

/* 文章頁側欄 272px：個人資料卡要能單行放下介紹文字（需 219px + 左右內距 44px） */
.post-main .layout { grid-template-columns: minmax(0, 1fr) 272px; }
/* 螢幕夠寬時讓側欄往右延伸出容器，內文維持 802px 不被壓縮 */
@media (min-width: 1280px) {
  .post-main .layout { margin-right: -50px; }
}
/* 這條規則的權重比通用的 .layout 高，窄螢幕要自己覆寫成單欄，否則不會收合 */
@media (max-width: 1068px) {
  .post-main .layout { grid-template-columns: minmax(0, 1fr); }
  /* 窄螢幕直接不顯示文章頁側欄（作者卡與目錄），不改成堆疊在下方 */
  .sidebar.is-post { display: none; }
}

/* 標題錨點 */
.entry-content h2, .entry-content h3 { position: relative; padding-right: 30px; }
.h-anchor {
  position: absolute; right: 0; top: 50%; translate: 0 -50%;
  display: inline-flex; opacity: 0; color: var(--text-3);
  transition: opacity .2s var(--ease), color .2s var(--ease);
}
.h-anchor .icon { width: 19px; height: 19px; }
.h-anchor:hover { color: var(--accent); text-decoration: none; }
.entry-content h2:hover .h-anchor, .entry-content h3:hover .h-anchor { opacity: 1; }

/* 內文：藍色項目符號、藍色行內程式碼 */
.entry-content ul { list-style: none; padding-left: 1.6em; }
.entry-content ul > li { position: relative; }
.entry-content ul > li::before {
  content: ""; position: absolute; left: -1.1em; top: .68em;
  width: 7px; height: 7px; border-radius: 50%; background: var(--accent);
}
.entry-content ol > li::marker { color: var(--accent); font-weight: 600; }
.entry-content :not(pre) > code {
  background: var(--accent-tint); color: var(--link);
  box-shadow: inset 0 0 0 1px rgba(0,113,227,.18);
}

/* 長程式碼收合 */
.code-window.is-collapsible .code-body { position: relative; max-height: 360px; overflow: hidden; }
.code-window.is-collapsible:not(.is-open) .code-body::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 90px; pointer-events: none;
  background: linear-gradient(180deg, transparent, var(--code-bg));
}
.code-window.is-open .code-body { max-height: none; }
.code-expand {
  display: flex; align-items: center; justify-content: center; gap: 6px; width: 100%;
  padding: 9px 12px; border: 0; border-top: 1px solid var(--code-border); cursor: pointer;
  background: var(--code-bar); color: var(--text-2); font: 500 12px var(--font);
  transition: color .2s var(--ease);
}
.code-expand:hover { color: var(--text); }
.code-expand .icon { width: 14px; height: 14px; transition: transform .35s var(--spring); }
.code-window.is-open .code-expand .icon { transform: rotate(180deg); }

/* 側邊欄：作者卡 + 目錄卡 */
.sidebar.is-post { position: sticky; top: calc(var(--nav-h) + 28px); align-self: start; gap: 20px; }
.author-card { padding: 18px; }
.author-top { display: flex; align-items: center; gap: 14px; }
.author-card .avatar { width: 52px; height: 52px; font-size: 22px; }
.author-card .profile-name { font-size: 17px; margin: 0; }
/* 簡介改成整列，側欄收窄後才不會被頭像擠成三行 */
.author-card .profile-bio { margin: 10px 0 0; }
.author-actions { display: flex; gap: 8px; margin-top: 16px; }
.author-btn {
  flex: 1; padding: 9px 12px; border-radius: var(--pill); text-align: center;
  background: var(--accent); color: #fff; font-size: 14px; font-weight: 500;
  transition: background .2s var(--ease);
}
.author-btn:hover { background: var(--accent-hover); color: #fff; text-decoration: none; }
.author-btn-plain { background: var(--fill-2); color: var(--text); }
.author-btn-plain:hover { background: var(--fill); color: var(--text); }

.toc-card { padding: 16px 8px 14px 14px; }
.toc-card .toc-title {
  display: flex; align-items: center; gap: 8px; margin: 0 0 10px; padding-left: 4px;
  font-size: 14px; font-weight: 600; color: var(--text);
}
.toc-card .toc-title .icon { width: 15px; height: 15px; color: var(--accent); }
.sidebar.is-post .toc { position: static; }
.toc-card .toc-list {
  border-left: 0; padding-right: 6px;
  max-height: min(56vh, 560px); overflow-y: auto; scrollbar-width: thin;
}
.toc-card .toc-list a {
  margin-left: 0; padding: 6px 8px; border-left: 0; border-radius: 8px;
  color: var(--text-2); font-size: 14px; transition: background .2s var(--ease), color .2s var(--ease);
}
.toc-card .toc-list a:hover { background: var(--fill-2); color: var(--text); }
.toc-card .toc-list a.is-active { background: var(--accent-tint); color: var(--link); font-weight: 600; }
.toc-card .toc-list .toc-h3 { padding-left: 18px; font-size: 12.5px; }

/* 相關文章 */
.related { margin-top: 40px; }
.related-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.related-card {
  display: flex; flex-direction: column; gap: 8px; padding: 18px 20px;
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-sm); color: var(--text);
  transition: transform .45s var(--spring), box-shadow .45s var(--ease);
}
.related-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-card-hover); text-decoration: none; }
.related-date { font-family: var(--font-mono); font-size: 12px; color: var(--text-3); }
.related-title {
  font-size: 16px; font-weight: 600; line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.related-card:hover .related-title { color: var(--link); }

/* 右下浮動按鈕 */
.fab-stack { position: fixed; right: 20px; bottom: 20px; z-index: 80; display: grid; gap: 10px; }
.fab {
  width: 42px; height: 42px; padding: 0; border: 0; border-radius: 14px; cursor: pointer;
  display: grid; place-items: center; color: #fff; background: var(--accent);
  box-shadow: 0 6px 18px rgba(0,90,220,.30);
  transition: background .2s var(--ease), transform .35s var(--spring);
}
.fab:hover { background: var(--accent-hover); color: #fff; text-decoration: none; transform: translateY(-2px); }
.fab .icon { width: 18px; height: 18px; }
.fab-stack .to-top {
  position: static; width: 42px; height: 42px; border-radius: 14px;
  background: var(--accent); color: #fff; box-shadow: 0 6px 18px rgba(0,90,220,.30);
  opacity: 0; visibility: hidden; transform: translateY(10px);
}
.fab-stack .to-top.is-visible { opacity: 1; visibility: visible; transform: none; }
.fab-stack .to-top:hover { background: var(--accent-hover); transform: translateY(-2px); }

/* 導覽列閱讀進度圈 */
.read-ring { position: relative; display: none; place-items: center; width: 34px; height: 34px; flex-shrink: 0; }
body.single .read-ring { display: grid; }
.read-ring svg { width: 34px; height: 34px; transform: rotate(-90deg); }
.read-ring .ring-bg { stroke: var(--fill); }
.read-ring .ring-fg { stroke: var(--accent); stroke-dashoffset: 0; transition: stroke-dashoffset .15s linear; }
.read-pct { position: absolute; font-size: 11px; font-weight: 600; color: var(--text-2); font-variant-numeric: tabular-nums; }

@media (max-width: 1068px) {
  .sidebar.is-post { position: static; }
  .toc-card .toc-list { max-height: 320px; }
}
@media (max-width: 834px) {
  .related-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 734px) {
  .post-cover { padding-bottom: 104px; text-align: center; }
  .cover-chips { justify-content: center; }
  .cover-title { max-width: none; }
  .cover-meta { justify-content: center; gap: 8px 16px; font-size: 13px; }
  .related-grid { grid-template-columns: minmax(0, 1fr); }
  .fab-stack { right: 14px; bottom: 14px; }
  body.single .read-ring { display: none; }
}

@media (max-width: 734px) {
  .tl { padding-left: 24px; }
  .tl-head { font-size: 19px; margin-top: 36px; }
  .tl-head .m { font-size: 17px; }
  .tl-head::before { left: -24px; width: 10px; height: 10px; }
  .tl-item::before { left: -21px; }
  .tl-title { font-size: 16px; }
}

/* ============================================================
   21. 分類／標籤總覽頁（面板 + 卡片格線）
   ============================================================ */
/* 這兩頁頂部是滿版封面，要吃掉 site-main 的上內距 */
body.page-template-template-categories .site-main,
body.page-template-template-tags .site-main { padding-top: 0; }

/* 面板本身不上底色，標題卡與卡片直接落在頁面背景上 */
.term-panel { padding: 0; }

.term-head {
  padding: 26px 28px;
  background: var(--surface);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
}
.term-head h2 {
  margin: 0 0 8px;
  font-size: 28px; font-weight: 700; letter-spacing: -.02em;
  color: var(--accent);
}
.term-head p { margin: 0; font-size: 14px; color: var(--text-3); }

.term-grid {
  margin-top: 14px;
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}

.term-card {
  display: flex; align-items: center; gap: 14px;
  padding: 24px 18px 24px 20px;
  background: var(--surface); border-radius: 14px;
  box-shadow: var(--shadow-sm); color: var(--text);
  transition: transform .4s var(--spring), box-shadow .4s var(--ease);
}
.term-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-card); text-decoration: none; }
.term-card:active { transform: translateY(-1px); }

.term-card-icon {
  flex-shrink: 0; width: 52px; height: 52px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent-tint); color: var(--accent);
}
.term-card-icon .icon { width: 25px; height: 25px; stroke-width: 1.8; }

.term-card-body { flex: 1; min-width: 0; }
.term-card-name {
  display: block;
  font-size: 19px; font-weight: 700; letter-spacing: -.01em; line-height: 1.3;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  transition: color .25s var(--ease);
}
.term-card-count { display: block; margin-top: 6px; font-size: 14px; color: var(--text-3); }
.term-card .chev {
  flex-shrink: 0; width: 18px; height: 18px; color: var(--text-3); stroke-width: 1.6;
  transition: transform .3s var(--spring), color .3s var(--ease);
}
.term-card:hover .term-card-name { color: var(--link); }
.term-card:hover .chev { color: var(--accent); transform: translateX(3px); }

.term-empty {
  margin-top: 14px; padding: 44px 24px;
  background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-sm);
  text-align: center; color: var(--text-3);
}
.term-empty .icon { width: 40px; height: 40px; stroke-width: 1.3; margin-bottom: 12px; }
.term-empty p { margin: 0; font-size: 15px; }

.term-intro { margin-top: 28px; }

/* 導覽列下拉子選單：指示箭頭 + 滑鼠橋接 */
.nav-menu .menu-item-has-children > a { display: inline-flex; align-items: center; gap: 5px; }
.nav-menu .menu-item-has-children > a::after {
  content: ""; width: 5px; height: 5px; margin-top: -2px;
  border-right: 1.4px solid currentColor; border-bottom: 1.4px solid currentColor;
  transform: rotate(45deg); opacity: .55;
  transition: transform .25s var(--spring);
}
.nav-menu .menu-item-has-children:hover > a::after { transform: rotate(45deg) translate(1px, 1px); }
/* 父項與子選單之間有 10px 空隙，補一塊透明的橋，否則滑過去時選單會關掉 */
.nav-menu .sub-menu::before { content: ""; position: absolute; left: 0; right: 0; top: -12px; height: 12px; }
.nav-menu .sub-menu a { white-space: nowrap; }

@media (max-width: 1068px) {
  .term-head { padding: 22px; }
  .term-head h2 { font-size: 24px; }
}
@media (max-width: 734px) {
  .term-grid { grid-template-columns: minmax(0, 1fr); }
  .term-card { padding: 18px 16px; }
}

/* 標籤總覽：一張白卡裝滿藥丸（.term-panel 的 cloud 版面） */
.term-cloud {
  margin-top: 14px;
  padding: 30px 26px;
  background: var(--surface);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
  display: flex; flex-wrap: wrap; gap: 14px 16px;
}
.tcloud-chip {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 11px 18px; border-radius: var(--pill);
  background: var(--fill-2); color: var(--text-2);
  font-size: 17px; font-weight: 500; line-height: 1.3;
  transition: background .25s var(--ease), color .25s var(--ease), transform .3s var(--spring);
}
.tcloud-chip:hover {
  background: var(--accent-tint); color: var(--link);
  text-decoration: none; transform: translateY(-2px);
}
.tcloud-count {
  flex-shrink: 0;
  min-width: 26px; height: 26px; padding: 0 7px; border-radius: var(--pill);
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--fill-hover); color: var(--text-3);
  font-size: 14px; font-weight: 500; line-height: 1;
  transition: background .25s var(--ease), color .25s var(--ease);
}
.tcloud-chip:hover .tcloud-count {
  background: rgba(0,113,227,.18); /* 舊瀏覽器後備 */
  background: color-mix(in srgb, var(--accent) 20%, transparent);
  color: var(--link);
}

@media (max-width: 734px) {
  .term-cloud { padding: 20px 16px; gap: 12px; }
  .tcloud-chip { padding: 9px 14px; font-size: 15px; gap: 8px; }
  .tcloud-count { min-width: 23px; height: 23px; font-size: 13px; }
}

/* ============================================================
   22. 靈動島：窄螢幕與減少動態
   ============================================================ */
@media (max-width: 834px) {
  /* 選單收進漢堡後就沒有項目可以滑，指示器一併停用 */
  .nav-ind { display: none; }
  .site-header { width: calc(100% - 24px); }
  .site-header.is-compact { transform: scale(.98); }
}
@media (prefers-reduced-motion: reduce) {
  .site-header, .nav-ind, .brand-text, .nav-menu .sub-menu { transition: none !important; }
  .site-header::before { display: none; }
}

/* ------------------------------------------------------------
   靈動島補強：兩個目視才看得出來的問題
   ------------------------------------------------------------ */
/* 1. 島縮小後常壓在白色卡片上，玻璃對白底沒有對比會「融」進去，
      所以 is-compact 時把陰影加深，讓它確實浮起來。 */
.site-header.is-compact {
  box-shadow: inset 0 1px 0 var(--glass-rim), inset 0 0 0 .5px var(--glass-edge),
              0 2px 8px rgba(0,0,0,.07), 0 16px 44px rgba(0,0,0,.18);
}
html[data-theme="dark"] .site-header.is-compact {
  box-shadow: inset 0 1px 0 var(--glass-rim), inset 0 0 0 .5px rgba(255,255,255,.10),
              0 2px 8px rgba(0,0,0,.5), 0 16px 44px rgba(0,0,0,.7);
}

/* 2. 行動版選單面板很高，會同時蓋到藍色封面與淺色內容，
      用島那種 .64 的透明度會上半透出藍、下半透出白，文字讀不清楚，
      所以面板要比島更實。 */
.mobile-nav {
  background: rgba(255, 255, 255, .95);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  backdrop-filter: blur(30px) saturate(180%);
  max-height: calc(100vh - var(--island-h, var(--nav-h)) - 48px);
}
html[data-theme="dark"] .mobile-nav { background: rgba(28, 28, 30, .95); }
@supports not ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .mobile-nav { background: var(--surface); }
}

/* ============================================================
   23. 背景輪播（首頁主視覺 + 各頁封面）
   ============================================================ */
/* 輪播層直接掛在既有的 .hero-bg / .post-cover-bg 上，不改 HTML 結構。
   每張圖是一個 .bgc-slide，用 opacity 交叉淡入，所以不會有位移或閃爍。 */
.bgc { position: absolute; inset: 0; overflow: hidden; }
.bgc-slide {
  position: absolute; inset: 0;
  background-size: cover; background-position: center;
  opacity: 0;
  transition: opacity 1.6s var(--ease);
  will-change: opacity;
  /* 極慢的推近，讓靜態圖看起來有呼吸感 */
  animation: bgc-drift 24s ease-in-out infinite alternate;
}
.bgc-slide.is-on { opacity: 1; }
@keyframes bgc-drift {
  from { transform: scale(1); }
  to   { transform: scale(1.07); }
}

/* 圖片是明亮的藍天，白色標題壓上去會看不清楚，
   所以一定要有深色遮罩；原本的漸層背景本身就兼任遮罩，換成圖之後得補回來。 */
.bgc-scrim {
  position: absolute; inset: 0;
  background:
    radial-gradient(60% 55% at 50% 30%, rgba(10,26,60,.10), rgba(10,26,60,.34) 70%),
    linear-gradient(180deg, rgba(8,22,52,.46) 0%, rgba(8,22,52,.30) 42%, rgba(8,22,52,.62) 100%);
}
html[data-theme="dark"] .bgc-scrim {
  background:
    radial-gradient(60% 55% at 50% 30%, rgba(2,8,22,.34), rgba(2,8,22,.58) 70%),
    linear-gradient(180deg, rgba(2,8,22,.66) 0%, rgba(2,8,22,.54) 42%, rgba(2,8,22,.80) 100%);
}

/* 有輪播時就不要再畫原本的藍色漸層，否則會透出來變色 */
.hero-bg.has-bgc, .post-cover-bg.has-bgc { background: #2C4694; }
html[data-theme="dark"] .hero-bg.has-bgc,
html[data-theme="dark"] .post-cover-bg.has-bgc { background: #0A1730; }

/* 文章有特色圖時，特色圖優先，不套輪播（沿用既有的 has-img 行為） */
.post-cover.has-img .bgc { display: none; }

@media (prefers-reduced-motion: reduce) {
  .bgc-slide { animation: none; transition: none; }
}

/* ============================================================
   24. 上下篇導覽 + 文章目錄（依參考圖 1:1）
   ============================================================ */
/* 這一節放在檔尾，才能勝過第 903 行的 .post-nav 與第 1771 行的 .toc-card 舊規則 */

/* --- 上下篇：兩張白卡，箭頭在外緣、標題朝中間，沒有「上一篇」標籤 --- */
.post-nav { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 22px; margin-top: 24px; }
.post-nav a {
  display: flex; align-items: center; gap: 18px;
  min-height: 76px; padding: 18px 26px; border-radius: 18px;
  background: var(--surface); box-shadow: var(--shadow-sm); color: var(--text);
  transition: transform .5s var(--spring), box-shadow .5s var(--ease);
}
.post-nav a:hover { transform: translateY(-2px); box-shadow: var(--shadow-card); text-decoration: none; }
.post-nav .pn-arrow {
  flex-shrink: 0; width: 22px; height: 22px; stroke-width: 2.2;
  color: #74A5F0;
  transition: transform .35s var(--island), color .25s var(--ease);
}
.post-nav a:hover .pn-arrow { color: var(--accent); }
.post-nav .prev:hover .pn-arrow { transform: translateX(-3px); }
.post-nav .next:hover .pn-arrow { transform: translateX(3px); }
/* 標題朝卡片中間靠，單行、放不下才截斷 */
.post-nav .t {
  flex: 1; min-width: 0;
  display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 17px; font-weight: 700; letter-spacing: -.01em; line-height: 1.4;
  text-wrap: nowrap;
}
.post-nav .prev .t { text-align: left; padding-left: 8px; }
.post-nav .next { justify-content: flex-end; }
.post-nav .next .t { text-align: right; padding-right: 8px; }

/* --- 文章目錄 --- */
.toc-card { padding: 20px 16px 18px; }
/* 標題左邊一條藍色短豎條 */
.toc-card .toc-title {
  display: flex; align-items: center; gap: 12px; margin: 0 0 14px; padding-left: 0;
  font-size: 20px; font-weight: 700; letter-spacing: -.02em; color: var(--text);
}
.toc-card .toc-title::before {
  content: ""; flex-shrink: 0;
  width: 4px; height: 20px; border-radius: 2px; background: var(--accent);
}
.toc-card .toc-list { border-left: 0; padding-right: 4px; display: grid; gap: 4px; }

.toc-card .toc-list a {
  display: flex; align-items: center; gap: 12px;
  margin-left: 0; padding: 9px 10px; border-left: 0; border-radius: 12px;
  color: var(--text); font-size: 15px; line-height: 1.4;
  transition: background .2s var(--ease), color .2s var(--ease);
}
.toc-card .toc-list .toc-text {
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* H2：圓形淡藍底的數字徽章 */
.toc-card .toc-no {
  flex-shrink: 0; width: 26px; height: 26px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: #D7E5F9; /* 舊瀏覽器後備 */
  background: color-mix(in srgb, var(--accent) 16%, var(--surface));
  color: var(--link); font-size: 13px; font-weight: 600; line-height: 1;
  transition: background .2s var(--ease), color .2s var(--ease);
}
.toc-card .toc-h2 { font-weight: 700; }

/* H3：縮排 + 灰色小圓點，不編號 */
.toc-card .toc-list .toc-h3 {
  padding-left: 26px; font-size: 14px; font-weight: 500; color: var(--text-2);
}
.toc-card .toc-dot {
  flex-shrink: 0; width: 26px; display: inline-flex; justify-content: center;
}
.toc-card .toc-dot::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%;
  background: var(--separator-2);
  transition: background .2s var(--ease);
}

/* 目前段落：整列淡藍灰底 */
.toc-card .toc-list a:hover { background: var(--fill-2); color: var(--text); }
.toc-card .toc-list a.is-active {
  background: #E8EFF8; /* 舊瀏覽器後備 */
  background: color-mix(in srgb, var(--accent) 9%, var(--fill-2));
  color: var(--text); font-weight: 700;
}
.toc-card .toc-list a.is-active .toc-no {
  background: var(--accent); color: #fff;
}
.toc-card .toc-list a.is-active .toc-dot::before { background: var(--accent); }

html[data-theme="dark"] .toc-card .toc-no { background: rgba(0,113,227,.26); }
html[data-theme="dark"] .toc-card .toc-list a.is-active { background: rgba(0,113,227,.16); }

@media (max-width: 734px) {
  .post-nav { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .post-nav a { min-height: 64px; padding: 16px 20px; }
  /* 單欄時不要翻轉方向：next 的 › 必須維持在右邊，否則會變成指向左 */
  .post-nav .next { justify-content: space-between; }
  .post-nav .next .t { text-align: left; padding-right: 8px; padding-left: 0; }
  .post-nav .prev { justify-content: flex-start; }
}

/* 第一篇／最後一篇只有單邊時，空的 <span> 佔位會讓那張卡孤零零靠邊，
   讓它跨滿兩欄比較好看。 */
.post-nav > span:empty { display: none; }
.post-nav > span:empty + a,
.post-nav > a:only-child { grid-column: 1 / -1; }
