/* ============ 全局基礎 ============ */
:root {
  --bg-1: #eef1f6;
  --bg-2: #dde3ec;
  --surface: #ecf0f5;
  --text: #3a4252;
  --text-soft: #7b8497;
  --accent: #8aa5d6;
  --accent-2: #b9a3d6;
  --warm: #f5d6c0;
  --shadow-dark: rgba(163, 177, 198, .55);
  --shadow-light: rgba(255, 255, 255, .95);
  --glass: rgba(255, 255, 255, .45);
  --glass-border: rgba(255, 255, 255, .7);

  /* 深灰黑漸層 — 用在主要動作按鈕、active 狀態,提高反差 */
  --btn-dark: linear-gradient(140deg, #1a1f2e, #3a4256);
  --btn-dark-hover: linear-gradient(140deg, #0f131e, #2c3346);
  --btn-dark-vert: linear-gradient(180deg, #1a1f2e, #3a4256);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  background-repeat: repeat;
  background-size: cover;
  background-attachment: fixed;
  height: 100%;
  background:
    radial-gradient(1100px 700px at 12% -10%, #ffe9d6 0%, transparent 55%),
    radial-gradient(900px 700px at 110% 20%, #d8e4ff 0%, transparent 55%),
    radial-gradient(800px 600px at 50% 110%, #e4d8ff 0%, transparent 55%),
    linear-gradient(180deg, var(--bg-1), var(--bg-2));
}

/* ── 鎖死 html / body 的 scroll ──
   過去 #sleeplog-summary 呼叫 scrollIntoView 會把 body 推下,
   切換 screen 後 body.scrollTop 殘留 → 所有 screen 看起來都上移。
   .screen 是 position:absolute inset:0 相對於 #app(position:relative),
   body 一捲 → #app 跟著移動 → 所有 .screen 看起來都被推。
   所以全域鎖死,scroll 一律交給有 overflow-y:auto 的 .screen 自己負責。 */
html, body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;            /* iOS 不要 bounce */
  -webkit-overflow-scrolling: auto;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "PingFang TC", "Noto Sans TC", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  color: var(--text);
  background:
    radial-gradient(1100px 700px at 12% -10%, #ffe9d6 0%, transparent 55%),
    radial-gradient(900px 700px at 110% 20%, #d8e4ff 0%, transparent 55%),
    radial-gradient(800px 600px at 50% 110%, #e4d8ff 0%, transparent 55%),
    linear-gradient(180deg, var(--bg-1), var(--bg-2));
  background-repeat: no-repeat;
  background-attachment: fixed;
  user-select: none;
  -webkit-user-select: none;
}

/* 自然光投影 */
body::before {
  /* content: ""; */
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(115deg, transparent 35%, rgba(255, 255, 255, .35) 42%, transparent 50%),
    radial-gradient(160px 480px at 78% 18%, rgba(255, 255, 255, .25), transparent 60%);
  mix-blend-mode: screen;
}

body::after {
  /* content: ""; */
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .18;
  background-image:
    linear-gradient(transparent 0 96%, rgba(120, 130, 160, .5) 96% 100%),
    linear-gradient(90deg, transparent 0 96%, rgba(120, 130, 160, .5) 96% 100%);
  background-size: 220px 220px;
  transform: skewY(-6deg);
  -webkit-mask: radial-gradient(600px 400px at 80% 10%, #000 0%, transparent 70%);
  mask: radial-gradient(600px 400px at 80% 10%, #000 0%, transparent 70%);
}

/* ============ 視窗容器 ============ */
#app {
  position: relative;
  height: 100vh;
  width: 100vw;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  overflow: hidden;
  /* 把 iOS 狀態列(以及瀏海/動態島)安全區留給內容,
     讓 body 的漸層仍能延伸到螢幕最頂端,避免狀態列下方有色塊斷層 */
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

.screen {
  width: 100%;
  height: 100%;
  position: absolute;
  inset: 0;
  /* v1.0.2+42:base 規則只留 16px + safe-area floor,網頁版桌面用就不會
     在上方留 60px 空白(原本是錯誤假設「style.css 只在 Flutter 用」,實際
     兩邊共用)。Flutter iOS WKWebView 內仍透過 @supports + .in-flutter-app
     的兩個 override 拉回 60px floor 給狀態列 / 動態島留空間。 */
  padding: max(16px, calc(16px + env(safe-area-inset-top, 0px))) 24px max(20px, calc(16px + env(safe-area-inset-bottom, 0px)));
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  opacity: 0;
  transform: translateY(14px);
  pointer-events: none;
  transition: opacity .45s ease, transform .45s ease;
}

.screen.active {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* 個人設定頁內容較高(包含推薦碼、危險區),需要可滾動 */
#screen-settings.active {
  overflow-y: auto;
}
/* 結算頁 / 助眠錄音頁可能比視窗高,要自己滾動(body 已鎖) */
#screen-sleeplog.active,
#screen-postsleep.active {
  overflow-y: auto;
}
/* 音樂列表頁底部加了 upgrade-cta-card,內容比視窗高 → 必須自己滾動。
   v1.0.1+15 加入。 */
#screen-musiclist.active {
  overflow-y: scroll;
  -webkit-overflow-scrolling: touch;
}

/* Pre-prompt 授權前說明頁(畫面 2)— hero + 3 項 prompt list + info banner + 2 顆按鈕
   內容偏多,在小螢幕上會超出 viewport,啟用滾動避免按鈕被截掉。 */
#screen-health-connect.active {
  overflow-y: scroll;
}

/* 主面板 (玻璃質感) */
.panel {
  width: min(420px, 100%);
  background: var(--glass);
  backdrop-filter: blur(22px) saturate(140%);
  -webkit-backdrop-filter: blur(22px) saturate(140%);
  border: 1px solid var(--glass-border);
  border-radius: 34px;
  padding: 8px 24px 26px;
  margin-bottom: 16px;
  box-shadow:
    18px 18px 40px var(--shadow-dark),
    -14px -14px 36px var(--shadow-light),
    inset 0 1px 0 rgba(255, 255, 255, .6);
}

/* AI 教練觀察(Premium 訂閱專屬) — 個人數據第一塊 panel 上方
   採用更柔和的圓角 + 漸層 + 細邊框,跟下方主 panel 視覺有區隔,
   暗示「這是 AI 給的觀察」而不是冷硬的數據。 */
.ai-summary-panel {
  width: min(420px, 100%);
  margin: 4px auto 14px;
  padding: 14px 18px 16px;
  border-radius: 22px;
  background: linear-gradient(135deg,
    rgba(136, 220, 235, 0.18),
    rgba(77, 158, 204, 0.10));
  border: 1px solid rgba(136, 220, 235, 0.35);
  font-size: 14.5px;
  line-height: 1.65;
  color: var(--text);
  box-shadow:
    0 8px 24px rgba(77, 158, 204, 0.10),
    inset 0 1px 0 rgba(255, 255, 255, 0.5);
  position: relative;
  letter-spacing: 0.2px;
}
.ai-summary-panel::before {
  content: '✦ AI 教練觀察';
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: #2f7ba8;
  margin-bottom: 8px;
  letter-spacing: 1px;
  text-transform: none;
  opacity: 0.85;
}
.ai-summary-panel.loading {
  opacity: 0.7;
  font-style: italic;
}
.ai-summary-panel.loading::after {
  content: '…';
  display: inline-block;
  animation: ai-summary-dot 1.2s infinite;
}
@keyframes ai-summary-dot {
  0%, 20%   { opacity: 0.2; }
  50%       { opacity: 1; }
  80%, 100% { opacity: 0.2; }
}
.ai-summary-panel.error {
  opacity: 0.5;
  font-size: 13px;
}

/* 額度用完狀態 — 訪客 3 次 / 免費 7 次跑完之後 */
.ai-summary-panel.quota-exhausted {
  background: linear-gradient(135deg,
    rgba(245, 158, 11, 0.12),
    rgba(245, 158, 11, 0.06));
  border: 1px solid rgba(245, 158, 11, 0.30);
  font-size: 14px;
  line-height: 1.55;
}
.ai-summary-panel.quota-exhausted::before {
  content: '✦ AI 教練觀察 · 額度已用完';
  color: #b45309;
}

/* 品牌頭 */
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  font-weight: 600;
  letter-spacing: .3px;
  border: none;
}

.brand .name {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -.3px;
}

.brand .tag {
  margin-left: auto;
  font-size: 14px;
  color: var(--text-soft);
  font-weight: 500;
  padding: 5px 12px;
  border-radius: 999px;
}

/* Logo 徽章 (放 logo.svg 用) */
.logo-mark {
  width: 42px;
  height: 42px;
  border-radius: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2px;
  flex: none;
}

.logo-mark img {
  width: 100%;
  height: auto;
  display: block;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .25));
}

.logo-mark.lg {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  padding: 11px;
}

/* 主畫面品牌列 */
.brand-mini {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mini .brand-name {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -.3px;
  color: var(--text);
}

.greeting-row {
  width: min(420px, 100%);
  font-size: 17px;
  color: var(--text-soft);
  padding: 2px 6px;
  margin-bottom: 14px;
  letter-spacing: -.2px;
}

.greeting-row b {
  color: var(--text);
  font-weight: 700;
}

/* 一般輸入框 (微凹) */
.field {
  width: 100%;
  height: 56px;
  border: none;
  outline: none;
  border-radius: 18px;
  background: var(--surface);
  padding: 0 18px;
  font-size: 17px;
  color: var(--text);
  box-shadow:
    inset 5px 5px 10px var(--shadow-dark),
    inset -5px -5px 10px var(--shadow-light);
  margin-bottom: 14px;
  font-family: inherit;
}

.field::placeholder {
  color: #a8b1c2;
}

/* 主要按鈕 (浮凸) */
.btn {
  width: 100%;
  height: 56px;
  border: none;
  cursor: pointer;
  border-radius: 18px;
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  font-size: 17px;
  letter-spacing: .3px;
  box-shadow:
    6px 6px 14px var(--shadow-dark),
    -6px -6px 14px var(--shadow-light);
  transition: transform .12s ease, box-shadow .2s ease;
  font-family: inherit;
}

.btn:active {
  box-shadow:
    inset 5px 5px 10px var(--shadow-dark),
    inset -5px -5px 10px var(--shadow-light);
  transform: translateY(1px);
}

.btn.primary {
  background: var(--btn-dark);
  color: #fff;
  box-shadow:
    6px 6px 14px var(--shadow-dark),
    -6px -6px 14px var(--shadow-light),
    inset 0 1px 0 rgba(255, 255, 255, .12);
}
.btn.primary:hover { background: var(--btn-dark-hover); }

.btn.ghost {
  background: transparent;
  box-shadow: none;
  color: var(--text-soft);
  height: 56px;
  font-weight: 500;
}

/* ============ 登入頁 ============ */
#screen-auth {
  /* 註冊頁有多欄位(含 genre chips),允許滑動避免內容被切掉 */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
#screen-auth .panel {
  padding-top: 32px;
  padding-bottom: 30px;
  /* v1.0.1+15:登入頁左上多了一顆「‹ 返回首頁」按鈕,
     panel 整塊往下推 60px,避免 NeuroRest logo 跟返回鈕重疊 */
  margin-top: 60px;
}

/* 喜愛音樂類型 chips(註冊頁) */
.genre-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 6px;
}
.genre-chip {
  padding: 9px 14px;
  border-radius: 999px;
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, .55);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: transform .12s ease, background-color .15s ease, color .15s ease, box-shadow .15s ease;
  -webkit-tap-highlight-color: transparent;
  font-family: inherit;
  white-space: nowrap;
}
.genre-chip:hover {
  background: rgba(255, 255, 255, .85);
}
.genre-chip:active {
  transform: scale(0.96);
}
.genre-chip.selected {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 10px rgba(138, 165, 214, .35);
}

.auth-title {
  font-size: 28px;
  font-weight: 700;
  margin: 6px 0 8px;
  letter-spacing: -.4px;
}

.auth-sub {
  font-size: 16px;
  color: var(--text-soft);
  margin-bottom: 24px;
  line-height: 1.6;
}

.auth-error {
  color: #c97a7a;
  margin: -8px 0 8px 4px;
}

/* ============ 推薦人代碼面板 ============ */
.referrer-panel {
  margin-top: 8px;
  border: 1px solid rgba(107, 109, 196, .25) !important;
  background: linear-gradient(135deg, rgba(232, 230, 248, .55), rgba(255, 255, 255, .35)) !important;
}

.referrer-title {
  font-size: 13px;
  font-weight: 700;
  color: #5d5fb0;
  letter-spacing: 1px;
  margin-bottom: 12px;
}

.referrer-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.referrer-code {
  flex: 1;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 4px;
  text-align: center;
  padding: 12px 8px;
  border-radius: 10px;
  background: rgba(107, 109, 196, .08);
  color: #3a3d8f;
  user-select: all;
}

.btn.btn-mini {
  font-size: 14px;
  width: 72px;
  padding: 8px 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  white-space: nowrap;
}

.btn.btn-mini svg {
  width: 14px;
  height: 14px;
}

.referrer-desc {
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--text-soft);
  margin: 4px 0 0;
}

/* 註冊表單:選填欄位文字提示 */
.field-optional {
  margin-left: 6px;
  font-size: 11.5px;
  font-weight: 400;
  color: var(--text-soft);
  letter-spacing: 0;
}

/* ============ 帳號刪除危險區 (Apple 5.1.1(v)) ============ */
.danger-zone {
  margin-top: 16px;
  border: 1.5px solid rgba(201, 122, 122, .35) !important;
  background: linear-gradient(135deg, rgba(248, 230, 230, .55), rgba(255, 255, 255, .35)) !important;
}

.danger-zone-title {
  font-size: 13px;
  font-weight: 700;
  color: #c97a7a;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.danger-zone-desc {
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--text-soft);
  margin: 0 0 14px;
}

.danger-zone-desc strong {
  color: var(--text);
  font-weight: 600;
}

.btn.danger-btn {
  background: rgba(201, 122, 122, .12);
  color: #b56b6b;
  border: 1.5px solid rgba(201, 122, 122, .4);
  font-weight: 600;
  width: 100%;
  letter-spacing: .3px;
}

.btn.danger-btn:active {
  background: rgba(201, 122, 122, .25);
  color: #884c4c;
}

/* 確認 modal 內的取消按鈕保持中性,僅 confirm 用 danger-btn 強調 */
#delete-modal .row-btns .btn:not(.danger-btn) {
  flex: 0 1 auto;
}

#delete-modal #delete-password {
  margin: 8px 0 4px;
}

/* ============ Apple 健康整合頁 (#screen-health) ============ */
#screen-health {
  overflow-y: scroll;
}

.health-status-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(245, 214, 192, 0.18), rgba(185, 163, 214, 0.14));
  border: 1px solid rgba(255, 255, 255, 0.7);
  margin-bottom: 18px;
}

.health-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.health-logo {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  color: #ff5765;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,.08));
}

.health-state {
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
}

.health-state-sub {
  font-size: 12px;
  color: var(--text-soft);
  margin-top: 2px;
}

.health-section {
  margin-bottom: 16px;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid rgba(255,255,255,.7);
}

.health-section-title {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.health-summary {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
  margin-bottom: 8px;
}

.health-stat {
  text-align: center;
}

.health-stat-num {
  font-size: 22px;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.health-stat-lbl {
  font-size: 11px;
  color: var(--text-soft);
  margin-top: 2px;
}

.health-source-hint {
  font-size: 11px;
  color: var(--text-faint, var(--text-soft));
  text-align: center;
  margin-top: 8px;
  letter-spacing: .2px;
}

.health-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  margin-bottom: 8px;
  cursor: pointer;
}

.health-toggle-text {
  font-size: 13px;
  color: var(--text);
}

.health-toggle-sub {
  font-size: 11px;
  color: var(--text-soft);
  margin-top: 2px;
}

.health-toggle-row input[type="checkbox"] {
  appearance: none;
  width: 38px;
  height: 22px;
  border-radius: 999px;
  background: rgba(120, 135, 165, .25);
  position: relative;
  transition: background .2s ease;
  cursor: pointer;
  flex-shrink: 0;
}

.health-toggle-row input[type="checkbox"]::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: transform .2s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,.15);
}

