/* 長康 — mobile-first・長者友善・LONGWELL 設計系統（翡翠綠 emerald × 檸黃）
   Driven by the LONGWELL design system design-tokens.css (--lw-*);
   以下舊變數名保留做 alias，令全 app 舊規則自動著新色。
   原則：大字體、大按鈕(≥44px)、圓角、柔和陰影、留白、避免刺眼警示色鋪滿 */

:root {
  --gold: var(--lw-accent);          /* 點綴 CTA 黃 */
  --gold-deep: var(--lw-primary);    /* 主色（原金深 → 翡翠綠） */
  --brown: var(--lw-n-900);          /* 標題深字 */
  --brown-dark: var(--lw-topbar);    /* 頂欄 */
  --teal: var(--lw-primary);         /* 正面/成功系 → 主色 */
  --teal-soft: #58B893;
  --cream: var(--lw-n-100);          /* 淺灰綠面 */
  --card: var(--lw-card);
  --line: var(--lw-border);
  --text: var(--lw-text);
  --muted: var(--lw-text-2);
  --warn: var(--lw-warning);
  --emerg: var(--lw-emergency);
  --radius: var(--lw-r-l);
  --shadow: var(--lw-sh-md);
  --shadow-soft: var(--lw-sh-sm);
}

* { box-sizing: border-box; }

/* hidden 屬性必須凌駕 display:flex 等設定（否則 modal/compose 等會蓋住畫面攔截點擊）*/
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--lw-bg);
  color: var(--text);
  font-family: var(--lw-font);
  font-size: 18px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

/* LONGWELL 線性 icon 基礎（icons.svg sprite，用 currentColor） */
.lw-icon { width: 22px; height: 22px; flex: none; vertical-align: -4px; }
h3 .lw-icon, h4 .lw-icon, .pn-head .lw-icon { color: var(--lw-primary); }

button { font-family: inherit; cursor: pointer; }
input, select { font-family: inherit; font-size: 17px; }

/* ---------- 頂欄 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--brown-dark);
  color: #f4ead2;
}
.brand { font-size: 20px; font-weight: 700; letter-spacing: 0.5px; }
.brand span { color: var(--gold); font-size: 13px; letter-spacing: 2px; }
.whoami { display: flex; align-items: center; gap: 10px; font-size: 14px; color: #d8ccb0; }

/* ---------- 畫面容器 ---------- */
main { padding-bottom: 40px; }
.screen { display: none; animation: fadeIn 0.4s ease; }
.screen.active { display: block; }
.screen#screen-app, .screen#screen-staff {
  max-width: 460px;
  margin: 0 auto;
  padding: 16px 14px;
}
.screen#screen-staff { max-width: 920px; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- 按鈕 ---------- */
.primary-btn {
  background: var(--gold-deep);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 12px 18px;
  font-size: 17px;
  font-weight: 600;
  min-height: 46px;
  transition: transform 0.1s ease, filter 0.15s ease;
}
.primary-btn:hover { filter: brightness(1.05); }
.primary-btn:active { transform: scale(0.97); }
.primary-btn.big { width: 100%; padding: 15px; font-size: 19px; margin-top: 8px; }

.ghost-btn {
  background: transparent;
  border: 1.5px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  padding: 9px 14px;
  font-size: 15px;
  min-height: 40px;
  transition: background 0.15s ease;
}
.ghost-btn:hover { background: rgba(200, 161, 90, 0.1); }
.ghost-btn.sm { min-height: 34px; padding: 5px 10px; font-size: 14px; }
.ghost-btn.danger { color: var(--emerg); border-color: rgba(198, 90, 79, 0.4); }
.topbar .ghost-btn { color: #e8dcc0; border-color: rgba(232, 220, 192, 0.3); }

/* ---------- 登入 ---------- */
#screen-login { max-width: 400px; margin: 0 auto; padding: 8vh 20px; }
.login-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 30px 24px;
  text-align: center;
}
.login-logo { font-size: 54px; }
.login-card h1 { margin: 6px 0 2px; font-size: 26px; color: var(--brown); }
.login-sub { margin: 0 0 20px; color: var(--muted); }
.login-form { text-align: left; display: flex; flex-direction: column; }
.login-form label { font-size: 14px; color: var(--muted); margin: 10px 0 4px; }
.login-form input {
  padding: 13px 14px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: #fff;
  min-height: 48px;
}
.login-form input:focus { outline: none; border-color: var(--gold); }
.login-error { color: var(--emerg); font-size: 15px; margin-top: 10px; min-height: 20px; }
.login-hint {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px dashed var(--line);
  text-align: left;
  font-size: 14px;
  color: var(--muted);
}
.hint-title { margin-bottom: 8px; }
.hint-row { margin: 4px 0; }

.chip {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 12px;
  color: #fff;
  margin-right: 4px;
}
.chip.elder { background: var(--teal); }
.chip.family { background: var(--gold-deep); }
.chip.staff { background: var(--brown); }

/* ---------- App：長者切換 ---------- */
.elder-switch {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}
.elder-switch select {
  flex: 1;
  padding: 11px 12px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  min-height: 46px;
}

