/* ===== 排版车间 · 多页画册工作台 ===== */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:       #0a0e13;
  --surface:  #11161d;
  --panel-bg: #141b24;
  --border:   #1e293b;
  --text:     #e2e8f0;
  --muted:    #64748b;
  --accent:   #8b5cf6;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text);
  width: 100vw; height: 100vh; overflow: hidden;
  display: flex; flex-direction: column;
}

/* ===== 顶部栏 ===== */
#topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; height: 48px; flex-shrink: 0;
  border-bottom: 1px solid var(--border); background: var(--surface);
}

/* ===== 主体三栏：flex-row + h-0 技巧锁死高度 ===== */
#main-row {
  display: flex; flex-direction: row; flex: 1; height: 0; width: 100%;
  overflow: hidden;
}

/* ===== 左侧工具栏：独立滚动舱 ===== */
#left-panel {
  width: 256px; flex-shrink: 0; height: 100%;
  background: var(--panel-bg); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 16px; gap: 10px;
  overflow-y: auto;
}

/* ===== 中央画布视窗：唯一自由滚动区 ===== */
#canvas-wrap {
  flex: 1; height: 100%; min-width: 0;
  display: flex; flex-direction: column;
  background: #090a0f;
  overflow: hidden;
}

/* 页面标签栏（已移到顶部） */
#page-bar {
  display: flex; align-items: center; gap: 4px;
  min-height: 32px;
}
#page-bar .page-tab {
  padding: 4px 14px; border-radius: 8px; font-size: 12px; font-weight: 600;
  border: 1px solid var(--border); background: var(--bg); color: var(--muted);
  cursor: pointer; white-space: nowrap; transition: all 0.15s;
}
#page-bar .page-tab:hover { border-color: var(--accent); color: var(--text); }
#page-bar .page-tab.active { background: rgba(139,92,246,0.15); border-color: var(--accent); color: #c4b5fd; }
#page-bar .page-tab .del-btn {
  margin-left: 6px; font-size: 11px; opacity: 0.5; cursor: pointer;
}
#page-bar .page-tab .del-btn:hover { opacity: 1; color: #fca5a5; }
#page-bar .add-page-btn {
  padding: 4px 12px; border-radius: 8px; font-size: 12px; font-weight: 700;
  border: 1px dashed var(--border); background: transparent; color: var(--muted);
  cursor: pointer; white-space: nowrap; transition: all 0.15s;
}
#page-bar .add-page-btn:hover { border-color: var(--accent); color: var(--accent); }

/* 画布滚动容器：完美居中，不贴任何边 */
#canvas-scroll {
  flex: 1; height: 100%; width: 100%;
  overflow: auto;
  display: flex !important;
  align-items: safe center !important;
  justify-content: safe center !important;
  background-color: #0f141c;
}
#canvas-scroll .canvas-inner {
  flex-shrink: 0;
}

/* Fabric 画布容器 */
.canvas-container {
  box-shadow: 0 8px 48px rgba(0,0,0,0.6) !important;
}

/* ===== 右侧属性面板：独立滚动舱 ===== */
#right-panel {
  width: 320px; flex-shrink: 0; height: 100%;
  background: var(--panel-bg); border-left: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 16px; gap: 14px;
  overflow-y: auto;
}

/* ===== 通用标签 ===== */
.section-label {
  font-size: 11px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.05em;
  margin-top: 8px; margin-bottom: 4px;
}
.section-label:first-child { margin-top: 0; }
.hint-text {
  margin-top: auto; font-size: 11px; color: var(--muted);
  line-height: 1.6; padding: 8px 0;
}
#prop-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  flex: 1; color: var(--muted); font-size: 13px; text-align: center; gap: 8px;
}

/* ===== 通用按钮 ===== */
.tool-btn {
  width: 100%; padding: 10px 12px; border-radius: 10px;
  font-size: 13px; font-weight: 600; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); cursor: pointer;
  transition: all 0.15s; text-align: left; display: flex; align-items: center; gap: 8px;
}
.tool-btn:hover { border-color: var(--accent); background: rgba(139,92,246,0.08); color: #c4b5fd; }

.export-btn {
  padding: 8px 20px; border-radius: 10px; font-size: 14px; font-weight: 700;
  border: none; cursor: pointer; transition: all 0.2s;
  background: linear-gradient(135deg, #8b5cf6, #6366f1); color: white;
}
.export-btn:hover { box-shadow: 0 4px 16px rgba(139,92,246,0.3); }

.back-link {
  color: var(--muted); text-decoration: none; font-size: 13px; font-weight: 600;
  transition: color 0.15s;
}
.back-link:hover { color: var(--accent); }

/* ===== 属性面板组件 ===== */
.prop-label {
  font-size: 11px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.05em;
}
.prop-row {
  display: flex; align-items: center; gap: 8px;
}
.prop-row input[type="color"] {
  width: 36px; height: 36px; border: 1px solid var(--border); border-radius: 8px;
  cursor: pointer; background: none; padding: 2px;
}
.prop-row input[type="range"] {
  flex: 1; accent-color: var(--accent);
}
.prop-row .val {
  font-size: 12px; color: var(--muted); width: 32px; text-align: right; font-family: monospace;
}
.prop-select {
  width: 100%; padding: 8px 10px; border-radius: 8px;
  font-size: 12px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border);
  outline: none; cursor: pointer; transition: border-color 0.15s;
}
.prop-select:focus { border-color: var(--accent); }
.toggle-btn {
  flex: 1; padding: 8px 0; border-radius: 8px; font-size: 12px; font-weight: 600;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  cursor: pointer; text-align: center; transition: all 0.15s;
}
.toggle-btn.active { background: rgba(139,92,246,0.2); border-color: var(--accent); color: #c4b5fd; }
.toggle-btn:hover { border-color: var(--accent); }

/* 背景选择弹窗 */
#bg-modal {
  display: none; position: fixed; inset: 0; z-index: 50;
  background: rgba(0,0,0,0.7); align-items: center; justify-content: center;
}
#bg-modal.show { display: flex; }
#bg-modal .modal-inner {
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  padding: 24px; max-width: 640px; width: 90%; max-height: 80vh; overflow-y: auto;
}
#bg-modal .modal-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 14px;
}
#bg-modal .modal-grid img {
  width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px;
  cursor: pointer; border: 2px solid transparent; transition: border-color 0.15s;
}
#bg-modal .modal-grid img:hover { border-color: var(--accent); }