.health-toggle-row input[type="checkbox"]:checked {
  background: var(--accent);
}

.health-toggle-row input[type="checkbox"]:checked::after {
  transform: translateX(16px);
}

.health-toast {
  margin-top: 10px;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(160, 200, 160, .25);
  color: var(--text);
  font-size: 12px;
  text-align: center;
}

.health-toast.error {
  background: rgba(220, 130, 130, .25);
}

.health-disclaimer {
  margin-top: 18px;
  padding: 0;
  background: none;
  border: none;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text);
}

.health-disclaimer strong {
  display: block;
  margin-bottom: 4px;
  color: var(--text);                 /* 黑色標題 */
}

.health-disclaimer p {
  margin: 4px 0;
  color: var(--text-soft);
}

.health-disclaimer em {
  font-style: normal;
  font-weight: 600;
  color: var(--text);
}

/* 註冊頁的欄位 label(在 input 上方) */
.field-label {
  display: block;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: .4px;
  margin: 12px 4px 4px;
}

.field-label:first-child {
  margin-top: 0;
}

/* 欄位下方的小提示文字 — 跟上方欄位/chips 留 8px 距離,下方 14px 給下個 label 緩衝 */
.field-hint {
  font-size: 16px;
  color: var(--text-soft);
  margin: 8px 4px 14px;
  letter-spacing: .2px;
  line-height: 1.5;
}

/* 註冊頁的「同意條款」checkbox + 說明文字 */
.auth-terms {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 16px;
  line-height: 1.55;
  color: var(--text-soft);
  margin: 4px 4px 20px;
  letter-spacing: .2px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

.auth-terms input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  margin-top: 1px;
  border: 1.5px solid rgba(120, 135, 165, .45);
  border-radius: 5px;
  background: rgba(255, 255, 255, .65);
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
  position: relative;
}

.auth-terms input[type="checkbox"]:hover {
  border-color: var(--accent);
}

.auth-terms input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}

.auth-terms input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 5px;
  width: 5px;
  height: 9px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.auth-terms span { flex: 1; }

.auth-terms a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px dotted var(--accent);
}

.auth-terms a:active {
  opacity: .6;
}

/* 登入 / 註冊兩個模式預設顯示行為由 hidden 屬性控制 */
.auth-mode[hidden] {
  display: none;
}

/* ============ 播放器頁 ============ */
.top-bar {
  width: min(420px, 100%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 6px;
  margin-bottom: 8px;
}

.greeting {
  font-size: 17px;
  color: var(--text-soft);
  letter-spacing: -.2px;
}

.greeting b {
  color: var(--text);
  font-weight: 700;
}

.icon-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: var(--surface);
  box-shadow: 5px 5px 10px var(--shadow-dark), -5px -5px 10px var(--shadow-light);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-soft);
}

.icon-btn:active {
  box-shadow: inset 4px 4px 8px var(--shadow-dark), inset -4px -4px 8px var(--shadow-light);
}

.icon-btn svg {
  width: 24px;
  height: 24px;
}

.top-actions {
  display: flex;
  gap: 10px;
}

/* 唱盤 */
.vinyl-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1/1;
  max-width: 300px;
  margin: 0px auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