/* ---------- 今日 AI 摘要 banner ---------- */
.ai-digest-banner {
  background: linear-gradient(135deg, #fbf4e6, #f3e9d2);
  border: 1px solid var(--line);
  border-left: 5px solid var(--gold);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-soft);
  animation: fadeIn 0.5s ease;
}
.ai-digest-banner.has-alert { border-left-color: var(--warn); background: linear-gradient(135deg, #fdf1e4, #f8e6d2); }
.banner-tag { font-size: 13px; color: var(--gold-deep); font-weight: 700; margin-bottom: 6px; }
.ai-digest-banner.has-alert .banner-tag { color: var(--warn); }
.banner-text { font-size: 17px; color: var(--brown); line-height: 1.7; }
.banner-loading { color: var(--muted); font-size: 15px; }

/* ---------- 對話 feed ---------- */
.phone-feed {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
  margin-bottom: 12px;
}
.feed-title {
  background: var(--brown-dark);
  color: #f4ead2;
  padding: 12px 16px;
  font-size: 16px;
  font-weight: 600;
}
.chat-feed {
  min-height: 120px;
  max-height: 360px;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.placeholder { color: var(--muted); text-align: center; padding: 30px 10px; font-size: 15px; }

.bubble {
  max-width: 86%;
  padding: 11px 14px;
  border-radius: 16px;
  font-size: 17px;
  line-height: 1.6;
  animation: fadeIn 0.35s ease;
}
.bubble .btag { display: block; font-size: 12px; opacity: 0.8; margin-bottom: 3px; }
.bubble.ai {
  align-self: flex-start;
  background: linear-gradient(135deg, #f6ecd6, #efe1c2);
  color: var(--brown);
  border-bottom-left-radius: 5px;
}
.bubble.me {
  align-self: flex-end;
  background: var(--teal);
  color: #fff;
  border-bottom-right-radius: 5px;
}

/* ---------- 對話輸入 ---------- */
.converse-box {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
}
.converse-box input {
  flex: 1;
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  min-height: 48px;
}
.converse-box input:focus { outline: none; border-color: var(--gold); }

/* ---------- 語音對話（Gemini 式輸入條 + 語言設定）---------- */
.feed-title { display: flex; align-items: center; justify-content: space-between; }
.feed-gear { background: transparent; border: none; color: #e8dcc0; font-size: 18px; padding: 2px 6px; cursor: pointer; min-height: 32px; line-height: 1; }

.input-bar {
  display: flex; align-items: center; gap: 8px; margin-bottom: 18px;
  background: var(--card); border: 1.5px solid var(--line); border-radius: 26px;
  padding: 6px 8px 6px 16px; box-shadow: var(--shadow-soft);
}
.input-bar input { flex: 1; border: none; background: transparent; font-size: 17px; min-height: 40px; }
.input-bar input:focus { outline: none; }
.input-bar input.dictating { color: var(--teal); font-weight: 600; }
.input-actions { display: flex; align-items: center; gap: 6px; }
.ib-btn {
  width: 46px; height: 46px; border-radius: 50%; border: none; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  transition: transform 0.1s ease, filter 0.15s ease;
}
.ib-btn:active { transform: scale(0.92); }
.ib-btn svg { width: 22px; height: 22px; fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ib-btn.mic { background: var(--gold-deep); }
.ib-btn.send { background: var(--gold-deep); }
.ib-btn.stop { background: var(--teal); }
.ib-btn.stop svg { fill: #fff; stroke: none; }

/* 語言設定 modal */
.lang-modal { max-width: 360px; }
.lang-options { display: flex; flex-direction: column; gap: 10px; margin: 10px 0 4px; }
.lang-options button { padding: 15px; border: 1.5px solid var(--line); border-radius: 12px; background: #fff; font-size: 18px; color: var(--text); min-height: 54px; cursor: pointer; }
.lang-options button.active { background: var(--gold-deep); color: #fff; border-color: var(--gold-deep); }

/* ---------- App 底部分頁（似 Google Health）---------- */
.screen#screen-app { padding-bottom: 82px; }
.app-tab { display: none; }
.app-tab.active { display: block; flex: 1 1 auto; min-height: 0; animation: fadeIn 0.25s ease; }
/* App 畫面用 flex 撐滿視窗（唔靠 vh 猜數），令對話 tab 個 feed 拉到貼近底部導航 */
.screen#screen-app.active { display: flex; flex-direction: column; min-height: calc(100vh - 56px); }
.app-tabs-content { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; }
/* 對話 tab：chat feed 拉滿可用高度 */
#tab-chat.active { display: flex; flex-direction: column; }
#tab-chat .phone-feed { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; margin-bottom: 10px; }
#tab-chat .chat-feed { flex: 1 1 auto; max-height: none; min-height: 0; }
.app-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 1000;
  max-width: 460px; margin: 0 auto;
  display: flex; background: var(--card); border-top: 1px solid var(--line);
  box-shadow: 0 -3px 14px rgba(60, 48, 30, 0.08);
}
.app-nav-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 9px 0 11px; background: transparent; border: none;
  font-size: 12px; color: var(--muted); min-height: 58px; cursor: pointer;
}
.app-nav-btn .nav-ico { font-size: 21px; filter: grayscale(0.35); transition: filter 0.15s ease; }
.app-nav-btn.active { color: var(--gold-deep); font-weight: 700; }
.app-nav-btn.active .nav-ico { filter: none; }
/* SOS 喺功能欄：紅色顯眼、緊急感 */
.app-nav-btn.nav-sos { color: var(--emerg); font-weight: 800; }
.app-nav-btn.nav-sos .nav-ico { filter: none; }
.app-nav-btn.nav-sos:active { transform: scale(0.94); }

/* 語言 segmented（設定分頁）*/
.lang-seg { display: flex; gap: 4px; background: #efe6d3; border-radius: 12px; padding: 4px; }
.lang-seg button { flex: 1; border: none; background: transparent; border-radius: 9px; padding: 11px 0; font-size: 16px; font-weight: 600; color: var(--muted); min-height: 46px; cursor: pointer; }
.lang-seg button.active { background: var(--gold-deep); color: #fff; }

/* ---------- 位置 · 電子圍欄 ---------- */
.loc-map { height: 220px; border-radius: 14px; overflow: hidden; border: 1px solid var(--line); background: #e9e3d5; position: relative; z-index: 0; isolation: isolate; }
.loc-map .leaflet-container { font-family: inherit; }
.loc-meta { font-size: 13px; color: var(--muted); margin-top: 10px; line-height: 1.5; }
.loc-pill { font-size: 13px; font-weight: 700; padding: 3px 11px; border-radius: 20px; }
.loc-pill.in { color: var(--teal); background: rgba(74, 122, 109, 0.15); }
.loc-pill.out { color: var(--emerg); background: rgba(198, 90, 79, 0.16); }
.loc-controls { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line); display: flex; flex-direction: column; gap: 10px; }
.loc-sim { display: flex; gap: 8px; flex-wrap: wrap; }
.loc-fence { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 14px; color: var(--muted); }
.loc-fence input { width: 84px; padding: 7px 9px; border: 1.5px solid var(--line); border-radius: 8px; min-height: 36px; }

/* 三點跳動（長康諗緊…）*/
.bubble.thinking .dots { display: inline-flex; gap: 4px; padding: 4px 0; }
.bubble.thinking .dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--gold-deep); animation: dotbounce 1.2s ease-in-out infinite; }
.bubble.thinking .dots i:nth-child(2) { animation-delay: 0.2s; }
.bubble.thinking .dots i:nth-child(3) { animation-delay: 0.4s; }
@keyframes dotbounce { 0%, 60%, 100% { transform: translateY(0); opacity: 0.4; } 30% { transform: translateY(-5px); opacity: 1; } }

/* AI 氣泡「再聽一次」*/
.replay-btn { display: inline-flex; align-items: center; gap: 4px; margin-top: 8px; background: rgba(176, 135, 63, 0.12); border: none; border-radius: 20px; padding: 5px 12px; font-size: 13px; color: var(--gold-deep); min-height: 34px; cursor: pointer; }
.replay-btn:active { transform: scale(0.96); }

/* ---------- 面板區塊 ---------- */
.panel-block {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  padding: 16px;
  margin-bottom: 16px;
}
.block-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.block-head h3 { margin: 0; font-size: 17px; color: var(--brown); }

/* ---------- 手錶健康數據儀表板 ---------- */
.health-block { animation: fadeIn 0.5s ease; }
.health-updated { font-size: 12px; color: var(--muted); }

/* 活動環卡片 */
.activity-card {
  display: flex;
  align-items: center;
  gap: 16px;
  background: linear-gradient(135deg, #fbf4e6, #f3e9d2);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 12px;
}
.ring-wrap { position: relative; width: 80px; height: 80px; flex-shrink: 0; }
.ring { transform: rotate(-90deg); }
.ring-track { fill: none; stroke: rgba(176, 135, 63, 0.18); stroke-width: 9; }
.ring-fill {
  fill: none;
  stroke: var(--gold-deep);
  stroke-width: 9;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.9s ease;
}
.ring-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring-num { font-size: 19px; font-weight: 800; color: var(--brown); line-height: 1; }
.ring-unit { font-size: 11px; color: var(--muted); }
.activity-meta { flex: 1; }
.am-title { font-size: 16px; font-weight: 700; color: var(--brown); margin-bottom: 4px; }
.am-line { font-size: 14px; color: var(--text); }
.am-line.muted { color: var(--muted); font-size: 13px; }

/* 指標 tiles */
.mtiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mtile {
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  border-left-width: 4px;
}
.mtile.s-good { border-left-color: var(--teal); }
.mtile.s-warning { border-left-color: var(--warn); }
.mtile.s-serious { border-left-color: var(--emerg); }
.mtile-top { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.mtile-icon { font-size: 15px; }
.mtile-name { font-size: 13px; color: var(--muted); }
.mtile-val { font-size: 24px; font-weight: 800; color: var(--brown); line-height: 1.1; }
.mtile-val small { font-size: 12px; font-weight: 600; color: var(--muted); margin-left: 3px; }
.mtile.tappable { cursor: pointer; transition: transform 0.1s ease, box-shadow 0.15s ease; }
.mtile.tappable:hover { box-shadow: var(--shadow); }
.mtile.tappable:active { transform: scale(0.98); }
.mtile-chev { margin-left: auto; color: var(--muted); font-size: 20px; line-height: 1; }
.activity-card.tappable { cursor: pointer; }
.mtile-foot { display: flex; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.mstatus { font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 10px; }
.mstatus.s-good { color: var(--teal); background: rgba(74, 122, 109, 0.12); }
.mstatus.s-warning { color: var(--warn); background: rgba(217, 138, 61, 0.15); }
.mstatus.s-serious { color: var(--emerg); background: rgba(198, 90, 79, 0.15); }
.mextra { font-size: 11px; color: var(--muted); }
.spark { width: 56px; height: 22px; margin-left: auto; }
.spark polyline { stroke: var(--gold-deep); stroke-width: 2; vector-effect: non-scaling-stroke; }
.spark-dot { fill: var(--gold-deep); }
.health-note { font-size: 11px; color: var(--muted); margin-top: 10px; text-align: center; }

/* 單項健康數據詳情頁 */
.metric-detail { animation: fadeIn 0.25s ease; }
.md-back { background: transparent; border: none; color: var(--gold-deep); font-size: 15px; font-weight: 600; padding: 4px 0; cursor: pointer; }
.md-head { display: flex; align-items: center; gap: 8px; margin: 8px 0 2px; }
.md-head h2 { margin: 0; font-size: 20px; color: var(--brown); }
.md-icon { font-size: 22px; }
.md-current { font-size: 34px; font-weight: 800; color: var(--brown); line-height: 1.1; }
.md-current small { font-size: 15px; color: var(--muted); font-weight: 600; margin-left: 3px; }
.md-sub { font-size: 14px; color: var(--muted); margin-top: 2px; }
.md-segs { display: flex; gap: 4px; margin: 16px 0 4px; background: rgba(200, 161, 90, 0.12); border-radius: 12px; padding: 4px; }
.md-seg { flex: 1; border: none; background: transparent; color: var(--muted); font-size: 15px; font-weight: 600; padding: 8px 0; border-radius: 9px; cursor: pointer; min-height: 40px; }
.md-seg.active { background: #fffdf8; color: var(--brown); box-shadow: 0 1px 3px rgba(43, 38, 32, 0.12); }
.md-range { font-size: 13px; color: var(--muted); margin: 12px 0 6px; }
.metric-chart { width: 100%; height: auto; display: block; background: #fffdf8; border: 1px solid var(--line); border-radius: 12px; padding: 4px; }
.metric-chart .ch-axis { stroke: var(--line); stroke-width: 1; }
.metric-chart .ch-lbl { font-size: 9px; fill: var(--muted); }
.md-stats { display: flex; gap: 10px; flex-wrap: wrap; margin: 14px 0; }
.md-stats span { background: rgba(200, 161, 90, 0.12); padding: 6px 12px; border-radius: 10px; font-size: 14px; color: var(--text); }
.md-about { margin-top: 6px; }
.md-about h4 { margin: 0 0 6px; font-size: 15px; color: var(--brown); }
.md-about p { margin: 0; font-size: 15px; color: var(--text); line-height: 1.75; }

/* ---------- 家人訊息 ---------- */
.family-thread { display: flex; flex-direction: column; gap: 10px; }
.fmsg { padding: 10px 13px; border-radius: 14px; max-width: 90%; }
.fmsg.in { align-self: flex-start; background: #f1ece0; }
.fmsg.out { align-self: flex-end; background: var(--teal); color: #fff; }
.fmsg-head { font-size: 13px; font-weight: 700; margin-bottom: 3px; opacity: 0.9; }
.fmsg-body { font-size: 16px; line-height: 1.5; }
.thread-loading, .thread-empty { color: var(--muted); font-size: 14px; padding: 6px 0; }

.family-compose { display: flex; gap: 8px; align-items: center; margin-top: 12px; flex-wrap: wrap; }
.family-compose input[type="text"] {
  flex: 1;
  min-width: 140px;
  padding: 11px 13px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  min-height: 46px;
}
.family-compose input:focus { outline: none; border-color: var(--gold); }
.voice-toggle { font-size: 14px; color: var(--muted); display: flex; align-items: center; gap: 4px; }

/* ---------- 用戶概述演化 ---------- */
.week-toggle { display: flex; gap: 6px; }
.week-btn {
  background: transparent;
  border: 1.5px solid var(--line);
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 13px;
  color: var(--muted);
}
.week-btn.active { background: var(--gold-deep); color: #fff; border-color: var(--gold-deep); }
.digest-text { font-size: 16px; line-height: 1.7; color: var(--brown); animation: fadeIn 0.3s ease; }
.digest-date { font-size: 12px; color: var(--muted); margin-top: 8px; }

/* ---------- 職員 Control Panel ---------- */
.staff-tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.staff-tab {
  flex: 1;
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 11px;
  font-size: 15px;
  color: var(--muted);
  min-height: 44px;
}
.staff-tab.active { background: var(--brown-dark); color: #f4ead2; border-color: var(--brown-dark); }
.staff-view { display: none; }
.staff-view.active { display: block; animation: fadeIn 0.35s ease; }

.report-cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 18px; }
.report-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  padding: 16px;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}
.report-card .num { font-size: 28px; font-weight: 700; color: var(--gold-deep); }

.monitor-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.monitor-head h3 { margin: 0; font-size: 17px; color: var(--brown); }

.live-cards { display: grid; grid-template-columns: 1fr; gap: 12px; }
.live-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  border-left: 5px solid var(--teal);
  padding: 14px 16px;
}
.live-card.level-Warning { border-left-color: var(--warn); }
.live-card.level-Emergency { border-left-color: var(--emerg); }
.live-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.live-name { font-size: 18px; font-weight: 700; color: var(--brown); }
.pl-badge {
  background: rgba(200, 161, 90, 0.15);
  color: var(--gold-deep);
  border-radius: 20px;
  padding: 3px 11px;
  font-size: 13px;
  font-weight: 600;
}
.live-vitals { display: flex; gap: 14px; flex-wrap: wrap; font-size: 15px; color: var(--text); margin-bottom: 10px; }
.live-foot { display: flex; align-items: center; justify-content: space-between; }
.alert-pill { padding: 3px 12px; border-radius: 20px; font-size: 13px; font-weight: 700; }
.alert-pill.Info { background: rgba(74, 122, 109, 0.15); color: var(--teal); }
.alert-pill.Warning { background: rgba(217, 138, 61, 0.18); color: var(--warn); }
.alert-pill.Emergency { background: rgba(198, 90, 79, 0.18); color: var(--emerg); }

.staff-tools { margin-top: 18px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.tool-status { font-size: 14px; color: var(--muted); }

/* 帳號管理 */
.admin-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.admin-head h3 { margin: 0; font-size: 17px; color: var(--brown); }
.user-table-wrap { overflow-x: auto; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow-soft); }
.user-table { width: 100%; border-collapse: collapse; font-size: 15px; min-width: 520px; }
.user-table th, .user-table td { padding: 11px 12px; text-align: left; border-bottom: 1px solid var(--line); }
.user-table th { background: #f3ece0; color: var(--muted); font-weight: 600; font-size: 13px; }
.row-actions { display: flex; gap: 6px; white-space: nowrap; }

/* 系統設定：長者 ↔ Agent 設定 */
.settings-hint { font-size: 14px; color: var(--muted); margin: 0 0 14px; line-height: 1.6; }
.config-cards { display: grid; grid-template-columns: 1fr; gap: 14px; }
.config-card {
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  padding: 16px;
}
.cc-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; }
.cc-name { font-size: 17px; font-weight: 700; color: var(--brown); }
.config-card label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
.config-card select, .config-card input {
  padding: 9px 11px; border: 1.5px solid var(--line); border-radius: 10px; background: #fff; min-height: 42px; width: 100%;
}
.config-card select:focus, .config-card input:focus { outline: none; border-color: var(--gold); }
.cc-thresholds { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.cc-row { display: flex; gap: 8px; }
.cc-foot { display: flex; align-items: center; gap: 10px; margin-top: 14px; }
.cc-status { font-size: 14px; }

@media (min-width: 720px) {
  .config-cards { grid-template-columns: 1fr 1fr; }
}

/* ---------- 批量裝置管理 ---------- */
.fleet-kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
.kpi { background: var(--card); border-radius: 14px; box-shadow: var(--shadow-soft); padding: 14px; text-align: center; }
.kpi-num { font-size: 26px; font-weight: 800; color: var(--brown); }
.kpi-label { font-size: 13px; color: var(--muted); }
.kpi-alert .kpi-num { color: var(--warn); }

.fleet-toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.fleet-toolbar input[type="search"] {
  flex: 1; min-width: 180px; padding: 10px 13px; border: 1.5px solid var(--line); border-radius: 10px; background: var(--card); min-height: 44px;
}
.fleet-toolbar select {
  padding: 9px 11px; border: 1.5px solid var(--line); border-radius: 10px; background: var(--card); min-height: 44px;
}
.fleet-toolbar input:focus, .fleet-toolbar select:focus { outline: none; border-color: var(--gold); }

.bulk-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  background: #f3ece0; border: 1.5px solid var(--gold); border-radius: 12px; padding: 10px 12px; margin-bottom: 12px;
}
.bulk-bar #fleetSelCount { font-weight: 700; color: var(--brown); }
.bulk-mini { padding: 6px 8px; border: 1.5px solid var(--line); border-radius: 8px; min-height: 34px; background: #fff; }

.fleet-table-wrap { overflow-x: auto; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow-soft); }
.fleet-table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 680px; }
.fleet-table th, .fleet-table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
.fleet-table th { background: #f3ece0; color: var(--muted); font-weight: 600; font-size: 13px; position: sticky; top: 0; }
.fleet-table td.ck, .fleet-table th.ck { width: 34px; text-align: center; }
.fleet-table .mono { font-family: ui-monospace, monospace; color: var(--muted); }
.fleet-table input[type="checkbox"] { width: 18px; height: 18px; }

.fleet-pager { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 14px; }
.pager-info { font-size: 14px; color: var(--muted); }

@media (min-width: 720px) {
  .fleet-kpis { grid-template-columns: repeat(4, 1fr); }
}

/* ---------- AI 設定問卷 ---------- */
.quiz-entry { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.quiz-entry-status { font-size: 14px; color: var(--teal); }
.quiz-modal { max-width: 460px; }
.quiz-intro { font-size: 14px; color: var(--muted); line-height: 1.6; margin: 0 0 6px; }
.quiz-section { border-top: 1px dashed var(--line); padding-top: 12px; margin-top: 12px; }
.quiz-sec-title { font-size: 15px; font-weight: 700; color: var(--gold-deep); margin-bottom: 10px; }
.quiz-q { margin-bottom: 14px; }
.quiz-label { font-size: 15px; color: var(--brown); margin-bottom: 8px; }
.quiz-opts { display: flex; flex-direction: column; gap: 6px; }
.quiz-opt { display: flex; align-items: center; gap: 8px; font-size: 15px; color: var(--text); padding: 4px 0; cursor: pointer; }
.quiz-opt input { width: 18px; height: 18px; }
.quiz-text { width: 100%; padding: 9px 11px; border: 1.5px solid var(--line); border-radius: 8px; }

/* 系統設定：問卷狀態 + 多選 */
.cc-pick { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.cc-pick input { width: 18px; height: 18px; }
.cc-qrow { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.q-badge { font-size: 12px; padding: 2px 9px; border-radius: 12px; background: #eee3cf; color: var(--muted); }
.q-badge.filled { background: rgba(74, 122, 109, 0.15); color: var(--teal); }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(28, 26, 23, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
  animation: fadeIn 0.2s ease;
}
.modal {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  width: 100%;
  max-width: 400px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal h3 { margin: 0 0 14px; color: var(--brown); }
.modal form { display: flex; flex-direction: column; }
.modal label { font-size: 14px; color: var(--muted); margin: 10px 0 4px; }
.modal input, .modal select {
  padding: 11px 13px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: #fff;
  min-height: 44px;
}
.modal input:focus, .modal select:focus { outline: none; border-color: var(--gold); }
.muted { color: var(--muted); font-size: 12px; }
.modal-error { color: var(--emerg); font-size: 14px; min-height: 18px; margin-top: 8px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }

/* ---------- SOS 緊急求助 ---------- */
.sos-block { margin-bottom: 14px; }
.sos-btn { width: 100%; display: flex; align-items: center; gap: 14px; border: none; cursor: pointer;
  background: linear-gradient(135deg, #d0574c, #b8433a); color: #fff; border-radius: var(--radius);
  padding: 18px 20px; box-shadow: 0 8px 22px rgba(198, 90, 79, 0.32); text-align: left; }
.sos-btn:active { transform: scale(0.98); }
.sos-ico { font-size: 34px; line-height: 1; }
.sos-txt { font-size: 22px; font-weight: 800; display: flex; flex-direction: column; }
.sos-txt small { font-size: 13px; font-weight: 500; opacity: 0.92; margin-top: 3px; }
.sos-status { font-size: 15px; margin-top: 8px; color: var(--text); min-height: 4px; }
.sos-status .sos-ok { color: var(--teal); font-weight: 600; }
.ghost-btn.danger { color: var(--emerg); border-color: rgba(198, 90, 79, 0.4); }

/* ---------- 心情打卡 ---------- */
.mood-seg { display: flex; gap: 8px; }
.mood-seg button { flex: 1; min-height: 52px; border: 1.5px solid var(--line); background: var(--card);
  border-radius: 14px; font-size: 16px; font-weight: 600; color: var(--text); cursor: pointer; }
.mood-seg button.active { border-color: var(--gold); background: rgba(200, 161, 90, 0.14); }
.mood-reply { font-size: 15px; color: var(--teal); margin-top: 10px; min-height: 4px; line-height: 1.6; }

/* ---------- 今日藥盒 ---------- */
.med-adherence { font-size: 13px; font-weight: 700; padding: 3px 10px; border-radius: 10px; }
.med-adherence.good { color: var(--teal); background: rgba(74, 122, 109, 0.12); }
.med-adherence.warn { color: var(--warn); background: rgba(217, 138, 61, 0.14); }
.med-adherence.bad { color: var(--emerg); background: rgba(198, 90, 79, 0.14); }
.med-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.med-row:last-child { border-bottom: none; }
.med-time { font-size: 17px; font-weight: 800; color: var(--brown); width: 52px; flex-shrink: 0; }
.med-info { flex: 1; min-width: 0; }
.med-name { font-size: 16px; color: var(--text); font-weight: 600; }
.med-note { font-size: 13px; color: var(--muted); margin-top: 2px; }
.med-row.missed .med-time { color: var(--emerg); }
.med-row.taken { opacity: 0.6; }
.med-pill { font-size: 13px; font-weight: 600; white-space: nowrap; }
.med-pill.taken { color: var(--teal); }
.med-pill.upcoming { color: var(--muted); }
.med-pill.due { color: var(--warn); }
.primary-btn.sm, .ghost-btn.sm { padding: 7px 14px; font-size: 14px; min-height: 38px; }

/* ---------- 關懷通知 / 事件時間線 ---------- */
.events-summary { font-size: 13px; font-weight: 700; padding: 3px 10px; border-radius: 10px; }
.events-summary.good { color: var(--teal); background: rgba(74, 122, 109, 0.12); }
.events-summary.warn { color: var(--warn); background: rgba(217, 138, 61, 0.14); }
.events-summary.bad { color: var(--emerg); background: rgba(198, 90, 79, 0.14); }
.evt-row { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.evt-row:last-child { border-bottom: none; }
.evt-row.resolved { opacity: 0.62; }
.evt-ico { font-size: 22px; flex-shrink: 0; width: 30px; text-align: center; }
.evt-main { flex: 1; min-width: 0; }
.evt-title { font-size: 16px; font-weight: 700; color: var(--brown); display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.evt-row.sev-emergency .evt-title { color: var(--emerg); }
.evt-time { font-size: 12px; font-weight: 500; color: var(--muted); white-space: nowrap; }
.evt-detail { font-size: 14px; color: var(--text); line-height: 1.6; margin: 3px 0 6px; }
.evt-status { font-size: 13px; color: var(--teal); font-weight: 600; }
.evt-row.sev-emergency { border-left: 3px solid var(--emerg); padding-left: 10px; margin-left: -13px; }

/* ---------- 本週長康觀察 週報 ---------- */
.rep-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }
.rep-stat { background: rgba(200, 161, 90, 0.1); border-radius: 12px; padding: 10px 4px; text-align: center; }
.rep-val { font-size: 20px; font-weight: 800; color: var(--brown); line-height: 1.1; }
.rep-val small { font-size: 11px; color: var(--muted); font-weight: 600; margin-left: 1px; }
.rep-lbl { font-size: 12px; color: var(--muted); margin-top: 3px; }
.rep-stats.rep-mental { grid-template-columns: repeat(3, 1fr); margin-top: -4px; }
.rep-stats.rep-mental .rep-stat { background: rgba(74,122,109,0.09); }
.rep-narrative { font-size: 16px; color: var(--text); line-height: 1.8; background: var(--cream); border-radius: 12px; padding: 14px 16px; }
.rep-meta { font-size: 12px; color: var(--muted); margin-top: 8px; }

/* ---------- 職員警報事件台 ---------- */
.alert-panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 18px; box-shadow: var(--shadow); }
.alert-panel.has-emergency { border-color: rgba(198, 90, 79, 0.5); box-shadow: 0 6px 20px rgba(198, 90, 79, 0.18); }
.alert-row { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.alert-row:last-child { border-bottom: none; }
.alert-ico { font-size: 24px; flex-shrink: 0; }
.alert-main { flex: 1; min-width: 0; }
.alert-title { font-size: 15px; font-weight: 700; color: var(--brown); display: flex; gap: 8px; flex-wrap: wrap; align-items: baseline; }
.alert-row.sev-emergency .alert-title { color: var(--emerg); }
.alert-detail { font-size: 13px; color: var(--muted); line-height: 1.5; margin-top: 2px; }
.alert-act { display: flex; gap: 6px; flex-shrink: 0; }

/* ---------- 手錶推送提示（夠鐘食藥）---------- */
.watch-push { background: linear-gradient(135deg, #2f5d54, #244c44); color: #fff; border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 14px; box-shadow: 0 8px 22px rgba(47, 93, 84, 0.3); animation: wpIn 0.35s ease; }
@keyframes wpIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
.wp-head { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 700; opacity: 0.95; margin-bottom: 8px; }
.wp-head .wp-ico { font-size: 18px; }
.wp-head .wp-time { margin-left: auto; font-size: 13px; opacity: 0.85; }
.wp-med { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.wp-name { flex: 1; font-size: 17px; font-weight: 700; }
.wp-take { border: none; background: #fff; color: #244c44; font-weight: 800; font-size: 15px; padding: 8px 16px; border-radius: 12px; cursor: pointer; min-height: 40px; }
.wp-take:active { transform: scale(0.96); }

/* ---------- 首頁功能開關 ---------- */
.settings-hint { font-size: 13px; color: var(--muted); line-height: 1.6; margin: 0 0 12px; }
.feature-toggles { display: flex; flex-direction: column; gap: 4px; }
.ftoggle { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.ftoggle:last-child { border-bottom: none; }
.ft-ico { font-size: 22px; flex-shrink: 0; }
.ft-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ft-name { font-size: 16px; font-weight: 600; color: var(--text); }
.ft-desc { font-size: 12px; color: var(--muted); line-height: 1.5; margin-top: 2px; }
.ftoggle input { position: absolute; opacity: 0; pointer-events: none; }
.ft-switch { flex-shrink: 0; width: 46px; height: 27px; border-radius: 14px; background: #d8cdb8; position: relative; transition: background 0.2s; }
.ft-switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 21px; height: 21px; border-radius: 50%; background: #fff; transition: transform 0.2s; box-shadow: 0 1px 3px rgba(0,0,0,0.2); }
.ftoggle input:checked ~ .ft-switch { background: var(--teal); }
.ftoggle input:checked ~ .ft-switch::after { transform: translateX(19px); }

/* ---------- 服藥時間設定 ---------- */
.sched-item { border: 1px solid var(--line); border-radius: 14px; padding: 12px; margin-bottom: 10px; background: var(--card); }
.sched-row1 { display: flex; gap: 8px; align-items: center; }
.sched-name { flex: 2; }
.sched-dose { flex: 1; min-width: 0; }
.sched-item input { border: 1.5px solid var(--line); border-radius: 10px; padding: 9px 10px; font-size: 15px; color: var(--text); background: #fff; }
.sched-item input:focus { outline: none; border-color: var(--gold); }
.sched-del { flex-shrink: 0; border: none; background: rgba(198,90,79,0.1); color: var(--emerg); width: 34px; height: 34px; border-radius: 9px; cursor: pointer; font-size: 15px; }
.sched-times { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 10px 0; }
.sched-lbl { font-size: 13px; color: var(--muted); }
.sched-time { display: inline-flex; align-items: center; gap: 2px; background: rgba(200,161,90,0.12); border-radius: 10px; padding: 2px 2px 2px 6px; }
.sched-time input { border: none !important; background: transparent; padding: 6px 2px; font-size: 15px; font-weight: 600; }
.sched-time-del { border: none; background: transparent; color: var(--muted); cursor: pointer; font-size: 13px; padding: 2px 4px; }
.sched-time-add { border: 1px dashed var(--gold); background: transparent; color: var(--gold-deep); border-radius: 10px; padding: 6px 10px; font-size: 13px; cursor: pointer; }
.sched-note { width: 100%; margin-top: 4px; }
.sched-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }

/* ---------- 右上角設定齒輪 + 設定面板 ---------- */
.icon-btn { background: transparent; border: none; font-size: 20px; cursor: pointer; padding: 6px; line-height: 1; border-radius: 10px; color: inherit; }
.icon-btn:active { transform: scale(0.92); }
.settings-modal { max-width: 460px; }
.settings-modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.settings-modal-head h3 { margin: 0; color: var(--brown); }
.settings-account { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--cream); border-radius: 14px; padding: 14px 16px; margin-bottom: 16px; }
.sa-name { font-size: 17px; font-weight: 700; color: var(--brown); }
.sa-role { font-size: 13px; color: var(--muted); margin-top: 2px; }
.settings-section { margin-bottom: 18px; }
.settings-section h4 { margin: 0 0 10px; font-size: 15px; color: var(--brown); }
.settings-section:last-child { margin-bottom: 0; }

/* ---------- 今日健康評分 ---------- */
.score-card { display: flex; align-items: center; gap: 16px; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; margin-bottom: 14px; box-shadow: var(--shadow); }
.score-card.band-great { background: linear-gradient(135deg, #fdf7e8, #eef6ef); }
.sc-left { flex-shrink: 0; }
.sc-right { flex: 1; min-width: 0; }
.sc-title { font-size: 13px; color: var(--muted); }
.sc-label { font-size: 22px; font-weight: 800; color: var(--brown); margin: 2px 0; }
.sc-tone { font-size: 14px; color: var(--text); line-height: 1.5; }
.sc-tips { margin-top: 6px; display: flex; flex-direction: column; gap: 2px; }
.sc-tip { font-size: 13px; color: var(--gold-deep); }
.score-ring .sg-track { fill: none; stroke: var(--line); stroke-width: 9; }
.score-ring .sg-fill { fill: none; stroke-width: 9; stroke-linecap: round; transition: stroke-dashoffset 0.6s; }
.score-ring.band-great .sg-fill { stroke: var(--teal); }
.score-ring.band-good .sg-fill { stroke: var(--teal-soft); }
.score-ring.band-fair .sg-fill { stroke: var(--warn); }
.score-ring.band-watch .sg-fill { stroke: var(--emerg); }
.sg-num { font-size: 30px; font-weight: 800; fill: var(--brown); }
.sg-unit { font-size: 12px; fill: var(--muted); }

/* ---------- 家人一起行（Together）---------- */
.together-pct { font-size: 14px; font-weight: 800; color: var(--teal); background: rgba(74,122,109,0.12); padding: 3px 10px; border-radius: 10px; }
.tg-summary { margin-bottom: 12px; }
.tg-total { font-size: 14px; color: var(--text); margin-bottom: 6px; }
.tg-total b { font-size: 18px; color: var(--brown); }
.tg-track { height: 10px; background: var(--line); border-radius: 6px; overflow: hidden; }
.tg-progress { height: 100%; background: linear-gradient(90deg, var(--teal-soft), var(--teal)); border-radius: 6px; }
.tg-bars { display: flex; align-items: flex-end; gap: 8px; height: 66px; padding: 0 2px; }
.tg-bar { flex: 1; display: flex; align-items: flex-end; justify-content: center; }
.tg-fill { width: 60%; background: var(--gold); border-radius: 4px 4px 0 0; opacity: 0.55; }
.tg-fill.today { background: var(--teal); opacity: 1; }
.tg-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; }
.tg-today { font-size: 14px; color: var(--muted); }

/* ---------- 提醒設定 ---------- */
.rem-type { border: 1.5px solid var(--line); border-radius: 10px; padding: 9px 8px; font-size: 14px; background: #fff; color: var(--text); flex-shrink: 0; }
.rem-label { flex: 1; min-width: 0; }
.rem-row2 { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 4px; }
.rem-note { flex: 1; min-width: 120px; }
.rem-date-lbl { font-size: 13px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.rem-date-lbl input, .rem-note { border: 1.5px solid var(--line); border-radius: 10px; padding: 9px 10px; font-size: 15px; color: var(--text); background: #fff; }
.rem-time-add { border: 1px dashed var(--gold); background: transparent; color: var(--gold-deep); border-radius: 10px; padding: 6px 10px; font-size: 13px; cursor: pointer; }
.rem-time-del { border: none; background: transparent; color: var(--muted); cursor: pointer; font-size: 13px; padding: 2px 4px; }

/* ---------- 睡眠報告 ---------- */
.sleep-report { background: linear-gradient(135deg, #3a3566, #2b2750); color: #fff; border-radius: 14px; padding: 16px; margin: 14px 0; }
.sleep-report h4 { margin: 0 0 12px; font-size: 15px; }
.sr-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.sr-stat { background: rgba(255,255,255,0.1); border-radius: 12px; padding: 10px 4px; text-align: center; }
.sr-val { font-size: 20px; font-weight: 800; }
.sr-val small { font-size: 11px; opacity: 0.8; font-weight: 600; margin-left: 1px; }
.sr-lbl { font-size: 12px; opacity: 0.8; margin-top: 3px; }
.sr-advice { font-size: 14px; line-height: 1.6; margin-top: 12px; opacity: 0.95; }

/* ---------- E1：同長康傾偈大入口 ---------- */
.chat-cta { width: 100%; display: flex; align-items: center; gap: 14px; cursor: pointer; text-align: left;
  background: linear-gradient(135deg, #4a7a6d, #3c655a); color: #fff; border: none; border-radius: var(--radius);
  padding: 18px 20px; margin-bottom: 14px; box-shadow: 0 8px 22px rgba(74, 122, 109, 0.28); min-height: 64px; }
.chat-cta:active { transform: scale(0.99); }
.cc-ico { font-size: 30px; line-height: 1; }
.cc-txt { flex: 1; font-size: 21px; font-weight: 800; display: flex; flex-direction: column; }
.cc-txt small { font-size: 13px; font-weight: 500; opacity: 0.9; margin-top: 3px; }
.cc-arrow { font-size: 30px; opacity: 0.85; }

/* ---------- E1：長者「更多」收合掣 ---------- */
.elder-more-btn { width: 100%; min-height: 48px; border: 1.5px dashed var(--line); background: transparent;
  color: var(--gold-deep); font-size: 15px; font-weight: 600; border-radius: 14px; padding: 12px; cursor: pointer; margin-bottom: 12px; }
.elder-more-btn:active { background: rgba(200, 161, 90, 0.08); }

/* ---------- E2：SOS 固定底部安全區 ---------- */
.sos-fixed { position: fixed; left: 0; right: 0; bottom: 72px; z-index: 950;
  max-width: 460px; margin: 0 auto; padding: 0 14px; }
.sos-fixed .sos-btn { box-shadow: 0 10px 26px rgba(198, 90, 79, 0.4); }
#tab-home.with-sos { padding-bottom: 78px; } /* 唔好俾固定 SOS 遮住最底內容 */

/* SOS 二次確認大掣 sheet */
.sos-confirm .sos-sheet { background: var(--card); border-radius: 22px; padding: 26px 22px; max-width: 380px;
  width: calc(100% - 40px); text-align: center; box-shadow: 0 20px 50px rgba(0,0,0,0.3); }
.ss-ico { font-size: 54px; }
.ss-title { font-size: 24px; font-weight: 800; color: var(--brown); margin: 8px 0 6px; }
.ss-sub { font-size: 16px; color: var(--muted); line-height: 1.6; margin-bottom: 8px; }
.ss-status { font-size: 15px; min-height: 4px; margin-bottom: 8px; }
.ss-status .sos-ok { color: var(--teal); font-weight: 600; }
.ss-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.ss-confirm { order: 1; background: linear-gradient(135deg, #d0574c, #b8433a); color: #fff; border: none;
  font-size: 20px; font-weight: 800; padding: 16px; border-radius: 14px; cursor: pointer; min-height: 56px; }
.ss-cancel { order: 2; background: var(--cream); color: var(--brown); border: 1.5px solid var(--line);
  font-size: 18px; font-weight: 700; padding: 15px; border-radius: 14px; cursor: pointer; min-height: 52px; }

/* ---------- E3：撤回提示 toast ---------- */
.undo-toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: 96px; z-index: 1100;
  background: var(--brown); color: #fff; border-radius: 14px; padding: 12px 16px; display: flex; align-items: center; gap: 14px;
  box-shadow: 0 10px 26px rgba(0,0,0,0.28); max-width: 92vw; animation: wpIn 0.25s ease; }
.undo-toast .undo-btn { background: var(--gold); color: var(--brown-dark); border: none; font-weight: 800;
  font-size: 14px; padding: 8px 12px; border-radius: 10px; cursor: pointer; white-space: nowrap; }

/* ---------- 即時警報 pop-up ---------- */
.alert-pop-wrap { position: fixed; top: 64px; left: 50%; transform: translateX(-50%); z-index: 1400;
  display: flex; flex-direction: column; gap: 8px; width: min(420px, calc(100vw - 24px)); pointer-events: none; }
.alert-pop { display: flex; align-items: center; gap: 10px; pointer-events: auto; cursor: default;
  background: var(--card); border-radius: 14px; padding: 12px 14px; box-shadow: 0 12px 32px rgba(0,0,0,0.25);
  border-left: 5px solid var(--warn); animation: popIn 0.3s ease; }
.alert-pop.sev-emergency { border-left-color: var(--emerg); background: linear-gradient(135deg, #fdf3f1, #fbe9e6); }
.alert-pop.sev-warning { border-left-color: var(--warn); }
.alert-pop.out { opacity: 0; transform: translateY(-8px); transition: all 0.3s; }
.ap-ico { font-size: 24px; flex-shrink: 0; }
.ap-main { flex: 1; min-width: 0; font-size: 14px; color: var(--text); line-height: 1.4; }
.ap-main b { color: var(--brown); }
.alert-pop.sev-emergency .ap-main b { color: var(--emerg); }
.ap-main small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.ap-close { border: none; background: transparent; color: var(--muted); font-size: 14px; cursor: pointer; padding: 4px; flex-shrink: 0; }
@keyframes popIn { from { opacity: 0; transform: translateY(-12px); } to { opacity: 1; transform: none; } }

/* ---------- KinFit 真機 badge ---------- */
.live-badge { display: inline-block; font-size: 11px; font-weight: 800; color: #2e7d4f;
  background: rgba(46,125,79,0.12); padding: 2px 8px; border-radius: 9px; white-space: nowrap; }

/* ---------- 情緒健康評估 ---------- */
.emo-updated { font-size: 12px; color: var(--muted); }
.emo-main { display: flex; align-items: center; gap: 16px; }
.emo-left { flex-shrink: 0; }
.emo-right { flex: 1; min-width: 0; }
.emo-ring .eg-track { fill: none; stroke: var(--line); stroke-width: 7; }
.emo-ring .eg-fill { fill: none; stroke-width: 7; stroke-linecap: round; }
.emo-ring.band-good .eg-fill { stroke: var(--teal); }
.emo-ring.band-warn .eg-fill { stroke: var(--warn); }
.emo-ring.band-bad .eg-fill { stroke: var(--emerg); }
.emo-ring.band-muted .eg-fill { stroke: var(--line); }
.eg-num { font-size: 22px; font-weight: 800; fill: var(--brown); }
.emo-level { font-size: 18px; font-weight: 800; }
.emo-level.lv-good { color: var(--teal); } .emo-level.lv-warn { color: var(--warn); } .emo-level.lv-bad { color: var(--emerg); } .emo-level.lv-muted { color: var(--muted); }
.emo-summary { font-size: 15px; color: var(--text); line-height: 1.6; margin: 4px 0 6px; }
.emo-signals { display: flex; flex-wrap: wrap; gap: 6px; }
.emo-sig { font-size: 12px; background: rgba(198,90,79,0.1); color: var(--emerg); padding: 2px 9px; border-radius: 9px; font-weight: 600; }
.emo-foot { font-size: 12px; margin-top: 10px; }
.emotion-block .settings-hint { margin-bottom: 12px; }
#emoAnalyzeBtn { margin-top: 12px; }
.emo-pill { font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: 10px; }
.emo-pill.lv-good { color: var(--teal); background: rgba(74,122,109,0.12); }
.emo-pill.lv-watch { color: var(--warn); background: rgba(217,138,61,0.14); }
.emo-pill.lv-concern { color: var(--emerg); background: rgba(198,90,79,0.14); }

/* ---------- 精神健康三維評估 ---------- */
.mh-dims { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.mh-dim { text-align: center; background: var(--cream); border-radius: 14px; padding: 12px 4px 10px; }
.mh-dim-label { font-size: 14px; font-weight: 700; color: var(--brown); margin-top: 4px; }
.mh-dim-level { font-size: 12px; font-weight: 600; margin-top: 1px; }
.mh-dim-level.lv-good { color: var(--teal); } .mh-dim-level.lv-warn { color: var(--warn); }
.mh-dim-level.lv-bad { color: var(--emerg); } .mh-dim-level.lv-muted { color: var(--muted); }
.mh-risk-banner { background: linear-gradient(135deg, #fdf0ee, #fbe3df); border: 1.5px solid var(--emerg);
  border-radius: 12px; padding: 12px 14px; font-size: 15px; font-weight: 700; color: var(--emerg);
  line-height: 1.6; margin-bottom: 12px; }
.mh-risk-banner small { font-weight: 500; color: var(--text); font-size: 12px; }
.mh-evidence { margin-top: 10px; background: var(--cream); border-radius: 12px; padding: 8px 12px; }
.mh-evidence summary { font-size: 14px; font-weight: 600; color: var(--gold-deep); cursor: pointer; padding: 4px 0; }
.mh-evid { padding: 8px 0; border-bottom: 1px solid var(--line); }
.mh-evid:last-child { border-bottom: none; }
.mh-evid-term { display: inline-block; background: rgba(198,90,79,0.12); color: var(--emerg); font-size: 12px;
  font-weight: 700; padding: 1px 8px; border-radius: 8px; margin-right: 6px; }
.mh-evid-sub { font-size: 12px; color: var(--muted); }
.mh-evid-text { font-size: 13px; color: var(--text); margin-top: 3px; line-height: 1.5; }
.emo-disclaimer { font-size: 11px; color: var(--muted); margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--line); }

/* ---------- 聯網搜索：搵緊 / 已聯網 ---------- */
.bubble .searching { font-size: 15px; color: var(--teal); font-weight: 600; }
.searched-tag { display: inline-block; font-size: 11px; font-weight: 700; color: var(--teal);
  background: rgba(74,122,109,0.12); padding: 1px 7px; border-radius: 8px; margin-left: 6px; vertical-align: middle; }

/* ---------- 時效事件記憶（會忘記）---------- */
.mem-events { margin-top: 14px; }
.mem-head { font-size: 14px; font-weight: 700; color: var(--brown); margin-bottom: 8px; display: flex; align-items: baseline; gap: 8px; }
.mem-hint { font-size: 12px; font-weight: 400; color: var(--muted); }
.mem-item { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.mem-item:last-child { border-bottom: none; }
.mem-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line); flex-shrink: 0; }
.mem-dot.on { background: var(--teal); }
.mem-text { flex: 1; font-size: 15px; color: var(--text); }
.mem-date { font-size: 13px; color: var(--teal); font-weight: 600; }
.mem-item.gone { opacity: 0.45; }
.mem-item.gone .mem-text { text-decoration: line-through; }
.mem-item.gone .mem-date { color: var(--muted); font-weight: 400; }
.mem-empty { font-size: 14px; color: var(--muted); padding: 6px 0; }

/* ---------- 長期記憶：更新 / 一鍵示範 ---------- */
.digest-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 12px; }
.digest-text.just-learned { border-left: 3px solid var(--teal); padding-left: 12px; background: rgba(74,122,109,0.06); border-radius: 8px; animation: wpIn 0.4s ease; }
.learned-badge { display: inline-block; background: var(--teal); color: #fff; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 8px; margin-right: 6px; }
.mem-done { color: var(--teal); font-weight: 600; line-height: 1.6; }

/* ---------- S2：批量操作確認 modal ---------- */
.bulk-modal { max-width: 440px; }
.bulk-msg { font-size: 15px; color: var(--text); line-height: 1.6; margin: 4px 0 10px; }
.bulk-targets { max-height: 200px; overflow-y: auto; background: var(--cream); border-radius: 12px; padding: 8px 4px; }
.bulk-targets ul { margin: 0; padding: 0 0 0 6px; list-style: none; }
.bulk-targets li { font-size: 14px; color: var(--text); padding: 5px 8px; border-bottom: 1px solid var(--line); }
.bulk-targets li:last-child { border-bottom: none; }

/* ---------- S1：職員後台異常優先（正常弱化、異常跳出）---------- */
.report-card.muted { opacity: 0.62; }
.report-card.muted .num { color: var(--muted); }
.report-card.stat-alert { background: linear-gradient(135deg, #f6d9d5, #efc4bd); border: 1.5px solid var(--emerg); opacity: 1; }
.report-card.stat-alert .num { color: var(--emerg); font-size: 30px; }

/* ---------- F1：私隱透明度 ---------- */
.privacy-note { background: rgba(74, 122, 109, 0.07); border: 1px solid rgba(74, 122, 109, 0.2); }
.pn-head { font-size: 15px; font-weight: 700; color: var(--teal); margin-bottom: 8px; }
.pn-body p { margin: 0 0 8px; font-size: 14px; color: var(--text); line-height: 1.6; }
.pn-shared, .mp-shared { list-style: none; padding: 0; margin: 8px 0; display: flex; flex-direction: column; gap: 6px; }
.pn-shared li, .mp-shared li { font-size: 14px; color: var(--text); }
.pn-elder, .mp-note { font-size: 13px; color: var(--muted); background: var(--cream); border-radius: 10px; padding: 10px 12px; line-height: 1.6; }
.my-privacy-body .mp-line { font-size: 15px; color: var(--text); margin: 0 0 8px; line-height: 1.6; }
.my-privacy-body b { color: var(--brown); }

/* ---------- G1：按鈕 loading spinner ---------- */
.btn-spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff; border-radius: 50%; animation: spin 0.7s linear infinite; vertical-align: -2px; margin-right: 4px; }
.primary-btn.loading { opacity: 0.85; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- G2：skeleton 骨架屏 ---------- */
.skeleton { border-radius: 10px; background: linear-gradient(90deg, rgba(200,161,90,0.10) 25%, rgba(200,161,90,0.20) 37%, rgba(200,161,90,0.10) 63%);
  background-size: 400% 100%; animation: shimmer 1.3s ease infinite; }
.sk-line { height: 14px; margin: 8px 0; }
.sk-line.w60 { width: 60%; } .sk-line.w80 { width: 80%; } .sk-line.w40 { width: 40%; }
.sk-card { height: 90px; margin: 10px 0; border-radius: 14px; }
.sk-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sk-tile { height: 96px; border-radius: 14px; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

/* ---------- 桌面：稍為放大留白，長者/家人維持窄欄手機感 ---------- */
@media (min-width: 720px) {
  .screen#screen-staff .live-cards { grid-template-columns: 1fr 1fr; }
  .report-cards { grid-template-columns: repeat(4, 1fr); }
}
