/* 維校園地：介面樣式
 * 主色取自校徽：深青綠 #006965、金黃 #F6AB00
 */
:root {
  --teal: #006965;
  --teal-dark: #00514E;
  --teal-soft: #E3F0EF;
  --teal-ink: #00514E;
  --gold: #F6AB00;
  --gold-soft: #FFF8E6;
  --gold-line: #F6D27A;
  --gold-ink: #5A3D00;
  --bg: #F4F6F5;
  --card: #FFFFFF;
  --ink: #1A2B2A;
  --ink-2: #2E403D;
  --muted: #4A5D5A;
  --faint: #5F716E;
  --line: #C5D1CE;
  --line-soft: #E0E6E4;
  --red: #C62828;
  --red-soft: #FCE4E4;
  --red-ink: #8A1C1C;
  --radius: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: 'Noto Sans TC', system-ui, -apple-system, 'PingFang TC', 'Microsoft JhengHei', sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--teal); }
[v-cloak] { display: none; }

.boot { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; color: var(--muted); }
.boot img { border-radius: 18px; }

/* 版面：手機寬度置中，桌機也能看 */
.app { max-width: 520px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; background: var(--bg); position: relative; }
.app.wide { max-width: 760px; }

/* 頂部 */
.topbar { background: var(--teal); color: #fff; padding: calc(12px + var(--safe-top)) 8px 12px; display: flex; align-items: center; gap: 4px; position: sticky; top: 0; z-index: 5; }
.topbar.teacher { background: var(--teal-dark); }
.topbar h1 { margin: 0; flex: 1; font-size: 19px; font-weight: 700; }
.topbar .sub { padding-right: 12px; color: #CDE7E5; font-size: 13px; }
.icon-btn { width: 44px; height: 44px; border: 0; background: transparent; color: inherit; display: inline-flex; align-items: center; justify-content: center; border-radius: 12px; }
.icon-btn:focus-visible, .btn:focus-visible, .tile:focus-visible, .pill:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

.hero { background: var(--teal); padding: calc(20px + var(--safe-top)) 20px 24px; border-radius: 0 0 28px 28px; display: flex; flex-direction: column; gap: 16px; }
.hero.teacher { background: var(--teal-dark); }
.brand { display: flex; align-items: center; justify-content: space-between; color: #fff; }
.brand .logo { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 700; letter-spacing: 1px; }
.brand .logo span.mark { width: 36px; height: 36px; border-radius: 10px; background: #fff; display: inline-flex; align-items: center; justify-content: center; }
.brand .logo img { width: 24px; height: 30px; object-fit: contain; }

/* 內容 */
.page { flex: 1; padding: 16px 20px calc(96px + var(--safe-bottom)); display: flex; flex-direction: column; gap: 16px; }
.page.no-nav { padding-bottom: calc(32px + var(--safe-bottom)); }
.section-title { margin: 4px 0 0; font-size: 16px; font-weight: 700; }
.card { background: var(--card); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.card h2 { margin: 0; font-size: 14px; font-weight: 700; color: var(--teal); }
.card p { margin: 0; font-size: 15px; line-height: 1.7; white-space: pre-line; }
.card.gold { background: var(--gold-soft); }
.card.gold h2 { color: #7A5200; }
.meta { font-size: 12px; color: var(--faint); }
.muted { color: var(--muted); font-size: 14px; line-height: 1.6; margin: 0; }
.empty { text-align: center; color: var(--faint); padding: 40px 12px; font-size: 15px; }

/* 小孩卡 */
.child-card { background: #fff; border-radius: 18px; padding: 14px 16px; display: flex; align-items: center; gap: 12px; }
.avatar { width: 48px; height: 48px; border-radius: 50%; background: #FDF0CC; color: #6B4A00; display: flex; align-items: center; justify-content: center; font-size: 20px; font-weight: 700; flex: none; }
.avatar.sm { width: 38px; height: 38px; font-size: 15px; }
.child-card .who { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.child-card .who b { font-size: 17px; }
.child-card .who span { font-size: 13px; color: var(--muted); }

/* 圖示格 */
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.tile { position: relative; background: #fff; border: 0; border-radius: 16px; padding: 16px 6px; display: flex; flex-direction: column; align-items: center; gap: 8px; text-decoration: none; color: var(--ink); font-size: 14px; font-weight: 500; min-height: 96px; }
.tile.off { background: #EEF1F0; color: var(--faint); cursor: default; }
.tile small { font-size: 11px; font-weight: 400; }
.badge { position: absolute; top: 8px; right: 10px; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: var(--red); color: #fff; font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center; }

/* 按鈕 */
.btn { height: 52px; border: 0; border-radius: 14px; background: var(--teal); color: #fff; font-size: 16px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0 20px; text-decoration: none; }
.btn.block { width: 100%; }
.btn.gold { background: var(--gold); color: #2B1E00; }
.btn.ghost { background: #fff; color: var(--teal); border: 1px solid var(--teal); }
.btn.soft { background: var(--teal-soft); color: var(--teal-ink); }
.btn.sm { height: 38px; font-size: 14px; border-radius: 19px; padding: 0 14px; }
.btn:disabled { opacity: .55; cursor: default; }
.link-btn { border: 0; background: transparent; color: var(--teal); font-size: 15px; height: 44px; }

.pills { display: flex; gap: 8px; flex-wrap: wrap; }
.pill { height: 36px; padding: 0 16px; border: 1px solid var(--line); border-radius: 18px; background: #fff; color: var(--ink-2); font-size: 14px; }
.pill.on { background: var(--teal); border-color: var(--teal); color: #fff; font-weight: 700; }

.seg { display: grid; grid-template-columns: repeat(var(--n, 2), minmax(0, 1fr)); background: #E3EAE8; border-radius: 12px; padding: 4px; }
.seg button { height: 44px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); font-size: 15px; }
.seg button.on { background: #fff; color: var(--teal); font-weight: 700; }

/* 表單 */
.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 500; }
.field input, .field textarea, .field select { min-height: 48px; border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; font-size: 16px; background: #fff; font-weight: 400; width: 100%; }
.field textarea { resize: vertical; line-height: 1.6; }
.field input:focus, .field textarea:focus, .field select:focus { outline: 2px solid var(--teal); outline-offset: 0; border-color: var(--teal); }
.row2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.choice3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.choice { height: 46px; border: 1px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink-2); font-size: 15px; }
.choice.on { border: 2px solid var(--teal); background: var(--teal-soft); color: var(--teal-ink); font-weight: 700; }
.error { background: var(--red-soft); color: var(--red-ink); border-radius: 12px; padding: 12px 14px; font-size: 14px; line-height: 1.5; }
.success { background: var(--teal-soft); color: var(--teal-ink); border-radius: 12px; padding: 12px 14px; font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; }

/* 列表項 */
.item { background: #fff; border-radius: 16px; overflow: hidden; }
.item > button { width: 100%; border: 0; background: transparent; padding: 16px; display: flex; gap: 12px; align-items: flex-start; text-align: left; }
.dot { width: 10px; height: 10px; border-radius: 5px; margin-top: 24px; flex: none; background: transparent; }
.dot.on { background: var(--red); }
.item .txt { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.item .title { font-size: 16px; line-height: 1.4; font-weight: 500; }
.item .title.unread { font-weight: 700; }
.item .toggle { font-size: 13px; color: var(--teal); padding-top: 18px; flex: none; }
.item .body { padding: 0 16px 16px 38px; font-size: 15px; line-height: 1.7; color: var(--ink-2); white-space: pre-line; }
.tag { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 10px; background: var(--teal-soft); color: var(--teal-ink); font-weight: 500; }

.row { background: #fff; border-radius: 14px; padding: 12px 14px; display: flex; align-items: center; gap: 12px; }
.row .txt { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.row .txt b { font-size: 15px; font-weight: 500; }
.chip { font-size: 13px; font-weight: 700; padding: 4px 10px; border-radius: 12px; flex: none; }
.chip.ok { color: var(--teal-ink); background: var(--teal-soft); }
.chip.no { color: var(--red-ink); background: var(--red-soft); }
.chip.leave { color: #5A3D00; background: #FDF0CC; }

.datebar { background: #fff; display: flex; align-items: center; justify-content: space-between; padding: 6px 8px; border-bottom: 1px solid var(--line-soft); }
.datebar b { font-size: 16px; }
.datebar .icon-btn { color: var(--teal); }
.datebar .icon-btn:disabled { color: #B5C1BE; cursor: default; }

.event { display: flex; gap: 12px; align-items: center; }
.cal { width: 48px; height: 52px; border-radius: 12px; background: var(--teal-soft); color: var(--teal); display: flex; flex-direction: column; align-items: center; justify-content: center; flex: none; }
.cal.holiday { background: #FDF0CC; color: #6B4A00; }
.cal span { font-size: 11px; }
.cal b { font-size: 18px; }

.progress { height: 10px; border-radius: 5px; background: #E3EAE8; overflow: hidden; }
.progress > div { height: 100%; background: var(--teal); border-radius: 5px; transition: width .3s; }

.notice-bar { background: var(--gold-soft); border: 1px solid var(--gold-line); border-radius: 16px; padding: 14px 16px; display: flex; align-items: center; gap: 12px; color: var(--gold-ink); font-size: 14px; line-height: 1.5; }
.notice-bar > div { flex: 1; }

.code-box { font-size: 30px; font-weight: 700; letter-spacing: 4px; text-align: center; padding: 18px; border-radius: 14px; background: var(--gold-soft); border: 2px dashed var(--gold); color: #2B1E00; user-select: all; }

/* 底部導覽 */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; background: #fff; border-top: 1px solid var(--line-soft); padding-bottom: var(--safe-bottom); }
.tabbar nav { max-width: 520px; margin: 0 auto; height: 64px; display: grid; grid-template-columns: repeat(var(--n, 3), minmax(0, 1fr)); }
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: var(--faint); text-decoration: none; font-size: 12px; position: relative; }
.tabbar a.on { color: var(--teal); font-weight: 700; }

.toast { position: fixed; left: 50%; bottom: calc(84px + var(--safe-bottom)); transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 14px; z-index: 20; max-width: 90vw; box-shadow: 0 6px 20px rgba(0,0,0,.18); }

/* 登入頁 */
.login-hero { background: var(--teal); padding: calc(64px + var(--safe-top)) 32px 36px; display: flex; flex-direction: column; align-items: center; gap: 10px; border-radius: 0 0 32px 32px; }
.login-hero .crest { width: 88px; height: 88px; border-radius: 24px; background: #fff; display: flex; align-items: center; justify-content: center; }
.login-hero .crest img { width: 58px; height: 72px; object-fit: contain; }
.login-hero h1 { margin: 0; color: #fff; font-size: 28px; letter-spacing: 2px; }
.login-hero p { margin: 0; color: #CDE7E5; font-size: 14px; }

.steps { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 8px; font-size: 15px; line-height: 1.6; }

@media (min-width: 560px) {
  .app { box-shadow: 0 0 0 1px var(--line-soft); }
}

/* 深色頂部裡的輸入框，文字維持深色 */
.hero .field input, .hero .field select { color: var(--ink); background: #fff; }

/* 老師端五個分頁，字小一點 */
.seg5 button { font-size: 14px; padding: 0 2px; }
button.card { font: inherit; color: inherit; cursor: pointer; width: 100%; }

/* 對話泡泡：自己的回覆靠右，對方的靠左 */
.chat { display: flex; flex-direction: column; gap: 10px; }
.bubble-row { display: flex; flex-direction: column; gap: 4px; max-width: 100%; }
.bubble-row.me { align-items: flex-end; }
.bubble-row.them { align-items: flex-start; }
.bubble { max-width: 82%; padding: 10px 14px; font-size: 15px; line-height: 1.6; white-space: pre-line; word-break: break-word; border-radius: 18px; }
.bubble-row.me .bubble { background: var(--teal); color: #fff; border-bottom-right-radius: 6px; }
.bubble-row.them .bubble { background: #EEF1F0; color: var(--ink); border-bottom-left-radius: 6px; }
.bubble-meta { font-size: 12px; color: var(--faint); padding: 0 6px; }

/* ===============================================================
 * v7 美化：校徽浮水印、金色校徽線、輕量動畫
 * 動畫只用 transform / opacity，手機不吃效能；系統設定「減少動態效果」時全部關閉
 * =============================================================== */

/* iPhone 的日期欄位有最小寬度，會撐出格子：讓格子可以縮、欄位不超出 */
.row2 > *, .choice3 > *, .tiles > * { min-width: 0; }
.field input[type="date"] {
  -webkit-appearance: none; appearance: none;
  display: block; min-width: 0; max-width: 100%; text-align: left; line-height: 26px;
}
.field input[type="date"]::-webkit-date-and-time-value { text-align: left; }

/* 深綠頂部：右側淡淡的校徽浮水印＋底部金色線（呼應校徽的金色 V） */
.hero, .login-hero { position: relative; overflow: hidden; isolation: isolate; }
.hero::before, .login-hero::before {
  content: ''; position: absolute; z-index: -1; pointer-events: none;
  right: -28px; top: 50%; width: 168px; height: 220px; transform: translateY(-50%) rotate(-8deg);
  background: url("img/crest-mark.webp") center / contain no-repeat; opacity: .10;
}
.login-hero::before { right: auto; left: 50%; width: 300px; height: 394px; transform: translate(-50%, -46%); opacity: .08; }
.hero::after, .login-hero::after {
  content: ''; position: absolute; left: 24px; right: 24px; bottom: 0; height: 4px;
  border-radius: 4px 4px 0 0; background: linear-gradient(90deg, transparent, var(--gold) 20%, var(--gold) 80%, transparent);
  opacity: .9;
}
.topbar { box-shadow: inset 0 -3px 0 rgba(246, 171, 0, .85); }

/* 卡片：細一點的陰影，層次比較清楚 */
.card, .tile, .item, .row, .child-card { box-shadow: 0 1px 2px rgba(0, 60, 58, .06), 0 2px 8px rgba(0, 60, 58, .04); }
.tile .badge { box-shadow: 0 0 0 2px #fff; }

/* 進入頁面：內容由下往上淡入，依序出現（最多錯開 6 個） */
@keyframes va-rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.page > * { animation: va-rise .32s cubic-bezier(.2, .7, .3, 1) both; }
.page > *:nth-child(2) { animation-delay: .04s; }
.page > *:nth-child(3) { animation-delay: .08s; }
.page > *:nth-child(4) { animation-delay: .12s; }
.page > *:nth-child(5) { animation-delay: .16s; }
.page > *:nth-child(n+6) { animation-delay: .2s; }
.child-card { animation: va-rise .36s cubic-bezier(.2, .7, .3, 1) both; }

/* 按下去的回饋 */
.tile, .btn, .pill, .choice, .icon-btn, button.card { transition: transform .12s ease, background-color .15s ease, box-shadow .15s ease; }
.tile:active, button.card:active { transform: scale(.96); }
.btn:active:not(:disabled), .pill:active, .choice:active { transform: scale(.97); }
@media (hover: hover) {
  .tile:hover { box-shadow: 0 4px 14px rgba(0, 60, 58, .10); }
}

/* 未讀數字、完成打勾：小小的彈出 */
@keyframes va-pop { 0% { transform: scale(.4); opacity: 0; } 70% { transform: scale(1.12); opacity: 1; } 100% { transform: scale(1); } }
.badge { animation: va-pop .35s .25s cubic-bezier(.2, .7, .3, 1.4) both; }
.success svg, .btn.soft svg { animation: va-pop .3s cubic-bezier(.2, .7, .3, 1.4) both; }

/* 提示訊息由下滑入 */
@keyframes va-toast { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }
.toast { animation: va-toast .22s ease-out both; }

/* 對話泡泡出現 */
@keyframes va-bubble { from { opacity: 0; transform: translateY(6px) scale(.98); } to { opacity: 1; transform: none; } }
.bubble { animation: va-bubble .25s ease-out both; }

/* 進度條長出來 */
@keyframes va-grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.progress > div { transform-origin: left center; animation: va-grow .6s .15s cubic-bezier(.2, .7, .3, 1) both; }

/* 登入頁校徽輕輕浮現 */
@keyframes va-crest { from { opacity: 0; transform: translateY(8px) scale(.94); } to { opacity: 1; transform: none; } }
.login-hero .crest { animation: va-crest .5s cubic-bezier(.2, .7, .3, 1) both; box-shadow: 0 6px 18px rgba(0, 0, 0, .18); }
.login-hero h1, .login-hero p { animation: va-rise .45s .1s cubic-bezier(.2, .7, .3, 1) both; }

/* 使用者在系統裡關閉動態效果時，全部不做 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ===============================================================
 * v8 校園照片背景＋校園小動物
 * 照片只在用到的頁面才下載（每張約 50 KB）；動物只動 transform
 * =============================================================== */

/* 照片當背景，上面疊深綠色，白字才看得清楚；照片時浮水印就不用了 */
.login-hero, .hero, .hero.teacher { background-size: cover; background-position: center; }
.login-hero::before, .hero::before { display: none; }
.login-hero {
  background-image: linear-gradient(180deg, rgba(0, 72, 69, .55) 0%, rgba(0, 105, 101, .78) 70%, rgba(0, 105, 101, .92) 100%),
                    url("img/campus-watercolor.webp");
  background-position: center, center 60%;
}
.hero {
  background-image: linear-gradient(180deg, rgba(0, 92, 88, .80) 0%, rgba(0, 105, 101, .90) 60%, rgba(0, 105, 101, .96) 100%),
                    url("img/campus-golden-tree.webp");
}
.hero.teacher {
  background-image: linear-gradient(180deg, rgba(0, 66, 63, .82) 0%, rgba(0, 81, 78, .92) 60%, rgba(0, 81, 78, .97) 100%),
                    url("img/campus-panorama.webp");
}
.login-hero h1, .brand .logo { text-shadow: 0 1px 8px rgba(0, 0, 0, .25); }
.hero { padding-bottom: 40px; }          /* 留一條小路給山羊走 */

/* 照片橫幅 */
.photo-banner {
  position: relative; overflow: hidden; margin: 0; height: 132px; border-radius: var(--radius);
  background-size: cover; background-position: center; display: flex; align-items: flex-end;
  box-shadow: 0 1px 2px rgba(0, 60, 58, .06), 0 2px 8px rgba(0, 60, 58, .04);
}
.photo-banner::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 45%, rgba(0, 0, 0, .45)); }
.photo-banner figcaption { position: relative; z-index: 1; color: #fff; font-size: 13px; font-weight: 500; padding: 10px 14px; text-shadow: 0 1px 4px rgba(0, 0, 0, .4); }

/* 共用：動物不擋點擊 */
.critter-track, .ducks, .butterfly-path { position: absolute; pointer-events: none; z-index: 2; }
.goat, .goat-bob, .duck, .duck-bob, .butterfly, .critter-track, .butterfly-path { will-change: transform; }

/* 山羊：沿著頂部底下的金線慢慢走過去，中途停下來吃草 */
.critter-track.goat-track { left: 0; bottom: 3px; width: 100%; height: 37px; animation: va-goat-walk 34s linear infinite; }
.goat-track .goat-bob { position: absolute; left: -60px; bottom: 0; animation: va-goat-bob .45s ease-in-out infinite alternate; }
.goat .leg-a { transform-origin: 50% 30px; transform-box: view-box; animation: va-leg .45s ease-in-out infinite alternate; }
.goat .leg-b { transform-origin: 50% 30px; transform-box: view-box; animation: va-leg .45s ease-in-out infinite alternate-reverse; }
.goat .head { transform-origin: 46px 20px; transform-box: view-box; animation: va-goat-graze 34s ease-in-out infinite; }
@keyframes va-goat-walk {
  0%   { transform: translateX(0); }
  42%  { transform: translateX(46%); }
  58%  { transform: translateX(46%); }        /* 停下來吃草 */
  100% { transform: translateX(calc(100% + 120px)); }
}
@keyframes va-goat-bob { from { transform: translateY(0); } to { transform: translateY(-1.5px); } }
@keyframes va-leg { from { transform: rotate(-9deg); } to { transform: rotate(9deg); } }
@keyframes va-goat-graze {
  0%, 43% { transform: rotate(0); }
  46%, 54% { transform: rotate(28deg); }      /* 低頭吃草 */
  50% { transform: rotate(22deg); }
  57%, 100% { transform: rotate(0); }
}

/* 鴨子：在登入頁和生態池照片底部浮著，輕輕上下晃、慢慢來回游 */
.ducks { left: 18px; bottom: 8px; width: 120px; height: 30px; }
.photo-banner .ducks { left: auto; right: 22px; bottom: 30px; }
.duck { position: absolute; bottom: 0; animation: va-duck-swim 16s ease-in-out infinite; }
.duck.d1 { left: 0; }
.duck.d2 { left: 44px; animation-delay: -5s; transform: scale(.85); }
.duck-bob { animation: va-duck-bob 2.6s ease-in-out infinite; transform-origin: 50% 80%; }
.duck.d2 .duck-bob { animation-delay: -1.1s; }
.duck .ripple { position: absolute; left: 2px; right: 6px; bottom: 1px; height: 4px; border-radius: 50%; border-bottom: 1.5px solid rgba(255, 255, 255, .55); animation: va-ripple 2.6s ease-in-out infinite; }
@keyframes va-duck-bob { 0%, 100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(1.5px) rotate(-3deg); } }
@keyframes va-duck-swim { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(34px); } }
@keyframes va-ripple { 0%, 100% { transform: scaleX(1); opacity: .7; } 50% { transform: scaleX(1.2); opacity: .35; } }

/* 蝴蝶：在右上角繞小圈飛，翅膀拍動 */
.butterfly-path { right: 28px; top: 18px; width: 22px; height: 18px; animation: va-flutter-path 13s ease-in-out infinite; }
.photo-banner .butterfly-path { top: 22px; right: 60px; }
.butterfly .wing-l, .butterfly .wing-r { transform-box: view-box; transform-origin: 12px 10px; animation: va-flap .22s ease-in-out infinite alternate; }
.butterfly .wing-r { animation-name: va-flap-r; }
@keyframes va-flap { from { transform: scaleX(1); } to { transform: scaleX(.35); } }
@keyframes va-flap-r { from { transform: scaleX(1); } to { transform: scaleX(.35); } }
@keyframes va-flutter-path {
  0%   { transform: translate(0, 0) rotate(-6deg); }
  25%  { transform: translate(-46px, 14px) rotate(8deg); }
  50%  { transform: translate(-90px, -4px) rotate(-4deg); }
  75%  { transform: translate(-40px, -10px) rotate(6deg); }
  100% { transform: translate(0, 0) rotate(-6deg); }
}

/* 減少動態效果：動物停在原地不動，照片照常顯示 */
@media (prefers-reduced-motion: reduce) {
  .critter-track.goat-track { transform: translateX(30%); }
}

/* v9：行事曆頂部的小動物步道（沒有照片）、底部選單的小雞 */
.critter-lane {
  position: relative; overflow: hidden; height: 46px; margin: -4px 0 -8px;
  border-bottom: 2px dashed rgba(0, 105, 101, .18);
}
.critter-lane .goat-track { bottom: 0; }
.critter-lane .butterfly-path { top: 4px; right: 40px; }

/* 目前這一頁的選單圖示上，坐著一隻會點頭的小雞 */
.tabbar a { overflow: visible; }
.tab-chick { position: absolute; top: 2px; left: calc(50% + 6px); pointer-events: none;
  animation: va-pop .35s cubic-bezier(.2, .7, .3, 1.4) both, va-chick 2.2s 0.4s ease-in-out infinite; transform-origin: 50% 100%; will-change: transform; }
@keyframes va-chick { 0%, 60%, 100% { transform: rotate(0); } 70% { transform: rotate(-12deg) translateY(-1px); } 80% { transform: rotate(6deg); } }
/* 按下選單時圖示跳一下 */
.tab-icon { display: inline-flex; transition: transform .15s ease; }
.tabbar a:active .tab-icon { transform: translateY(-3px) scale(1.08); }
.tabbar a.on .tab-icon { animation: va-hop .4s cubic-bezier(.2, .7, .3, 1.4) both; }
@keyframes va-hop { 0% { transform: translateY(0); } 40% { transform: translateY(-5px); } 100% { transform: translateY(0); } }

/* v10：自動更新提示與有變化的列 */
.sync-note { display: flex; align-items: center; gap: 6px; margin: -4px 0 0; font-size: 12px; }
.sync-dot { width: 7px; height: 7px; border-radius: 50%; background: #2e9e6a; animation: va-breathe 2.4s ease-in-out infinite; }
@keyframes va-breathe { 0%, 100% { opacity: .35; transform: scale(.85); } 50% { opacity: 1; transform: scale(1); } }
@keyframes va-flash { 0% { background-color: #FFF1C2; } 100% { background-color: #fff; } }
.row.flash, .card.flash { animation: va-flash 2.4s ease-out both; }

/* ---------- v11：照片、放大檢視、失物招領 ---------- */
.tiles.four { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.tiles.four .tile { font-size: 13px; padding-left: 4px; padding-right: 4px; }
.photo-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.photo-grid.n1 { grid-template-columns: minmax(0, 1fr); }
.photo-grid.n1 .photo-cell { aspect-ratio: 4 / 3; }
.photo-grid.n2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.photo-cell { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: #eef3f2;
  border: 0; padding: 0; margin: 0; display: block; cursor: zoom-in; }
.photo-cell img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-grid.edit .photo-cell { cursor: default; }
.photo-x { position: absolute; top: 4px; right: 4px; width: 28px; height: 28px; border-radius: 50%; border: 0;
  background: rgba(0,0,0,.6); color: #fff; font-size: 14px; line-height: 28px; padding: 0; cursor: pointer; }
.photo-cell.busy img { opacity: .45; }
.photo-status { position: absolute; inset: auto 0 0 0; background: rgba(0,0,0,.55); color: #fff; font-size: 12px; text-align: center; padding: 3px 0; }
.photo-add { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  border: 2px dashed var(--teal); background: #f3faf9; color: var(--teal); font-size: 13px; font-weight: 500; cursor: pointer; }
.photo-picker { display: flex; flex-direction: column; gap: 8px; }
.photo-count { font-size: 12px; color: var(--ink-2); font-weight: 400; white-space: nowrap; }
.lightbox { position: fixed; inset: 0; z-index: 100; background: rgba(10,14,14,.94); display: flex; align-items: center; justify-content: center;
  animation: va-fade .15s ease-out; touch-action: pan-y; }
.lightbox > img { max-width: 100%; max-height: calc(100% - 120px); object-fit: contain; }
.lb-bar { position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top, 0px) + 8px) 12px 8px; color: #fff; font-size: 15px; }
.lb-bar .icon-btn { color: #fff; font-size: 20px; text-decoration: none; }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 64px; border: 0; border-radius: 10px;
  background: rgba(255,255,255,.12); color: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.lb-nav.prev { left: 8px; } .lb-nav.next { right: 8px; }
.card.dim { opacity: .62; }
@keyframes va-fade { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .lightbox { animation: none; } }
.seg5 { gap: 2px; } .seg5 button { font-size: 13px; letter-spacing: -.2px; }

/* ---------- v13：校園動物 公雞、猴子、鸚鵡（只用 transform／opacity，不吃效能） ---------- */
.rooster, .monkey, .parrot { position: absolute; pointer-events: none; z-index: 2; }
.rooster-body, .monkey-swing, .parrot-body, .rooster .head, .rooster .beak-low, .monkey .eyes, .parrot .head, .parrot .wing { will-change: transform; }

/* 公雞：登入頁右下角，偶爾抬頭啼叫 */
.rooster { right: 22px; bottom: 8px; width: 44px; height: 44px; }
.rooster-body { animation: va-rooster-bob 1.8s ease-in-out infinite; transform-origin: 50% 100%; }
.rooster .head { transform-box: view-box; transform-origin: 35px 16px; animation: va-crow 9s ease-in-out infinite; }
.rooster .beak-low { transform-box: view-box; transform-origin: 41px 12.5px; animation: va-beak 9s ease-in-out infinite; }
.rooster .tail { transform-box: view-box; transform-origin: 16px 28px; animation: va-tail 3.6s ease-in-out infinite; }
.crow-bubble { position: absolute; right: 30px; top: -18px; white-space: nowrap; background: #fff; color: var(--teal-ink); font-size: 11px; font-weight: 700;
  padding: 2px 7px; border-radius: 10px 10px 2px 10px; box-shadow: 0 2px 6px rgba(0,0,0,.15); opacity: 0; transform: scale(.6); transform-origin: 100% 100%;
  animation: va-bubble 9s ease-in-out infinite; }
@keyframes va-rooster-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-1px); } }
@keyframes va-crow { 0%, 58% { transform: rotate(0); } 62%, 74% { transform: rotate(-22deg); } 78%, 100% { transform: rotate(0); } }
@keyframes va-beak { 0%, 62% { transform: rotate(0); } 64%, 72% { transform: rotate(28deg); } 74%, 100% { transform: rotate(0); } }
@keyframes va-tail { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(-5deg); } }
@keyframes va-bubble { 0%, 62% { opacity: 0; transform: scale(.6); } 65%, 74% { opacity: 1; transform: scale(1); } 78%, 100% { opacity: 0; transform: scale(.6); } }
/* 行事曆的小路上：公雞低頭啄米，不啼叫 */
.critter-lane .rooster { right: auto; left: 18%; bottom: -2px; transform: scale(.82); transform-origin: 50% 100%; }
.critter-lane .rooster .head { animation: va-peck 5s ease-in-out infinite; }
.critter-lane .rooster .beak-low, .critter-lane .crow-bubble { animation: none; }
@keyframes va-peck { 0%, 60% { transform: rotate(0); } 64% { transform: rotate(42deg) translateY(2px); } 68% { transform: rotate(5deg); }
  72% { transform: rotate(42deg) translateY(2px); } 78%, 100% { transform: rotate(0); } }

/* 猴子：掛在樹枝上盪來盪去、眨眼 */
.monkey { right: 20px; top: var(--safe-top, 0px); width: 70px; height: 56px; }
.monkey .branch { position: absolute; top: 2px; right: -24px; width: 92px; height: 5px; border-radius: 3px; background: #6d4322;
  box-shadow: inset 0 -1px 0 rgba(0,0,0,.2); }
.monkey .branch::after { content: ''; position: absolute; left: 6px; top: -6px; width: 12px; height: 7px; border-radius: 0 10px 0 10px; background: #5aa65e; transform: rotate(-20deg); }
.monkey-swing { position: absolute; top: 0; left: 20px; transform-origin: 47% 8%; animation: va-swing 2.8s ease-in-out infinite alternate; }
.monkey .eyes { transform-box: view-box; transform-origin: 20px 21.5px; animation: va-blink 4.5s infinite; }
.monkey .tail { transform-box: view-box; transform-origin: 16px 42px; animation: va-tail 2.8s ease-in-out infinite alternate; }
@keyframes va-swing { from { transform: rotate(-13deg); } to { transform: rotate(13deg); } }
@keyframes va-blink { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(.1); } }
.hero .butterfly-path { right: 96px; }
.photo-banner .monkey { right: auto; left: 10px; top: 0; }
.photo-banner .monkey .branch { right: auto; left: -16px; }

/* 鸚鵡：站在標題列的金色線上，歪頭、偶爾整理羽毛 */
.parrot { right: 14px; bottom: -6px; width: 26px; height: 36px; }
.parrot-body { animation: va-rooster-bob 2.4s ease-in-out infinite; transform-origin: 50% 100%; }
.parrot .head { transform-box: view-box; transform-origin: 16px 14px; animation: va-tilt 6s ease-in-out infinite; }
.parrot .wing { transform-box: view-box; transform-origin: 11px 18px; animation: va-ruffle 6s ease-in-out infinite; }
@keyframes va-tilt { 0%, 30% { transform: rotate(0); } 36%, 46% { transform: rotate(-16deg); } 52%, 60% { transform: rotate(12deg); } 66%, 100% { transform: rotate(0); } }
@keyframes va-ruffle { 0%, 78% { transform: rotate(0); } 82% { transform: rotate(-24deg); } 86% { transform: rotate(-4deg); } 90% { transform: rotate(-20deg); } 94%, 100% { transform: rotate(0); } }
.topbar.has-pet .sub { padding-right: 44px; }
.hero.teacher .parrot { bottom: auto; top: calc(var(--safe-top, 0px) + 18px); right: 20px; transform: scale(1.15); transform-origin: 100% 0; }
.login-hero { padding-bottom: 58px; }          /* 留空間給鴨子和公雞 */
.login-hero .rooster { right: 18px; bottom: 6px; }
.crow-bubble { top: 2px; right: 42px; border-radius: 10px 10px 2px 10px; }
