:root{
  --p-bg: rgba(255,255,255,.88);
  --p-border: rgba(226,232,240,.95);
  --p-shadow: 0 10px 22px rgba(15,23,42,.10);
  --p-text: #0f172a;
  --p-sub: #334155;
}

/* iPhone bottom bar / safe area 通用修正：只要加 class="safe-bottom" 就保護 */
.safe-bottom{
  padding-bottom: calc(env(safe-area-inset-bottom) + 12px) !important;
}

/* ============ Floating Bar (Premium) ============ */
.fb{
  position: fixed;
  z-index: 99999; /* ✅ 拉高，避免 canvas/overlay 蓋住 */
  left: calc(env(safe-area-inset-left) + 12px);
  top: calc(env(safe-area-inset-top) + 12px);
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
  touch-action: none;
  pointer-events: auto;
}

.fb *{ pointer-events: auto; }

.fb__handle{
  width: 36px;
  height: 36px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: rgba(255,237,213,.92);
  border: 1px solid var(--p-border);
  box-shadow: 0 8px 18px rgba(15,23,42,.06);
  color: #ea580c;
  font-weight: 900;
  cursor: grab;
}

.fb:active .fb__handle{ cursor: grabbing; }

.fb__btn{
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 14px;
  background: var(--p-bg);
  border: 1px solid var(--p-border);
  box-shadow: var(--p-shadow);
  color: var(--p-text);
  text-decoration: none;
  font-size: 12px;
  font-weight: 600;
  backdrop-filter: blur(10px);
}

.fb__icon{ font-size: 14px; }
.fb__text{ white-space: nowrap; }

.fb__btn--home{
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 999px;
  justify-content: center;
}
.fb__icon--home{
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.fb__icon--home svg{ display:block; width:24px; height:24px; }

.fb--compact .fb__handle{
  width: 30px;
  height: 30px;
  border-radius: 12px;
  font-size: 14px;
}
.fb--compact .fb__btn--home{
  width: 32px;
  height: 32px;
}
.fb--compact .fb__icon--home svg{ width:18px; height:18px; }

.fb__toggle{
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(248,250,252,.92);
  border: 1px solid var(--p-border);
  font-size: 12px;
  color: var(--p-sub);
  font-weight: 700;
  box-shadow: 0 8px 18px rgba(15,23,42,.06);
  cursor: pointer;
}

.backer-footer{
  width: 100%;
  text-align: center;
  font-size: 13px;
  color: #475569;
  letter-spacing: 0.01em;
  padding: 14px 12px 16px;
  white-space: nowrap;
}
.backer-footer--wrap{ white-space: normal; }
.backer-footer a{
  color: #f97316;
  font-weight: 800;
  text-decoration: none;
}
.backer-footer a:hover{ text-decoration: underline; }
.backer-footer--safe{
  padding-bottom: calc(env(safe-area-inset-bottom) + 78px);
}
.backer-footer--fixed{
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 60;
  background: rgba(255,255,255,.85);
  backdrop-filter: blur(10px);
  padding: 10px 12px calc(env(safe-area-inset-bottom) + 10px);
}
.backer-footer--inline{
  margin-top: auto;
  background: transparent;
  padding: 10px 12px 14px;
}
.backer-footer--panel{
  background: transparent;
  padding: 8px 12px 10px;
  font-size: 12px;
}
.backer-footer--panel-right{
  margin-top: auto;
  padding: 8px 6px 4px;
  font-size: 12px;
  color: #64748b;
}

/* 收折 */
.fb--closed .fb__text{ display:none; }
.fb--closed .fb__toggle{ display:none; }
.fb--closed .fb__btn{
  padding: 10px;
  border-radius: 999px;
}

/* 手機上稍微縮小，減少遮擋 */
@media (max-width: 640px){
  .fb__btn, .fb__toggle{ padding: 9px 10px; border-radius: 13px; }
  .fb__handle{ width: 34px; height: 34px; border-radius: 13px; }
  .fb__btn--home{ width: 38px; height: 38px; padding: 0; }
  .fb__icon--home svg{ width:22px; height:22px; }
}
