:root {
  --bg: #111216;
  --panel: #17191f;
  --panel-2: #1d2028;
  --text: #eceef5;
  --muted: #a9adbb;
  --accent: #8fe9d2;
  --border: #2a2f3a;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-full: 999px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: radial-gradient(circle at 20% 20%, #1d2230 0%, var(--bg) 40%), var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  padding: 18px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

#projectSelect {
  min-width: 160px;
}

#renameProjectBtn,
#deleteProjectBtn {
  white-space: nowrap;
}

#azureProfileSelect {
  min-width: 180px;
}

.brand {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.4px;
}

.stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 24px;
}

.hero {
  text-align: center;
  color: var(--muted);
}

.hero h1 {
  color: var(--text);
  margin: 16px 0 6px;
}

.orb {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-md);
  margin: 0 auto;
  background: conic-gradient(from 120deg, #8fe9d2, #7ec8ff, #8fe9d2);
  animation: spin 4s linear infinite;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

@keyframes shimmer {
  0% {
    background-position: -1000px 0;
  }
  100% {
    background-position: 1000px 0;
  }
}

.result-grid {
  width: min(1100px, 100%);
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}

.gallery-selection-toolbar {
  width: 100%;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.gallery-selection-toolbar[hidden] {
  display: none;
}

.gallery-selection-toolbar .gallery-selection-status {
  margin-right: auto;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: rgba(23, 25, 31, 0.92);
}

.gallery-selection-toolbar .gallery-selection-actions {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: rgba(23, 25, 31, 0.92);
}

.gallery-selection-status {
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
}

.gallery-selection-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.result-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  position: relative;
}

.result-card img {
  width: 100%;
  height: 240px;
  object-fit: cover;
  display: block;
  cursor: zoom-in;
}

.result-card--selectable img {
  cursor: pointer;
}

.result-card--selected {
  border-color: rgba(143, 233, 210, 0.95);
  box-shadow: 0 0 0 2px rgba(143, 233, 210, 0.18);
}

.result-card-select-toggle {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 3;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  background: rgba(10, 14, 20, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.14);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.result-card-select-toggle input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: #8fe9d2;
}

/* 加载中状态 */
.result-card--loading img {
  background: linear-gradient(
    90deg,
    var(--panel-2) 0%,
    var(--panel) 20%,
    var(--panel-2) 40%,
    var(--panel-2) 100%
  );
  background-size: 1000px 100%;
  animation: shimmer 2s infinite;
  opacity: 0.6;
}

.result-card--loading .result-loading-spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  margin-left: -16px;
  margin-top: -16px;
  z-index: 10;
}

.result-loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(159, 233, 210, 0.2);
  border-top-color: #8fe9d2;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* 错误状态 */
.result-card--error {
  border-color: #ff6b6b;
  background: rgba(255, 107, 107, 0.05);
}

