/* 文件描述: AI Image 本地前台样式 */
/* 版本号: V.0031 */

:root {
  --bg: #f7f8fb;
  --panel: #ffffff;
  --panel-soft: #fbfcfe;
  --line: #dfe5ee;
  --line-strong: #c8d1df;
  --text: #233044;
  --muted: #7a8799;
  --accent: #ff8a2a;
  --accent-soft: #ffd9b4;
  --blue: #1f7ae0;
  --green: #23865f;
  --danger: #be3b35;
  --button-bg: #ffffff;
  --button-hover: #f8fbff;
  --shadow: 0 10px 26px rgba(35, 48, 68, 0.08);
  --radius: 8px;
}

@keyframes slow-breath {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(35, 134, 95, 0.14);
    filter: saturate(1) brightness(1);
  }

  50% {
    box-shadow: 0 0 0 5px rgba(35, 134, 95, 0.13);
    filter: saturate(1.16) brightness(1.04);
  }
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "IBM Plex Sans", "Noto Sans SC", "PingFang SC", Helvetica, sans-serif;
  letter-spacing: 0;
}

body.is-theater-open {
  overflow: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

button:disabled {
  cursor: not-allowed;
}

.app-shell {
  width: min(1780px, calc(100vw - 20px));
  min-height: calc(100vh - 20px);
  margin: 10px auto;
  border: 1px solid var(--line);
  background: var(--panel-soft);
  box-shadow: var(--shadow);
}

.top-tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 46px;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
}

.studio-layout {
  display: grid;
  grid-template-columns: minmax(360px, 40%) minmax(560px, 1fr);
  gap: 12px;
  padding: 12px;
}

.left-workbench,
.right-stage {
  min-width: 0;
}

.left-workbench {
  display: grid;
  gap: 10px;
  align-content: start;
}

.right-stage {
  display: grid;
  gap: 10px;
  align-content: start;
}

.prompt-panel,
.option-panel,
.progress-panel,
.preview-panel,
.reference-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.prompt-panel,
.option-panel,
.preview-panel,
.reference-panel {
  padding: 10px;
}

.panel-title {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.panel-title h1,
.section-heading h2 {
  margin: 0;
  color: var(--text);
}

.panel-title h1 {
  font-size: 14px;
  font-weight: 700;
}

.panel-title span {
  color: var(--muted);
  font-size: 12px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.section-heading h2 {
  font-size: 15px;
}

.prompt-stack {
  display: grid;
  gap: 8px;
}

.field-block,
.control-grid label,
.template-inline {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

textarea,
input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--text);
  outline: none;
}

textarea {
  padding: 10px 12px;
  resize: vertical;
  line-height: 1.45;
}

#prompt {
  min-height: 152px;
}

#negative-prompt {
  min-height: 104px;
}

input,
select {
  height: 32px;
  padding: 0 9px;
}

textarea:focus,
input:focus,
select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(31, 122, 224, 0.12);
}

.tab,
.icon-button,
.generate-button,
.action-button,
.download-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--button-bg);
  color: var(--text);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0;
  box-shadow: none;
  transition: border-color 160ms ease, background-color 160ms ease, box-shadow 160ms ease;
}

.tab:hover,
.icon-button:hover,
.generate-button:hover,
.action-button:hover,
.download-button:hover {
  border-color: var(--blue);
  background: var(--button-hover);
}

.tab:disabled,
.icon-button:disabled,
.generate-button:disabled,
.action-button:disabled {
  opacity: 0.6;
}

.tab.is-active {
  color: var(--text);
  border-color: var(--blue);
  background: var(--button-bg);
  box-shadow: 0 0 0 3px rgba(31, 122, 224, 0.1);
}

.tab {
  height: 34px;
  padding: 0 16px;
}

.prompt-tools {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) max-content max-content;
  gap: 8px;
  align-items: end;
  margin-top: 8px;
}

.icon-button {
  min-width: 70px;
  width: auto;
  height: 34px;
  padding: 0 10px;
  white-space: nowrap;
}

.token-count {
  justify-self: end;
  color: var(--muted);
  font-size: 12px;
}

.control-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px 10px;
}

.toggle-row {
  margin-top: 9px;
}

.switch-field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 14px;
}

.switch-field input {
  width: 18px;
  height: 18px;
}

.prompt-generate-row {
  margin-top: 8px;
}

.generate-button {
  width: 100%;
  min-height: 42px;
  border-color: #f1b879;
  background: #fff2e4;
  color: #9b4b00;
}

.generate-button:hover:not(:disabled) {
  border-color: var(--accent);
  background: #ffe3c7;
}

button.generate-button:disabled,
button.generate-button.is-busy {
  opacity: 1;
  border-color: var(--line-strong);
  background: #eef2f6;
  background-color: #eef2f6;
  background-image: none;
  color: var(--muted);
  box-shadow: inset 0 0 0 1px rgba(122, 135, 153, 0.14);
}

.progress-panel {
  overflow: hidden;
}

.progress-header {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  list-style: none;
  cursor: pointer;
}

.progress-header::-webkit-details-marker {
  display: none;
}

.progress-header strong {
  color: var(--text);
}

.progress-summary-right {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 220px;
}

.progress-mini-bar {
  display: block;
  width: 150px;
  height: 6px;
  border-radius: 999px;
  background: #e8f2ed;
  overflow: hidden;
}

.progress-mini-bar span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--green);
  transition: width 180ms ease;
}

.progress-mini-bar span.is-breathing {
  animation: slow-breath 3.1s ease-in-out infinite;
}

.event-list {
  min-height: 62px;
  max-height: 96px;
  margin: 0;
  padding: 8px 12px 8px 30px;
  overflow: auto;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.preview-frame {
  position: relative;
  display: grid;
  place-items: center;
  height: calc(100vh - 162px);
  min-height: 520px;
  max-height: 860px;
  border: 1px solid var(--line);
  background: #fbfcfd;
  overflow: hidden;
}

.preview-frame img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  cursor: zoom-in;
}

.image-meta {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  max-width: calc(100% - 76px);
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.38);
  border-radius: 8px;
  background: rgba(13, 20, 30, 0.72);
  color: #ffffff;
  font-size: 12px;
  line-height: 1.35;
  backdrop-filter: blur(8px);
}

.image-meta span {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.meta-download {
  flex: 0 0 auto;
  min-height: 26px;
  padding: 5px 10px;
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.38);
  background: rgba(255, 255, 255, 0.12);
}

.meta-download:hover {
  background: rgba(255, 255, 255, 0.2);
}

.empty-preview {
  width: 100%;
  height: 100%;
}

.hover-zoom {
  position: absolute;
  top: 18px;
  right: 18px;
  z-index: 3;
  width: min(34%, 340px);
  aspect-ratio: 4 / 3;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 8px;
  background-color: #ffffff;
  background-repeat: no-repeat;
  box-shadow: 0 18px 42px rgba(13, 20, 30, 0.22);
  opacity: 0;
  pointer-events: none;
  transform: translateY(6px);
  transition: opacity 140ms ease, transform 140ms ease;
}

.hover-zoom.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.is-refined-preview .reference-hover-zoom {
  position: fixed;
  z-index: 920;
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 252, 0.88);
  border-radius: 8px;
  background: #fffefa;
  box-shadow: 0 24px 64px rgba(27, 43, 38, 0.22);
  opacity: 0;
  pointer-events: none;
  transform: translateY(6px);
  transition: opacity 140ms ease, transform 140ms ease;
}

.is-refined-preview .asset-picker-modal:not([hidden]) ~ .reference-hover-zoom {
  z-index: 920;
}

.is-refined-preview .reference-hover-zoom.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.is-refined-preview .reference-hover-zoom img {
  width: 100%;
  max-height: 310px;
  border-radius: 6px;
  object-fit: contain;
  background: #f3f6f4;
}

.is-refined-preview .reference-hover-zoom div {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.action-button,
.download-button {
  display: grid;
  place-items: center;
  min-height: 48px;
  text-decoration: none;
}

.reference-drop {
  display: grid;
  place-items: center;
  min-height: 148px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: #fbfcfd;
  color: var(--muted);
  overflow: hidden;
}

.reference-list {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 8px;
  padding: 8px;
}

.reference-item {
  position: relative;
  display: grid;
  gap: 5px;
  min-width: 0;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.reference-thumb {
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  overflow: hidden;
}

.reference-thumb:hover {
  box-shadow: 0 0 0 3px rgba(31, 122, 224, 0.14);
}

.reference-thumb img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 6px;
  background: #eef2f7;
}

.reference-item-meta {
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reference-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 999px;
  background: rgba(13, 20, 30, 0.68);
  color: #ffffff;
  line-height: 1;
}

.reference-drop.is-active,
.reference-drop:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(31, 122, 224, 0.1);
  outline: none;
}

.reference-drop img {
  max-width: 100%;
  max-height: 190px;
  object-fit: contain;
}

.reference-empty {
  font-size: 13px;
  font-weight: 700;
}

.reference-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.theater-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  overflow: hidden;
  background: rgba(8, 12, 18, 0.9);
  overscroll-behavior: contain;
  touch-action: none;
}

.theater-overlay[hidden] {
  display: none;
}

.theater-stage {
  position: absolute;
  inset: 56px 56px 72px;
  z-index: 1;
  display: grid;
  place-items: center;
  overflow: hidden;
  cursor: zoom-in;
  touch-action: none;
}

.theater-stage.is-zoomed {
  cursor: grab;
}

.theater-stage.is-dragging {
  cursor: grabbing;
}

.theater-stage img {
  max-width: none;
  max-height: none;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
  transform: translate(0, 0) scale(1);
  transform-origin: center center;
  user-select: none;
  -webkit-user-drag: none;
  touch-action: none;
  will-change: transform;
}

.theater-stage img.is-fitting {
  visibility: hidden;
}

.theater-close {
  position: fixed;
  top: 22px;
  right: 24px;
  z-index: 3;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  font-size: 22px;
  line-height: 1;
}

.theater-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

.theater-meta {
  position: fixed;
  left: 24px;
  right: 84px;
  bottom: 22px;
  z-index: 2;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.35);
  color: rgba(255, 255, 255, 0.9);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  pointer-events: none;
}

.template-view {
  display: grid;
  grid-template-columns: minmax(340px, 34%) minmax(620px, 1fr);
  gap: 12px;
  padding: 12px;
}

.template-list-panel,
.template-detail {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 12px;
}

.template-list {
  display: grid;
  gap: 9px;
  max-height: calc(100vh - 140px);
  overflow: auto;
}

.template-item {
  display: grid;
  gap: 5px;
  width: 100%;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  text-align: left;
}

.template-item:hover,
.template-item.is-active {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(31, 122, 224, 0.1);
}

.template-item-name {
  font-weight: 700;
  font-size: 14px;
}

