/* Canvast 风格布局 */
* { margin: 0; padding: 0; box-sizing: border-box; }

/* ⚠️ 全站字体规范（2026-08-12 定稿）：
   中文长文本 → 苹方 PingFang SC / 微软雅黑（系统中文最佳阅读字体）
   英文/数字 → 系统无衬线（SF/Roboto/Segoe）
   代码 → 等宽 Consolas/Menlo */
:root {
  --font-cn: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', '微软雅黑', sans-serif;
  --font-code: ui-monospace, SFMono-Regular, Consolas, Menlo, 'Courier New', monospace;
}

body {
  font-family: var(--font-cn);
  height: 100vh;
  overflow: hidden;
}
code, pre, .mono { font-family: var(--font-code); }

/* === 主体三段式 === */
.main-container {
  display: flex;
  height: calc(100vh - 48px); /* 减底部工具栏 */
}

/* --- 左侧画布 --- */
.canvas-container {
  flex: 1;
  position: relative;
  background: #e8e8e8;
  overflow: hidden;
}
.canvas-area {
  width: 100%;
  height: 100%;
  position: relative;
}

/* --- 画布元素 --- */
.canvas-image {
  position: absolute;
  cursor: move;
  user-select: none;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  z-index: 40; /* ⚠️ 高于选择框拖拽层(36)：选择框存在时图片仍可单独拖动 */
}

/* ⚠️ 选中内容默认隐藏锚点，鼠标悬停才显示（8/14 用户要求） */
.canvas-image.selected {
  outline: none;
}
/* ⚠️ 8/15：消除点击后浏览器默认 focus ring（浅灰 3px——与选中黄边不一致/叠加） */
.canvas-image:focus { outline: none; }
.placeholder-rect:focus { outline: none; }
.canvas-image.selected:hover {
  /* ⚠️ 8/15：与占位区完全一致——只 1px 金边（无光晕；原光晕在 transform scale 内被缩放几乎不可见，视觉不统一） */
  outline: 1px solid #ffcc00;
  outline-offset: 2px;
  box-shadow: none;
}

/* --- 占位区 --- */
/* ⚠️ 8/15 「生成按钮样式」——图片/视频生成器配置面板的「生成 ⚡」按钮统一（基础 + hover 白底黑字） */
/* ⚠️ 8/16「生成按钮样式」v2——图片/视频生成器配置面板的「生成 ⚡」按钮：静态白底黑字，无 hover 效果 */
.gen-cost-btn {
  padding:6px 12px;border-radius:8px;cursor:pointer;font-size:13px;font-weight:600;
  color:#111;background:#fff;white-space:nowrap;
}
.gen-cost-btn #gen-cost, .gen-cost-btn #video-cost { color:#111; }

.placeholder-rect {
  position: absolute;
  width: 512px;
  height: 512px;
  /* ⚠️ 配置面板同款底色 + 无边框形式（8/15 用户要求）；选中时黄边（2px） */
  border: none;
  background: rgba(20,22,26,0.97);
  cursor: pointer;
  box-sizing: border-box;
}
/* ⚠️ 占位区选中：常显金边（8/15——Ctrl 多选可见性：原 hover 才显示导致多选时其他选中占位区看不到黄边，用户以为不支持多选） */
.placeholder-rect.selected {
  outline: 1px solid #ffcc00;
  outline-offset: 2px;
}
.placeholder-rect.selected:hover,
.placeholder-rect.panel-open {
  /* ⚠️ 8/15：与图片选中完全一致——只 1px 金边（无 box-shadow 光晕——图片在 transform scale 内光晕被缩放几乎不可见，占位区光晕完整显示造成视觉差距） */
  outline: 1px solid #ffcc00;
  outline-offset: 2px;
  box-shadow: none;
}

.placeholder-rect.loading {
  /* ⚠️ 8/15：生成中保持与普通占位区完全一致（无边框+原底色）——只加中央「生成中...」文字 */
  border: none;
  background: rgba(20,22,26,0.97);
  box-shadow: none;
  animation: none;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* --- 配置面板 --- */
.config-panel {
  position: absolute;
  width: 340px;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  padding: 16px;
  z-index: 200;
  font-size: 14px;
}

.config-panel.collapsed {
  padding: 8px 12px;
  width: auto;
}

.config-toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  user-select: none;
  margin-bottom: 8px;
}

