/* ════════════════════════════════════════════════════
   威软助手 · 3D 模型创作模块样式（即梦风格对话流）
   左侧创作面板 + 右侧对话流；成果以气泡沉淀，支持双击全屏。
   ════════════════════════════════════════════════════ */

.m3d-layout {
  display: flex;
  gap: 20px;
  align-items: stretch;
  flex-wrap: wrap;
}
.m3d-panel {
  flex: 1 1 360px;
  max-width: 440px;
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: 16px;
  padding: 22px;
  box-shadow: 0 1px 3px rgba(17, 24, 39, 0.05);
  align-self: flex-start;
}

/* 选项卡 */
.m3d-tabs { display: flex; gap: 8px; margin-bottom: 18px; }
.m3d-tab {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid var(--gray-200);
  background: var(--gray-50);
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--gray-600);
  cursor: pointer;
  transition: all var(--duration-fast, 0.15s) var(--ease-out, ease);
}
.m3d-tab:hover { border-color: var(--brand-300); color: var(--brand-600); }
.m3d-tab.active {
  background: var(--brand-500);
  border-color: var(--brand-500);
  color: #fff;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.28);
}

/* 字段 */
.m3d-field { margin-bottom: 16px; }
.m3d-field > label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 8px;
}
.m3d-textarea {
  width: 100%;
  border: 1px solid var(--gray-200);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 0.92rem;
  font-family: inherit;
  color: var(--gray-900);
  background: var(--gray-50);
  resize: vertical;
  transition: border-color var(--duration-fast, 0.15s), box-shadow var(--duration-fast, 0.15s);
}
.m3d-textarea:focus {
  outline: none;
  border-color: var(--brand-400);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}
.m3d-file { width: 100%; font-size: 0.85rem; color: var(--gray-600); }
.m3d-select {
  width: 100%;
  border: 1px solid var(--gray-200);
  border-radius: 10px;
  padding: 11px 14px;
  font-size: 0.92rem;
  font-family: inherit;
  color: var(--gray-900);
  background: var(--gray-50);
  cursor: pointer;
  transition: border-color var(--duration-fast, 0.15s), box-shadow var(--duration-fast, 0.15s);
}
.m3d-select:focus {
  outline: none;
  border-color: var(--brand-400);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}
