/* ═══════════════════════════════════════
   USER.CSS — 用户端专属样式
   放置在 app.css 之后加载
   ═══════════════════════════════════════ */

/* ── Page Header ── */
.page-hd {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: clamp(10px, 1.2vw, 16px);
  margin-bottom: clamp(16px, 2vw, 24px);
}

.page-hd p {
  margin: 0;
  font-size: clamp(12px, 1.4vw, 14px);
  color: var(--text-muted);
  font-weight: 600;
}

.page-hd h1 {
  margin: 2px 0 0;
  font-size: clamp(22px, 3vw, 32px);
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
}

.page-hd-actions {
  display: flex;
  align-items: center;
  gap: clamp(8px, 1vw, 14px);
  flex-shrink: 0;
}

.canvas-project-titlebar {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.canvas-project-titlebox {
  display: grid;
  gap: 6px;
  min-width: min(100%, 320px);
}

.canvas-project-titlebox span {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
}

.canvas-project-titlebox input {
  width: min(100%, 360px);
  height: 42px;
  padding: 0 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--main-surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  outline: none;
  transition: border-color var(--duration-fast) var(--ease-out-expo), box-shadow var(--duration-fast) var(--ease-out-expo);
}

.canvas-project-titlebox input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-glow);
}

.canvas-project-save-state {
  min-height: 20px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.12);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
}

.canvas-project-save-state.is-pending {
  background: rgba(245, 158, 11, 0.14);
  color: #b45309;
}

.canvas-project-save-state.is-saving {
  background: rgba(59, 130, 246, 0.14);
  color: #1d4ed8;
}

.canvas-project-save-state.is-saved {
  background: rgba(16, 185, 129, 0.14);
  color: #047857;
}

.canvas-project-save-state.is-error {
  background: rgba(239, 68, 68, 0.12);
  color: #dc2626;
}

.badge-balance {
  display: flex;
  align-items: center;
  gap: clamp(6px, 0.8vw, 10px);
  padding: clamp(6px, 0.8vw, 10px) clamp(10px, 1.2vw, 16px);
  border-radius: var(--radius-full);
  background: var(--main-surface);
  border: 1px solid var(--line);
  text-decoration: none;
  transition: all var(--duration-fast) var(--ease-out-expo);
}

.badge-balance:hover {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.badge-balance .num {
  font-size: clamp(15px, 1.8vw, 20px);
  font-weight: 800;
  color: var(--text);
}

.badge-balance .label {
  font-size: clamp(11px, 1.3vw, 13px);
  color: var(--text-muted);
  font-weight: 600;
}

/* ── Grid layouts ── */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(16px, 2vw, 24px);
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: clamp(14px, 1.6vw, 20px);
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: clamp(12px, 1.4vw, 18px);
}

.grid-auto {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr));
  gap: clamp(12px, 1.4vw, 18px);
}

/* ── Card v3 ── */
.card-v3 {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--main-surface);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  transition: box-shadow var(--duration-normal) var(--ease-out-expo);
}

.card-v3:hover {
  box-shadow: var(--shadow);
}

.card-v3-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: clamp(10px, 1.2vw, 16px);
  padding: clamp(14px, 1.8vw, 20px) clamp(16px, 2vw, 24px);
  border-bottom: 1px solid var(--line);
  min-height: 44px;
}

.card-v3-head > div { min-width: 0; }

.card-v3-head .eyebrow {
  margin: 0;
  font-size: clamp(10px, 1.2vw, 12px);
  color: var(--text-muted);
  font-weight: 700;
  letter-spacing: 0.03em;
}

.card-v3-head h3 {
  margin: 2px 0 0;
  font-size: clamp(15px, 1.8vw, 19px);
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.01em;
}

.card-v3-body {
  padding: clamp(14px, 1.8vw, 22px) clamp(16px, 2vw, 24px);
}

/* ── Mode Toggle ── */
.mode-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.mode-toggle label {
  min-height: clamp(44px, 5.5vw, 52px);
  display: grid;
  place-items: center;
  border: 1.5px solid var(--line);
  border-radius: var(--radius, 14px);
  background: var(--main-surface);
  color: var(--text-soft);
  font-weight: 750;
  font-size: clamp(13px, 1.5vw, 15px);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out-expo);
  padding: 0 clamp(12px, 1.4vw, 16px);
}

.mode-toggle label:hover {
  border-color: rgba(59,130,246,0.5);
  background: var(--primary-soft);
  color: var(--primary);
}

.mode-toggle input { display: none; }

.mode-toggle label:has(input:checked),
.mode-toggle label.active {
  border-color: var(--primary);
  background: linear-gradient(135deg, var(--primary-soft), transparent);
  color: var(--primary-dark);
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.1);
}

/* ── Media Card (Gallery) ── */
.media-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--main-surface);
  overflow: hidden;
  transition: all var(--duration-normal) var(--ease-out-expo);
}

.media-card:hover {
  border-color: var(--primary-soft);
  box-shadow: 0 4px 16px var(--primary-glow);
  transform: translateY(-2px);
}

.media-card img,
.media-card video {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
}

.media-card-body {
  padding: clamp(8px, 1vw, 12px) clamp(10px, 1.2vw, 14px);
}

.media-card-body .prompt {
  font-size: clamp(12px, 1.4vw, 14px);
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.media-card-body .meta {
  display: flex;
  align-items: center;
  gap: clamp(4px, 0.5vw, 8px);
  margin-top: 4px;
  font-size: clamp(10px, 1.2vw, 12px);
  color: var(--text-muted);
  font-weight: 600;
}

/* ── Status Badge ── */
.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: clamp(10px, 1.1vw, 11px);
  font-weight: 700;
  letter-spacing: 0.01em;
}

.status-badge.pending {
  background: rgba(245, 158, 11, 0.12);
  color: #b45309;
}

.status-badge.running {
  background: rgba(59, 130, 246, 0.12);
  color: #2563eb;
}

.status-badge.succeeded {
  background: rgba(16, 185, 129, 0.12);
  color: #047857;
}

.status-badge.failed {
  background: rgba(239, 68, 68, 0.1);
  color: #dc2626;
}

/* ── Upload Box ── */
.edit-upload-box {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border: 2px dashed var(--line-strong);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out-expo);
}

.edit-upload-box:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.edit-upload-box input { display: none; }

.edit-upload-box strong {
  display: block;
  font-size: 13px;
  color: var(--text);
}

.edit-upload-box small {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  color: var(--text-muted);
}

.edit-upload-icon {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--main-surface-soft);
  font-size: 20px;
  font-weight: 300;
  color: var(--text-muted);
  flex-shrink: 0;
}

.edit-upload-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.edit-upload-preview img {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
}

/* ── Pricing / Shop ── */
.price-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 24px;
  text-align: center;
  background: var(--main-surface);
  transition: all var(--duration-normal) var(--ease-out-expo);
}

.price-card:hover {
  border-color: var(--primary-soft);
  box-shadow: 0 8px 24px var(--primary-glow);
  transform: translateY(-4px);
}

.price-card .price {
  font-size: 32px;
  font-weight: 800;
  color: var(--text);
}

.price-card .price small {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
}

/* ── History ── */
.history-list {
  display: grid;
  gap: 8px;
}

.record-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--main-surface);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out-expo);
}

.record-card:hover {
  border-color: var(--primary-soft);
  background: var(--primary-soft);
}

/* ── Utility ── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  line-height: 1.5;
}

.alert.error {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.alert strong { display: block; font-weight: 700; margin-bottom: 4px; }
.alert span { opacity: 0.85; }

.hidden { display: none !important; }

/* ── User Center ── */
.uc-section {
  margin-bottom: clamp(16px, 2vw, 24px);
}

/* ── Responsive ── */
@media (max-width: 1024px) {
  .grid-2 { grid-template-columns: 1fr; }
  .chat-layout { grid-template-columns: 1fr; height: auto; }
}

@media (max-width: 640px) {
  .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .page-hd { flex-direction: column; align-items: flex-start; }
}

/* ── Button Variants ── */
.btn-primary {
  background: linear-gradient(135deg, var(--primary-light, #60a5fa), var(--primary, #3b82f6));
  color: #fff;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.22);
}
.btn-primary:hover {
  background: linear-gradient(135deg, var(--primary, #3b82f6), var(--primary-dark, #2563eb));
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.3);
  transform: translateY(-2px);
}
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  border-color: var(--line);
  background: var(--main-surface);
  color: var(--text-soft);
}
.btn-secondary:hover {
  border-color: rgba(59,130,246,0.5);
  background: var(--primary-soft);
  color: var(--primary);
}

.btn-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--text-soft);
}
.btn-ghost:hover { background: var(--main-surface-soft); }

.btn-sm {
  min-height: 30px;
  padding: 0 clamp(8px, 1vw, 14px);
  font-size: clamp(11px, 1.3vw, 13px);
}

.btn-lg {
  min-height: 48px;
  padding: 0 28px;
  font-size: 15px;
}

/* ── Edit Upload ── */
.edit-upload-field {
  display: grid;
  gap: 8px;
}

.edit-upload-field.hidden { display: none; }

/* ── Prompt Optimize ── */
.prompt-optimize-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.hint { color: var(--text-muted); font-size: 12px; }
.hint.hidden { display: none; }

/* ── Record Delete Form ── */
.record-delete-form { display: inline; }

/* ── Card v3 subtitle ── */
.card-v3-head .sub {
  margin: 0;
  font-size: clamp(10px, 1.2vw, 12px);
  color: var(--text-muted);
  font-weight: 700;
  letter-spacing: 0.03em;
}

/* ── History Empty ── */
.history-empty-inline {
  padding: 32px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
}

/* ── Chat Message Text ── */
.chat-msg-text {
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}
.chat-msg-text p { margin: 0 0 8px; }
.chat-msg-text p:last-child { margin-bottom: 0; }

/* ── Dot (typing indicator) ── */
.dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: dotPulse 1.4s infinite ease-in-out;
}
.dot:nth-child(2) { animation-delay: 0.16s; }
.dot:nth-child(3) { animation-delay: 0.32s; }
@keyframes dotPulse {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
  40% { opacity: 1; transform: scale(1); }
}

/* ── Prompt Optimize Status ── */
.hint.is-error { color: var(--danger, #ef4444); }

.btn-secondary.is-loading { pointer-events: none; opacity: 0.7; }
.field-hint {
  font-size: clamp(11px, 1.3vw, 13px);
  color: var(--text-muted);
  font-weight: 600;
}
.field-hint.hidden { display: none; }
.field-hint.is-error { color: var(--danger, #ef4444); }

/* ── Chat Model Picker (beautified) ── */
.chat-model-picker {
  border: none;
  outline: none;
  background: transparent;
  color: var(--primary, #3b82f6);
  font-size: clamp(11px, 1.3vw, 13px);
  font-weight: 700;
  cursor: pointer;
  padding: 0 16px 0 0;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23999' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 2px center;
  background-size: 10px;
}

.chat-model-picker:hover {
  color: var(--primary-dark, #2563eb);
}

.chat-model-picker option {
  color: var(--text, #1e293b);
  background: var(--main-surface, #fff);
  padding: 4px 8px;
}

/* ── Chat Input Textarea scroll fix ── */
.chat-input::-webkit-scrollbar {
  width: 4px;
}
.chat-input::-webkit-scrollbar-thumb {
  background: var(--line-strong, #cbd5e1);
  border-radius: 2px;
}

/* ── Canvas ── */
.canvas-page {
  display: grid;
  gap: 18px;
}

.canvas-layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 18px;
  min-height: calc(100vh - 180px);
}

.canvas-sidebar {
  display: grid;
  gap: 16px;
  align-content: start;
}

.canvas-sidebar-tabs {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.canvas-sidebar-tabs button {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--main-surface);
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 700;
  padding: 10px 8px;
  cursor: pointer;
}

.canvas-sidebar-tabs button.is-active {
  border-color: rgba(59,130,246,.35);
  background: var(--primary-soft);
  color: var(--primary);
}

.canvas-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--main-surface);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  display: none;
}

.canvas-panel.is-active {
  display: block;
}

.canvas-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.canvas-panel-head h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 800;
}

.canvas-panel-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.canvas-projects,
.canvas-form {
  display: grid;
  gap: 12px;
  padding: 16px 18px 18px;
}

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

.canvas-quick-node-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.canvas-quick-node-card {
  display: grid;
  gap: 4px;
  text-align: left;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--main-surface);
  cursor: pointer;
}

.canvas-quick-node-card strong {
  font-size: 13px;
  color: var(--text);
}

.canvas-quick-node-card small {
  font-size: 11px;
  color: var(--text-muted);
}

.canvas-upload-actions,
.canvas-guide-list {
  display: grid;
  gap: 8px;
}

.canvas-guide-item {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--main-surface-soft);
  font-size: 12px;
  color: var(--text-soft);
  line-height: 1.5;
}

.canvas-preset-card {
  display: grid;
  gap: 4px;
  text-align: left;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background:
    linear-gradient(135deg, rgba(59,130,246,.08), rgba(14,165,233,.04)),
    var(--main-surface);
  cursor: pointer;
  transition: transform var(--duration-fast) var(--ease-out-expo),
              border-color var(--duration-fast) var(--ease-out-expo),
              box-shadow var(--duration-fast) var(--ease-out-expo);
}

.canvas-preset-card:hover {
  transform: translateY(-1px);
  border-color: rgba(59,130,246,.35);
  box-shadow: 0 10px 24px rgba(59,130,246,.12);
}

.canvas-preset-card strong {
  font-size: 13px;
  color: var(--text);
}

.canvas-preset-card small {
  font-size: 11px;
  line-height: 1.45;
  color: var(--text-muted);
}

.canvas-project-card {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  text-decoration: none;
  color: inherit;
  background: var(--main-surface);
  transition: all var(--duration-fast) var(--ease-out-expo);
}

.canvas-project-card:hover,
.canvas-project-card.active {
  border-color: rgba(59,130,246,0.45);
  background: var(--primary-soft);
}

.canvas-project-card .thumb {
  width: 64px;
  height: 64px;
  border-radius: 12px;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, rgba(59,130,246,.12), rgba(14,165,233,.06));
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
}

.canvas-project-card .thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.canvas-project-card .meta {
  min-width: 0;
  display: grid;
  align-content: center;
  gap: 4px;
}

.canvas-project-card .meta strong {
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.canvas-project-card .meta span,
.canvas-empty {
  font-size: 11px;
  color: var(--text-muted);
}

.canvas-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.canvas-workflow-steps {
  display: grid;
  gap: 8px;
}

.canvas-workflow-step {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--main-surface-soft);
  font-size: 13px;
  font-weight: 600;
}

.canvas-task-list {
  display: grid;
  gap: 10px;
  padding: 16px 18px 18px;
}

.canvas-task-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--main-surface);
}

.canvas-task-card .top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.canvas-task-card .top strong {
  font-size: 13px;
}

.canvas-task-card .meta {
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-muted);
}

.canvas-task-card .steps {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.canvas-stage-wrap {
  min-width: 0;
  border: 1px solid rgba(15,23,42,.22);
  border-radius: 16px;
  background: #111827;
  box-shadow: var(--shadow-card);
  overflow: hidden;
  display: grid;
  grid-template-rows: auto 1fr;
}

body.canvas-immersive-active {
  overflow: hidden;
}

.canvas-stage-wrap.is-immersive {
  position: fixed;
  inset: 0;
  z-index: 1100;
  border-radius: 0;
  border: 0;
  width: 100vw;
  height: 100vh;
  max-width: none;
  box-shadow: none;
}

.canvas-stage-wrap.is-immersive .canvas-stage-shell {
  min-height: 0;
  height: 100%;
}

.canvas-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  background: rgba(15,23,42,.92);
  backdrop-filter: blur(10px);
}

.canvas-toolbar-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.canvas-node-quickbar {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border: 1px solid rgba(148,163,184,.18);
  border-radius: 12px;
  background: rgba(2,6,23,.38);
}

.canvas-node-quickbar-label {
  font-size: 11px;
  color: #cbd5e1;
  max-width: 180px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.canvas-toolbar-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-right: 4px;
}

.canvas-toolbar .btn.is-active {
  border-color: rgba(59,130,246,.45);
  background: var(--primary-soft);
  color: var(--primary);
}

.canvas-fullscreen-btn {
  height: 46px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 0 18px;
  border: 1px solid rgba(20, 184, 166, 0.26);
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.98), rgba(15, 118, 110, 0.88));
  color: #ecfeff;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.01em;
  box-shadow: 0 12px 30px rgba(13, 148, 136, 0.18);
  cursor: pointer;
  transition: transform var(--duration-fast) var(--ease-out-expo), box-shadow var(--duration-fast) var(--ease-out-expo), border-color var(--duration-fast) var(--ease-out-expo);
}

.canvas-fullscreen-btn:hover {
  transform: translateY(-1px) scale(1.01);
  border-color: rgba(94, 234, 212, 0.52);
  box-shadow: 0 16px 36px rgba(13, 148, 136, 0.26);
}

.canvas-fullscreen-btn.is-active {
  background: linear-gradient(135deg, rgba(8, 47, 73, 0.98), rgba(14, 116, 144, 0.9));
  border-color: rgba(125, 211, 252, 0.56);
}

.canvas-fullscreen-btn svg {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.canvas-upload-btn {
  position: relative;
  overflow: hidden;
}

.canvas-stage-shell {
  position: relative;
  overflow: hidden;
  min-height: 620px;
  background:
    radial-gradient(circle at top left, rgba(20,184,166,.12), transparent 24%),
    radial-gradient(circle at bottom right, rgba(148,163,184,.08), transparent 22%),
    #0b1120;
}

.canvas-stage {
  --canvas-width: 10000px;
  --canvas-height: 8000px;
  --canvas-x: 0px;
  --canvas-y: 0px;
  --canvas-scale: 1;
  position: absolute;
  inset: 0;
  overflow: hidden;
  cursor: grab;
}

.canvas-stage:active {
  cursor: grabbing;
}

.canvas-grid,
.canvas-group-layer,
.canvas-items,
.canvas-selection {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--canvas-width);
  height: var(--canvas-height);
  transform: translate(var(--canvas-x), var(--canvas-y)) scale(var(--canvas-scale));
  transform-origin: top left;
}

.canvas-grid {
  background-image:
    linear-gradient(rgba(148,163,184,.12) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148,163,184,.12) 1px, transparent 1px),
    linear-gradient(rgba(148,163,184,.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148,163,184,.04) 1px, transparent 1px);
  background-size: 80px 80px, 80px 80px, 20px 20px, 20px 20px;
}

.canvas-item {
  position: absolute;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(15,23,42,.12);
  border: 1px solid rgba(255,255,255,.55);
  background: rgba(255,255,255,.82);
}

.canvas-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.canvas-item-text {
  display: grid;
  place-items: center;
  padding: 10px 14px;
  backdrop-filter: blur(12px);
  font-weight: 700;
  text-align: center;
}

.canvas-selection {
  border: 2px dashed rgba(59,130,246,.9);
  background: rgba(59,130,246,.12);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.4);
  pointer-events: none;
}

.canvas-group-layer,
.canvas-node-layer {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--canvas-width);
  height: var(--canvas-height);
  transform: translate(var(--canvas-x), var(--canvas-y)) scale(var(--canvas-scale));
  transform-origin: top left;
}

.canvas-group-card {
  position: absolute;
  border: 1px dashed rgba(125,211,252,.5);
  border-radius: 20px;
  background: rgba(59,130,246,.06);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.03);
}

.canvas-group-card.active {
  border-color: rgba(34,197,94,.72);
  background: rgba(16,185,129,.08);
}

.canvas-group-head {
  position: absolute;
  left: 16px;
  top: -18px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 999px;
  background: rgba(15,23,42,.92);
  color: #e2e8f0;
  border: 1px solid rgba(148,163,184,.18);
  font-size: 11px;
}

.canvas-group-action {
  border: 0;
  border-radius: 999px;
  padding: 4px 8px;
  background: rgba(59,130,246,.14);
  color: #bfdbfe;
  font-size: 10px;
  cursor: pointer;
}

.canvas-minimap {
  position: absolute;
  left: 18px;
  bottom: 18px;
  z-index: 15;
  display: grid;
  gap: 8px;
}

.canvas-minimap-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.canvas-minimap-toggle {
  border: 1px solid rgba(148,163,184,.2);
  border-radius: 999px;
  background: rgba(15,23,42,.92);
  color: #e2e8f0;
  font-size: 12px;
  padding: 8px 12px;
  cursor: pointer;
}

.canvas-minimap-help {
  width: 34px;
  height: 34px;
  border: 1px solid rgba(94, 234, 212, 0.38);
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(20, 184, 166, 0.88), rgba(14, 116, 144, 0.88));
  color: #f0fdfa;
  font-size: 16px;
  font-weight: 900;
  box-shadow: 0 10px 20px rgba(13, 148, 136, 0.18);
  cursor: pointer;
}

.canvas-minimap-panel {
  width: 200px;
  padding: 10px;
  border-radius: 16px;
  background: rgba(15,23,42,.92);
  border: 1px solid rgba(148,163,184,.18);
}

.canvas-minimap-stage {
  position: relative;
  width: 180px;
  height: 120px;
  border-radius: 12px;
  overflow: hidden;
  background:
    linear-gradient(rgba(148,163,184,.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148,163,184,.08) 1px, transparent 1px),
    #0b1120;
  background-size: 18px 18px;
  cursor: pointer;
}

.canvas-minimap-node {
  position: absolute;
  border-radius: 4px;
  background: rgba(125,211,252,.58);
}

.canvas-minimap-node.active {
  background: rgba(34,197,94,.72);
}

.canvas-minimap-viewport {
  position: absolute;
  border: 1px solid rgba(255,255,255,.82);
  background: rgba(255,255,255,.08);
  border-radius: 4px;
  pointer-events: none;
}

.canvas-zoom-label {
  min-width: 52px;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-soft);
}

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

@media (max-width: 640px) {
  .canvas-actions {
    grid-template-columns: 1fr;
  }

  .canvas-stage-shell {
    min-height: 460px;
  }
}

.canvas-edges {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--canvas-width);
  height: var(--canvas-height);
  transform: translate(var(--canvas-x), var(--canvas-y)) scale(var(--canvas-scale));
  transform-origin: top left;
}

.canvas-edge-path {
  cursor: default;
  pointer-events: none;
  filter: drop-shadow(0 0 5px rgba(20,184,166,.22));
}

.canvas-edge-hit {
  cursor: pointer;
  pointer-events: stroke;
}

.canvas-edge-path:hover {
  stroke: #5eead4;
  stroke-width: 4;
}

.canvas-node-card {
  position: absolute;
  width: 240px;
  min-height: 124px;
  padding: 10px 12px 12px;
  border-radius: 8px;
  border: 1px solid rgba(148,163,184,.24);
  background: linear-gradient(180deg, rgba(30,41,59,.98), rgba(15,23,42,.98));
  box-shadow: 0 14px 32px rgba(0,0,0,.28);
  text-align: left;
  display: grid;
  gap: 8px;
  cursor: grab;
  user-select: none;
  color: #e5e7eb;
}

.canvas-node-card.active {
  border-color: rgba(20,184,166,.72);
  box-shadow: 0 0 0 2px rgba(20,184,166,.18), 0 18px 38px rgba(0,0,0,.32);
}

.canvas-node-card.dragging {
  cursor: grabbing;
  box-shadow: 0 0 0 3px rgba(59,130,246,.16), 0 18px 36px rgba(15,23,42,.18);
}

body.canvas-node-dragging,
body.canvas-node-dragging * {
  user-select: none !important;
  -webkit-user-select: none !important;
}

.canvas-node-icon {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(20,184,166,.18);
  color: #5eead4;
  font-size: 11px;
  font-weight: 800;
}

