/* ===== iOS Multi-page Desktop ===== */

.desktop-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  z-index: 2;
  padding-bottom: 110px; /* 为底部 Dock 留空 */
}

.pages-wrapper {
  display: flex;
  flex: 1;
  width: 100%;
  transition: transform 0.42s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  touch-action: pan-x;
  will-change: transform;
}

.desktop-page {
  min-width: 100%;
  width: 100%;
  flex-shrink: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 16px 20px 8px;
  box-sizing: border-box;
}

.desktop-page .app-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px 8px;
  width: 100%;
  max-width: 360px;
  justify-items: center;
  align-content: start;
}

/* ===== Page Indicators (iOS dots) ===== */
.page-indicators {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 12px 0;
}

.indicator {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255,255,255,0.35);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.34,1.56,0.64,1);
}

.indicator.active {
  background: rgba(255,255,255,0.95);
  width: 20px;
  border-radius: 4px;
  box-shadow: 0 0 6px rgba(255,255,255,0.4);
}

.indicator:hover {
  background: rgba(255,255,255,0.6);
}

/* ===== Drag & Drop ===== */
.desktop-page .app-icon {
  position: relative;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

.desktop-page .app-icon.dragging {
  opacity: 0.35;
  transform: scale(0.88);
}

.drag-ghost {
  position: fixed;
  pointer-events: none;
  z-index: 10000;
  display: none;
  transform: translate(-50%, -50%) scale(1.12);
  filter: drop-shadow(0 12px 28px rgba(0,0,0,0.28));
  transition: none;
}

.drag-ghost.active {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.drag-ghost .icon-wrapper {
  width: 76px;
  height: 76px;
  border-radius: 17px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 12px 36px rgba(0,0,0,0.30);
  background: linear-gradient(135deg,#ff9a9e 0%,#fad0c4 100%);
}

.drag-ghost .main-icon { font-size: 2.2rem; }
.drag-ghost .app-name {
  color: #fff;
  font-size: 0.78rem;
  text-shadow: 0 1px 6px rgba(0,0,0,0.35);
  font-weight: 400;
}

/* Drop target ring */
.desktop-page .app-icon.drop-target::before {
  content: '';
  position: absolute;
  inset: -6px;
  border: 2px dashed rgba(255,255,255,0.7);
  border-radius: 22px;
  animation: pulse 0.7s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}

.app-placeholder {
  width: 76px;
  height: 106px;
  border: 2px dashed rgba(255,255,255,0.18);
  border-radius: 17px;
  opacity: 0;
  transition: opacity 0.2s;
}
.app-placeholder.visible { opacity: 1; }

/* ===== Edit Mode (wiggle like iOS) ===== */
body.edit-mode .desktop-page .app-icon {
  animation: wiggle 0.28s ease-in-out infinite;
}
body.edit-mode .desktop-page .app-icon:nth-child(even) {
  animation-delay: 0.14s;
}
@keyframes wiggle {
  0%, 100% { transform: rotate(-1.8deg); }
  50% { transform: rotate(1.8deg); }
}

/* Delete badge */
.desktop-page .app-icon .delete-btn {
  position: absolute;
  top: -7px;
  left: -7px;
  width: 20px;
  height: 20px;
  background: #ff3b30;
  border: 2px solid #fff;
  border-radius: 50%;
  color: #fff;
  font-size: 12px;
  line-height: 16px;
  text-align: center;
  cursor: pointer;
  display: none;
  z-index: 10;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
  font-weight: 700;
}
body.edit-mode .desktop-page .app-icon .delete-btn { display: block; }

/* ===== Icon styles ===== */
.desktop-page .icon-wrapper {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.22), 0 1px 2px rgba(0,0,0,0.10);
  transition: transform 0.15s cubic-bezier(0.34,1.56,0.64,1);
  background: linear-gradient(145deg,#ff9a9e,#fad0c4);
  will-change: transform;
}
.desktop-page .icon-wrapper:active { transform: scale(0.86); transition: transform 0.08s ease; }
.desktop-page .main-icon {
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.5px;
  text-shadow: 0 1px 2px rgba(0,0,0,0.18);
  line-height: 1;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", sans-serif;
}
.desktop-page .app-name {
  color: #fff;
  font-size: 0.72rem;
  font-weight: 400;
  text-shadow: 0 1px 4px rgba(0,0,0,0.4);
  text-align: center;
  width: 72px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: 0.1px;
  margin-top: 2px;
}

/* ===== Responsive ===== */
@media (max-width: 375px) {
  .desktop-page .app-grid { max-width: 290px; gap: 16px 20px; }
  .desktop-page .icon-wrapper { width: 64px; height: 64px; border-radius: 15px; }
  .desktop-page .main-icon { font-size: 1.9rem; }
  .desktop-page .app-name { font-size: 0.72rem; max-width: 64px; }
  .drag-ghost .icon-wrapper { width: 64px; height: 64px; }
}
@media (max-width: 320px) {
  .desktop-page .app-grid { max-width: 250px; gap: 12px 14px; }
  .desktop-page .icon-wrapper { width: 56px; height: 56px; border-radius: 13px; }
  .desktop-page .main-icon { font-size: 1.7rem; }
  .desktop-page .app-name { font-size: 0.68rem; max-width: 56px; }
}
@media (min-width: 769px) {
  .desktop-page .app-grid { max-width: 400px; gap: 24px 38px; }
  .desktop-page .icon-wrapper { width: 82px; height: 82px; border-radius: 19px; }
  .desktop-page .main-icon { font-size: 2.4rem; }
  .desktop-page .app-name { font-size: 0.82rem; max-width: 82px; }
}
@media (min-width: 481px) and (max-width: 768px) {
  .desktop-page .app-grid { max-width: 360px; gap: 20px 32px; }
  .desktop-page .icon-wrapper { width: 78px; height: 78px; }
}
@media (orientation: landscape) and (max-height: 500px) {
  .desktop-container { padding-bottom: 12px; }
  .desktop-page { padding: 8px 20px; }
  .desktop-page .app-grid { max-width: 400px; gap: 10px 28px; min-height: 180px; }
  .desktop-page .icon-wrapper { width: 52px; height: 52px; }
  .desktop-page .main-icon { font-size: 1.5rem; }
  .desktop-page .app-name { font-size: 0.7rem; }
  .page-indicators { padding: 6px 0; }
}

/* ===== iOS Dock ===== */
.ios-dock {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  padding: 10px 20px 28px;
  z-index: 100;
  display: flex;
  justify-content: center;
}

.dock-inner {
  display: flex;
  gap: 16px;
  background: rgba(255,255,255,0.22);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-radius: 26px;
  padding: 12px 20px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.16), inset 0 0.5px 0 rgba(255,255,255,0.4);
  border: 0.5px solid rgba(255,255,255,0.3);
}

.dock-app {
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
}

.dock-icon {
  width: 58px;
  height: 58px;
  border-radius: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 10px rgba(0,0,0,0.22);
  transition: transform 0.15s cubic-bezier(0.34,1.56,0.64,1);
  padding: 10px;
}

.dock-icon:active {
  transform: scale(0.86);
}

.dock-icon svg {
  width: 100%;
  height: 100%;
}