.vinyl {
  width: 88%;
  height: 88%;
  border-radius: 50%;
  background: linear-gradient(140deg, #e6ebf3, #d4dbe9);
  box-shadow:
    inset 16px 16px 34px var(--shadow-dark),
    inset -12px -12px 30px var(--shadow-light),
    inset 0 0 0 1px rgba(255, 255, 255, .35);
  position: relative;
  overflow: hidden;
}

.vinyl::before,
.vinyl::after {
  display: none;
  content: none;
}

/* d3 SVG 動態漸層畫布 - 邊緣柔和淡出讓內凹陰影透出 */
.vinyl-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  pointer-events: none;
  z-index: 1;
  -webkit-mask: radial-gradient(circle at 50% 50%, #000 62%, rgba(0, 0, 0, .4) 88%, transparent 100%);
  mask: radial-gradient(circle at 50% 50%, #000 62%, rgba(0, 0, 0, .4) 88%, transparent 100%);
  filter: blur(.4px) saturate(108%);
}

/* 內凹邊緣的柔和暗角 - 強化碗狀深度感 */
.vinyl-rim {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  pointer-events: none;
  z-index: 2;
  background: radial-gradient(circle at 50% 50%, transparent 58%, rgba(110, 120, 150, .22) 100%);
  /* 高光弧線 (碗的內緣反光) */
  box-shadow:
    inset 0 -2px 5px rgba(255, 255, 255, .6),
    inset 0 2px 5px rgba(110, 120, 150, .18);
}

.wave-pulse {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1px solid rgba(138, 165, 214, .35);
  animation: pulse 3.5s ease-out infinite;
  opacity: 0;
}

.wave-pulse.p2 {
  animation-delay: 1.2s;
}

.wave-pulse.p3 {
  animation-delay: 2.4s;
}

.vinyl.playing~.wave-pulse {
  opacity: 1;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes pulse {
  0% {
    transform: scale(.9);
    opacity: .55;
  }

  100% {
    transform: scale(1.18);
    opacity: 0;
  }
}

/* 曲目資訊 */
.track-name {
  font-size: 24px;
  font-weight: 700;
  text-align: center;
  letter-spacing: -.4px;
}

.track-sub {
  font-size: 14px;
  color: var(--text-soft);
  text-align: center;
  margin-top: 6px;
  letter-spacing: .6px;
}

.track-sub .badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  margin-left: 8px;
  font-size: 14px;
  font-weight: 600;
  background: linear-gradient(140deg, #fce7d3, #f5d6c0);
  color: #a06b3f;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .6);
}

.track-sub .badge.locked {
  background: linear-gradient(140deg, #e8e2f1, #d9cfe9);
  color: #6c5f86;
}

/* 進度條 */
.progress {
  margin-top: 16px;
  height: 18px;
  border-radius: 999px;
  background: var(--surface);
  box-shadow: inset 5px 5px 10px var(--shadow-dark), inset -5px -5px 10px var(--shadow-light);
  position: relative;
  overflow: hidden;
  cursor: pointer;
  transition: height .2s ease;
}

.progress:hover {
  height: 22px;
}

.progress>i {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg,
      #ff6b6b 0%, #ff8e72 12%, #ffa559 24%, #ffc75f 36%,
      #f9ca24 48%, #6bcf7f 60%, #4ecdc4 72%, #45b7d1 84%,
      #8e7cc3 96%, #ff6b6b 100%);
  background-size: 200% 100%;
  border-radius: 999px;
  transition: width .1s linear, background .4s ease, box-shadow .4s ease;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .4),
    0 4px 12px rgba(255, 107, 107, .3);
  position: relative;
}

/* 海洋主題：當播放海潮時，整條 bar 改成藍色漸層 */
body.theme-ocean .progress>i {
  background: linear-gradient(90deg,
      #a8dceb 0%, #88c5e8 18%, #5fb3dc 35%, #4fa0c0 52%,
      #3d8bb0 68%, #2d7eaf 84%, #1f6a99 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .45),
    0 4px 12px rgba(45, 126, 175, .35);
}

body.theme-ocean .progress>i::after {
  background: radial-gradient(circle, #ffffff 0%, #a8dceb 60%, transparent 100%) !important;
  box-shadow: 0 0 12px rgba(168, 220, 235, .9), 0 0 4px rgba(255, 255, 255, .7) !important;
}

/* 森林主題：皓月播放時，進度條漸變為苔綠 → 深森林綠 */
body.theme-forest .progress>i {
  background: linear-gradient(90deg,
      #d8e89c 0%, #b5d68a 18%, #88c070 35%, #6ba858 52%,
      #4d8a45 68%, #336b30 84%, #1f4422 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .45),
    0 4px 12px rgba(74, 136, 69, .35);
}

body.theme-forest .progress>i::after {
  background: radial-gradient(circle, #fff8c8 0%, #d8e89c 60%, transparent 100%) !important;
  box-shadow: 0 0 12px rgba(216, 232, 156, .85), 0 0 4px rgba(255, 248, 200, .8) !important;
}

/* 腦波音樂主題：午夜深藍漸層，呼應 buildBinauralScene */
body.theme-binaural .progress>i {
  background: linear-gradient(90deg,
      #b8d8ff 0%, #7fb8ff 18%, #5fa8ff 35%, #3a78d8 52%,
      #2a4f9c 68%, #1a3a78 84%, #0f2547 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .45),
    0 4px 12px rgba(58, 120, 216, .35);
}

body.theme-binaural .progress>i::after {
  background: radial-gradient(circle, #e8f3ff 0%, #7fb8ff 60%, transparent 100%) !important;
  box-shadow: 0 0 12px rgba(127, 184, 255, .9), 0 0 4px rgba(232, 243, 255, .7) !important;
}

/* 晚霞主題：粉紫晚霞 → 深紫，呼應紫色 buildPurpleSunsetScene */
body.theme-sunshine .progress>i {
  background: linear-gradient(90deg,
      #f0d8f8 0%, #d4a8e8 18%, #b06dd0 35%, #8c40c0 52%,
      #6822a0 68%, #4a1880 84%, #2e0e5e 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .55),
    0 4px 12px rgba(140, 64, 192, .35);
}

body.theme-sunshine .progress>i::after {
  background: radial-gradient(circle, #f8e8fc 0%, #d4a8e8 60%, transparent 100%) !important;
  box-shadow: 0 0 12px rgba(212, 168, 232, .9), 0 0 4px rgba(248, 232, 252, .8) !important;
}

.progress>i::after {
  content: '';
  position: absolute;
  right: -2px;
  top: 50%;
  transform: translateY(-50%);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .2);
  opacity: 0;
  transition: opacity .2s ease;
}

.progress:hover>i::after {
  opacity: 1;
}

.time-row {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  color: var(--text-soft);
  margin-top: 10px;
  font-feature-settings: "tnum";
  font-weight: 500;
}

/* 大播放鍵 */
.play-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  margin: 0 6px;
}

.play-btn {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: linear-gradient(140deg, #fff, #dfe6f1);
  color: #5b6d8e;
  box-shadow:
    10px 10px 24px var(--shadow-dark),
    -8px -8px 22px var(--shadow-light),
    inset 0 1px 0 rgba(255, 255, 255, .7);
  display: flex;
  align-items: center;
  justify-content: center;
}

.play-btn:active {
  box-shadow:
    inset 8px 8px 16px var(--shadow-dark),
    inset -8px -8px 16px var(--shadow-light);
}

.play-btn svg {
  width: 36px;
  height: 36px;
}

.mini-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: var(--surface);
  color: var(--text-soft);
  box-shadow: 6px 6px 12px var(--shadow-dark), -6px -6px 12px var(--shadow-light);
  display: flex;
  align-items: center;
  justify-content: center;
}

.mini-btn:active {
  box-shadow: inset 5px 5px 10px var(--shadow-dark), inset -5px -5px 10px var(--shadow-light);
}

.mini-btn svg {
  width: 32px;
  height: 32px;
}

/* 音量 */
.vol-row {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 18px;
  color: var(--text-soft);
  font-size: 14px;
  font-weight: 500;
}

.vol-row svg {
  width: 22px;
  height: 22px;
}

.slider {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  height: 12px;
  border-radius: 999px;
  /* v1.0.2+42:用 linear-gradient + CSS 變數 --p 顯示「已調到的進度」
     灰色填充。JS 端在 input 事件即時更新 --p,沒有 JS 也至少看得到原始
     neumorphic 底色,不影響功能。 */
  background:
    linear-gradient(
      to right,
      rgba(120, 130, 150, 0.32) 0%,
      rgba(120, 130, 150, 0.32) var(--p, 0%),
      var(--surface) var(--p, 0%),
      var(--surface) 100%
    );
  box-shadow: inset 4px 4px 8px var(--shadow-dark), inset -4px -4px 8px var(--shadow-light);
  outline: none;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: linear-gradient(140deg, #fff, #cfd8e8);
  box-shadow: 3px 3px 8px var(--shadow-dark), -2px -2px 6px var(--shadow-light);
  cursor: pointer;
}

/* 白噪音區 */
.noise-card {
  width: min(420px, 100%);
  margin-top: 14px;
  background: var(--surface);
  border-radius: 24px;
  padding: 18px 18px 20px;
  box-shadow: 8px 8px 18px var(--shadow-dark), -8px -8px 18px var(--shadow-light);
}

.noise-title {
  font-size: 14px;
  color: var(--text-soft);
  margin: 0 2px 14px;
  letter-spacing: .5px;
  display: flex;
  justify-content: space-between;
}

.noise-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  justify-items: center;
}

.noise-btn {
  border: none;
  cursor: pointer;
  background: transparent;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: var(--text-soft);
  font-family: inherit;
  transition: color .2s, transform .15s;
}

.noise-btn .circle {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow:
    6px 6px 12px var(--shadow-dark),
    -6px -6px 12px var(--shadow-light);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: box-shadow .3s ease, color .2s, transform .12s;
}

.noise-btn .circle svg {
  width: 30px;
  height: 30px;
}

.noise-btn .lb {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 2px;
}

.noise-btn:active .circle {
  transform: scale(.96);
}

.noise-btn.on {
  color: var(--text);
}

.noise-btn.on .circle {
  color: #5b6d8e;
  box-shadow:
    inset 5px 5px 10px var(--shadow-dark),
    inset -5px -5px 10px var(--shadow-light);
}

.noise-btn.on .circle svg {
  filter: drop-shadow(0 2px 6px rgba(138, 165, 214, .55));
}

/* ============ 主頁三圓鈕 ============ */
.home-tabs {
  width: min(420px, 100%);
  margin-top: 16px;
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  justify-items: center;
}

/* 四圓鈕模式：縮小圓鈕讓四個排得下 */
.home-tabs.four {
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.home-tabs.four .tab-btn .circle {
  width: 74px;
  height: 74px;
}

.home-tabs.four .tab-btn .circle svg {
  width: 30px;
  height: 30px;
}

.home-tabs.four .tab-btn .lb {
  font-size: 16px;
  letter-spacing: .5px;
}

.tab-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  font-family: inherit;
  color: var(--text-soft);
}

.tab-btn .circle {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow:
    8px 8px 18px var(--shadow-dark),
    -8px -8px 18px var(--shadow-light),
    inset 0 1px 0 rgba(255, 255, 255, .6);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #5b6d8e;
  transition: box-shadow .25s, transform .15s;
}

.tab-btn .circle svg {
  width: 28px;
  height: 28px;
}

.tab-btn .lb {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 1px;
  color: var(--text);
}

.tab-btn:active .circle {
  transform: scale(.95);
  box-shadow: inset 6px 6px 12px var(--shadow-dark), inset -6px -6px 12px var(--shadow-light);
}

/* ============ 子頁: 環境白噪音 ============ */
.subpage-hint {
  font-size: 16px;
  color: var(--text-soft);
  text-align: center;
  line-height: 1.7;
  margin: 4px 0 22px;
}

.noise-grid-large {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  justify-items: center;
  margin-top: 8px;
}

.noise-grid-large .noise-btn {
  gap: 14px;
}

.noise-grid-large .noise-btn .circle {
  /* 手機版預設縮小成 80×80（避免 6 顆擠在一起、按鈕太大）;
     ≥768px 在 responsive.css 復原成 92×92。*/
  width: 80px;
  height: 80px;
}

.noise-grid-large .noise-btn .circle svg {
  width: 38px;
  height: 38px;
}

.noise-grid-large .noise-btn .lb {
  font-size: 16px;
}

/* 個別音量 — 圓鈕下方迷你 slider，僅播放時顯示 */
.noise-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}

/* 預設隱藏（按下圓鈕開啟對應白噪音才出現） */
.noise-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 80px;
  /* 不超過 92px 的圓鈕寬度 */
  max-width: 100%;
  height: 6px;
  border-radius: 999px;
  outline: none;
  cursor: pointer;
  background: var(--surface);
  box-shadow:
    inset 2px 2px 4px var(--shadow-dark),
    inset -2px -2px 4px var(--shadow-light);
  /* 隱藏 + 滑入動畫 */
  opacity: 0;
  max-height: 0;
  margin: 0;
  pointer-events: none;
  transition:
    opacity 0.28s ease,
    max-height 0.28s ease,
    margin 0.28s ease;
}

.noise-cell:has(.noise-btn.on) .noise-slider {
  opacity: 1;
  max-height: 20px;
  margin-top: 12px;
  pointer-events: auto;
}

/* 各自不同的漸層色 — 蟬鳴：暖陽綠｜海浪：海洋藍｜雨聲：霧紫
   篝火：火焰橘｜溪流：清水青｜蛙叫：池塘綠 */
.noise-cell:has(.noise-btn.on) .noise-slider[data-noise="cicada"] {
  background: linear-gradient(90deg, #d8e07a, #88a85a);
  box-shadow:
    inset 1px 1px 3px rgba(60, 80, 30, 0.25),
    inset -1px -1px 2px rgba(255, 255, 255, 0.35);
}

.noise-cell:has(.noise-btn.on) .noise-slider[data-noise="ocean"] {
  background: linear-gradient(90deg, #a8dcf0, #4d8fc8);
  box-shadow:
    inset 1px 1px 3px rgba(30, 70, 110, 0.25),
    inset -1px -1px 2px rgba(255, 255, 255, 0.4);
}

.noise-cell:has(.noise-btn.on) .noise-slider[data-noise="rain"] {
  background: linear-gradient(90deg, #c8c0e8, #8878b8);
  box-shadow:
    inset 1px 1px 3px rgba(60, 50, 100, 0.25),
    inset -1px -1px 2px rgba(255, 255, 255, 0.4);
}

.noise-cell:has(.noise-btn.on) .noise-slider[data-noise="bonfire"] {
  background: linear-gradient(90deg, #ffd07a, #ff8838, #d44820);
  box-shadow:
    inset 1px 1px 3px rgba(120, 40, 10, 0.30),
    inset -1px -1px 2px rgba(255, 255, 255, 0.35);
}

.noise-cell:has(.noise-btn.on) .noise-slider[data-noise="stream"] {
  background: linear-gradient(90deg, #bce8e0, #5fb8c8, #2b7a8a);
  box-shadow:
    inset 1px 1px 3px rgba(20, 80, 100, 0.25),
    inset -1px -1px 2px rgba(255, 255, 255, 0.4);
}

.noise-cell:has(.noise-btn.on) .noise-slider[data-noise="frog"] {
  background: linear-gradient(90deg, #d8ec8c, #88c460, #3f7a3a);
  box-shadow:
    inset 1px 1px 3px rgba(40, 80, 30, 0.28),
    inset -1px -1px 2px rgba(255, 255, 255, 0.35);
}

/* 蟋蟀：秋夜月光紫｜鳥叫：晨曦暖粉｜風鈴：微風銀藍 */
.noise-cell:has(.noise-btn.on) .noise-slider[data-noise="cricket"] {
  background: linear-gradient(90deg, #c8b8e0, #7868a8, #4a3878);
  box-shadow:
    inset 1px 1px 3px rgba(50, 30, 90, 0.28),
    inset -1px -1px 2px rgba(255, 255, 255, 0.35);
}

.noise-cell:has(.noise-btn.on) .noise-slider[data-noise="bird"] {
  background: linear-gradient(90deg, #ffe0c8, #ffa888, #e06848);
  box-shadow:
    inset 1px 1px 3px rgba(140, 60, 30, 0.25),
    inset -1px -1px 2px rgba(255, 255, 255, 0.4);
}

.noise-cell:has(.noise-btn.on) .noise-slider[data-noise="windchime"] {
  background: linear-gradient(90deg, #e8f0f8, #a8c0d8, #6080a8);
  box-shadow:
    inset 1px 1px 3px rgba(40, 70, 120, 0.22),
    inset -1px -1px 2px rgba(255, 255, 255, 0.45);
}

/* Thumb (拖把) — 共用，與漸層對比明亮的白珠 */
.noise-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: linear-gradient(140deg, #ffffff, #e2eaf5);
  box-shadow:
    1px 1px 3px rgba(60, 70, 100, 0.4),
    -1px -1px 2px rgba(255, 255, 255, 0.7),
    0 0 0 1px rgba(255, 255, 255, 0.6);
  cursor: pointer;
  border: none;
}

.noise-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: linear-gradient(140deg, #ffffff, #e2eaf5);
  box-shadow:
    1px 1px 3px rgba(60, 70, 100, 0.4),
    -1px -1px 2px rgba(255, 255, 255, 0.7),
    0 0 0 1px rgba(255, 255, 255, 0.6);
  cursor: pointer;
  border: none;
}

/* ============ 子頁: 音樂列表（播放清單樣式） ============ */
/* 播放清單控制列：歌曲數資訊 + 隨機播放按鈕 */
.playlist-controls {
  display: flex;
  align-items: center;
  margin-bottom: 14px;
  padding: 0 4px;
  gap: 8px;
  /* 三顆按鈕之間固定 8px */
}

/* info 靠左：把按鈕群推到右側 */
.playlist-controls .playlist-info {
  margin-right: auto;
}

/* 拖移提示 — 緊鄰 .playlist-controls 下方,track-list 之前 */
.playlist-hint {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: -4px 4px 12px;
  padding: 0;
  font-size: 12.5px;
  color: var(--text-faint);
  letter-spacing: .2px;
  line-height: 1.4;
}
.playlist-hint-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  opacity: .75;
}
body.dark .playlist-hint {
  color: rgba(240, 244, 255, .45);
}


.playlist-info {
  font-size: 14px;
  color: var(--text-soft);
  font-weight: 500;
  letter-spacing: .3px;
}

.shuffle-toggle {
  border: none;
  cursor: pointer;
  background: var(--surface);
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-soft);
  font-family: inherit;
  box-shadow:
    5px 5px 10px var(--shadow-dark),
    -5px -5px 10px var(--shadow-light);
  transition: all .25s ease;
}

.shuffle-toggle:active {
  transform: translateY(1px);
}

.shuffle-toggle svg {
  width: 18px;
  height: 18px;
}

.shuffle-toggle.active {
  background: linear-gradient(140deg, #b9a3d6, #8e7cc3);
  color: #fff;
  box-shadow:
    5px 5px 12px var(--shadow-dark),
    -3px -3px 10px var(--shadow-light),
    inset 0 1px 0 rgba(255, 255, 255, .35),
    0 0 16px rgba(142, 124, 195, .35);
}

/* 播放中動畫條（取代右側「播放中」文字） */
.now-playing-bars {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 16px;
  flex: none;
  transform: translateX(-20px) scale(1.3);
}

.now-playing-bars i {
  width: 3px;
  background: linear-gradient(180deg, #b9a3d6, #8e7cc3);
  border-radius: 2px;
  animation: np-bounce 1.1s ease-in-out infinite;
}

.now-playing-bars i:nth-child(1) {
  animation-delay: 0s;
  height: 50%;
}

.now-playing-bars i:nth-child(2) {
  animation-delay: .2s;
  height: 90%;
}

.now-playing-bars i:nth-child(3) {
  animation-delay: .4s;
  height: 70%;
}

.now-playing-bars i:nth-child(4) {
  animation-delay: .15s;
  height: 100%;
}

@keyframes np-bounce {

  0%,
  100% {
    transform: scaleY(.35);
  }

  50% {
    transform: scaleY(1);
  }
}

/* 點當前曲目暫停 → 整個 row 顯示凸起浮凸 + 紫色播放三角 */
.track-item.active-paused {
  box-shadow:
    11px 11px 24px var(--shadow-dark),
    -8px -8px 20px var(--shadow-light),
    inset 0 1px 0 rgba(255, 255, 255, .65);
  transform: translateY(-1px);
  transition: box-shadow .25s ease, transform .15s ease;
}

.track-item.active-paused .info b {
  color: #6c5f86;
}

.track-item.active-paused .info span {
  color: #8e7cc3;
  font-weight: 600;
}

/* 暫停指示器（紫色實心三角，提示「點擊繼續播放」） */
.now-playing-paused {
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(140deg, #c8b8e0, #8e7cc3);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    3px 3px 8px rgba(120, 100, 160, .35),
    -1px -1px 4px rgba(255, 255, 255, .55),
    inset 0 1px 0 rgba(255, 255, 255, .35);
}

.now-playing-paused svg {
  width: 14px;
  height: 14px;
  margin-left: 2px;
  /* 三角圖形的視覺重心偏左，往右挪一點視覺對齊 */
}

/* 序號 badge */
.track-num {
  flex: none;
  width: 22px;
  text-align: center;
  font-size: 24px;
  font-weight: lighter;
  color: var(--text-soft);
  font-feature-settings: "tnum";
}

.track-item.active-track .track-num {
  color: #8e7cc3;
}

.track-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 18px;
}

/* 拖曳排序視覺回饋 */
.track-item.draggable {
  cursor: grab;
  transition: transform .18s ease, box-shadow .18s ease, opacity .18s ease;
  user-select: none;
  -webkit-user-select: none;
  touch-action: pan-y;
}

.track-item.dragging {
  opacity: .5;
  cursor: grabbing;
  transform: scale(1.03);
  box-shadow:
    10px 10px 22px var(--shadow-dark),
    -8px -8px 18px var(--shadow-light);
  z-index: 10;
}

.track-item.drag-over {
  /* dragover 中的目標：稍微 outline 提示插入位置 */
  outline: 2px dashed var(--accent, #8AA5D6);
  outline-offset: -4px;
}

.track-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 20px;
  background: var(--surface);
  box-shadow: 6px 6px 14px var(--shadow-dark), -6px -6px 14px var(--shadow-light);
}

.track-item .cover {
  width: 54px;
  height: 54px;
  border-radius: 16px;
  flex: none;
  background: linear-gradient(140deg, #a7bce4, #b9a3d6);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .4);
}

/* 每首音樂的封面色 — 對應自家 D3 場景配色 */
.track-item .cover.cover-music1 {
  /* 仲夏：粉橘晚霞 */
  background: linear-gradient(140deg, #ffb0c8, #d8528c);
  color: #fff;
}

.track-item .cover.cover-music2 {
  /* 海潮：海洋藍 */
  background: linear-gradient(140deg, #7fb6e5, #4a7bb5);
  color: #fff;
}

.track-item .cover.cover-music3 {
  /* 皓月：苔綠 */
  background: linear-gradient(140deg, #a9d4a2, #4a7c59);
  color: #fff;
}

.track-item .cover.cover-music4 {
  /* 晚霞：紫色晚霞 + 一抹桃紅 */
  background: linear-gradient(140deg, #f5c8de 0%, #d8a8e8 35%, #8a4ec8 100%);
  color: #fff;
}

.track-item .cover.cover-binaural,
.track-item .cover.cover-silent {
  /* 腦波音樂：深紫月光(silent.mp3 沿用 binaural 配色) */
  background: linear-gradient(140deg, #6b4f9e 0%, #2a1f4a 100%);
  color: #fff;
}

/* v1.0.1+31:music5 ~ music15 的封面色,跟對應 D3 場景的主色對齊 */
.track-item .cover.cover-music5 {
  /* 星河:銀河深紫 + 冷藍 */
  background: linear-gradient(140deg, #7e8fff 0%, #1d0c3d 100%);
  color: #fff;
}
.track-item .cover.cover-music6 {
  /* 微雨:灰藍冷色 */
  background: linear-gradient(140deg, #a8b8c8 0%, #4f5e72 100%);
  color: #fff;
}
.track-item .cover.cover-music7 {
  /* 雲海:淡粉 + 雲白 */
  background: linear-gradient(140deg, #fff5fa 0%, #d8e0ee 100%);
  color: #a8a0b8;
}
.track-item .cover.cover-music8 {
  /* 月夜:午夜藍 + 月光暖白 */
  background: linear-gradient(140deg, #d8d0a0 0%, #0e1830 100%);
  color: #fff;
}
.track-item .cover.cover-music9 {
  /* 朝霧:淡黃 + 柔綠 */
  background: linear-gradient(140deg, #fff8c8 0%, #b8d0a8 100%);
  color: #6a7858;
}
.track-item .cover.cover-music10 {
  /* 銀杏:金黃 → 焦褐 */
  background: linear-gradient(140deg, #ffd060 0%, #c87838 100%);
  color: #fff;
}
.track-item .cover.cover-music11 {
  /* 流螢:螢光黃 → 深綠夜 */
  background: linear-gradient(140deg, #d8ff90 0%, #0e2a1e 100%);
  color: #fff;
}
.track-item .cover.cover-music12 {
  /* 春櫻:櫻花粉 */
  background: linear-gradient(140deg, #ffd8e8 0%, #e878a8 100%);
  color: #fff;
}
.track-item .cover.cover-music13 {
  /* 雪落:冰白 → 淡藍灰 */
  background: linear-gradient(140deg, #ffffff 0%, #a8b0c8 100%);
  color: #5a6878;
}
.track-item .cover.cover-music14 {
  /* 蘆葦:暖黃 → 橄欖 */
  background: linear-gradient(140deg, #fff0c0 0%, #a89860 100%);
  color: #fff;
}
.track-item .cover.cover-music15 {
  /* 燭光:火焰橘 → 深褐 */
  background: linear-gradient(140deg, #ffb060 0%, #3a2410 100%);
  color: #fff;
}

/* 腦波音樂 row 不可拖曳 */
.track-item[data-binaural-only] {
  cursor: pointer;
}
.track-item[data-binaural-only] .track-num {
  color: #8b6dc4;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 舊類別保留 backward compatible（暫時還有人用 .cover.warm 的話） */
.track-item .cover.warm {
  background: linear-gradient(140deg, #fce7d3, #f5b88a);
  color: #a06b3f;
}

.track-item .cover svg {
  width: 24px;
  height: 24px;
}

.track-item .info {
  flex: 1;
  min-width: 0;
}

.track-item .info b {
  display: block;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -.2px;
}

.track-item .info span {
  display: block;
  font-size: 14px;
  color: var(--text-soft);
  margin-top: 3px;
  letter-spacing: .3px;
}

.track-item .status {
  font-size: 14px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 999px;
  background: linear-gradient(140deg, #fce7d3, #f5d6c0);
  color: #a06b3f;
  flex: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .6);
}

.track-item .status.locked {
  background: linear-gradient(140deg, #e8e2f1, #d9cfe9);
  color: #6c5f86;
}

/* 線上 / 離線 切換 pill */
.track-mode-toggle {
  border: none;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform .12s, box-shadow .12s, background .15s;
  white-space: nowrap;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.6);
}
.track-mode-toggle svg {
  width: 14px;
  height: 14px;
  flex: none;
}
.track-mode-toggle.online {
  background: linear-gradient(140deg, #e3ecfb, #cdddf3);
  color: #4a6fa8;
}
.track-mode-toggle.offline {
  background: linear-gradient(140deg, #d8efdc, #bfe2c5);
  color: #2f7a3c;
}
.track-mode-toggle.downloading {
  background: linear-gradient(140deg, #f3e9d4, #e6d5b3);
  color: #8a6f33;
  cursor: progress;
  font-variant-numeric: tabular-nums;
}
.track-mode-toggle:not(:disabled):active {
  transform: scale(0.96);
  filter: brightness(0.96);
}

/* binaural 內建標籤(灰色,不可點擊) */
.track-mode-bundled {
  font-size: 13px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 999px;
  background: linear-gradient(140deg, #ebe6f4, #ddd4ec);
  color: #6c5f86;
  flex: none;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.6);
}

.track-item.active-track {
  box-shadow: inset 5px 5px 10px var(--shadow-dark), inset -5px -5px 10px var(--shadow-light);
}

.track-item.active-track .status {
  background: var(--btn-dark);
  color: #fff;
}

/* ============ 子頁: 睡眠紀錄 ============ */
.stat-hero {
  text-align: center;
  padding: 8px 0 14px;
}

.stat-hero .num {
  font-size: 48px;
  font-weight: 700;
  letter-spacing: -1.5px;
  color: var(--text);
  font-feature-settings: "tnum";
}

.stat-hero .num small {
  font-size: 22px;
  font-weight: 500;
  color: var(--text-soft);
  margin-left: 2px;
}

.stat-hero .lb {
  font-size: 14px;
  color: var(--text-soft);
  margin-top: 4px;
  letter-spacing: .5px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}

.stat-cell {
  text-align: center;
  padding: 14px 6px;
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 5px 5px 10px var(--shadow-dark), -5px -5px 10px var(--shadow-light);
}

.stat-cell .v {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -.3px;
}

.stat-cell .k {
  font-size: 14px;
  color: var(--text-soft);
  margin-top: 4px;
  letter-spacing: .5px;
}

.sleep-chart {
  height: 120px;
  border-radius: 18px;
  padding: 12px 14px;
  background: var(--surface);
  box-shadow: inset 4px 4px 8px var(--shadow-dark), inset -4px -4px 8px var(--shadow-light);
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.sleep-chart .bar {
  flex: 1;
  background: linear-gradient(180deg, #b9a3d6, #a7bce4);
  border-radius: 6px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .4);
  position: relative;
}

.sleep-chart .bar small {
  position: absolute;
  bottom: -18px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 14px;
  color: var(--text-soft);
}

.sleep-chart-wrap {
  padding-bottom: 22px;
}

/* ============ 個人數據（睡眠分析儀表板） ============ */
/* 日期標頭 — 可點擊開月曆 */
.stats-date-bar {
  width: min(420px, 100%);
  display: flex;
  align-items: center;
  margin-bottom: 12px;
  padding: 0 4px;
}

.stats-date-btn {
  border: none;
  cursor: pointer;
  background: transparent;
  font-family: inherit;
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.4px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-radius: 12px;
  transition: background .2s;
}

.stats-date-btn:active {
  background: rgba(120, 140, 180, .08);
}

.stats-date-btn svg {
  width: 16px;
  height: 16px;
  color: var(--text-soft);
}

/* 同一天多筆 session 的 Report 頁籤 */
.stats-week {
  width: min(420px, 100%);
  display: flex;
  justify-content: space-between;
  margin-bottom: 16px;
  padding: 0 4px;
}

.day-circle {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: var(--surface);
  color: var(--text-soft);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  box-shadow:
    inset 3px 3px 6px var(--shadow-dark),
    inset -3px -3px 6px var(--shadow-light);
  transition: all .25s ease;
}

.day-circle {
  position: relative;
}

/* 該日有資料 → 加一圈黑色外框 */
.day-circle.has-data {
  box-shadow:
    inset 3px 3px 6px var(--shadow-dark),
    inset -3px -3px 6px var(--shadow-light),
    0 0 0 2px #000;
  color: var(--text);
}

.day-circle.active {
  background: var(--btn-dark);
  color: #fff;
  box-shadow:
    4px 4px 10px var(--shadow-dark),
    -3px -3px 8px var(--shadow-light),
    inset 0 1px 0 rgba(255, 255, 255, .35);
}

.day-circle.active.has-data {
  /* active 狀態優先，覆蓋 has-data 的 box-shadow */
  box-shadow:
    4px 4px 10px var(--shadow-dark),
    -3px -3px 8px var(--shadow-light),
    inset 0 1px 0 rgba(255, 255, 255, .35),
    0 0 0 2px #000;
}

/* ============ 月曆 Modal — 新擬態 + 玻璃質感（與 App 整體風格一致） ============ */
.calendar-modal {
  position: fixed;
  max-width: 640px;
  margin: 0 auto;
  inset: 0;
  z-index: 200;
  display: none;
  flex-direction: column;
  overflow: hidden;
  color: var(--text);
  /* 與 body 同款的暖色霧光漸層（DINOTAENG 風格） */
  background:
    radial-gradient(1100px 700px at 12% -10%, #ffe9d6 0%, transparent 55%),
    radial-gradient(900px 700px at 110% 20%, #d8e4ff 0%, transparent 55%),
    radial-gradient(800px 600px at 50% 110%, #e4d8ff 0%, transparent 55%),
    linear-gradient(180deg, var(--bg-1), var(--bg-2));
}

/* 自然光斜線 */
.calendar-modal::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(115deg, transparent 35%, rgba(255, 255, 255, .35) 42%, transparent 50%),
    radial-gradient(160px 480px at 78% 18%, rgba(255, 255, 255, .25), transparent 60%);
  mix-blend-mode: screen;
}

.calendar-modal.show {
  display: flex;
}

/* 頂部標頭：玻璃質感 */
.calendar-head {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 24px 22px 18px;
  background: rgba(255, 255, 255, .45);
  backdrop-filter: blur(22px) saturate(140%);
  -webkit-backdrop-filter: blur(22px) saturate(140%);
  border-bottom: 1px solid rgba(255, 255, 255, .55);
  box-shadow: 0 6px 20px rgba(120, 140, 180, .1);
  z-index: 2;
}

.calendar-head .icon-btn {
  width: 44px;
  height: 44px;
  background: var(--surface);
  color: var(--text-soft);
  box-shadow:
    5px 5px 10px var(--shadow-dark),
    -5px -5px 10px var(--shadow-light);
}

.calendar-head .icon-btn:active {
  background: var(--surface);
  box-shadow:
    inset 4px 4px 8px var(--shadow-dark),
    inset -4px -4px 8px var(--shadow-light);
}

.calendar-head .icon-btn svg {
  width: 20px;
  height: 20px;
}

.calendar-head h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -.4px;
  color: var(--text);
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

/* 星期欄 */
.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  padding: 14px 16px 10px;
  position: relative;
  z-index: 1;
}

.calendar-weekdays span {
  text-align: center;
  font-size: 14px;
  color: var(--text-soft);
  font-weight: 600;
  letter-spacing: 1px;
}

.calendar-body {
  flex: 1;
  overflow-y: auto;
  padding: 6px 22px 40px;
  -webkit-overflow-scrolling: touch;
  position: relative;
  z-index: 1;
}

.cal-month {
  margin-bottom: 28px;
}

.cal-month h3 {
  font-size: 20px;
  font-weight: 700;
  margin: 14px 6px 18px;
  color: var(--text);
  letter-spacing: -.3px;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 10px;
  justify-items: center;
}

/* 日期圓鈕（微凹新擬態） — 預設不可點，只有 has-data 才開放 */
.cal-day {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: rgba(120, 140, 170, .42);
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: default;
  box-shadow: none;
  transition: all .25s ease, transform .12s ease;
}

.cal-day.empty {
  background: transparent;
  box-shadow: none;
  cursor: default;
}

.cal-day.future {
  color: rgba(120, 140, 170, .25);
  cursor: not-allowed;
  background: transparent;
  box-shadow: none;
}

/* 有紀錄的日期：黑色外框 + 微凹 + 柔和外暈（唯一可點擊狀態） */
.cal-day.has-data {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
  box-shadow:
    inset 1px 1px 3px var(--shadow-dark),
    inset -1px -1px 3px var(--shadow-light),
    0 0 0 2px #000,
    0 4px 10px rgba(0, 0, 0, .18);
}

/* 異常紀錄（score 偏低）：暖橘環 */
.cal-day.has-data.warning {
  color: #a0522d;
  box-shadow:
    inset 1px 1px 3px var(--shadow-dark),
    inset -1px -1px 3px var(--shadow-light),
    0 0 0 2px #e89968,
    0 4px 10px rgba(232, 153, 104, .25);
}

/* 當前選中：浮凸藍漸層 */
.cal-day.active {
  background: var(--btn-dark);
  color: #fff;
  font-weight: 700;
  box-shadow:
    4px 4px 10px var(--shadow-dark),
    -3px -3px 8px var(--shadow-light),
    inset 0 1px 0 rgba(255, 255, 255, .35);
}

.cal-day.active.has-data {
  /* active + has-data 同時：保留浮凸 + 黑色邊框 */
  box-shadow:
    4px 4px 10px var(--shadow-dark),
    -3px -3px 8px var(--shadow-light),
    inset 0 1px 0 rgba(255, 255, 255, .35),
    0 0 0 2px #000;
}

.cal-day.has-data:active {
  transform: scale(.92);
}

/* Hero: 大圓分數 + 右側資訊 */

/* 同一天多筆 session 的 Report 頁籤 */
.stats-reports {
  width: min(420px, 100%);
  display: none;
  gap: 8px;
  margin: -4px 0 14px;
  padding: 0 4px;
  flex-wrap: wrap;
}

.stats-reports.show {
  display: flex;
}

.report-tab {
  border: none;
  cursor: pointer;
  background: var(--surface);
  color: var(--text-soft);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  padding: 8px 18px;
  border-radius: 999px;
  box-shadow:
    inset 2px 2px 4px var(--shadow-dark),
    inset -2px -2px 4px var(--shadow-light);
  transition: all .25s ease;
}

.report-tab.active {
  background: var(--btn-dark);
  color: #fff;
  box-shadow:
    3px 3px 8px var(--shadow-dark),
    -2px -2px 6px var(--shadow-light),
    inset 0 1px 0 rgba(255, 255, 255, .3);
}

/* Hero: 大圓分數 + 右側資訊 */
.stats-hero {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 4px 0 18px;
}

.score-ring {
  position: relative;
  width: 130px;
  height: 130px;
  flex: none;
}

.score-ring svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 4px 12px rgba(77, 158, 204, .25));
}

.score-text {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.score-text b {
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -.5px;
  color: var(--text);
}

.score-text small {
  font-size: 14px;
  color: var(--text-soft);
  margin-top: -2px;
}

.hero-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.hero-info .row-item .lbl {
  font-size: 14px;
  color: var(--text-soft);
  display: flex;
  align-items: center;
  gap: 4px;
}

.hero-info .row-item .lbl em.warn {
  font-style: normal;
  background: #f5a45b;
  color: #fff;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
}

.hero-info .row-item b {
  display: block;
  font-size: 17px;
  font-weight: 700;
  margin-top: 3px;
  letter-spacing: -.3px;
}

/* 子分頁 */
.stats-subtabs {
  display: none;
  gap: 8px;
  margin: 4px 0 14px;
}

.subtab {
  border: none;
  cursor: pointer;
  background: var(--surface);
  color: var(--text-soft);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  padding: 8px 16px;
  border-radius: 999px;
  box-shadow:
    inset 2px 2px 4px var(--shadow-dark),
    inset -2px -2px 4px var(--shadow-light);
}

.subtab.active {
  background: var(--btn-dark);
  color: #fff;
  box-shadow:
    3px 3px 8px var(--shadow-dark),
    -2px -2px 6px var(--shadow-light),
    inset 0 1px 0 rgba(255, 255, 255, .3);
}

/* 概覽標題 */
.overview-head {
  font-size: 14px;
  color: var(--text-soft);
  margin: 8px 2px 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  letter-spacing: .5px;
}

.overview-head .more {
  opacity: 0;
  font-size: 14px;
  color: var(--accent);
}

/* 睡眠階段時間軸 — 3 lane swim-lane chart + 時間軸 */
.stages-chart {
  border-radius: 14px;
  background: var(--surface);
  box-shadow:
    inset 4px 4px 8px var(--shadow-dark),
    inset -4px -4px 8px var(--shadow-light);
  padding: 14px 14px 10px;
  position: relative;
  overflow: hidden;
}

/* 主 chart：固定高度，3 lane × 約 36px */
.stages-chart .stages-svg {
  width: 100%;
  height: 110px;
  display: block;
  border-radius: 4px;
}

/* 空狀態 SVG（佔位）保持原本舊的 svg 標籤 — fallback */
.stages-chart>svg:not(.stages-svg) {
  width: 100%;
  height: 100%;
}

/* 時間軸：與 chart 同寬、相對定位，labels 用 left:% 絕對對齊 */
.stages-axis {
  position: relative;
  height: 22px;
  margin-top: 8px;
}

.stage-tick {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  font-size: 12px;
  letter-spacing: .3px;
  color: var(--text-soft);
  white-space: nowrap;
}

/* 空狀態：此日無睡眠紀錄時顯示 */
.stages-empty {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 8px;
  color: var(--text-soft);
  font-size: 14px;
  letter-spacing: .5px;
  opacity: .6;
}

.stages-empty svg {
  width: 28px;
  height: 28px;
  opacity: .55;
}

.stages-legend {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 14px;
  margin-top: 14px;
  font-size: 14px;
  color: var(--text-soft);
}

.stages-legend>div {
  display: flex;
  align-items: center;
  gap: 6px;
}

.stages-legend b {
  color: var(--text);
  font-weight: 600;
}

.stages-legend .dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex: none;
}

.stages-legend .dot.wake {
  background: #f5d65b;
}

.stages-legend .dot.light {
  background: #5fb3e8;
}

.stages-legend .dot.deep {
  background: #8579cf;
}

/* 統計卡片 */
.stats-card {
  position: relative;
  width: min(420px, 100%);
  /* width: 100%; */
  margin-top: 14px;
  background: var(--surface);
  border-radius: 22px;
  padding: 16px 18px 18px;
  box-shadow:
    8px 8px 18px var(--shadow-dark),
    -8px -8px 18px var(--shadow-light);
}

.stats-card .card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 10px;
}

.stats-card .card-head .ico {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #5b9fc8;
}

.stats-card .card-head .ico svg {
  width: 18px;
  height: 18px;
}

.stats-card .card-head .title {
  flex: 1;
}

.stats-card .card-head .arr {
  color: var(--text-soft);
  font-size: 18px;
}

.stats-card .card-body {
  display: grid;
  grid-template-columns: auto auto 1fr;
  align-items: center;
  gap: 12px;
  position: relative;
}

.stats-card .big-num b {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -1px;
  font-feature-settings: "tnum";
}

.stats-card .big-num small {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-soft);
  margin-left: 2px;
}

.stats-card .big-num.gray b {
  color: var(--text-soft);
}

.stats-card .badge {
  font-size: 14px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  align-self: flex-end;
  margin-bottom: 4px;
}

.stats-card .badge.ok {
  background: rgba(120, 200, 140, .25);
  color: #2c7044;
}

.stats-card .badge.low {
  background: rgba(245, 130, 100, .25);
  color: #a04030;
}

.stats-card .badge.soft {
  background: rgba(140, 160, 220, .25);
  color: #4d5a8c;
}

/* 卡片右側迷你週柱狀圖 */
.mini-bars {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 36px;
  position: absolute;
  right: 24px;
  z-index: 3;
  opacity: 0;
}

.mini-bars i {
  flex: 0 0 8px;
  background: var(--btn-dark-vert);
  border-radius: 3px 3px 0 0;
  min-height: 4px;
}

.mini-bars.rainbow i {
  background: linear-gradient(180deg, #88dceb, #88579b);
}

/* ============ 助眠紀錄（ShutEye 風格麥克風偵測） ============ */
.rec-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0;
  text-align: center;
}

/* .rec-status 已合併進 .rec-hint(放在 mic button 上方),不再使用 */

.rec-mic {
  position: relative;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: linear-gradient(140deg, #fff, #dfe6f1);
  color: #5b6d8e;
  box-shadow:
    14px 14px 30px var(--shadow-dark),
    -10px -10px 26px var(--shadow-light),
    inset 0 1px 0 rgba(255, 255, 255, .7);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .3s ease;
}

.rec-mic:active {
  transform: scale(.97);
}

.rec-mic-icon {
  width: 46px;
  height: 46px;
  position: relative;
  z-index: 2;
}

.rec-mic.recording {
  background: linear-gradient(140deg, #ffe2d0, #f5b88a);
  color: #a04030;
  box-shadow:
    inset 8px 8px 18px rgba(160, 80, 60, .2),
    inset -6px -6px 16px rgba(255, 255, 255, .45),
    0 0 30px rgba(245, 140, 100, .3);
}

.rec-pulse {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid rgba(245, 150, 100, .5);
  opacity: 0;
  pointer-events: none;
}

.rec-mic.recording .rec-pulse {
  animation: rec-pulse 2.2s ease-out infinite;
}

.rec-mic.recording .rec-pulse.p2 {
  animation-delay: 1.1s;
}

@keyframes rec-pulse {
  0% {
    transform: scale(.95);
    opacity: .7;
  }

  100% {
    transform: scale(1.4);
    opacity: 0;
  }
}

.rec-elapsed {
  margin-top: 14px;
  font-size: 32px;
  font-weight: 700;
  letter-spacing: 1px;
  font-feature-settings: "tnum";
  color: var(--text);
}

/* .rec-hint 現在放在 mic 按鈕「上方」,作為主要狀態提示。
   錄音時格式:「收音中:XXX」,字體加大強化視覺份量。 */
.rec-hint {
  margin: 0 0 24px;
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.5;
  max-width: 320px;
  text-align: center;
  letter-spacing: .3px;
  min-height: 1.5em;   /* 預留高度避免文字切換時 layout 跳動 */
}

/* 音量 meter */
.rec-meter-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0 10px;
}

.rec-meter {
  flex: 1;
  height: 10px;
  border-radius: 999px;
  background: var(--surface);
  box-shadow:
    inset 3px 3px 6px var(--shadow-dark),
    inset -3px -3px 6px var(--shadow-light);
  overflow: hidden;
  position: relative;
}

.rec-meter-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #88d5b8, #a3d8a8 30%, #f5d488 60%, #f5a888 85%, #f08868);
  border-radius: 999px;
  transition: width .08s linear;
}

.rec-db {
  font-size: 14px;
  font-weight: 600;
  font-feature-settings: "tnum";
  color: var(--text-soft);
  min-width: 62px;
  text-align: right;
}

/* 波形 canvas */
.rec-wave-wrap {
  height: 80px;
  border-radius: 18px;
  background: var(--surface);
  box-shadow:
    inset 4px 4px 8px var(--shadow-dark),
    inset -4px -4px 8px var(--shadow-light);
  padding: 8px 12px;
  margin-bottom: 18px;
  overflow: hidden;
}

.rec-wave-wrap canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* 事件統計三格 */
.rec-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.rec-stat {
  text-align: center;
  padding: 14px 6px 12px;
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 5px 5px 10px var(--shadow-dark), -5px -5px 10px var(--shadow-light);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.rec-stat .ic {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .6);
}

.rec-stat .ic svg {
  width: 20px;
  height: 20px;
}

.rec-stat .ic.snore {
  background: linear-gradient(140deg, #ffe2d0, #f5b88a);
  color: #a06b3f;
}

.rec-stat .ic.loud {
  background: linear-gradient(140deg, #ffd4d8, #f5a3a8);
  color: #a04050;
}

.rec-stat .ic.quiet {
  background: linear-gradient(140deg, #d8e3f5, #a8c0e0);
  color: #3d5e8e;
}

.rec-stat .v {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -.3px;
  font-feature-settings: "tnum";
}

.rec-stat .k {
  font-size: 14px;
  color: var(--text-soft);
  letter-spacing: .5px;
}

/* 隱私提示 */
.rec-privacy {
  width: min(420px, 100%);
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 14px;
  background: rgba(168, 200, 232, .18);
  font-size: 14px;
  color: var(--text-soft);
  line-height: 1.5;
}

.rec-privacy svg {
  width: 18px;
  height: 18px;
  flex: none;
  color: #5b8ec8;
}

.rec-privacy b {
  color: var(--text);
  font-weight: 600;
}

/* 列表類「設定」入口 */
.menu-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 5px 5px 10px var(--shadow-dark), -5px -5px 10px var(--shadow-light);
  cursor: pointer;
  font-size: 16px;
  font-weight: 600;
}

.menu-row:active {
  box-shadow: inset 4px 4px 8px var(--shadow-dark), inset -4px -4px 8px var(--shadow-light);
}

.menu-row .ic {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(140deg, #fff, #dfe6f1);
  color: #5b6d8e;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .7);
  flex: none;
}

.menu-row .ic svg {
  width: 18px;
  height: 18px;
}

.menu-row .tx {
  flex: 1;
}

.menu-row .tx span {
  display: block;
  font-size: 14px;
  color: var(--text-soft);
  font-weight: 500;
  margin-top: 2px;
  letter-spacing: .3px;
}

.menu-row .arr {
  color: var(--text-soft);
  font-size: 18px;
}

/* 底部導覽 (legacy 兼容) */
.nav-row {
  width: min(420px, 100%);
  margin-top: 14px;
  display: flex;
  gap: 12px;
}

.nav-card {
  flex: 1;
  border: none;
  cursor: pointer;
  border-radius: 20px;
  padding: 14px 12px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 6px 6px 14px var(--shadow-dark), -6px -6px 14px var(--shadow-light);
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: inherit;
}

.nav-card:active {
  box-shadow: inset 5px 5px 10px var(--shadow-dark), inset -5px -5px 10px var(--shadow-light);
}

.nav-card .ic {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(140deg, #fff, #dfe6f1);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #5b6d8e;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .7);
}

.nav-card .ic svg {
  width: 16px;
  height: 16px;
}

.nav-card .tx {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.nav-card .tx b {
  font-size: 14px;
}

.nav-card .tx span {
  font-size: 14px;
  color: var(--text-soft);
  margin-top: 1px;
}

/* ============ 兌換頁 / 設定頁 ============ */
.page-head {
  width: min(420px, 100%);
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
  padding: 4px 6px;
}

.page-head h2 {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -.5px;
}

.page-head .icon-btn {
  margin-right: 6px;
  width: 46px;
  height: 46px;
}

/* 右上角次要動作按鈕(目前用在白噪音 ↔ 音樂列表 交叉導覽)
   margin-left:auto 把它推到 page-head 右側,跟 .redeem-pill 並排時也會
   一起被推到右側,因為 redeem-pill 自己也有 margin-left:auto。 */
.page-head .icon-btn.page-head-right {
  margin-left: auto;
  margin-right: 0;
}

/* 個人數據右上角同步資訊 badge */
.sync-badge {
  margin-left: auto;
  font-size: 14px;
  color: var(--text-soft, #7B8497);
  text-align: right;
  line-height: 1.4;
  letter-spacing: .2px;
  white-space: nowrap;
  margin-right: 8px;
}

.sync-badge .lbl {
  opacity: .75;
  margin-right: 2px;
}

.sync-badge .lbl.err {
  color: #c97a7a;
  opacity: 1;
}

.sync-badge .line1,
.sync-badge .line2 {
  display: block;
  line-height: 1.4;
}

.sync-badge .line2 {
  font-size: 14px;
  opacity: .85;
  margin-top: 1px;
}

.sync-badge b {
  color: var(--accent, #8AA5D6);
  font-weight: 700;
  font-size: 14px;
}

body.dark .sync-badge {
  color: #b0b9d0;
}

body.dark .sync-badge b {
  color: #c8d4ff;
}

.page-head .icon-btn svg {
  width: 20px;
  height: 20px;
}

/* 「兌換新音樂」pill — 左字右 icon、新擬態浮凸（音樂列表頁右側） */
.page-head .redeem-pill {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px 9px 18px;
  border: none;
  cursor: pointer;
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  letter-spacing: .5px;
  box-shadow:
    5px 5px 10px var(--shadow-dark),
    -5px -5px 10px var(--shadow-light),
    inset 0 1px 0 rgba(255, 255, 255, .55);
  transition: box-shadow .2s, transform .12s;
}

.page-head .redeem-pill:active {
  box-shadow:
    inset 4px 4px 8px var(--shadow-dark),
    inset -4px -4px 8px var(--shadow-light);
  transform: translateY(1px);
}

.page-head .redeem-pill svg {
  width: 16px;
  height: 16px;
  flex: none;
}

.redeem-code {
  display: flex;
  gap: 2px;
  justify-content: space-between;
  margin: 10px 0 10px;
}

.redeem-code input {
  width: 12.5%;
  height: 50px;
  text-align: center;
  font-size: 20px;
  font-weight: 700;
  border: none;
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  box-shadow: inset 4px 4px 8px var(--shadow-dark), inset -4px -4px 8px var(--shadow-light);
  outline: none;
  font-family: inherit;
}

.redeem-code input:focus {
  box-shadow: inset 4px 4px 8px var(--shadow-dark), inset -4px -4px 8px var(--shadow-light),
    0 0 0 2px rgba(138, 165, 214, .5);
}

.hint {
  font-size: 14px;
  color: var(--text-soft);
  text-align: center;
  margin: 6px 0 14px;
  line-height: 1.7;
}

.hint code {
  background: rgba(255, 255, 255, .6);
  padding: 1px 6px;
  border-radius: 6px;
  color: #6c5f86;
  font-size: 14px;
}

.toast {
  margin: 10px 0 0;
  padding: 10px 14px;
  border-radius: 14px;
  background: rgba(138, 165, 214, .18);
  color: #3a4252;
  font-size: 14px;
  text-align: center;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .6);
  transition: opacity .3s;
}

.toast.err {
  background: rgba(201, 122, 122, .18);
  color: #7a3030;
}

.toast.hide {
  opacity: 0;
}

/* 暗黑模式：toast 字色改白，避免在深底上看不清 */
body.dark .toast {
  color: #f0f4ff;
  background: rgba(138, 165, 214, .14);
}

body.dark .toast.err {
  color: #ffd5d5;
  background: rgba(201, 122, 122, .22);
}

/* 設定頁 */
.profile {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 6px 4px 18px;
  position: relative;
}
.profile .name-block { flex: 1; min-width: 0; }
.profile-edit-btn {
  position: absolute;
  top: 4px;
  right: 6px;
}

.avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(140deg, #fce7d3, #f5d6c0);
  color: #a06b3f;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .6),
    4px 4px 10px var(--shadow-dark),
    -3px -3px 8px var(--shadow-light);
}

.avatar svg {
  width: 32px;
  height: 32px;
}

/* ============ iOS 風格開關（暗黑模式切換用） ============ */
.toggle-row {
  cursor: default !important;
}

.ios-switch {
  position: relative;
  display: inline-block;
  width: 52px;
  height: 30px;
  cursor: pointer;
}

.ios-switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.ios-switch .track {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: var(--surface);
  box-shadow:
    inset 3px 3px 6px var(--shadow-dark),
    inset -3px -3px 6px var(--shadow-light);
  transition: background .3s ease;
}

.ios-switch .knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: linear-gradient(140deg, #fff, #e2eaf5);
  box-shadow:
    2px 2px 5px rgba(60, 70, 100, .35),
    -1px -1px 2px rgba(255, 255, 255, .8);
  transition: left .28s cubic-bezier(.4, 1.4, .6, 1);
}

.ios-switch input:checked~.track {
  background: var(--btn-dark);
  box-shadow:
    inset 2px 2px 5px rgba(20, 30, 50, .55),
    inset -2px -2px 4px rgba(110, 130, 170, .25);
}

.ios-switch input:checked~.track .knob {
  left: 25px;
  background: linear-gradient(140deg, #fff, #d8dff0);
  box-shadow:
    2px 2px 5px rgba(20, 30, 50, .45),
    -1px -1px 2px rgba(255, 255, 255, .9),
    0 0 8px rgba(138, 165, 214, .35);
}

/* ============ 暗黑模式（body.dark 套用） ============ */
/* html 的背景也要換成深色，避免上下拉/橡皮筋彈性露出原本暖色底 */
html.dark {
  background:
    radial-gradient(1100px 700px at 12% -10%, rgba(80, 60, 110, .28) 0%, transparent 55%),
    radial-gradient(900px 700px at 110% 20%, rgba(40, 65, 115, .35) 0%, transparent 55%),
    radial-gradient(800px 600px at 50% 110%, rgba(70, 50, 110, .25) 0%, transparent 55%),
    linear-gradient(180deg, #1a2030, #0d1220);
}

body.dark {
  /* 顛倒所有設計 token */
  --bg-1: #1a2030;
  --bg-2: #0d1220;
  --surface: #1e2638;
  --text: #e0e6f0;
  --text-soft: #8993a8;
  --shadow-dark: rgba(0, 0, 0, .65);
  --shadow-light: rgba(75, 90, 125, .32);
  --glass: rgba(40, 50, 75, .55);
  --glass-border: rgba(110, 130, 170, .35);

  background:
    radial-gradient(1100px 700px at 12% -10%, rgba(80, 60, 110, .28) 0%, transparent 55%),
    radial-gradient(900px 700px at 110% 20%, rgba(40, 65, 115, .35) 0%, transparent 55%),
    radial-gradient(800px 600px at 50% 110%, rgba(70, 50, 110, .25) 0%, transparent 55%),
    linear-gradient(180deg, var(--bg-1), var(--bg-2));
}

/* 暗黑下的自然光投影：降低亮度避免太刺眼 */
body.dark::before {
  background:
    linear-gradient(115deg, transparent 35%, rgba(255, 255, 255, .08) 42%, transparent 50%),
    radial-gradient(160px 480px at 78% 18%, rgba(160, 180, 220, .08), transparent 60%);
  mix-blend-mode: screen;
}

body.dark::after {
  opacity: .08;
}

/* 月曆 modal 暗黑版 */
body.dark .calendar-modal {
  background:
    radial-gradient(1100px 700px at 12% -10%, rgba(80, 60, 110, .28) 0%, transparent 55%),
    radial-gradient(900px 700px at 110% 20%, rgba(40, 65, 115, .35) 0%, transparent 55%),
    radial-gradient(800px 600px at 50% 110%, rgba(70, 50, 110, .25) 0%, transparent 55%),
    linear-gradient(180deg, var(--bg-1), var(--bg-2));
}

body.dark .calendar-head {
  background: rgba(31, 40, 60, .6);
  border-bottom-color: rgba(110, 130, 170, .15);
}

/* 暗黑下：玻璃面板更深、邊框更明顯 */
body.dark .panel {
  background: rgba(50, 60, 85, .45);
  border-color: rgba(120, 140, 175, .25);
}

/* 月曆 modal 玻璃頭部 */
body.dark .calendar-head {
  backdrop-filter: blur(22px) saturate(110%);
}

/* 暗黑下的 modal-mask */
body.dark .modal-mask {
  background: rgba(5, 10, 20, .55);
}

/* 暗黑下的兌換頁圓鈕（本來底色 surface，dark 下會自動跟 surface 變深）— 文字維持 */

/* 暗黑下的 day-circle.has-data 環色稍微提亮以對比深底 */
body.dark .day-circle.has-data {
  box-shadow:
    inset 3px 3px 6px var(--shadow-dark),
    inset -3px -3px 6px var(--shadow-light),
    0 0 0 2px #7fc2e8;
}

body.dark .cal-day.has-data {
  background: var(--surface);
  color: #88d0f0;
  box-shadow:
    inset 1px 1px 3px var(--shadow-dark),
    inset -1px -1px 3px var(--shadow-light),
    0 0 0 2px #7fc2e8,
    0 4px 10px rgba(127, 194, 232, .25);
}

/* 暗黑下：登入頁 .field/.btn 的色調保留新擬態（已用 var(--surface) 自動繼承） */

/* 暗黑下：badge 對比加強 */
body.dark .track-sub .badge {
  background: linear-gradient(140deg, rgba(252, 231, 211, .25), rgba(245, 214, 192, .35));
  color: #f5cfae;
}

body.dark .track-sub .badge.locked {
  background: linear-gradient(140deg, rgba(232, 226, 241, .2), rgba(217, 207, 233, .3));
  color: #c8b8e0;
}

body.dark .track-item .status {
  background: linear-gradient(140deg, rgba(252, 231, 211, .2), rgba(245, 214, 192, .3));
  color: #f5cfae;
}

body.dark .track-item .status.locked {
  background: linear-gradient(140deg, rgba(232, 226, 241, .15), rgba(217, 207, 233, .25));
  color: #c8b8e0;
}

/* 暗黑下進度條的彩色保留（適應暗背景） */

/* 暗黑下睡眠記錄頁的 .rec-meter / canvas 背景仍用 var(--surface)，自動變深 */

/* 暗黑下：主頁四圓鈕 icon 提亮 — 用 filter 調整亮度 + 飽和 + 微光暈 */
body.dark .tab-btn .circle {
  color: #c5d8f0;
  /* 提亮基底色，filter 在此基礎上加成 */
}

body.dark .tab-btn .circle svg {
  filter: brightness(1.35) saturate(1.15) drop-shadow(0 0 5px rgba(165, 195, 235, .35));
}

body.dark .tab-btn .lb {
  color: #d0d8e6;
  /* 標籤文字也提亮 */
}

/* 暗黑下：logo 徽章反白（深色 logo svg 變成淺色，並加微光暈） */
body.dark .logo-mark img {
  filter: invert(1) hue-rotate(180deg) brightness(1.1) drop-shadow(0 0 4px rgba(180, 200, 235, .35));
}

.profile .name-block b {
  font-size: 17px;
}

.profile .name-block span {
  display: block;
  font-size: 16px;
  color: var(--text-soft);
  margin-top: 2px;
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 14px;
  border-radius: 16px;
  margin-bottom: 10px;
  background: var(--surface);
  font-size: 16px;
  box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.11), -5px -5px 10px var(--shadow-light);
}

.row span.k {
  color: var(--text-soft);
  font-size: 16px;
}

.row span.v {
  font-weight: 600;
}

.row.action {
  cursor: pointer;
}

/* beat-vol-row / music-vol-row:音量控制(直向兩段:label / slider bar)
   slider 樣式沿用主頁 .vol-row + .slider 的 neumorphic 白色音量條
   v1.0.2+42:加 .music-vol-row 共用同樣樣式,讓背景音樂音量跟雙耳節拍版面一致 */
.row.beat-vol-row,
.row.music-vol-row {
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  padding: 14px 16px;
}
.row.beat-vol-row .beat-vol-label,
.row.music-vol-row .beat-vol-label {
  display: flex;
  align-items: center;
  color: var(--text-soft);
  font-size: 16px;
}
.row.beat-vol-row .beat-vol-bar,
.row.music-vol-row .beat-vol-bar {
  margin-top: 0;
  gap: 10px;
  font-size: 13px;
}
.row.beat-vol-row .beat-vol-val,
.row.music-vol-row .beat-vol-val {
  min-width: 42px;
  text-align: right;
  color: var(--text-soft);
  font-variant-numeric: tabular-nums;
}

/* slider-row:row 內含 range slider(舊版相容,目前未使用) */
.row.slider-row {
  align-items: center;
}
.row.slider-row .row-slider {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  margin-left: 12px;
  max-width: 60%;
}
.row.slider-row .row-slider input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 2px;
  background: var(--shadow-dark, rgba(0,0,0,.12));
  outline: none;
}
.row.slider-row .row-slider input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: linear-gradient(140deg, #6b85be, #8aa5d6);
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0,0,0,.2);
}
.row.slider-row .row-slider input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border: none;
  border-radius: 50%;
  background: linear-gradient(140deg, #6b85be, #8aa5d6);
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0,0,0,.2);
}
.row.slider-row .row-slider-val {
  font-size: 12px;
  color: var(--text-soft);
  min-width: 36px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.row.action:active {
  box-shadow: inset 4px 4px 8px var(--shadow-dark), inset -4px -4px 8px var(--shadow-light);
}

.row.danger {
  color: #a85e5e;
}

.row.warn {
  color: #b07840;
}

/* 顯示名稱右側的編輯小圖示按鈕 */
.row-name-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.row-edit-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--surface);
  color: var(--text-soft);
  cursor: pointer;
  box-shadow:
    3px 3px 6px var(--shadow-dark),
    -3px -3px 6px var(--shadow-light);
  transition: color .15s ease, transform .12s ease, box-shadow .15s ease;
  -webkit-tap-highlight-color: transparent;
}
.row-edit-btn svg {
  width: 14px;
  height: 14px;
  display: block;
}
.row-edit-btn:hover {
  color: var(--text);
}
.row-edit-btn:active {
  transform: translateY(1px);
  box-shadow:
    inset 2px 2px 5px var(--shadow-dark),
    inset -2px -2px 5px var(--shadow-light);
}

/* ============ Apple Watch 設定畫面 ============ */
.row .row-icon {
  width: 18px;
  height: 18px;
  vertical-align: -3px;
  margin-right: 8px;
  color: var(--text-soft);
}

#screen-watch.active {
  overflow: scroll;
  padding: 0;
}
#screen-watch .scroll-area {
  padding: 24px;
  box-sizing: border-box;
}

.watch-hero {
  text-align: center;
  padding: 28px 22px 24px;
}
.watch-illu {
  position: relative;
  width: 84px;
  height: 96px;
  margin: 0 auto 14px;
  color: var(--text);
}
.watch-illu svg {
  width: 100%;
  height: 100%;
  filter:
    drop-shadow(4px 6px 12px rgba(163,177,198,.55))
    drop-shadow(-3px -3px 8px rgba(255,255,255,.85));
}
.watch-dot {
  position: absolute;
  top: 30px; right: 12px;
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 3px solid var(--surface);
  background: #c5cad6;
  transition: background .25s ease, box-shadow .25s ease;
}
.watch-dot.connected { background: #6cd49a; box-shadow: 0 0 12px rgba(108,212,154,.7); }
.watch-dot.paired    { background: #c79760; }
.watch-dot.error     { background: #c97373; }

.watch-state-text {
  font-size: 19px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
  letter-spacing: -.2px;
}
.watch-state-sub {
  font-size: 13px;
  color: var(--text-soft);
  max-width: 320px;
  margin: 0 auto;
  line-height: 1.5;
}

.panel-title {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 4px 6px 10px;
}

.panel-desc {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-faint);
  padding: 0 6px 12px;
  margin: 0;
}

.watch-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(120,135,165,.12);
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .2px;
}
.watch-pill::before {
  content: "";
  width: 7px; height: 7px;
  border-radius: 50%;
  background: currentColor;
  opacity: .55;
}
.watch-pill.ok       { background: rgba(108,212,154,.18); color: #2d8855; }
.watch-pill.partial  { background: rgba(199,151,96,.18); color: #97631f; }
.watch-pill.fail     { background: rgba(201,115,115,.16); color: #a13e3e; }

.watch-hint {
  font-size: 12.5px;
  color: var(--text-soft);
  line-height: 1.65;
  padding: 10px 14px 4px;
  margin: 0;
}

.watch-status-row {
  background: var(--surface);
}

#row-watch-status {
  font-size: 13px;
  color: var(--text-soft);
}
#row-watch-status.ok      { color: #2d8855; font-weight: 600; }
#row-watch-status.partial { color: #97631f; }
#row-watch-status.fail    { color: #a13e3e; }

/* ============ 滾動容器 ============ */
/* #screen-stats 本身就是滾動容器(改用 auto 比 scroll 好:沒滿時不顯示卷軸,
   避免內容短時還看到灰條)。.scroll-area 不另外加 overflow,
   讓內容自然往下流,由外層 #screen-stats 控制滾動。 */
#screen-stats.active {
  overflow-y: auto;
  padding: 0;
}

#screen-stats .scroll-area {
  padding: 24px;
  box-sizing: border-box;
}

#screen-stats>.scroll-area>.page-head {
  margin-bottom: 8px;
}

.scroll-area {
  width: 100%;
  max-height: calc(100vh - 60px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-bottom: 24px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  overflow: visible;
}

.scroll-area::-webkit-scrollbar {
  display: none;
}

/* footer 版本 */
.footer {
  font-size: 14px;
  color: var(--text-soft);
  margin-top: 14px;
  letter-spacing: 1px;
  opacity: .7;

}

/* 對話框 */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(40, 50, 70, .25);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 99;
}

.modal-mask.show {
  display: flex;
}

.modal {
  width: min(320px, 90%);
  background: var(--surface);
  border-radius: 24px;
  padding: 22px;
  box-shadow: 14px 14px 32px var(--shadow-dark), -10px -10px 28px var(--shadow-light);
  text-align: center;
}

.modal h3 {
  margin: 6px 0 8px;
  font-size: 16px;
}

.modal p {
  margin: 0 0 16px;
  font-size: 14px;
  color: var(--text-soft);
  line-height: 1.6;
}

.modal .row-btns {
  display: flex;
  gap: 10px;
}

/* ============ 鎖定 / 空狀態 ============ */
#screen-home .empty-state {
  display: none;
}

#screen-home.locked .player-content {
  display: none;
}

#screen-home.locked .empty-state {
  display: flex;
}

#screen-home.locked #noise-card {
  display: none;
}

/* 兌換引導動畫 - 右上角發光呼吸 */
#screen-home.locked #go-redeem {
  animation: hint-pulse 2.4s ease-in-out infinite;
}

@keyframes hint-pulse {

  0%,
  100% {
    box-shadow: 5px 5px 10px var(--shadow-dark), -5px -5px 10px var(--shadow-light), 0 0 0 0 rgba(245, 184, 138, .55);
  }

  50% {
    box-shadow: 5px 5px 10px var(--shadow-dark), -5px -5px 10px var(--shadow-light), 0 0 0 10px rgba(245, 184, 138, 0);
  }
}

.empty-state {
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 18px 8px 8px;
  gap: 10px;
  position: relative;
}

.empty-state .gift-ic {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: linear-gradient(140deg, #fde6cf, #f5cfae);
  color: #a06b3f;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    10px 10px 22px var(--shadow-dark),
    -8px -8px 20px var(--shadow-light),
    inset 0 1px 0 rgba(255, 255, 255, .7);
  margin-top: 6px;
  margin-bottom: 6px;
  animation: float 4s ease-in-out infinite;
}

.empty-state .gift-ic svg {
  width: 42px;
  height: 42px;
}

@keyframes float {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-6px);
  }
}

.empty-state h3 {
  margin: 6px 0 0;
  font-size: 18px;
  font-weight: 700;
}

.empty-state p {
  margin: 0;
  font-size: 14px;
  color: var(--text-soft);
  line-height: 1.8;
}

.empty-state .hint-arrow {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 80px;
  height: 60px;
  color: #d6a07a;
  opacity: .7;
}

.empty-state .cta {
  width: auto;
  padding: 0 28px;
  height: 46px;
  margin-top: 8px;
}

/* 載入提示(黑底白字 + download 圖標) */
.loading-pill {
  position: fixed;
  left: 50%;
  top: 18px;
  transform: translateX(-50%);
  background: #1a1f3a;
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: .3px;
  align-items: center;
  gap: 8px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, .28), 0 2px 6px rgba(0, 0, 0, .18);
  z-index: 50;
  display: none;   /* 預設隱藏,由 .show 切換成 inline-flex */
}
.loading-pill svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  stroke: currentColor;
  fill: none;
}
.loading-pill.show {
  display: inline-flex;
}
/* Apple Guideline 2.5.1 — HealthKit 整合視覺強化:
   讓首頁 #go-health 按鈕用 Apple Health 招牌的 fc3158 紅、加 visible label
   "Apple 健康" 文字。reviewer 一眼能辨識 HealthKit 整合入口。 */
.icon-btn.icon-btn-health {
  position: relative;
  background: linear-gradient(135deg, #ffb0bc, #fc3158);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, .35);
}
.icon-btn.icon-btn-health svg {
  fill: #fff;
}
.icon-btn.icon-btn-health .icon-btn-label {
  position: absolute;
  bottom: -18px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  font-weight: 600;
  color: #fc3158;
  white-space: nowrap;
  letter-spacing: .3px;
}

/* HealthKit info card(放在 #screen-health panel 最頂)— 明確列出 read/write 的健康資料類型 */
.healthkit-info-card {
  background: linear-gradient(135deg, rgba(252, 49, 88, .06), rgba(255, 176, 188, .08));
  border: 1px solid rgba(252, 49, 88, .25);
  border-radius: 16px;
  padding: 16px 18px;
  margin-bottom: 18px;
}
.healthkit-info-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.healthkit-info-head strong {
  font-size: 16px;
  color: var(--text);
  letter-spacing: .2px;
}
.healthkit-info-card p {
  font-size: 14px;
  color: #000;
  line-height: 1.6;
  margin: 0 0 8px;
}
.healthkit-data-list {
  margin: 6px 0 10px;
  padding-left: 22px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-soft);
}
.healthkit-data-list li {
  margin: 2px 0;
}
.healthkit-data-list li b {
  color: #fc3158;
  font-weight: 700;
}
.healthkit-info-foot {
  font-size: 12px !important;
  color: var(--text-faint) !important;
  margin: 0 !important;
  padding-top: 6px;
  border-top: 1px dashed rgba(252, 49, 88, .15);
}


/* v1.0.2+42:原本 @supports (-webkit-touch-callout: none) 區塊強制 60px floor,
   但這個 @supports 對所有 iOS Safari(含 iPad、iPhone)都會 match —— 不只 Flutter
   WebView。結果 iPad 上開 web 版會在頂部留 60px 空白(notch 之外無意義)。
   改成只在 .in-flutter-app 條件下 floor 到 60px(實機 App 才需要),其他都依
   env(safe-area-inset-top) 自然值,有瀏海/動態島會自動撐到 ~60px,沒有就 16px。 */

/* 結算面板 scrollIntoView 時的安全距離 — 避免 #sleeplog-summary 捲到貼狀態列 */
#sleeplog-summary,
#sleeplog-live,
.panel.sleeplog-summary,
.stats-hero,
.score-ring {
  scroll-margin-top: max(60px, calc(16px + env(safe-area-inset-top, 0px)));
}

/* Flutter App (iOS WKWebView) 才需要的 60px 頂部安全區 floor。
   判定方式:檢測 window.flutter_inappwebview 存在 → JS 在 <html> 掛 .in-flutter-app,
   PWA / 一般瀏覽器都不會 match,僅在實機 App 內生效。 */
.in-flutter-app .screen {
  padding: max(60px, calc(16px + env(safe-area-inset-top))) 24px max(20px, calc(16px + env(safe-area-inset-bottom)));
}
.in-flutter-app #screen-stats.active,
.in-flutter-app #screen-watch.active {
  padding: max(60px, calc(16px + env(safe-area-inset-top))) 0 0;
}
.in-flutter-app .loading-pill {
  top: max(60px, calc(18px + env(safe-area-inset-top)));
}
.in-flutter-app .calendar-head {
  padding-top: max(60px, calc(24px + env(safe-area-inset-top)));
}

/* v1.0.2+42:網頁版首頁可垂直捲動(桌面 / iPad 內容超出時)。
   只在非 Flutter WebView 環境生效 — iOS App 維持原本不捲動的設計
   (避免跟原生手勢 / inset shadow 衝突)。 */
html:not(.in-flutter-app) #screen-home.screen.active {
  overflow-y: auto;
}

/* v1.0.2+42:網頁版手機尺寸 RWD 調整(只限 < 768px + 非 Flutter App)。
   iOS 原生 App 維持原樣。 */
@media (max-width: 767px) {
  html:not(.in-flutter-app) .vinyl-wrap {
    max-width: 180px;
  }
  html:not(.in-flutter-app) .home-tabs {
    margin-top: 0;
  }
}

/* v1.0.2+42:網頁版隱藏 Apple 健康相關 UI(只在 iOS App 有意義)。
   - #row-health:個人設定的 Apple 健康 row
   - #go-health-2:助眠紀錄頁右上角的心愛 icon
   - .hk-banner:助眠紀錄頁的「連結 Apple 健康」粉色橫幅 */
html:not(.in-flutter-app) #row-health,
html:not(.in-flutter-app) #go-health-2,
html:not(.in-flutter-app) .hk-banner {
  display: none !important;
}

/* HealthKit 整合說明 banner(Apple Guideline 2.5.1)— 放在 .page-head 下方,
   獨立一行避免跟 h2 標題重疊;清楚說明連結後的寫入流程。
   結構:`.hk-banner-row`(icon + 說明)+ `.hk-banner-cta`(未連結時才顯示) */
.hk-banner {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  padding: 10px 14px 11px;
  margin: -2px 0 12px;
  border-radius: 12px;
  background: rgba(252, 49, 88, .08);
  border: 1px solid rgba(252, 49, 88, .22);
  color: #000;
  font-size: 13px;
  letter-spacing: .2px;
  line-height: 1.45;
}
.hk-banner-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.hk-banner svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  fill: #fc3158;                   /* 圖示保留紅色作為警示視覺 */
}
.hk-banner span {
  flex: 1;
  color: #000;
}
.hk-banner b {
  font-weight: 700;
  color: #fc3158;                  /* 只有「Apple 健康」字樣保留紅色 */
}
/* 未連結時下方 CTA:整列寬,紅色漸層,點擊跳到 #screen-health */
.hk-banner-cta {
  width: 100%;
  padding: 10px 14px;
  border-radius: 10px;
  border: none;
  background: linear-gradient(180deg, #ff5277, #fc3158);
  color: #fff;
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: .3px;
  cursor: pointer;
  box-shadow:
    0 6px 14px rgba(252, 49, 88, .25),
    inset 0 1px 0 rgba(255, 255, 255, .25);
  transition: transform .1s ease, box-shadow .15s ease;
}
.hk-banner-cta:hover {
  box-shadow:
    0 8px 18px rgba(252, 49, 88, .32),
    inset 0 1px 0 rgba(255, 255, 255, .3);
}
.hk-banner-cta:active {
  transform: scale(.98);
}

/* 音樂列表 row 載入進度條(indeterminate)— 點擊 track 觸發 native AVPlayer
   下載/buffering 時顯示,canplay 後消失。視覺:row 底部 3px 動態漸層滑動 */
.track-item {
  position: relative;  /* 確保 track-progress 絕對定位以 row 為基準 */
}
.track-item.loading {
  /* 載入中讓整 row 略呈現「進行中」氛圍 */
  opacity: 0.92;
}
.track-progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  border-radius: 0 0 14px 14px;
  overflow: visible;   /* visible 讓 % 文字能浮在 bar 上方 */
  background: rgba(138, 165, 214, 0.15);
  pointer-events: none;
}
/* 真實 %:track-progress-fill 寬度由 inline style 控制 0-100% */
.track-progress-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 999px;
  transition: width 0.25s ease;
}
.track-progress-pct {
  position: absolute;
  right: 8px;
  bottom: 6px;
  font-size: 10px;
  font-weight: 600;
  color: var(--accent);
  background: rgba(255, 255, 255, .85);
  padding: 1px 6px;
  border-radius: 999px;
  letter-spacing: .3px;
}
/* indeterminate:點擊後 buffer 中(無精準 %),滑動漸層條 */
.track-progress.track-progress-indeterminate {
  overflow: hidden;
}
.track-progress.track-progress-indeterminate::before {
  content: '';
  position: absolute;
  left: -40%;
  top: 0;
  bottom: 0;
  width: 40%;
  background: linear-gradient(90deg,
    transparent 0%,
    var(--accent) 20%,
    var(--accent-2) 50%,
    var(--accent) 80%,
    transparent 100%);
  border-radius: 999px;
  animation: track-progress-slide 1.4s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}
@keyframes track-progress-slide {
  0%   { left: -40%; }
  60%  { left: 100%; }
  100% { left: 100%; }
}

/* ============================================================
   HealthKit 整合 UI(5 個畫面)— 對應 NeuroRest_HealthKit_UI_Mockups_White.html
   ============================================================ */

/* ─── #screen-health-connect (畫面 2 · Pre-prompt 授權前說明) ─── */
.hc-hero { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 18px 12px 4px; margin-bottom: 6px; }
/* iOS app-icon 風格:白底圓角方塊 + 紅漸層心(自繪 SVG,不使用 Apple 自家 icon 圖檔) */
.hc-hero-icon { width: 88px; height: 88px; border-radius: 22px; display: inline-flex; align-items: center; justify-content: center;
  background: #fff;
  box-shadow: 0 10px 26px rgba(0, 0, 0, .10), 0 2px 6px rgba(0, 0, 0, .06), inset 0 1px 0 rgba(255, 255, 255, 1);
  margin-bottom: 18px; }
.hc-hero-icon svg { width: 54px; height: 54px; }
.hc-hero-title { font-size: 22px; font-weight: 700; line-height: 1.35; color: var(--text); letter-spacing: -.3px; margin-bottom: 10px; }
.hc-hero-sub { font-size: 14px; line-height: 1.65; color: var(--text-soft); margin: 0 auto 8px; }

.hc-prompt-list { background: rgba(255, 255, 255, .04); border: 1px solid rgba(255, 255, 255, .08); border-radius: 16px;
  padding: 14px 16px; margin: 14px 0 12px; display: flex; flex-direction: column; gap: 10px; }
.hc-prompt-item { display: flex; align-items: flex-start; gap: 12px; padding: 4px 0; }
.hc-prompt-item + .hc-prompt-item { border-top: 1px dashed rgba(255, 255, 255, .08); padding-top: 12px; }
.hc-prompt-item > div { flex: 1; min-width: 0; }
.hc-prompt-item b { font-size: 14.5px; color: var(--text); font-weight: 600; display: block; }
.hc-prompt-meta { font-size: 12.5px; color: var(--text-soft); margin-top: 3px; line-height: 1.5; }
.hc-check { flex-shrink: 0; width: 26px; height: 26px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 800; background: linear-gradient(135deg, #ff5277, #fc3158); color: #fff;
  box-shadow: 0 4px 10px rgba(252, 49, 88, .3); line-height: 1; }
.hc-check.read { background: linear-gradient(135deg, #7c8cff, #5a7eff); box-shadow: 0 4px 10px rgba(90, 126, 255, .3); }

.hc-info-banner { display: flex; gap: 10px; align-items: flex-start; padding: 11px 13px; margin: 8px 0 6px;
  border-radius: 14px; background: rgba(90, 126, 255, .08); border: 1px solid rgba(90, 126, 255, .22);
  font-size: 12.5px; line-height: 1.6; color: var(--text-soft); }
.hc-info-mark { flex-shrink: 0; font-size: 15px; color: #5a7eff; line-height: 1.2; margin-top: 1px; }
.hc-info-banner b { color: var(--text); font-weight: 700; }

.hc-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }
.hc-actions .btn { width: 100%; }
/* Pre-prompt 頁的「先不連結」加黑框線,跟主色「繼續」按鈕視覺份量平衡,
   讓使用者明顯看到拒絕選項,避免 dark pattern 嫌疑(Apple Review 2.5.1 友善)。*/
#hc-cancel {
  border: 1.5px solid var(--text, #1a1f3a);
  color: var(--text, #1a1f3a);
  box-shadow: none;
}
.hc-footnote { font-size: 12px; color: var(--text-faint); line-height: 1.6; margin: 14px 4px 0; text-align: center; }

/* ─── #screen-health-onboarding (畫面 1 · 引導) ─── */
.onboarding-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 4px 10px; border-bottom: none !important; }
.onboarding-step { font-size: 11.5px; font-weight: 600; letter-spacing: 1px; color: var(--text-faint); text-transform: uppercase; }
.onboarding-skip { background: none; border: none; color: var(--text-soft); font-size: 14px; padding: 6px 10px; cursor: pointer; border-radius: 10px; transition: background .15s ease, color .15s ease; }
.onboarding-skip:hover, .onboarding-skip:focus { background: rgba(255, 255, 255, .06); color: var(--text); outline: none; }
.onboarding-panel { display: flex; flex-direction: column; min-height: calc(100vh - 120px); padding-top: 24px; }
.onb-hero { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 28px 16px 8px; flex: 1; justify-content: center; }
.onb-hero-icon { width: 96px; height: 96px; border-radius: 28px; display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #ff5277 0%, #fc3158 60%, #e91e63 100%); color: #fff;
  box-shadow: 0 22px 44px rgba(252, 49, 88, .32), 0 8px 16px rgba(252, 49, 88, .2), inset 0 2px 0 rgba(255, 255, 255, .5); margin-bottom: 26px; }
.onb-hero-icon svg { width: 54px; height: 54px; fill: currentColor; }
.onb-title { font-size: 26px; line-height: 1.3; font-weight: 800; color: var(--text); letter-spacing: -.4px; margin: 0 0 14px; }
.onb-desc { font-size: 15px; line-height: 1.7; color: var(--text-soft); margin: 0 0 14px; max-width: 440px; }
.onb-desc b { color: var(--text); font-weight: 700; }
.onb-note { font-size: 12.5px; line-height: 1.6; color: var(--text-faint); margin: 0; max-width: 420px; }
.onb-actions { display: flex; flex-direction: column; gap: 10px; padding: 24px 4px 0; }
.onb-actions .btn { width: 100%; }
.onb-btn-connect { display: inline-flex; align-items: center; justify-content: center; gap: 10px; }
.onb-btn-icon { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 6px; background: rgba(255, 255, 255, .18); }
.onb-btn-icon svg { width: 14px; height: 14px; fill: #fff; }
.onb-footnote { font-size: 12px; color: var(--text-faint); line-height: 1.6; margin: 18px 8px 0; text-align: center; }

/* ─── #sleeplog-summary (畫面 4 · 睡眠結算) ─── */
.sleeplog-summary { margin-top: 14px; }
.summary-head { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 4px 4px 14px; }
.summary-meta { font-size: 12.5px; color: var(--text-faint); letter-spacing: .2px; }
.summary-duration { font-size: 32px; font-weight: 800; letter-spacing: -1px; color: var(--text); line-height: 1.15; }
.summary-stage-bar { display: flex; height: 10px; border-radius: 6px; overflow: hidden; background: rgba(255, 255, 255, .05);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .04); margin: 4px 0 10px; }
.summary-stage-bar > div { height: 100%; }
.summary-stage-bar .stage-wake { background: linear-gradient(90deg, #ffd28a, #ffb454); }
.summary-stage-bar .stage-light { background: linear-gradient(90deg, #a8b5ff, #7c8cff); }
.summary-stage-bar .stage-deep { background: linear-gradient(90deg, #5466e0, #3a4ad9); }
.summary-stage-legend { display: flex; flex-wrap: wrap; gap: 14px; margin: 4px 0 16px; font-size: 12px; color: var(--text-soft); }
.summary-stage-legend > span { display: inline-flex; align-items: center; gap: 6px; }
.summary-stage-legend i.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.summary-stage-legend i.stage-light { background: #7c8cff; }
.summary-stage-legend i.stage-deep { background: #3a4ad9; }
.summary-stage-legend i.stage-wake { background: #ffb454; }

.saved-card { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: 18px; margin: 6px 0 4px; border: 1px solid transparent; }
.saved-card .saved-card-text { flex: 1; min-width: 0; }
.saved-card .saved-card-text .title { font-size: 14px; font-weight: 700; line-height: 1.3; margin-bottom: 2px; }
.saved-card .saved-card-text .meta { font-size: 11.5px; color: var(--text-soft); line-height: 1.4; }
.saved-card-icon { flex-shrink: 0; width: 36px; height: 36px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #ff5277 0%, #fc3158 60%, #e91e63 100%); color: #fff;
  box-shadow: 0 6px 14px rgba(252, 49, 88, .32), inset 0 1px 0 rgba(255, 255, 255, .4); }
.saved-card-icon svg { width: 20px; height: 20px; fill: currentColor; }
.saved-card.ok { background: linear-gradient(135deg, rgba(34, 197, 94, .14), rgba(34, 197, 94, .04)); border-color: rgba(34, 197, 94, .28); }
.saved-card.ok .title { color: #22c55e; }
.check-ring { flex-shrink: 0; width: 32px; height: 32px; border-radius: 50%; background: rgba(34, 197, 94, .12);
  border: 2px solid #22c55e; color: #22c55e; display: inline-flex; align-items: center; justify-content: center; font-size: 16px; font-weight: 900; line-height: 1; }
.saved-card.warn { background: linear-gradient(135deg, rgba(245, 158, 11, .14), rgba(245, 158, 11, .04)); border-color: rgba(245, 158, 11, .28); }
.saved-card.warn .title { color: #f59e0b; }
.saved-card-retry { flex-shrink: 0; padding: 8px 14px; font-size: 13px; font-weight: 600; border-radius: 12px;
  border: 1px solid rgba(245, 158, 11, .45); background: rgba(245, 158, 11, .08); color: #f59e0b; cursor: pointer; transition: background .15s ease, transform .1s ease; }
.saved-card-retry:hover { background: rgba(245, 158, 11, .14); }
.saved-card-retry:active { transform: scale(.97); }
.saved-card-retry:disabled { opacity: .5; cursor: not-allowed; }
.saved-card.skip { background: rgba(255, 255, 255, .04); border-color: rgba(255, 255, 255, .08); }
.saved-card.skip .saved-card-icon { background: linear-gradient(135deg, #475569, #334155); box-shadow: none; opacity: .85; }
.saved-card.skip .title { color: var(--text); }
.saved-card-link { flex-shrink: 0; padding: 6px 0; background: none; border: none; font-size: 13px; font-weight: 600; color: #5a7eff; cursor: pointer; }
.saved-card-link:hover { text-decoration: underline; }
.summary-tip { font-size: 12.5px; line-height: 1.6; color: var(--text-faint); margin: 16px 4px 6px; }
.summary-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.summary-actions .btn { width: 100%; }

/* ─── #health-backfill (補寫入過去 7 天) ─── */
/* v1.0.1+15:文字 + 按鈕改上下排,不再併排 */
.backfill-row {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(252, 49, 88, .08), rgba(252, 49, 88, .02));
  border: 1px solid rgba(252, 49, 88, .22);
}
.backfill-text { width: 100%; min-width: 0; }
.backfill-count { font-size: 18px; font-weight: 800; color: #fc3158; letter-spacing: -.3px; line-height: 1.2; }
.backfill-sub { font-size: 12px; color: var(--text-soft); margin-top: 2px; line-height: 1.4; }
.backfill-btn {
  width: 100% !important;
  padding: 12px 16px !important;
  font-size: 14px !important;
}
.backfill-btn:disabled { opacity: .5; cursor: not-allowed; }
.backfill-progress { margin-top: 12px; padding: 12px 14px; border-radius: 14px; background: rgba(255, 255, 255, .04); border: 1px solid rgba(255, 255, 255, .06); }
.backfill-bar { width: 100%; height: 6px; border-radius: 3px; background: rgba(255, 255, 255, .08); overflow: hidden; }
.backfill-bar-fill { height: 100%; width: 0%; background: linear-gradient(90deg, #ff5277, #fc3158); transition: width .25s ease; }
.backfill-progress-text { font-size: 12px; color: var(--text-soft); margin-top: 8px; line-height: 1.4; }

/* ─── #screen-postsleep (本次紀錄獨立頁) ─── */
/* 復用 .panel / .stats-hero / .stages-legend 的既有樣式,只追加少數新元素 */
#screen-postsleep .page-head {
  position: relative;        /* 提供 z-index stacking context */
  z-index: 3;                /* 提高 z 軸,避免被下方的 .panel / score ring 蓋住 */
  margin-bottom: 8px;
}
#screen-postsleep .page-head h2 {
  position: relative;
  z-index: 3;
  flex: 1;
  text-align: center;
  margin: 0;
}
/* 概覽 bar + 起迄時間 */
.postsleep-overview {
  margin: 6px 0 14px;
}
.postsleep-overview .summary-stage-bar {
  margin-bottom: 8px;
}
.postsleep-time-range {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-faint);
  letter-spacing: .2px;
  padding: 0 2px;
}
/* 底部「回到首頁」按鈕區 */
.postsleep-actions {
  display: flex;
  justify-content: center;
  margin-top: 18px;
  margin-bottom: 24px;
}

/* ============ Premium / 訂閱相關 UI ============ */

/* 音樂列表 Premium 鎖頭(只有 SVG 線條鎖頭,沒有文字)
   設計:圓徽 28×28,金色漸層底,白色線條鎖,跟 .session-health-mark 同等視覺權重 */
.track-item .status.premium {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 9px;
  background: linear-gradient(135deg, #ffd86a 0%, #ffb43c 60%, #f59a1a 100%);
  color: #fff;
  box-shadow:
    0 2px 6px rgba(255, 168, 60, .35),
    inset 0 1px 0 rgba(255, 255, 255, .5);
  flex-shrink: 0;
}
.track-item .status.premium svg {
  width: 14px;
  height: 14px;
}

/* ─── 音樂列表底部 升級訂閱 CTA 卡片 ─── */
/* v1.0.1+20:加 position: relative + z-index 避免被上方 panel 陰影蓋到,
   並把下緣 margin 拉到 20px 讓視覺有呼吸空間 */
.upgrade-cta-card {
  position: relative;
  z-index: 3;
  width: min(420px, 100%);
  /* 下緣 32px:跟 panel 底邊有足夠呼吸感(原 16px 太貼) */
  margin: 14px auto 32px;
  padding: 18px 18px 16px;
  border-radius: 22px;
  background: var(--surface);
  box-shadow:
    8px 8px 18px var(--shadow-dark),
    -8px -8px 18px var(--shadow-light);
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease;
}
.upgrade-cta-card:active {
  transform: translateY(1px);
  box-shadow:
    4px 4px 10px var(--shadow-dark),
    -4px -4px 10px var(--shadow-light);
}
.upgrade-cta-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}
.upgrade-cta-icon {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  padding: 10px;
  border-radius: 14px;
  background: linear-gradient(135deg, #ff8aa0 0%, #fc3158 60%, #b91954 100%);
  color: #fff;
  box-shadow: 0 4px 10px rgba(252, 49, 88, .3),
              inset 0 1px 0 rgba(255, 255, 255, .35);
}
.upgrade-cta-title {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.upgrade-cta-title b {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}
.upgrade-cta-title span {
  font-size: 12.5px;
  color: var(--text-soft);
}
.upgrade-cta-features {
  list-style: none;
  padding: 0;
  margin: 0 0 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.upgrade-cta-features li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--text);
}
.upgrade-cta-features .check {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6fd58a 0%, #3aaf5a 100%);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
}
.upgrade-cta-btn-row {
  display: flex;
  justify-content: center;
  margin-top: 4px;
}
.upgrade-cta-btn {
  display: inline-block;
  padding: 10px 22px;
  border-radius: 14px;
  background: linear-gradient(135deg, #ff5277 0%, #fc3158 60%, #e91e63 100%);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .3px;
  box-shadow: 0 4px 10px rgba(252, 49, 88, .35),
              inset 0 1px 0 rgba(255, 255, 255, .35);
}

/* 個人設定頁 — 訪客 CTA 卡(只在未登入時顯示)*/
.guest-cta-panel {
  background: var(--surface);
  border-radius: 22px;
  padding: 18px 18px 16px;
  margin-bottom: 16px;
  /* 跟 .upgrade-cta-card 一致:抬升到上層,避免下方面板 inset shadow 蓋到按鈕 */
  position: relative;
  z-index: 3;
}
.guest-cta-head {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 14px;
}
.guest-cta-icon {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  padding: 10px;
  border-radius: 14px;
  background: linear-gradient(135deg, #c2d4ff 0%, #8aa9f0 100%);
  color: #fff;
  box-shadow: 0 4px 10px rgba(140, 170, 240, .35);
}
.guest-cta-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.guest-cta-text b {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}
.guest-cta-text span {
  font-size: 13px;
  color: var(--text-soft);
  line-height: 1.5;
}
.guest-cta-btn {
  width: 100%;
}

/* 個人設定頁 — 訂閱狀態卡 */
.sub-status-panel {
  background: var(--surface);
  border-radius: 22px;
  padding: 18px;
  margin-bottom: 14px;
}
.sub-status-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.sub-status-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}
.sub-status-badge {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .3px;
  padding: 4px 10px;
  border-radius: 10px;
  background: rgba(140, 150, 170, .15);
  color: var(--text-soft);
}
.sub-status-badge.active {
  background: linear-gradient(135deg, #6fd58a 0%, #3aaf5a 100%);
  color: #fff;
  box-shadow: 0 2px 6px rgba(58, 175, 90, .35);
}
.sub-status-desc {
  font-size: 13px;
  color: var(--text-soft);
  line-height: 1.5;
  margin: 0 0 14px 0;
}

/* ============ Paywall 頁 ============ */
#screen-paywall .page-head {
  position: relative;
  z-index: 3;
  margin-bottom: 8px;
}
#screen-paywall .page-head h2 {
  position: relative;
  z-index: 3;
  flex: 1;
  text-align: center;
  margin: 0;
}
/* v1.0.1+15:整頁壓縮高度,目標一個 iPhone 視窗塞滿不溢出 */
.paywall-panel {
  padding: 18px 22px 18px;
}
.paywall-hero {
  text-align: center;
  margin-bottom: 12px;
}
.paywall-icon {
  width: 52px;
  height: 52px;
  margin: 0 auto 8px;
  padding: 12px;
  border-radius: 16px;
  background: linear-gradient(135deg, #ff8aa0 0%, #fc3158 60%, #b91954 100%);
  color: #fff;
  box-shadow: 0 6px 14px rgba(252, 49, 88, .3),
              inset 0 1px 0 rgba(255, 255, 255, .45);
}
.paywall-icon svg { width: 100%; height: 100%; }
.paywall-subtitle {
  font-size: 13.5px;
  color: var(--text-soft);
  line-height: 1.5;
  margin: 0;
}
.paywall-features {
  list-style: none;
  padding: 0;
  margin: 0 0 14px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.paywall-features li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--text);
}
.paywall-features .check {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: linear-gradient(135deg, #6fd58a 0%, #3aaf5a 100%);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}
.paywall-price-card {
  background: linear-gradient(135deg, rgba(252, 49, 88, .06) 0%, rgba(252, 49, 88, .02) 100%);
  border: 1px solid rgba(252, 49, 88, .14);
  border-radius: 16px;
  padding: 12px 16px;
  margin-bottom: 12px;
  text-align: center;
}
.paywall-price-card .trial-label {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .5px;
  color: #2e8540;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.paywall-price-card .product-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
  letter-spacing: .1px;
}
.paywall-price-card .price-line {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 4px;
}
.paywall-price-card .price {
  font-size: 24px;
  font-weight: 800;
  color: var(--text);
}
.paywall-price-card .period {
  font-size: 14px;
  color: var(--text-soft);
}
.paywall-price-card .price-note {
  font-size: 11px;
  color: var(--text-faint);
  margin-top: 3px;
}
.paywall-cta {
  width: 100%;
  margin-bottom: 8px;
}
/* 恢復購買:加深色邊框,跟主按鈕的深色實心對比 */
.paywall-restore,
#btn-back-login {
  width: 100%;
  margin-bottom: 10px;
  background: transparent;
  color: var(--text);
  border: 1.5px solid var(--text);
  font-weight: 600;
}
/* v1.0.1+30:auth 頁「返回登入」跟上方「建立並登入」間隔 8px,避免太貼 */
#btn-back-login {
  margin-top: 8px;
}
.paywall-restore:active,
#btn-back-login:active {
  background: rgba(0, 0, 0, .06);
}
.paywall-fineprint {
  font-size: 10.5px;
  line-height: 1.55;
  color: var(--text-faint);
  text-align: left;
  margin: 0 0 12px;
  padding: 0 2px;
}
.paywall-links {
  /* v1.0.1+30:Privacy Policy + Terms of Use (EULA) 改成兩個 outlined button,
     上下排堆疊。沿用 .btn.ghost 樣式,只調容器間距。 */
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
}
.paywall-link-btn {
  width: 100%;
  font-size: 13px;
  padding-top: 12px;
  padding-bottom: 12px;
  /* 淺灰色框線(比「恢復購買」的深色 1.5px solid var(--text) 更淡),
     讓 EULA / Privacy 兩條輔助連結視覺權重低於主訂閱按鈕,但仍清楚是可點按鈕 */
  border: 1px solid rgba(120, 130, 160, 0.35);
  background: transparent;
  color: var(--text-soft);
  font-weight: 500;
}
.paywall-link-btn:active {
  background: rgba(0, 0, 0, .05);
  border-color: rgba(120, 130, 160, 0.55);
}
/* .dot 分隔點若殘留則隱藏 */
.paywall-links .dot {
  display: none;
}
.postsleep-actions .btn {
  min-width: 200px;
}

/* ─── #session-history (畫面 5 · 睡眠歷史) ─── */
/* 跟上方 .stats-card 同款白色凸起樣式(neumorphic shadow) */
.session-history {
  position: relative;
  width: min(420px, 100%);
  margin: 14px 0 4px;
  padding: 18px 18px 14px;
  border-radius: 22px;
  background: var(--surface);
  box-shadow:
    8px 8px 18px var(--shadow-dark),
    -8px -8px 18px var(--shadow-light);
}
.session-history-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.session-history-title { display: flex; align-items: center; gap: 9px; font-size: 15px; font-weight: 700; color: var(--text); }
.hh-pill { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 8px;
  background: linear-gradient(135deg, #ff5277 0%, #fc3158 60%, #e91e63 100%); color: #fff;
  box-shadow: 0 4px 10px rgba(252, 49, 88, .28), inset 0 1px 0 rgba(255, 255, 255, .35); }
.hh-pill svg { width: 14px; height: 14px; fill: currentColor; }
.session-history-meta { font-size: 11.5px; color: var(--text-faint); letter-spacing: .2px; }
.session-list { display: flex; flex-direction: column; }
.session-empty { padding: 18px 4px; text-align: center; font-size: 13px; color: var(--text-faint); }
/* 每一筆紀錄外面包一層 .session-row-wrap,內含 row 本體 + 右側的刪除鈕 */
.session-row-wrap { position: relative; display: flex; align-items: center; gap: 4px; border-bottom: 1px solid rgba(255, 255, 255, .06); }
.session-row-wrap:last-child { border-bottom: none; }
.session-row { position: relative; display: flex; align-items: center; gap: 14px; flex: 1; min-width: 0; padding: 14px 4px;
  border: none; background: none; text-align: left; color: inherit; font: inherit; cursor: pointer;
  transition: background .15s ease; border-radius: 10px; }
/* 刪除鈕(垃圾桶) — 灰色低調,hover/active 時轉成柔和粉紅,避免跟紅色 ❤ 撞色太強 */
.session-delete { flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; padding: 0; margin-left: 4px;
  border: none; border-radius: 10px; background: rgba(120, 130, 150, .06);
  color: var(--text-faint); cursor: pointer;
  transition: background .15s ease, color .15s ease, transform .12s ease; }
.session-delete:hover { background: rgba(252, 49, 88, .10); color: #e91e63; }
.session-delete:active { transform: scale(.92); background: rgba(252, 49, 88, .18); color: #c2185b; }
.session-delete svg { width: 16px; height: 16px; }
.session-row:hover { background: rgba(255, 255, 255, .03); }
.session-row:active { background: rgba(255, 255, 255, .06); }
.session-row.active { background: rgba(252, 49, 88, .06); border-bottom-color: rgba(252, 49, 88, .12); }
.session-row.active::before { content: ""; position: absolute; left: -8px; top: 50%; transform: translateY(-50%); width: 3px; height: 36px; border-radius: 2px; background: linear-gradient(180deg, #ff5277, #fc3158); }
.session-date { flex-shrink: 0; width: 56px; display: flex; flex-direction: column; align-items: flex-start; line-height: 1.2; }
.session-date b { font-size: 15px; color: var(--text); font-weight: 700; }
.session-date span { font-size: 11.5px; color: var(--text-faint); margin-top: 2px; }
.session-body { flex: 1; min-width: 0; }
.session-name { font-size: 14.5px; font-weight: 600; color: var(--text); line-height: 1.3; }
.session-meta { font-size: 11.5px; color: var(--text-soft); margin-top: 3px; line-height: 1.4; }
.session-health-mark { flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 7px;
  background: linear-gradient(135deg, #ff5277 0%, #fc3158 60%, #e91e63 100%); color: #fff;
  box-shadow: 0 4px 10px rgba(252, 49, 88, .28), inset 0 1px 0 rgba(255, 255, 255, .35); transition: opacity .15s ease, filter .15s ease; }
.session-health-mark svg { width: 13px; height: 13px; fill: currentColor; }
.session-health-mark.unwritten { opacity: .25; filter: saturate(0); box-shadow: none; }

/* #screen-health 已授權但「健康」App 沒資料的空狀態 hint */
.health-empty-hint {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 10px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(90, 126, 255, .07);
  border: 1px dashed rgba(90, 126, 255, .25);
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-soft);
}
.health-empty-hint strong {
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
}

/* iPad 裝置不支援 HealthKit(iPadOS < 17)的替代狀態提示
   樣式跟 .health-disclaimer 一致:黑色標題、無背景、無框線、padding:0 */
.hk-unavailable-hint {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 18px;
  padding: 0;
  background: none;
  border: none;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-soft);
}
.hk-unavailable-hint strong {
  display: block;
  margin-bottom: 4px;
  color: var(--text);                 /* 黑色標題 */
  font-size: 13px;
  font-weight: 700;
}

/* iPad 響應式 — column wrapper 整段已移除。
   原本想加 max-width 限制 #app,但因為 .panel 本身就是 width: min(420px, 100%),
   寬螢幕已自然置中,不需要再加一層 column wrapper(反而會把原本的亮色漸層 body
   蓋成暗色,跟線框稿 / App 視覺基調不一致)。
   iPad portrait/landscape 直接走 default 路徑:
     body 亮色漸層 → #app 100vw → .screen align-items:center → .panel 420px 浮中。

   保留下方一條 visible-label 微調:平板上 #go-health 底部的「Apple 健康」label
   字體放大易讀,並調整位置。 */
@media (min-width: 840px) {
  #screen-home .top-actions #go-health::after {
    font-size: 14px;
    letter-spacing: 0;
    top: calc(100% + 6px);
  }
}

/* =============================================================
   推薦人代碼:設定頁就地輸入(inline 緊湊版)
   - 結構:.row.referral-input-row 內 inline 排:
       <span class="k">標題</span>  <input>  <button.row-edit-btn>  + 隱藏 toast(換行)
   - 標題:var(--text-soft) / 16px / gap:0(無 icon、無額外間距)
   - 輸入框:背景透明、無框、右對齊,點選後出現淡淡 focus 提示
   - 套用按鈕:沿用 .row-edit-btn 圓形 neumorphic icon-only(打勾)
   - Toast:flex-wrap 換行,僅在送出時顯示
   ============================================================= */
.row.referral-input-row {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px 16px;
}
.row.referral-input-row .k {
  display: inline-flex;
  align-items: center;
  gap: 0;
  color: var(--text-soft);
  font-size: 16px;
  flex-shrink: 0;
}

/* 透明輸入框 — 撐滿剩餘空間,但設 max-width 不要太寬 */
.referral-inline-input {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 200px;
  padding: 6px 10px;
  margin: 0;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 15px;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  letter-spacing: 2px;
  text-transform: uppercase;
  outline: none;
  text-align: right;
  -webkit-appearance: none;
  appearance: none;
  transition: background .15s ease;
  border-radius: 8px;
}
.referral-inline-input::placeholder {
  color: var(--text-faint);
  letter-spacing: .3px;
  text-transform: none;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", sans-serif;
  font-size: 13.5px;
}
.referral-inline-input:focus {
  background: rgba(15, 23, 42, .04);
}

/* 套用按鈕:沿用 .row-edit-btn 圓形 neumorphic icon 樣式,
   不在這裡重寫(避免衝突),只覆蓋 disabled 狀態與在 referral 列裡的位置 */
.row.referral-input-row .row-edit-btn {
  flex-shrink: 0;
  position: static;     /* 取消 .profile-edit-btn 的 absolute 定位殘留(若有) */
  color: var(--ok, #22c55e);   /* 打勾用綠 */
}
.row.referral-input-row .row-edit-btn:disabled {
  opacity: .45;
  cursor: not-allowed;
}

/* 結果提示 — flex 佔整行,position 在下方 */
.referral-toast {
  flex: 1 0 100%;
  font-size: 12.5px;
  line-height: 1.5;
  padding: 8px 12px;
  margin: 4px 0 0;
  border-radius: 10px;
  background: rgba(34, 197, 94, .12);
  color: #16a34a;
  border: 1px solid rgba(34, 197, 94, .22);
}
.referral-toast.err {
  background: rgba(252, 49, 88, .1);
  color: #c0254f;
  border-color: rgba(252, 49, 88, .25);
}
.referral-toast.info {
  background: rgba(90, 126, 255, .1);
  color: #3b50d9;
  border-color: rgba(90, 126, 255, .22);
}

/* ─── 暗黑模式 ─── */
body.dark .referral-inline-input {
  color: #f0f4ff;
}
body.dark .referral-inline-input::placeholder {
  color: rgba(240, 244, 255, .35);
}
body.dark .referral-inline-input:focus {
  background: rgba(255, 255, 255, .04);
}
body.dark .referral-toast {
  background: rgba(34, 197, 94, .18);
  color: #6ee7b7;
  border-color: rgba(34, 197, 94, .3);
}
body.dark .referral-toast.err {
  background: rgba(252, 49, 88, .2);
  color: #ffb8c8;
  border-color: rgba(252, 49, 88, .35);
}
body.dark .referral-toast.info {
  background: rgba(90, 126, 255, .2);
  color: #b4c0ff;
  border-color: rgba(90, 126, 255, .35);
}

