/* 大超越設計系統 2026-10-31 — Web/PWA tokens。套用在各模組 CSS 之後。 */
:root {
  color-scheme: light;
  --bb-bg: #f5f7fa;
  --bb-surface: #ffffff;
  --bb-surface-subtle: #edf3f7;
  --bb-text: #17212b;
  --bb-text-secondary: #526170;
  --bb-border: #dce3e9;
  --bb-accent: #076d9e;
  --bb-accent-soft: #e5f3fa;
  --bb-success: #176a45;
  --bb-warning: #895600;
  --bb-error: #af3030;
  --bb-radius-sm: 10px;
  --bb-radius-md: 16px;
  --bb-radius-lg: 22px;
  --bb-space-1: 4px;
  --bb-space-2: 8px;
  --bb-space-3: 12px;
  --bb-space-4: 16px;
  --bb-space-5: 20px;
  --bb-space-6: 24px;
  --bb-focus: #005c89;
  --home-blue: var(--bb-accent);
  --home-blue-deep: var(--bb-accent);
  --home-blue-soft: var(--bb-accent-soft);
  --home-text: var(--bb-text);
  --home-muted: var(--bb-text-secondary);
  --home-line: var(--bb-border);
  --a2-blue: var(--bb-accent);
  --a2-bg: var(--bb-bg);
  --a2-text: var(--bb-text);
  --a2-muted: var(--bb-text-secondary);
  --a2-line: var(--bb-border);
  --dream-blue: var(--bb-accent);
  --dream-soft: var(--bb-accent-soft);
  --dream-muted: var(--bb-text-secondary);
  --dream-line: var(--bb-border);
  --byactivity-blue: var(--bb-accent);
  --byactivity-blue-soft: var(--bb-accent-soft);
}
html { background: var(--bb-bg); -webkit-text-size-adjust: 100%; }
body.home-page, body.hearter-page, body.byactivity-page, body.hearteat-page,
body.dream-page, body.settings-page, body.admin-page {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans TC',
    'PingFang TC', 'Microsoft JhengHei', system-ui, sans-serif;
  color: var(--bb-text);
  background: var(--bb-bg);
  line-height: 1.55;
  overflow-wrap: anywhere;
  min-height: 100dvh;
}
button, input, select, textarea { font-family: inherit; }
button, a, input, textarea, select, summary { -webkit-tap-highlight-color: transparent; }
:where(button, a, input, textarea, select, summary, [role="tab"]):focus-visible {
  outline: 3px solid var(--bb-focus) !important;
  outline-offset: 3px;
}
:where(button, input, select, textarea):disabled { opacity: .55; cursor: not-allowed; }
:where(input, select, textarea) {
  color: var(--bb-text);
  background-color: var(--bb-surface);
  border-color: var(--bb-border);
  font-size: max(16px, 1rem);
}
:where(h1, h2, h3, p) { overflow-wrap: anywhere; }
:where([role="status"], [role="alert"]) { overflow-wrap: anywhere; }

/* 共用 Material Symbols Rounded：字型未載入時隱藏 ligature，不顯示 home 等單字。 */
.bb-icon {
  display: inline-block;
  flex: 0 0 auto;
  width: var(--bb-icon-size,24px);
  height: var(--bb-icon-size,24px);
  font-family: 'Material Symbols Rounded' !important;
  font-style: normal;
  font-weight: 400;
  font-size: var(--bb-icon-size,24px);
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  text-align: center;
  white-space: nowrap;
  direction: ltr;
  font-feature-settings: 'liga';
  -webkit-font-feature-settings: 'liga';
  -webkit-font-smoothing: antialiased;
  font-variation-settings: 'FILL' var(--bb-icon-fill,0),'wght' 400,'GRAD' 0,'opsz' 24;
  visibility: hidden;
}
.bb-icons-ready .bb-icon { visibility: visible; }
.bb-icon-fallback { font-size: .76rem; font-weight: 700; }
.bb-icons-ready .bb-icon-fallback { display: none; }