.result-card--error img {
  background: linear-gradient(135deg, var(--panel-2) 0%, #ff6b6b15 100%);
  opacity: 0.3;
}

.result-card--error .result-error-badge {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 10;
  text-align: center;
}

.result-error-badge {
  color: #ff6b6b;
  font-size: 14px;
  font-weight: 600;
  max-width: 80%;
}

.result-meta {
  padding: 10px 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.result-card-actions {
  padding: 0 12px 12px;
  display: flex;
  justify-content: flex-end;
}

.result-card-delete-btn {
  color: #ffb0b0;
  border-color: rgba(255, 107, 107, 0.35);
  background: rgba(255, 107, 107, 0.08);
}

.result-card-delete-btn:hover {
  border-color: rgba(255, 107, 107, 0.6);
  background: rgba(255, 107, 107, 0.14);
}

.ghost-btn.is-active {
  border-color: rgba(143, 233, 210, 0.8);
  background: rgba(143, 233, 210, 0.12);
  color: var(--text);
}

.prompt-dock {
  position: sticky;
  bottom: 0;
  background: linear-gradient(180deg, rgba(17, 18, 22, 0.1), rgba(17, 18, 22, 0.95) 35%);
  padding: 10px 14px 12px;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.usage-row {
  width: min(1100px, 100%);
  margin: 0 auto 8px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.status-cluster {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-full);
  background: rgba(22, 25, 32, 0.72);
  color: var(--muted);
  white-space: nowrap;
}

.status-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex: 0 0 auto;
}

.input-panel {
  width: min(1100px, 100%);
  margin: 0 auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 12px 12px;
  display: grid;
  gap: 10px;
}

.composer-row {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.composer-aside {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.reference-panel,
.mask-editor-panel {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0 10px;
}

.mask-editor-panel {
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  margin-top: 8px;
}

.mask-editor-header {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 12px;
  flex-wrap: wrap;
}

.mask-editor-copy {
  display: grid;
  gap: 4px;
}

.mask-editor-copy strong {
  font-size: 14px;
}

.mask-editor-copy span {
  font-size: 12px;
  color: var(--muted);
}

.mask-editor-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.mask-editor-brush {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.mask-editor-brush strong {
  color: var(--text);
  font-size: 14px;
}

.mask-editor-toolbar input[type="range"] {
  width: min(260px, 44vw);
}

.mask-editor-canvas-wrap {
  position: relative;
  width: min(100%, 960px);
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #0f131a;
  margin: 0 auto;
}

.mask-editor-canvas-wrap img,
.mask-editor-canvas-wrap canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: none;
  touch-action: none;
}

.mask-editor-canvas-wrap img {
  position: absolute;
  inset: 0;
  object-fit: contain;
  object-position: center;
  pointer-events: none;
}

.mask-editor-canvas-wrap canvas {
  position: absolute;
  inset: 0;
  z-index: 2;
  height: 100%;
  opacity: 0.42;
}

.mask-brush-cursor {
  position: absolute;
  left: 0;
  top: 0;
  width: 20px;
  height: 20px;
  margin-left: -10px;
  margin-top: -10px;
  border: 1.5px solid rgba(255, 255, 255, 0.95);
  background: rgba(255, 96, 96, 0.16);
  border-radius: var(--radius-full);
  pointer-events: none;
  z-index: 4;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35);
}

.mask-brush-cursor.is-eraser {
  border-style: dashed;
  border-color: rgba(173, 223, 255, 0.95);
  background: rgba(135, 206, 250, 0.14);
}

.mask-editor-hint {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  text-align: center;
  color: rgba(236, 238, 245, 0.72);
  font-size: 13px;
  background: linear-gradient(135deg, rgba(15, 19, 26, 0.5), rgba(15, 19, 26, 0.82));
  pointer-events: none;
  z-index: 3;
}

#imageInput {
  display: none;
}

.upload-btn {
  color: var(--text);
  border-color: #3b4452;
  background: linear-gradient(120deg, #242b36, #1e2530);
  font-weight: 600;
}

.reference-preview {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: #141821;
  padding: 6px;
  min-width: 280px;
}

.reference-preview-list {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  padding: 0 0 2px;
  overflow-x: auto;
  overflow-y: hidden;
  min-height: 0;
}

.reference-preview-stack {
  position: relative;
  width: 88px;
  height: 96px;
  padding: 0;
  overflow: visible;
  display: block;
}

.reference-preview-stack[hidden] {
  display: none;
}

.reference-preview-stack .reference-preview-item {
  position: absolute;
  top: 0;
  left: calc(var(--stack-index, 0) * var(--stack-step, 0px));
  width: 72px;
  flex: 0 0 72px;
  height: 96px;
  transition: transform 160ms ease, left 180ms ease, box-shadow 180ms ease, border-color 160ms ease, opacity 160ms ease;
  box-shadow: 0 1px 5px rgba(5, 8, 15, 0.13);
  z-index: calc(20 - var(--stack-index, 0));
}

.reference-preview-stack:hover .reference-preview-item,
.reference-preview-stack:focus-within .reference-preview-item {
  left: calc(var(--stack-index, 0) * 66px);
  box-shadow: 0 10px 26px rgba(5, 8, 15, 0.22);
}

.reference-preview-stack .reference-preview-item:hover,
.reference-preview-stack .reference-preview-item:focus-within {
  transform: translateY(-4px);
  z-index: 40;
}

.reference-preview-stack .reference-preview-item:nth-child(n + 6):not(.reference-preview-add) {
  opacity: 0;
  pointer-events: none;
}

.reference-preview-stack:hover .reference-preview-item:nth-child(n + 6):not(.reference-preview-add),
.reference-preview-stack:focus-within .reference-preview-item:nth-child(n + 6):not(.reference-preview-add) {
  opacity: 1;
  pointer-events: auto;
}

.reference-preview-add {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px dashed rgba(255, 255, 255, 0.18) !important;
  background: rgba(22, 26, 34, 0.6);
  cursor: pointer;
  box-shadow: none;
  border-radius: var(--radius-md);
}

.reference-preview-add-btn {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  padding: 0;
  background: transparent;
  color: rgba(236, 238, 245, 0.45);
  cursor: pointer;
  transition: color 140ms ease;
}

.reference-preview-add-btn:hover {
  color: rgba(236, 238, 245, 0.85);
}

.reference-preview-item {
  position: relative;
  width: 72px;
  flex: 0 0 72px;
  height: 96px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #141821;
  -webkit-user-select: none;
  user-select: none;
  cursor: grab;
}

.reference-preview-item.is-dragging {
  opacity: 0.55;
  transform: scale(0.98);
}

.reference-preview-item.is-drop-target {
  border-color: rgba(143, 233, 210, 0.88);
  box-shadow: 0 0 0 1px rgba(143, 233, 210, 0.18) inset;
}

.reference-preview-open {
  position: relative;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: zoom-in;
  display: block;
}

.reference-preview-delete {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 2;
  width: 24px;
  height: 24px;
  padding: 0;
  border-radius: var(--radius-full);
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(10, 14, 20, 0.86);
  color: var(--text);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.reference-preview-delete:hover {
  background: rgba(255, 107, 107, 0.22);
  border-color: rgba(255, 107, 107, 0.55);
}

.reference-preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.reference-preview-stack .reference-index-badge,
.reference-preview-stack .reference-preview-delete {
  opacity: 0;
  transition: opacity 120ms ease;
}

.reference-preview-stack:hover .reference-preview-item:hover .reference-index-badge,
.reference-preview-stack:hover .reference-preview-item:hover .reference-preview-delete {
  opacity: 1;
}

.reference-preview-item .reference-index-badge {
  position: absolute;
  top: 6px;
  left: 6px;
  min-width: 24px;
  height: 24px;
  border-radius: var(--radius-full);
  background: rgba(10, 14, 20, 0.86);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid rgba(255, 255, 255, 0.12);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.reference-preview-item .reference-preview-item-meta {
  padding: 6px 7px 7px;
  display: grid;
  gap: 2px;
}

.reference-preview-item .reference-preview-item-meta strong {
  font-size: 11px;
  color: var(--text);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reference-preview-item .reference-preview-item-meta span {
  font-size: 10px;
  color: var(--muted);
}

#maskPreview img {
  width: 46px;
  height: 46px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  flex: 0 0 auto;
}

textarea {
  width: 100%;
  min-height: 64px;
  max-height: 160px;
  resize: vertical;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--text);
  font-size: 15px;
  padding: 2px 0;
}

textarea::-webkit-scrollbar {
  width: 8px;
}

textarea::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-full);
}

textarea::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(143, 233, 210, 0.75), rgba(116, 183, 255, 0.6));
  border: 2px solid transparent;
  border-radius: var(--radius-full);
  background-clip: content-box;
}

