/* V37：解鎖蘑菇 + 登入鈕 #v37LoginBtn 右上固定 + 圖片模糊 */
.postcard-card.v37-mushroom-locked {
  position: relative;
}

/* V38 Optimization: Hardware accelerate blurred cards */
.postcard-card.v37-mushroom-locked .postcard-photo img {
  filter: blur(25px) brightness(0.9);
  transform: translateZ(0) scale(1.04);
  will-change: filter;
  transition: filter .25s ease, transform .25s ease;
}

.postcard-card.v37-mushroom-locked .postcard-photo::after {
  content: "待解鎖";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  color: #ffffff !important;
  background: transparent !important;
  padding: 6px 14px;
  border-radius: 50px;
  font-size: 11px;
  font-weight: 800;
  border: 1px solid rgba(255, 255, 255, 0.6) !important;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  pointer-events: none;
  z-index: 2;
  backdrop-filter: blur(4px);
}

.postcard-card.v37-mushroom-locked .postcard-coords {
  color: #6b7a70 !important;
  background: rgba(226, 234, 226, .86) !important;
  border: 1px dashed rgba(79, 117, 88, .45) !important;
  cursor: default !important;
  user-select: none;
  font-size: 11px !important;
}

/* host：全螢幕 fixed 層，強制 GPU 合成（translateZ）確保 fixed 在所有瀏覽器正確 */
.sidebar-auth-section {
  margin-top: auto !important; /* 推到側邊欄底部 */
  padding: 15px !important;
  display: flex !important;
  justify-content: center !important;
  border-top: 1px solid rgba(0,0,0,0.05);
  transition: padding 0.3s ease;
}

.sidebar.collapsed .sidebar-auth-section {
  padding: 10px 5px !important;
}

/* 登入鈕：呼吸 + 外發光（僅陰影／透明度，避免 keyframes transform 破壞 fixed） */
@keyframes v37-login-breathe-glow {
  0%, 100% {
    box-shadow:
      0 4px 12px rgba(0, 0, 0, 0.05),
      0 0 0 0 rgba(120, 201, 107, 0.15);
    transform: scale(1);
  }
  50% {
    box-shadow:
      0 6px 18px rgba(39, 122, 65, 0.08),
      0 0 15px 4px rgba(168, 224, 99, 0.25);
    transform: scale(1.02);
  }
}

/* 已解鎖／管理員：較溫和的橘光 */
@keyframes v37-login-breathe-glow-warm {
  0%, 100% {
    box-shadow:
      0 4px 12px rgba(0, 0, 0, 0.05),
      0 0 0 0 rgba(255, 200, 87, 0.2);
    transform: scale(1);
  }
  50% {
    box-shadow:
      0 6px 18px rgba(242, 139, 46, 0.08),
      0 0 15px 5px rgba(255, 200, 87, 0.35);
    transform: scale(1.02);
  }
}

/* 🌱 登入按鈕：使用最高權重選擇器 + fixed 定位 */
html body #v37LoginBtn {
  position: relative !important;
  top: 15px !important;
  right: auto !important;
  left: auto !important;
  bottom: auto !important;
  margin: 0 auto !important;
  
  width: 58px;
  height: 58px;
  border: none !important;
  border-radius: 18px;

  display: flex;
  align-items: center;
  justify-content: center;

  font-size: 26px;
  background: transparent !important;
  color: #56ab2f !important;

  box-shadow: none !important;
  cursor: pointer;
  transition: all 0.3s ease !important; /* 強制與側邊欄 0.3s 同步 */
}

.sidebar.collapsed #v37LoginBtn {
  width: 44px;
  height: 44px;
  border: none !important;
  border-radius: 50%;
  font-size: 24px;
  background: transparent !important;
  box-shadow: none !important;
  animation: none !important; /* 收合時不跳動，保持簡潔 */
}

/* 讓收合時的解鎖狀態也保持一致 */
.sidebar.collapsed #v37LoginBtn.v37-unlocked {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
}

html body #v37LoginBtn:hover {
  transform: translateY(-2px) scale(1.05);
  background: rgba(120, 201, 107, 0.08) !important;
}