.config-toggle .toggle-text {
  font-weight: 600;
  color: #333;
}

.config-toggle .toggle-icon {
  color: #666;
  font-size: 12px;
  transition: transform 0.2s;
}

.config-toggle.expanded .toggle-icon {
  transform: rotate(180deg);
}

.config-content {
  display: none;
}

.config-panel.expanded .config-content {
  display: block;
}

.config-group {
  margin-bottom: 14px;
}

.config-label {
  display: block;
  font-weight: 500;
  color: #333;
  margin-bottom: 6px;
  font-size: 13px;
}

.config-select, .config-input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.config-select:focus, .config-input:focus {
  border-color: #007aff;
}

.config-select:disabled {
  background: #f5f5f5;
  color: #999;
  cursor: not-allowed;
}

.config-row {
  display: flex;
  gap: 10px;
}

.config-row .config-group {
  flex: 1;
}

.config-textarea {
  width: 100%;
  min-height: 80px;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
  resize: vertical;
  outline: none;
  font-family: inherit;
}

.config-textarea:focus {
  border-color: #007aff;
}

.config-buttons {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.btn-primary, .btn-secondary {
  flex: 1;
  padding: 10px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-primary {
  background: #007aff;
  color: #fff;
}

.btn-primary:hover {
  background: #0066cc;
}

.btn-primary:disabled {
  background: #a0d0ff;
  cursor: not-allowed;
}

.btn-secondary {
  background: #f0f0f0;
  color: #333;
}

.btn-secondary:hover {
  background: #e0e0e0;
}

.model-option {
  display: flex;
  align-items: center;
  gap: 6px;
}

.model-status {
  font-size: 12px;
}

.model-status.available {
  color: #34c759;
}

.model-status.coming-soon {
  color: #ff9500;
}

/* --- 右侧聊天面板 --- */
.chat-panel {
  width: 320px;
  background: #fff;
  border-left: 1px solid #e0e0e0;
  display: flex;
  flex-direction: column;
}
.chat-header {
  padding: 16px;
  border-bottom: 1px solid #eee;
}
.chat-header h3 { font-size: 16px; color: #333; }
.chat-tabs {
  display: flex;
  padding: 8px 16px;
  gap: 8px;
  border-bottom: 1px solid #eee;
}
.chat-tab {
  padding: 6px 16px;
  border-radius: 20px;
  border: 1px solid #ddd;
  background: #fff;
  cursor: pointer;
  font-size: 13px;
  color: #666;
}
.chat-tab.active { background: #333; color: #fff; border-color: #333; }
.chat-input-area {
  padding: 16px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.chat-input-area textarea {
  flex: 1;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 12px;
  font-size: 14px;
  resize: none;
  outline: none;
}
.chat-input-area textarea:focus { border-color: #999; }
.send-btn {
  background: #333;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px;
  font-size: 14px;
  cursor: pointer;
}
.send-btn:hover { background: #555; }

/* === 底部工具栏 - 浮动胶囊 === */
.toolbar {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.12);
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  gap: 2px;
  z-index: 100;
}

.tool-btn {
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: #333;
  white-space: nowrap;
}
.tool-btn:hover { background: #e8e8e8; }
.tool-btn:active { background: #ddd; }
.tool-btn.active { background: #007aff; color: #fff; }
.tool-btn .icon { font-size: 16px; }

/* 工具提示向上弹出 */
.tool-btn::after {
  content: attr(data-label);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: #333;
  color: #fff;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
}
.tool-btn:hover::after { opacity: 1; }

/* === 左下角功能入口 === */
.bottom-panel {
  position: absolute;
  bottom: 56px;
  left: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 50;
}
.panel-btn {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  border: 1px solid #ddd;
  background: #fff;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #666;
}
.panel-btn:hover { background: #e8e8e8; transform: scale(1.05); }
.panel-btn:active { background: #ddd; transform: scale(0.95); }

/* === 左上角项目名 === */
.project-name {
  position: absolute;
  top: 12px;
  left: 16px;
  font-size: 20px;
  font-weight: 600;
  color: #333;
  cursor: text;
  padding: 4px 8px;
  border-radius: 4px;
  z-index: 50;
}
.project-name:hover { background: rgba(0,0,0,0.05); }
.project-name:focus { outline: 2px solid #999; background: #fff; }

/* === 右上角积分 === */
.top-right {
  position: absolute;
  top: 12px;
  right: 336px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 50;
  font-size: 13px;
  color: #666;
}

/* === 参考图关联 === */
.ref-image-list {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.ref-image-item {
  width: 60px;
  height: 60px;
  border: 2px solid #ddd;
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  position: relative;
}

.ref-image-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ref-image-item .remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  background: rgba(0,0,0,0.6);
  color: #fff;
  border: none;
  border-radius: 50%;
  font-size: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ref-add-btn {
  width: 60px;
  height: 60px;
  border: 2px dashed #ddd;
  border-radius: 6px;
  background: #fafafa;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: #999;
}

.ref-add-btn:hover {
  border-color: #007aff;
  color: #007aff;
}

/* === 对齐参考线 === */
.guide-line {
  position: absolute;
  background: #ff3b30;
  z-index: 150;
  pointer-events: none;
}

.guide-line.h {
  height: 1px;
  width: 100%;
  left: 0;
}

.guide-line.v {
  width: 1px;
  height: 100%;
  top: 0;
}

/* ⚠️ 8/15 用户要求：项目内画布 + AI 会话区所有滚动条统一为细长条（图2 效果） */
/* ⚠️ 常规滚轴样式（8/15 定义）：基准 = 提示词文本框滚轴；全局应用，所有上弹菜单/滚动区域统一
   宽度4px/透明轨道/thumb rgba(255,255,255,0.18)/999px圆角/hover 0.32 */
*::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}
*::-webkit-scrollbar-track {
  background: transparent;
}
*::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.18);
  border-radius: 999px;
}
*::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,0.32);
}
/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.25) transparent;
}

/* === 提示词文本框滚动条（浅色细长，被全局规则覆盖，保留兼容） === */
.prompt-scroll::-webkit-scrollbar {
  width: 4px;
}
.prompt-scroll::-webkit-scrollbar-track {
  background: transparent;
}
.prompt-scroll::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.18);
  border-radius: 999px;
}
.prompt-scroll::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,0.32);
}

/* ⚠️ 生成图 hover 提示 + 双击查看无损原图灯箱（8/13） */
.hover-orig-tip {
  position: fixed;
  z-index: 9999;
  background: rgba(20,20,30,0.92);
  color: #fff;
  font-size: 12px;
  padding: 5px 11px;
  border-radius: 6px;
  pointer-events: none;
  white-space: nowrap;
  border: 1px solid rgba(255,255,255,0.16);
  box-shadow: 0 2px 10px rgba(0,0,0,0.5);
}
.lightbox-mask {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.86);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lightbox-box {
  position: relative;
  max-width: 92vw;
  max-height: 88vh;
}
.lightbox-img {
  display: block;
  max-width: 92vw;
  max-height: 88vh;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.6);
}
.lightbox-close {
  position: absolute;
  top: -18px;
  right: -18px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255,255,255,0.14);
  border: 1px solid rgba(255,255,255,0.3);
  color: #fff;
  font-size: 15px;
  cursor: pointer;
  line-height: 1;
  z-index: 2;
}
.lightbox-close:hover {
  background: rgba(255,255,255,0.28);
}
.lightbox-title {
  position: absolute;
  bottom: -32px;
  left: 0;
  right: 0;
  text-align: center;
  color: rgba(255,255,255,0.7);
  font-size: 12px;
  pointer-events: none;
}

/* ⚠️ 多选项菜单样式 chips hover（8/15 定义）：图片/视频生成器参数选项 chips
   hover 背景 0.06→0.12、边框 0.12→0.25；选中项(active=白底黑字)不受影响
   （chips 是内联样式故用 !important；:not(.active) 排除选中项） */
.res-btn:hover:not(.active), .ratio-btn:hover:not(.active),
.quality-btn:hover:not(.active), .vres-btn:hover:not(.active), .vratio-btn:hover:not(.active) {
  background: rgba(255,255,255,0.12) !important;
  border-color: rgba(255,255,255,0.25) !important;
}