textarea::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, rgba(143, 233, 210, 0.95), rgba(116, 183, 255, 0.85));
  background-clip: content-box;
}

.controls {
  display: grid;
  grid-template-columns: 1fr auto auto auto auto auto;
  gap: 6px;
  align-items: center;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

.controls select,
.controls input,
.controls button {
  min-width: 0;
}

.icon-btn {
  display: inline-flex !important;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.gen-settings-btn {
  justify-content: flex-start;
  overflow: hidden;
  gap: 6px;
  min-width: 0;
  max-width: 100%;
}

.gen-settings-btn span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  opacity: 0.85;
}

/* ── 生成设置面板 ──────────────────────────────────────────────── */

.gen-settings-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.gen-settings-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.gen-settings-row label {
  width: 70px;
  flex-shrink: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.gen-settings-row select,
.gen-settings-row input[type="number"] {
  flex: 1;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
}

.gen-settings-row .size-input-group {
  display: flex;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.gen-settings-row .size-input-group select {
  flex: 3;
  min-width: 0;
}

.gen-settings-row .size-input-group input {
  flex: 1;
  min-width: 60px;
}

.icon-svg {
  width: 16px;
  height: 16px;
  display: inline-block;
  flex: 0 0 auto;
}

.compact-controls .ghost-btn {
  white-space: nowrap;
}

#openMaskEditorBtn,
#runBtn {
  white-space: nowrap;
  flex: 0 0 auto;
}

#customSize {
  min-width: 50px;
}

#openMaskEditorBtn {
  min-width: 0;
}

