/* Gamm 图片画布弹框：外层卡片有边框，画布点阵，工具在顶部中间，缩放在画布右下角 */

.gamm-editor {
  position: fixed;
  inset: 0;
  z-index: 320;
  display: grid;
  place-items: center;
  padding: 20px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

.gamm-editor *,
.gamm-editor *::before,
.gamm-editor *::after {
  box-sizing: border-box;
}

.gamm-editor[hidden] {
  display: none;
}

body.gamm-editor-open {
  overflow: hidden;
}

.gamm-editor-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 5, 7, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  animation: gamm-editor-fade 0.2s ease both;
}

@keyframes gamm-editor-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.gamm-editor-panel {
  position: relative;
  z-index: 1;
  width: min(1360px, 97vw);
  height: min(900px, 95vh);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 20px;
  background: #0c0d10;
  box-shadow: 0 50px 120px rgba(0, 0, 0, 0.7);
  overflow: hidden;
  animation: gamm-editor-rise 0.26s cubic-bezier(0.22, 0.61, 0.36, 1) both;
}

@keyframes gamm-editor-rise {
  from { opacity: 0; transform: translateY(10px) scale(0.99); }
  to { opacity: 1; transform: none; }
}

/* ------------------------------- 顶部工具栏 ------------------------------- */

.gamm-editor-topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  height: 58px;
  min-width: 0;
  padding: 0 14px 0 18px;
}

.gamm-editor-topbar-left,
.gamm-editor-topbar-right,
.gamm-editor-topbar-center {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.gamm-editor-topbar-center {
  justify-content: center;
}

.gamm-editor-topbar-right {
  justify-content: flex-end;
}

.gamm-editor-counter {
  font-size: 12px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.4);
  font-variant-numeric: tabular-nums;
}

.gamm-editor-btn {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  min-width: 84px;
  padding: 0 14px;
  border: 0;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.78);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.gamm-editor-btn svg {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.gamm-editor-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
}

.gamm-editor-btn[hidden] {
  display: none;
}

.gamm-editor-btn.is-square {
  min-width: 34px;
  width: 34px;
  padding: 0;
  font-size: 15px;
  line-height: 1;
}

.gamm-editor-btn.is-zoom {
  min-width: 66px;
  padding: 0 8px;
  font-size: 11.5px;
  color: rgba(255, 255, 255, 0.5);
  font-variant-numeric: tabular-nums;
}

.gamm-editor-btn.is-active {
  color: #fff;
  background: rgba(255, 255, 255, 0.16);
}

.gamm-editor-btn.is-primary {
  color:#ffffff;
  background: linear-gradient(180deg, #ff2d68, #ff2d68);
}

.gamm-editor-btn.is-primary:hover {
  background: linear-gradient(180deg, #ff2d68, #ff4d9b);
}

.gamm-editor-btn.is-primary:disabled {
  color: rgba(255, 255, 255, 0.45);
  background: rgba(255, 255, 255, 0.06);
  cursor: not-allowed;
}

.gamm-editor-gen-cost {
  font-size: 10.5px;
  font-weight: 600;
  color: rgba(255,255,255,.72);
}

.gamm-editor-btn.is-primary:disabled .gamm-editor-gen-cost {
  color: rgba(255, 255, 255, 0.4);
}

.gamm-editor-btn.is-compact {
  min-width: auto;
  padding: 0 14px;
}

/* ------------------------------- 主体：缩略图栏 + 画布 ------------------------------- */

.gamm-editor-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  min-height: 0;
  padding: 0 12px 12px;
}

.gamm-editor-body.has-thumbs {
  grid-template-columns: 76px minmax(0, 1fr);
}

.gamm-editor-thumbs {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
}

.gamm-editor-thumbs::-webkit-scrollbar {
  width: 0;
}

.gamm-editor-thumbs[hidden] {
  display: none;
}

.gamm-editor-thumb {
  position: relative;
  flex: 0 0 auto;
  width: 100%;
  aspect-ratio: 1 / 1;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  overflow: hidden;
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 0.16s ease, box-shadow 0.16s ease;
}

.gamm-editor-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.gamm-editor-thumb:hover {
  opacity: 0.85;
}

.gamm-editor-thumb.is-active {
  opacity: 1;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.6);
}