.canvas-node-head {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.canvas-node-title {
  font-size: 12px;
  font-weight: 800;
  color: #f8fafc;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.canvas-node-status {
  margin-left: auto;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(148,163,184,.12);
  color: #94a3b8;
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
}

.canvas-node-status.queued {
  background: rgba(245,158,11,.16);
  color: #fbbf24;
}

.canvas-node-status.running {
  background: rgba(59,130,246,.16);
  color: #93c5fd;
}

.canvas-node-status.done {
  background: rgba(20,184,166,.18);
  color: #5eead4;
}

.canvas-node-status.error {
  background: rgba(239,68,68,.18);
  color: #fca5a5;
}

.canvas-node-body {
  min-height: 34px;
  padding: 7px 8px;
  border-radius: 6px;
  background: rgba(2,6,23,.48);
  color: #94a3b8;
  font-size: 10px;
  line-height: 1.4;
  overflow: hidden;
  white-space: pre-wrap;
  word-break: break-word;
}

.canvas-node-ports {
  display: grid;
  gap: 7px;
}

.canvas-node-ports-in {
  justify-items: start;
}

.canvas-node-ports-out {
  justify-items: end;
}

.canvas-port {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #cbd5e1;
  font-size: 10px;
  line-height: 1;
  cursor: crosshair;
}

.canvas-node-title-input {
  min-width: 0;
  flex: 1;
  border: 0;
  background: transparent;
  color: #f8fafc;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  padding: 0;
  outline: none;
}

.canvas-node-delete-btn {
  border: 0;
  border-radius: 999px;
  padding: 4px 8px;
  background: rgba(239,68,68,.12);
  color: #fca5a5;
  font-size: 10px;
  cursor: pointer;
}

.canvas-node-inline-text,
.canvas-node-provider input,
.canvas-node-provider textarea,
.canvas-node-provider select {
  width: 100%;
  border: 1px solid rgba(148,163,184,.18);
  border-radius: 8px;
  background: rgba(2,6,23,.46);
  color: #e5e7eb;
  font-size: 11px;
  line-height: 1.45;
  padding: 8px 10px;
  outline: none;
}

.canvas-node-inline-text {
  min-height: 70px;
  resize: vertical;
}

.canvas-node-inline-text.is-script {
  min-height: 132px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.canvas-script-card,
.canvas-generator-panel {
  display: grid;
  gap: 8px;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid rgba(148,163,184,.16);
  background: linear-gradient(180deg, rgba(15,23,42,.72), rgba(2,6,23,.5));
}

.canvas-script-card-top,
.canvas-generator-panel-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.canvas-script-card-top strong,
.canvas-generator-panel-head strong {
  color: #f8fafc;
  font-size: 11px;
}

.canvas-script-card-top span,
.canvas-generator-panel-head span {
  padding: 3px 7px;
  border-radius: 999px;
  background: rgba(20,184,166,.12);
  color: #99f6e4;
  font-size: 10px;
}

.canvas-script-card-body {
  color: #cbd5e1;
  font-size: 11px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.canvas-script-board {
  display: grid;
  gap: 8px;
}

.canvas-script-board-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.canvas-script-table,
.canvas-script-card-list {
  display: grid;
  gap: 8px;
}

.canvas-script-row,
.canvas-script-shot-card {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid rgba(148,163,184,.16);
  border-radius: 10px;
  background: rgba(2,6,23,.34);
}

.canvas-script-row {
  grid-template-columns: auto 24px 1fr 1.5fr;
  align-items: center;
}

.canvas-script-row input[type="text"] {
  width: 100%;
  border: 1px solid rgba(148,163,184,.18);
  border-radius: 8px;
  background: rgba(15,23,42,.6);
  color: #e5e7eb;
  padding: 8px 10px;
  font-size: 11px;
}

.canvas-script-row-index {
  color: #94a3b8;
  font-size: 11px;
  text-align: center;
}

.canvas-script-shot-card strong {
  color: #f8fafc;
  font-size: 12px;
}

.canvas-script-shot-card p {
  margin: 0;
  color: #cbd5e1;
  font-size: 11px;
  line-height: 1.5;
}

.canvas-generator-panel.is-image {
  border-color: rgba(59,130,246,.2);
}

.canvas-generator-panel.is-video {
  border-color: rgba(16,185,129,.22);
}

.canvas-generator-panel-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.canvas-node-media-row,
.canvas-node-media-preview,
.canvas-node-media-tools,
.canvas-node-provider,
.canvas-node-editor-actions,
.canvas-node-run-row,
.canvas-node-result {
  display: grid;
  gap: 8px;
}

.canvas-node-media-row {
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
}

.canvas-node-upload {
  display: grid;
  gap: 6px;
  padding: 8px;
  border: 1px dashed rgba(148,163,184,.24);
  border-radius: 8px;
  background: rgba(15,23,42,.42);
  color: #cbd5e1;
  font-size: 10px;
  cursor: pointer;
}

.canvas-node-media-item {
  display: grid;
  gap: 8px;
  padding: 8px;
  border: 1px solid rgba(148,163,184,.16);
  border-radius: 10px;
  background: rgba(2,6,23,.4);
}

.canvas-node-media-thumb {
  border-radius: 8px;
  overflow: hidden;
  background: rgba(15,23,42,.8);
  min-height: 84px;
}

.canvas-node-media-thumb img,
.canvas-node-media-thumb video,
.canvas-node-result video,
.canvas-node-result audio,
.canvas-media-lightbox-body img,
.canvas-media-lightbox-body video,
.canvas-media-lightbox-body audio {
  display: block;
  width: 100%;
  max-width: 100%;
}

.canvas-node-media-thumb img,
.canvas-node-result-grid img,
.canvas-media-lightbox-body img,
.canvas-media-lightbox-body video {
  object-fit: contain;
}

.canvas-node-video-placeholder {
  display: grid;
  place-items: center;
  min-height: 120px;
  color: #94a3b8;
  font-size: 11px;
}

.canvas-node-media-tools {
  grid-template-columns: 1fr repeat(3, auto);
  align-items: center;
}

.canvas-node-media-tools button,
.canvas-node-run-btn {
  border: 1px solid rgba(20,184,166,.22);
  border-radius: 8px;
  background: rgba(20,184,166,.12);
  color: #ccfbf1;
  font-size: 10px;
  padding: 6px 8px;
  cursor: pointer;
}

.canvas-node-result-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.canvas-node-result-tools .is-download {
  padding: 8px 14px;
  border-color: rgba(34, 197, 94, 0.36);
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.24), rgba(20, 184, 166, 0.22));
  color: #ecfdf5;
  font-weight: 800;
  text-decoration: none;
  box-shadow: 0 10px 18px rgba(22, 163, 74, 0.16);
}

.canvas-node-preview-frame {
  position: relative;
  overflow: hidden;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  background: linear-gradient(180deg, rgba(2, 6, 23, 0.74), rgba(15, 23, 42, 0.92));
}

.canvas-node-provider span,
.canvas-node-result > span {
  color: #94a3b8;
  font-size: 10px;
}

.canvas-node-result.is-error .canvas-node-preview-frame {
  border-color: rgba(248,113,113,.38);
  background: rgba(127,29,29,.16);
}

.canvas-node-result.is-error .canvas-node-preview-empty strong,
.canvas-node-result.is-error > span {
  color: #fecaca;
}

.canvas-node-result.is-error .canvas-node-preview-empty small {
  color: #fca5a5;
}

.canvas-node-result-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.canvas-node-result-grid img {
  border-radius: 8px;
  background: rgba(15,23,42,.72);
  aspect-ratio: 1 / 1;
}

.canvas-node-preview-frame.is-video video,
.canvas-node-result-grid img,
.canvas-media-lightbox-body video,
.canvas-media-lightbox-body img {
  will-change: transform;
  transform: translateZ(0);
  backface-visibility: hidden;
}

.canvas-node-result-image {
  padding: 0;
  border: 0;
  border-radius: 10px;
  overflow: hidden;
  background: transparent;
  cursor: pointer;
}

.canvas-node-result-image.is-active {
  box-shadow: 0 0 0 2px rgba(94, 234, 212, 0.48);
}

.canvas-node-card.is-script {
  border-color: rgba(244,114,182,.28);
}

.canvas-node-card.is-image-node {
  border-color: rgba(59,130,246,.24);
}

.canvas-node-card.is-video-node {
  border-color: rgba(16,185,129,.26);
}

.canvas-history-check {
  accent-color: #14b8a6;
}

.canvas-media-lightbox {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: grid;
  place-items: center;
  padding: 32px;
  background: rgba(2,6,23,.84);
  backdrop-filter: blur(8px);
}

.canvas-media-lightbox-shell {
  width: min(94vw, 1280px);
  max-height: 90vh;
  display: grid;
  gap: 12px;
}

.canvas-media-lightbox-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #f8fafc;
}

.canvas-media-lightbox-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.canvas-media-lightbox-close {
  border: 0;
  border-radius: 999px;
  padding: 8px 14px;
  background: rgba(15,23,42,.92);
  color: #fff;
  cursor: pointer;
}

.canvas-media-lightbox-body {
  width: 100%;
  max-height: 88vh;
  overflow: auto;
  border-radius: 18px;
  background: rgba(15,23,42,.96);
  padding: 18px;
  box-shadow: 0 24px 64px rgba(0,0,0,.42);
  overscroll-behavior: contain;
}

.canvas-media-lightbox-body video {
  width: auto;
  min-width: min(100%, 960px);
  max-height: calc(88vh - 90px);
  margin: 0 auto;
}

.canvas-help-modal {
  position: fixed;
  inset: 0;
  z-index: 1400;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(2, 6, 23, 0.74);
  backdrop-filter: blur(10px);
}

.canvas-help-panel {
  width: min(760px, 92vw);
  max-height: 88vh;
  overflow: auto;
  border-radius: 24px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  background:
    radial-gradient(circle at top right, rgba(20, 184, 166, 0.18), transparent 26%),
    linear-gradient(180deg, rgba(15, 23, 42, 0.99), rgba(2, 6, 23, 0.98));
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.36);
  color: #e2e8f0;
}

.canvas-help-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 24px 14px;
}

.canvas-help-head span {
  display: inline-block;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #5eead4;
}

.canvas-help-head h2 {
  margin: 8px 0 0;
  font-size: 28px;
  line-height: 1.1;
  color: #f8fafc;
}

.canvas-help-close {
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.8);
  color: #f8fafc;
  padding: 8px 14px;
  cursor: pointer;
}

.canvas-help-body {
  display: grid;
  gap: 12px;
  padding: 0 24px 24px;
}

.canvas-help-section {
  padding: 16px 18px;
  border-radius: 18px;
  background: rgba(15, 23, 42, 0.68);
  border: 1px solid rgba(148, 163, 184, 0.12);
}

.canvas-help-section strong {
  display: block;
  margin-bottom: 6px;
  font-size: 15px;
  color: #f8fafc;
}

.canvas-help-section p {
  margin: 0;
  font-size: 14px;
  line-height: 1.7;
  color: #cbd5e1;
}

body.canvas-script-editor-open {
  overflow: hidden;
}

.canvas-script-modal {
  position: fixed;
  inset: 0;
  z-index: 1500;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(2,6,23,.82);
  backdrop-filter: blur(8px);
}

.canvas-script-modal.hidden {
  display: none;
}

.canvas-script-modal-panel {
  width: min(980px, 92vw);
  max-height: 90vh;
  display: grid;
  gap: 14px;
  padding: 20px;
  border-radius: 18px;
  background: rgba(15,23,42,.98);
  border: 1px solid rgba(148,163,184,.16);
  box-shadow: 0 24px 64px rgba(0,0,0,.42);
}

.canvas-script-modal-head,
.canvas-script-modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.canvas-script-modal textarea {
  width: 100%;
  min-height: 52vh;
  border: 1px solid rgba(148,163,184,.2);
  border-radius: 14px;
  background: rgba(2,6,23,.6);
  color: #e5e7eb;
  font: 13px/1.7 ui-monospace, SFMono-Regular, Menlo, monospace;
  padding: 14px 16px;
  resize: vertical;
  outline: none;
}

.canvas-port i {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: #0f172a;
  border: 2px solid #14b8a6;
  box-shadow: 0 0 0 3px rgba(20,184,166,.12);
}

.canvas-port:hover i {
  background: #5eead4;
}

.canvas-port.active i {
  background: #5eead4;
  border-color: #ccfbf1;
  box-shadow: 0 0 0 5px rgba(20,184,166,.22);
}

.canvas-step-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.canvas-step-preview {
  font-size: 11px;
  color: var(--primary);
  text-decoration: none;
}

.canvas-template-actions {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
}

.canvas-template-actions input {
  min-width: 0;
}

.canvas-template-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.canvas-template-chip {
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--main-surface);
  color: var(--text-soft);
  font-size: 12px;
  cursor: pointer;
}

.canvas-node-whitelist {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.canvas-node-editor-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.canvas-node-editor-head strong {
  display: block;
  font-size: 14px;
  color: var(--text);
}

.canvas-node-editor-meta {
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-muted);
}

.canvas-node-editor-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

@media (max-width: 720px) {
  .canvas-generator-panel-grid {
    grid-template-columns: 1fr;
  }

  .canvas-script-row {
    grid-template-columns: 1fr;
  }

  .canvas-project-titlebar {
    align-items: stretch;
  }

  .canvas-project-titlebox,
  .canvas-project-titlebox input {
    width: 100%;
  }

  .canvas-fullscreen-btn {
    padding: 0 14px;
  }

  .canvas-help-head {
    flex-direction: column;
  }
}

.canvas-context-menu {
  position: fixed;
  z-index: 1400;
  width: 260px;
  max-height: min(520px, 80vh);
  overflow: auto;
  background: rgba(15,23,42,.98);
  border: 1px solid rgba(148,163,184,.24);
  border-radius: 10px;
  box-shadow: 0 18px 42px rgba(0,0,0,.34);
  padding: 8px;
  display: grid;
  gap: 4px;
}

.canvas-context-meta {
  padding: 4px 10px 2px;
  color: #e2e8f0;
  font-size: 10px;
  font-weight: 800;
}

.canvas-node-search {
  width: 100%;
  margin-bottom: 6px;
  padding: 8px 9px;
  border-radius: 8px;
  border: 1px solid rgba(148,163,184,.28);
  background: rgba(2,6,23,.72);
  color: #e5e7eb;
  font-size: 11px;
  outline: none;
}

.canvas-node-search:focus {
  border-color: rgba(20,184,166,.72);
}

.canvas-context-menu button {
  text-align: left;
  border: none;
  background: transparent;
  color: #e5e7eb;
  padding: 7px 9px;
  border-radius: 8px;
  cursor: pointer;
  display: grid;
  gap: 2px;
  font-size: 12px;
  line-height: 1.25;
}

.canvas-context-menu button span {
  color: #94a3b8;
  font-size: 9px;
  font-weight: 800;
}

.canvas-context-section {
  display: grid;
  gap: 4px;
}

.canvas-context-title {
  padding: 6px 10px 2px;
  color: #94a3b8;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.canvas-context-menu button:hover {
  background: rgba(20,184,166,.14);
  color: #ccfbf1;
}

/* ═══════════════════════════════════════
   User area tech-theme refinements
   ═══════════════════════════════════════ */

.credits-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr));
  gap: clamp(12px, 1.5vw, 18px);
  margin-bottom: clamp(16px, 2vw, 24px);
}

.credits-stat {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: clamp(16px, 2vw, 22px);
  background:
    radial-gradient(circle at 100% 0%, rgba(0,224,255,.16), transparent 38%),
    linear-gradient(145deg, rgba(255,255,255,.082), rgba(255,255,255,.032)),
    rgba(9, 12, 20, 0.76);
  box-shadow: var(--shadow-card);
}

.credits-stat::after {
  content: "";
  position: absolute;
  inset: auto 16px 14px auto;
  width: 46px;
  height: 2px;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, var(--primary));
}

.credits-stat .label,
.credits-stat .sub {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.credits-stat .value {
  margin: 8px 0 4px;
  color: #fff;
  font-size: clamp(28px, 4vw, 46px);
  font-weight: 900;
  letter-spacing: -.055em;
  line-height: 1;
}

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

.credits-item {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: rgba(255,255,255,.038);
}

.credits-item .icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: rgba(0,224,255,.12);
}

.credits-item .prompt {
  color: var(--text);
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.credits-item .meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 5px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
}

.credits-item .cost {
  min-width: 70px;
  text-align: right;
  color: var(--primary-light);
  font-size: 18px;
  font-weight: 900;
}

.model-chip {
  display: grid;
  gap: 8px;
}

.model-chip label,
.model-chip .chip {
  border-color: var(--line);
  background: rgba(255,255,255,.045);
}

.compact-param-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  gap: 8px;
  align-items: end;
  margin: 2px 0 6px;
}

.compact-param-field {
  min-width: 0;
  gap: 4px;
  margin-bottom: 0;
}

.compact-param-field > label {
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.2;
  font-weight: 800;
  letter-spacing: 0;
}

.compact-param-field select,
.compact-param-field input[type="text"],
.compact-param-field input[type="number"] {
  min-height: 34px;
  height: 34px;
  border-radius: 9px;
  padding: 0 28px 0 10px;
  font-size: 12px;
  line-height: 34px;
}

.compact-param-field .model-chip {
  gap: 0;
}

.compact-param-field .model-chip select {
  width: 100%;
}

@media (min-width: 900px) {
  .image-param-row {
    grid-template-columns: minmax(118px, .75fr) minmax(160px, 1.25fr);
  }

  .video-param-row {
    grid-template-columns: minmax(104px, .82fr) minmax(112px, .9fr) minmax(96px, .72fr) minmax(96px, .72fr) minmax(150px, 1.24fr);
  }
}

@media (max-width: 640px) {
  .compact-param-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .compact-param-field-wide {
    grid-column: 1 / -1;
  }
}

.media-card {
  position: relative;
  isolation: isolate;
}

.media-card::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  opacity: 0;
  background: radial-gradient(circle at 50% 0%, rgba(0,224,255,.22), transparent 54%);
  transition: opacity var(--duration-normal) var(--ease-out-expo);
}

.media-card:hover::after {
  opacity: 1;
}

.canvas-project-card,
.canvas-preset-card,
.canvas-task-card {
  border-color: var(--line);
  background:
    linear-gradient(145deg, rgba(255,255,255,.065), rgba(255,255,255,.026)),
    rgba(7, 10, 17, 0.72);
}

.canvas-project-card:hover,
.canvas-project-card.active,
.canvas-preset-card:hover,
.canvas-task-card:hover {
  border-color: rgba(0,224,255,.32);
  box-shadow: 0 0 34px rgba(0,224,255,.10);
}

.canvas-project-card .thumb {
  background:
    radial-gradient(circle at 40% 30%, rgba(0,224,255,.24), transparent 42%),
    rgba(255,255,255,.045);
}

@media (max-width: 640px) {
  .credits-item {
    grid-template-columns: 36px minmax(0, 1fr);
  }

  .credits-item .cost {
    grid-column: 2;
    text-align: left;
  }

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

/* ═══════════════════════════════════════
   USER UI REFINEMENT — compact controls, airy layout
   ═══════════════════════════════════════ */

body:not(.page-admin) {
  --main-bg: #f9fafb;
  --main-surface: #ffffff;
  --main-surface-soft: #f6f7f9;
  --text: #333333;
  --text-soft: #4b5563;
  --text-muted: #7b8494;
  --primary: #4f74a8;
  --primary-dark: #3f628f;
  --primary-light: #6f8fba;
  --primary-soft: rgba(79, 116, 168, 0.08);
  --primary-glow: rgba(79, 116, 168, 0.10);
  --sidebar-bg: #111827;
  --sidebar-surface: #1f2937;
  --sidebar-text: #a7b0bf;
  --sidebar-text-hover: #f3f4f6;
  --sidebar-text-active: #d9e5f6;
  --sidebar-accent: #6f8fba;
  --sidebar-accent-glow: rgba(111, 143, 186, 0.13);
  --sidebar-border: rgba(255, 255, 255, 0.08);
  --line: #e5e7eb;
  --line-strong: #dfe3e8;
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.03);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 4px 12px rgba(15, 23, 42, 0.06);
  --shadow-xl: 0 8px 24px rgba(15, 23, 42, 0.08);
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.04);
  --shadow-elevated: 0 6px 18px rgba(15, 23, 42, 0.07);
  --radius-sm: 8px;
  --radius: 10px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  font-family: Inter, "Helvetica Neue", -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  color: var(--text);
  font-size: 13px;
  line-height: 1.55;
  font-weight: 400;
  background: var(--main-bg);
}

body:not(.page-admin) * {
  letter-spacing: 0;
}

body:not(.page-admin) .main-area {
  padding: clamp(24px, 3.4vw, 42px) clamp(24px, 4vw, 48px);
  background: var(--main-bg);
}

body.page-embed .main-area {
  margin-left: 0;
  padding: 0;
  min-height: 100dvh;
}

body.page-embed main {
  margin: 0;
}

body:not(.page-admin) main,
body:not(.page-admin) .form,
body:not(.page-admin) .card-v3-body,
body:not(.page-admin) .record-dialog-body {
  gap: clamp(14px, 1.8vw, 22px);
}

body:not(.page-admin) .grid-2,
body:not(.page-admin) .grid-3,
body:not(.page-admin) .grid-4,
body:not(.page-admin) .grid-auto {
  gap: clamp(22px, 2.8vw, 34px);
}

body:not(.page-admin) .page-hd {
  gap: clamp(18px, 2.3vw, 28px);
  margin-bottom: clamp(24px, 3vw, 38px);
}

body:not(.page-admin) .page-hd p {
  font-size: clamp(10px, 1.1vw, 12px);
  font-weight: 400;
}

body:not(.page-admin) .page-hd h1 {
  font-size: clamp(20px, 2.5vw, 28px);
  font-weight: 500;
  color: #333;
}

body:not(.page-admin) .page-hd-actions {
  gap: clamp(12px, 1.5vw, 18px);
}

body:not(.page-admin) .sidebar-logo,
body:not(.page-admin) .sidebar-user-avatar {
  background: var(--primary);
  box-shadow: none;
}

body:not(.page-admin) .sidebar-logo {
  width: clamp(30px, 3.2vw, 36px);
  height: clamp(30px, 3.2vw, 36px);
}

body:not(.page-admin) .sidebar-brand-text h1,
body:not(.page-admin) .sidebar-user-info strong {
  font-weight: 500;
}

body:not(.page-admin) .sidebar-brand-text small,
body:not(.page-admin) .sidebar-user-info span,
body:not(.page-admin) .sidebar-balance,
body:not(.page-admin) .sidebar-action-btn,
body:not(.page-admin) .sidebar-nav-item,
body:not(.page-admin) .sidebar-nav-section {
  font-weight: 400;
}

body:not(.page-admin) .sidebar-nav {
  gap: 5px;
  padding: 14px;
}

body:not(.page-admin) .sidebar-nav-item {
  padding: 10px 11px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.45;
}

body:not(.page-admin) .sidebar-nav-item.active {
  box-shadow: inset 2px 0 0 var(--sidebar-accent);
}

body:not(.page-admin) .sidebar-nav-item.is-agent-hub,
body:not(.page-admin) .sidebar-nav-item.is-agent-hub:hover {
  color: var(--sidebar-text-hover);
  background: var(--sidebar-accent-glow);
  border-color: var(--sidebar-border);
}

body:not(.page-admin) .sidebar-nav-item svg,
body:not(.page-admin) .sidebar-action-btn svg,
body:not(.page-admin) .btn svg,
body:not(.page-admin) .button svg {
  width: 14px;
  height: 14px;
  stroke-width: 1.75;
}

body:not(.page-admin) .sidebar-nav-item .nav-badge {
  min-height: 17px;
  padding: 0 5px;
  font-size: 9px;
  font-weight: 500;
  background: rgba(111, 143, 186, 0.16);
  color: #d9e5f6;
}

body:not(.page-admin) .card-v3,
body:not(.page-admin) .media-card,
body:not(.page-admin) .record-dialog-panel,
body:not(.page-admin) .package-card,
body:not(.page-admin) .credits-item,
body:not(.page-admin) .canvas-project-card,
body:not(.page-admin) .canvas-preset-card,
body:not(.page-admin) .canvas-task-card {
  border: 1px solid var(--line);
  background: var(--main-surface);
  box-shadow: var(--shadow-card);
}

body:not(.page-admin) .card-v3:hover,
body:not(.page-admin) .media-card:hover,
body:not(.page-admin) .package-card:hover,
body:not(.page-admin) .canvas-project-card:hover,
body:not(.page-admin) .canvas-project-card.active,
body:not(.page-admin) .canvas-preset-card:hover,
body:not(.page-admin) .canvas-task-card:hover {
  border-color: #d7dde5;
  box-shadow: var(--shadow-lg);
}

body:not(.page-admin) .media-card::after,
body:not(.page-admin) .media-card:hover::after {
  display: none;
}

body:not(.page-admin) .card-v3-head {
  min-height: 40px;
  padding: clamp(13px, 1.7vw, 18px) clamp(18px, 2.4vw, 28px);
}

body:not(.page-admin) .card-v3-head h3 {
  font-size: clamp(14px, 1.5vw, 17px);
  font-weight: 500;
}

body:not(.page-admin) .card-v3-head .eyebrow,
body:not(.page-admin) .card-v3-head .sub {
  font-size: 10px;
  font-weight: 400;
  color: var(--text-muted);
}

body:not(.page-admin) .card-v3-body {
  padding: clamp(20px, 2.8vw, 32px);
}

body:not(.page-admin) .field-v3 {
  gap: 7px;
  margin-bottom: clamp(14px, 1.9vw, 22px);
}

body:not(.page-admin) .field-v3 > label,
body:not(.page-admin) .field-v3 > span,
body:not(.page-admin) .compact-param-field > label {
  font-size: 11px;
  line-height: 1.5;
  font-weight: 400;
  color: var(--text-muted);
}

body:not(.page-admin) input[type="text"],
body:not(.page-admin) input[type="password"],
body:not(.page-admin) input[type="email"],
body:not(.page-admin) input[type="number"],
body:not(.page-admin) input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]):not([type="hidden"]),
body:not(.page-admin) select,
body:not(.page-admin) textarea,
body:not(.page-admin) .canvas-project-titlebox input,
body:not(.page-admin) .canvas-node-provider input,
body:not(.page-admin) .canvas-node-provider select,
body:not(.page-admin) .canvas-node-provider textarea,
body:not(.page-admin) .designer-inspector-field input,
body:not(.page-admin) .designer-inspector-field select,
body:not(.page-admin) .designer-inspector-field textarea {
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: var(--text);
  box-shadow: none;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.55;
}

body:not(.page-admin) input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]):not([type="hidden"]),
body:not(.page-admin) input[type="text"],
body:not(.page-admin) input[type="password"],
body:not(.page-admin) input[type="email"],
body:not(.page-admin) input[type="number"],
body:not(.page-admin) select {
  height: 36px;
  min-height: 36px;
  padding: 0 11px;
}

body:not(.page-admin) textarea {
  min-height: 108px;
  padding: 10px 12px;
  line-height: 1.65;
}

body:not(.page-admin) input:hover,
body:not(.page-admin) select:hover,
body:not(.page-admin) textarea:hover {
  border-color: #d1d5db;
}

