/* ===== REFINE EDITOR WORKSPACE ===== */
.refine-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4); z-index: 6000; display: none;
  backdrop-filter: blur(3px);
}
.refine-overlay.show { display: block; }

.refine-editor {
  position: fixed; top: 5vh; left: 3vw; right: 3vw; bottom: 5vh;
  background: var(--surface); border-radius: var(--radius-lg);
  box-shadow: 0 8px 60px rgba(0,0,0,0.2);
  z-index: 6001; display: none; overflow: hidden;
  flex-direction: column;
}
.refine-editor.show { display: flex; }

.refine-editor-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px; border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.refine-editor-header h2 { font-family: var(--font-display); font-size: 15px; color: var(--ink); margin: 0; display: flex; align-items: center; gap: 8px; }
.refine-editor-header h2 span { font-size: 11px; color: var(--mist); font-weight: 400; font-family: var(--font-body); }
.refine-close { background: none; border: none; font-size: 22px; color: var(--mist); cursor: pointer; padding: 0 6px; }
.refine-close:hover { color: var(--ink); }

.refine-body {
  display: flex; flex: 1; overflow: hidden;
}

/* Left sidebar — mode selector */
.refine-sidebar {
  width: clamp(100px, 100px + (100vw - 1024px) * 0.05, 160px);
  min-width: 100px;
  border-right: 1px solid var(--border);
  background: var(--surface-alt); padding: 4px 0; overflow-y: auto;
}
.refine-mode-group { margin-bottom: 2px; }
.refine-mode-group-title {
  font-size: 9px; font-weight: 700; color: var(--gold-dark);
  padding: 8px 14px 3px; letter-spacing: 0.08em; text-transform: uppercase;
}
.refine-mode-group-inner { display: flex; flex-direction: column; }
.refine-mode-btn {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 7px 14px; border: none; background: none; cursor: pointer;
  font-size: 11px; color: var(--mist); text-align: left;
  border-radius: 6px; transition: all 0.15s;
  margin: 2px 6px; width: calc(100% - 12px);
}
.refine-mode-btn:hover { background: var(--surface); color: var(--ink); }
.refine-mode-btn.active { background: #FDF9F3; color: var(--gold-dark); font-weight: 600; box-shadow: inset 3px 0 0 var(--gold); }
.refine-mode-btn .mode-icon { width: 16px; height: 16px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }

/* Center — image display */
.refine-center {
  flex: 1; display: flex; flex-direction: column;
  position: relative;
}
.refine-image-area {
  flex: 1; display: flex; align-items: center; justify-content: center;
  background: #f0ede8; position: relative; overflow: hidden;
}
.refine-image-area img { max-width: 100%; max-height: 100%; object-fit: contain; }
.refine-canvas-overlay {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  cursor: none; display: none;
}
.refine-canvas-overlay.show { display: block; }

/* Preview mode — 卡片式对比布局 */
.refine-preview-wrap { display: none; flex: 1; }
.refine-preview-wrap.show {
  display: flex;
  overflow-y: auto;
  gap: 24px;
  padding: 16px 20px;
  align-items: stretch; /* 两卡片等高 */
  justify-content: center;
  background: linear-gradient(135deg, #FAF8F5 0%, #F5F0EA 100%);
  flex: 1;
  min-height: 0;
}

.refine-preview-card {
  flex: 1;
  max-width: 48%;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 16px rgba(45,42,40,0.06), 0 1px 4px rgba(45,42,40,0.04);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  animation: refineCardFadeIn 0.35s ease both;
}
.refine-preview-card.is-result {
  flex: 1.2;
  border: 1px solid rgba(184,148,92,0.35);
  transform: scale(1.02);
  box-shadow: 0 4px 24px rgba(184,148,92,0.10);
}

@keyframes refineCardFadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
.refine-preview-card:nth-child(2) { animation-delay: 0.08s; }

.refine-preview-img-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  min-height: 200px;
  background: #F0EDE8;
  position: relative;
}
.refine-preview-img-wrap img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 1px 6px rgba(0,0,0,0.06);
}
.refine-preview-badge {
  position: absolute;
  top: 10px;
  right: 12px;
  font-size: 9px;
  font-weight: 700;
  color: #9A7B4A;
  background: rgba(255,248,235,0.92);
  border: 1px solid rgba(184,148,92,0.3);
  padding: 2px 10px;
  border-radius: 10px;
  letter-spacing: 0.05em;
  backdrop-filter: blur(4px);
}
.refine-preview-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--mist);
  padding: 8px 12px 6px;
  text-align: center;
  letter-spacing: 0.04em;
  border-top: 1px solid var(--border);
}
.refine-preview-label-result {
  color: #9A7B4A;
  border-top-color: rgba(184,148,92,0.25);
}
.refine-preview-sub {
  font-size: 9px;
  color: var(--mist);
  text-align: center;
  padding: 0 12px 8px;
}