.sidebar.collapsed #v37LoginBtn:hover {
  background: rgba(120, 201, 107, 0.12) !important;
  transform: scale(1.1);
}

html body #v37LoginBtn.v37-unlocked {
  background: transparent !important;
  color: #f28b2e !important;
}

html body #v37LoginBtn.v37-unlocked:hover {
  background: rgba(242, 139, 46, 0.08) !important;
}

/* 窄頁面模式 (手機/平板)：整合進 Logo 標題容器最右側 */
@media (max-width: 1024px) {
  /* 確保外層標題容器可以作為定位基準 */
  .main-header {
    position: relative !important;
    overflow: visible !important; /* 防止按鈕被裁切 */
  }

  html body #v37LoginBtn {
    display: flex !important;
    visibility: visible !important;
    position: absolute !important;
    top: 50% !important;
    right: 20px !important;
    left: auto !important;
    bottom: auto !important;
    transform: translateY(-50%) !important;
    
    width: 44px !important;
    height: 44px !important;
    border-radius: 50% !important;
    
    /* 暫時加上背景與輕微邊框確保能看見 */
    background: rgba(255, 255, 255, 0.4) !important;
    border: 1px solid rgba(120, 201, 107, 0.2) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05) !important;
    z-index: 99999 !important;
    
    color: #56ab2f !important;
    /* 懸浮動作按鈕 (FAB)：新增明信片按鈕 */
  html body #openUploadBtn {
    position: fixed !important;
    bottom: 25px !important;
    right: 20px !important;
    left: auto !important;
    top: auto !important;
    
    width: 60px !important;
    height: 60px !important;
    border-radius: 50% !important;
    
    background: #78c96b !important;
    color: white !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2) !important;
    z-index: 10000 !important;
    
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 !important;
    font-size: 30px !important;
  }

  html body #openUploadBtn .btn-text {
    display: none !important; /* 手機版隱藏文字，只留 + 號 */
  }

  html body #openUploadBtn:active {
    transform: scale(0.9);
  }

  /* 窄螢幕下縮短公告欄高度 */
  #bulletinContainer {
    min-height: 150px !important;
    max-height: 150px !important;
  }
}

  html body #v37LoginBtn:hover {
    transform: translateY(-50%) scale(1.1) !important;
    background: rgba(255, 255, 255, 0.8) !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  html body #v37LoginBtn {
    animation: none !important;
    transition: none;
  }

  html body #v37LoginBtn:hover {
    transform: none;
  }
}

#v37AuthPanelBackdrop {
  position: fixed;
  inset: 0;
  z-index: 10060;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  /* 遮罩要夠透，面板上的 backdrop-filter 才會模糊到「網頁內容」，否則只糊在灰底上像實色 */
  background: rgba(22, 38, 28, 0.14);
  backdrop-filter: blur(10px) saturate(1.08);
  -webkit-backdrop-filter: blur(10px) saturate(1.08);
}

#v37AuthPanelBackdrop.show {
  display: flex;
}

/* 玻璃擬態：低不透明度 + 強模糊；isolation 協助合成層穩定 */
.v37-auth-panel {
  position: relative;
  isolation: isolate;
  width: min(420px, 100%);
  border-radius: 22px;
  padding: 22px 22px 20px;
  color: #1a2e1f;
  background: rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(40px) saturate(1.65);
  -webkit-backdrop-filter: blur(40px) saturate(1.65);
  border: 1px solid rgba(255, 255, 255, 0.58);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.55),
    inset 0 0 0 1px rgba(255, 255, 255, 0.08),
    0 24px 56px rgba(12, 36, 24, 0.14);
}

.v37-auth-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}

.v37-auth-title {
  font-size: 20px;
  font-weight: 900;
  margin: 0 0 4px;
  color: #132818;
  letter-spacing: -0.02em;
}

.v37-auth-subtitle {
  font-size: 13px;
  margin: 0;
  color: rgba(38, 62, 44, 0.78);
  line-height: 1.5;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.35);
}

.v37-auth-close {
  border: 1px solid rgba(255, 255, 255, 0.5);
  background: rgba(255, 255, 255, 0.28);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: 999px;
  width: 36px;
  height: 36px;
  cursor: pointer;
  font-size: 18px;
  color: rgba(32, 52, 38, 0.75);
  line-height: 1;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.4) inset;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}

