/* =========================================
   全站基礎設定與 3D 舞台
========================================= */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "PingFang TC", "Microsoft JhengHei", sans-serif;
}

body,
html {
  width: 100vw;
  height: 100vh; height: 100dvh;
  background: url("images/background.webp") no-repeat center center fixed;
  background-size: cover;
  background-color: #06192a;
  color: white;
  overflow: hidden !important;
  user-select: none;
  -webkit-user-select: none;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background: radial-gradient(
    circle at 50% 45%,
    rgba(0, 30, 60, 0.35) 0%,
    rgba(2, 15, 30, 0.85) 100%
  );
  z-index: -1;
}

/* =========================================
   頂部導覽列（電腦版預設）
========================================= */
.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  background: rgba(255, 255, 255, 0.1);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 100;
}

.top-bar h1 {
  font-size: 1.3rem;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
  letter-spacing: 0.5px;
  white-space: nowrap;
  flex-shrink: 0;
}

.top-bar > div {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

.btn-back {
  background: rgba(255, 255, 255, 0.15);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.4);
  padding: 6px 14px;
  border-radius: 20px;
  cursor: pointer;
  transition: 0.25s;
  font-weight: bold;
  font-size: 0.88rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-back:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: translateY(-2px);
}

.btn-refresh {
  background: linear-gradient(
    135deg,
    rgba(77, 166, 255, 0.35),
    rgba(0, 115, 230, 0.45)
  ) !important;
  border-color: #38bdf8 !important;
}
.btn-refresh:hover {
  background: linear-gradient(135deg, #4da6ff, #0073e6) !important;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.5);
}

/* =========================================
   🌐 3D 空間視窗
========================================= */
.sphere-viewport {
  position: absolute;
  inset: 0;
  perspective: 1000px;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: grab;
  touch-action: none;
  z-index: 10;
}

.sphere-viewport:active {
  cursor: grabbing;
}

.sphere-world {
  position: relative;
  width: 0;
  height: 0;
  will-change: transform;
  transition: opacity 0.25s ease;
}

.sphere-world.refreshing {
  opacity: 0;
}

/* 📌 便利貼卡片 */
.note-card {
  position: absolute;
  width: 175px;
  min-height: 125px;
  left: -87px;
  top: -62px;
  padding: 18px 14px 10px 14px;
  border-radius: 3px 16px 3px 16px;
  color: #1e3a8a;
  box-shadow:
    0 12px 25px rgba(0, 0, 0, 0.3),
    inset 0 0 12px rgba(255, 255, 255, 0.45);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  cursor: pointer;
  will-change: transform, opacity, filter;
  transition:
    filter 0.15s ease,
    opacity 0.15s ease,
    box-shadow 0.25s ease;
}

.note-card::before {
  content: "";
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%) rotate(-2deg);
  width: 52px;
  height: 17px;
  background: rgba(255, 255, 255, 0.45);
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
  border: 1px solid rgba(255, 255, 255, 0.4);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  z-index: 2;
}

.note-card.is-focused {
  box-shadow:
    0 18px 45px rgba(56, 189, 248, 0.65),
    0 0 25px rgba(255, 255, 255, 0.9),
    inset 0 0 15px rgba(255, 255, 255, 0.8) !important;
  filter: drop-shadow(0 0 12px rgba(56, 189, 248, 0.6)) brightness(1.06) !important;
}

.note-text {
  font-size: 0.95rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  flex-grow: 1;
  font-weight: 800;
  z-index: 1;
}

.note-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  font-size: 0.75rem;
  color: rgba(0, 0, 0, 0.55);
  border-top: 1px dashed rgba(0, 0, 0, 0.18);
  padding-top: 6px;
  font-weight: bold;
}

/* 操作提示 */
.drag-hint {
  position: absolute;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 15, 35, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.2);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  padding: 7px 18px;
  border-radius: 25px;
  font-size: 0.82rem;
  color: #cbd5e1;
  pointer-events: none;
  letter-spacing: 0.5px;
  white-space: nowrap;
  z-index: 50;
}

/* =========================================
   ✏️ 浮動發布按鈕與輸入彈窗
========================================= */
.fab-create-btn {
  position: fixed;
  bottom: 22px;
  right: 22px;
  padding: 10px 20px;
  border-radius: 25px;
  background: linear-gradient(135deg, #00b4db, #0083b0);
  border: 1.5px solid rgba(255, 255, 255, 0.6);
  color: #ffffff;
  font-size: 0.95rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(0, 180, 219, 0.4);
  transition: all 0.25s ease;
  z-index: 100;
}

.fab-create-btn:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 12px 28px rgba(0, 180, 219, 0.6);
}