#runBtn {
  min-width: 4.8em;
}

select,
input,
button {
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  padding: 8px 10px;
}

.primary-btn {
  background: linear-gradient(120deg, #65d8bc, #74b7ff);
  border: 0;
  color: #10141c;
  font-weight: 700;
  cursor: pointer;
}

.ghost-btn {
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.ghost-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.danger-btn {
  border-color: #5b2a34;
  color: #ffb7c3;
}

dialog {
  border: 0;
  border-radius: var(--radius-md);
  width: min(560px, 92vw);
  background: var(--panel);
  color: var(--text);
}

dialog::backdrop {
  background: rgba(6, 8, 12, 0.72);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.mask-dialog {
  width: min(1080px, 96vw);
  background: transparent;
  padding: 0;
}

.snippet-dialog {
  width: min(1180px, 98vw);
  max-width: 98vw;
  max-height: 90vh;
  background: transparent;
  padding: 0;
}

.transfer-dialog {
  width: min(460px, 92vw);
  background: transparent;
  padding: 0;
}

.snippet-shell {
  background: linear-gradient(180deg, rgba(20, 23, 30, 0.98), rgba(15, 18, 24, 0.98));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  width: 100%;
  box-sizing: border-box;
  max-height: 90vh;
  overflow: hidden;
}

.transfer-shell {
  background: linear-gradient(180deg, rgba(20, 23, 30, 0.98), rgba(15, 18, 24, 0.98));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

.snippet-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}

.snippet-header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.snippet-header-actions button {
  white-space: nowrap;
}

.snippet-header h3 {
  margin: 0 0 6px;
}

.snippet-header p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.snippet-layout {
  display: grid;
  grid-template-columns: minmax(360px, 460px) minmax(0, 1fr);
  gap: 14px;
  min-width: 0;
}

.snippet-list {
  display: block;
  max-height: min(60vh, 560px);
  overflow: auto;
  padding-right: 4px;
  min-width: 0;
}

.snippet-browser {
  display: grid;
  grid-template-columns: minmax(150px, 190px) minmax(0, 1fr);
  gap: 12px;
  min-width: 0;
}

.snippet-category-list,
.snippet-item-list {
  display: grid;
  gap: 10px;
}

.snippet-category-list {
  align-content: start;
  max-height: min(60vh, 560px);
  overflow: auto;
  padding-right: 4px;
  min-width: 180px;
}

.snippet-category-item {
  text-align: left;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--panel-2);
  display: grid;
  gap: 4px;
  cursor: pointer;
}

.snippet-category-item strong {
  font-size: 14px;
}

.snippet-category-item span {
  color: var(--muted);
  font-size: 12px;
}

.snippet-category-item.is-active {
  border-color: rgba(143, 233, 210, 0.85);
  background: rgba(143, 233, 210, 0.1);
}

.snippet-item-list {
  align-content: start;
  max-height: min(60vh, 560px);
  overflow: auto;
  padding-right: 4px;
  min-width: 0;
}

.snippet-list::-webkit-scrollbar,
.snippet-category-list::-webkit-scrollbar,
.snippet-item-list::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.snippet-list::-webkit-scrollbar-track,
.snippet-category-list::-webkit-scrollbar-track,
.snippet-item-list::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-full);
}