.v37-auth-close:hover {
  background: rgba(255, 255, 255, 0.48);
  color: #1a2e1f;
}

.v37-auth-field {
  display: flex !important;
  flex-direction: column !important;
  align-items: flex-start !important;
  gap: 8px !important;
  margin: 12px 0 !important;
  width: 100% !important;
}

.v37-auth-field label {
  font-size: 13px !important;
  font-weight: 800 !important;
  color: rgba(36, 58, 42, 0.88) !important;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.3) !important;
  margin-bottom: 4px !important;
}

.v37-auth-input {
  display: block !important;
  width: 100% !important;
  box-sizing: border-box !important;
  border: 1px solid rgba(255, 255, 255, 0.55) !important;
  background: rgba(255, 255, 255, 0.42) !important;
  backdrop-filter: blur(12px) !important;
  -webkit-backdrop-filter: blur(12px) !important;
  border-radius: 999px !important; /* 強制恢復圓角 */
  padding: 11px 20px !important;
  font-size: 15px !important;
  outline: none !important;
  color: #142818 !important;
  margin-top: 2px !important;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.35) inset !important;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease !important;
}

.v37-auth-field input::placeholder {
  color: rgba(38, 58, 44, 0.45);
}

.v37-auth-field input:focus {
  border-color: rgba(94, 168, 88, 0.85);
  background: rgba(255, 255, 255, 0.5);
  box-shadow:
    0 0 0 3px rgba(117, 184, 109, 0.22),
    0 1px 0 rgba(255, 255, 255, 0.45) inset;
}

/* Google 已登入：唯讀顯示暱稱／邀請碼（無按鈕） */
.v37-auth-readonly-block {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 10px;
  padding: 11px 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.36);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.45);
  font-size: 15px;
  line-height: 1.45;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.3) inset;
}

/* 未登入時會設 hidden；勿讓 display:flex 蓋掉原生 hidden，否則唯讀列會重疊在輸入框下方 */
.v37-auth-readonly-block[hidden] {
  display: none !important;
}

.v37-auth-bound-label {
  font-weight: 800;
  color: rgba(36, 58, 42, 0.85);
  flex-shrink: 0;
}

.v37-auth-bound-value {
  font-weight: 800;
  color: #142818;
  letter-spacing: 0.02em;
  word-break: break-all;
}

.v37-auth-actions {
  display: grid;
  gap: 10px;
  margin-top: 29px;
}

.v37-auth-primary,
.v37-auth-secondary,
.v37-auth-danger {
  border-radius: 999px;
  min-height: 46px;
  padding: 12px 18px;
  cursor: pointer;
  font-weight: 900;
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease, border-color 0.16s ease;
}

.v37-auth-primary {
  border: 1px solid rgba(255, 255, 255, 0.7);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #14522a;
  box-shadow: 0 10px 28px rgba(24, 56, 36, 0.14);
}

.v37-auth-primary:hover {
  background: #fff;
  box-shadow: 0 12px 32px rgba(24, 56, 36, 0.18);
  transform: translateY(-1px);
}

.v37-auth-secondary {
  border: 1px solid rgba(255, 255, 255, 0.45);
  background: rgba(255, 255, 255, 0.22);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #1e3a24;
}

.v37-auth-danger {
  border: 1px solid rgba(255, 200, 180, 0.65);
  background: rgba(255, 245, 240, 0.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #9a3412;
}

.v37-auth-danger:hover {
  background: rgba(255, 235, 228, 0.62);
}

.v37-auth-status {
  min-height: 20px;
  margin-top: 10px;
  color: rgba(42, 72, 52, 0.82);
  font-size: 13px;
  line-height: 1.45;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.25);
}

.v37-modal-locked #modalCardImage {
  filter: blur(10px) brightness(.72);
}

.v37-modal-locked #modalCardLocation {
  color: #6b7a70;
}

/* LOGO 文字區塊：100% 透明（避免被其他樣式覆蓋） */
header.main-header,
header.main-header .brand,
header.main-header .brand-text,
header.main-header .brand-text h1,
header.main-header .brand-text p {
  background: transparent !important;
  background-color: transparent !important;
  box-shadow: none !important;
}