.creator-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 15, 30, 0.72);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  z-index: 200;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 15px;
}

.glass-panel {
  background: rgba(10, 30, 55, 0.95);
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
  border: 1.5px solid rgba(77, 166, 255, 0.45);
  border-radius: 22px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.6);
}

.note-creator {
  padding: 24px 20px;
  width: 100%;
  max-width: 440px;
}

.creator-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}
.creator-header h3 {
  margin: 0;
  font-size: 1.15rem;
  color: #38bdf8;
  font-weight: 800;
}
.close-modal-btn {
  font-size: 1.25rem;
  color: #94a3b8;
  cursor: pointer;
}
.close-modal-btn:hover {
  color: #ff6b6b;
}

.note-creator textarea {
  width: 100%;
  background: rgba(255, 255, 255, 0.08);
  border: 1.5px solid rgba(255, 255, 255, 0.2);
  border-radius: 14px;
  padding: 14px;
  color: white;
  font-size: 1rem;
  resize: none;
  outline: none;
  line-height: 1.6;
}
.note-creator textarea:focus {
  border-color: #38bdf8;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.4);
}
.note-creator textarea::placeholder {
  color: rgba(255, 255, 255, 0.6);
}

.creator-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 14px;
}

.char-count {
  font-size: 0.85rem;
  font-weight: bold;
  color: rgba(255, 255, 255, 0.7);
  background: rgba(255, 255, 255, 0.1);
  padding: 4px 10px;
  border-radius: 10px;
}
.char-count.limit {
  color: #ff9999;
}

.btn-action {
  background: linear-gradient(135deg, #00b4db, #0083b0);
  color: white;
  border: none;
  padding: 9px 24px;
  border-radius: 20px;
  font-weight: bold;
  font-size: 0.95rem;
  cursor: pointer;
  transition: 0.25s;
}
.btn-action:hover {
  filter: brightness(1.15);
}

/* 吐司通知 */
#toast-container {
  position: fixed;
  top: 75px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: rgba(10, 30, 55, 0.92);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.4);
  color: #fff;
  padding: 10px 24px;
  border-radius: 40px;
  font-size: 0.9rem;
  font-weight: bold;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.35);
  opacity: 0;
  transform: translateY(-20px);
  animation: slideIn 0.35s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;
}

.toast.success {
  border-left: 4px solid #4ade80;
}
.toast.warning {
  border-left: 4px solid #facc15;
}
.toast.error {
  border-left: 4px solid #ef4444;
}
.toast.fade-out {
  animation: fadeOut 0.3s forwards;
}

@keyframes slideIn {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
@keyframes fadeOut {
  to {
    opacity: 0;
    transform: translateY(-20px);
  }
}

/* =========================================
   📱 手機版 RWD 專屬優化 (極致防擠壓)
========================================= */
@media screen and (max-width: 600px) {
  /* 1. 頂部導覽列：完美單行防折行 */
  .top-bar {
    padding: 8px 10px;
  }
  .top-bar h1 {
    font-size: 0.92rem;
    white-space: nowrap !important;
    letter-spacing: 0;
  }
  .top-bar > div {
    gap: 4px !important;
  }
  .btn-back {
    padding: 4px 7px !important;
    font-size: 0.74rem !important;
    border-radius: 12px;
    white-space: nowrap !important;
    flex-shrink: 0;
  }

  /* 2. 手機版便利貼尺寸：等比縮小，避免過大擠壓視角 */
  .note-card {
    width: 120px;
    min-height: 88px;
    left: -60px;
    top: -44px;
    padding: 10px 8px 5px 8px;
    border-radius: 3px 12px 3px 12px;
  }
  .note-card::before {
    width: 36px;
    height: 12px;
    top: -5px;
  }
  .note-text {
    font-size: 0.74rem;
    line-height: 1.32;
  }
  .note-footer {
    font-size: 0.63rem;
    margin-top: 3px;
    padding-top: 3px;
  }

  /* 3. 底部提示列與發布按鈕 */
  .drag-hint {
    bottom: 72px;
    font-size: 0.72rem;
    padding: 5px 12px;
    max-width: 90%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .fab-create-btn {
    bottom: 18px;
    right: 14px;
    padding: 8px 16px;
    font-size: 0.86rem;
  }
}