/* 頁面最上方輕量工具列：操作與主要分頁分離。 */
.bb-app-toolbar {
  position: relative;
  z-index: 20;
  padding: max(8px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
    8px max(16px, env(safe-area-inset-left));
  background: var(--bb-bg);
}
.bb-app-toolbar-inner {
  display: flex; align-items: center; gap: 10px; width: min(100%, 880px);
  min-height: 48px; margin: auto;
}
.bb-app-toolbar-title {
  min-width: 0; flex: 1;
  color: var(--bb-text); font-size: 1.07rem; font-weight: 750; line-height: 1.35;
}
.bb-toolbar-actions { display: flex; flex: 0 0 auto; align-items: center; gap: 6px; }
.bb-tool-button {
  display: inline-flex; justify-content: center; align-items: center; gap: 6px;
  min-width: 44px; min-height: 44px; padding: 6px 10px;
  border: 1px solid var(--bb-border); border-radius: 15px;
  background: var(--bb-surface); color: var(--bb-text);
  box-shadow: none; cursor: pointer; text-align: center;
}
.bb-tool-button .bb-icon { --bb-icon-size: 24px; }
.bb-tool-button:active, .bb-primary-action:active { transform: scale(.98); }
.bb-offline-notice {
  padding: 9px 16px; background: #fff3de; color: #785000;
  text-align: center; font-weight: 650; font-size: .9rem;
}
.bb-offline-notice[hidden] { display: none !important; }

/* 主分頁是控制層，不在這裡放重整、建立或掃碼。使用不透明後援。 */
.common-bottom-nav {
  z-index: 8000;
  background: rgba(252,253,254,.97);
  border-top: 1px solid var(--bb-border);
  box-shadow: 0 -3px 16px rgba(20,36,50,.06);
  padding-bottom: calc(7px + env(safe-area-inset-bottom));
}
.common-bottom-nav-inner { max-width: 520px; gap: 3px; }
.common-bottom-nav-item {
  min-height: 56px; min-width: 44px; border-radius: 16px; color: var(--bb-text-secondary);
  font-size: .77rem; font-weight: 700;
}
.common-bottom-nav-item.is-active { background: var(--bb-accent-soft); color: var(--bb-accent); }
.common-bottom-nav-icon { width: 24px; height: 24px; }
.common-bottom-nav-icon .bb-icon { --bb-icon-size: 24px; }
.bb-keyboard-open .common-bottom-nav { display: none !important; }
@supports ((backdrop-filter: blur(10px)) or (-webkit-backdrop-filter: blur(10px))) {
  .common-bottom-nav {
    background: rgba(252,253,254,.87);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  }
}
@media (prefers-reduced-transparency: reduce) {
  .common-bottom-nav { background: var(--bb-surface); backdrop-filter: none; -webkit-backdrop-filter: none; }
}

/* 首頁：品牌縮小、功能上移、月曆以日期/標記為主。 */
.home-page { padding: 8px 16px calc(100px + env(safe-area-inset-bottom)); }
.home-shell { max-width: 800px; }
.home-hero { background: transparent; border: 0; border-radius: 0; box-shadow: none; }
.home-hero img {
  height: clamp(78px, 15vw, 132px); width: 100%; padding: 5px 10px;
  object-fit: contain;
}
.home-welcome-card {
  margin-top: 8px; padding: 16px 18px; border-radius: var(--bb-radius-lg);
  background: var(--bb-surface); border-color: var(--bb-border); box-shadow: none;
}
.home-welcome-title { font-size: clamp(1.2rem, 4.8vw, 1.55rem); font-weight: 760; }
.home-welcome-subtitle { margin-top: 3px; font-size: .89rem; color: var(--bb-text-secondary); }
.home-member-number { margin-top: 10px; padding-top: 9px; font-size: .9rem; gap: 8px; }
.home-member-number-icon { width: 24px; height: 24px; flex-basis: 24px; font-size: .65rem; border-width: 1px; }
.home-auth-badge { padding: 5px 9px; font-size: .75rem; font-weight: 700; color: var(--bb-accent); }
.bb-home-task-heading {
  font-size: 1.17rem; line-height: 1.3; margin: 22px 0 10px;
  color: var(--bb-text); font-weight: 760;
}
.home-page .common-function-cards { margin-top: 0 !important; gap: 10px; }
.home-page .common-function-card {
  min-height: 112px; padding: 14px 12px; background: var(--bb-surface);
  border: 1px solid var(--bb-border); border-radius: var(--bb-radius-md);
  box-shadow: none; text-align: left;
}
.home-page .common-function-card-icon,
.home-page.is-phone-device .common-function-card-icon {
  width: 38px !important; height: 38px !important;
  margin-bottom: 8px !important; color: var(--bb-accent); background: var(--bb-accent-soft);
}
.common-function-card-title { color: var(--bb-text); font-size: 1rem; font-weight: 730; }
.common-function-card-description { color: var(--bb-text-secondary); font-size: .83rem; }
.home-page .home-calendar-card {
  margin-top: 16px; padding: 16px 12px; background: var(--bb-surface);
  border: 1px solid var(--bb-border); border-radius: var(--bb-radius-lg); box-shadow: none;
}
.home-calendar-kicker, .home-study-links-eyebrow { display: none !important; }
.home-calendar-head h2 { font-size: 1.17rem; }
.home-calendar-day { min-height: 48px; padding: 5px 1px; }
.home-calendar-day-events { justify-content: center; gap: 2px; min-height: 5px; }
.home-calendar-event-chip {
  display: inline-block !important; width: 6px !important; height: 6px !important;
  min-width: 6px !important; min-height: 6px !important;
  padding: 0 !important; overflow: hidden; font-size: 0 !important;
  border-radius: 50% !important; vertical-align: middle;
}
.home-calendar-more { font-size: .66rem; line-height: 1; }
.home-calendar-day.is-selected { outline: 2px solid var(--bb-accent); outline-offset: -2px; }
.home-calendar-day.is-today .home-calendar-day-number { font-weight: 900; text-decoration: underline; text-underline-offset: 3px; }
.home-calendar-toolbar button, .home-calendar-today { min-width: 44px; min-height: 44px; }
.home-push-card { border: 1px solid var(--bb-border); border-radius: var(--bb-radius-md); box-shadow: none; background: var(--bb-surface); }

/* 隱藏狀態優先於按鈕樣式：絕不能讓未授權操作露出。 */
.bb-primary-action[hidden], .bb-secondary-action[hidden] { display: none !important; }

/* 內容區統一清楚的表面，不在大區塊上堆 Liquid Glass。 */
.hearter-page, .byactivity-page, .dream-page { padding-top: 8px; }
.hearter-hero, .byactivity-hero { margin-bottom: 10px; }
.hearter-hero img, .byactivity-hero img { max-height: 110px; object-fit: contain; }
.hearter-navigation, .byactivity-navigation { margin-bottom: 12px; }
.hearter-tabs, .byactivity-tabs, .dream-tabs, .hearteat-tabs {
  background: var(--bb-surface-subtle); padding: 4px;
  border-radius: 14px; gap: 4px; box-shadow: none;
}
.hearter-tab, .byactivity-tab, .dream-tab, .hearteat-tabs button {
  min-height: 44px; border-radius: 11px; font-weight: 700;
}
.hearter-tab.active, .byactivity-tab.active, .dream-tab.is-active, .hearteat-tabs button.is-active {
  background: var(--bb-surface); color: var(--bb-accent);
  border-color: var(--bb-border); box-shadow: 0 1px 3px rgba(20,30,45,.08);
}
.hearter-dashboard-eyebrow, .dream-overline, .dream-eyebrow, .hearteat-eyebrow,
.settings-kicker, .settings-section-kicker, .admin-kicker, .admin-section-kicker,
.byactivity-modal-header small { display:none !important; }
.hearter-dashboard-title, .byactivity-page-heading h1, .settings-hero h1,
.hearteat-hero h1, .dream-hero h1 { font-size: clamp(1.42rem, 5vw, 1.85rem); font-weight: 760; }
.hearter-page .form-card, .byactivity-page .form-card, .hearter-stat-card,
.settings-hero, .settings-card, .hearteat-toolbar, .hearteat-card, .admin-card {
  background: var(--bb-surface); border-color: var(--bb-border); box-shadow: none;
  border-radius: var(--bb-radius-md);
}
.byactivity-page-heading { margin-bottom: 14px; }
.byactivity-member { color: var(--bb-text-secondary); font-weight: 500; }
.bb-primary-action, .bb-secondary-action {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 16px; border-radius: 12px;
  font-size: 1rem; line-height: 1.25; font-weight: 750; cursor: pointer;
}
.bb-primary-action { color: white; background: var(--bb-accent); border: 1px solid var(--bb-accent); }
.bb-secondary-action { color: var(--bb-accent); background: var(--bb-surface); border: 1px solid var(--bb-border); }
.byactivity-page-heading > .bb-primary-action { margin-top: 12px; }
.hearteat-hero {
  min-height: 82px; padding: 16px 18px; background: var(--bb-surface);
  color: var(--bb-text); border: 1px solid var(--bb-border); box-shadow: none; border-radius: var(--bb-radius-lg);
}
.hearteat-hero p { color: var(--bb-text-secondary); }
.hearteat-hero .hearteat-icon-button { background: var(--bb-accent-soft); color: var(--bb-accent); }
.hearteat-shell { padding-top: 8px; padding-bottom: calc(112px + env(safe-area-inset-bottom)); }
.hearteat-tabs { display:flex; flex-wrap:wrap; margin: 12px 0; }
.hearteat-tabs button { flex: 1 1 auto; border: 0; background: transparent; color: var(--bb-text-secondary); }
.hearteat-tabs .bb-action-source { display: none !important; }
.bb-a2-actions { display:flex; gap:8px; flex-wrap:wrap; margin: 0 0 16px; }
.bb-a2-actions button { flex: 1 1 140px; }
.dream-hero {
  min-height: 0; padding: 20px; border-radius: var(--bb-radius-lg);
  background: var(--bb-surface); color: var(--bb-text); border: 1px solid var(--bb-border); box-shadow: none;
}
.dream-hero-mark, .dream-hero-decoration { display: none !important; }
.dream-hero-copy p, .dream-intro p { color: var(--bb-text-secondary); }
.dream-intro { background: var(--bb-surface); box-shadow: none; }
.settings-page .settings-shell { padding-top: 8px; }
.settings-hero { margin-top: 0; padding: 18px; }
.settings-card { padding: 18px; }

/* Modal 比底部分頁高，安全區以可視視窗為準；鎖背景捲動。 */
body.bb-modal-active { overflow:hidden !important; }
body.bb-modal-active .common-bottom-nav { pointer-events:none; }
.home-study-links-overlay, .byactivity-modal, .hearteat-dialog, .hearter-global-message {
  z-index: 12000 !important;
}
.home-study-links-overlay, .byactivity-modal, .hearteat-dialog {
  padding-bottom: max(14px,env(safe-area-inset-bottom)) !important;
}
.home-study-links-panel, .byactivity-modal-card, .hearteat-dialog-card {
  max-height: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 30px) !important;
  background: var(--bb-surface); border-radius: var(--bb-radius-lg);
}