body:not(.page-admin) input:focus,
body:not(.page-admin) select:focus,
body:not(.page-admin) textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

body:not(.page-admin) .btn,
body:not(.page-admin) .button,
body:not(.page-admin) .btn-primary,
body:not(.page-admin) .btn-secondary,
body:not(.page-admin) .btn-ghost {
  min-height: 34px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 9px;
  box-shadow: none;
  font-size: 13px;
  line-height: 1.4;
  font-weight: 400;
}

body:not(.page-admin) .btn-sm,
body:not(.page-admin) .btn.sm,
body:not(.page-admin) .button.small {
  min-height: 28px;
  padding: 0 10px;
  font-size: 12px;
}

body:not(.page-admin) .btn-lg,
body:not(.page-admin) .btn.lg {
  min-height: 40px;
  padding: 0 18px;
  font-size: 14px;
}

body:not(.page-admin) .btn::after,
body:not(.page-admin) .button::after {
  display: none;
}

body:not(.page-admin) .btn-primary,
body:not(.page-admin) .btn.primary,
body:not(.page-admin) .button.primary {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

body:not(.page-admin) .btn-primary:hover,
body:not(.page-admin) .btn.primary:hover,
body:not(.page-admin) .button.primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
  box-shadow: var(--shadow-sm);
}

body:not(.page-admin) .btn-secondary,
body:not(.page-admin) .btn.secondary,
body:not(.page-admin) .button.secondary,
body:not(.page-admin) .btn-ghost,
body:not(.page-admin) .btn.ghost {
  background: #fff;
  color: var(--text-soft);
}

body:not(.page-admin) .btn-secondary:hover,
body:not(.page-admin) .btn.secondary:hover,
body:not(.page-admin) .button.secondary:hover,
body:not(.page-admin) .btn-ghost:hover,
body:not(.page-admin) .btn.ghost:hover {
  border-color: #d1d5db;
  background: var(--main-surface-soft);
  color: var(--text);
  box-shadow: none;
}

body:not(.page-admin) .mode-toggle,
body:not(.page-admin) .video-reference-modes,
body:not(.page-admin) .chip-group,
body:not(.page-admin) .compact-param-row,
body:not(.page-admin) .generate-actions {
  gap: clamp(10px, 1.3vw, 16px);
}

body:not(.page-admin) .mode-toggle label,
body:not(.page-admin) .video-reference-modes label,
body:not(.page-admin) .chip-group label,
body:not(.page-admin) .pay-type-item {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 400;
  box-shadow: none;
}

body:not(.page-admin) .mode-toggle label:has(input:checked),
body:not(.page-admin) .video-reference-modes label:has(input:checked),
body:not(.page-admin) .chip-group label:has(input:checked),
body:not(.page-admin) .pay-type-item:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary-dark);
  box-shadow: none;
}

body:not(.page-admin) .edit-upload-box {
  min-height: 76px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px;
  background: #fff;
}

body:not(.page-admin) .edit-upload-box:hover {
  border-color: #d1d5db;
  background: var(--main-surface-soft);
  box-shadow: none;
}

body:not(.page-admin) .edit-upload-icon,
body:not(.page-admin) .video-reference-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  box-shadow: none;
  font-size: 14px;
}

body:not(.page-admin) .edit-upload-box strong,
body:not(.page-admin) .media-card-body .prompt,
body:not(.page-admin) .media-card .prompt {
  font-size: 13px;
  font-weight: 400;
  line-height: 1.55;
}

body:not(.page-admin) .edit-upload-box small,
body:not(.page-admin) .field-hint,
body:not(.page-admin) .hint,
body:not(.page-admin) .media-card-body .meta,
body:not(.page-admin) .media-card .meta {
  font-size: 11px;
  font-weight: 400;
  line-height: 1.55;
  color: var(--text-muted);
}

body:not(.page-admin) .edit-upload-preview {
  gap: 10px;
}

body:not(.page-admin) .edit-preview-item {
  border: 1px solid var(--line);
  border-radius: 9px;
}

body:not(.page-admin) .compact-param-field select,
body:not(.page-admin) .compact-param-field input[type="text"],
body:not(.page-admin) .compact-param-field input[type="number"] {
  height: 32px;
  min-height: 32px;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.4;
}

body:not(.page-admin) .cost-hint,
body:not(.page-admin) .generation-notice,
body:not(.page-admin) .alert,
body:not(.page-admin) .badge-balance,
body:not(.page-admin) .canvas-project-save-state {
  border: 1px solid var(--line);
  background: #fff;
  box-shadow: var(--shadow-xs);
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 400;
}

body:not(.page-admin) .badge-balance {
  padding: 7px 12px;
}

body:not(.page-admin) .badge-balance .num {
  font-size: 16px;
  font-weight: 500;
}

body:not(.page-admin) .badge-balance .label {
  font-size: 11px;
  font-weight: 400;
}

body:not(.page-admin) .record-dialog-panel {
  border-radius: 12px;
}

body:not(.page-admin) .record-dialog-head,
body:not(.page-admin) .record-dialog-foot {
  padding: 14px 18px;
  border-color: var(--line);
}

body:not(.page-admin) .record-dialog-body {
  padding: 20px;
}

body:not(.page-admin) .record-dialog-head h2 {
  font-size: 17px;
  font-weight: 500;
}

body:not(.page-admin) .record-dialog-close,
body:not(.page-admin) .record-action-trigger {
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  box-shadow: none;
}

body:not(.page-admin) .media-card {
  border-radius: 10px;
}

body:not(.page-admin) .media-card-body {
  padding: 12px;
}

body:not(.page-admin) .status-badge,
body:not(.page-admin) .nav-badge {
  font-weight: 400;
}

body:not(.page-admin) .jpt-toast,
body:not(.page-admin) .jpt-layer-panel {
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
}

/* ═══════════════════════════════════════
   THEME MODES + COMPACT MEDIA LISTS
   ═══════════════════════════════════════ */

html[data-theme="light"] {
  color-scheme: light;
}

html[data-theme="dark"] {
  color-scheme: dark;
}

html[data-theme="chinese"] {
  color-scheme: light;
}

html[data-theme="light"] body:not(.page-admin) {
  --main-bg: #f9fafb;
  --main-surface: #ffffff;
  --main-surface-soft: #f4f6f8;
  --text: #333333;
  --text-soft: #4b5563;
  --text-muted: #7b8494;
  --primary: #4f74a8;
  --primary-dark: #3f628f;
  --primary-light: #6f8fba;
  --primary-soft: rgba(79, 116, 168, 0.08);
  --primary-glow: rgba(79, 116, 168, 0.10);
  --panel-bg: #ffffff;
  --panel-muted: #f3f4f6;
  --panel-inset: #f7f8fa;
  --notice-bg: #eef3f8;
  --notice-border: #d8e1ec;
  --line: #e5e7eb;
  --line-strong: #dfe3e8;
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.03);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 8px 22px rgba(15, 23, 42, 0.07);
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.04);
  background: var(--main-bg);
}

html[data-theme="dark"] body:not(.page-admin) {
  --main-bg: #0b111d;
  --main-surface: #111827;
  --main-surface-soft: #172033;
  --text: #e5e7eb;
  --text-soft: #c3cad6;
  --text-muted: #8792a3;
  --primary: #83a7d8;
  --primary-dark: #a8c2e8;
  --primary-light: #bfd4f0;
  --primary-soft: rgba(131, 167, 216, 0.13);
  --primary-glow: rgba(131, 167, 216, 0.18);
  --panel-bg: #111827;
  --panel-muted: #172033;
  --panel-inset: #0d1422;
  --notice-bg: #172236;
  --notice-border: #2c3a52;
  --sidebar-bg: #080d16;
  --sidebar-surface: #101827;
  --sidebar-text: #9da8ba;
  --sidebar-text-hover: #eef2f7;
  --sidebar-text-active: #d7e7ff;
  --sidebar-accent: #9ab8e2;
  --sidebar-accent-glow: rgba(154, 184, 226, 0.14);
  --sidebar-border: rgba(255, 255, 255, 0.08);
  --line: #273244;
  --line-strong: #344155;
  --success-soft: rgba(16, 185, 129, 0.14);
  --warning-soft: rgba(245, 158, 11, 0.15);
  --danger-soft: rgba(239, 68, 68, 0.15);
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.22);
  --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.20);
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.24);
  --shadow-lg: 0 14px 36px rgba(0, 0, 0, 0.32);
  --shadow-card: 0 1px 0 rgba(255, 255, 255, 0.03), 0 12px 28px rgba(0, 0, 0, 0.22);
  background:
    radial-gradient(circle at 18% 6%, rgba(131, 167, 216, 0.10), transparent 28%),
    radial-gradient(circle at 90% 20%, rgba(65, 88, 128, 0.12), transparent 26%),
    var(--main-bg);
}

html[data-theme="chinese"] body:not(.page-admin) {
  --main-bg: #f7f1e6;
  --main-surface: #fffaf0;
  --main-surface-soft: #f3eadb;
  --text: #2f3433;
  --text-soft: #5a5148;
  --text-muted: #8a7b68;
  --primary: #b84a3a;
  --primary-dark: #8f3429;
  --primary-light: #cf7d69;
  --primary-soft: rgba(184, 74, 58, 0.10);
  --primary-glow: rgba(184, 74, 58, 0.14);
  --panel-bg: #fffaf0;
  --panel-muted: #f3eadb;
  --panel-inset: #f8efe0;
  --notice-bg: #f5e4d8;
  --notice-border: #e2c4a9;
  --sidebar-bg: #211d19;
  --sidebar-surface: #302820;
  --sidebar-text: #c8bbaa;
  --sidebar-text-hover: #fffaf0;
  --sidebar-text-active: #fff2df;
  --sidebar-accent: #d7aa62;
  --sidebar-accent-glow: rgba(215, 170, 98, 0.14);
  --sidebar-border: rgba(255, 250, 240, 0.10);
  --line: #e2d6c4;
  --line-strong: #cdbca5;
  --shadow-xs: 0 1px 2px rgba(61, 43, 31, 0.04);
  --shadow-sm: 0 2px 7px rgba(61, 43, 31, 0.07);
  --shadow: 0 8px 22px rgba(61, 43, 31, 0.08);
  --shadow-lg: 0 16px 38px rgba(61, 43, 31, 0.11);
  --shadow-card: 0 1px 0 rgba(255, 255, 255, 0.72), 0 10px 24px rgba(61, 43, 31, 0.07);
  background: var(--main-bg);
}

html[data-theme] body:not(.page-admin)::before,
html[data-theme] body:not(.page-admin)::after {
  display: none;
}

html[data-theme] body:not(.page-admin) .main-area {
  background: var(--main-bg);
}

html[data-theme] body:not(.page-admin) .sidebar {
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  box-shadow: var(--shadow-sm);
}

html[data-theme] body:not(.page-admin) .sidebar-header,
html[data-theme] body:not(.page-admin) .sidebar-footer {
  background: transparent;
}

html[data-theme] body:not(.page-admin) .sidebar-logo,
html[data-theme] body:not(.page-admin) .sidebar-user-avatar {
  background: var(--primary);
  color: #fff;
}

html[data-theme="dark"] body:not(.page-admin) .sidebar-logo,
html[data-theme="dark"] body:not(.page-admin) .sidebar-user-avatar {
  color: #0b111d;
}

html[data-theme] body:not(.page-admin) .sidebar-action-btn.theme-toggle {
  border: 1px solid var(--sidebar-border);
  background: rgba(255, 255, 255, 0.04);
  font-family: inherit;
  cursor: pointer;
}

html[data-theme] body:not(.page-admin) .theme-picker {
  position: relative;
  flex: 1;
  min-width: 0;
}

html[data-theme] body:not(.page-admin) .theme-picker .theme-toggle {
  width: 100%;
}

html[data-theme] body:not(.page-admin) .theme-menu {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 8px);
  z-index: 20;
  display: none;
  padding: 6px;
  border: 1px solid var(--sidebar-border);
  border-radius: 10px;
  background: var(--sidebar-surface);
  box-shadow: var(--shadow-lg);
}

html[data-theme] body:not(.page-admin) .theme-picker.is-open .theme-menu {
  display: grid;
  gap: 4px;
}

html[data-theme] body:not(.page-admin) .theme-menu button {
  width: 100%;
  min-height: 30px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--sidebar-text);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

html[data-theme] body:not(.page-admin) .theme-menu button:hover,
html[data-theme] body:not(.page-admin) .theme-menu button.is-active {
  border-color: var(--sidebar-border);
  background: var(--sidebar-accent-glow);
  color: var(--sidebar-text-hover);
}

html[data-theme] body:not(.page-admin) .theme-icon-dark,
html[data-theme] body:not(.page-admin) .theme-icon-chinese,
html[data-theme="dark"] body:not(.page-admin) .theme-icon-light,
html[data-theme="chinese"] body:not(.page-admin) .theme-icon-light {
  display: none;
}

html[data-theme="dark"] body:not(.page-admin) .theme-icon-dark {
  display: block;
}

html[data-theme="chinese"] body:not(.page-admin) .theme-icon-chinese {
  display: block;
}

html[data-theme] body:not(.page-admin) .page-hd,
html[data-theme] body:not(.page-admin) .card-v3,
html[data-theme] body:not(.page-admin) .media-card,
html[data-theme] body:not(.page-admin) .record-dialog-panel,
html[data-theme] body:not(.page-admin) .redeem-panel,
html[data-theme] body:not(.page-admin) .jpt-layer-panel,
html[data-theme] body:not(.page-admin) .jpt-toast,
html[data-theme] body:not(.page-admin) .canvas-panel,
html[data-theme] body:not(.page-admin) .chat-main,
html[data-theme] body:not(.page-admin) .package-card,
html[data-theme] body:not(.page-admin) .credits-item,
html[data-theme] body:not(.page-admin) .stat-card,
html[data-theme] body:not(.page-admin) .empty-state,
html[data-theme] body:not(.page-admin) .table-wrap {
  border: 1px solid var(--line);
  background: var(--main-surface);
  color: var(--text);
  box-shadow: var(--shadow-card);
}

html[data-theme="dark"] body:not(.page-admin) .page-hd,
html[data-theme="dark"] body:not(.page-admin) .card-v3,
html[data-theme="dark"] body:not(.page-admin) .media-card,
html[data-theme="dark"] body:not(.page-admin) .record-dialog-panel,
html[data-theme="dark"] body:not(.page-admin) .redeem-panel,
html[data-theme="dark"] body:not(.page-admin) .jpt-layer-panel,
html[data-theme="dark"] body:not(.page-admin) .jpt-toast,
html[data-theme="dark"] body:not(.page-admin) .canvas-panel,
html[data-theme="dark"] body:not(.page-admin) .chat-main,
html[data-theme="dark"] body:not(.page-admin) .package-card,
html[data-theme="dark"] body:not(.page-admin) .credits-item,
html[data-theme="dark"] body:not(.page-admin) .stat-card,
html[data-theme="dark"] body:not(.page-admin) .empty-state,
html[data-theme="dark"] body:not(.page-admin) .table-wrap {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.018)), var(--main-surface);
}

html[data-theme] body:not(.page-admin) .card-v3-head,
html[data-theme] body:not(.page-admin) .record-dialog-head,
html[data-theme] body:not(.page-admin) .record-dialog-foot,
html[data-theme] body:not(.page-admin) .redeem-head {
  border-color: var(--line);
  background: var(--panel-muted);
}

html[data-theme] body:not(.page-admin) .record-dialog-body,
html[data-theme] body:not(.page-admin) .redeem-form,
html[data-theme] body:not(.page-admin) .jpt-layer-head,
html[data-theme] body:not(.page-admin) .jpt-layer-actions {
  background: var(--panel-bg);
}

html[data-theme] body:not(.page-admin) .record-full-prompt,
html[data-theme] body:not(.page-admin) .record-detail-grid > div,
html[data-theme] body:not(.page-admin) .record-error,
html[data-theme] body:not(.page-admin) .record-dialog-image,
html[data-theme] body:not(.page-admin) .error-dialog-body,
html[data-theme] body:not(.page-admin) .jpt-layer-panel p,
html[data-theme] body:not(.page-admin) .redeem-form .field,
html[data-theme] body:not(.page-admin) .content-slot,
html[data-theme] body:not(.page-admin) .history-empty-inline {
  border: 1px solid var(--line);
  background: var(--panel-inset);
  color: var(--text-soft);
}

html[data-theme] body:not(.page-admin) .alert,
html[data-theme] body:not(.page-admin) .generation-notice,
html[data-theme] body:not(.page-admin) .cost-hint,
html[data-theme] body:not(.page-admin) .field-hint:not(.hidden),
html[data-theme] body:not(.page-admin) .hint:not(.hidden),
html[data-theme] body:not(.page-admin) .canvas-project-save-state,
html[data-theme] body:not(.page-admin) .jpt-toast {
  border: 1px solid var(--notice-border);
  background: var(--notice-bg);
  color: var(--text-soft);
}

html[data-theme] body:not(.page-admin) .record-action-dropdown,
html[data-theme] body:not(.page-admin) .record-action-dropdown button,
html[data-theme] body:not(.page-admin) .record-action-dropdown a {
  border-color: var(--line);
  background: var(--panel-bg);
  color: var(--text-soft);
}

html[data-theme] body:not(.page-admin) .record-action-dropdown button:hover,
html[data-theme] body:not(.page-admin) .record-action-dropdown a:hover {
  background: var(--panel-muted);
  color: var(--text);
}

html[data-theme] body:not(.page-admin) .media-card-body,
html[data-theme] body:not(.page-admin) #audioHistoryList .media-card > div:first-child,
html[data-theme] body.page-app:not(.page-admin) #historyList .media-card > div:first-child,
html[data-theme] body:not(.page-admin) #videoHistoryList .media-card > div:first-child {
  background: var(--panel-inset) !important;
}

html[data-theme] body:not(.page-admin) .media-card > img,
html[data-theme] body:not(.page-admin) .media-card > video {
  background-color: var(--panel-muted);
}

html[data-theme] body:not(.page-admin) .record-detail-grid {
  gap: 10px;
}

html[data-theme] body:not(.page-admin) .record-detail-grid > div strong,
html[data-theme] body:not(.page-admin) .record-full-prompt p {
  color: var(--text);
}

html[data-theme] body:not(.page-admin) .record-full-prompt > span,
html[data-theme] body:not(.page-admin) .record-detail-grid > div span {
  color: var(--text-muted);
}

html[data-theme] body:not(.page-admin) .page-hd h1,
html[data-theme] body:not(.page-admin) .card-v3-head h3,
html[data-theme] body:not(.page-admin) .media-card .prompt,
html[data-theme] body:not(.page-admin) .media-card-body .prompt,
html[data-theme] body:not(.page-admin) .record-dialog-head h2,
html[data-theme] body:not(.page-admin) .edit-upload-box strong {
  color: var(--text);
}

html[data-theme] body:not(.page-admin) .page-hd p,
html[data-theme] body:not(.page-admin) .card-v3-head .sub,
html[data-theme] body:not(.page-admin) .card-v3-head .eyebrow,
html[data-theme] body:not(.page-admin) .media-card .meta,
html[data-theme] body:not(.page-admin) .media-card-body .meta,
html[data-theme] body:not(.page-admin) .field-hint,
html[data-theme] body:not(.page-admin) .hint {
  color: var(--text-muted);
}

html[data-theme] body:not(.page-admin) input[type="text"],
html[data-theme] body:not(.page-admin) input[type="password"],
html[data-theme] body:not(.page-admin) input[type="email"],
html[data-theme] body:not(.page-admin) input[type="number"],
html[data-theme] body:not(.page-admin) input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]):not([type="hidden"]),
html[data-theme] body:not(.page-admin) select,
html[data-theme] body:not(.page-admin) textarea,
html[data-theme] body:not(.page-admin) .edit-upload-box,
html[data-theme] body:not(.page-admin) .video-reference-modes,
html[data-theme] body:not(.page-admin) .mode-toggle label,
html[data-theme] body:not(.page-admin) .video-reference-modes label,
html[data-theme] body:not(.page-admin) .chip-group label,
html[data-theme] body:not(.page-admin) .cost-hint,
html[data-theme] body:not(.page-admin) .generation-notice,
html[data-theme] body:not(.page-admin) .alert,
html[data-theme] body:not(.page-admin) .badge-balance,
html[data-theme] body:not(.page-admin) .record-dialog-close,
html[data-theme] body:not(.page-admin) .record-action-trigger {
  border: 1px solid var(--line);
  background: var(--panel-bg);
  color: var(--text);
  box-shadow: none;
}

html[data-theme] body:not(.page-admin) .edit-upload-box,
html[data-theme] body:not(.page-admin) .video-reference-modes,
html[data-theme] body:not(.page-admin) .mode-toggle label,
html[data-theme] body:not(.page-admin) .video-reference-modes label,
html[data-theme] body:not(.page-admin) .chip-group label {
  background: var(--panel-inset);
}

html[data-theme] body:not(.page-admin) textarea,
html[data-theme] body:not(.page-admin) input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]):not([type="hidden"]),
html[data-theme] body:not(.page-admin) select {
  background: var(--panel-bg);
}

html[data-theme] body:not(.page-admin) input:focus,
html[data-theme] body:not(.page-admin) select:focus,
html[data-theme] body:not(.page-admin) textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

html[data-theme] body:not(.page-admin) .mode-toggle label:has(input:checked),
html[data-theme] body:not(.page-admin) .video-reference-modes label:has(input:checked),
html[data-theme] body:not(.page-admin) .chip-group label:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary-dark);
}

html[data-theme] body:not(.page-admin) .btn-primary,
html[data-theme] body:not(.page-admin) .btn.primary,
html[data-theme] body:not(.page-admin) .button.primary {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

html[data-theme="dark"] body:not(.page-admin) .btn-primary,
html[data-theme="dark"] body:not(.page-admin) .btn.primary,
html[data-theme="dark"] body:not(.page-admin) .button.primary {
  color: #0b111d;
}

html[data-theme] body:not(.page-admin) .btn-secondary,
html[data-theme] body:not(.page-admin) .btn.secondary,
html[data-theme] body:not(.page-admin) .button.secondary,
html[data-theme] body:not(.page-admin) .btn-ghost,
html[data-theme] body:not(.page-admin) .btn.ghost {
  border-color: var(--line);
  background: var(--main-surface);
  color: var(--text-soft);
}

html[data-theme] body:not(.page-admin) .btn-secondary:hover,
html[data-theme] body:not(.page-admin) .btn.secondary:hover,
html[data-theme] body:not(.page-admin) .button.secondary:hover,
html[data-theme] body:not(.page-admin) .btn-ghost:hover,
html[data-theme] body:not(.page-admin) .btn.ghost:hover,
html[data-theme] body:not(.page-admin) .edit-upload-box:hover {
  border-color: var(--line-strong);
  background: var(--main-surface-soft);
  color: var(--text);
}

html[data-theme] body.page-app:not(.page-admin) #historyList.grid-auto,
html[data-theme] body:not(.page-admin) #videoHistoryList.grid-auto,
html[data-theme] body:not(.page-admin) #audioHistoryList.grid-auto {
  grid-template-columns: 1fr;
  gap: 12px;
}

html[data-theme] body.page-app:not(.page-admin) .grid-2:has(#historyList),
html[data-theme] body.page-video:not(.page-admin) .grid-2:has(#videoHistoryList),
html[data-theme] body.page-audio:not(.page-admin) .grid-2:has(#audioHistoryList) {
  grid-template-columns: minmax(0, 1fr) clamp(260px, 28vw, 340px);
  align-items: start;
}

html[data-theme] body.page-app:not(.page-admin) .grid-2:has(#historyList) > section:last-child,
html[data-theme] body.page-video:not(.page-admin) .grid-2:has(#videoHistoryList) > section:last-child,
html[data-theme] body.page-audio:not(.page-admin) .grid-2:has(#audioHistoryList) > section:last-child {
  width: 100%;
}

html[data-theme] body.page-app:not(.page-admin) #historyList .media-card,
html[data-theme] body:not(.page-admin) #videoHistoryList .media-card,
html[data-theme] body:not(.page-admin) #audioHistoryList .media-card {
  width: 100%;
  display: grid;
  grid-template-columns: clamp(112px, 38%, 160px) minmax(0, 1fr);
  align-items: stretch;
  overflow: hidden;
}

html[data-theme] body.page-app:not(.page-admin) #historyList .media-card > img,
html[data-theme] body.page-app:not(.page-admin) #historyList .media-card > video,
html[data-theme] body.page-app:not(.page-admin) #historyList .media-card > div:first-child,
html[data-theme] body:not(.page-admin) #videoHistoryList .media-card > video,
html[data-theme] body:not(.page-admin) #audioHistoryList .media-card > div:first-child,
html[data-theme] body:not(.page-admin) #videoHistoryList .media-card > div:first-child {
  width: 100%;
  height: 100%;
  min-height: 112px;
  max-height: 160px;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-right: 1px solid var(--line);
  background: var(--main-surface-soft) !important;
}

html[data-theme] body:not(.page-admin) #audioHistoryList .media-card > div:first-child {
  padding: 12px !important;
  align-content: center;
}

html[data-theme] body:not(.page-admin) #audioHistoryList .media-card audio {
  width: 100%;
  min-width: 0;
}

html[data-theme] body.page-app:not(.page-admin) #historyList .media-card-body,
html[data-theme] body:not(.page-admin) #videoHistoryList .media-card-body,
html[data-theme] body:not(.page-admin) #audioHistoryList .media-card-body {
  min-width: 0;
  padding: 10px 12px;
  display: grid;
  align-content: space-between;
  gap: 8px;
}