.snippet-list::-webkit-scrollbar-thumb,
.snippet-category-list::-webkit-scrollbar-thumb,
.snippet-item-list::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(143, 233, 210, 0.85), rgba(143, 233, 210, 0.45));
  border-radius: var(--radius-full);
  border: 2px solid rgba(15, 18, 24, 0.95);
}

.snippet-list::-webkit-scrollbar-thumb:hover,
.snippet-category-list::-webkit-scrollbar-thumb:hover,
.snippet-item-list::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, rgba(143, 233, 210, 1), rgba(143, 233, 210, 0.6));
}

.snippet-empty-state,
.snippet-list-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--panel-2);
}

.snippet-empty-state {
  padding: 14px;
  color: var(--muted);
  font-size: 13px;
}

.snippet-list-item {
  text-align: left;
  padding: 12px;
  cursor: pointer;
  display: grid;
  gap: 6px;
}

.snippet-list-item strong {
  font-size: 14px;
}

.snippet-list-item span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.snippet-list-item.is-active {
  border-color: rgba(143, 233, 210, 0.85);
  background: rgba(143, 233, 210, 0.1);
}

.snippet-editor {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.snippet-language-hint {
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  background: rgba(255, 255, 255, 0.02);
}

.snippet-bilingual-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.snippet-bilingual-fields textarea {
  min-height: 180px;
}

@media (max-width: 860px) {
  .snippet-dialog {
    width: min(96vw, 980px);
  }

  .snippet-header {
    flex-wrap: wrap;
  }

  .snippet-browser {
    grid-template-columns: 1fr;
  }

  .snippet-layout {
    grid-template-columns: 1fr;
  }

  .snippet-list,
  .snippet-category-list {
    min-width: 0;
  }
}

.transfer-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}

.transfer-header h3 {
  margin: 0 0 6px;
}

.transfer-header p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.transfer-field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.transfer-field select {
  width: 100%;
}

.transfer-dialog .dialog-actions {
  margin-top: 14px;
}

.snippet-editor {
  display: grid;
  gap: 12px;
}

.snippet-editor textarea {
  min-height: 260px;
}

.snippet-list::-webkit-scrollbar,
.snippet-category-list::-webkit-scrollbar,
.snippet-item-list::-webkit-scrollbar,
.snippet-editor textarea::-webkit-scrollbar,
.snippet-bilingual-fields textarea::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

.snippet-list::-webkit-scrollbar-track,
.snippet-category-list::-webkit-scrollbar-track,
.snippet-item-list::-webkit-scrollbar-track,
.snippet-editor textarea::-webkit-scrollbar-track,
.snippet-bilingual-fields textarea::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-full);
}

.snippet-list::-webkit-scrollbar-thumb,
.snippet-category-list::-webkit-scrollbar-thumb,
.snippet-item-list::-webkit-scrollbar-thumb,
.snippet-editor textarea::-webkit-scrollbar-thumb,
.snippet-bilingual-fields textarea::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(143, 233, 210, 0.95), rgba(116, 183, 255, 0.8));
  border: 2px solid rgba(20, 23, 30, 0.9);
  border-radius: var(--radius-full);
}

.snippet-list::-webkit-scrollbar-thumb:hover,
.snippet-category-list::-webkit-scrollbar-thumb:hover,
.snippet-item-list::-webkit-scrollbar-thumb:hover,
.snippet-editor textarea::-webkit-scrollbar-thumb:hover,
.snippet-bilingual-fields textarea::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, rgba(143, 233, 210, 1), rgba(116, 183, 255, 0.95));
}

.snippet-footer-actions {
  justify-content: flex-end;
}

.snippet-footer-actions button {
  min-width: 9.5em;
}

.preview-actions {
  margin-top: 12px;
  justify-content: flex-start;
}

.mask-dialog-shell {
  background: linear-gradient(180deg, rgba(20, 23, 30, 0.98), rgba(15, 18, 24, 0.98));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  max-height: 88vh;
  overflow: auto;
}

.settings-panel {
  display: grid;
  gap: 10px;
  padding: 16px;
  min-width: 0;
  max-height: 88vh;
  overflow-x: hidden;
  overflow-y: auto;
}

.settings-panel::-webkit-scrollbar {
  width: 10px;
}

.settings-panel::-webkit-scrollbar-track {
  background: rgba(14, 18, 24, 0.7);
  border-radius: var(--radius-full);
}