.gamm-editor-thumb-new {
  position: absolute;
  top: 4px;
  right: 4px;
  padding: 1px 5px;
  border-radius: 6px;
  font-size: 9.5px;
  font-weight: 700;
  color:#ffffff;
  background: #ff2d68;
}

/* 画布：点阵背景 */

.gamm-editor-stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  border-radius: 16px;
  background-color: #08090b;
  background-image:
    radial-gradient(900px 460px at 50% -8%, rgba(255, 255, 255, 0.05), transparent 70%),
    radial-gradient(rgba(255, 255, 255, 0.11) 1.2px, transparent 1.3px);
  background-size: 100% 100%, var(--dot, 24px) var(--dot, 24px);
  background-position: 0 0, var(--dot-x, 0) var(--dot-y, 0);
  background-repeat: no-repeat, repeat;
  overflow: hidden;
}

.gamm-editor-viewport {
  position: absolute;
  inset: 0;
  /* 底部留出缩放控件的高度，避免图片被浮层压住。 */
  padding: 20px 20px 58px;
  touch-action: none;
}

.gamm-editor-viewport.is-grabbable {
  cursor: grab;
}

.gamm-editor-viewport.is-panning {
  cursor: grabbing;
}

.gamm-editor-canvas-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
  transform-origin: center center;
  transition: transform 0.16s cubic-bezier(0.22, 0.61, 0.36, 1);
}

.gamm-editor-viewport.is-panning .gamm-editor-canvas-wrap {
  transition: none;
}

.gamm-editor-image {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  display: block;
  border-radius: 8px;
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.6);
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
}

.gamm-editor-canvas {
  position: absolute;
  left: 0;
  top: 0;
  border-radius: 8px;
  touch-action: none;
}

.gamm-editor[data-editable="true"] .gamm-editor-canvas-wrap[data-editor-mode="region"] .gamm-editor-canvas {
  cursor: crosshair;
}

.gamm-editor[data-editable="true"] .gamm-editor-canvas-wrap[data-editor-mode="paint"] .gamm-editor-canvas {
  cursor: none;
}

.gamm-editor-canvas-wrap[data-editor-mode="preview"] .gamm-editor-canvas {
  pointer-events: none;
}

.gamm-editor-brush-ring {
  position: absolute;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  box-shadow: 0 0 0 1.5px rgba(255, 255, 255, 0.9), 0 0 0 2.5px rgba(0, 0, 0, 0.4);
  pointer-events: none;
}

/* 画布右下角浮层：下载 + 缩放 */

.gamm-editor-canvas-tools {
  position: absolute;
  right: 14px;
  bottom: 14px;
  z-index: 4;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border-radius: 13px;
  background: rgba(20, 21, 24, 0.78);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
}
/* 右下角下载使用独立状态，不让加载文案改变缩放工具组的宽度。 */
.gamm-editor-canvas-tools [data-editor-download] {
  width: 74px;
  min-width: 74px;
  flex: 0 0 auto;
  padding: 0 9px;
}
.gamm-editor-canvas-tools [data-editor-download] span {
  min-width: 38px;
  text-align: center;
}
.gamm-editor-canvas-tools [data-editor-download].is-downloading,
.gamm-editor-canvas-tools [data-editor-download].is-download-success,
.gamm-editor-canvas-tools [data-editor-download].is-download-error {
  pointer-events: none;
  opacity: 1;
}
.gamm-editor-canvas-tools [data-editor-download].is-downloading:disabled {
  opacity: 1;
}
.gamm-editor-canvas-tools [data-editor-download].is-downloading::before {
  content: "";
  width: 11px;
  height: 11px;
  flex: 0 0 auto;
  border: 2px solid rgba(255,255,255,.22);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: gamm-editor-spin .72s linear infinite;
}
.gamm-editor-canvas-tools [data-editor-download].is-download-success {
  color: #9be8c3;
  background: rgba(34,119,82,.2);
}
.gamm-editor-canvas-tools [data-editor-download].is-download-success::before {
  content: "";
  width: 12px;
  height: 12px;
  flex: 0 0 auto;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4 12.5l5 5L20 6.5' fill='none' stroke='%23fff' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4 12.5l5 5L20 6.5' fill='none' stroke='%23fff' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
}
.gamm-editor-canvas-tools [data-editor-download].is-download-error {
  color: #ffaaa4;
  background: rgba(255,113,100,.16);
}
.gamm-editor-canvas-tools [data-editor-download].is-download-error::before {
  content: "!";
  width: 12px;
  height: 12px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
}