/* 提示词 chips */
.m3d-hints { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.m3d-hint {
  font-size: 0.78rem;
  padding: 5px 11px;
  background: var(--brand-50, #eef2ff);
  color: var(--brand-600, #4f46e5);
  border: 1px solid var(--brand-100, #e0e7ff);
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.m3d-hint:hover { background: var(--brand-100, #e0e7ff); transform: translateY(-1px); }

.m3d-img-preview { margin-top: 10px; position: relative; display: inline-block; }
.m3d-img-preview img { max-width: 180px; border-radius: 10px; border: 1px solid var(--gray-200); }
.m3d-img-clear {
  position: absolute; top: -8px; right: -8px;
  width: 22px; height: 22px; line-height: 22px; text-align: center;
  background: var(--error-500, #ef4444); color: #fff; border-radius: 50%;
  cursor: pointer; font-size: 0.7rem;
}

.m3d-gen-btn { width: 100%; margin-top: 4px; }
.m3d-tip { font-size: 0.78rem; color: var(--gray-500); margin: 12px 0 0; line-height: 1.6; }

/* ══════════════ 右侧对话流 ══════════════ */
.m3d-stream-wrap {
  flex: 1 1 420px;
  min-width: 320px;
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: 16px;
  box-shadow: 0 1px 3px rgba(17, 24, 39, 0.05);
  overflow: hidden;
}
.m3d-stream-bar {
  display: flex; align-items: baseline; gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--gray-200);
  background: linear-gradient(180deg, var(--brand-50, #eef2ff), #fff);
}
.m3d-stream-title { font-size: 0.95rem; font-weight: 700; color: var(--gray-800); }
.m3d-stream-sub { font-size: 0.76rem; color: var(--gray-400); }

.m3d-stream {
  flex: 1;
  min-height: 460px;
  max-height: 72vh;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background:
    radial-gradient(140% 100% at 50% 0%, #faf9ff 0%, #f4f5fb 60%, #eef1f8 100%);
}
.m3d-stream-empty {
  margin: auto;
  text-align: center;
  color: var(--gray-400);
  font-size: 0.95rem;
  line-height: 1.9;
}
.m3d-stream-empty span { font-size: 0.8rem; color: var(--gray-400); }

/* 气泡 */
.m3d-bubble { display: flex; gap: 10px; align-items: flex-start; max-width: 100%; }
.m3d-bubble-avatar {
  flex: 0 0 auto;
  width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  background: var(--brand-100, #e0e7ff);
  border: 1px solid var(--brand-200, #c7d2fe);
}
.m3d-bubble-ai .m3d-bubble-avatar { background: #e0e7ff; }
.m3d-bubble-user { flex-direction: row-reverse; }
.m3d-bubble-user .m3d-bubble-avatar { background: var(--gray-100); border-color: var(--gray-200); }
.m3d-bubble-body {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 86%;
}
.m3d-bubble-user .m3d-bubble-body { display: flex; flex-direction: column; align-items: flex-end; }

/* 用户气泡 */
.m3d-ub-text {
  background: var(--brand-500);
  color: #fff;
  padding: 10px 14px;
  border-radius: 14px 14px 4px 14px;
  font-size: 0.9rem;
  line-height: 1.55;
  word-break: break-word;
  white-space: pre-wrap;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.18);
}
.m3d-ub-meta {
  display: flex; align-items: center; gap: 6px;
  margin-top: 6px; font-size: 0.72rem; color: var(--gray-500);
}
.m3d-ub-thumb {
  width: 38px; height: 38px; object-fit: cover; border-radius: 8px;
  border: 1px solid var(--gray-200);
}
.m3d-ub-engine {
  padding: 2px 8px; border-radius: 999px;
  background: var(--gray-100); color: var(--gray-600);
}
.m3d-ub-tag {
  padding: 2px 8px; border-radius: 999px;
  background: #fef3c7; color: #b45309; font-weight: 600;
}
.m3d-ub-time { color: var(--gray-400); }

/* AI 气泡 / 成果卡 */
.m3d-bubble-ai .m3d-bubble-body { max-width: 100%; }
.m3d-result {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: 14px 14px 14px 4px;
  padding: 12px;
  box-shadow: 0 2px 8px rgba(17, 24, 39, 0.05);
}
.m3d-mv-slot {
  width: 100%;
  border-radius: 12px;
  overflow: hidden;
  background: #15151f;
  cursor: zoom-in;
  min-height: 300px;
  display: flex; align-items: center; justify-content: center;
}
.m3d-mv { display: block; }
.m3d-mv-poster-img { width: 100%; max-height: 300px; object-fit: contain; background: #15151f; }
.m3d-mv-poster-ph {
  width: 100%; height: 300px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px;
  color: #c7c9e0; font-size: 2.4rem;
  background: linear-gradient(160deg, #1b1b2b, #23233a);
}
.m3d-mv-poster-ph span { font-size: 0.8rem; color: #9aa0c0; }

.m3d-result-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; flex-wrap: wrap; margin-top: 10px;
}
.m3d-result-title {
  font-size: 0.9rem; font-weight: 700; color: var(--gray-800);
  cursor: text; line-height: 1.3; word-break: break-all;
  padding: 2px 4px; border-radius: 6px;
}
.m3d-result-title:hover { background: var(--gray-50); color: var(--brand-600); }
.m3d-result-rename {
  font-size: 0.9rem; font-weight: 700; color: var(--gray-800);
  border: 1px solid var(--brand-400); border-radius: 6px; padding: 2px 6px;
  width: 60%; min-width: 160px; font-family: inherit;
}
.m3d-result-rename:focus { outline: none; box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15); }

.m3d-result-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.m3d-rbtn {
  padding: 6px 12px; font-size: 0.8rem; border-radius: 9px;
  border: 1px solid var(--gray-200); background: var(--gray-50);
  color: var(--gray-700); cursor: pointer; transition: all 0.15s ease;
  text-decoration: none; display: inline-flex; align-items: center; gap: 4px;
}
.m3d-rbtn:hover { border-color: var(--brand-300); color: var(--brand-600); background: var(--brand-50, #eef2ff); }
.m3d-rbtn.danger:hover { border-color: var(--error-400); color: var(--error-600); background: #fef2f2; }
.m3d-rbtn.armed {
  background: var(--error-500, #ef4444) !important;
  border-color: var(--error-500, #ef4444) !important;
  color: #fff !important;
}
.m3d-rbtn-a { color: var(--brand-600); }

/* 进度 */
.m3d-ai-progress {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: 14px 14px 14px 4px;
  padding: 26px 20px; text-align: center; color: var(--gray-700);
}
.m3d-ai-progress h3 { margin: 14px 0 6px; color: var(--gray-800); font-size: 1.05rem; }
.m3d-stage { color: var(--brand-600); font-size: 0.9rem; margin: 0 0 18px; min-height: 1.3em; font-weight: 500; }
.m3d-bar { position: relative; height: 14px; background: var(--gray-200); border-radius: 999px; overflow: hidden; max-width: 320px; margin: 0 auto; }
.m3d-bar-fill {
  height: 100%; background: linear-gradient(90deg, var(--brand-400), var(--brand-600));
  border-radius: 999px; transition: width 0.8s ease; position: relative; overflow: hidden;
}
.m3d-bar-fill::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.55), transparent);
  transform: translateX(-100%); animation: m3d-shimmer 1.3s infinite;
}
@keyframes m3d-shimmer { 100% { transform: translateX(100%); } }
.m3d-spin {
  width: 42px; height: 42px; margin: 0 auto;
  border: 5px solid var(--brand-100, #e0e7ff);
  border-top-color: var(--brand-500);
  border-radius: 50%;
  animation: m3d-spin 0.9s linear infinite;
}
@keyframes m3d-spin { to { transform: rotate(360deg); } }
.m3d-pct { font-size: 0.84rem; color: var(--gray-600); margin: 10px 0 6px; font-weight: 600; }
.m3d-prog-desc { font-size: 0.76rem; color: var(--gray-500); margin: 0 0 8px; word-break: break-all; line-height: 1.5; }
.m3d-task { font-size: 0.74rem; color: var(--gray-400); margin-top: 4px; }

.m3d-ai-fail {
  background: #fff; border: 1px solid var(--error-200, #fecaca);
  border-radius: 14px 14px 14px 4px; padding: 16px 18px; text-align: center;
}
.m3d-ai-fail p { margin: 0 0 8px; color: var(--error-600, #dc2626); font-weight: 600; }
.m3d-ai-fail small { display: block; color: var(--gray-500); font-size: 0.74rem; word-break: break-all; margin-bottom: 10px; }

/* 加载更多 */
.m3d-loadmore { display: flex; justify-content: center; padding: 4px 0 8px; }
.m3d-loadmore-btn {
  padding: 8px 16px; font-size: 0.82rem; border-radius: 999px;
  border: 1px solid var(--brand-200, #c7d2fe); background: var(--brand-50, #eef2ff);
  color: var(--brand-700, #4338ca); cursor: pointer; transition: all 0.15s ease;
}
.m3d-loadmore-btn:hover { background: var(--brand-100, #e0e7ff); }
.m3d-loadmore-btn:disabled { opacity: 0.6; cursor: default; }

/* ══════════════ 全屏预览 ══════════════ */
.m3d-fs {
  position: fixed; inset: 0; z-index: 80;
  display: none; align-items: center; justify-content: center;
  background: rgba(8, 8, 16, 0.82);
  backdrop-filter: blur(2px);
}
.m3d-fs.open { display: flex; }
.m3d-fs-box {
  position: relative;
  width: min(92vw, 1000px);
  height: min(86vh, 760px);
  background: #101019;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
}
.m3d-fs-stage { width: 100%; height: 100%; }
.m3d-fs-close {
  position: absolute; top: 12px; right: 12px; z-index: 2;
  width: 38px; height: 38px; border-radius: 50%;
  border: none; background: rgba(255, 255, 255, 0.14);
  color: #fff; font-size: 1.1rem; cursor: pointer; transition: background 0.15s ease;
}
.m3d-fs-close:hover { background: rgba(255, 255, 255, 0.28); }
.m3d-fs-hint {
  position: absolute; bottom: 12px; left: 0; right: 0; text-align: center;
  color: rgba(255, 255, 255, 0.7); font-size: 0.8rem; pointer-events: none;
}

@media (max-width: 860px) {
  .m3d-layout { flex-direction: column; }
  .m3d-panel { flex: 1 1 100%; max-width: 100%; width: 100%; }
  .m3d-stream-wrap { flex: 1 1 100%; width: 100%; }
  .m3d-stream { max-height: none; min-height: 360px; }
}

/* 二次创作入口按钮（渐变强调） */
.m3d-rbtn-studio {
  background: linear-gradient(135deg, #6366f1, #a855f7);
  color: #fff !important;
  border: none;
  font-weight: 700;
}
.m3d-rbtn-studio:hover { filter: brightness(1.12); background: linear-gradient(135deg, #6366f1, #a855f7); color: #fff !important; }
