/* ==============================================
   iOS Simulation - Desktop Adaptive v2
   移动端: 全屏 iPhone 风格
   桌面端 (>=768px): 原生适配桌面，铺满窗口
   ============================================== */

:root {
  --ios-bg: #000;
  --ios-wallpaper: linear-gradient(180deg, #1e293b 0%, #0f172a 35%, #0a0f1a 70%, #05080e 100%);
  --ios-text: #fff;
  --ios-blue: #007aff;
  --ios-red: #ff3b30;
  --ios-green: #34c759;
  --ios-orange: #ff9500;
  --ios-gray: #8e8e93;

  --status-height: 54px;
  --dock-height: 92px;
  --app-icon-size: 60px;
  --app-icon-radius: 15px;
  --grid-columns: 4;
  --grid-gap: clamp(16px, 2.5vw, 40px);
  --grid-row-gap: clamp(18px, 3vh, 40px);
  --home-padding-x: clamp(20px, 6vw, 80px);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; user-select: none; }

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  font-family: -apple-system, 'SF Pro Display', 'SF Pro Text', 'Helvetica Neue', sans-serif;
  background: #000;
  color: var(--ios-text);
}

#app-container {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
  background: #000;
}

/* ========== MOBILE (< 768px): full-screen phone fill ========== */
@media (max-width: 767px) {
  body { background: #000; }
}

/* ========== DESKTOP (>= 768px): adaptive full-window ========== */
@media (min-width: 768px) {
  :root {
    --status-height: 44px;
    --dock-height: clamp(100px, 12vh, 140px);
    --app-icon-size: clamp(72px, 7vw, 110px);
    --app-icon-radius: calc(var(--app-icon-size) * 0.25);
  }
  body { background: #05080a; }
  #app-container {
    max-width: min(90vw, 1200px);
    margin: 0 auto;
  }
  .ios-notch { display: none; }
  .status-bar { padding: 0 clamp(24px, 4vw, 60px) 6px; }
  .dock {
    justify-content: center;
    gap: clamp(20px, 5vw, 80px);
    padding: 0 clamp(24px, 6vw, 100px) 16px;
  }
}

@media (min-width: 1200px) {
  :root {
    --app-icon-size: clamp(90px, 6vw, 120px);
  }
}

@media (min-width: 1600px) {
  :root {
    --app-icon-size: clamp(100px, 6vw, 130px);
  }
}

/* ========== Base screen styles ========== */
.screen {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  display: none;
  z-index: 1;
}
.screen.active { display: flex; flex-direction: column; }

/* ========== Status Bar ========== */
.status-bar {
  height: var(--status-height);
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 0 26px 6px;
  flex-shrink: 0;
  color: #fff;
  background: transparent;
  cursor: pointer;
  touch-action: none;
  position: relative;
  z-index: 100;
}

.status-time {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.3px;
  font-feature-settings: "tnum";
}

.status-right { display: flex; align-items: center; gap: 6px; }
.status-signal { display: flex; align-items: flex-end; gap: 1.5px; height: 12px; }
.status-signal-bar { width: 3px; background: #fff; border-radius: 1px; }
.status-wifi svg { width: 16px; height: 12px; display: block; }
.status-battery { display: flex; align-items: center; }
.status-battery-body { width: 24px; height: 11.5px; border: 1.5px solid rgba(255,255,255,0.85); border-radius: 3px; padding: 1.5px; position: relative; }
.status-battery-fill { height: 100%; width: 72%; background: #34c759; border-radius: 1px; }
.status-battery-tip { width: 3px; height: 5px; background: rgba(255,255,255,0.6); border-radius: 0 1px 1px 0; margin-left: 1px; }

/* ========== Lock Screen ========== */
#lock-screen {
  background: var(--ios-wallpaper);
  justify-content: center;
  align-items: center;
  gap: 12px;
  overflow: hidden;
}

.lock-status-bar { position: absolute; top: 60px; left: 0; width: 100%; text-align: center; z-index: 5; }
.lock-time { font-size: clamp(64px, 10vw, 120px); font-weight: 600; letter-spacing: -4px; color: #fff; text-shadow: 0 2px 12px rgba(0,0,0,0.4); line-height: 1; font-variant-numeric: tabular-nums; }
.lock-date { font-size: clamp(16px, 2.5vw, 28px); font-weight: 500; margin-top: 6px; color: rgba(255,255,255,0.8); text-shadow: 0 1px 6px rgba(0,0,0,0.3); }

.lock-notifications { position: absolute; top: clamp(140px, 20vh, 200px); left: 16px; right: 16px; display: flex; flex-direction: column; gap: 8px; }
.lock-notification { background: rgba(255,255,255,0.08); backdrop-filter: blur(20px); border-radius: 14px; padding: 12px 14px; display: flex; align-items: flex-start; gap: 10px; }

.lock-hint { font-size: 17px; color: rgba(255,255,255,0.35); font-weight: 400; letter-spacing: 0.5px; }

.lock-handle { width: 36px; height: 5px; background: rgba(255,255,255,0.25); border-radius: 3px; cursor: pointer; touch-action: none; }

.lock-quick-actions { display: flex; justify-content: center; gap: 60px; padding: 20px 0; }
.lock-quick-btn { width: clamp(44px, 5vw, 60px); height: clamp(44px, 5vw, 60px); border-radius: 50%; background: rgba(0,0,0,0.45); backdrop-filter: blur(8px); border: 2px solid rgba(255,255,255,0.08); cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 18px; color: rgba(255,255,255,0.9); outline: none; }

/* ========== Home Screen ========== */
#home-screen { background: var(--ios-wallpaper); }
.home-scroll-container { flex: 1; position: relative; }
.home-content { overflow-y: auto; height: 100%; -webkit-overflow-scrolling: touch; padding: 0 var(--home-padding-x) 10px; }

.home-page-track { display: flex; height: calc(100% - 28px); transition: transform 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94); will-change: transform; }
.home-page { min-width: 100%; height: 100%; overflow-y: auto; }
.home-page::-webkit-scrollbar { display: none; }

.home-header { padding: 6px 0 10px; font-size: clamp(12px, 1.2vw, 16px); color: rgba(255,255,255,0.5); text-align: center; font-weight: 500; }

/* ========== App Grid ========== */
.app-grid {
  display: grid;
  grid-template-columns: repeat(var(--grid-columns), 1fr);
  gap: var(--grid-row-gap) var(--grid-gap);
  padding: 8px 0 2px;
  justify-items: center;
}

.app-icon-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  cursor: pointer;
  position: relative;
  padding: 6px 4px;
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.app-icon-wrapper:active { transform: scale(0.86); }

.app-icon {
  width: var(--app-icon-size);
  height: var(--app-icon-size);
  border-radius: var(--app-icon-radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  position: relative;
  overflow: hidden;
  box-shadow: 0 3px 8px rgba(0,0,0,0.35);
}

.app-icon::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 48%;
  background: linear-gradient(180deg, rgba(255,255,255,0.25) 0%, rgba(255,255,255,0.08) 50%, rgba(255,255,255,0) 100%);
  border-radius: var(--app-icon-radius) var(--app-icon-radius) 0 0;
  pointer-events: none;
}

.app-icon img { width: 100%; height: 100%; object-fit: cover; border-radius: var(--app-icon-radius); }
.app-icon svg { display: block; }

.app-name {
  font-size: clamp(10px, 1vw, 14px);
  color: rgba(255,255,255,0.92);
  text-align: center;
  line-height: 1.15;
  max-width: calc(var(--app-icon-size) * 1.2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-shadow: 0 1px 4px rgba(0,0,0,0.5);
  font-weight: 500;
  letter-spacing: 0.1px;
}

.app-badge {
  position: absolute; top: 0; right: 0;
  min-width: 19px; height: 19px;
  background: var(--ios-red);
  border-radius: 10px;
  font-size: 12px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  padding: 0 5px;
  border: 1.5px solid rgba(255,255,255,0.3);
  color: #fff; z-index: 2;
}

/* ========== Dock ========== */
.dock {
  height: var(--dock-height);
  background: rgba(255,255,255,0.06);
  backdrop-filter: blur(50px);
  -webkit-backdrop-filter: blur(50px);
  border-top: 0.5px solid rgba(255,255,255,0.04);
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 0 36px 14px;
  flex-shrink: 0;
  position: relative;
}

.dock-icon-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  cursor: pointer;
  position: relative;
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.dock-icon-wrapper:active { transform: scale(0.88); }

.dock-icon {
  width: calc(var(--app-icon-size) * 0.9);
  height: calc(var(--app-icon-size) * 0.9);
  border-radius: calc(var(--app-icon-radius) * 0.9);
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  position: relative; overflow: hidden;
  box-shadow: 0 3px 10px rgba(0,0,0,0.4);
}
.dock-icon::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 48%;
  background: linear-gradient(180deg, rgba(255,255,255,0.22) 0%, rgba(255,255,255,0.05) 50%, rgba(255,255,255,0) 100%);
  border-radius: calc(var(--app-icon-radius) * 0.9) calc(var(--app-icon-radius) * 0.9) 0 0;
  pointer-events: none;
}
.dock-icon img { width: 100%; height: 100%; object-fit: cover; border-radius: calc(var(--app-icon-radius) * 0.9); }
.dock-icon svg { display: block; }

.dock-name {
  font-size: clamp(9px, 0.8vw, 12px);
  color: rgba(255,255,255,0.88);
  text-align: center;
  text-shadow: 0 1px 4px rgba(0,0,0,0.5);
  font-weight: 400;
}

.home-indicator {
  position: absolute;
  bottom: 8px; left: 50%;
  transform: translateX(-50%);
  width: 134px; height: 5px;
  background: rgba(255,255,255,0.18);
  border-radius: 3px;
}

/* ========== Widgets ========== */
.widget-strip { display: flex; gap: 10px; padding: 0 0 10px; overflow-x: auto; }
.widget-strip::-webkit-scrollbar { display: none; }
.widget-card { min-width: clamp(120px, 14vw, 220px); background: rgba(255,255,255,0.07); backdrop-filter: blur(20px); border-radius: 14px; padding: 12px; flex-shrink: 0; }
.widget-card-title { font-size: clamp(10px, 0.8vw, 13px); color: rgba(255,255,255,0.45); letter-spacing: 0.5px; margin-bottom: 5px; font-weight: 500; }
.widget-card-value { font-size: clamp(18px, 2.2vw, 30px); font-weight: 700; color: #fff; }
.widget-card-sub { font-size: clamp(10px, 0.8vw, 13px); color: rgba(255,255,255,0.35); margin-top: 2px; }

/* ========== Page Dots ========== */
.page-dots { display: flex; justify-content: center; gap: 6px; padding: 10px 0 4px; }
.page-dot { width: 6px; height: 6px; border-radius: 3px; background: rgba(255,255,255,0.22); transition: all 0.3s; }
.page-dot.active { width: 20px; background: rgba(255,255,255,0.75); }

/* ========== App Viewport ========== */
#app-viewport { background: #f2f2f6; z-index: 20; transform: translateY(100%); transition: transform 0.4s cubic-bezier(0.32, 0.72, 0, 1); display: flex; flex-direction: column; }
#app-viewport.open { transform: translateY(0); }
#app-viewport.active { display: flex; flex-direction: column; }
#app-frame { display: flex; flex-direction: column; flex: 1; }

.app-viewport-header {
  height: 44px;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  border-bottom: 0.5px solid rgba(0,0,0,0.08);
  flex-shrink: 0;
}
.app-viewport-title { font-size: 17px; font-weight: 600; color: #000; }
.app-back-btn, .app-close-btn {
  position: absolute; top: 50%; transform: translateY(-50%);
  background: none; border: none;
  font-size: 16px; color: #007aff;
  cursor: pointer; display: flex; align-items: center; gap: 2px;
  padding: 4px 12px; font-family: inherit;
}
.app-back-btn { left: 4px; }
.app-close-btn { right: 4px; }
.app-back-btn svg { width: 18px; height: 18px; }

.app-viewport-body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }

/* Home indicator bar at bottom of apps - swipe up to close */
.viewport-home-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px 0 8px;
  flex-shrink: 0;
  background: #f2f2f6;
}
.viewport-home-bar {
  width: 134px;
  height: 5px;
  background: rgba(0,0,0,0.12);
  border-radius: 3px;
  cursor: pointer;
}

/* ========== Modal ========== */
#modal-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.35); z-index: 200; backdrop-filter: blur(4px); }
#modal-content { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 201; background: #fff; border-radius: 14px; max-width: min(400px, 80vw); width: 90%; overflow: hidden; color: #000; max-height: 80vh; overflow-y: auto; }
.hidden { display: none !important; }

/* ========== Notification Center ========== */
.notif-center { background: rgba(0,0,0,0.85); backdrop-filter: blur(50px); z-index: 50; transform: translateY(-100%); transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1); padding-top: max(55px, 5vh); overflow: hidden; }
.notif-center.open { transform: translateY(0); }
.notif-list { flex: 1; overflow-y: auto; padding: 0 clamp(16px, 4vw, 48px); max-width: min(600px, 100%); margin: 0 auto; width: 100%; }
.notif-item { background: rgba(255,255,255,0.07); backdrop-filter: blur(20px); border-radius: 14px; padding: 14px; margin-bottom: 10px; display: flex; align-items: flex-start; gap: 10px; }
.notif-handle-area { text-align: center; padding: 16px 0; flex-shrink: 0; cursor: pointer; }
.notif-handle { width: 40px; height: 5px; background: rgba(255,255,255,0.25); border-radius: 3px; margin: 0 auto; }

/* ========== Control Center ========== */
#control-center { background: rgba(25,25,35,0.92); backdrop-filter: blur(60px); z-index: 60; padding: max(60px, 6vh) clamp(20px, 5vw, 60px) 30px; transform: translateY(-100%); transition: transform 0.4s cubic-bezier(0.32, 0.72, 0, 1); overflow: hidden; }
#control-center.open { transform: translateY(0); }

/* ========== General ========== */
::-webkit-scrollbar { width: 0; height: 0; }
