:root {
  /* 从参考图中提取的精确色彩 */
  --bg-paper: #fbf6f0;        /* 整体奶油底色 */
  --icon-blue: #b6cde0;       /* 软雾蓝 */
  --icon-blue-light: #d5e4ed; /* 浅雾蓝 */
  --icon-peach: #f8d3c5;      /* 奶油杏/蜜桃色 */
  --icon-cream: #fdf8f4;      /* 图标底色 */
  --tape-orange: #f1b98f;     /* 橘色胶带 */
  --tape-blue: #a8c2d8;       /* 蓝色胶带 */
  --ink-blue: #5c7b8f;        /* 深蓝灰（用于文字和深色图形） */
  --ink-brown: #8c7362;       /* 暖棕色（用于文字） */
  
  --radius-icon: 22px;
  --shadow-icon: 0 4px 10px rgba(182, 205, 224, 0.3);
  --shadow-paper: 2px 4px 12px rgba(140, 115, 98, 0.08);
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-family-base); /* 跟随全局字体变量，可被自定义上传字体覆盖 */
  background-color: #dcd6d0;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
}

/* 模拟手机外壳 */
.device-mockup {
  width: 375px;
  height: 812px;
  background-color: var(--bg-paper);
  background-image:
    linear-gradient(rgba(251, 246, 240, 0.22), rgba(251, 246, 240, 0.22)),
    url("assets/wallpapers/home-mood-default.png");
  background-size: cover;
  background-position: center;
  border-radius: 40px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.15), inset 0 0 0 6px #fff;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* 状态栏 */
.status-bar {
  height: 44px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 24px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-blue);
  z-index: 10;
  font-family: -apple-system, sans-serif;
}

/* 页面容器 */
.home-pages-container {
  flex: 1;
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
}
.home-pages-container::-webkit-scrollbar { display: none; }

/* 触屏设备常驻降级毛玻璃；不随滑动切换，避免透明度与合成层闪烁。 */
@media (hover: none), (pointer: coarse) {
  html body #page-container > .home-shell-page.page,
  html body #page-container > .home-shell-page.page * {
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
  }
}

.home-page {
  min-width: 100%;
  padding: 10px 24px 24px;
  box-sizing: border-box;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  display: flex;
  flex-direction: column;
  gap: 24px;
  position: relative;
}

.device-mockup .home-page {
  padding-bottom: 150px;
}

/* 装饰性胶带 */
.deco-tape {
  position: absolute;
  height: 24px;
  opacity: 0.85;
  mix-blend-mode: multiply;
}
.tape-1 {
  top: 10px; left: -10px; width: 100px;
  background-color: var(--tape-orange);
  transform: rotate(-15deg);
  /* 格子纹理 */
  background-image: linear-gradient(rgba(255,255,255,0.3) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,0.3) 1px, transparent 1px);
  background-size: 8px 8px;
}
/* 手账风卡片组件 */
.widget-card {
  background: var(--icon-cream);
  border-radius: 8px; /* 稍微圆润一点的纸张角 */
  padding: 16px;
  box-shadow: var(--shadow-paper);
  position: relative;
  transition: transform 0.2s;
}

/* 替换图片/背景的悬浮提示 */
.replaceable {
  position: relative;
  cursor: default;
}
.replaceable::after {
  content: '';
  display: none;
  position: absolute;
  bottom: 6px;
  right: 6px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink-brown);
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 12px;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
  box-shadow: 0 2px 6px rgba(140, 115, 98, 0.2);
  font-weight: bold;
  z-index: 20;
}
.replaceable:hover::after {
  opacity: 1;
}