.template-item-meta {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.template-editor {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.template-editor label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

.template-editor .wide-field {
  grid-column: 1 / -1;
}

.template-editor textarea {
  min-height: 96px;
}

.template-switch {
  align-self: end;
}

.template-editor .switch-field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 14px;
}

.template-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.danger-action {
  color: var(--danger);
  border-color: #e7bbb7;
  background: #fff7f6;
}

.danger-action:hover {
  color: var(--danger);
  border-color: var(--danger);
  background: #fff0ee;
}

.form-message {
  color: var(--muted);
  font-size: 12px;
}

.history-search-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px 10px;
  align-items: center;
  margin-top: 10px;
}

.history-search-panel label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.history-search-panel input {
  grid-column: 1 / -1;
  min-height: 38px;
}

.history-search-panel span {
  justify-self: end;
  color: var(--muted);
  font-size: 12px;
}

.history-view {
  display: grid;
  grid-template-columns: minmax(360px, 38%) minmax(560px, 1fr);
  gap: 18px;
  padding: 18px;
  height: calc(100vh - 46px);
  overflow: hidden;
}

.history-list-panel,
.history-detail {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 14px;
  overflow-y: auto;
  height: 100%;
}

.compact-action {
  min-height: 34px;
  padding: 0 12px;
  font-size: 13px;
}

.history-list {
  display: grid;
  gap: 10px;
}

.history-item {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  gap: 12px;
  width: 100%;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  text-align: left;
}

.history-item:hover,
.history-item.is-active {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(31, 122, 224, 0.1);
}

.history-item.is-running {
  border-color: rgba(35, 134, 95, 0.38);
  background: #f8fcfa;
  animation: slow-breath 3.1s ease-in-out infinite;
}

.history-item img {
  width: 86px;
  height: 64px;
  border-radius: 6px;
  object-fit: cover;
  background: #eef2f7;
}

.history-thumb-placeholder {
  width: 86px;
  height: 64px;
  border: 1px dashed rgba(35, 134, 95, 0.24);
  border-radius: 6px;
  background: rgba(35, 134, 95, 0.055);
}

.history-item-body {
  min-width: 0;
  display: grid;
  gap: 5px;
}

.history-item-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.history-item-date,
.history-item-options {
  color: var(--muted);
  font-size: 12px;
}

.history-item-options {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 8px;
  align-items: center;
}

.history-item-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.history-chip {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfd;
  color: var(--text);
  font-size: 12px;
  line-height: 1;
}

.history-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  width: fit-content;
  padding: 2px 7px;
  border: 1px solid rgba(35, 134, 95, 0.28);
  border-radius: 999px;
  background: rgba(35, 134, 95, 0.08);
  color: #1f7554;
  font-weight: 700;
  line-height: 1.25;
}

.history-status-badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--green);
}

.history-status-badge.is-running {
  background: rgba(35, 134, 95, 0.11);
}

.history-status-badge.is-failed {
  background: rgba(225, 50, 50, 0.08);
  color: #c53030;
  border-color: rgba(225, 50, 50, 0.28);
}

.history-status-badge.is-failed::before {
  background: #e53e3e;
}

.history-option-detail {
  min-width: 0;
}

.history-item-prompt {
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.history-detail {
  min-height: 0;
}

.history-detail-empty {
  display: grid;
  place-items: center;
  min-height: 640px;
  color: var(--muted);
  font-size: 18px;
}

.history-detail-content {
  display: grid;
  gap: 14px;
}

.history-detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.history-detail-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.history-detail-state {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.history-detail-icon {
  position: relative;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: var(--green);
}

.history-detail-icon::before {
  width: 13px;
  height: 7px;
  border-left: 3px solid #ffffff;
  border-bottom: 3px solid #ffffff;
  content: "";
  transform: rotate(-45deg) translate(1px, -1px);
}

.history-detail-state strong {
  color: var(--green);
  font-size: 18px;
}

.history-detail-state.is-failed .history-detail-icon {
  background: #e53e3e;
}

.history-detail-state.is-failed .history-detail-icon::before {
  width: 14px;
  height: 14px;
  border: none;
  background: none;
  content: "\2715 ";
  color: #ffffff;
  font-size: 16px;
  font-weight: 800;
  transform: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.history-detail-state.is-failed strong {
  color: #c53030;
}

.history-detail-state.is-running .history-detail-icon {
  background: var(--blue);
}

.history-detail-state.is-running strong {
  color: var(--blue);
}

.history-detail-state span:last-child {
  color: var(--muted);
  font-size: 13px;
}

.history-error-field span {
  color: #c53030;
  font-weight: 700;
}

.history-error-field textarea {
  color: #c53030;
  background: rgba(225, 50, 50, 0.04);
  border-color: rgba(225, 50, 50, 0.28);
}

.history-image-frame {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 360px;
  border: 1px solid var(--line);
  background: #fbfcfd;
}

.history-download,
.history-regenerate {
  min-height: 32px;
  padding: 0 14px;
}

.history-image-frame img {
  max-width: 100%;
  max-height: 620px;
  object-fit: contain;
  cursor: zoom-in;
}

.history-reference-section {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  padding: 10px;
}

.history-reference-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 8px;
}

.history-reference-item {
  padding: 6px;
}

.history-detail-grid {
  display: grid;
  grid-template-columns: minmax(170px, 0.8fr) minmax(120px, 0.55fr) minmax(120px, 0.55fr) minmax(120px, 0.55fr);
  gap: 12px;
}

.history-detail-grid label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

.history-detail-grid .history-text-field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

.history-detail-grid .wide-field {
  grid-column: 1 / -1;
}

.history-detail-grid textarea {
  min-height: 0;
  overflow: hidden;
  resize: none;
}

@media (max-width: 1080px) {
  .studio-layout {
    grid-template-columns: 1fr;
  }

  .template-view,
  .history-view,
  .system-config-workspace {
    grid-template-columns: 1fr;
  }

}

@media (max-width: 620px) {
  .app-shell {
    width: min(100vw - 16px, 1780px);
    margin: 8px auto;
  }

  .studio-layout {
    padding: 10px;
  }

  .control-grid {
    grid-template-columns: 1fr;
  }

  .prompt-tools {
    grid-template-columns: 1fr;
  }

  .token-count {
    justify-self: start;
  }

  .preview-frame {
    min-height: 360px;
  }

  .theater-overlay {
    padding: 0;
  }

  .theater-stage {
    inset: 44px 12px 72px;
  }

  .history-detail-grid {
    grid-template-columns: 1fr;
  }

  .template-editor,
  .template-actions {
    grid-template-columns: 1fr;
  }

  .theater-meta {
    left: 12px;
    right: 12px;
    bottom: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .history-item.is-running,
  .progress-mini-bar span.is-breathing {
    animation: none;
  }
}

/* Refined Preview: scoped visual system for the separate web_refined frontend. */
body.is-refined-preview {
  --bg: #f4f6f3;
  --panel: #fffefa;
  --panel-soft: #f9faf6;
  --line: #d9e1dc;
  --line-strong: #becbc4;
  --text: #1f2d2b;
  --muted: #718079;
  --accent: #e87422;
  --accent-soft: #fff0df;
  --blue: #16766d;
  --green: #237c5d;
  --danger: #b63832;
  --button-bg: #fffefa;
  --button-hover: #f3faf7;
  --shadow: 0 18px 48px rgba(28, 43, 38, 0.09);
  --panel-shadow: 0 10px 28px rgba(28, 43, 38, 0.055);
  --focus-ring: 0 0 0 3px rgba(22, 118, 109, 0.14);
  background: var(--bg);
  font-family: Inter, "Noto Sans SC", "PingFang SC", Helvetica, sans-serif;
}

.is-refined-preview .app-shell {
  width: min(1760px, calc(100vw - 24px));
  min-height: calc(100vh - 24px);
  margin: 12px auto;
  border-color: #cfd9d3;
  border-radius: 8px;
  background: var(--panel-soft);
  overflow: hidden;
}

.is-refined-preview .top-tabs {
  height: 56px;
  gap: 10px;
  padding: 0 14px;
  border-bottom-color: #d6dfd9;
  background: rgba(255, 254, 250, 0.94);
}

.is-refined-preview .tab {
  height: 38px;
  min-width: 116px;
  border-color: #d7e0dc;
  background: #ffffff;
  color: #263633;
  font-size: 14px;
  font-weight: 700;
  transition: transform 120ms ease, border-color 160ms ease, background-color 160ms ease, box-shadow 160ms ease;
}

.is-refined-preview .tab:hover {
  transform: translateY(-1px);
  border-color: rgba(22, 118, 109, 0.42);
  background: #f7fcfa;
}

.is-refined-preview .tab.is-active {
  border-color: var(--blue);
  background: #eff8f5;
  color: #123f3b;
  box-shadow: inset 0 0 0 1px rgba(22, 118, 109, 0.2), var(--focus-ring);
}

.is-refined-preview .studio-layout,
.is-refined-preview .template-view,
.is-refined-preview .history-view {
  gap: 14px;
  padding: 14px;
}

.is-refined-preview .studio-layout {
  grid-template-columns: minmax(390px, 39%) minmax(600px, 1fr);
}

.is-refined-preview .prompt-panel,
.is-refined-preview .option-panel,
.is-refined-preview .progress-panel,
.is-refined-preview .preview-panel,
.is-refined-preview .reference-panel,
.is-refined-preview .template-list-panel,
.is-refined-preview .template-detail,
.is-refined-preview .history-list-panel,
.is-refined-preview .history-detail {
  border-color: #d7e0dc;
  background: rgba(255, 254, 250, 0.96);
  box-shadow: var(--panel-shadow);
}

.is-refined-preview .prompt-panel,
.is-refined-preview .option-panel,
.is-refined-preview .preview-panel,
.is-refined-preview .reference-panel {
  padding: 12px;
}

.is-refined-preview .panel-title {
  padding-bottom: 6px;
  border-bottom: 1px solid #edf1ee;
}

.is-refined-preview .panel-title h1,
.is-refined-preview .section-heading h2 {
  color: #172724;
  letter-spacing: 0;
}

.is-refined-preview .panel-title h1 {
  font-size: 15px;
}

.is-refined-preview .section-heading h2 {
  font-size: 14px;
}

.is-refined-preview .field-block,
.is-refined-preview .control-grid label,
.is-refined-preview .template-inline,
.is-refined-preview .template-editor label,
.is-refined-preview .history-detail-grid label,
.is-refined-preview .history-text-field {
  color: #718079;
  font-size: 12px;
  font-weight: 650;
}

.is-refined-preview textarea,
.is-refined-preview input,
.is-refined-preview select {
  border-color: #d6dfd9;
  background: #fffefa;
  color: #1f2d2b;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.is-refined-preview textarea:focus,
.is-refined-preview input:focus,
.is-refined-preview select:focus,
.is-refined-preview .reference-drop:focus,
.is-refined-preview .reference-drop.is-active {
  border-color: var(--blue);
  box-shadow: var(--focus-ring);
}

.is-refined-preview textarea {
  line-height: 1.5;
}

.is-refined-preview .prompt-composer textarea,
.is-refined-preview #template-name,
.is-refined-preview .template-editor-card textarea,
.is-refined-preview .history-detail-grid textarea {
  color: #2d3f3b;
  font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.62;
}

.is-refined-preview .prompt-composer textarea::placeholder,
.is-refined-preview .template-editor-card textarea::placeholder,
.is-refined-preview #template-name::placeholder {
  color: #889891;
  font-weight: 400;
}

.is-refined-preview #prompt {
  min-height: 164px;
}

.is-refined-preview #negative-prompt {
  min-height: 112px;
}

.is-refined-preview .control-grid {
  gap: 10px;
}

.is-refined-preview .switch-field {
  font-weight: 650;
}

/* 自绘复选框：原生未选态顶部有渐变/内阴影，会让上边框看起来比其它三边浅；
   改为 appearance:none 后四边边框一致，勾选态统一为全站绿色主题 */
.is-refined-preview .switch-field input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  margin: 0;
  display: inline-grid;
  place-content: center;
  border: 1px solid #c4d0cb;
  border-radius: 5px;
  background: #fffefa;
  box-shadow: none;
  cursor: pointer;
  transition: border-color 140ms ease, background-color 140ms ease;
}

