* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg-color);
  font-family: system-ui, -apple-system, 'Microsoft YaHei', sans-serif;
  color: #334155;
  overflow-x: hidden;
}

/* 移动端顶部栏 */
.mobile-header {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 56px;
  background: var(--panel-bg);
  box-shadow: 0 2px 10px rgba(0,0,0,.05);
  z-index: 100;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
}
.mobile-header h2 { margin: 0; font-size: 16px; color: #1e293b; }
.mobile-menu-btn {
  background: var(--primary);
  color: #fff;
  border: none;
  height: 34px;
  padding: 0 16px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.5);
  z-index: 1001;
  opacity: 0;
  transition: opacity .3s;
}
.overlay.show { display: block; opacity: 1; }

/* 侧边栏 */
.sidebar {
  position: fixed;
  right: 0; top: 0;
  width: 390px;
  height: 100vh;
  overflow-y: auto;
  background: var(--panel-bg);
  border-left: 1px solid var(--border-color);
  padding: 20px 20px 30px;
  box-shadow: -4px 0 15px rgba(0,0,0,.03);
  z-index: 1002;
  display: flex;
  flex-direction: column;
  transition: transform .3s ease;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }

/* 预览区 */
.preview-wrapper {
  margin-right: 390px;
  padding: 30px;
  min-height: 100vh;
  overflow-x: auto;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

.preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  transform-origin: top center;
  transition: margin-bottom .2s;
}

.page {
  width: var(--pageWidth);
  min-height: var(--pageHeight);
  background: #fff;
  padding: var(--pagePadding);
  margin-bottom: 30px;
  display: grid;
  gap: var(--gap);
  justify-content: center;
  align-content: start;
  box-shadow: 0 10px 25px -5px rgba(0,0,0,.1), 0 8px 10px -6px rgba(0,0,0,.1);
  border-radius: 4px;
  transform: translate(var(--offsetX), var(--offsetY));
}
.page:last-child { margin-bottom: 0; }

@media (max-width: 768px) {
  .mobile-header { display: flex; }
  .sidebar {
    width: 85vw;
    max-width: 390px;
    transform: translateX(100%);
    padding-top: 20px;
  }
  .sidebar.show { transform: translateX(0); }
  .preview-wrapper {
    margin-right: 0;
    padding: 16px;
    padding-top: 76px;
  }
}