html[data-theme] body.page-app:not(.page-admin) #historyList .media-card .prompt,
html[data-theme] body:not(.page-admin) #videoHistoryList .media-card .prompt,
html[data-theme] body:not(.page-admin) #audioHistoryList .media-card .prompt {
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

html[data-theme] body.page-app:not(.page-admin) #historyList .media-card .meta,
html[data-theme] body:not(.page-admin) #videoHistoryList .media-card .meta,
html[data-theme] body:not(.page-admin) #audioHistoryList .media-card .meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

@media (max-width: 560px) {
  html[data-theme] body.page-app:not(.page-admin) #historyList .media-card,
  html[data-theme] body:not(.page-admin) #videoHistoryList .media-card,
  html[data-theme] body:not(.page-admin) #audioHistoryList .media-card {
    grid-template-columns: 104px minmax(0, 1fr);
  }
}

@media (max-width: 960px) {
  html[data-theme] body.page-app:not(.page-admin) .grid-2:has(#historyList),
  html[data-theme] body.page-video:not(.page-admin) .grid-2:has(#videoHistoryList),
  html[data-theme] body.page-audio:not(.page-admin) .grid-2:has(#audioHistoryList) {
    grid-template-columns: 1fr;
  }
}

/* ═══════════════════════════════════════
   NEW CHINESE VISUAL DETAILS
   ═══════════════════════════════════════ */

html[data-theme="chinese"] body:not(.page-admin) {
  --cn-red: #b84a3a;
  --cn-red-soft: rgba(184, 74, 58, 0.10);
  --cn-gold: #a77832;
  --cn-ink: #2f3433;
  --cn-paper-line: rgba(93, 76, 58, 0.08);
  --cn-corner: rgba(184, 74, 58, 0.42);
}

html[data-theme="chinese"] body:not(.page-admin) .main-area {
  background:
    linear-gradient(90deg, var(--cn-paper-line) 1px, transparent 1px),
    linear-gradient(var(--cn-paper-line) 1px, transparent 1px),
    var(--main-bg);
  background-size: 28px 28px;
}

html[data-theme="chinese"] body:not(.page-admin) .page-hd,
html[data-theme="chinese"] body:not(.page-admin) .card-v3,
html[data-theme="chinese"] body:not(.page-admin) .media-card,
html[data-theme="chinese"] body:not(.page-admin) .record-dialog-panel,
html[data-theme="chinese"] body:not(.page-admin) .redeem-panel {
  position: relative;
  border-color: color-mix(in srgb, var(--line) 74%, var(--cn-gold));
}

html[data-theme="chinese"] body:not(.page-admin) .page-hd::before,
html[data-theme="chinese"] body:not(.page-admin) .card-v3::before,
html[data-theme="chinese"] body:not(.page-admin) .record-dialog-panel::before,
html[data-theme="chinese"] body:not(.page-admin) .redeem-panel::before {
  content: "";
  position: absolute;
  top: 10px;
  right: 10px;
  width: 22px;
  height: 22px;
  pointer-events: none;
  opacity: 0.72;
  background:
    linear-gradient(var(--cn-corner), var(--cn-corner)) top right / 16px 1px no-repeat,
    linear-gradient(var(--cn-corner), var(--cn-corner)) top right / 1px 16px no-repeat,
    linear-gradient(var(--cn-corner), var(--cn-corner)) bottom left / 12px 1px no-repeat,
    linear-gradient(var(--cn-corner), var(--cn-corner)) bottom left / 1px 12px no-repeat;
}

html[data-theme="chinese"] body:not(.page-admin) .page-hd::after {
  content: "创";
  position: absolute;
  right: clamp(24px, 3vw, 36px);
  bottom: clamp(18px, 2.4vw, 28px);
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 1px solid var(--cn-red);
  border-radius: 6px;
  color: var(--cn-red);
  font-family: "STKaiti", "KaiTi", "Songti SC", serif;
  font-size: 17px;
  line-height: 1;
  opacity: 0.42;
  transform: rotate(-5deg);
  pointer-events: none;
}

html[data-theme="chinese"] body:not(.page-admin) .card-v3-head {
  background:
    linear-gradient(90deg, var(--cn-red-soft), transparent 42%),
    var(--main-surface);
}

html[data-theme="chinese"] body:not(.page-admin) .card-v3-head h3,
html[data-theme="chinese"] body:not(.page-admin) .page-hd h1,
html[data-theme="chinese"] body:not(.page-admin) .record-dialog-head h2 {
  font-family: "Songti SC", "STSong", "Noto Serif SC", "PingFang SC", serif;
  color: var(--cn-ink);
}

html[data-theme="chinese"] body:not(.page-admin) .card-v3-head h3::before {
  content: "";
  display: inline-block;
  width: 4px;
  height: 1em;
  margin-right: 8px;
  border-radius: 999px;
  background: var(--cn-red);
  vertical-align: -0.12em;
}

html[data-theme="chinese"] body:not(.page-admin) .card-v3-head .sub,
html[data-theme="chinese"] body:not(.page-admin) .card-v3-head .eyebrow,
html[data-theme="chinese"] body:not(.page-admin) .page-hd p {
  color: color-mix(in srgb, var(--text-muted) 72%, var(--cn-red));
}

html[data-theme="chinese"] body:not(.page-admin) .btn-primary,
html[data-theme="chinese"] body:not(.page-admin) .btn.primary,
html[data-theme="chinese"] body:not(.page-admin) .button.primary {
  border-color: var(--cn-red);
  background: var(--cn-red);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.16), var(--shadow-sm);
}

html[data-theme="chinese"] body:not(.page-admin) .btn-primary:hover,
html[data-theme="chinese"] body:not(.page-admin) .btn.primary:hover,
html[data-theme="chinese"] body:not(.page-admin) .button.primary:hover {
  border-color: color-mix(in srgb, var(--cn-red) 82%, #000);
  background: color-mix(in srgb, var(--cn-red) 88%, #000);
}

html[data-theme="chinese"] body:not(.page-admin) .btn-primary,
html[data-theme="chinese"] body:not(.page-admin) .btn.primary,
html[data-theme="chinese"] body:not(.page-admin) .button.primary {
  color: #fff8f0;
}

html[data-theme="chinese"] body:not(.page-admin) input:focus,
html[data-theme="chinese"] body:not(.page-admin) select:focus,
html[data-theme="chinese"] body:not(.page-admin) textarea:focus,
html[data-theme="chinese"] body:not(.page-admin) .mode-toggle label:has(input:checked),
html[data-theme="chinese"] body:not(.page-admin) .video-reference-modes label:has(input:checked),
html[data-theme="chinese"] body:not(.page-admin) .chip-group label:has(input:checked) {
  border-color: var(--cn-red);
  box-shadow: 0 0 0 3px var(--cn-red-soft);
}

html[data-theme="chinese"] body:not(.page-admin) .mode-toggle label:has(input:checked),
html[data-theme="chinese"] body:not(.page-admin) .video-reference-modes label:has(input:checked),
html[data-theme="chinese"] body:not(.page-admin) .chip-group label:has(input:checked) {
  background: var(--cn-red-soft);
  color: color-mix(in srgb, var(--cn-red) 84%, var(--text));
}

html[data-theme="chinese"] body:not(.page-admin) .sidebar-nav-item.active {
  color: var(--sidebar-text-hover);
  box-shadow: inset 2px 0 0 var(--cn-red);
}

html[data-theme="chinese"] body:not(.page-admin) .sidebar-nav-item.active::after {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 2px;
  background: var(--cn-red);
  transform: rotate(45deg);
  box-shadow: 0 0 0 3px var(--cn-red-soft);
}

html[data-theme="chinese"] body:not(.page-admin) .badge-balance .num,
html[data-theme="chinese"] body:not(.page-admin) .cost-hint strong,
html[data-theme="chinese"] body:not(.page-admin) .sidebar-balance strong {
  color: var(--cn-red);
}

html[data-theme="chinese"] body:not(.page-admin) .edit-upload-icon,
html[data-theme="chinese"] body:not(.page-admin) .video-reference-icon,
html[data-theme="chinese"] body:not(.page-admin) .status-badge.succeeded {
  background: var(--cn-red-soft);
  color: var(--cn-red);
}

html[data-theme="chinese"] body:not(.page-admin) .media-card {
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.02),
    var(--shadow-card);
}

html[data-theme="chinese"] body:not(.page-admin) .media-card:hover {
  border-color: color-mix(in srgb, var(--line) 52%, var(--cn-red));
}

body:not(.page-admin) .edit-preview-item video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

body:not(.page-admin) .edit-preview-item.is-audio {
  display: grid;
  place-items: center;
  gap: 4px;
  padding: 8px;
  text-align: center;
}

body:not(.page-admin) .edit-preview-media-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  min-height: 22px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-size: 11px;
  font-weight: 700;
}

body:not(.page-admin) .edit-preview-item.is-audio small {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-muted);
  font-size: 10px;
}

/* Sidebar collapse and canvas workspace expansion */
body:not(.page-admin).sidebar-collapsed .sidebar {
  transform: translateX(calc(-1 * var(--sidebar-width)));
}

body:not(.page-admin).sidebar-collapsed .main-area,
body.page-designer-canvas.sidebar-collapsed .main-area {
  margin-left: 0;
}

body:not(.page-admin).sidebar-collapsed .sidebar-toggle {
  display: grid;
}

body.page-canvas .main-area {
  padding: 12px 14px;
}

body.page-canvas .canvas-page {
  gap: 10px;
}

body.page-canvas .page-hd {
  margin-bottom: 8px;
}

body.page-canvas .canvas-layout {
  gap: 10px;
  min-height: calc(100vh - 132px);
}

body.page-canvas .canvas-stage-wrap {
  border-width: 1px;
  border-radius: 10px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.12);
}

body.page-canvas .canvas-toolbar {
  padding: 9px 10px;
}

body.page-canvas .canvas-stage-shell {
  min-height: calc(100vh - 190px);
}

body.page-canvas.sidebar-collapsed .canvas-layout {
  grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
}

body.page-designer-canvas .designer-topbar {
  height: 54px;
  padding: 0 12px;
}

body.page-designer-canvas .main-area {
  margin-left: var(--sidebar-width);
  padding: 0;
  overflow: hidden;
  background: #05070c;
}

body.page-designer-canvas::before,
body.page-designer-canvas::after {
  display: none;
}

body.page-designer-canvas.sidebar-collapsed .main-area {
  margin-left: 0;
}

body.page-designer-canvas .designer-workbench {
  height: calc(100vh - 54px);
  height: calc(100dvh - 54px);
}

body.page-designer-canvas .designer-stage-wrap {
  border: 0;
}

body.page-app #historyList .media-card-compact,
body.page-video #videoHistoryList .media-card-compact,
body.page-audio #audioHistoryList .media-card-compact {
  display: grid;
  grid-template-columns: clamp(112px, 38%, 160px) minmax(0, 1fr);
  grid-template-rows: auto;
  align-items: stretch;
  min-height: 112px;
  overflow: hidden;
  border-radius: 12px;
}

body.page-app #historyList .media-card-compact > .media-card-thumb,
body.page-video #videoHistoryList .media-card-compact > .media-card-thumb,
body.page-audio #audioHistoryList .media-card-compact > .media-card-thumb {
  min-width: 0;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: var(--main-surface-soft);
  align-self: start;
  cursor: zoom-in;
}

body.page-app #historyList .media-card-compact > .media-card-thumb > img,
body.page-app #historyList .media-card-compact > .media-card-thumb > video,
body.page-video #videoHistoryList .media-card-compact > .media-card-thumb > video,
body.page-audio #audioHistoryList .media-card-compact > .media-card-thumb > audio {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

body.page-video #videoHistoryList .media-card-video-thumb {
  pointer-events: none;
}

body.page-audio #audioHistoryList .media-card-compact > .media-card-thumb {
  display: grid;
  place-items: center;
  gap: 8px;
  padding: 10px;
}

body.page-app #historyList .media-card-compact .media-card-body,
body.page-video #videoHistoryList .media-card-compact .media-card-body,
body.page-audio #audioHistoryList .media-card-compact .media-card-body {
  display: grid;
  align-content: space-between;
  gap: 8px;
  padding: 12px 14px;
  min-width: 0;
}

body.page-app #historyList .media-card-compact .media-card-body .prompt,
body.page-video #videoHistoryList .media-card-compact .media-card-body .prompt,
body.page-audio #audioHistoryList .media-card-compact .media-card-body .prompt {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
  white-space: normal;
  line-height: 1.45;
  min-height: 3.8em;
}

body.page-app #historyList .media-card > img,
body.page-app #historyList .media-card > video,
body.page-video #videoHistoryList .media-card > video,
body.page-audio #audioHistoryList .media-card > div:first-child {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  display: block;
}

body.page-audio #audioHistoryList .media-card > div:first-child {
  display: grid;
  align-items: center;
  justify-items: center;
  padding: 12px;
}

.media-card-summary {
  justify-content: space-between;
  gap: 6px;
  min-width: 0;
}

.media-card-summary time {
  color: var(--text-muted);
  font-size: 10px;
  white-space: nowrap;
}

.creation-asset-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.compact-reference-upload {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 auto;
  min-width: 0;
}

.compact-reference-upload .edit-upload-box {
  width: 78px;
  height: 78px;
  padding: 8px;
  flex: 0 0 78px;
  display: grid;
  place-items: center;
  text-align: center;
  gap: 4px;
  border-radius: 10px;
}

.compact-reference-upload .edit-upload-icon {
  width: 28px;
  height: 28px;
  font-size: 20px;
}

.compact-reference-upload .edit-upload-box strong {
  font-size: 12px;
  line-height: 1;
}

.compact-reference-upload .edit-upload-box small {
  display: none;
}

.compact-reference-upload .edit-upload-preview {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  overflow-x: auto;
  padding: 2px 0;
}

.compact-reference-upload .edit-preview-item,
.compact-reference-upload .edit-upload-preview img {
  width: 64px;
  height: 64px;
  aspect-ratio: 1 / 1;
  border-radius: 9px;
  object-fit: cover;
  flex: 0 0 64px;
}

.prompt-optimize-inline {
  margin: 0;
  align-self: center;
  flex: 0 0 auto;
}

.prompt-optimize-inline .btn {
  min-height: 42px;
  padding-inline: 18px;
}

.compact-param-row {
  grid-template-columns: repeat(auto-fit, minmax(126px, 1fr));
  gap: 10px;
}

.compact-param-field-wide {
  min-width: 180px;
}

/* ── Home dashboard layout ── */
body.page-app {
  background: #0b1220;
}

body.page-app::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  background: var(--home-bg-image) center var(--home-ve-bg-y) / cover no-repeat;
  filter: blur(var(--home-bg-blur));
}

body.page-app::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(circle at 50% 18%, rgba(255,255,255,.12), transparent 34%),
    linear-gradient(180deg, rgba(7,14,28,.10), rgba(255,255,255,var(--home-ve-bg-fade)) 78%, rgba(255,255,255,.42));
  pointer-events: none;
}

body.page-app .main-area {
  background:
    linear-gradient(180deg, rgba(7,14,28,.08), rgba(255,255,255,var(--home-ve-bg-fade)) 78%, rgba(255,255,255,.36)),
    var(--home-bg-image) center var(--home-ve-bg-y) / cover fixed no-repeat !important;
}

.home-dashboard {
  display: grid;
  width: min(100%, 1180px);
  margin: 0 auto;
  gap: clamp(14px, 1.6vw, 22px);
  padding-top: clamp(10px, 2vh, 24px);
}

.home-dashboard > .page-hd {
  width: min(100%, 1120px);
  margin: 0 auto;
  padding: 10px 14px;
  border: 1px solid rgba(255,255,255,.34);
  border-radius: 22px;
  background: rgba(255,255,255,.34);
  backdrop-filter: blur(18px);
  box-shadow: 0 12px 36px rgba(15,23,42,.08);
}

.home-dashboard > .page-hd h1 {
  font-size: clamp(22px, 3.2vw, 44px);
  font-weight: 500;
  color: rgba(255,255,255,.92);
  text-shadow: 0 2px 18px rgba(15,23,42,.28);
}

.home-dashboard > .page-hd p {
  color: rgba(255,255,255,.76);
}

.home-dashboard .page-hd-actions .btn,
.home-dashboard .badge-balance {
  min-height: 36px;
  border-color: rgba(255,255,255,.42);
  background: rgba(255,255,255,.58);
  backdrop-filter: blur(12px);
}

.home-hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  width: min(100%, 780px);
  margin: 0 auto;
  gap: 12px;
}

.home-hero-grid:has(> :only-child) {
  grid-template-columns: 1fr;
}

.home-feature-card {
  position: relative;
  min-height: 92px;
  display: grid;
  align-content: end;
  gap: 4px;
  padding: 16px 18px;
  border: 1px solid rgba(255,255,255,.28);
  border-radius: 20px;
  overflow: hidden;
  text-decoration: none;
  color: var(--text);
  background: rgba(255,255,255,.34);
  backdrop-filter: blur(18px);
  box-shadow: 0 14px 40px rgba(15,23,42,.08);
  transition: transform var(--duration-normal) var(--ease-out-expo),
              border-color var(--duration-normal) var(--ease-out-expo),
              box-shadow var(--duration-normal) var(--ease-out-expo);
}

.home-feature-card::before {
  display: none;
}

.home-feature-card:hover {
  transform: translateY(-3px);
  border-color: rgba(59, 130, 246, 0.32);
  box-shadow: var(--shadow-lg);
}

.home-feature-agent {
  background: rgba(255,255,255,.36);
}

.home-feature-canvas {
  background: rgba(255,255,255,.36);
}

.home-feature-kicker,
.home-section-title span {
  position: relative;
  z-index: 1;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.home-feature-card strong {
  position: relative;
  z-index: 1;
  font-size: clamp(16px, 1.8vw, 22px);
  line-height: 1.05;
  font-weight: 700;
  color: var(--text);
}

.home-feature-card small {
  position: relative;
  z-index: 1;
  max-width: 520px;
  color: var(--text-soft);
  font-size: 12px;
  line-height: 1.45;
}

.home-console {
  overflow: visible;
  width: min(100%, 760px);
  margin: 0 auto;
  border: 1px solid rgba(255,255,255,.42);
  border-radius: 26px;
  background: rgba(255,255,255,.72);
  backdrop-filter: blur(26px);
  box-shadow: 0 24px 70px rgba(15,23,42,.14);
}

.home-project-thread {
  width: min(100%, 820px);
  margin: 0 auto;
  border: 1px solid rgba(255,255,255,.32);
  border-radius: 22px;
  background: rgba(255,255,255,.46);
  backdrop-filter: blur(22px);
  box-shadow: 0 18px 54px rgba(15,23,42,.10);
}

.sidebar-history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.sidebar-history-head a {
  color: inherit;
  opacity: .72;
  text-decoration: none;
  font-size: 11px;
  font-weight: 800;
}

.sidebar-history-list {
  display: grid;
  gap: 8px;
  margin: 4px 10px 10px;
}

.sidebar-history-empty {
  padding: 8px 10px;
  color: var(--sidebar-text);
  font-size: 12px;
  opacity: .72;
}

.sidebar-history-item {
  width: 100%;
  min-width: 0;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 14px;
  background: transparent;
  color: var(--sidebar-text);
  text-align: left;
  cursor: pointer;
}

.sidebar-history-item:hover,
.sidebar-history-item.active {
  background: var(--sidebar-accent-glow);
  border-color: var(--sidebar-border);
  color: var(--sidebar-text-hover);
}

.sidebar-history-thumb {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 12px;
  background: var(--sidebar-surface);
  color: var(--sidebar-text-hover);
  font-size: 13px;
  font-weight: 900;
}

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

.sidebar-history-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.sidebar-history-copy strong,
.sidebar-history-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-history-copy strong {
  font-size: 13px;
  color: inherit;
}

.sidebar-history-copy small {
  font-size: 11px;
  color: var(--sidebar-text);
}

.home-project-thread {
  overflow: hidden;
}

.home-project-body {
  display: grid;
  gap: 10px;
  padding: 14px 18px;
}

.home-project-message {
  max-width: 960px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--main-surface-soft);
}

.home-project-message p {
  margin: 0;
  color: var(--text);
  font-size: 13px;
  line-height: 1.6;
}

.home-project-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.home-project-steps span {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text-soft);
  background: var(--main-surface);
  font-size: 12px;
  font-weight: 800;
}

.home-project-steps i {
  width: 8px;
  height: 8px;
  display: inline-block;
  border-radius: 50%;
  background: var(--text-muted);
}

.home-project-steps span.is-done i {
  background: #22c55e;
}

.home-project-preview {
  max-width: 520px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--main-surface);
}

.home-project-preview img,
.home-project-preview video {
  width: 100%;
  display: block;
  max-height: 360px;
  object-fit: contain;
}

.home-project-preview audio {
  width: 100%;
  display: block;
  padding: 12px;
}

.home-console-head {
  align-items: center;
  flex-wrap: wrap;
}

.home-mode-tabs,
.home-showcase-tabs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.home-mode-tabs button,
.home-showcase-tabs button,
.home-showcase-tabs a,
.home-resource-links a {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--main-surface);
  color: var(--text-soft);
  text-decoration: none;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}

.home-mode-tabs button:hover,
.home-showcase-tabs button:hover,
.home-showcase-tabs a:hover,
.home-resource-links a:hover {
  border-color: rgba(59, 130, 246, 0.36);
  color: var(--primary);
}

.home-mode-tabs button.active,
.home-showcase-tabs button.active,
.home-showcase-tabs a.active {
  border-color: transparent;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  box-shadow: 0 6px 16px rgba(59, 130, 246, 0.18);
}

.home-console-body {
  padding: 0;
}

.home-mode-panel {
  display: none;
  padding: 12px 18px;
}

.home-mode-panel.is-active {
  display: block;
}

.home-embed-frame {
  width: 100%;
  min-height: min(980px, calc(100vh - 150px));
  display: block;
  border: 0;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  background: var(--main-bg);
}

.home-chat-frame {
  min-height: min(860px, calc(100vh - 150px));
}

.home-video-frame {
  min-height: min(1120px, calc(100vh - 120px));
}

.home-console #generateForm,
.home-create-form {
  display: grid;
  gap: 10px;
  padding: 18px;
}

.home-console .prompt-field-compact textarea,
.home-prompt-field textarea {
  min-height: 72px;
  max-height: 288px;
  border-color: transparent;
  border-radius: 18px;
  background: rgba(255,255,255,.62);
  font-size: 14px;
  resize: none;
  overflow-y: auto;
}

.home-prompt-shell {
  position: relative;
}

.home-prompt-shell textarea {
  width: 100%;
  padding-right: 48px;
}

.home-prompt-expand {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(15,23,42,.08);
  border-radius: 9px;
  background: rgba(255,255,255,.72);
  color: rgba(17,24,39,.56);
  cursor: pointer;
}

.home-prompt-expand:hover {
  color: var(--primary);
  border-color: rgba(59,130,246,.28);
  background: #fff;
}

.home-prompt-expand svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.home-console #generateButton,
.home-console #homeGenerateButton {
  width: auto;
  min-width: 76px;
  max-width: none;
  min-height: 40px;
  justify-self: center;
  padding: 0 18px;
  border-radius: 999px;
  overflow: visible;
  position: relative;
  text-indent: 0;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 900;
}

.home-console #homeGenerateButton::after {
  content: none;
}

.home-create-alert {
  margin: clamp(14px, 1.8vw, 22px) clamp(16px, 2vw, 24px) 0;
}

.home-create-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.home-create-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-left: auto;
}

@media (max-width: 720px) {
  .home-create-actions {
    width: 100%;
  }
}

.home-file-tool {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--main-surface);
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.home-file-tool input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.home-file-tool span {
  width: 18px;
  height: 18px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  line-height: 1;
}

.home-file-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.home-reference-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.home-file-chip {
  max-width: min(100%, 260px);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--main-surface-soft);
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 700;
}

.home-file-chip.is-reference {
  cursor: pointer;
}

.home-reference-chip {
  max-width: min(100%, 280px);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--main-surface-soft);
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.home-file-chip img,
.home-reference-chip img {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  object-fit: cover;
}

.home-reference-chip strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.home-reference-chip button {
  width: 18px;
  height: 18px;
  border: 0;
  border-radius: 50%;
  background: var(--main-surface);
  color: var(--text-muted);
  cursor: pointer;
}

.home-reference-bank {
  display: grid;
  gap: 8px;
}

.home-reference-bank > span {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 900;
}

.home-reference-bank > div {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.home-reference-bank button {
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  overflow: hidden;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 14px;
  background: var(--main-surface-soft);
  cursor: pointer;
}

.home-reference-bank button:hover {
  border-color: var(--primary);
}

.home-reference-bank img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.home-model-fields {
  margin-top: 8px;
}

.home-toggle-field {
  align-content: center;
}

.home-toggle-field span {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 800;
}

.home-file-chip span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.home-file-chip button {
  width: 18px;
  height: 18px;
  border: 0;
  border-radius: 50%;
  background: var(--main-surface);
  color: var(--text-muted);
  cursor: pointer;
  line-height: 18px;
}

.home-chat-result {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.home-chat-bubble {
  display: grid;
  gap: 6px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--main-surface);
  color: var(--text);
}

.home-chat-bubble strong {
  font-size: 12px;
  color: var(--text-muted);
}

.home-chat-bubble p {
  margin: 0;
  line-height: 1.7;
  font-size: 14px;
}

.home-chat-bubble-user {
  background: var(--primary-soft);
  border-color: rgba(59, 130, 246, 0.22);
}

.home-photo-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.home-photo-presets button {
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--main-surface);
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.home-photo-presets button.is-active,
.home-photo-presets button:hover {
  border-color: rgba(59, 130, 246, 0.4);
  color: var(--primary);
  background: var(--primary-soft);
}

.home-reference-modes {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 8px;
}

.home-reference-modes label {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--main-surface);
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.home-reference-modes input {
  accent-color: var(--primary);
}

.home-audio-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(180px, .8fr) minmax(180px, .8fr);
  gap: 8px;
  margin-bottom: 8px;
}

