/* 婉娩魔法切图：画布在左、检查器在右，按“图片 → 画板 → 导出”的顺序操作。 */
:root {
  --el-color-primary: #6d55d9;
  --el-color-primary-light-3: #927fe4;
  --el-color-primary-light-5: #b5a8ec;
  --el-color-primary-light-7: #d5cdef;
  --el-color-primary-light-8: #e4dff5;
  --el-color-primary-light-9: #f1edfc;
  --el-color-primary-dark-2: #5840bd;
  --accent: #6d55d9;
  --accent-dark: #5840bd;
  --accent-soft: #f1eefd;
  --ink: #1d1b26;
  --text: #4b4858;
  --muted: #8b8798;
  --bg: #f3f3f6;
  --surface: #fff;
  --line: #e7e6ec;
  --track: #f0eff4;
  --radius: 10px;
}
html, body { min-width: 320px; background: var(--bg); color: var(--ink); }
body {
  -webkit-font-smoothing: antialiased;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

/* ---- 外框 ---- */
.app-shell.editor {
  box-sizing: border-box;
  display: grid;
  grid-template: 56px minmax(0, 1fr) / minmax(0, 1fr) 360px;
  width: 100%;
  max-width: none;
  height: 100dvh;
  min-height: 560px;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: var(--bg);
}
.editor .tool-stack { display: none !important; }
.editor button:focus-visible, .editor input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* 顶栏：品牌 + 唯一主操作 */
.editor .app-header {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 16px;
  max-width: none;
  min-height: 0;
  margin: 0;
  padding: 0 16px 0 20px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.brand { display: flex; align-items: center; gap: 10px; }
.editor .app-logo { width: 28px; height: 28px; border-radius: 8px; object-fit: cover; box-shadow: none; }
.editor .app-header h1 { margin: 0; color: var(--ink); font-size: 15px; font-weight: 650; letter-spacing: 0; }
.quick-save, .layer-button.primary, .empty-upload {
  border: 0;
  color: #fff;
  background: var(--accent);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background-color .15s;
}
.quick-save:not(:disabled):hover, .layer-button.primary:hover, .empty-upload:hover { background: var(--accent-dark); }
.quick-save { height: 36px; margin-left: auto; padding: 0 18px; border-radius: 9px; font-size: 13px; }
.quick-save:disabled { color: #a9a6b3; background: var(--track); cursor: not-allowed; }

/* ---- 画布 ---- */
.workspace {
  position: relative;
  display: flex;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: var(--bg) radial-gradient(#d9d7e0 1px, transparent 1px) 0 0 / 20px 20px;
}
.editor .workspace .preview-frame {
  position: relative;
  flex: none;
  width: var(--fit-width, 360px);
  max-width: calc(100% - 48px);
  margin: auto;
  overflow: hidden;
  border: 0;
  border-radius: 4px;
  background: #fff conic-gradient(#efeff2 25%, transparent 0 50%, #efeff2 0 75%, transparent 0) 0 0 / 16px 16px;
  box-shadow: 0 1px 2px #1d1b260f, 0 12px 40px #1d1b2614;
}
.editor:not(.has-image) .preview-frame { background: var(--surface); }
.editor:not(.has-image) .board-overlay { display: none; }
/* 缩放、拖动时只移动照片图层（GPU 合成），格子在停止 150ms 后重算；期间先隐藏旧格子，避免画面看起来卡住 */
.editor .preview-image { will-change: transform; }
.editor .preview-frame[data-adjusting] .board-canvas { visibility: hidden; }
.editor .dashed-border { border: 0; border-radius: 4px; }
.editor .grid-line { opacity: .55; }
.editor .zoom-badge { border-radius: 6px; color: #fff; background: #1d1b26b3; }
.editor .preview-placeholder { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 28px; color: #b2adc0; text-align: center; }
.editor .preview-placeholder > span:not(.empty-hint) { color: var(--ink); font-size: 15px; font-weight: 600; }
.empty-hint { max-width: 260px; color: var(--muted); font-size: 12px; line-height: 1.6; }
.empty-upload { height: 38px; margin-top: 4px; padding: 0 22px; border-radius: 9px; font-size: 13px; }
.editor .preview-frame.is-dragging { box-shadow: 0 0 0 2px var(--accent), 0 12px 40px #1d1b2626; }
.editor .preview-frame.is-dragging::after {
  content: '松开以上传图片';
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  color: var(--accent-dark);
  background: #f1eefdee;
  font-size: 15px;
  font-weight: 600;
  pointer-events: none;
}

/* 缩放时的临时图层预览 */
.live-preview { position: absolute; inset: 0; z-index: 3; overflow: hidden; background: #eef2f7; pointer-events: none; contain: layout paint; }
.live-preview[hidden] { display: none; }
.live-surface { position: absolute; top: 50%; left: 50%; width: 100%; height: 100%; overflow: hidden; transform: translate(-50%, -50%); }
.live-surface img { position: absolute; inset: 0; width: 100%; height: 100%; max-width: none; }
.live-background { object-fit: cover; }
.live-foreground { transform-origin: center; will-change: transform; }

/* ---- 检查器 ---- */
.inspector {
  min-width: 0;
  min-height: 0;
  overflow: hidden auto;
  border-left: 1px solid var(--line);
  background: var(--surface);
  scrollbar-width: thin;
}
.section { padding: 20px; }
.section + .section { border-top: 1px solid var(--line); }
.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 16px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 650;
}
.step {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  color: var(--accent);
  background: var(--accent-soft);
  font-size: 11px;
  font-weight: 700;
}
.control-label, .layer-label {
  display: block;
  margin: 16px 0 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}
.section-title + .control-label { margin-top: 0; }

/* 原站控件统一成无框样式 */
.editor .inspector .control-strip {
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
}

/* ① 图片 */
.layer-button {
  width: 100%;
  height: 40px;
  padding: 0 14px;
  overflow: hidden;
  border-radius: 9px;
  font-size: 13px;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.has-image .layer-button.primary { border: 1px solid var(--line); color: var(--text); background: var(--surface); font-weight: 500; }
.has-image .layer-button.primary:hover { border-color: #cfc8e6; background: #faf9fc; }
.history { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch-card { position: relative; }
.swatch {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--muted);
  background: var(--track);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: box-shadow .15s;
}
.swatch img { width: 100%; height: 100%; object-fit: cover; }
.swatch.is-light { color: var(--text); }
.swatch.is-dark { border-color: #1d1b26; color: #fff; }
.swatch:hover { box-shadow: 0 0 0 2px #fff, 0 0 0 3px #cfc8e6; }
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--accent); }
.swatch-add { border-style: dashed; color: var(--accent); background: transparent; font-size: 18px; }
.swatch-add:disabled { opacity: .5; cursor: wait; }
.swatch-delete {
  position: absolute;
  top: -6px;
  right: -6px;
  display: none;
  place-items: center;
  width: 18px;
  height: 18px;
  padding: 0;
  border: 2px solid #fff;
  border-radius: 50%;
  color: #fff;
  background: var(--ink);
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
}
.swatch-card:hover .swatch-delete, .swatch-delete:focus-visible { display: grid; }
.swatch-delete:hover { background: #c2456a; }
@media (hover: none) { .swatch-delete { display: grid; } }
.layer-size {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
}
.editor:not(.has-image) .layer-size { display: none; }
.layer-size .layer-label { margin: 0; }
.layer-size input { width: 100%; height: 20px; accent-color: var(--accent); cursor: pointer; }
.size-value {
  min-width: 50px;
  height: 26px;
  padding: 0 8px;
  border: 0;
  border-radius: 6px;
  color: var(--text);
  background: var(--track);
  font: inherit;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}
.size-value:hover { color: var(--accent); }
.layer-status { margin: 12px 0 0; color: #c2456a; font-size: 12px; line-height: 1.6; overflow-wrap: anywhere; }
.layer-status:empty { display: none; }

/* ② 画板：比例与布局用分段控件 */
.editor .inspector .choice-strip.control-strip, .editor .inspector .layout-choices {
  display: grid;
  gap: 2px;
  width: auto;
  padding: 3px;
  overflow: visible;
  border-radius: var(--radius);
  background: var(--track);
}
.editor .inspector .choice-strip.control-strip { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.editor .inspector .layout-choices { grid-template-columns: repeat(7, minmax(0, 1fr)); }
.editor .inspector .grid-strip { display: flex; flex-direction: column; gap: 0; }
.editor .inspector .choice-chip {
  min-width: 0;
  height: 32px;
  min-height: 0;
  padding: 0 2px;
  border: 0;
  border-radius: 7px;
  color: var(--muted);
  background: transparent;
  box-shadow: none;
  transition: color .15s, background-color .15s;
}
.editor .choice-chip:hover { color: var(--ink); background: transparent; }
.editor .choice-chip.selected { color: var(--ink); background: var(--surface); box-shadow: 0 1px 3px #1d1b261a, 0 0 0 1px #1d1b260a; }
.editor .choice-chip span:last-child { font-size: 12px; font-weight: 600; }
.editor .ratio-icon, .editor .mini-grid-icon { display: none; }
.editor .preview-options { display: flex; flex-wrap: wrap; gap: 4px 20px; margin-top: 12px; padding: 0; }
.editor .el-checkbox { height: 28px; }
.editor .el-checkbox__label { color: var(--text); font-size: 13px; }

/* 画板效果开启后的附加选项 */
.editor .editing-row { margin-top: 12px; }
.editor .editing-label { color: var(--muted); font-size: 12px; }
.editor .optimization-report, .editor .artwork-list { margin-top: 12px; }
.editor .game-grid-spec { margin-top: 12px; color: var(--muted); font-size: 12px; line-height: 1.6; }
.editor .editing-hint {
  max-height: 84px;
  margin-top: 12px;
  padding: 10px 12px;
  overflow: auto;
  border-radius: 8px;
  color: var(--muted);
  background: var(--track);
  font-size: 11px;
  line-height: 1.6;
}

/* ③ 导出：顶栏按钮负责保存，这里只放命名、格式和位置 */
.editor .inspector .naming-strip { display: flex; align-items: center; gap: 8px; min-height: 0; }
.editor .inspector .naming-strip { flex-wrap: nowrap; }
.editor .inspector .naming-strip .el-input { flex: 1 1 auto; width: auto; min-width: 0; }
.editor .inspector .naming-strip .format-select { flex: 0 0 88px; width: 88px; }
.editor .inspector .naming-strip > .el-button { flex: none; margin: 0; }
.editor .el-input__wrapper, .editor .el-select__wrapper { border-radius: 8px; background: var(--surface); box-shadow: 0 0 0 1px var(--line) inset; }
.editor .inspector .folder-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 0;
  height: 36px;
  padding: 0 4px 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
}
.editor .folder-strip .strip-icon { flex: none; font-size: 16px !important; }
.editor .folder-strip .path-button { flex: 1; text-align: left; }
.editor .folder-strip .is-circle { flex: none; width: 28px; height: 28px; border: 0; }
.editor .folder-strip .path-text, .editor .folder-strip .path-button { min-width: 0; overflow: hidden; color: var(--text); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.editor .inspector .action-strip { display: flex; margin-top: 12px; padding: 0; background: none; }
.editor .action-strip .el-button--primary { display: none; }
.editor .action-strip .el-button { flex: 1; height: 36px; margin: 0; border-radius: 8px; font-size: 13px; }

/* ---- 响应式：窄屏改为上下布局，导出按钮常驻顶部 ---- */
@media (max-width: 959px) {
  .app-shell.editor {
    display: flex;
    flex-direction: column;
    height: auto;
    min-height: 100dvh;
    overflow: visible;
  }
  .editor .app-header { position: sticky; top: 0; z-index: 30; flex: none; height: 56px; padding: 0 12px 0 16px; }
  .workspace { flex: none; padding: 16px 0; }
  .editor .workspace .preview-frame { max-width: calc(100% - 32px); }
  .inspector { overflow: visible; border-top: 1px solid var(--line); border-left: 0; }
  .section { padding: 20px 16px; }
  .editor .inspector .choice-chip { height: 36px; }
}
@media (prefers-reduced-motion: reduce) {
  .editor *, .editor *::before, .editor *::after { transition-duration: .01ms !important; }
}
