* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f3f4f6;
  height: 100vh;
  overflow: hidden;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* 顶部工具栏 */
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
}

.page-nav {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-btn {
  width: 32px;
  height: 32px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #fff;
  font-size: 18px;
  cursor: pointer;
}

.nav-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.nav-btn:not(:disabled):active {
  background: #f3f4f6;
}

#pageInfo {
  font-size: 14px;
  color: #374151;
  min-width: 60px;
  text-align: center;
}

.split-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

#splitRatio {
  font-size: 16px;
  font-weight: 600;
  color: #ef4444;
  min-width: 45px;
}

.reset-btn {
  padding: 6px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #fff;
  font-size: 13px;
  color: #6b7280;
  cursor: pointer;
}

/* 预览区 */
.preview-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow: hidden;
  position: relative;
}

.canvas-wrapper {
  position: relative;
  background: #fff;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  border-radius: 4px;
  overflow: hidden;
}

#pdfCanvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
}

/* 分割线 */
.split-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 44px;
  margin-left: -22px;
  cursor: ew-resize;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
}

.split-handle {
  width: 4px;
  height: 100%;
  background: #ef4444;
  position: relative;
}

.split-handle::before,
.split-handle::after {
  content: '';
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: 24px;
  height: 24px;
  background: #ef4444;
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(239,68,68,0.4);
}

.split-handle::before { top: 15%; }
.split-handle::after { bottom: 15%; }

/* 预览遮罩 */
.preview-mask {
  position: absolute;
  top: 0;
  bottom: 0;
  background: rgba(79, 70, 229, 0.1);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}

.preview-mask.left { left: 0; border-right: 2px dashed #4f46e5; }
.preview-mask.right { right: 0; border-left: 2px dashed #4f46e5; }

.canvas-wrapper.previewing .preview-mask { opacity: 1; }

/* 加载提示 */
.loading {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.loading.hidden { display: none; }

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #e5e7eb;
  border-top-color: #4f46e5;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading p {
  font-size: 14px;
  color: #6b7280;
}

/* 缩略图栏 */
.thumbnail-bar {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  background: #fff;
  border-top: 1px solid #e5e7eb;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.thumbnail-bar:empty { display: none; }

.thumbnail {
  flex-shrink: 0;
  width: 48px;
  height: 68px;
  border: 2px solid transparent;
  border-radius: 4px;
  overflow: hidden;
  cursor: pointer;
  position: relative;
}

.thumbnail.active {
  border-color: #4f46e5;
}

.thumbnail canvas {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.thumbnail-num {
  position: absolute;
  bottom: 2px;
  right: 2px;
  background: rgba(0,0,0,0.6);
  color: #fff;
  font-size: 10px;
  padding: 1px 4px;
  border-radius: 2px;
}

/* 底部操作栏 */
.action-bar {
  display: flex;
  gap: 12px;
  padding: 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
  background: #fff;
  border-top: 1px solid #e5e7eb;
}

.btn {
  flex: 1;
  height: 48px;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
}

.btn-secondary {
  background: #f3f4f6;
  color: #374151;
}

.btn-primary {
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  color: #fff;
}

.btn:active {
  opacity: 0.8;
}

/* 预览弹窗 */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s;
}

.modal.show {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  background: #fff;
  border-radius: 12px;
  width: 90%;
  max-width: 400px;
  max-height: 80vh;
  overflow: hidden;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid #e5e7eb;
  font-weight: 600;
}

.close-btn {
  width: 28px;
  height: 28px;
  border: none;
  background: #f3f4f6;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
}

.modal-body {
  padding: 16px;
}

.preview-pages {
  display: flex;
  gap: 16px;
}

.preview-page {
  flex: 1;
  text-align: center;
}

.preview-page canvas {
  width: 100%;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
}

.preview-page p {
  margin-top: 8px;
  font-size: 13px;
  color: #6b7280;
}