.home-audio-demo {
  grid-column: 1 / -1;
}

.home-cost-hint {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  margin-top: 0;
  padding: 0 12px;
  white-space: nowrap;
}

.home-prompt-modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(15,23,42,.36);
  backdrop-filter: blur(14px);
}

.home-prompt-modal.hidden {
  display: none;
}

.home-prompt-modal-panel {
  width: min(60vw, 960px);
  height: min(60vh, 720px);
  min-width: min(92vw, 520px);
  min-height: min(72vh, 420px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 10px;
  padding: 14px;
  border: 1px solid rgba(255,255,255,.52);
  border-radius: 18px;
  background: rgba(255,255,255,.9);
  box-shadow: 0 30px 90px rgba(15,23,42,.22);
}

.home-prompt-modal-head,
.home-prompt-modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.home-prompt-modal-head strong {
  color: var(--text);
  font-size: 14px;
}

.home-prompt-modal-head button {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 10px;
  background: rgba(15,23,42,.06);
  color: var(--text-soft);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.home-prompt-modal textarea {
  width: 100%;
  height: 100%;
  min-height: 0;
  resize: none;
  border: 1px solid rgba(15,23,42,.08);
  border-radius: 14px;
  background: #fff;
  color: var(--text);
  font-size: 14px;
  line-height: 1.7;
}

.home-prompt-modal-actions {
  justify-content: flex-end;
}

.home-workflow-strip {
  display: grid;
  gap: 12px;
  width: min(100%, 760px);
  margin: 0 auto;
}

.home-section-title {
  display: flex;
  align-items: baseline;
  justify-content: flex-start;
  gap: 12px;
}

.home-section-title strong {
  color: var(--text);
  font-size: clamp(16px, 1.8vw, 20px);
  font-weight: 700;
}

.home-workflow-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(12px, 1.5vw, 18px);
}

.home-workflow-card {
  min-height: 112px;
  display: grid;
  align-content: space-between;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--main-surface);
  color: var(--text);
  text-decoration: none;
  box-shadow: var(--shadow-card);
  transition: transform var(--duration-fast) var(--ease-out-expo),
              border-color var(--duration-fast) var(--ease-out-expo),
              box-shadow var(--duration-fast) var(--ease-out-expo);
}

.home-workflow-card:hover {
  transform: translateY(-2px);
  border-color: rgba(16, 185, 129, 0.34);
  box-shadow: var(--shadow);
}

.home-workflow-card strong {
  font-size: 15px;
  font-weight: 800;
}

.home-workflow-card span {
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.55;
}

.home-showcase-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 320px);
  width: min(100%, 1120px);
  margin: 0 auto;
  gap: clamp(16px, 2vw, 24px);
  align-items: start;
}

.home-showcase-main,
.home-resource-panel {
  border-color: rgba(255,255,255,.38);
  background: rgba(255,255,255,.76);
  backdrop-filter: blur(22px);
}

.home-showcase-main .media-card {
  transform: scale(.96);
  transform-origin: top center;
}

.home-showcase-tabs {
  margin-bottom: 16px;
}

.home-showcase-panel {
  display: none;
}

.home-showcase-panel.is-active {
  display: grid;
}

.home-showcase-main.is-searching .home-showcase-panel {
  display: grid;
  margin-top: 14px;
}

.home-chat-records {
  gap: 10px;
}

.home-chat-record {
  width: 100%;
  display: grid;
  gap: 4px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--main-surface);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  box-shadow: var(--shadow-card);
}

.home-chat-record:hover {
  border-color: rgba(59, 130, 246, 0.34);
  box-shadow: var(--shadow);
}

.home-chat-record strong {
  font-size: 14px;
  font-weight: 800;
}

.home-chat-record span {
  color: var(--text-muted);
  font-size: 12px;
}

.home-resource-panel {
  position: sticky;
  top: 24px;
}

.home-resource-search {
  display: grid;
  gap: 8px;
}

.home-resource-search span {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 800;
}

.home-resource-search input {
  width: 100%;
  min-height: 42px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--main-surface-soft);
  color: var(--text);
  outline: none;
}

.home-resource-search input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-glow);
}

.home-resource-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

html[data-theme="dark"] body:not(.page-admin) .home-feature-card {
  background: rgba(17, 24, 39, 0.62);
}

html[data-theme="dark"] body:not(.page-admin) .home-feature-agent {
  background: rgba(17, 24, 39, 0.62);
}

html[data-theme="dark"] body:not(.page-admin) .home-feature-card::before {
  border-color: rgba(96, 165, 250, 0.20);
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.10) 1px, transparent 1px),
    linear-gradient(rgba(255, 255, 255, 0.10) 1px, transparent 1px);
}

@media (max-width: 1180px) {
  .home-workflow-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .home-showcase-grid {
    grid-template-columns: 1fr;
  }

  .home-resource-panel {
    position: static;
  }
}

@media (max-width: 720px) {
  .home-hero-grid,
  .home-workflow-grid {
    grid-template-columns: 1fr;
  }

  .home-feature-card {
    min-height: 86px;
  }

  .home-dashboard {
    padding-top: 8px;
  }

  .home-dashboard > .page-hd {
    border-radius: 18px;
  }

  .home-console,
  .home-project-thread {
    border-radius: 20px;
  }

  .home-prompt-field textarea {
    min-height: 118px;
  }

  .home-console-head {
    align-items: flex-start;
  }

  .home-mode-tabs {
    width: 100%;
  }

  .home-mode-tabs button {
    flex: 1 1 calc(50% - 8px);
  }

  .home-audio-grid {
    grid-template-columns: 1fr;
  }

  .home-create-toolbar {
    gap: 8px;
  }

  .home-file-tool,
  .home-create-toolbar .btn {
    flex: 1 1 auto;
  }
}

.record-dialog-panel {
  max-width: min(1175px, calc(100vw - 24px));
  width: min(1175px, calc(100vw - 24px));
}

.record-dialog-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.record-preview-zoom-btn {
  min-width: 44px;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.24);
  background: rgba(255,255,255,.06);
  color: var(--text);
  cursor: pointer;
  font-weight: 750;
  line-height: 1;
}

.record-preview-fullscreen-btn {
  font-size: 18px;
}

.record-dialog-image {
  height: min(65.625vh, 715px);
  min-height: min(65.625vh, 715px);
  display: grid;
  place-items: center;
  background: #070b12;
  padding: 0;
  overflow: hidden;
}

.record-dialog-body {
  padding: 8px 10px 10px;
}

.record-dialog-viewport {
  position: relative;
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  overflow: hidden;
  cursor: zoom-in;
  touch-action: none;
}

.record-dialog-viewport.is-draggable {
  cursor: grab;
}

.record-dialog-viewport.is-dragging {
  cursor: grabbing;
}

.record-dialog-image img,
.record-dialog-image video {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 10px;
}

.record-dialog-image img.dialog-media-preview,
.record-dialog-image video.dialog-media-preview {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
}

.record-dialog-image video.dialog-media-preview.is-portrait {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.record-dialog-image video.dialog-media-preview.is-landscape {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.record-dialog-image img.dialog-media-preview.is-zoomable {
  transform: translate(var(--dialog-preview-offset-x, 0px), var(--dialog-preview-offset-y, 0px)) scale(var(--dialog-preview-scale, 1));
  transform-origin: center center;
  transition: transform 120ms ease-out;
  will-change: transform;
  user-select: none;
  -webkit-user-drag: none;
  touch-action: none;
  max-width: min(100%, 1600px);
  max-height: 100%;
}

.record-dialog.is-preview-fullscreen {
  padding: 0;
}

.record-dialog.is-preview-fullscreen .record-dialog-panel,
.record-dialog-panel:fullscreen {
  width: 100vw;
  max-width: none;
  height: 100dvh;
  max-height: none;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  border-radius: 0;
  overflow: hidden;
  background: var(--main-surface);
}

.record-dialog.is-preview-fullscreen .record-dialog-body,
.record-dialog-panel:fullscreen .record-dialog-body {
  min-height: 0;
  padding: 8px 10px 10px;
  overflow: hidden;
}

.record-dialog.is-preview-fullscreen .record-dialog-image,
.record-dialog-panel:fullscreen .record-dialog-image {
  height: 100%;
  min-height: 0;
  margin-bottom: 0;
}

.record-dialog.is-preview-fullscreen .record-dialog-image video.dialog-media-preview,
.record-dialog-panel:fullscreen .record-dialog-image video.dialog-media-preview {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.record-dialog.is-preview-fullscreen .record-detail-panel,
.record-dialog-panel:fullscreen .record-detail-panel {
  display: none;
}

.record-detail-panel {
  margin-top: 12px;
}

.record-preview-actions {
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.record-preview-actions form {
  display: none;
}

@media (max-width: 1024px) {
  .sidebar-collapse-btn {
    display: none;
  }

  body:not(.page-admin).sidebar-collapsed .sidebar {
    transform: translateX(-100%);
  }

  body.page-canvas .main-area {
    padding-top: 64px;
  }

  body.page-canvas.sidebar-collapsed .canvas-layout {
    grid-template-columns: 1fr;
  }
}

/* Final home art direction: compact glass UI over the scenic background. */
html[data-theme] body.page-app:not(.page-admin) {
  background: #eef3f7;
}

html[data-theme] body.page-app:not(.page-admin)::before {
  background: var(--home-bg-image) center var(--home-ve-bg-y) / cover no-repeat;
  filter: blur(var(--home-bg-blur));
}

html[data-theme] body.page-app:not(.page-admin)::after {
  background:
    radial-gradient(circle at 50% 18%, rgba(255,255,255,.14), transparent 30%),
    linear-gradient(180deg, rgba(7,14,28,.08), rgba(255,255,255,var(--home-ve-bg-fade)) 78%, rgba(255,255,255,.40));
}

html[data-theme] body.page-app:not(.page-admin) .main-area {
  background:
    linear-gradient(180deg, rgba(7,14,28,.08), rgba(255,255,255,var(--home-ve-bg-fade)) 78%, rgba(255,255,255,.36)),
    var(--home-bg-image) center var(--home-ve-bg-y) / cover fixed no-repeat !important;
  padding-top: 28px;
}

html[data-theme] body.page-app:not(.page-admin) .home-dashboard {
  width: min(100%, 1080px);
  gap: 16px;
  padding-top: 0;
}

html[data-theme] body.page-app.sidebar-collapsed:not(.page-admin) .main-area {
  margin-left: 0;
}

html[data-theme] body.page-app:not(.page-admin) .home-dashboard > .page-hd,
html[data-theme] body.page-app:not(.page-admin) .home-feature-card,
html[data-theme] body.page-app:not(.page-admin) .home-project-thread,
html[data-theme] body.page-app:not(.page-admin) .home-console,
html[data-theme] body.page-app:not(.page-admin) .home-showcase-main,
html[data-theme] body.page-app:not(.page-admin) .home-resource-panel,
html[data-theme] body.page-app:not(.page-admin) .home-workflow-card {
  border-color: rgba(255,255,255,.42) !important;
  background: rgba(255,255,255,.58) !important;
  color: #111827;
  box-shadow: 0 22px 70px rgba(15,23,42,.12);
  backdrop-filter: blur(24px) saturate(1.1);
}

html[data-theme] body.page-app:not(.page-admin) .home-dashboard > .page-hd {
  width: min(100%, 980px);
  min-height: 84px;
  margin-top: 0;
}

html[data-theme] body.page-app:not(.page-admin) .home-dashboard > .page-hd h1 {
  color: rgba(255,255,255,.94);
  font-size: clamp(28px, 4vw, 50px);
  font-weight: 500;
  letter-spacing: 0;
  text-shadow: 0 2px 22px rgba(15,23,42,.28);
}

html[data-theme] body.page-app:not(.page-admin) .home-dashboard > .page-hd p,
html[data-theme] body.page-app:not(.page-admin) .card-v3-head .sub,
html[data-theme] body.page-app:not(.page-admin) .home-feature-kicker,
html[data-theme] body.page-app:not(.page-admin) .home-section-title span {
  color: rgba(17,24,39,.58);
}

html[data-theme] body.page-app:not(.page-admin) .home-hero-grid {
  width: min(100%, 700px);
  margin-top: 28px;
}

html[data-theme] body.page-app:not(.page-admin) .home-feature-card {
  min-height: 84px;
  border-radius: 20px;
  padding: 14px 18px;
}

html[data-theme] body.page-app:not(.page-admin) .home-feature-card strong {
  color: #111827;
  font-size: 18px;
}

html[data-theme] body.page-app:not(.page-admin) .home-feature-card small {
  color: rgba(17,24,39,.66);
}

html[data-theme] body.page-app:not(.page-admin) .home-project-thread {
  width: min(100%, 760px);
  border-radius: 22px;
}

html[data-theme] body.page-app:not(.page-admin) .home-project-message,
html[data-theme] body.page-app:not(.page-admin) .home-project-steps span,
html[data-theme] body.page-app:not(.page-admin) .home-chat-bubble,
html[data-theme] body.page-app:not(.page-admin) .home-file-tool,
html[data-theme] body.page-app:not(.page-admin) .home-file-chip,
html[data-theme] body.page-app:not(.page-admin) .home-reference-chip,
html[data-theme] body.page-app:not(.page-admin) .home-reference-bank button,
html[data-theme] body.page-app:not(.page-admin) .home-mode-tabs button,
html[data-theme] body.page-app:not(.page-admin) .home-showcase-tabs button,
html[data-theme] body.page-app:not(.page-admin) .home-showcase-tabs a,
html[data-theme] body.page-app:not(.page-admin) .home-resource-links a {
  border-color: rgba(15,23,42,.08);
  background: rgba(255,255,255,.64);
  color: #1f2937;
}

html[data-theme] body.page-app:not(.page-admin) .home-console {
  width: min(100%, 720px);
  border-radius: 28px;
  margin-top: 8px;
}

html[data-theme] body.page-app:not(.page-admin) .home-console-head {
  min-height: 58px;
  padding: 12px 18px;
  border-bottom-color: rgba(15,23,42,.07);
}

html[data-theme] body.page-app:not(.page-admin) .home-console-head h3 {
  color: #111827;
  font-size: 16px;
}

html[data-theme] body.page-app:not(.page-admin) .home-create-form {
  padding: 16px 18px 18px;
  gap: 10px;
}

html[data-theme] body.page-app:not(.page-admin) .home-prompt-field textarea {
  min-height: 72px;
  max-height: 288px;
  border: 0;
  border-radius: 20px;
  background: rgba(255,255,255,.72);
  color: #111827;
  box-shadow: inset 0 0 0 1px rgba(15,23,42,.06);
}

html[data-theme] body.page-app:not(.page-admin) .home-prompt-field textarea::placeholder {
  color: rgba(17,24,39,.42);
}

html[data-theme] body.page-app:not(.page-admin) .home-console #homeGenerateButton {
  width: auto;
  min-width: 76px;
  max-width: none;
  min-height: 40px;
  padding: 0 18px;
  border-radius: 999px;
  background: rgba(17,24,39,.92);
  box-shadow: 0 8px 22px rgba(15,23,42,.16);
}

html[data-theme] body.page-app:not(.page-admin) .home-mode-tabs button.active {
  color: #fff;
  background: rgba(17,24,39,.88) !important;
  box-shadow: 0 8px 22px rgba(15,23,42,.16);
}

html[data-theme] body.page-app:not(.page-admin) .home-workflow-strip {
  width: min(100%, 720px);
}

html[data-theme] body.page-app:not(.page-admin) .home-workflow-card {
  min-height: 70px;
  border-radius: 18px;
  padding: 14px 16px;
}

html[data-theme] body.page-app:not(.page-admin) .home-showcase-grid {
  width: min(100%, 1000px);
}

html[data-theme] body.page-app:not(.page-admin) .home-showcase-main .media-card {
  box-shadow: none;
}

@media (max-width: 720px) {
  html[data-theme] body.page-app:not(.page-admin) .main-area {
    padding-top: 72px;
  }

  html[data-theme] body.page-app:not(.page-admin) .home-dashboard {
    width: min(100%, calc(100vw - 24px));
  }
}

/* Home compact viewport: match the smaller, centered UI scale from the reference. */
html[data-theme] body.page-app:not(.page-admin)::before {
  background: var(--home-bg-image) center var(--home-ve-bg-y) / cover no-repeat;
  filter: blur(var(--home-bg-blur));
}

html[data-theme] body.page-app:not(.page-admin)::after {
  background:
    linear-gradient(180deg, rgba(7,14,28,.08), rgba(255,255,255,var(--home-ve-bg-fade)) 78%, rgba(255,255,255,.40)),
    radial-gradient(circle at 50% 18%, rgba(255,255,255,.14), transparent 34%);
}

html[data-theme] body.page-app:not(.page-admin) .main-area {
  padding: clamp(18px, 2.4vh, 30px) clamp(22px, 3vw, 46px) 56px;
}

html[data-theme] body.page-app:not(.page-admin) .home-dashboard {
  width: min(100%, 1040px);
  gap: clamp(10px, 1.2vw, 15px);
}

html[data-theme] body.page-app:not(.page-admin) .home-dashboard > .page-hd {
  width: min(100%, 920px);
  min-height: 64px;
  padding: 8px 12px;
  border-radius: 18px;
  background: rgba(255,255,255,.28) !important;
  box-shadow: 0 14px 44px rgba(15,23,42,.08);
}

html[data-theme] body.page-app:not(.page-admin) .home-dashboard > .page-hd h1 {
  font-size: clamp(24px, 3.2vw, 42px);
  line-height: 1.08;
}

html[data-theme] body.page-app:not(.page-admin) .home-dashboard .page-hd-actions .btn,
html[data-theme] body.page-app:not(.page-admin) .home-dashboard .badge-balance {
  min-height: 32px;
  padding: 5px 11px;
  font-size: 12px;
}

html[data-theme] body.page-app:not(.page-admin) .home-hero-grid {
  width: min(100%, 560px);
  gap: 8px;
  margin-top: 18px;
}

html[data-theme] body.page-app:not(.page-admin) .home-feature-card {
  min-height: 66px;
  padding: 11px 14px;
  border-radius: 17px;
}

html[data-theme] body.page-app:not(.page-admin) .home-feature-card strong {
  font-size: 15px;
}

html[data-theme] body.page-app:not(.page-admin) .home-feature-card small,
html[data-theme] body.page-app:not(.page-admin) .home-feature-kicker {
  font-size: 10px;
  line-height: 1.35;
}

html[data-theme] body.page-app:not(.page-admin) .home-project-thread:not(.is-active):not(.has-preview) {
  display: none;
}

html[data-theme] body.page-app:not(.page-admin) .home-console {
  width: min(100%, 640px);
  margin-top: 4px;
  border-radius: 24px;
  box-shadow: 0 22px 66px rgba(15,23,42,.13);
}

html[data-theme] body.page-app:not(.page-admin) .home-console-head {
  min-height: 50px;
  padding: 10px 16px;
}

html[data-theme] body.page-app:not(.page-admin) .home-console-head h3 {
  font-size: 14px;
}

html[data-theme] body.page-app:not(.page-admin) .home-mode-tabs,
html[data-theme] body.page-app:not(.page-admin) .home-showcase-tabs {
  gap: 6px;
}

html[data-theme] body.page-app:not(.page-admin) .home-mode-tabs button,
html[data-theme] body.page-app:not(.page-admin) .home-showcase-tabs button,
html[data-theme] body.page-app:not(.page-admin) .home-showcase-tabs a,
html[data-theme] body.page-app:not(.page-admin) .home-resource-links a {
  min-height: 28px;
  padding: 0 10px;
  font-size: 11px;
}

html[data-theme] body.page-app:not(.page-admin) .home-create-form {
  padding: 14px 16px 16px;
  gap: 8px;
}

html[data-theme] body.page-app:not(.page-admin) .home-prompt-field label {
  display: none;
}

html[data-theme] body.page-app:not(.page-admin) .home-prompt-field textarea {
  min-height: 66px;
  max-height: 264px;
  padding: 14px 16px;
  border-radius: 18px;
  font-size: 13px;
}

html[data-theme] body.page-app:not(.page-admin) .home-mode-panel {
  padding: 8px 16px;
}

html[data-theme] body.page-app:not(.page-admin) .compact-param-row {
  gap: 8px;
}

html[data-theme] body.page-app:not(.page-admin) .compact-param-field label,
html[data-theme] body.page-app:not(.page-admin) .field-v3 label {
  font-size: 11px;
}

html[data-theme] body.page-app:not(.page-admin) .field-v3 input,
html[data-theme] body.page-app:not(.page-admin) .field-v3 select,
html[data-theme] body.page-app:not(.page-admin) .field-v3 textarea {
  min-height: 34px;
  font-size: 12px;
}

html[data-theme] body.page-app:not(.page-admin) .home-file-tool,
html[data-theme] body.page-app:not(.page-admin) .home-photo-presets button,
html[data-theme] body.page-app:not(.page-admin) .home-reference-modes label {
  min-height: 30px;
  padding: 0 10px;
  font-size: 11px;
}

html[data-theme] body.page-app:not(.page-admin) .home-console #homeGenerateButton {
  width: auto;
  min-width: 72px;
  max-width: none;
  min-height: 36px;
  padding: 0 16px;
}

html[data-theme] body.page-app:not(.page-admin) .home-workflow-strip {
  width: min(100%, 640px);
}

html[data-theme] body.page-app:not(.page-admin) .home-workflow-grid {
  gap: 9px;
}

html[data-theme] body.page-app:not(.page-admin) .home-workflow-card {
  min-height: 58px;
  padding: 11px 13px;
  border-radius: 16px;
}

html[data-theme] body.page-app:not(.page-admin) .home-workflow-card strong {
  font-size: 13px;
}

html[data-theme] body.page-app:not(.page-admin) .home-workflow-card span {
  font-size: 10px;
  line-height: 1.4;
}

html[data-theme] body.page-app:not(.page-admin) .home-showcase-grid {
  width: min(100%, 1080px);
  grid-template-columns: minmax(0, 1fr) minmax(230px, 280px);
  gap: 16px;
  margin-top: 12px;
}

html[data-theme] body.page-app:not(.page-admin) .home-showcase-main .card-v3-head,
html[data-theme] body.page-app:not(.page-admin) .home-resource-panel .card-v3-head {
  min-height: 58px;
  padding: 13px 18px;
  border-bottom-color: rgba(15, 23, 42, .06);
  background: rgba(255, 255, 255, .42);
}

html[data-theme] body.page-app:not(.page-admin) .home-showcase-main .card-v3-body,
html[data-theme] body.page-app:not(.page-admin) .home-resource-panel .card-v3-body {
  padding: 16px 18px 18px;
}

html[data-theme] body.page-app:not(.page-admin) .home-showcase-main .grid-auto {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr));
  gap: 18px 16px;
  align-items: start;
}

html[data-theme] body.page-app:not(.page-admin) .home-showcase-main .media-card {
  transform: none;
  border-radius: 16px;
}

html[data-theme] body.page-app:not(.page-admin) .home-showcase-main .media-card-body {
  padding: 10px 11px;
}

html[data-theme] body.page-app:not(.page-admin) .home-showcase-main #historyList.grid-auto,
html[data-theme] body.page-app:not(.page-admin) .home-showcase-main .home-showcase-panel.grid-auto {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr)) !important;
  gap: 20px 16px !important;
  overflow: visible;
}