.is-refined-preview .switch-field input[type="checkbox"]::after {
  content: "";
  width: 10px;
  height: 10px;
  transform: scale(0);
  transition: transform 120ms ease;
  background: #ffffff;
  clip-path: polygon(14% 44%, 0 65%, 40% 100%, 100% 16%, 82% 0, 37% 70%);
}

.is-refined-preview .switch-field input[type="checkbox"]:checked {
  border-color: #16766d;
  background: #16766d;
}

.is-refined-preview .switch-field input[type="checkbox"]:checked::after {
  transform: scale(1);
}

.is-refined-preview .switch-field input[type="checkbox"]:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(22, 118, 109, 0.18);
}

.is-refined-preview .tab,
.is-refined-preview .icon-button,
.is-refined-preview .generate-button,
.is-refined-preview .action-button,
.is-refined-preview .download-button {
  border-color: #d6dfd9;
  background: #fffefa;
  color: #1f2d2b;
  font-weight: 750;
  transition: transform 120ms ease, border-color 160ms ease, background-color 160ms ease, box-shadow 160ms ease;
}

.is-refined-preview .icon-button:hover,
.is-refined-preview .action-button:hover,
.is-refined-preview .download-button:hover {
  transform: translateY(-1px);
  border-color: rgba(22, 118, 109, 0.42);
  background: #f5fbf8;
}

.is-refined-preview .generate-button {
  min-height: 44px;
  border-color: #e9a76d;
  background: var(--accent-soft);
  color: #8a3c08;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72), 0 10px 22px rgba(232, 116, 34, 0.13);
}

.is-refined-preview .generate-button:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: var(--accent);
  background: #ffe6cb;
}

.is-refined-preview button.generate-button:disabled,
.is-refined-preview button.generate-button.is-busy {
  border-color: #d0d9d4;
  background: #edf2ef;
  color: #7f8d86;
  box-shadow: inset 0 0 0 1px rgba(113, 128, 121, 0.12);
}

.is-refined-preview .danger-action {
  border-color: #e6c0bd;
  background: #fff8f7;
  color: var(--danger);
}

.is-refined-preview .danger-action:hover {
  border-color: var(--danger);
  background: #fff1ef;
}

.is-refined-preview .progress-header {
  min-height: 44px;
  padding: 10px 14px;
  border-bottom-color: #dce5df;
  color: #718079;
}

.is-refined-preview .progress-mini-bar {
  background: #dfeee8;
}

.is-refined-preview .event-list {
  color: #6e7d77;
  font-family: "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.65;
}

.is-refined-preview .preview-frame,
.is-refined-preview .history-image-frame {
  border-color: #d4ddd8;
  background: #fbfcf8;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.62);
}

.is-refined-preview .preview-frame {
  height: calc(100vh - 176px);
  min-height: 520px;
}

.is-refined-preview .image-meta {
  border-color: rgba(255, 255, 255, 0.32);
  background: rgba(22, 31, 29, 0.76);
  box-shadow: 0 14px 34px rgba(10, 16, 15, 0.18);
}

.is-refined-preview .reference-drop {
  border-color: #c9d7d1;
  background: #fbfcf8;
}

.is-refined-preview .reference-item,
.is-refined-preview .template-item,
.is-refined-preview .history-item {
  border-color: #d7e0dc;
  background: #fffefa;
  box-shadow: 0 6px 16px rgba(28, 43, 38, 0.045);
}

.is-refined-preview .reference-thumb:hover,
.is-refined-preview .template-item:hover,
.is-refined-preview .template-item.is-active,
.is-refined-preview .history-item:hover,
.is-refined-preview .history-item.is-active {
  border-color: rgba(22, 118, 109, 0.46);
  box-shadow: var(--focus-ring), 0 10px 24px rgba(28, 43, 38, 0.07);
}

.is-refined-preview .history-item.is-running {
  border-color: rgba(35, 124, 93, 0.42);
  background: #f7fcf9;
}

.is-refined-preview .history-status-badge {
  border-color: rgba(35, 124, 93, 0.3);
  background: rgba(35, 124, 93, 0.09);
  color: #1e684f;
}

.is-refined-preview .history-detail-grid input,
.is-refined-preview .history-detail-grid textarea {
  background: #fcfdf9;
}

.is-refined-preview .theater-overlay {
  background: rgba(8, 13, 12, 0.92);
}

.is-refined-preview .theater-close {
  border-color: rgba(255, 255, 255, 0.26);
  background: rgba(255, 255, 255, 0.1);
}

.is-refined-preview .theater-meta {
  background: rgba(8, 13, 12, 0.42);
}

@media (max-width: 1080px) {
  .is-refined-preview .studio-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .is-refined-preview .app-shell {
    width: min(100vw - 16px, 1760px);
    margin: 8px auto;
  }

  .is-refined-preview .top-tabs {
    height: auto;
    min-height: 56px;
    flex-wrap: wrap;
    padding: 10px;
  }

  .is-refined-preview .tab {
    flex: 1 1 44%;
    min-width: 0;
  }

  .is-refined-preview .preview-frame {
    min-height: 360px;
  }
}

.is-refined-preview .product-mark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 210px;
  padding-right: 8px;
}

.is-refined-preview .brand-glyph {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: #143f3a;
  color: #fffefa;
  box-shadow: 0 10px 22px rgba(20, 63, 58, 0.18);
}

.is-refined-preview .brand-copy {
  display: grid;
  gap: 1px;
  line-height: 1.1;
}

.is-refined-preview .brand-copy strong {
  color: #182b28;
  font-size: 14px;
  font-weight: 800;
}

.is-refined-preview .brand-copy small {
  color: #73827c;
  font-size: 11px;
}

.is-refined-preview .nav-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.is-refined-preview .top-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-width: 52px;
}

.is-refined-preview .top-action-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border: 1px solid #d7e0dc;
  border-radius: 999px;
  background: #fffefa;
  color: #233633;
  text-decoration: none;
  box-shadow: 0 6px 18px rgba(28, 43, 38, 0.045);
  transition: border-color 160ms ease, background-color 160ms ease, box-shadow 160ms ease;
}

.is-refined-preview .top-action-button:hover,
.is-refined-preview .top-action-button:focus-visible {
  border-color: rgba(15, 143, 133, 0.46);
  background: #f6fffb;
  box-shadow: 0 0 0 3px rgba(15, 143, 133, 0.1);
}

.is-refined-preview .button-icon {
  position: relative;
  display: inline-block;
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  color: currentColor;
}

.is-refined-preview .button-icon::before,
.is-refined-preview .button-icon::after {
  position: absolute;
  content: "";
  box-sizing: border-box;
}

.is-refined-preview .icon-text::before {
  inset: 3px 2px;
  border-top: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
}

.is-refined-preview .icon-text::after {
  left: 2px;
  right: 6px;
  top: 7px;
  border-top: 2px solid currentColor;
}

.is-refined-preview .icon-image::before {
  inset: 2px;
  border: 1.8px solid currentColor;
  border-radius: 3px;
}

.is-refined-preview .icon-image::after {
  left: 4px;
  right: 4px;
  bottom: 4px;
  height: 5px;
  border-left: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: skewX(-24deg);
}

.is-refined-preview .icon-template::before {
  inset: 2px;
  border: 1.8px solid currentColor;
  border-radius: 3px;
}

.is-refined-preview .icon-template::after {
  left: 5px;
  top: 2px;
  bottom: 2px;
  border-left: 1.8px solid currentColor;
}

.is-refined-preview .icon-history::before {
  inset: 2px;
  border: 1.8px solid currentColor;
  border-radius: 999px;
}

.is-refined-preview .icon-history::after {
  left: 8px;
  top: 4px;
  width: 4px;
  height: 5px;
  border-left: 1.8px solid currentColor;
  border-bottom: 1.8px solid currentColor;
}

.is-refined-preview .icon-settings::before {
  inset: 3px;
  border: 1.8px solid currentColor;
  border-radius: 999px;
}

.is-refined-preview .icon-settings::after {
  left: 50%;
  top: 1px;
  width: 1.8px;
  height: 4px;
  background: currentColor;
  transform: translateX(-50%);
  box-shadow:
    0 10px 0 currentColor,
    -4px 5px 0 currentColor,
    4px 5px 0 currentColor;
}


.is-refined-preview .icon-help::before {
  inset: 2px;
  border: 1.8px solid currentColor;
  border-radius: 999px;
}

.is-refined-preview .icon-help::after {
  content: "?";
  inset: 0;
  display: grid;
  place-items: center;
  border: 0;
  font-size: 13px;
  font-weight: 850;
  line-height: 1;
  transform: none;
  box-shadow: none;
}

.is-refined-preview .icon-logout::before {
  left: 2px;
  top: 2px;
  bottom: 2px;
  width: 7px;
  border: 1.8px solid currentColor;
  border-right: 0;
  border-radius: 3px 0 0 3px;
}

.is-refined-preview .icon-logout::after {
  right: 3px;
  top: 50%;
  width: 7px;
  height: 7px;
  border-top: 1.8px solid currentColor;
  border-right: 1.8px solid currentColor;
  transform: translateY(-50%) rotate(45deg);
}

.is-refined-preview .icon-spark::before {
  left: 7px;
  top: 3px;
  width: 2px;
  height: 10px;
  background: currentColor;
  border-radius: 999px;
}

.is-refined-preview .icon-spark::after {
  left: 3px;
  top: 7px;
  width: 10px;
  height: 2px;
  background: currentColor;
  border-radius: 999px;
}