/* A2：外層已依底部導覽列縮短高度；不能再用整個 100dvh 限制內卡片。
 * 過長內容只在卡片內捲動，避免置中時上方標題與最下方按鍵被裁掉。
 */
.hearteat-dialog {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
}
.hearteat-dialog-card {
  flex: 0 1 auto;
  min-height: 0;
  max-height: 100% !important;
}
.hearteat-dialog-body {
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.home-study-links-head { background: var(--bb-surface); }
.home-study-links-item-icon, .home-study-links-heading-icon { color: var(--bb-accent); }
.home-study-links-close, .byactivity-modal-close { min-width: 44px; min-height: 44px; }

/* 小螢幕、大字級與無障礙減少效果。 */
@media (max-width: 430px) {
  .home-page, .hearter-page, .byactivity-page, .dream-page { padding-left: 12px; padding-right: 12px; }
  .bb-app-toolbar { padding-left: 12px; padding-right: 12px; }
  .hearter-tabs, .byactivity-tabs { overflow-x:auto; scrollbar-width: thin; }
  .home-calendar-day { min-height: 48px; }
  .home-calendar-day-number { font-size: .93rem; }
  .byactivity-page-heading { width:100%; }
}
@media (max-width: 360px) {
  .home-page .common-function-card { min-height: 102px; }
  .home-calendar-card { padding-left: 6px !important; padding-right: 6px !important; }
  .home-calendar-grid { column-gap: 0 !important; }
  .home-calendar-day { padding-left: 0 !important; padding-right: 0 !important; }
}
@media (min-width: 820px) {
  .bb-app-toolbar-inner { max-width: 980px; }
  .home-hero img { max-height: 120px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    scroll-behavior: auto !important; transition-duration: .01ms !important;
  }
}