html[data-theme] body.page-app:not(.page-admin) .home-showcase-main #historyList .media-card-compact,
html[data-theme] body.page-app:not(.page-admin) .home-showcase-main .home-showcase-panel .media-card-compact {
  display: grid !important;
  grid-template-columns: 1fr !important;
  grid-template-rows: auto auto !important;
  min-height: 0 !important;
  width: 100%;
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

html[data-theme] body.page-app:not(.page-admin) .home-showcase-main #historyList .media-card-compact > .media-card-thumb,
html[data-theme] body.page-app:not(.page-admin) .home-showcase-main .home-showcase-panel .media-card-compact > .media-card-thumb,
html[data-theme] body.page-app:not(.page-admin) .home-showcase-main #historyList .media-card > div:first-child,
html[data-theme] body.page-app:not(.page-admin) .home-showcase-main .home-showcase-panel .media-card > div:first-child {
  width: 100% !important;
  height: auto !important;
  min-height: 0 !important;
  max-height: none !important;
  aspect-ratio: 16 / 9 !important;
  border: 1px solid rgba(15, 23, 42, .08) !important;
  border-radius: 16px !important;
  overflow: hidden;
  background: var(--main-surface-soft) !important;
  box-shadow: 0 12px 30px rgba(15, 23, 42, .09);
}

html[data-theme] body.page-app:not(.page-admin) .home-showcase-main #historyList .media-card-compact > .media-card-thumb > img,
html[data-theme] body.page-app:not(.page-admin) .home-showcase-main #historyList .media-card-compact > .media-card-thumb > video,
html[data-theme] body.page-app:not(.page-admin) .home-showcase-main .home-showcase-panel .media-card-compact > .media-card-thumb > img,
html[data-theme] body.page-app:not(.page-admin) .home-showcase-main .home-showcase-panel .media-card-compact > .media-card-thumb > video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

html[data-theme] body.page-app:not(.page-admin) .home-showcase-main #historyList .media-card-compact .media-card-body,
html[data-theme] body.page-app:not(.page-admin) .home-showcase-main .home-showcase-panel .media-card-compact .media-card-body {
  display: grid !important;
  gap: 6px !important;
  padding: 10px 3px 0 !important;
  align-content: start !important;
}

html[data-theme] body.page-app:not(.page-admin) .home-showcase-main #historyList .media-card-compact .prompt,
html[data-theme] body.page-app:not(.page-admin) .home-showcase-main .home-showcase-panel .media-card-compact .prompt {
  min-height: 0 !important;
  margin: 0;
  color: var(--text);
  font-size: 13.5px;
  font-weight: 800;
  line-height: 1.35;
  -webkit-line-clamp: 2 !important;
}

html[data-theme] body.page-app:not(.page-admin) .home-showcase-main #historyList .media-card-compact .meta,
html[data-theme] body.page-app:not(.page-admin) .home-showcase-main .home-showcase-panel .media-card-compact .meta {
  gap: 6px;
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.35;
}

html[data-theme] body.page-app:not(.page-admin) .home-showcase-main,
html[data-theme] body.page-app:not(.page-admin) .home-resource-panel {
  border-color: rgba(255, 255, 255, .48);
  border-radius: 22px;
  background: rgba(255, 255, 255, .72) !important;
}

html[data-theme] body.page-app:not(.page-admin) .home-resource-panel {
  align-self: start;
}

html[data-theme] body.page-app:not(.page-admin) .home-resource-panel .card-v3-body {
  display: grid;
  gap: 14px;
}

@keyframes homeFloatingPillShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

html[data-theme] body.page-app:not(.page-admin) .home-resource-links {
  gap: 8px;
}

html[data-theme] body.page-app:not(.page-admin) .home-resource-links a {
  min-height: 32px;
  border-radius: 999px;
}

html[data-theme] body.page-app.sidebar-collapsed:not(.page-admin) .main-area {
  padding-left: clamp(30px, 3.2vw, 58px);
  padding-right: clamp(30px, 3.2vw, 58px);
}

html[data-theme] body.page-app.sidebar-collapsed:not(.page-admin) .home-dashboard {
  width: min(100%, calc(100vw - 96px)) !important;
}

html[data-theme] body.page-app.sidebar-collapsed:not(.page-admin) .home-showcase-grid {
  width: min(100%, calc(100vw - 120px)) !important;
  grid-template-columns: minmax(0, 1fr) minmax(250px, 330px) !important;
  gap: 18px !important;
}

html[data-theme] body.page-app.sidebar-collapsed:not(.page-admin) .home-showcase-main #historyList.grid-auto,
html[data-theme] body.page-app.sidebar-collapsed:not(.page-admin) .home-showcase-main .home-showcase-panel.grid-auto {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 160px), 1fr)) !important;
}

html[data-theme] body.page-app:not(.page-admin) .home-showcase-main #historyList .media-card-compact time,
html[data-theme] body.page-app:not(.page-admin) .home-showcase-main .home-showcase-panel .media-card-compact time {
  display: none;
}

@media (max-width: 1180px) {
  html[data-theme] body.page-app:not(.page-admin) .home-showcase-grid {
    grid-template-columns: 1fr;
    width: min(100%, 820px);
  }
}

@media (max-width: 720px) {
  html[data-theme] body.page-app:not(.page-admin) .main-area {
    padding: 72px 12px 36px;
  }

  html[data-theme] body.page-app:not(.page-admin) .home-dashboard {
    width: 100%;
  }

  html[data-theme] body.page-app:not(.page-admin) .home-dashboard > .page-hd {
    min-height: 58px;
    padding: 8px 10px;
  }

  html[data-theme] body.page-app:not(.page-admin) .home-dashboard > .page-hd h1 {
    font-size: 25px;
  }

  html[data-theme] body.page-app:not(.page-admin) .home-hero-grid,
  html[data-theme] body.page-app:not(.page-admin) .home-workflow-grid {
    grid-template-columns: 1fr;
  }

  html[data-theme] body.page-app:not(.page-admin) .home-console,
  html[data-theme] body.page-app:not(.page-admin) .home-workflow-strip,
  html[data-theme] body.page-app:not(.page-admin) .home-showcase-grid {
    width: 100%;
  }
}

/* Visual layout editor for /user/index?layout_editor=1 */
:root {
  --home-bg-image: url("/user/assets/home-bg-custom.png");
  --home-bg-blur: 0px;
  --home-ve-page-width: 1030px;
  --home-ve-top-width: 970px;
  --home-ve-console-width: 900px;
  --home-ve-feature-width: 900px;
  --home-ve-showcase-width: 980px;
  --home-ve-gap: 10px;
  --home-ve-radius: 34px;
  --home-ve-glass: 0.83;
  --home-ve-blur: 13px;
  --home-ve-scale: 1.03;
  --home-ve-main-pad-y: 2px;
  --home-ve-hero-offset: 0px;
  --home-ve-prompt-height: 62px;
  --home-ve-card-shadow: 0.28;
  --home-ve-gallery-min: 140px;
  --home-ve-resource-width: 220px;
  --home-ve-feature-height: 64px;
  --home-ve-bg-fade: 0.18;
  --home-ve-bg-y: 2%;
  --home-ve-top-pad-x: 36px;
  --home-ve-top-pad-y: 4px;
  --home-ve-card-pad: 13px;
  --home-ve-console-head-pad: 32px;
  --home-ve-editor-x: 8px;
  --home-ve-editor-y: 23px;
  --home-ve-editor-width: 300px;
  --home-ve-accent: #000000;
  --home-ve-active-text: #d95000;
}

body.page-app.home-layout-editing:not(.page-admin)::before {
  background: var(--home-bg-image) center var(--home-ve-bg-y) / cover no-repeat !important;
  filter: blur(var(--home-bg-blur));
}

body.page-app.home-layout-editing:not(.page-admin) .main-area {
  padding-top: var(--home-ve-main-pad-y) !important;
}

body.page-app.home-layout-editing:not(.page-admin) .home-dashboard {
  width: min(100%, var(--home-ve-page-width)) !important;
  gap: var(--home-ve-gap) !important;
  transform: scale(var(--home-ve-scale));
  transform-origin: top center;
}

body.page-app.home-layout-editing:not(.page-admin) .home-dashboard > .page-hd {
  width: min(100%, var(--home-ve-top-width)) !important;
  padding: var(--home-ve-top-pad-y) var(--home-ve-top-pad-x) !important;
  border-radius: calc(var(--home-ve-radius) - 6px) !important;
}

body.page-app.home-layout-editing:not(.page-admin) .home-hero-grid {
  width: min(100%, var(--home-ve-feature-width)) !important;
  gap: calc(var(--home-ve-gap) * .6) !important;
  margin-top: var(--home-ve-hero-offset) !important;
}

body.page-app.home-layout-editing:not(.page-admin) .home-console,
body.page-app.home-layout-editing:not(.page-admin) .home-workflow-strip {
  width: min(100%, var(--home-ve-console-width)) !important;
}

body.page-app.home-layout-editing:not(.page-admin) .home-showcase-grid {
  width: min(100%, var(--home-ve-showcase-width)) !important;
  grid-template-columns: minmax(0, 1fr) minmax(220px, var(--home-ve-resource-width)) !important;
  gap: var(--home-ve-gap) !important;
}

body.page-app.home-layout-editing:not(.page-admin) .home-feature-card,
body.page-app.home-layout-editing:not(.page-admin) .home-console,
body.page-app.home-layout-editing:not(.page-admin) .home-workflow-card,
body.page-app.home-layout-editing:not(.page-admin) .home-showcase-main,
body.page-app.home-layout-editing:not(.page-admin) .home-resource-panel,
body.page-app.home-layout-editing:not(.page-admin) .home-dashboard > .page-hd {
  background: rgba(255,255,255,var(--home-ve-glass)) !important;
  box-shadow: 0 22px 70px rgba(15,23,42,var(--home-ve-card-shadow)) !important;
  backdrop-filter: blur(var(--home-ve-blur)) saturate(1.1) !important;
}

body.page-app.home-layout-editing:not(.page-admin) .home-feature-card {
  min-height: var(--home-ve-feature-height) !important;
  padding: var(--home-ve-card-pad) !important;
  border-radius: calc(var(--home-ve-radius) - 7px) !important;
}

body.page-app.home-layout-editing:not(.page-admin) .home-console {
  border-radius: var(--home-ve-radius) !important;
}

body.page-app.home-layout-editing:not(.page-admin) .home-console-head,
body.page-app.home-layout-editing:not(.page-admin) .home-showcase-main .card-v3-head,
body.page-app.home-layout-editing:not(.page-admin) .home-resource-panel .card-v3-head {
  padding-left: var(--home-ve-console-head-pad) !important;
  padding-right: var(--home-ve-console-head-pad) !important;
}

body.page-app.home-layout-editing:not(.page-admin) .home-prompt-field textarea {
  min-height: var(--home-ve-prompt-height) !important;
  border-radius: calc(var(--home-ve-radius) - 6px) !important;
}

body.page-app.home-layout-editing:not(.page-admin) .home-workflow-grid {
  gap: calc(var(--home-ve-gap) * .65) !important;
}

body.page-app.home-layout-editing:not(.page-admin) .home-workflow-card {
  border-radius: calc(var(--home-ve-radius) - 8px) !important;
}

body.page-app.home-layout-editing:not(.page-admin) .home-showcase-main .grid-auto {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--home-ve-gallery-min)), 1fr)) !important;
}

body.page-app.home-layout-editing.home-layout-hide-hero:not(.page-admin) .home-hero-grid,
body.page-app.home-layout-editing.home-layout-hide-project:not(.page-admin) .home-project-thread,
body.page-app.home-layout-editing.home-layout-hide-workflow:not(.page-admin) .home-workflow-strip,
body.page-app.home-layout-editing.home-layout-hide-showcase:not(.page-admin) .home-showcase-grid {
  display: none !important;
}

body.page-app.home-layout-editing.home-layout-focus-console:not(.page-admin) .home-dashboard > .page-hd,
body.page-app.home-layout-editing.home-layout-focus-console:not(.page-admin) .home-hero-grid,
body.page-app.home-layout-editing.home-layout-focus-console:not(.page-admin) .home-workflow-strip,
body.page-app.home-layout-editing.home-layout-focus-console:not(.page-admin) .home-showcase-grid {
  opacity: .32;
  filter: saturate(.72);
}

body.page-app.home-layout-editing:not(.page-admin) .home-mode-tabs button.active,
body.page-app.home-layout-editing:not(.page-admin) .home-showcase-tabs button.active,
body.page-app.home-layout-editing:not(.page-admin) .home-console #homeGenerateButton {
  background: var(--home-ve-accent) !important;
  color: var(--home-ve-active-text) !important;
}

body.page-app:not(.page-admin) .home-builder-style-solid {
  background: #fff !important;
  backdrop-filter: none !important;
}

body.page-app:not(.page-admin) .home-builder-style-outline {
  background: transparent !important;
  border-style: dashed !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
}

body.page-app:not(.page-admin) .home-builder-style-flat {
  background: transparent !important;
  border-color: transparent !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
}

body.page-app:not(.page-admin) .home-builder-style-spotlight {
  transform: translateY(-2px);
  border-color: rgba(17,24,39,.18) !important;
  box-shadow: 0 28px 86px rgba(15,23,42,.18) !important;
}

body.page-app.home-layout-editing .home-layout-selected {
  position: relative;
  outline: 2px solid var(--home-ve-accent) !important;
  outline-offset: 4px;
}

body.page-app.home-layout-editing .home-layout-selected::after {
  content: attr(data-layout-name);
  position: absolute;
  top: -13px;
  left: 14px;
  z-index: 10;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--home-ve-accent);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  pointer-events: none;
}

.home-layout-editor-panel {
  position: fixed;
  right: var(--home-ve-editor-x);
  bottom: var(--home-ve-editor-y);
  z-index: 1000;
  width: min(var(--home-ve-editor-width), calc(100vw - 36px));
  max-height: min(720px, calc(100dvh - 36px));
  overflow: auto;
  padding: 14px;
  border: 1px solid rgba(15,23,42,.10);
  border-radius: 18px;
  background: rgba(255,255,255,.90);
  box-shadow: 0 24px 70px rgba(15,23,42,.20);
  backdrop-filter: blur(24px);
}

.home-layout-editor-tabs,
.home-layout-editor-presets,
.home-layout-editor-switches,
.home-layout-editor-field-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.home-layout-editor-tabs {
  margin: 0 0 10px;
}

.home-layout-editor-tabs button,
.home-layout-editor-presets button,
.home-layout-editor-switches label,
.home-layout-editor-field-grid button {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 10px;
  border: 1px solid rgba(15,23,42,.10);
  border-radius: 999px;
  background: rgba(255,255,255,.72);
  color: #334155;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.home-layout-editor-tabs button.is-active,
.home-layout-editor-presets button:hover,
.home-layout-editor-switches label:has(input:checked),
.home-layout-editor-field-grid button:hover {
  border-color: #111827;
  background: #111827;
  color: #fff;
}

.home-layout-editor-section {
  display: none;
}

.home-layout-editor-section.is-active {
  display: block;
}

.home-layout-editor-panel header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.home-layout-editor-panel h2 {
  margin: 0;
  color: #111827;
  font-size: 16px;
  letter-spacing: 0;
}

.home-layout-editor-panel small,
.home-layout-editor-note {
  color: #64748b;
  font-size: 12px;
  line-height: 1.55;
}

.home-layout-editor-control {
  display: grid;
  gap: 7px;
  padding: 10px 0;
  border-top: 1px solid rgba(15,23,42,.08);
}

.home-layout-selected-controls {
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid rgba(15,23,42,.08);
  border-radius: 12px;
  background: rgba(248,250,252,.72);
}

.home-layout-selected-controls .home-layout-editor-note {
  margin: 0 0 4px;
}

.home-layout-selected-controls input:disabled {
  opacity: .38;
  cursor: not-allowed;
}

.home-layout-editor-control label {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: #334155;
  font-size: 12px;
  font-weight: 800;
}

.home-layout-editor-control output {
  color: #0f172a;
  font-variant-numeric: tabular-nums;
}

.home-layout-editor-control input {
  width: 100%;
  accent-color: #111827;
}

.home-layout-editor-import {
  display: grid;
  gap: 8px;
  padding: 10px 0;
  border-top: 1px solid rgba(15,23,42,.08);
}

.home-layout-editor-import textarea {
  width: 100%;
  min-height: 118px;
  padding: 10px;
  border: 1px solid rgba(15,23,42,.10);
  border-radius: 12px;
  background: rgba(255,255,255,.78);
  color: #111827;
  font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  resize: vertical;
}

.home-layout-editor-text-field {
  display: grid;
  gap: 6px;
  padding: 9px 0;
  border-top: 1px solid rgba(15,23,42,.08);
}

.home-layout-editor-text-field label {
  color: #334155;
  font-size: 12px;
  font-weight: 800;
}

.home-layout-editor-text-field input,
.home-layout-editor-text-field textarea,
.home-layout-editor-spec-field input,
.home-layout-editor-spec-field textarea,
.home-layout-editor-spec-field select {
  width: 100%;
  min-height: 34px;
  padding: 8px 10px;
  border: 1px solid rgba(15,23,42,.10);
  border-radius: 10px;
  background: rgba(255,255,255,.78);
  color: #111827;
  font-size: 12px;
  outline: none;
}

.home-layout-editor-text-field textarea {
  min-height: 62px;
  resize: vertical;
}

.home-layout-button-editor {
  display: grid;
  gap: 8px;
  padding: 10px 0;
  border-top: 1px solid rgba(15,23,42,.08);
}

.home-layout-button-row {
  display: grid;
  grid-template-columns: 62px 62px minmax(0, 1fr) 42px;
  gap: 8px;
  align-items: center;
}

.home-layout-button-row label {
  min-height: 32px;
  display: flex;
  align-items: center;
  gap: 5px;
  color: #334155;
  font-size: 12px;
  font-weight: 800;
}

.home-layout-button-row input[type="number"],
.home-layout-button-row input[type="text"] {
  width: 100%;
  min-height: 32px;
  padding: 7px 8px;
  border: 1px solid rgba(15,23,42,.10);
  border-radius: 10px;
  background: rgba(255,255,255,.78);
  color: #111827;
  font-size: 12px;
  outline: none;
}

.home-layout-button-row span {
  color: #94a3b8;
  font-size: 11px;
  font-weight: 800;
}

.home-layout-editor-spec-field {
  display: grid;
  gap: 6px;
  padding: 9px 0;
  border-top: 1px solid rgba(15,23,42,.08);
}

.home-layout-editor-spec-field label {
  color: #334155;
  font-size: 12px;
  font-weight: 800;
}

.home-layout-editor-spec-field textarea {
  min-height: 82px;
  resize: vertical;
}

.home-layout-editor-color-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 46px;
  gap: 8px;
  align-items: center;
}

.home-layout-editor-color-row input[type="color"] {
  width: 46px;
  min-height: 34px;
  padding: 2px;
}

.home-layout-editor-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid rgba(15,23,42,.08);
}

.home-layout-editor-actions button {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid rgba(15,23,42,.10);
  border-radius: 10px;
  background: #fff;
  color: #111827;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.home-layout-editor-actions button.is-primary {
  border-color: #111827;
  background: #111827;
  color: #fff;
}

.home-layout-editor-panel.is-collapsed .home-layout-editor-control,
.home-layout-editor-panel.is-collapsed .home-layout-editor-note,
.home-layout-editor-panel.is-collapsed .home-layout-editor-tabs,
.home-layout-editor-panel.is-collapsed .home-layout-editor-section {
  display: none;
}

@media (max-width: 1180px) {
  body.page-app.home-layout-editing:not(.page-admin) .home-showcase-grid {
    grid-template-columns: 1fr !important;
  }
}

/* Solidified home layout: apply builder variables on normal /user/index too. */
html[data-theme] body.page-app:not(.page-admin)::before {
  background: var(--home-bg-image) center var(--home-ve-bg-y) / cover no-repeat !important;
  filter: blur(var(--home-bg-blur));
}

html[data-theme] body.page-app:not(.page-admin) .main-area {
  background:
    linear-gradient(180deg, rgba(7,14,28,.08), rgba(255,255,255,var(--home-ve-bg-fade)) 78%, rgba(255,255,255,.36)),
    var(--home-bg-image) center var(--home-ve-bg-y) / cover fixed no-repeat !important;
  padding-top: var(--home-ve-main-pad-y) !important;
}

html[data-theme] body.page-app:not(.page-admin) .home-dashboard {
  width: min(100%, var(--home-ve-page-width)) !important;
  gap: var(--home-ve-gap) !important;
  transform: scale(var(--home-ve-scale));
  transform-origin: top center;
}

html[data-theme] body.page-app:not(.page-admin) .home-dashboard > .page-hd {
  width: min(100%, var(--home-ve-top-width)) !important;
  padding: var(--home-ve-top-pad-y) var(--home-ve-top-pad-x) !important;
  border-radius: calc(var(--home-ve-radius) - 6px) !important;
}

html[data-theme] body.page-app:not(.page-admin) .home-hero-grid {
  width: min(100%, var(--home-ve-feature-width)) !important;
  gap: calc(var(--home-ve-gap) * .6) !important;
  margin-top: var(--home-ve-hero-offset) !important;
}

html[data-theme] body.page-app:not(.page-admin) .home-console,
html[data-theme] body.page-app:not(.page-admin) .home-workflow-strip {
  width: min(100%, var(--home-ve-console-width)) !important;
}

html[data-theme] body.page-app:not(.page-admin) .home-showcase-grid {
  width: min(100%, var(--home-ve-showcase-width)) !important;
  grid-template-columns: minmax(0, 1fr) minmax(220px, var(--home-ve-resource-width)) !important;
  gap: var(--home-ve-gap) !important;
}

html[data-theme] body.page-app:not(.page-admin) .home-feature-card,
html[data-theme] body.page-app:not(.page-admin) .home-console,
html[data-theme] body.page-app:not(.page-admin) .home-workflow-card,
html[data-theme] body.page-app:not(.page-admin) .home-showcase-main,
html[data-theme] body.page-app:not(.page-admin) .home-resource-panel,
html[data-theme] body.page-app:not(.page-admin) .home-dashboard > .page-hd {
  background: rgba(255,255,255,var(--home-ve-glass)) !important;
  box-shadow: 0 22px 70px rgba(15,23,42,var(--home-ve-card-shadow)) !important;
  backdrop-filter: blur(var(--home-ve-blur)) saturate(1.1) !important;
}

html[data-theme] body.page-app:not(.page-admin) .home-feature-card {
  min-height: var(--home-ve-feature-height) !important;
  padding: var(--home-ve-card-pad) !important;
  border-radius: calc(var(--home-ve-radius) - 7px) !important;
}

html[data-theme] body.page-app:not(.page-admin) .home-console {
  border-radius: var(--home-ve-radius) !important;
}

html[data-theme] body.page-app:not(.page-admin) .home-console-head,
html[data-theme] body.page-app:not(.page-admin) .home-showcase-main .card-v3-head,
html[data-theme] body.page-app:not(.page-admin) .home-resource-panel .card-v3-head {
  padding-left: var(--home-ve-console-head-pad) !important;
  padding-right: var(--home-ve-console-head-pad) !important;
}

html[data-theme] body.page-app:not(.page-admin) .home-prompt-field textarea {
  min-height: var(--home-ve-prompt-height) !important;
  border-radius: calc(var(--home-ve-radius) - 6px) !important;
}

html[data-theme] body.page-app:not(.page-admin) .home-workflow-grid {
  gap: calc(var(--home-ve-gap) * .65) !important;
}

html[data-theme] body.page-app:not(.page-admin) .home-workflow-card {
  border-radius: calc(var(--home-ve-radius) - 8px) !important;
}

html[data-theme] body.page-app:not(.page-admin) .home-showcase-main .grid-auto {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--home-ve-gallery-min)), 1fr)) !important;
}

html[data-theme] body.page-app:not(.page-admin) .home-mode-tabs button.active,
html[data-theme] body.page-app:not(.page-admin) .home-showcase-tabs button.active,
html[data-theme] body.page-app:not(.page-admin) .home-console #homeGenerateButton {
  background: var(--home-ve-accent) !important;
  color: var(--home-ve-active-text) !important;
}

html[data-theme] body.page-app:not(.page-admin) .home-console-head {
  min-height: 44px !important;
  padding-top: 8px !important;
  padding-bottom: 8px !important;
}

html[data-theme] body.page-app:not(.page-admin) .home-create-form {
  padding: 10px 16px 12px !important;
  gap: 4px !important;
}

html[data-theme] body.page-app:not(.page-admin) .home-prompt-field textarea {
  min-height: 62px !important;
  max-height: 248px !important;
  padding: 11px 14px !important;
}

html[data-theme] body.page-app:not(.page-admin) .home-prompt-shell textarea {
  padding-right: 48px !important;
}

html[data-theme] body.page-app:not(.page-admin) .home-create-toolbar {
  gap: 8px !important;
  margin-top: 0 !important;
}

html[data-theme] body.page-app:not(.page-admin) .home-mode-panel {
  padding: 2px 16px 4px !important;
}

html[data-theme] body.page-app:not(.page-admin) .compact-param-row {
  gap: 5px !important;
  margin: 0 0 3px !important;
}

html[data-theme] body.page-app:not(.page-admin) .compact-param-field label,
html[data-theme] body.page-app:not(.page-admin) .field-v3 label {
  margin-bottom: 3px !important;
}

@media (max-width: 1180px) {
  html[data-theme] body.page-app:not(.page-admin) .home-showcase-grid {
    grid-template-columns: 1fr !important;
  }
}

/* Final home showcase polish: wider collapsed layout, cleaner gallery cards. */
html[data-theme] body.page-app:not(.page-admin) .home-showcase-grid {
  width: min(100%, 1080px) !important;
  grid-template-columns: minmax(0, 1fr) minmax(230px, 280px) !important;
  gap: 16px !important;
  margin-top: 12px;
}

html[data-theme] body.page-app:not(.page-admin) .home-showcase-main,
html[data-theme] body.page-app:not(.page-admin) .home-resource-panel {
  border-color: rgba(255, 255, 255, .48) !important;
  border-radius: 22px !important;
  background: rgba(255, 255, 255, .72) !important;
}

html[data-theme] body.page-app:not(.page-admin) .home-showcase-main .card-v3-head,
html[data-theme] body.page-app:not(.page-admin) .home-resource-panel .card-v3-head {
  min-height: 58px !important;
  padding: 13px 18px !important;
  border-bottom-color: rgba(15, 23, 42, .06) !important;
  background: rgba(255, 255, 255, .42) !important;
}

html[data-theme] body.page-app:not(.page-admin) .home-showcase-main .card-v3-body,
html[data-theme] body.page-app:not(.page-admin) .home-resource-panel .card-v3-body {
  padding: 16px 18px 18px !important;
}

html[data-theme] body.page-app:not(.page-admin) .home-showcase-main #historyList.grid-auto,
html[data-theme] body.page-app:not(.page-admin) .home-showcase-main .home-showcase-panel.grid-auto {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr)) !important;
  gap: 20px 16px !important;
  align-items: start;
  overflow: visible;
}