/* 涂抹工具栏：只在涂抹模式出现，和 holo 的擦除工具栏对齐（笔刷大小 / 清空 / 退出）。 */
.gamm-editor-paint-tools {
  position: absolute;
  left: 50%;
  bottom: 14px;
  z-index: 4;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 13px;
  background: rgba(20, 21, 24, 0.82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
  white-space: nowrap;
}

.gamm-editor-paint-tools[hidden] {
  display: none;
}

.gamm-editor-paint-size {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 4px;
  color: rgba(255, 255, 255, 0.5);
}

.gamm-editor-paint-size span {
  font-size: 18px;
  line-height: 1;
}

.gamm-editor-paint-size input {
  width: 96px;
  margin: 0;
  accent-color: #ff8ab2;
  cursor: pointer;
}

.gamm-editor-paint-btn {
  height: 30px;
  padding: 0 11px;
  border: 0;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.07);
  color: rgba(255, 255, 255, 0.78);
  font: inherit;
  font-size: 12px;
  font-weight: 620;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.gamm-editor-paint-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}

.gamm-editor-paint-btn:disabled {
  cursor: not-allowed;
  opacity: 0.4;
  background: rgba(255, 255, 255, 0.04);
}

.gamm-editor-divider {
  width: 1px;
  height: 18px;
  margin: 0 2px;
  background: rgba(255, 255, 255, 0.12);
}

/* ------------------------------- 画布上的标识与输入框 ------------------------------- */

.gamm-editor-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.gamm-editor-marker {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: #fff;
  font: inherit;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  pointer-events: auto;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  transition: transform 0.14s ease;
}

.gamm-editor-marker:hover {
  transform: translate(-50%, -50%) scale(1.1);
}

.gamm-editor-marker[data-color="blue"] { background: #2563eb; }
.gamm-editor-marker[data-color="green"] { background: #22c55e; }
.gamm-editor-marker[data-color="red"] { background: #ef4444; }
.gamm-editor-marker[data-color="orange"] { background: #ea580c; }

.gamm-editor-marker.is-paint {
  background: #ef4444;
  font-size: 12px;
}

/* 还没填写要求的标记，加一圈白环提示 */
.gamm-editor-marker[data-confirmed="0"] {
  box-shadow: 0 0 0 2.5px #fff, 0 4px 12px rgba(0, 0, 0, 0.5);
}

.gamm-editor-popover {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 6px 5px 10px;
  border-radius: 12px;
  background: rgba(22, 23, 27, 0.97);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.6);
  pointer-events: auto;
}

.gamm-editor-popover-input {
  width: clamp(150px, 20vw, 240px);
  height: 28px;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: #fff;
  font: inherit;
  font-size: 12.5px;
}

.gamm-editor-popover-input::placeholder {
  color: rgba(255, 255, 255, 0.3);
}

.gamm-editor-popover-btn {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.07);
  color: rgba(255, 255, 255, 0.7);
  font: inherit;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.gamm-editor-popover-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.14);
}

.gamm-editor-popover-btn.is-confirm {
  width: 30px;
  min-width: 30px;
  height: 30px;
  padding: 0;
  color:#ffffff;
  background: #ff2d68;
  font-size: 13px;
  font-weight: 700;
}

.gamm-editor-popover-btn.is-confirm:hover {
  background: #ff2d68;
}

.gamm-editor-popover-btn.is-remove {
  width: 30px;
  height: 30px;
  font-size: 13px;
}

/* ------------------------------- 其它状态 ------------------------------- */

.gamm-editor-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.36);
}