@media (prefers-reduced-transparency: reduce) {
  #v37AuthPanelBackdrop {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: rgba(22, 38, 28, 0.72);
  }

  .v37-auth-panel {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: rgba(255, 253, 248, 0.97);
  }

  .v37-auth-field input,
  .v37-auth-readonly-block,
  .v37-auth-close,
  .v37-auth-secondary,
  .v37-auth-danger {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
}

@media (max-width: 768px) {
  html body #v37LoginBtn {
    width: 50px;
    height: 50px;
    font-size: 23px;
  }
}

/* 搜尋欄與按鈕中間：即時蘑菇情報（寬版/窄版固定 80px） */
.main.v28-scope .pikmin-toolbar .mushroom-info-slot {
  grid-column: 1 / -1 !important;
  order: 2 !important;
  transform: translateY(-30px) !important;
  height: 80px !important;
  min-height: 80px !important;
  max-height: 80px !important;
  border-radius: 16px !important;
  border: 1px solid rgba(120, 160, 102, 0.22) !important;
  background: rgba(255, 255, 255, 0.42) !important;
  display: flex !important;
  align-items: center !important;
  padding: 0 16px !important;
  overflow: hidden !important;
}

.main.v28-scope .pikmin-toolbar .mushroom-info-title {
  font-size: 14px !important;
  font-weight: 800 !important;
  color: #2f7438 !important;
  letter-spacing: 0.01em !important;
}

/* 搜尋葉子避免被上方裁切：只對 toolbar 與 search-box 開 visible，不碰 .main 避免破壞 fixed 定位 */
.main.v28-scope > .toolbar.pikmin-toolbar,
.main.v28-scope .pikmin-toolbar .pikmin-search.search-box {
  overflow: visible !important;
}

.main.v28-scope .pikmin-toolbar .pikmin-leaf {
  top: -10px !important;
  right: 17px !important;
  z-index: 10 !important;
}

/* 讓搜尋欄工具列浮在 main-header 之上（isolation 建立新 stacking context，使葉子可見） */
.main.v28-scope > .toolbar.pikmin-toolbar {
  isolation: isolate;
  z-index: 2;
  position: relative;
}

header.main-header {
  z-index: 1;
  position: relative;
}

/* 即時蘑菇情報下方按鈕列 + 內容區再往上 10px */
.main.v28-scope .pikmin-toolbar .pikmin-toolbar-actions {
  transform: translateY(-20px) !important;
}

.main.v28-scope #collectionView,
.main.v28-scope #mapView {
  margin-top: -20px !important;
}

/* 預覽／瀏覽模式：桌機覆寫 v33-sidebar 的側欄 margin-left，避免內容縮在左半邊 */
@media (min-width: 1025px) {
  /* 桌機：搜尋欄、蘑菇情報、按鈕、內文整體上移 50px（由 100 -> 50） */
  .main.v28-scope {
    padding-top: 50px !important;
  }
  /* 在整體下移後，搜尋欄單獨往上 50px */
  .main.v28-scope .pikmin-toolbar .pikmin-search.search-box {
    order: 1 !important;
    transform: translateY(-50px) !important;
    margin-bottom: -5px !important;
  }
  .main.v28-scope .pikmin-toolbar .pikmin-toolbar-actions {
    order: 3 !important;
  }

  body.is-browse-mode .sidebar ~ header.main-header,
  body.is-browse-mode .sidebar ~ main.main,
  body.is-browse-mode .sidebar ~ .main-footer-guestbook {
    margin-left: 0 !important;
    margin-right: 0 !important;
    width: 100% !important;
    max-width: none !important;
  }
}

/* 窄版：搜尋欄單獨往上 50px（其餘按鈕與內容維持原位） */
@media (max-width: 1024px) {
  .main.v28-scope .pikmin-toolbar .pikmin-search.search-box {
    order: 1 !important;
    transform: translateY(-50px) !important;
    margin-bottom: -5px !important;
  }
  .main.v28-scope .pikmin-toolbar .pikmin-toolbar-actions {
    order: 3 !important;
  }
}