/* Right panel — controls */
.refine-right {
  width: clamp(210px, 210px + (100vw - 1024px) * 0.095, 300px);
  min-width: 210px;
  border-left: 1px solid var(--border);
  display: flex; flex-direction: column; overflow: hidden;
}
.refine-controls {
  flex: 1; display: flex; flex-direction: column; overflow: hidden;
  background: linear-gradient(180deg, #fff 0%, #FAF8F5 100%);
}
.refine-controls-scroll {
  flex: 1; overflow-y: auto; padding: 12px 14px 0;
}
.refine-control-group { margin-bottom: 12px; }
.refine-control-label {
  font-size: 10px; font-weight: 600; color: var(--mist); letter-spacing: 0.06em;
  margin-bottom: 6px; text-transform: uppercase;
  display: flex; align-items: center; gap: 4px;
}

/* Mode info icon + tooltip */
.refine-mode-info-icon {
  display: inline-flex; align-items: center; position: relative;
  color: var(--mist); cursor: help;
  transition: color 0.15s;
}
.refine-mode-info-icon:hover { color: var(--gold); }
.refine-mode-info-tooltip {
  display: none;
  position: absolute; left: 18px; top: -4px;
  width: 200px; padding: 8px 10px;
  background: #333; color: #fff; font-size: 10px; line-height: 1.5;
  border-radius: 6px; z-index: 100;
  font-weight: 400; text-transform: none; letter-spacing: 0;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  pointer-events: none;
}
.refine-mode-info-icon:hover .refine-mode-info-tooltip {
  display: block;
}
.refine-ref-upload {
  border: 2px dashed var(--border); border-radius: var(--radius-sm);
  padding: 12px; text-align: center; cursor: pointer; transition: 0.2s;
  min-height: 60px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
}
.refine-ref-upload:hover { border-color: var(--gold); background: var(--surface-alt); }
.refine-ref-upload.has-file { border-color: var(--gold); background: #FDF9F3; }
.refine-ref-preview { max-width: 100%; max-height: 70px; border-radius: 4px; display: none; }
.refine-ref-preview.show { display: block; }
.refine-ref-name { display: none; }

/* Brush controls — 优雅紧凑的画笔工具面板 */
.refine-brush-controls { display: none; }
.refine-brush-controls.show { display: block; }
.refine-brush-row {
  display: flex; align-items: center; gap: 10px; margin-bottom: 8px;
  background: #F8F6F3; border-radius: 8px; padding: 6px 10px;
}
.refine-brush-row label {
  font-size: 11px; color: var(--ink); font-weight: 500; min-width: 36px;
  letter-spacing: 0.02em;
}
.refine-brush-row input[type=range] {
  flex: 1; -webkit-appearance: none; appearance: none;
  height: 4px; border-radius: 2px;
  background: linear-gradient(90deg, #D4C5A9 0%, #C9B896 100%);
  outline: none;
}
.refine-brush-row input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 14px; height: 14px;
  border-radius: 50%; background: white;
  border: 2px solid #B8945C; cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.12);
  transition: transform 0.12s;
}
.refine-brush-row input[type=range]::-webkit-slider-thumb:hover { transform: scale(1.15); }
.refine-brush-row input[type=range]::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%;
  background: white; border: 2px solid #B8945C; cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.12);
}
.refine-brush-row .brush-val {
  font-size: 12px; font-weight: 600; color: #9A7B4A;
  min-width: 26px; text-align: right;
}
.refine-brush-actions {
  display: flex; gap: 6px; flex-wrap: wrap;
}
.refine-brush-actions .btn {
  flex: 1; min-width: 0;
  font-size: 10px; padding: 5px 8px; border-radius: 6px;
  background: #F8F6F3; border: 1px solid var(--border);
  color: var(--ink); cursor: pointer; transition: all 0.15s;
  text-align: center; line-height: 1.3;
}
.refine-brush-actions .btn:hover {
  background: #FDF9F3; border-color: #D4C5A9; color: #9A7B4A;
}
.refine-brush-actions .btn:active { background: #F5F0EA; }

/* Material grid (inline in workspace) */
.refine-mat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; max-height: 160px; overflow-y: auto; }
.refine-mat-item {
  border: 1px solid var(--border); border-radius: 4px; overflow: hidden;
  cursor: pointer; padding: 3px; transition: 0.15s;
  position: relative;
}
.refine-mat-item:hover { border-color: var(--gold); }
.refine-mat-item.selected { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(184,148,92,0.2); }
.refine-mat-item img { width: 100%; height: 40px; object-fit: cover; border-radius: 2px; }
.refine-mat-item span { font-size: 9px; color: var(--mist); display: block; text-align: center; padding: 2px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.refine-mat-remove {
  position: absolute; top: -4px; right: -4px; z-index: 2;
  width: 20px; height: 20px;
  background: rgba(120,110,100,0.7); color: #fff;
  border: none; border-radius: 50%;
  font-size: 0; line-height: 1; cursor: pointer;
  padding: 0; display: none;
  align-items: center; justify-content: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.12);
  transition: background 0.15s, transform 0.2s;
}
.refine-mat-remove svg { display: block; width: 12px; height: 12px; }
.refine-mat-item:hover .refine-mat-remove { display: flex; }
.refine-mat-item.selected .refine-mat-remove { display: flex; }
.refine-mat-remove:hover { background: var(--gold); transform: scale(1.15); box-shadow: 0 2px 6px rgba(184,148,92,0.3); }

/* Textarea wrap — inside .refine-controls, below scroll area */
.refine-textarea-wrap {
  flex-shrink: 0;
  padding: 0 14px;
}

.refine-textarea-input {
  width: 100%;
  height: auto;
  min-height: 180px; /* 10行文字高度（12px字体 × 1.5行高 × 10行） */
  max-height: 250px; /* 上限，防止覆盖执行按钮 */
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12px;
  font-family: var(--font-body);
  resize: none;
  overflow-y: auto;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-sizing: border-box;
  line-height: 1.5;
}
.refine-textarea-input:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(184,148,92,0.1);
}

