/* ============ PocketOS · 口袋系统 ============ */

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

html, body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(1200px 800px at 50% 30%, #1a222c, #0c1014);
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  color: #eef2f6;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

/* ---------- 手机机身（桌面端居中机框 / 手机端全屏） ---------- */
#phone {
  --bg: #0b0f14;
  --panel: #131a22;
  --panel2: #1c2530;
  --text: #eef2f6;
  --sub: #8fa0b0;
  --accent: #4da3ff;
  --line: rgba(255, 255, 255, 0.08);

  position: relative;
  width: min(420px, 100vw);
  height: min(880px, 100dvh);
  overflow: hidden;
  background: var(--bg);
  border-radius: 36px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6), 0 0 0 10px #1b2129, 0 0 0 12px #2c3540;
}

#phone.light {
  --bg: #f3f5f8;
  --panel: #ffffff;
  --panel2: #e9edf2;
  --text: #1b2733;
  --sub: #67788a;
  --accent: #2f6fed;
  --line: rgba(0, 0, 0, 0.08);
}

@media (max-width: 480px) {
  body { background: #000; }
  #phone {
    width: 100vw;
    height: 100dvh;
    border-radius: 0;
    box-shadow: none;
  }
}

/* ---------- 状态栏 ---------- */
#statusBar {
  position: absolute;
  top: env(safe-area-inset-top);
  left: 0; right: 0;
  height: 40px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
  z-index: 10;
  pointer-events: none;
}
#statusBar i { font-style: normal; margin-left: 8px; }

/* ---------- 锁屏 ---------- */
#lockScreen {
  position: absolute;
  inset: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(rgba(8, 12, 16, 0.25), rgba(8, 12, 16, 0.65));
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
#lockScreen.gone { display: none; }

.lock-inner { text-align: center; }
#lockTime {
  font-size: 72px;
  font-weight: 200;
  letter-spacing: 3px;
  color: #fff;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.45);
}
#lockDate {
  margin-top: 6px;
  font-size: 16px;
  color: rgba(255, 255, 255, 0.85);
  letter-spacing: 2px;
}

.lock-hint {
  position: absolute;
  bottom: calc(46px + env(safe-area-inset-bottom));
  left: 0; right: 0;
  text-align: center;
  font-size: 14px;
  letter-spacing: 4px;
  color: rgba(255, 255, 255, 0.8);
  animation: floatUp 2.2s ease-in-out infinite;
}
@keyframes floatUp {
  0%, 100% { transform: translateY(0); opacity: 0.65; }
  50% { transform: translateY(-8px); opacity: 1; }
}

/* ---------- 主屏 ---------- */
#home {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding-top: calc(48px + env(safe-area-inset-top));
}

#wallpaper {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: linear-gradient(160deg, #0f2027, #203a43, #2c5364);
  transition: background 0.5s ease;
}

#clockWidget {
  position: relative;
  z-index: 1;
  margin: 4vh 24px 0;
}
#cwTime {
  font-size: 46px;
  font-weight: 200;
  color: #fff;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.4);
}
#cwDate {
  margin-top: 2px;
  font-size: 13.5px;
  color: rgba(255, 255, 255, 0.8);
  letter-spacing: 1px;
}

#appGrid {
  position: relative;
  z-index: 1;
  flex: 1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  padding: 20px 26px;
  align-content: center;
}

.app-icon {
  aspect-ratio: 1 / 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.22);
  transition: transform 0.25s ease, background 0.25s ease;
}
.app-icon:hover { transform: translateY(-2px); background: rgba(255, 255, 255, 0.22); }
.app-icon:active { transform: scale(0.92); }
.ai-emoji { font-size: 34px; line-height: 1; }
.ai-label {
  font-size: 12.5px;
  letter-spacing: 2px;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
}

#homeBar {
  position: relative;
  z-index: 1;
  height: calc(30px + env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  justify-content: center;
}
.hb-pill {
  width: 120px;
  height: 5px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.85);
}

/* ---------- 应用层 ---------- */
#appLayer {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  transform: translateY(103%);
  transition: transform 0.38s cubic-bezier(0.32, 0.72, 0.34, 1);
  pointer-events: none;
}
#appLayer.open { transform: translateY(0); pointer-events: auto; }

#appHeader {
  height: calc(52px + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 14px 0;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
#appBack {
  padding: 7px 14px;
  border-radius: 10px;
  background: var(--panel2);
  color: var(--accent);
  font-size: 14px;
  transition: filter 0.2s;
}
#appBack:active { filter: brightness(1.2); }
#appTitle { font-size: 16px; font-weight: 600; color: var(--text); }

#appContent { flex: 1; position: relative; overflow: hidden; }

#appHomeBar {
  height: calc(26px + env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--panel);
  border-top: 1px solid var(--line);
  flex-shrink: 0;
}
#appHomeBar .hb-pill { background: var(--sub); opacity: 0.55; }

/* ---------- 通用应用视图 ---------- */
.app-view {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  overflow-y: auto;
  background: var(--bg);
}
.app-view.on { display: flex; }

.btn-primary {
  padding: 13px;
  border-radius: 13px;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  transition: filter 0.2s, transform 0.15s;
}
.btn-primary:active { filter: brightness(1.15); transform: scale(0.98); }