.settings-panel::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(143, 233, 210, 0.75), rgba(116, 183, 255, 0.75));
  border: 2px solid rgba(14, 18, 24, 0.7);
  border-radius: var(--radius-full);
}

.settings-panel::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, rgba(143, 233, 210, 0.95), rgba(116, 183, 255, 0.95));
}

.settings-panel label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

.settings-panel > label > input,
.settings-panel > label > select,
.settings-panel > label > textarea,
.azure-profile-manager select {
  width: 100%;
  min-width: 0;
}

.azure-profile-manager {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.02);
}

.azure-profile-manager-header {
  display: grid;
  gap: 4px;
}

.azure-profile-manager-header strong {
  color: var(--text);
  font-size: 14px;
}

.azure-profile-manager-header span {
  color: var(--muted);
  font-size: 12px;
}

.azure-profile-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.azure-profile-actions button,
.settings-inline-actions button {
  flex: 1 1 0;
  min-width: 0;
}

.azure-profile-note {
  margin-top: -2px;
  margin-bottom: 2px;
  font-size: 12px;
  color: var(--muted);
}

.settings-inline-actions {
  display: flex;
  justify-content: flex-start;
  gap: 8px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.preview-dialog {
  width: min(960px, 96vw);
  background: #0f131b;
  border: 1px solid #293142;
  padding: 0;
}

.preview-shell {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.preview-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 10px;
}

.preview-header h3 {
  margin: 0;
}

.preview-header p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.preview-stage {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #0b0f16;
  max-height: 70vh;
}

.preview-stage img {
  width: 100%;
  height: auto;
  max-height: 70vh;
  object-fit: contain;
  display: block;
}

.preview-meta {
  color: var(--muted);
  font-size: 12px;
}

/* ── 素材库 ────────────────────────────────────────────────── */

.material-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 10px;
  max-height: 55vh;
  overflow-y: auto;
  padding: 4px 2px;
}

.material-grid::-webkit-scrollbar {
  width: 8px;
}

.material-grid::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-full);
}

.material-grid::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(143, 233, 210, 0.75), rgba(116, 183, 255, 0.6));
  border-radius: var(--radius-full);
  border: 2px solid transparent;
  background-clip: content-box;
}

.material-item {
  position: relative;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  overflow: hidden;
  cursor: pointer;
  aspect-ratio: 1;
  background: var(--panel-2);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.material-item:hover {
  border-color: rgba(143, 233, 210, 0.7);
  box-shadow: 0 0 0 2px rgba(143, 233, 210, 0.12);
}

.material-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.material-item-delete {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  padding: 0;
  border-radius: var(--radius-full);
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(10, 14, 20, 0.85);
  color: var(--text);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  z-index: 2;
}

.material-item:hover .material-item-delete {
  display: inline-flex;
}

.material-item-delete:hover {
  background: rgba(255, 107, 107, 0.25);
  border-color: rgba(255, 107, 107, 0.5);
}

.material-empty {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 40px 20px;
}

.material-item-name {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 7px 8px 5px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.78));
  color: #fff;
  font-size: 11px;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  z-index: 1;
}

.preview-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

@media (max-width: 780px) {
  .usage-row {
    grid-template-columns: 1fr;
  }

  .status-actions {
    justify-content: flex-end;
  }

  .composer-row {
    grid-template-columns: 1fr;
  }

  .reference-preview-item {
    width: 64px;
    flex-basis: 64px;
    height: 85px;
  }

  .reference-preview-stack {
    width: 80px;
    height: 85px;
  }

  .reference-preview-stack .reference-preview-item {
    left: calc(var(--stack-index, 0) * var(--stack-step, 0px));
    width: 64px;
    flex-basis: 64px;
    height: 85px;
  }

  .reference-preview-stack:hover .reference-preview-item,
  .reference-preview-stack:focus-within .reference-preview-item {
    left: calc(var(--stack-index, 0) * 58px);
    box-shadow: 0 8px 20px rgba(5, 8, 15, 0.22);
  }

  .controls {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .controls .primary-btn,
  .controls button {
    grid-column: span 1;
  }
}