.is-refined-preview .icon-generate::before {
  inset: 3px;
  border: 2px solid currentColor;
  border-radius: 999px;
}

.is-refined-preview .icon-generate::after {
  right: 0;
  top: 1px;
  width: 5px;
  height: 5px;
  background: currentColor;
  border-radius: 999px;
}

.is-refined-preview .icon-copy::before {
  left: 5px;
  top: 3px;
  width: 8px;
  height: 10px;
  border: 1.8px solid currentColor;
  border-radius: 2px;
}

.is-refined-preview .icon-copy::after {
  left: 2px;
  top: 6px;
  width: 8px;
  height: 8px;
  border: 1.8px solid currentColor;
  border-radius: 2px;
  background: var(--panel);
}

.is-refined-preview .icon-clear::before,
.is-refined-preview .icon-clear::after {
  left: 3px;
  top: 7px;
  width: 10px;
  height: 2px;
  background: currentColor;
  border-radius: 999px;
}

.is-refined-preview .icon-clear::before {
  transform: rotate(45deg);
}

.is-refined-preview .icon-clear::after {
  transform: rotate(-45deg);
}

.is-refined-preview .icon-load::before {
  inset: 3px;
  border: 2px solid currentColor;
  border-left-color: transparent;
  border-radius: 999px;
}

.is-refined-preview .icon-upload::before {
  left: 7px;
  top: 3px;
  height: 8px;
  border-left: 2px solid currentColor;
}

.is-refined-preview .icon-upload::after {
  left: 4px;
  top: 3px;
  width: 8px;
  height: 8px;
  border-left: 2px solid currentColor;
  border-top: 2px solid currentColor;
  transform: rotate(45deg);
}

.is-refined-preview .icon-collapse::before {
  left: 3px;
  right: 3px;
  top: 7px;
  border-top: 2px solid currentColor;
}

.is-refined-preview .tab,
.is-refined-preview .icon-button,
.is-refined-preview .generate-button,
.is-refined-preview .action-button,
.is-refined-preview .download-button,
.is-refined-preview .tool-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}

.is-refined-preview .prompt-stack {
  gap: 10px;
}

.is-refined-preview .prompt-composer {
  gap: 0;
  border: 1px solid #d7e0dc;
  border-radius: 8px;
  background: #fffefa;
  overflow: hidden;
  box-shadow: 0 8px 20px rgba(28, 43, 38, 0.04);
}

.is-refined-preview .primary-composer {
  border-color: rgba(22, 118, 109, 0.24);
}

.is-refined-preview .composer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 38px;
  padding: 7px 9px 7px 11px;
  border-bottom: 1px solid #edf1ee;
  background: #fbfcf8;
}

.is-refined-preview .composer-header label {
  color: #1f2d2b;
  font-size: 12px;
  font-weight: 800;
}

.is-refined-preview .composer-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.is-refined-preview .tool-button {
  min-height: 28px;
  padding: 0 8px;
  border: 1px solid #d7e0dc;
  border-radius: 7px;
  background: #ffffff;
  color: #40514c;
  font-size: 12px;
  font-weight: 750;
}

.is-refined-preview .tool-button:hover {
  border-color: rgba(22, 118, 109, 0.4);
  background: #f4fbf8;
}

.is-refined-preview .tool-button.is-confirmed {
  border-color: rgba(35, 124, 93, 0.46);
  background: #eef8f3;
  color: #1e684f;
}

.is-refined-preview .prompt-composer textarea {
  border: 0;
  border-radius: 0;
  background: #fffefa;
  box-shadow: none;
}

.is-refined-preview .prompt-composer textarea:focus {
  box-shadow: inset 0 0 0 2px rgba(22, 118, 109, 0.14);
}

.is-refined-preview .secondary-composer.is-collapsed .composer-header {
  border-bottom: 0;
}

.is-refined-preview .inspector-panel {
  display: grid;
  gap: 10px;
}

.is-refined-preview .inspector-quick-grid {
  display: grid;
  gap: 9px;
}

.is-refined-preview .inspector-block {
  display: grid;
  gap: 6px;
}

.is-refined-preview .inspector-label {
  color: #718079;
  font-size: 11px;
  font-weight: 800;
}

.is-refined-preview .option-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.is-refined-preview .option-chip {
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid #d7e0dc;
  border-radius: 999px;
  background: #ffffff;
  color: #344743;
  font-size: 12px;
  font-weight: 750;
  transition: transform 120ms ease, border-color 160ms ease, background-color 160ms ease, box-shadow 160ms ease;
}

.is-refined-preview .option-chip:hover {
  transform: translateY(-1px);
  border-color: rgba(22, 118, 109, 0.4);
  background: #f5fbf8;
}

.is-refined-preview .option-chip.is-active {
  border-color: rgba(22, 118, 109, 0.58);
  background: #edf8f4;
  color: #12413c;
  box-shadow: inset 0 0 0 1px rgba(22, 118, 109, 0.16);
}

.is-refined-preview .inspector-select {
  width: 100%;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid #d7e0dc;
  border-radius: 8px;
  background: #fffefa;
  color: #12413c;
  font-size: 13px;
}

.is-refined-preview .inspector-select:hover {
  border-color: rgba(22, 118, 109, 0.4);
}

.is-refined-preview .inspector-select:focus {
  outline: none;
  border-color: rgba(22, 118, 109, 0.58);
  box-shadow: 0 0 0 3px rgba(22, 118, 109, 0.12);
}

/* 比例选择：带宽高比形状图标的自定义下拉 */
.is-refined-preview .ratio-field {
  position: relative;
}

.is-refined-preview .ratio-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid #d7e0dc;
  border-radius: 8px;
  background: #fffefa;
  color: #12413c;
  font-size: 13px;
  cursor: pointer;
}

.is-refined-preview .ratio-trigger:hover {
  border-color: rgba(22, 118, 109, 0.4);
}

.is-refined-preview .ratio-field.is-open .ratio-trigger {
  border-color: rgba(22, 118, 109, 0.58);
  box-shadow: 0 0 0 3px rgba(22, 118, 109, 0.12);
}

.is-refined-preview .ratio-trigger-label {
  flex: 1 1 auto;
  text-align: left;
}

.is-refined-preview .ratio-caret {
  flex: 0 0 auto;
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid #6b8079;
}

.is-refined-preview .ratio-shape {
  display: inline-block;
  box-sizing: border-box;
  border: 1.6px solid currentColor;
  border-radius: 3px;
  flex: 0 0 auto;
}

.is-refined-preview .ratio-shape[data-ratio-shape="auto"] { width: 16px; height: 16px; border-style: dashed; }
.is-refined-preview .ratio-shape[data-ratio-shape="1:1"] { width: 16px; height: 16px; }
.is-refined-preview .ratio-shape[data-ratio-shape="3:4"] { width: 12px; height: 16px; }
.is-refined-preview .ratio-shape[data-ratio-shape="9:16"] { width: 9px; height: 16px; }
.is-refined-preview .ratio-shape[data-ratio-shape="4:3"] { width: 16px; height: 12px; }
.is-refined-preview .ratio-shape[data-ratio-shape="16:9"] { width: 16px; height: 9px; }

.is-refined-preview .ratio-trigger > .ratio-shape {
  color: #4a5d57;
}

/* 固定定位浮层：避免被 .app-shell 的 overflow:hidden 裁切，也不撑乱页面滚动；
   具体 left/width/top 由 JS 按触发器位置计算，空间不足时向上翻并内部滚动 */
.is-refined-preview .ratio-popover {
  position: fixed;
  z-index: 60;
  display: grid;
  gap: 2px;
  padding: 8px;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: #fffefd;
  border: 1px solid #d7e0dc;
  border-radius: 10px;
  box-shadow: 0 12px 30px rgba(15, 40, 35, 0.14);
}

.is-refined-preview .ratio-popover-title {
  padding: 4px 8px 6px;
  font-size: 12px;
  color: #6b8079;
}

.is-refined-preview .ratio-option {
  display: grid;
  grid-template-columns: 24px 1fr auto 16px;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #12413c;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}

.is-refined-preview .ratio-option:hover {
  background: #f1f8f5;
}

.is-refined-preview .ratio-option .ratio-shape {
  justify-self: center;
  color: #4a5d57;
}

.is-refined-preview .ratio-option-name {
  justify-self: start;
  font-weight: 600;
}

.is-refined-preview .ratio-option-tag {
  color: #8a9a93;
  font-size: 12px;
}

.is-refined-preview .ratio-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
}

.is-refined-preview .ratio-option.is-active {
  background: #edf8f4;
}

.is-refined-preview .ratio-option.is-active .ratio-shape {
  color: #0f8f85;
}

.is-refined-preview .ratio-option.is-active .ratio-check::after {
  content: "\2713";
  color: #0f8f85;
  font-size: 13px;
  font-weight: 700;
}

.is-refined-preview .canvas-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 42px;
  padding: 9px 12px;
  border: 1px solid #d7e0dc;
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  background: #fffefa;
}

.is-refined-preview .canvas-title {
  display: grid;
  gap: 1px;
}

.is-refined-preview .canvas-title span {
  color: #718079;
  font-size: 11px;
  font-weight: 800;
}

.is-refined-preview .canvas-title strong {
  color: #1f2d2b;
  font-size: 13px;
}

.is-refined-preview .canvas-hint {
  color: #718079;
  font-size: 12px;
}

.is-refined-preview .canvas-toolbar + .preview-frame {
  border-radius: 0 0 8px 8px;
}

.is-refined-preview .canvas-empty-state {
  display: grid;
  place-items: center;
  gap: 8px;
  max-width: 280px;
  color: #718079;
  text-align: center;
  line-height: 1.45;
}

.is-refined-preview .canvas-empty-state .button-icon {
  width: 38px;
  height: 38px;
  color: #87a199;
}

.is-refined-preview .canvas-empty-state strong {
  color: #253633;
  font-size: 15px;
}

.is-refined-preview .canvas-empty-state span:last-child {
  font-size: 12px;
}

@media (max-width: 760px) {
  .is-refined-preview .product-mark {
    min-width: 100%;
  }

  .is-refined-preview .nav-group {
    width: 100%;
    flex-wrap: wrap;
  }

  .is-refined-preview .top-actions {
    margin-left: auto;
  }

  .is-refined-preview .composer-header,
  .is-refined-preview .canvas-toolbar {
    align-items: stretch;
    flex-direction: column;
  }
}

/* AI Studio Demo: structure and polish inspired by the supplied product mockup. */
.is-refined-preview .image-workspace-header {
  position: relative;
  min-height: 72px;
  padding: 0 26px;
  border-bottom-color: rgba(18, 42, 38, 0.08);
  background: rgba(255, 255, 252, 0.98);
}

.is-refined-preview .app-shell {
  width: 100%;
  min-height: 100vh;
  margin: 0;
  border: 0;
  border-radius: 0;
  background: #f7f8f5;
  box-shadow: none;
}

