/* ============================================================
   BASE — 全站共用：色票、導覽列、按鈕、頁尾、通用元件
   主題：純黑 #000000 × 粉 #FF7CA2
   ============================================================ */

:root {
  --font-body: 'Inter', 'Noto Sans TC', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
  --nav-h: 64px;
  --radius: 12px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --t: .22s var(--ease);
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #000000;
  --bg-1: #08080a;
  --bg-2: #101014;
  --bg-3: #17171c;
  --line: rgba(255, 255, 255, .09);
  --line-2: rgba(255, 255, 255, .16);
  --text: #f5f3f4;
  --text-2: #aaa6a9;
  --text-3: #6d696d;
  --accent: #FF7CA2;
  --accent-hi: #ffa3bd;
  --accent-ink: #1a0610;            /* 粉色底上的文字 */
  --accent-soft: rgba(255, 124, 162, .10);
  --accent-line: rgba(255, 124, 162, .32);
  --accent-glow: rgba(255, 124, 162, .42);
  --glass: rgba(255, 255, 255, .055);
  --glass-hi: rgba(255, 255, 255, .10);
  --glass-line: rgba(255, 255, 255, .15);
  --nav-bg: rgba(0, 0, 0, .55);
  --danger: #ff8f8f;
  --danger-soft: rgba(255, 110, 110, .09);
  --danger-line: rgba(255, 110, 110, .28);
  --ok: #5eead4;
  --grid-dot: rgba(255, 255, 255, .06);
  --scroll: #2a2a30;
  /* 鍵帽質感 */
  --k-top: #26262d; --k-bot: #14141a; --k-edge: rgba(255,255,255,.08);
  --k-hi: rgba(255,255,255,.16); --k-lo: rgba(0,0,0,.55);
  --k-drop-1: rgba(0,0,0,.6); --k-drop-2: rgba(0,0,0,.85); --k-press: rgba(0,0,0,.75);
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #ffffff;
  --bg-1: #f7f6f7;
  --bg-2: #efedef;
  --bg-3: #e6e3e6;
  --line: rgba(0, 0, 0, .09);
  --line-2: rgba(0, 0, 0, .17);
  --text: #0b0b0c;
  --text-2: #55525a;
  --text-3: #8d8991;
  --accent: #e23d72;                /* #FF7CA2 加深，確保白底文字對比度 */
  --accent-hi: #c42b5e;
  --accent-ink: #ffffff;
  --accent-soft: rgba(226, 61, 114, .08);
  --accent-line: rgba(226, 61, 114, .30);
  --accent-glow: rgba(255, 124, 162, .55);
  --glass: rgba(0, 0, 0, .04);
  --glass-hi: rgba(0, 0, 0, .075);
  --glass-line: rgba(0, 0, 0, .13);
  --nav-bg: rgba(255, 255, 255, .62);
  --danger: #c0353f;
  --danger-soft: rgba(192, 53, 63, .07);
  --danger-line: rgba(192, 53, 63, .26);
  --ok: #0f9d8a;
  --grid-dot: rgba(0, 0, 0, .07);
  --scroll: #cfcbd0;
  /* 鍵帽質感 */
  --k-top: #ffffff; --k-bot: #eceaea; --k-edge: rgba(0,0,0,.07);
  --k-hi: rgba(255,255,255,1); --k-lo: rgba(60,40,40,.10);
  --k-drop-1: rgba(60,40,30,.18); --k-drop-2: rgba(60,40,30,.34); --k-press: rgba(60,40,30,.28);
}

/* ───── Reset ───── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  transition: background-color var(--t), color var(--t);
}
body.no-scroll { overflow: hidden; }
a { color: inherit; }
img { max-width: 100%; }
button { font: inherit; color: inherit; }
ul { list-style: none; }
code {
  font-family: var(--font-mono);
  font-size: .85em;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--accent-line);
  padding: .08em .45em;
  border-radius: 6px;
}
kbd {
  font-family: var(--font-mono);
  font-size: .7rem;
  color: var(--text-3);
  border: 1px solid var(--line-2);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 0 .4em;
  line-height: 1.5;
}
::selection { background: var(--accent); color: var(--accent-ink); }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--scroll); border-radius: 99px; }
::-webkit-scrollbar-track { background: transparent; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* ───── 通用小元件 ───── */
.mono-label {
  font-family: var(--font-mono);
  font-size: .7rem;
  font-weight: 500;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--text-3);
}
.mono { font-family: var(--font-mono); }