/* ---------- 计算器 ---------- */
#app-calc { overflow: hidden; }
#calcScreen {
  padding: 20px 18px 14px;
  text-align: right;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
#calcExpr { min-height: 20px; font-size: 15px; color: var(--sub); word-break: break-all; }
#calcResult {
  margin-top: 6px;
  font-size: 44px;
  font-weight: 300;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  word-break: break-all;
  line-height: 1.15;
}
#calcPad {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  padding: 12px;
}
#calcPad button {
  font-size: 21px;
  border-radius: 15px;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  transition: transform 0.12s, background 0.2s;
}
#calcPad button:active { transform: scale(0.93); background: var(--panel2); }
#calcPad .k-wide { grid-column: span 2; }
#calcPad .k-eq { background: var(--accent); color: #fff; border-color: transparent; }

/* ---------- 备忘录 ---------- */
.note-editor {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.note-editor input,
.note-editor textarea {
  background: var(--panel2);
  border: none;
  outline: none;
  border-radius: 12px;
  padding: 12px;
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  resize: none;
}
.note-editor textarea { min-height: 88px; }

#noteList { list-style: none; padding: 12px; }
.note-item {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 10px;
}
.nt-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.nt-head b { font-size: 15px; color: var(--text); }
.nt-date { display: block; margin-top: 2px; font-size: 11px; color: var(--sub); }
.nt-del {
  flex-shrink: 0;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--panel2);
  color: var(--sub);
  font-size: 13px;
  transition: all 0.25s;
}
.nt-del:hover { background: #8b3a3a; color: #fff; }
.note-item p { margin-top: 8px; font-size: 13.5px; color: var(--sub); white-space: pre-wrap; word-break: break-word; }
.note-empty { text-align: center; padding: 30px 0; font-size: 13.5px; color: var(--sub); letter-spacing: 1px; }

/* ---------- 时钟与秒表 ---------- */
#clockBig {
  padding: 44px 0 20px;
  text-align: center;
  font-size: 54px;
  font-weight: 200;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.sw-box {
  margin: 10px 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 26px 20px;
}
#swDisplay {
  text-align: center;
  font-size: 42px;
  font-weight: 300;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.sw-btns { display: flex; gap: 12px; margin-top: 20px; }
.sw-btns button {
  flex: 1;
  padding: 13px;
  border-radius: 12px;
  font-size: 15px;
  transition: filter 0.2s;
}
#swStart { background: var(--accent); color: #fff; font-weight: 600; }
#swReset { background: var(--panel2); color: var(--text); border: 1px solid var(--line); }
.sw-btns button:active { filter: brightness(1.2); }

/* ---------- 音乐 ---------- */
#app-music { overflow: hidden; }
#musicDisc {
  width: 128px; height: 128px;
  margin: 26px auto 12px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #3d4f63, #10161d 70%);
  border: 1px solid rgba(255, 255, 255, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 44px;
  animation: spin 9s linear infinite;
  animation-play-state: paused;
  flex-shrink: 0;
}
#musicDisc.spin { animation-play-state: running; }
@keyframes spin { to { transform: rotate(360deg); } }

#musicTitle {
  text-align: center;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 16px;
  flex-shrink: 0;
}
#musicList {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 20px;
}
.track-item {
  text-align: left;
  padding: 13px 15px;
  border-radius: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 14px;
  transition: border-color 0.2s, color 0.2s;
}
.track-item.playing { border-color: var(--accent); color: var(--accent); background: var(--panel2); }
#musicPlay { margin: 14px 20px calc(18px + env(safe-area-inset-bottom)); flex-shrink: 0; }

/* ---------- 设置 ---------- */
#app-settings h3 {
  padding: 18px 20px 8px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 3px;
  color: var(--sub);
}
#wallPicker {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 0 20px;
}
.wall-chip {
  height: 64px;
  border-radius: 14px;
  border: 2px solid transparent;
  transition: border-color 0.2s, transform 0.15s;
}
.wall-chip:active { transform: scale(0.95); }
.wall-chip.sel { border-color: var(--accent); }

.set-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 20px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  font-size: 15px;
}
.switch {
  padding: 7px 16px;
  border-radius: 999px;
  background: var(--panel2);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 13px;
}
.about {
  padding: 4px 20px 28px;
  font-size: 13px;
  color: var(--sub);
  line-height: 1.9;
}

/* ---------- 马里奥 ---------- */
#app-mario.on { overflow: hidden; }
#marioStage {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #000;
}
#marioFrame {
  position: absolute;
  width: 800px;
  height: 500px;
  border: 0;
  transform-origin: 0 0;
}

#touchPad {
  height: 122px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px calc(6px + env(safe-area-inset-bottom));
  background: #10151b;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.tp-left, .tp-right { display: flex; gap: 14px; align-items: center; }
.tp-btn {
  width: 58px; height: 58px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  font-size: 19px;
  touch-action: none;
  transition: background 0.12s, transform 0.12s;
}
.tp-btn.press { background: rgba(255, 255, 255, 0.3); transform: scale(0.94); }
.tp-act {
  width: 68px; height: 68px;
  background: #e52521;
  border-color: #a11;
  font-weight: 700;
}
.tp-act.press { background: #ff4b47; }