.is-refined-preview .product-mark {
  min-width: 250px;
}

.is-refined-preview .brand-glyph {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: #20887d;
  box-shadow: 0 12px 24px rgba(32, 136, 125, 0.2);
}

.is-refined-preview .brand-glyph::before {
  left: 9px;
  top: 9px;
  width: 18px;
  height: 18px;
  border-radius: 6px;
  background: #f7fffb;
  transform: none;
}

.is-refined-preview .brand-glyph::after {
  display: none;
}

.is-refined-preview .brand-copy strong {
  font-size: 17px;
}

.is-refined-preview .brand-copy small {
  margin-top: 2px;
  font-size: 12px;
}

.is-refined-preview .nav-group {
  margin: 0 auto;
  gap: 12px;
}

.is-refined-preview .tab {
  position: relative;
  min-width: 132px;
  height: 44px;
  border-radius: 8px;
  background: #fffefa;
  box-shadow: 0 6px 18px rgba(28, 43, 38, 0.045);
}

.is-refined-preview .tab.is-active {
  background: #edf7f4;
  box-shadow: 0 10px 24px rgba(22, 118, 109, 0.1);
}

.is-refined-preview .tab.is-active::after {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: -9px;
  height: 2px;
  border-radius: 999px;
  background: var(--blue);
  content: "";
}

.is-refined-preview .studio-layout {
  grid-template-columns: minmax(420px, 36.5%) minmax(640px, 1fr);
  gap: 20px;
  padding: 22px 24px;
}

.is-refined-preview .left-workbench,
.is-refined-preview .right-stage {
  gap: 18px;
}

.is-refined-preview .prompt-panel,
.is-refined-preview .option-panel,
.is-refined-preview .progress-panel,
.is-refined-preview .preview-panel,
.is-refined-preview .reference-panel,
.is-refined-preview .template-list-panel,
.is-refined-preview .template-detail,
.is-refined-preview .history-list-panel,
.is-refined-preview .history-detail {
  border-radius: 8px;
  background: rgba(255, 255, 252, 0.98);
  box-shadow: 0 14px 34px rgba(27, 43, 38, 0.07);
}

.is-refined-preview .section-heading {
  min-height: 28px;
}

.is-refined-preview .section-heading h2,
.is-refined-preview .panel-title h1 {
  font-size: 15px;
  font-weight: 820;
}

.is-refined-preview .job-indicator {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #718079;
  font-size: 12px;
  font-weight: 750;
}

.is-refined-preview .status-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: #59c5a7;
}

.is-refined-preview .reference-drop {
  min-height: 205px;
  border-style: dashed;
  border-color: #bfd1cb;
  background: #fcfdfb;
}

.is-refined-preview .reference-empty {
  display: grid;
  place-items: center;
  gap: 8px;
  padding: 24px 18px;
  color: #77877f;
  text-align: center;
}

.is-refined-preview .reference-empty strong {
  color: #243531;
  font-size: 14px;
  font-weight: 820;
}

.is-refined-preview .reference-empty small {
  color: #7c8b84;
  font-size: 12px;
}

.is-refined-preview .reference-empty-art {
  position: relative;
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border: 2px solid rgba(32, 136, 125, 0.24);
  border-radius: 12px;
  background: #edf8f5;
  color: #6fbdb0;
}

.is-refined-preview .reference-empty-art > .button-icon {
  width: 28px;
  height: 28px;
}

.is-refined-preview .upload-badge {
  position: absolute;
  right: -8px;
  bottom: -6px;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 2px solid #fffefa;
  border-radius: 999px;
  background: #2aa28f;
  color: #ffffff;
  box-shadow: 0 8px 16px rgba(42, 162, 143, 0.22);
}

.is-refined-preview .upload-badge .button-icon {
  width: 13px;
  height: 13px;
}

.is-refined-preview .reference-actions {
  grid-template-columns: 1fr 1fr;
  margin-top: 12px;
}

.is-refined-preview .prompt-stack {
  gap: 14px;
}

.is-refined-preview .prompt-composer {
  border-color: #d9e2dd;
  background: #fffefa;
}

.is-refined-preview .composer-header {
  min-height: 42px;
  background: #fbfcfa;
}

.is-refined-preview .prompt-composer textarea {
  padding: 13px 16px;
  font-size: 13px;
  line-height: 1.62;
}

.is-refined-preview #prompt {
  min-height: 166px;
}

.is-refined-preview #negative-prompt {
  min-height: 104px;
}

.is-refined-preview .composer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 30px;
  padding: 0 13px 9px;
  color: #81908a;
  font-size: 12px;
}

.is-refined-preview .field-counter {
  color: #73827c;
  font-variant-numeric: tabular-nums;
}

.is-refined-preview .prompt-tools {
  grid-template-columns: minmax(180px, 1fr) max-content max-content;
  gap: 10px;
}

.is-refined-preview .generate-button {
  min-height: 46px;
  border-color: #27877d;
  background: #16766d;
  color: #ffffff;
  box-shadow: 0 12px 24px rgba(22, 118, 109, 0.18);
}

.is-refined-preview .generate-button:hover:not(:disabled) {
  border-color: #11645d;
  background: #116f67;
}

.is-refined-preview .progress-header {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  padding: 18px 22px;
}

.is-refined-preview .progress-title-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  color: #718079;
  font-size: 15px;
  font-weight: 800;
}

.is-refined-preview .progress-status-group {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.is-refined-preview .progress-title-line strong,
.is-refined-preview .job-elapsed {
  min-width: 58px;
  padding: 7px 13px;
  border-radius: 999px;
  background: #eef6f3;
  color: #23443d;
  text-align: center;
  font-size: 13px;
}

.is-refined-preview .job-elapsed {
  min-width: 66px;
  background: #f7fbf8;
  color: #08766f;
  font-family: "SFMono-Regular", Menlo, Consolas, monospace;
  font-weight: 800;
}

.is-refined-preview .progress-summary-right {
  min-width: 0;
  width: 100%;
}

.is-refined-preview .progress-mini-bar {
  width: 100%;
  height: 12px;
  background: #e8ecea;
}

.is-refined-preview .progress-mini-bar span {
  background: #238b68;
}

.is-refined-preview .event-list {
  max-height: 112px;
  padding: 12px 22px 12px 38px;
}

.is-refined-preview .preview-panel {
  padding: 20px;
}

.is-refined-preview .canvas-toolbar {
  min-height: 56px;
  padding: 0 4px 14px;
  border: 0;
  background: transparent;
}

.is-refined-preview .canvas-toolbar + .preview-frame {
  border-radius: 8px;
}

.is-refined-preview .preview-frame {
  aspect-ratio: 1 / 1;
  width: 100%;
  height: auto;
  min-height: 0;
  max-height: none;
  background: #fcfdfb;
}

.is-refined-preview .preview-frame img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  min-width: 0;
  min-height: 0;
  object-fit: contain;
  object-position: center;
}

.is-refined-preview .empty-preview {
  display: grid;
  place-items: center;
}

.is-refined-preview .hover-zoom {
  width: min(51%, 510px);
  border-color: rgba(255, 255, 252, 0.82);
  background-color: #fffefa;
  box-shadow: 0 22px 54px rgba(27, 43, 38, 0.22);
}

.is-refined-preview .canvas-empty-state {
  max-width: 520px;
  gap: 12px;
}

.is-refined-preview .canvas-empty-visual {
  position: relative;
  width: 168px;
  height: 126px;
}

.is-refined-preview .canvas-card-shape {
  position: absolute;
  left: 26px;
  top: 20px;
  display: grid;
  place-items: center;
  width: 112px;
  height: 88px;
  border: 1px solid #dbe5e0;
  border-radius: 14px;
  background: #f2f6f4;
  color: #c5d3ce;
  box-shadow: 0 16px 30px rgba(27, 43, 38, 0.06);
}

.is-refined-preview .canvas-card-shape .button-icon {
  width: 54px;
  height: 54px;
}

.is-refined-preview .canvas-wand-shape {
  position: absolute;
  right: 10px;
  bottom: 10px;
  width: 12px;
  height: 82px;
  border-radius: 999px;
  background: #267b73;
  transform: rotate(-38deg);
  box-shadow: 0 0 0 7px rgba(49, 177, 160, 0.1);
}

.is-refined-preview .canvas-wand-shape::before,
.is-refined-preview .canvas-wand-shape::after {
  position: absolute;
  width: 9px;
  height: 9px;
  border-radius: 2px;
  background: #61cfc0;
  content: "";
  transform: rotate(38deg);
}

.is-refined-preview .canvas-wand-shape::before {
  left: -30px;
  top: -8px;
}

.is-refined-preview .canvas-wand-shape::after {
  right: -24px;
  top: 24px;
}

.is-refined-preview .canvas-empty-state strong {
  font-size: 22px;
}

.is-refined-preview .canvas-empty-state > span {
  color: #77877f;
  font-size: 14px;
}

.is-refined-preview .canvas-tip {
  margin-top: 10px;
  padding: 10px 14px;
  border-radius: 8px;
  background: #f2f4f2;
  color: #73827c;
  font-size: 13px;
}

@media (max-width: 1080px) {
  .is-refined-preview .image-workspace-header {
    min-height: auto;
    padding: 12px 16px;
  }

  .is-refined-preview .nav-group {
    margin: 0;
  }
}

.is-refined-preview.help-page {
  background: #f7f8f5;
}

.is-refined-preview .help-shell {
  width: min(1180px, calc(100vw - 28px));
  margin: 18px auto 32px;
}

.is-refined-preview .help-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 20px;
  align-items: center;
  padding: 22px;
  border: 1px solid #d7e0dc;
  border-radius: 8px;
  background: #fffefa;
  box-shadow: 0 14px 34px rgba(27, 43, 38, 0.07);
}

.is-refined-preview .help-header h1 {
  margin: 0;
  color: #172724;
  font-size: 28px;
  letter-spacing: 0;
}

.is-refined-preview .help-header p {
  max-width: 780px;
  margin: 8px 0 0;
  color: #65756f;
  line-height: 1.7;
}

.is-refined-preview .help-back {
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid #d7e0dc;
  border-radius: 8px;
  background: #ffffff;
  color: #223633;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  font-weight: 750;
}

.is-refined-preview .help-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(0, 1.4fr);
  gap: 16px;
  margin-top: 16px;
}

.is-refined-preview .help-card {
  border: 1px solid #d7e0dc;
  border-radius: 8px;
  background: #fffefa;
  box-shadow: 0 14px 34px rgba(27, 43, 38, 0.055);
  overflow: hidden;
}

.is-refined-preview .help-card-content {
  padding: 18px;
}

.is-refined-preview .help-card h2 {
  margin: 0 0 10px;
  color: #172724;
  font-size: 18px;
}

.is-refined-preview .help-card p,
.is-refined-preview .help-card li {
  color: #5f6f69;
  line-height: 1.7;
}

