/* 家人 App（首頁、地圖、成員、同意說明）。共用元件在 /shared/milk.css。 */

body { overscroll-behavior-y: none; }
#app { min-height: 100vh; outline: none; overflow-x: clip; } /* 換頁的滑動轉場不能撐出橫向捲軸 */
.page { max-width: 560px; margin: 0 auto; padding: calc(max(20px, env(safe-area-inset-top)) + 20px) 18px calc(110px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 20px; }
.page.wide { max-width: 720px; }

/* 啟動畫面：奶茶杯＋平台名稱 */
.splash { position: fixed; inset: 0; z-index: 200; overflow: hidden; display: grid; place-content: center; justify-items: center; gap: 18px; background: var(--bg); transition: opacity .45s ease, visibility .45s; }
.splash.done { opacity: 0; visibility: hidden; }
.splash p { margin: 0; font-size: 20px; color: var(--text-soft); }
.cup.big { transform: scale(1.6); margin-bottom: 26px; }

/* 首頁問候 */
.hello { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.hello p { margin: 0; }
.hello .org { font-size: 13px; color: var(--text-soft); letter-spacing: 1px; }
.hello h1 { margin: 4px 0; }
.hello .sub { color: var(--text-soft); font-size: 15px; }
.hello .cup { flex: none; }

/* 全家在哪裡 */
.family-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 10px 6px; }
.family-row a, .family-row button { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 4px 0; border: 0; background: none; color: var(--text); text-decoration: none; font: inherit; cursor: pointer; border-radius: var(--r-md); }
.family-row .who { font-size: 13px; text-align: center; line-height: 1.3; max-width: 84px; overflow: hidden; text-overflow: ellipsis; }
.family-row .who small { display: block; color: var(--text-soft); font-size: 12px; }

/* 快捷方塊 */
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.tile { display: flex; flex-direction: column; gap: 8px; min-height: 118px; padding: 16px; border-radius: var(--r-lg); background: var(--surface-2); color: var(--text); text-decoration: none; transition: transform .2s var(--ease-pop), box-shadow .2s ease; }
.tile:hover { color: var(--text); box-shadow: var(--shadow-1); }
.tile:active { transform: scale(.97); }
.tile svg { width: 28px; height: 28px; stroke: var(--primary); fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tile strong { font: 18px/1.2 var(--font-display); font-weight: 400; }
.tile span { font-size: 13px; color: var(--text-soft); }

/* 動態清單 */
.feed { display: flex; flex-direction: column; gap: 8px; }
.feed-item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow-1); }
.feed-item .dot { width: 10px; height: 10px; border-radius: 5px; background: var(--c); flex: none; }
.feed-item p { margin: 0; font-size: 15px; flex: 1; min-width: 0; }
.feed-item time { font-size: 13px; color: var(--text-soft); flex: none; }