html[data-theme] body.page-app:not(.page-admin) .home-showcase-main #historyList .media-card-compact,
html[data-theme] body.page-app:not(.page-admin) .home-showcase-main .home-showcase-panel .media-card-compact {
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}

html[data-theme] body.page-app:not(.page-admin) .home-showcase-main #historyList .media-card-compact > .media-card-thumb,
html[data-theme] body.page-app:not(.page-admin) .home-showcase-main .home-showcase-panel .media-card-compact > .media-card-thumb {
  border-radius: 16px !important;
  box-shadow: 0 12px 30px rgba(15, 23, 42, .09) !important;
}

html[data-theme] body.page-app:not(.page-admin) .home-showcase-main #historyList .media-card-compact .media-card-body,
html[data-theme] body.page-app:not(.page-admin) .home-showcase-main .home-showcase-panel .media-card-compact .media-card-body {
  padding: 10px 3px 0 !important;
}

html[data-theme] body.page-app:not(.page-admin) .home-showcase-main #historyList .media-card-compact .prompt,
html[data-theme] body.page-app:not(.page-admin) .home-showcase-main .home-showcase-panel .media-card-compact .prompt {
  font-size: 13.5px !important;
}

html[data-theme] body.page-app:not(.page-admin) .home-resource-panel .card-v3-body {
  display: grid;
  gap: 14px;
}

html[data-theme] body.page-app:not(.page-admin) .home-resource-links {
  gap: 8px;
}

html[data-theme] body.page-app:not(.page-admin) .home-resource-links a {
  min-height: 32px !important;
  border-radius: 999px !important;
}

html[data-theme] body.page-app.sidebar-collapsed:not(.page-admin) .main-area {
  padding-left: clamp(30px, 3.2vw, 58px) !important;
  padding-right: clamp(30px, 3.2vw, 58px) !important;
}

html[data-theme] body.page-app.sidebar-collapsed:not(.page-admin) .home-dashboard {
  width: min(100%, calc(100vw - 96px)) !important;
}

html[data-theme] body.page-app.sidebar-collapsed:not(.page-admin) .home-showcase-grid {
  width: min(100%, calc(100vw - 120px)) !important;
  grid-template-columns: minmax(0, 1fr) minmax(250px, 330px) !important;
  gap: 18px !important;
}

html[data-theme] body.page-app.sidebar-collapsed:not(.page-admin) .home-showcase-main #historyList.grid-auto,
html[data-theme] body.page-app.sidebar-collapsed:not(.page-admin) .home-showcase-main .home-showcase-panel.grid-auto {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 160px), 1fr)) !important;
}

@media (max-width: 1180px) {
  html[data-theme] body.page-app.sidebar-collapsed:not(.page-admin) .home-showcase-grid {
    width: 100% !important;
    grid-template-columns: 1fr !important;
  }
}

/* Resource search is now embedded in the showcase header. */
html[data-theme] body.page-app:not(.page-admin) .home-showcase-grid,
html[data-theme] body.page-app.sidebar-collapsed:not(.page-admin) .home-showcase-grid {
  width: min(100%, calc(100vw - 112px)) !important;
  grid-template-columns: minmax(0, 1fr) !important;
  gap: 0 !important;
}

html[data-theme] body.page-app:not(.page-admin) .home-showcase-head-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex: 1 1 auto;
  min-width: 260px;
}

html[data-theme] body.page-app:not(.page-admin) .home-showcase-search-inline {
  width: min(360px, 42vw);
  min-width: 220px;
  display: block;
}

html[data-theme] body.page-app:not(.page-admin) .home-showcase-search-inline input {
  width: 100%;
  height: 38px;
  padding: 0 14px;
  border: 1px solid rgba(15, 23, 42, .08);
  border-radius: 14px;
  background: rgba(255, 255, 255, .76);
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  outline: none;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .32);
}

html[data-theme] body.page-app:not(.page-admin) .home-showcase-search-inline input:focus {
  border-color: rgba(17, 24, 39, .20);
  background: rgba(255, 255, 255, .92);
  box-shadow: 0 0 0 4px rgba(17, 24, 39, .06);
}

html[data-theme] body.page-app:not(.page-admin) .home-showcase-search-inline input::placeholder {
  color: rgba(31, 41, 55, .44);
}

html[data-theme] body.page-app:not(.page-admin) .home-showcase-main #historyList.grid-auto,
html[data-theme] body.page-app:not(.page-admin) .home-showcase-main .home-showcase-panel.grid-auto,
html[data-theme] body.page-app.sidebar-collapsed:not(.page-admin) .home-showcase-main #historyList.grid-auto,
html[data-theme] body.page-app.sidebar-collapsed:not(.page-admin) .home-showcase-main .home-showcase-panel.grid-auto {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 170px), 1fr)) !important;
}

@media (max-width: 720px) {
  html[data-theme] body.page-app:not(.page-admin) .home-showcase-grid,
  html[data-theme] body.page-app.sidebar-collapsed:not(.page-admin) .home-showcase-grid {
    width: 100% !important;
  }

  html[data-theme] body.page-app:not(.page-admin) .home-showcase-main .card-v3-head {
    align-items: stretch;
    flex-direction: column;
  }

  html[data-theme] body.page-app:not(.page-admin) .home-showcase-head-actions {
    width: 100%;
    min-width: 0;
  }

  html[data-theme] body.page-app:not(.page-admin) .home-showcase-search-inline {
    width: 100%;
    min-width: 0;
  }
}

body.page-app:not(.page-admin) .home-resource-panel {
  display: none !important;
}

body.page-app:not(.page-admin) .home-showcase-grid,
body.page-app.sidebar-collapsed:not(.page-admin) .home-showcase-grid {
  width: min(100%, calc(100vw - 112px)) !important;
  grid-template-columns: minmax(0, 1fr) !important;
  gap: 0 !important;
}

body.page-app:not(.page-admin) .home-showcase-head-actions {
  display: flex !important;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex: 1 1 auto;
}

body.page-app:not(.page-admin) .home-showcase-search-inline {
  display: block !important;
}

/* Home top bar: single-line floating site navigation. */
html[data-theme] body.page-app:not(.page-admin) .home-dashboard > .page-hd {
  width: min(100%, calc(100vw - 112px)) !important;
  min-height: 56px !important;
  display: grid !important;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center !important;
  gap: 14px !important;
  padding: 8px 12px 8px 14px !important;
  border-radius: 999px !important;
  border: 1px solid rgba(255, 255, 255, .55) !important;
  background: rgba(255, 255, 255, .46) !important;
  box-shadow: 0 18px 54px rgba(15, 23, 42, .13) !important;
  backdrop-filter: blur(24px) saturate(1.12) !important;
  -webkit-backdrop-filter: blur(24px) saturate(1.12) !important;
  overflow: hidden;
}

html[data-theme] body.page-app.sidebar-collapsed:not(.page-admin) .home-dashboard > .page-hd {
  width: min(100%, calc(100vw - 96px)) !important;
}

html[data-theme] body.page-app:not(.page-admin) .home-top-brand {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: #111827;
  text-decoration: none;
  white-space: nowrap;
}

html[data-theme] body.page-app:not(.page-admin) .home-top-mark {
  width: 30px;
  height: 30px;
  display: inline-grid;
  place-items: center;
  border-radius: 10px;
  background: rgba(17, 24, 39, .90);
  color: #fff;
  font-size: 15px;
  font-weight: 900;
  line-height: 1;
}

html[data-theme] body.page-app:not(.page-admin) .home-top-name {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  color: rgba(17, 24, 39, .86);
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 0;
}

html[data-theme] body.page-app:not(.page-admin) .home-top-nav {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  overflow: hidden;
  white-space: nowrap;
}

html[data-theme] body.page-app:not(.page-admin) .home-top-nav a {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 13px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: rgba(17, 24, 39, .74);
  text-decoration: none;
  font-size: 13px;
  font-weight: 850;
  line-height: 1;
  white-space: nowrap;
}

html[data-theme] body.page-app:not(.page-admin) .home-top-nav a:hover,
html[data-theme] body.page-app:not(.page-admin) .home-top-nav a.is-active {
  border-color: rgba(255, 255, 255, .68);
  background: rgba(255, 255, 255, .68);
  color: #111827;
  box-shadow: 0 8px 22px rgba(15, 23, 42, .08);
}

html[data-theme] body.page-app:not(.page-admin) .home-dashboard > .page-hd .page-hd-actions {
  min-width: max-content;
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  white-space: nowrap;
}

html[data-theme] body.page-app:not(.page-admin) .home-dashboard > .page-hd .btn,
html[data-theme] body.page-app:not(.page-admin) .home-dashboard > .page-hd .badge-balance {
  min-height: 36px !important;
  padding: 0 13px !important;
  border-radius: 999px !important;
  border-color: rgba(255, 255, 255, .72) !important;
  background: rgba(255, 255, 255, .70) !important;
  color: #111827 !important;
  box-shadow: 0 8px 22px rgba(15, 23, 42, .08) !important;
}

html[data-theme] body.page-app:not(.page-admin) .home-dashboard > .page-hd .badge-balance .num {
  font-size: 15px !important;
}

html[data-theme] body.page-app:not(.page-admin) .home-dashboard > .page-hd .badge-balance .label {
  font-size: 12px !important;
}

@media (max-width: 980px) {
  html[data-theme] body.page-app:not(.page-admin) .home-dashboard > .page-hd {
    width: 100% !important;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 8px !important;
  }

  html[data-theme] body.page-app:not(.page-admin) .home-top-name {
    max-width: 120px;
  }

  html[data-theme] body.page-app:not(.page-admin) .home-top-nav {
    justify-content: flex-start;
    overflow-x: auto;
    scrollbar-width: none;
  }

  html[data-theme] body.page-app:not(.page-admin) .home-top-nav::-webkit-scrollbar {
    display: none;
  }
}

@media (max-width: 720px) {
  html[data-theme] body.page-app:not(.page-admin) .home-dashboard > .page-hd {
    min-height: 52px !important;
    padding: 7px 9px !important;
  }

  html[data-theme] body.page-app:not(.page-admin) .home-top-name {
    display: none;
  }

  html[data-theme] body.page-app:not(.page-admin) .home-top-nav a {
    padding: 0 10px;
    font-size: 12px;
  }

  html[data-theme] body.page-app:not(.page-admin) .home-dashboard > .page-hd .btn span:last-child,
  html[data-theme] body.page-app:not(.page-admin) .home-dashboard > .page-hd .badge-balance .label {
    display: none;
  }
}

/* Must stay last: user-requested compact floating creation panel controls. */
html[data-theme] body.page-app:not(.page-admin) .home-console {
  position: relative !important;
  margin-top: 74px !important;
  padding-top: 0 !important;
  padding-bottom: 12px !important;
  overflow: visible !important;
}

html[data-theme] body.page-app:not(.page-admin) .home-console-head {
  position: absolute !important;
  z-index: 7 !important;
  left: 0 !important;
  right: 0 !important;
  top: -64px !important;
  min-height: 48px !important;
  padding: 0 2px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 16px !important;
  border-bottom: 0 !important;
  background: transparent !important;
}

html[data-theme] body.page-app:not(.page-admin) .home-console-head > div {
  min-height: 46px !important;
  display: inline-grid !important;
  align-content: center !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
  animation: none !important;
}

html[data-theme] body.page-app:not(.page-admin) .home-mode-tabs {
  position: static !important;
  z-index: 6 !important;
  top: auto !important;
  right: auto !important;
  width: auto !important;
  max-width: calc(100% - 36px) !important;
  padding: 3px !important;
  border: 1px solid rgba(255, 255, 255, .68) !important;
  border-radius: 999px !important;
  background: linear-gradient(120deg, rgba(255,255,255,.72), rgba(236,253,245,.76), rgba(255,247,237,.74), rgba(255,255,255,.72)) !important;
  background-size: 260% 260% !important;
  box-shadow: 0 12px 30px rgba(15, 23, 42, .12) !important;
  backdrop-filter: blur(18px) saturate(1.25) !important;
  animation: homeFloatingPillShift 9s ease infinite !important;
}

html[data-theme] body.page-app:not(.page-admin) .home-mode-tabs button,
html[data-theme] body.page-app:not(.page-admin) .home-create-toolbar .btn,
html[data-theme] body.page-app:not(.page-admin) .home-file-tool,
html[data-theme] body.page-app:not(.page-admin) .home-cost-hint,
html[data-theme] body.page-app:not(.page-admin) .home-console #homeGenerateButton {
  min-height: 34px !important;
  border: 1px solid rgba(255, 255, 255, .62) !important;
  border-radius: 999px !important;
  background: linear-gradient(120deg, rgba(255,255,255,.78), rgba(240,253,250,.74), rgba(255,247,237,.78), rgba(255,255,255,.76)) !important;
  background-size: 240% 240% !important;
  color: #172033 !important;
  box-shadow: 0 10px 24px rgba(15, 23, 42, .11) !important;
  backdrop-filter: blur(16px) saturate(1.18) !important;
  animation: homeFloatingPillShift 8s ease infinite !important;
}

html[data-theme] body.page-app:not(.page-admin) .home-mode-tabs button {
  flex: 0 0 auto !important;
  padding: 0 15px !important;
  box-shadow: none !important;
}

html[data-theme] body.page-app:not(.page-admin) .home-mode-tabs button.active {
  border-color: rgba(255, 122, 24, .72) !important;
  background: linear-gradient(120deg, #ff7a18, #ff9f1c, #ff6a00, #ff8a1f) !important;
  background-size: 240% 240% !important;
  color: #fff !important;
  box-shadow: 0 10px 24px rgba(255, 122, 24, .26) !important;
}

html[data-theme] body.page-app:not(.page-admin) .home-console #homeGenerateButton {
  border-color: rgba(17, 24, 39, .82) !important;
  background: linear-gradient(120deg, #050505, #151515, #1d1d1d, #050505) !important;
  background-size: 240% 240% !important;
  color: #fff !important;
}

html[data-theme] body.page-app:not(.page-admin) .home-console-body {
  position: relative !important;
}

html[data-theme] body.page-app:not(.page-admin) .home-create-form {
  position: relative !important;
  padding: 18px 18px 0 !important;
  gap: 8px !important;
}

html[data-theme] body.page-app:not(.page-admin) .home-create-toolbar {
  position: static !important;
  z-index: auto !important;
  top: auto !important;
  left: auto !important;
  right: auto !important;
  display: flex !important;
  gap: 8px !important;
  transform: none !important;
  pointer-events: auto !important;
  margin-top: -2px !important;
}

html[data-theme] body.page-app:not(.page-admin) .home-create-toolbar .home-create-actions {
  padding-right: 0 !important;
}

html[data-theme] body.page-app:not(.page-admin) .home-create-toolbar > * {
  pointer-events: auto !important;
}

html[data-theme] body.page-app:not(.page-admin) .home-create-actions {
  margin-left: auto !important;
}

html[data-theme] body.page-app:not(.page-admin) .home-prompt-field {
  margin: 0 !important;
}

html[data-theme] body.page-app:not(.page-admin) .home-prompt-field textarea {
  height: 86px !important;
  min-height: 86px !important;
  max-height: 128px !important;
  padding: 14px 48px 12px 16px !important;
  border-radius: 24px !important;
}

html[data-theme] body.page-app:not(.page-admin) .home-prompt-shell textarea {
  padding-right: 48px !important;
}

html[data-theme] body.page-app:not(.page-admin) .home-mode-panel {
  padding: 4px 18px 0 !important;
}

html[data-theme] body.page-app:not(.page-admin) .compact-param-row {
  gap: 8px !important;
  margin: 0 !important;
}

html[data-theme] body.page-app:not(.page-admin) .home-file-preview:empty,
html[data-theme] body.page-app:not(.page-admin) .home-reference-preview:empty {
  display: none !important;
}

html[data-theme] body.page-app:not(.page-admin) .home-file-preview,
html[data-theme] body.page-app:not(.page-admin) .home-reference-preview {
  margin: 6px 0 0 !important;
  min-height: 0 !important;
}

html[data-theme] body.page-app:not(.page-admin) .compact-param-field select,
html[data-theme] body.page-app:not(.page-admin) .compact-param-field input[type="text"],
html[data-theme] body.page-app:not(.page-admin) .compact-param-field input[type="number"],
html[data-theme] body.page-app:not(.page-admin) .field-v3 select,
html[data-theme] body.page-app:not(.page-admin) .field-v3 input[type="text"],
html[data-theme] body.page-app:not(.page-admin) .field-v3 input[type="number"] {
  min-height: 34px !important;
  height: 34px !important;
}

@media (max-width: 720px) {
  html[data-theme] body.page-app:not(.page-admin) .home-console {
    margin-top: 104px !important;
    padding-top: 0 !important;
  }

  html[data-theme] body.page-app:not(.page-admin) .home-console-head {
    top: -96px !important;
    align-items: stretch !important;
    flex-direction: column !important;
    gap: 8px !important;
  }

  html[data-theme] body.page-app:not(.page-admin) .home-mode-tabs {
    top: auto !important;
    left: auto !important;
    right: auto !important;
    width: 100% !important;
    overflow-x: auto !important;
  }

  html[data-theme] body.page-app:not(.page-admin) .home-create-form {
    padding-top: 16px !important;
  }

  html[data-theme] body.page-app:not(.page-admin) .home-create-toolbar {
    align-items: flex-start !important;
    overflow-x: auto !important;
    transform: none !important;
  }

  html[data-theme] body.page-app:not(.page-admin) .home-create-actions {
    width: auto !important;
    flex: 0 0 auto !important;
  }
}

html[data-theme] body.home-prompt-modal-open {
  overflow: hidden !important;
}

html[data-theme] body.page-app:not(.page-admin) .home-prompt-modal {
  z-index: 2147483000 !important;
  background: rgba(10, 14, 24, .42) !important;
  backdrop-filter: blur(22px) saturate(.9) !important;
  -webkit-backdrop-filter: blur(22px) saturate(.9) !important;
}

html[data-theme] body.page-app:not(.page-admin) .home-prompt-modal-panel {
  position: relative !important;
  z-index: 2147483001 !important;
  width: min(72vw, 1080px) !important;
  height: min(68vh, 760px) !important;
  background: rgba(255, 255, 255, .94) !important;
  box-shadow: 0 36px 110px rgba(0, 0, 0, .32) !important;
}

html[data-theme] body.page-app:not(.page-admin):not(.home-layout-editing) .home-project-thread {
  display: none !important;
}

.home-history-dialog-body {
  display: grid;
  gap: 16px;
}

.home-history-dialog-preview {
  display: grid;
  place-items: center;
  max-height: 58vh;
  overflow: hidden;
  border-radius: 18px;
  background: rgba(15, 23, 42, .06);
}

.home-history-dialog-preview img,
.home-history-dialog-preview video {
  display: block;
  width: 100%;
  max-height: 58vh;
  object-fit: contain;
}

.home-history-dialog-preview audio {
  width: min(100%, 560px);
  margin: 24px;
}

/* Resource/developer pages share the creation workbench backdrop and one glass shell. */
html[data-theme] body.page-shop:not(.page-admin)::before,
html[data-theme] body.page-records:not(.page-admin)::before,
html[data-theme] body.page-gallery:not(.page-admin)::before,
html[data-theme] body.page-invite:not(.page-admin)::before,
html[data-theme] body.page-credits:not(.page-admin)::before,
html[data-theme] body.page-api-tokens:not(.page-admin)::before {
  background: var(--home-bg-image) center var(--home-ve-bg-y) / cover no-repeat !important;
  filter: blur(var(--home-bg-blur));
}

html[data-theme] body.page-shop:not(.page-admin) .main-area,
html[data-theme] body.page-records:not(.page-admin) .main-area,
html[data-theme] body.page-gallery:not(.page-admin) .main-area,
html[data-theme] body.page-invite:not(.page-admin) .main-area,
html[data-theme] body.page-credits:not(.page-admin) .main-area,
html[data-theme] body.page-api-tokens:not(.page-admin) .main-area {
  background:
    linear-gradient(180deg, rgba(7,14,28,.08), rgba(255,255,255,var(--home-ve-bg-fade)) 78%, rgba(255,255,255,.36)),
    var(--home-bg-image) center var(--home-ve-bg-y) / cover fixed no-repeat !important;
  padding: clamp(22px, 3vw, 38px) clamp(18px, 3vw, 42px) !important;
}

html[data-theme] body.page-shop:not(.page-admin) .main-area > main,
html[data-theme] body.page-records:not(.page-admin) .main-area > main,
html[data-theme] body.page-gallery:not(.page-admin) .main-area > main,
html[data-theme] body.page-invite:not(.page-admin) .main-area > main,
html[data-theme] body.page-credits:not(.page-admin) .main-area > main,
html[data-theme] body.page-api-tokens:not(.page-admin) .main-area > main {
  width: min(100%, 1120px) !important;
  max-width: 1120px !important;
  min-height: calc(100vh - clamp(44px, 6vw, 76px)) !important;
  margin: 0 auto !important;
  padding: clamp(18px, 2.3vw, 28px) !important;
  border: 1px solid rgba(255, 255, 255, .48) !important;
  border-radius: 24px !important;
  background: rgba(255, 255, 255, .70) !important;
  box-shadow: 0 28px 86px rgba(15, 23, 42, .18) !important;
  backdrop-filter: blur(var(--home-ve-blur, 18px)) saturate(1.08) !important;
  -webkit-backdrop-filter: blur(var(--home-ve-blur, 18px)) saturate(1.08) !important;
}

html[data-theme="dark"] body.page-shop:not(.page-admin) .main-area > main,
html[data-theme="dark"] body.page-records:not(.page-admin) .main-area > main,
html[data-theme="dark"] body.page-gallery:not(.page-admin) .main-area > main,
html[data-theme="dark"] body.page-invite:not(.page-admin) .main-area > main,
html[data-theme="dark"] body.page-credits:not(.page-admin) .main-area > main,
html[data-theme="dark"] body.page-api-tokens:not(.page-admin) .main-area > main {
  border-color: rgba(255, 255, 255, .14) !important;
  background: rgba(15, 23, 42, .70) !important;
  box-shadow: 0 28px 86px rgba(0, 0, 0, .34) !important;
}

html[data-theme] body.page-shop:not(.page-admin) .page-hd,
html[data-theme] body.page-records:not(.page-admin) .page-hd,
html[data-theme] body.page-gallery:not(.page-admin) .page-hd,
html[data-theme] body.page-invite:not(.page-admin) .page-hd,
html[data-theme] body.page-credits:not(.page-admin) .page-hd,
html[data-theme] body.page-api-tokens:not(.page-admin) .page-hd,
html[data-theme] body.page-shop:not(.page-admin) .card-v3,
html[data-theme] body.page-records:not(.page-admin) .card-v3,
html[data-theme] body.page-gallery:not(.page-admin) .card-v3,
html[data-theme] body.page-credits:not(.page-admin) .card-v3,
html[data-theme] body.page-api-tokens:not(.page-admin) .card-v3,
html[data-theme] body.page-shop:not(.page-admin) .pricing-card,
html[data-theme] body.page-shop:not(.page-admin) .balance-banner,
html[data-theme] body.page-shop:not(.page-admin) .order-item,
html[data-theme] body.page-invite:not(.page-admin) .invite-stat,
html[data-theme] body.page-invite:not(.page-admin) .invite-section,
html[data-theme] body.page-credits:not(.page-admin) .credits-stat,
html[data-theme] body.page-credits:not(.page-admin) .credits-item,
html[data-theme] body.page-gallery:not(.page-admin) .media-card,
html[data-theme] body.page-records:not(.page-admin) .media-card {
  background: rgba(255, 255, 255, .72) !important;
  border-color: rgba(255, 255, 255, .46) !important;
  box-shadow: 0 14px 38px rgba(15, 23, 42, .08) !important;
  backdrop-filter: blur(14px) saturate(1.05) !important;
  -webkit-backdrop-filter: blur(14px) saturate(1.05) !important;
}

html[data-theme="dark"] body.page-shop:not(.page-admin) .page-hd,
html[data-theme="dark"] body.page-records:not(.page-admin) .page-hd,
html[data-theme="dark"] body.page-gallery:not(.page-admin) .page-hd,
html[data-theme="dark"] body.page-invite:not(.page-admin) .page-hd,
html[data-theme="dark"] body.page-credits:not(.page-admin) .page-hd,
html[data-theme="dark"] body.page-api-tokens:not(.page-admin) .page-hd,
html[data-theme="dark"] body.page-shop:not(.page-admin) .card-v3,
html[data-theme="dark"] body.page-records:not(.page-admin) .card-v3,
html[data-theme="dark"] body.page-gallery:not(.page-admin) .card-v3,
html[data-theme="dark"] body.page-credits:not(.page-admin) .card-v3,
html[data-theme="dark"] body.page-api-tokens:not(.page-admin) .card-v3,
html[data-theme="dark"] body.page-shop:not(.page-admin) .pricing-card,
html[data-theme="dark"] body.page-shop:not(.page-admin) .balance-banner,
html[data-theme="dark"] body.page-shop:not(.page-admin) .order-item,
html[data-theme="dark"] body.page-invite:not(.page-admin) .invite-stat,
html[data-theme="dark"] body.page-invite:not(.page-admin) .invite-section,
html[data-theme="dark"] body.page-credits:not(.page-admin) .credits-stat,
html[data-theme="dark"] body.page-credits:not(.page-admin) .credits-item,
html[data-theme="dark"] body.page-gallery:not(.page-admin) .media-card,
html[data-theme="dark"] body.page-records:not(.page-admin) .media-card {
  background: rgba(15, 23, 42, .62) !important;
  border-color: rgba(255, 255, 255, .12) !important;
  box-shadow: 0 14px 38px rgba(0, 0, 0, .20) !important;
}

@media (max-width: 720px) {
  html[data-theme] body.page-shop:not(.page-admin) .main-area,
  html[data-theme] body.page-records:not(.page-admin) .main-area,
  html[data-theme] body.page-gallery:not(.page-admin) .main-area,
  html[data-theme] body.page-invite:not(.page-admin) .main-area,
  html[data-theme] body.page-credits:not(.page-admin) .main-area,
  html[data-theme] body.page-api-tokens:not(.page-admin) .main-area {
    padding: 14px 12px !important;
  }

  html[data-theme] body.page-shop:not(.page-admin) .main-area > main,
  html[data-theme] body.page-records:not(.page-admin) .main-area > main,
  html[data-theme] body.page-gallery:not(.page-admin) .main-area > main,
  html[data-theme] body.page-invite:not(.page-admin) .main-area > main,
  html[data-theme] body.page-credits:not(.page-admin) .main-area > main,
  html[data-theme] body.page-api-tokens:not(.page-admin) .main-area > main {
    min-height: calc(100vh - 28px) !important;
    padding: 14px !important;
    border-radius: 18px !important;
  }
}

@keyframes sidebarOrangeBreath {
  0%, 100% {
    box-shadow:
      0 0 0 1px rgba(255, 142, 38, .92),
      0 0 12px rgba(255, 118, 20, .58),
      0 0 34px rgba(255, 96, 12, .30),
      16px 28px 76px rgba(7, 12, 22, .36),
      inset -2px 0 0 rgba(8, 13, 23, .96),
      inset 0 1px 0 rgba(255, 229, 188, .22);
  }
  50% {
    box-shadow:
      0 0 0 1px rgba(255, 196, 94, 1),
      0 0 22px rgba(255, 122, 20, .88),
      0 0 54px rgba(255, 84, 10, .46),
      18px 30px 84px rgba(7, 12, 22, .38),
      inset -2px 0 0 rgba(8, 13, 23, .96),
      inset 0 1px 0 rgba(255, 229, 188, .26);
  }
}

/* User sidebar: elevated pull-out drawer with rounded vertical edges. */
html[data-theme] body:not(.page-admin) .sidebar {
  --user-drawer-width: calc(var(--sidebar-width) - clamp(14px, 1.7vw, 22px));
  top: 0 !important;
  left: 0 !important;
  bottom: 0 !important;
  width: var(--user-drawer-width) !important;
  background:
    linear-gradient(180deg, rgba(7, 13, 24, .78), rgba(11, 17, 29, .66)),
    var(--home-bg-image, linear-gradient(145deg, #eef4fb, #f7fbff)) center var(--home-ve-bg-y, 2%) / cover fixed no-repeat !important;
  border: 0 !important;
  border-radius: 0 26px 26px 0 !important;
  box-shadow:
    0 0 0 1px rgba(255, 142, 38, .92),
    0 0 12px rgba(255, 118, 20, .58),
    0 0 34px rgba(255, 96, 12, .30),
    16px 28px 76px rgba(7, 12, 22, .36),
    inset -2px 0 0 rgba(8, 13, 23, .96),
    inset 0 1px 0 rgba(255, 229, 188, .22) !important;
  animation: sidebarOrangeBreath 2.8s ease-in-out infinite !important;
  backdrop-filter: blur(30px) saturate(.9) !important;
  -webkit-backdrop-filter: blur(30px) saturate(.9) !important;
  overflow: visible !important;
  will-change: transform, box-shadow !important;
  transform: translateZ(0) !important;
  transition:
    transform 420ms cubic-bezier(.22, 1, .36, 1),
    box-shadow 420ms ease,
    background 420ms ease,
    backdrop-filter 420ms ease,
    -webkit-backdrop-filter 420ms ease !important;
}

html[data-theme] body:not(.page-admin) .sidebar::before {
  content: none !important;
}

html[data-theme] body:not(.page-admin) .sidebar::after {
  content: none !important;
}

html[data-theme] body:not(.page-admin) .sidebar > * {
  position: relative !important;
  z-index: 2 !important;
}

html[data-theme] body:not(.page-admin) .sidebar-header,
html[data-theme] body:not(.page-admin) .sidebar-footer {
  background: rgba(8, 13, 23, .10) !important;
  border-color: transparent !important;
}

html[data-theme] body:not(.page-admin) .sidebar-nav-item,
html[data-theme] body:not(.page-admin) .sidebar-history-item,
html[data-theme] body:not(.page-admin) .sidebar-user,
html[data-theme] body:not(.page-admin) .sidebar-balance,
html[data-theme] body:not(.page-admin) .sidebar-action-btn {
  border: 1px solid transparent !important;
  background: rgba(238, 248, 255, .15) !important;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .18),
    0 10px 28px rgba(0, 0, 0, .12) !important;
  backdrop-filter: blur(12px) saturate(.92) !important;
  -webkit-backdrop-filter: blur(12px) saturate(.92) !important;
}

html[data-theme] body:not(.page-admin) .sidebar-brand {
  min-height: 54px !important;
  padding: 6px 8px !important;
  border: 1px solid rgba(255, 210, 160, .30) !important;
  border-radius: 16px !important;
  background: rgba(244, 250, 255, .20) !important;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .24),
    0 12px 34px rgba(0, 0, 0, .14) !important;
  backdrop-filter: blur(14px) saturate(.96) !important;
  -webkit-backdrop-filter: blur(14px) saturate(.96) !important;
}

html[data-theme] body:not(.page-admin) .sidebar-collapse-btn {
  border-color: rgba(255, 210, 160, .34) !important;
  background: rgba(244, 250, 255, .18) !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .20), 0 10px 24px rgba(0, 0, 0, .12) !important;
  backdrop-filter: blur(14px) saturate(.96) !important;
  -webkit-backdrop-filter: blur(14px) saturate(.96) !important;
}