.is-refined-preview .help-card ul,
.is-refined-preview .help-card ol {
  margin: 8px 0 0;
  padding-left: 20px;
}

.is-refined-preview .help-card strong {
  color: #172724;
}

.is-refined-preview .help-shot {
  display: grid;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid #e4ebe7;
  background: #fbfcf8;
}

.is-refined-preview .help-shot img {
  display: block;
  width: 100%;
  border: 1px solid #d7e0dc;
  border-radius: 8px;
  background: #f3f6f4;
}

.is-refined-preview .help-shot figcaption {
  color: #718079;
  font-size: 12px;
  line-height: 1.5;
}

.is-refined-preview .help-flow {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.is-refined-preview .help-flow-item {
  padding: 14px;
  border: 1px solid #e2e8e5;
  border-radius: 8px;
  background: #fffefd;
}

.is-refined-preview .help-flow-item span {
  display: inline-flex;
  margin-bottom: 6px;
  padding: 4px 9px;
  border: 1px solid #e2e8e5;
  border-radius: 7px;
  background: #fffefa;
  color: #40514c;
  font-size: 12px;
}

@media (max-width: 920px) {
  .is-refined-preview .help-header,
  .is-refined-preview .help-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .is-refined-preview .studio-layout {
    padding: 14px;
  }

  .is-refined-preview .prompt-tools {
    grid-template-columns: 1fr;
  }

  .is-refined-preview .preview-frame {
    height: auto;
    min-height: 0;
  }
}

/* Refined Preview: productized secondary pages for template and history. */
.is-refined-preview .refined-secondary-view {
  gap: 20px;
  padding: 22px 24px;
}

.is-refined-preview .template-workspace {
  grid-template-columns: minmax(360px, 30%) minmax(680px, 1fr);
}

.is-refined-preview .history-workspace {
  grid-template-columns: minmax(420px, 34%) minmax(720px, 1fr);
  align-items: stretch;
}

.is-refined-preview .section-title-copy {
  display: grid;
  gap: 3px;
}

.is-refined-preview .section-title-copy span {
  color: #74837d;
  font-size: 12px;
  font-weight: 650;
}

.is-refined-preview .history-search-panel {
  margin-bottom: 16px;
  padding: 12px;
  border: 1px solid #d7e0dc;
  border-radius: 8px;
  background: #fcfdfb;
}

.is-refined-preview .history-search-panel label {
  color: #263a35;
  font-size: 13px;
  font-weight: 820;
}

.is-refined-preview .history-search-panel input {
  min-height: 42px;
  border-radius: 8px;
  background: #fffefa;
}

.is-refined-preview .history-search-panel span {
  color: #74837d;
  font-weight: 700;
}

.is-refined-preview .template-list-panel,
.is-refined-preview .history-list-panel {
  padding: 20px;
}

.is-refined-preview .history-list-panel {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 122px);
}

.is-refined-preview .template-detail,
.is-refined-preview .history-detail {
  padding: 20px;
}

.is-refined-preview .template-list,
.is-refined-preview .history-list {
  margin-top: 12px;
  padding-right: 4px;
}

.is-refined-preview .template-list-panel {
  background: #fffefd;
}

.is-refined-preview .template-detail {
  background: #fffefd;
}

.is-refined-preview .history-list {
  flex: 1 1 auto;
  align-content: start;
  grid-auto-rows: max-content;
  max-height: none;
  min-height: calc(100vh - 238px);
}

.is-refined-preview .template-item,
.is-refined-preview .history-item {
  border-radius: 8px;
  background: #fffefa;
}

.is-refined-preview .template-item {
  position: relative;
  padding: 14px;
  padding-right: 42px;
  min-height: 76px;
}

.is-refined-preview .template-item::after {
  position: absolute;
  right: 18px;
  top: 50%;
  color: #3f5550;
  font-size: 24px;
  line-height: 1;
  content: ">";
  transform: translateY(-50%);
}

.is-refined-preview .template-item:hover,
.is-refined-preview .template-item.is-active {
  border-color: #0f8f85;
  background: #f7fffc;
  box-shadow: inset 3px 0 0 #0f8f85, 0 14px 28px rgba(18, 75, 69, 0.08);
}

.is-refined-preview .template-item-name {
  font-size: 15px;
}

.is-refined-preview .template-editor-card {
  gap: 16px 18px;
  margin-top: 12px;
  padding: 18px;
  border: 1px solid #d7e0dc;
  border-radius: 8px;
  background: #fffefd;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72), 0 14px 32px rgba(28, 43, 38, 0.045);
}

.is-refined-preview .template-editor-card textarea,
.is-refined-preview .template-editor-card input,
.is-refined-preview .template-editor-card select {
  background: #fffefa;
}

.is-refined-preview .template-editor-card textarea {
  min-height: 126px;
  padding: 13px 14px;
  overflow: hidden;
}

.is-refined-preview .template-editor-card #template-negative-prompt {
  min-height: 90px;
}

.is-refined-preview .template-actions {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
  margin: 2px -18px -18px;
  padding: 18px;
  border-top: 1px solid #e5ece8;
  background: #fbfcf9;
}

.is-refined-preview .template-actions .action-button {
  min-height: 52px;
  font-size: 14px;
}

.is-refined-preview #template-new {
  min-height: 40px;
  border-color: rgba(255, 255, 255, 0.34);
  background: #0f8f85;
  color: #ffffff;
  box-shadow: 0 12px 26px rgba(15, 143, 133, 0.18);
}

.is-refined-preview #template-save {
  border-color: #0f8f85;
  background: #f8fffc;
  color: #08766f;
}

.is-refined-preview #template-delete {
  border-color: #f0b9b4;
  background: #fff8f7;
  color: #be3b35;
}

.is-refined-preview .history-item {
  grid-template-columns: 122px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  min-height: 108px;
  padding: 8px 12px 8px 8px;
  border-color: #e4ebe7;
  background: #fffefd;
}

.is-refined-preview .history-item img,
.is-refined-preview .history-thumb-placeholder {
  width: 122px;
  height: 90px;
  border-radius: 8px;
}

.is-refined-preview .history-item:hover,
.is-refined-preview .history-item.is-active {
  border-color: #0f8f85;
  background: #fbfffd;
  box-shadow: inset 3px 0 0 #0f8f85, 0 16px 34px rgba(18, 75, 69, 0.08);
}

.is-refined-preview .history-item-body {
  gap: 12px;
}

.is-refined-preview .history-item-top {
  gap: 12px;
}

.is-refined-preview .history-item-prompt {
  font-size: 14px;
}

.is-refined-preview .history-item-date,
.is-refined-preview .history-item-options {
  font-size: 12px;
}

.is-refined-preview .history-item-date {
  color: #263a35;
  font-size: 14px;
  font-weight: 400;
}

.is-refined-preview .history-status-badge {
  padding: 5px 12px;
  border: 0;
  background: #eaf8f0;
  color: #158b57;
  font-size: 12px;
  font-weight: 800;
}

.is-refined-preview .history-status-badge.is-running {
  background: #eaf8f0;
  animation: slow-breath 2.05s ease-in-out infinite;
}

.is-refined-preview .history-status-badge.is-failed {
  background: #fdecec;
  color: #d32f2f;
}

.is-refined-preview .history-status-badge::before {
  display: none;
}

.is-refined-preview .history-item-chips {
  gap: 8px;
}

.is-refined-preview .history-chip {
  min-height: 28px;
  padding: 0 10px;
  border-color: #e2e8e5;
  border-radius: 7px;
  background: #fffefa;
  color: #43534f;
  font-size: 12px;
  font-weight: 400;
}

.is-refined-preview .history-detail-card {
  gap: 16px;
  margin-top: 12px;
}

.is-refined-preview .history-detail-header {
  min-height: 48px;
}

.is-refined-preview .history-detail-actions {
  gap: 10px;
}

.is-refined-preview .history-detail-state strong {
  color: #078b63;
  font-size: 18px;
  font-weight: 820;
}

.is-refined-preview .history-detail-state span:last-child {
  color: #61716c;
  font-size: 13px;
  font-weight: 400;
}

.is-refined-preview .history-detail-state.is-running .history-detail-icon,
.is-refined-preview .history-detail-state.is-running strong {
  animation: slow-breath 2.05s ease-in-out infinite;
}

.is-refined-preview .history-download {
  min-width: 126px;
  min-height: 42px;
  border-color: rgba(255, 255, 255, 0.4);
  background: #078d82;
  color: #ffffff;
  box-shadow: 0 12px 24px rgba(7, 141, 130, 0.18);
}

.is-refined-preview .history-download:hover {
  border-color: rgba(255, 255, 255, 0.52);
  background: #077d73;
}

.is-refined-preview .history-regenerate {
  min-width: 126px;
  min-height: 42px;
  border-color: #cddad4;
  background: #fffefa;
  color: #22302d;
  box-shadow: none;
}

.is-refined-preview .history-regenerate:hover {
  border-color: #078d82;
  background: #f3faf7;
}

.is-refined-preview .history-detail-empty {
  min-height: calc(100vh - 188px);
  border: 1px dashed #cddad4;
  border-radius: 8px;
  background: #fcfdfb;
  color: #7c8b84;
}

.is-refined-preview .history-image-frame {
  min-height: 430px;
  border-radius: 8px;
  background: #fcfdfb;
}

.is-refined-preview .history-reference-section {
  border-color: #d7e0dc;
  border-radius: 8px;
  background: #fcfdfb;
}

.is-refined-preview .history-detail-grid {
  gap: 14px;
}

.is-refined-preview .history-field-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.is-refined-preview .history-field-header label {
  color: #718079;
  font-size: 12px;
  font-weight: 650;
}

.is-refined-preview .history-detail-grid input,
.is-refined-preview .history-detail-grid textarea {
  border-radius: 8px;
  background: #fffefa;
}

.is-refined-preview .confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 850;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(17, 28, 25, 0.34);
  backdrop-filter: blur(8px);
}

.is-refined-preview .confirm-dialog {
  width: min(440px, 100%);
  padding: 22px;
  border: 1px solid #dce4df;
  border-radius: 8px;
  background: #fffefd;
  box-shadow: 0 28px 70px rgba(17, 28, 25, 0.22);
}

.is-refined-preview .generate-confirm-dialog {
  width: min(520px, 100%);
}

.is-refined-preview .confirm-header {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.is-refined-preview .confirm-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid #f0b9b4;
  border-radius: 8px;
  background: #fff4f2;
  color: #be3b35;
}

.is-refined-preview .confirm-header h2 {
  margin: 0;
  color: #172724;
  font-size: 18px;
}

.is-refined-preview .confirm-header p {
  margin: 6px 0 0;
  color: #6f8079;
  font-size: 13px;
  line-height: 1.6;
}