/* 网格纸样式 */
.grid-paper {
  background-color: #fff;
  background-image: linear-gradient(#e8eef3 1px, transparent 1px), linear-gradient(90deg, #e8eef3 1px, transparent 1px);
  background-size: 16px 16px;
  border: 1px solid #e8eef3;
  transform: rotate(1deg);
}

/* 撕纸边缘效果 - 优化边缘 */
.torn-paper {
  background: #fff;
  filter: drop-shadow(0 4px 6px rgba(140, 115, 98, 0.1));
  border-radius: 8px 8px 0 0;
  padding-bottom: 20px;
  margin-bottom: 10px;
}
.torn-paper::after {
  content: "";
  position: absolute;
  bottom: -8px;
  left: 0;
  right: 0;
  height: 8px;
  background-size: 16px 16px;
  background-image: linear-gradient(135deg, #fff 25%, transparent 25%), linear-gradient(225deg, #fff 25%, transparent 25%);
  background-position: 0 0;
}

.user-header {
  display: flex;
  align-items: center;
  gap: 16px;
  transform: rotate(-1deg);
}
.avatar-placeholder {
  width: 50px; height: 50px;
  background: var(--icon-blue-light);
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: var(--shadow-paper);
  overflow: hidden;
}
.user-info .greeting {
  font-size: 18px; font-weight: bold; color: var(--ink-brown);
}
.user-info .status-text {
  font-size: 13px; color: var(--ink-blue); margin-top: 4px;
}

/* 图标网格 */
.app-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px 16px;
  margin-top: 10px;
  position: relative;
  z-index: 2;
}
.app-drop-slot {
  display: block;
  min-height: 82px;
  border-radius: var(--radius-icon);
  visibility: hidden;
  pointer-events: none;
}
.is-home-editing .app-drop-slot {
  visibility: visible;
  border: 1.5px dashed rgba(255, 255, 255, 0.72);
  background: rgba(255, 255, 255, 0.18);
  box-shadow: inset 0 0 0 1px rgba(140, 115, 98, 0.08);
}
.page-two-grid {
  margin-top: -4px;
}
.page-one .polaroid-widget {
  margin-top: auto;
  margin-bottom: auto;
}
.page-one .app-grid {
  margin-top: 0;
  margin-bottom: 0;
}
.page-three .app-grid {
  margin-top: auto;
  margin-bottom: 0;
}
.app-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

/* 用户自建分页：纯 App 网格，撑满整页高度，方便把图标拖进空页放置 */
.page-extra .page-extra-grid {
  flex: 1;
  align-content: flex-start;
  min-height: 240px;
  margin-top: 6px;
}
.home-shell-page .page-extra {
  padding-bottom: 128px;
  scroll-snap-stop: always;
}
.app-label {
  color: var(--ink-brown);
  font-size: 12px;
  line-height: 1;
  pointer-events: none;
  user-select: none;
}
.app-icon {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-icon);
  background-color: var(--icon-cream);
  border: 4px solid #ffffff; /* 贴纸白边 */
  box-shadow: 0 4px 10px rgba(140, 115, 98, 0.15); /* 贴纸投影 */
  display: flex;
  justify-content: center;
  align-items: center;
  transition: transform 0.2s;
  position: relative;
}
.app-icon:active { transform: scale(0.92); }
.app-icon svg {
  width: 36px; height: 36px;
}
/* 贴纸图标占位图覆盖层（用于上传图片后覆盖SVG） */
.app-icon .custom-img {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  border-radius: calc(var(--radius-icon) - 4px);
  object-fit: cover;
  display: none; /* 默认隐藏，上传后显示 */
  filter: none !important;
  mix-blend-mode: normal !important;
  forced-color-adjust: none;
}

/* 按钮重置不能盖掉贴纸白边；关闭边缘时见 html.app-icon-edge-off */
button.app-icon,
button.home-dock-icon {
  padding: 0;
  font: inherit;
  cursor: pointer;
}
html:not(.app-icon-edge-off) button.app-icon {
  border: 4px solid #ffffff;
}
html.app-icon-edge-off .app-icon,
html.app-icon-edge-off button.app-icon {
  border: none !important;
  box-shadow: 0 3px 10px rgba(140, 115, 98, 0.12);
}
html.app-icon-edge-off .app-icon .custom-img {
  border-radius: inherit;
}

.app-badge {
  position: absolute;
  top: -7px;
  right: -7px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #e77878;
  border: 2px solid rgba(255, 253, 248, 0.96);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 14px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(90, 70, 55, 0.18);
  pointer-events: none;
  z-index: 2;
}

/* 图标底色分类 */
.bg-peach { background-color: var(--icon-peach); }
.bg-blue { background-color: var(--icon-blue); }
.bg-blue-light { background-color: var(--icon-blue-light); }
.bg-cream { background-color: var(--icon-cream); }