/* History */
.refine-history-label { font-size: 9px; color: var(--mist); margin-bottom: 2px; }
.refine-history-items { display: flex; gap: 4px; flex-wrap: wrap; }
.refine-shortcut-hint { margin-top: 4px; font-size: 9px; color: var(--mist); text-align: right; }

/* Execute button — inside .refine-controls, below textarea */
.refine-exec-btn {
  flex-shrink: 0;
  width: calc(100% - 28px);
  margin: 0 14px 14px;
  height: 44px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: #fff;
  background: linear-gradient(135deg, #B8945C 0%, #9A7B4A 100%);
  box-shadow: 0 2px 8px rgba(184,148,92,0.25);
  transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  position: relative;
  overflow: hidden;
}
.refine-exec-btn::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.12) 0%, transparent 50%);
  pointer-events: none;
}
.refine-exec-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(184,148,92,0.35);
}
.refine-exec-btn:active {
  transform: translateY(0);
  box-shadow: 0 1px 4px rgba(184,148,92,0.2);
}
.refine-exec-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}
.refine-exec-btn .exec-icon { font-size: 15px; display: flex; align-items: center; }
.refine-exec-btn .exec-icon svg { display: block; }
.refine-exec-btn .exec-text { }

.refine-exec-btn.loading {
  pointer-events: none;
  animation: refineBtnPulse 1.2s ease-in-out infinite;
}
@keyframes refineBtnPulse {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}