.glass {
  background: var(--glass);
  border: 1px solid var(--glass-line);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  backdrop-filter: blur(18px) saturate(160%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .08);
}

.spinner {
  width: 28px; height: 28px;
  border: 2px solid var(--line-2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-3);
  flex-shrink: 0;
}
.status-dot.online { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 22%, transparent), 0 0 10px var(--ok); }
.status-dot.offline { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft), 0 0 10px var(--danger); }

.toast {
  position: fixed; left: 50%; bottom: 28px;
  transform: translate(-50%, 16px);
  opacity: 0; pointer-events: none;
  z-index: 400;
  padding: .55rem 1.1rem;
  border-radius: 99px;
  font-size: .85rem;
  background: var(--bg-2);
  border: 1px solid var(--accent-line);
  color: var(--text);
  box-shadow: 0 8px 30px rgba(0, 0, 0, .35);
  transition: opacity .2s, transform .2s var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ───── 質感按鈕：軟擬物鍵帽 + 邊緣流光（靈感：日夜切換開關） ─────
   共用語言：上緣高光、下緣內陰影、柔和投影；懸停時一圈光沿邊緣流動；按下時凹陷。 */
@property --ang { syntax: '<angle>'; inherits: false; initial-value: 0deg; }

/* 邊緣流光：以遮罩只留一圈細邊的 conic 漸層，--ang 旋轉 */
.btn-glass::before, .btn-primary::before, .icon-btn::before {
  content: ''; position: absolute; inset: -1px; z-index: 2; border-radius: inherit; padding: 1.5px; pointer-events: none;
  background: conic-gradient(from calc(var(--ang) - 70deg), transparent 0deg, var(--accent) 45deg, #fff 70deg, var(--accent-hi) 95deg, transparent 140deg 360deg);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  opacity: 0; transition: opacity .35s var(--ease);
  filter: drop-shadow(0 0 5px var(--accent));
}
.btn-glass:hover:not(:disabled)::before, .btn-primary:hover:not(:disabled)::before, .icon-btn:hover::before,
.btn-glass:focus-visible::before, .btn-primary:focus-visible::before { opacity: 1; animation: edge-spin 2.2s linear infinite; }
@keyframes edge-spin { to { --ang: 360deg; } }

.btn {
  position: relative; isolation: isolate;
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  font-family: inherit; font-size: .92rem; font-weight: 600; letter-spacing: .01em;
  padding: .72rem 1.5rem;
  border-radius: 16px;
  border: 1px solid transparent;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: transform .28s var(--ease), background var(--t), border-color var(--t), box-shadow .28s var(--ease), color var(--t);
}
.btn:active:not(:disabled) { transform: translateY(1px) scale(.985); }
.btn-sm { font-size: .8rem; padding: .45rem 1rem; border-radius: 12px; }
.btn-lg { font-size: 1rem; padding: .9rem 2rem; border-radius: 18px; }
.btn:disabled { opacity: .55; cursor: default; }

/* 鍵帽表面（霧面玻璃 + 凸起） */
.btn-glass, .icon-btn {
  color: var(--text);
  background: linear-gradient(180deg, var(--k-top), var(--k-bot));
  border-color: var(--k-edge);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  backdrop-filter: blur(18px) saturate(160%);
  box-shadow: inset 0 1px 0 var(--k-hi), inset 0 -2px 4px var(--k-lo), 0 1px 1px var(--k-drop-1), 0 10px 20px -10px var(--k-drop-2);
}
.btn-glass:hover:not(:disabled) {
  color: var(--text);
  background: linear-gradient(180deg, color-mix(in srgb, var(--k-top) 86%, #fff), var(--k-bot));
  border-color: var(--accent-line);
  box-shadow: inset 0 1px 0 var(--k-hi), inset 0 -2px 4px var(--k-lo), 0 1px 1px var(--k-drop-1), 0 12px 26px -10px var(--k-drop-2), 0 0 26px -6px var(--accent-glow);
  transform: translateY(-1px);
}
.btn-glass:active:not(:disabled) {
  background: linear-gradient(180deg, var(--k-bot), var(--k-top));
  box-shadow: inset 0 3px 7px var(--k-press), inset 0 -1px 0 var(--k-hi), 0 0 0 transparent, 0 0 18px -6px var(--accent-glow);
}

/* 主按鈕：粉色玻璃鍵帽 */
.btn-primary {
  color: var(--accent-ink);
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent-hi) 82%, #fff) 0%, var(--accent) 58%, color-mix(in srgb, var(--accent) 80%, #8d0f3c) 100%);
  border-color: color-mix(in srgb, var(--accent-hi) 70%, #fff);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .6), inset 0 -3px 6px rgba(120, 10, 50, .32), 0 1px 1px rgba(0, 0, 0, .25), 0 12px 24px -10px var(--accent-glow);
}
.btn-primary:hover:not(:disabled) { transform: translateY(-1px); filter: brightness(1.06); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .65), inset 0 -3px 6px rgba(120, 10, 50, .32), 0 1px 1px rgba(0, 0, 0, .25), 0 14px 34px -8px var(--accent-glow); }
.btn-primary:active:not(:disabled) { box-shadow: inset 0 3px 8px rgba(120, 10, 50, .5), 0 0 16px -4px var(--accent-glow); filter: brightness(.97); }

.icon-btn {
  position: relative; isolation: isolate;
  width: 40px; height: 40px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 13px; cursor: pointer; text-decoration: none;
  color: var(--text-2); border: 1px solid var(--k-edge);
  transition: color var(--t), transform .28s var(--ease), box-shadow .28s var(--ease), background var(--t);
}
.icon-btn:hover { color: var(--accent); transform: translateY(-1px); box-shadow: inset 0 1px 0 var(--k-hi), inset 0 -2px 4px var(--k-lo), 0 12px 24px -10px var(--k-drop-2), 0 0 22px -6px var(--accent-glow); }
.icon-btn:active { transform: translateY(1px) scale(.96); box-shadow: inset 0 3px 7px var(--k-press), inset 0 -1px 0 var(--k-hi); }

/* ───── 日夜切換開關（復刻自影片：凹陷軌道 + 玻璃滑塊 + 流光弧 + 像素圖示） ───── */
.theme-switch {
  --tc: #9d94ff;               /* 夜：靛紫流光 */
  --tc-soft: rgba(140, 128, 255, .55);
  position: relative; flex-shrink: 0; width: 76px; height: 40px; padding: 0; border: 0; cursor: pointer;
  background: none; border-radius: 15px; -webkit-tap-highlight-color: transparent;
}
[data-theme="light"] .theme-switch { --tc: #ffae1a; --tc-soft: rgba(255, 170, 20, .55); }
.theme-switch:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 15px; }
.ts-track {
  position: absolute; inset: 0; border-radius: inherit; overflow: hidden;
  background: linear-gradient(180deg, #08080b, #1b1b22);
  box-shadow: inset 0 3px 7px rgba(0, 0, 0, .95), inset 0 -1px 0 rgba(255, 255, 255, .1), 0 1px 0 rgba(255, 255, 255, .1), 0 0 0 1px rgba(255, 255, 255, .08);
  transition: background .5s var(--ease), box-shadow .5s var(--ease);
}
[data-theme="light"] .ts-track {
  background: linear-gradient(180deg, #dcdad7, #ebe9e6);
  box-shadow: inset 0 3px 7px rgba(70, 55, 40, .28), inset 0 -1px 0 rgba(255, 255, 255, .9), 0 1px 0 rgba(255, 255, 255, .9), 0 0 0 1px rgba(0, 0, 0, .04);
}
.ts-thumb {
  position: absolute; top: 4px; left: 4px; width: 36px; height: 32px; border-radius: 12px;
  display: grid; place-items: center;
  background: linear-gradient(160deg, #565664 0%, #34343e 55%, #2a2a33 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .28), inset 0 -3px 6px rgba(120, 110, 255, .28), 0 6px 12px -4px rgba(0, 0, 0, .9), 0 0 16px -2px var(--tc-soft);
  transition: transform .55s cubic-bezier(.5, 1.35, .45, 1), background .5s var(--ease), box-shadow .5s var(--ease);
  will-change: transform;
}
[data-theme="light"] .ts-thumb {
  transform: translateX(32px);
  background: linear-gradient(160deg, #ffffff 0%, #f6f3ee 60%, #ece6dc 100%);
  box-shadow: inset 0 1px 0 #fff, inset 0 -3px 6px rgba(255, 170, 20, .38), 0 6px 12px -4px rgba(90, 60, 20, .4), 0 0 18px -2px var(--tc-soft);
}
.theme-switch:hover .ts-thumb { filter: brightness(1.08); }
.theme-switch:active .ts-thumb { transform: translateX(var(--tx, 0)) scale(.94); }
[data-theme="light"] .theme-switch:active .ts-thumb { --tx: 32px; }
/* 滑塊邊緣的流光弧 */
.ts-ring {
  --ang: 180deg;
  position: absolute; inset: -1px; border-radius: inherit; padding: 1.6px; pointer-events: none; opacity: .6;
  background: conic-gradient(from calc(var(--ang) - 70deg), transparent 0deg, var(--tc) 38deg, #fff 70deg, var(--tc) 102deg, transparent 140deg 360deg);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  filter: drop-shadow(0 0 4px var(--tc)) drop-shadow(0 0 9px var(--tc-soft));
}
.theme-switch.go-r .ts-ring { animation: ts-arc-r .75s var(--ease) both; }
.theme-switch.go-l .ts-ring { animation: ts-arc-l .75s var(--ease) both; }
@keyframes ts-arc-r { 0% { --ang: 330deg; opacity: 1; } 55% { --ang: 250deg; opacity: 1; } 100% { --ang: 180deg; opacity: .6; } }
@keyframes ts-arc-l { 0% { --ang: 30deg; opacity: 1; } 55% { --ang: 110deg; opacity: 1; } 100% { --ang: 180deg; opacity: .6; } }
.ts-px { width: 24px; height: 24px; display: block; image-rendering: pixelated; position: relative; }

/* ───── 邀請機器人：粉色玻璃鍵帽 + 流動光弧 + 底部光暈 + 像素閃爍 ───── */
.invite-btn {
  --ang: 0deg;
  position: relative; isolation: isolate;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: .86rem; font-weight: 700; letter-spacing: .03em;
  padding: .55rem 1.3rem;
  border-radius: 14px;
  color: var(--accent-ink);
  background:
    radial-gradient(120% 90% at 50% -10%, rgba(255, 255, 255, .55), transparent 55%),
    linear-gradient(180deg, color-mix(in srgb, var(--accent-hi) 78%, #fff) 0%, var(--accent) 56%, color-mix(in srgb, var(--accent) 78%, #8d0f3c) 100%);
  text-decoration: none; white-space: nowrap; flex-shrink: 0;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .7), inset 0 -4px 8px rgba(125, 10, 55, .34), 0 1px 2px rgba(0, 0, 0, .3), 0 10px 22px -8px var(--accent-glow);
  transition: transform .3s var(--ease), filter .3s var(--ease), box-shadow .3s var(--ease);
}
.invite-btn.lg { font-size: 1.02rem; padding: .9rem 2.3rem; border-radius: 18px; }
/* 沿邊緣流動的光弧 */
.invite-btn::before {
  content: ''; position: absolute; inset: -1px; z-index: 2; border-radius: inherit; padding: 1.6px; pointer-events: none;
  background: conic-gradient(from calc(var(--ang) - 80deg), transparent 0deg, #ffd0e0 40deg, #fff 80deg, #ffd0e0 120deg, transparent 165deg 360deg);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  animation: edge-spin 3.2s linear infinite;
  filter: drop-shadow(0 0 4px rgba(255, 255, 255, .9));
}
/* 底部光暈：像影片裡滑塊下方漫出的反光 */
.invite-btn::after {
  content: ''; position: absolute; left: 10%; right: 10%; bottom: -9px; height: 16px; z-index: -1; border-radius: 50%;
  background: var(--accent); filter: blur(11px); opacity: .6;
  animation: invite-breathe 3s ease-in-out infinite;
}
.invite-label { position: relative; z-index: 1; text-shadow: 0 1px 0 rgba(255, 255, 255, .28); }
.invite-shine { position: absolute; inset: 0; border-radius: inherit; overflow: hidden; pointer-events: none; }
.invite-shine::before {
  content: ''; position: absolute; top: 0; bottom: 0; width: 32%; left: -60%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .55), transparent);
  transform: skewX(-20deg);
  animation: invite-sweep 4s ease-in-out infinite;
}
/* 像素星點：方塊階梯式閃爍，呼應影片的像素圖示 */
.spark {
  position: absolute; z-index: 3; width: 4px; height: 4px; pointer-events: none;
  background: #fff; box-shadow: 0 0 6px 1px rgba(255, 255, 255, .9), 0 0 12px var(--accent-hi);
  opacity: 0; animation: px-twinkle 2.8s steps(6, end) infinite;
}
.spark.s1 { top: -5px; right: 16%; animation-delay: 0s; }
.spark.s2 { bottom: -4px; left: 14%; width: 3px; height: 3px; animation-delay: .9s; }
.spark.s3 { top: 18%; left: -5px; width: 3px; height: 3px; animation-delay: 1.8s; }
.invite-btn:hover { transform: translateY(-2px); filter: brightness(1.07) saturate(1.05); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .8), inset 0 -4px 8px rgba(125, 10, 55, .34), 0 1px 2px rgba(0, 0, 0, .3), 0 16px 32px -8px var(--accent-glow); }
.invite-btn:hover::before { animation-duration: 1.4s; }
.invite-btn:hover .spark { animation-duration: 1.4s; }
.invite-btn:active { transform: translateY(1px) scale(.985); box-shadow: inset 0 4px 9px rgba(125, 10, 55, .55), 0 0 18px -4px var(--accent-glow); }

@keyframes invite-breathe { 0%, 100% { opacity: .4; transform: scaleX(.9); } 50% { opacity: .75; transform: scaleX(1.05); } }
@keyframes invite-sweep { 0%, 60% { left: -60%; } 100% { left: 130%; } }
@keyframes px-twinkle { 0%, 100% { opacity: 0; transform: scale(.3); } 35% { opacity: 1; transform: scale(1); } 65% { opacity: 0; transform: scale(.5) translate(2px, -2px); } }

/* ───── 導覽列 ───── */
.navbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--nav-h);
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0 1.5rem;
  background: var(--nav-bg);
  -webkit-backdrop-filter: blur(22px) saturate(170%);
  backdrop-filter: blur(22px) saturate(170%);
  border-bottom: 1px solid var(--line);
}
.nav-brand {
  display: flex; align-items: center; gap: .65rem;
  font-weight: 700; font-size: 1rem; letter-spacing: .01em;
  text-decoration: none; color: var(--text); white-space: nowrap;
}
.nav-logo { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; border: 1px solid var(--accent-line); }
.nav-right { display: flex; align-items: center; gap: .6rem; }

.nav-links {
  display: flex; align-items: center; gap: .15rem;
  padding: 4px; border-radius: 99px;
}
.nav-link {
  position: relative;
  font-size: .84rem; font-weight: 500;
  padding: .38rem .9rem; border-radius: 99px;
  color: var(--text-2); text-decoration: none; white-space: nowrap;
  transition: color var(--t), background var(--t);
}
.nav-link:hover { color: var(--text); background: var(--glass-hi); }
.nav-link.active { color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent-line); }

.nav-burger { display: none; flex-direction: column; gap: 4px; padding: 0; }
.nav-burger span { display: block; width: 15px; height: 1.5px; background: currentColor; border-radius: 2px; transition: transform var(--t), opacity var(--t); }
.nav-burger.open span:nth-child(1) { transform: translateY(5.5px) rotate(45deg); }
.nav-burger.open span:nth-child(2) { opacity: 0; }
.nav-burger.open span:nth-child(3) { transform: translateY(-5.5px) rotate(-45deg); }

.mobile-menu {
  position: fixed; top: var(--nav-h); left: 0; right: 0; z-index: 99;
  display: none; flex-direction: column; gap: .3rem;
  padding: .8rem 1rem 1.2rem;
  background: var(--nav-bg);
  -webkit-backdrop-filter: blur(24px) saturate(170%);
  backdrop-filter: blur(24px) saturate(170%);
  border-bottom: 1px solid var(--line);
  /* 項目變多時選單要能捲動：高度不超過視窗，內容超出就在選單內滑動 */
  max-height: calc(100vh - var(--nav-h));
  max-height: calc(100dvh - var(--nav-h));
  overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  padding-bottom: max(1.2rem, env(safe-area-inset-bottom));
}
.mobile-menu.open { display: flex; animation: drop .22s var(--ease); }
.mobile-menu .nav-link { padding: .7rem 1rem; font-size: .95rem; border-radius: 10px; }
.mobile-menu .invite-btn { margin-top: .7rem; align-self: stretch; }
@keyframes drop { from { opacity: 0; transform: translateY(-8px); } }

@media (max-width: 960px) {
  .nav-links { display: none; }
  .nav-burger { display: inline-flex; }
}
@media (max-width: 560px) {
  .navbar { padding: 0 .9rem; }
  .nav-brand span { font-size: .9rem; }
  .nav-right > .invite-btn { display: none; }
}

/* ───── 導覽列下拉選單（小工具） ───── */
.nav-item { position: relative; display: flex; }
.nav-item.has-menu > .nav-link::after {
  content: ''; display: inline-block; width: 5px; height: 5px; margin-left: .45rem; vertical-align: .12em;
  border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg); transition: transform var(--t);
}
.nav-item.has-menu:hover > .nav-link::after,
.nav-item.has-menu:focus-within > .nav-link::after { transform: rotate(225deg) translate(-1px, -1px); }
.nav-menu {
  position: absolute; top: 100%; left: 50%; width: max-content; min-width: 220px; margin-top: 10px; padding: 6px;
  /* 兩欄，依序由上到下填滿：左欄前一半、右欄後一半 */
  display: grid; grid-auto-flow: column; grid-template-rows: repeat(var(--rows, 5), auto); grid-template-columns: repeat(2, minmax(210px, 1fr)); gap: 2px 6px; border-radius: 16px;
  -webkit-backdrop-filter: blur(24px) saturate(170%); backdrop-filter: blur(24px) saturate(170%);
  background: color-mix(in srgb, var(--bg) 90%, transparent); box-shadow: 0 24px 60px -24px rgba(0, 0, 0, .7), 0 0 0 1px var(--glass-line);
  opacity: 0; visibility: hidden; transform: translate(-50%, -6px);
  transition: opacity var(--t), transform var(--t), visibility 0s linear .22s;
}
/* 透明的橋，避免滑鼠從按鈕移到選單的縫隙中途關閉 */
.nav-menu::before { content: ''; position: absolute; left: 0; right: 0; top: -12px; height: 12px; }
.nav-item.has-menu:hover > .nav-menu,
.nav-item.has-menu:focus-within > .nav-menu { opacity: 1; visibility: visible; transform: translate(-50%, 0); transition-delay: 0s; }
.nav-sub { display: grid; gap: .1rem; padding: .6rem .85rem; border-radius: 11px; text-decoration: none; color: var(--text); transition: background var(--t); }
.nav-sub:hover, .nav-sub:focus-visible { background: var(--accent-soft); }
.nav-sub-name { font-size: .88rem; font-weight: 600; }
.nav-sub-desc { font-size: .75rem; color: var(--text-3); }
.nav-sub:hover .nav-sub-name { color: var(--accent); }
.nav-sub.active .nav-sub-name { color: var(--accent); }
/* 手機選單：小工具 = 連結 + 右側 v 展開鈕；子選單預設收合，按 v 才展開 */
.mobile-menu .m-row { display: flex; align-items: stretch; gap: .3rem; }
.mobile-menu .m-row .nav-link { flex: 1; min-width: 0; }
.m-toggle {
  position: relative; flex-shrink: 0; width: 46px; cursor: pointer; border-radius: 10px;
  color: var(--text-2); background: transparent; border: 0; transition: color var(--t), background var(--t);
}
.m-toggle:hover, .m-toggle[aria-expanded="true"] { color: var(--accent); background: var(--accent-soft); }
.m-toggle span {
  position: absolute; top: 50%; left: 50%; width: 8px; height: 8px; margin: -6px 0 0 -4px;
  border-right: 1.8px solid currentColor; border-bottom: 1.8px solid currentColor;
  transform: rotate(45deg); transition: transform var(--t);
}
.m-toggle[aria-expanded="true"] span { transform: rotate(225deg) translate(-2px, -2px); }
.mobile-menu .nav-sub-list { display: grid; grid-auto-flow: column; grid-template-rows: repeat(var(--rows, 5), auto); grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px 4px; margin: 0 0 .3rem .6rem; padding-left: .5rem; border-left: 1px solid var(--accent-line); }
.mobile-menu .nav-sub-list[hidden] { display: none; }
.mobile-menu .nav-sub-list:not([hidden]) { animation: drop .2s var(--ease); }
.mobile-menu .nav-sub { padding: .55rem .6rem; min-width: 0; }
.mobile-menu .nav-sub-name { font-size: .84rem; overflow-wrap: anywhere; }
.mobile-menu .nav-sub-desc { display: none; }

/* ───── 頁面容器 ───── */
#view { min-height: 100vh; padding-top: var(--nav-h); }
.page { animation: page-in .45s var(--ease); }
@keyframes page-in { from { opacity: 0; transform: translateY(8px); } }

.page-error { display: grid; place-items: center; min-height: 60vh; padding: 2rem 1.5rem; }
.error-card { text-align: center; max-width: 420px; display: grid; gap: .8rem; justify-items: center; }
.error-card p:not(.mono-label) { color: var(--text-2); font-size: .9rem; word-break: break-word; }

/* ───── 頁尾 ───── */
.site-footer { border-top: 1px solid var(--line); background: var(--bg-1); padding: 2rem 1.5rem; }
.footer-inner {
  max-width: 1040px; margin: 0 auto;
  display: grid; grid-template-columns: 1fr auto 1fr; gap: 1.5rem; align-items: start;
}
.footer-left { display: grid; gap: 1rem; justify-items: start; }
.footer-born { display: grid; gap: .15rem; }
.born-counter { font-family: var(--font-mono); font-size: .86rem; font-weight: 500; color: var(--accent); font-variant-numeric: tabular-nums; }
.footer-copy { font-size: .78rem; color: var(--text-3); white-space: nowrap; }
.footer-center { display: grid; gap: .2rem; justify-items: center; text-align: center; }
.footer-rights { font-size: .74rem; color: var(--text-3); letter-spacing: .02em; }
.footer-visits { margin-top: .5rem; display: flex; gap: .5rem; align-items: baseline; justify-content: center; }
.visit-counter { font-family: var(--font-mono); font-size: .8rem; color: var(--accent); font-variant-numeric: tabular-nums; }
.footer-right { display: grid; gap: .3rem; justify-items: end; }
.footer-right a { font-size: .8rem; color: var(--text-3); text-decoration: none; transition: color var(--t); }
.footer-right a:hover { color: var(--accent); }
/* 手機：第一列「加入支援群」靠左、「法律條款」靠右；其下置中「版權宣告 + 累計造訪」，最後是「機器人已誕生」 */
@media (max-width: 720px) {
  .footer-inner {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "support legal" "center center" "born born";
    gap: 1.4rem 1rem; align-items: start;
  }
  .footer-left { display: contents; }
  .footer-left > .btn { grid-area: support; justify-self: start; }
  .footer-right { grid-area: legal; justify-items: end; text-align: right; }
  .footer-center { grid-area: center; padding-top: 1.2rem; border-top: 1px solid var(--line); }
  .footer-born { grid-area: born; justify-items: center; text-align: center; }
}
@media (max-width: 380px) {
  .footer-left > .btn { white-space: normal; text-align: left; line-height: 1.4; }
}

/* ───── 區塊標題（多頁共用） ───── */
.section-head { text-align: center; display: grid; gap: .5rem; margin-bottom: 3rem; justify-items: center; }
.section-head h2 { font-size: clamp(1.6rem, 3.4vw, 2.2rem); font-weight: 700; letter-spacing: -.01em; line-height: 1.25; }
.section-head p:last-child { color: var(--text-3); font-size: .95rem; }