/* 底部 Dock */
.dock {
  position: absolute;
  bottom: 22px;
  left: 24px;
  right: 24px;
  height: 74px;
  background: rgba(253, 248, 244, 0.88);
  backdrop-filter: blur(12px);
  border-radius: 28px;
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 0 8px;
  box-shadow: 0 10px 30px rgba(182, 205, 224, 0.2);
  border: 1px solid rgba(255,255,255,0.6);
}
.dock .app-icon {
  width: 54px;
  height: 54px;
  border-radius: 18px;
}
.dock .app-icon svg {
  width: 30px;
  height: 30px;
}

/* 页面指示器 */
.page-indicators {
  position: absolute;
  bottom: 106px;
  left: 0; right: 0;
  display: flex;
  justify-content: center;
  gap: 8px;
}
.dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: rgba(92, 123, 143, 0.2);
}
.dot.active {
  background: var(--ink-blue);
}

/* 小组件内部样式 */
.note-title { color: var(--tape-orange); font-weight: bold; font-size: 16px; margin-bottom: 8px; outline: none; }
.note-list { margin: 0; padding-left: 20px; color: var(--ink-brown); font-size: 15px; line-height: 1.8; outline: none; }
.note-list li { margin-bottom: 4px; }

/* 拍立得组件 */
.polaroid-widget {
  padding-bottom: 14px;
}
.photo-area { 
  background: #e8eef3; 
  aspect-ratio: 1.1 / 1;
  margin-bottom: 10px; 
  border-radius: 4px;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}
.photo-area svg { width: 100%; height: 100%; object-fit: cover; }
.caption { text-align: center; color: var(--ink-brown); font-size: 14px; outline: none; }

/* 胶片/贴纸组件：左侧留镂空胶片图片区，右侧留小贴纸图片区 */
.film-widget {
  min-height: 136px;
  background: rgba(255, 255, 255, 0.84);
  overflow: visible;
  margin-top: 2px;
}
.film-layout {
  position: relative;
  min-height: 106px;
}
.film-ring {
  position: absolute;
  left: 10px;
  bottom: -4px;
  width: 116px;
  height: 116px;
  border-radius: 50%;
  background:
    radial-gradient(circle, transparent 0 42%, #ffffff 43% 50%, transparent 51%),
    conic-gradient(from 0deg, var(--icon-blue), var(--icon-blue-light), var(--icon-peach), var(--icon-blue));
  border: 5px solid #fff;
  box-shadow: 0 6px 16px rgba(140, 115, 98, 0.14);
}
.film-sticker {
  position: absolute;
  right: 10px;
  bottom: 0;
  width: 86px;
  height: 118px;
  border: 4px solid #fff;
  border-radius: 4px;
  background: rgba(253, 248, 244, 0.7);
  box-shadow: 0 6px 14px rgba(140, 115, 98, 0.12);
}
.film-sticker::after {
  content: '';
  position: absolute;
  right: -20px;
  bottom: -12px;
  width: 92px;
  height: 22px;
  transform: rotate(-5deg);
  background-color: var(--tape-blue);
  opacity: 0.75;
  background-image: radial-gradient(rgba(255,255,255,0.55) 2px, transparent 2px);
  background-size: 10px 10px;
}

/* 日历组件 */
.calendar-widget { background: #fff; padding: 20px; }
.cal-header { color: var(--tape-orange); font-weight: bold; text-align: center; margin-bottom: 16px; font-size: 16px; outline: none; }
.cal-grid { 
  display: grid; 
  grid-template-columns: repeat(7, 1fr); 
  gap: 10px 4px; 
  text-align: center; 
  font-size: 13px; 
  color: var(--ink-brown); 
}
.cal-grid .day-name { color: var(--ink-blue); font-weight: bold; margin-bottom: 4px; }
.cal-grid .marked {
  position: relative;
  color: #fff;
  z-index: 1;
  font-weight: bold;
}
.cal-grid .marked::before {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 24px; height: 24px;
  background: var(--tape-orange);
  border-radius: 50%;
  z-index: -1;
}

/* ── 真机壳内主屏 ── */
.home-shell-page {
  position: relative;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-paper);
}

.home-shell-page .home-pages-container {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}

.home-shell-page .home-page {
  height: 100%;
  max-height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: calc(10px + var(--safe-top)) 24px 18px;
}

.home-shell-page .page-one {
  gap: 18px;
  display: flex;
  flex-direction: column;
  min-height: 720px;
  padding-bottom: 128px;
}

.home-shell-page .page-one .user-header {
  min-height: 96px;
  padding: 18px 16px;
  box-sizing: border-box;
}

.home-polaroid-feature {
  width: 100%;
  min-height: 390px;
  padding: 16px 16px 18px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
}

.home-polaroid-feature .photo-area {
  flex: 1 1 auto;
  min-height: 0;
  aspect-ratio: 1.02 / 1;
}

.home-polaroid-feature .caption {
  flex: 0 0 auto;
  font-size: 18px;
  line-height: 1.25;
  padding-top: 4px;
}

.home-shell-page .page-one .app-grid {
  flex: 0 0 auto;
  margin: 0;
  gap: 18px 16px;
}

.home-shell-page .page-one .app-icon {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-icon);
}