.gamm-editor-empty[hidden] {
  display: none;
}

.gamm-editor-loader {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(8, 9, 11, 0.5);
}

.gamm-editor-loader[hidden] {
  display: none;
}

.gamm-editor-spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.16);
  border-top-color: rgba(255,45,104, 0.9);
  animation: gamm-editor-spin 0.8s linear infinite;
}

.gamm-editor-spinner.is-large {
  width: 30px;
  height: 30px;
  border-width: 3px;
}

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

.gamm-editor-busy {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  background: rgba(7, 8, 10, 0.78);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.gamm-editor-busy[hidden] {
  display: none;
}

.gamm-editor-busy-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 24px 32px;
  border-radius: 16px;
  background: rgba(24, 26, 30, 0.96);
  box-shadow: 0 24px 50px rgba(0, 0, 0, 0.6);
}

.gamm-editor-busy-card strong {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
}

/* 打开弹层时的加载态：图片读完再展示，避免一片空白 */
.gamm-editor-prepare {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: #0c0d10;
}

.gamm-editor-prepare[hidden] {
  display: none;
}

/* ------------------------------- 历史卡片里的编辑入口 ------------------------------- */

.ugc-history-btn.is-edit {
  color: rgba(255, 255, 255, 0.78);
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.13);
}

.ugc-history-btn.is-edit:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.22);
}

.ugc-video-body .ugc-history-btn.is-edit {
  color: var(--hf-text-2, rgba(255, 255, 255, 0.7));
  background: var(--hf-surface, rgba(255, 255, 255, 0.05));
  border-color: var(--hf-line, rgba(255, 255, 255, 0.1));
}

.ugc-video-body .ugc-history-btn.is-edit:hover {
  color: #fff;
  background: var(--hf-surface-2, rgba(255, 255, 255, 0.1));
}

/* ------------------------------- 响应式 ------------------------------- */

@media (max-width: 860px) {
  .gamm-editor {
    padding: 0;
  }

  .gamm-editor-panel {
    width: 100vw;
    height: 100vh;
    border: 0;
    border-radius: 0;
  }

  .gamm-editor-topbar {
    display: flex;
    height: 54px;
    gap: 8px;
    padding: 0 10px 0 12px;
  }

  .gamm-editor-topbar-left {
    display: none;
  }

  .gamm-editor-topbar-center {
    margin-right: auto;
    flex: 1 1 auto;
    justify-content: flex-start;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .gamm-editor-topbar-center::-webkit-scrollbar {
    height: 0;
  }

  .gamm-editor-btn {
    min-width: 62px;
    padding: 0 10px;
    font-size: 12px;
  }

  .gamm-editor-btn.is-square {
    min-width: 34px;
    width: 34px;
    padding: 0;
  }

  .gamm-editor-btn.is-zoom {
    min-width: 56px;
  }

  .gamm-editor-body {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    gap: 8px;
    padding: 0 8px 8px;
  }

  .gamm-editor-body.has-thumbs {
    grid-template-columns: minmax(0, 1fr);
  }

  .gamm-editor-thumbs {
    flex-direction: row;
    height: 60px;
    overflow-x: auto;
    overflow-y: hidden;
  }

  .gamm-editor-thumb {
    width: 52px;
    flex: 0 0 52px;
  }

  .gamm-editor-viewport {
    padding: 12px 12px 58px;
  }

  .gamm-editor-canvas-tools {
    right: 10px;
    bottom: 10px;
  }

  .gamm-editor-popover-input {
    width: clamp(120px, 42vw, 200px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .gamm-editor-panel,
  .gamm-editor-backdrop,
  .gamm-editor-canvas-wrap,
  .gamm-editor-spinner,
  .gamm-editor-marker {
    animation: none !important;
    transition: none !important;
  }
}
