body {
  margin: 0;
  font-family: 'Noto Sans TC', sans-serif;
  background: linear-gradient(135deg, #0f2027, #203a43, #2c5364);
  color: white;
}

/* 桌面 */
.desktop {
  height: 100dvh;
  padding: 30px;
  box-sizing: border-box;

  overflow: visible;
}

/* Grid */
.app-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 25px;
  justify-content: start;
  padding-bottom: calc(140px + env(safe-area-inset-bottom));
}

/* ===== App ===== */
.app {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center; /* 文字置中 */
  cursor: pointer;
  will-change: transform;
  transition: transform 0.25s ease;
}

/* icon */
.app img {
  width: 80px;
  height: 80px;
  border-radius: 20px;
  object-fit: cover;
  transition: transform 0.25s ease;

  /* 防止拖曳卡住 */
  pointer-events: none;
}

/* hover（拖曳時不觸發） */
.app:not(.dragging):hover img {
  transform: scale(1.1);
}

/* 文字 */
.app span {
  margin-top: 8px;
  font-size: 13px;
  width: 100%; 
  text-align: center;
  font-weight: 500;
  letter-spacing: 0.5px;
}

/* 連結 */
.app a {
  display: block;
  width: 100%;
  height: 100%;
  text-decoration: none;
  color: inherit;
}

/* ===== 拖曳 ===== */
.app.dragging {
  opacity: 0.5;
  transform: scale(1.1);
  transition: none !important; 
}

/* ===== 資料夾預覽 ===== */
.folder-preview {
  width: 80px;
  height: 80px;
  border-radius: 20px;
  background: rgba(255,255,255,0.12);
  backdrop-filter: blur(6px);

  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 5px;

  padding: 8px;
  box-sizing: border-box;

  transition: transform 0.25s ease;
}

.folder-preview:hover {
  transform: scale(1.1);
}

.folder-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 6px;
}

/* ===== 資料夾遮罩 ===== */
.folder {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);

  display: flex;
  align-items: center;
  justify-content: center;

  padding: 20px;

  opacity: 0;
  pointer-events: none;
  transition: 0.3s;

  z-index: 9999;
}

.folder.active {
  opacity: 1;
  pointer-events: auto;
}

/* ===== 資料夾內容 ===== */
.folder-box {
  width: 300px;
  height: 340px;

  background: rgba(30,30,30,0.9);
  border-radius: 25px;

  padding: 20px;

  transform: scale(0.8);
  transition: 0.3s;
}

.folder.active .folder-box {
  transform: scale(1);
}

/* Grid */
.folder-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: 100px;
  gap: 15px;
}

/* 項目 */
.folder-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
}

.folder-item img {
  width: 80px;
  height: 80px;
  border-radius: 20px;
  object-fit: cover;
  transition: 0.25s;
}

.folder-item:hover img {
  transform: scale(1.1);
}

/* 兩行斷字 */
.folder-item span {
  text-align: center;
  font-size: 11px;
  margin-top: 6px;
  width: 80px;
  line-height: 1.2em;
  height: 2.4em;

  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;

  overflow: hidden;
  word-break: break-word;
  color: #eee;
}

.folder-item:hover span {
  color: #ccc;
}

/* 關閉 */
.close-btn {
  text-align: right;
  margin-bottom: 10px;
  cursor: pointer;
}

/* ===== Dock ===== */
.dock {
  position: fixed;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);

  display: flex;
  gap: 25px;
  padding: 15px 25px;

  background: rgba(255,255,255,0.1);
  border-radius: 30px;
  backdrop-filter: blur(10px);

  align-items: center;
  z-index: 100;
}

.dock img {
  width: 60px;
  height: 60px;
  object-fit: contain;
  transition: transform 0.25s ease;
}

.dock a:hover img {
  transform: scale(1.4) translateY(-10px);
}

/* 預覽格 */
.preview-cell {
  width: 100%;
  aspect-ratio: 1 / 1;
  overflow: hidden;
}

.preview-cell img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ===== 手機版 ===== */
@media (max-width: 600px) {
  body {
  overscroll-behavior: none;
  }

  img {
  -webkit-user-drag: none;
  user-drag: none;
  }

  a {
    -webkit-user-drag: none;
  }

  .app {
    -webkit-user-drag: none;
  }

  .desktop {
    padding:
      calc(15px + env(safe-area-inset-top))
      15px
      calc(15px + env(safe-area-inset-bottom));
    display: flex;
    min-height: 100dvh;
    box-sizing: border-box; 
    justify-content: center;

    padding-bottom: 160px;
  }

  .app {
    -webkit-touch-callout: none; /*iOS 長按選單 */
    -webkit-user-select: none;
    transform: translate3d(0,0,0);
    user-select: none;
    width: 80px; 
    min-width: 0;
  }

.app-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-auto-rows: auto;
  gap: 16px;

  padding-bottom: 160px;
  justify-items: center;   /* 水平置中 */
}

  .app img {
    width: 100%;
    aspect-ratio: 1 / 1;
    height: auto;
    border-radius: 15px;
    max-width: 80px;
  }

  .app span {
    font-size: 11px;
  }

  .folder-preview {
    width: 100%;
    aspect-ratio: 1 / 1;
    grid-template-columns: repeat(2, 1fr);
    gap: 4px;
    padding: 6px;
    border-radius: 18px;
    
  }

  .folder-preview > * {
    aspect-ratio: 1 / 1;
    overflow: hidden;
  }

  .folder-preview img {
    border-radius: 3px;
  }

  .folder-box {
    width: 90%;
    max-height: 80vh;
    height: auto;
    overflow-y: auto;
  }

  .folder-grid {
    grid-template-columns: repeat(3, 1fr);
    grid-auto-rows: 90px;
    gap: 10px;
  }

  .folder-item img {
    width: 60px;
    height: 60px;
  }

  .folder-item span {
    width: 100%;
    font-size: 10px;
  }



  .dock {
    display: none;
  }

  html, body {
  overscroll-behavior: none;
  touch-action: manipulation;
  }

  .app-grid {
  touch-action: pan-y;
  }

  .app {
  touch-action: manipulation;
  }

  .app.dragging {
  touch-action: none;
  }
  

}

