/* 深淺色切換開關（首頁頁首、精簡列、效果單頁共用）：太陽／月亮旋鈕彈跳滑動，白天有雲、夜晚有星星；切換時整頁從開關位置畫圓展開 */
.thm{--w:64px;--h:32px;--k:26px;position:relative;flex:none;width:var(--w);height:var(--h);padding:0;border:0;border-radius:99px;cursor:pointer;background:none;-webkit-tap-highlight-color:transparent}
.thm-track{position:absolute;inset:0;border-radius:inherit;overflow:hidden;background:linear-gradient(180deg,#bfe3f5,#f6e7b8);box-shadow:inset 0 0 0 1px #00000014,inset 0 2px 4px #0000001f;transition:background .5s}
:root[data-theme=dark] .thm-track{background:linear-gradient(180deg,#0e1424,#2b3656);box-shadow:inset 0 0 0 1px #ffffff1a,inset 0 2px 4px #0006}
/* 雲（白天）與星星（夜晚） */
.thm .cl{position:absolute;right:7px;top:15px;width:14px;height:7px;border-radius:99px;background:#fff;box-shadow:-6px -3px 0 1px #fff,4px 2px 0 -1px #fffc;transition:transform .5s cubic-bezier(.5,1.6,.5,1),opacity .35s}
:root[data-theme=dark] .thm .cl{transform:translateY(16px);opacity:0}
.thm .st{position:absolute;width:3px;height:3px;border-radius:50%;background:#fff;opacity:0;transform:scale(0);transition:transform .45s cubic-bezier(.5,2,.5,1),opacity .3s}
.thm .s1{left:10px;top:8px}.thm .s2{left:20px;top:18px;width:2px;height:2px}.thm .s3{left:28px;top:9px;width:2px;height:2px}
:root[data-theme=dark] .thm .st{opacity:1;transform:scale(1)}
:root[data-theme=dark] .thm .s1{transition-delay:.18s}:root[data-theme=dark] .thm .s2{transition-delay:.28s}:root[data-theme=dark] .thm .s3{transition-delay:.38s}
:root[data-theme=dark] .thm .st{animation:thm-tw 2.4s ease-in-out .8s infinite}
:root[data-theme=dark] .thm .s2{animation-delay:1.4s}:root[data-theme=dark] .thm .s3{animation-delay:2s}
@keyframes thm-tw{50%{opacity:.35}}
/* 旋鈕：彈跳滑過去並翻轉，太陽換成月亮 */
.thm-knob{position:absolute;top:calc((var(--h) - var(--k))/2);left:calc((var(--h) - var(--k))/2);width:var(--k);height:var(--k);border-radius:50%;background:#ffd257;box-shadow:0 2px 6px #b8860b66,inset 0 -2px 0 #e9a92a;transition:transform .6s cubic-bezier(.45,1.7,.45,1),background .4s,box-shadow .4s}
:root[data-theme=dark] .thm-knob{transform:translateX(calc(var(--w) - var(--h))) rotate(360deg);background:#eef1f7;box-shadow:0 2px 8px #0008,inset 0 -2px 0 #c9d0de}
.thm-knob i{position:absolute;border-radius:50%;background:#cfd6e4;opacity:0;transition:opacity .3s .25s}
.thm-knob .c1{width:7px;height:7px;left:6px;top:6px}.thm-knob .c2{width:4px;height:4px;left:15px;top:14px}.thm-knob .c3{width:3px;height:3px;left:8px;top:16px}
:root[data-theme=dark] .thm-knob i{opacity:1}
.thm:hover .thm-knob{box-shadow:0 0 0 4px #ffd25733,0 2px 6px #b8860b66,inset 0 -2px 0 #e9a92a}
:root[data-theme=dark] .thm:hover .thm-knob{box-shadow:0 0 0 4px #eef1f726,0 2px 8px #0008,inset 0 -2px 0 #c9d0de}
.thm:active .thm-knob{width:calc(var(--k) + 6px);border-radius:99px}
:root[data-theme=dark] .thm:active .thm-knob{margin-left:-6px}
.thm:focus-visible{outline:2px solid var(--link,#705d44);outline-offset:3px}
/* 切換時：新畫面從開關位置畫圓展開（支援 View Transitions 的瀏覽器） */
::view-transition-old(root),::view-transition-new(root){animation:none;mix-blend-mode:normal}
@media (prefers-reduced-motion:reduce){.thm *,.thm-knob{transition:none!important;animation:none!important}}

/* 語言切換（中文 ⇄ English）：深淺色開關旁邊的小膠囊；首頁頁首、精簡列、效果單頁共用 */
.lang{display:inline-flex;align-items:center;justify-content:center;gap:5px;flex:none;height:32px;padding:0 12px;border-radius:99px;border:1px solid var(--line);background:var(--card);color:var(--fg);font:700 13px/1 "Noto Sans TC",system-ui,sans-serif;letter-spacing:.02em;text-decoration:none;white-space:nowrap;transition:border-color .2s,background-color .2s}
.lang svg{width:15px;height:15px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
.lang:hover,.lang:focus-visible{border-color:var(--link)}
#mini .lang{height:28px;padding:0 10px;border-radius:8px}
.crumb .lang{margin-left:auto}
.crumb .lang+.thm{margin-left:0}
@media (max-width:760px){#mini .lang{display:none}header .hd-r{gap:6px}header .hd-r .lang,header .hd-r .qa-link{padding:0 10px}}
/* Q&A 入口：和語言切換同款的小膠囊，放在頁首右上角（首頁）與效果頁導覽列 */
.qa-link{display:inline-flex;align-items:center;justify-content:center;flex:none;height:32px;padding:0 12px;border-radius:99px;border:1px solid var(--line);background:var(--card);color:var(--fg);font:700 13px/1 "Noto Sans TC",system-ui,sans-serif;text-decoration:none;white-space:nowrap;transition:border-color .2s}
.qa-link:hover,.qa-link:focus-visible{border-color:var(--link)}
.crumb .qa-link{margin-left:auto}
.crumb .qa-link+.lang{margin-left:0}
/* 手機：右上角放 Q&A、語言、深淺色三顆，改成較小的尺寸並拿掉地球圖示，才不會壓到左邊的文字 */
@media (max-width:520px){
  header .hd-r .thm,.crumb .thm{--w:52px;--h:28px;--k:22px}
  header .hd-r .lang svg,.crumb .lang svg{display:none}
  header .hd-r .lang,header .hd-r .qa-link,.crumb .lang,.crumb .qa-link{height:28px;padding:0 9px;font-size:12px}
  header .hd-r .thm-knob .c1,.crumb .thm-knob .c1{left:5px;top:5px}header .hd-r .thm-knob .c2,.crumb .thm-knob .c2{left:13px;top:12px}header .hd-r .thm-knob .c3,.crumb .thm-knob .c3{left:6px;top:14px}
  .crumb{gap:6px}.crumb>a:first-child{white-space:nowrap}.crumb .cat{display:none}
}