html[data-theme] body:not(.page-admin) .sidebar-nav-item::before {
  content: none !important;
}

html[data-theme] body:not(.page-admin) .sidebar-nav-item:hover,
html[data-theme] body:not(.page-admin) .sidebar-nav-item.active,
html[data-theme] body:not(.page-admin) .sidebar-history-item:hover,
html[data-theme] body:not(.page-admin) .sidebar-history-item.active,
html[data-theme] body:not(.page-admin) .sidebar-user:hover,
html[data-theme] body:not(.page-admin) .sidebar-action-btn:hover {
  background: rgba(255, 255, 255, .26) !important;
  border-color: rgba(255, 210, 160, .32) !important;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .20),
    0 14px 34px rgba(0, 0, 0, .16) !important;
}

html[data-theme] body:not(.page-admin) .sidebar-nav-item.active {
  color: var(--sidebar-text-hover) !important;
  background: rgba(255, 255, 255, .30) !important;
  border-color: rgba(255, 205, 145, .42) !important;
  box-shadow:
    inset 3px 0 0 rgba(255, 151, 56, .78),
    inset 0 1px 0 rgba(255, 255, 255, .20),
    0 14px 36px rgba(0, 0, 0, .18) !important;
}

html[data-theme] body:not(.page-admin) .sidebar-history-list {
  margin: 8px 10px 18px !important;
}

html[data-theme] body:not(.page-admin) .sidebar-actions {
  gap: 6px !important;
}

html[data-theme] body:not(.page-admin) .sidebar-balance {
  justify-content: space-between !important;
}

html[data-theme] body:not(.page-admin) .main-area {
  margin-left: calc(var(--sidebar-width) - clamp(14px, 1.7vw, 22px) - 10px) !important;
}

html[data-theme] body:not(.page-admin).sidebar-collapsed .sidebar {
  transform: translate3d(calc(-1 * (var(--sidebar-width) + 72px)), 0, 0) !important;
}

html[data-theme] body:not(.page-admin).sidebar-open .sidebar,
html[data-theme] body:not(.page-admin):not(.sidebar-collapsed) .sidebar {
  transform: translate3d(0, 0, 0) !important;
}

html[data-theme] body:not(.page-admin).sidebar-collapsed .main-area,
html[data-theme] body.page-designer-canvas.sidebar-collapsed .main-area {
  margin-left: 0 !important;
}

@media (max-width: 1024px) {
  html[data-theme] body:not(.page-admin) .sidebar {
    top: 0 !important;
    left: 0 !important;
    bottom: 0 !important;
    width: min(320px, 100vw) !important;
    border-radius: 0 24px 24px 0 !important;
  }

  html[data-theme] body:not(.page-admin) .main-area {
    margin-left: 0 !important;
  }

  html[data-theme] body:not(.page-admin).sidebar-open .sidebar {
    transform: translate3d(0, 0, 0) !important;
  }
}

/* Creation room bottom composer: keep controls tight to the input. */
html[data-theme] body.page-creation:not(.page-admin) .creation-composer.home-console {
  bottom: clamp(42px, 5.8vh, 72px) !important;
  padding: 0 !important;
  width: min(84vw, 980px) !important;
  max-width: calc(100vw - 310px) !important;
}

html[data-theme] body.page-creation:not(.page-admin) .creation-composer .home-create-form {
  padding: 14px 18px 16px !important;
  gap: 5px !important;
}

html[data-theme] body.page-creation:not(.page-admin) .creation-composer .home-create-toolbar {
  order: 1;
  align-items: center !important;
  gap: 6px !important;
  margin: 0 0 4px !important;
}

html[data-theme] body.page-creation:not(.page-admin) .creation-composer .home-prompt-field {
  order: 3;
  margin: 0 !important;
}

html[data-theme] body.page-creation:not(.page-admin) .creation-composer .home-file-preview {
  order: 4;
}

html[data-theme] body.page-creation:not(.page-admin) .creation-composer .home-reference-preview {
  order: 5;
}

html[data-theme] body.page-creation:not(.page-admin) .creation-composer .home-mode-panel {
  order: 2;
  padding: 0 0 5px !important;
  max-height: 112px !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
}

html[data-theme] body.page-creation:not(.page-admin) .creation-composer #homeGenerateMessage {
  order: 6;
}

html[data-theme] body.page-creation:not(.page-admin) .creation-composer .home-prompt-field label {
  display: none !important;
}

html[data-theme] body.page-creation:not(.page-admin) .creation-composer .home-prompt-field textarea {
  height: 58px !important;
  min-height: 58px !important;
  max-height: 108px !important;
  padding: 13px 46px 11px 16px !important;
  border-radius: 16px !important;
  line-height: 1.35 !important;
}

html[data-theme] body.page-creation:not(.page-admin) .creation-composer .home-prompt-expand {
  top: 10px !important;
  right: 10px !important;
  width: 26px !important;
  height: 26px !important;
}

html[data-theme] body.page-creation:not(.page-admin) .creation-composer .home-mode-tabs {
  order: -1;
  margin-right: 2px !important;
}

html[data-theme] body.page-creation:not(.page-admin) .creation-composer .home-file-tool,
html[data-theme] body.page-creation:not(.page-admin) .creation-composer .home-create-toolbar .btn,
html[data-theme] body.page-creation:not(.page-admin) .creation-composer .home-mode-tabs button,
html[data-theme] body.page-creation:not(.page-admin) .creation-composer .home-cost-hint,
html[data-theme] body.page-creation:not(.page-admin) .creation-composer #homeGenerateButton {
  min-height: 32px !important;
}

html[data-theme] body.page-creation:not(.page-admin) .creation-composer .home-create-actions {
  margin-left: auto !important;
  gap: 6px !important;
}

html[data-theme] body.page-creation:not(.page-admin) .creation-composer .home-file-preview,
html[data-theme] body.page-creation:not(.page-admin) .creation-composer .home-reference-preview {
  margin-top: 2px !important;
}

html[data-theme] body.page-creation:not(.page-admin) .creation-composer .compact-param-row {
  grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)) !important;
  gap: 6px !important;
  margin: 0 !important;
}

html[data-theme] body.page-creation:not(.page-admin) .creation-composer .compact-param-field > label,
html[data-theme] body.page-creation:not(.page-admin) .creation-composer .home-model-fields .field-v3 label {
  display: block !important;
  margin-bottom: 3px !important;
  font-size: 11px !important;
  line-height: 1.2 !important;
  color: var(--text-muted) !important;
}

html[data-theme] body.page-creation:not(.page-admin) .creation-composer .compact-param-field select,
html[data-theme] body.page-creation:not(.page-admin) .creation-composer .compact-param-field input[type="text"],
html[data-theme] body.page-creation:not(.page-admin) .creation-composer .compact-param-field input[type="number"] {
  height: 32px !important;
  min-height: 32px !important;
  border-radius: 9px !important;
  font-size: 12px !important;
}

html[data-theme] body.page-creation:not(.page-admin) .creation-thread {
  padding-bottom: 178px !important;
}

html[data-theme] body.page-creation:not(.page-admin) .creation-composer .home-prompt-modal {
  inset: var(--prompt-modal-top, 0) auto auto var(--prompt-modal-left, 0) !important;
  width: var(--prompt-modal-width, 100vw) !important;
  height: var(--prompt-modal-height, 100vh) !important;
  z-index: 9000 !important;
  padding: 0 !important;
  display: grid !important;
  place-items: center !important;
  background: rgba(15, 23, 42, .28) !important;
}

html[data-theme] body.page-creation:not(.page-admin) .creation-composer .home-prompt-modal.hidden {
  display: none !important;
}

html[data-theme] body.page-creation:not(.page-admin) .creation-composer .home-prompt-modal-panel {
  width: min(78%, 920px) !important;
  height: min(68%, 680px) !important;
  min-width: min(92%, 520px) !important;
  min-height: min(78%, 390px) !important;
  margin: 0 !important;
}

@media (max-width: 720px) {
  html[data-theme] body.page-creation:not(.page-admin) .creation-composer.home-console {
    bottom: 26px !important;
    width: calc(100vw - 20px) !important;
    max-width: calc(100vw - 20px) !important;
  }

  html[data-theme] body.page-creation:not(.page-admin) .creation-composer .home-create-form {
    padding: 10px 12px 12px !important;
  }

  html[data-theme] body.page-creation:not(.page-admin) .creation-composer .home-create-toolbar {
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
  }

  html[data-theme] body.page-creation:not(.page-admin) .creation-composer .home-create-actions {
    width: auto !important;
    flex: 0 0 auto !important;
  }
}

/* Creation room containment: every surface stays inside the rounded room frame. */
html[data-theme] body.page-creation:not(.page-admin) .main-area {
  overflow: hidden !important;
}

html[data-theme] body.page-creation:not(.page-admin) .creation-workspace {
  box-sizing: border-box !important;
  display: grid !important;
  grid-template-columns: 236px minmax(0, 1fr) !important;
  grid-template-rows: minmax(0, 1fr) !important;
  height: calc(100vh - clamp(36px, 5vw, 68px)) !important;
  max-height: calc(100vh - clamp(36px, 5vw, 68px)) !important;
  min-height: 0 !important;
  overflow: hidden !important;
}

html[data-theme] body.page-creation:not(.page-admin) .creation-sidebar {
  position: relative !important;
  top: auto !important;
  height: auto !important;
  min-height: 0 !important;
  overflow-y: auto !important;
}

html[data-theme] body.page-creation:not(.page-admin) .creation-main {
  min-height: 0 !important;
  height: 100% !important;
  display: grid !important;
  grid-template-rows: auto minmax(0, 1fr) auto !important;
  overflow: hidden !important;
}

html[data-theme] body.page-creation:not(.page-admin) .creation-topbar {
  flex: 0 0 auto !important;
}

html[data-theme] body.page-creation:not(.page-admin) .creation-thread {
  min-height: 0 !important;
  overflow-y: auto !important;
  padding-bottom: 18px !important;
}

html[data-theme] body.page-creation:not(.page-admin) .creation-composer.home-console {
  position: relative !important;
  left: auto !important;
  right: auto !important;
  bottom: auto !important;
  z-index: 3 !important;
  width: min(calc(100% - 32px), 980px) !important;
  max-width: calc(100% - 32px) !important;
  margin: 0 auto 16px !important;
  transform: none !important;
  align-self: end !important;
}

html[data-theme] body.page-creation:not(.page-admin) .creation-result-media {
  max-width: 100% !important;
  min-width: 0 !important;
}

@media (max-width: 860px) {
  html[data-theme] body.page-creation:not(.page-admin) .creation-workspace {
    grid-template-columns: 1fr !important;
    grid-template-rows: auto minmax(0, 1fr) !important;
  }

  html[data-theme] body.page-creation:not(.page-admin) .creation-sidebar {
    max-height: 190px !important;
  }

  html[data-theme] body.page-creation:not(.page-admin) .creation-composer.home-console {
    width: calc(100% - 20px) !important;
    max-width: calc(100% - 20px) !important;
    margin-bottom: 10px !important;
  }
}

/* Creation room final sizing: compact composer and in-frame prompt modal. */
html[data-theme] body.page-creation:not(.page-admin) .creation-main {
  position: relative !important;
}

html[data-theme] body.page-creation:not(.page-admin) .creation-main > .home-prompt-modal {
  position: absolute !important;
  inset: 0 !important;
  z-index: 40 !important;
  width: auto !important;
  height: auto !important;
  display: grid !important;
  place-items: center !important;
  padding: 0 !important;
  background: rgba(15, 23, 42, .28) !important;
  backdrop-filter: blur(12px) saturate(.9) !important;
  -webkit-backdrop-filter: blur(12px) saturate(.9) !important;
}

html[data-theme] body.page-creation:not(.page-admin) .creation-main > .home-prompt-modal.hidden {
  display: none !important;
}

html[data-theme] body.page-creation:not(.page-admin) .creation-main > .home-prompt-modal .home-prompt-modal-panel {
  width: min(72%, 720px) !important;
  height: min(62%, 560px) !important;
  min-width: min(86%, 460px) !important;
  min-height: min(72%, 340px) !important;
  margin: 0 !important;
}

html[data-theme] body.page-creation:not(.page-admin) .creation-composer.home-console {
  width: min(66.666%, 720px) !important;
  max-width: min(66.666%, 720px) !important;
  margin: 0 auto 8px !important;
  border-radius: 14px !important;
}

html[data-theme] body.page-creation:not(.page-admin) .creation-composer .home-create-form {
  padding: 8px 12px 8px !important;
  gap: 3px !important;
}

html[data-theme] body.page-creation:not(.page-admin) .creation-composer .home-create-toolbar {
  gap: 5px !important;
  margin-bottom: 3px !important;
}

html[data-theme] body.page-creation:not(.page-admin) .creation-composer .home-mode-panel {
  max-height: 82px !important;
  padding-bottom: 3px !important;
}

html[data-theme] body.page-creation:not(.page-admin) .creation-composer .home-prompt-field textarea {
  height: 46px !important;
  min-height: 46px !important;
  max-height: 86px !important;
  padding: 10px 40px 9px 13px !important;
  border-radius: 14px !important;
}

html[data-theme] body.page-creation:not(.page-admin) .creation-composer .home-prompt-expand {
  top: 8px !important;
  right: 8px !important;
  width: 24px !important;
  height: 24px !important;
}

html[data-theme] body.page-creation:not(.page-admin) .creation-composer .home-file-tool,
html[data-theme] body.page-creation:not(.page-admin) .creation-composer .home-create-toolbar .btn,
html[data-theme] body.page-creation:not(.page-admin) .creation-composer .home-mode-tabs button,
html[data-theme] body.page-creation:not(.page-admin) .creation-composer .home-cost-hint,
html[data-theme] body.page-creation:not(.page-admin) .creation-composer #homeGenerateButton {
  min-height: 28px !important;
  padding-top: 3px !important;
  padding-bottom: 3px !important;
}

html[data-theme] body.page-creation:not(.page-admin) .creation-composer .compact-param-field select,
html[data-theme] body.page-creation:not(.page-admin) .creation-composer .compact-param-field input[type="text"],
html[data-theme] body.page-creation:not(.page-admin) .creation-composer .compact-param-field input[type="number"] {
  height: 28px !important;
  min-height: 28px !important;
}

@media (max-width: 860px) {
  html[data-theme] body.page-creation:not(.page-admin) .creation-composer.home-console {
    width: calc(100% - 20px) !important;
    max-width: calc(100% - 20px) !important;
  }
}

/* Final compact prompt panel tuning */
html[data-theme] body.page-app:not(.page-admin) .home-console {
  padding-bottom: 8px !important;
}

html[data-theme] body.page-app:not(.page-admin) .home-create-form {
  padding: 10px 14px 8px !important;
  gap: 6px !important;
}

html[data-theme] body.page-app:not(.page-admin) .home-prompt-field textarea {
  min-height: 72px !important;
  height: auto !important;
  max-height: 216px !important;
  padding: 12px 46px 10px 14px !important;
  border-radius: 21px !important;
  overflow-y: hidden;
}

html[data-theme] body.page-app:not(.page-admin) .home-prompt-expand {
  top: 8px !important;
  right: 8px !important;
}

html[data-theme] body.page-app:not(.page-admin) .home-create-toolbar {
  gap: 7px !important;
  margin-top: 2px !important;
  align-items: center !important;
}

html[data-theme] body.page-app:not(.page-admin) .home-mode-panel {
  padding: 2px 14px 0 !important;
}

html[data-theme] body.page-app:not(.page-admin) .home-file-preview,
html[data-theme] body.page-app:not(.page-admin) .home-reference-preview {
  margin-top: 2px !important;
}

html[data-theme] body.page-creation:not(.page-admin) .creation-composer .home-prompt-field textarea {
  height: auto !important;
  max-height: 126px !important;
  overflow-y: hidden;
}

html[data-theme] body.page-app:not(.page-admin) .home-console > .home-prompt-modal,
html[data-theme] body.page-creation:not(.page-admin) .creation-main > .home-prompt-modal {
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  z-index: 9000 !important;
  display: grid !important;
  place-items: center !important;
  padding: 18px !important;
  background: rgba(15, 23, 42, .24) !important;
  backdrop-filter: blur(16px) saturate(.95) !important;
  -webkit-backdrop-filter: blur(16px) saturate(.95) !important;
}

html[data-theme] body.page-app:not(.page-admin) .home-console > .home-prompt-modal.hidden,
html[data-theme] body.page-creation:not(.page-admin) .creation-main > .home-prompt-modal.hidden {
  display: none !important;
}

html[data-theme] body.page-app:not(.page-admin) .home-console > .home-prompt-modal .home-prompt-modal-panel,
html[data-theme] body.page-creation:not(.page-admin) .creation-main > .home-prompt-modal .home-prompt-modal-panel {
  width: min(86%, 1180px) !important;
  height: min(86%, 920px) !important;
  min-width: min(92%, 520px) !important;
  min-height: min(86%, 620px) !important;
  margin: 0 !important;
}

html[data-theme] body.page-app:not(.page-admin) .home-console > .home-prompt-modal textarea,
html[data-theme] body.page-creation:not(.page-admin) .creation-main > .home-prompt-modal textarea {
  min-height: 420px !important;
}

/* Creation room composer: inline parameter labels to reduce vertical height. */
html[data-theme] body.page-creation:not(.page-admin) .creation-composer.home-console {
  width: min(73.333%, 792px) !important;
  max-width: min(73.333%, 792px) !important;
  margin-bottom: 4px !important;
}

html[data-theme] body.page-creation:not(.page-admin) .creation-composer .home-create-form {
  padding: 6px 10px 6px !important;
  gap: 2px !important;
}

html[data-theme] body.page-creation:not(.page-admin) .creation-composer .home-mode-panel {
  max-height: 70px !important;
  padding-bottom: 2px !important;
}

html[data-theme] body.page-creation:not(.page-admin) .creation-composer .compact-param-row {
  gap: 5px !important;
}

html[data-theme] body.page-creation:not(.page-admin) .creation-composer .compact-param-field {
  position: relative !important;
}

html[data-theme] body.page-creation:not(.page-admin) .creation-composer .compact-param-field:not(.home-toggle-field) > label,
html[data-theme] body.page-creation:not(.page-admin) .creation-composer .home-model-fields .field-v3:not(.home-toggle-field) > label {
  position: absolute !important;
  left: 10px !important;
  top: 50% !important;
  z-index: 2 !important;
  max-width: 54px !important;
  margin: 0 !important;
  overflow: hidden !important;
  color: var(--text-muted) !important;
  font-size: 11px !important;
  line-height: 1 !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
  pointer-events: none !important;
  transform: translateY(-50%) !important;
}

html[data-theme] body.page-creation:not(.page-admin) .creation-composer .compact-param-field select,
html[data-theme] body.page-creation:not(.page-admin) .creation-composer .compact-param-field input[type="text"],
html[data-theme] body.page-creation:not(.page-admin) .creation-composer .compact-param-field input[type="number"] {
  height: 30px !important;
  min-height: 30px !important;
  padding-left: 70px !important;
}

html[data-theme] body.page-creation:not(.page-admin) .creation-composer .home-toggle-field {
  min-height: 30px !important;
}

html[data-theme] body.page-creation:not(.page-admin) .creation-composer .home-prompt-field textarea {
  height: 42px !important;
  min-height: 42px !important;
  max-height: 76px !important;
  padding-top: 9px !important;
  padding-bottom: 8px !important;
}

html[data-theme] body.page-creation:not(.page-admin) .creation-composer .home-create-toolbar {
  margin-bottom: 2px !important;
}

@media (max-width: 860px) {
  html[data-theme] body.page-creation:not(.page-admin) .creation-composer.home-console {
    width: calc(100% - 20px) !important;
    max-width: calc(100% - 20px) !important;
  }
}