.home-shell-page .page-one .app-label {
  font-size: 12px;
  line-height: 1.1;
}

@media (max-height: 700px) {
  .home-shell-page .page-one {
    padding-left: 20px;
    padding-right: 20px;
    min-height: 690px;
  }

  .home-shell-page .avatar-placeholder {
    width: 44px;
    height: 44px;
  }

  .home-shell-page .user-info .greeting {
    font-size: 17px;
  }

  .home-shell-page .user-info .status-text {
    font-size: 12px;
  }
}

.home-custom-widget {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: hidden;
}

/* 代码组件：内容走 shadow DOM，外壳只负责占位与裁切 */
.home-custom-widget.home-code-widget {
  display: block;
  gap: 0;
  padding: 0;
}

.home-custom-widget-image {
  min-height: 0;
  flex: 1;
  border-radius: 6px;
  overflow: hidden;
  background: rgba(182, 205, 224, 0.22);
}

.home-custom-widget-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.home-custom-widget-title {
  color: var(--ink-brown);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.25;
}

.home-custom-widget-body {
  color: var(--text-secondary, #a08978);
  font-size: 12px;
  line-height: 1.45;
  word-break: break-word;
}

.home-real-edit-bar {
  position: absolute;
  top: calc(10px + var(--safe-top));
  left: 14px;
  right: 14px;
  z-index: 40;
  display: flex;
  justify-content: space-between;
  pointer-events: none;
}

.home-real-edit-bar[hidden] {
  display: none;
}

.home-real-edit-action,
.home-real-edit-done {
  min-height: 42px;
  padding: 0 16px;
  border: 0;
  border-radius: 21px;
  background: rgba(92, 102, 112, 0.78);
  color: #fff;
  box-shadow: 0 6px 16px rgba(90, 70, 55, 0.18);
  font: 700 14px var(--font-family-base, inherit);
  pointer-events: auto;
}

.home-real-edit-action {
  width: 42px;
  padding: 0;
}

.home-real-edit-action.home-real-edit-wide {
  width: auto;
  padding: 0 12px;
}

.home-wallpaper-pick {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.home-edit-delete {
  display: none;
  position: absolute;
  top: -10px;
  left: -10px;
  z-index: 8;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  background: rgba(220, 220, 220, 0.92);
  color: #6f6660;
  font: 700 18px/18px var(--font-family-base, inherit);
  box-shadow: 0 3px 8px rgba(140, 115, 98, 0.18);
}

.is-home-editing .home-edit-delete {
  display: block;
}

.is-home-editing .app-item[data-home-longpress-item],
.is-home-editing .home-dock-slot[data-home-longpress-item] {
  cursor: grab;
  touch-action: none;
  -webkit-touch-callout: none;
}

.is-home-editing .widget-card[data-home-longpress-item],
.is-home-editing .home-custom-widget[data-home-longpress-item] {
  cursor: default;
  touch-action: auto;
}

.home-inline-editable {
  -webkit-user-select: text;
  user-select: text;
}

.home-inline-editable:focus {
  outline: 2px solid rgba(92, 123, 143, 0.28);
  outline-offset: 3px;
  border-radius: 3px;
}

.is-home-editing .home-inline-editable {
  pointer-events: none;
  -webkit-user-select: none;
  user-select: none;
}

.is-reordering .home-pages-container {
  touch-action: none;
}

.is-home-editing .app-item,
.is-home-editing .home-dock-slot,
.is-home-editing .widget-card[data-home-longpress-item],
.is-home-editing .home-custom-widget[data-home-longpress-item] {
  animation: home-edit-wiggle 0.18s ease-in-out infinite alternate;
}

.is-real-dragging {
  opacity: 0.25;
}

/* 拖拽重排进行中：停掉抖动（rotate 会盖掉 FLIP 的位移），让其它图标平滑挤开/排齐 */
.is-reordering .app-item,
.is-reordering .home-dock-slot,
.is-reordering .widget-card[data-home-longpress-item],
.is-reordering .home-custom-widget[data-home-longpress-item] {
  animation: none !important;
}

.is-reordering .app-item.is-real-dragging,
.is-reordering .home-dock-slot.is-real-dragging {
  transition: none !important;
}

.home-real-drag-ghost {
  position: fixed;
  z-index: 10000;
  pointer-events: none;
  opacity: 0.96;
  transform: scale(1.04);
  filter: drop-shadow(0 14px 22px rgba(90, 70, 55, 0.18));
}

.home-edit-toast {
  position: absolute;
  left: 50%;
  bottom: calc(106px + var(--safe-bottom));
  transform: translateX(-50%);
  z-index: 20;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 253, 248, 0.94);
  color: var(--ink-brown);
  box-shadow: var(--shadow-paper);
  font-size: 12px;
  font-weight: 700;
}

@keyframes home-edit-wiggle {
  from { transform: rotate(-0.35deg); }
  to { transform: rotate(0.35deg); }
}

/* ── 手账主屏 · 全屏壁纸 crossfade 层（含 dock 下方区域，与分页同步）── */
.home-shell-page .home-wallpaper-layer {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  background-color: var(--bg-paper, #fbf6f0);
}

.home-shell-page .home-wallpaper-layer.has-home-pano {
  background-color: transparent;
}

.home-shell-page .sea-wallpaper-slide {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background-color: var(--bg-paper, #fbf6f0);
}

.home-shell-page .home-wallpaper-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  pointer-events: none;
  -webkit-user-drag: none;
  user-select: none;
}

.home-shell-page .home-wallpaper-img--base {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.home-shell-page .home-wallpaper-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.home-shell-page .home-pages-container {
  position: relative;
  z-index: 2;
}

.home-shell-page .home-bottom-chrome {
  flex: 0 0 auto;
  padding: 4px 16px calc(6px + var(--safe-bottom));
  z-index: 6;
}

.home-shell-page .page-indicators {
  position: static;
  left: auto;
  right: auto;
  bottom: auto;
  margin-bottom: 6px;
}

.home-shell-page .dock {
  position: static;
  left: auto;
  right: auto;
  bottom: auto;
  width: 100%;
  margin: 0;
  -webkit-backdrop-filter: blur(12px);
}

.home-dock-slot {
  position: relative;
  flex: 0 0 auto;
}

button.app-icon:disabled {
  opacity: 0.42;
}

.app-icon .custom-img,
.photo-area .photo-custom,
.avatar-placeholder .avatar-custom {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.film-ring,
.film-sticker {
  overflow: hidden;
}

.film-ring .film-custom,
.film-sticker .film-custom {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.home-tape-top-center {
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  height: 16px;
  background: var(--tape-blue);
}

.home-tape-polaroid-p1 {
  top: -10px;
  right: 20px;
  width: 40px;
  height: 16px;
  background: var(--tape-blue);
  transform: rotate(-5deg);
}

.home-tape-note {
  top: -10px;
  left: 20px;
  width: 60px;
  height: 20px;
  background: var(--tape-orange);
  transform: rotate(5deg);
}

.home-tape-polaroid-p3 {
  top: -12px;
  right: 30px;
  width: 50px;
  height: 20px;
  background: var(--tape-blue);
  transform: rotate(-10deg);
}

/* 第三页拍立得：照片填满整张蓝卡片，文字只占底部一条 */
.page-three .polaroid-widget {
  align-self: center;
  width: 100%;
  max-width: 240px;
  padding: 12px 12px 10px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
}
.page-three .polaroid-widget .photo-area {
  flex: 1 1 auto;
  aspect-ratio: auto;
  min-height: 180px;
  margin-bottom: 8px;
}
.page-three .polaroid-widget .caption {
  flex: 0 0 auto;
  font-size: 13px;
  line-height: 1.2;
}

.home-shell-page .deco-tape {
  position: absolute;
  opacity: 0.85;
}