.is-refined-preview .confirm-target {
  margin-top: 16px;
  padding: 12px 14px;
  border: 1px solid #e3eae6;
  border-radius: 8px;
  background: #fbfcf9;
  color: #253a35;
  font-weight: 800;
}

.is-refined-preview #generate-confirm-mode {
  border-color: rgba(15, 143, 133, 0.2);
  background: #eef8f5;
  color: #08766f;
}

.is-refined-preview #confirm-generate {
  border-color: #0f8f85;
  background: #0f8f85;
  color: #ffffff;
  box-shadow: 0 12px 26px rgba(15, 143, 133, 0.18);
}

.is-refined-preview #confirm-generate:hover {
  border-color: #08766f;
  background: #08766f;
}

.is-refined-preview .confirm-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 18px;
}

.is-refined-preview .confirm-actions .action-button {
  min-height: 44px;
}

.is-refined-preview .reference-actions {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.is-refined-preview .reference-thumb {
  position: relative;
}

.is-refined-preview .reference-label {
  position: absolute;
  left: 6px;
  top: 6px;
  padding: 3px 7px;
  border-radius: 7px;
  background: rgba(15, 38, 33, 0.78);
  color: #ffffff;
  font-size: 11px;
  font-weight: 800;
}

.is-refined-preview .reference-prompt-map {
  display: grid;
  gap: 6px;
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid #d7e0dc;
  border-radius: 8px;
  background: #fcfdfb;
  color: #43534f;
  font-size: 12px;
  line-height: 1.5;
}

.is-refined-preview .asset-library-workspace {
  display: grid;
  grid-template-columns: minmax(360px, 30%) minmax(680px, 1fr);
  align-items: stretch;
  min-height: calc(100vh - 122px);
}

.is-refined-preview .asset-library-list-panel,
.is-refined-preview .asset-library-detail {
  padding: 20px;
}

.is-refined-preview .asset-library-list-panel {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 122px);
  background: #fffefd;
}

.is-refined-preview .asset-library-list-panel .history-search-panel label {
  font-size: 12px;
  font-weight: 700;
}

.is-refined-preview .asset-library-list {
  flex: 1 1 auto;
  margin-top: 12px;
  padding-right: 4px;
  overflow: auto;
}

.is-refined-preview .asset-library-item {
  width: 100%;
}

.is-refined-preview .asset-library-item .template-item-name {
  font-size: 14px;
  font-weight: 700;
}

.is-refined-preview .asset-library-item .template-item-meta {
  font-size: 12px;
  font-weight: 400;
}

.is-refined-preview .asset-library-detail {
  min-height: calc(100vh - 122px);
  background: #fffefd;
}

.is-refined-preview .asset-library-empty {
  display: grid;
  place-items: center;
  min-height: calc(100vh - 188px);
  border: 1px dashed #cddad4;
  border-radius: 8px;
  background: #fcfdfb;
  color: #7c8b84;
  font-weight: 700;
}

.is-refined-preview .asset-library-detail-content {
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
  gap: 16px;
}

.is-refined-preview .asset-library-editor {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(150px, 0.55fr) minmax(170px, 0.7fr);
}

.is-refined-preview .asset-library-editor label {
  color: #718079;
  font-size: 12px;
  font-weight: 650;
}

.is-refined-preview .asset-library-editor .wide-field {
  grid-column: 1 / -1;
}

.is-refined-preview .asset-library-editor input,
.is-refined-preview .asset-library-editor textarea,
.is-refined-preview .asset-toolbar input,
.is-refined-preview .asset-title-input {
  font-size: 14px;
  font-weight: 400;
}

.is-refined-preview .asset-library-upload {
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 172px;
  padding: 18px;
  border: 1px dashed #b9c8c1;
  border-radius: 8px;
  background: #fcfdfb;
  color: #263a35;
  text-align: center;
}

.is-refined-preview .asset-library-upload.is-active {
  border-color: #0f8f85;
  background: #f3faf7;
}

.is-refined-preview .asset-library-upload strong {
  font-size: 14px;
  font-weight: 700;
}

.is-refined-preview .asset-library-upload small {
  color: #74837d;
  font-size: 12px;
}

.is-refined-preview .asset-toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto;
  gap: 12px;
  align-items: end;
  padding: 12px;
  border: 1px solid #d7e0dc;
  border-radius: 8px;
  background: #fcfdfb;
}

.is-refined-preview .asset-toolbar label {
  display: grid;
  gap: 6px;
}

.is-refined-preview .asset-toolbar span {
  color: #718079;
  font-size: 12px;
  font-weight: 650;
}

.is-refined-preview .asset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
}

.is-refined-preview .asset-empty {
  grid-column: 1 / -1;
  padding: 24px;
  border: 1px dashed #cddad4;
  border-radius: 8px;
  background: #fcfdfb;
  color: #7c8b84;
  text-align: center;
  font-weight: 700;
}

.is-refined-preview .asset-card {
  display: grid;
  gap: 10px;
  padding: 10px;
  border: 1px solid #dfe7e2;
  border-radius: 8px;
  background: #fffefa;
  box-shadow: 0 10px 22px rgba(29, 54, 47, 0.04);
}

.is-refined-preview .asset-card-top {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px;
  align-items: start;
}

.is-refined-preview .asset-thumb {
  width: 100%;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border: 1px solid #d7e0dc;
  border-radius: 8px;
  background: #f8faf7;
}

.is-refined-preview .asset-thumb img,
.is-refined-preview .asset-picker-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.is-refined-preview .asset-title-input {
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid #d7e0dc;
  border-radius: 8px;
  background: #fffefd;
  color: #253a35;
}

.is-refined-preview .asset-meta {
  min-height: 38px;
  color: #74837d;
  font-size: 11px;
  line-height: 1.45;
}

.is-refined-preview .asset-actions {
  display: flex;
  justify-content: flex-end;
}

.is-refined-preview .asset-actions .action-button {
  min-height: 34px;
  padding: 0 12px;
  font-size: 12px;
}

.is-refined-preview .asset-picker-modal {
  align-items: center;
}

.is-refined-preview .asset-picker-dialog {
  width: min(1320px, calc(100vw - 48px));
  max-height: calc(100vh - 48px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 14px;
  padding: 20px;
  border: 1px solid #dce4df;
  border-radius: 8px;
  background: #fffefd;
  box-shadow: 0 28px 70px rgba(17, 28, 25, 0.22);
}

.is-refined-preview .asset-picker-heading {
  margin-bottom: 0;
}

.is-refined-preview .asset-picker-body {
  min-height: 0;
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr) 300px;
  gap: 14px;
}

.is-refined-preview .asset-picker-libraries,
.is-refined-preview .asset-picker-assets,
.is-refined-preview .asset-picker-selection {
  min-width: 0;
  min-height: 0;
  display: grid;
  gap: 10px;
  align-content: start;
  padding: 12px;
  border: 1px solid #d7e0dc;
  border-radius: 8px;
  background: #fcfdfb;
}

.is-refined-preview .asset-picker-library-list,
.is-refined-preview .asset-picker-grid,
.is-refined-preview #asset-picker-selection-list {
  min-height: 0;
  overflow: auto;
}

.is-refined-preview .asset-picker-library-item {
  width: 100%;
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid #d7e0dc;
  border-radius: 8px;
  background: #fffefa;
  color: #43534f;
  text-align: left;
  font-size: 13px;
  font-weight: 700;
}

.is-refined-preview .asset-picker-library-item.is-active {
  border-color: #0f8f85;
  background: #f3faf7;
  color: #08766f;
}

.is-refined-preview .asset-picker-tools {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.is-refined-preview .asset-picker-tools span {
  color: #08766f;
  font-size: 12px;
  font-weight: 800;
}

.is-refined-preview .asset-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
  gap: 10px;
}

.is-refined-preview .asset-picker-card {
  display: grid;
  gap: 7px;
  padding: 8px;
  border: 1px solid #d7e0dc;
  border-radius: 8px;
  background: #fffefa;
  color: #253a35;
  text-align: left;
}

.is-refined-preview .asset-picker-card.is-selected {
  border-color: #0f8f85;
  background: #f3faf7;
  box-shadow: inset 0 0 0 2px rgba(15, 143, 133, 0.12);
}

.is-refined-preview .asset-picker-card img {
  aspect-ratio: 1 / 1;
  border-radius: 7px;
  background: #f8faf7;
}

.is-refined-preview .asset-picker-card span {
  overflow: hidden;
  color: #253a35;
  font-size: 12px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.is-refined-preview .asset-picker-selection h3 {
  margin: 0;
  color: #253a35;
  font-size: 14px;
}

.is-refined-preview .asset-picker-selected-row {
  display: grid;
  gap: 6px;
  padding: 8px;
  border: 1px solid #d7e0dc;
  border-radius: 8px;
  background: #fffefa;
}

.is-refined-preview .asset-picker-selected-row span {
  color: #08766f;
  font-size: 12px;
  font-weight: 900;
}

.is-refined-preview .asset-picker-selected-row strong {
  color: #253a35;
  font-size: 13px;
}

.is-refined-preview .asset-picker-actions {
  grid-template-columns: 1fr 1fr;
  margin-top: 0;
}

@media (max-width: 1080px) {
  .is-refined-preview .template-workspace,
  .is-refined-preview .history-workspace,
  .is-refined-preview .asset-library-workspace,
  .is-refined-preview .asset-picker-body {
    grid-template-columns: 1fr;
  }
}

/* ===== 系统配置页签 ===== */
.is-refined-preview .system-config-view {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
  min-height: 0;
}

.system-config-workspace {
  display: grid;
  grid-template-columns: minmax(340px, 34%) minmax(620px, 1fr);
  gap: 12px;
  padding: 12px;
}

.system-config-list-panel,
.system-config-detail {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 12px;
}

.system-config-editor {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.system-config-editor label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

.system-config-editor .wide-field {
  grid-column: 1 / -1;
}

.system-config-empty {
  color: var(--muted);
  font-size: 14px;
  padding: 24px 6px;
}

.provider-status-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.provider-status-badge,
.provider-item-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: #0f8f85;
  background: #e7f7f2;
  border: 1px solid rgba(15, 143, 133, 0.35);
}

.provider-item-badge {
  margin-top: 4px;
  justify-self: start;
}

.field-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.form-message.is-success {
  color: #10b981;
}

.form-message.is-error {
  color: #ef4444;
}

/* Responsive */
@media (max-width: 768px) {
  .system-config-workspace {
    grid-template-columns: 1fr;
    padding: 20px 16px;
  }
}

/* 用户菜单 / 登录 / 用户管理 */
.is-refined-preview .user-menu {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.is-refined-preview .user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 42px;
  padding: 0 12px;
  border: 1px solid #d7e0dc;
  border-radius: 999px;
  background: #fffefa;
  box-shadow: 0 6px 18px rgba(28, 43, 38, 0.045);
  cursor: pointer;
  transition: border-color 160ms ease, background-color 160ms ease, box-shadow 160ms ease;
}

.is-refined-preview .user-chip:hover,
.is-refined-preview .user-chip[aria-expanded="true"] {
  border-color: rgba(15, 143, 133, 0.46);
  background: #f6fffb;
  box-shadow: 0 0 0 3px rgba(15, 143, 133, 0.1);
}

.is-refined-preview .user-chip-caret {
  width: 0;
  height: 0;
  margin-left: 2px;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid #5b6b66;
  transition: transform 160ms ease;
}

.is-refined-preview .user-chip[aria-expanded="true"] .user-chip-caret {
  transform: rotate(180deg);
}

.is-refined-preview .user-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 80;
  min-width: 168px;
  display: grid;
  gap: 2px;
  padding: 6px;
  border: 1px solid #d7e0dc;
  border-radius: 12px;
  background: #fffefa;
  box-shadow: 0 18px 44px rgba(18, 32, 29, 0.18);
}

