:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-hover: #f0f2f5;
  --border: #e4e7eb;
  --text: #1a1d23;
  --text-secondary: #6b7280;
  --text-tertiary: #9ca3af;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.1), 0 4px 10px rgba(0, 0, 0, 0.04);
  --radius: 8px;
  --sidebar-width: 280px;
}

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

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

.app {
  display: flex;
  height: 100vh;
  width: 100%;
}

/* 侧边栏 */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: margin-left 0.25s ease;
}

.sidebar.collapsed {
  margin-left: calc(-1 * var(--sidebar-width));
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}

.logo {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
}

.logo svg {
  color: var(--primary);
  flex-shrink: 0;
}

.collapse-btn,
.expand-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 5px;
  border-radius: 6px;
  transition: all 0.15s;
}

.collapse-btn:hover,
.expand-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.file-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
}

.file-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s;
  border: 1px solid transparent;
  margin-bottom: 4px;
}

.file-item:hover {
  background: var(--surface-hover);
}

.file-item.active {
  background: #eff6ff;
  border-color: #bfdbfe;
}

.file-item.active .file-name {
  color: var(--primary);
  font-weight: 500;
}

.file-icon {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fef2f2;
  color: #dc2626;
  border-radius: 7px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.file-item.active .file-icon {
  background: #fee2e2;
}

.file-info {
  flex: 1;
  min-width: 0;
}

.file-name {
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}

.file-meta {
  font-size: 11px;
  color: var(--text-tertiary);
}

.sidebar-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-tertiary);
}

/* 主区域 */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* 工具栏 */
.toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  z-index: 10;
  flex-wrap: wrap;
}

.doc-title {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 120px;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.page-nav,
.zoom-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg);
  border-radius: var(--radius);
  padding: 3px;
}

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.15s;
  flex-shrink: 0;
}

.icon-btn:hover:not(:disabled) {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

.icon-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.page-input-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-secondary);
}

#pageInput {
  width: 40px;
  height: 28px;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 12px;
  color: var(--text);
  background: var(--surface);
  outline: none;
  -moz-appearance: textfield;
}

#pageInput::-webkit-outer-spin-button,
#pageInput::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

#pageInput:focus {
  border-color: var(--primary);
}

.zoom-level {
  font-size: 12px;
  color: var(--text-secondary);
  min-width: 42px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* 查看区 */
.viewer-container {
  flex: 1;
  overflow: auto;
  display: flex;
  justify-content: center;
  padding: 24px;
  position: relative;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-tertiary);
  gap: 16px;
  text-align: center;
}

.empty-state p {
  font-size: 14px;
}

.pdf-canvas {
  box-shadow: var(--shadow-lg);
  border-radius: 2px;
  background: #fff;
  max-width: none;
}

/* 视频播放器 */
.video-player {
  max-width: 100%;
  max-height: calc(100vh - 130px);
  border-radius: 6px;
  box-shadow: var(--shadow-lg);
  background: #000;
  margin: auto 0;
}

/* 视频文件图标 */
.file-icon.video {
  background: #f5f3ff;
  color: #7c3aed;
}

.file-item.active .file-icon.video {
  background: #ede9fe;
}

.loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  color: var(--text-secondary);
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* 滚动条 */
.file-list::-webkit-scrollbar,
.viewer-container::-webkit-scrollbar {
  width: 8px;
}

.file-list::-webkit-scrollbar-track,
.viewer-container::-webkit-scrollbar-track {
  background: transparent;
}

.file-list::-webkit-scrollbar-thumb,
.viewer-container::-webkit-scrollbar-thumb {
  background: var(--text-tertiary);
  border-radius: 4px;
  opacity: 0.4;
}

.file-list::-webkit-scrollbar-thumb:hover,
.viewer-container::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

/* 响应式 */
@media (max-width: 680px) {
  .sidebar {
    position: fixed;
    z-index: 100;
    height: 100vh;
    box-shadow: var(--shadow-lg);
  }
  .toolbar {
    padding: 10px 12px;
    gap: 8px;
  }
  .doc-title {
    font-size: 13px;
  }
  .toolbar-actions {
    gap: 8px;
  }
}