/* 底部導覽列 */
.tabbar { position: fixed; left: 12px; right: 12px; bottom: calc(14px + env(safe-area-inset-bottom)); z-index: 40; max-width: 520px; margin: 0 auto; display: flex; gap: 6px; padding: 7px; border-radius: 30px; background: var(--cocoa); box-shadow: 0 12px 28px rgba(74, 52, 38, .32); }
:root[data-theme="dark"] .tabbar { background: #4A382C; }
.tabbar a { flex: 1; min-height: 48px; display: flex; align-items: center; justify-content: center; gap: 6px; border-radius: 24px; color: var(--cream); text-decoration: none; font: 15px/1 var(--font-display); transition: background .3s var(--ease-out), color .3s ease; }
.tabbar a svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tabbar a[aria-current="page"] { background: var(--tea); color: var(--cocoa); }
.tabbar a:active { transform: scale(.95); }

/* 登入 */
.login { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 18px; padding: 32px 22px; text-align: center; }
.login .cup.big { margin: 10px 0 24px; }
.login h1 { font-size: 30px; }
.login p { margin: 0; color: var(--text-soft); max-width: 340px; }
.login .btn { min-width: 260px; }
.google-btn { min-height: 60px; padding: 0 28px; gap: 12px; }
.google-btn .two { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; text-align: left; }
.google-btn small { font: 13px/1.2 var(--font-body); opacity: .85; }
.login .g { width: 22px; height: 22px; border-radius: 11px; background: #fff; display: grid; place-items: center; }
.login .g svg { width: 15px; height: 15px; }

/* 同意說明頁 */
.consent h1 { margin-bottom: 4px; }
.consent .lead { color: var(--text-soft); }
.consent-list { display: flex; flex-direction: column; gap: 12px; margin: 0; padding: 0; list-style: none; }
.consent-list li { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 12px; align-items: start; padding: 14px; border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow-1); }
.consent-list .ic { width: 44px; height: 44px; border-radius: 22px; display: grid; place-items: center; background: var(--surface-2); }
.consent-list .ic svg { width: 22px; height: 22px; fill: none; stroke: var(--primary); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.consent-list h3 { font-size: 17px; margin-bottom: 2px; }
.consent-list p { margin: 0; font-size: 15px; }
.consent-list .id { display: block; margin-top: 6px; color: var(--text-soft); font-size: 14px; }
/* 雙語：印尼文另起一行、字小一點；按鈕裡維持同一行 */
.consent h1 .id, .consent h3 .id, .consent .lead .id, .agree .id { display: block; margin-top: 4px; font-size: .72em; color: var(--text-soft); font-family: var(--font-body); }
.consent h3 .id { font-size: 14px; margin-top: 0; }
.consent .lead .id { font-size: 15px; margin-top: 8px; }
.agree .id { font-size: 14px; font-weight: 400; }
.btn .id { margin-left: .5em; font-size: .85em; opacity: .85; }
.agree { display: flex; gap: 12px; align-items: flex-start; padding: 14px; border-radius: var(--r-lg); background: var(--surface-2); cursor: pointer; font-weight: 600; }
.agree input { width: 24px; height: 24px; margin: 0; accent-color: var(--caramel); flex: none; }
.lang-pick { align-self: flex-start; }

/* 地圖頁 */
.map-page { position: fixed; inset: 0; background: #F3EADF; }
:root[data-theme="dark"] .map-page { background: #2B211B; }
#map { position: absolute; inset: 0; }
.map-top { position: absolute; left: 14px; right: 14px; top: calc(max(12px, env(safe-area-inset-top)) + 4px); z-index: 10; display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 12px; border-radius: 24px; background: color-mix(in srgb, var(--bg) 94%, transparent); box-shadow: var(--shadow-2); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); max-width: 640px; margin: 0 auto; }
.map-top h1 { font-size: 20px; }
.map-top p { margin: 0; font-size: 12px; color: var(--text-soft); }
.map-top .spacer { flex: 1; }
.map-notice { position: absolute; left: 50%; transform: translateX(-50%); top: calc(max(12px, env(safe-area-inset-top)) + 76px); z-index: 10; width: min(420px, calc(100% - 28px)); }
.map-fallback { position: absolute; inset: 0; display: grid; place-content: center; padding: 24px 24px 300px; text-align: center; color: var(--text-soft); }

/* 地圖頭像 */
.pin { position: relative; width: 60px; height: 60px; display: grid; place-items: center; cursor: pointer; border: 0; padding: 0; background: none; -webkit-tap-highlight-color: transparent; }
.pin .avatar { --size: 54px; box-shadow: inset 0 0 0 4px var(--c), 0 8px 18px rgba(74, 52, 38, .3); }
.pin .avatar.breathe { animation-name: pin-breathe; }
.pin .avatar.battery, .cluster .avatar.battery { box-shadow: 0 8px 18px rgba(74, 52, 38, .3); animation: none; }
@keyframes pin-breathe { 0%, 100% { box-shadow: inset 0 0 0 4px var(--c), 0 8px 18px rgba(74, 52, 38, .3), 0 0 0 0 color-mix(in srgb, var(--c) 50%, transparent); } 50% { box-shadow: inset 0 0 0 4px var(--c), 0 8px 18px rgba(74, 52, 38, .3), 0 0 0 14px color-mix(in srgb, var(--c) 0%, transparent); } }
.pin.selected .avatar { transform: scale(1.12); }
.pin .avatar { transition: transform .35s var(--ease-pop); }
.pin .trail { position: absolute; left: 50%; top: 50%; width: 0; height: 0; pointer-events: none; }
.pin .trail i { position: absolute; top: -5px; width: 10px; height: 10px; border-radius: 5px; background: var(--c); animation: trail-fade 1.3s ease-in-out infinite alternate; }
.pin .trail i:nth-child(1) { left: -44px; opacity: .55; width: 12px; height: 12px; top: -6px; }
.pin .trail i:nth-child(2) { left: -60px; opacity: .35; animation-delay: .25s; }
.pin .trail i:nth-child(3) { left: -73px; opacity: .2; width: 8px; height: 8px; top: -4px; animation-delay: .5s; }
@keyframes trail-fade { from { opacity: .7; } to { opacity: .15; } }
.pin.stale .avatar { filter: saturate(.4); }
.pin .tag { position: absolute; top: calc(100% - 2px); left: 50%; transform: translateX(-50%); padding: 2px 8px; border-radius: 10px; background: var(--surface); color: var(--text); font-size: 12px; white-space: nowrap; box-shadow: var(--shadow-1); }
.cluster { position: relative; height: 60px; display: flex; align-items: center; cursor: pointer; border: 0; padding: 0 6px; background: none; }
.cluster .avatar { --size: 50px; margin-left: -22px; box-shadow: inset 0 0 0 3px var(--c), 0 6px 14px rgba(74, 52, 38, .28); }
.cluster .avatar:first-child { margin-left: 0; }
.cluster .count { position: absolute; right: -2px; top: 0; min-width: 24px; height: 24px; padding: 0 6px; border-radius: 12px; display: grid; place-items: center; background: var(--caramel); color: var(--cream); font-size: 13px; font-weight: 700; box-shadow: var(--shadow-1); }
/* MapLibre 用 transform 定位 marker，動畫只能放在裡面的頭像上，不能放在 .pin／.cluster 本身。 */
.pin.spread .avatar { animation: milk-pop .45s var(--ease-pop) both; }

/* 地圖下方的抽屜 */
.sheet { position: absolute; left: 0; right: 0; bottom: 0; z-index: 20; max-width: 640px; margin: 0 auto; padding: 10px 16px calc(96px + env(safe-area-inset-bottom)); border-radius: 30px 30px 0 0; background: var(--bg); box-shadow: 0 -12px 32px rgba(74, 52, 38, .18); transition: transform .4s var(--ease-out); max-height: 46vh; display: flex; flex-direction: column; }
.sheet.collapsed { transform: translateY(calc(100% - 150px - env(safe-area-inset-bottom))); }
.sheet .handle { width: 100%; height: 26px; border: 0; background: none; cursor: pointer; display: grid; place-items: center; flex: none; }
.sheet .handle::before { content: ""; width: 44px; height: 5px; border-radius: 3px; background: var(--line-strong); }
.sheet .body { overflow-y: auto; min-height: 0; display: flex; flex-direction: column; gap: 8px; padding-bottom: 4px; }
.member-btn { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 60px; padding: 8px 12px; border: 0; border-radius: var(--r-lg); background: var(--surface); color: var(--text); text-align: left; font: inherit; cursor: pointer; box-shadow: var(--shadow-1); transition: transform .2s var(--ease-pop); }
.member-btn:active { transform: scale(.98); }
.member-btn .txt { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.member-btn .txt strong { font: 16px/1.3 var(--font-display); font-weight: 400; }
.member-btn .txt small { color: var(--text-soft); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-btn .side { font-size: 13px; color: var(--text-soft); text-align: right; flex: none; }
.member-btn .side.low { color: var(--orange); font-weight: 700; }
.detail { display: flex; flex-direction: column; gap: 14px; animation: milk-rise .35s var(--ease-out) both; }
.detail-head { display: flex; align-items: center; gap: 14px; }
.detail-head .txt { flex: 1; min-width: 0; }
.detail-head h2 { font-size: 22px; }
.detail-head p { margin: 2px 0 0; font-size: 14px; color: var(--text-soft); }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.stats div { padding: 10px 12px; border-radius: var(--r-md); background: var(--surface-2); }
.stats span { display: block; font-size: 12px; color: var(--text-soft); }
.stats strong { font: 18px/1.3 var(--font-display); font-weight: 400; }

/* 成員頁 */
.me-card { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.me-card h2 { font-size: 24px; }
.avatar-choices { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.emoji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(48px, 1fr)); gap: 6px; }
.emoji-grid button { height: 48px; border: 0; border-radius: var(--r-sm); background: var(--surface-2); font-size: 26px; cursor: pointer; transition: transform .15s var(--ease-pop); }
.emoji-grid button[aria-pressed="true"] { background: var(--tea); }
.emoji-grid button:active { transform: scale(.88); }
.colors { display: flex; gap: 10px; flex-wrap: wrap; }
.colors button { width: 44px; height: 44px; border-radius: 22px; border: 0; background: var(--c); cursor: pointer; box-shadow: inset 0 0 0 4px var(--tint); transition: transform .2s var(--ease-pop); }
.colors button[aria-pressed="true"] { box-shadow: inset 0 0 0 4px var(--tint), 0 0 0 3px var(--bg), 0 0 0 6px var(--c); transform: scale(1.06); }
.colors button:disabled { opacity: .3; cursor: not-allowed; }
.share-card { display: flex; flex-direction: column; gap: 12px; }
.share-card .state { display: flex; align-items: center; gap: 14px; }
.share-card .state .big-dot { width: 14px; height: 14px; border-radius: 7px; background: var(--matcha); box-shadow: 0 0 0 6px var(--ok-soft); flex: none; }
.share-card.paused .state .big-dot { background: var(--text-soft); box-shadow: 0 0 0 6px var(--surface-2); }
.share-card h3 { font-size: 20px; }
.list { display: flex; flex-direction: column; gap: 0; }
.list > div { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.list > div:first-child { border-top: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .grow small { display: block; color: var(--text-soft); font-size: 13px; }

/* 電量環：0–100%，每 5% 一格（不能用 style 屬性，CSP 只允許外部樣式） */
.b0 { --batt: 2%; } .b5 { --batt: 5%; } .b10 { --batt: 10%; } .b15 { --batt: 15%; } .b20 { --batt: 20%; } .b25 { --batt: 25%; } .b30 { --batt: 30%; }


/* ---------- 第 2 階段 ---------- */

/* 詳細卡下方的三顆按鈕：立即定位、軌跡、戳一下 */
.actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 8px; }
.act { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 64px; padding: 8px 6px; border: 0; border-radius: var(--r-lg); background: var(--surface-2); color: var(--text); font: 14px/1.2 var(--font-display); cursor: pointer; transition: transform .2s var(--ease-pop), background .2s ease; -webkit-tap-highlight-color: transparent; }
.act svg { width: 24px; height: 24px; fill: none; stroke: var(--caramel); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.act:active { transform: scale(.94); }
.act.peach { background: var(--peachy-tint); }
.act.peach svg { stroke: var(--peachy-deep); }
.act[aria-busy="true"] { opacity: .65; }
.act[aria-busy="true"] svg { animation: act-spin 1.4s linear infinite; }
@keyframes act-spin { to { transform: rotate(360deg); } }

/* 立即定位：從頭像擴散雷達波紋 */
.pin.radar::before, .pin.radar::after { content: ""; position: absolute; left: 50%; top: 50%; width: 54px; height: 54px; margin: -27px 0 0 -27px; border-radius: 50%; border: 3px solid var(--c, var(--tea)); pointer-events: none; animation: radar 1.6s ease-out infinite; }
.pin.radar::after { animation-delay: .8s; }
@keyframes radar { from { transform: scale(.9); opacity: .9; } to { transform: scale(2.6); opacity: 0; } }
/* 被戳：頭像晃一下 */
.avatar.wiggle { animation: wiggle .6s var(--ease-pop); }
@keyframes wiggle { 0%, 100% { transform: rotate(0); } 20% { transform: rotate(-12deg) scale(1.06); } 45% { transform: rotate(10deg); } 70% { transform: rotate(-5deg); } }

/* 地圖上的小房子：冷氣開著時亮起、冒涼風 */
.pin { z-index: 2; }
.house { position: relative; z-index: 1; width: 58px; height: 52px; display: grid; place-items: center; padding: 0; border: 0; background: none; cursor: pointer; -webkit-tap-highlight-color: transparent; transition: opacity .3s ease; }
.house .roofbox { position: relative; width: 46px; height: 46px; border-radius: 16px; display: grid; place-items: center; background: var(--surface); box-shadow: 0 6px 16px rgba(74, 52, 38, .28); transition: background .4s ease, box-shadow .4s ease; }
.house svg { width: 34px; height: 34px; fill: none; stroke: var(--caramel); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.house .win { fill: var(--surface-3); stroke-width: 0; }
.house .door { fill: var(--tea); stroke-width: 0; }
.house.on .roofbox { background: #E6F0F8; box-shadow: 0 0 0 4px rgba(91, 141, 184, .25), 0 6px 18px rgba(47, 85, 120, .35); animation: house-glow 2.8s ease-in-out infinite; }
:root[data-theme="dark"] .house.on .roofbox { background: #2E3D4B; }
.house.on svg { stroke: var(--salt-deep); }
.house.on .win { fill: #FFE7A8; }
:root[data-theme="dark"] .house.on svg { stroke: #C9DCEC; }
.house.unknown .roofbox { opacity: .6; }
.house.dim { opacity: .35; pointer-events: none; }
@keyframes house-glow { 50% { box-shadow: 0 0 0 9px rgba(91, 141, 184, .08), 0 6px 18px rgba(47, 85, 120, .35); } }
.house .flake { position: absolute; right: -6px; top: -6px; width: 20px; height: 20px; border-radius: 10px; display: grid; place-items: center; background: var(--salt); box-shadow: var(--shadow-1); }
.house .flake svg { width: 13px; height: 13px; stroke: #fff; stroke-width: 2.4; }
.house .temp { position: absolute; left: 50%; bottom: -14px; transform: translateX(-50%); padding: 1px 7px; border-radius: 9px; background: var(--surface); color: var(--text); font: 12px/1.4 var(--font-display); box-shadow: var(--shadow-1); white-space: nowrap; }
.house .breeze { position: absolute; left: 50%; top: 2px; width: 0; height: 0; pointer-events: none; }
.house .breeze i { position: absolute; top: 0; width: 14px; height: 7px; border: 2.5px solid rgba(91, 141, 184, .7); border-bottom: 0; border-left: 0; border-right: 0; border-radius: 50% 50% 0 0; animation: breeze 2.2s ease-out infinite; }
.house .breeze i:nth-child(1) { left: -24px; }
.house .breeze i:nth-child(2) { left: -7px; animation-delay: .7s; }
.house .breeze i:nth-child(3) { left: 10px; animation-delay: 1.4s; }
@keyframes breeze { 0% { transform: translateY(0) scaleX(.6); opacity: 0; } 30% { opacity: 1; } 100% { transform: translateY(-22px) scaleX(1.2); opacity: 0; } }
.house-ic { width: 56px; height: 56px; flex: none; border-radius: 18px; display: grid; place-items: center; background: var(--surface-2); }
.house-ic svg { width: 38px; height: 38px; fill: none; stroke: var(--caramel); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.house-ic .win { fill: var(--surface-3); stroke-width: 0; } .house-ic .door { fill: var(--tea); stroke-width: 0; }
.house-ic.on { background: #E6F0F8; } .house-ic.on svg { stroke: var(--salt-deep); } .house-ic.on .win { fill: #FFE7A8; }
:root[data-theme="dark"] .house-ic.on { background: #2E3D4B; }
.ac-list { display: flex; flex-direction: column; gap: 8px; }
.ac { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: var(--r-md); background: var(--surface-2); }
.ac .dot { width: 12px; height: 12px; border-radius: 6px; background: var(--surface-3); flex: none; }
.ac.on .dot { background: var(--salt); box-shadow: 0 0 0 5px rgba(91, 141, 184, .2); }
.ac .txt { display: flex; flex-direction: column; min-width: 0; }
.ac strong { font: 16px/1.3 var(--font-display); font-weight: 400; }
.ac small { color: var(--text-soft); font-size: 13px; }
.home-who { gap: 6px; }
.home-who .avatar { margin-right: -10px; }
.home-who .muted { margin-left: 14px; }

/* 團聚時刻 */
.cluster .gather { position: absolute; left: 50%; top: calc(100% - 4px); transform: translateX(-50%); padding: 2px 10px; border-radius: 10px; background: var(--peachy); color: #fff; font: 12px/1.5 var(--font-display); white-space: nowrap; box-shadow: var(--shadow-1); animation: gather-bob 2.4s ease-in-out infinite; }
@keyframes gather-bob { 50% { margin-top: -3px; } }
.gather-card { display: flex; align-items: center; gap: 14px; color: var(--text); text-decoration: none; background: linear-gradient(120deg, var(--peachy-tint), var(--surface)); }
.gather-card:hover { color: var(--text); }
.gather-card .stack-av { display: flex; flex: none; }
.gather-card .stack-av .avatar { margin-left: -12px; } .gather-card .stack-av .avatar:first-child { margin-left: 0; }
.gather-card strong { display: block; font: 17px/1.3 var(--font-display); font-weight: 400; color: var(--peachy-deep); }
:root[data-theme="dark"] .gather-card strong { color: var(--peachy-light); }
.gather-card small { color: var(--text-soft); font-size: 14px; }

/* 軌跡 */
.track { display: flex; flex-direction: column; gap: 12px; animation: milk-rise .35s var(--ease-out) both; }
.track .detail-head h2 { font-size: 20px; }
.track-when { display: flex; align-items: center; gap: 8px; }
.track-when .icon-btn:disabled { opacity: .35; cursor: default; }
.date-pill { flex: 1; }
.track input[type=date], .track input[type=time] { font: 16px/1.2 var(--font-display); width: 100%; min-height: 44px; padding: 6px 12px; border: 2px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--text); text-align: center; }
.track-range { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: 8px; align-items: end; }
.track-range label { display: grid; gap: 4px; font-size: 12px; color: var(--text-soft); }
.chip { min-height: 44px; padding: 0 14px; border: 0; border-radius: 999px; background: var(--surface-2); color: var(--text); font: 14px/1 var(--font-display); cursor: pointer; }
.chip:active { transform: scale(.95); }
.scrub { display: flex; align-items: center; gap: 10px; padding: 8px 12px 8px 8px; border-radius: 999px; background: var(--surface-2); }
.scrub .play { width: 42px; height: 42px; flex: none; border: 0; border-radius: 21px; display: grid; place-items: center; background: var(--caramel); cursor: pointer; box-shadow: 0 3px 0 var(--cocoa); transition: transform .12s ease; }
.scrub .play:active { transform: translateY(3px); box-shadow: none; }
.scrub .play svg { width: 18px; height: 18px; fill: var(--cream); stroke: none; }
.scrub input[type=range] { flex: 1; min-width: 0; accent-color: var(--caramel); height: 28px; }
.scrub time { font: 16px/1 var(--font-display); min-width: 3.2em; text-align: right; font-variant-numeric: tabular-nums; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 4px; display: flex; flex-direction: column; position: relative; }
.timeline::before { content: ""; position: absolute; left: 24px; top: 20px; bottom: 20px; width: 3px; border-radius: 2px; background: linear-gradient(var(--c-light), var(--c-deep)); }
.seg { position: relative; display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 6px 10px 6px 0; border: 0; border-radius: var(--r-md); background: none; color: var(--text); text-align: left; font: inherit; cursor: pointer; transition: background .2s ease; }
.seg.now { background: color-mix(in srgb, var(--c) 12%, transparent); }
@media (hover: hover) { .seg:hover { background: color-mix(in srgb, var(--c) 8%, transparent); } }
.seg .ic { width: 42px; height: 42px; flex: none; border-radius: 21px; display: grid; place-items: center; background: var(--surface); box-shadow: inset 0 0 0 3px var(--c); position: relative; z-index: 1; }
.seg.move .ic { width: 34px; height: 34px; margin: 0 4px; background: var(--c); box-shadow: none; }
.seg .ic svg { width: 20px; height: 20px; fill: none; stroke: var(--c-deep); stroke-width: 2.3; stroke-linecap: round; stroke-linejoin: round; }
.seg.move .ic svg { width: 18px; height: 18px; stroke: #fff; }
.seg .txt { display: flex; flex-direction: column; min-width: 0; }
.seg strong { font: 16px/1.3 var(--font-display); font-weight: 400; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seg.move strong { font-size: 15px; color: var(--text-soft); }
.seg small { color: var(--text-soft); font-size: 13px; }
.seg.now .ic { transform: scale(1.08); }
.pin.ghost { pointer-events: none; }
.sheet.tracking { max-height: 58vh; }
.pin.ghost .avatar { box-shadow: inset 0 0 0 4px var(--c), 0 0 0 6px color-mix(in srgb, var(--c) 30%, transparent), 0 8px 18px rgba(74, 52, 38, .3); }
.access time { flex: none; }
.btn.small svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- 第 3 階段 ---------- */

/* 頭像狀態燈號：綠＝正常、黃＝注意、紅（玫瑰色，紅豆色只留給 SOS）＝超過 2 小時沒更新 */
.avatar .st { position: absolute; right: -1px; top: -1px; width: 30%; height: 30%; min-width: 11px; min-height: 11px; max-width: 16px; max-height: 16px; border-radius: 50%; box-shadow: 0 0 0 2.5px var(--bg); }
.avatar .st-ok { background: var(--matcha); }
.avatar .st-warn { background: var(--honey); }
.avatar .st-bad { background: var(--rose); }
.avatar.xs .st { display: none; }

/* 到家倒數 */
.eta-note, .sos-note { display: flex; align-items: center; gap: 10px; margin: 0; padding: 10px 14px; border-radius: var(--r-md); background: var(--salt-tint); color: var(--text); font: 16px/1.3 var(--font-display); }
.eta-note svg, .sos-note svg { width: 20px; height: 20px; flex: none; fill: none; stroke: var(--salt-deep); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
:root[data-theme="dark"] .eta-note svg { stroke: var(--salt-light); }

/* SOS：紅豆色只在這裡出現 */
.avatar.sos { box-shadow: inset 0 0 0 var(--border) var(--redbean); }
.pin.sos .avatar { box-shadow: inset 0 0 0 4px var(--redbean), 0 8px 18px rgba(74, 52, 38, .3); animation: none; }
.pin.sos::before, .pin.sos::after, .cluster.sos::before, .cluster.sos::after { content: ""; position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; margin: -28px 0 0 -28px; border-radius: 50%; background: color-mix(in srgb, var(--redbean) 45%, transparent); pointer-events: none; animation: sos-pulse 1.6s ease-out infinite; }
.pin.sos::after, .cluster.sos::after { animation-delay: .8s; }
.cluster.sos { z-index: 5; }
.pin.sos { z-index: 5; }
@keyframes sos-pulse { from { transform: scale(1); opacity: .9; } to { transform: scale(3); opacity: 0; } }
.sos-note { background: var(--danger-soft); color: var(--danger); }
.sos-note svg { stroke: var(--danger); }
.sos-banner { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: var(--r-lg); background: var(--redbean); color: #fff; box-shadow: 0 10px 26px rgba(181, 82, 74, .35); animation: milk-rise .4s var(--ease-out) both; }
.sos-banner.drill { background: var(--surface-2); color: var(--text); box-shadow: inset 0 0 0 2px var(--redbean); }
.sos-banner .grow { flex: 1; min-width: 0; }
.sos-banner strong { display: block; font: 18px/1.3 var(--font-display); font-weight: 400; }
.sos-banner small { opacity: .85; font-size: 13px; }
.sos-banner .btn { --btn-bg: #fff; --btn-fg: var(--redbean); --btn-edge: #E8BDB7; flex: none; }
.sos-banner.drill .btn { --btn-bg: var(--redbean); --btn-fg: #fff; --btn-edge: #7E3630; }
.tile.sos-tile { border: 0; font: inherit; text-align: left; cursor: pointer; background: var(--surface); box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--redbean) 55%, transparent); }
.tile.sos-tile svg { stroke: var(--redbean); }
.tile.sos-tile strong { color: var(--redbean); }
.sos-overlay { position: fixed; inset: 0; z-index: 300; display: grid; place-items: center; padding: 24px; background: rgba(43, 33, 27, .72); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); animation: milk-fade .25s ease both; }
.sos-overlay.out { opacity: 0; transition: opacity .25s ease; }
.sos-box { width: min(380px, 100%); display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 28px 22px 22px; border-radius: 30px; background: var(--bg); text-align: center; box-shadow: 0 24px 60px rgba(0, 0, 0, .35); }
.sos-box h2 { font-size: 22px; }
.sos-box p { margin: 0; color: var(--text-soft); }
.sos-ring { width: 120px; height: 120px; border-radius: 50%; display: grid; place-items: center; background: var(--redbean); color: #fff; box-shadow: 0 0 0 10px var(--danger-soft); animation: sos-beat 1s ease-in-out infinite; }
.sos-overlay.drill .sos-ring { background: var(--caramel); box-shadow: 0 0 0 10px var(--surface-2); }
.sos-ring b { font: 56px/1 var(--font-display); font-weight: 400; font-variant-numeric: tabular-nums; }
@keyframes sos-beat { 50% { transform: scale(1.06); } }
.sos-cancel { min-height: 60px; font-size: 20px; }
.sos-now { --btn-fg: var(--redbean); box-shadow: inset 0 0 0 2px var(--redbean); }
.sos-card h2 svg, .notes h2 svg { width: 22px; height: 22px; fill: none; stroke: var(--redbean); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.notes h2 svg { stroke: var(--caramel); }
.sos-card h3 { font-size: 17px; margin-top: 4px; }
.copy-row { display: flex; gap: 8px; align-items: center; }
.copy-row code { flex: 1; min-width: 0; padding: 10px 12px; border-radius: var(--r-sm); background: var(--surface-2); font-size: 13px; overflow-wrap: anywhere; user-select: all; }
.steps { margin: 0; padding: 12px 14px; border-radius: var(--r-md); background: var(--surface-2); line-height: 1.7; }
ul.plain { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
ul.plain li { padding: 10px 14px; border-radius: var(--r-md); background: var(--surface-2); font-size: 15px; }

/* 到達／離開通知 */
.watch-list { display: flex; flex-direction: column; gap: 8px; }
.watch-row { display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 14px; border-radius: var(--r-md); background: var(--surface-2); }
.watch-row strong { flex: 1; min-width: 0; font: 16px/1.3 var(--font-display); font-weight: 400; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.watch-row .chip { min-height: 38px; background: var(--surface); }
.chip.on { background: var(--caramel); color: var(--cream); }

/* 小紙條 */
.notes h2 { display: flex; align-items: center; gap: 8px; }
.note-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.note-list li { position: relative; }
.note-list .paper { min-height: 96px; padding: 14px 14px 12px; border-radius: 6px 18px 18px 18px; background: #FFF4C9; color: #4A3426; box-shadow: 0 6px 14px rgba(74, 52, 38, .14); transform: rotate(-1.2deg); }
.note-list li:nth-child(2n) .paper { transform: rotate(1deg); background: #FBE3DA; }
.note-list li:nth-child(3n) .paper { background: #E3EED8; }
.note-list .paper p { margin: 0 0 8px; font: 17px/1.4 var(--font-display); overflow-wrap: anywhere; }
.note-list .paper small { color: #7A6352; font-size: 12px; }
.note-list li.done .paper { opacity: .6; }
.note-list .icon-btn { position: absolute; right: -6px; top: -8px; width: 32px; height: 32px; min-height: 0; background: var(--surface); box-shadow: var(--shadow-1); }
.note-list .icon-btn svg { width: 14px; height: 14px; }
.note-form { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px 10px; align-items: end; }
.note-form label { display: grid; gap: 4px; font-size: 12px; color: var(--text-soft); }
.note-form select { width: auto; min-width: 7em; }
.note-form .btn { grid-column: 1 / -1; }

@media (min-width: 900px) {
  .page { padding-top: 48px; }
  .sheet { left: 24px; right: auto; width: 380px; bottom: 24px; border-radius: 30px; max-height: calc(100vh - 140px); padding-bottom: 16px; }
  .sheet.collapsed { transform: none; }
  .sheet.tracking { max-height: calc(100vh - 140px); }
  .tabbar { left: 50%; right: auto; transform: translateX(-50%); width: 420px; }
  .map-top { left: 24px; right: auto; width: 380px; margin: 0; }
  .map-notice { left: auto; right: 24px; transform: none; }
}