.is-refined-preview .user-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #233633;
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: background-color 140ms ease, color 140ms ease;
}

.is-refined-preview .user-dropdown-item:hover {
  background: #eef5f2;
}

.is-refined-preview .user-dropdown-item.is-danger {
  color: #c0392b;
}

.is-refined-preview .user-dropdown-item.is-danger:hover {
  background: #fdecea;
}

.is-refined-preview .login-captcha-row {
  display: flex;
  gap: 10px;
  align-items: stretch;
}

.is-refined-preview .login-captcha-row input {
  flex: 1 1 auto;
  min-width: 0;
}

.is-refined-preview .login-captcha-image {
  flex: 0 0 auto;
  width: 132px;
  height: 44px;
  padding: 0;
  border: 1px solid #d7e0dc;
  border-radius: 10px;
  background: #eef3f1;
  cursor: pointer;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.is-refined-preview .login-captcha-image svg {
  display: block;
  width: 100%;
  height: 100%;
}

.change-password-dialog {
  display: grid;
  gap: 14px;
  text-align: left;
}

.is-refined-preview .user-avatar {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: #16766d;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.is-refined-preview .user-chip-copy {
  display: grid;
  line-height: 1.15;
}

.is-refined-preview .user-chip-copy strong {
  color: #182b28;
  font-size: 13px;
  font-weight: 800;
}

.is-refined-preview .user-chip-copy small {
  color: #73827c;
  font-size: 11px;
}

.is-refined-preview .settings-subtabs {
  display: flex;
  gap: 8px;
  padding: 12px 12px 0;
}

.is-refined-preview .settings-subtab {
  appearance: none;
  border: 1px solid #d7e0dc;
  background: #fffefa;
  color: #36534d;
  font-size: 13px;
  font-weight: 700;
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
  transition: border-color 160ms ease, background-color 160ms ease, color 160ms ease;
}

.is-refined-preview .settings-subtab:hover {
  border-color: rgba(15, 143, 133, 0.46);
  background: #f6fffb;
}

.is-refined-preview .settings-subtab.is-active {
  background: #16766d;
  border-color: #16766d;
  color: #fff;
}

.is-refined-preview .user-item-badge {
  display: inline-flex;
  align-items: center;
  margin-top: 4px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  justify-self: start;
}

.is-refined-preview .user-item-badge.is-admin {
  color: #0f8f85;
  background: #e7f7f2;
  border: 1px solid rgba(15, 143, 133, 0.35);
}

.is-refined-preview .user-item-badge.is-user {
  color: #5b6b66;
  background: #eef2f0;
  border: 1px solid #d7e0dc;
}

.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(155deg, #eaf4f0 0%, #dcefe8 48%, #cfe7df 100%);
}

/* 鉴权结果未确定前：用与登录页同色的不透明遮罩盖住主界面，避免首页一闪 */
body.auth-pending .app-shell {
  visibility: hidden;
}

body.auth-pending::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 150;
  background: linear-gradient(155deg, #eaf4f0 0%, #dcefe8 48%, #cfe7df 100%);
}

.login-card {
  width: min(380px, 100%);
  display: grid;
  gap: 16px;
  padding: 28px;
  border-radius: 18px;
  background: #fffefa;
  border: 1px solid #e1e8e4;
  box-shadow: 0 30px 80px rgba(18, 32, 29, 0.28);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.login-brand .brand-glyph {
  width: 30px;
  height: 30px;
  color: #16766d;
}

.login-brand-copy {
  display: grid;
  line-height: 1.25;
}

.login-brand-copy strong {
  color: #182b28;
  font-size: 18px;
  font-weight: 850;
}

.login-brand-copy small {
  color: #73827c;
  font-size: 12px;
}

.login-field {
  display: grid;
  gap: 6px;
  color: #36534d;
  font-size: 13px;
  font-weight: 600;
}

.login-field input {
  height: 42px;
  padding: 0 12px;
  border: 1px solid #d7e0dc;
  border-radius: 10px;
  background: #fff;
  font-size: 14px;
  color: #182b28;
}

.login-field input:focus-visible {
  outline: none;
  border-color: #16766d;
  box-shadow: 0 0 0 3px rgba(22, 118, 109, 0.16);
}

.login-message {
  margin: 0;
  color: #ef4444;
  font-size: 13px;
}

.login-submit {
  width: 100%;
  justify-content: center;
  height: 44px;
}

.is-refined-preview .option-chip:disabled {
  opacity: 0.42;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.is-refined-preview .option-chip:disabled:hover {
  transform: none;
  border-color: #d7e0dc;
  background: #ffffff;
}

.is-refined-preview .field-hint {
  display: block;
  margin-top: 6px;
  color: #7a8799;
  font-size: 11px;
}

.is-refined-preview .batch-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
  padding: 10px;
  border: 1px solid #dce4df;
  border-radius: 10px;
  background: #fbfcf8;
}

.is-refined-preview .batch-item {
  position: relative;
  width: 96px;
  height: 96px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 8px;
  overflow: hidden;
  background: #eef2ef;
  cursor: pointer;
  transition: border-color 140ms ease, transform 140ms ease;
}

.is-refined-preview .batch-item:hover:not(:disabled) {
  transform: translateY(-1px);
}

.is-refined-preview .batch-item:disabled {
  cursor: default;
}

.is-refined-preview .batch-item.is-active {
  border-color: rgba(22, 118, 109, 0.7);
  box-shadow: 0 0 0 2px rgba(22, 118, 109, 0.18);
}

.is-refined-preview .batch-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.is-refined-preview .batch-item .batch-item-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 6px;
  background: rgba(247, 250, 248, 0.92);
  color: #5a6c67;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
  line-height: 1.4;
}

.is-refined-preview .batch-item.is-running .batch-item-state::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 3px;
  background: linear-gradient(90deg, rgba(22, 118, 109, 0), rgba(22, 118, 109, 0.65), rgba(22, 118, 109, 0));
  animation: batch-running-sweep 1.4s ease-in-out infinite;
}

@keyframes batch-running-sweep {
  0% { transform: translateX(-60%); }
  100% { transform: translateX(60%); }
}

.is-refined-preview .batch-item.is-failed .batch-item-state {
  color: #b3392f;
  background: rgba(252, 243, 241, 0.95);
}

.is-refined-preview .batch-item .batch-item-label {
  position: absolute;
  left: 5px;
  top: 5px;
  z-index: 1;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: rgba(13, 20, 30, 0.66);
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}

.is-refined-preview .mask-editor-dialog {
  width: min(1280px, calc(100vw - 48px));
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px;
  border: 1px solid #dce4df;
  border-radius: 8px;
  background: #fffefd;
  box-shadow: 0 28px 70px rgba(17, 28, 25, 0.22);
}

.is-refined-preview .mask-editor-heading {
  margin-bottom: 0;
}

.is-refined-preview .mask-editor-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 16px;
  min-height: 0;
}

.is-refined-preview .mask-canvas-wrap {
  display: grid;
  place-items: center;
  min-height: 320px;
  max-height: calc(100vh - 220px);
  padding: 12px;
  border: 1px solid #dce4df;
  border-radius: 8px;
  background:
    repeating-conic-gradient(#f1f4f1 0% 25%, #ffffff 0% 50%) 0 0 / 22px 22px;
  overflow: auto;
}

.is-refined-preview .mask-canvas-wrap canvas {
  max-width: 100%;
  max-height: calc(100vh - 250px);
  border-radius: 6px;
  box-shadow: 0 10px 28px rgba(17, 28, 25, 0.16);
  cursor: crosshair;
  touch-action: none;
}

.is-refined-preview .mask-editor-controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.is-refined-preview .mask-brush-field,
.is-refined-preview .mask-prompt-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: #344743;
  font-size: 12px;
  font-weight: 700;
}

.is-refined-preview .mask-brush-field input[type="range"] {
  width: 100%;
  accent-color: #16766d;
}

.is-refined-preview .mask-prompt-field textarea {
  width: 100%;
  resize: vertical;
  min-height: 96px;
  padding: 10px;
  border: 1px solid #d7e0dc;
  border-radius: 8px;
  background: #fffefa;
  color: #182b28;
  font-size: 13px;
  line-height: 1.55;
  font-family: inherit;
}

.is-refined-preview .mask-prompt-field textarea:focus-visible {
  outline: none;
  border-color: #16766d;
  box-shadow: 0 0 0 3px rgba(22, 118, 109, 0.16);
}

.is-refined-preview .mask-tool-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.is-refined-preview .mask-editor-meta {
  min-height: 18px;
  color: #7a8799;
  font-size: 12px;
  line-height: 1.5;
}

.is-refined-preview .mask-editor-actions {
  margin-top: auto;
}

@media (max-width: 980px) {
  .is-refined-preview .mask-editor-body {
    grid-template-columns: minmax(0, 1fr);
  }

  .is-refined-preview .mask-canvas-wrap {
    max-height: 52vh;
  }

  .is-refined-preview .mask-canvas-wrap canvas {
    max-height: 48vh;
  }
}

.is-refined-preview .features-workspace {
  display: block;
}

.is-refined-preview .features-panel {
  max-width: 720px;
}

.is-refined-preview .feature-toggle-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 14px 0;
}

.is-refined-preview .feature-toggle {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid #dce4df;
  border-radius: 10px;
  background: #fffefa;
  cursor: pointer;
  transition: border-color 140ms ease, background-color 140ms ease;
}

.is-refined-preview .feature-toggle:hover {
  border-color: rgba(22, 118, 109, 0.4);
  background: #f8fbf8;
}

.is-refined-preview .feature-toggle input[type="checkbox"] {
  margin-top: 2px;
  flex: none;
}

.is-refined-preview .feature-toggle-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.is-refined-preview .feature-toggle-copy strong {
  color: #182b28;
  font-size: 13px;
  font-weight: 750;
}

.is-refined-preview .feature-toggle-copy small {
  color: #7a8799;
  font-size: 12px;
  line-height: 1.5;
}