/* Preview footer — shown during preview mode */
.refine-preview-footer {
  display: none;
  flex-shrink: 0;
  padding: 16px 14px 18px;
  border-top: 1px solid var(--border);
  background: linear-gradient(180deg, var(--surface) 0%, #FAF8F5 100%);
  flex-direction: column;
  gap: 10px;
  align-items: center;
}
.refine-preview-footer.show { display: flex; }
/* Support old ID selector */
#refineActionsBottom { display: none; }
#refineActionsBottom.show { display: flex; }

/* Preview actions */
.refine-preview-actions { display: none; gap: 8px; align-items: center; justify-content: center; flex-wrap: wrap; width: 100%; }
.refine-preview-actions.show { display: flex; }




.refine-primary-btn {
  height: 40px; flex: 1; min-width: 100px;
  border: none; border-radius: 8px; cursor: pointer;
  font-size: 12px; font-weight: 600; color: #fff;
  background: linear-gradient(135deg, #B8945C 0%, #9A7B4A 100%);
  box-shadow: 0 2px 6px rgba(184,148,92,0.2);
  transition: transform 0.12s, box-shadow 0.12s;
  padding: 0 16px;
}
.refine-primary-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(184,148,92,0.3); }
.refine-primary-btn:active { transform: translateY(0); }

.refine-secondary-btn {
  height: 40px; flex: 1; min-width: 90px;
  border: 1px solid var(--border); border-radius: 8px; cursor: pointer;
  font-size: 12px; font-weight: 500; color: var(--ink);
  background: #fff;
  transition: background 0.12s, border-color 0.12s;
  padding: 0 16px;
}
.refine-secondary-btn:hover { background: #FDF9F3; border-color: var(--gold); }
.refine-secondary-btn:active { background: #F8F3ED; }

/* ===== BRUSH CURSOR PREVIEW ===== */
.refine-brush-cursor {
  position: absolute; top: 0; left: 0;
  pointer-events: none;
  display: none;
  z-index: 10;
  /* Default: circular cursor */
  border-radius: 50%;
  border: 2px solid rgba(60, 120, 255, 0.5);
  background: rgba(60, 120, 255, 0.08);
  box-shadow: 0 0 4px rgba(60, 120, 255, 0.15);
}
/* Crosshair mode (non-color modes) */
.refine-brush-cursor.crosshair-mode {
  border: none;
  background: none;
  box-shadow: none;
}
.refine-brush-cursor.crosshair-mode::before,
.refine-brush-cursor.crosshair-mode::after {
  content: '';
  position: absolute;
  background: rgba(60, 120, 255, 0.7);
}
.refine-brush-cursor.crosshair-mode::before {
  /* Vertical line */
  width: 1.5px;
  height: 100%;
  left: 50%;
  top: 0;
  transform: translateX(-50%);
}
.refine-brush-cursor.crosshair-mode::after {
  /* Horizontal line */
  width: 100%;
  height: 1.5px;
  top: 50%;
  left: 0;
  transform: translateY(-50%);
}
/* Center dot for crosshair mode */
.refine-brush-cursor.crosshair-mode .cursor-center-dot {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 4px;
  height: 4px;
  background: rgba(60, 120, 255, 0.85);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  z-index: 2;
}

/* Right panel hidden state */
.refine-right.hide { display: none; }

/* [修复] 面料质感模式：CSS防御层强制隐藏"上传参考图"区域 */
.refine-editor.texture-mode #refineRefUploadGroup { display: none !important; }

/* Background preset selected state */
.refine-bg-selected { border-color: var(--gold) !important; background: #FDF9F3; }

/* ===== SHORTCUT HINT ===== */
#refineShortcutHint kbd {
  display: inline-block;
  padding: 1px 5px;
  font-size: 9px;
  font-family: var(--font-body);
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--mist);
  line-height: 1.4;
}

/* ===== PROMPT HISTORY IMPROVED ===== */
.refine-prompt-history-item {
  font-size: 10px; padding: 3px 10px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--mist); cursor: pointer; transition: all 0.15s;
  max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.refine-prompt-history-item:hover {
  border-color: var(--gold); color: var(--ink); background: #FDF9F3;
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(184,148,92,0.1);
}

/* ===== COLOR PALETTE (E类: 色彩调整) ===== */
#refineColorGroup { display: none; }
#refineColorGroup.show { display: block; }

/* 选色盘 — 色系分组布局 */
.refine-palette-container { margin-bottom: 6px; }
.refine-palette-family { margin-bottom: 4px; }
.refine-palette-family-label {
  font-size: 9px; font-weight: 600; color: var(--mist);
  text-transform: uppercase; letter-spacing: 0.06em;
  margin-bottom: 2px; padding-left: 2px;
}
.refine-palette-swatches {
  display: flex; flex-wrap: wrap; gap: 4px;
}

.refine-swatch {
  width: 22px; height: 22px; border-radius: 3px;
  cursor: pointer; border: 1px solid rgba(0,0,0,0.08);
  transition: all 0.15s; flex-shrink: 0;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}
.refine-swatch:hover { transform: scale(1.2); box-shadow: 0 2px 6px rgba(0,0,0,0.12); z-index: 1; position: relative; }
.refine-swatch.active {
  border-color: var(--gold-dark);
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--gold);
  transform: scale(1.15);
  z-index: 1; position: relative;
}
.refine-color-divider {
  height: 1px; background: var(--border); margin: 6px 0 4px;
}
.refine-color-row {
  display: flex; align-items: center; gap: 6px;
  margin-top: 2px;
}
.refine-color-preview {
  width: 20px; height: 20px; border-radius: 3px;
  border: 1px solid var(--border);
}

/* ===== 保存到图库（右侧面板内，预览模式） ===== */
.refine-save-gallery-panel {
  padding: 8px 14px 0;
  border-top: 1px solid var(--border);
  margin: 0 -14px;
  margin-top: 12px;
}
.refine-save-btn-full {
  width: 100%; height: 44px; font-size: 13px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  border: none; border-radius: 8px; cursor: pointer;
  font-weight: 600; color: #fff;
  background: linear-gradient(135deg, #B8945C 0%, #9A7B4A 100%);
  box-shadow: 0 2px 8px rgba(184,148,92,0.25);
  transition: transform 0.15s, box-shadow 0.15s;
  letter-spacing: 0.04em;
}
.refine-save-btn-full:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(184,148,92,0.35);
}
.refine-save-btn-full:active {
  transform: translateY(0);
}

/* ===== REFINE EDITOR RESPONSIVE ===== */
/* 宽屏 1920+ */
@media (min-width: 1920px) {
  .refine-editor { top: 4vh; left: 2vw; right: 2vw; bottom: 4vh; }
  .refine-sidebar .refine-mode-btn { font-size: 12px; padding: 8px 16px; }
  .refine-sidebar .refine-mode-group-title { font-size: 10px; padding: 10px 16px 4px; }
  .refine-controls-scroll { padding: 14px 18px 0; }
  .refine-control-label { font-size: 11px; }
  .refine-textarea-input { min-height: 200px; max-height: 280px; font-size: 13px; padding: 12px 14px; }
  .refine-exec-btn { height: 48px; font-size: 14px; }
  .refine-mat-grid { grid-template-columns: 1fr 1fr; max-height: 200px; gap: 6px; }
  .refine-mat-item img { height: 50px; }
  .refine-preview-wrap { gap: 32px; padding: 20px 28px; }
  .refine-preview-card { max-width: 46%; }
  .refine-preview-img-wrap { min-height: 280px; }
  .refine-brush-row { padding: 8px 12px; gap: 12px; }
  .refine-brush-row label { font-size: 12px; min-width: 40px; }
  .refine-editor-header { padding: 14px 24px; }
  .refine-editor-header h2 { font-size: 17px; }
  .refine-editor-header h2 span { font-size: 12px; }
}

@media (max-width: 1440px) and (min-width: 1367px) {
  .refine-editor { top: 4vh; left: 2vw; right: 2vw; bottom: 4vh; }
}

@media (max-width: 1366px) and (min-width: 1025px) {
  .refine-editor { top: 3vh; left: 2vw; right: 2vw; bottom: 3vh; }
  .refine-sidebar .refine-mode-btn { font-size: 10px; padding: 5px 10px; gap: 5px; }
  .refine-sidebar .refine-mode-group-title { font-size: 8px; padding: 6px 10px 2px; }
  .refine-controls-scroll { padding: 8px 10px 0; }
  .refine-textarea-input { min-height: 120px; max-height: 180px; font-size: 11px; }
  .refine-exec-btn { height: 38px; font-size: 12px; }
  .refine-mat-grid { grid-template-columns: 1fr 1fr; max-height: 120px; }
}

@media (max-width: 1024px) {
  .refine-editor { top: 2vh; left: 1vw; right: 1vw; bottom: 2vh; border-radius: 12px; }
  .refine-editor-header { padding: 8px 14px; }
  .refine-editor-header h2 { font-size: 13px; }
  .refine-body { flex-direction: column; }
  .refine-sidebar {
    width: 100%; min-width: auto;
    border-right: none; border-bottom: 1px solid var(--border);
    padding: 2px 0; overflow-x: auto;
    display: flex; flex-direction: row;
    flex-shrink: 0;
    max-height: 54px;
  }
  .refine-sidebar .refine-mode-group {
    display: inline-flex; margin-bottom: 0;
    flex-shrink: 0;
  }
  .refine-sidebar .refine-mode-group-title { display: none; }
  .refine-sidebar .refine-mode-group-inner { display: flex; flex-direction: row; }
  .refine-sidebar .refine-mode-btn {
    width: auto; margin: 2px 4px; padding: 5px 10px;
    font-size: 10px; white-space: nowrap;
  }
  .refine-sidebar .refine-mode-btn .mode-icon { width: 14px; height: 14px; }
  .refine-center { flex: 1; min-height: 200px; }
  .refine-right {
    width: 100%; min-width: auto;
    border-left: none; border-top: 1px solid var(--border);
    max-height: 35vh;
  }
  .refine-controls-scroll { padding: 8px 10px 0; }
  .refine-textarea-input { min-height: 80px; max-height: 120px; font-size: 11px; }
  .refine-exec-btn { height: 36px; font-size: 12px; width: calc(100% - 20px); margin: 0 10px 10px; }
  .refine-preview-wrap { flex-direction: column; gap: 12px; padding: 12px; }
  .refine-preview-card { max-width: 100%; }
  .refine-preview-card.is-result { flex: 1; transform: none; }
  .refine-mat-grid { grid-template-columns: 1fr 1fr; max-height: 100px; }
  .refine-brush-row { padding: 4px 8px; gap: 6px; }
}

@media (max-width: 768px) {
  .refine-editor { top: 0; left: 0; right: 0; bottom: 0; border-radius: 0; }
  .refine-editor-header { padding: 6px 10px; }
  .refine-editor-header h2 { font-size: 12px; }
  .refine-editor-header h2 span { font-size: 10px; }
  .refine-close { font-size: 18px; }
  .refine-sidebar { max-height: 46px; }
  .refine-sidebar .refine-mode-btn { font-size: 9px; padding: 4px 8px; }
  .refine-sidebar .refine-mode-btn .mode-icon { width: 12px; height: 12px; }
  .refine-right { max-height: 30vh; }
  .refine-controls-scroll { padding: 6px 8px 0; }
  .refine-control-label { font-size: 9px; }
  .refine-textarea-input { min-height: 60px; max-height: 100px; font-size: 10px; padding: 6px 8px; }
  .refine-exec-btn { height: 34px; font-size: 11px; }
  .refine-ref-upload { padding: 8px; min-height: 40px; }
  .refine-brush-row { padding: 4px 6px; gap: 4px; }
  .refine-brush-row label { font-size: 10px; min-width: 28px; }
  .refine-preview-wrap { gap: 8px; padding: 8px; }
  .refine-preview-card { border-radius: 8px; }
  .refine-preview-img-wrap { min-height: 120px; padding: 8px; }
  .refine-preview-footer { padding: 10px 10px 12px; }
  .refine-primary-btn { height: 34px; font-size: 11px; min-width: 80px; }
  .refine-secondary-btn { height: 34px; font-size: 11px; min-width: 70px; }
  .refine-mat-grid { max-height: 80px; gap: 3px; }
  .refine-mat-item img { height: 32px; }
  .refine-save-btn-full { height: 38px; font-size: 12px; }
}