/* ===== 手機橫向提示 ===== */
.rotate-hint {
  position: fixed;
  inset: 0;
  z-index: 99999;

  display: flex;
  align-items: center;
  justify-content: center;

  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(10px);

  opacity: 0;
  pointer-events: none;
  transition: 0.35s ease;
}

.rotate-hint.show {
  opacity: 1;
  pointer-events: auto;
}

/* 卡片 */
.rotate-box {
  background: rgba(255,255,255,0.08);
  backdrop-filter: blur(20px);

  padding: 30px 40px;
  border-radius: 20px;

  text-align: center;
  color: white;

  transform: translateY(20px) scale(0.9);
  opacity: 0;

  transition: 0.4s cubic-bezier(.2,.8,.2,1);
}

.rotate-hint.show .rotate-box {
  transform: translateY(0) scale(1);
  opacity: 1;
}

/* ===== 手機 icon ===== */
.phone {
  width: 50px;
  height: 80px;
  border: 3px solid white;
  border-radius: 12px;
  margin: 0 auto 15px;

  position: relative;
}

/* 畫面 */
.screen {
  position: absolute;
  inset: 8px;
  background: white;
  border-radius: 6px;
}

/* ===== 動畫方向控制 ===== */

/* 右橫 */
.rotate-hint[data-dir="right"] .phone {
  animation: rotateRight 2.2s ease-in-out infinite;
}

/* 左橫 */
.rotate-hint[data-dir="left"] .phone {
  animation: rotateLeft 2.2s ease-in-out infinite;
}

/* ===== 動畫 ===== */

/* 右橫 → 轉回直 */
@keyframes rotateRight {
  0%   { transform: rotate(90deg); }   /* 一開始橫的 */

  20%  { transform: rotate(0deg); }    /* 轉回直 */
  90%  { transform: rotate(0deg); }    /* 直向停很久 */

  100% { transform: rotate(90deg); }   /* 回到橫 */
}

/* 左橫 → 轉回直 */
@keyframes rotateLeft {
  0%   { transform: rotate(-90deg); }  /* 一開始橫的 */

  20%  { transform: rotate(0deg); }
  90%  { transform: rotate(0deg); }    /* 停久一點 */

  100% { transform: rotate(-90deg); }
}
/* 文字 */
.rotate-box p {
  font-size: 16px;
  letter-spacing: 1px;
  opacity: 0.9;
}

/*跳轉介面*/
/* ===== 遮罩 ===== */
#overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: 0.3s;
  z-index: 9998;
}

#overlay.show {
  opacity: 1;
  pointer-events: none !important;
}

/* ===== 彈窗 ===== */
#m-warning {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -60%) scale(0.95);
  background: rgba(30,30,30,0.9);
  color: white;
  padding: 28px 32px;
  border-radius: 16px;
  font-size: 15px;
  text-align: center;
  min-width: 280px;
  z-index: 9999;
  display: none;
  opacity: 0;
  transition: 0.3s;
}

/* 顯示狀態 */
#m-warning.show {
  display: block;
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

/* 訊息 */
#m-msg {
  margin-bottom: 20px;
  font-size: 16px;
  font-weight: 500;
}

/* 按鈕區 */
.btn-group {
  display: flex;
  gap: 14px;
}

/* 按鈕 */
.btn-primary,
.btn-secondary {
  flex: 1;
  padding: 12px 0;
  font-size: 15px;
  border-radius: 10px;
  cursor: pointer;
}

/* 主按鈕 */
.btn-primary {
  background: #4da3ff;
  color: white;
  border: none;
}

.btn-primary:hover {
  background: #3a8be0;
}

/* 次按鈕 */
.btn-secondary {
  background: transparent;
  color: #ddd;
  border: 1px solid #777;
}

.btn-secondary:hover {
  background: rgba(255,255,255,0.1);
}


.app-emoji {
  width: 80px;
  height: 80px;

  display: flex;
  align-items: center;
  justify-content: center;

  font-size: 60px; 

  border-radius: 20px;
  background: #6b647a;

  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
}

.app-emoji span{
  display: block;
  font-size: 60px;
  line-height: 60px;

  transform: translateY(-8px);
}